(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function t(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(r){if(r.ep)return;r.ep=!0;const a=t(r);fetch(r.href,a)}})();function p1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var eL={exports:{}},m1={};/**
 * @license React
 * react-jsx-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Sz=Symbol.for("react.transitional.element"),Tz=Symbol.for("react.fragment");function tL(n,e,t){var i=null;if(t!==void 0&&(i=""+t),e.key!==void 0&&(i=""+e.key),"key"in e){t={};for(var r in e)r!=="key"&&(t[r]=e[r])}else t=e;return e=t.ref,{$$typeof:Sz,type:n,key:i,ref:e!==void 0?e:null,props:t}}m1.Fragment=Tz;m1.jsx=tL;m1.jsxs=tL;eL.exports=m1;var Mt=eL.exports,nL={exports:{}},Xt={};/**
 * @license React
 * react.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var vM=Symbol.for("react.transitional.element"),Ez=Symbol.for("react.portal"),Mz=Symbol.for("react.fragment"),bz=Symbol.for("react.strict_mode"),Az=Symbol.for("react.profiler"),wz=Symbol.for("react.consumer"),Rz=Symbol.for("react.context"),Cz=Symbol.for("react.forward_ref"),Dz=Symbol.for("react.suspense"),Nz=Symbol.for("react.memo"),iL=Symbol.for("react.lazy"),Oz=Symbol.for("react.activity"),XR=Symbol.iterator;function Lz(n){return n===null||typeof n!="object"?null:(n=XR&&n[XR]||n["@@iterator"],typeof n=="function"?n:null)}var rL={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},aL=Object.assign,sL={};function Fd(n,e,t){this.props=n,this.context=e,this.refs=sL,this.updater=t||rL}Fd.prototype.isReactComponent={};Fd.prototype.setState=function(n,e){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,e,"setState")};Fd.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function oL(){}oL.prototype=Fd.prototype;function _M(n,e,t){this.props=n,this.context=e,this.refs=sL,this.updater=t||rL}var xM=_M.prototype=new oL;xM.constructor=_M;aL(xM,Fd.prototype);xM.isPureReactComponent=!0;var YR=Array.isArray;function p3(){}var ti={H:null,A:null,T:null,S:null},lL=Object.prototype.hasOwnProperty;function yM(n,e,t){var i=t.ref;return{$$typeof:vM,type:n,key:e,ref:i!==void 0?i:null,props:t}}function Iz(n,e){return yM(n.type,e,n.props)}function SM(n){return typeof n=="object"&&n!==null&&n.$$typeof===vM}function Uz(n){var e={"=":"=0",":":"=2"};return"$"+n.replace(/[=:]/g,function(t){return e[t]})}var qR=/\/+/g;function KS(n,e){return typeof n=="object"&&n!==null&&n.key!=null?Uz(""+n.key):e.toString(36)}function Pz(n){switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:switch(typeof n.status=="string"?n.then(p3,p3):(n.status="pending",n.then(function(e){n.status==="pending"&&(n.status="fulfilled",n.value=e)},function(e){n.status==="pending"&&(n.status="rejected",n.reason=e)})),n.status){case"fulfilled":return n.value;case"rejected":throw n.reason}}throw n}function Cf(n,e,t,i,r){var a=typeof n;(a==="undefined"||a==="boolean")&&(n=null);var s=!1;if(n===null)s=!0;else switch(a){case"bigint":case"string":case"number":s=!0;break;case"object":switch(n.$$typeof){case vM:case Ez:s=!0;break;case iL:return s=n._init,Cf(s(n._payload),e,t,i,r)}}if(s)return r=r(n),s=i===""?"."+KS(n,0):i,YR(r)?(t="",s!=null&&(t=s.replace(qR,"$&/")+"/"),Cf(r,e,t,"",function(h){return h})):r!=null&&(SM(r)&&(r=Iz(r,t+(r.key==null||n&&n.key===r.key?"":(""+r.key).replace(qR,"$&/")+"/")+s)),e.push(r)),1;s=0;var o=i===""?".":i+":";if(YR(n))for(var l=0;l<n.length;l++)i=n[l],a=o+KS(i,l),s+=Cf(i,e,t,a,r);else if(l=Lz(n),typeof l=="function")for(n=l.call(n),l=0;!(i=n.next()).done;)i=i.value,a=o+KS(i,l++),s+=Cf(i,e,t,a,r);else if(a==="object"){if(typeof n.then=="function")return Cf(Pz(n),e,t,i,r);throw e=String(n),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.")}return s}function Ug(n,e,t){if(n==null)return n;var i=[],r=0;return Cf(n,i,"","",function(a){return e.call(t,a,r++)}),i}function zz(n){if(n._status===-1){var e=n._result;e=e(),e.then(function(t){(n._status===0||n._status===-1)&&(n._status=1,n._result=t)},function(t){(n._status===0||n._status===-1)&&(n._status=2,n._result=t)}),n._status===-1&&(n._status=0,n._result=e)}if(n._status===1)return n._result.default;throw n._result}var jR=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Bz={map:Ug,forEach:function(n,e,t){Ug(n,function(){e.apply(this,arguments)},t)},count:function(n){var e=0;return Ug(n,function(){e++}),e},toArray:function(n){return Ug(n,function(e){return e})||[]},only:function(n){if(!SM(n))throw Error("React.Children.only expected to receive a single React element child.");return n}};Xt.Activity=Oz;Xt.Children=Bz;Xt.Component=Fd;Xt.Fragment=Mz;Xt.Profiler=Az;Xt.PureComponent=_M;Xt.StrictMode=bz;Xt.Suspense=Dz;Xt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ti;Xt.__COMPILER_RUNTIME={__proto__:null,c:function(n){return ti.H.useMemoCache(n)}};Xt.cache=function(n){return function(){return n.apply(null,arguments)}};Xt.cacheSignal=function(){return null};Xt.cloneElement=function(n,e,t){if(n==null)throw Error("The argument must be a React element, but you passed "+n+".");var i=aL({},n.props),r=n.key;if(e!=null)for(a in e.key!==void 0&&(r=""+e.key),e)!lL.call(e,a)||a==="key"||a==="__self"||a==="__source"||a==="ref"&&e.ref===void 0||(i[a]=e[a]);var a=arguments.length-2;if(a===1)i.children=t;else if(1<a){for(var s=Array(a),o=0;o<a;o++)s[o]=arguments[o+2];i.children=s}return yM(n.type,r,i)};Xt.createContext=function(n){return n={$$typeof:Rz,_currentValue:n,_currentValue2:n,_threadCount:0,Provider:null,Consumer:null},n.Provider=n,n.Consumer={$$typeof:wz,_context:n},n};Xt.createElement=function(n,e,t){var i,r={},a=null;if(e!=null)for(i in e.key!==void 0&&(a=""+e.key),e)lL.call(e,i)&&i!=="key"&&i!=="__self"&&i!=="__source"&&(r[i]=e[i]);var s=arguments.length-2;if(s===1)r.children=t;else if(1<s){for(var o=Array(s),l=0;l<s;l++)o[l]=arguments[l+2];r.children=o}if(n&&n.defaultProps)for(i in s=n.defaultProps,s)r[i]===void 0&&(r[i]=s[i]);return yM(n,a,r)};Xt.createRef=function(){return{current:null}};Xt.forwardRef=function(n){return{$$typeof:Cz,render:n}};Xt.isValidElement=SM;Xt.lazy=function(n){return{$$typeof:iL,_payload:{_status:-1,_result:n},_init:zz}};Xt.memo=function(n,e){return{$$typeof:Nz,type:n,compare:e===void 0?null:e}};Xt.startTransition=function(n){var e=ti.T,t={};ti.T=t;try{var i=n(),r=ti.S;r!==null&&r(t,i),typeof i=="object"&&i!==null&&typeof i.then=="function"&&i.then(p3,jR)}catch(a){jR(a)}finally{e!==null&&t.types!==null&&(e.types=t.types),ti.T=e}};Xt.unstable_useCacheRefresh=function(){return ti.H.useCacheRefresh()};Xt.use=function(n){return ti.H.use(n)};Xt.useActionState=function(n,e,t){return ti.H.useActionState(n,e,t)};Xt.useCallback=function(n,e){return ti.H.useCallback(n,e)};Xt.useContext=function(n){return ti.H.useContext(n)};Xt.useDebugValue=function(){};Xt.useDeferredValue=function(n,e){return ti.H.useDeferredValue(n,e)};Xt.useEffect=function(n,e){return ti.H.useEffect(n,e)};Xt.useEffectEvent=function(n){return ti.H.useEffectEvent(n)};Xt.useId=function(){return ti.H.useId()};Xt.useImperativeHandle=function(n,e,t){return ti.H.useImperativeHandle(n,e,t)};Xt.useInsertionEffect=function(n,e){return ti.H.useInsertionEffect(n,e)};Xt.useLayoutEffect=function(n,e){return ti.H.useLayoutEffect(n,e)};Xt.useMemo=function(n,e){return ti.H.useMemo(n,e)};Xt.useOptimistic=function(n,e){return ti.H.useOptimistic(n,e)};Xt.useReducer=function(n,e,t){return ti.H.useReducer(n,e,t)};Xt.useRef=function(n){return ti.H.useRef(n)};Xt.useState=function(n){return ti.H.useState(n)};Xt.useSyncExternalStore=function(n,e,t){return ti.H.useSyncExternalStore(n,e,t)};Xt.useTransition=function(){return ti.H.useTransition()};Xt.version="19.2.0";nL.exports=Xt;var Me=nL.exports;const TM=p1(Me);var cL={exports:{}},g1={},uL={exports:{}},hL={};/**
 * @license React
 * scheduler.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */(function(n){function e(W,te){var K=W.length;W.push(te);e:for(;0<K;){var oe=K-1>>>1,ie=W[oe];if(0<r(ie,te))W[oe]=te,W[K]=ie,K=oe;else break e}}function t(W){return W.length===0?null:W[0]}function i(W){if(W.length===0)return null;var te=W[0],K=W.pop();if(K!==te){W[0]=K;e:for(var oe=0,ie=W.length,Ce=ie>>>1;oe<Ce;){var Xe=2*(oe+1)-1,nt=W[Xe],tt=Xe+1,gt=W[tt];if(0>r(nt,K))tt<ie&&0>r(gt,nt)?(W[oe]=gt,W[tt]=K,oe=tt):(W[oe]=nt,W[Xe]=K,oe=Xe);else if(tt<ie&&0>r(gt,K))W[oe]=gt,W[tt]=K,oe=tt;else break e}}return te}function r(W,te){var K=W.sortIndex-te.sortIndex;return K!==0?K:W.id-te.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;n.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();n.unstable_now=function(){return s.now()-o}}var l=[],h=[],f=1,d=null,p=3,g=!1,_=!1,T=!1,y=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function b(W){for(var te=t(h);te!==null;){if(te.callback===null)i(h);else if(te.startTime<=W)i(h),te.sortIndex=te.expirationTime,e(l,te);else break;te=t(h)}}function N(W){if(T=!1,b(W),!_)if(t(l)!==null)_=!0,R||(R=!0,j());else{var te=t(h);te!==null&&ae(N,te.startTime-W)}}var R=!1,I=-1,U=5,O=-1;function w(){return y?!0:!(n.unstable_now()-O<U)}function B(){if(y=!1,R){var W=n.unstable_now();O=W;var te=!0;try{e:{_=!1,T&&(T=!1,S(I),I=-1),g=!0;var K=p;try{t:{for(b(W),d=t(l);d!==null&&!(d.expirationTime>W&&w());){var oe=d.callback;if(typeof oe=="function"){d.callback=null,p=d.priorityLevel;var ie=oe(d.expirationTime<=W);if(W=n.unstable_now(),typeof ie=="function"){d.callback=ie,b(W),te=!0;break t}d===t(l)&&i(l),b(W)}else i(l);d=t(l)}if(d!==null)te=!0;else{var Ce=t(h);Ce!==null&&ae(N,Ce.startTime-W),te=!1}}break e}finally{d=null,p=K,g=!1}te=void 0}}finally{te?j():R=!1}}}var j;if(typeof E=="function")j=function(){E(B)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,se=ee.port2;ee.port1.onmessage=B,j=function(){se.postMessage(null)}}else j=function(){v(B,0)};function ae(W,te){I=v(function(){W(n.unstable_now())},te)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(W){W.callback=null},n.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<W?Math.floor(1e3/W):5},n.unstable_getCurrentPriorityLevel=function(){return p},n.unstable_next=function(W){switch(p){case 1:case 2:case 3:var te=3;break;default:te=p}var K=p;p=te;try{return W()}finally{p=K}},n.unstable_requestPaint=function(){y=!0},n.unstable_runWithPriority=function(W,te){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var K=p;p=W;try{return te()}finally{p=K}},n.unstable_scheduleCallback=function(W,te,K){var oe=n.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?oe+K:oe):K=oe,W){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=K+ie,W={id:f++,callback:te,priorityLevel:W,startTime:K,expirationTime:ie,sortIndex:-1},K>oe?(W.sortIndex=K,e(h,W),t(l)===null&&W===t(h)&&(T?(S(I),I=-1):T=!0,ae(N,K-oe))):(W.sortIndex=ie,e(l,W),_||g||(_=!0,R||(R=!0,j()))),W},n.unstable_shouldYield=w,n.unstable_wrapCallback=function(W){var te=p;return function(){var K=p;p=te;try{return W.apply(this,arguments)}finally{p=K}}}})(hL);uL.exports=hL;var Hz=uL.exports,fL={exports:{}},zr={};/**
 * @license React
 * react-dom.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Fz=Me;function dL(n){var e="https://react.dev/errors/"+n;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var t=2;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t])}return"Minified React error #"+n+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function Cl(){}var Ir={d:{f:Cl,r:function(){throw Error(dL(522))},D:Cl,C:Cl,L:Cl,m:Cl,X:Cl,S:Cl,M:Cl},p:0,findDOMNode:null},Gz=Symbol.for("react.portal");function Vz(n,e,t){var i=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Gz,key:i==null?null:""+i,children:n,containerInfo:e,implementation:t}}var Tm=Fz.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function v1(n,e){if(n==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}zr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Ir;zr.createPortal=function(n,e){var t=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error(dL(299));return Vz(n,e,null,t)};zr.flushSync=function(n){var e=Tm.T,t=Ir.p;try{if(Tm.T=null,Ir.p=2,n)return n()}finally{Tm.T=e,Ir.p=t,Ir.d.f()}};zr.preconnect=function(n,e){typeof n=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,Ir.d.C(n,e))};zr.prefetchDNS=function(n){typeof n=="string"&&Ir.d.D(n)};zr.preinit=function(n,e){if(typeof n=="string"&&e&&typeof e.as=="string"){var t=e.as,i=v1(t,e.crossOrigin),r=typeof e.integrity=="string"?e.integrity:void 0,a=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;t==="style"?Ir.d.S(n,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:i,integrity:r,fetchPriority:a}):t==="script"&&Ir.d.X(n,{crossOrigin:i,integrity:r,fetchPriority:a,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};zr.preinitModule=function(n,e){if(typeof n=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var t=v1(e.as,e.crossOrigin);Ir.d.M(n,{crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})}}else e==null&&Ir.d.M(n)};zr.preload=function(n,e){if(typeof n=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var t=e.as,i=v1(t,e.crossOrigin);Ir.d.L(n,t,{crossOrigin:i,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}};zr.preloadModule=function(n,e){if(typeof n=="string")if(e){var t=v1(e.as,e.crossOrigin);Ir.d.m(n,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:t,integrity:typeof e.integrity=="string"?e.integrity:void 0})}else Ir.d.m(n)};zr.requestFormReset=function(n){Ir.d.r(n)};zr.unstable_batchedUpdates=function(n,e){return n(e)};zr.useFormState=function(n,e,t){return Tm.H.useFormState(n,e,t)};zr.useFormStatus=function(){return Tm.H.useHostTransitionStatus()};zr.version="19.2.0";function pL(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(pL)}catch(n){console.error(n)}}pL(),fL.exports=zr;var kz=fL.exports;/**
 * @license React
 * react-dom-client.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Gi=Hz,mL=Me,Wz=kz;function Ue(n){var e="https://react.dev/errors/"+n;if(1<arguments.length){e+="?args[]="+encodeURIComponent(arguments[1]);for(var t=2;t<arguments.length;t++)e+="&args[]="+encodeURIComponent(arguments[t])}return"Minified React error #"+n+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function gL(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function A0(n){var e=n,t=n;if(n.alternate)for(;e.return;)e=e.return;else{n=e;do e=n,e.flags&4098&&(t=e.return),n=e.return;while(n)}return e.tag===3?t:null}function vL(n){if(n.tag===13){var e=n.memoizedState;if(e===null&&(n=n.alternate,n!==null&&(e=n.memoizedState)),e!==null)return e.dehydrated}return null}function _L(n){if(n.tag===31){var e=n.memoizedState;if(e===null&&(n=n.alternate,n!==null&&(e=n.memoizedState)),e!==null)return e.dehydrated}return null}function ZR(n){if(A0(n)!==n)throw Error(Ue(188))}function Xz(n){var e=n.alternate;if(!e){if(e=A0(n),e===null)throw Error(Ue(188));return e!==n?null:n}for(var t=n,i=e;;){var r=t.return;if(r===null)break;var a=r.alternate;if(a===null){if(i=r.return,i!==null){t=i;continue}break}if(r.child===a.child){for(a=r.child;a;){if(a===t)return ZR(r),n;if(a===i)return ZR(r),e;a=a.sibling}throw Error(Ue(188))}if(t.return!==i.return)t=r,i=a;else{for(var s=!1,o=r.child;o;){if(o===t){s=!0,t=r,i=a;break}if(o===i){s=!0,i=r,t=a;break}o=o.sibling}if(!s){for(o=a.child;o;){if(o===t){s=!0,t=a,i=r;break}if(o===i){s=!0,i=a,t=r;break}o=o.sibling}if(!s)throw Error(Ue(189))}}if(t.alternate!==i)throw Error(Ue(190))}if(t.tag!==3)throw Error(Ue(188));return t.stateNode.current===t?n:e}function xL(n){var e=n.tag;if(e===5||e===26||e===27||e===6)return n;for(n=n.child;n!==null;){if(e=xL(n),e!==null)return e;n=n.sibling}return null}var ni=Object.assign,Yz=Symbol.for("react.element"),Pg=Symbol.for("react.transitional.element"),cm=Symbol.for("react.portal"),If=Symbol.for("react.fragment"),yL=Symbol.for("react.strict_mode"),m3=Symbol.for("react.profiler"),SL=Symbol.for("react.consumer"),jo=Symbol.for("react.context"),EM=Symbol.for("react.forward_ref"),g3=Symbol.for("react.suspense"),v3=Symbol.for("react.suspense_list"),MM=Symbol.for("react.memo"),Vl=Symbol.for("react.lazy"),_3=Symbol.for("react.activity"),qz=Symbol.for("react.memo_cache_sentinel"),KR=Symbol.iterator;function Dp(n){return n===null||typeof n!="object"?null:(n=KR&&n[KR]||n["@@iterator"],typeof n=="function"?n:null)}var jz=Symbol.for("react.client.reference");function x3(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===jz?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case If:return"Fragment";case m3:return"Profiler";case yL:return"StrictMode";case g3:return"Suspense";case v3:return"SuspenseList";case _3:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case cm:return"Portal";case jo:return n.displayName||"Context";case SL:return(n._context.displayName||"Context")+".Consumer";case EM:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case MM:return e=n.displayName||null,e!==null?e:x3(n.type)||"Memo";case Vl:e=n._payload,n=n._init;try{return x3(n(e))}catch{}}return null}var um=Array.isArray,Ut=mL.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Sn=Wz.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ou={pending:!1,data:null,method:null,action:null},y3=[],Uf=-1;function co(n){return{current:n}}function er(n){0>Uf||(n.current=y3[Uf],y3[Uf]=null,Uf--)}function qn(n,e){Uf++,y3[Uf]=n.current,n.current=e}var ro=co(null),Km=co(null),ic=co(null),O_=co(null);function L_(n,e){switch(qn(ic,e),qn(Km,n),qn(ro,null),e.nodeType){case 9:case 11:n=(n=e.documentElement)&&(n=n.namespaceURI)?n4(n):0;break;default:if(n=e.tagName,e=e.namespaceURI)e=n4(e),n=GI(e,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}er(ro),qn(ro,n)}function hd(){er(ro),er(Km),er(ic)}function S3(n){n.memoizedState!==null&&qn(O_,n);var e=ro.current,t=GI(e,n.type);e!==t&&(qn(Km,n),qn(ro,t))}function I_(n){Km.current===n&&(er(ro),er(Km)),O_.current===n&&(er(O_),o0._currentValue=Ou)}var QS,QR;function mu(n){if(QS===void 0)try{throw Error()}catch(t){var e=t.stack.trim().match(/\n( *(at )?)/);QS=e&&e[1]||"",QR=-1<t.stack.indexOf(`
    at`)?" (<anonymous>)":-1<t.stack.indexOf("@")?"@unknown:0:0":""}return`
`+QS+n+QR}var JS=!1;function $S(n,e){if(!n||JS)return"";JS=!0;var t=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(e){var d=function(){throw Error()};if(Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(g){var p=g}Reflect.construct(n,[],d)}else{try{d.call()}catch(g){p=g}n.call(d.prototype)}}else{try{throw Error()}catch(g){p=g}(d=n())&&typeof d.catch=="function"&&d.catch(function(){})}}catch(g){if(g&&p&&typeof g.stack=="string")return[g.stack,p.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var a=i.DetermineComponentFrameRoot(),s=a[0],o=a[1];if(s&&o){var l=s.split(`
`),h=o.split(`
`);for(r=i=0;i<l.length&&!l[i].includes("DetermineComponentFrameRoot");)i++;for(;r<h.length&&!h[r].includes("DetermineComponentFrameRoot");)r++;if(i===l.length||r===h.length)for(i=l.length-1,r=h.length-1;1<=i&&0<=r&&l[i]!==h[r];)r--;for(;1<=i&&0<=r;i--,r--)if(l[i]!==h[r]){if(i!==1||r!==1)do if(i--,r--,0>r||l[i]!==h[r]){var f=`
`+l[i].replace(" at new "," at ");return n.displayName&&f.includes("<anonymous>")&&(f=f.replace("<anonymous>",n.displayName)),f}while(1<=i&&0<=r);break}}}finally{JS=!1,Error.prepareStackTrace=t}return(t=n?n.displayName||n.name:"")?mu(t):""}function Zz(n,e){switch(n.tag){case 26:case 27:case 5:return mu(n.type);case 16:return mu("Lazy");case 13:return n.child!==e&&e!==null?mu("Suspense Fallback"):mu("Suspense");case 19:return mu("SuspenseList");case 0:case 15:return $S(n.type,!1);case 11:return $S(n.type.render,!1);case 1:return $S(n.type,!0);case 31:return mu("Activity");default:return""}}function JR(n){try{var e="",t=null;do e+=Zz(n,t),t=n,n=n.return;while(n);return e}catch(i){return`
Error generating stack: `+i.message+`
`+i.stack}}var T3=Object.prototype.hasOwnProperty,bM=Gi.unstable_scheduleCallback,eT=Gi.unstable_cancelCallback,Kz=Gi.unstable_shouldYield,Qz=Gi.unstable_requestPaint,Ra=Gi.unstable_now,Jz=Gi.unstable_getCurrentPriorityLevel,TL=Gi.unstable_ImmediatePriority,EL=Gi.unstable_UserBlockingPriority,U_=Gi.unstable_NormalPriority,$z=Gi.unstable_LowPriority,ML=Gi.unstable_IdlePriority,eB=Gi.log,tB=Gi.unstable_setDisableYieldValue,w0=null,Ca=null;function Zl(n){if(typeof eB=="function"&&tB(n),Ca&&typeof Ca.setStrictMode=="function")try{Ca.setStrictMode(w0,n)}catch{}}var Da=Math.clz32?Math.clz32:rB,nB=Math.log,iB=Math.LN2;function rB(n){return n>>>=0,n===0?32:31-(nB(n)/iB|0)|0}var zg=256,Bg=262144,Hg=4194304;function gu(n){var e=n&42;if(e!==0)return e;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function _1(n,e,t){var i=n.pendingLanes;if(i===0)return 0;var r=0,a=n.suspendedLanes,s=n.pingedLanes;n=n.warmLanes;var o=i&134217727;return o!==0?(i=o&~a,i!==0?r=gu(i):(s&=o,s!==0?r=gu(s):t||(t=o&~n,t!==0&&(r=gu(t))))):(o=i&~a,o!==0?r=gu(o):s!==0?r=gu(s):t||(t=i&~n,t!==0&&(r=gu(t)))),r===0?0:e!==0&&e!==r&&!(e&a)&&(a=r&-r,t=e&-e,a>=t||a===32&&(t&4194048)!==0)?e:r}function R0(n,e){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&e)===0}function aB(n,e){switch(n){case 1:case 2:case 4:case 8:case 64:return e+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function bL(){var n=Hg;return Hg<<=1,!(Hg&62914560)&&(Hg=4194304),n}function tT(n){for(var e=[],t=0;31>t;t++)e.push(n);return e}function C0(n,e){n.pendingLanes|=e,e!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function sB(n,e,t,i,r,a){var s=n.pendingLanes;n.pendingLanes=t,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=t,n.entangledLanes&=t,n.errorRecoveryDisabledLanes&=t,n.shellSuspendCounter=0;var o=n.entanglements,l=n.expirationTimes,h=n.hiddenUpdates;for(t=s&~t;0<t;){var f=31-Da(t),d=1<<f;o[f]=0,l[f]=-1;var p=h[f];if(p!==null)for(h[f]=null,f=0;f<p.length;f++){var g=p[f];g!==null&&(g.lane&=-536870913)}t&=~d}i!==0&&AL(n,i,0),a!==0&&r===0&&n.tag!==0&&(n.suspendedLanes|=a&~(s&~e))}function AL(n,e,t){n.pendingLanes|=e,n.suspendedLanes&=~e;var i=31-Da(e);n.entangledLanes|=e,n.entanglements[i]=n.entanglements[i]|1073741824|t&261930}function wL(n,e){var t=n.entangledLanes|=e;for(n=n.entanglements;t;){var i=31-Da(t),r=1<<i;r&e|n[i]&e&&(n[i]|=e),t&=~r}}function RL(n,e){var t=e&-e;return t=t&42?1:AM(t),t&(n.suspendedLanes|e)?0:t}function AM(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=16;break;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:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function wM(n){return n&=-n,2<n?8<n?n&134217727?32:268435456:8:2}function CL(){var n=Sn.p;return n!==0?n:(n=window.event,n===void 0?32:JI(n.type))}function $R(n,e){var t=Sn.p;try{return Sn.p=n,e()}finally{Sn.p=t}}var Tc=Math.random().toString(36).slice(2),or="__reactFiber$"+Tc,ta="__reactProps$"+Tc,Gd="__reactContainer$"+Tc,E3="__reactEvents$"+Tc,oB="__reactListeners$"+Tc,lB="__reactHandles$"+Tc,eC="__reactResources$"+Tc,D0="__reactMarker$"+Tc;function RM(n){delete n[or],delete n[ta],delete n[E3],delete n[oB],delete n[lB]}function Pf(n){var e=n[or];if(e)return e;for(var t=n.parentNode;t;){if(e=t[Gd]||t[or]){if(t=e.alternate,e.child!==null||t!==null&&t.child!==null)for(n=o4(n);n!==null;){if(t=n[or])return t;n=o4(n)}return e}n=t,t=n.parentNode}return null}function Vd(n){if(n=n[or]||n[Gd]){var e=n.tag;if(e===5||e===6||e===13||e===31||e===26||e===27||e===3)return n}return null}function hm(n){var e=n.tag;if(e===5||e===26||e===27||e===6)return n.stateNode;throw Error(Ue(33))}function $f(n){var e=n[eC];return e||(e=n[eC]={hoistableStyles:new Map,hoistableScripts:new Map}),e}function $i(n){n[D0]=!0}var DL=new Set,NL={};function oh(n,e){fd(n,e),fd(n+"Capture",e)}function fd(n,e){for(NL[n]=e,n=0;n<e.length;n++)DL.add(e[n])}var cB=RegExp("^[: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]*$"),tC={},nC={};function uB(n){return T3.call(nC,n)?!0:T3.call(tC,n)?!1:cB.test(n)?nC[n]=!0:(tC[n]=!0,!1)}function s_(n,e,t){if(uB(e))if(t===null)n.removeAttribute(e);else{switch(typeof t){case"undefined":case"function":case"symbol":n.removeAttribute(e);return;case"boolean":var i=e.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){n.removeAttribute(e);return}}n.setAttribute(e,""+t)}}function Fg(n,e,t){if(t===null)n.removeAttribute(e);else{switch(typeof t){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(e);return}n.setAttribute(e,""+t)}}function bo(n,e,t,i){if(i===null)n.removeAttribute(t);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(t);return}n.setAttributeNS(e,t,""+i)}}function Ka(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function OL(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function hB(n,e,t){var i=Object.getOwnPropertyDescriptor(n.constructor.prototype,e);if(!n.hasOwnProperty(e)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var r=i.get,a=i.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return r.call(this)},set:function(s){t=""+s,a.call(this,s)}}),Object.defineProperty(n,e,{enumerable:i.enumerable}),{getValue:function(){return t},setValue:function(s){t=""+s},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function M3(n){if(!n._valueTracker){var e=OL(n)?"checked":"value";n._valueTracker=hB(n,e,""+n[e])}}function LL(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),i="";return n&&(i=OL(n)?n.checked?"true":"false":n.value),n=i,n!==t?(e.setValue(n),!0):!1}function P_(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var fB=/[\n"\\]/g;function $a(n){return n.replace(fB,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function b3(n,e,t,i,r,a,s,o){n.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?n.type=s:n.removeAttribute("type"),e!=null?s==="number"?(e===0&&n.value===""||n.value!=e)&&(n.value=""+Ka(e)):n.value!==""+Ka(e)&&(n.value=""+Ka(e)):s!=="submit"&&s!=="reset"||n.removeAttribute("value"),e!=null?A3(n,s,Ka(e)):t!=null?A3(n,s,Ka(t)):i!=null&&n.removeAttribute("value"),r==null&&a!=null&&(n.defaultChecked=!!a),r!=null&&(n.checked=r&&typeof r!="function"&&typeof r!="symbol"),o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"?n.name=""+Ka(o):n.removeAttribute("name")}function IL(n,e,t,i,r,a,s,o){if(a!=null&&typeof a!="function"&&typeof a!="symbol"&&typeof a!="boolean"&&(n.type=a),e!=null||t!=null){if(!(a!=="submit"&&a!=="reset"||e!=null)){M3(n);return}t=t!=null?""+Ka(t):"",e=e!=null?""+Ka(e):t,o||e===n.value||(n.value=e),n.defaultValue=e}i=i??r,i=typeof i!="function"&&typeof i!="symbol"&&!!i,n.checked=o?n.checked:!!i,n.defaultChecked=!!i,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(n.name=s),M3(n)}function A3(n,e,t){e==="number"&&P_(n.ownerDocument)===n||n.defaultValue===""+t||(n.defaultValue=""+t)}function ed(n,e,t,i){if(n=n.options,e){e={};for(var r=0;r<t.length;r++)e["$"+t[r]]=!0;for(t=0;t<n.length;t++)r=e.hasOwnProperty("$"+n[t].value),n[t].selected!==r&&(n[t].selected=r),r&&i&&(n[t].defaultSelected=!0)}else{for(t=""+Ka(t),e=null,r=0;r<n.length;r++){if(n[r].value===t){n[r].selected=!0,i&&(n[r].defaultSelected=!0);return}e!==null||n[r].disabled||(e=n[r])}e!==null&&(e.selected=!0)}}function UL(n,e,t){if(e!=null&&(e=""+Ka(e),e!==n.value&&(n.value=e),t==null)){n.defaultValue!==e&&(n.defaultValue=e);return}n.defaultValue=t!=null?""+Ka(t):""}function PL(n,e,t,i){if(e==null){if(i!=null){if(t!=null)throw Error(Ue(92));if(um(i)){if(1<i.length)throw Error(Ue(93));i=i[0]}t=i}t==null&&(t=""),e=t}t=Ka(e),n.defaultValue=t,i=n.textContent,i===t&&i!==""&&i!==null&&(n.value=i),M3(n)}function dd(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var dB=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function iC(n,e,t){var i=e.indexOf("--")===0;t==null||typeof t=="boolean"||t===""?i?n.setProperty(e,""):e==="float"?n.cssFloat="":n[e]="":i?n.setProperty(e,t):typeof t!="number"||t===0||dB.has(e)?e==="float"?n.cssFloat=t:n[e]=(""+t).trim():n[e]=t+"px"}function zL(n,e,t){if(e!=null&&typeof e!="object")throw Error(Ue(62));if(n=n.style,t!=null){for(var i in t)!t.hasOwnProperty(i)||e!=null&&e.hasOwnProperty(i)||(i.indexOf("--")===0?n.setProperty(i,""):i==="float"?n.cssFloat="":n[i]="");for(var r in e)i=e[r],e.hasOwnProperty(r)&&t[r]!==i&&iC(n,r,i)}else for(var a in e)e.hasOwnProperty(a)&&iC(n,a,e[a])}function CM(n){if(n.indexOf("-")===-1)return!1;switch(n){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 pB=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),mB=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function o_(n){return mB.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function Zo(){}var w3=null;function DM(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var zf=null,td=null;function rC(n){var e=Vd(n);if(e&&(n=e.stateNode)){var t=n[ta]||null;e:switch(n=e.stateNode,e.type){case"input":if(b3(n,t.value,t.defaultValue,t.defaultValue,t.checked,t.defaultChecked,t.type,t.name),e=t.name,t.type==="radio"&&e!=null){for(t=n;t.parentNode;)t=t.parentNode;for(t=t.querySelectorAll('input[name="'+$a(""+e)+'"][type="radio"]'),e=0;e<t.length;e++){var i=t[e];if(i!==n&&i.form===n.form){var r=i[ta]||null;if(!r)throw Error(Ue(90));b3(i,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name)}}for(e=0;e<t.length;e++)i=t[e],i.form===n.form&&LL(i)}break e;case"textarea":UL(n,t.value,t.defaultValue);break e;case"select":e=t.value,e!=null&&ed(n,!!t.multiple,e,!1)}}}var nT=!1;function BL(n,e,t){if(nT)return n(e,t);nT=!0;try{var i=n(e);return i}finally{if(nT=!1,(zf!==null||td!==null)&&(D1(),zf&&(e=zf,n=td,td=zf=null,rC(e),n)))for(e=0;e<n.length;e++)rC(n[e])}}function Qm(n,e){var t=n.stateNode;if(t===null)return null;var i=t[ta]||null;if(i===null)return null;t=i[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(n=n.type,i=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!i;break e;default:n=!1}if(n)return null;if(t&&typeof t!="function")throw Error(Ue(231,e,typeof t));return t}var nl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),R3=!1;if(nl)try{var Np={};Object.defineProperty(Np,"passive",{get:function(){R3=!0}}),window.addEventListener("test",Np,Np),window.removeEventListener("test",Np,Np)}catch{R3=!1}var Kl=null,NM=null,l_=null;function HL(){if(l_)return l_;var n,e=NM,t=e.length,i,r="value"in Kl?Kl.value:Kl.textContent,a=r.length;for(n=0;n<t&&e[n]===r[n];n++);var s=t-n;for(i=1;i<=s&&e[t-i]===r[a-i];i++);return l_=r.slice(n,1<i?1-i:void 0)}function c_(n){var e=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&e===13&&(n=13)):n=e,n===10&&(n=13),32<=n||n===13?n:0}function Gg(){return!0}function aC(){return!1}function ia(n){function e(t,i,r,a,s){this._reactName=t,this._targetInst=r,this.type=i,this.nativeEvent=a,this.target=s,this.currentTarget=null;for(var o in n)n.hasOwnProperty(o)&&(t=n[o],this[o]=t?t(a):a[o]);return this.isDefaultPrevented=(a.defaultPrevented!=null?a.defaultPrevented:a.returnValue===!1)?Gg:aC,this.isPropagationStopped=aC,this}return ni(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var t=this.nativeEvent;t&&(t.preventDefault?t.preventDefault():typeof t.returnValue!="unknown"&&(t.returnValue=!1),this.isDefaultPrevented=Gg)},stopPropagation:function(){var t=this.nativeEvent;t&&(t.stopPropagation?t.stopPropagation():typeof t.cancelBubble!="unknown"&&(t.cancelBubble=!0),this.isPropagationStopped=Gg)},persist:function(){},isPersistent:Gg}),e}var lh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},x1=ia(lh),N0=ni({},lh,{view:0,detail:0}),gB=ia(N0),iT,rT,Op,y1=ni({},N0,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:OM,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Op&&(Op&&n.type==="mousemove"?(iT=n.screenX-Op.screenX,rT=n.screenY-Op.screenY):rT=iT=0,Op=n),iT)},movementY:function(n){return"movementY"in n?n.movementY:rT}}),sC=ia(y1),vB=ni({},y1,{dataTransfer:0}),_B=ia(vB),xB=ni({},N0,{relatedTarget:0}),aT=ia(xB),yB=ni({},lh,{animationName:0,elapsedTime:0,pseudoElement:0}),SB=ia(yB),TB=ni({},lh,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),EB=ia(TB),MB=ni({},lh,{data:0}),oC=ia(MB),bB={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},AB={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"},wB={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function RB(n){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(n):(n=wB[n])?!!e[n]:!1}function OM(){return RB}var CB=ni({},N0,{key:function(n){if(n.key){var e=bB[n.key]||n.key;if(e!=="Unidentified")return e}return n.type==="keypress"?(n=c_(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?AB[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:OM,charCode:function(n){return n.type==="keypress"?c_(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?c_(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),DB=ia(CB),NB=ni({},y1,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),lC=ia(NB),OB=ni({},N0,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:OM}),LB=ia(OB),IB=ni({},lh,{propertyName:0,elapsedTime:0,pseudoElement:0}),UB=ia(IB),PB=ni({},y1,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),zB=ia(PB),BB=ni({},lh,{newState:0,oldState:0}),HB=ia(BB),FB=[9,13,27,32],LM=nl&&"CompositionEvent"in window,Em=null;nl&&"documentMode"in document&&(Em=document.documentMode);var GB=nl&&"TextEvent"in window&&!Em,FL=nl&&(!LM||Em&&8<Em&&11>=Em),cC=" ",uC=!1;function GL(n,e){switch(n){case"keyup":return FB.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function VL(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Bf=!1;function VB(n,e){switch(n){case"compositionend":return VL(e);case"keypress":return e.which!==32?null:(uC=!0,cC);case"textInput":return n=e.data,n===cC&&uC?null:n;default:return null}}function kB(n,e){if(Bf)return n==="compositionend"||!LM&&GL(n,e)?(n=HL(),l_=NM=Kl=null,Bf=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return FL&&e.locale!=="ko"?null:e.data;default:return null}}var WB={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 hC(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e==="input"?!!WB[n.type]:e==="textarea"}function kL(n,e,t,i){zf?td?td.push(i):td=[i]:zf=i,e=ex(e,"onChange"),0<e.length&&(t=new x1("onChange","change",null,t,i),n.push({event:t,listeners:e}))}var Mm=null,Jm=null;function XB(n){BI(n,0)}function S1(n){var e=hm(n);if(LL(e))return n}function fC(n,e){if(n==="change")return e}var WL=!1;if(nl){var sT;if(nl){var oT="oninput"in document;if(!oT){var dC=document.createElement("div");dC.setAttribute("oninput","return;"),oT=typeof dC.oninput=="function"}sT=oT}else sT=!1;WL=sT&&(!document.documentMode||9<document.documentMode)}function pC(){Mm&&(Mm.detachEvent("onpropertychange",XL),Jm=Mm=null)}function XL(n){if(n.propertyName==="value"&&S1(Jm)){var e=[];kL(e,Jm,n,DM(n)),BL(XB,e)}}function YB(n,e,t){n==="focusin"?(pC(),Mm=e,Jm=t,Mm.attachEvent("onpropertychange",XL)):n==="focusout"&&pC()}function qB(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return S1(Jm)}function jB(n,e){if(n==="click")return S1(e)}function ZB(n,e){if(n==="input"||n==="change")return S1(e)}function KB(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var La=typeof Object.is=="function"?Object.is:KB;function $m(n,e){if(La(n,e))return!0;if(typeof n!="object"||n===null||typeof e!="object"||e===null)return!1;var t=Object.keys(n),i=Object.keys(e);if(t.length!==i.length)return!1;for(i=0;i<t.length;i++){var r=t[i];if(!T3.call(e,r)||!La(n[r],e[r]))return!1}return!0}function mC(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function gC(n,e){var t=mC(n);n=0;for(var i;t;){if(t.nodeType===3){if(i=n+t.textContent.length,n<=e&&i>=e)return{node:t,offset:e-n};n=i}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=mC(t)}}function YL(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?YL(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function qL(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var e=P_(n.document);e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=P_(n.document)}return e}function IM(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}var QB=nl&&"documentMode"in document&&11>=document.documentMode,Hf=null,C3=null,bm=null,D3=!1;function vC(n,e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;D3||Hf==null||Hf!==P_(i)||(i=Hf,"selectionStart"in i&&IM(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),bm&&$m(bm,i)||(bm=i,i=ex(C3,"onSelect"),0<i.length&&(e=new x1("onSelect","select",null,e,t),n.push({event:e,listeners:i}),e.target=Hf)))}function Zc(n,e){var t={};return t[n.toLowerCase()]=e.toLowerCase(),t["Webkit"+n]="webkit"+e,t["Moz"+n]="moz"+e,t}var Ff={animationend:Zc("Animation","AnimationEnd"),animationiteration:Zc("Animation","AnimationIteration"),animationstart:Zc("Animation","AnimationStart"),transitionrun:Zc("Transition","TransitionRun"),transitionstart:Zc("Transition","TransitionStart"),transitioncancel:Zc("Transition","TransitionCancel"),transitionend:Zc("Transition","TransitionEnd")},lT={},jL={};nl&&(jL=document.createElement("div").style,"AnimationEvent"in window||(delete Ff.animationend.animation,delete Ff.animationiteration.animation,delete Ff.animationstart.animation),"TransitionEvent"in window||delete Ff.transitionend.transition);function ch(n){if(lT[n])return lT[n];if(!Ff[n])return n;var e=Ff[n],t;for(t in e)if(e.hasOwnProperty(t)&&t in jL)return lT[n]=e[t];return n}var ZL=ch("animationend"),KL=ch("animationiteration"),QL=ch("animationstart"),JB=ch("transitionrun"),$B=ch("transitionstart"),eH=ch("transitioncancel"),JL=ch("transitionend"),$L=new Map,N3="abort auxClick beforeToggle 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(" ");N3.push("scrollEnd");function Ls(n,e){$L.set(n,e),oh(e,[n])}var z_=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Za=[],Gf=0,UM=0;function T1(){for(var n=Gf,e=UM=Gf=0;e<n;){var t=Za[e];Za[e++]=null;var i=Za[e];Za[e++]=null;var r=Za[e];Za[e++]=null;var a=Za[e];if(Za[e++]=null,i!==null&&r!==null){var s=i.pending;s===null?r.next=r:(r.next=s.next,s.next=r),i.pending=r}a!==0&&e5(t,r,a)}}function E1(n,e,t,i){Za[Gf++]=n,Za[Gf++]=e,Za[Gf++]=t,Za[Gf++]=i,UM|=i,n.lanes|=i,n=n.alternate,n!==null&&(n.lanes|=i)}function PM(n,e,t,i){return E1(n,e,t,i),B_(n)}function uh(n,e){return E1(n,null,null,e),B_(n)}function e5(n,e,t){n.lanes|=t;var i=n.alternate;i!==null&&(i.lanes|=t);for(var r=!1,a=n.return;a!==null;)a.childLanes|=t,i=a.alternate,i!==null&&(i.childLanes|=t),a.tag===22&&(n=a.stateNode,n===null||n._visibility&1||(r=!0)),n=a,a=a.return;return n.tag===3?(a=n.stateNode,r&&e!==null&&(r=31-Da(t),n=a.hiddenUpdates,i=n[r],i===null?n[r]=[e]:i.push(e),e.lane=t|536870912),a):null}function B_(n){if(50<Im)throw Im=0,J3=null,Error(Ue(185));for(var e=n.return;e!==null;)n=e,e=n.return;return n.tag===3?n.stateNode:null}var Vf={};function tH(n,e,t,i){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ma(n,e,t,i){return new tH(n,e,t,i)}function zM(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Qo(n,e){var t=n.alternate;return t===null?(t=Ma(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&65011712,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t.refCleanup=n.refCleanup,t}function t5(n,e){n.flags&=65011714;var t=n.alternate;return t===null?(n.childLanes=0,n.lanes=e,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,n.type=t.type,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n}function u_(n,e,t,i,r,a){var s=0;if(i=n,typeof n=="function")zM(n)&&(s=1);else if(typeof n=="string")s=sF(n,t,ro.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case _3:return n=Ma(31,t,e,r),n.elementType=_3,n.lanes=a,n;case If:return Lu(t.children,r,a,e);case yL:s=8,r|=24;break;case m3:return n=Ma(12,t,e,r|2),n.elementType=m3,n.lanes=a,n;case g3:return n=Ma(13,t,e,r),n.elementType=g3,n.lanes=a,n;case v3:return n=Ma(19,t,e,r),n.elementType=v3,n.lanes=a,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case jo:s=10;break e;case SL:s=9;break e;case EM:s=11;break e;case MM:s=14;break e;case Vl:s=16,i=null;break e}s=29,t=Error(Ue(130,n===null?"null":typeof n,"")),i=null}return e=Ma(s,t,e,r),e.elementType=n,e.type=i,e.lanes=a,e}function Lu(n,e,t,i){return n=Ma(7,n,i,e),n.lanes=t,n}function cT(n,e,t){return n=Ma(6,n,null,e),n.lanes=t,n}function n5(n){var e=Ma(18,null,null,0);return e.stateNode=n,e}function uT(n,e,t){return e=Ma(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}var _C=new WeakMap;function es(n,e){if(typeof n=="object"&&n!==null){var t=_C.get(n);return t!==void 0?t:(e={value:n,source:e,stack:JR(e)},_C.set(n,e),e)}return{value:n,source:e,stack:JR(e)}}var kf=[],Wf=0,H_=null,e0=0,Qa=[],Ja=0,pc=null,eo=1,to="";function Vo(n,e){kf[Wf++]=e0,kf[Wf++]=H_,H_=n,e0=e}function i5(n,e,t){Qa[Ja++]=eo,Qa[Ja++]=to,Qa[Ja++]=pc,pc=n;var i=eo;n=to;var r=32-Da(i)-1;i&=~(1<<r),t+=1;var a=32-Da(e)+r;if(30<a){var s=r-r%5;a=(i&(1<<s)-1).toString(32),i>>=s,r-=s,eo=1<<32-Da(e)+r|t<<r|i,to=a+n}else eo=1<<a|t<<r|i,to=n}function BM(n){n.return!==null&&(Vo(n,1),i5(n,1,0))}function HM(n){for(;n===H_;)H_=kf[--Wf],kf[Wf]=null,e0=kf[--Wf],kf[Wf]=null;for(;n===pc;)pc=Qa[--Ja],Qa[Ja]=null,to=Qa[--Ja],Qa[Ja]=null,eo=Qa[--Ja],Qa[Ja]=null}function r5(n,e){Qa[Ja++]=eo,Qa[Ja++]=to,Qa[Ja++]=pc,eo=e.id,to=e.overflow,pc=n}var lr=null,Jn=null,un=!1,rc=null,ts=!1,O3=Error(Ue(519));function mc(n){var e=Error(Ue(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw t0(es(e,n)),O3}function xC(n){var e=n.stateNode,t=n.type,i=n.memoizedProps;switch(e[or]=n,e[ta]=i,t){case"dialog":an("cancel",e),an("close",e);break;case"iframe":case"object":case"embed":an("load",e);break;case"video":case"audio":for(t=0;t<a0.length;t++)an(a0[t],e);break;case"source":an("error",e);break;case"img":case"image":case"link":an("error",e),an("load",e);break;case"details":an("toggle",e);break;case"input":an("invalid",e),IL(e,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":an("invalid",e);break;case"textarea":an("invalid",e),PL(e,i.value,i.defaultValue,i.children)}t=i.children,typeof t!="string"&&typeof t!="number"&&typeof t!="bigint"||e.textContent===""+t||i.suppressHydrationWarning===!0||FI(e.textContent,t)?(i.popover!=null&&(an("beforetoggle",e),an("toggle",e)),i.onScroll!=null&&an("scroll",e),i.onScrollEnd!=null&&an("scrollend",e),i.onClick!=null&&(e.onclick=Zo),e=!0):e=!1,e||mc(n,!0)}function yC(n){for(lr=n.return;lr;)switch(lr.tag){case 5:case 31:case 13:ts=!1;return;case 27:case 3:ts=!0;return;default:lr=lr.return}}function Yh(n){if(n!==lr)return!1;if(!un)return yC(n),un=!0,!1;var e=n.tag,t;if((t=e!==3&&e!==27)&&((t=e===5)&&(t=n.type,t=!(t!=="form"&&t!=="button")||iE(n.type,n.memoizedProps)),t=!t),t&&Jn&&mc(n),yC(n),e===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(Ue(317));Jn=s4(n)}else if(e===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(Ue(317));Jn=s4(n)}else e===27?(e=Jn,Ec(n.type)?(n=oE,oE=null,Jn=n):Jn=e):Jn=lr?rs(n.stateNode.nextSibling):null;return!0}function ku(){Jn=lr=null,un=!1}function hT(){var n=rc;return n!==null&&(Qr===null?Qr=n:Qr.push.apply(Qr,n),rc=null),n}function t0(n){rc===null?rc=[n]:rc.push(n)}var L3=co(null),hh=null,Ko=null;function Wl(n,e,t){qn(L3,e._currentValue),e._currentValue=t}function Jo(n){n._currentValue=L3.current,er(L3)}function I3(n,e,t){for(;n!==null;){var i=n.alternate;if((n.childLanes&e)!==e?(n.childLanes|=e,i!==null&&(i.childLanes|=e)):i!==null&&(i.childLanes&e)!==e&&(i.childLanes|=e),n===t)break;n=n.return}}function U3(n,e,t,i){var r=n.child;for(r!==null&&(r.return=n);r!==null;){var a=r.dependencies;if(a!==null){var s=r.child;a=a.firstContext;e:for(;a!==null;){var o=a;a=r;for(var l=0;l<e.length;l++)if(o.context===e[l]){a.lanes|=t,o=a.alternate,o!==null&&(o.lanes|=t),I3(a.return,t,n),i||(s=null);break e}a=o.next}}else if(r.tag===18){if(s=r.return,s===null)throw Error(Ue(341));s.lanes|=t,a=s.alternate,a!==null&&(a.lanes|=t),I3(s,t,n),s=null}else s=r.child;if(s!==null)s.return=r;else for(s=r;s!==null;){if(s===n){s=null;break}if(r=s.sibling,r!==null){r.return=s.return,s=r;break}s=s.return}r=s}}function kd(n,e,t,i){n=null;for(var r=e,a=!1;r!==null;){if(!a){if(r.flags&524288)a=!0;else if(r.flags&262144)break}if(r.tag===10){var s=r.alternate;if(s===null)throw Error(Ue(387));if(s=s.memoizedProps,s!==null){var o=r.type;La(r.pendingProps.value,s.value)||(n!==null?n.push(o):n=[o])}}else if(r===O_.current){if(s=r.alternate,s===null)throw Error(Ue(387));s.memoizedState.memoizedState!==r.memoizedState.memoizedState&&(n!==null?n.push(o0):n=[o0])}r=r.return}n!==null&&U3(e,n,t,i),e.flags|=262144}function F_(n){for(n=n.firstContext;n!==null;){if(!La(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Wu(n){hh=n,Ko=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function ur(n){return a5(hh,n)}function Vg(n,e){return hh===null&&Wu(n),a5(n,e)}function a5(n,e){var t=e._currentValue;if(e={context:e,memoizedValue:t,next:null},Ko===null){if(n===null)throw Error(Ue(308));Ko=e,n.dependencies={lanes:0,firstContext:e},n.flags|=524288}else Ko=Ko.next=e;return t}var nH=typeof AbortController<"u"?AbortController:function(){var n=[],e=this.signal={aborted:!1,addEventListener:function(t,i){n.push(i)}};this.abort=function(){e.aborted=!0,n.forEach(function(t){return t()})}},iH=Gi.unstable_scheduleCallback,rH=Gi.unstable_NormalPriority,Oi={$$typeof:jo,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function FM(){return{controller:new nH,data:new Map,refCount:0}}function O0(n){n.refCount--,n.refCount===0&&iH(rH,function(){n.controller.abort()})}var Am=null,P3=0,pd=0,nd=null;function aH(n,e){if(Am===null){var t=Am=[];P3=0,pd=hb(),nd={status:"pending",value:void 0,then:function(i){t.push(i)}}}return P3++,e.then(SC,SC),e}function SC(){if(--P3===0&&Am!==null){nd!==null&&(nd.status="fulfilled");var n=Am;Am=null,pd=0,nd=null;for(var e=0;e<n.length;e++)(0,n[e])()}}function sH(n,e){var t=[],i={status:"pending",value:null,reason:null,then:function(r){t.push(r)}};return n.then(function(){i.status="fulfilled",i.value=e;for(var r=0;r<t.length;r++)(0,t[r])(e)},function(r){for(i.status="rejected",i.reason=r,r=0;r<t.length;r++)(0,t[r])(void 0)}),i}var TC=Ut.S;Ut.S=function(n,e){xI=Ra(),typeof e=="object"&&e!==null&&typeof e.then=="function"&&aH(n,e),TC!==null&&TC(n,e)};var Iu=co(null);function GM(){var n=Iu.current;return n!==null?n:Gn.pooledCache}function h_(n,e){e===null?qn(Iu,Iu.current):qn(Iu,e.pool)}function s5(){var n=GM();return n===null?null:{parent:Oi._currentValue,pool:n}}var Wd=Error(Ue(460)),VM=Error(Ue(474)),M1=Error(Ue(542)),G_={then:function(){}};function EC(n){return n=n.status,n==="fulfilled"||n==="rejected"}function o5(n,e,t){switch(t=n[t],t===void 0?n.push(e):t!==e&&(e.then(Zo,Zo),e=t),e.status){case"fulfilled":return e.value;case"rejected":throw n=e.reason,bC(n),n;default:if(typeof e.status=="string")e.then(Zo,Zo);else{if(n=Gn,n!==null&&100<n.shellSuspendCounter)throw Error(Ue(482));n=e,n.status="pending",n.then(function(i){if(e.status==="pending"){var r=e;r.status="fulfilled",r.value=i}},function(i){if(e.status==="pending"){var r=e;r.status="rejected",r.reason=i}})}switch(e.status){case"fulfilled":return e.value;case"rejected":throw n=e.reason,bC(n),n}throw Uu=e,Wd}}function vu(n){try{var e=n._init;return e(n._payload)}catch(t){throw t!==null&&typeof t=="object"&&typeof t.then=="function"?(Uu=t,Wd):t}}var Uu=null;function MC(){if(Uu===null)throw Error(Ue(459));var n=Uu;return Uu=null,n}function bC(n){if(n===Wd||n===M1)throw Error(Ue(483))}var id=null,n0=0;function kg(n){var e=n0;return n0+=1,id===null&&(id=[]),o5(id,n,e)}function Lp(n,e){e=e.props.ref,n.ref=e!==void 0?e:null}function Wg(n,e){throw e.$$typeof===Yz?Error(Ue(525)):(n=Object.prototype.toString.call(e),Error(Ue(31,n==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":n)))}function l5(n){function e(v,S){if(n){var E=v.deletions;E===null?(v.deletions=[S],v.flags|=16):E.push(S)}}function t(v,S){if(!n)return null;for(;S!==null;)e(v,S),S=S.sibling;return null}function i(v){for(var S=new Map;v!==null;)v.key!==null?S.set(v.key,v):S.set(v.index,v),v=v.sibling;return S}function r(v,S){return v=Qo(v,S),v.index=0,v.sibling=null,v}function a(v,S,E){return v.index=E,n?(E=v.alternate,E!==null?(E=E.index,E<S?(v.flags|=67108866,S):E):(v.flags|=67108866,S)):(v.flags|=1048576,S)}function s(v){return n&&v.alternate===null&&(v.flags|=67108866),v}function o(v,S,E,b){return S===null||S.tag!==6?(S=cT(E,v.mode,b),S.return=v,S):(S=r(S,E),S.return=v,S)}function l(v,S,E,b){var N=E.type;return N===If?f(v,S,E.props.children,b,E.key):S!==null&&(S.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Vl&&vu(N)===S.type)?(S=r(S,E.props),Lp(S,E),S.return=v,S):(S=u_(E.type,E.key,E.props,null,v.mode,b),Lp(S,E),S.return=v,S)}function h(v,S,E,b){return S===null||S.tag!==4||S.stateNode.containerInfo!==E.containerInfo||S.stateNode.implementation!==E.implementation?(S=uT(E,v.mode,b),S.return=v,S):(S=r(S,E.children||[]),S.return=v,S)}function f(v,S,E,b,N){return S===null||S.tag!==7?(S=Lu(E,v.mode,b,N),S.return=v,S):(S=r(S,E),S.return=v,S)}function d(v,S,E){if(typeof S=="string"&&S!==""||typeof S=="number"||typeof S=="bigint")return S=cT(""+S,v.mode,E),S.return=v,S;if(typeof S=="object"&&S!==null){switch(S.$$typeof){case Pg:return E=u_(S.type,S.key,S.props,null,v.mode,E),Lp(E,S),E.return=v,E;case cm:return S=uT(S,v.mode,E),S.return=v,S;case Vl:return S=vu(S),d(v,S,E)}if(um(S)||Dp(S))return S=Lu(S,v.mode,E,null),S.return=v,S;if(typeof S.then=="function")return d(v,kg(S),E);if(S.$$typeof===jo)return d(v,Vg(v,S),E);Wg(v,S)}return null}function p(v,S,E,b){var N=S!==null?S.key:null;if(typeof E=="string"&&E!==""||typeof E=="number"||typeof E=="bigint")return N!==null?null:o(v,S,""+E,b);if(typeof E=="object"&&E!==null){switch(E.$$typeof){case Pg:return E.key===N?l(v,S,E,b):null;case cm:return E.key===N?h(v,S,E,b):null;case Vl:return E=vu(E),p(v,S,E,b)}if(um(E)||Dp(E))return N!==null?null:f(v,S,E,b,null);if(typeof E.then=="function")return p(v,S,kg(E),b);if(E.$$typeof===jo)return p(v,S,Vg(v,E),b);Wg(v,E)}return null}function g(v,S,E,b,N){if(typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint")return v=v.get(E)||null,o(S,v,""+b,N);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Pg:return v=v.get(b.key===null?E:b.key)||null,l(S,v,b,N);case cm:return v=v.get(b.key===null?E:b.key)||null,h(S,v,b,N);case Vl:return b=vu(b),g(v,S,E,b,N)}if(um(b)||Dp(b))return v=v.get(E)||null,f(S,v,b,N,null);if(typeof b.then=="function")return g(v,S,E,kg(b),N);if(b.$$typeof===jo)return g(v,S,E,Vg(S,b),N);Wg(S,b)}return null}function _(v,S,E,b){for(var N=null,R=null,I=S,U=S=0,O=null;I!==null&&U<E.length;U++){I.index>U?(O=I,I=null):O=I.sibling;var w=p(v,I,E[U],b);if(w===null){I===null&&(I=O);break}n&&I&&w.alternate===null&&e(v,I),S=a(w,S,U),R===null?N=w:R.sibling=w,R=w,I=O}if(U===E.length)return t(v,I),un&&Vo(v,U),N;if(I===null){for(;U<E.length;U++)I=d(v,E[U],b),I!==null&&(S=a(I,S,U),R===null?N=I:R.sibling=I,R=I);return un&&Vo(v,U),N}for(I=i(I);U<E.length;U++)O=g(I,v,U,E[U],b),O!==null&&(n&&O.alternate!==null&&I.delete(O.key===null?U:O.key),S=a(O,S,U),R===null?N=O:R.sibling=O,R=O);return n&&I.forEach(function(B){return e(v,B)}),un&&Vo(v,U),N}function T(v,S,E,b){if(E==null)throw Error(Ue(151));for(var N=null,R=null,I=S,U=S=0,O=null,w=E.next();I!==null&&!w.done;U++,w=E.next()){I.index>U?(O=I,I=null):O=I.sibling;var B=p(v,I,w.value,b);if(B===null){I===null&&(I=O);break}n&&I&&B.alternate===null&&e(v,I),S=a(B,S,U),R===null?N=B:R.sibling=B,R=B,I=O}if(w.done)return t(v,I),un&&Vo(v,U),N;if(I===null){for(;!w.done;U++,w=E.next())w=d(v,w.value,b),w!==null&&(S=a(w,S,U),R===null?N=w:R.sibling=w,R=w);return un&&Vo(v,U),N}for(I=i(I);!w.done;U++,w=E.next())w=g(I,v,U,w.value,b),w!==null&&(n&&w.alternate!==null&&I.delete(w.key===null?U:w.key),S=a(w,S,U),R===null?N=w:R.sibling=w,R=w);return n&&I.forEach(function(j){return e(v,j)}),un&&Vo(v,U),N}function y(v,S,E,b){if(typeof E=="object"&&E!==null&&E.type===If&&E.key===null&&(E=E.props.children),typeof E=="object"&&E!==null){switch(E.$$typeof){case Pg:e:{for(var N=E.key;S!==null;){if(S.key===N){if(N=E.type,N===If){if(S.tag===7){t(v,S.sibling),b=r(S,E.props.children),b.return=v,v=b;break e}}else if(S.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Vl&&vu(N)===S.type){t(v,S.sibling),b=r(S,E.props),Lp(b,E),b.return=v,v=b;break e}t(v,S);break}else e(v,S);S=S.sibling}E.type===If?(b=Lu(E.props.children,v.mode,b,E.key),b.return=v,v=b):(b=u_(E.type,E.key,E.props,null,v.mode,b),Lp(b,E),b.return=v,v=b)}return s(v);case cm:e:{for(N=E.key;S!==null;){if(S.key===N)if(S.tag===4&&S.stateNode.containerInfo===E.containerInfo&&S.stateNode.implementation===E.implementation){t(v,S.sibling),b=r(S,E.children||[]),b.return=v,v=b;break e}else{t(v,S);break}else e(v,S);S=S.sibling}b=uT(E,v.mode,b),b.return=v,v=b}return s(v);case Vl:return E=vu(E),y(v,S,E,b)}if(um(E))return _(v,S,E,b);if(Dp(E)){if(N=Dp(E),typeof N!="function")throw Error(Ue(150));return E=N.call(E),T(v,S,E,b)}if(typeof E.then=="function")return y(v,S,kg(E),b);if(E.$$typeof===jo)return y(v,S,Vg(v,E),b);Wg(v,E)}return typeof E=="string"&&E!==""||typeof E=="number"||typeof E=="bigint"?(E=""+E,S!==null&&S.tag===6?(t(v,S.sibling),b=r(S,E),b.return=v,v=b):(t(v,S),b=cT(E,v.mode,b),b.return=v,v=b),s(v)):t(v,S)}return function(v,S,E,b){try{n0=0;var N=y(v,S,E,b);return id=null,N}catch(I){if(I===Wd||I===M1)throw I;var R=Ma(29,I,null,v.mode);return R.lanes=b,R.return=v,R}finally{}}}var Xu=l5(!0),c5=l5(!1),kl=!1;function kM(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function z3(n,e){n=n.updateQueue,e.updateQueue===n&&(e.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function ac(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function sc(n,e,t){var i=n.updateQueue;if(i===null)return null;if(i=i.shared,yn&2){var r=i.pending;return r===null?e.next=e:(e.next=r.next,r.next=e),i.pending=e,e=B_(n),e5(n,null,t),e}return E1(n,i,e,t),B_(n)}function wm(n,e,t){if(e=e.updateQueue,e!==null&&(e=e.shared,(t&4194048)!==0)){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,wL(n,t)}}function fT(n,e){var t=n.updateQueue,i=n.alternate;if(i!==null&&(i=i.updateQueue,t===i)){var r=null,a=null;if(t=t.firstBaseUpdate,t!==null){do{var s={lane:t.lane,tag:t.tag,payload:t.payload,callback:null,next:null};a===null?r=a=s:a=a.next=s,t=t.next}while(t!==null);a===null?r=a=e:a=a.next=e}else r=a=e;t={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:i.shared,callbacks:i.callbacks},n.updateQueue=t;return}n=t.lastBaseUpdate,n===null?t.firstBaseUpdate=e:n.next=e,t.lastBaseUpdate=e}var B3=!1;function Rm(){if(B3){var n=nd;if(n!==null)throw n}}function Cm(n,e,t,i){B3=!1;var r=n.updateQueue;kl=!1;var a=r.firstBaseUpdate,s=r.lastBaseUpdate,o=r.shared.pending;if(o!==null){r.shared.pending=null;var l=o,h=l.next;l.next=null,s===null?a=h:s.next=h,s=l;var f=n.alternate;f!==null&&(f=f.updateQueue,o=f.lastBaseUpdate,o!==s&&(o===null?f.firstBaseUpdate=h:o.next=h,f.lastBaseUpdate=l))}if(a!==null){var d=r.baseState;s=0,f=h=l=null,o=a;do{var p=o.lane&-536870913,g=p!==o.lane;if(g?(cn&p)===p:(i&p)===p){p!==0&&p===pd&&(B3=!0),f!==null&&(f=f.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var _=n,T=o;p=e;var y=t;switch(T.tag){case 1:if(_=T.payload,typeof _=="function"){d=_.call(y,d,p);break e}d=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=T.payload,p=typeof _=="function"?_.call(y,d,p):_,p==null)break e;d=ni({},d,p);break e;case 2:kl=!0}}p=o.callback,p!==null&&(n.flags|=64,g&&(n.flags|=8192),g=r.callbacks,g===null?r.callbacks=[p]:g.push(p))}else g={lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},f===null?(h=f=g,l=d):f=f.next=g,s|=p;if(o=o.next,o===null){if(o=r.shared.pending,o===null)break;g=o,o=g.next,g.next=null,r.lastBaseUpdate=g,r.shared.pending=null}}while(!0);f===null&&(l=d),r.baseState=l,r.firstBaseUpdate=h,r.lastBaseUpdate=f,a===null&&(r.shared.lanes=0),vc|=s,n.lanes=s,n.memoizedState=d}}function u5(n,e){if(typeof n!="function")throw Error(Ue(191,n));n.call(e)}function h5(n,e){var t=n.callbacks;if(t!==null)for(n.callbacks=null,n=0;n<t.length;n++)u5(t[n],e)}var md=co(null),V_=co(0);function AC(n,e){n=sl,qn(V_,n),qn(md,e),sl=n|e.baseLanes}function H3(){qn(V_,sl),qn(md,md.current)}function WM(){sl=V_.current,er(md),er(V_)}var Ia=co(null),is=null;function Xl(n){var e=n.alternate;qn(Ti,Ti.current&1),qn(Ia,n),is===null&&(e===null||md.current!==null||e.memoizedState!==null)&&(is=n)}function F3(n){qn(Ti,Ti.current),qn(Ia,n),is===null&&(is=n)}function f5(n){n.tag===22?(qn(Ti,Ti.current),qn(Ia,n),is===null&&(is=n)):Yl()}function Yl(){qn(Ti,Ti.current),qn(Ia,Ia.current)}function Ea(n){er(Ia),is===n&&(is=null),er(Ti)}var Ti=co(0);function k_(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||aE(t)||sE(t)))return e}else if(e.tag===19&&(e.memoizedProps.revealOrder==="forwards"||e.memoizedProps.revealOrder==="backwards"||e.memoizedProps.revealOrder==="unstable_legacy-backwards"||e.memoizedProps.revealOrder==="together")){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var il=0,Zt=null,zn=null,Ci=null,W_=!1,rd=!1,Yu=!1,X_=0,i0=0,ad=null,oH=0;function vi(){throw Error(Ue(321))}function XM(n,e){if(e===null)return!1;for(var t=0;t<e.length&&t<n.length;t++)if(!La(n[t],e[t]))return!1;return!0}function YM(n,e,t,i,r,a){return il=a,Zt=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,Ut.H=n===null||n.memoizedState===null?k5:ib,Yu=!1,a=t(i,r),Yu=!1,rd&&(a=p5(e,t,i,r)),d5(n),a}function d5(n){Ut.H=r0;var e=zn!==null&&zn.next!==null;if(il=0,Ci=zn=Zt=null,W_=!1,i0=0,ad=null,e)throw Error(Ue(300));n===null||Li||(n=n.dependencies,n!==null&&F_(n)&&(Li=!0))}function p5(n,e,t,i){Zt=n;var r=0;do{if(rd&&(ad=null),i0=0,rd=!1,25<=r)throw Error(Ue(301));if(r+=1,Ci=zn=null,n.updateQueue!=null){var a=n.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,a.memoCache!=null&&(a.memoCache.index=0)}Ut.H=W5,a=e(t,i)}while(rd);return a}function lH(){var n=Ut.H,e=n.useState()[0];return e=typeof e.then=="function"?L0(e):e,n=n.useState()[0],(zn!==null?zn.memoizedState:null)!==n&&(Zt.flags|=1024),e}function qM(){var n=X_!==0;return X_=0,n}function jM(n,e,t){e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~t}function ZM(n){if(W_){for(n=n.memoizedState;n!==null;){var e=n.queue;e!==null&&(e.pending=null),n=n.next}W_=!1}il=0,Ci=zn=Zt=null,rd=!1,i0=X_=0,ad=null}function Cr(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ci===null?Zt.memoizedState=Ci=n:Ci=Ci.next=n,Ci}function Ei(){if(zn===null){var n=Zt.alternate;n=n!==null?n.memoizedState:null}else n=zn.next;var e=Ci===null?Zt.memoizedState:Ci.next;if(e!==null)Ci=e,zn=n;else{if(n===null)throw Zt.alternate===null?Error(Ue(467)):Error(Ue(310));zn=n,n={memoizedState:zn.memoizedState,baseState:zn.baseState,baseQueue:zn.baseQueue,queue:zn.queue,next:null},Ci===null?Zt.memoizedState=Ci=n:Ci=Ci.next=n}return Ci}function b1(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function L0(n){var e=i0;return i0+=1,ad===null&&(ad=[]),n=o5(ad,n,e),e=Zt,(Ci===null?e.memoizedState:Ci.next)===null&&(e=e.alternate,Ut.H=e===null||e.memoizedState===null?k5:ib),n}function A1(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return L0(n);if(n.$$typeof===jo)return ur(n)}throw Error(Ue(438,String(n)))}function KM(n){var e=null,t=Zt.updateQueue;if(t!==null&&(e=t.memoCache),e==null){var i=Zt.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(e={data:i.data.map(function(r){return r.slice()}),index:0})))}if(e==null&&(e={data:[],index:0}),t===null&&(t=b1(),Zt.updateQueue=t),t.memoCache=e,t=e.data[e.index],t===void 0)for(t=e.data[e.index]=Array(n),i=0;i<n;i++)t[i]=qz;return e.index++,t}function rl(n,e){return typeof e=="function"?e(n):e}function f_(n){var e=Ei();return QM(e,zn,n)}function QM(n,e,t){var i=n.queue;if(i===null)throw Error(Ue(311));i.lastRenderedReducer=t;var r=n.baseQueue,a=i.pending;if(a!==null){if(r!==null){var s=r.next;r.next=a.next,a.next=s}e.baseQueue=r=a,i.pending=null}if(a=n.baseState,r===null)n.memoizedState=a;else{e=r.next;var o=s=null,l=null,h=e,f=!1;do{var d=h.lane&-536870913;if(d!==h.lane?(cn&d)===d:(il&d)===d){var p=h.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null}),d===pd&&(f=!0);else if((il&p)===p){h=h.next,p===pd&&(f=!0);continue}else d={lane:0,revertLane:h.revertLane,gesture:null,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null},l===null?(o=l=d,s=a):l=l.next=d,Zt.lanes|=p,vc|=p;d=h.action,Yu&&t(a,d),a=h.hasEagerState?h.eagerState:t(a,d)}else p={lane:d,revertLane:h.revertLane,gesture:h.gesture,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null},l===null?(o=l=p,s=a):l=l.next=p,Zt.lanes|=d,vc|=d;h=h.next}while(h!==null&&h!==e);if(l===null?s=a:l.next=o,!La(a,n.memoizedState)&&(Li=!0,f&&(t=nd,t!==null)))throw t;n.memoizedState=a,n.baseState=s,n.baseQueue=l,i.lastRenderedState=a}return r===null&&(i.lanes=0),[n.memoizedState,i.dispatch]}function dT(n){var e=Ei(),t=e.queue;if(t===null)throw Error(Ue(311));t.lastRenderedReducer=n;var i=t.dispatch,r=t.pending,a=e.memoizedState;if(r!==null){t.pending=null;var s=r=r.next;do a=n(a,s.action),s=s.next;while(s!==r);La(a,e.memoizedState)||(Li=!0),e.memoizedState=a,e.baseQueue===null&&(e.baseState=a),t.lastRenderedState=a}return[a,i]}function m5(n,e,t){var i=Zt,r=Ei(),a=un;if(a){if(t===void 0)throw Error(Ue(407));t=t()}else t=e();var s=!La((zn||r).memoizedState,t);if(s&&(r.memoizedState=t,Li=!0),r=r.queue,JM(_5.bind(null,i,r,n),[n]),r.getSnapshot!==e||s||Ci!==null&&Ci.memoizedState.tag&1){if(i.flags|=2048,gd(9,{destroy:void 0},v5.bind(null,i,r,t,e),null),Gn===null)throw Error(Ue(349));a||il&127||g5(i,e,t)}return t}function g5(n,e,t){n.flags|=16384,n={getSnapshot:e,value:t},e=Zt.updateQueue,e===null?(e=b1(),Zt.updateQueue=e,e.stores=[n]):(t=e.stores,t===null?e.stores=[n]:t.push(n))}function v5(n,e,t,i){e.value=t,e.getSnapshot=i,x5(e)&&y5(n)}function _5(n,e,t){return t(function(){x5(e)&&y5(n)})}function x5(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!La(n,t)}catch{return!0}}function y5(n){var e=uh(n,2);e!==null&&$r(e,n,2)}function G3(n){var e=Cr();if(typeof n=="function"){var t=n;if(n=t(),Yu){Zl(!0);try{t()}finally{Zl(!1)}}}return e.memoizedState=e.baseState=n,e.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:rl,lastRenderedState:n},e}function S5(n,e,t,i){return n.baseState=t,QM(n,zn,typeof i=="function"?i:rl)}function cH(n,e,t,i,r){if(R1(n))throw Error(Ue(485));if(n=e.action,n!==null){var a={payload:r,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){a.listeners.push(s)}};Ut.T!==null?t(!0):a.isTransition=!1,i(a),t=e.pending,t===null?(a.next=e.pending=a,T5(e,a)):(a.next=t.next,e.pending=t.next=a)}}function T5(n,e){var t=e.action,i=e.payload,r=n.state;if(e.isTransition){var a=Ut.T,s={};Ut.T=s;try{var o=t(r,i),l=Ut.S;l!==null&&l(s,o),wC(n,e,o)}catch(h){V3(n,e,h)}finally{a!==null&&s.types!==null&&(a.types=s.types),Ut.T=a}}else try{a=t(r,i),wC(n,e,a)}catch(h){V3(n,e,h)}}function wC(n,e,t){t!==null&&typeof t=="object"&&typeof t.then=="function"?t.then(function(i){RC(n,e,i)},function(i){return V3(n,e,i)}):RC(n,e,t)}function RC(n,e,t){e.status="fulfilled",e.value=t,E5(e),n.state=t,e=n.pending,e!==null&&(t=e.next,t===e?n.pending=null:(t=t.next,e.next=t,T5(n,t)))}function V3(n,e,t){var i=n.pending;if(n.pending=null,i!==null){i=i.next;do e.status="rejected",e.reason=t,E5(e),e=e.next;while(e!==i)}n.action=null}function E5(n){n=n.listeners;for(var e=0;e<n.length;e++)(0,n[e])()}function M5(n,e){return e}function CC(n,e){if(un){var t=Gn.formState;if(t!==null){e:{var i=Zt;if(un){if(Jn){t:{for(var r=Jn,a=ts;r.nodeType!==8;){if(!a){r=null;break t}if(r=rs(r.nextSibling),r===null){r=null;break t}}a=r.data,r=a==="F!"||a==="F"?r:null}if(r){Jn=rs(r.nextSibling),i=r.data==="F!";break e}}mc(i)}i=!1}i&&(e=t[0])}}return t=Cr(),t.memoizedState=t.baseState=e,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:M5,lastRenderedState:e},t.queue=i,t=F5.bind(null,Zt,i),i.dispatch=t,i=G3(!1),a=nb.bind(null,Zt,!1,i.queue),i=Cr(),r={state:e,dispatch:null,action:n,pending:null},i.queue=r,t=cH.bind(null,Zt,r,a,t),r.dispatch=t,i.memoizedState=n,[e,t,!1]}function DC(n){var e=Ei();return b5(e,zn,n)}function b5(n,e,t){if(e=QM(n,e,M5)[0],n=f_(rl)[0],typeof e=="object"&&e!==null&&typeof e.then=="function")try{var i=L0(e)}catch(s){throw s===Wd?M1:s}else i=e;e=Ei();var r=e.queue,a=r.dispatch;return t!==e.memoizedState&&(Zt.flags|=2048,gd(9,{destroy:void 0},uH.bind(null,r,t),null)),[i,a,n]}function uH(n,e){n.action=e}function NC(n){var e=Ei(),t=zn;if(t!==null)return b5(e,t,n);Ei(),e=e.memoizedState,t=Ei();var i=t.queue.dispatch;return t.memoizedState=n,[e,i,!1]}function gd(n,e,t,i){return n={tag:n,create:t,deps:i,inst:e,next:null},e=Zt.updateQueue,e===null&&(e=b1(),Zt.updateQueue=e),t=e.lastEffect,t===null?e.lastEffect=n.next=n:(i=t.next,t.next=n,n.next=i,e.lastEffect=n),n}function A5(){return Ei().memoizedState}function d_(n,e,t,i){var r=Cr();Zt.flags|=n,r.memoizedState=gd(1|e,{destroy:void 0},t,i===void 0?null:i)}function w1(n,e,t,i){var r=Ei();i=i===void 0?null:i;var a=r.memoizedState.inst;zn!==null&&i!==null&&XM(i,zn.memoizedState.deps)?r.memoizedState=gd(e,a,t,i):(Zt.flags|=n,r.memoizedState=gd(1|e,a,t,i))}function OC(n,e){d_(8390656,8,n,e)}function JM(n,e){w1(2048,8,n,e)}function hH(n){Zt.flags|=4;var e=Zt.updateQueue;if(e===null)e=b1(),Zt.updateQueue=e,e.events=[n];else{var t=e.events;t===null?e.events=[n]:t.push(n)}}function w5(n){var e=Ei().memoizedState;return hH({ref:e,nextImpl:n}),function(){if(yn&2)throw Error(Ue(440));return e.impl.apply(void 0,arguments)}}function R5(n,e){return w1(4,2,n,e)}function C5(n,e){return w1(4,4,n,e)}function D5(n,e){if(typeof e=="function"){n=n();var t=e(n);return function(){typeof t=="function"?t():e(null)}}if(e!=null)return n=n(),e.current=n,function(){e.current=null}}function N5(n,e,t){t=t!=null?t.concat([n]):null,w1(4,4,D5.bind(null,e,n),t)}function $M(){}function O5(n,e){var t=Ei();e=e===void 0?null:e;var i=t.memoizedState;return e!==null&&XM(e,i[1])?i[0]:(t.memoizedState=[n,e],n)}function L5(n,e){var t=Ei();e=e===void 0?null:e;var i=t.memoizedState;if(e!==null&&XM(e,i[1]))return i[0];if(i=n(),Yu){Zl(!0);try{n()}finally{Zl(!1)}}return t.memoizedState=[i,e],i}function eb(n,e,t){return t===void 0||il&1073741824&&!(cn&261930)?n.memoizedState=e:(n.memoizedState=t,n=SI(),Zt.lanes|=n,vc|=n,t)}function I5(n,e,t,i){return La(t,e)?t:md.current!==null?(n=eb(n,t,i),La(n,e)||(Li=!0),n):!(il&42)||il&1073741824&&!(cn&261930)?(Li=!0,n.memoizedState=t):(n=SI(),Zt.lanes|=n,vc|=n,e)}function U5(n,e,t,i,r){var a=Sn.p;Sn.p=a!==0&&8>a?a:8;var s=Ut.T,o={};Ut.T=o,nb(n,!1,e,t);try{var l=r(),h=Ut.S;if(h!==null&&h(o,l),l!==null&&typeof l=="object"&&typeof l.then=="function"){var f=sH(l,i);Dm(n,e,f,Na(n))}else Dm(n,e,i,Na(n))}catch(d){Dm(n,e,{then:function(){},status:"rejected",reason:d},Na())}finally{Sn.p=a,s!==null&&o.types!==null&&(s.types=o.types),Ut.T=s}}function fH(){}function k3(n,e,t,i){if(n.tag!==5)throw Error(Ue(476));var r=P5(n).queue;U5(n,r,e,Ou,t===null?fH:function(){return z5(n),t(i)})}function P5(n){var e=n.memoizedState;if(e!==null)return e;e={memoizedState:Ou,baseState:Ou,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:rl,lastRenderedState:Ou},next:null};var t={};return e.next={memoizedState:t,baseState:t,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:rl,lastRenderedState:t},next:null},n.memoizedState=e,n=n.alternate,n!==null&&(n.memoizedState=e),e}function z5(n){var e=P5(n);e.next===null&&(e=n.alternate.memoizedState),Dm(n,e.next.queue,{},Na())}function tb(){return ur(o0)}function B5(){return Ei().memoizedState}function H5(){return Ei().memoizedState}function dH(n){for(var e=n.return;e!==null;){switch(e.tag){case 24:case 3:var t=Na();n=ac(t);var i=sc(e,n,t);i!==null&&($r(i,e,t),wm(i,e,t)),e={cache:FM()},n.payload=e;return}e=e.return}}function pH(n,e,t){var i=Na();t={lane:i,revertLane:0,gesture:null,action:t,hasEagerState:!1,eagerState:null,next:null},R1(n)?G5(e,t):(t=PM(n,e,t,i),t!==null&&($r(t,n,i),V5(t,e,i)))}function F5(n,e,t){var i=Na();Dm(n,e,t,i)}function Dm(n,e,t,i){var r={lane:i,revertLane:0,gesture:null,action:t,hasEagerState:!1,eagerState:null,next:null};if(R1(n))G5(e,r);else{var a=n.alternate;if(n.lanes===0&&(a===null||a.lanes===0)&&(a=e.lastRenderedReducer,a!==null))try{var s=e.lastRenderedState,o=a(s,t);if(r.hasEagerState=!0,r.eagerState=o,La(o,s))return E1(n,e,r,0),Gn===null&&T1(),!1}catch{}finally{}if(t=PM(n,e,r,i),t!==null)return $r(t,n,i),V5(t,e,i),!0}return!1}function nb(n,e,t,i){if(i={lane:2,revertLane:hb(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},R1(n)){if(e)throw Error(Ue(479))}else e=PM(n,t,i,2),e!==null&&$r(e,n,2)}function R1(n){var e=n.alternate;return n===Zt||e!==null&&e===Zt}function G5(n,e){rd=W_=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function V5(n,e,t){if(t&4194048){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,wL(n,t)}}var r0={readContext:ur,use:A1,useCallback:vi,useContext:vi,useEffect:vi,useImperativeHandle:vi,useLayoutEffect:vi,useInsertionEffect:vi,useMemo:vi,useReducer:vi,useRef:vi,useState:vi,useDebugValue:vi,useDeferredValue:vi,useTransition:vi,useSyncExternalStore:vi,useId:vi,useHostTransitionStatus:vi,useFormState:vi,useActionState:vi,useOptimistic:vi,useMemoCache:vi,useCacheRefresh:vi};r0.useEffectEvent=vi;var k5={readContext:ur,use:A1,useCallback:function(n,e){return Cr().memoizedState=[n,e===void 0?null:e],n},useContext:ur,useEffect:OC,useImperativeHandle:function(n,e,t){t=t!=null?t.concat([n]):null,d_(4194308,4,D5.bind(null,e,n),t)},useLayoutEffect:function(n,e){return d_(4194308,4,n,e)},useInsertionEffect:function(n,e){d_(4,2,n,e)},useMemo:function(n,e){var t=Cr();e=e===void 0?null:e;var i=n();if(Yu){Zl(!0);try{n()}finally{Zl(!1)}}return t.memoizedState=[i,e],i},useReducer:function(n,e,t){var i=Cr();if(t!==void 0){var r=t(e);if(Yu){Zl(!0);try{t(e)}finally{Zl(!1)}}}else r=e;return i.memoizedState=i.baseState=r,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},i.queue=n,n=n.dispatch=pH.bind(null,Zt,n),[i.memoizedState,n]},useRef:function(n){var e=Cr();return n={current:n},e.memoizedState=n},useState:function(n){n=G3(n);var e=n.queue,t=F5.bind(null,Zt,e);return e.dispatch=t,[n.memoizedState,t]},useDebugValue:$M,useDeferredValue:function(n,e){var t=Cr();return eb(t,n,e)},useTransition:function(){var n=G3(!1);return n=U5.bind(null,Zt,n.queue,!0,!1),Cr().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,e,t){var i=Zt,r=Cr();if(un){if(t===void 0)throw Error(Ue(407));t=t()}else{if(t=e(),Gn===null)throw Error(Ue(349));cn&127||g5(i,e,t)}r.memoizedState=t;var a={value:t,getSnapshot:e};return r.queue=a,OC(_5.bind(null,i,a,n),[n]),i.flags|=2048,gd(9,{destroy:void 0},v5.bind(null,i,a,t,e),null),t},useId:function(){var n=Cr(),e=Gn.identifierPrefix;if(un){var t=to,i=eo;t=(i&~(1<<32-Da(i)-1)).toString(32)+t,e="_"+e+"R_"+t,t=X_++,0<t&&(e+="H"+t.toString(32)),e+="_"}else t=oH++,e="_"+e+"r_"+t.toString(32)+"_";return n.memoizedState=e},useHostTransitionStatus:tb,useFormState:CC,useActionState:CC,useOptimistic:function(n){var e=Cr();e.memoizedState=e.baseState=n;var t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return e.queue=t,e=nb.bind(null,Zt,!0,t),t.dispatch=e,[n,e]},useMemoCache:KM,useCacheRefresh:function(){return Cr().memoizedState=dH.bind(null,Zt)},useEffectEvent:function(n){var e=Cr(),t={impl:n};return e.memoizedState=t,function(){if(yn&2)throw Error(Ue(440));return t.impl.apply(void 0,arguments)}}},ib={readContext:ur,use:A1,useCallback:O5,useContext:ur,useEffect:JM,useImperativeHandle:N5,useInsertionEffect:R5,useLayoutEffect:C5,useMemo:L5,useReducer:f_,useRef:A5,useState:function(){return f_(rl)},useDebugValue:$M,useDeferredValue:function(n,e){var t=Ei();return I5(t,zn.memoizedState,n,e)},useTransition:function(){var n=f_(rl)[0],e=Ei().memoizedState;return[typeof n=="boolean"?n:L0(n),e]},useSyncExternalStore:m5,useId:B5,useHostTransitionStatus:tb,useFormState:DC,useActionState:DC,useOptimistic:function(n,e){var t=Ei();return S5(t,zn,n,e)},useMemoCache:KM,useCacheRefresh:H5};ib.useEffectEvent=w5;var W5={readContext:ur,use:A1,useCallback:O5,useContext:ur,useEffect:JM,useImperativeHandle:N5,useInsertionEffect:R5,useLayoutEffect:C5,useMemo:L5,useReducer:dT,useRef:A5,useState:function(){return dT(rl)},useDebugValue:$M,useDeferredValue:function(n,e){var t=Ei();return zn===null?eb(t,n,e):I5(t,zn.memoizedState,n,e)},useTransition:function(){var n=dT(rl)[0],e=Ei().memoizedState;return[typeof n=="boolean"?n:L0(n),e]},useSyncExternalStore:m5,useId:B5,useHostTransitionStatus:tb,useFormState:NC,useActionState:NC,useOptimistic:function(n,e){var t=Ei();return zn!==null?S5(t,zn,n,e):(t.baseState=n,[n,t.queue.dispatch])},useMemoCache:KM,useCacheRefresh:H5};W5.useEffectEvent=w5;function pT(n,e,t,i){e=n.memoizedState,t=t(i,e),t=t==null?e:ni({},e,t),n.memoizedState=t,n.lanes===0&&(n.updateQueue.baseState=t)}var W3={enqueueSetState:function(n,e,t){n=n._reactInternals;var i=Na(),r=ac(i);r.payload=e,t!=null&&(r.callback=t),e=sc(n,r,i),e!==null&&($r(e,n,i),wm(e,n,i))},enqueueReplaceState:function(n,e,t){n=n._reactInternals;var i=Na(),r=ac(i);r.tag=1,r.payload=e,t!=null&&(r.callback=t),e=sc(n,r,i),e!==null&&($r(e,n,i),wm(e,n,i))},enqueueForceUpdate:function(n,e){n=n._reactInternals;var t=Na(),i=ac(t);i.tag=2,e!=null&&(i.callback=e),e=sc(n,i,t),e!==null&&($r(e,n,t),wm(e,n,t))}};function LC(n,e,t,i,r,a,s){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(i,a,s):e.prototype&&e.prototype.isPureReactComponent?!$m(t,i)||!$m(r,a):!0}function IC(n,e,t,i){n=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(t,i),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(t,i),e.state!==n&&W3.enqueueReplaceState(e,e.state,null)}function qu(n,e){var t=e;if("ref"in e){t={};for(var i in e)i!=="ref"&&(t[i]=e[i])}if(n=n.defaultProps){t===e&&(t=ni({},t));for(var r in n)t[r]===void 0&&(t[r]=n[r])}return t}function X5(n){z_(n)}function Y5(n){console.error(n)}function q5(n){z_(n)}function Y_(n,e){try{var t=n.onUncaughtError;t(e.value,{componentStack:e.stack})}catch(i){setTimeout(function(){throw i})}}function UC(n,e,t){try{var i=n.onCaughtError;i(t.value,{componentStack:t.stack,errorBoundary:e.tag===1?e.stateNode:null})}catch(r){setTimeout(function(){throw r})}}function X3(n,e,t){return t=ac(t),t.tag=3,t.payload={element:null},t.callback=function(){Y_(n,e)},t}function j5(n){return n=ac(n),n.tag=3,n}function Z5(n,e,t,i){var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var a=i.value;n.payload=function(){return r(a)},n.callback=function(){UC(e,t,i)}}var s=t.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){UC(e,t,i),typeof r!="function"&&(oc===null?oc=new Set([this]):oc.add(this));var o=i.stack;this.componentDidCatch(i.value,{componentStack:o!==null?o:""})})}function mH(n,e,t,i,r){if(t.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(e=t.alternate,e!==null&&kd(e,t,r,!0),t=Ia.current,t!==null){switch(t.tag){case 31:case 13:return is===null?Q_():t.alternate===null&&_i===0&&(_i=3),t.flags&=-257,t.flags|=65536,t.lanes=r,i===G_?t.flags|=16384:(e=t.updateQueue,e===null?t.updateQueue=new Set([i]):e.add(i),bT(n,i,r)),!1;case 22:return t.flags|=65536,i===G_?t.flags|=16384:(e=t.updateQueue,e===null?(e={transitions:null,markerInstances:null,retryQueue:new Set([i])},t.updateQueue=e):(t=e.retryQueue,t===null?e.retryQueue=new Set([i]):t.add(i)),bT(n,i,r)),!1}throw Error(Ue(435,t.tag))}return bT(n,i,r),Q_(),!1}if(un)return e=Ia.current,e!==null?(!(e.flags&65536)&&(e.flags|=256),e.flags|=65536,e.lanes=r,i!==O3&&(n=Error(Ue(422),{cause:i}),t0(es(n,t)))):(i!==O3&&(e=Error(Ue(423),{cause:i}),t0(es(e,t))),n=n.current.alternate,n.flags|=65536,r&=-r,n.lanes|=r,i=es(i,t),r=X3(n.stateNode,i,r),fT(n,r),_i!==4&&(_i=2)),!1;var a=Error(Ue(520),{cause:i});if(a=es(a,t),Lm===null?Lm=[a]:Lm.push(a),_i!==4&&(_i=2),e===null)return!0;i=es(i,t),t=e;do{switch(t.tag){case 3:return t.flags|=65536,n=r&-r,t.lanes|=n,n=X3(t.stateNode,i,n),fT(t,n),!1;case 1:if(e=t.type,a=t.stateNode,(t.flags&128)===0&&(typeof e.getDerivedStateFromError=="function"||a!==null&&typeof a.componentDidCatch=="function"&&(oc===null||!oc.has(a))))return t.flags|=65536,r&=-r,t.lanes|=r,r=j5(r),Z5(r,n,t,i),fT(t,r),!1}t=t.return}while(t!==null);return!1}var rb=Error(Ue(461)),Li=!1;function sr(n,e,t,i){e.child=n===null?c5(e,null,t,i):Xu(e,n.child,t,i)}function PC(n,e,t,i,r){t=t.render;var a=e.ref;if("ref"in i){var s={};for(var o in i)o!=="ref"&&(s[o]=i[o])}else s=i;return Wu(e),i=YM(n,e,t,s,a,r),o=qM(),n!==null&&!Li?(jM(n,e,r),al(n,e,r)):(un&&o&&BM(e),e.flags|=1,sr(n,e,i,r),e.child)}function zC(n,e,t,i,r){if(n===null){var a=t.type;return typeof a=="function"&&!zM(a)&&a.defaultProps===void 0&&t.compare===null?(e.tag=15,e.type=a,K5(n,e,a,i,r)):(n=u_(t.type,null,i,e,e.mode,r),n.ref=e.ref,n.return=e,e.child=n)}if(a=n.child,!ab(n,r)){var s=a.memoizedProps;if(t=t.compare,t=t!==null?t:$m,t(s,i)&&n.ref===e.ref)return al(n,e,r)}return e.flags|=1,n=Qo(a,i),n.ref=e.ref,n.return=e,e.child=n}function K5(n,e,t,i,r){if(n!==null){var a=n.memoizedProps;if($m(a,i)&&n.ref===e.ref)if(Li=!1,e.pendingProps=i=a,ab(n,r))n.flags&131072&&(Li=!0);else return e.lanes=n.lanes,al(n,e,r)}return Y3(n,e,t,i,r)}function Q5(n,e,t,i){var r=i.children,a=n!==null?n.memoizedState:null;if(n===null&&e.stateNode===null&&(e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if(e.flags&128){if(a=a!==null?a.baseLanes|t:t,n!==null){for(i=e.child=n.child,r=0;i!==null;)r=r|i.lanes|i.childLanes,i=i.sibling;i=r&~a}else i=0,e.child=null;return BC(n,e,a,t,i)}if(t&536870912)e.memoizedState={baseLanes:0,cachePool:null},n!==null&&h_(e,a!==null?a.cachePool:null),a!==null?AC(e,a):H3(),f5(e);else return i=e.lanes=536870912,BC(n,e,a!==null?a.baseLanes|t:t,t,i)}else a!==null?(h_(e,a.cachePool),AC(e,a),Yl(),e.memoizedState=null):(n!==null&&h_(e,null),H3(),Yl());return sr(n,e,r,t),e.child}function fm(n,e){return n!==null&&n.tag===22||e.stateNode!==null||(e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),e.sibling}function BC(n,e,t,i,r){var a=GM();return a=a===null?null:{parent:Oi._currentValue,pool:a},e.memoizedState={baseLanes:t,cachePool:a},n!==null&&h_(e,null),H3(),f5(e),n!==null&&kd(n,e,i,!0),e.childLanes=r,null}function p_(n,e){return e=q_({mode:e.mode,children:e.children},n.mode),e.ref=n.ref,n.child=e,e.return=n,e}function HC(n,e,t){return Xu(e,n.child,null,t),n=p_(e,e.pendingProps),n.flags|=2,Ea(e),e.memoizedState=null,n}function gH(n,e,t){var i=e.pendingProps,r=(e.flags&128)!==0;if(e.flags&=-129,n===null){if(un){if(i.mode==="hidden")return n=p_(e,i),e.lanes=536870912,fm(null,n);if(F3(e),(n=Jn)?(n=kI(n,ts),n=n!==null&&n.data==="&"?n:null,n!==null&&(e.memoizedState={dehydrated:n,treeContext:pc!==null?{id:eo,overflow:to}:null,retryLane:536870912,hydrationErrors:null},t=n5(n),t.return=e,e.child=t,lr=e,Jn=null)):n=null,n===null)throw mc(e);return e.lanes=536870912,null}return p_(e,i)}var a=n.memoizedState;if(a!==null){var s=a.dehydrated;if(F3(e),r)if(e.flags&256)e.flags&=-257,e=HC(n,e,t);else if(e.memoizedState!==null)e.child=n.child,e.flags|=128,e=null;else throw Error(Ue(558));else if(Li||kd(n,e,t,!1),r=(t&n.childLanes)!==0,Li||r){if(i=Gn,i!==null&&(s=RL(i,t),s!==0&&s!==a.retryLane))throw a.retryLane=s,uh(n,s),$r(i,n,s),rb;Q_(),e=HC(n,e,t)}else n=a.treeContext,Jn=rs(s.nextSibling),lr=e,un=!0,rc=null,ts=!1,n!==null&&r5(e,n),e=p_(e,i),e.flags|=4096;return e}return n=Qo(n.child,{mode:i.mode,children:i.children}),n.ref=e.ref,e.child=n,n.return=e,n}function m_(n,e){var t=e.ref;if(t===null)n!==null&&n.ref!==null&&(e.flags|=4194816);else{if(typeof t!="function"&&typeof t!="object")throw Error(Ue(284));(n===null||n.ref!==t)&&(e.flags|=4194816)}}function Y3(n,e,t,i,r){return Wu(e),t=YM(n,e,t,i,void 0,r),i=qM(),n!==null&&!Li?(jM(n,e,r),al(n,e,r)):(un&&i&&BM(e),e.flags|=1,sr(n,e,t,r),e.child)}function FC(n,e,t,i,r,a){return Wu(e),e.updateQueue=null,t=p5(e,i,t,r),d5(n),i=qM(),n!==null&&!Li?(jM(n,e,a),al(n,e,a)):(un&&i&&BM(e),e.flags|=1,sr(n,e,t,a),e.child)}function GC(n,e,t,i,r){if(Wu(e),e.stateNode===null){var a=Vf,s=t.contextType;typeof s=="object"&&s!==null&&(a=ur(s)),a=new t(i,a),e.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=W3,e.stateNode=a,a._reactInternals=e,a=e.stateNode,a.props=i,a.state=e.memoizedState,a.refs={},kM(e),s=t.contextType,a.context=typeof s=="object"&&s!==null?ur(s):Vf,a.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(pT(e,t,s,i),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(s=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),s!==a.state&&W3.enqueueReplaceState(a,a.state,null),Cm(e,i,a,r),Rm(),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308),i=!0}else if(n===null){a=e.stateNode;var o=e.memoizedProps,l=qu(t,o);a.props=l;var h=a.context,f=t.contextType;s=Vf,typeof f=="object"&&f!==null&&(s=ur(f));var d=t.getDerivedStateFromProps;f=typeof d=="function"||typeof a.getSnapshotBeforeUpdate=="function",o=e.pendingProps!==o,f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o||h!==s)&&IC(e,a,i,s),kl=!1;var p=e.memoizedState;a.state=p,Cm(e,i,a,r),Rm(),h=e.memoizedState,o||p!==h||kl?(typeof d=="function"&&(pT(e,t,d,i),h=e.memoizedState),(l=kl||LC(e,t,l,i,p,h,s))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(e.flags|=4194308)):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=i,e.memoizedState=h),a.props=i,a.state=h,a.context=s,i=l):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),i=!1)}else{a=e.stateNode,z3(n,e),s=e.memoizedProps,f=qu(t,s),a.props=f,d=e.pendingProps,p=a.context,h=t.contextType,l=Vf,typeof h=="object"&&h!==null&&(l=ur(h)),o=t.getDerivedStateFromProps,(h=typeof o=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(s!==d||p!==l)&&IC(e,a,i,l),kl=!1,p=e.memoizedState,a.state=p,Cm(e,i,a,r),Rm();var g=e.memoizedState;s!==d||p!==g||kl||n!==null&&n.dependencies!==null&&F_(n.dependencies)?(typeof o=="function"&&(pT(e,t,o,i),g=e.memoizedState),(f=kl||LC(e,t,f,i,p,g,l)||n!==null&&n.dependencies!==null&&F_(n.dependencies))?(h||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(i,g,l),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(i,g,l)),typeof a.componentDidUpdate=="function"&&(e.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof a.componentDidUpdate!="function"||s===n.memoizedProps&&p===n.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||s===n.memoizedProps&&p===n.memoizedState||(e.flags|=1024),e.memoizedProps=i,e.memoizedState=g),a.props=i,a.state=g,a.context=l,i=f):(typeof a.componentDidUpdate!="function"||s===n.memoizedProps&&p===n.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||s===n.memoizedProps&&p===n.memoizedState||(e.flags|=1024),i=!1)}return a=i,m_(n,e),i=(e.flags&128)!==0,a||i?(a=e.stateNode,t=i&&typeof t.getDerivedStateFromError!="function"?null:a.render(),e.flags|=1,n!==null&&i?(e.child=Xu(e,n.child,null,r),e.child=Xu(e,null,t,r)):sr(n,e,t,r),e.memoizedState=a.state,n=e.child):n=al(n,e,r),n}function VC(n,e,t,i){return ku(),e.flags|=256,sr(n,e,t,i),e.child}var mT={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function gT(n){return{baseLanes:n,cachePool:s5()}}function vT(n,e,t){return n=n!==null?n.childLanes&~t:0,e&&(n|=ba),n}function J5(n,e,t){var i=e.pendingProps,r=!1,a=(e.flags&128)!==0,s;if((s=a)||(s=n!==null&&n.memoizedState===null?!1:(Ti.current&2)!==0),s&&(r=!0,e.flags&=-129),s=(e.flags&32)!==0,e.flags&=-33,n===null){if(un){if(r?Xl(e):Yl(),(n=Jn)?(n=kI(n,ts),n=n!==null&&n.data!=="&"?n:null,n!==null&&(e.memoizedState={dehydrated:n,treeContext:pc!==null?{id:eo,overflow:to}:null,retryLane:536870912,hydrationErrors:null},t=n5(n),t.return=e,e.child=t,lr=e,Jn=null)):n=null,n===null)throw mc(e);return sE(n)?e.lanes=32:e.lanes=536870912,null}var o=i.children;return i=i.fallback,r?(Yl(),r=e.mode,o=q_({mode:"hidden",children:o},r),i=Lu(i,r,t,null),o.return=e,i.return=e,o.sibling=i,e.child=o,i=e.child,i.memoizedState=gT(t),i.childLanes=vT(n,s,t),e.memoizedState=mT,fm(null,i)):(Xl(e),q3(e,o))}var l=n.memoizedState;if(l!==null&&(o=l.dehydrated,o!==null)){if(a)e.flags&256?(Xl(e),e.flags&=-257,e=_T(n,e,t)):e.memoizedState!==null?(Yl(),e.child=n.child,e.flags|=128,e=null):(Yl(),o=i.fallback,r=e.mode,i=q_({mode:"visible",children:i.children},r),o=Lu(o,r,t,null),o.flags|=2,i.return=e,o.return=e,i.sibling=o,e.child=i,Xu(e,n.child,null,t),i=e.child,i.memoizedState=gT(t),i.childLanes=vT(n,s,t),e.memoizedState=mT,e=fm(null,i));else if(Xl(e),sE(o)){if(s=o.nextSibling&&o.nextSibling.dataset,s)var h=s.dgst;s=h,i=Error(Ue(419)),i.stack="",i.digest=s,t0({value:i,source:null,stack:null}),e=_T(n,e,t)}else if(Li||kd(n,e,t,!1),s=(t&n.childLanes)!==0,Li||s){if(s=Gn,s!==null&&(i=RL(s,t),i!==0&&i!==l.retryLane))throw l.retryLane=i,uh(n,i),$r(s,n,i),rb;aE(o)||Q_(),e=_T(n,e,t)}else aE(o)?(e.flags|=192,e.child=n.child,e=null):(n=l.treeContext,Jn=rs(o.nextSibling),lr=e,un=!0,rc=null,ts=!1,n!==null&&r5(e,n),e=q3(e,i.children),e.flags|=4096);return e}return r?(Yl(),o=i.fallback,r=e.mode,l=n.child,h=l.sibling,i=Qo(l,{mode:"hidden",children:i.children}),i.subtreeFlags=l.subtreeFlags&65011712,h!==null?o=Qo(h,o):(o=Lu(o,r,t,null),o.flags|=2),o.return=e,i.return=e,i.sibling=o,e.child=i,fm(null,i),i=e.child,o=n.child.memoizedState,o===null?o=gT(t):(r=o.cachePool,r!==null?(l=Oi._currentValue,r=r.parent!==l?{parent:l,pool:l}:r):r=s5(),o={baseLanes:o.baseLanes|t,cachePool:r}),i.memoizedState=o,i.childLanes=vT(n,s,t),e.memoizedState=mT,fm(n.child,i)):(Xl(e),t=n.child,n=t.sibling,t=Qo(t,{mode:"visible",children:i.children}),t.return=e,t.sibling=null,n!==null&&(s=e.deletions,s===null?(e.deletions=[n],e.flags|=16):s.push(n)),e.child=t,e.memoizedState=null,t)}function q3(n,e){return e=q_({mode:"visible",children:e},n.mode),e.return=n,n.child=e}function q_(n,e){return n=Ma(22,n,null,e),n.lanes=0,n}function _T(n,e,t){return Xu(e,n.child,null,t),n=q3(e,e.pendingProps.children),n.flags|=2,e.memoizedState=null,n}function kC(n,e,t){n.lanes|=e;var i=n.alternate;i!==null&&(i.lanes|=e),I3(n.return,e,t)}function xT(n,e,t,i,r,a){var s=n.memoizedState;s===null?n.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:i,tail:t,tailMode:r,treeForkCount:a}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=t,s.tailMode=r,s.treeForkCount=a)}function $5(n,e,t){var i=e.pendingProps,r=i.revealOrder,a=i.tail;i=i.children;var s=Ti.current,o=(s&2)!==0;if(o?(s=s&1|2,e.flags|=128):s&=1,qn(Ti,s),sr(n,e,i,t),i=un?e0:0,!o&&n!==null&&n.flags&128)e:for(n=e.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&kC(n,t,e);else if(n.tag===19)kC(n,t,e);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(r){case"forwards":for(t=e.child,r=null;t!==null;)n=t.alternate,n!==null&&k_(n)===null&&(r=t),t=t.sibling;t=r,t===null?(r=e.child,e.child=null):(r=t.sibling,t.sibling=null),xT(e,!1,r,t,a,i);break;case"backwards":case"unstable_legacy-backwards":for(t=null,r=e.child,e.child=null;r!==null;){if(n=r.alternate,n!==null&&k_(n)===null){e.child=r;break}n=r.sibling,r.sibling=t,t=r,r=n}xT(e,!0,t,null,a,i);break;case"together":xT(e,!1,null,null,void 0,i);break;default:e.memoizedState=null}return e.child}function al(n,e,t){if(n!==null&&(e.dependencies=n.dependencies),vc|=e.lanes,!(t&e.childLanes))if(n!==null){if(kd(n,e,t,!1),(t&e.childLanes)===0)return null}else return null;if(n!==null&&e.child!==n.child)throw Error(Ue(153));if(e.child!==null){for(n=e.child,t=Qo(n,n.pendingProps),e.child=t,t.return=e;n.sibling!==null;)n=n.sibling,t=t.sibling=Qo(n,n.pendingProps),t.return=e;t.sibling=null}return e.child}function ab(n,e){return n.lanes&e?!0:(n=n.dependencies,!!(n!==null&&F_(n)))}function vH(n,e,t){switch(e.tag){case 3:L_(e,e.stateNode.containerInfo),Wl(e,Oi,n.memoizedState.cache),ku();break;case 27:case 5:S3(e);break;case 4:L_(e,e.stateNode.containerInfo);break;case 10:Wl(e,e.type,e.memoizedProps.value);break;case 31:if(e.memoizedState!==null)return e.flags|=128,F3(e),null;break;case 13:var i=e.memoizedState;if(i!==null)return i.dehydrated!==null?(Xl(e),e.flags|=128,null):t&e.child.childLanes?J5(n,e,t):(Xl(e),n=al(n,e,t),n!==null?n.sibling:null);Xl(e);break;case 19:var r=(n.flags&128)!==0;if(i=(t&e.childLanes)!==0,i||(kd(n,e,t,!1),i=(t&e.childLanes)!==0),r){if(i)return $5(n,e,t);e.flags|=128}if(r=e.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),qn(Ti,Ti.current),i)break;return null;case 22:return e.lanes=0,Q5(n,e,t,e.pendingProps);case 24:Wl(e,Oi,n.memoizedState.cache)}return al(n,e,t)}function eI(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps)Li=!0;else{if(!ab(n,t)&&!(e.flags&128))return Li=!1,vH(n,e,t);Li=!!(n.flags&131072)}else Li=!1,un&&e.flags&1048576&&i5(e,e0,e.index);switch(e.lanes=0,e.tag){case 16:e:{var i=e.pendingProps;if(n=vu(e.elementType),e.type=n,typeof n=="function")zM(n)?(i=qu(n,i),e.tag=1,e=GC(null,e,n,i,t)):(e.tag=0,e=Y3(null,e,n,i,t));else{if(n!=null){var r=n.$$typeof;if(r===EM){e.tag=11,e=PC(null,e,n,i,t);break e}else if(r===MM){e.tag=14,e=zC(null,e,n,i,t);break e}}throw e=x3(n)||n,Error(Ue(306,e,""))}}return e;case 0:return Y3(n,e,e.type,e.pendingProps,t);case 1:return i=e.type,r=qu(i,e.pendingProps),GC(n,e,i,r,t);case 3:e:{if(L_(e,e.stateNode.containerInfo),n===null)throw Error(Ue(387));i=e.pendingProps;var a=e.memoizedState;r=a.element,z3(n,e),Cm(e,i,null,t);var s=e.memoizedState;if(i=s.cache,Wl(e,Oi,i),i!==a.cache&&U3(e,[Oi],t,!0),Rm(),i=s.element,a.isDehydrated)if(a={element:i,isDehydrated:!1,cache:s.cache},e.updateQueue.baseState=a,e.memoizedState=a,e.flags&256){e=VC(n,e,i,t);break e}else if(i!==r){r=es(Error(Ue(424)),e),t0(r),e=VC(n,e,i,t);break e}else{switch(n=e.stateNode.containerInfo,n.nodeType){case 9:n=n.body;break;default:n=n.nodeName==="HTML"?n.ownerDocument.body:n}for(Jn=rs(n.firstChild),lr=e,un=!0,rc=null,ts=!0,t=c5(e,null,i,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling}else{if(ku(),i===r){e=al(n,e,t);break e}sr(n,e,i,t)}e=e.child}return e;case 26:return m_(n,e),n===null?(t=c4(e.type,null,e.pendingProps,null))?e.memoizedState=t:un||(t=e.type,n=e.pendingProps,i=tx(ic.current).createElement(t),i[or]=e,i[ta]=n,hr(i,t,n),$i(i),e.stateNode=i):e.memoizedState=c4(e.type,n.memoizedProps,e.pendingProps,n.memoizedState),null;case 27:return S3(e),n===null&&un&&(i=e.stateNode=WI(e.type,e.pendingProps,ic.current),lr=e,ts=!0,r=Jn,Ec(e.type)?(oE=r,Jn=rs(i.firstChild)):Jn=r),sr(n,e,e.pendingProps.children,t),m_(n,e),n===null&&(e.flags|=4194304),e.child;case 5:return n===null&&un&&((r=i=Jn)&&(i=qH(i,e.type,e.pendingProps,ts),i!==null?(e.stateNode=i,lr=e,Jn=rs(i.firstChild),ts=!1,r=!0):r=!1),r||mc(e)),S3(e),r=e.type,a=e.pendingProps,s=n!==null?n.memoizedProps:null,i=a.children,iE(r,a)?i=null:s!==null&&iE(r,s)&&(e.flags|=32),e.memoizedState!==null&&(r=YM(n,e,lH,null,null,t),o0._currentValue=r),m_(n,e),sr(n,e,i,t),e.child;case 6:return n===null&&un&&((n=t=Jn)&&(t=jH(t,e.pendingProps,ts),t!==null?(e.stateNode=t,lr=e,Jn=null,n=!0):n=!1),n||mc(e)),null;case 13:return J5(n,e,t);case 4:return L_(e,e.stateNode.containerInfo),i=e.pendingProps,n===null?e.child=Xu(e,null,i,t):sr(n,e,i,t),e.child;case 11:return PC(n,e,e.type,e.pendingProps,t);case 7:return sr(n,e,e.pendingProps,t),e.child;case 8:return sr(n,e,e.pendingProps.children,t),e.child;case 12:return sr(n,e,e.pendingProps.children,t),e.child;case 10:return i=e.pendingProps,Wl(e,e.type,i.value),sr(n,e,i.children,t),e.child;case 9:return r=e.type._context,i=e.pendingProps.children,Wu(e),r=ur(r),i=i(r),e.flags|=1,sr(n,e,i,t),e.child;case 14:return zC(n,e,e.type,e.pendingProps,t);case 15:return K5(n,e,e.type,e.pendingProps,t);case 19:return $5(n,e,t);case 31:return gH(n,e,t);case 22:return Q5(n,e,t,e.pendingProps);case 24:return Wu(e),i=ur(Oi),n===null?(r=GM(),r===null&&(r=Gn,a=FM(),r.pooledCache=a,a.refCount++,a!==null&&(r.pooledCacheLanes|=t),r=a),e.memoizedState={parent:i,cache:r},kM(e),Wl(e,Oi,r)):(n.lanes&t&&(z3(n,e),Cm(e,null,null,t),Rm()),r=n.memoizedState,a=e.memoizedState,r.parent!==i?(r={parent:i,cache:i},e.memoizedState=r,e.lanes===0&&(e.memoizedState=e.updateQueue.baseState=r),Wl(e,Oi,i)):(i=a.cache,Wl(e,Oi,i),i!==r.cache&&U3(e,[Oi],t,!0))),sr(n,e,e.pendingProps.children,t),e.child;case 29:throw e.pendingProps}throw Error(Ue(156,e.tag))}function Ao(n){n.flags|=4}function yT(n,e,t,i,r){if((e=(n.mode&32)!==0)&&(e=!1),e){if(n.flags|=16777216,(r&335544128)===r)if(n.stateNode.complete)n.flags|=8192;else if(MI())n.flags|=8192;else throw Uu=G_,VM}else n.flags&=-16777217}function WC(n,e){if(e.type!=="stylesheet"||e.state.loading&4)n.flags&=-16777217;else if(n.flags|=16777216,!qI(e))if(MI())n.flags|=8192;else throw Uu=G_,VM}function Xg(n,e){e!==null&&(n.flags|=4),n.flags&16384&&(e=n.tag!==22?bL():536870912,n.lanes|=e,vd|=e)}function Ip(n,e){if(!un)switch(n.tailMode){case"hidden":e=n.tail;for(var t=null;e!==null;)e.alternate!==null&&(t=e),e=e.sibling;t===null?n.tail=null:t.sibling=null;break;case"collapsed":t=n.tail;for(var i=null;t!==null;)t.alternate!==null&&(i=t),t=t.sibling;i===null?e||n.tail===null?n.tail=null:n.tail.sibling=null:i.sibling=null}}function Qn(n){var e=n.alternate!==null&&n.alternate.child===n.child,t=0,i=0;if(e)for(var r=n.child;r!==null;)t|=r.lanes|r.childLanes,i|=r.subtreeFlags&65011712,i|=r.flags&65011712,r.return=n,r=r.sibling;else for(r=n.child;r!==null;)t|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=n,r=r.sibling;return n.subtreeFlags|=i,n.childLanes=t,e}function _H(n,e,t){var i=e.pendingProps;switch(HM(e),e.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Qn(e),null;case 1:return Qn(e),null;case 3:return t=e.stateNode,i=null,n!==null&&(i=n.memoizedState.cache),e.memoizedState.cache!==i&&(e.flags|=2048),Jo(Oi),hd(),t.pendingContext&&(t.context=t.pendingContext,t.pendingContext=null),(n===null||n.child===null)&&(Yh(e)?Ao(e):n===null||n.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,hT())),Qn(e),null;case 26:var r=e.type,a=e.memoizedState;return n===null?(Ao(e),a!==null?(Qn(e),WC(e,a)):(Qn(e),yT(e,r,null,i,t))):a?a!==n.memoizedState?(Ao(e),Qn(e),WC(e,a)):(Qn(e),e.flags&=-16777217):(n=n.memoizedProps,n!==i&&Ao(e),Qn(e),yT(e,r,n,i,t)),null;case 27:if(I_(e),t=ic.current,r=e.type,n!==null&&e.stateNode!=null)n.memoizedProps!==i&&Ao(e);else{if(!i){if(e.stateNode===null)throw Error(Ue(166));return Qn(e),null}n=ro.current,Yh(e)?xC(e):(n=WI(r,i,t),e.stateNode=n,Ao(e))}return Qn(e),null;case 5:if(I_(e),r=e.type,n!==null&&e.stateNode!=null)n.memoizedProps!==i&&Ao(e);else{if(!i){if(e.stateNode===null)throw Error(Ue(166));return Qn(e),null}if(a=ro.current,Yh(e))xC(e);else{var s=tx(ic.current);switch(a){case 1:a=s.createElementNS("http://www.w3.org/2000/svg",r);break;case 2:a=s.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;default:switch(r){case"svg":a=s.createElementNS("http://www.w3.org/2000/svg",r);break;case"math":a=s.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;case"script":a=s.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild);break;case"select":a=typeof i.is=="string"?s.createElement("select",{is:i.is}):s.createElement("select"),i.multiple?a.multiple=!0:i.size&&(a.size=i.size);break;default:a=typeof i.is=="string"?s.createElement(r,{is:i.is}):s.createElement(r)}}a[or]=e,a[ta]=i;e:for(s=e.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===e)break e;for(;s.sibling===null;){if(s.return===null||s.return===e)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}e.stateNode=a;e:switch(hr(a,r,i),r){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Ao(e)}}return Qn(e),yT(e,e.type,n===null?null:n.memoizedProps,e.pendingProps,t),null;case 6:if(n&&e.stateNode!=null)n.memoizedProps!==i&&Ao(e);else{if(typeof i!="string"&&e.stateNode===null)throw Error(Ue(166));if(n=ic.current,Yh(e)){if(n=e.stateNode,t=e.memoizedProps,i=null,r=lr,r!==null)switch(r.tag){case 27:case 5:i=r.memoizedProps}n[or]=e,n=!!(n.nodeValue===t||i!==null&&i.suppressHydrationWarning===!0||FI(n.nodeValue,t)),n||mc(e,!0)}else n=tx(n).createTextNode(i),n[or]=e,e.stateNode=n}return Qn(e),null;case 31:if(t=e.memoizedState,n===null||n.memoizedState!==null){if(i=Yh(e),t!==null){if(n===null){if(!i)throw Error(Ue(318));if(n=e.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(Ue(557));n[or]=e}else ku(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Qn(e),n=!1}else t=hT(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=t),n=!0;if(!n)return e.flags&256?(Ea(e),e):(Ea(e),null);if(e.flags&128)throw Error(Ue(558))}return Qn(e),null;case 13:if(i=e.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(r=Yh(e),i!==null&&i.dehydrated!==null){if(n===null){if(!r)throw Error(Ue(318));if(r=e.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(Ue(317));r[or]=e}else ku(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Qn(e),r=!1}else r=hT(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=r),r=!0;if(!r)return e.flags&256?(Ea(e),e):(Ea(e),null)}return Ea(e),e.flags&128?(e.lanes=t,e):(t=i!==null,n=n!==null&&n.memoizedState!==null,t&&(i=e.child,r=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(r=i.alternate.memoizedState.cachePool.pool),a=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),a!==r&&(i.flags|=2048)),t!==n&&t&&(e.child.flags|=8192),Xg(e,e.updateQueue),Qn(e),null);case 4:return hd(),n===null&&fb(e.stateNode.containerInfo),Qn(e),null;case 10:return Jo(e.type),Qn(e),null;case 19:if(er(Ti),i=e.memoizedState,i===null)return Qn(e),null;if(r=(e.flags&128)!==0,a=i.rendering,a===null)if(r)Ip(i,!1);else{if(_i!==0||n!==null&&n.flags&128)for(n=e.child;n!==null;){if(a=k_(n),a!==null){for(e.flags|=128,Ip(i,!1),n=a.updateQueue,e.updateQueue=n,Xg(e,n),e.subtreeFlags=0,n=t,t=e.child;t!==null;)t5(t,n),t=t.sibling;return qn(Ti,Ti.current&1|2),un&&Vo(e,i.treeForkCount),e.child}n=n.sibling}i.tail!==null&&Ra()>Z_&&(e.flags|=128,r=!0,Ip(i,!1),e.lanes=4194304)}else{if(!r)if(n=k_(a),n!==null){if(e.flags|=128,r=!0,n=n.updateQueue,e.updateQueue=n,Xg(e,n),Ip(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!un)return Qn(e),null}else 2*Ra()-i.renderingStartTime>Z_&&t!==536870912&&(e.flags|=128,r=!0,Ip(i,!1),e.lanes=4194304);i.isBackwards?(a.sibling=e.child,e.child=a):(n=i.last,n!==null?n.sibling=a:e.child=a,i.last=a)}return i.tail!==null?(n=i.tail,i.rendering=n,i.tail=n.sibling,i.renderingStartTime=Ra(),n.sibling=null,t=Ti.current,qn(Ti,r?t&1|2:t&1),un&&Vo(e,i.treeForkCount),n):(Qn(e),null);case 22:case 23:return Ea(e),WM(),i=e.memoizedState!==null,n!==null?n.memoizedState!==null!==i&&(e.flags|=8192):i&&(e.flags|=8192),i?t&536870912&&!(e.flags&128)&&(Qn(e),e.subtreeFlags&6&&(e.flags|=8192)):Qn(e),t=e.updateQueue,t!==null&&Xg(e,t.retryQueue),t=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(t=n.memoizedState.cachePool.pool),i=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),i!==t&&(e.flags|=2048),n!==null&&er(Iu),null;case 24:return t=null,n!==null&&(t=n.memoizedState.cache),e.memoizedState.cache!==t&&(e.flags|=2048),Jo(Oi),Qn(e),null;case 25:return null;case 30:return null}throw Error(Ue(156,e.tag))}function xH(n,e){switch(HM(e),e.tag){case 1:return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return Jo(Oi),hd(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 26:case 27:case 5:return I_(e),null;case 31:if(e.memoizedState!==null){if(Ea(e),e.alternate===null)throw Error(Ue(340));ku()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 13:if(Ea(e),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(Ue(340));ku()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return er(Ti),null;case 4:return hd(),null;case 10:return Jo(e.type),null;case 22:case 23:return Ea(e),WM(),n!==null&&er(Iu),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 24:return Jo(Oi),null;case 25:return null;default:return null}}function tI(n,e){switch(HM(e),e.tag){case 3:Jo(Oi),hd();break;case 26:case 27:case 5:I_(e);break;case 4:hd();break;case 31:e.memoizedState!==null&&Ea(e);break;case 13:Ea(e);break;case 19:er(Ti);break;case 10:Jo(e.type);break;case 22:case 23:Ea(e),WM(),n!==null&&er(Iu);break;case 24:Jo(Oi)}}function I0(n,e){try{var t=e.updateQueue,i=t!==null?t.lastEffect:null;if(i!==null){var r=i.next;t=r;do{if((t.tag&n)===n){i=void 0;var a=t.create,s=t.inst;i=a(),s.destroy=i}t=t.next}while(t!==r)}}catch(o){Dn(e,e.return,o)}}function gc(n,e,t){try{var i=e.updateQueue,r=i!==null?i.lastEffect:null;if(r!==null){var a=r.next;i=a;do{if((i.tag&n)===n){var s=i.inst,o=s.destroy;if(o!==void 0){s.destroy=void 0,r=e;var l=t,h=o;try{h()}catch(f){Dn(r,l,f)}}}i=i.next}while(i!==a)}}catch(f){Dn(e,e.return,f)}}function nI(n){var e=n.updateQueue;if(e!==null){var t=n.stateNode;try{h5(e,t)}catch(i){Dn(n,n.return,i)}}}function iI(n,e,t){t.props=qu(n.type,n.memoizedProps),t.state=n.memoizedState;try{t.componentWillUnmount()}catch(i){Dn(n,e,i)}}function Nm(n,e){try{var t=n.ref;if(t!==null){switch(n.tag){case 26:case 27:case 5:var i=n.stateNode;break;case 30:i=n.stateNode;break;default:i=n.stateNode}typeof t=="function"?n.refCleanup=t(i):t.current=i}}catch(r){Dn(n,e,r)}}function no(n,e){var t=n.ref,i=n.refCleanup;if(t!==null)if(typeof i=="function")try{i()}catch(r){Dn(n,e,r)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof t=="function")try{t(null)}catch(r){Dn(n,e,r)}else t.current=null}function rI(n){var e=n.type,t=n.memoizedProps,i=n.stateNode;try{e:switch(e){case"button":case"input":case"select":case"textarea":t.autoFocus&&i.focus();break e;case"img":t.src?i.src=t.src:t.srcSet&&(i.srcset=t.srcSet)}}catch(r){Dn(n,n.return,r)}}function ST(n,e,t){try{var i=n.stateNode;GH(i,n.type,t,e),i[ta]=e}catch(r){Dn(n,n.return,r)}}function aI(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&Ec(n.type)||n.tag===4}function TT(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||aI(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&Ec(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function j3(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t).insertBefore(n,e):(e=t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,e.appendChild(n),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=Zo));else if(i!==4&&(i===27&&Ec(n.type)&&(t=n.stateNode,e=null),n=n.child,n!==null))for(j3(n,e,t),n=n.sibling;n!==null;)j3(n,e,t),n=n.sibling}function j_(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(i!==4&&(i===27&&Ec(n.type)&&(t=n.stateNode),n=n.child,n!==null))for(j_(n,e,t),n=n.sibling;n!==null;)j_(n,e,t),n=n.sibling}function sI(n){var e=n.stateNode,t=n.memoizedProps;try{for(var i=n.type,r=e.attributes;r.length;)e.removeAttributeNode(r[0]);hr(e,i,t),e[or]=n,e[ta]=t}catch(a){Dn(n,n.return,a)}}var Wo=!1,Di=!1,ET=!1,XC=typeof WeakSet=="function"?WeakSet:Set,Ji=null;function yH(n,e){if(n=n.containerInfo,tE=ax,n=qL(n),IM(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var i=t.getSelection&&t.getSelection();if(i&&i.rangeCount!==0){t=i.anchorNode;var r=i.anchorOffset,a=i.focusNode;i=i.focusOffset;try{t.nodeType,a.nodeType}catch{t=null;break e}var s=0,o=-1,l=-1,h=0,f=0,d=n,p=null;t:for(;;){for(var g;d!==t||r!==0&&d.nodeType!==3||(o=s+r),d!==a||i!==0&&d.nodeType!==3||(l=s+i),d.nodeType===3&&(s+=d.nodeValue.length),(g=d.firstChild)!==null;)p=d,d=g;for(;;){if(d===n)break t;if(p===t&&++h===r&&(o=s),p===a&&++f===i&&(l=s),(g=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=g}t=o===-1||l===-1?null:{start:o,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(nE={focusedElem:n,selectionRange:t},ax=!1,Ji=e;Ji!==null;)if(e=Ji,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,Ji=n;else for(;Ji!==null;){switch(e=Ji,a=e.alternate,n=e.flags,e.tag){case 0:if(n&4&&(n=e.updateQueue,n=n!==null?n.events:null,n!==null))for(t=0;t<n.length;t++)r=n[t],r.ref.impl=r.nextImpl;break;case 11:case 15:break;case 1:if(n&1024&&a!==null){n=void 0,t=e,r=a.memoizedProps,a=a.memoizedState,i=t.stateNode;try{var _=qu(t.type,r);n=i.getSnapshotBeforeUpdate(_,a),i.__reactInternalSnapshotBeforeUpdate=n}catch(T){Dn(t,t.return,T)}}break;case 3:if(n&1024){if(n=e.stateNode.containerInfo,t=n.nodeType,t===9)rE(n);else if(t===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":rE(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(n&1024)throw Error(Ue(163))}if(n=e.sibling,n!==null){n.return=e.return,Ji=n;break}Ji=e.return}}function oI(n,e,t){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Ro(n,t),i&4&&I0(5,t);break;case 1:if(Ro(n,t),i&4)if(n=t.stateNode,e===null)try{n.componentDidMount()}catch(s){Dn(t,t.return,s)}else{var r=qu(t.type,e.memoizedProps);e=e.memoizedState;try{n.componentDidUpdate(r,e,n.__reactInternalSnapshotBeforeUpdate)}catch(s){Dn(t,t.return,s)}}i&64&&nI(t),i&512&&Nm(t,t.return);break;case 3:if(Ro(n,t),i&64&&(n=t.updateQueue,n!==null)){if(e=null,t.child!==null)switch(t.child.tag){case 27:case 5:e=t.child.stateNode;break;case 1:e=t.child.stateNode}try{h5(n,e)}catch(s){Dn(t,t.return,s)}}break;case 27:e===null&&i&4&&sI(t);case 26:case 5:Ro(n,t),e===null&&i&4&&rI(t),i&512&&Nm(t,t.return);break;case 12:Ro(n,t);break;case 31:Ro(n,t),i&4&&uI(n,t);break;case 13:Ro(n,t),i&4&&hI(n,t),i&64&&(n=t.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(t=CH.bind(null,t),ZH(n,t))));break;case 22:if(i=t.memoizedState!==null||Wo,!i){e=e!==null&&e.memoizedState!==null||Di,r=Wo;var a=Di;Wo=i,(Di=e)&&!a?Bo(n,t,(t.subtreeFlags&8772)!==0):Ro(n,t),Wo=r,Di=a}break;case 30:break;default:Ro(n,t)}}function lI(n){var e=n.alternate;e!==null&&(n.alternate=null,lI(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&RM(e)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var ii=null,Kr=!1;function wo(n,e,t){for(t=t.child;t!==null;)cI(n,e,t),t=t.sibling}function cI(n,e,t){if(Ca&&typeof Ca.onCommitFiberUnmount=="function")try{Ca.onCommitFiberUnmount(w0,t)}catch{}switch(t.tag){case 26:Di||no(t,e),wo(n,e,t),t.memoizedState?t.memoizedState.count--:t.stateNode&&(t=t.stateNode,t.parentNode.removeChild(t));break;case 27:Di||no(t,e);var i=ii,r=Kr;Ec(t.type)&&(ii=t.stateNode,Kr=!1),wo(n,e,t),Um(t.stateNode),ii=i,Kr=r;break;case 5:Di||no(t,e);case 6:if(i=ii,r=Kr,ii=null,wo(n,e,t),ii=i,Kr=r,ii!==null)if(Kr)try{(ii.nodeType===9?ii.body:ii.nodeName==="HTML"?ii.ownerDocument.body:ii).removeChild(t.stateNode)}catch(a){Dn(t,e,a)}else try{ii.removeChild(t.stateNode)}catch(a){Dn(t,e,a)}break;case 18:ii!==null&&(Kr?(n=ii,r4(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.stateNode),Sd(n)):r4(ii,t.stateNode));break;case 4:i=ii,r=Kr,ii=t.stateNode.containerInfo,Kr=!0,wo(n,e,t),ii=i,Kr=r;break;case 0:case 11:case 14:case 15:gc(2,t,e),Di||gc(4,t,e),wo(n,e,t);break;case 1:Di||(no(t,e),i=t.stateNode,typeof i.componentWillUnmount=="function"&&iI(t,e,i)),wo(n,e,t);break;case 21:wo(n,e,t);break;case 22:Di=(i=Di)||t.memoizedState!==null,wo(n,e,t),Di=i;break;default:wo(n,e,t)}}function uI(n,e){if(e.memoizedState===null&&(n=e.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{Sd(n)}catch(t){Dn(e,e.return,t)}}}function hI(n,e){if(e.memoizedState===null&&(n=e.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{Sd(n)}catch(t){Dn(e,e.return,t)}}function SH(n){switch(n.tag){case 31:case 13:case 19:var e=n.stateNode;return e===null&&(e=n.stateNode=new XC),e;case 22:return n=n.stateNode,e=n._retryCache,e===null&&(e=n._retryCache=new XC),e;default:throw Error(Ue(435,n.tag))}}function Yg(n,e){var t=SH(n);e.forEach(function(i){if(!t.has(i)){t.add(i);var r=DH.bind(null,n,i);i.then(r,r)}})}function Wr(n,e){var t=e.deletions;if(t!==null)for(var i=0;i<t.length;i++){var r=t[i],a=n,s=e,o=s;e:for(;o!==null;){switch(o.tag){case 27:if(Ec(o.type)){ii=o.stateNode,Kr=!1;break e}break;case 5:ii=o.stateNode,Kr=!1;break e;case 3:case 4:ii=o.stateNode.containerInfo,Kr=!0;break e}o=o.return}if(ii===null)throw Error(Ue(160));cI(a,s,r),ii=null,Kr=!1,a=r.alternate,a!==null&&(a.return=null),r.return=null}if(e.subtreeFlags&13886)for(e=e.child;e!==null;)fI(e,n),e=e.sibling}var bs=null;function fI(n,e){var t=n.alternate,i=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:Wr(e,n),Xr(n),i&4&&(gc(3,n,n.return),I0(3,n),gc(5,n,n.return));break;case 1:Wr(e,n),Xr(n),i&512&&(Di||t===null||no(t,t.return)),i&64&&Wo&&(n=n.updateQueue,n!==null&&(i=n.callbacks,i!==null&&(t=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=t===null?i:t.concat(i))));break;case 26:var r=bs;if(Wr(e,n),Xr(n),i&512&&(Di||t===null||no(t,t.return)),i&4){var a=t!==null?t.memoizedState:null;if(i=n.memoizedState,t===null)if(i===null)if(n.stateNode===null){e:{i=n.type,t=n.memoizedProps,r=r.ownerDocument||r;t:switch(i){case"title":a=r.getElementsByTagName("title")[0],(!a||a[D0]||a[or]||a.namespaceURI==="http://www.w3.org/2000/svg"||a.hasAttribute("itemprop"))&&(a=r.createElement(i),r.head.insertBefore(a,r.querySelector("head > title"))),hr(a,i,t),a[or]=n,$i(a),i=a;break e;case"link":var s=h4("link","href",r).get(i+(t.href||""));if(s){for(var o=0;o<s.length;o++)if(a=s[o],a.getAttribute("href")===(t.href==null||t.href===""?null:t.href)&&a.getAttribute("rel")===(t.rel==null?null:t.rel)&&a.getAttribute("title")===(t.title==null?null:t.title)&&a.getAttribute("crossorigin")===(t.crossOrigin==null?null:t.crossOrigin)){s.splice(o,1);break t}}a=r.createElement(i),hr(a,i,t),r.head.appendChild(a);break;case"meta":if(s=h4("meta","content",r).get(i+(t.content||""))){for(o=0;o<s.length;o++)if(a=s[o],a.getAttribute("content")===(t.content==null?null:""+t.content)&&a.getAttribute("name")===(t.name==null?null:t.name)&&a.getAttribute("property")===(t.property==null?null:t.property)&&a.getAttribute("http-equiv")===(t.httpEquiv==null?null:t.httpEquiv)&&a.getAttribute("charset")===(t.charSet==null?null:t.charSet)){s.splice(o,1);break t}}a=r.createElement(i),hr(a,i,t),r.head.appendChild(a);break;default:throw Error(Ue(468,i))}a[or]=n,$i(a),i=a}n.stateNode=i}else f4(r,n.type,n.stateNode);else n.stateNode=u4(r,i,n.memoizedProps);else a!==i?(a===null?t.stateNode!==null&&(t=t.stateNode,t.parentNode.removeChild(t)):a.count--,i===null?f4(r,n.type,n.stateNode):u4(r,i,n.memoizedProps)):i===null&&n.stateNode!==null&&ST(n,n.memoizedProps,t.memoizedProps)}break;case 27:Wr(e,n),Xr(n),i&512&&(Di||t===null||no(t,t.return)),t!==null&&i&4&&ST(n,n.memoizedProps,t.memoizedProps);break;case 5:if(Wr(e,n),Xr(n),i&512&&(Di||t===null||no(t,t.return)),n.flags&32){r=n.stateNode;try{dd(r,"")}catch(_){Dn(n,n.return,_)}}i&4&&n.stateNode!=null&&(r=n.memoizedProps,ST(n,r,t!==null?t.memoizedProps:r)),i&1024&&(ET=!0);break;case 6:if(Wr(e,n),Xr(n),i&4){if(n.stateNode===null)throw Error(Ue(162));i=n.memoizedProps,t=n.stateNode;try{t.nodeValue=i}catch(_){Dn(n,n.return,_)}}break;case 3:if(__=null,r=bs,bs=nx(e.containerInfo),Wr(e,n),bs=r,Xr(n),i&4&&t!==null&&t.memoizedState.isDehydrated)try{Sd(e.containerInfo)}catch(_){Dn(n,n.return,_)}ET&&(ET=!1,dI(n));break;case 4:i=bs,bs=nx(n.stateNode.containerInfo),Wr(e,n),Xr(n),bs=i;break;case 12:Wr(e,n),Xr(n);break;case 31:Wr(e,n),Xr(n),i&4&&(i=n.updateQueue,i!==null&&(n.updateQueue=null,Yg(n,i)));break;case 13:Wr(e,n),Xr(n),n.child.flags&8192&&n.memoizedState!==null!=(t!==null&&t.memoizedState!==null)&&(C1=Ra()),i&4&&(i=n.updateQueue,i!==null&&(n.updateQueue=null,Yg(n,i)));break;case 22:r=n.memoizedState!==null;var l=t!==null&&t.memoizedState!==null,h=Wo,f=Di;if(Wo=h||r,Di=f||l,Wr(e,n),Di=f,Wo=h,Xr(n),i&8192)e:for(e=n.stateNode,e._visibility=r?e._visibility&-2:e._visibility|1,r&&(t===null||l||Wo||Di||_u(n)),t=null,e=n;;){if(e.tag===5||e.tag===26){if(t===null){l=t=e;try{if(a=l.stateNode,r)s=a.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none";else{o=l.stateNode;var d=l.memoizedProps.style,p=d!=null&&d.hasOwnProperty("display")?d.display:null;o.style.display=p==null||typeof p=="boolean"?"":(""+p).trim()}}catch(_){Dn(l,l.return,_)}}}else if(e.tag===6){if(t===null){l=e;try{l.stateNode.nodeValue=r?"":l.memoizedProps}catch(_){Dn(l,l.return,_)}}}else if(e.tag===18){if(t===null){l=e;try{var g=l.stateNode;r?a4(g,!0):a4(l.stateNode,!1)}catch(_){Dn(l,l.return,_)}}}else if((e.tag!==22&&e.tag!==23||e.memoizedState===null||e===n)&&e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;t===e&&(t=null),e=e.return}t===e&&(t=null),e.sibling.return=e.return,e=e.sibling}i&4&&(i=n.updateQueue,i!==null&&(t=i.retryQueue,t!==null&&(i.retryQueue=null,Yg(n,t))));break;case 19:Wr(e,n),Xr(n),i&4&&(i=n.updateQueue,i!==null&&(n.updateQueue=null,Yg(n,i)));break;case 30:break;case 21:break;default:Wr(e,n),Xr(n)}}function Xr(n){var e=n.flags;if(e&2){try{for(var t,i=n.return;i!==null;){if(aI(i)){t=i;break}i=i.return}if(t==null)throw Error(Ue(160));switch(t.tag){case 27:var r=t.stateNode,a=TT(n);j_(n,a,r);break;case 5:var s=t.stateNode;t.flags&32&&(dd(s,""),t.flags&=-33);var o=TT(n);j_(n,o,s);break;case 3:case 4:var l=t.stateNode.containerInfo,h=TT(n);j3(n,h,l);break;default:throw Error(Ue(161))}}catch(f){Dn(n,n.return,f)}n.flags&=-3}e&4096&&(n.flags&=-4097)}function dI(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var e=n;dI(e),e.tag===5&&e.flags&1024&&e.stateNode.reset(),n=n.sibling}}function Ro(n,e){if(e.subtreeFlags&8772)for(e=e.child;e!==null;)oI(n,e.alternate,e),e=e.sibling}function _u(n){for(n=n.child;n!==null;){var e=n;switch(e.tag){case 0:case 11:case 14:case 15:gc(4,e,e.return),_u(e);break;case 1:no(e,e.return);var t=e.stateNode;typeof t.componentWillUnmount=="function"&&iI(e,e.return,t),_u(e);break;case 27:Um(e.stateNode);case 26:case 5:no(e,e.return),_u(e);break;case 22:e.memoizedState===null&&_u(e);break;case 30:_u(e);break;default:_u(e)}n=n.sibling}}function Bo(n,e,t){for(t=t&&(e.subtreeFlags&8772)!==0,e=e.child;e!==null;){var i=e.alternate,r=n,a=e,s=a.flags;switch(a.tag){case 0:case 11:case 15:Bo(r,a,t),I0(4,a);break;case 1:if(Bo(r,a,t),i=a,r=i.stateNode,typeof r.componentDidMount=="function")try{r.componentDidMount()}catch(h){Dn(i,i.return,h)}if(i=a,r=i.updateQueue,r!==null){var o=i.stateNode;try{var l=r.shared.hiddenCallbacks;if(l!==null)for(r.shared.hiddenCallbacks=null,r=0;r<l.length;r++)u5(l[r],o)}catch(h){Dn(i,i.return,h)}}t&&s&64&&nI(a),Nm(a,a.return);break;case 27:sI(a);case 26:case 5:Bo(r,a,t),t&&i===null&&s&4&&rI(a),Nm(a,a.return);break;case 12:Bo(r,a,t);break;case 31:Bo(r,a,t),t&&s&4&&uI(r,a);break;case 13:Bo(r,a,t),t&&s&4&&hI(r,a);break;case 22:a.memoizedState===null&&Bo(r,a,t),Nm(a,a.return);break;case 30:break;default:Bo(r,a,t)}e=e.sibling}}function sb(n,e){var t=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(t=n.memoizedState.cachePool.pool),n=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),n!==t&&(n!=null&&n.refCount++,t!=null&&O0(t))}function ob(n,e){n=null,e.alternate!==null&&(n=e.alternate.memoizedState.cache),e=e.memoizedState.cache,e!==n&&(e.refCount++,n!=null&&O0(n))}function ms(n,e,t,i){if(e.subtreeFlags&10256)for(e=e.child;e!==null;)pI(n,e,t,i),e=e.sibling}function pI(n,e,t,i){var r=e.flags;switch(e.tag){case 0:case 11:case 15:ms(n,e,t,i),r&2048&&I0(9,e);break;case 1:ms(n,e,t,i);break;case 3:ms(n,e,t,i),r&2048&&(n=null,e.alternate!==null&&(n=e.alternate.memoizedState.cache),e=e.memoizedState.cache,e!==n&&(e.refCount++,n!=null&&O0(n)));break;case 12:if(r&2048){ms(n,e,t,i),n=e.stateNode;try{var a=e.memoizedProps,s=a.id,o=a.onPostCommit;typeof o=="function"&&o(s,e.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(l){Dn(e,e.return,l)}}else ms(n,e,t,i);break;case 31:ms(n,e,t,i);break;case 13:ms(n,e,t,i);break;case 23:break;case 22:a=e.stateNode,s=e.alternate,e.memoizedState!==null?a._visibility&2?ms(n,e,t,i):Om(n,e):a._visibility&2?ms(n,e,t,i):(a._visibility|=2,Df(n,e,t,i,(e.subtreeFlags&10256)!==0||!1)),r&2048&&sb(s,e);break;case 24:ms(n,e,t,i),r&2048&&ob(e.alternate,e);break;default:ms(n,e,t,i)}}function Df(n,e,t,i,r){for(r=r&&((e.subtreeFlags&10256)!==0||!1),e=e.child;e!==null;){var a=n,s=e,o=t,l=i,h=s.flags;switch(s.tag){case 0:case 11:case 15:Df(a,s,o,l,r),I0(8,s);break;case 23:break;case 22:var f=s.stateNode;s.memoizedState!==null?f._visibility&2?Df(a,s,o,l,r):Om(a,s):(f._visibility|=2,Df(a,s,o,l,r)),r&&h&2048&&sb(s.alternate,s);break;case 24:Df(a,s,o,l,r),r&&h&2048&&ob(s.alternate,s);break;default:Df(a,s,o,l,r)}e=e.sibling}}function Om(n,e){if(e.subtreeFlags&10256)for(e=e.child;e!==null;){var t=n,i=e,r=i.flags;switch(i.tag){case 22:Om(t,i),r&2048&&sb(i.alternate,i);break;case 24:Om(t,i),r&2048&&ob(i.alternate,i);break;default:Om(t,i)}e=e.sibling}}var dm=8192;function qh(n,e,t){if(n.subtreeFlags&dm)for(n=n.child;n!==null;)mI(n,e,t),n=n.sibling}function mI(n,e,t){switch(n.tag){case 26:qh(n,e,t),n.flags&dm&&n.memoizedState!==null&&oF(t,bs,n.memoizedState,n.memoizedProps);break;case 5:qh(n,e,t);break;case 3:case 4:var i=bs;bs=nx(n.stateNode.containerInfo),qh(n,e,t),bs=i;break;case 22:n.memoizedState===null&&(i=n.alternate,i!==null&&i.memoizedState!==null?(i=dm,dm=16777216,qh(n,e,t),dm=i):qh(n,e,t));break;default:qh(n,e,t)}}function gI(n){var e=n.alternate;if(e!==null&&(n=e.child,n!==null)){e.child=null;do e=n.sibling,n.sibling=null,n=e;while(n!==null)}}function Up(n){var e=n.deletions;if(n.flags&16){if(e!==null)for(var t=0;t<e.length;t++){var i=e[t];Ji=i,_I(i,n)}gI(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)vI(n),n=n.sibling}function vI(n){switch(n.tag){case 0:case 11:case 15:Up(n),n.flags&2048&&gc(9,n,n.return);break;case 3:Up(n);break;case 12:Up(n);break;case 22:var e=n.stateNode;n.memoizedState!==null&&e._visibility&2&&(n.return===null||n.return.tag!==13)?(e._visibility&=-3,g_(n)):Up(n);break;default:Up(n)}}function g_(n){var e=n.deletions;if(n.flags&16){if(e!==null)for(var t=0;t<e.length;t++){var i=e[t];Ji=i,_I(i,n)}gI(n)}for(n=n.child;n!==null;){switch(e=n,e.tag){case 0:case 11:case 15:gc(8,e,e.return),g_(e);break;case 22:t=e.stateNode,t._visibility&2&&(t._visibility&=-3,g_(e));break;default:g_(e)}n=n.sibling}}function _I(n,e){for(;Ji!==null;){var t=Ji;switch(t.tag){case 0:case 11:case 15:gc(8,t,e);break;case 23:case 22:if(t.memoizedState!==null&&t.memoizedState.cachePool!==null){var i=t.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:O0(t.memoizedState.cache)}if(i=t.child,i!==null)i.return=t,Ji=i;else e:for(t=n;Ji!==null;){i=Ji;var r=i.sibling,a=i.return;if(lI(i),i===t){Ji=null;break e}if(r!==null){r.return=a,Ji=r;break e}Ji=a}}}var TH={getCacheForType:function(n){var e=ur(Oi),t=e.data.get(n);return t===void 0&&(t=n(),e.data.set(n,t)),t},cacheSignal:function(){return ur(Oi).controller.signal}},EH=typeof WeakMap=="function"?WeakMap:Map,yn=0,Gn=null,sn=null,cn=0,Rn=0,Ta=null,Ql=!1,Xd=!1,lb=!1,sl=0,_i=0,vc=0,Pu=0,cb=0,ba=0,vd=0,Lm=null,Qr=null,Z3=!1,C1=0,xI=0,Z_=1/0,K_=null,oc=null,Fi=0,lc=null,_d=null,$o=0,K3=0,Q3=null,yI=null,Im=0,J3=null;function Na(){return yn&2&&cn!==0?cn&-cn:Ut.T!==null?hb():CL()}function SI(){if(ba===0)if(!(cn&536870912)||un){var n=Bg;Bg<<=1,!(Bg&3932160)&&(Bg=262144),ba=n}else ba=536870912;return n=Ia.current,n!==null&&(n.flags|=32),ba}function $r(n,e,t){(n===Gn&&(Rn===2||Rn===9)||n.cancelPendingCommit!==null)&&(xd(n,0),Jl(n,cn,ba,!1)),C0(n,t),(!(yn&2)||n!==Gn)&&(n===Gn&&(!(yn&2)&&(Pu|=t),_i===4&&Jl(n,cn,ba,!1)),uo(n))}function TI(n,e,t){if(yn&6)throw Error(Ue(327));var i=!t&&(e&127)===0&&(e&n.expiredLanes)===0||R0(n,e),r=i?AH(n,e):MT(n,e,!0),a=i;do{if(r===0){Xd&&!i&&Jl(n,e,0,!1);break}else{if(t=n.current.alternate,a&&!MH(t)){r=MT(n,e,!1),a=!1;continue}if(r===2){if(a=e,n.errorRecoveryDisabledLanes&a)var s=0;else s=n.pendingLanes&-536870913,s=s!==0?s:s&536870912?536870912:0;if(s!==0){e=s;e:{var o=n;r=Lm;var l=o.current.memoizedState.isDehydrated;if(l&&(xd(o,s).flags|=256),s=MT(o,s,!1),s!==2){if(lb&&!l){o.errorRecoveryDisabledLanes|=a,Pu|=a,r=4;break e}a=Qr,Qr=r,a!==null&&(Qr===null?Qr=a:Qr.push.apply(Qr,a))}r=s}if(a=!1,r!==2)continue}}if(r===1){xd(n,0),Jl(n,e,0,!0);break}e:{switch(i=n,a=r,a){case 0:case 1:throw Error(Ue(345));case 4:if((e&4194048)!==e)break;case 6:Jl(i,e,ba,!Ql);break e;case 2:Qr=null;break;case 3:case 5:break;default:throw Error(Ue(329))}if((e&62914560)===e&&(r=C1+300-Ra(),10<r)){if(Jl(i,e,ba,!Ql),_1(i,0,!0)!==0)break e;$o=e,i.timeoutHandle=VI(YC.bind(null,i,t,Qr,K_,Z3,e,ba,Pu,vd,Ql,a,"Throttled",-0,0),r);break e}YC(i,t,Qr,K_,Z3,e,ba,Pu,vd,Ql,a,null,-0,0)}}break}while(!0);uo(n)}function YC(n,e,t,i,r,a,s,o,l,h,f,d,p,g){if(n.timeoutHandle=-1,d=e.subtreeFlags,d&8192||(d&16785408)===16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Zo},mI(e,a,d);var _=(a&62914560)===a?C1-Ra():(a&4194048)===a?xI-Ra():0;if(_=lF(d,_),_!==null){$o=a,n.cancelPendingCommit=_(jC.bind(null,n,e,a,t,i,r,s,o,l,f,d,null,p,g)),Jl(n,a,s,!h);return}}jC(n,e,a,t,i,r,s,o,l)}function MH(n){for(var e=n;;){var t=e.tag;if((t===0||t===11||t===15)&&e.flags&16384&&(t=e.updateQueue,t!==null&&(t=t.stores,t!==null)))for(var i=0;i<t.length;i++){var r=t[i],a=r.getSnapshot;r=r.value;try{if(!La(a(),r))return!1}catch{return!1}}if(t=e.child,e.subtreeFlags&16384&&t!==null)t.return=e,e=t;else{if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function Jl(n,e,t,i){e&=~cb,e&=~Pu,n.suspendedLanes|=e,n.pingedLanes&=~e,i&&(n.warmLanes|=e),i=n.expirationTimes;for(var r=e;0<r;){var a=31-Da(r),s=1<<a;i[a]=-1,r&=~s}t!==0&&AL(n,t,e)}function D1(){return yn&6?!0:(U0(0),!1)}function ub(){if(sn!==null){if(Rn===0)var n=sn.return;else n=sn,Ko=hh=null,ZM(n),id=null,n0=0,n=sn;for(;n!==null;)tI(n.alternate,n),n=n.return;sn=null}}function xd(n,e){var t=n.timeoutHandle;t!==-1&&(n.timeoutHandle=-1,WH(t)),t=n.cancelPendingCommit,t!==null&&(n.cancelPendingCommit=null,t()),$o=0,ub(),Gn=n,sn=t=Qo(n.current,null),cn=e,Rn=0,Ta=null,Ql=!1,Xd=R0(n,e),lb=!1,vd=ba=cb=Pu=vc=_i=0,Qr=Lm=null,Z3=!1,e&8&&(e|=e&32);var i=n.entangledLanes;if(i!==0)for(n=n.entanglements,i&=e;0<i;){var r=31-Da(i),a=1<<r;e|=n[r],i&=~a}return sl=e,T1(),t}function EI(n,e){Zt=null,Ut.H=r0,e===Wd||e===M1?(e=MC(),Rn=3):e===VM?(e=MC(),Rn=4):Rn=e===rb?8:e!==null&&typeof e=="object"&&typeof e.then=="function"?6:1,Ta=e,sn===null&&(_i=1,Y_(n,es(e,n.current)))}function MI(){var n=Ia.current;return n===null?!0:(cn&4194048)===cn?is===null:(cn&62914560)===cn||cn&536870912?n===is:!1}function bI(){var n=Ut.H;return Ut.H=r0,n===null?r0:n}function AI(){var n=Ut.A;return Ut.A=TH,n}function Q_(){_i=4,Ql||(cn&4194048)!==cn&&Ia.current!==null||(Xd=!0),!(vc&134217727)&&!(Pu&134217727)||Gn===null||Jl(Gn,cn,ba,!1)}function MT(n,e,t){var i=yn;yn|=2;var r=bI(),a=AI();(Gn!==n||cn!==e)&&(K_=null,xd(n,e)),e=!1;var s=_i;e:do try{if(Rn!==0&&sn!==null){var o=sn,l=Ta;switch(Rn){case 8:ub(),s=6;break e;case 3:case 2:case 9:case 6:Ia.current===null&&(e=!0);var h=Rn;if(Rn=0,Ta=null,Xf(n,o,l,h),t&&Xd){s=0;break e}break;default:h=Rn,Rn=0,Ta=null,Xf(n,o,l,h)}}bH(),s=_i;break}catch(f){EI(n,f)}while(!0);return e&&n.shellSuspendCounter++,Ko=hh=null,yn=i,Ut.H=r,Ut.A=a,sn===null&&(Gn=null,cn=0,T1()),s}function bH(){for(;sn!==null;)wI(sn)}function AH(n,e){var t=yn;yn|=2;var i=bI(),r=AI();Gn!==n||cn!==e?(K_=null,Z_=Ra()+500,xd(n,e)):Xd=R0(n,e);e:do try{if(Rn!==0&&sn!==null){e=sn;var a=Ta;t:switch(Rn){case 1:Rn=0,Ta=null,Xf(n,e,a,1);break;case 2:case 9:if(EC(a)){Rn=0,Ta=null,qC(e);break}e=function(){Rn!==2&&Rn!==9||Gn!==n||(Rn=7),uo(n)},a.then(e,e);break e;case 3:Rn=7;break e;case 4:Rn=5;break e;case 7:EC(a)?(Rn=0,Ta=null,qC(e)):(Rn=0,Ta=null,Xf(n,e,a,7));break;case 5:var s=null;switch(sn.tag){case 26:s=sn.memoizedState;case 5:case 27:var o=sn;if(s?qI(s):o.stateNode.complete){Rn=0,Ta=null;var l=o.sibling;if(l!==null)sn=l;else{var h=o.return;h!==null?(sn=h,N1(h)):sn=null}break t}}Rn=0,Ta=null,Xf(n,e,a,5);break;case 6:Rn=0,Ta=null,Xf(n,e,a,6);break;case 8:ub(),_i=6;break e;default:throw Error(Ue(462))}}wH();break}catch(f){EI(n,f)}while(!0);return Ko=hh=null,Ut.H=i,Ut.A=r,yn=t,sn!==null?0:(Gn=null,cn=0,T1(),_i)}function wH(){for(;sn!==null&&!Kz();)wI(sn)}function wI(n){var e=eI(n.alternate,n,sl);n.memoizedProps=n.pendingProps,e===null?N1(n):sn=e}function qC(n){var e=n,t=e.alternate;switch(e.tag){case 15:case 0:e=FC(t,e,e.pendingProps,e.type,void 0,cn);break;case 11:e=FC(t,e,e.pendingProps,e.type.render,e.ref,cn);break;case 5:ZM(e);default:tI(t,e),e=sn=t5(e,sl),e=eI(t,e,sl)}n.memoizedProps=n.pendingProps,e===null?N1(n):sn=e}function Xf(n,e,t,i){Ko=hh=null,ZM(e),id=null,n0=0;var r=e.return;try{if(mH(n,r,e,t,cn)){_i=1,Y_(n,es(t,n.current)),sn=null;return}}catch(a){if(r!==null)throw sn=r,a;_i=1,Y_(n,es(t,n.current)),sn=null;return}e.flags&32768?(un||i===1?n=!0:Xd||cn&536870912?n=!1:(Ql=n=!0,(i===2||i===9||i===3||i===6)&&(i=Ia.current,i!==null&&i.tag===13&&(i.flags|=16384))),RI(e,n)):N1(e)}function N1(n){var e=n;do{if(e.flags&32768){RI(e,Ql);return}n=e.return;var t=_H(e.alternate,e,sl);if(t!==null){sn=t;return}if(e=e.sibling,e!==null){sn=e;return}sn=e=n}while(e!==null);_i===0&&(_i=5)}function RI(n,e){do{var t=xH(n.alternate,n);if(t!==null){t.flags&=32767,sn=t;return}if(t=n.return,t!==null&&(t.flags|=32768,t.subtreeFlags=0,t.deletions=null),!e&&(n=n.sibling,n!==null)){sn=n;return}sn=n=t}while(n!==null);_i=6,sn=null}function jC(n,e,t,i,r,a,s,o,l){n.cancelPendingCommit=null;do O1();while(Fi!==0);if(yn&6)throw Error(Ue(327));if(e!==null){if(e===n.current)throw Error(Ue(177));if(a=e.lanes|e.childLanes,a|=UM,sB(n,t,a,s,o,l),n===Gn&&(sn=Gn=null,cn=0),_d=e,lc=n,$o=t,K3=a,Q3=r,yI=i,e.subtreeFlags&10256||e.flags&10256?(n.callbackNode=null,n.callbackPriority=0,NH(U_,function(){return LI(),null})):(n.callbackNode=null,n.callbackPriority=0),i=(e.flags&13878)!==0,e.subtreeFlags&13878||i){i=Ut.T,Ut.T=null,r=Sn.p,Sn.p=2,s=yn,yn|=4;try{yH(n,e,t)}finally{yn=s,Sn.p=r,Ut.T=i}}Fi=1,CI(),DI(),NI()}}function CI(){if(Fi===1){Fi=0;var n=lc,e=_d,t=(e.flags&13878)!==0;if(e.subtreeFlags&13878||t){t=Ut.T,Ut.T=null;var i=Sn.p;Sn.p=2;var r=yn;yn|=4;try{fI(e,n);var a=nE,s=qL(n.containerInfo),o=a.focusedElem,l=a.selectionRange;if(s!==o&&o&&o.ownerDocument&&YL(o.ownerDocument.documentElement,o)){if(l!==null&&IM(o)){var h=l.start,f=l.end;if(f===void 0&&(f=h),"selectionStart"in o)o.selectionStart=h,o.selectionEnd=Math.min(f,o.value.length);else{var d=o.ownerDocument||document,p=d&&d.defaultView||window;if(p.getSelection){var g=p.getSelection(),_=o.textContent.length,T=Math.min(l.start,_),y=l.end===void 0?T:Math.min(l.end,_);!g.extend&&T>y&&(s=y,y=T,T=s);var v=gC(o,T),S=gC(o,y);if(v&&S&&(g.rangeCount!==1||g.anchorNode!==v.node||g.anchorOffset!==v.offset||g.focusNode!==S.node||g.focusOffset!==S.offset)){var E=d.createRange();E.setStart(v.node,v.offset),g.removeAllRanges(),T>y?(g.addRange(E),g.extend(S.node,S.offset)):(E.setEnd(S.node,S.offset),g.addRange(E))}}}}for(d=[],g=o;g=g.parentNode;)g.nodeType===1&&d.push({element:g,left:g.scrollLeft,top:g.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<d.length;o++){var b=d[o];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}ax=!!tE,nE=tE=null}finally{yn=r,Sn.p=i,Ut.T=t}}n.current=e,Fi=2}}function DI(){if(Fi===2){Fi=0;var n=lc,e=_d,t=(e.flags&8772)!==0;if(e.subtreeFlags&8772||t){t=Ut.T,Ut.T=null;var i=Sn.p;Sn.p=2;var r=yn;yn|=4;try{oI(n,e.alternate,e)}finally{yn=r,Sn.p=i,Ut.T=t}}Fi=3}}function NI(){if(Fi===4||Fi===3){Fi=0,Qz();var n=lc,e=_d,t=$o,i=yI;e.subtreeFlags&10256||e.flags&10256?Fi=5:(Fi=0,_d=lc=null,OI(n,n.pendingLanes));var r=n.pendingLanes;if(r===0&&(oc=null),wM(t),e=e.stateNode,Ca&&typeof Ca.onCommitFiberRoot=="function")try{Ca.onCommitFiberRoot(w0,e,void 0,(e.current.flags&128)===128)}catch{}if(i!==null){e=Ut.T,r=Sn.p,Sn.p=2,Ut.T=null;try{for(var a=n.onRecoverableError,s=0;s<i.length;s++){var o=i[s];a(o.value,{componentStack:o.stack})}}finally{Ut.T=e,Sn.p=r}}$o&3&&O1(),uo(n),r=n.pendingLanes,t&261930&&r&42?n===J3?Im++:(Im=0,J3=n):Im=0,U0(0)}}function OI(n,e){(n.pooledCacheLanes&=e)===0&&(e=n.pooledCache,e!=null&&(n.pooledCache=null,O0(e)))}function O1(){return CI(),DI(),NI(),LI()}function LI(){if(Fi!==5)return!1;var n=lc,e=K3;K3=0;var t=wM($o),i=Ut.T,r=Sn.p;try{Sn.p=32>t?32:t,Ut.T=null,t=Q3,Q3=null;var a=lc,s=$o;if(Fi=0,_d=lc=null,$o=0,yn&6)throw Error(Ue(331));var o=yn;if(yn|=4,vI(a.current),pI(a,a.current,s,t),yn=o,U0(0,!1),Ca&&typeof Ca.onPostCommitFiberRoot=="function")try{Ca.onPostCommitFiberRoot(w0,a)}catch{}return!0}finally{Sn.p=r,Ut.T=i,OI(n,e)}}function ZC(n,e,t){e=es(t,e),e=X3(n.stateNode,e,2),n=sc(n,e,2),n!==null&&(C0(n,2),uo(n))}function Dn(n,e,t){if(n.tag===3)ZC(n,n,t);else for(;e!==null;){if(e.tag===3){ZC(e,n,t);break}else if(e.tag===1){var i=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(oc===null||!oc.has(i))){n=es(t,n),t=j5(2),i=sc(e,t,2),i!==null&&(Z5(t,i,e,n),C0(i,2),uo(i));break}}e=e.return}}function bT(n,e,t){var i=n.pingCache;if(i===null){i=n.pingCache=new EH;var r=new Set;i.set(e,r)}else r=i.get(e),r===void 0&&(r=new Set,i.set(e,r));r.has(t)||(lb=!0,r.add(t),n=RH.bind(null,n,e,t),e.then(n,n))}function RH(n,e,t){var i=n.pingCache;i!==null&&i.delete(e),n.pingedLanes|=n.suspendedLanes&t,n.warmLanes&=~t,Gn===n&&(cn&t)===t&&(_i===4||_i===3&&(cn&62914560)===cn&&300>Ra()-C1?!(yn&2)&&xd(n,0):cb|=t,vd===cn&&(vd=0)),uo(n)}function II(n,e){e===0&&(e=bL()),n=uh(n,e),n!==null&&(C0(n,e),uo(n))}function CH(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),II(n,t)}function DH(n,e){var t=0;switch(n.tag){case 31:case 13:var i=n.stateNode,r=n.memoizedState;r!==null&&(t=r.retryLane);break;case 19:i=n.stateNode;break;case 22:i=n.stateNode._retryCache;break;default:throw Error(Ue(314))}i!==null&&i.delete(e),II(n,t)}function NH(n,e){return bM(n,e)}var J_=null,Nf=null,$3=!1,$_=!1,AT=!1,$l=0;function uo(n){n!==Nf&&n.next===null&&(Nf===null?J_=Nf=n:Nf=Nf.next=n),$_=!0,$3||($3=!0,LH())}function U0(n,e){if(!AT&&$_){AT=!0;do for(var t=!1,i=J_;i!==null;){if(n!==0){var r=i.pendingLanes;if(r===0)var a=0;else{var s=i.suspendedLanes,o=i.pingedLanes;a=(1<<31-Da(42|n)+1)-1,a&=r&~(s&~o),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(t=!0,KC(i,a))}else a=cn,a=_1(i,i===Gn?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),!(a&3)||R0(i,a)||(t=!0,KC(i,a));i=i.next}while(t);AT=!1}}function OH(){UI()}function UI(){$_=$3=!1;var n=0;$l!==0&&kH()&&(n=$l);for(var e=Ra(),t=null,i=J_;i!==null;){var r=i.next,a=PI(i,e);a===0?(i.next=null,t===null?J_=r:t.next=r,r===null&&(Nf=t)):(t=i,(n!==0||a&3)&&($_=!0)),i=r}Fi!==0&&Fi!==5||U0(n),$l!==0&&($l=0)}function PI(n,e){for(var t=n.suspendedLanes,i=n.pingedLanes,r=n.expirationTimes,a=n.pendingLanes&-62914561;0<a;){var s=31-Da(a),o=1<<s,l=r[s];l===-1?(!(o&t)||o&i)&&(r[s]=aB(o,e)):l<=e&&(n.expiredLanes|=o),a&=~o}if(e=Gn,t=cn,t=_1(n,n===e?t:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),i=n.callbackNode,t===0||n===e&&(Rn===2||Rn===9)||n.cancelPendingCommit!==null)return i!==null&&i!==null&&eT(i),n.callbackNode=null,n.callbackPriority=0;if(!(t&3)||R0(n,t)){if(e=t&-t,e===n.callbackPriority)return e;switch(i!==null&&eT(i),wM(t)){case 2:case 8:t=EL;break;case 32:t=U_;break;case 268435456:t=ML;break;default:t=U_}return i=zI.bind(null,n),t=bM(t,i),n.callbackPriority=e,n.callbackNode=t,e}return i!==null&&i!==null&&eT(i),n.callbackPriority=2,n.callbackNode=null,2}function zI(n,e){if(Fi!==0&&Fi!==5)return n.callbackNode=null,n.callbackPriority=0,null;var t=n.callbackNode;if(O1()&&n.callbackNode!==t)return null;var i=cn;return i=_1(n,n===Gn?i:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),i===0?null:(TI(n,i,e),PI(n,Ra()),n.callbackNode!=null&&n.callbackNode===t?zI.bind(null,n):null)}function KC(n,e){if(O1())return null;TI(n,e,!0)}function LH(){XH(function(){yn&6?bM(TL,OH):UI()})}function hb(){if($l===0){var n=pd;n===0&&(n=zg,zg<<=1,!(zg&261888)&&(zg=256)),$l=n}return $l}function QC(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:o_(""+n)}function JC(n,e){var t=e.ownerDocument.createElement("input");return t.name=e.name,t.value=e.value,n.id&&t.setAttribute("form",n.id),e.parentNode.insertBefore(t,e),n=new FormData(n),t.parentNode.removeChild(t),n}function IH(n,e,t,i,r){if(e==="submit"&&t&&t.stateNode===r){var a=QC((r[ta]||null).action),s=i.submitter;s&&(e=(e=s[ta]||null)?QC(e.formAction):s.getAttribute("formAction"),e!==null&&(a=e,s=null));var o=new x1("action","action",null,i,r);n.push({event:o,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if($l!==0){var l=s?JC(r,s):new FormData(r);k3(t,{pending:!0,data:l,method:r.method,action:a},null,l)}}else typeof a=="function"&&(o.preventDefault(),l=s?JC(r,s):new FormData(r),k3(t,{pending:!0,data:l,method:r.method,action:a},a,l))},currentTarget:r}]})}}for(var wT=0;wT<N3.length;wT++){var RT=N3[wT],UH=RT.toLowerCase(),PH=RT[0].toUpperCase()+RT.slice(1);Ls(UH,"on"+PH)}Ls(ZL,"onAnimationEnd");Ls(KL,"onAnimationIteration");Ls(QL,"onAnimationStart");Ls("dblclick","onDoubleClick");Ls("focusin","onFocus");Ls("focusout","onBlur");Ls(JB,"onTransitionRun");Ls($B,"onTransitionStart");Ls(eH,"onTransitionCancel");Ls(JL,"onTransitionEnd");fd("onMouseEnter",["mouseout","mouseover"]);fd("onMouseLeave",["mouseout","mouseover"]);fd("onPointerEnter",["pointerout","pointerover"]);fd("onPointerLeave",["pointerout","pointerover"]);oh("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));oh("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));oh("onBeforeInput",["compositionend","keypress","textInput","paste"]);oh("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));oh("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));oh("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var a0="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(" "),zH=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(a0));function BI(n,e){e=(e&4)!==0;for(var t=0;t<n.length;t++){var i=n[t],r=i.event;i=i.listeners;e:{var a=void 0;if(e)for(var s=i.length-1;0<=s;s--){var o=i[s],l=o.instance,h=o.currentTarget;if(o=o.listener,l!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=h;try{a(r)}catch(f){z_(f)}r.currentTarget=null,a=l}else for(s=0;s<i.length;s++){if(o=i[s],l=o.instance,h=o.currentTarget,o=o.listener,l!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=h;try{a(r)}catch(f){z_(f)}r.currentTarget=null,a=l}}}}function an(n,e){var t=e[E3];t===void 0&&(t=e[E3]=new Set);var i=n+"__bubble";t.has(i)||(HI(e,n,2,!1),t.add(i))}function CT(n,e,t){var i=0;e&&(i|=4),HI(t,n,i,e)}var qg="_reactListening"+Math.random().toString(36).slice(2);function fb(n){if(!n[qg]){n[qg]=!0,DL.forEach(function(t){t!=="selectionchange"&&(zH.has(t)||CT(t,!1,n),CT(t,!0,n))});var e=n.nodeType===9?n:n.ownerDocument;e===null||e[qg]||(e[qg]=!0,CT("selectionchange",!1,e))}}function HI(n,e,t,i){switch(JI(e)){case 2:var r=hF;break;case 8:r=fF;break;default:r=gb}t=r.bind(null,e,t,n),r=void 0,!R3||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(r=!0),i?r!==void 0?n.addEventListener(e,t,{capture:!0,passive:r}):n.addEventListener(e,t,!0):r!==void 0?n.addEventListener(e,t,{passive:r}):n.addEventListener(e,t,!1)}function DT(n,e,t,i,r){var a=i;if(!(e&1)&&!(e&2)&&i!==null)e:for(;;){if(i===null)return;var s=i.tag;if(s===3||s===4){var o=i.stateNode.containerInfo;if(o===r)break;if(s===4)for(s=i.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===r)return;s=s.return}for(;o!==null;){if(s=Pf(o),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){i=a=s;continue e}o=o.parentNode}}i=i.return}BL(function(){var h=a,f=DM(t),d=[];e:{var p=$L.get(n);if(p!==void 0){var g=x1,_=n;switch(n){case"keypress":if(c_(t)===0)break e;case"keydown":case"keyup":g=DB;break;case"focusin":_="focus",g=aT;break;case"focusout":_="blur",g=aT;break;case"beforeblur":case"afterblur":g=aT;break;case"click":if(t.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":g=sC;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":g=_B;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":g=LB;break;case ZL:case KL:case QL:g=SB;break;case JL:g=UB;break;case"scroll":case"scrollend":g=gB;break;case"wheel":g=zB;break;case"copy":case"cut":case"paste":g=EB;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":g=lC;break;case"toggle":case"beforetoggle":g=HB}var T=(e&4)!==0,y=!T&&(n==="scroll"||n==="scrollend"),v=T?p!==null?p+"Capture":null:p;T=[];for(var S=h,E;S!==null;){var b=S;if(E=b.stateNode,b=b.tag,b!==5&&b!==26&&b!==27||E===null||v===null||(b=Qm(S,v),b!=null&&T.push(s0(S,b,E))),y)break;S=S.return}0<T.length&&(p=new g(p,_,null,t,f),d.push({event:p,listeners:T}))}}if(!(e&7)){e:{if(p=n==="mouseover"||n==="pointerover",g=n==="mouseout"||n==="pointerout",p&&t!==w3&&(_=t.relatedTarget||t.fromElement)&&(Pf(_)||_[Gd]))break e;if((g||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,g?(_=t.relatedTarget||t.toElement,g=h,_=_?Pf(_):null,_!==null&&(y=A0(_),T=_.tag,_!==y||T!==5&&T!==27&&T!==6)&&(_=null)):(g=null,_=h),g!==_)){if(T=sC,b="onMouseLeave",v="onMouseEnter",S="mouse",(n==="pointerout"||n==="pointerover")&&(T=lC,b="onPointerLeave",v="onPointerEnter",S="pointer"),y=g==null?p:hm(g),E=_==null?p:hm(_),p=new T(b,S+"leave",g,t,f),p.target=y,p.relatedTarget=E,b=null,Pf(f)===h&&(T=new T(v,S+"enter",_,t,f),T.target=E,T.relatedTarget=y,b=T),y=b,g&&_)t:{for(T=BH,v=g,S=_,E=0,b=v;b;b=T(b))E++;b=0;for(var N=S;N;N=T(N))b++;for(;0<E-b;)v=T(v),E--;for(;0<b-E;)S=T(S),b--;for(;E--;){if(v===S||S!==null&&v===S.alternate){T=v;break t}v=T(v),S=T(S)}T=null}else T=null;g!==null&&$C(d,p,g,T,!1),_!==null&&y!==null&&$C(d,y,_,T,!0)}}e:{if(p=h?hm(h):window,g=p.nodeName&&p.nodeName.toLowerCase(),g==="select"||g==="input"&&p.type==="file")var R=fC;else if(hC(p))if(WL)R=ZB;else{R=qB;var I=YB}else g=p.nodeName,!g||g.toLowerCase()!=="input"||p.type!=="checkbox"&&p.type!=="radio"?h&&CM(h.elementType)&&(R=fC):R=jB;if(R&&(R=R(n,h))){kL(d,R,t,f);break e}I&&I(n,p,h),n==="focusout"&&h&&p.type==="number"&&h.memoizedProps.value!=null&&A3(p,"number",p.value)}switch(I=h?hm(h):window,n){case"focusin":(hC(I)||I.contentEditable==="true")&&(Hf=I,C3=h,bm=null);break;case"focusout":bm=C3=Hf=null;break;case"mousedown":D3=!0;break;case"contextmenu":case"mouseup":case"dragend":D3=!1,vC(d,t,f);break;case"selectionchange":if(QB)break;case"keydown":case"keyup":vC(d,t,f)}var U;if(LM)e:{switch(n){case"compositionstart":var O="onCompositionStart";break e;case"compositionend":O="onCompositionEnd";break e;case"compositionupdate":O="onCompositionUpdate";break e}O=void 0}else Bf?GL(n,t)&&(O="onCompositionEnd"):n==="keydown"&&t.keyCode===229&&(O="onCompositionStart");O&&(FL&&t.locale!=="ko"&&(Bf||O!=="onCompositionStart"?O==="onCompositionEnd"&&Bf&&(U=HL()):(Kl=f,NM="value"in Kl?Kl.value:Kl.textContent,Bf=!0)),I=ex(h,O),0<I.length&&(O=new oC(O,n,null,t,f),d.push({event:O,listeners:I}),U?O.data=U:(U=VL(t),U!==null&&(O.data=U)))),(U=GB?VB(n,t):kB(n,t))&&(O=ex(h,"onBeforeInput"),0<O.length&&(I=new oC("onBeforeInput","beforeinput",null,t,f),d.push({event:I,listeners:O}),I.data=U)),IH(d,n,h,t,f)}BI(d,e)})}function s0(n,e,t){return{instance:n,listener:e,currentTarget:t}}function ex(n,e){for(var t=e+"Capture",i=[];n!==null;){var r=n,a=r.stateNode;if(r=r.tag,r!==5&&r!==26&&r!==27||a===null||(r=Qm(n,t),r!=null&&i.unshift(s0(n,r,a)),r=Qm(n,e),r!=null&&i.push(s0(n,r,a))),n.tag===3)return i;n=n.return}return[]}function BH(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function $C(n,e,t,i,r){for(var a=e._reactName,s=[];t!==null&&t!==i;){var o=t,l=o.alternate,h=o.stateNode;if(o=o.tag,l!==null&&l===i)break;o!==5&&o!==26&&o!==27||h===null||(l=h,r?(h=Qm(t,a),h!=null&&s.unshift(s0(t,h,l))):r||(h=Qm(t,a),h!=null&&s.push(s0(t,h,l)))),t=t.return}s.length!==0&&n.push({event:e,listeners:s})}var HH=/\r\n?/g,FH=/\u0000|\uFFFD/g;function e4(n){return(typeof n=="string"?n:""+n).replace(HH,`
`).replace(FH,"")}function FI(n,e){return e=e4(e),e4(n)===e}function Pn(n,e,t,i,r,a){switch(t){case"children":typeof i=="string"?e==="body"||e==="textarea"&&i===""||dd(n,i):(typeof i=="number"||typeof i=="bigint")&&e!=="body"&&dd(n,""+i);break;case"className":Fg(n,"class",i);break;case"tabIndex":Fg(n,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Fg(n,t,i);break;case"style":zL(n,i,a);break;case"data":if(e!=="object"){Fg(n,"data",i);break}case"src":case"href":if(i===""&&(e!=="a"||t!=="href")){n.removeAttribute(t);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){n.removeAttribute(t);break}i=o_(""+i),n.setAttribute(t,i);break;case"action":case"formAction":if(typeof i=="function"){n.setAttribute(t,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof a=="function"&&(t==="formAction"?(e!=="input"&&Pn(n,e,"name",r.name,r,null),Pn(n,e,"formEncType",r.formEncType,r,null),Pn(n,e,"formMethod",r.formMethod,r,null),Pn(n,e,"formTarget",r.formTarget,r,null)):(Pn(n,e,"encType",r.encType,r,null),Pn(n,e,"method",r.method,r,null),Pn(n,e,"target",r.target,r,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){n.removeAttribute(t);break}i=o_(""+i),n.setAttribute(t,i);break;case"onClick":i!=null&&(n.onclick=Zo);break;case"onScroll":i!=null&&an("scroll",n);break;case"onScrollEnd":i!=null&&an("scrollend",n);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(Ue(61));if(t=i.__html,t!=null){if(r.children!=null)throw Error(Ue(60));n.innerHTML=t}}break;case"multiple":n.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":n.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){n.removeAttribute("xlink:href");break}t=o_(""+i),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?n.setAttribute(t,""+i):n.removeAttribute(t);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?n.setAttribute(t,""):n.removeAttribute(t);break;case"capture":case"download":i===!0?n.setAttribute(t,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?n.setAttribute(t,i):n.removeAttribute(t);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?n.setAttribute(t,i):n.removeAttribute(t);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?n.removeAttribute(t):n.setAttribute(t,i);break;case"popover":an("beforetoggle",n),an("toggle",n),s_(n,"popover",i);break;case"xlinkActuate":bo(n,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":bo(n,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":bo(n,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":bo(n,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":bo(n,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":bo(n,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":bo(n,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":bo(n,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":bo(n,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":s_(n,"is",i);break;case"innerText":case"textContent":break;default:(!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(t=pB.get(t)||t,s_(n,t,i))}}function eE(n,e,t,i,r,a){switch(t){case"style":zL(n,i,a);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(Ue(61));if(t=i.__html,t!=null){if(r.children!=null)throw Error(Ue(60));n.innerHTML=t}}break;case"children":typeof i=="string"?dd(n,i):(typeof i=="number"||typeof i=="bigint")&&dd(n,""+i);break;case"onScroll":i!=null&&an("scroll",n);break;case"onScrollEnd":i!=null&&an("scrollend",n);break;case"onClick":i!=null&&(n.onclick=Zo);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!NL.hasOwnProperty(t))e:{if(t[0]==="o"&&t[1]==="n"&&(r=t.endsWith("Capture"),e=t.slice(2,r?t.length-7:void 0),a=n[ta]||null,a=a!=null?a[t]:null,typeof a=="function"&&n.removeEventListener(e,a,r),typeof i=="function")){typeof a!="function"&&a!==null&&(t in n?n[t]=null:n.hasAttribute(t)&&n.removeAttribute(t)),n.addEventListener(e,i,r);break e}t in n?n[t]=i:i===!0?n.setAttribute(t,""):s_(n,t,i)}}}function hr(n,e,t){switch(e){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":an("error",n),an("load",n);var i=!1,r=!1,a;for(a in t)if(t.hasOwnProperty(a)){var s=t[a];if(s!=null)switch(a){case"src":i=!0;break;case"srcSet":r=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(Ue(137,e));default:Pn(n,e,a,s,t,null)}}r&&Pn(n,e,"srcSet",t.srcSet,t,null),i&&Pn(n,e,"src",t.src,t,null);return;case"input":an("invalid",n);var o=a=s=r=null,l=null,h=null;for(i in t)if(t.hasOwnProperty(i)){var f=t[i];if(f!=null)switch(i){case"name":r=f;break;case"type":s=f;break;case"checked":l=f;break;case"defaultChecked":h=f;break;case"value":a=f;break;case"defaultValue":o=f;break;case"children":case"dangerouslySetInnerHTML":if(f!=null)throw Error(Ue(137,e));break;default:Pn(n,e,i,f,t,null)}}IL(n,a,o,l,h,s,r,!1);return;case"select":an("invalid",n),i=s=a=null;for(r in t)if(t.hasOwnProperty(r)&&(o=t[r],o!=null))switch(r){case"value":a=o;break;case"defaultValue":s=o;break;case"multiple":i=o;default:Pn(n,e,r,o,t,null)}e=a,t=s,n.multiple=!!i,e!=null?ed(n,!!i,e,!1):t!=null&&ed(n,!!i,t,!0);return;case"textarea":an("invalid",n),a=r=i=null;for(s in t)if(t.hasOwnProperty(s)&&(o=t[s],o!=null))switch(s){case"value":i=o;break;case"defaultValue":r=o;break;case"children":a=o;break;case"dangerouslySetInnerHTML":if(o!=null)throw Error(Ue(91));break;default:Pn(n,e,s,o,t,null)}PL(n,i,r,a);return;case"option":for(l in t)if(t.hasOwnProperty(l)&&(i=t[l],i!=null))switch(l){case"selected":n.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:Pn(n,e,l,i,t,null)}return;case"dialog":an("beforetoggle",n),an("toggle",n),an("cancel",n),an("close",n);break;case"iframe":case"object":an("load",n);break;case"video":case"audio":for(i=0;i<a0.length;i++)an(a0[i],n);break;case"image":an("error",n),an("load",n);break;case"details":an("toggle",n);break;case"embed":case"source":case"link":an("error",n),an("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(h in t)if(t.hasOwnProperty(h)&&(i=t[h],i!=null))switch(h){case"children":case"dangerouslySetInnerHTML":throw Error(Ue(137,e));default:Pn(n,e,h,i,t,null)}return;default:if(CM(e)){for(f in t)t.hasOwnProperty(f)&&(i=t[f],i!==void 0&&eE(n,e,f,i,t,void 0));return}}for(o in t)t.hasOwnProperty(o)&&(i=t[o],i!=null&&Pn(n,e,o,i,t,null))}function GH(n,e,t,i){switch(e){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var r=null,a=null,s=null,o=null,l=null,h=null,f=null;for(g in t){var d=t[g];if(t.hasOwnProperty(g)&&d!=null)switch(g){case"checked":break;case"value":break;case"defaultValue":l=d;default:i.hasOwnProperty(g)||Pn(n,e,g,null,i,d)}}for(var p in i){var g=i[p];if(d=t[p],i.hasOwnProperty(p)&&(g!=null||d!=null))switch(p){case"type":a=g;break;case"name":r=g;break;case"checked":h=g;break;case"defaultChecked":f=g;break;case"value":s=g;break;case"defaultValue":o=g;break;case"children":case"dangerouslySetInnerHTML":if(g!=null)throw Error(Ue(137,e));break;default:g!==d&&Pn(n,e,p,g,i,d)}}b3(n,s,o,l,h,f,a,r);return;case"select":g=s=o=p=null;for(a in t)if(l=t[a],t.hasOwnProperty(a)&&l!=null)switch(a){case"value":break;case"multiple":g=l;default:i.hasOwnProperty(a)||Pn(n,e,a,null,i,l)}for(r in i)if(a=i[r],l=t[r],i.hasOwnProperty(r)&&(a!=null||l!=null))switch(r){case"value":p=a;break;case"defaultValue":o=a;break;case"multiple":s=a;default:a!==l&&Pn(n,e,r,a,i,l)}e=o,t=s,i=g,p!=null?ed(n,!!t,p,!1):!!i!=!!t&&(e!=null?ed(n,!!t,e,!0):ed(n,!!t,t?[]:"",!1));return;case"textarea":g=p=null;for(o in t)if(r=t[o],t.hasOwnProperty(o)&&r!=null&&!i.hasOwnProperty(o))switch(o){case"value":break;case"children":break;default:Pn(n,e,o,null,i,r)}for(s in i)if(r=i[s],a=t[s],i.hasOwnProperty(s)&&(r!=null||a!=null))switch(s){case"value":p=r;break;case"defaultValue":g=r;break;case"children":break;case"dangerouslySetInnerHTML":if(r!=null)throw Error(Ue(91));break;default:r!==a&&Pn(n,e,s,r,i,a)}UL(n,p,g);return;case"option":for(var _ in t)if(p=t[_],t.hasOwnProperty(_)&&p!=null&&!i.hasOwnProperty(_))switch(_){case"selected":n.selected=!1;break;default:Pn(n,e,_,null,i,p)}for(l in i)if(p=i[l],g=t[l],i.hasOwnProperty(l)&&p!==g&&(p!=null||g!=null))switch(l){case"selected":n.selected=p&&typeof p!="function"&&typeof p!="symbol";break;default:Pn(n,e,l,p,i,g)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var T in t)p=t[T],t.hasOwnProperty(T)&&p!=null&&!i.hasOwnProperty(T)&&Pn(n,e,T,null,i,p);for(h in i)if(p=i[h],g=t[h],i.hasOwnProperty(h)&&p!==g&&(p!=null||g!=null))switch(h){case"children":case"dangerouslySetInnerHTML":if(p!=null)throw Error(Ue(137,e));break;default:Pn(n,e,h,p,i,g)}return;default:if(CM(e)){for(var y in t)p=t[y],t.hasOwnProperty(y)&&p!==void 0&&!i.hasOwnProperty(y)&&eE(n,e,y,void 0,i,p);for(f in i)p=i[f],g=t[f],!i.hasOwnProperty(f)||p===g||p===void 0&&g===void 0||eE(n,e,f,p,i,g);return}}for(var v in t)p=t[v],t.hasOwnProperty(v)&&p!=null&&!i.hasOwnProperty(v)&&Pn(n,e,v,null,i,p);for(d in i)p=i[d],g=t[d],!i.hasOwnProperty(d)||p===g||p==null&&g==null||Pn(n,e,d,p,i,g)}function t4(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function VH(){if(typeof performance.getEntriesByType=="function"){for(var n=0,e=0,t=performance.getEntriesByType("resource"),i=0;i<t.length;i++){var r=t[i],a=r.transferSize,s=r.initiatorType,o=r.duration;if(a&&o&&t4(s)){for(s=0,o=r.responseEnd,i+=1;i<t.length;i++){var l=t[i],h=l.startTime;if(h>o)break;var f=l.transferSize,d=l.initiatorType;f&&t4(d)&&(l=l.responseEnd,s+=f*(l<o?1:(o-h)/(l-h)))}if(--i,e+=8*(a+s)/(r.duration/1e3),n++,10<n)break}}if(0<n)return e/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var tE=null,nE=null;function tx(n){return n.nodeType===9?n:n.ownerDocument}function n4(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function GI(n,e){if(n===0)switch(e){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&e==="foreignObject"?0:n}function iE(n,e){return n==="textarea"||n==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.children=="bigint"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var NT=null;function kH(){var n=window.event;return n&&n.type==="popstate"?n===NT?!1:(NT=n,!0):(NT=null,!1)}var VI=typeof setTimeout=="function"?setTimeout:void 0,WH=typeof clearTimeout=="function"?clearTimeout:void 0,i4=typeof Promise=="function"?Promise:void 0,XH=typeof queueMicrotask=="function"?queueMicrotask:typeof i4<"u"?function(n){return i4.resolve(null).then(n).catch(YH)}:VI;function YH(n){setTimeout(function(){throw n})}function Ec(n){return n==="head"}function r4(n,e){var t=e,i=0;do{var r=t.nextSibling;if(n.removeChild(t),r&&r.nodeType===8)if(t=r.data,t==="/$"||t==="/&"){if(i===0){n.removeChild(r),Sd(e);return}i--}else if(t==="$"||t==="$?"||t==="$~"||t==="$!"||t==="&")i++;else if(t==="html")Um(n.ownerDocument.documentElement);else if(t==="head"){t=n.ownerDocument.head,Um(t);for(var a=t.firstChild;a;){var s=a.nextSibling,o=a.nodeName;a[D0]||o==="SCRIPT"||o==="STYLE"||o==="LINK"&&a.rel.toLowerCase()==="stylesheet"||t.removeChild(a),a=s}}else t==="body"&&Um(n.ownerDocument.body);t=r}while(t);Sd(e)}function a4(n,e){var t=n;n=0;do{var i=t.nextSibling;if(t.nodeType===1?e?(t._stashedDisplay=t.style.display,t.style.display="none"):(t.style.display=t._stashedDisplay||"",t.getAttribute("style")===""&&t.removeAttribute("style")):t.nodeType===3&&(e?(t._stashedText=t.nodeValue,t.nodeValue=""):t.nodeValue=t._stashedText||""),i&&i.nodeType===8)if(t=i.data,t==="/$"){if(n===0)break;n--}else t!=="$"&&t!=="$?"&&t!=="$~"&&t!=="$!"||n++;t=i}while(t)}function rE(n){var e=n.firstChild;for(e&&e.nodeType===10&&(e=e.nextSibling);e;){var t=e;switch(e=e.nextSibling,t.nodeName){case"HTML":case"HEAD":case"BODY":rE(t),RM(t);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(t.rel.toLowerCase()==="stylesheet")continue}n.removeChild(t)}}function qH(n,e,t,i){for(;n.nodeType===1;){var r=t;if(n.nodeName.toLowerCase()!==e.toLowerCase()){if(!i&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(i){if(!n[D0])switch(e){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(a=n.getAttribute("rel"),a==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(a!==r.rel||n.getAttribute("href")!==(r.href==null||r.href===""?null:r.href)||n.getAttribute("crossorigin")!==(r.crossOrigin==null?null:r.crossOrigin)||n.getAttribute("title")!==(r.title==null?null:r.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(a=n.getAttribute("src"),(a!==(r.src==null?null:r.src)||n.getAttribute("type")!==(r.type==null?null:r.type)||n.getAttribute("crossorigin")!==(r.crossOrigin==null?null:r.crossOrigin))&&a&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(e==="input"&&n.type==="hidden"){var a=r.name==null?null:""+r.name;if(r.type==="hidden"&&n.getAttribute("name")===a)return n}else return n;if(n=rs(n.nextSibling),n===null)break}return null}function jH(n,e,t){if(e==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!t||(n=rs(n.nextSibling),n===null))return null;return n}function kI(n,e){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!e||(n=rs(n.nextSibling),n===null))return null;return n}function aE(n){return n.data==="$?"||n.data==="$~"}function sE(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function ZH(n,e){var t=n.ownerDocument;if(n.data==="$~")n._reactRetry=e;else if(n.data!=="$?"||t.readyState!=="loading")e();else{var i=function(){e(),t.removeEventListener("DOMContentLoaded",i)};t.addEventListener("DOMContentLoaded",i),n._reactRetry=i}}function rs(n){for(;n!=null;n=n.nextSibling){var e=n.nodeType;if(e===1||e===3)break;if(e===8){if(e=n.data,e==="$"||e==="$!"||e==="$?"||e==="$~"||e==="&"||e==="F!"||e==="F")break;if(e==="/$"||e==="/&")return null}}return n}var oE=null;function s4(n){n=n.nextSibling;for(var e=0;n;){if(n.nodeType===8){var t=n.data;if(t==="/$"||t==="/&"){if(e===0)return rs(n.nextSibling);e--}else t!=="$"&&t!=="$!"&&t!=="$?"&&t!=="$~"&&t!=="&"||e++}n=n.nextSibling}return null}function o4(n){n=n.previousSibling;for(var e=0;n;){if(n.nodeType===8){var t=n.data;if(t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"){if(e===0)return n;e--}else t!=="/$"&&t!=="/&"||e++}n=n.previousSibling}return null}function WI(n,e,t){switch(e=tx(t),n){case"html":if(n=e.documentElement,!n)throw Error(Ue(452));return n;case"head":if(n=e.head,!n)throw Error(Ue(453));return n;case"body":if(n=e.body,!n)throw Error(Ue(454));return n;default:throw Error(Ue(451))}}function Um(n){for(var e=n.attributes;e.length;)n.removeAttributeNode(e[0]);RM(n)}var ls=new Map,l4=new Set;function nx(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var ul=Sn.d;Sn.d={f:KH,r:QH,D:JH,C:$H,L:eF,m:tF,X:iF,S:nF,M:rF};function KH(){var n=ul.f(),e=D1();return n||e}function QH(n){var e=Vd(n);e!==null&&e.tag===5&&e.type==="form"?z5(e):ul.r(n)}var Yd=typeof document>"u"?null:document;function XI(n,e,t){var i=Yd;if(i&&typeof e=="string"&&e){var r=$a(e);r='link[rel="'+n+'"][href="'+r+'"]',typeof t=="string"&&(r+='[crossorigin="'+t+'"]'),l4.has(r)||(l4.add(r),n={rel:n,crossOrigin:t,href:e},i.querySelector(r)===null&&(e=i.createElement("link"),hr(e,"link",n),$i(e),i.head.appendChild(e)))}}function JH(n){ul.D(n),XI("dns-prefetch",n,null)}function $H(n,e){ul.C(n,e),XI("preconnect",n,e)}function eF(n,e,t){ul.L(n,e,t);var i=Yd;if(i&&n&&e){var r='link[rel="preload"][as="'+$a(e)+'"]';e==="image"&&t&&t.imageSrcSet?(r+='[imagesrcset="'+$a(t.imageSrcSet)+'"]',typeof t.imageSizes=="string"&&(r+='[imagesizes="'+$a(t.imageSizes)+'"]')):r+='[href="'+$a(n)+'"]';var a=r;switch(e){case"style":a=yd(n);break;case"script":a=qd(n)}ls.has(a)||(n=ni({rel:"preload",href:e==="image"&&t&&t.imageSrcSet?void 0:n,as:e},t),ls.set(a,n),i.querySelector(r)!==null||e==="style"&&i.querySelector(P0(a))||e==="script"&&i.querySelector(z0(a))||(e=i.createElement("link"),hr(e,"link",n),$i(e),i.head.appendChild(e)))}}function tF(n,e){ul.m(n,e);var t=Yd;if(t&&n){var i=e&&typeof e.as=="string"?e.as:"script",r='link[rel="modulepreload"][as="'+$a(i)+'"][href="'+$a(n)+'"]',a=r;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":a=qd(n)}if(!ls.has(a)&&(n=ni({rel:"modulepreload",href:n},e),ls.set(a,n),t.querySelector(r)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(t.querySelector(z0(a)))return}i=t.createElement("link"),hr(i,"link",n),$i(i),t.head.appendChild(i)}}}function nF(n,e,t){ul.S(n,e,t);var i=Yd;if(i&&n){var r=$f(i).hoistableStyles,a=yd(n);e=e||"default";var s=r.get(a);if(!s){var o={loading:0,preload:null};if(s=i.querySelector(P0(a)))o.loading=5;else{n=ni({rel:"stylesheet",href:n,"data-precedence":e},t),(t=ls.get(a))&&db(n,t);var l=s=i.createElement("link");$i(l),hr(l,"link",n),l._p=new Promise(function(h,f){l.onload=h,l.onerror=f}),l.addEventListener("load",function(){o.loading|=1}),l.addEventListener("error",function(){o.loading|=2}),o.loading|=4,v_(s,e,i)}s={type:"stylesheet",instance:s,count:1,state:o},r.set(a,s)}}}function iF(n,e){ul.X(n,e);var t=Yd;if(t&&n){var i=$f(t).hoistableScripts,r=qd(n),a=i.get(r);a||(a=t.querySelector(z0(r)),a||(n=ni({src:n,async:!0},e),(e=ls.get(r))&&pb(n,e),a=t.createElement("script"),$i(a),hr(a,"link",n),t.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},i.set(r,a))}}function rF(n,e){ul.M(n,e);var t=Yd;if(t&&n){var i=$f(t).hoistableScripts,r=qd(n),a=i.get(r);a||(a=t.querySelector(z0(r)),a||(n=ni({src:n,async:!0,type:"module"},e),(e=ls.get(r))&&pb(n,e),a=t.createElement("script"),$i(a),hr(a,"link",n),t.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},i.set(r,a))}}function c4(n,e,t,i){var r=(r=ic.current)?nx(r):null;if(!r)throw Error(Ue(446));switch(n){case"meta":case"title":return null;case"style":return typeof t.precedence=="string"&&typeof t.href=="string"?(e=yd(t.href),t=$f(r).hoistableStyles,i=t.get(e),i||(i={type:"style",instance:null,count:0,state:null},t.set(e,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(t.rel==="stylesheet"&&typeof t.href=="string"&&typeof t.precedence=="string"){n=yd(t.href);var a=$f(r).hoistableStyles,s=a.get(n);if(s||(r=r.ownerDocument||r,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},a.set(n,s),(a=r.querySelector(P0(n)))&&!a._p&&(s.instance=a,s.state.loading=5),ls.has(n)||(t={rel:"preload",as:"style",href:t.href,crossOrigin:t.crossOrigin,integrity:t.integrity,media:t.media,hrefLang:t.hrefLang,referrerPolicy:t.referrerPolicy},ls.set(n,t),a||aF(r,n,t,s.state))),e&&i===null)throw Error(Ue(528,""));return s}if(e&&i!==null)throw Error(Ue(529,""));return null;case"script":return e=t.async,t=t.src,typeof t=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=qd(t),t=$f(r).hoistableScripts,i=t.get(e),i||(i={type:"script",instance:null,count:0,state:null},t.set(e,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(Ue(444,n))}}function yd(n){return'href="'+$a(n)+'"'}function P0(n){return'link[rel="stylesheet"]['+n+"]"}function YI(n){return ni({},n,{"data-precedence":n.precedence,precedence:null})}function aF(n,e,t,i){n.querySelector('link[rel="preload"][as="style"]['+e+"]")?i.loading=1:(e=n.createElement("link"),i.preload=e,e.addEventListener("load",function(){return i.loading|=1}),e.addEventListener("error",function(){return i.loading|=2}),hr(e,"link",t),$i(e),n.head.appendChild(e))}function qd(n){return'[src="'+$a(n)+'"]'}function z0(n){return"script[async]"+n}function u4(n,e,t){if(e.count++,e.instance===null)switch(e.type){case"style":var i=n.querySelector('style[data-href~="'+$a(t.href)+'"]');if(i)return e.instance=i,$i(i),i;var r=ni({},t,{"data-href":t.href,"data-precedence":t.precedence,href:null,precedence:null});return i=(n.ownerDocument||n).createElement("style"),$i(i),hr(i,"style",r),v_(i,t.precedence,n),e.instance=i;case"stylesheet":r=yd(t.href);var a=n.querySelector(P0(r));if(a)return e.state.loading|=4,e.instance=a,$i(a),a;i=YI(t),(r=ls.get(r))&&db(i,r),a=(n.ownerDocument||n).createElement("link"),$i(a);var s=a;return s._p=new Promise(function(o,l){s.onload=o,s.onerror=l}),hr(a,"link",i),e.state.loading|=4,v_(a,t.precedence,n),e.instance=a;case"script":return a=qd(t.src),(r=n.querySelector(z0(a)))?(e.instance=r,$i(r),r):(i=t,(r=ls.get(a))&&(i=ni({},t),pb(i,r)),n=n.ownerDocument||n,r=n.createElement("script"),$i(r),hr(r,"link",i),n.head.appendChild(r),e.instance=r);case"void":return null;default:throw Error(Ue(443,e.type))}else e.type==="stylesheet"&&!(e.state.loading&4)&&(i=e.instance,e.state.loading|=4,v_(i,t.precedence,n));return e.instance}function v_(n,e,t){for(var i=t.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=i.length?i[i.length-1]:null,a=r,s=0;s<i.length;s++){var o=i[s];if(o.dataset.precedence===e)a=o;else if(a!==r)break}a?a.parentNode.insertBefore(n,a.nextSibling):(e=t.nodeType===9?t.head:t,e.insertBefore(n,e.firstChild))}function db(n,e){n.crossOrigin==null&&(n.crossOrigin=e.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=e.referrerPolicy),n.title==null&&(n.title=e.title)}function pb(n,e){n.crossOrigin==null&&(n.crossOrigin=e.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=e.referrerPolicy),n.integrity==null&&(n.integrity=e.integrity)}var __=null;function h4(n,e,t){if(__===null){var i=new Map,r=__=new Map;r.set(t,i)}else r=__,i=r.get(t),i||(i=new Map,r.set(t,i));if(i.has(n))return i;for(i.set(n,null),t=t.getElementsByTagName(n),r=0;r<t.length;r++){var a=t[r];if(!(a[D0]||a[or]||n==="link"&&a.getAttribute("rel")==="stylesheet")&&a.namespaceURI!=="http://www.w3.org/2000/svg"){var s=a.getAttribute(e)||"";s=n+s;var o=i.get(s);o?o.push(a):i.set(s,[a])}}return i}function f4(n,e,t){n=n.ownerDocument||n,n.head.insertBefore(t,e==="title"?n.querySelector("head > title"):null)}function sF(n,e,t){if(t===1||e.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;switch(e.rel){case"stylesheet":return n=e.disabled,typeof e.precedence=="string"&&n==null;default:return!0}case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function qI(n){return!(n.type==="stylesheet"&&!(n.state.loading&3))}function oF(n,e,t,i){if(t.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&!(t.state.loading&4)){if(t.instance===null){var r=yd(i.href),a=e.querySelector(P0(r));if(a){e=a._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(n.count++,n=ix.bind(n),e.then(n,n)),t.state.loading|=4,t.instance=a,$i(a);return}a=e.ownerDocument||e,i=YI(i),(r=ls.get(r))&&db(i,r),a=a.createElement("link"),$i(a);var s=a;s._p=new Promise(function(o,l){s.onload=o,s.onerror=l}),hr(a,"link",i),t.instance=a}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(t,e),(e=t.state.preload)&&!(t.state.loading&3)&&(n.count++,t=ix.bind(n),e.addEventListener("load",t),e.addEventListener("error",t))}}var OT=0;function lF(n,e){return n.stylesheets&&n.count===0&&x_(n,n.stylesheets),0<n.count||0<n.imgCount?function(t){var i=setTimeout(function(){if(n.stylesheets&&x_(n,n.stylesheets),n.unsuspend){var a=n.unsuspend;n.unsuspend=null,a()}},6e4+e);0<n.imgBytes&&OT===0&&(OT=62500*VH());var r=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&x_(n,n.stylesheets),n.unsuspend)){var a=n.unsuspend;n.unsuspend=null,a()}},(n.imgBytes>OT?50:800)+e);return n.unsuspend=t,function(){n.unsuspend=null,clearTimeout(i),clearTimeout(r)}}:null}function ix(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)x_(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var rx=null;function x_(n,e){n.stylesheets=null,n.unsuspend!==null&&(n.count++,rx=new Map,e.forEach(cF,n),rx=null,ix.call(n))}function cF(n,e){if(!(e.state.loading&4)){var t=rx.get(n);if(t)var i=t.get(null);else{t=new Map,rx.set(n,t);for(var r=n.querySelectorAll("link[data-precedence],style[data-precedence]"),a=0;a<r.length;a++){var s=r[a];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(t.set(s.dataset.precedence,s),i=s)}i&&t.set(null,i)}r=e.instance,s=r.getAttribute("data-precedence"),a=t.get(s)||i,a===i&&t.set(null,r),t.set(s,r),this.count++,i=ix.bind(this),r.addEventListener("load",i),r.addEventListener("error",i),a?a.parentNode.insertBefore(r,a.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(r,n.firstChild)),e.state.loading|=4}}var o0={$$typeof:jo,Provider:null,Consumer:null,_currentValue:Ou,_currentValue2:Ou,_threadCount:0};function uF(n,e,t,i,r,a,s,o,l){this.tag=1,this.containerInfo=n,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=tT(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tT(0),this.hiddenUpdates=tT(null),this.identifierPrefix=i,this.onUncaughtError=r,this.onCaughtError=a,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function jI(n,e,t,i,r,a,s,o,l,h,f,d){return n=new uF(n,e,t,s,l,h,f,d,o),e=1,a===!0&&(e|=24),a=Ma(3,null,null,e),n.current=a,a.stateNode=n,e=FM(),e.refCount++,n.pooledCache=e,e.refCount++,a.memoizedState={element:i,isDehydrated:t,cache:e},kM(a),n}function ZI(n){return n?(n=Vf,n):Vf}function KI(n,e,t,i,r,a){r=ZI(r),i.context===null?i.context=r:i.pendingContext=r,i=ac(e),i.payload={element:t},a=a===void 0?null:a,a!==null&&(i.callback=a),t=sc(n,i,e),t!==null&&($r(t,n,e),wm(t,n,e))}function d4(n,e){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var t=n.retryLane;n.retryLane=t!==0&&t<e?t:e}}function mb(n,e){d4(n,e),(n=n.alternate)&&d4(n,e)}function QI(n){if(n.tag===13||n.tag===31){var e=uh(n,67108864);e!==null&&$r(e,n,67108864),mb(n,67108864)}}function p4(n){if(n.tag===13||n.tag===31){var e=Na();e=AM(e);var t=uh(n,e);t!==null&&$r(t,n,e),mb(n,e)}}var ax=!0;function hF(n,e,t,i){var r=Ut.T;Ut.T=null;var a=Sn.p;try{Sn.p=2,gb(n,e,t,i)}finally{Sn.p=a,Ut.T=r}}function fF(n,e,t,i){var r=Ut.T;Ut.T=null;var a=Sn.p;try{Sn.p=8,gb(n,e,t,i)}finally{Sn.p=a,Ut.T=r}}function gb(n,e,t,i){if(ax){var r=lE(i);if(r===null)DT(n,e,i,sx,t),m4(n,i);else if(pF(r,n,e,t,i))i.stopPropagation();else if(m4(n,i),e&4&&-1<dF.indexOf(n)){for(;r!==null;){var a=Vd(r);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var s=gu(a.pendingLanes);if(s!==0){var o=a;for(o.pendingLanes|=2,o.entangledLanes|=2;s;){var l=1<<31-Da(s);o.entanglements[1]|=l,s&=~l}uo(a),!(yn&6)&&(Z_=Ra()+500,U0(0))}}break;case 31:case 13:o=uh(a,2),o!==null&&$r(o,a,2),D1(),mb(a,2)}if(a=lE(i),a===null&&DT(n,e,i,sx,t),a===r)break;r=a}r!==null&&i.stopPropagation()}else DT(n,e,i,null,t)}}function lE(n){return n=DM(n),vb(n)}var sx=null;function vb(n){if(sx=null,n=Pf(n),n!==null){var e=A0(n);if(e===null)n=null;else{var t=e.tag;if(t===13){if(n=vL(e),n!==null)return n;n=null}else if(t===31){if(n=_L(e),n!==null)return n;n=null}else if(t===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;n=null}else e!==n&&(n=null)}}return sx=n,null}function JI(n){switch(n){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Jz()){case TL:return 2;case EL:return 8;case U_:case $z:return 32;case ML:return 268435456;default:return 32}default:return 32}}var cE=!1,cc=null,uc=null,hc=null,l0=new Map,c0=new Map,ql=[],dF="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".split(" ");function m4(n,e){switch(n){case"focusin":case"focusout":cc=null;break;case"dragenter":case"dragleave":uc=null;break;case"mouseover":case"mouseout":hc=null;break;case"pointerover":case"pointerout":l0.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":c0.delete(e.pointerId)}}function Pp(n,e,t,i,r,a){return n===null||n.nativeEvent!==a?(n={blockedOn:e,domEventName:t,eventSystemFlags:i,nativeEvent:a,targetContainers:[r]},e!==null&&(e=Vd(e),e!==null&&QI(e)),n):(n.eventSystemFlags|=i,e=n.targetContainers,r!==null&&e.indexOf(r)===-1&&e.push(r),n)}function pF(n,e,t,i,r){switch(e){case"focusin":return cc=Pp(cc,n,e,t,i,r),!0;case"dragenter":return uc=Pp(uc,n,e,t,i,r),!0;case"mouseover":return hc=Pp(hc,n,e,t,i,r),!0;case"pointerover":var a=r.pointerId;return l0.set(a,Pp(l0.get(a)||null,n,e,t,i,r)),!0;case"gotpointercapture":return a=r.pointerId,c0.set(a,Pp(c0.get(a)||null,n,e,t,i,r)),!0}return!1}function $I(n){var e=Pf(n.target);if(e!==null){var t=A0(e);if(t!==null){if(e=t.tag,e===13){if(e=vL(t),e!==null){n.blockedOn=e,$R(n.priority,function(){p4(t)});return}}else if(e===31){if(e=_L(t),e!==null){n.blockedOn=e,$R(n.priority,function(){p4(t)});return}}else if(e===3&&t.stateNode.current.memoizedState.isDehydrated){n.blockedOn=t.tag===3?t.stateNode.containerInfo:null;return}}}n.blockedOn=null}function y_(n){if(n.blockedOn!==null)return!1;for(var e=n.targetContainers;0<e.length;){var t=lE(n.nativeEvent);if(t===null){t=n.nativeEvent;var i=new t.constructor(t.type,t);w3=i,t.target.dispatchEvent(i),w3=null}else return e=Vd(t),e!==null&&QI(e),n.blockedOn=t,!1;e.shift()}return!0}function g4(n,e,t){y_(n)&&t.delete(e)}function mF(){cE=!1,cc!==null&&y_(cc)&&(cc=null),uc!==null&&y_(uc)&&(uc=null),hc!==null&&y_(hc)&&(hc=null),l0.forEach(g4),c0.forEach(g4)}function jg(n,e){n.blockedOn===e&&(n.blockedOn=null,cE||(cE=!0,Gi.unstable_scheduleCallback(Gi.unstable_NormalPriority,mF)))}var Zg=null;function v4(n){Zg!==n&&(Zg=n,Gi.unstable_scheduleCallback(Gi.unstable_NormalPriority,function(){Zg===n&&(Zg=null);for(var e=0;e<n.length;e+=3){var t=n[e],i=n[e+1],r=n[e+2];if(typeof i!="function"){if(vb(i||t)===null)continue;break}var a=Vd(t);a!==null&&(n.splice(e,3),e-=3,k3(a,{pending:!0,data:r,method:t.method,action:i},i,r))}}))}function Sd(n){function e(l){return jg(l,n)}cc!==null&&jg(cc,n),uc!==null&&jg(uc,n),hc!==null&&jg(hc,n),l0.forEach(e),c0.forEach(e);for(var t=0;t<ql.length;t++){var i=ql[t];i.blockedOn===n&&(i.blockedOn=null)}for(;0<ql.length&&(t=ql[0],t.blockedOn===null);)$I(t),t.blockedOn===null&&ql.shift();if(t=(n.ownerDocument||n).$$reactFormReplay,t!=null)for(i=0;i<t.length;i+=3){var r=t[i],a=t[i+1],s=r[ta]||null;if(typeof a=="function")s||v4(t);else if(s){var o=null;if(a&&a.hasAttribute("formAction")){if(r=a,s=a[ta]||null)o=s.formAction;else if(vb(r)!==null)continue}else o=s.action;typeof o=="function"?t[i+1]=o:(t.splice(i,3),i-=3),v4(t)}}}function eU(){function n(a){a.canIntercept&&a.info==="react-transition"&&a.intercept({handler:function(){return new Promise(function(s){return r=s})},focusReset:"manual",scroll:"manual"})}function e(){r!==null&&(r(),r=null),i||setTimeout(t,20)}function t(){if(!i&&!navigation.transition){var a=navigation.currentEntry;a&&a.url!=null&&navigation.navigate(a.url,{state:a.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,r=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",e),navigation.addEventListener("navigateerror",e),setTimeout(t,100),function(){i=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",e),navigation.removeEventListener("navigateerror",e),r!==null&&(r(),r=null)}}}function _b(n){this._internalRoot=n}L1.prototype.render=_b.prototype.render=function(n){var e=this._internalRoot;if(e===null)throw Error(Ue(409));var t=e.current,i=Na();KI(t,i,n,e,null,null)};L1.prototype.unmount=_b.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var e=n.containerInfo;KI(n.current,2,null,n,null,null),D1(),e[Gd]=null}};function L1(n){this._internalRoot=n}L1.prototype.unstable_scheduleHydration=function(n){if(n){var e=CL();n={blockedOn:null,target:n,priority:e};for(var t=0;t<ql.length&&e!==0&&e<ql[t].priority;t++);ql.splice(t,0,n),t===0&&$I(n)}};var _4=mL.version;if(_4!=="19.2.0")throw Error(Ue(527,_4,"19.2.0"));Sn.findDOMNode=function(n){var e=n._reactInternals;if(e===void 0)throw typeof n.render=="function"?Error(Ue(188)):(n=Object.keys(n).join(","),Error(Ue(268,n)));return n=Xz(e),n=n!==null?xL(n):null,n=n===null?null:n.stateNode,n};var gF={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:Ut,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Kg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Kg.isDisabled&&Kg.supportsFiber)try{w0=Kg.inject(gF),Ca=Kg}catch{}}g1.createRoot=function(n,e){if(!gL(n))throw Error(Ue(299));var t=!1,i="",r=X5,a=Y5,s=q5;return e!=null&&(e.unstable_strictMode===!0&&(t=!0),e.identifierPrefix!==void 0&&(i=e.identifierPrefix),e.onUncaughtError!==void 0&&(r=e.onUncaughtError),e.onCaughtError!==void 0&&(a=e.onCaughtError),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=jI(n,1,!1,null,null,t,i,null,r,a,s,eU),n[Gd]=e.current,fb(n),new _b(e)};g1.hydrateRoot=function(n,e,t){if(!gL(n))throw Error(Ue(299));var i=!1,r="",a=X5,s=Y5,o=q5,l=null;return t!=null&&(t.unstable_strictMode===!0&&(i=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(a=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(o=t.onRecoverableError),t.formState!==void 0&&(l=t.formState)),e=jI(n,1,!0,e,t??null,i,r,l,a,s,o,eU),e.context=ZI(null),t=e.current,i=Na(),i=AM(i),r=ac(i),r.callback=null,sc(t,r,i),t=i,e.current.lanes=t,C0(e,t),uo(e),n[Gd]=e.current,fb(n),new L1(e)};g1.version="19.2.0";function tU(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(tU)}catch(n){console.error(n)}}tU(),cL.exports=g1;var vF=cL.exports;const _F=p1(vF);var nU={exports:{}},Mc={};/**
 * @license React
 * react-reconciler-constants.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */Mc.ConcurrentRoot=1;Mc.ContinuousEventPriority=8;Mc.DefaultEventPriority=32;Mc.DiscreteEventPriority=2;Mc.IdleEventPriority=268435456;Mc.LegacyRoot=0;Mc.NoEventPriority=0;nU.exports=Mc;var S_=nU.exports;/**
 * @license
 * Copyright 2010-2025 Three.js Authors
 * SPDX-License-Identifier: MIT
 */const Ds="181",xu={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},yu={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},iU=0,uE=1,rU=2,xF=3,aU=0,I1=1,Pm=2,Ts=3,Ns=0,Ii=1,cr=2,Er=0,zu=1,hE=2,fE=3,dE=4,xb=5,$s=100,sU=101,oU=102,lU=103,cU=104,uU=200,Yf=201,hU=202,fU=203,ox=204,lx=205,dU=206,pU=207,mU=208,gU=209,vU=210,_U=211,xU=212,yU=213,SU=214,cx=0,u0=1,ux=2,ju=3,hx=4,fx=5,dx=6,px=7,B0=0,TU=1,EU=2,as=0,MU=1,bU=2,AU=3,yb=4,wU=5,RU=6,CU=7,pE="attached",DU="detached",U1=300,ol=301,_c=302,h0=303,f0=304,jd=306,Mr=1e3,Ui=1001,Td=1002,Vn=1003,P1=1004,yF=1004,bu=1005,SF=1005,Ht=1006,sd=1007,TF=1007,Aa=1008,NU=1008,Pi=1009,z1=1010,B1=1011,Zu=1012,H0=1013,Os=1014,si=1015,Yn=1016,H1=1017,F1=1018,Ku=1020,Sb=35902,Tb=35899,Eb=1021,Mb=1022,$n=1023,Ed=1026,Qu=1027,ws=1028,F0=1029,Xo=1030,G1=1031,EF=1032,V1=1033,zm=33776,Bm=33777,Hm=33778,Fm=33779,mx=35840,gx=35841,vx=35842,_x=35843,xx=36196,yx=37492,Sx=37496,Tx=37808,Ex=37809,Mx=37810,bx=37811,Ax=37812,wx=37813,Rx=37814,Cx=37815,Dx=37816,Nx=37817,Ox=37818,Lx=37819,Ix=37820,Ux=37821,Px=36492,zx=36494,Bx=36495,Hx=36283,Fx=36284,Gx=36285,Vx=36286,bb=2200,OU=2201,LU=2202,Md=2300,bd=2301,T_=2302,Au=2400,wu=2401,d0=2402,k1=2500,Ab=2501,IU=0,wb=1,kx=2,bc=3200,UU=3201,MF=3202,bF=3203,hl=0,PU=1,Or="",dn="srgb",Fn="srgb-linear",p0="linear",wn="srgb",AF=0,Su=7680,wF=7681,RF=7682,CF=7683,DF=34055,NF=34056,OF=5386,LF=512,IF=513,UF=514,PF=515,zF=516,BF=517,HF=518,mE=519,zU=512,BU=513,HU=514,Rb=515,FU=516,GU=517,VU=518,kU=519,m0=35044,WU=35048,FF=35040,GF=35045,VF=35049,kF=35041,WF=35046,XF=35050,YF=35042,qF="100",so="300 es",wa=2e3,Ad=2001,jF={COMPUTE:"compute",RENDER:"render"},ZF={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},KF={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function XU(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const QF={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function qf(n,e){return new QF[n](e)}function g0(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function YU(){const n=g0("canvas");return n.style.display="block",n}const x4={};let xc=null;function JF(n){xc=n}function $F(){return xc}function v0(...n){const e="THREE."+n.shift();xc?xc("log",e,...n):console.log(e,...n)}function ut(...n){const e="THREE."+n.shift();xc?xc("warn",e,...n):console.warn(e,...n)}function Bt(...n){const e="THREE."+n.shift();xc?xc("error",e,...n):console.error(e,...n)}function wd(...n){const e=n.join(" ");e in x4||(x4[e]=!0,ut(...n))}function eG(n,e,t){return new Promise(function(i,r){function a(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(a,t);break;default:i()}}setTimeout(a,t)})}let ra=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let a=0,s=r.length;a<s;a++)r[a].call(this,e);e.target=null}}};const _r=["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 y4=1234567;const Bu=Math.PI/180,Rd=180/Math.PI;function Oa(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(_r[n&255]+_r[n>>8&255]+_r[n>>16&255]+_r[n>>24&255]+"-"+_r[e&255]+_r[e>>8&255]+"-"+_r[e>>16&15|64]+_r[e>>24&255]+"-"+_r[t&63|128]+_r[t>>8&255]+"-"+_r[t>>16&255]+_r[t>>24&255]+_r[i&255]+_r[i>>8&255]+_r[i>>16&255]+_r[i>>24&255]).toLowerCase()}function Lt(n,e,t){return Math.max(e,Math.min(t,n))}function Cb(n,e){return(n%e+e)%e}function tG(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function nG(n,e,t){return n!==e?(t-n)/(e-n):0}function Gm(n,e,t){return(1-t)*n+t*e}function iG(n,e,t,i){return Gm(n,e,1-Math.exp(-t*i))}function rG(n,e=1){return e-Math.abs(Cb(n,e*2)-e)}function aG(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function sG(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function oG(n,e){return n+Math.floor(Math.random()*(e-n+1))}function lG(n,e){return n+Math.random()*(e-n)}function cG(n){return n*(.5-Math.random())}function uG(n){n!==void 0&&(y4=n);let e=y4+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function hG(n){return n*Bu}function fG(n){return n*Rd}function dG(n){return(n&n-1)===0&&n!==0}function pG(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function mG(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function gG(n,e,t,i,r){const a=Math.cos,s=Math.sin,o=a(t/2),l=s(t/2),h=a((e+i)/2),f=s((e+i)/2),d=a((e-i)/2),p=s((e-i)/2),g=a((i-e)/2),_=s((i-e)/2);switch(r){case"XYX":n.set(o*f,l*d,l*p,o*h);break;case"YZY":n.set(l*p,o*f,l*d,o*h);break;case"ZXZ":n.set(l*d,l*p,o*f,o*h);break;case"XZX":n.set(o*f,l*_,l*g,o*h);break;case"YXY":n.set(l*g,o*f,l*_,o*h);break;case"ZYZ":n.set(l*_,l*g,o*f,o*h);break;default:ut("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Lr(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function jt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const tn={DEG2RAD:Bu,RAD2DEG:Rd,generateUUID:Oa,clamp:Lt,euclideanModulo:Cb,mapLinear:tG,inverseLerp:nG,lerp:Gm,damp:iG,pingpong:rG,smoothstep:aG,smootherstep:sG,randInt:oG,randFloat:lG,randFloatSpread:cG,seededRandom:uG,degToRad:hG,radToDeg:fG,isPowerOfTwo:dG,ceilPowerOfTwo:pG,floorPowerOfTwo:mG,setQuaternionFromProperEuler:gG,normalize:jt,denormalize:Lr};class de{constructor(e=0,t=0){de.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+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=Lt(this.x,e.x,t.x),this.y=Lt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Lt(this.x,e,t),this.y=Lt(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Lt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Lt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class _t{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,a,s,o){let l=i[r+0],h=i[r+1],f=i[r+2],d=i[r+3],p=a[s+0],g=a[s+1],_=a[s+2],T=a[s+3];if(o<=0){e[t+0]=l,e[t+1]=h,e[t+2]=f,e[t+3]=d;return}if(o>=1){e[t+0]=p,e[t+1]=g,e[t+2]=_,e[t+3]=T;return}if(d!==T||l!==p||h!==g||f!==_){let y=l*p+h*g+f*_+d*T;y<0&&(p=-p,g=-g,_=-_,T=-T,y=-y);let v=1-o;if(y<.9995){const S=Math.acos(y),E=Math.sin(S);v=Math.sin(v*S)/E,o=Math.sin(o*S)/E,l=l*v+p*o,h=h*v+g*o,f=f*v+_*o,d=d*v+T*o}else{l=l*v+p*o,h=h*v+g*o,f=f*v+_*o,d=d*v+T*o;const S=1/Math.sqrt(l*l+h*h+f*f+d*d);l*=S,h*=S,f*=S,d*=S}}e[t]=l,e[t+1]=h,e[t+2]=f,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,r,a,s){const o=i[r],l=i[r+1],h=i[r+2],f=i[r+3],d=a[s],p=a[s+1],g=a[s+2],_=a[s+3];return e[t]=o*_+f*d+l*g-h*p,e[t+1]=l*_+f*p+h*d-o*g,e[t+2]=h*_+f*g+o*p-l*d,e[t+3]=f*_-o*d-l*p-h*g,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,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,a=e._z,s=e._order,o=Math.cos,l=Math.sin,h=o(i/2),f=o(r/2),d=o(a/2),p=l(i/2),g=l(r/2),_=l(a/2);switch(s){case"XYZ":this._x=p*f*d+h*g*_,this._y=h*g*d-p*f*_,this._z=h*f*_+p*g*d,this._w=h*f*d-p*g*_;break;case"YXZ":this._x=p*f*d+h*g*_,this._y=h*g*d-p*f*_,this._z=h*f*_-p*g*d,this._w=h*f*d+p*g*_;break;case"ZXY":this._x=p*f*d-h*g*_,this._y=h*g*d+p*f*_,this._z=h*f*_+p*g*d,this._w=h*f*d-p*g*_;break;case"ZYX":this._x=p*f*d-h*g*_,this._y=h*g*d+p*f*_,this._z=h*f*_-p*g*d,this._w=h*f*d+p*g*_;break;case"YZX":this._x=p*f*d+h*g*_,this._y=h*g*d+p*f*_,this._z=h*f*_-p*g*d,this._w=h*f*d-p*g*_;break;case"XZY":this._x=p*f*d-h*g*_,this._y=h*g*d-p*f*_,this._z=h*f*_+p*g*d,this._w=h*f*d+p*g*_;break;default:ut("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],a=t[8],s=t[1],o=t[5],l=t[9],h=t[2],f=t[6],d=t[10],p=i+o+d;if(p>0){const g=.5/Math.sqrt(p+1);this._w=.25/g,this._x=(f-l)*g,this._y=(a-h)*g,this._z=(s-r)*g}else if(i>o&&i>d){const g=2*Math.sqrt(1+i-o-d);this._w=(f-l)/g,this._x=.25*g,this._y=(r+s)/g,this._z=(a+h)/g}else if(o>d){const g=2*Math.sqrt(1+o-i-d);this._w=(a-h)/g,this._x=(r+s)/g,this._y=.25*g,this._z=(l+f)/g}else{const g=2*Math.sqrt(1+d-i-o);this._w=(s-r)/g,this._x=(a+h)/g,this._y=(l+f)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Lt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=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 i=e._x,r=e._y,a=e._z,s=e._w,o=t._x,l=t._y,h=t._z,f=t._w;return this._x=i*f+s*o+r*h-a*l,this._y=r*f+s*l+a*o-i*h,this._z=a*f+s*h+i*l-r*o,this._w=s*f-i*o-r*l-a*h,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,r=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,a=-a,s=-s,o=-o);let l=1-t;if(o<.9995){const h=Math.acos(o),f=Math.sin(h);l=Math.sin(l*h)/f,t=Math.sin(t*h)/f,this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+a*t,this._w=this._w*l+s*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+r*t,this._z=this._z*l+a*t,this._w=this._w*l+s*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),a=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),a*Math.sin(t),a*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class L{constructor(e=0,t=0,i=0){L.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,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(S4.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(S4.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6]*r,this.y=a[1]*t+a[4]*i+a[7]*r,this.z=a[2]*t+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*t+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*t+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*t+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*t+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,a=e.x,s=e.y,o=e.z,l=e.w,h=2*(s*r-o*i),f=2*(o*t-a*r),d=2*(a*i-s*t);return this.x=t+l*h+s*d-o*f,this.y=i+l*f+o*h-a*d,this.z=r+l*d+a*f-s*h,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,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r,this.y=a[1]*t+a[5]*i+a[9]*r,this.z=a[2]*t+a[6]*i+a[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=Lt(this.x,e.x,t.x),this.y=Lt(this.y,e.y,t.y),this.z=Lt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Lt(this.x,e,t),this.y=Lt(this.y,e,t),this.z=Lt(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Lt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,a=e.z,s=t.x,o=t.y,l=t.z;return this.x=r*l-a*o,this.y=a*s-i*l,this.z=i*o-r*s,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return LT.copy(this).projectOnVector(e),this.sub(LT)}reflect(e){return this.sub(LT.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Lt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+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,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const LT=new L,S4=new _t;class Et{constructor(e,t,i,r,a,s,o,l,h){Et.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,l,h)}set(e,t,i,r,a,s,o,l,h){const f=this.elements;return f[0]=e,f[1]=r,f[2]=o,f[3]=t,f[4]=a,f[5]=l,f[6]=i,f[7]=s,f[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[3],l=i[6],h=i[1],f=i[4],d=i[7],p=i[2],g=i[5],_=i[8],T=r[0],y=r[3],v=r[6],S=r[1],E=r[4],b=r[7],N=r[2],R=r[5],I=r[8];return a[0]=s*T+o*S+l*N,a[3]=s*y+o*E+l*R,a[6]=s*v+o*b+l*I,a[1]=h*T+f*S+d*N,a[4]=h*y+f*E+d*R,a[7]=h*v+f*b+d*I,a[2]=p*T+g*S+_*N,a[5]=p*y+g*E+_*R,a[8]=p*v+g*b+_*I,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],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],h=e[7],f=e[8];return t*s*f-t*o*h-i*a*f+i*o*l+r*a*h-r*s*l}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],h=e[7],f=e[8],d=f*s-o*h,p=o*l-f*a,g=h*a-s*l,_=t*d+i*p+r*g;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const T=1/_;return e[0]=d*T,e[1]=(r*h-f*i)*T,e[2]=(o*i-r*s)*T,e[3]=p*T,e[4]=(f*t-r*l)*T,e[5]=(r*a-o*t)*T,e[6]=g*T,e[7]=(i*l-h*t)*T,e[8]=(s*t-i*a)*T,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,i,r,a,s,o){const l=Math.cos(a),h=Math.sin(a);return this.set(i*l,i*h,-i*(l*s+h*o)+s+e,-r*h,r*l,-r*(-h*s+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(IT.makeScale(e,t)),this}rotate(e){return this.premultiply(IT.makeRotation(-e)),this}translate(e,t){return this.premultiply(IT.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),i=Math.sin(e);return this.set(t,-i,0,i,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,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const IT=new Et,T4=new Et().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),E4=new Et().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function vG(){const n={enabled:!0,workingColorSpace:Fn,spaces:{},convert:function(r,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===wn&&(r.r=el(r.r),r.g=el(r.g),r.b=el(r.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(r.applyMatrix3(this.spaces[a].toXYZ),r.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===wn&&(r.r=od(r.r),r.g=od(r.g),r.b=od(r.b))),r},workingToColorSpace:function(r,a){return this.convert(r,this.workingColorSpace,a)},colorSpaceToWorking:function(r,a){return this.convert(r,a,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Or?p0:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,a=this.workingColorSpace){return r.fromArray(this.spaces[a].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,a,s){return r.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,a){return wd("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return wd("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,a)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Fn]:{primaries:e,whitePoint:i,transfer:p0,toXYZ:T4,fromXYZ:E4,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:dn},outputColorSpaceConfig:{drawingBufferColorSpace:dn}},[dn]:{primaries:e,whitePoint:i,transfer:wn,toXYZ:T4,fromXYZ:E4,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:dn}}}),n}const en=vG();function el(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function od(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let jh;class qU{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{jh===void 0&&(jh=g0("canvas")),jh.width=e.width,jh.height=e.height;const r=jh.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=jh}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=g0("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let s=0;s<a.length;s++)a[s]=el(a[s]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(el(t[i]/255)*255):t[i]=el(t[i]);return{data:t,width:e.width,height:e.height}}else return ut("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let _G=0;class ec{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:_G++}),this.uuid=Oa(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let a;if(Array.isArray(r)){a=[];for(let s=0,o=r.length;s<o;s++)r[s].isDataTexture?a.push(UT(r[s].image)):a.push(UT(r[s]))}else a=UT(r);i.url=a}return t||(e.images[this.uuid]=i),i}}function UT(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?qU.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(ut("Texture: Unable to serialize Texture."),{})}let xG=0;const PT=new L;class Nn extends ra{constructor(e=Nn.DEFAULT_IMAGE,t=Nn.DEFAULT_MAPPING,i=Ui,r=Ui,a=Ht,s=Aa,o=$n,l=Pi,h=Nn.DEFAULT_ANISOTROPY,f=Or){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xG++}),this.uuid=Oa(),this.name="",this.source=new ec(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=a,this.minFilter=s,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=l,this.offset=new de(0,0),this.repeat=new de(1,1),this.center=new de(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Et,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(PT).x}get height(){return this.source.getSize(PT).y}get depth(){return this.source.getSize(PT).z}get image(){return this.source.data}set image(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)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){ut(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){ut(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==U1)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Mr:e.x=e.x-Math.floor(e.x);break;case Ui:e.x=e.x<0?0:1;break;case Td:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Mr:e.y=e.y-Math.floor(e.y);break;case Ui:e.y=e.y<0?0:1;break;case Td:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Nn.DEFAULT_IMAGE=null;Nn.DEFAULT_MAPPING=U1;Nn.DEFAULT_ANISOTROPY=1;class zt{constructor(e=0,t=0,i=0,r=1){zt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,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,i,r){return this.x=e,this.y=t,this.z=i,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=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*t+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*t+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*t+s[7]*i+s[11]*r+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);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,i,r,a;const l=e.elements,h=l[0],f=l[4],d=l[8],p=l[1],g=l[5],_=l[9],T=l[2],y=l[6],v=l[10];if(Math.abs(f-p)<.01&&Math.abs(d-T)<.01&&Math.abs(_-y)<.01){if(Math.abs(f+p)<.1&&Math.abs(d+T)<.1&&Math.abs(_+y)<.1&&Math.abs(h+g+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(h+1)/2,b=(g+1)/2,N=(v+1)/2,R=(f+p)/4,I=(d+T)/4,U=(_+y)/4;return E>b&&E>N?E<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(E),r=R/i,a=I/i):b>N?b<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(b),i=R/r,a=U/r):N<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(N),i=I/a,r=U/a),this.set(i,r,a,t),this}let S=Math.sqrt((y-_)*(y-_)+(d-T)*(d-T)+(p-f)*(p-f));return Math.abs(S)<.001&&(S=1),this.x=(y-_)/S,this.y=(d-T)/S,this.z=(p-f)/S,this.w=Math.acos((h+g+v-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=Lt(this.x,e.x,t.x),this.y=Lt(this.y,e.y,t.y),this.z=Lt(this.z,e.z,t.z),this.w=Lt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Lt(this.x,e,t),this.y=Lt(this.y,e,t),this.z=Lt(this.z,e,t),this.w=Lt(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Lt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Db extends ra{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ht,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new zt(0,0,e,t),this.scissorTest=!1,this.viewport=new zt(0,0,e,t);const r={width:e,height:t,depth:i.depth},a=new Nn(r);this.textures=[];const s=i.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const t={minFilter:Ht,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,a=this.textures.length;r<a;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new ec(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class xi extends Db{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class W1 extends Nn{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Vn,this.minFilter=Vn,this.wrapR=Ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class jU extends xi{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new W1(null,e,t,i),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class ss extends Nn{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Vn,this.minFilter=Vn,this.wrapR=Ui,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ZU extends xi{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new ss(null,e,t,i),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class tr{constructor(e=new L(1/0,1/0,1/0),t=new L(-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,i=e.length;t<i;t+=3)this.expandByPoint(gs.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(gs.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=gs.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const a=i.getAttribute("position");if(t===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,gs):gs.fromBufferAttribute(a,s),gs.applyMatrix4(e.matrixWorld),this.expandByPoint(gs);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Qg.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Qg.copy(i.boundingBox)),Qg.applyMatrix4(e.matrixWorld),this.union(Qg)}const r=e.children;for(let a=0,s=r.length;a<s;a++)this.expandByObject(r[a],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,gs),gs.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(zp),Jg.subVectors(this.max,zp),Zh.subVectors(e.a,zp),Kh.subVectors(e.b,zp),Qh.subVectors(e.c,zp),Dl.subVectors(Kh,Zh),Nl.subVectors(Qh,Kh),Kc.subVectors(Zh,Qh);let t=[0,-Dl.z,Dl.y,0,-Nl.z,Nl.y,0,-Kc.z,Kc.y,Dl.z,0,-Dl.x,Nl.z,0,-Nl.x,Kc.z,0,-Kc.x,-Dl.y,Dl.x,0,-Nl.y,Nl.x,0,-Kc.y,Kc.x,0];return!zT(t,Zh,Kh,Qh,Jg)||(t=[1,0,0,0,1,0,0,0,1],!zT(t,Zh,Kh,Qh,Jg))?!1:($g.crossVectors(Dl,Nl),t=[$g.x,$g.y,$g.z],zT(t,Zh,Kh,Qh,Jg))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,gs).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(gs).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Co[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Co[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Co[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Co[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Co[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Co[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Co[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Co[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Co),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Co=[new L,new L,new L,new L,new L,new L,new L,new L],gs=new L,Qg=new tr,Zh=new L,Kh=new L,Qh=new L,Dl=new L,Nl=new L,Kc=new L,zp=new L,Jg=new L,$g=new L,Qc=new L;function zT(n,e,t,i,r){for(let a=0,s=n.length-3;a<=s;a+=3){Qc.fromArray(n,a);const o=r.x*Math.abs(Qc.x)+r.y*Math.abs(Qc.y)+r.z*Math.abs(Qc.z),l=e.dot(Qc),h=t.dot(Qc),f=i.dot(Qc);if(Math.max(-Math.max(l,h,f),Math.min(l,h,f))>o)return!1}return!0}const yG=new tr,Bp=new L,BT=new L;class nr{constructor(e=new L,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):yG.setFromPoints(e).getCenter(i);let r=0;for(let a=0,s=e.length;a<s;a++)r=Math.max(r,i.distanceToSquared(e[a]));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 i=this.center.distanceToSquared(e);return t.copy(e),i>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;Bp.subVectors(e,this.center);const t=Bp.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(Bp,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(BT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Bp.copy(e.center).add(BT)),this.expandByPoint(Bp.copy(e.center).sub(BT))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Do=new L,HT=new L,ev=new L,Ol=new L,FT=new L,tv=new L,GT=new L;class Ac{constructor(e=new L,t=new L(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,Do)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Do.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Do.copy(this.origin).addScaledVector(this.direction,t),Do.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){HT.copy(e).add(t).multiplyScalar(.5),ev.copy(t).sub(e).normalize(),Ol.copy(this.origin).sub(HT);const a=e.distanceTo(t)*.5,s=-this.direction.dot(ev),o=Ol.dot(this.direction),l=-Ol.dot(ev),h=Ol.lengthSq(),f=Math.abs(1-s*s);let d,p,g,_;if(f>0)if(d=s*l-o,p=s*o-l,_=a*f,d>=0)if(p>=-_)if(p<=_){const T=1/f;d*=T,p*=T,g=d*(d+s*p+2*o)+p*(s*d+p+2*l)+h}else p=a,d=Math.max(0,-(s*p+o)),g=-d*d+p*(p+2*l)+h;else p=-a,d=Math.max(0,-(s*p+o)),g=-d*d+p*(p+2*l)+h;else p<=-_?(d=Math.max(0,-(-s*a+o)),p=d>0?-a:Math.min(Math.max(-a,-l),a),g=-d*d+p*(p+2*l)+h):p<=_?(d=0,p=Math.min(Math.max(-a,-l),a),g=p*(p+2*l)+h):(d=Math.max(0,-(s*a+o)),p=d>0?a:Math.min(Math.max(-a,-l),a),g=-d*d+p*(p+2*l)+h);else p=s>0?-a:a,d=Math.max(0,-(s*p+o)),g=-d*d+p*(p+2*l)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(HT).addScaledVector(ev,p),g}intersectSphere(e,t){Do.subVectors(e.center,this.origin);const i=Do.dot(this.direction),r=Do.dot(Do)-i*i,a=e.radius*e.radius;if(r>a)return null;const s=Math.sqrt(a-r),o=i-s,l=i+s;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,a,s,o,l;const h=1/this.direction.x,f=1/this.direction.y,d=1/this.direction.z,p=this.origin;return h>=0?(i=(e.min.x-p.x)*h,r=(e.max.x-p.x)*h):(i=(e.max.x-p.x)*h,r=(e.min.x-p.x)*h),f>=0?(a=(e.min.y-p.y)*f,s=(e.max.y-p.y)*f):(a=(e.max.y-p.y)*f,s=(e.min.y-p.y)*f),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),d>=0?(o=(e.min.z-p.z)*d,l=(e.max.z-p.z)*d):(o=(e.max.z-p.z)*d,l=(e.min.z-p.z)*d),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Do)!==null}intersectTriangle(e,t,i,r,a){FT.subVectors(t,e),tv.subVectors(i,e),GT.crossVectors(FT,tv);let s=this.direction.dot(GT),o;if(s>0){if(r)return null;o=1}else if(s<0)o=-1,s=-s;else return null;Ol.subVectors(this.origin,e);const l=o*this.direction.dot(tv.crossVectors(Ol,tv));if(l<0)return null;const h=o*this.direction.dot(FT.cross(Ol));if(h<0||l+h>s)return null;const f=-o*Ol.dot(GT);return f<0?null:this.at(f/s,a)}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 Ve{constructor(e,t,i,r,a,s,o,l,h,f,d,p,g,_,T,y){Ve.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,l,h,f,d,p,g,_,T,y)}set(e,t,i,r,a,s,o,l,h,f,d,p,g,_,T,y){const v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=r,v[1]=a,v[5]=s,v[9]=o,v[13]=l,v[2]=h,v[6]=f,v[10]=d,v[14]=p,v[3]=g,v[7]=_,v[11]=T,v[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ve().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/Jh.setFromMatrixColumn(e,0).length(),a=1/Jh.setFromMatrixColumn(e,1).length(),s=1/Jh.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*a,t[5]=i[5]*a,t[6]=i[6]*a,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),o=Math.sin(i),l=Math.cos(r),h=Math.sin(r),f=Math.cos(a),d=Math.sin(a);if(e.order==="XYZ"){const p=s*f,g=s*d,_=o*f,T=o*d;t[0]=l*f,t[4]=-l*d,t[8]=h,t[1]=g+_*h,t[5]=p-T*h,t[9]=-o*l,t[2]=T-p*h,t[6]=_+g*h,t[10]=s*l}else if(e.order==="YXZ"){const p=l*f,g=l*d,_=h*f,T=h*d;t[0]=p+T*o,t[4]=_*o-g,t[8]=s*h,t[1]=s*d,t[5]=s*f,t[9]=-o,t[2]=g*o-_,t[6]=T+p*o,t[10]=s*l}else if(e.order==="ZXY"){const p=l*f,g=l*d,_=h*f,T=h*d;t[0]=p-T*o,t[4]=-s*d,t[8]=_+g*o,t[1]=g+_*o,t[5]=s*f,t[9]=T-p*o,t[2]=-s*h,t[6]=o,t[10]=s*l}else if(e.order==="ZYX"){const p=s*f,g=s*d,_=o*f,T=o*d;t[0]=l*f,t[4]=_*h-g,t[8]=p*h+T,t[1]=l*d,t[5]=T*h+p,t[9]=g*h-_,t[2]=-h,t[6]=o*l,t[10]=s*l}else if(e.order==="YZX"){const p=s*l,g=s*h,_=o*l,T=o*h;t[0]=l*f,t[4]=T-p*d,t[8]=_*d+g,t[1]=d,t[5]=s*f,t[9]=-o*f,t[2]=-h*f,t[6]=g*d+_,t[10]=p-T*d}else if(e.order==="XZY"){const p=s*l,g=s*h,_=o*l,T=o*h;t[0]=l*f,t[4]=-d,t[8]=h*f,t[1]=p*d+T,t[5]=s*f,t[9]=g*d-_,t[2]=_*d-g,t[6]=o*f,t[10]=T*d+p}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(SG,e,TG)}lookAt(e,t,i){const r=this.elements;return xa.subVectors(e,t),xa.lengthSq()===0&&(xa.z=1),xa.normalize(),Ll.crossVectors(i,xa),Ll.lengthSq()===0&&(Math.abs(i.z)===1?xa.x+=1e-4:xa.z+=1e-4,xa.normalize(),Ll.crossVectors(i,xa)),Ll.normalize(),nv.crossVectors(xa,Ll),r[0]=Ll.x,r[4]=nv.x,r[8]=xa.x,r[1]=Ll.y,r[5]=nv.y,r[9]=xa.y,r[2]=Ll.z,r[6]=nv.z,r[10]=xa.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[4],l=i[8],h=i[12],f=i[1],d=i[5],p=i[9],g=i[13],_=i[2],T=i[6],y=i[10],v=i[14],S=i[3],E=i[7],b=i[11],N=i[15],R=r[0],I=r[4],U=r[8],O=r[12],w=r[1],B=r[5],j=r[9],ee=r[13],se=r[2],ae=r[6],W=r[10],te=r[14],K=r[3],oe=r[7],ie=r[11],Ce=r[15];return a[0]=s*R+o*w+l*se+h*K,a[4]=s*I+o*B+l*ae+h*oe,a[8]=s*U+o*j+l*W+h*ie,a[12]=s*O+o*ee+l*te+h*Ce,a[1]=f*R+d*w+p*se+g*K,a[5]=f*I+d*B+p*ae+g*oe,a[9]=f*U+d*j+p*W+g*ie,a[13]=f*O+d*ee+p*te+g*Ce,a[2]=_*R+T*w+y*se+v*K,a[6]=_*I+T*B+y*ae+v*oe,a[10]=_*U+T*j+y*W+v*ie,a[14]=_*O+T*ee+y*te+v*Ce,a[3]=S*R+E*w+b*se+N*K,a[7]=S*I+E*B+b*ae+N*oe,a[11]=S*U+E*j+b*W+N*ie,a[15]=S*O+E*ee+b*te+N*Ce,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],i=e[4],r=e[8],a=e[12],s=e[1],o=e[5],l=e[9],h=e[13],f=e[2],d=e[6],p=e[10],g=e[14],_=e[3],T=e[7],y=e[11],v=e[15];return _*(+a*l*d-r*h*d-a*o*p+i*h*p+r*o*g-i*l*g)+T*(+t*l*g-t*h*p+a*s*p-r*s*g+r*h*f-a*l*f)+y*(+t*h*d-t*o*g-a*s*d+i*s*g+a*o*f-i*h*f)+v*(-r*o*f-t*l*d+t*o*p+r*s*d-i*s*p+i*l*f)}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,i){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]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],h=e[7],f=e[8],d=e[9],p=e[10],g=e[11],_=e[12],T=e[13],y=e[14],v=e[15],S=d*y*h-T*p*h+T*l*g-o*y*g-d*l*v+o*p*v,E=_*p*h-f*y*h-_*l*g+s*y*g+f*l*v-s*p*v,b=f*T*h-_*d*h+_*o*g-s*T*g-f*o*v+s*d*v,N=_*d*l-f*T*l-_*o*p+s*T*p+f*o*y-s*d*y,R=t*S+i*E+r*b+a*N;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const I=1/R;return e[0]=S*I,e[1]=(T*p*a-d*y*a-T*r*g+i*y*g+d*r*v-i*p*v)*I,e[2]=(o*y*a-T*l*a+T*r*h-i*y*h-o*r*v+i*l*v)*I,e[3]=(d*l*a-o*p*a-d*r*h+i*p*h+o*r*g-i*l*g)*I,e[4]=E*I,e[5]=(f*y*a-_*p*a+_*r*g-t*y*g-f*r*v+t*p*v)*I,e[6]=(_*l*a-s*y*a-_*r*h+t*y*h+s*r*v-t*l*v)*I,e[7]=(s*p*a-f*l*a+f*r*h-t*p*h-s*r*g+t*l*g)*I,e[8]=b*I,e[9]=(_*d*a-f*T*a-_*i*g+t*T*g+f*i*v-t*d*v)*I,e[10]=(s*T*a-_*o*a+_*i*h-t*T*h-s*i*v+t*o*v)*I,e[11]=(f*o*a-s*d*a-f*i*h+t*d*h+s*i*g-t*o*g)*I,e[12]=N*I,e[13]=(f*T*r-_*d*r+_*i*p-t*T*p-f*i*y+t*d*y)*I,e[14]=(_*o*r-s*T*r-_*i*l+t*T*l+s*i*y-t*o*y)*I,e[15]=(s*d*r-f*o*r+f*i*l-t*d*l-s*i*p+t*o*p)*I,this}scale(e){const t=this.elements,i=e.x,r=e.y,a=e.z;return t[0]*=i,t[4]*=r,t[8]*=a,t[1]*=i,t[5]*=r,t[9]*=a,t[2]*=i,t[6]*=r,t[10]*=a,t[3]*=i,t[7]*=r,t[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=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,i,r))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),a=1-i,s=e.x,o=e.y,l=e.z,h=a*s,f=a*o;return this.set(h*s+i,h*o-r*l,h*l+r*o,0,h*o+r*l,f*o+i,f*l-r*s,0,h*l-r*o,f*l+r*s,a*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,a=t._x,s=t._y,o=t._z,l=t._w,h=a+a,f=s+s,d=o+o,p=a*h,g=a*f,_=a*d,T=s*f,y=s*d,v=o*d,S=l*h,E=l*f,b=l*d,N=i.x,R=i.y,I=i.z;return r[0]=(1-(T+v))*N,r[1]=(g+b)*N,r[2]=(_-E)*N,r[3]=0,r[4]=(g-b)*R,r[5]=(1-(p+v))*R,r[6]=(y+S)*R,r[7]=0,r[8]=(_+E)*I,r[9]=(y-S)*I,r[10]=(1-(p+T))*I,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let a=Jh.set(r[0],r[1],r[2]).length();const s=Jh.set(r[4],r[5],r[6]).length(),o=Jh.set(r[8],r[9],r[10]).length();this.determinant()<0&&(a=-a),e.x=r[12],e.y=r[13],e.z=r[14],vs.copy(this);const h=1/a,f=1/s,d=1/o;return vs.elements[0]*=h,vs.elements[1]*=h,vs.elements[2]*=h,vs.elements[4]*=f,vs.elements[5]*=f,vs.elements[6]*=f,vs.elements[8]*=d,vs.elements[9]*=d,vs.elements[10]*=d,t.setFromRotationMatrix(vs),i.x=a,i.y=s,i.z=o,this}makePerspective(e,t,i,r,a,s,o=wa,l=!1){const h=this.elements,f=2*a/(t-e),d=2*a/(i-r),p=(t+e)/(t-e),g=(i+r)/(i-r);let _,T;if(l)_=a/(s-a),T=s*a/(s-a);else if(o===wa)_=-(s+a)/(s-a),T=-2*s*a/(s-a);else if(o===Ad)_=-s/(s-a),T=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return h[0]=f,h[4]=0,h[8]=p,h[12]=0,h[1]=0,h[5]=d,h[9]=g,h[13]=0,h[2]=0,h[6]=0,h[10]=_,h[14]=T,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,i,r,a,s,o=wa,l=!1){const h=this.elements,f=2/(t-e),d=2/(i-r),p=-(t+e)/(t-e),g=-(i+r)/(i-r);let _,T;if(l)_=1/(s-a),T=s/(s-a);else if(o===wa)_=-2/(s-a),T=-(s+a)/(s-a);else if(o===Ad)_=-1/(s-a),T=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return h[0]=f,h[4]=0,h[8]=0,h[12]=p,h[1]=0,h[5]=d,h[9]=0,h[13]=g,h[2]=0,h[6]=0,h[10]=_,h[14]=T,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Jh=new L,vs=new Ve,SG=new L(0,0,0),TG=new L(1,1,1),Ll=new L,nv=new L,xa=new L,M4=new Ve,b4=new _t;class zi{constructor(e=0,t=0,i=0,r=zi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,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,i,r=this._order){return this._x=e,this._y=t,this._z=i,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,t=this._order,i=!0){const r=e.elements,a=r[0],s=r[4],o=r[8],l=r[1],h=r[5],f=r[9],d=r[2],p=r[6],g=r[10];switch(t){case"XYZ":this._y=Math.asin(Lt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,g),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(p,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Lt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(l,h)):(this._y=Math.atan2(-d,a),this._z=0);break;case"ZXY":this._x=Math.asin(Lt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-d,g),this._z=Math.atan2(-s,h)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-Lt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(p,g),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,h));break;case"YZX":this._z=Math.asin(Lt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-f,h),this._y=Math.atan2(-d,a)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-Lt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(p,h),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-f,g),this._y=0);break;default:ut("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return M4.makeRotationFromQuaternion(e),this.setFromRotationMatrix(M4,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return b4.setFromEuler(this),this.setFromQuaternion(b4,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}zi.DEFAULT_ORDER="XYZ";class Cd{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let EG=0;const A4=new L,$h=new _t,No=new Ve,iv=new L,Hp=new L,MG=new L,bG=new _t,w4=new L(1,0,0),R4=new L(0,1,0),C4=new L(0,0,1),D4={type:"added"},AG={type:"removed"},ef={type:"childadded",child:null},VT={type:"childremoved",child:null};class Wt extends ra{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:EG++}),this.uuid=Oa(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Wt.DEFAULT_UP.clone();const e=new L,t=new zi,i=new _t,r=new L(1,1,1);function a(){i.setFromEuler(t,!1)}function s(){t.setFromQuaternion(i,void 0,!1)}t._onChange(a),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Ve},normalMatrix:{value:new Et}}),this.matrix=new Ve,this.matrixWorld=new Ve,this.matrixAutoUpdate=Wt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Wt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Cd,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.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 $h.setFromAxisAngle(e,t),this.quaternion.multiply($h),this}rotateOnWorldAxis(e,t){return $h.setFromAxisAngle(e,t),this.quaternion.premultiply($h),this}rotateX(e){return this.rotateOnAxis(w4,e)}rotateY(e){return this.rotateOnAxis(R4,e)}rotateZ(e){return this.rotateOnAxis(C4,e)}translateOnAxis(e,t){return A4.copy(e).applyQuaternion(this.quaternion),this.position.add(A4.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(w4,e)}translateY(e){return this.translateOnAxis(R4,e)}translateZ(e){return this.translateOnAxis(C4,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(No.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?iv.copy(e):iv.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Hp.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?No.lookAt(Hp,iv,this.up):No.lookAt(iv,Hp,this.up),this.quaternion.setFromRotationMatrix(No),r&&(No.extractRotation(r.matrixWorld),$h.setFromRotationMatrix(No),this.quaternion.premultiply($h.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Bt("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(D4),ef.child=e,this.dispatchEvent(ef),ef.child=null):Bt("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(AG),VT.child=e,this.dispatchEvent(VT),VT.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),No.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),No.multiply(e.parent.matrixWorld)),e.applyMatrix4(No),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(D4),ef.child=e,this.dispatchEvent(ef),ef.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 i=0,r=this.children.length;i<r;i++){const s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hp,e,MG),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hp,bG,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 i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(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)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(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(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function a(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let h=0,f=l.length;h<f;h++){const d=l[h];a(e.shapes,d)}else a(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,h=this.material.length;l<h;l++)o.push(a(e.materials,this.material[l]));r.material=o}else r.material=a(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(a(e.animations,l))}}if(t){const o=s(e.geometries),l=s(e.materials),h=s(e.textures),f=s(e.images),d=s(e.shapes),p=s(e.skeletons),g=s(e.animations),_=s(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),h.length>0&&(i.textures=h),f.length>0&&(i.images=f),d.length>0&&(i.shapes=d),p.length>0&&(i.skeletons=p),g.length>0&&(i.animations=g),_.length>0&&(i.nodes=_)}return i.object=r,i;function s(o){const l=[];for(const h in o){const f=o[h];delete f.metadata,l.push(f)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.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)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}Wt.DEFAULT_UP=new L(0,1,0);Wt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Wt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const _s=new L,Oo=new L,kT=new L,Lo=new L,tf=new L,nf=new L,N4=new L,WT=new L,XT=new L,YT=new L,qT=new zt,jT=new zt,ZT=new zt;class Jr{constructor(e=new L,t=new L,i=new L){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),_s.subVectors(e,t),r.cross(_s);const a=r.lengthSq();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,t,i,r,a){_s.subVectors(r,t),Oo.subVectors(i,t),kT.subVectors(e,t);const s=_s.dot(_s),o=_s.dot(Oo),l=_s.dot(kT),h=Oo.dot(Oo),f=Oo.dot(kT),d=s*h-o*o;if(d===0)return a.set(0,0,0),null;const p=1/d,g=(h*l-o*f)*p,_=(s*f-o*l)*p;return a.set(1-g-_,_,g)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Lo)===null?!1:Lo.x>=0&&Lo.y>=0&&Lo.x+Lo.y<=1}static getInterpolation(e,t,i,r,a,s,o,l){return this.getBarycoord(e,t,i,r,Lo)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(a,Lo.x),l.addScaledVector(s,Lo.y),l.addScaledVector(o,Lo.z),l)}static getInterpolatedAttribute(e,t,i,r,a,s){return qT.setScalar(0),jT.setScalar(0),ZT.setScalar(0),qT.fromBufferAttribute(e,t),jT.fromBufferAttribute(e,i),ZT.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(qT,a.x),s.addScaledVector(jT,a.y),s.addScaledVector(ZT,a.z),s}static isFrontFacing(e,t,i,r){return _s.subVectors(i,t),Oo.subVectors(e,t),_s.cross(Oo).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),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 _s.subVectors(this.c,this.b),Oo.subVectors(this.a,this.b),_s.cross(Oo).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Jr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Jr.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,a){return Jr.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}containsPoint(e){return Jr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Jr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,a=this.c;let s,o;tf.subVectors(r,i),nf.subVectors(a,i),WT.subVectors(e,i);const l=tf.dot(WT),h=nf.dot(WT);if(l<=0&&h<=0)return t.copy(i);XT.subVectors(e,r);const f=tf.dot(XT),d=nf.dot(XT);if(f>=0&&d<=f)return t.copy(r);const p=l*d-f*h;if(p<=0&&l>=0&&f<=0)return s=l/(l-f),t.copy(i).addScaledVector(tf,s);YT.subVectors(e,a);const g=tf.dot(YT),_=nf.dot(YT);if(_>=0&&g<=_)return t.copy(a);const T=g*h-l*_;if(T<=0&&h>=0&&_<=0)return o=h/(h-_),t.copy(i).addScaledVector(nf,o);const y=f*_-g*d;if(y<=0&&d-f>=0&&g-_>=0)return N4.subVectors(a,r),o=(d-f)/(d-f+(g-_)),t.copy(r).addScaledVector(N4,o);const v=1/(y+T+p);return s=T*v,o=p*v,t.copy(i).addScaledVector(tf,s).addScaledVector(nf,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const KU={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},Il={h:0,s:0,l:0},rv={h:0,s:0,l:0};function KT(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=dn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,en.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=en.workingColorSpace){return this.r=e,this.g=t,this.b=i,en.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=en.workingColorSpace){if(e=Cb(e,1),t=Lt(t,0,1),i=Lt(i,0,1),t===0)this.r=this.g=this.b=i;else{const a=i<=.5?i*(1+t):i+t-i*t,s=2*i-a;this.r=KT(s,a,e+1/3),this.g=KT(s,a,e),this.b=KT(s,a,e-1/3)}return en.colorSpaceToWorking(this,r),this}setStyle(e,t=dn){function i(a){a!==void 0&&parseFloat(a)<1&&ut("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=r[1],o=r[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:ut("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=r[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(s===6)return this.setHex(parseInt(a,16),t);ut("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=dn){const i=KU[e.toLowerCase()];return i!==void 0?this.setHex(i,t):ut("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=el(e.r),this.g=el(e.g),this.b=el(e.b),this}copyLinearToSRGB(e){return this.r=od(e.r),this.g=od(e.g),this.b=od(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=dn){return en.workingToColorSpace(xr.copy(this),e),Math.round(Lt(xr.r*255,0,255))*65536+Math.round(Lt(xr.g*255,0,255))*256+Math.round(Lt(xr.b*255,0,255))}getHexString(e=dn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=en.workingColorSpace){en.workingToColorSpace(xr.copy(this),t);const i=xr.r,r=xr.g,a=xr.b,s=Math.max(i,r,a),o=Math.min(i,r,a);let l,h;const f=(o+s)/2;if(o===s)l=0,h=0;else{const d=s-o;switch(h=f<=.5?d/(s+o):d/(2-s-o),s){case i:l=(r-a)/d+(r<a?6:0);break;case r:l=(a-i)/d+2;break;case a:l=(i-r)/d+4;break}l/=6}return e.h=l,e.s=h,e.l=f,e}getRGB(e,t=en.workingColorSpace){return en.workingToColorSpace(xr.copy(this),t),e.r=xr.r,e.g=xr.g,e.b=xr.b,e}getStyle(e=dn){en.workingToColorSpace(xr.copy(this),e);const t=xr.r,i=xr.g,r=xr.b;return e!==dn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(Il),this.setHSL(Il.h+e,Il.s+t,Il.l+i)}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,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Il),e.getHSL(rv);const i=Gm(Il.h,rv.h,t),r=Gm(Il.s,rv.s,t),a=Gm(Il.l,rv.l,t);return this.setHSL(i,r,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,a=e.elements;return this.r=a[0]*t+a[3]*i+a[6]*r,this.g=a[1]*t+a[4]*i+a[7]*r,this.b=a[2]*t+a[5]*i+a[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const xr=new qe;qe.NAMES=KU;let wG=0;class jn extends ra{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wG++}),this.uuid=Oa(),this.name="",this.type="Material",this.blending=zu,this.side=Ns,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ox,this.blendDst=lx,this.blendEquation=$s,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qe(0,0,0),this.blendAlpha=0,this.depthFunc=ju,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=mE,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Su,this.stencilZFail=Su,this.stencilZPass=Su,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){ut(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){ut(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zu&&(i.blending=this.blending),this.side!==Ns&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==ox&&(i.blendSrc=this.blendSrc),this.blendDst!==lx&&(i.blendDst=this.blendDst),this.blendEquation!==$s&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ju&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==mE&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Su&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Su&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Su&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(a){const s=[];for(const o in a){const l=a[o];delete l.metadata,s.push(l)}return s}if(t){const a=r(e.textures),s=r(e.images);a.length>0&&(i.textures=a),s.length>0&&(i.images=s)}return i}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 i=null;if(t!==null){const r=t.length;i=new Array(r);for(let a=0;a!==r;++a)i[a]=t[a].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ur extends jn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qe(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 zi,this.combine=B0,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 Yo=RG();function RG(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){const h=l-127;h<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):h<-14?(i[l]=1024>>-h-14,i[l|256]=1024>>-h-14|32768,r[l]=-h-1,r[l|256]=-h-1):h<=15?(i[l]=h+15<<10,i[l|256]=h+15<<10|32768,r[l]=13,r[l|256]=13):h<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}const a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let h=l<<13,f=0;for(;!(h&8388608);)h<<=1,f-=8388608;h&=-8388609,f+=947912704,a[l]=h|f}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)s[l]=l<<23;s[31]=1199570944,s[32]=2147483648;for(let l=33;l<63;++l)s[l]=2147483648+(l-32<<23);s[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}function qr(n){Math.abs(n)>65504&&ut("DataUtils.toHalfFloat(): Value out of range."),n=Lt(n,-65504,65504),Yo.floatView[0]=n;const e=Yo.uint32View[0],t=e>>23&511;return Yo.baseTable[t]+((e&8388607)>>Yo.shiftTable[t])}function pm(n){const e=n>>10;return Yo.uint32View[0]=Yo.mantissaTable[Yo.offsetTable[e]+(n&1023)]+Yo.exponentTable[e],Yo.floatView[0]}class gE{static toHalfFloat(e){return qr(e)}static fromHalfFloat(e){return pm(e)}}const Ri=new L,av=new de;let CG=0;class Ot{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:CG++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=m0,this.updateRanges=[],this.gpuType=si,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,a=this.itemSize;r<a;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)av.fromBufferAttribute(this,t),av.applyMatrix3(e),this.setXY(t,av.x,av.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Ri.fromBufferAttribute(this,t),Ri.applyMatrix3(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Ri.fromBufferAttribute(this,t),Ri.applyMatrix4(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ri.fromBufferAttribute(this,t),Ri.applyNormalMatrix(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ri.fromBufferAttribute(this,t),Ri.transformDirection(e),this.setXYZ(t,Ri.x,Ri.y,Ri.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Lr(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=jt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Lr(t,this.array)),t}setX(e,t){return this.normalized&&(t=jt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Lr(t,this.array)),t}setY(e,t){return this.normalized&&(t=jt(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=Lr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=jt(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=Lr(t,this.array)),t}setW(e,t){return this.normalized&&(t=jt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=jt(t,this.array),i=jt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=jt(t,this.array),i=jt(i,this.array),r=jt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e*=this.itemSize,this.normalized&&(t=jt(t,this.array),i=jt(i,this.array),r=jt(r,this.array),a=jt(a,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=a,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!==m0&&(e.usage=this.usage),e}}class DG extends Ot{constructor(e,t,i){super(new Int8Array(e),t,i)}}class NG extends Ot{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class OG extends Ot{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class LG extends Ot{constructor(e,t,i){super(new Int16Array(e),t,i)}}class Nb extends Ot{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class IG extends Ot{constructor(e,t,i){super(new Int32Array(e),t,i)}}class Ob extends Ot{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class UG extends Ot{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=pm(this.array[e*this.itemSize]);return this.normalized&&(t=Lr(t,this.array)),t}setX(e,t){return this.normalized&&(t=jt(t,this.array)),this.array[e*this.itemSize]=qr(t),this}getY(e){let t=pm(this.array[e*this.itemSize+1]);return this.normalized&&(t=Lr(t,this.array)),t}setY(e,t){return this.normalized&&(t=jt(t,this.array)),this.array[e*this.itemSize+1]=qr(t),this}getZ(e){let t=pm(this.array[e*this.itemSize+2]);return this.normalized&&(t=Lr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=jt(t,this.array)),this.array[e*this.itemSize+2]=qr(t),this}getW(e){let t=pm(this.array[e*this.itemSize+3]);return this.normalized&&(t=Lr(t,this.array)),t}setW(e,t){return this.normalized&&(t=jt(t,this.array)),this.array[e*this.itemSize+3]=qr(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=jt(t,this.array),i=jt(i,this.array)),this.array[e+0]=qr(t),this.array[e+1]=qr(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=jt(t,this.array),i=jt(i,this.array),r=jt(r,this.array)),this.array[e+0]=qr(t),this.array[e+1]=qr(i),this.array[e+2]=qr(r),this}setXYZW(e,t,i,r,a){return e*=this.itemSize,this.normalized&&(t=jt(t,this.array),i=jt(i,this.array),r=jt(r,this.array),a=jt(a,this.array)),this.array[e+0]=qr(t),this.array[e+1]=qr(i),this.array[e+2]=qr(r),this.array[e+3]=qr(a),this}}class yt extends Ot{constructor(e,t,i){super(new Float32Array(e),t,i)}}let PG=0;const Xa=new Ve,QT=new Wt,rf=new L,ya=new tr,Fp=new tr,Zi=new L;class Ct extends ra{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:PG++}),this.uuid=Oa(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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(XU(e)?Ob:Nb)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const a=new Et().getNormalMatrix(e);i.applyNormalMatrix(a),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Xa.makeRotationFromQuaternion(e),this.applyMatrix4(Xa),this}rotateX(e){return Xa.makeRotationX(e),this.applyMatrix4(Xa),this}rotateY(e){return Xa.makeRotationY(e),this.applyMatrix4(Xa),this}rotateZ(e){return Xa.makeRotationZ(e),this.applyMatrix4(Xa),this}translate(e,t,i){return Xa.makeTranslation(e,t,i),this.applyMatrix4(Xa),this}scale(e,t,i){return Xa.makeScale(e,t,i),this.applyMatrix4(Xa),this}lookAt(e){return QT.lookAt(e),QT.updateMatrix(),this.applyMatrix4(QT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(rf).negate(),this.translate(rf.x,rf.y,rf.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,a=e.length;r<a;r++){const s=e[r];i.push(s.x,s.y,s.z||0)}this.setAttribute("position",new yt(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const a=e[r];t.setXYZ(r,a.x,a.y,a.z||0)}e.length>t.count&&ut("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new tr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Bt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const a=t[i];ya.setFromBufferAttribute(a),this.morphTargetsRelative?(Zi.addVectors(this.boundingBox.min,ya.min),this.boundingBox.expandByPoint(Zi),Zi.addVectors(this.boundingBox.max,ya.max),this.boundingBox.expandByPoint(Zi)):(this.boundingBox.expandByPoint(ya.min),this.boundingBox.expandByPoint(ya.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Bt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new nr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Bt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new L,1/0);return}if(e){const i=this.boundingSphere.center;if(ya.setFromBufferAttribute(e),t)for(let a=0,s=t.length;a<s;a++){const o=t[a];Fp.setFromBufferAttribute(o),this.morphTargetsRelative?(Zi.addVectors(ya.min,Fp.min),ya.expandByPoint(Zi),Zi.addVectors(ya.max,Fp.max),ya.expandByPoint(Zi)):(ya.expandByPoint(Fp.min),ya.expandByPoint(Fp.max))}ya.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)Zi.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(Zi));if(t)for(let a=0,s=t.length;a<s;a++){const o=t[a],l=this.morphTargetsRelative;for(let h=0,f=o.count;h<f;h++)Zi.fromBufferAttribute(o,h),l&&(rf.fromBufferAttribute(e,h),Zi.add(rf)),r=Math.max(r,i.distanceToSquared(Zi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Bt('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(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Bt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,a=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ot(new Float32Array(4*i.count),4));const s=this.getAttribute("tangent"),o=[],l=[];for(let U=0;U<i.count;U++)o[U]=new L,l[U]=new L;const h=new L,f=new L,d=new L,p=new de,g=new de,_=new de,T=new L,y=new L;function v(U,O,w){h.fromBufferAttribute(i,U),f.fromBufferAttribute(i,O),d.fromBufferAttribute(i,w),p.fromBufferAttribute(a,U),g.fromBufferAttribute(a,O),_.fromBufferAttribute(a,w),f.sub(h),d.sub(h),g.sub(p),_.sub(p);const B=1/(g.x*_.y-_.x*g.y);isFinite(B)&&(T.copy(f).multiplyScalar(_.y).addScaledVector(d,-g.y).multiplyScalar(B),y.copy(d).multiplyScalar(g.x).addScaledVector(f,-_.x).multiplyScalar(B),o[U].add(T),o[O].add(T),o[w].add(T),l[U].add(y),l[O].add(y),l[w].add(y))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let U=0,O=S.length;U<O;++U){const w=S[U],B=w.start,j=w.count;for(let ee=B,se=B+j;ee<se;ee+=3)v(e.getX(ee+0),e.getX(ee+1),e.getX(ee+2))}const E=new L,b=new L,N=new L,R=new L;function I(U){N.fromBufferAttribute(r,U),R.copy(N);const O=o[U];E.copy(O),E.sub(N.multiplyScalar(N.dot(O))).normalize(),b.crossVectors(R,O);const B=b.dot(l[U])<0?-1:1;s.setXYZW(U,E.x,E.y,E.z,B)}for(let U=0,O=S.length;U<O;++U){const w=S[U],B=w.start,j=w.count;for(let ee=B,se=B+j;ee<se;ee+=3)I(e.getX(ee+0)),I(e.getX(ee+1)),I(e.getX(ee+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Ot(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let p=0,g=i.count;p<g;p++)i.setXYZ(p,0,0,0);const r=new L,a=new L,s=new L,o=new L,l=new L,h=new L,f=new L,d=new L;if(e)for(let p=0,g=e.count;p<g;p+=3){const _=e.getX(p+0),T=e.getX(p+1),y=e.getX(p+2);r.fromBufferAttribute(t,_),a.fromBufferAttribute(t,T),s.fromBufferAttribute(t,y),f.subVectors(s,a),d.subVectors(r,a),f.cross(d),o.fromBufferAttribute(i,_),l.fromBufferAttribute(i,T),h.fromBufferAttribute(i,y),o.add(f),l.add(f),h.add(f),i.setXYZ(_,o.x,o.y,o.z),i.setXYZ(T,l.x,l.y,l.z),i.setXYZ(y,h.x,h.y,h.z)}else for(let p=0,g=t.count;p<g;p+=3)r.fromBufferAttribute(t,p+0),a.fromBufferAttribute(t,p+1),s.fromBufferAttribute(t,p+2),f.subVectors(s,a),d.subVectors(r,a),f.cross(d),i.setXYZ(p+0,f.x,f.y,f.z),i.setXYZ(p+1,f.x,f.y,f.z),i.setXYZ(p+2,f.x,f.y,f.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Zi.fromBufferAttribute(e,t),Zi.normalize(),e.setXYZ(t,Zi.x,Zi.y,Zi.z)}toNonIndexed(){function e(o,l){const h=o.array,f=o.itemSize,d=o.normalized,p=new h.constructor(l.length*f);let g=0,_=0;for(let T=0,y=l.length;T<y;T++){o.isInterleavedBufferAttribute?g=l[T]*o.data.stride+o.offset:g=l[T]*f;for(let v=0;v<f;v++)p[_++]=h[g++]}return new Ot(p,f,d)}if(this.index===null)return ut("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Ct,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],h=e(l,i);t.setAttribute(o,h)}const a=this.morphAttributes;for(const o in a){const l=[],h=a[o];for(let f=0,d=h.length;f<d;f++){const p=h[f],g=e(p,i);l.push(g)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,l=s.length;o<l;o++){const h=s[o];t.addGroup(h.start,h.count,h.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,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),this.parameters!==void 0){const l=this.parameters;for(const h in l)l[h]!==void 0&&(e[h]=l[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const h=i[l];e.data.attributes[l]=h.toJSON(e.data)}const r={};let a=!1;for(const l in this.morphAttributes){const h=this.morphAttributes[l],f=[];for(let d=0,p=h.length;d<p;d++){const g=h[d];f.push(g.toJSON(e.data))}f.length>0&&(r[l]=f,a=!0)}a&&(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 o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const h in r){const f=r[h];this.setAttribute(h,f.clone(t))}const a=e.morphAttributes;for(const h in a){const f=[],d=a[h];for(let p=0,g=d.length;p<g;p++)f.push(d[p].clone(t));this.morphAttributes[h]=f}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let h=0,f=s.length;h<f;h++){const d=s[h];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const O4=new Ve,Jc=new Ac,sv=new nr,L4=new L,ov=new L,lv=new L,cv=new L,JT=new L,uv=new L,I4=new L,hv=new L;class oi extends Wt{constructor(e=new Ct,t=new Ur){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){const o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,a=i.morphAttributes.position,s=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(a&&o){uv.set(0,0,0);for(let l=0,h=a.length;l<h;l++){const f=o[l],d=a[l];f!==0&&(JT.fromBufferAttribute(d,e),s?uv.addScaledVector(JT,f):uv.addScaledVector(JT.sub(t),f))}t.add(uv)}return t}raycast(e,t){const i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),sv.copy(i.boundingSphere),sv.applyMatrix4(a),Jc.copy(e.ray).recast(e.near),!(sv.containsPoint(Jc.origin)===!1&&(Jc.intersectSphere(sv,L4)===null||Jc.origin.distanceToSquared(L4)>(e.far-e.near)**2))&&(O4.copy(a).invert(),Jc.copy(e.ray).applyMatrix4(O4),!(i.boundingBox!==null&&Jc.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Jc)))}_computeIntersections(e,t,i){let r;const a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,h=a.attributes.uv,f=a.attributes.uv1,d=a.attributes.normal,p=a.groups,g=a.drawRange;if(o!==null)if(Array.isArray(s))for(let _=0,T=p.length;_<T;_++){const y=p[_],v=s[y.materialIndex],S=Math.max(y.start,g.start),E=Math.min(o.count,Math.min(y.start+y.count,g.start+g.count));for(let b=S,N=E;b<N;b+=3){const R=o.getX(b),I=o.getX(b+1),U=o.getX(b+2);r=fv(this,v,e,i,h,f,d,R,I,U),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=y.materialIndex,t.push(r))}}else{const _=Math.max(0,g.start),T=Math.min(o.count,g.start+g.count);for(let y=_,v=T;y<v;y+=3){const S=o.getX(y),E=o.getX(y+1),b=o.getX(y+2);r=fv(this,s,e,i,h,f,d,S,E,b),r&&(r.faceIndex=Math.floor(y/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(s))for(let _=0,T=p.length;_<T;_++){const y=p[_],v=s[y.materialIndex],S=Math.max(y.start,g.start),E=Math.min(l.count,Math.min(y.start+y.count,g.start+g.count));for(let b=S,N=E;b<N;b+=3){const R=b,I=b+1,U=b+2;r=fv(this,v,e,i,h,f,d,R,I,U),r&&(r.faceIndex=Math.floor(b/3),r.face.materialIndex=y.materialIndex,t.push(r))}}else{const _=Math.max(0,g.start),T=Math.min(l.count,g.start+g.count);for(let y=_,v=T;y<v;y+=3){const S=y,E=y+1,b=y+2;r=fv(this,s,e,i,h,f,d,S,E,b),r&&(r.faceIndex=Math.floor(y/3),t.push(r))}}}}function zG(n,e,t,i,r,a,s,o){let l;if(e.side===Ii?l=i.intersectTriangle(s,a,r,!0,o):l=i.intersectTriangle(r,a,s,e.side===Ns,o),l===null)return null;hv.copy(o),hv.applyMatrix4(n.matrixWorld);const h=t.ray.origin.distanceTo(hv);return h<t.near||h>t.far?null:{distance:h,point:hv.clone(),object:n}}function fv(n,e,t,i,r,a,s,o,l,h){n.getVertexPosition(o,ov),n.getVertexPosition(l,lv),n.getVertexPosition(h,cv);const f=zG(n,e,t,i,ov,lv,cv,I4);if(f){const d=new L;Jr.getBarycoord(I4,ov,lv,cv,d),r&&(f.uv=Jr.getInterpolatedAttribute(r,o,l,h,d,new de)),a&&(f.uv1=Jr.getInterpolatedAttribute(a,o,l,h,d,new de)),s&&(f.normal=Jr.getInterpolatedAttribute(s,o,l,h,d,new L),f.normal.dot(i.direction)>0&&f.normal.multiplyScalar(-1));const p={a:o,b:l,c:h,normal:new L,materialIndex:0};Jr.getNormal(ov,lv,cv,p.normal),f.face=p,f.barycoord=d}return f}class fh extends Ct{constructor(e=1,t=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};const o=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);const l=[],h=[],f=[],d=[];let p=0,g=0;_("z","y","x",-1,-1,i,t,e,s,a,0),_("z","y","x",1,-1,i,t,-e,s,a,1),_("x","z","y",1,1,e,i,t,r,s,2),_("x","z","y",1,-1,e,i,-t,r,s,3),_("x","y","z",1,-1,e,t,i,r,a,4),_("x","y","z",-1,-1,e,t,-i,r,a,5),this.setIndex(l),this.setAttribute("position",new yt(h,3)),this.setAttribute("normal",new yt(f,3)),this.setAttribute("uv",new yt(d,2));function _(T,y,v,S,E,b,N,R,I,U,O){const w=b/I,B=N/U,j=b/2,ee=N/2,se=R/2,ae=I+1,W=U+1;let te=0,K=0;const oe=new L;for(let ie=0;ie<W;ie++){const Ce=ie*B-ee;for(let Xe=0;Xe<ae;Xe++){const nt=Xe*w-j;oe[T]=nt*S,oe[y]=Ce*E,oe[v]=se,h.push(oe.x,oe.y,oe.z),oe[T]=0,oe[y]=0,oe[v]=R>0?1:-1,f.push(oe.x,oe.y,oe.z),d.push(Xe/I),d.push(1-ie/U),te+=1}}for(let ie=0;ie<U;ie++)for(let Ce=0;Ce<I;Ce++){const Xe=p+Ce+ae*ie,nt=p+Ce+ae*(ie+1),tt=p+(Ce+1)+ae*(ie+1),gt=p+(Ce+1)+ae*ie;l.push(Xe,nt,gt),l.push(nt,tt,gt),K+=6}o.addGroup(g,K,O),g+=K,p+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fh(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Dd(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(ut("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function Rr(n){const e={};for(let t=0;t<n.length;t++){const i=Dd(n[t]);for(const r in i)e[r]=i[r]}return e}function BG(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function QU(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:en.workingColorSpace}const Lb={clone:Dd,merge:Rr};var HG=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,FG=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class Vi extends jn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=HG,this.fragmentShader=FG,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Dd(e.uniforms),this.uniformsGroups=BG(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 s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}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 i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class wc extends Wt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ve,this.projectionMatrix=new Ve,this.projectionMatrixInverse=new Ve,this.coordinateSystem=wa,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){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 Ul=new L,U4=new de,P4=new de;let hi=class extends wc{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,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=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Rd*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Bu*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Rd*2*Math.atan(Math.tan(Bu*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Ul.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ul.x,Ul.y).multiplyScalar(-e/Ul.z),Ul.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ul.x,Ul.y).multiplyScalar(-e/Ul.z)}getViewSize(e,t){return this.getViewBounds(e,U4,P4),t.subVectors(P4,U4)}setViewOffset(e,t,i,r,a,s){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Bu*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,a=-.5*r;const s=this.view;if(this.view!==null&&this.view.enabled){const l=s.fullWidth,h=s.fullHeight;a+=s.offsetX*r/l,t-=s.offsetY*i/h,r*=s.width/l,i*=s.height/h}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};const af=-90,sf=1;class JU extends Wt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new hi(af,sf,e,t);r.layers=this.layers,this.add(r);const a=new hi(af,sf,e,t);a.layers=this.layers,this.add(a);const s=new hi(af,sf,e,t);s.layers=this.layers,this.add(s);const o=new hi(af,sf,e,t);o.layers=this.layers,this.add(o);const l=new hi(af,sf,e,t);l.layers=this.layers,this.add(l);const h=new hi(af,sf,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,a,s,o,l]=t;for(const h of t)this.remove(h);if(e===wa)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ad)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,l,h,f]=this.children,d=e.getRenderTarget(),p=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const T=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,a),e.setRenderTarget(i,1,r),e.render(t,s),e.setRenderTarget(i,2,r),e.render(t,o),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,h),i.texture.generateMipmaps=T,e.setRenderTarget(i,5,r),e.render(t,f),e.setRenderTarget(d,p,g),e.xr.enabled=_,i.texture.needsPMREMUpdate=!0}}class G0 extends Nn{constructor(e=[],t=ol,i,r,a,s,o,l,h,f){super(e,t,i,r,a,s,o,l,h,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class $U extends xi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new G0(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`,fragmentShader:`

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`},r=new fh(5,5,5),a=new Vi({name:"CubemapFromEquirect",uniforms:Dd(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ii,blending:Er});a.uniforms.tEquirect.value=t;const s=new oi(r,a),o=t.minFilter;return t.minFilter===Aa&&(t.minFilter=Ht),new JU(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,r);e.setRenderTarget(a)}}class Pr extends Wt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const GG={type:"move"};class E_{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Pr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Pr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Pr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,a=null,s=null;const o=this._targetRay,l=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){s=!0;for(const T of e.hand.values()){const y=t.getJointPose(T,i),v=this._getHandJoint(h,T);y!==null&&(v.matrix.fromArray(y.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=y.radius),v.visible=y!==null}const f=h.joints["index-finger-tip"],d=h.joints["thumb-tip"],p=f.position.distanceTo(d.position),g=.02,_=.005;h.inputState.pinching&&p>g+_?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&p<=g-_&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,i),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(GG)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=a!==null),h!==null&&(h.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Pr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class X1{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new qe(e),this.density=t}clone(){return new X1(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Y1{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new qe(e),this.near=t,this.far=i}clone(){return new Y1(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Nd extends Wt{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 zi,this.environmentIntensity=1,this.environmentRotation=new zi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Zd{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=m0,this.updateRanges=[],this.version=0,this.uuid=Oa()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,a=this.stride;r<a;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Oa()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Oa()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(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 wr=new L;class ll{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,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,i=this.data.count;t<i;t++)wr.fromBufferAttribute(this,t),wr.applyMatrix4(e),this.setXYZ(t,wr.x,wr.y,wr.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)wr.fromBufferAttribute(this,t),wr.applyNormalMatrix(e),this.setXYZ(t,wr.x,wr.y,wr.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)wr.fromBufferAttribute(this,t),wr.transformDirection(e),this.setXYZ(t,wr.x,wr.y,wr.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Lr(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=jt(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=jt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=jt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=jt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=jt(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=Lr(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Lr(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Lr(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Lr(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=jt(t,this.array),i=jt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=jt(t,this.array),i=jt(i,this.array),r=jt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=jt(t,this.array),i=jt(i,this.array),r=jt(r,this.array),a=jt(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=a,this}clone(e){if(e===void 0){v0("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return new Ot(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ll(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){v0("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(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 Ib extends jn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new qe(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 of;const Gp=new L,lf=new L,cf=new L,uf=new de,Vp=new de,e6=new Ve,dv=new L,kp=new L,pv=new L,z4=new de,$T=new de,B4=new de;class t6 extends Wt{constructor(e=new Ib){if(super(),this.isSprite=!0,this.type="Sprite",of===void 0){of=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Zd(t,5);of.setIndex([0,1,2,0,2,3]),of.setAttribute("position",new ll(i,3,0,!1)),of.setAttribute("uv",new ll(i,2,3,!1))}this.geometry=of,this.material=e,this.center=new de(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Bt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),lf.setFromMatrixScale(this.matrixWorld),e6.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),cf.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&lf.multiplyScalar(-cf.z);const i=this.material.rotation;let r,a;i!==0&&(a=Math.cos(i),r=Math.sin(i));const s=this.center;mv(dv.set(-.5,-.5,0),cf,s,lf,r,a),mv(kp.set(.5,-.5,0),cf,s,lf,r,a),mv(pv.set(.5,.5,0),cf,s,lf,r,a),z4.set(0,0),$T.set(1,0),B4.set(1,1);let o=e.ray.intersectTriangle(dv,kp,pv,!1,Gp);if(o===null&&(mv(kp.set(-.5,.5,0),cf,s,lf,r,a),$T.set(0,1),o=e.ray.intersectTriangle(dv,pv,kp,!1,Gp),o===null))return;const l=e.ray.origin.distanceTo(Gp);l<e.near||l>e.far||t.push({distance:l,point:Gp.clone(),uv:Jr.getInterpolation(Gp,dv,kp,pv,z4,$T,B4,new de),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function mv(n,e,t,i,r,a){uf.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(Vp.x=a*uf.x-r*uf.y,Vp.y=r*uf.x+a*uf.y):Vp.copy(uf),n.copy(e),n.x+=Vp.x,n.y+=Vp.y,n.applyMatrix4(e6)}const gv=new L,H4=new L;class n6 extends Wt{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const a=t[i];this.addLevel(a.object.clone(),a.distance,a.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let a;for(a=0;a<r.length&&!(t<r[a].distance);a++);return r.splice(a,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const r=t.splice(i,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let a=t[i].distance;if(t[i].object.visible&&(a-=a*t[i].hysteresis),e<a)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){gv.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(gv);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){gv.setFromMatrixPosition(e.matrixWorld),H4.setFromMatrixPosition(this.matrixWorld);const i=gv.distanceTo(H4)/e.zoom;t[0].object.visible=!0;let r,a;for(r=1,a=t.length;r<a;r++){let s=t[r].distance;if(t[r].object.visible&&(s-=s*t[r].hysteresis),i>=s)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<a;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,a=i.length;r<a;r++){const s=i[r];t.object.levels.push({object:s.object.uuid,distance:s.distance,hysteresis:s.hysteresis})}return t}}const F4=new L,G4=new zt,V4=new zt,VG=new L,k4=new Ve,vv=new L,e2=new nr,W4=new Ve,t2=new Ac;class q1 extends oi{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=pE,this.bindMatrix=new Ve,this.bindMatrixInverse=new Ve,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new tr),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,vv),this.boundingBox.expandByPoint(vv)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new nr),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,vv),this.boundingSphere.expandByPoint(vv)}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,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),e2.copy(this.boundingSphere),e2.applyMatrix4(r),e.ray.intersectsSphere(e2)!==!1&&(W4.copy(r).invert(),t2.copy(e.ray).applyMatrix4(W4),!(this.boundingBox!==null&&t2.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,t2)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new zt,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const a=1/e.manhattanLength();a!==1/0?e.multiplyScalar(a):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===pE?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===DU?this.bindMatrixInverse.copy(this.bindMatrix).invert():ut("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;G4.fromBufferAttribute(r.attributes.skinIndex,e),V4.fromBufferAttribute(r.attributes.skinWeight,e),F4.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){const s=V4.getComponent(a);if(s!==0){const o=G4.getComponent(a);k4.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(VG.copy(F4).applyMatrix4(k4),s)}}return t.applyMatrix4(this.bindMatrixInverse)}}class j1 extends Wt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class ea extends Nn{constructor(e=null,t=1,i=1,r,a,s,o,l,h=Vn,f=Vn,d,p){super(null,s,o,l,h,f,r,a,d,p),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const X4=new Ve,kG=new Ve;class Rc{constructor(e=[],t=[]){this.uuid=Oa(),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(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){ut("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Ve)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Ve;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let a=0,s=e.length;a<s;a++){const o=e[a]?e[a].matrixWorld:kG;X4.multiplyMatrices(o,t[a]),X4.toArray(i,a*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Rc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new ea(t,e,e,$n,si);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const a=e.bones[i];let s=t[a];s===void 0&&(ut("Skeleton: No bone found with UUID:",a),s=new j1),this.bones.push(s),this.boneInverses.push(new Ve().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,a=t.length;r<a;r++){const s=t[r];e.bones.push(s.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}class Ju extends Ot{constructor(e,t,i,r=1){super(e,t,i),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 hf=new Ve,Y4=new Ve,_v=[],q4=new tr,WG=new Ve,Wp=new oi,Xp=new nr;class Ub extends oi{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ju(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,WG)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new tr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,hf),q4.copy(e.boundingBox).applyMatrix4(hf),this.boundingBox.union(q4)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new nr),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,hf),Xp.copy(e.boundingSphere).applyMatrix4(hf),this.boundingSphere.union(Xp)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,a=i.length+1,s=e*a+1;for(let o=0;o<i.length;o++)i[o]=r[s+o]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(Wp.geometry=this.geometry,Wp.material=this.material,Wp.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Xp.copy(this.boundingSphere),Xp.applyMatrix4(i),e.ray.intersectsSphere(Xp)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,hf),Y4.multiplyMatrices(i,hf),Wp.matrixWorld=Y4,Wp.raycast(e,_v);for(let s=0,o=_v.length;s<o;s++){const l=_v[s];l.instanceId=a,l.object=this,t.push(l)}_v.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ju(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new ea(new Float32Array(r*this.count),r,this.count,ws,si));const a=this.morphTexture.source.data.data;let s=0;for(let h=0;h<i.length;h++)s+=i[h];const o=this.geometry.morphTargetsRelative?1:1-s,l=r*e;a[l]=o,a.set(i,l+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const n2=new L,XG=new L,YG=new Et;class ko{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=n2.subVectors(i,t).cross(XG.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 i=e.delta(n2),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return a<0||a>1?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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 i=t||YG.getNormalMatrix(e),r=this.coplanarPoint(n2).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),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 $c=new nr,qG=new de(.5,.5),xv=new L;class Kd{constructor(e=new ko,t=new ko,i=new ko,r=new ko,a=new ko,s=new ko){this.planes=[e,t,i,r,a,s]}set(e,t,i,r,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(a),o[5].copy(s),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=wa,i=!1){const r=this.planes,a=e.elements,s=a[0],o=a[1],l=a[2],h=a[3],f=a[4],d=a[5],p=a[6],g=a[7],_=a[8],T=a[9],y=a[10],v=a[11],S=a[12],E=a[13],b=a[14],N=a[15];if(r[0].setComponents(h-s,g-f,v-_,N-S).normalize(),r[1].setComponents(h+s,g+f,v+_,N+S).normalize(),r[2].setComponents(h+o,g+d,v+T,N+E).normalize(),r[3].setComponents(h-o,g-d,v-T,N-E).normalize(),i)r[4].setComponents(l,p,y,b).normalize(),r[5].setComponents(h-l,g-p,v-y,N-b).normalize();else if(r[4].setComponents(h-l,g-p,v-y,N-b).normalize(),t===wa)r[5].setComponents(h+l,g+p,v+y,N+b).normalize();else if(t===Ad)r[5].setComponents(l,p,y,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),$c.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),$c.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere($c)}intersectsSprite(e){$c.center.set(0,0,0);const t=qG.distanceTo(e.center);return $c.radius=.7071067811865476+t,$c.applyMatrix4(e.matrixWorld),this.intersectsSphere($c)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(xv.x=r.normal.x>0?e.max.x:e.min.x,xv.y=r.normal.y>0?e.max.y:e.min.y,xv.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(xv)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Ws=new Ve,Xs=new Kd;class Z1{constructor(){this.coordinateSystem=wa}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Ws.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Xs.setFromProjectionMatrix(Ws,r.coordinateSystem,r.reversedDepth),Xs.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Ws.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Xs.setFromProjectionMatrix(Ws,r.coordinateSystem,r.reversedDepth),Xs.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Ws.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Xs.setFromProjectionMatrix(Ws,r.coordinateSystem,r.reversedDepth),Xs.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Ws.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Xs.setFromProjectionMatrix(Ws,r.coordinateSystem,r.reversedDepth),Xs.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const r=t.cameras[i];if(Ws.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Xs.setFromProjectionMatrix(Ws,r.coordinateSystem,r.reversedDepth),Xs.containsPoint(e))return!0}return!1}clone(){return new Z1}}function i2(n,e){return n-e}function jG(n,e){return n.z-e.z}function ZG(n,e){return e.z-n.z}class KG{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,r){const a=this.pool,s=this.list;this.index>=a.length&&a.push({start:-1,count:-1,z:-1,index:-1});const o=a[this.index];s.push(o),this.index++,o.start=e,o.count=t,o.z=i,o.index=r}reset(){this.list.length=0,this.index=0}}const Yr=new Ve,QG=new qe(1,1,1),j4=new Kd,JG=new Z1,yv=new tr,eu=new nr,Yp=new L,Z4=new L,$G=new L,r2=new KG,yr=new oi,Sv=[];function eV(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let a=0;a<r;a++)for(let s=0;s<i;s++)e.setComponent(a+t,s,n.getComponent(a,s))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function tu(n,e){if(n.constructor!==e.constructor){const t=Math.min(n.length,e.length);for(let i=0;i<t;i++)e[i]=n[i]}else{const t=Math.min(n.length,e.length);e.set(new n.constructor(n.buffer,0,t))}}class i6 extends oi{constructor(e,t,i=t*2,r){super(new Ct,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new ea(t,e,e,$n,si);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new ea(t,e,e,F0,Os);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new ea(t,e,e,$n,si);i.colorSpace=en.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const a in e.attributes){const s=e.getAttribute(a),{array:o,itemSize:l,normalized:h}=s,f=new o.constructor(i*l),d=new Ot(f,l,h);t.setAttribute(a,d)}if(e.getIndex()!==null){const a=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new Ot(a,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),a=t.getAttribute(i);if(r.itemSize!==a.itemSize||r.normalized!==a.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new tr);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const a=t[i].geometryIndex;this.getMatrixAt(i,Yr),this.getBoundingBoxAt(a,yv).applyMatrix4(Yr),e.union(yv)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new nr);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const a=t[i].geometryIndex;this.getMatrixAt(i,Yr),this.getBoundingSphereAt(a,eu).applyMatrix4(Yr),e.union(eu)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:e};let r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(i2),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=i):(r=this._instanceInfo.length,this._instanceInfo.push(i));const a=this._matricesTexture;Yr.identity().toArray(a.image.data,r*16),a.needsUpdate=!0;const s=this._colorsTexture;return s&&(QG.toArray(s.image.data,r*4),s.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},a=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const s=e.getIndex();if(s!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=i===-1?s.count:i),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(i2),l=this._availableGeometryIds.shift(),a[l]=r):(l=this._geometryCount,this._geometryCount++,a.push(r)),this.setGeometryAt(l,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,l}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,a=i.getIndex(),s=t.getIndex(),o=this._geometryInfo[e];if(r&&s.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,h=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const f in i.attributes){const d=t.getAttribute(f),p=i.getAttribute(f);eV(d,p,l);const g=d.itemSize;for(let _=d.count,T=h;_<T;_++){const y=l+_;for(let v=0;v<g;v++)p.setComponent(y,v,0)}p.needsUpdate=!0,p.addUpdateRange(l*g,h*g)}if(r){const f=o.indexStart,d=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let p=0;p<s.count;p++)a.setX(f+p,l+s.getX(p));for(let p=s.count,g=d;p<g;p++)a.setX(f+p,l);a.needsUpdate=!0,a.addUpdateRange(f,o.reservedIndexCount)}return o.start=r?o.indexStart:o.vertexStart,o.count=r?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const i=this._instanceInfo;for(let r=0,a=i.length;r<a;r++)i[r].active&&i[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const i=this._geometryInfo,r=i.map((s,o)=>o).sort((s,o)=>i[s].vertexStart-i[o].vertexStart),a=this.geometry;for(let s=0,o=i.length;s<o;s++){const l=r[s],h=i[l];if(h.active!==!1){if(a.index!==null){if(h.indexStart!==t){const{indexStart:f,vertexStart:d,reservedIndexCount:p}=h,g=a.index,_=g.array,T=e-d;for(let y=f;y<f+p;y++)_[y]=_[y]+T;g.array.copyWithin(t,f,f+p),g.addUpdateRange(t,p),h.indexStart=t}t+=h.reservedIndexCount}if(h.vertexStart!==e){const{vertexStart:f,reservedVertexCount:d}=h,p=a.attributes;for(const g in p){const _=p[g],{array:T,itemSize:y}=_;T.copyWithin(e*y,f*y,(f+d)*y),_.addUpdateRange(e*y,d*y)}h.vertexStart=e}e+=h.reservedVertexCount,h.start=a.index?h.indexStart:h.vertexStart,this._nextIndexStart=a.index?h.indexStart+h.reservedIndexCount:0,this._nextVertexStart=h.vertexStart+h.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const a=new tr,s=i.index,o=i.attributes.position;for(let l=r.start,h=r.start+r.count;l<h;l++){let f=l;s&&(f=s.getX(f)),a.expandByPoint(Yp.fromBufferAttribute(o,f))}r.boundingBox=a}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const a=new nr;this.getBoundingBoxAt(e,yv),yv.getCenter(a.center);const s=i.index,o=i.attributes.position;let l=0;for(let h=r.start,f=r.start+r.count;h<f;h++){let d=h;s&&(d=s.getX(d)),Yp.fromBufferAttribute(o,d),l=Math.max(l,a.center.distanceToSquared(Yp))}a.radius=Math.sqrt(l),r.boundingSphere=a}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const i=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),i.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const i=this._geometryInfo[e];return t.vertexStart=i.vertexStart,t.vertexCount=i.vertexCount,t.reservedVertexCount=i.reservedVertexCount,t.indexStart=i.indexStart,t.indexCount=i.indexCount,t.reservedIndexCount=i.reservedIndexCount,t.start=i.start,t.count=i.count,t}setInstanceCount(e){const t=this._availableInstanceIds,i=this._instanceInfo;for(t.sort(i2);t[t.length-1]===i.length-1;)i.pop(),t.pop();if(e<i.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const r=new Int32Array(e),a=new Int32Array(e);tu(this._multiDrawCounts,r),tu(this._multiDrawStarts,a),this._multiDrawCounts=r,this._multiDrawStarts=a,this._maxInstanceCount=e;const s=this._indirectTexture,o=this._matricesTexture,l=this._colorsTexture;s.dispose(),this._initIndirectTexture(),tu(s.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),tu(o.image.data,this._matricesTexture.image.data),l&&(l.dispose(),this._initColorsTexture(),tu(l.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const i=[...this._geometryInfo].filter(o=>o.active);if(Math.max(...i.map(o=>o.vertexStart+o.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(l=>l.indexStart+l.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const a=this.geometry;a.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Ct,this._initializeGeometry(a));const s=this.geometry;a.index&&tu(a.index.array,s.index.array);for(const o in a.attributes)tu(a.attributes[o].array,s.attributes[o].array)}raycast(e,t){const i=this._instanceInfo,r=this._geometryInfo,a=this.matrixWorld,s=this.geometry;yr.material=this.material,yr.geometry.index=s.index,yr.geometry.attributes=s.attributes,yr.geometry.boundingBox===null&&(yr.geometry.boundingBox=new tr),yr.geometry.boundingSphere===null&&(yr.geometry.boundingSphere=new nr);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const h=i[o].geometryIndex,f=r[h];yr.geometry.setDrawRange(f.start,f.count),this.getMatrixAt(o,yr.matrixWorld).premultiply(a),this.getBoundingBoxAt(h,yr.geometry.boundingBox),this.getBoundingSphereAt(h,yr.geometry.boundingSphere),yr.raycast(e,Sv);for(let d=0,p=Sv.length;d<p;d++){const g=Sv[d];g.object=this,g.batchId=o,t.push(g)}Sv.length=0}yr.material=null,yr.geometry.index=null,yr.geometry.attributes={},yr.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=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,i,r,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=r.getIndex(),o=s===null?1:s.array.BYTES_PER_ELEMENT,l=this._instanceInfo,h=this._multiDrawStarts,f=this._multiDrawCounts,d=this._geometryInfo,p=this.perObjectFrustumCulled,g=this._indirectTexture,_=g.image.data,T=i.isArrayCamera?JG:j4;p&&!i.isArrayCamera&&(Yr.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),j4.setFromProjectionMatrix(Yr,i.coordinateSystem,i.reversedDepth));let y=0;if(this.sortObjects){Yr.copy(this.matrixWorld).invert(),Yp.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Yr),Z4.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(Yr);for(let E=0,b=l.length;E<b;E++)if(l[E].visible&&l[E].active){const N=l[E].geometryIndex;this.getMatrixAt(E,Yr),this.getBoundingSphereAt(N,eu).applyMatrix4(Yr);let R=!1;if(p&&(R=!T.intersectsSphere(eu,i)),!R){const I=d[N],U=$G.subVectors(eu.center,Yp).dot(Z4);r2.push(I.start,I.count,U,E)}}const v=r2.list,S=this.customSort;S===null?v.sort(a.transparent?ZG:jG):S.call(this,v,i);for(let E=0,b=v.length;E<b;E++){const N=v[E];h[y]=N.start*o,f[y]=N.count,_[y]=N.index,y++}r2.reset()}else for(let v=0,S=l.length;v<S;v++)if(l[v].visible&&l[v].active){const E=l[v].geometryIndex;let b=!1;if(p&&(this.getMatrixAt(v,Yr),this.getBoundingSphereAt(E,eu).applyMatrix4(Yr),b=!T.intersectsSphere(eu,i)),!b){const N=d[E];h[y]=N.start*o,f[y]=N.count,_[y]=v,y++}}g.needsUpdate=!0,this._multiDrawCount=y,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,a,s){this.onBeforeRender(e,null,r,a,s)}}class Bi extends jn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qe(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 Wx=new L,Xx=new L,K4=new Ve,qp=new Ac,Tv=new nr,a2=new L,Q4=new L;class oo extends Wt{constructor(e=new Ct,t=new Bi){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,a=t.count;r<a;r++)Wx.fromBufferAttribute(t,r-1),Xx.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Wx.distanceTo(Xx);e.setAttribute("lineDistance",new yt(i,1))}else ut("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,a=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Tv.copy(i.boundingSphere),Tv.applyMatrix4(r),Tv.radius+=a,e.ray.intersectsSphere(Tv)===!1)return;K4.copy(r).invert(),qp.copy(e.ray).applyMatrix4(K4);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,h=this.isLineSegments?2:1,f=i.index,p=i.attributes.position;if(f!==null){const g=Math.max(0,s.start),_=Math.min(f.count,s.start+s.count);for(let T=g,y=_-1;T<y;T+=h){const v=f.getX(T),S=f.getX(T+1),E=Ev(this,e,qp,l,v,S,T);E&&t.push(E)}if(this.isLineLoop){const T=f.getX(_-1),y=f.getX(g),v=Ev(this,e,qp,l,T,y,_-1);v&&t.push(v)}}else{const g=Math.max(0,s.start),_=Math.min(p.count,s.start+s.count);for(let T=g,y=_-1;T<y;T+=h){const v=Ev(this,e,qp,l,T,T+1,T);v&&t.push(v)}if(this.isLineLoop){const T=Ev(this,e,qp,l,_-1,g,_-1);T&&t.push(T)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){const o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}function Ev(n,e,t,i,r,a,s){const o=n.geometry.attributes.position;if(Wx.fromBufferAttribute(o,r),Xx.fromBufferAttribute(o,a),t.distanceSqToSegment(Wx,Xx,a2,Q4)>i)return;a2.applyMatrix4(n.matrixWorld);const h=e.ray.origin.distanceTo(a2);if(!(h<e.near||h>e.far))return{distance:h,point:Q4.clone().applyMatrix4(n.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:n}}const J4=new L,$4=new L;class aa extends oo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,a=t.count;r<a;r+=2)J4.fromBufferAttribute(t,r),$4.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+J4.distanceTo($4);e.setAttribute("lineDistance",new yt(i,1))}else ut("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Pb extends oo{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class K1 extends jn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qe(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 eD=new Ve,vE=new Ac,Mv=new nr,bv=new L;class zb extends Wt{constructor(e=new Ct,t=new K1){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,a=e.params.Points.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Mv.copy(i.boundingSphere),Mv.applyMatrix4(r),Mv.radius+=a,e.ray.intersectsSphere(Mv)===!1)return;eD.copy(r).invert(),vE.copy(e.ray).applyMatrix4(eD);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,h=i.index,d=i.attributes.position;if(h!==null){const p=Math.max(0,s.start),g=Math.min(h.count,s.start+s.count);for(let _=p,T=g;_<T;_++){const y=h.getX(_);bv.fromBufferAttribute(d,y),tD(bv,y,l,r,e,t,this)}}else{const p=Math.max(0,s.start),g=Math.min(d.count,s.start+s.count);for(let _=p,T=g;_<T;_++)bv.fromBufferAttribute(d,_),tD(bv,_,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){const o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}function tD(n,e,t,i,r,a,s){const o=vE.distanceSqToPoint(n);if(o<t){const l=new L;vE.closestPointToPoint(n,l),l.applyMatrix4(i);const h=r.ray.origin.distanceTo(l);if(h<r.near||h>r.far)return;a.push({distance:h,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:s})}}class r6 extends Nn{constructor(e,t,i,r,a=Ht,s=Ht,o,l,h){super(e,t,i,r,a,s,o,l,h),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const f=this;function d(){f.needsUpdate=!0,f._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class tV extends r6{constructor(e,t,i,r,a,s,o,l){super({},e,t,i,r,a,s,o,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class nV extends Nn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Vn,this.minFilter=Vn,this.generateMipmaps=!1,this.needsUpdate=!0}}class Q1 extends Nn{constructor(e,t,i,r,a,s,o,l,h,f,d,p){super(null,s,o,l,h,f,r,a,d,p),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class iV extends Q1{constructor(e,t,i,r,a,s){super(e,t,i,a,s),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Ui,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class rV extends Q1{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,ol),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class aV extends Nn{constructor(e,t,i,r,a,s,o,l,h){super(e,t,i,r,a,s,o,l,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class V0 extends Nn{constructor(e,t,i=Os,r,a,s,o=Vn,l=Vn,h,f=Ed,d=1){if(f!==Ed&&f!==Qu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:t,depth:d};super(p,r,a,s,o,l,f,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ec(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Bb extends Nn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class J1 extends Ct{constructor(e=1,t=1,i=4,r=8,a=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:r,heightSegments:a},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),r=Math.max(3,Math.floor(r)),a=Math.max(1,Math.floor(a));const s=[],o=[],l=[],h=[],f=t/2,d=Math.PI/2*e,p=t,g=2*d+p,_=i*2+a,T=r+1,y=new L,v=new L;for(let S=0;S<=_;S++){let E=0,b=0,N=0,R=0;if(S<=i){const O=S/i,w=O*Math.PI/2;b=-f-e*Math.cos(w),N=e*Math.sin(w),R=-e*Math.cos(w),E=O*d}else if(S<=i+a){const O=(S-i)/a;b=-f+O*t,N=e,R=0,E=d+O*p}else{const O=(S-i-a)/i,w=O*Math.PI/2;b=f+e*Math.sin(w),N=e*Math.cos(w),R=e*Math.sin(w),E=d+p+O*d}const I=Math.max(0,Math.min(1,E/g));let U=0;S===0?U=.5/r:S===_&&(U=-.5/r);for(let O=0;O<=r;O++){const w=O/r,B=w*Math.PI*2,j=Math.sin(B),ee=Math.cos(B);v.x=-N*ee,v.y=b,v.z=N*j,o.push(v.x,v.y,v.z),y.set(-N*ee,R,N*j),y.normalize(),l.push(y.x,y.y,y.z),h.push(w+U,I)}if(S>0){const O=(S-1)*T;for(let w=0;w<r;w++){const B=O+w,j=O+w+1,ee=S*T+w,se=S*T+w+1;s.push(B,j,ee),s.push(j,se,ee)}}}this.setIndex(s),this.setAttribute("position",new yt(o,3)),this.setAttribute("normal",new yt(l,3)),this.setAttribute("uv",new yt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new J1(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class $1 extends Ct{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const a=[],s=[],o=[],l=[],h=new L,f=new de;s.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,p=3;d<=t;d++,p+=3){const g=i+d/t*r;h.x=e*Math.cos(g),h.y=e*Math.sin(g),s.push(h.x,h.y,h.z),o.push(0,0,1),f.x=(s[p]/e+1)/2,f.y=(s[p+1]/e+1)/2,l.push(f.x,f.y)}for(let d=1;d<=t;d++)a.push(d,d+1,0);this.setIndex(a),this.setAttribute("position",new yt(s,3)),this.setAttribute("normal",new yt(o,3)),this.setAttribute("uv",new yt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $1(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class k0 extends Ct{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:o,thetaLength:l};const h=this;r=Math.floor(r),a=Math.floor(a);const f=[],d=[],p=[],g=[];let _=0;const T=[],y=i/2;let v=0;S(),s===!1&&(e>0&&E(!0),t>0&&E(!1)),this.setIndex(f),this.setAttribute("position",new yt(d,3)),this.setAttribute("normal",new yt(p,3)),this.setAttribute("uv",new yt(g,2));function S(){const b=new L,N=new L;let R=0;const I=(t-e)/i;for(let U=0;U<=a;U++){const O=[],w=U/a,B=w*(t-e)+e;for(let j=0;j<=r;j++){const ee=j/r,se=ee*l+o,ae=Math.sin(se),W=Math.cos(se);N.x=B*ae,N.y=-w*i+y,N.z=B*W,d.push(N.x,N.y,N.z),b.set(ae,I,W).normalize(),p.push(b.x,b.y,b.z),g.push(ee,1-w),O.push(_++)}T.push(O)}for(let U=0;U<r;U++)for(let O=0;O<a;O++){const w=T[O][U],B=T[O+1][U],j=T[O+1][U+1],ee=T[O][U+1];(e>0||O!==0)&&(f.push(w,B,ee),R+=3),(t>0||O!==a-1)&&(f.push(B,j,ee),R+=3)}h.addGroup(v,R,0),v+=R}function E(b){const N=_,R=new de,I=new L;let U=0;const O=b===!0?e:t,w=b===!0?1:-1;for(let j=1;j<=r;j++)d.push(0,y*w,0),p.push(0,w,0),g.push(.5,.5),_++;const B=_;for(let j=0;j<=r;j++){const se=j/r*l+o,ae=Math.cos(se),W=Math.sin(se);I.x=O*W,I.y=y*w,I.z=O*ae,d.push(I.x,I.y,I.z),p.push(0,w,0),R.x=ae*.5+.5,R.y=W*.5*w+.5,g.push(R.x,R.y),_++}for(let j=0;j<r;j++){const ee=N+j,se=B+j;b===!0?f.push(se,se+1,ee):f.push(se+1,se,ee),U+=3}h.addGroup(v,U,b===!0?1:2),v+=U}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new k0(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class W0 extends k0{constructor(e=1,t=1,i=32,r=1,a=!1,s=0,o=Math.PI*2){super(0,e,t,i,r,a,s,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o}}static fromJSON(e){return new W0(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Cc extends Ct{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const a=[],s=[];o(r),h(i),f(),this.setAttribute("position",new yt(a,3)),this.setAttribute("normal",new yt(a.slice(),3)),this.setAttribute("uv",new yt(s,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(S){const E=new L,b=new L,N=new L;for(let R=0;R<t.length;R+=3)g(t[R+0],E),g(t[R+1],b),g(t[R+2],N),l(E,b,N,S)}function l(S,E,b,N){const R=N+1,I=[];for(let U=0;U<=R;U++){I[U]=[];const O=S.clone().lerp(b,U/R),w=E.clone().lerp(b,U/R),B=R-U;for(let j=0;j<=B;j++)j===0&&U===R?I[U][j]=O:I[U][j]=O.clone().lerp(w,j/B)}for(let U=0;U<R;U++)for(let O=0;O<2*(R-U)-1;O++){const w=Math.floor(O/2);O%2===0?(p(I[U][w+1]),p(I[U+1][w]),p(I[U][w])):(p(I[U][w+1]),p(I[U+1][w+1]),p(I[U+1][w]))}}function h(S){const E=new L;for(let b=0;b<a.length;b+=3)E.x=a[b+0],E.y=a[b+1],E.z=a[b+2],E.normalize().multiplyScalar(S),a[b+0]=E.x,a[b+1]=E.y,a[b+2]=E.z}function f(){const S=new L;for(let E=0;E<a.length;E+=3){S.x=a[E+0],S.y=a[E+1],S.z=a[E+2];const b=y(S)/2/Math.PI+.5,N=v(S)/Math.PI+.5;s.push(b,1-N)}_(),d()}function d(){for(let S=0;S<s.length;S+=6){const E=s[S+0],b=s[S+2],N=s[S+4],R=Math.max(E,b,N),I=Math.min(E,b,N);R>.9&&I<.1&&(E<.2&&(s[S+0]+=1),b<.2&&(s[S+2]+=1),N<.2&&(s[S+4]+=1))}}function p(S){a.push(S.x,S.y,S.z)}function g(S,E){const b=S*3;E.x=e[b+0],E.y=e[b+1],E.z=e[b+2]}function _(){const S=new L,E=new L,b=new L,N=new L,R=new de,I=new de,U=new de;for(let O=0,w=0;O<a.length;O+=9,w+=6){S.set(a[O+0],a[O+1],a[O+2]),E.set(a[O+3],a[O+4],a[O+5]),b.set(a[O+6],a[O+7],a[O+8]),R.set(s[w+0],s[w+1]),I.set(s[w+2],s[w+3]),U.set(s[w+4],s[w+5]),N.copy(S).add(E).add(b).divideScalar(3);const B=y(N);T(R,w+0,S,B),T(I,w+2,E,B),T(U,w+4,b,B)}}function T(S,E,b,N){N<0&&S.x===1&&(s[E]=S.x-1),b.x===0&&b.z===0&&(s[E]=N/2/Math.PI+.5)}function y(S){return Math.atan2(S.z,-S.x)}function v(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Cc(e.vertices,e.indices,e.radius,e.details)}}class ey extends Cc{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,a=[-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,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],s=[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];super(a,s,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ey(e.radius,e.detail)}}const Av=new L,wv=new L,s2=new L,Rv=new Jr;class a6 extends Ct{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const r=Math.pow(10,4),a=Math.cos(Bu*t),s=e.getIndex(),o=e.getAttribute("position"),l=s?s.count:o.count,h=[0,0,0],f=["a","b","c"],d=new Array(3),p={},g=[];for(let _=0;_<l;_+=3){s?(h[0]=s.getX(_),h[1]=s.getX(_+1),h[2]=s.getX(_+2)):(h[0]=_,h[1]=_+1,h[2]=_+2);const{a:T,b:y,c:v}=Rv;if(T.fromBufferAttribute(o,h[0]),y.fromBufferAttribute(o,h[1]),v.fromBufferAttribute(o,h[2]),Rv.getNormal(s2),d[0]=`${Math.round(T.x*r)},${Math.round(T.y*r)},${Math.round(T.z*r)}`,d[1]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,d[2]=`${Math.round(v.x*r)},${Math.round(v.y*r)},${Math.round(v.z*r)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let S=0;S<3;S++){const E=(S+1)%3,b=d[S],N=d[E],R=Rv[f[S]],I=Rv[f[E]],U=`${b}_${N}`,O=`${N}_${b}`;O in p&&p[O]?(s2.dot(p[O].normal)<=a&&(g.push(R.x,R.y,R.z),g.push(I.x,I.y,I.z)),p[O]=null):U in p||(p[U]={index0:h[S],index1:h[E],normal:s2.clone()})}}for(const _ in p)if(p[_]){const{index0:T,index1:y}=p[_];Av.fromBufferAttribute(o,T),wv.fromBufferAttribute(o,y),g.push(Av.x,Av.y,Av.z),g.push(wv.x,wv.y,wv.z)}this.setAttribute("position",new yt(g,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Is{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){ut("Curve: .getPoint() not implemented.")}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const i=this.getLengths();let r=0;const a=i.length;let s;t?s=t:s=e*i[a-1];let o=0,l=a-1,h;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),h=i[r]-s,h<0)o=r+1;else if(h>0)l=r-1;else{l=r;break}if(r=l,i[r]===s)return r/(a-1);const f=i[r],p=i[r+1]-f,g=(s-f)/p;return(r+g)/(a-1)}getTangent(e,t){let r=e-1e-4,a=e+1e-4;r<0&&(r=0),a>1&&(a=1);const s=this.getPoint(r),o=this.getPoint(a),l=t||(s.isVector2?new de:new L);return l.copy(o).sub(s).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new L,r=[],a=[],s=[],o=new L,l=new Ve;for(let g=0;g<=e;g++){const _=g/e;r[g]=this.getTangentAt(_,new L)}a[0]=new L,s[0]=new L;let h=Number.MAX_VALUE;const f=Math.abs(r[0].x),d=Math.abs(r[0].y),p=Math.abs(r[0].z);f<=h&&(h=f,i.set(1,0,0)),d<=h&&(h=d,i.set(0,1,0)),p<=h&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],o),s[0].crossVectors(r[0],a[0]);for(let g=1;g<=e;g++){if(a[g]=a[g-1].clone(),s[g]=s[g-1].clone(),o.crossVectors(r[g-1],r[g]),o.length()>Number.EPSILON){o.normalize();const _=Math.acos(Lt(r[g-1].dot(r[g]),-1,1));a[g].applyMatrix4(l.makeRotationAxis(o,_))}s[g].crossVectors(r[g],a[g])}if(t===!0){let g=Math.acos(Lt(a[0].dot(a[e]),-1,1));g/=e,r[0].dot(o.crossVectors(a[0],a[e]))>0&&(g=-g);for(let _=1;_<=e;_++)a[_].applyMatrix4(l.makeRotationAxis(r[_],g*_)),s[_].crossVectors(r[_],a[_])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class ty extends Is{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new de){const i=t,r=Math.PI*2;let a=this.aEndAngle-this.aStartAngle;const s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);const o=this.aStartAngle+e*a;let l=this.aX+this.xRadius*Math.cos(o),h=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const f=Math.cos(this.aRotation),d=Math.sin(this.aRotation),p=l-this.aX,g=h-this.aY;l=p*f-g*d+this.aX,h=p*d+g*f+this.aY}return i.set(l,h)}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 s6 extends ty{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}}function Hb(){let n=0,e=0,t=0,i=0;function r(a,s,o,l){n=a,e=o,t=-3*a+3*s-2*o-l,i=2*a-2*s+o+l}return{initCatmullRom:function(a,s,o,l,h){r(s,o,h*(o-a),h*(l-s))},initNonuniformCatmullRom:function(a,s,o,l,h,f,d){let p=(s-a)/h-(o-a)/(h+f)+(o-s)/f,g=(o-s)/f-(l-s)/(f+d)+(l-o)/d;p*=f,g*=f,r(s,o,p,g)},calc:function(a){const s=a*a,o=s*a;return n+e*a+t*s+i*o}}}const Cv=new L,o2=new Hb,l2=new Hb,c2=new Hb;class o6 extends Is{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new L){const i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e;let o=Math.floor(s),l=s-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/a)+1)*a:l===0&&o===a-1&&(o=a-2,l=1);let h,f;this.closed||o>0?h=r[(o-1)%a]:(Cv.subVectors(r[0],r[1]).add(r[0]),h=Cv);const d=r[o%a],p=r[(o+1)%a];if(this.closed||o+2<a?f=r[(o+2)%a]:(Cv.subVectors(r[a-1],r[a-2]).add(r[a-1]),f=Cv),this.curveType==="centripetal"||this.curveType==="chordal"){const g=this.curveType==="chordal"?.5:.25;let _=Math.pow(h.distanceToSquared(d),g),T=Math.pow(d.distanceToSquared(p),g),y=Math.pow(p.distanceToSquared(f),g);T<1e-4&&(T=1),_<1e-4&&(_=T),y<1e-4&&(y=T),o2.initNonuniformCatmullRom(h.x,d.x,p.x,f.x,_,T,y),l2.initNonuniformCatmullRom(h.y,d.y,p.y,f.y,_,T,y),c2.initNonuniformCatmullRom(h.z,d.z,p.z,f.z,_,T,y)}else this.curveType==="catmullrom"&&(o2.initCatmullRom(h.x,d.x,p.x,f.x,this.tension),l2.initCatmullRom(h.y,d.y,p.y,f.y,this.tension),c2.initCatmullRom(h.z,d.z,p.z,f.z,this.tension));return i.set(o2.calc(l),l2.calc(l),c2.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.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,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.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,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new L().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function nD(n,e,t,i,r){const a=(i-e)*.5,s=(r-t)*.5,o=n*n,l=n*o;return(2*t-2*i+a+s)*l+(-3*t+3*i-2*a-s)*o+a*n+t}function sV(n,e){const t=1-n;return t*t*e}function oV(n,e){return 2*(1-n)*n*e}function lV(n,e){return n*n*e}function Vm(n,e,t,i){return sV(n,e)+oV(n,t)+lV(n,i)}function cV(n,e){const t=1-n;return t*t*t*e}function uV(n,e){const t=1-n;return 3*t*t*n*e}function hV(n,e){return 3*(1-n)*n*n*e}function fV(n,e){return n*n*n*e}function km(n,e,t,i,r){return cV(n,e)+uV(n,t)+hV(n,i)+fV(n,r)}class Fb extends Is{constructor(e=new de,t=new de,i=new de,r=new de){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new de){const i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(km(e,r.x,a.x,s.x,o.x),km(e,r.y,a.y,s.y,o.y)),i}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 l6 extends Is{constructor(e=new L,t=new L,i=new L,r=new L){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new L){const i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(km(e,r.x,a.x,s.x,o.x),km(e,r.y,a.y,s.y,o.y),km(e,r.z,a.z,s.z,o.z)),i}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 Gb extends Is{constructor(e=new de,t=new de){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new de){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new de){return t.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 c6 extends Is{constructor(e=new L,t=new L){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new L){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new L){return t.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 Vb extends Is{constructor(e=new de,t=new de,i=new de){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new de){const i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(Vm(e,r.x,a.x,s.x),Vm(e,r.y,a.y,s.y)),i}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 kb extends Is{constructor(e=new L,t=new L,i=new L){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new L){const i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(Vm(e,r.x,a.x,s.x),Vm(e,r.y,a.y,s.y),Vm(e,r.z,a.z,s.z)),i}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 Wb extends Is{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new de){const i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),o=a-s,l=r[s===0?s:s-1],h=r[s],f=r[s>r.length-2?r.length-1:s+1],d=r[s>r.length-3?r.length-1:s+2];return i.set(nD(o,l.x,h.x,f.x,d.x),nD(o,l.y,h.y,f.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new de().fromArray(r))}return this}}var Yx=Object.freeze({__proto__:null,ArcCurve:s6,CatmullRomCurve3:o6,CubicBezierCurve:Fb,CubicBezierCurve3:l6,EllipseCurve:ty,LineCurve:Gb,LineCurve3:c6,QuadraticBezierCurve:Vb,QuadraticBezierCurve3:kb,SplineCurve:Wb});class u6 extends Is{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 i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Yx[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let a=0;for(;a<r.length;){if(r[a]>=i){const s=r[a]-i,o=this.curves[a],l=o.getLength(),h=l===0?0:1-s/l;return o.getPointAt(h,t)}a++}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 i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,a=this.curves;r<a.length;r++){const s=a[r],o=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,l=s.getPoints(o);for(let h=0;h<l.length;h++){const f=l[h];i&&i.equals(f)||(t.push(f),i=f)}}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,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new Yx[r.type]().fromJSON(r))}return this}}class qx extends u6{constructor(e){super(),this.type="Path",this.currentPoint=new de,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;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 i=new Gb(this.currentPoint.clone(),new de(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const a=new Vb(this.currentPoint.clone(),new de(e,t),new de(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){const o=new Fb(this.currentPoint.clone(),new de(e,t),new de(i,r),new de(a,s));return this.curves.push(o),this.currentPoint.set(a,s),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Wb(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,o,l){const h=this.currentPoint.x,f=this.currentPoint.y;return this.absellipse(e+h,t+f,i,r,a,s,o,l),this}absellipse(e,t,i,r,a,s,o,l){const h=new ty(e,t,i,r,a,s,o,l);if(this.curves.length>0){const d=h.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(h);const f=h.getPoint(1);return this.currentPoint.copy(f),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 Hu extends qx{constructor(e){super(e),this.uuid=Oa(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].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,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new qx().fromJSON(r))}return this}}function dV(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let a=h6(n,0,r,t,!0);const s=[];if(!a||a.next===a.prev)return s;let o,l,h;if(i&&(a=_V(n,e,a,t)),n.length>80*t){o=n[0],l=n[1];let f=o,d=l;for(let p=t;p<r;p+=t){const g=n[p],_=n[p+1];g<o&&(o=g),_<l&&(l=_),g>f&&(f=g),_>d&&(d=_)}h=Math.max(f-o,d-l),h=h!==0?32767/h:0}return _0(a,s,t,o,l,h,0),s}function h6(n,e,t,i,r){let a;if(r===CV(n,e,t,i)>0)for(let s=e;s<t;s+=i)a=iD(s/i|0,n[s],n[s+1],a);else for(let s=t-i;s>=e;s-=i)a=iD(s/i|0,n[s],n[s+1],a);return a&&Od(a,a.next)&&(y0(a),a=a.next),a}function $u(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Od(t,t.next)||fi(t.prev,t,t.next)===0)){if(y0(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function _0(n,e,t,i,r,a,s){if(!n)return;!s&&a&&EV(n,i,r,a);let o=n;for(;n.prev!==n.next;){const l=n.prev,h=n.next;if(a?mV(n,i,r,a):pV(n)){e.push(l.i,n.i,h.i),y0(n),n=h.next,o=h.next;continue}if(n=h,n===o){s?s===1?(n=gV($u(n),e),_0(n,e,t,i,r,a,2)):s===2&&vV(n,e,t,i,r,a):_0($u(n),e,t,i,r,a,1);break}}}function pV(n){const e=n.prev,t=n,i=n.next;if(fi(e,t,i)>=0)return!1;const r=e.x,a=t.x,s=i.x,o=e.y,l=t.y,h=i.y,f=Math.min(r,a,s),d=Math.min(o,l,h),p=Math.max(r,a,s),g=Math.max(o,l,h);let _=i.next;for(;_!==e;){if(_.x>=f&&_.x<=p&&_.y>=d&&_.y<=g&&mm(r,o,a,l,s,h,_.x,_.y)&&fi(_.prev,_,_.next)>=0)return!1;_=_.next}return!0}function mV(n,e,t,i){const r=n.prev,a=n,s=n.next;if(fi(r,a,s)>=0)return!1;const o=r.x,l=a.x,h=s.x,f=r.y,d=a.y,p=s.y,g=Math.min(o,l,h),_=Math.min(f,d,p),T=Math.max(o,l,h),y=Math.max(f,d,p),v=_E(g,_,e,t,i),S=_E(T,y,e,t,i);let E=n.prevZ,b=n.nextZ;for(;E&&E.z>=v&&b&&b.z<=S;){if(E.x>=g&&E.x<=T&&E.y>=_&&E.y<=y&&E!==r&&E!==s&&mm(o,f,l,d,h,p,E.x,E.y)&&fi(E.prev,E,E.next)>=0||(E=E.prevZ,b.x>=g&&b.x<=T&&b.y>=_&&b.y<=y&&b!==r&&b!==s&&mm(o,f,l,d,h,p,b.x,b.y)&&fi(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;E&&E.z>=v;){if(E.x>=g&&E.x<=T&&E.y>=_&&E.y<=y&&E!==r&&E!==s&&mm(o,f,l,d,h,p,E.x,E.y)&&fi(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;b&&b.z<=S;){if(b.x>=g&&b.x<=T&&b.y>=_&&b.y<=y&&b!==r&&b!==s&&mm(o,f,l,d,h,p,b.x,b.y)&&fi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function gV(n,e){let t=n;do{const i=t.prev,r=t.next.next;!Od(i,r)&&d6(i,t,t.next,r)&&x0(i,r)&&x0(r,i)&&(e.push(i.i,t.i,r.i),y0(t),y0(t.next),t=n=r),t=t.next}while(t!==n);return $u(t)}function vV(n,e,t,i,r,a){let s=n;do{let o=s.next.next;for(;o!==s.prev;){if(s.i!==o.i&&AV(s,o)){let l=p6(s,o);s=$u(s,s.next),l=$u(l,l.next),_0(s,e,t,i,r,a,0),_0(l,e,t,i,r,a,0);return}o=o.next}s=s.next}while(s!==n)}function _V(n,e,t,i){const r=[];for(let a=0,s=e.length;a<s;a++){const o=e[a]*i,l=a<s-1?e[a+1]*i:n.length,h=h6(n,o,l,i,!1);h===h.next&&(h.steiner=!0),r.push(bV(h))}r.sort(xV);for(let a=0;a<r.length;a++)t=yV(r[a],t);return t}function xV(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){const i=(n.next.y-n.y)/(n.next.x-n.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=i-r}return t}function yV(n,e){const t=SV(n,e);if(!t)return e;const i=p6(t,n);return $u(i,i.next),$u(t,t.next)}function SV(n,e){let t=e;const i=n.x,r=n.y;let a=-1/0,s;if(Od(n,t))return t;do{if(Od(n,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const d=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>a&&(a=d,s=t.x<t.next.x?t:t.next,d===i))return s}t=t.next}while(t!==e);if(!s)return null;const o=s,l=s.x,h=s.y;let f=1/0;t=s;do{if(i>=t.x&&t.x>=l&&i!==t.x&&f6(r<h?i:a,r,l,h,r<h?a:i,r,t.x,t.y)){const d=Math.abs(r-t.y)/(i-t.x);x0(t,n)&&(d<f||d===f&&(t.x>s.x||t.x===s.x&&TV(s,t)))&&(s=t,f=d)}t=t.next}while(t!==o);return s}function TV(n,e){return fi(n.prev,n,e.prev)<0&&fi(e.next,n,n.next)<0}function EV(n,e,t,i){let r=n;do r.z===0&&(r.z=_E(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,MV(r)}function MV(n){let e,t=1;do{let i=n,r;n=null;let a=null;for(e=0;i;){e++;let s=i,o=0;for(let h=0;h<t&&(o++,s=s.nextZ,!!s);h++);let l=t;for(;o>0||l>0&&s;)o!==0&&(l===0||!s||i.z<=s.z)?(r=i,i=i.nextZ,o--):(r=s,s=s.nextZ,l--),a?a.nextZ=r:n=r,r.prevZ=a,a=r;i=s}a.nextZ=null,t*=2}while(e>1);return n}function _E(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function bV(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function f6(n,e,t,i,r,a,s,o){return(r-s)*(e-o)>=(n-s)*(a-o)&&(n-s)*(i-o)>=(t-s)*(e-o)&&(t-s)*(a-o)>=(r-s)*(i-o)}function mm(n,e,t,i,r,a,s,o){return!(n===s&&e===o)&&f6(n,e,t,i,r,a,s,o)}function AV(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!wV(n,e)&&(x0(n,e)&&x0(e,n)&&RV(n,e)&&(fi(n.prev,n,e.prev)||fi(n,e.prev,e))||Od(n,e)&&fi(n.prev,n,n.next)>0&&fi(e.prev,e,e.next)>0)}function fi(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Od(n,e){return n.x===e.x&&n.y===e.y}function d6(n,e,t,i){const r=Nv(fi(n,e,t)),a=Nv(fi(n,e,i)),s=Nv(fi(t,i,n)),o=Nv(fi(t,i,e));return!!(r!==a&&s!==o||r===0&&Dv(n,t,e)||a===0&&Dv(n,i,e)||s===0&&Dv(t,n,i)||o===0&&Dv(t,e,i))}function Dv(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Nv(n){return n>0?1:n<0?-1:0}function wV(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&d6(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function x0(n,e){return fi(n.prev,n,n.next)<0?fi(n,e,n.next)>=0&&fi(n,n.prev,e)>=0:fi(n,e,n.prev)<0||fi(n,n.next,e)<0}function RV(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,a=(n.y+e.y)/2;do t.y>a!=t.next.y>a&&t.next.y!==t.y&&r<(t.next.x-t.x)*(a-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function p6(n,e){const t=xE(n.i,n.x,n.y),i=xE(e.i,e.x,e.y),r=n.next,a=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,a.next=i,i.prev=a,i}function iD(n,e,t,i){const r=xE(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function y0(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xE(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function CV(n,e,t,i){let r=0;for(let a=e,s=t-i;a<t;a+=i)r+=(n[s]-n[a])*(n[a+1]+n[s+1]),s=a;return r}class DV{static triangulate(e,t,i=2){return dV(e,t,i)}}class Rs{static area(e){const t=e.length;let i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return Rs.area(e)<0}static triangulateShape(e,t){const i=[],r=[],a=[];rD(e),aD(i,e);let s=e.length;t.forEach(rD);for(let l=0;l<t.length;l++)r.push(s),s+=t[l].length,aD(i,t[l]);const o=DV.triangulate(i,r);for(let l=0;l<o.length;l+=3)a.push(o.slice(l,l+3));return a}}function rD(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function aD(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class ny extends Ct{constructor(e=new Hu([new de(.5,.5),new de(-.5,.5),new de(-.5,-.5),new de(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],a=[];for(let o=0,l=e.length;o<l;o++){const h=e[o];s(h)}this.setAttribute("position",new yt(r,3)),this.setAttribute("uv",new yt(a,2)),this.computeVertexNormals();function s(o){const l=[],h=t.curveSegments!==void 0?t.curveSegments:12,f=t.steps!==void 0?t.steps:1,d=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,g=t.bevelThickness!==void 0?t.bevelThickness:.2,_=t.bevelSize!==void 0?t.bevelSize:g-.1,T=t.bevelOffset!==void 0?t.bevelOffset:0,y=t.bevelSegments!==void 0?t.bevelSegments:3;const v=t.extrudePath,S=t.UVGenerator!==void 0?t.UVGenerator:NV;let E,b=!1,N,R,I,U;v&&(E=v.getSpacedPoints(f),b=!0,p=!1,N=v.computeFrenetFrames(f,!1),R=new L,I=new L,U=new L),p||(y=0,g=0,_=0,T=0);const O=o.extractPoints(h);let w=O.shape;const B=O.holes;if(!Rs.isClockWise(w)){w=w.reverse();for(let Te=0,G=B.length;Te<G;Te++){const be=B[Te];Rs.isClockWise(be)&&(B[Te]=be.reverse())}}function ee(Te){const be=10000000000000001e-36;let Ne=Te[0];for(let Fe=1;Fe<=Te.length;Fe++){const Be=Fe%Te.length,$e=Te[Be],Je=$e.x-Ne.x,ct=$e.y-Ne.y,k=Je*Je+ct*ct,P=Math.max(Math.abs($e.x),Math.abs($e.y),Math.abs(Ne.x),Math.abs(Ne.y)),ce=be*P*P;if(k<=ce){Te.splice(Be,1),Fe--;continue}Ne=$e}}ee(w),B.forEach(ee);const se=B.length,ae=w;for(let Te=0;Te<se;Te++){const G=B[Te];w=w.concat(G)}function W(Te,G,be){return G||Bt("ExtrudeGeometry: vec does not exist"),Te.clone().addScaledVector(G,be)}const te=w.length;function K(Te,G,be){let Ne,Fe,Be;const $e=Te.x-G.x,Je=Te.y-G.y,ct=be.x-Te.x,k=be.y-Te.y,P=$e*$e+Je*Je,ce=$e*k-Je*ct;if(Math.abs(ce)>Number.EPSILON){const Ee=Math.sqrt(P),Le=Math.sqrt(ct*ct+k*k),ye=G.x-Je/Ee,vt=G.y+$e/Ee,je=be.x-k/Le,xt=be.y+ct/Le,pt=((je-ye)*k-(xt-vt)*ct)/($e*k-Je*ct);Ne=ye+$e*pt-Te.x,Fe=vt+Je*pt-Te.y;const Ie=Ne*Ne+Fe*Fe;if(Ie<=2)return new de(Ne,Fe);Be=Math.sqrt(Ie/2)}else{let Ee=!1;$e>Number.EPSILON?ct>Number.EPSILON&&(Ee=!0):$e<-Number.EPSILON?ct<-Number.EPSILON&&(Ee=!0):Math.sign(Je)===Math.sign(k)&&(Ee=!0),Ee?(Ne=-Je,Fe=$e,Be=Math.sqrt(P)):(Ne=$e,Fe=Je,Be=Math.sqrt(P/2))}return new de(Ne/Be,Fe/Be)}const oe=[];for(let Te=0,G=ae.length,be=G-1,Ne=Te+1;Te<G;Te++,be++,Ne++)be===G&&(be=0),Ne===G&&(Ne=0),oe[Te]=K(ae[Te],ae[be],ae[Ne]);const ie=[];let Ce,Xe=oe.concat();for(let Te=0,G=se;Te<G;Te++){const be=B[Te];Ce=[];for(let Ne=0,Fe=be.length,Be=Fe-1,$e=Ne+1;Ne<Fe;Ne++,Be++,$e++)Be===Fe&&(Be=0),$e===Fe&&($e=0),Ce[Ne]=K(be[Ne],be[Be],be[$e]);ie.push(Ce),Xe=Xe.concat(Ce)}let nt;if(y===0)nt=Rs.triangulateShape(ae,B);else{const Te=[],G=[];for(let be=0;be<y;be++){const Ne=be/y,Fe=g*Math.cos(Ne*Math.PI/2),Be=_*Math.sin(Ne*Math.PI/2)+T;for(let $e=0,Je=ae.length;$e<Je;$e++){const ct=W(ae[$e],oe[$e],Be);ue(ct.x,ct.y,-Fe),Ne===0&&Te.push(ct)}for(let $e=0,Je=se;$e<Je;$e++){const ct=B[$e];Ce=ie[$e];const k=[];for(let P=0,ce=ct.length;P<ce;P++){const Ee=W(ct[P],Ce[P],Be);ue(Ee.x,Ee.y,-Fe),Ne===0&&k.push(Ee)}Ne===0&&G.push(k)}}nt=Rs.triangulateShape(Te,G)}const tt=nt.length,gt=_+T;for(let Te=0;Te<te;Te++){const G=p?W(w[Te],Xe[Te],gt):w[Te];b?(I.copy(N.normals[0]).multiplyScalar(G.x),R.copy(N.binormals[0]).multiplyScalar(G.y),U.copy(E[0]).add(I).add(R),ue(U.x,U.y,U.z)):ue(G.x,G.y,0)}for(let Te=1;Te<=f;Te++)for(let G=0;G<te;G++){const be=p?W(w[G],Xe[G],gt):w[G];b?(I.copy(N.normals[Te]).multiplyScalar(be.x),R.copy(N.binormals[Te]).multiplyScalar(be.y),U.copy(E[Te]).add(I).add(R),ue(U.x,U.y,U.z)):ue(be.x,be.y,d/f*Te)}for(let Te=y-1;Te>=0;Te--){const G=Te/y,be=g*Math.cos(G*Math.PI/2),Ne=_*Math.sin(G*Math.PI/2)+T;for(let Fe=0,Be=ae.length;Fe<Be;Fe++){const $e=W(ae[Fe],oe[Fe],Ne);ue($e.x,$e.y,d+be)}for(let Fe=0,Be=B.length;Fe<Be;Fe++){const $e=B[Fe];Ce=ie[Fe];for(let Je=0,ct=$e.length;Je<ct;Je++){const k=W($e[Je],Ce[Je],Ne);b?ue(k.x,k.y+E[f-1].y,E[f-1].x+be):ue(k.x,k.y,d+be)}}}ge(),Ae();function ge(){const Te=r.length/3;if(p){let G=0,be=te*G;for(let Ne=0;Ne<tt;Ne++){const Fe=nt[Ne];it(Fe[2]+be,Fe[1]+be,Fe[0]+be)}G=f+y*2,be=te*G;for(let Ne=0;Ne<tt;Ne++){const Fe=nt[Ne];it(Fe[0]+be,Fe[1]+be,Fe[2]+be)}}else{for(let G=0;G<tt;G++){const be=nt[G];it(be[2],be[1],be[0])}for(let G=0;G<tt;G++){const be=nt[G];it(be[0]+te*f,be[1]+te*f,be[2]+te*f)}}i.addGroup(Te,r.length/3-Te,0)}function Ae(){const Te=r.length/3;let G=0;Ze(ae,G),G+=ae.length;for(let be=0,Ne=B.length;be<Ne;be++){const Fe=B[be];Ze(Fe,G),G+=Fe.length}i.addGroup(Te,r.length/3-Te,1)}function Ze(Te,G){let be=Te.length;for(;--be>=0;){const Ne=be;let Fe=be-1;Fe<0&&(Fe=Te.length-1);for(let Be=0,$e=f+y*2;Be<$e;Be++){const Je=te*Be,ct=te*(Be+1),k=G+Ne+Je,P=G+Fe+Je,ce=G+Fe+ct,Ee=G+Ne+ct;bt(k,P,ce,Ee)}}}function ue(Te,G,be){l.push(Te),l.push(G),l.push(be)}function it(Te,G,be){ot(Te),ot(G),ot(be);const Ne=r.length/3,Fe=S.generateTopUV(i,r,Ne-3,Ne-2,Ne-1);Ke(Fe[0]),Ke(Fe[1]),Ke(Fe[2])}function bt(Te,G,be,Ne){ot(Te),ot(G),ot(Ne),ot(G),ot(be),ot(Ne);const Fe=r.length/3,Be=S.generateSideWallUV(i,r,Fe-6,Fe-3,Fe-2,Fe-1);Ke(Be[0]),Ke(Be[1]),Ke(Be[3]),Ke(Be[1]),Ke(Be[2]),Ke(Be[3])}function ot(Te){r.push(l[Te*3+0]),r.push(l[Te*3+1]),r.push(l[Te*3+2])}function Ke(Te){a.push(Te.x),a.push(Te.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return OV(t,i,e)}static fromJSON(e,t){const i=[];for(let a=0,s=e.shapes.length;a<s;a++){const o=t[e.shapes[a]];i.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Yx[r.type]().fromJSON(r)),new ny(i,e.options)}}const NV={generateTopUV:function(n,e,t,i,r){const a=e[t*3],s=e[t*3+1],o=e[i*3],l=e[i*3+1],h=e[r*3],f=e[r*3+1];return[new de(a,s),new de(o,l),new de(h,f)]},generateSideWallUV:function(n,e,t,i,r,a){const s=e[t*3],o=e[t*3+1],l=e[t*3+2],h=e[i*3],f=e[i*3+1],d=e[i*3+2],p=e[r*3],g=e[r*3+1],_=e[r*3+2],T=e[a*3],y=e[a*3+1],v=e[a*3+2];return Math.abs(o-f)<Math.abs(s-h)?[new de(s,1-l),new de(h,1-d),new de(p,1-_),new de(T,1-v)]:[new de(o,1-l),new de(f,1-d),new de(g,1-_),new de(y,1-v)]}};function OV(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const a=n[i];t.shapes.push(a.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class iy extends Cc{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],a=[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];super(r,a,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new iy(e.radius,e.detail)}}class ry extends Ct{constructor(e=[new de(0,-.5),new de(.5,0),new de(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Lt(r,0,Math.PI*2);const a=[],s=[],o=[],l=[],h=[],f=1/t,d=new L,p=new de,g=new L,_=new L,T=new L;let y=0,v=0;for(let S=0;S<=e.length-1;S++)switch(S){case 0:y=e[S+1].x-e[S].x,v=e[S+1].y-e[S].y,g.x=v*1,g.y=-y,g.z=v*0,T.copy(g),g.normalize(),l.push(g.x,g.y,g.z);break;case e.length-1:l.push(T.x,T.y,T.z);break;default:y=e[S+1].x-e[S].x,v=e[S+1].y-e[S].y,g.x=v*1,g.y=-y,g.z=v*0,_.copy(g),g.x+=T.x,g.y+=T.y,g.z+=T.z,g.normalize(),l.push(g.x,g.y,g.z),T.copy(_)}for(let S=0;S<=t;S++){const E=i+S*f*r,b=Math.sin(E),N=Math.cos(E);for(let R=0;R<=e.length-1;R++){d.x=e[R].x*b,d.y=e[R].y,d.z=e[R].x*N,s.push(d.x,d.y,d.z),p.x=S/t,p.y=R/(e.length-1),o.push(p.x,p.y);const I=l[3*R+0]*b,U=l[3*R+1],O=l[3*R+0]*N;h.push(I,U,O)}}for(let S=0;S<t;S++)for(let E=0;E<e.length-1;E++){const b=E+S*e.length,N=b,R=b+e.length,I=b+e.length+1,U=b+1;a.push(N,R,U),a.push(I,U,R)}this.setIndex(a),this.setAttribute("position",new yt(s,3)),this.setAttribute("uv",new yt(o,2)),this.setAttribute("normal",new yt(h,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ry(e.points,e.segments,e.phiStart,e.phiLength)}}class X0 extends Cc{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new X0(e.radius,e.detail)}}class dh extends Ct{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const a=e/2,s=t/2,o=Math.floor(i),l=Math.floor(r),h=o+1,f=l+1,d=e/o,p=t/l,g=[],_=[],T=[],y=[];for(let v=0;v<f;v++){const S=v*p-s;for(let E=0;E<h;E++){const b=E*d-a;_.push(b,-S,0),T.push(0,0,1),y.push(E/o),y.push(1-v/l)}}for(let v=0;v<l;v++)for(let S=0;S<o;S++){const E=S+h*v,b=S+h*(v+1),N=S+1+h*(v+1),R=S+1+h*v;g.push(E,b,R),g.push(b,N,R)}this.setIndex(g),this.setAttribute("position",new yt(_,3)),this.setAttribute("normal",new yt(T,3)),this.setAttribute("uv",new yt(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dh(e.width,e.height,e.widthSegments,e.heightSegments)}}class ay extends Ct{constructor(e=.5,t=1,i=32,r=1,a=0,s=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:a,thetaLength:s},i=Math.max(3,i),r=Math.max(1,r);const o=[],l=[],h=[],f=[];let d=e;const p=(t-e)/r,g=new L,_=new de;for(let T=0;T<=r;T++){for(let y=0;y<=i;y++){const v=a+y/i*s;g.x=d*Math.cos(v),g.y=d*Math.sin(v),l.push(g.x,g.y,g.z),h.push(0,0,1),_.x=(g.x/t+1)/2,_.y=(g.y/t+1)/2,f.push(_.x,_.y)}d+=p}for(let T=0;T<r;T++){const y=T*(i+1);for(let v=0;v<i;v++){const S=v+y,E=S,b=S+i+1,N=S+i+2,R=S+1;o.push(E,b,R),o.push(b,N,R)}}this.setIndex(o),this.setAttribute("position",new yt(l,3)),this.setAttribute("normal",new yt(h,3)),this.setAttribute("uv",new yt(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ay(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class sy extends Ct{constructor(e=new Hu([new de(0,.5),new de(-.5,-.5),new de(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],a=[],s=[];let o=0,l=0;if(Array.isArray(e)===!1)h(e);else for(let f=0;f<e.length;f++)h(e[f]),this.addGroup(o,l,f),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new yt(r,3)),this.setAttribute("normal",new yt(a,3)),this.setAttribute("uv",new yt(s,2));function h(f){const d=r.length/3,p=f.extractPoints(t);let g=p.shape;const _=p.holes;Rs.isClockWise(g)===!1&&(g=g.reverse());for(let y=0,v=_.length;y<v;y++){const S=_[y];Rs.isClockWise(S)===!0&&(_[y]=S.reverse())}const T=Rs.triangulateShape(g,_);for(let y=0,v=_.length;y<v;y++){const S=_[y];g=g.concat(S)}for(let y=0,v=g.length;y<v;y++){const S=g[y];r.push(S.x,S.y,0),a.push(0,0,1),s.push(S.x,S.y)}for(let y=0,v=T.length;y<v;y++){const S=T[y],E=S[0]+d,b=S[1]+d,N=S[2]+d;i.push(E,b,N),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return LV(t,e)}static fromJSON(e,t){const i=[];for(let r=0,a=e.shapes.length;r<a;r++){const s=t[e.shapes[r]];i.push(s)}return new sy(i,e.curveSegments)}}function LV(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class Y0 extends Ct{constructor(e=1,t=32,i=16,r=0,a=Math.PI*2,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:s,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(s+o,Math.PI);let h=0;const f=[],d=new L,p=new L,g=[],_=[],T=[],y=[];for(let v=0;v<=i;v++){const S=[],E=v/i;let b=0;v===0&&s===0?b=.5/t:v===i&&l===Math.PI&&(b=-.5/t);for(let N=0;N<=t;N++){const R=N/t;d.x=-e*Math.cos(r+R*a)*Math.sin(s+E*o),d.y=e*Math.cos(s+E*o),d.z=e*Math.sin(r+R*a)*Math.sin(s+E*o),_.push(d.x,d.y,d.z),p.copy(d).normalize(),T.push(p.x,p.y,p.z),y.push(R+b,1-E),S.push(h++)}f.push(S)}for(let v=0;v<i;v++)for(let S=0;S<t;S++){const E=f[v][S+1],b=f[v][S],N=f[v+1][S],R=f[v+1][S+1];(v!==0||s>0)&&g.push(E,b,R),(v!==i-1||l<Math.PI)&&g.push(b,N,R)}this.setIndex(g),this.setAttribute("position",new yt(_,3)),this.setAttribute("normal",new yt(T,3)),this.setAttribute("uv",new yt(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Y0(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class oy extends Cc{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new oy(e.radius,e.detail)}}class ly extends Ct{constructor(e=1,t=.4,i=12,r=48,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:a},i=Math.floor(i),r=Math.floor(r);const s=[],o=[],l=[],h=[],f=new L,d=new L,p=new L;for(let g=0;g<=i;g++)for(let _=0;_<=r;_++){const T=_/r*a,y=g/i*Math.PI*2;d.x=(e+t*Math.cos(y))*Math.cos(T),d.y=(e+t*Math.cos(y))*Math.sin(T),d.z=t*Math.sin(y),o.push(d.x,d.y,d.z),f.x=e*Math.cos(T),f.y=e*Math.sin(T),p.subVectors(d,f).normalize(),l.push(p.x,p.y,p.z),h.push(_/r),h.push(g/i)}for(let g=1;g<=i;g++)for(let _=1;_<=r;_++){const T=(r+1)*g+_-1,y=(r+1)*(g-1)+_-1,v=(r+1)*(g-1)+_,S=(r+1)*g+_;s.push(T,y,S),s.push(y,v,S)}this.setIndex(s),this.setAttribute("position",new yt(o,3)),this.setAttribute("normal",new yt(l,3)),this.setAttribute("uv",new yt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ly(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class cy extends Ct{constructor(e=1,t=.4,i=64,r=8,a=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:a,q:s},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],h=[],f=[],d=new L,p=new L,g=new L,_=new L,T=new L,y=new L,v=new L;for(let E=0;E<=i;++E){const b=E/i*a*Math.PI*2;S(b,a,s,e,g),S(b+.01,a,s,e,_),y.subVectors(_,g),v.addVectors(_,g),T.crossVectors(y,v),v.crossVectors(T,y),T.normalize(),v.normalize();for(let N=0;N<=r;++N){const R=N/r*Math.PI*2,I=-t*Math.cos(R),U=t*Math.sin(R);d.x=g.x+(I*v.x+U*T.x),d.y=g.y+(I*v.y+U*T.y),d.z=g.z+(I*v.z+U*T.z),l.push(d.x,d.y,d.z),p.subVectors(d,g).normalize(),h.push(p.x,p.y,p.z),f.push(E/i),f.push(N/r)}}for(let E=1;E<=i;E++)for(let b=1;b<=r;b++){const N=(r+1)*(E-1)+(b-1),R=(r+1)*E+(b-1),I=(r+1)*E+b,U=(r+1)*(E-1)+b;o.push(N,R,U),o.push(R,I,U)}this.setIndex(o),this.setAttribute("position",new yt(l,3)),this.setAttribute("normal",new yt(h,3)),this.setAttribute("uv",new yt(f,2));function S(E,b,N,R,I){const U=Math.cos(E),O=Math.sin(E),w=N/b*E,B=Math.cos(w);I.x=R*(2+B)*.5*U,I.y=R*(2+B)*O*.5,I.z=R*Math.sin(w)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cy(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class uy extends Ct{constructor(e=new kb(new L(-1,-1,0),new L(-1,1,0),new L(1,1,0)),t=64,i=1,r=8,a=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:a};const s=e.computeFrenetFrames(t,a);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const o=new L,l=new L,h=new de;let f=new L;const d=[],p=[],g=[],_=[];T(),this.setIndex(_),this.setAttribute("position",new yt(d,3)),this.setAttribute("normal",new yt(p,3)),this.setAttribute("uv",new yt(g,2));function T(){for(let E=0;E<t;E++)y(E);y(a===!1?t:0),S(),v()}function y(E){f=e.getPointAt(E/t,f);const b=s.normals[E],N=s.binormals[E];for(let R=0;R<=r;R++){const I=R/r*Math.PI*2,U=Math.sin(I),O=-Math.cos(I);l.x=O*b.x+U*N.x,l.y=O*b.y+U*N.y,l.z=O*b.z+U*N.z,l.normalize(),p.push(l.x,l.y,l.z),o.x=f.x+i*l.x,o.y=f.y+i*l.y,o.z=f.z+i*l.z,d.push(o.x,o.y,o.z)}}function v(){for(let E=1;E<=t;E++)for(let b=1;b<=r;b++){const N=(r+1)*(E-1)+(b-1),R=(r+1)*E+(b-1),I=(r+1)*E+b,U=(r+1)*(E-1)+b;_.push(N,R,U),_.push(R,I,U)}}function S(){for(let E=0;E<=t;E++)for(let b=0;b<=r;b++)h.x=E/t,h.y=b/r,g.push(h.x,h.y)}}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 uy(new Yx[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class m6 extends Ct{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new L,a=new L;if(e.index!==null){const s=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let h=0,f=l.length;h<f;++h){const d=l[h],p=d.start,g=d.count;for(let _=p,T=p+g;_<T;_+=3)for(let y=0;y<3;y++){const v=o.getX(_+y),S=o.getX(_+(y+1)%3);r.fromBufferAttribute(s,v),a.fromBufferAttribute(s,S),sD(r,a,i)===!0&&(t.push(r.x,r.y,r.z),t.push(a.x,a.y,a.z))}}}else{const s=e.attributes.position;for(let o=0,l=s.count/3;o<l;o++)for(let h=0;h<3;h++){const f=3*o+h,d=3*o+(h+1)%3;r.fromBufferAttribute(s,f),a.fromBufferAttribute(s,d),sD(r,a,i)===!0&&(t.push(r.x,r.y,r.z),t.push(a.x,a.y,a.z))}}this.setAttribute("position",new yt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function sD(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var oD=Object.freeze({__proto__:null,BoxGeometry:fh,CapsuleGeometry:J1,CircleGeometry:$1,ConeGeometry:W0,CylinderGeometry:k0,DodecahedronGeometry:ey,EdgesGeometry:a6,ExtrudeGeometry:ny,IcosahedronGeometry:iy,LatheGeometry:ry,OctahedronGeometry:X0,PlaneGeometry:dh,PolyhedronGeometry:Cc,RingGeometry:ay,ShapeGeometry:sy,SphereGeometry:Y0,TetrahedronGeometry:oy,TorusGeometry:ly,TorusKnotGeometry:cy,TubeGeometry:uy,WireframeGeometry:m6});class g6 extends jn{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new qe(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 ph extends Vi{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class q0 extends jn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new qe(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 qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hl,this.normalScale=new de(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 zi,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 cs extends q0{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 de(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Lt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new qe(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 qe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qe(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 v6 extends jn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new qe(16777215),this.specular=new qe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hl,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new zi,this.combine=B0,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 _6 extends jn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new qe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hl,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Xb extends jn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hl,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class x6 extends jn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new qe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hl,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new zi,this.combine=B0,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 Yb extends jn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=bc,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 qb extends jn{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}}class y6 extends jn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new qe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hl,this.normalScale=new de(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class S6 extends Bi{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 Ru(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function T6(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function E6(n){function e(r,a){return n[r]-n[a]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function yE(n,e,t){const i=n.length,r=new n.constructor(i);for(let a=0,s=0;s!==i;++a){const o=t[a]*e;for(let l=0;l!==e;++l)r[s++]=n[o+l]}return r}function jb(n,e,t,i){let r=1,a=n[0];for(;a!==void 0&&a[i]===void 0;)a=n[r++];if(a===void 0)return;let s=a[i];if(s!==void 0)if(Array.isArray(s))do s=a[i],s!==void 0&&(e.push(a.time),t.push(...s)),a=n[r++];while(a!==void 0);else if(s.toArray!==void 0)do s=a[i],s!==void 0&&(e.push(a.time),s.toArray(t,t.length)),a=n[r++];while(a!==void 0);else do s=a[i],s!==void 0&&(e.push(a.time),t.push(s)),a=n[r++];while(a!==void 0)}function IV(n,e,t,i,r=30){const a=n.clone();a.name=e;const s=[];for(let l=0;l<a.tracks.length;++l){const h=a.tracks[l],f=h.getValueSize(),d=[],p=[];for(let g=0;g<h.times.length;++g){const _=h.times[g]*r;if(!(_<t||_>=i)){d.push(h.times[g]);for(let T=0;T<f;++T)p.push(h.values[g*f+T])}}d.length!==0&&(h.times=Ru(d,h.times.constructor),h.values=Ru(p,h.values.constructor),s.push(h))}a.tracks=s;let o=1/0;for(let l=0;l<a.tracks.length;++l)o>a.tracks[l].times[0]&&(o=a.tracks[l].times[0]);for(let l=0;l<a.tracks.length;++l)a.tracks[l].shift(-1*o);return a.resetDuration(),a}function UV(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,a=e/i;for(let s=0;s<r;++s){const o=t.tracks[s],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const h=n.tracks.find(function(v){return v.name===o.name&&v.ValueTypeName===l});if(h===void 0)continue;let f=0;const d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);let p=0;const g=h.getValueSize();h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=g/3);const _=o.times.length-1;let T;if(a<=o.times[0]){const v=f,S=d-f;T=o.values.slice(v,S)}else if(a>=o.times[_]){const v=_*d+f,S=v+d-f;T=o.values.slice(v,S)}else{const v=o.createInterpolant(),S=f,E=d-f;v.evaluate(a),T=v.resultBuffer.slice(S,E)}l==="quaternion"&&new _t().fromArray(T).normalize().conjugate().toArray(T);const y=h.times.length;for(let v=0;v<y;++v){const S=v*g+p;if(l==="quaternion")_t.multiplyQuaternionsFlat(h.values,S,T,0,h.values,S);else{const E=g-p*2;for(let b=0;b<E;++b)h.values[S+b]-=T[b]}}}return n.blendMode=Ab,n}class PV{static convertArray(e,t){return Ru(e,t)}static isTypedArray(e){return T6(e)}static getKeyframeOrder(e){return E6(e)}static sortedArray(e,t,i){return yE(e,t,i)}static flattenJSON(e,t,i,r){jb(e,t,i,r)}static subclip(e,t,i,r,a=30){return IV(e,t,i,r,a)}static makeClipAdditive(e,t=0,i=e,r=30){return UV(e,t,i,r)}}class Qd{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;n:{i:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<a)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break n}if(!(e>=a)){const o=t[1];e<o&&(i=2,a=o);for(let l=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break n}break e}for(;i<s;){const o=i+s>>>1;e<t[o]?s=o:i=o+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class M6 extends Qd{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Au,endingEnd:Au}}intervalChanged_(e,t,i){const r=this.parameterPositions;let a=e-2,s=e+1,o=r[a],l=r[s];if(o===void 0)switch(this.getSettings_().endingStart){case wu:a=e,o=2*t-i;break;case d0:a=r.length-2,o=t+r[a]-r[a+1];break;default:a=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case wu:s=e,l=2*i-t;break;case d0:s=1,l=i+r[1]-r[0];break;default:s=e-1,l=t}const h=(i-t)*.5,f=this.valueSize;this._weightPrev=h/(t-o),this._weightNext=h/(l-i),this._offsetPrev=a*f,this._offsetNext=s*f}interpolate_(e,t,i,r){const a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,l=e*o,h=l-o,f=this._offsetPrev,d=this._offsetNext,p=this._weightPrev,g=this._weightNext,_=(i-t)/(r-t),T=_*_,y=T*_,v=-p*y+2*p*T-p*_,S=(1+p)*y+(-1.5-2*p)*T+(-.5+p)*_+1,E=(-1-g)*y+(1.5+g)*T+.5*_,b=g*y-g*T;for(let N=0;N!==o;++N)a[N]=v*s[f+N]+S*s[h+N]+E*s[l+N]+b*s[d+N];return a}}class Zb extends Qd{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,l=e*o,h=l-o,f=(i-t)/(r-t),d=1-f;for(let p=0;p!==o;++p)a[p]=s[h+p]*d+s[l+p]*f;return a}}class b6 extends Qd{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class us{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ru(t,this.TimeBufferType),this.values=Ru(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Ru(e.times,Array),values:Ru(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new b6(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Zb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new M6(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Md:t=this.InterpolantFactoryMethodDiscrete;break;case bd:t=this.InterpolantFactoryMethodLinear;break;case T_:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return ut("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Md;case this.InterpolantFactoryMethodLinear:return bd;case this.InterpolantFactoryMethodSmooth:return T_}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);const o=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*o,s*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Bt("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,a=i.length;a===0&&(Bt("KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let o=0;o!==a;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){Bt("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(s!==null&&s>l){Bt("KeyframeTrack: Out of order keys.",this,o,l,s),e=!1;break}s=l}if(r!==void 0&&T6(r))for(let o=0,l=r.length;o!==l;++o){const h=r[o];if(isNaN(h)){Bt("KeyframeTrack: Value is not a valid number.",this,o,h),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===T_,a=e.length-1;let s=1;for(let o=1;o<a;++o){let l=!1;const h=e[o],f=e[o+1];if(h!==f&&(o!==1||h!==e[0]))if(r)l=!0;else{const d=o*i,p=d-i,g=d+i;for(let _=0;_!==i;++_){const T=t[d+_];if(T!==t[p+_]||T!==t[g+_]){l=!0;break}}}if(l){if(o!==s){e[s]=e[o];const d=o*i,p=s*i;for(let g=0;g!==i;++g)t[p+g]=t[d+g]}++s}}if(a>0){e[s]=e[a];for(let o=a*i,l=s*i,h=0;h!==i;++h)t[l+h]=t[o+h];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}us.prototype.ValueTypeName="";us.prototype.TimeBufferType=Float32Array;us.prototype.ValueBufferType=Float32Array;us.prototype.DefaultInterpolation=bd;class mh extends us{constructor(e,t,i){super(e,t,i)}}mh.prototype.ValueTypeName="bool";mh.prototype.ValueBufferType=Array;mh.prototype.DefaultInterpolation=Md;mh.prototype.InterpolantFactoryMethodLinear=void 0;mh.prototype.InterpolantFactoryMethodSmooth=void 0;class Kb extends us{constructor(e,t,i,r){super(e,t,i,r)}}Kb.prototype.ValueTypeName="color";class yc extends us{constructor(e,t,i,r){super(e,t,i,r)}}yc.prototype.ValueTypeName="number";class A6 extends Qd{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let h=e*o;for(let f=h+o;h!==f;h+=4)_t.slerpFlat(a,0,s,h-o,s,h,l);return a}}class Sc extends us{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new A6(this.times,this.values,this.getValueSize(),e)}}Sc.prototype.ValueTypeName="quaternion";Sc.prototype.InterpolantFactoryMethodSmooth=void 0;class gh extends us{constructor(e,t,i){super(e,t,i)}}gh.prototype.ValueTypeName="string";gh.prototype.ValueBufferType=Array;gh.prototype.DefaultInterpolation=Md;gh.prototype.InterpolantFactoryMethodLinear=void 0;gh.prototype.InterpolantFactoryMethodSmooth=void 0;class eh extends us{constructor(e,t,i,r){super(e,t,i,r)}}eh.prototype.ValueTypeName="vector";class th{constructor(e="",t=-1,i=[],r=k1){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Oa(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let s=0,o=i.length;s!==o;++s)t.push(BV(i[s]).scale(r));const a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a.userData=JSON.parse(e.userData||"{}"),a}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let a=0,s=i.length;a!==s;++a)t.push(us.toJSON(i[a]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const a=t.length,s=[];for(let o=0;o<a;o++){let l=[],h=[];l.push((o+a-1)%a,o,(o+1)%a),h.push(0,1,0);const f=E6(l);l=yE(l,1,f),h=yE(h,1,f),!r&&l[0]===0&&(l.push(a),h.push(h[0])),s.push(new yc(".morphTargetInfluences["+t[o].name+"]",l,h).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},a=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const h=e[o],f=h.name.match(a);if(f&&f.length>1){const d=f[1];let p=r[d];p||(r[d]=p=[]),p.push(h)}}const s=[];for(const o in r)s.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return s}static parseAnimation(e,t){if(ut("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Bt("AnimationClip: No animation in JSONLoader data."),null;const i=function(d,p,g,_,T){if(g.length!==0){const y=[],v=[];jb(g,y,v,_),y.length!==0&&T.push(new d(p,y,v))}},r=[],a=e.name||"default",s=e.fps||30,o=e.blendMode;let l=e.length||-1;const h=e.hierarchy||[];for(let d=0;d<h.length;d++){const p=h[d].keys;if(!(!p||p.length===0))if(p[0].morphTargets){const g={};let _;for(_=0;_<p.length;_++)if(p[_].morphTargets)for(let T=0;T<p[_].morphTargets.length;T++)g[p[_].morphTargets[T]]=-1;for(const T in g){const y=[],v=[];for(let S=0;S!==p[_].morphTargets.length;++S){const E=p[_];y.push(E.time),v.push(E.morphTarget===T?1:0)}r.push(new yc(".morphTargetInfluence["+T+"]",y,v))}l=g.length*s}else{const g=".bones["+t[d].name+"]";i(eh,g+".position",p,"pos",r),i(Sc,g+".quaternion",p,"rot",r),i(eh,g+".scale",p,"scl",r)}}return r.length===0?null:new this(a,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const a=this.tracks[i];t=Math.max(t,a.times[a.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let i=0;i<this.tracks.length;i++)e.push(this.tracks[i].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function zV(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return yc;case"vector":case"vector2":case"vector3":case"vector4":return eh;case"color":return Kb;case"quaternion":return Sc;case"bool":case"boolean":return mh;case"string":return gh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function BV(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=zV(n.type);if(n.times===void 0){const t=[],i=[];jb(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const io={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class Qb{constructor(e,t,i){const r=this;let a=!1,s=0,o=0,l;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(f){o++,a===!1&&r.onStart!==void 0&&r.onStart(f,s,o),a=!0},this.itemEnd=function(f){s++,r.onProgress!==void 0&&r.onProgress(f,s,o),s===o&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(f){r.onError!==void 0&&r.onError(f)},this.resolveURL=function(f){return l?l(f):f},this.setURLModifier=function(f){return l=f,this},this.addHandler=function(f,d){return h.push(f,d),this},this.removeHandler=function(f){const d=h.indexOf(f);return d!==-1&&h.splice(d,2),this},this.getHandler=function(f){for(let d=0,p=h.length;d<p;d+=2){const g=h[d],_=h[d+1];if(g.global&&(g.lastIndex=0),g.test(f))return _}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const w6=new Qb;class yi{constructor(e){this.manager=e!==void 0?e:w6,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}yi.DEFAULT_MATERIAL_NAME="__DEFAULT";const Io={};class HV extends Error{constructor(e,t){super(e),this.response=t}}class na extends yi{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=io.get(`file:${e}`);if(a!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(a),this.manager.itemEnd(e)},0),a;if(Io[e]!==void 0){Io[e].push({onLoad:t,onProgress:i,onError:r});return}Io[e]=[],Io[e].push({onLoad:t,onProgress:i,onError:r});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(s).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&ut("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const f=Io[e],d=h.body.getReader(),p=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),g=p?parseInt(p):0,_=g!==0;let T=0;const y=new ReadableStream({start(v){S();function S(){d.read().then(({done:E,value:b})=>{if(E)v.close();else{T+=b.byteLength;const N=new ProgressEvent("progress",{lengthComputable:_,loaded:T,total:g});for(let R=0,I=f.length;R<I;R++){const U=f[R];U.onProgress&&U.onProgress(N)}v.enqueue(b),S()}},E=>{v.error(E)})}}});return new Response(y)}else throw new HV(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(l){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(f=>new DOMParser().parseFromString(f,o));case"json":return h.json();default:if(o==="")return h.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),p=d&&d[1]?d[1].toLowerCase():void 0,g=new TextDecoder(p);return h.arrayBuffer().then(_=>g.decode(_))}}}).then(h=>{io.add(`file:${e}`,h);const f=Io[e];delete Io[e];for(let d=0,p=f.length;d<p;d++){const g=f[d];g.onLoad&&g.onLoad(h)}}).catch(h=>{const f=Io[e];if(f===void 0)throw this.manager.itemError(e),h;delete Io[e];for(let d=0,p=f.length;d<p;d++){const g=f[d];g.onError&&g.onError(h)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class FV extends yi{constructor(e){super(e)}load(e,t,i,r){const a=this,s=new na(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(o){try{t(a.parse(JSON.parse(o)))}catch(l){r?r(l):Bt(l),a.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=th.parse(e[i]);t.push(r)}return t}}class GV extends yi{constructor(e){super(e)}load(e,t,i,r){const a=this,s=[],o=new Q1,l=new na(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(a.withCredentials);let h=0;function f(d){l.load(e[d],function(p){const g=a.parse(p,!0);s[d]={width:g.width,height:g.height,format:g.format,mipmaps:g.mipmaps},h+=1,h===6&&(g.mipmapCount===1&&(o.minFilter=Ht),o.image=s,o.format=g.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let d=0,p=e.length;d<p;++d)f(d);else l.load(e,function(d){const p=a.parse(d,!0);if(p.isCubemap){const g=p.mipmaps.length/p.mipmapCount;for(let _=0;_<g;_++){s[_]={mipmaps:[]};for(let T=0;T<p.mipmapCount;T++)s[_].mipmaps.push(p.mipmaps[_*p.mipmapCount+T]),s[_].format=p.format,s[_].width=p.width,s[_].height=p.height}o.image=s}else o.image.width=p.width,o.image.height=p.height,o.mipmaps=p.mipmaps;p.mipmapCount===1&&(o.minFilter=Ht),o.format=p.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}}const ff=new WeakMap;class Ld extends yi{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=this,s=io.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)a.manager.itemStart(e),setTimeout(function(){t&&t(s),a.manager.itemEnd(e)},0);else{let d=ff.get(s);d===void 0&&(d=[],ff.set(s,d)),d.push({onLoad:t,onError:r})}return s}const o=g0("img");function l(){f(),t&&t(this);const d=ff.get(this)||[];for(let p=0;p<d.length;p++){const g=d[p];g.onLoad&&g.onLoad(this)}ff.delete(this),a.manager.itemEnd(e)}function h(d){f(),r&&r(d),io.remove(`image:${e}`);const p=ff.get(this)||[];for(let g=0;g<p.length;g++){const _=p[g];_.onError&&_.onError(d)}ff.delete(this),a.manager.itemError(e),a.manager.itemEnd(e)}function f(){o.removeEventListener("load",l,!1),o.removeEventListener("error",h,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),io.add(`image:${e}`,o),a.manager.itemStart(e),o.src=e,o}}class VV extends yi{constructor(e){super(e)}load(e,t,i,r){const a=new G0;a.colorSpace=dn;const s=new Ld(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let o=0;function l(h){s.load(e[h],function(f){a.images[h]=f,o++,o===6&&(a.needsUpdate=!0,t&&t(a))},void 0,r)}for(let h=0;h<e.length;++h)l(h);return a}}class R6 extends yi{constructor(e){super(e)}load(e,t,i,r){const a=this,s=new ea,o=new na(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(a.withCredentials),o.load(e,function(l){let h;try{h=a.parse(l)}catch(f){if(r!==void 0)r(f);else{f(f);return}}h.image!==void 0?s.image=h.image:h.data!==void 0&&(s.image.width=h.width,s.image.height=h.height,s.image.data=h.data),s.wrapS=h.wrapS!==void 0?h.wrapS:Ui,s.wrapT=h.wrapT!==void 0?h.wrapT:Ui,s.magFilter=h.magFilter!==void 0?h.magFilter:Ht,s.minFilter=h.minFilter!==void 0?h.minFilter:Ht,s.anisotropy=h.anisotropy!==void 0?h.anisotropy:1,h.colorSpace!==void 0&&(s.colorSpace=h.colorSpace),h.flipY!==void 0&&(s.flipY=h.flipY),h.format!==void 0&&(s.format=h.format),h.type!==void 0&&(s.type=h.type),h.mipmaps!==void 0&&(s.mipmaps=h.mipmaps,s.minFilter=Aa),h.mipmapCount===1&&(s.minFilter=Ht),h.generateMipmaps!==void 0&&(s.generateMipmaps=h.generateMipmaps),s.needsUpdate=!0,t&&t(s,h)},i,r),s}}class Jb extends yi{constructor(e){super(e)}load(e,t,i,r){const a=new Nn,s=new Ld(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){a.image=o,a.needsUpdate=!0,t!==void 0&&t(a)},i,r),a}}class Dc extends Wt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new qe(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,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class C6 extends Dc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Wt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new qe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const u2=new Ve,lD=new L,cD=new L;class $b{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new de(512,512),this.mapType=Pi,this.map=null,this.mapPass=null,this.matrix=new Ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Kd,this._frameExtents=new de(1,1),this._viewportCount=1,this._viewports=[new zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;lD.setFromMatrixPosition(e.matrixWorld),t.position.copy(lD),cD.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(cD),t.updateMatrixWorld(),u2.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(u2,t.coordinateSystem,t.reversedDepth),t.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(u2)}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.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class kV extends $b{constructor(){super(new hi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=Rd*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,a=e.distance||t.far;(i!==t.fov||r!==t.aspect||a!==t.far)&&(t.fov=i,t.aspect=r,t.far=a,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class eA extends Dc{constructor(e,t,i=0,r=Math.PI/3,a=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Wt.DEFAULT_UP),this.updateMatrix(),this.target=new Wt,this.distance=i,this.angle=r,this.penumbra=a,this.decay=s,this.map=null,this.shadow=new kV}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 uD=new Ve,jp=new L,h2=new L;class WV extends $b{constructor(){super(new hi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new de(4,2),this._viewportCount=6,this._viewports=[new zt(2,1,1,1),new zt(0,1,1,1),new zt(3,1,1,1),new zt(1,1,1,1),new zt(3,0,1,1),new zt(1,0,1,1)],this._cubeDirections=[new L(1,0,0),new L(-1,0,0),new L(0,0,1),new L(0,0,-1),new L(0,1,0),new L(0,-1,0)],this._cubeUps=[new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,0,1),new L(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),jp.setFromMatrixPosition(e.matrixWorld),i.position.copy(jp),h2.copy(i.position),h2.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(h2),i.updateMatrixWorld(),r.makeTranslation(-jp.x,-jp.y,-jp.z),uD.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(uD,i.coordinateSystem,i.reversedDepth)}}class tA extends Dc{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new WV}get power(){return this.intensity*4*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 ao extends wc{constructor(e=-1,t=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let a=i-e,s=i+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=h*this.view.offsetX,s=a+h*this.view.width,o-=f*this.view.offsetY,l=o-f*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class XV extends $b{constructor(){super(new ao(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class nA extends Dc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Wt.DEFAULT_UP),this.updateMatrix(),this.target=new Wt,this.shadow=new XV}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class D6 extends Dc{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class N6 extends Dc{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,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 O6{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new L)}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 i=e.x,r=e.y,a=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*r),t.addScaledVector(s[2],.488603*a),t.addScaledVector(s[3],.488603*i),t.addScaledVector(s[4],1.092548*(i*r)),t.addScaledVector(s[5],1.092548*(r*a)),t.addScaledVector(s[6],.315392*(3*a*a-1)),t.addScaledVector(s[7],1.092548*(i*a)),t.addScaledVector(s[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,a=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],2*.511664*r),t.addScaledVector(s[2],2*.511664*a),t.addScaledVector(s[3],2*.511664*i),t.addScaledVector(s[4],2*.429043*i*r),t.addScaledVector(s[5],2*.429043*r*a),t.addScaledVector(s[6],.743125*a*a-.247708),t.addScaledVector(s[7],2*.429043*i*a),t.addScaledVector(s[8],.429043*(i*i-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 i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],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,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,a=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*a,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*a,t[6]=.315392*(3*a*a-1),t[7]=1.092548*i*a,t[8]=.546274*(i*i-r*r)}}class L6 extends Dc{constructor(e=new O6,t=1){super(void 0,t),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 hy extends yi{constructor(e){super(e),this.textures={}}load(e,t,i,r){const a=this,s=new na(a.manager);s.setPath(a.path),s.setRequestHeader(a.requestHeader),s.setWithCredentials(a.withCredentials),s.load(e,function(o){try{t(a.parse(JSON.parse(o)))}catch(l){r?r(l):Bt(l),a.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(a){return t[a]===void 0&&ut("MaterialLoader: Undefined texture",a),t[a]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const a in e.uniforms){const s=e.uniforms[a];switch(r.uniforms[a]={},s.type){case"t":r.uniforms[a].value=i(s.value);break;case"c":r.uniforms[a].value=new qe().setHex(s.value);break;case"v2":r.uniforms[a].value=new de().fromArray(s.value);break;case"v3":r.uniforms[a].value=new L().fromArray(s.value);break;case"v4":r.uniforms[a].value=new zt().fromArray(s.value);break;case"m3":r.uniforms[a].value=new Et().fromArray(s.value);break;case"m4":r.uniforms[a].value=new Ve().fromArray(s.value);break;default:r.uniforms[a].value=s.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const a in e.extensions)r.extensions[a]=e.extensions[a];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let a=e.normalScale;Array.isArray(a)===!1&&(a=[a,a]),r.normalScale=new de().fromArray(a)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new de().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return hy.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:g6,SpriteMaterial:Ib,RawShaderMaterial:ph,ShaderMaterial:Vi,PointsMaterial:K1,MeshPhysicalMaterial:cs,MeshStandardMaterial:q0,MeshPhongMaterial:v6,MeshToonMaterial:_6,MeshNormalMaterial:Xb,MeshLambertMaterial:x6,MeshDepthMaterial:Yb,MeshDistanceMaterial:qb,MeshBasicMaterial:Ur,MeshMatcapMaterial:y6,LineDashedMaterial:S6,LineBasicMaterial:Bi,Material:jn};return new t[e]}}class fc{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class I6 extends Ct{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 U6 extends yi{constructor(e){super(e)}load(e,t,i,r){const a=this,s=new na(a.manager);s.setPath(a.path),s.setRequestHeader(a.requestHeader),s.setWithCredentials(a.withCredentials),s.load(e,function(o){try{t(a.parse(JSON.parse(o)))}catch(l){r?r(l):Bt(l),a.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(g,_){if(t[_]!==void 0)return t[_];const y=g.interleavedBuffers[_],v=a(g,y.buffer),S=qf(y.type,v),E=new Zd(S,y.stride);return E.uuid=y.uuid,t[_]=E,E}function a(g,_){if(i[_]!==void 0)return i[_];const y=g.arrayBuffers[_],v=new Uint32Array(y).buffer;return i[_]=v,v}const s=e.isInstancedBufferGeometry?new I6:new Ct,o=e.data.index;if(o!==void 0){const g=qf(o.type,o.array);s.setIndex(new Ot(g,1))}const l=e.data.attributes;for(const g in l){const _=l[g];let T;if(_.isInterleavedBufferAttribute){const y=r(e.data,_.data);T=new ll(y,_.itemSize,_.offset,_.normalized)}else{const y=qf(_.type,_.array),v=_.isInstancedBufferAttribute?Ju:Ot;T=new v(y,_.itemSize,_.normalized)}_.name!==void 0&&(T.name=_.name),_.usage!==void 0&&T.setUsage(_.usage),s.setAttribute(g,T)}const h=e.data.morphAttributes;if(h)for(const g in h){const _=h[g],T=[];for(let y=0,v=_.length;y<v;y++){const S=_[y];let E;if(S.isInterleavedBufferAttribute){const b=r(e.data,S.data);E=new ll(b,S.itemSize,S.offset,S.normalized)}else{const b=qf(S.type,S.array);E=new Ot(b,S.itemSize,S.normalized)}S.name!==void 0&&(E.name=S.name),T.push(E)}s.morphAttributes[g]=T}e.data.morphTargetsRelative&&(s.morphTargetsRelative=!0);const d=e.data.groups||e.data.drawcalls||e.data.offsets;if(d!==void 0)for(let g=0,_=d.length;g!==_;++g){const T=d[g];s.addGroup(T.start,T.count,T.materialIndex)}const p=e.data.boundingSphere;return p!==void 0&&(s.boundingSphere=new nr().fromJSON(p)),e.name&&(s.name=e.name),e.userData&&(s.userData=e.userData),s}}class YV extends yi{constructor(e){super(e)}load(e,t,i,r){const a=this,s=this.path===""?fc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;const o=new na(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let h=null;try{h=JSON.parse(l)}catch(d){r!==void 0&&r(d),d("ObjectLoader: Can't parse "+e+".",d.message);return}const f=h.metadata;if(f===void 0||f.type===void 0||f.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),Bt("ObjectLoader: Can't load "+e);return}a.parse(h,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?fc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const a=new na(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials);const s=await a.loadAsync(e,t),o=JSON.parse(s),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),a=this.parseGeometries(e.geometries,r),s=this.parseImages(e.images,function(){t!==void 0&&t(h)}),o=this.parseTextures(e.textures,s),l=this.parseMaterials(e.materials,o),h=this.parseObject(e.object,a,l,o,i),f=this.parseSkeletons(e.skeletons,h);if(this.bindSkeletons(h,f),this.bindLightTargets(h),t!==void 0){let d=!1;for(const p in s)if(s[p].data instanceof HTMLImageElement){d=!0;break}d===!1&&t(h)}return h}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),a=await this.parseImagesAsync(e.images),s=this.parseTextures(e.textures,a),o=this.parseMaterials(e.materials,s),l=this.parseObject(e.object,r,o,s,t),h=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,h),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const a=new Hu().fromJSON(e[i]);t[a.uuid]=a}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(a){a.isBone&&(r[a.uuid]=a)}),e!==void 0)for(let a=0,s=e.length;a<s;a++){const o=new Rc().fromJSON(e[a],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new U6;for(let a=0,s=e.length;a<s;a++){let o;const l=e[a];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in oD?o=oD[l.type].fromJSON(l,t):ut(`ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),i[l.uuid]=o}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const a=new hy;a.setTextures(t);for(let s=0,o=e.length;s<o;s++){const l=e[s];i[l.uuid]===void 0&&(i[l.uuid]=a.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],a=th.parse(r);t[a.uuid]=a}return t}parseImages(e,t){const i=this,r={};let a;function s(l){return i.manager.itemStart(l),a.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const h=l,f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h)?h:i.resourcePath+h;return s(f)}else return l.data?{data:qf(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new Qb(t);a=new Ld(l),a.setCrossOrigin(this.crossOrigin);for(let h=0,f=e.length;h<f;h++){const d=e[h],p=d.url;if(Array.isArray(p)){const g=[];for(let _=0,T=p.length;_<T;_++){const y=p[_],v=o(y);v!==null&&(v instanceof HTMLImageElement?g.push(v):g.push(new ea(v.data,v.width,v.height)))}r[d.uuid]=new ec(g)}else{const g=o(d.url);r[d.uuid]=new ec(g)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function a(s){if(typeof s=="string"){const o=s,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return s.data?{data:qf(s.type,s.data),width:s.width,height:s.height}:null}if(e!==void 0&&e.length>0){r=new Ld(this.manager),r.setCrossOrigin(this.crossOrigin);for(let s=0,o=e.length;s<o;s++){const l=e[s],h=l.url;if(Array.isArray(h)){const f=[];for(let d=0,p=h.length;d<p;d++){const g=h[d],_=await a(g);_!==null&&(_ instanceof HTMLImageElement?f.push(_):f.push(new ea(_.data,_.width,_.height)))}i[l.uuid]=new ec(f)}else{const f=await a(l.url);i[l.uuid]=new ec(f)}}}return i}parseTextures(e,t){function i(a,s){return typeof a=="number"?a:(ut("ObjectLoader.parseTexture: Constant should be in numeric form.",a),s[a])}const r={};if(e!==void 0)for(let a=0,s=e.length;a<s;a++){const o=e[a];o.image===void 0&&ut('ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&ut("ObjectLoader: Undefined image",o.image);const l=t[o.image],h=l.data;let f;Array.isArray(h)?(f=new G0,h.length===6&&(f.needsUpdate=!0)):(h&&h.data?f=new ea:f=new Nn,h&&(f.needsUpdate=!0)),f.source=l,f.uuid=o.uuid,o.name!==void 0&&(f.name=o.name),o.mapping!==void 0&&(f.mapping=i(o.mapping,qV)),o.channel!==void 0&&(f.channel=o.channel),o.offset!==void 0&&f.offset.fromArray(o.offset),o.repeat!==void 0&&f.repeat.fromArray(o.repeat),o.center!==void 0&&f.center.fromArray(o.center),o.rotation!==void 0&&(f.rotation=o.rotation),o.wrap!==void 0&&(f.wrapS=i(o.wrap[0],hD),f.wrapT=i(o.wrap[1],hD)),o.format!==void 0&&(f.format=o.format),o.internalFormat!==void 0&&(f.internalFormat=o.internalFormat),o.type!==void 0&&(f.type=o.type),o.colorSpace!==void 0&&(f.colorSpace=o.colorSpace),o.minFilter!==void 0&&(f.minFilter=i(o.minFilter,fD)),o.magFilter!==void 0&&(f.magFilter=i(o.magFilter,fD)),o.anisotropy!==void 0&&(f.anisotropy=o.anisotropy),o.flipY!==void 0&&(f.flipY=o.flipY),o.generateMipmaps!==void 0&&(f.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(f.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(f.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(f.compareFunction=o.compareFunction),o.userData!==void 0&&(f.userData=o.userData),r[o.uuid]=f}return r}parseObject(e,t,i,r,a){let s;function o(p){return t[p]===void 0&&ut("ObjectLoader: Undefined geometry",p),t[p]}function l(p){if(p!==void 0){if(Array.isArray(p)){const g=[];for(let _=0,T=p.length;_<T;_++){const y=p[_];i[y]===void 0&&ut("ObjectLoader: Undefined material",y),g.push(i[y])}return g}return i[p]===void 0&&ut("ObjectLoader: Undefined material",p),i[p]}}function h(p){return r[p]===void 0&&ut("ObjectLoader: Undefined texture",p),r[p]}let f,d;switch(e.type){case"Scene":s=new Nd,e.background!==void 0&&(Number.isInteger(e.background)?s.background=new qe(e.background):s.background=h(e.background)),e.environment!==void 0&&(s.environment=h(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?s.fog=new Y1(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(s.fog=new X1(e.fog.color,e.fog.density)),e.fog.name!==""&&(s.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(s.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(s.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&s.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(s.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&s.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":s=new hi(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(s.focus=e.focus),e.zoom!==void 0&&(s.zoom=e.zoom),e.filmGauge!==void 0&&(s.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(s.filmOffset=e.filmOffset),e.view!==void 0&&(s.view=Object.assign({},e.view));break;case"OrthographicCamera":s=new ao(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(s.zoom=e.zoom),e.view!==void 0&&(s.view=Object.assign({},e.view));break;case"AmbientLight":s=new D6(e.color,e.intensity);break;case"DirectionalLight":s=new nA(e.color,e.intensity),s.target=e.target||"";break;case"PointLight":s=new tA(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":s=new N6(e.color,e.intensity,e.width,e.height);break;case"SpotLight":s=new eA(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),s.target=e.target||"";break;case"HemisphereLight":s=new C6(e.color,e.groundColor,e.intensity);break;case"LightProbe":s=new L6().fromJSON(e);break;case"SkinnedMesh":f=o(e.geometry),d=l(e.material),s=new q1(f,d),e.bindMode!==void 0&&(s.bindMode=e.bindMode),e.bindMatrix!==void 0&&s.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(s.skeleton=e.skeleton);break;case"Mesh":f=o(e.geometry),d=l(e.material),s=new oi(f,d);break;case"InstancedMesh":f=o(e.geometry),d=l(e.material);const p=e.count,g=e.instanceMatrix,_=e.instanceColor;s=new Ub(f,d,p),s.instanceMatrix=new Ju(new Float32Array(g.array),16),_!==void 0&&(s.instanceColor=new Ju(new Float32Array(_.array),_.itemSize));break;case"BatchedMesh":f=o(e.geometry),d=l(e.material),s=new i6(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,d),s.geometry=f,s.perObjectFrustumCulled=e.perObjectFrustumCulled,s.sortObjects=e.sortObjects,s._drawRanges=e.drawRanges,s._reservedRanges=e.reservedRanges,s._geometryInfo=e.geometryInfo.map(T=>{let y=null,v=null;return T.boundingBox!==void 0&&(y=new tr().fromJSON(T.boundingBox)),T.boundingSphere!==void 0&&(v=new nr().fromJSON(T.boundingSphere)),{...T,boundingBox:y,boundingSphere:v}}),s._instanceInfo=e.instanceInfo,s._availableInstanceIds=e._availableInstanceIds,s._availableGeometryIds=e._availableGeometryIds,s._nextIndexStart=e.nextIndexStart,s._nextVertexStart=e.nextVertexStart,s._geometryCount=e.geometryCount,s._maxInstanceCount=e.maxInstanceCount,s._maxVertexCount=e.maxVertexCount,s._maxIndexCount=e.maxIndexCount,s._geometryInitialized=e.geometryInitialized,s._matricesTexture=h(e.matricesTexture.uuid),s._indirectTexture=h(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(s._colorsTexture=h(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(s.boundingSphere=new nr().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(s.boundingBox=new tr().fromJSON(e.boundingBox));break;case"LOD":s=new n6;break;case"Line":s=new oo(o(e.geometry),l(e.material));break;case"LineLoop":s=new Pb(o(e.geometry),l(e.material));break;case"LineSegments":s=new aa(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":s=new zb(o(e.geometry),l(e.material));break;case"Sprite":s=new t6(l(e.material));break;case"Group":s=new Pr;break;case"Bone":s=new j1;break;default:s=new Wt}if(s.uuid=e.uuid,e.name!==void 0&&(s.name=e.name),e.matrix!==void 0?(s.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(s.matrixAutoUpdate=e.matrixAutoUpdate),s.matrixAutoUpdate&&s.matrix.decompose(s.position,s.quaternion,s.scale)):(e.position!==void 0&&s.position.fromArray(e.position),e.rotation!==void 0&&s.rotation.fromArray(e.rotation),e.quaternion!==void 0&&s.quaternion.fromArray(e.quaternion),e.scale!==void 0&&s.scale.fromArray(e.scale)),e.up!==void 0&&s.up.fromArray(e.up),e.castShadow!==void 0&&(s.castShadow=e.castShadow),e.receiveShadow!==void 0&&(s.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(s.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(s.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(s.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(s.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&s.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(s.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(s.visible=e.visible),e.frustumCulled!==void 0&&(s.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(s.renderOrder=e.renderOrder),e.userData!==void 0&&(s.userData=e.userData),e.layers!==void 0&&(s.layers.mask=e.layers),e.children!==void 0){const p=e.children;for(let g=0;g<p.length;g++)s.add(this.parseObject(p[g],t,i,r,a))}if(e.animations!==void 0){const p=e.animations;for(let g=0;g<p.length;g++){const _=p[g];s.animations.push(a[_])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(s.autoUpdate=e.autoUpdate);const p=e.levels;for(let g=0;g<p.length;g++){const _=p[g],T=s.getObjectByProperty("uuid",_.object);T!==void 0&&s.addLevel(T,_.distance,_.hysteresis)}}return s}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?ut("ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,r=e.getObjectByProperty("uuid",i);r!==void 0?t.target=r:t.target=new Wt}})}}const qV={UVMapping:U1,CubeReflectionMapping:ol,CubeRefractionMapping:_c,EquirectangularReflectionMapping:h0,EquirectangularRefractionMapping:f0,CubeUVReflectionMapping:jd},hD={RepeatWrapping:Mr,ClampToEdgeWrapping:Ui,MirroredRepeatWrapping:Td},fD={NearestFilter:Vn,NearestMipmapNearestFilter:P1,NearestMipmapLinearFilter:bu,LinearFilter:Ht,LinearMipmapNearestFilter:sd,LinearMipmapLinearFilter:Aa},f2=new WeakMap;class P6 extends yi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&ut("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&ut("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=this,s=io.get(`image-bitmap:${e}`);if(s!==void 0){if(a.manager.itemStart(e),s.then){s.then(h=>{if(f2.has(s)===!0)r&&r(f2.get(s)),a.manager.itemError(e),a.manager.itemEnd(e);else return t&&t(h),a.manager.itemEnd(e),h});return}return setTimeout(function(){t&&t(s),a.manager.itemEnd(e)},0),s}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(a.options,{colorSpaceConversion:"none"}))}).then(function(h){return io.add(`image-bitmap:${e}`,h),t&&t(h),a.manager.itemEnd(e),h}).catch(function(h){r&&r(h),f2.set(l,h),io.remove(`image-bitmap:${e}`),a.manager.itemError(e),a.manager.itemEnd(e)});io.add(`image-bitmap:${e}`,l),a.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let Ov;class iA{static getContext(){return Ov===void 0&&(Ov=new(window.AudioContext||window.webkitAudioContext)),Ov}static setContext(e){Ov=e}}class jV extends yi{constructor(e){super(e)}load(e,t,i,r){const a=this,s=new na(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(l){try{const h=l.slice(0);iA.getContext().decodeAudioData(h,function(d){t(d)}).catch(o)}catch(h){o(h)}},i,r);function o(l){r?r(l):Bt(l),a.manager.itemError(e)}}}const dD=new Ve,pD=new Ve,nu=new Ve;class ZV{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new hi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new hi,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,nu.copy(e.projectionMatrix);const r=t.eyeSep/2,a=r*t.near/t.focus,s=t.near*Math.tan(Bu*t.fov*.5)/t.zoom;let o,l;pD.elements[12]=-r,dD.elements[12]=r,o=-s*t.aspect+a,l=s*t.aspect+a,nu.elements[0]=2*t.near/(l-o),nu.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(nu),o=-s*t.aspect-a,l=s*t.aspect-a,nu.elements[0]=2*t.near/(l-o),nu.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(nu)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(pD),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(dD)}}class z6 extends hi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class rA{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),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=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const iu=new L,d2=new _t,KV=new L,ru=new L,au=new L;class QV extends Wt{constructor(){super(),this.type="AudioListener",this.context=iA.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new rA}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(iu,d2,KV),ru.set(0,0,-1).applyQuaternion(d2),au.set(0,1,0).applyQuaternion(d2),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(iu.x,i),t.positionY.linearRampToValueAtTime(iu.y,i),t.positionZ.linearRampToValueAtTime(iu.z,i),t.forwardX.linearRampToValueAtTime(ru.x,i),t.forwardY.linearRampToValueAtTime(ru.y,i),t.forwardZ.linearRampToValueAtTime(ru.z,i),t.upX.linearRampToValueAtTime(au.x,i),t.upY.linearRampToValueAtTime(au.y,i),t.upZ.linearRampToValueAtTime(au.z,i)}else t.setPosition(iu.x,iu.y,iu.z),t.setOrientation(ru.x,ru.y,ru.z,au.x,au.y,au.z)}}class B6 extends Wt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){ut("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;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(this._connected!==!1){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=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&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(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(ut("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){ut("Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}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}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(ut("Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const su=new L,mD=new _t,JV=new L,ou=new L;class $V extends B6{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}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,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(su,mD,JV),ou.set(0,0,1).applyQuaternion(mD);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(su.x,i),t.positionY.linearRampToValueAtTime(su.y,i),t.positionZ.linearRampToValueAtTime(su.z,i),t.orientationX.linearRampToValueAtTime(ou.x,i),t.orientationY.linearRampToValueAtTime(ou.y,i),t.orientationZ.linearRampToValueAtTime(ou.z,i)}else t.setPosition(su.x,su.y,su.z),t.setOrientation(ou.x,ou.y,ou.z)}}class ek{constructor(e,t=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 i=0;i<t.length;i++)e+=t[i];return e/t.length}}class H6{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,a,s;switch(t){case"quaternion":r=this._slerp,a=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,a=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,a=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=a,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 i=this.buffer,r=this.valueSize,a=e*r+r;let s=this.cumulativeWeight;if(s===0){for(let o=0;o!==r;++o)i[a+o]=i[o];s=t}else{s+=t;const o=t/s;this._mixBufferRegion(i,a,0,o,r)}this.cumulativeWeight=s}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,a=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,a<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-a,t)}s>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,h=t+t;l!==h;++l)if(i[l]!==i[l+t]){o.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let a=i,s=r;a!==s;++a)t[a]=t[r+a%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=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 i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,a){if(r>=.5)for(let s=0;s!==a;++s)e[t+s]=e[i+s]}_slerp(e,t,i,r){_t.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,a){const s=this._workIndex*a;_t.multiplyQuaternionsFlat(e,s,e,t,e,i),_t.slerpFlat(e,t,e,t,e,s,r)}_lerp(e,t,i,r,a){const s=1-r;for(let o=0;o!==a;++o){const l=t+o;e[l]=e[l]*s+e[i+o]*r}}_lerpAdditive(e,t,i,r,a){for(let s=0;s!==a;++s){const o=t+s;e[o]=e[o]+e[i+s]*r}}}const aA="\\[\\]\\.:\\/",tk=new RegExp("["+aA+"]","g"),sA="[^"+aA+"]",nk="[^"+aA.replace("\\.","")+"]",ik=/((?:WC+[\/:])*)/.source.replace("WC",sA),rk=/(WCOD+)?/.source.replace("WCOD",nk),ak=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",sA),sk=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",sA),ok=new RegExp("^"+ik+rk+ak+sk+"$"),lk=["material","materials","bones","map"];class ck{constructor(e,t,i){const r=i||fn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class fn{constructor(e,t,i){this.path=t,this.parsedPath=i||fn.parseTrackName(t),this.node=fn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new fn.Composite(e,t,i):new fn(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(tk,"")}static parseTrackName(e){const t=ok.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const a=i.nodeName.substring(r+1);lk.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(a){for(let s=0;s<a.length;s++){const o=a[s];if(o.name===t||o.uuid===t)return o;const l=i(o.children);if(l)return l}return null},r=i(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 i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[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 i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[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,i=t.objectName,r=t.propertyName;let a=t.propertyIndex;if(e||(e=fn.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){ut("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let h=t.objectIndex;switch(i){case"materials":if(!e.material){Bt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Bt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Bt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let f=0;f<e.length;f++)if(e[f].name===h){h=f;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Bt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Bt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){Bt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(h!==void 0){if(e[h]===void 0){Bt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[h]}}const s=e[r];if(s===void 0){const h=t.nodeName;Bt("PropertyBinding: Trying to update property for track: "+h+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(a!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){Bt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Bt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}l=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(l=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}fn.Composite=ck;fn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};fn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};fn.prototype.GetterByBindingType=[fn.prototype._getValue_direct,fn.prototype._getValue_array,fn.prototype._getValue_arrayElement,fn.prototype._getValue_toArray];fn.prototype.SetterByBindingTypeAndVersioning=[[fn.prototype._setValue_direct,fn.prototype._setValue_direct_setNeedsUpdate,fn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[fn.prototype._setValue_array,fn.prototype._setValue_array_setNeedsUpdate,fn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[fn.prototype._setValue_arrayElement,fn.prototype._setValue_arrayElement_setNeedsUpdate,fn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[fn.prototype._setValue_fromArray,fn.prototype._setValue_fromArray_setNeedsUpdate,fn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class uk{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Oa(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;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,i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length;let o,l=e.length,h=this.nCachedObjects_;for(let f=0,d=arguments.length;f!==d;++f){const p=arguments[f],g=p.uuid;let _=t[g];if(_===void 0){_=l++,t[g]=_,e.push(p);for(let T=0,y=s;T!==y;++T)a[T].push(new fn(p,i[T],r[T]))}else if(_<h){o=e[_];const T=--h,y=e[T];t[y.uuid]=_,e[_]=y,t[g]=T,e[T]=p;for(let v=0,S=s;v!==S;++v){const E=a[v],b=E[T];let N=E[_];E[_]=b,N===void 0&&(N=new fn(p,i[v],r[v])),E[T]=N}}else e[_]!==o&&Bt("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let a=this.nCachedObjects_;for(let s=0,o=arguments.length;s!==o;++s){const l=arguments[s],h=l.uuid,f=t[h];if(f!==void 0&&f>=a){const d=a++,p=e[d];t[p.uuid]=f,e[f]=p,t[h]=d,e[d]=l;for(let g=0,_=r;g!==_;++g){const T=i[g],y=T[d],v=T[f];T[f]=y,T[d]=v}}}this.nCachedObjects_=a}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let a=this.nCachedObjects_,s=e.length;for(let o=0,l=arguments.length;o!==l;++o){const h=arguments[o],f=h.uuid,d=t[f];if(d!==void 0)if(delete t[f],d<a){const p=--a,g=e[p],_=--s,T=e[_];t[g.uuid]=d,e[d]=g,t[T.uuid]=p,e[p]=T,e.pop();for(let y=0,v=r;y!==v;++y){const S=i[y],E=S[p],b=S[_];S[d]=E,S[p]=b,S.pop()}}else{const p=--s,g=e[p];p>0&&(t[g.uuid]=d),e[d]=g,e.pop();for(let _=0,T=r;_!==T;++_){const y=i[_];y[d]=y[p],y.pop()}}}this.nCachedObjects_=a}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const a=this._bindings;if(r!==void 0)return a[r];const s=this._paths,o=this._parsedPaths,l=this._objects,h=l.length,f=this.nCachedObjects_,d=new Array(h);r=a.length,i[e]=r,s.push(e),o.push(t),a.push(d);for(let p=f,g=l.length;p!==g;++p){const _=l[p];d[p]=new fn(_,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,a=this._parsedPaths,s=this._bindings,o=s.length-1,l=s[o],h=e[o];t[h]=i,s[i]=l,s.pop(),a[i]=a[o],a.pop(),r[i]=r[o],r.pop()}}}class F6{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const a=t.tracks,s=a.length,o=new Array(s),l={endingStart:Au,endingEnd:Au};for(let h=0;h!==s;++h){const f=a[h].createInterpolant(null);o[h]=f,f.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=OU,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){const r=this._clip.duration,a=e._clip.duration,s=a/r,o=r/a;e.warp(1,s,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,a=r.time,s=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,h=o.sampleValues;return l[0]=a,l[1]=a+i,h[0]=e/s,h[1]=t/s,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const a=this._startTime;if(a!==null){const l=(e-a)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const s=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case Ab:for(let f=0,d=l.length;f!==d;++f)l[f].evaluate(s),h[f].accumulateAdditive(o);break;case k1:default:for(let f=0,d=l.length;f!==d;++f)l[f].evaluate(s),h[f].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,a=this._loopCount;const s=i===LU;if(e===0)return a===-1?r:s&&(a&1)===1?t-r:r;if(i===bb){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}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(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,a+=Math.abs(o);const l=this.repetitions-a;if(l<=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(l===1){const h=e<0;this._setEndings(h,!h,s)}else this._setEndings(!1,!1,s);this._loopCount=a,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(s&&(a&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=wu,r.endingEnd=wu):(e?r.endingStart=this.zeroSlopeAtStart?wu:Au:r.endingStart=d0,t?r.endingEnd=this.zeroSlopeAtEnd?wu:Au:r.endingEnd=d0)}_scheduleFading(e,t,i){const r=this._mixer,a=r.time;let s=this._weightInterpolant;s===null&&(s=r._lendControlInterpolant(),this._weightInterpolant=s);const o=s.parameterPositions,l=s.sampleValues;return o[0]=a,l[0]=t,o[1]=a+e,l[1]=i,this}}const hk=new Float32Array(1);class G6 extends ra{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,a=r.length,s=e._propertyBindings,o=e._interpolants,l=i.uuid,h=this._bindingsByRootAndName;let f=h[l];f===void 0&&(f={},h[l]=f);for(let d=0;d!==a;++d){const p=r[d],g=p.name;let _=f[g];if(_!==void 0)++_.referenceCount,s[d]=_;else{if(_=s[d],_!==void 0){_._cacheIndex===null&&(++_.referenceCount,this._addInactiveBinding(_,l,g));continue}const T=t&&t._propertyBindings[d].binding.parsedPath;_=new H6(fn.create(i,g,T),p.ValueTypeName,p.getValueSize()),++_.referenceCount,this._addInactiveBinding(_,l,g),s[d]=_}o[d].resultBuffer=_.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,a=this._actionsByClip[r];this._bindAction(e,a&&a.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const a=t[i];a.useCount++===0&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const a=t[i];--a.useCount===0&&(a.restoreOriginalState(),this._takeBackBinding(a))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,a=this._actionsByClip;let s=a[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,a[t]=s;else{const o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const a=e._clip.uuid,s=this._actionsByClip,o=s[a],l=o.knownActions,h=l[l.length-1],f=e._byClipCacheIndex;h._byClipCacheIndex=f,l[f]=h,l.pop(),e._byClipCacheIndex=null;const d=o.actionByRoot,p=(e._localRoot||this._root).uuid;delete d[p],l.length===0&&delete s[a],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const a=t[i];--a.referenceCount===0&&this._removeInactiveBinding(a)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,a=this._bindings;let s=r[t];s===void 0&&(s={},r[t]=s),s[i]=e,e._cacheIndex=a.length,a.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,a=i.path,s=this._bindingsByRootAndName,o=s[r],l=t[t.length-1],h=e._cacheIndex;l._cacheIndex=h,t[h]=l,t.pop(),delete o[a],Object.keys(o).length===0&&delete s[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,a=t[r];e._cacheIndex=r,t[r]=e,a._cacheIndex=i,t[i]=a}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Zb(new Float32Array(2),new Float32Array(2),1,hk),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,a=t[r];e.__cacheIndex=r,t[r]=e,a.__cacheIndex=i,t[i]=a}clipAction(e,t,i){const r=t||this._root,a=r.uuid;let s=typeof e=="string"?th.findByName(r,e):e;const o=s!==null?s.uuid:e,l=this._actionsByClip[o];let h=null;if(i===void 0&&(s!==null?i=s.blendMode:i=k1),l!==void 0){const d=l.actionByRoot[a];if(d!==void 0&&d.blendMode===i)return d;h=l.knownActions[0],s===null&&(s=h._clip)}if(s===null)return null;const f=new F6(this,s,t,i);return this._bindAction(f,h),this._addInactiveAction(f,o,a),f}existingAction(e,t){const i=t||this._root,r=i.uuid,a=typeof e=="string"?th.findByName(i,e):e,s=a?a.uuid:e,o=this._actionsByClip[s];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,a=Math.sign(e),s=this._accuIndex^=1;for(let h=0;h!==i;++h)t[h]._update(r,e,a,s);const o=this._bindings,l=this._nActiveBindings;for(let h=0;h!==l;++h)o[h].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,i=e.uuid,r=this._actionsByClip,a=r[i];if(a!==void 0){const s=a.knownActions;for(let o=0,l=s.length;o!==l;++o){const h=s[o];this._deactivateAction(h);const f=h._cacheIndex,d=t[t.length-1];h._cacheIndex=null,h._byClipCacheIndex=null,d._cacheIndex=f,t[f]=d,t.pop(),this._removeInactiveBindingsForAction(h)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const s in i){const o=i[s].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,a=r[t];if(a!==void 0)for(const s in a){const o=a[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class fk extends Db{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=i,this.texture=new ss(null,e,t,i),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class J{constructor(e){this.value=e}clone(){return new J(this.value.clone===void 0?this.value:this.value.clone())}}let dk=0;class pk extends ra{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:dk++}),this.name="",this.usage=m0,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){const a=Array.isArray(t[i])?t[i]:[t[i]];for(let s=0;s<a.length;s++)this.uniforms.push(a[s].clone())}return this}clone(){return new this.constructor().copy(this)}}class mk extends Zd{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}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 SE{constructor(e,t,i,r,a,s=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=a,this.normalized=s,this.version=0}set needsUpdate(e){e===!0&&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 gD=new Ve;class V6{constructor(e,t,i=0,r=1/0){this.ray=new Ac(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Cd,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):Bt("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return gD.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(gD),this}intersectObject(e,t=!0,i=[]){return TE(e,this,i,t),i.sort(vD),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)TE(e[r],this,i,t);return i.sort(vD),i}}function vD(n,e){return n.distance-e.distance}function TE(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const a=n.children;for(let s=0,o=a.length;s<o;s++)TE(a[s],e,t,!0)}}let gk=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=vk.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function vk(){this._document.hidden===!1&&this.reset()}class EE{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Lt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Lt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class _k{constructor(e=1,t=0,i=0){this.radius=e,this.theta=t,this.y=i}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,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,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}class oA{constructor(e,t,i,r){oA.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const a=this.elements;return a[0]=e,a[2]=t,a[1]=i,a[3]=r,this}}const _D=new de;class xk{constructor(e=new de(1/0,1/0),t=new de(-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,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=_D.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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,_D).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 xD=new L,Lv=new L,df=new L,pf=new L,p2=new L,yk=new L,Sk=new L;class Tk{constructor(e=new L,t=new L){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){xD.subVectors(e,this.start),Lv.subVectors(this.end,this.start);const i=Lv.dot(Lv);let a=Lv.dot(xD)/i;return t&&(a=Lt(a,0,1)),a}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=yk,i=Sk){const r=10000000000000001e-32;let a,s;const o=this.start,l=e.start,h=this.end,f=e.end;df.subVectors(h,o),pf.subVectors(f,l),p2.subVectors(o,l);const d=df.dot(df),p=pf.dot(pf),g=pf.dot(p2);if(d<=r&&p<=r)return t.copy(o),i.copy(l),t.sub(i),t.dot(t);if(d<=r)a=0,s=g/p,s=Lt(s,0,1);else{const _=df.dot(p2);if(p<=r)s=0,a=Lt(-_/d,0,1);else{const T=df.dot(pf),y=d*p-T*T;y!==0?a=Lt((T*g-_*p)/y,0,1):a=0,s=(T*a+g)/p,s<0?(s=0,a=Lt(-_/d,0,1)):s>1&&(s=1,a=Lt((T-_)/d,0,1))}}return t.copy(o).add(df.multiplyScalar(a)),i.copy(l).add(pf.multiplyScalar(s)),t.sub(i),t.dot(t)}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 yD=new L;class Ek extends Wt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new Ct,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,o=1,l=32;s<l;s++,o++){const h=s/l*Math.PI*2,f=o/l*Math.PI*2;r.push(Math.cos(h),Math.sin(h),1,Math.cos(f),Math.sin(f),1)}i.setAttribute("position",new yt(r,3));const a=new Bi({fog:!1,toneMapped:!1});this.cone=new aa(i,a),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),yD.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(yD),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Pl=new L,Iv=new Ve,m2=new Ve;class Mk extends aa{constructor(e){const t=k6(e),i=new Ct,r=[],a=[];for(let h=0;h<t.length;h++){const f=t[h];f.parent&&f.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),a.push(0,0,0),a.push(0,0,0))}i.setAttribute("position",new yt(r,3)),i.setAttribute("color",new yt(a,3));const s=new Bi({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,s),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const o=new qe(255),l=new qe(65280);this.setColors(o,l)}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");m2.copy(this.root.matrixWorld).invert();for(let a=0,s=0;a<t.length;a++){const o=t[a];o.parent&&o.parent.isBone&&(Iv.multiplyMatrices(m2,o.matrixWorld),Pl.setFromMatrixPosition(Iv),r.setXYZ(s,Pl.x,Pl.y,Pl.z),Iv.multiplyMatrices(m2,o.parent.matrixWorld),Pl.setFromMatrixPosition(Iv),r.setXYZ(s+1,Pl.x,Pl.y,Pl.z),s+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const r=this.geometry.getAttribute("color");for(let a=0;a<r.count;a+=2)r.setXYZ(a,e.r,e.g,e.b),r.setXYZ(a+1,t.r,t.g,t.b);return r.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function k6(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push(...k6(n.children[t]));return e}class bk extends oi{constructor(e,t,i){const r=new Y0(t,4,2),a=new Ur({wireframe:!0,fog:!1,toneMapped:!1});super(r,a),this.light=e,this.color=i,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),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const Ak=new L,SD=new qe,TD=new qe;class wk extends Wt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const r=new X0(t);r.rotateY(Math.PI*.5),this.material=new Ur({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const a=r.getAttribute("position"),s=new Float32Array(a.count*3);r.setAttribute("color",new Ot(s,3)),this.add(new oi(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");SD.copy(this.light.color),TD.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const a=i<r/2?SD:TD;t.setXYZ(i,a.r,a.g,a.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Ak.setFromMatrixPosition(this.light.matrixWorld).negate())}}class Rk extends aa{constructor(e=10,t=10,i=4473924,r=8947848){i=new qe(i),r=new qe(r);const a=t/2,s=e/t,o=e/2,l=[],h=[];for(let p=0,g=0,_=-o;p<=t;p++,_+=s){l.push(-o,0,_,o,0,_),l.push(_,0,-o,_,0,o);const T=p===a?i:r;T.toArray(h,g),g+=3,T.toArray(h,g),g+=3,T.toArray(h,g),g+=3,T.toArray(h,g),g+=3}const f=new Ct;f.setAttribute("position",new yt(l,3)),f.setAttribute("color",new yt(h,3));const d=new Bi({vertexColors:!0,toneMapped:!1});super(f,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ck extends aa{constructor(e=10,t=16,i=8,r=64,a=4473924,s=8947848){a=new qe(a),s=new qe(s);const o=[],l=[];if(t>1)for(let d=0;d<t;d++){const p=d/t*(Math.PI*2),g=Math.sin(p)*e,_=Math.cos(p)*e;o.push(0,0,0),o.push(g,0,_);const T=d&1?a:s;l.push(T.r,T.g,T.b),l.push(T.r,T.g,T.b)}for(let d=0;d<i;d++){const p=d&1?a:s,g=e-e/i*d;for(let _=0;_<r;_++){let T=_/r*(Math.PI*2),y=Math.sin(T)*g,v=Math.cos(T)*g;o.push(y,0,v),l.push(p.r,p.g,p.b),T=(_+1)/r*(Math.PI*2),y=Math.sin(T)*g,v=Math.cos(T)*g,o.push(y,0,v),l.push(p.r,p.g,p.b)}}const h=new Ct;h.setAttribute("position",new yt(o,3)),h.setAttribute("color",new yt(l,3));const f=new Bi({vertexColors:!0,toneMapped:!1});super(h,f),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const ED=new L,Uv=new L,MD=new L;class Dk extends Wt{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Ct;r.setAttribute("position",new yt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const a=new Bi({fog:!1,toneMapped:!1});this.lightPlane=new oo(r,a),this.add(this.lightPlane),r=new Ct,r.setAttribute("position",new yt([0,0,0,0,0,1],3)),this.targetLine=new oo(r,a),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),ED.setFromMatrixPosition(this.light.matrixWorld),Uv.setFromMatrixPosition(this.light.target.matrixWorld),MD.subVectors(Uv,ED),this.lightPlane.lookAt(Uv),this.color!==void 0?(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(Uv),this.targetLine.scale.z=MD.length()}}const Pv=new L,gi=new wc;class Nk extends aa{constructor(e){const t=new Ct,i=new Bi({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],a=[],s={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(_,T){l(_),l(T)}function l(_){r.push(0,0,0),a.push(0,0,0),s[_]===void 0&&(s[_]=[]),s[_].push(r.length/3-1)}t.setAttribute("position",new yt(r,3)),t.setAttribute("color",new yt(a,3)),super(t,i),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 h=new qe(16755200),f=new qe(16711680),d=new qe(43775),p=new qe(16777215),g=new qe(3355443);this.setColors(h,f,d,p,g)}setColors(e,t,i,r,a){const o=this.geometry.getAttribute("color");return o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,i.r,i.g,i.b),o.setXYZ(33,i.r,i.g,i.b),o.setXYZ(34,i.r,i.g,i.b),o.setXYZ(35,i.r,i.g,i.b),o.setXYZ(36,i.r,i.g,i.b),o.setXYZ(37,i.r,i.g,i.b),o.setXYZ(38,r.r,r.g,r.b),o.setXYZ(39,r.r,r.g,r.b),o.setXYZ(40,a.r,a.g,a.b),o.setXYZ(41,a.r,a.g,a.b),o.setXYZ(42,a.r,a.g,a.b),o.setXYZ(43,a.r,a.g,a.b),o.setXYZ(44,a.r,a.g,a.b),o.setXYZ(45,a.r,a.g,a.b),o.setXYZ(46,a.r,a.g,a.b),o.setXYZ(47,a.r,a.g,a.b),o.setXYZ(48,a.r,a.g,a.b),o.setXYZ(49,a.r,a.g,a.b),o.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;let a,s;if(gi.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)a=1,s=0;else if(this.camera.coordinateSystem===wa)a=-1,s=1;else if(this.camera.coordinateSystem===Ad)a=0,s=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);Si("c",t,e,gi,0,0,a),Si("t",t,e,gi,0,0,s),Si("n1",t,e,gi,-i,-r,a),Si("n2",t,e,gi,i,-r,a),Si("n3",t,e,gi,-i,r,a),Si("n4",t,e,gi,i,r,a),Si("f1",t,e,gi,-i,-r,s),Si("f2",t,e,gi,i,-r,s),Si("f3",t,e,gi,-i,r,s),Si("f4",t,e,gi,i,r,s),Si("u1",t,e,gi,i*.7,r*1.1,a),Si("u2",t,e,gi,-i*.7,r*1.1,a),Si("u3",t,e,gi,0,r*2,a),Si("cf1",t,e,gi,-i,0,s),Si("cf2",t,e,gi,i,0,s),Si("cf3",t,e,gi,0,-r,s),Si("cf4",t,e,gi,0,r,s),Si("cn1",t,e,gi,-i,0,a),Si("cn2",t,e,gi,i,0,a),Si("cn3",t,e,gi,0,-r,a),Si("cn4",t,e,gi,0,r,a),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Si(n,e,t,i,r,a,s){Pv.set(r,a,s).unproject(i);const o=e[n];if(o!==void 0){const l=t.getAttribute("position");for(let h=0,f=o.length;h<f;h++)l.setXYZ(o[h],Pv.x,Pv.y,Pv.z)}}const zv=new tr;class Ok extends aa{constructor(e,t=16776960){const i=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(8*3),a=new Ct;a.setIndex(new Ot(i,1)),a.setAttribute("position",new Ot(r,3)),super(a,new Bi({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&zv.setFromObject(this.object),zv.isEmpty())return;const e=zv.min,t=zv.max,i=this.geometry.attributes.position,r=i.array;r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=e.x,r[4]=t.y,r[5]=t.z,r[6]=e.x,r[7]=e.y,r[8]=t.z,r[9]=t.x,r[10]=e.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=e.z,r[15]=e.x,r[16]=t.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=t.x,r[22]=e.y,r[23]=e.z,i.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 Lk extends aa{constructor(e,t=16776960){const i=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=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],a=new Ct;a.setIndex(new Ot(i,1)),a.setAttribute("position",new yt(r,3)),super(a,new Bi({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 Ik extends oo{constructor(e,t=1,i=16776960){const r=i,a=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],s=new Ct;s.setAttribute("position",new yt(a,3)),s.computeBoundingSphere(),super(s,new Bi({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Ct;l.setAttribute("position",new yt(o,3)),l.computeBoundingSphere(),this.add(new oi(l,new Ur({color:r,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 bD=new L;let Bv,g2;class Uk extends Wt{constructor(e=new L(0,0,1),t=new L(0,0,0),i=1,r=16776960,a=i*.2,s=a*.2){super(),this.type="ArrowHelper",Bv===void 0&&(Bv=new Ct,Bv.setAttribute("position",new yt([0,0,0,0,1,0],3)),g2=new W0(.5,1,5,1),g2.translate(0,-.5,0)),this.position.copy(t),this.line=new oo(Bv,new Bi({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new oi(g2,new Ur({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,a,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{bD.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(bD,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),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 W6 extends aa{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ct;r.setAttribute("position",new yt(t,3)),r.setAttribute("color",new yt(i,3));const a=new Bi({vertexColors:!0,toneMapped:!1});super(r,a),this.type="AxesHelper"}setColors(e,t,i){const r=new qe,a=this.geometry.attributes.color.array;return r.set(e),r.toArray(a,0),r.toArray(a,3),r.set(t),r.toArray(a,6),r.toArray(a,9),r.set(i),r.toArray(a,12),r.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Pk{constructor(){this.type="ShapePath",this.color=new qe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new qx,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,a,s){return this.currentPath.bezierCurveTo(e,t,i,r,a,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(v){const S=[];for(let E=0,b=v.length;E<b;E++){const N=v[E],R=new Hu;R.curves=N.curves,S.push(R)}return S}function i(v,S){const E=S.length;let b=!1;for(let N=E-1,R=0;R<E;N=R++){let I=S[N],U=S[R],O=U.x-I.x,w=U.y-I.y;if(Math.abs(w)>Number.EPSILON){if(w<0&&(I=S[R],O=-O,U=S[N],w=-w),v.y<I.y||v.y>U.y)continue;if(v.y===I.y){if(v.x===I.x)return!0}else{const B=w*(v.x-I.x)-O*(v.y-I.y);if(B===0)return!0;if(B<0)continue;b=!b}}else{if(v.y!==I.y)continue;if(U.x<=v.x&&v.x<=I.x||I.x<=v.x&&v.x<=U.x)return!0}}return b}const r=Rs.isClockWise,a=this.subPaths;if(a.length===0)return[];let s,o,l;const h=[];if(a.length===1)return o=a[0],l=new Hu,l.curves=o.curves,h.push(l),h;let f=!r(a[0].getPoints());f=e?!f:f;const d=[],p=[];let g=[],_=0,T;p[_]=void 0,g[_]=[];for(let v=0,S=a.length;v<S;v++)o=a[v],T=o.getPoints(),s=r(T),s=e?!s:s,s?(!f&&p[_]&&_++,p[_]={s:new Hu,p:T},p[_].s.curves=o.curves,f&&_++,g[_]=[]):g[_].push({h:o,p:T[0]});if(!p[0])return t(a);if(p.length>1){let v=!1,S=0;for(let E=0,b=p.length;E<b;E++)d[E]=[];for(let E=0,b=p.length;E<b;E++){const N=g[E];for(let R=0;R<N.length;R++){const I=N[R];let U=!0;for(let O=0;O<p.length;O++)i(I.p,p[O].p)&&(E!==O&&S++,U?(U=!1,d[O].push(I)):v=!0);U&&d[E].push(I)}}S>0&&v===!1&&(g=d)}let y;for(let v=0,S=p.length;v<S;v++){l=p[v].s,h.push(l),y=g[v];for(let E=0,b=y.length;E<b;E++)l.holes.push(y[E].h)}return h}}class zk extends ra{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){ut("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Bk(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2):(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0),n}function Hk(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0):(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2),n}function Fk(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function ME(n,e,t,i){const r=Gk(i);switch(t){case Eb:return n*e;case ws:return n*e/r.components*r.byteLength;case F0:return n*e/r.components*r.byteLength;case Xo:return n*e*2/r.components*r.byteLength;case G1:return n*e*2/r.components*r.byteLength;case Mb:return n*e*3/r.components*r.byteLength;case $n:return n*e*4/r.components*r.byteLength;case V1:return n*e*4/r.components*r.byteLength;case zm:case Bm:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Hm:case Fm:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case gx:case _x:return Math.max(n,16)*Math.max(e,8)/4;case mx:case vx:return Math.max(n,8)*Math.max(e,8)/2;case xx:case yx:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Sx:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Tx:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Ex:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Mx:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case bx:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Ax:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case wx:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Rx:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Cx:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Dx:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case Nx:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Ox:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Lx:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Ix:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Ux:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Px:case zx:case Bx:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Hx:case Fx:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Gx:case Vx:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Gk(n){switch(n){case Pi:case z1:return{byteLength:1,components:1};case Zu:case B1:case Yn:return{byteLength:2,components:1};case H1:case F1:return{byteLength:2,components:4};case Os:case H0:case si:return{byteLength:4,components:1};case Sb:case Tb:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}class Vk{static contain(e,t){return Bk(e,t)}static cover(e,t){return Hk(e,t)}static fill(e){return Fk(e)}static getByteLength(e,t,i,r){return ME(e,t,i,r)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ds}}));typeof window<"u"&&(window.__THREE__?ut("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ds);/**
 * @license
 * Copyright 2010-2025 Three.js Authors
 * SPDX-License-Identifier: MIT
 */function X6(){let n=null,e=!1,t=null,i=null;function r(a,s){t(a,s),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(a){t=a},setContext:function(a){n=a}}}function kk(n){const e=new WeakMap;function t(o,l){const h=o.array,f=o.usage,d=h.byteLength,p=n.createBuffer();n.bindBuffer(l,p),n.bufferData(l,h,f),o.onUploadCallback();let g;if(h instanceof Float32Array)g=n.FLOAT;else if(typeof Float16Array<"u"&&h instanceof Float16Array)g=n.HALF_FLOAT;else if(h instanceof Uint16Array)o.isFloat16BufferAttribute?g=n.HALF_FLOAT:g=n.UNSIGNED_SHORT;else if(h instanceof Int16Array)g=n.SHORT;else if(h instanceof Uint32Array)g=n.UNSIGNED_INT;else if(h instanceof Int32Array)g=n.INT;else if(h instanceof Int8Array)g=n.BYTE;else if(h instanceof Uint8Array)g=n.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)g=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:p,type:g,bytesPerElement:h.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,h){const f=l.array,d=l.updateRanges;if(n.bindBuffer(h,o),d.length===0)n.bufferSubData(h,0,f);else{d.sort((g,_)=>g.start-_.start);let p=0;for(let g=1;g<d.length;g++){const _=d[p],T=d[g];T.start<=_.start+_.count+1?_.count=Math.max(_.count,T.start+T.count-_.start):(++p,d[p]=T)}d.length=p+1;for(let g=0,_=d.length;g<_;g++){const T=d[g];n.bufferSubData(h,T.start*f.BYTES_PER_ELEMENT,f,T.start,T.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function s(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const f=e.get(o);(!f||f.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const h=e.get(o);if(h===void 0)e.set(o,t(o,l));else if(h.version<o.version){if(h.size!==o.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.");i(h.buffer,o,l),h.version=o.version}}return{get:r,remove:a,update:s}}var Wk=`#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,Xk=`#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`,Yk=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,qk=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,jk=`#ifdef USE_ALPHATEST
	#ifdef ALPHA_TO_COVERAGE
	diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
	if ( diffuseColor.a == 0.0 ) discard;
	#else
	if ( diffuseColor.a < alphaTest ) discard;
	#endif
#endif`,Zk=`#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`,Kk=`#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`,Qk=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,Jk=`#ifdef USE_BATCHING
	#if ! defined( GL_ANGLE_multi_draw )
	#define gl_DrawID _gl_DrawID
	uniform int _gl_DrawID;
	#endif
	uniform highp sampler2D batchingTexture;
	uniform highp usampler2D batchingIdTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
	float getIndirectIndex( const in int i ) {
		int size = textureSize( batchingIdTexture, 0 ).x;
		int x = i % size;
		int y = i / size;
		return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
	}
#endif
#ifdef USE_BATCHING_COLOR
	uniform sampler2D batchingColorTexture;
	vec3 getBatchingColor( const in float i ) {
		int size = textureSize( batchingColorTexture, 0 ).x;
		int j = int( i );
		int x = j % size;
		int y = j / size;
		return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
	}
#endif`,$k=`#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,eW=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`,tW=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,nW=`float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`,iW=`#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`,rW=`#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`,aW=`#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#ifdef ALPHA_TO_COVERAGE
		float distanceToPlane, distanceGradient;
		float clipOpacity = 1.0;
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
			distanceGradient = fwidth( distanceToPlane ) / 2.0;
			clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			if ( clipOpacity == 0.0 ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			float unionClipOpacity = 1.0;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
				distanceGradient = fwidth( distanceToPlane ) / 2.0;
				unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			}
			#pragma unroll_loop_end
			clipOpacity *= 1.0 - unionClipOpacity;
		#endif
		diffuseColor.a *= clipOpacity;
		if ( diffuseColor.a == 0.0 ) discard;
	#else
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			bool clipped = true;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
			}
			#pragma unroll_loop_end
			if ( clipped ) discard;
		#endif
	#endif
#endif`,sW=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,oW=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,lW=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,cW=`#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`,uW=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`,hW=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`,fW=`#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
	vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
	vColor.xyz *= batchingColor.xyz;
#endif`,dW=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,pW=`#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`,mW=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,gW=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,vW=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,_W=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
		emissiveColor = sRGBTransferEOTF( emissiveColor );
	#endif
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,xW=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,yW="gl_FragColor = linearToOutputTexel( gl_FragColor );",SW=`vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,TW=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`,EW=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
#endif`,MW=`#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`,bW=`#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`,AW=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`,wW=`#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`,RW=`#ifdef USE_FOG
	varying float vFogDepth;
#endif`,CW=`#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,DW=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,NW=`#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`,OW=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,LW=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,IW=`varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`,UW=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if ( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`,PW=`#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`,zW=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,BW=`varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`,HW=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,FW=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`,GW=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
	material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,VW=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	float dispersion;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	vec2 uv = vec2( roughness, dotNV );
	return texture2D( dfgLUT, uv ).rg;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
	vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
	vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
	vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
	float Ess_V = dfgV.x + dfgV.y;
	float Ess_L = dfgL.x + dfgL.y;
	float Ems_V = 1.0 - Ess_V;
	float Ems_L = 1.0 - Ess_L;
	vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
	vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
	float compensationFactor = Ems_V * Ems_L;
	vec3 multiScatter = Fms * compensationFactor;
	return singleScatter + multiScatter;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,kW=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,WW=`#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`,XW=`#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,YW=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,qW=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,jW=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,ZW=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,KW=`#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`,QW=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,JW=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,$W=`#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,eX=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`,tX=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,nX=`#ifdef USE_INSTANCING_MORPH
	float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		morphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
	}
#endif`,iX=`#if defined( USE_MORPHCOLORS )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`,rX=`#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,aX=`#ifdef USE_MORPHTARGETS
	#ifndef USE_INSTANCING_MORPH
		uniform float morphTargetBaseInfluence;
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	#endif
	uniform sampler2DArray morphTargetsTexture;
	uniform ivec2 morphTargetsTextureSize;
	vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
		int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
		int y = texelIndex / morphTargetsTextureSize.x;
		int x = texelIndex - y * morphTargetsTextureSize.x;
		ivec3 morphUV = ivec3( x, y, morphTargetIndex );
		return texelFetch( morphTargetsTexture, morphUV, 0 );
	}
#endif`,sX=`#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,oX=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`,lX=`#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,cX=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,uX=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,hX=`#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`,fX=`#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`,dX=`#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,pX=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,mX=`#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`,gX=`#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`,vX=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,_X=`vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
	if( v <= 0.0 )
		return vec4( 0., 0., 0., 0. );
	if( v >= 1.0 )
		return vec4( 1., 1., 1., 1. );
	float vuf;
	float af = modf( v * PackFactors.a, vuf );
	float bf = modf( vuf * ShiftRight8, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
	if( v <= 0.0 )
		return vec3( 0., 0., 0. );
	if( v >= 1.0 )
		return vec3( 1., 1., 1. );
	float vuf;
	float bf = modf( v * PackFactors.b, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
	if( v <= 0.0 )
		return vec2( 0., 0. );
	if( v >= 1.0 )
		return vec2( 1., 1. );
	float vuf;
	float gf = modf( v * 256., vuf );
	return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
	return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
	return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`,xX=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,yX=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,SX=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,TX=`#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`,EX=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`,MX=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,bX=`#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
		#ifdef USE_REVERSED_DEPTH_BUFFER
			return step( depth, compare );
		#else
			return step( compare, depth );
		#endif
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		#ifdef USE_REVERSED_DEPTH_BUFFER
			float hard_shadow = step( distribution.x, compare );
		#else
			float hard_shadow = step( compare, distribution.x );
		#endif
		if ( hard_shadow != 1.0 ) {
			float distance = compare - distribution.x;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		float shadow = 1.0;
		vec3 lightToPosition = shadowCoord.xyz;
		
		float lightToPositionLength = length( lightToPosition );
		if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
			float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );			dp += shadowBias;
			vec3 bd3D = normalize( lightToPosition );
			vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
			#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
				vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
				shadow = (
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
				) * ( 1.0 / 9.0 );
			#else
				shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
			#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
#endif`,AX=`#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`,wX=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`,RX=`float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`,CX=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,DX=`#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`,NX=`#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,OX=`#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`,LX=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,IX=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,UX=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,PX=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color *= toneMappingExposure;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	color = clamp( color, 0.0, 1.0 );
	return color;
}
vec3 NeutralToneMapping( vec3 color ) {
	const float StartCompression = 0.8 - 0.04;
	const float Desaturation = 0.15;
	color *= toneMappingExposure;
	float x = min( color.r, min( color.g, color.b ) );
	float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
	color -= offset;
	float peak = max( color.r, max( color.g, color.b ) );
	if ( peak < StartCompression ) return color;
	float d = 1. - StartCompression;
	float newPeak = 1. - d * d / ( peak + d - StartCompression );
	color *= newPeak / peak;
	float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
	return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,zX=`#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,BX=`#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec4 transmittedLight;
		vec3 transmittance;
		#ifdef USE_DISPERSION
			float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
			vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
			for ( int i = 0; i < 3; i ++ ) {
				vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
				vec3 refractedRayExit = position + transmissionRay;
				vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
				vec2 refractionCoords = ndcPos.xy / ndcPos.w;
				refractionCoords += 1.0;
				refractionCoords /= 2.0;
				vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
				transmittedLight[ i ] = transmissionSample[ i ];
				transmittedLight.a += transmissionSample.a;
				transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
			}
			transmittedLight.a /= 3.0;
		#else
			vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
			vec3 refractedRayExit = position + transmissionRay;
			vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
			vec2 refractionCoords = ndcPos.xy / ndcPos.w;
			refractionCoords += 1.0;
			refractionCoords /= 2.0;
			transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
			transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		#endif
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`,HX=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,FX=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,GX=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,VX=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`;const kX=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,WX=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,XX=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,YX=`#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,qX=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,jX=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,ZX=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`,KX=`#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	#ifdef USE_REVERSED_DEPTH_BUFFER
		float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
	#else
		float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
	#endif
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#elif DEPTH_PACKING == 3202
		gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
	#elif DEPTH_PACKING == 3203
		gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
	#endif
}`,QX=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`,JX=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`,$X=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,eY=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,tY=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,nY=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,iY=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`,rY=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,aY=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,sY=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,oY=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`,lY=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,cY=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`,uY=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`,hY=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,fY=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,dY=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`,pY=`#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
	uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,mY=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,gY=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,vY=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`,_Y=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,xY=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,yY=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,SY=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix[ 3 ];
	vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,TY=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,Qt={alphahash_fragment:Wk,alphahash_pars_fragment:Xk,alphamap_fragment:Yk,alphamap_pars_fragment:qk,alphatest_fragment:jk,alphatest_pars_fragment:Zk,aomap_fragment:Kk,aomap_pars_fragment:Qk,batching_pars_vertex:Jk,batching_vertex:$k,begin_vertex:eW,beginnormal_vertex:tW,bsdfs:nW,iridescence_fragment:iW,bumpmap_pars_fragment:rW,clipping_planes_fragment:aW,clipping_planes_pars_fragment:sW,clipping_planes_pars_vertex:oW,clipping_planes_vertex:lW,color_fragment:cW,color_pars_fragment:uW,color_pars_vertex:hW,color_vertex:fW,common:dW,cube_uv_reflection_fragment:pW,defaultnormal_vertex:mW,displacementmap_pars_vertex:gW,displacementmap_vertex:vW,emissivemap_fragment:_W,emissivemap_pars_fragment:xW,colorspace_fragment:yW,colorspace_pars_fragment:SW,envmap_fragment:TW,envmap_common_pars_fragment:EW,envmap_pars_fragment:MW,envmap_pars_vertex:bW,envmap_physical_pars_fragment:PW,envmap_vertex:AW,fog_vertex:wW,fog_pars_vertex:RW,fog_fragment:CW,fog_pars_fragment:DW,gradientmap_pars_fragment:NW,lightmap_pars_fragment:OW,lights_lambert_fragment:LW,lights_lambert_pars_fragment:IW,lights_pars_begin:UW,lights_toon_fragment:zW,lights_toon_pars_fragment:BW,lights_phong_fragment:HW,lights_phong_pars_fragment:FW,lights_physical_fragment:GW,lights_physical_pars_fragment:VW,lights_fragment_begin:kW,lights_fragment_maps:WW,lights_fragment_end:XW,logdepthbuf_fragment:YW,logdepthbuf_pars_fragment:qW,logdepthbuf_pars_vertex:jW,logdepthbuf_vertex:ZW,map_fragment:KW,map_pars_fragment:QW,map_particle_fragment:JW,map_particle_pars_fragment:$W,metalnessmap_fragment:eX,metalnessmap_pars_fragment:tX,morphinstance_vertex:nX,morphcolor_vertex:iX,morphnormal_vertex:rX,morphtarget_pars_vertex:aX,morphtarget_vertex:sX,normal_fragment_begin:oX,normal_fragment_maps:lX,normal_pars_fragment:cX,normal_pars_vertex:uX,normal_vertex:hX,normalmap_pars_fragment:fX,clearcoat_normal_fragment_begin:dX,clearcoat_normal_fragment_maps:pX,clearcoat_pars_fragment:mX,iridescence_pars_fragment:gX,opaque_fragment:vX,packing:_X,premultiplied_alpha_fragment:xX,project_vertex:yX,dithering_fragment:SX,dithering_pars_fragment:TX,roughnessmap_fragment:EX,roughnessmap_pars_fragment:MX,shadowmap_pars_fragment:bX,shadowmap_pars_vertex:AX,shadowmap_vertex:wX,shadowmask_pars_fragment:RX,skinbase_vertex:CX,skinning_pars_vertex:DX,skinning_vertex:NX,skinnormal_vertex:OX,specularmap_fragment:LX,specularmap_pars_fragment:IX,tonemapping_fragment:UX,tonemapping_pars_fragment:PX,transmission_fragment:zX,transmission_pars_fragment:BX,uv_pars_fragment:HX,uv_pars_vertex:FX,uv_vertex:GX,worldpos_vertex:VX,background_vert:kX,background_frag:WX,backgroundCube_vert:XX,backgroundCube_frag:YX,cube_vert:qX,cube_frag:jX,depth_vert:ZX,depth_frag:KX,distanceRGBA_vert:QX,distanceRGBA_frag:JX,equirect_vert:$X,equirect_frag:eY,linedashed_vert:tY,linedashed_frag:nY,meshbasic_vert:iY,meshbasic_frag:rY,meshlambert_vert:aY,meshlambert_frag:sY,meshmatcap_vert:oY,meshmatcap_frag:lY,meshnormal_vert:cY,meshnormal_frag:uY,meshphong_vert:hY,meshphong_frag:fY,meshphysical_vert:dY,meshphysical_frag:pY,meshtoon_vert:mY,meshtoon_frag:gY,points_vert:vY,points_frag:_Y,shadow_vert:xY,shadow_frag:yY,sprite_vert:SY,sprite_frag:TY},rt={common:{diffuse:{value:new qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Et},alphaMap:{value:null},alphaMapTransform:{value:new Et},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Et}},envmap:{envMap:{value:null},envMapRotation:{value:new Et},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Et}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Et}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Et},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Et},normalScale:{value:new de(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Et},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Et}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Et}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Et}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new qe(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 qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Et},alphaTest:{value:0},uvTransform:{value:new Et}},sprite:{diffuse:{value:new qe(16777215)},opacity:{value:1},center:{value:new de(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Et},alphaMap:{value:null},alphaMapTransform:{value:new Et},alphaTest:{value:0}}},As={basic:{uniforms:Rr([rt.common,rt.specularmap,rt.envmap,rt.aomap,rt.lightmap,rt.fog]),vertexShader:Qt.meshbasic_vert,fragmentShader:Qt.meshbasic_frag},lambert:{uniforms:Rr([rt.common,rt.specularmap,rt.envmap,rt.aomap,rt.lightmap,rt.emissivemap,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.fog,rt.lights,{emissive:{value:new qe(0)}}]),vertexShader:Qt.meshlambert_vert,fragmentShader:Qt.meshlambert_frag},phong:{uniforms:Rr([rt.common,rt.specularmap,rt.envmap,rt.aomap,rt.lightmap,rt.emissivemap,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.fog,rt.lights,{emissive:{value:new qe(0)},specular:{value:new qe(1118481)},shininess:{value:30}}]),vertexShader:Qt.meshphong_vert,fragmentShader:Qt.meshphong_frag},standard:{uniforms:Rr([rt.common,rt.envmap,rt.aomap,rt.lightmap,rt.emissivemap,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.roughnessmap,rt.metalnessmap,rt.fog,rt.lights,{emissive:{value:new qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Qt.meshphysical_vert,fragmentShader:Qt.meshphysical_frag},toon:{uniforms:Rr([rt.common,rt.aomap,rt.lightmap,rt.emissivemap,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.gradientmap,rt.fog,rt.lights,{emissive:{value:new qe(0)}}]),vertexShader:Qt.meshtoon_vert,fragmentShader:Qt.meshtoon_frag},matcap:{uniforms:Rr([rt.common,rt.bumpmap,rt.normalmap,rt.displacementmap,rt.fog,{matcap:{value:null}}]),vertexShader:Qt.meshmatcap_vert,fragmentShader:Qt.meshmatcap_frag},points:{uniforms:Rr([rt.points,rt.fog]),vertexShader:Qt.points_vert,fragmentShader:Qt.points_frag},dashed:{uniforms:Rr([rt.common,rt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qt.linedashed_vert,fragmentShader:Qt.linedashed_frag},depth:{uniforms:Rr([rt.common,rt.displacementmap]),vertexShader:Qt.depth_vert,fragmentShader:Qt.depth_frag},normal:{uniforms:Rr([rt.common,rt.bumpmap,rt.normalmap,rt.displacementmap,{opacity:{value:1}}]),vertexShader:Qt.meshnormal_vert,fragmentShader:Qt.meshnormal_frag},sprite:{uniforms:Rr([rt.sprite,rt.fog]),vertexShader:Qt.sprite_vert,fragmentShader:Qt.sprite_frag},background:{uniforms:{uvTransform:{value:new Et},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Qt.background_vert,fragmentShader:Qt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Et}},vertexShader:Qt.backgroundCube_vert,fragmentShader:Qt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Qt.cube_vert,fragmentShader:Qt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Qt.equirect_vert,fragmentShader:Qt.equirect_frag},distanceRGBA:{uniforms:Rr([rt.common,rt.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qt.distanceRGBA_vert,fragmentShader:Qt.distanceRGBA_frag},shadow:{uniforms:Rr([rt.lights,rt.fog,{color:{value:new qe(0)},opacity:{value:1}}]),vertexShader:Qt.shadow_vert,fragmentShader:Qt.shadow_frag}};As.physical={uniforms:Rr([As.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Et},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Et},clearcoatNormalScale:{value:new de(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Et},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Et},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Et},sheen:{value:0},sheenColor:{value:new qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Et},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Et},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Et},transmissionSamplerSize:{value:new de},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Et},attenuationDistance:{value:0},attenuationColor:{value:new qe(0)},specularColor:{value:new qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Et},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Et},anisotropyVector:{value:new de},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Et}}]),vertexShader:Qt.meshphysical_vert,fragmentShader:Qt.meshphysical_frag};const Hv={r:0,b:0,g:0},lu=new zi,EY=new Ve;function MY(n,e,t,i,r,a,s){const o=new qe(0);let l=a===!0?0:1,h,f,d=null,p=0,g=null;function _(E){let b=E.isScene===!0?E.background:null;return b&&b.isTexture&&(b=(E.backgroundBlurriness>0?t:e).get(b)),b}function T(E){let b=!1;const N=_(E);N===null?v(o,l):N&&N.isColor&&(v(N,1),b=!0);const R=n.xr.getEnvironmentBlendMode();R==="additive"?i.buffers.color.setClear(0,0,0,1,s):R==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,s),(n.autoClear||b)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function y(E,b){const N=_(b);N&&(N.isCubeTexture||N.mapping===jd)?(f===void 0&&(f=new oi(new fh(1,1,1),new Vi({name:"BackgroundCubeMaterial",uniforms:Dd(As.backgroundCube.uniforms),vertexShader:As.backgroundCube.vertexShader,fragmentShader:As.backgroundCube.fragmentShader,side:Ii,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),f.geometry.deleteAttribute("normal"),f.geometry.deleteAttribute("uv"),f.onBeforeRender=function(R,I,U){this.matrixWorld.copyPosition(U.matrixWorld)},Object.defineProperty(f.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(f)),lu.copy(b.backgroundRotation),lu.x*=-1,lu.y*=-1,lu.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(lu.y*=-1,lu.z*=-1),f.material.uniforms.envMap.value=N,f.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,f.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,f.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,f.material.uniforms.backgroundRotation.value.setFromMatrix4(EY.makeRotationFromEuler(lu)),f.material.toneMapped=en.getTransfer(N.colorSpace)!==wn,(d!==N||p!==N.version||g!==n.toneMapping)&&(f.material.needsUpdate=!0,d=N,p=N.version,g=n.toneMapping),f.layers.enableAll(),E.unshift(f,f.geometry,f.material,0,0,null)):N&&N.isTexture&&(h===void 0&&(h=new oi(new dh(2,2),new Vi({name:"BackgroundMaterial",uniforms:Dd(As.background.uniforms),vertexShader:As.background.vertexShader,fragmentShader:As.background.fragmentShader,side:Ns,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=N,h.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,h.material.toneMapped=en.getTransfer(N.colorSpace)!==wn,N.matrixAutoUpdate===!0&&N.updateMatrix(),h.material.uniforms.uvTransform.value.copy(N.matrix),(d!==N||p!==N.version||g!==n.toneMapping)&&(h.material.needsUpdate=!0,d=N,p=N.version,g=n.toneMapping),h.layers.enableAll(),E.unshift(h,h.geometry,h.material,0,0,null))}function v(E,b){E.getRGB(Hv,QU(n)),i.buffers.color.setClear(Hv.r,Hv.g,Hv.b,b,s)}function S(){f!==void 0&&(f.geometry.dispose(),f.material.dispose(),f=void 0),h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0)}return{getClearColor:function(){return o},setClearColor:function(E,b=1){o.set(E),l=b,v(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(E){l=E,v(o,l)},render:T,addToRenderList:y,dispose:S}}function bY(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=p(null);let a=r,s=!1;function o(w,B,j,ee,se){let ae=!1;const W=d(ee,j,B);a!==W&&(a=W,h(a.object)),ae=g(w,ee,j,se),ae&&_(w,ee,j,se),se!==null&&e.update(se,n.ELEMENT_ARRAY_BUFFER),(ae||s)&&(s=!1,b(w,B,j,ee),se!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(se).buffer))}function l(){return n.createVertexArray()}function h(w){return n.bindVertexArray(w)}function f(w){return n.deleteVertexArray(w)}function d(w,B,j){const ee=j.wireframe===!0;let se=i[w.id];se===void 0&&(se={},i[w.id]=se);let ae=se[B.id];ae===void 0&&(ae={},se[B.id]=ae);let W=ae[ee];return W===void 0&&(W=p(l()),ae[ee]=W),W}function p(w){const B=[],j=[],ee=[];for(let se=0;se<t;se++)B[se]=0,j[se]=0,ee[se]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:j,attributeDivisors:ee,object:w,attributes:{},index:null}}function g(w,B,j,ee){const se=a.attributes,ae=B.attributes;let W=0;const te=j.getAttributes();for(const K in te)if(te[K].location>=0){const ie=se[K];let Ce=ae[K];if(Ce===void 0&&(K==="instanceMatrix"&&w.instanceMatrix&&(Ce=w.instanceMatrix),K==="instanceColor"&&w.instanceColor&&(Ce=w.instanceColor)),ie===void 0||ie.attribute!==Ce||Ce&&ie.data!==Ce.data)return!0;W++}return a.attributesNum!==W||a.index!==ee}function _(w,B,j,ee){const se={},ae=B.attributes;let W=0;const te=j.getAttributes();for(const K in te)if(te[K].location>=0){let ie=ae[K];ie===void 0&&(K==="instanceMatrix"&&w.instanceMatrix&&(ie=w.instanceMatrix),K==="instanceColor"&&w.instanceColor&&(ie=w.instanceColor));const Ce={};Ce.attribute=ie,ie&&ie.data&&(Ce.data=ie.data),se[K]=Ce,W++}a.attributes=se,a.attributesNum=W,a.index=ee}function T(){const w=a.newAttributes;for(let B=0,j=w.length;B<j;B++)w[B]=0}function y(w){v(w,0)}function v(w,B){const j=a.newAttributes,ee=a.enabledAttributes,se=a.attributeDivisors;j[w]=1,ee[w]===0&&(n.enableVertexAttribArray(w),ee[w]=1),se[w]!==B&&(n.vertexAttribDivisor(w,B),se[w]=B)}function S(){const w=a.newAttributes,B=a.enabledAttributes;for(let j=0,ee=B.length;j<ee;j++)B[j]!==w[j]&&(n.disableVertexAttribArray(j),B[j]=0)}function E(w,B,j,ee,se,ae,W){W===!0?n.vertexAttribIPointer(w,B,j,se,ae):n.vertexAttribPointer(w,B,j,ee,se,ae)}function b(w,B,j,ee){T();const se=ee.attributes,ae=j.getAttributes(),W=B.defaultAttributeValues;for(const te in ae){const K=ae[te];if(K.location>=0){let oe=se[te];if(oe===void 0&&(te==="instanceMatrix"&&w.instanceMatrix&&(oe=w.instanceMatrix),te==="instanceColor"&&w.instanceColor&&(oe=w.instanceColor)),oe!==void 0){const ie=oe.normalized,Ce=oe.itemSize,Xe=e.get(oe);if(Xe===void 0)continue;const nt=Xe.buffer,tt=Xe.type,gt=Xe.bytesPerElement,ge=tt===n.INT||tt===n.UNSIGNED_INT||oe.gpuType===H0;if(oe.isInterleavedBufferAttribute){const Ae=oe.data,Ze=Ae.stride,ue=oe.offset;if(Ae.isInstancedInterleavedBuffer){for(let it=0;it<K.locationSize;it++)v(K.location+it,Ae.meshPerAttribute);w.isInstancedMesh!==!0&&ee._maxInstanceCount===void 0&&(ee._maxInstanceCount=Ae.meshPerAttribute*Ae.count)}else for(let it=0;it<K.locationSize;it++)y(K.location+it);n.bindBuffer(n.ARRAY_BUFFER,nt);for(let it=0;it<K.locationSize;it++)E(K.location+it,Ce/K.locationSize,tt,ie,Ze*gt,(ue+Ce/K.locationSize*it)*gt,ge)}else{if(oe.isInstancedBufferAttribute){for(let Ae=0;Ae<K.locationSize;Ae++)v(K.location+Ae,oe.meshPerAttribute);w.isInstancedMesh!==!0&&ee._maxInstanceCount===void 0&&(ee._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let Ae=0;Ae<K.locationSize;Ae++)y(K.location+Ae);n.bindBuffer(n.ARRAY_BUFFER,nt);for(let Ae=0;Ae<K.locationSize;Ae++)E(K.location+Ae,Ce/K.locationSize,tt,ie,Ce*gt,Ce/K.locationSize*Ae*gt,ge)}}else if(W!==void 0){const ie=W[te];if(ie!==void 0)switch(ie.length){case 2:n.vertexAttrib2fv(K.location,ie);break;case 3:n.vertexAttrib3fv(K.location,ie);break;case 4:n.vertexAttrib4fv(K.location,ie);break;default:n.vertexAttrib1fv(K.location,ie)}}}}S()}function N(){U();for(const w in i){const B=i[w];for(const j in B){const ee=B[j];for(const se in ee)f(ee[se].object),delete ee[se];delete B[j]}delete i[w]}}function R(w){if(i[w.id]===void 0)return;const B=i[w.id];for(const j in B){const ee=B[j];for(const se in ee)f(ee[se].object),delete ee[se];delete B[j]}delete i[w.id]}function I(w){for(const B in i){const j=i[B];if(j[w.id]===void 0)continue;const ee=j[w.id];for(const se in ee)f(ee[se].object),delete ee[se];delete j[w.id]}}function U(){O(),s=!0,a!==r&&(a=r,h(a.object))}function O(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:U,resetDefaultState:O,dispose:N,releaseStatesOfGeometry:R,releaseStatesOfProgram:I,initAttributes:T,enableAttribute:y,disableUnusedAttributes:S}}function AY(n,e,t){let i;function r(h){i=h}function a(h,f){n.drawArrays(i,h,f),t.update(f,i,1)}function s(h,f,d){d!==0&&(n.drawArraysInstanced(i,h,f,d),t.update(f,i,d))}function o(h,f,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,h,0,f,0,d);let g=0;for(let _=0;_<d;_++)g+=f[_];t.update(g,i,1)}function l(h,f,d,p){if(d===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let _=0;_<h.length;_++)s(h[_],f[_],p[_]);else{g.multiDrawArraysInstancedWEBGL(i,h,0,f,0,p,0,d);let _=0;for(let T=0;T<d;T++)_+=f[T]*p[T];t.update(_,i,1)}}this.setMode=r,this.render=a,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function wY(n,e,t,i){let r;function a(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const I=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(I.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(I){return!(I!==$n&&i.convert(I)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(I){const U=I===Yn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(I!==Pi&&i.convert(I)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&I!==si&&!U)}function l(I){if(I==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";I="mediump"}return I==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const f=l(h);f!==h&&(ut("WebGLRenderer:",h,"not supported, using",f,"instead."),h=f);const d=t.logarithmicDepthBuffer===!0,p=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),g=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=n.getParameter(n.MAX_TEXTURE_SIZE),y=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),v=n.getParameter(n.MAX_VERTEX_ATTRIBS),S=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),b=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),N=_>0,R=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:l,textureFormatReadable:s,textureTypeReadable:o,precision:h,logarithmicDepthBuffer:d,reversedDepthBuffer:p,maxTextures:g,maxVertexTextures:_,maxTextureSize:T,maxCubemapSize:y,maxAttributes:v,maxVertexUniforms:S,maxVaryings:E,maxFragmentUniforms:b,vertexTextures:N,maxSamples:R}}function RY(n){const e=this;let t=null,i=0,r=!1,a=!1;const s=new ko,o=new Et,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,p){const g=d.length!==0||p||i!==0||r;return r=p,i=d.length,g},this.beginShadows=function(){a=!0,f(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(d,p){t=f(d,p,0)},this.setState=function(d,p,g){const _=d.clippingPlanes,T=d.clipIntersection,y=d.clipShadows,v=n.get(d);if(!r||_===null||_.length===0||a&&!y)a?f(null):h();else{const S=a?0:i,E=S*4;let b=v.clippingState||null;l.value=b,b=f(_,p,E,g);for(let N=0;N!==E;++N)b[N]=t[N];v.clippingState=b,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=S}};function h(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function f(d,p,g,_){const T=d!==null?d.length:0;let y=null;if(T!==0){if(y=l.value,_!==!0||y===null){const v=g+T*4,S=p.matrixWorldInverse;o.getNormalMatrix(S),(y===null||y.length<v)&&(y=new Float32Array(v));for(let E=0,b=g;E!==T;++E,b+=4)s.copy(d[E]).applyMatrix4(S,o),s.normal.toArray(y,b),y[b+3]=s.constant}l.value=y,l.needsUpdate=!0}return e.numPlanes=T,e.numIntersection=0,y}}function CY(n){let e=new WeakMap;function t(s,o){return o===h0?s.mapping=ol:o===f0&&(s.mapping=_c),s}function i(s){if(s&&s.isTexture){const o=s.mapping;if(o===h0||o===f0)if(e.has(s)){const l=e.get(s).texture;return t(l,s.mapping)}else{const l=s.image;if(l&&l.height>0){const h=new $U(l.height);return h.fromEquirectangularTexture(n,s),e.set(s,h),s.addEventListener("dispose",r),t(h.texture,s.mapping)}else return null}}return s}function r(s){const o=s.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function a(){e=new WeakMap}return{get:i,dispose:a}}const tc=4,AD=[.125,.215,.35,.446,.526,.582],Eu=20,DY=256,Zp=new ao,wD=new qe;let v2=null,_2=0,x2=0,y2=!1;const NY=new L;class bE{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,a={}){const{size:s=256,position:o=NY}=a;v2=this._renderer.getRenderTarget(),_2=this._renderer.getActiveCubeFace(),x2=this._renderer.getActiveMipmapLevel(),y2=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=DD(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=CD(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(v2,_2,x2),this._renderer.xr.enabled=y2,e.scissorTest=!1,mf(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ol||e.mapping===_c?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),v2=this._renderer.getRenderTarget(),_2=this._renderer.getActiveCubeFace(),x2=this._renderer.getActiveMipmapLevel(),y2=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Ht,minFilter:Ht,generateMipmaps:!1,type:Yn,format:$n,colorSpace:Fn,depthBuffer:!1},r=RD(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=RD(e,t,i);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=OY(a)),this._blurMaterial=IY(a,e,t),this._ggxMaterial=LY(a,e,t)}return r}_compileMaterial(e){const t=new oi(new Ct,e);this._renderer.compile(t,Zp)}_sceneToCubeUV(e,t,i,r,a){const l=new hi(90,1,t,i),h=[1,-1,1,1,1,1],f=[1,1,1,-1,-1,-1],d=this._renderer,p=d.autoClear,g=d.toneMapping;d.getClearColor(wD),d.toneMapping=as,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(r),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new oi(new fh,new Ur({name:"PMREM.Background",side:Ii,depthWrite:!1,depthTest:!1})));const T=this._backgroundBox,y=T.material;let v=!1;const S=e.background;S?S.isColor&&(y.color.copy(S),e.background=null,v=!0):(y.color.copy(wD),v=!0);for(let E=0;E<6;E++){const b=E%3;b===0?(l.up.set(0,h[E],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x+f[E],a.y,a.z)):b===1?(l.up.set(0,0,h[E]),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y+f[E],a.z)):(l.up.set(0,h[E],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y,a.z+f[E]));const N=this._cubeSize;mf(r,b*N,E>2?N:0,N,N),d.setRenderTarget(r),v&&d.render(T,l),d.render(e,l)}d.toneMapping=g,d.autoClear=p,e.background=S}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===ol||e.mapping===_c;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=DD()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=CD());const a=r?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;const o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;mf(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(s,Zp)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let a=1;a<r;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=i}_applyGGXFilter(e,t,i){const r=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[i];o.material=s;const l=s.uniforms,h=i/(this._lodMeshes.length-1),f=t/(this._lodMeshes.length-1),d=Math.sqrt(h*h-f*f),p=.05+h*.95,g=d*p,{_lodMax:_}=this,T=this._sizeLods[i],y=3*T*(i>_-tc?i-_+tc:0),v=4*(this._cubeSize-T);l.envMap.value=e.texture,l.roughness.value=g,l.mipInt.value=_-t,mf(a,y,v,3*T,2*T),r.setRenderTarget(a),r.render(o,Zp),l.envMap.value=a.texture,l.roughness.value=0,l.mipInt.value=_-i,mf(e,y,v,3*T,2*T),r.setRenderTarget(e),r.render(o,Zp)}_blur(e,t,i,r,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,i,r,"latitudinal",a),this._halfBlur(s,e,i,i,r,"longitudinal",a)}_halfBlur(e,t,i,r,a,s,o){const l=this._renderer,h=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&Bt("blur direction must be either latitudinal or longitudinal!");const f=3,d=this._lodMeshes[r];d.material=h;const p=h.uniforms,g=this._sizeLods[i]-1,_=isFinite(a)?Math.PI/(2*g):2*Math.PI/(2*Eu-1),T=a/_,y=isFinite(a)?1+Math.floor(f*T):Eu;y>Eu&&ut(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Eu}`);const v=[];let S=0;for(let I=0;I<Eu;++I){const U=I/T,O=Math.exp(-U*U/2);v.push(O),I===0?S+=O:I<y&&(S+=2*O)}for(let I=0;I<v.length;I++)v[I]=v[I]/S;p.envMap.value=e.texture,p.samples.value=y,p.weights.value=v,p.latitudinal.value=s==="latitudinal",o&&(p.poleAxis.value=o);const{_lodMax:E}=this;p.dTheta.value=_,p.mipInt.value=E-i;const b=this._sizeLods[r],N=3*b*(r>E-tc?r-E+tc:0),R=4*(this._cubeSize-b);mf(t,N,R,3*b,2*b),l.setRenderTarget(t),l.render(d,Zp)}}function OY(n){const e=[],t=[],i=[];let r=n;const a=n-tc+1+AD.length;for(let s=0;s<a;s++){const o=Math.pow(2,r);e.push(o);let l=1/o;s>n-tc?l=AD[s-n+tc-1]:s===0&&(l=0),t.push(l);const h=1/(o-2),f=-h,d=1+h,p=[f,f,d,f,d,d,f,f,d,d,f,d],g=6,_=6,T=3,y=2,v=1,S=new Float32Array(T*_*g),E=new Float32Array(y*_*g),b=new Float32Array(v*_*g);for(let R=0;R<g;R++){const I=R%3*2/3-1,U=R>2?0:-1,O=[I,U,0,I+2/3,U,0,I+2/3,U+1,0,I,U,0,I+2/3,U+1,0,I,U+1,0];S.set(O,T*_*R),E.set(p,y*_*R);const w=[R,R,R,R,R,R];b.set(w,v*_*R)}const N=new Ct;N.setAttribute("position",new Ot(S,T)),N.setAttribute("uv",new Ot(E,y)),N.setAttribute("faceIndex",new Ot(b,v)),i.push(new oi(N,null)),r>tc&&r--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function RD(n,e,t){const i=new xi(n,e,t);return i.texture.mapping=jd,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function mf(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function LY(n,e,t){return new Vi({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:DY,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:fy(),fragmentShader:`

			precision highp float;
			precision highp int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform float roughness;
			uniform float mipInt;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			#define PI 3.14159265359

			// Van der Corput radical inverse
			float radicalInverse_VdC(uint bits) {
				bits = (bits << 16u) | (bits >> 16u);
				bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
				bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
				bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
				bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
				return float(bits) * 2.3283064365386963e-10; // / 0x100000000
			}

			// Hammersley sequence
			vec2 hammersley(uint i, uint N) {
				return vec2(float(i) / float(N), radicalInverse_VdC(i));
			}

			// GGX VNDF importance sampling (Eric Heitz 2018)
			// "Sampling the GGX Distribution of Visible Normals"
			// https://jcgt.org/published/0007/04/01/
			vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
				float alpha = roughness * roughness;

				// Section 3.2: Transform view direction to hemisphere configuration
				vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));

				// Section 4.1: Orthonormal basis
				float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
				vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
				vec3 T2 = cross(Vh, T1);

				// Section 4.2: Parameterization of projected area
				float r = sqrt(Xi.x);
				float phi = 2.0 * PI * Xi.y;
				float t1 = r * cos(phi);
				float t2 = r * sin(phi);
				float s = 0.5 * (1.0 + Vh.z);
				t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;

				// Section 4.3: Reprojection onto hemisphere
				vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;

				// Section 3.4: Transform back to ellipsoid configuration
				return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
			}

			void main() {
				vec3 N = normalize(vOutputDirection);
				vec3 V = N; // Assume view direction equals normal for pre-filtering

				vec3 prefilteredColor = vec3(0.0);
				float totalWeight = 0.0;

				// For very low roughness, just sample the environment directly
				if (roughness < 0.001) {
					gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
					return;
				}

				// Tangent space basis for VNDF sampling
				vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
				vec3 tangent = normalize(cross(up, N));
				vec3 bitangent = cross(N, tangent);

				for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
					vec2 Xi = hammersley(i, uint(GGX_SAMPLES));

					// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
					vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);

					// Transform H back to world space
					vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
					vec3 L = normalize(2.0 * dot(V, H) * H - V);

					float NdotL = max(dot(N, L), 0.0);

					if(NdotL > 0.0) {
						// Sample environment at fixed mip level
						// VNDF importance sampling handles the distribution filtering
						vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);

						// Weight by NdotL for the split-sum approximation
						// VNDF PDF naturally accounts for the visible microfacet distribution
						prefilteredColor += sampleColor * NdotL;
						totalWeight += NdotL;
					}
				}

				if (totalWeight > 0.0) {
					prefilteredColor = prefilteredColor / totalWeight;
				}

				gl_FragColor = vec4(prefilteredColor, 1.0);
			}
		`,blending:Er,depthTest:!1,depthWrite:!1})}function IY(n,e,t){const i=new Float32Array(Eu),r=new L(0,1,0);return new Vi({name:"SphericalGaussianBlur",defines:{n:Eu,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:fy(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`,blending:Er,depthTest:!1,depthWrite:!1})}function CD(){return new Vi({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:fy(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`,blending:Er,depthTest:!1,depthWrite:!1})}function DD(){return new Vi({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:fy(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`,blending:Er,depthTest:!1,depthWrite:!1})}function fy(){return`

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`}function UY(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,h=l===h0||l===f0,f=l===ol||l===_c;if(h||f){let d=e.get(o);const p=d!==void 0?d.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==p)return t===null&&(t=new bE(n)),d=h?t.fromEquirectangular(o,d):t.fromCubemap(o,d),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),d.texture;if(d!==void 0)return d.texture;{const g=o.image;return h&&g&&g.height>0||f&&g&&r(g)?(t===null&&(t=new bE(n)),d=h?t.fromEquirectangular(o):t.fromCubemap(o),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),o.addEventListener("dispose",a),d.texture):null}}}return o}function r(o){let l=0;const h=6;for(let f=0;f<h;f++)o[f]!==void 0&&l++;return l===h}function a(o){const l=o.target;l.removeEventListener("dispose",a);const h=e.get(l);h!==void 0&&(e.delete(l),h.dispose())}function s(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:s}}function PY(n){const e={};function t(i){if(e[i]!==void 0)return e[i];const r=n.getExtension(i);return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&wd("WebGLRenderer: "+i+" extension not supported."),r}}}function zY(n,e,t,i){const r={},a=new WeakMap;function s(d){const p=d.target;p.index!==null&&e.remove(p.index);for(const _ in p.attributes)e.remove(p.attributes[_]);p.removeEventListener("dispose",s),delete r[p.id];const g=a.get(p);g&&(e.remove(g),a.delete(p)),i.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function o(d,p){return r[p.id]===!0||(p.addEventListener("dispose",s),r[p.id]=!0,t.memory.geometries++),p}function l(d){const p=d.attributes;for(const g in p)e.update(p[g],n.ARRAY_BUFFER)}function h(d){const p=[],g=d.index,_=d.attributes.position;let T=0;if(g!==null){const S=g.array;T=g.version;for(let E=0,b=S.length;E<b;E+=3){const N=S[E+0],R=S[E+1],I=S[E+2];p.push(N,R,R,I,I,N)}}else if(_!==void 0){const S=_.array;T=_.version;for(let E=0,b=S.length/3-1;E<b;E+=3){const N=E+0,R=E+1,I=E+2;p.push(N,R,R,I,I,N)}}else return;const y=new(XU(p)?Ob:Nb)(p,1);y.version=T;const v=a.get(d);v&&e.remove(v),a.set(d,y)}function f(d){const p=a.get(d);if(p){const g=d.index;g!==null&&p.version<g.version&&h(d)}else h(d);return a.get(d)}return{get:o,update:l,getWireframeAttribute:f}}function BY(n,e,t){let i;function r(p){i=p}let a,s;function o(p){a=p.type,s=p.bytesPerElement}function l(p,g){n.drawElements(i,g,a,p*s),t.update(g,i,1)}function h(p,g,_){_!==0&&(n.drawElementsInstanced(i,g,a,p*s,_),t.update(g,i,_))}function f(p,g,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,g,0,a,p,0,_);let y=0;for(let v=0;v<_;v++)y+=g[v];t.update(y,i,1)}function d(p,g,_,T){if(_===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let v=0;v<p.length;v++)h(p[v]/s,g[v],T[v]);else{y.multiDrawElementsInstancedWEBGL(i,g,0,a,p,0,T,0,_);let v=0;for(let S=0;S<_;S++)v+=g[S]*T[S];t.update(v,i,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=h,this.renderMultiDraw=f,this.renderMultiDrawInstances=d}function HY(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(a,s,o){switch(t.calls++,s){case n.TRIANGLES:t.triangles+=o*(a/3);break;case n.LINES:t.lines+=o*(a/2);break;case n.LINE_STRIP:t.lines+=o*(a-1);break;case n.LINE_LOOP:t.lines+=o*a;break;case n.POINTS:t.points+=o*a;break;default:Bt("WebGLInfo: Unknown draw mode:",s);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function FY(n,e,t){const i=new WeakMap,r=new zt;function a(s,o,l){const h=s.morphTargetInfluences,f=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=f!==void 0?f.length:0;let p=i.get(o);if(p===void 0||p.count!==d){let w=function(){U.dispose(),i.delete(o),o.removeEventListener("dispose",w)};var g=w;p!==void 0&&p.texture.dispose();const _=o.morphAttributes.position!==void 0,T=o.morphAttributes.normal!==void 0,y=o.morphAttributes.color!==void 0,v=o.morphAttributes.position||[],S=o.morphAttributes.normal||[],E=o.morphAttributes.color||[];let b=0;_===!0&&(b=1),T===!0&&(b=2),y===!0&&(b=3);let N=o.attributes.position.count*b,R=1;N>e.maxTextureSize&&(R=Math.ceil(N/e.maxTextureSize),N=e.maxTextureSize);const I=new Float32Array(N*R*4*d),U=new W1(I,N,R,d);U.type=si,U.needsUpdate=!0;const O=b*4;for(let B=0;B<d;B++){const j=v[B],ee=S[B],se=E[B],ae=N*R*4*B;for(let W=0;W<j.count;W++){const te=W*O;_===!0&&(r.fromBufferAttribute(j,W),I[ae+te+0]=r.x,I[ae+te+1]=r.y,I[ae+te+2]=r.z,I[ae+te+3]=0),T===!0&&(r.fromBufferAttribute(ee,W),I[ae+te+4]=r.x,I[ae+te+5]=r.y,I[ae+te+6]=r.z,I[ae+te+7]=0),y===!0&&(r.fromBufferAttribute(se,W),I[ae+te+8]=r.x,I[ae+te+9]=r.y,I[ae+te+10]=r.z,I[ae+te+11]=se.itemSize===4?r.w:1)}}p={count:d,texture:U,size:new de(N,R)},i.set(o,p),o.addEventListener("dispose",w)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",s.morphTexture,t);else{let _=0;for(let y=0;y<h.length;y++)_+=h[y];const T=o.morphTargetsRelative?1:1-_;l.getUniforms().setValue(n,"morphTargetBaseInfluence",T),l.getUniforms().setValue(n,"morphTargetInfluences",h)}l.getUniforms().setValue(n,"morphTargetsTexture",p.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",p.size)}return{update:a}}function GY(n,e,t,i){let r=new WeakMap;function a(l){const h=i.render.frame,f=l.geometry,d=e.get(l,f);if(r.get(d)!==h&&(e.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==h&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){const p=l.skeleton;r.get(p)!==h&&(p.update(),r.set(p,h))}return d}function s(){r=new WeakMap}function o(l){const h=l.target;h.removeEventListener("dispose",o),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:s}}const Y6=new Nn,ND=new V0(1,1),q6=new W1,j6=new ss,Z6=new G0,OD=[],LD=[],ID=new Float32Array(16),UD=new Float32Array(9),PD=new Float32Array(4);function Jd(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let a=OD[r];if(a===void 0&&(a=new Float32Array(r),OD[r]=a),e!==0){i.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=t,n[s].toArray(a,o)}return a}function ki(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Wi(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function dy(n,e){let t=LD[e];t===void 0&&(t=new Int32Array(e),LD[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function VY(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function kY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ki(t,e))return;n.uniform2fv(this.addr,e),Wi(t,e)}}function WY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(ki(t,e))return;n.uniform3fv(this.addr,e),Wi(t,e)}}function XY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ki(t,e))return;n.uniform4fv(this.addr,e),Wi(t,e)}}function YY(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(ki(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Wi(t,e)}else{if(ki(t,i))return;PD.set(i),n.uniformMatrix2fv(this.addr,!1,PD),Wi(t,i)}}function qY(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(ki(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Wi(t,e)}else{if(ki(t,i))return;UD.set(i),n.uniformMatrix3fv(this.addr,!1,UD),Wi(t,i)}}function jY(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(ki(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Wi(t,e)}else{if(ki(t,i))return;ID.set(i),n.uniformMatrix4fv(this.addr,!1,ID),Wi(t,i)}}function ZY(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function KY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ki(t,e))return;n.uniform2iv(this.addr,e),Wi(t,e)}}function QY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ki(t,e))return;n.uniform3iv(this.addr,e),Wi(t,e)}}function JY(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ki(t,e))return;n.uniform4iv(this.addr,e),Wi(t,e)}}function $Y(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function eq(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(ki(t,e))return;n.uniform2uiv(this.addr,e),Wi(t,e)}}function tq(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(ki(t,e))return;n.uniform3uiv(this.addr,e),Wi(t,e)}}function nq(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(ki(t,e))return;n.uniform4uiv(this.addr,e),Wi(t,e)}}function iq(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let a;this.type===n.SAMPLER_2D_SHADOW?(ND.compareFunction=Rb,a=ND):a=Y6,t.setTexture2D(e||a,r)}function rq(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||j6,r)}function aq(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Z6,r)}function sq(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||q6,r)}function oq(n){switch(n){case 5126:return VY;case 35664:return kY;case 35665:return WY;case 35666:return XY;case 35674:return YY;case 35675:return qY;case 35676:return jY;case 5124:case 35670:return ZY;case 35667:case 35671:return KY;case 35668:case 35672:return QY;case 35669:case 35673:return JY;case 5125:return $Y;case 36294:return eq;case 36295:return tq;case 36296:return nq;case 35678:case 36198:case 36298:case 36306:case 35682:return iq;case 35679:case 36299:case 36307:return rq;case 35680:case 36300:case 36308:case 36293:return aq;case 36289:case 36303:case 36311:case 36292:return sq}}function lq(n,e){n.uniform1fv(this.addr,e)}function cq(n,e){const t=Jd(e,this.size,2);n.uniform2fv(this.addr,t)}function uq(n,e){const t=Jd(e,this.size,3);n.uniform3fv(this.addr,t)}function hq(n,e){const t=Jd(e,this.size,4);n.uniform4fv(this.addr,t)}function fq(n,e){const t=Jd(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function dq(n,e){const t=Jd(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function pq(n,e){const t=Jd(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function mq(n,e){n.uniform1iv(this.addr,e)}function gq(n,e){n.uniform2iv(this.addr,e)}function vq(n,e){n.uniform3iv(this.addr,e)}function _q(n,e){n.uniform4iv(this.addr,e)}function xq(n,e){n.uniform1uiv(this.addr,e)}function yq(n,e){n.uniform2uiv(this.addr,e)}function Sq(n,e){n.uniform3uiv(this.addr,e)}function Tq(n,e){n.uniform4uiv(this.addr,e)}function Eq(n,e,t){const i=this.cache,r=e.length,a=dy(t,r);ki(i,a)||(n.uniform1iv(this.addr,a),Wi(i,a));for(let s=0;s!==r;++s)t.setTexture2D(e[s]||Y6,a[s])}function Mq(n,e,t){const i=this.cache,r=e.length,a=dy(t,r);ki(i,a)||(n.uniform1iv(this.addr,a),Wi(i,a));for(let s=0;s!==r;++s)t.setTexture3D(e[s]||j6,a[s])}function bq(n,e,t){const i=this.cache,r=e.length,a=dy(t,r);ki(i,a)||(n.uniform1iv(this.addr,a),Wi(i,a));for(let s=0;s!==r;++s)t.setTextureCube(e[s]||Z6,a[s])}function Aq(n,e,t){const i=this.cache,r=e.length,a=dy(t,r);ki(i,a)||(n.uniform1iv(this.addr,a),Wi(i,a));for(let s=0;s!==r;++s)t.setTexture2DArray(e[s]||q6,a[s])}function wq(n){switch(n){case 5126:return lq;case 35664:return cq;case 35665:return uq;case 35666:return hq;case 35674:return fq;case 35675:return dq;case 35676:return pq;case 5124:case 35670:return mq;case 35667:case 35671:return gq;case 35668:case 35672:return vq;case 35669:case 35673:return _q;case 5125:return xq;case 36294:return yq;case 36295:return Sq;case 36296:return Tq;case 35678:case 36198:case 36298:case 36306:case 35682:return Eq;case 35679:case 36299:case 36307:return Mq;case 35680:case 36300:case 36308:case 36293:return bq;case 36289:case 36303:case 36311:case 36292:return Aq}}class Rq{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=oq(t.type)}}class Cq{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=wq(t.type)}}class Dq{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let a=0,s=r.length;a!==s;++a){const o=r[a];o.setValue(e,t[o.id],i)}}}const S2=/(\w+)(\])?(\[|\.)?/g;function zD(n,e){n.seq.push(e),n.map[e.id]=e}function Nq(n,e,t){const i=n.name,r=i.length;for(S2.lastIndex=0;;){const a=S2.exec(i),s=S2.lastIndex;let o=a[1];const l=a[2]==="]",h=a[3];if(l&&(o=o|0),h===void 0||h==="["&&s+2===r){zD(t,h===void 0?new Rq(o,n,e):new Cq(o,n,e));break}else{let d=t.map[o];d===void 0&&(d=new Dq(o),zD(t,d)),t=d}}}class M_{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const a=e.getActiveUniform(t,r),s=e.getUniformLocation(t,a.name);Nq(a,s,this)}}setValue(e,t,i,r){const a=this.map[t];a!==void 0&&a.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let a=0,s=t.length;a!==s;++a){const o=t[a],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,a=e.length;r!==a;++r){const s=e[r];s.id in t&&i.push(s)}return i}}function BD(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const Oq=37297;let Lq=0;function Iq(n,e){const t=n.split(`
`),i=[],r=Math.max(e-6,0),a=Math.min(e+6,t.length);for(let s=r;s<a;s++){const o=s+1;i.push(`${o===e?">":" "} ${o}: ${t[s]}`)}return i.join(`
`)}const HD=new Et;function Uq(n){en._getMatrix(HD,en.workingColorSpace,n);const e=`mat3( ${HD.elements.map(t=>t.toFixed(4))} )`;switch(en.getTransfer(n)){case p0:return[e,"LinearTransferOETF"];case wn:return[e,"sRGBTransferOETF"];default:return ut("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function FD(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),a=(n.getShaderInfoLog(e)||"").trim();if(i&&a==="")return"";const s=/ERROR: 0:(\d+)/.exec(a);if(s){const o=parseInt(s[1]);return t.toUpperCase()+`

`+a+`

`+Iq(n.getShaderSource(e),o)}else return a}function Pq(n,e){const t=Uq(e);return[`vec4 ${n}( vec4 value ) {`,`	return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}function zq(n,e){let t;switch(e){case MU:t="Linear";break;case bU:t="Reinhard";break;case AU:t="Cineon";break;case yb:t="ACESFilmic";break;case RU:t="AgX";break;case CU:t="Neutral";break;case wU:t="Custom";break;default:ut("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Fv=new L;function Bq(){en.getLuminanceCoefficients(Fv);const n=Fv.x.toFixed(4),e=Fv.y.toFixed(4),t=Fv.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",`	const vec3 weights = vec3( ${n}, ${e}, ${t} );`,"	return dot( weights, rgb );","}"].join(`
`)}function Hq(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(gm).join(`
`)}function Fq(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
`)}function Gq(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const a=n.getActiveAttrib(e,r),s=a.name;let o=1;a.type===n.FLOAT_MAT2&&(o=2),a.type===n.FLOAT_MAT3&&(o=3),a.type===n.FLOAT_MAT4&&(o=4),t[s]={type:a.type,location:n.getAttribLocation(e,s),locationSize:o}}return t}function gm(n){return n!==""}function GD(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function VD(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Vq=/^[ \t]*#include +<([\w\d./]+)>/gm;function AE(n){return n.replace(Vq,Wq)}const kq=new Map;function Wq(n,e){let t=Qt[e];if(t===void 0){const i=kq.get(e);if(i!==void 0)t=Qt[i],ut('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return AE(t)}const Xq=/#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 kD(n){return n.replace(Xq,Yq)}function Yq(n,e,t,i){let r="";for(let a=parseInt(e);a<parseInt(t);a++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function WD(n){let e=`precision ${n.precision} float;
	precision ${n.precision} int;
	precision ${n.precision} sampler2D;
	precision ${n.precision} samplerCube;
	precision ${n.precision} sampler3D;
	precision ${n.precision} sampler2DArray;
	precision ${n.precision} sampler2DShadow;
	precision ${n.precision} samplerCubeShadow;
	precision ${n.precision} sampler2DArrayShadow;
	precision ${n.precision} isampler2D;
	precision ${n.precision} isampler3D;
	precision ${n.precision} isamplerCube;
	precision ${n.precision} isampler2DArray;
	precision ${n.precision} usampler2D;
	precision ${n.precision} usampler3D;
	precision ${n.precision} usamplerCube;
	precision ${n.precision} usampler2DArray;
	`;return n.precision==="highp"?e+=`
#define HIGH_PRECISION`:n.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function qq(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===I1?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===Pm?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Ts&&(e="SHADOWMAP_TYPE_VSM"),e}function jq(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case ol:case _c:e="ENVMAP_TYPE_CUBE";break;case jd:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Zq(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case _c:e="ENVMAP_MODE_REFRACTION";break}return e}function Kq(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case B0:e="ENVMAP_BLENDING_MULTIPLY";break;case TU:e="ENVMAP_BLENDING_MIX";break;case EU:e="ENVMAP_BLENDING_ADD";break}return e}function Qq(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:i,maxMip:t}}function Jq(n,e,t,i){const r=n.getContext(),a=t.defines;let s=t.vertexShader,o=t.fragmentShader;const l=qq(t),h=jq(t),f=Zq(t),d=Kq(t),p=Qq(t),g=Hq(t),_=Fq(a),T=r.createProgram();let y,v,S=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(y=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(gm).join(`
`),y.length>0&&(y+=`
`),v=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(gm).join(`
`),v.length>0&&(v+=`
`)):(y=[WD(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+f:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","	attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","	attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","	uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","	attribute vec2 uv1;","#endif","#ifdef USE_UV2","	attribute vec2 uv2;","#endif","#ifdef USE_UV3","	attribute vec2 uv3;","#endif","#ifdef USE_TANGENT","	attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","	attribute vec4 color;","#elif defined( USE_COLOR )","	attribute vec3 color;","#endif","#ifdef USE_SKINNING","	attribute vec4 skinIndex;","	attribute vec4 skinWeight;","#endif",`
`].filter(gm).join(`
`),v=[WD(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+f:"",t.envMap?"#define "+d:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==as?"#define TONE_MAPPING":"",t.toneMapping!==as?Qt.tonemapping_pars_fragment:"",t.toneMapping!==as?zq("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Qt.colorspace_pars_fragment,Pq("linearToOutputTexel",t.outputColorSpace),Bq(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(gm).join(`
`)),s=AE(s),s=GD(s,t),s=VD(s,t),o=AE(o),o=GD(o,t),o=VD(o,t),s=kD(s),o=kD(o),t.isRawShaderMaterial!==!0&&(S=`#version 300 es
`,y=[g,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+y,v=["#define varying in",t.glslVersion===so?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===so?"":"#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(`
`)+`
`+v);const E=S+y+s,b=S+v+o,N=BD(r,r.VERTEX_SHADER,E),R=BD(r,r.FRAGMENT_SHADER,b);r.attachShader(T,N),r.attachShader(T,R),t.index0AttributeName!==void 0?r.bindAttribLocation(T,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(T,0,"position"),r.linkProgram(T);function I(B){if(n.debug.checkShaderErrors){const j=r.getProgramInfoLog(T)||"",ee=r.getShaderInfoLog(N)||"",se=r.getShaderInfoLog(R)||"",ae=j.trim(),W=ee.trim(),te=se.trim();let K=!0,oe=!0;if(r.getProgramParameter(T,r.LINK_STATUS)===!1)if(K=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,T,N,R);else{const ie=FD(r,N,"vertex"),Ce=FD(r,R,"fragment");Bt("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(T,r.VALIDATE_STATUS)+`

Material Name: `+B.name+`
Material Type: `+B.type+`

Program Info Log: `+ae+`
`+ie+`
`+Ce)}else ae!==""?ut("WebGLProgram: Program Info Log:",ae):(W===""||te==="")&&(oe=!1);oe&&(B.diagnostics={runnable:K,programLog:ae,vertexShader:{log:W,prefix:y},fragmentShader:{log:te,prefix:v}})}r.deleteShader(N),r.deleteShader(R),U=new M_(r,T),O=Gq(r,T)}let U;this.getUniforms=function(){return U===void 0&&I(this),U};let O;this.getAttributes=function(){return O===void 0&&I(this),O};let w=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return w===!1&&(w=r.getProgramParameter(T,Oq)),w},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(T),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Lq++,this.cacheKey=e,this.usedTimes=1,this.program=T,this.vertexShader=N,this.fragmentShader=R,this}let $q=0;class ej{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),a=this._getShaderStage(i),s=this._getShaderCacheForMaterial(e);return s.has(r)===!1&&(s.add(r),r.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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 i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new tj(e),t.set(e,i)),i}}class tj{constructor(e){this.id=$q++,this.code=e,this.usedTimes=0}}function nj(n,e,t,i,r,a,s){const o=new Cd,l=new ej,h=new Set,f=[],d=r.logarithmicDepthBuffer,p=r.vertexTextures;let g=r.precision;const _={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 T(O){return h.add(O),O===0?"uv":`uv${O}`}function y(O,w,B,j,ee){const se=j.fog,ae=ee.geometry,W=O.isMeshStandardMaterial?j.environment:null,te=(O.isMeshStandardMaterial?t:e).get(O.envMap||W),K=te&&te.mapping===jd?te.image.height:null,oe=_[O.type];O.precision!==null&&(g=r.getMaxPrecision(O.precision),g!==O.precision&&ut("WebGLProgram.getParameters:",O.precision,"not supported, using",g,"instead."));const ie=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,Ce=ie!==void 0?ie.length:0;let Xe=0;ae.morphAttributes.position!==void 0&&(Xe=1),ae.morphAttributes.normal!==void 0&&(Xe=2),ae.morphAttributes.color!==void 0&&(Xe=3);let nt,tt,gt,ge;if(oe){const Vt=As[oe];nt=Vt.vertexShader,tt=Vt.fragmentShader}else nt=O.vertexShader,tt=O.fragmentShader,l.update(O),gt=l.getVertexShaderID(O),ge=l.getFragmentShaderID(O);const Ae=n.getRenderTarget(),Ze=n.state.buffers.depth.getReversed(),ue=ee.isInstancedMesh===!0,it=ee.isBatchedMesh===!0,bt=!!O.map,ot=!!O.matcap,Ke=!!te,Te=!!O.aoMap,G=!!O.lightMap,be=!!O.bumpMap,Ne=!!O.normalMap,Fe=!!O.displacementMap,Be=!!O.emissiveMap,$e=!!O.metalnessMap,Je=!!O.roughnessMap,ct=O.anisotropy>0,k=O.clearcoat>0,P=O.dispersion>0,ce=O.iridescence>0,Ee=O.sheen>0,Le=O.transmission>0,ye=ct&&!!O.anisotropyMap,vt=k&&!!O.clearcoatMap,je=k&&!!O.clearcoatNormalMap,xt=k&&!!O.clearcoatRoughnessMap,pt=ce&&!!O.iridescenceMap,Ie=ce&&!!O.iridescenceThicknessMap,He=Ee&&!!O.sheenColorMap,ht=Ee&&!!O.sheenRoughnessMap,Q=!!O.specularMap,pe=!!O.specularColorMap,Oe=!!O.specularIntensityMap,q=Le&&!!O.transmissionMap,ke=Le&&!!O.thicknessMap,me=!!O.gradientMap,We=!!O.alphaMap,Ge=O.alphaTest>0,we=!!O.alphaHash,at=!!O.extensions;let St=as;O.toneMapped&&(Ae===null||Ae.isXRRenderTarget===!0)&&(St=n.toneMapping);const Gt={shaderID:oe,shaderType:O.type,shaderName:O.name,vertexShader:nt,fragmentShader:tt,defines:O.defines,customVertexShaderID:gt,customFragmentShaderID:ge,isRawShaderMaterial:O.isRawShaderMaterial===!0,glslVersion:O.glslVersion,precision:g,batching:it,batchingColor:it&&ee._colorsTexture!==null,instancing:ue,instancingColor:ue&&ee.instanceColor!==null,instancingMorph:ue&&ee.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:Ae===null?n.outputColorSpace:Ae.isXRRenderTarget===!0?Ae.texture.colorSpace:Fn,alphaToCoverage:!!O.alphaToCoverage,map:bt,matcap:ot,envMap:Ke,envMapMode:Ke&&te.mapping,envMapCubeUVHeight:K,aoMap:Te,lightMap:G,bumpMap:be,normalMap:Ne,displacementMap:p&&Fe,emissiveMap:Be,normalMapObjectSpace:Ne&&O.normalMapType===PU,normalMapTangentSpace:Ne&&O.normalMapType===hl,metalnessMap:$e,roughnessMap:Je,anisotropy:ct,anisotropyMap:ye,clearcoat:k,clearcoatMap:vt,clearcoatNormalMap:je,clearcoatRoughnessMap:xt,dispersion:P,iridescence:ce,iridescenceMap:pt,iridescenceThicknessMap:Ie,sheen:Ee,sheenColorMap:He,sheenRoughnessMap:ht,specularMap:Q,specularColorMap:pe,specularIntensityMap:Oe,transmission:Le,transmissionMap:q,thicknessMap:ke,gradientMap:me,opaque:O.transparent===!1&&O.blending===zu&&O.alphaToCoverage===!1,alphaMap:We,alphaTest:Ge,alphaHash:we,combine:O.combine,mapUv:bt&&T(O.map.channel),aoMapUv:Te&&T(O.aoMap.channel),lightMapUv:G&&T(O.lightMap.channel),bumpMapUv:be&&T(O.bumpMap.channel),normalMapUv:Ne&&T(O.normalMap.channel),displacementMapUv:Fe&&T(O.displacementMap.channel),emissiveMapUv:Be&&T(O.emissiveMap.channel),metalnessMapUv:$e&&T(O.metalnessMap.channel),roughnessMapUv:Je&&T(O.roughnessMap.channel),anisotropyMapUv:ye&&T(O.anisotropyMap.channel),clearcoatMapUv:vt&&T(O.clearcoatMap.channel),clearcoatNormalMapUv:je&&T(O.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:xt&&T(O.clearcoatRoughnessMap.channel),iridescenceMapUv:pt&&T(O.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&T(O.iridescenceThicknessMap.channel),sheenColorMapUv:He&&T(O.sheenColorMap.channel),sheenRoughnessMapUv:ht&&T(O.sheenRoughnessMap.channel),specularMapUv:Q&&T(O.specularMap.channel),specularColorMapUv:pe&&T(O.specularColorMap.channel),specularIntensityMapUv:Oe&&T(O.specularIntensityMap.channel),transmissionMapUv:q&&T(O.transmissionMap.channel),thicknessMapUv:ke&&T(O.thicknessMap.channel),alphaMapUv:We&&T(O.alphaMap.channel),vertexTangents:!!ae.attributes.tangent&&(Ne||ct),vertexColors:O.vertexColors,vertexAlphas:O.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,pointsUvs:ee.isPoints===!0&&!!ae.attributes.uv&&(bt||We),fog:!!se,useFog:O.fog===!0,fogExp2:!!se&&se.isFogExp2,flatShading:O.flatShading===!0&&O.wireframe===!1,sizeAttenuation:O.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Ze,skinning:ee.isSkinnedMesh===!0,morphTargets:ae.morphAttributes.position!==void 0,morphNormals:ae.morphAttributes.normal!==void 0,morphColors:ae.morphAttributes.color!==void 0,morphTargetsCount:Ce,morphTextureStride:Xe,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:O.dithering,shadowMapEnabled:n.shadowMap.enabled&&B.length>0,shadowMapType:n.shadowMap.type,toneMapping:St,decodeVideoTexture:bt&&O.map.isVideoTexture===!0&&en.getTransfer(O.map.colorSpace)===wn,decodeVideoTextureEmissive:Be&&O.emissiveMap.isVideoTexture===!0&&en.getTransfer(O.emissiveMap.colorSpace)===wn,premultipliedAlpha:O.premultipliedAlpha,doubleSided:O.side===cr,flipSided:O.side===Ii,useDepthPacking:O.depthPacking>=0,depthPacking:O.depthPacking||0,index0AttributeName:O.index0AttributeName,extensionClipCullDistance:at&&O.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(at&&O.extensions.multiDraw===!0||it)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:O.customProgramCacheKey()};return Gt.vertexUv1s=h.has(1),Gt.vertexUv2s=h.has(2),Gt.vertexUv3s=h.has(3),h.clear(),Gt}function v(O){const w=[];if(O.shaderID?w.push(O.shaderID):(w.push(O.customVertexShaderID),w.push(O.customFragmentShaderID)),O.defines!==void 0)for(const B in O.defines)w.push(B),w.push(O.defines[B]);return O.isRawShaderMaterial===!1&&(S(w,O),E(w,O),w.push(n.outputColorSpace)),w.push(O.customProgramCacheKey),w.join()}function S(O,w){O.push(w.precision),O.push(w.outputColorSpace),O.push(w.envMapMode),O.push(w.envMapCubeUVHeight),O.push(w.mapUv),O.push(w.alphaMapUv),O.push(w.lightMapUv),O.push(w.aoMapUv),O.push(w.bumpMapUv),O.push(w.normalMapUv),O.push(w.displacementMapUv),O.push(w.emissiveMapUv),O.push(w.metalnessMapUv),O.push(w.roughnessMapUv),O.push(w.anisotropyMapUv),O.push(w.clearcoatMapUv),O.push(w.clearcoatNormalMapUv),O.push(w.clearcoatRoughnessMapUv),O.push(w.iridescenceMapUv),O.push(w.iridescenceThicknessMapUv),O.push(w.sheenColorMapUv),O.push(w.sheenRoughnessMapUv),O.push(w.specularMapUv),O.push(w.specularColorMapUv),O.push(w.specularIntensityMapUv),O.push(w.transmissionMapUv),O.push(w.thicknessMapUv),O.push(w.combine),O.push(w.fogExp2),O.push(w.sizeAttenuation),O.push(w.morphTargetsCount),O.push(w.morphAttributeCount),O.push(w.numDirLights),O.push(w.numPointLights),O.push(w.numSpotLights),O.push(w.numSpotLightMaps),O.push(w.numHemiLights),O.push(w.numRectAreaLights),O.push(w.numDirLightShadows),O.push(w.numPointLightShadows),O.push(w.numSpotLightShadows),O.push(w.numSpotLightShadowsWithMaps),O.push(w.numLightProbes),O.push(w.shadowMapType),O.push(w.toneMapping),O.push(w.numClippingPlanes),O.push(w.numClipIntersection),O.push(w.depthPacking)}function E(O,w){o.disableAll(),w.supportsVertexTextures&&o.enable(0),w.instancing&&o.enable(1),w.instancingColor&&o.enable(2),w.instancingMorph&&o.enable(3),w.matcap&&o.enable(4),w.envMap&&o.enable(5),w.normalMapObjectSpace&&o.enable(6),w.normalMapTangentSpace&&o.enable(7),w.clearcoat&&o.enable(8),w.iridescence&&o.enable(9),w.alphaTest&&o.enable(10),w.vertexColors&&o.enable(11),w.vertexAlphas&&o.enable(12),w.vertexUv1s&&o.enable(13),w.vertexUv2s&&o.enable(14),w.vertexUv3s&&o.enable(15),w.vertexTangents&&o.enable(16),w.anisotropy&&o.enable(17),w.alphaHash&&o.enable(18),w.batching&&o.enable(19),w.dispersion&&o.enable(20),w.batchingColor&&o.enable(21),w.gradientMap&&o.enable(22),O.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.reversedDepthBuffer&&o.enable(4),w.skinning&&o.enable(5),w.morphTargets&&o.enable(6),w.morphNormals&&o.enable(7),w.morphColors&&o.enable(8),w.premultipliedAlpha&&o.enable(9),w.shadowMapEnabled&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),w.decodeVideoTexture&&o.enable(19),w.decodeVideoTextureEmissive&&o.enable(20),w.alphaToCoverage&&o.enable(21),O.push(o.mask)}function b(O){const w=_[O.type];let B;if(w){const j=As[w];B=Lb.clone(j.uniforms)}else B=O.uniforms;return B}function N(O,w){let B;for(let j=0,ee=f.length;j<ee;j++){const se=f[j];if(se.cacheKey===w){B=se,++B.usedTimes;break}}return B===void 0&&(B=new Jq(n,w,O,a),f.push(B)),B}function R(O){if(--O.usedTimes===0){const w=f.indexOf(O);f[w]=f[f.length-1],f.pop(),O.destroy()}}function I(O){l.remove(O)}function U(){l.dispose()}return{getParameters:y,getProgramCacheKey:v,getUniforms:b,acquireProgram:N,releaseProgram:R,releaseShaderCache:I,programs:f,dispose:U}}function ij(){let n=new WeakMap;function e(s){return n.has(s)}function t(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function i(s){n.delete(s)}function r(s,o,l){n.get(s)[o]=l}function a(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:a}}function rj(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function XD(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function YD(){const n=[];let e=0;const t=[],i=[],r=[];function a(){e=0,t.length=0,i.length=0,r.length=0}function s(d,p,g,_,T,y){let v=n[e];return v===void 0?(v={id:d.id,object:d,geometry:p,material:g,groupOrder:_,renderOrder:d.renderOrder,z:T,group:y},n[e]=v):(v.id=d.id,v.object=d,v.geometry=p,v.material=g,v.groupOrder=_,v.renderOrder=d.renderOrder,v.z=T,v.group=y),e++,v}function o(d,p,g,_,T,y){const v=s(d,p,g,_,T,y);g.transmission>0?i.push(v):g.transparent===!0?r.push(v):t.push(v)}function l(d,p,g,_,T,y){const v=s(d,p,g,_,T,y);g.transmission>0?i.unshift(v):g.transparent===!0?r.unshift(v):t.unshift(v)}function h(d,p){t.length>1&&t.sort(d||rj),i.length>1&&i.sort(p||XD),r.length>1&&r.sort(p||XD)}function f(){for(let d=e,p=n.length;d<p;d++){const g=n[d];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:i,transparent:r,init:a,push:o,unshift:l,finish:f,sort:h}}function aj(){let n=new WeakMap;function e(i,r){const a=n.get(i);let s;return a===void 0?(s=new YD,n.set(i,[s])):r>=a.length?(s=new YD,a.push(s)):s=a[r],s}function t(){n=new WeakMap}return{get:e,dispose:t}}function sj(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new L,color:new qe};break;case"SpotLight":t={position:new L,direction:new L,color:new qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new L,color:new qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new L,skyColor:new qe,groundColor:new qe};break;case"RectAreaLight":t={color:new qe,position:new L,halfWidth:new L,halfHeight:new L};break}return n[e.id]=t,t}}}function oj(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new de};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new de};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new de,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let lj=0;function cj(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function uj(n){const e=new sj,t=oj(),i={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 h=0;h<9;h++)i.probe.push(new L);const r=new L,a=new Ve,s=new Ve;function o(h){let f=0,d=0,p=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let g=0,_=0,T=0,y=0,v=0,S=0,E=0,b=0,N=0,R=0,I=0;h.sort(cj);for(let O=0,w=h.length;O<w;O++){const B=h[O],j=B.color,ee=B.intensity,se=B.distance,ae=B.shadow&&B.shadow.map?B.shadow.map.texture:null;if(B.isAmbientLight)f+=j.r*ee,d+=j.g*ee,p+=j.b*ee;else if(B.isLightProbe){for(let W=0;W<9;W++)i.probe[W].addScaledVector(B.sh.coefficients[W],ee);I++}else if(B.isDirectionalLight){const W=e.get(B);if(W.color.copy(B.color).multiplyScalar(B.intensity),B.castShadow){const te=B.shadow,K=t.get(B);K.shadowIntensity=te.intensity,K.shadowBias=te.bias,K.shadowNormalBias=te.normalBias,K.shadowRadius=te.radius,K.shadowMapSize=te.mapSize,i.directionalShadow[g]=K,i.directionalShadowMap[g]=ae,i.directionalShadowMatrix[g]=B.shadow.matrix,S++}i.directional[g]=W,g++}else if(B.isSpotLight){const W=e.get(B);W.position.setFromMatrixPosition(B.matrixWorld),W.color.copy(j).multiplyScalar(ee),W.distance=se,W.coneCos=Math.cos(B.angle),W.penumbraCos=Math.cos(B.angle*(1-B.penumbra)),W.decay=B.decay,i.spot[T]=W;const te=B.shadow;if(B.map&&(i.spotLightMap[N]=B.map,N++,te.updateMatrices(B),B.castShadow&&R++),i.spotLightMatrix[T]=te.matrix,B.castShadow){const K=t.get(B);K.shadowIntensity=te.intensity,K.shadowBias=te.bias,K.shadowNormalBias=te.normalBias,K.shadowRadius=te.radius,K.shadowMapSize=te.mapSize,i.spotShadow[T]=K,i.spotShadowMap[T]=ae,b++}T++}else if(B.isRectAreaLight){const W=e.get(B);W.color.copy(j).multiplyScalar(ee),W.halfWidth.set(B.width*.5,0,0),W.halfHeight.set(0,B.height*.5,0),i.rectArea[y]=W,y++}else if(B.isPointLight){const W=e.get(B);if(W.color.copy(B.color).multiplyScalar(B.intensity),W.distance=B.distance,W.decay=B.decay,B.castShadow){const te=B.shadow,K=t.get(B);K.shadowIntensity=te.intensity,K.shadowBias=te.bias,K.shadowNormalBias=te.normalBias,K.shadowRadius=te.radius,K.shadowMapSize=te.mapSize,K.shadowCameraNear=te.camera.near,K.shadowCameraFar=te.camera.far,i.pointShadow[_]=K,i.pointShadowMap[_]=ae,i.pointShadowMatrix[_]=B.shadow.matrix,E++}i.point[_]=W,_++}else if(B.isHemisphereLight){const W=e.get(B);W.skyColor.copy(B.color).multiplyScalar(ee),W.groundColor.copy(B.groundColor).multiplyScalar(ee),i.hemi[v]=W,v++}}y>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=rt.LTC_FLOAT_1,i.rectAreaLTC2=rt.LTC_FLOAT_2):(i.rectAreaLTC1=rt.LTC_HALF_1,i.rectAreaLTC2=rt.LTC_HALF_2)),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=p;const U=i.hash;(U.directionalLength!==g||U.pointLength!==_||U.spotLength!==T||U.rectAreaLength!==y||U.hemiLength!==v||U.numDirectionalShadows!==S||U.numPointShadows!==E||U.numSpotShadows!==b||U.numSpotMaps!==N||U.numLightProbes!==I)&&(i.directional.length=g,i.spot.length=T,i.rectArea.length=y,i.point.length=_,i.hemi.length=v,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=b,i.spotShadowMap.length=b,i.directionalShadowMatrix.length=S,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=b+N-R,i.spotLightMap.length=N,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=I,U.directionalLength=g,U.pointLength=_,U.spotLength=T,U.rectAreaLength=y,U.hemiLength=v,U.numDirectionalShadows=S,U.numPointShadows=E,U.numSpotShadows=b,U.numSpotMaps=N,U.numLightProbes=I,i.version=lj++)}function l(h,f){let d=0,p=0,g=0,_=0,T=0;const y=f.matrixWorldInverse;for(let v=0,S=h.length;v<S;v++){const E=h[v];if(E.isDirectionalLight){const b=i.directional[d];b.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(y),d++}else if(E.isSpotLight){const b=i.spot[g];b.position.setFromMatrixPosition(E.matrixWorld),b.position.applyMatrix4(y),b.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),b.direction.sub(r),b.direction.transformDirection(y),g++}else if(E.isRectAreaLight){const b=i.rectArea[_];b.position.setFromMatrixPosition(E.matrixWorld),b.position.applyMatrix4(y),s.identity(),a.copy(E.matrixWorld),a.premultiply(y),s.extractRotation(a),b.halfWidth.set(E.width*.5,0,0),b.halfHeight.set(0,E.height*.5,0),b.halfWidth.applyMatrix4(s),b.halfHeight.applyMatrix4(s),_++}else if(E.isPointLight){const b=i.point[p];b.position.setFromMatrixPosition(E.matrixWorld),b.position.applyMatrix4(y),p++}else if(E.isHemisphereLight){const b=i.hemi[T];b.direction.setFromMatrixPosition(E.matrixWorld),b.direction.transformDirection(y),T++}}}return{setup:o,setupView:l,state:i}}function qD(n){const e=new uj(n),t=[],i=[];function r(f){h.camera=f,t.length=0,i.length=0}function a(f){t.push(f)}function s(f){i.push(f)}function o(){e.setup(t)}function l(f){e.setupView(t,f)}const h={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:h,setupLights:o,setupLightsView:l,pushLight:a,pushShadow:s}}function hj(n){let e=new WeakMap;function t(r,a=0){const s=e.get(r);let o;return s===void 0?(o=new qD(n),e.set(r,[o])):a>=s.length?(o=new qD(n),s.push(o)):o=s[a],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const fj=`void main() {
	gl_Position = vec4( position, 1.0 );
}`,dj=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function pj(n,e,t){let i=new Kd;const r=new de,a=new de,s=new zt,o=new Yb({depthPacking:UU}),l=new qb,h={},f=t.maxTextureSize,d={[Ns]:Ii,[Ii]:Ns,[cr]:cr},p=new Vi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new de},radius:{value:4}},vertexShader:fj,fragmentShader:dj}),g=p.clone();g.defines.HORIZONTAL_PASS=1;const _=new Ct;_.setAttribute("position",new Ot(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const T=new oi(_,p),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=I1;let v=this.type;this.render=function(R,I,U){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||R.length===0)return;const O=n.getRenderTarget(),w=n.getActiveCubeFace(),B=n.getActiveMipmapLevel(),j=n.state;j.setBlending(Er),j.buffers.depth.getReversed()===!0?j.buffers.color.setClear(0,0,0,0):j.buffers.color.setClear(1,1,1,1),j.buffers.depth.setTest(!0),j.setScissorTest(!1);const ee=v!==Ts&&this.type===Ts,se=v===Ts&&this.type!==Ts;for(let ae=0,W=R.length;ae<W;ae++){const te=R[ae],K=te.shadow;if(K===void 0){ut("WebGLShadowMap:",te,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;r.copy(K.mapSize);const oe=K.getFrameExtents();if(r.multiply(oe),a.copy(K.mapSize),(r.x>f||r.y>f)&&(r.x>f&&(a.x=Math.floor(f/oe.x),r.x=a.x*oe.x,K.mapSize.x=a.x),r.y>f&&(a.y=Math.floor(f/oe.y),r.y=a.y*oe.y,K.mapSize.y=a.y)),K.map===null||ee===!0||se===!0){const Ce=this.type!==Ts?{minFilter:Vn,magFilter:Vn}:{};K.map!==null&&K.map.dispose(),K.map=new xi(r.x,r.y,Ce),K.map.texture.name=te.name+".shadowMap",K.camera.updateProjectionMatrix()}n.setRenderTarget(K.map),n.clear();const ie=K.getViewportCount();for(let Ce=0;Ce<ie;Ce++){const Xe=K.getViewport(Ce);s.set(a.x*Xe.x,a.y*Xe.y,a.x*Xe.z,a.y*Xe.w),j.viewport(s),K.updateMatrices(te,Ce),i=K.getFrustum(),b(I,U,K.camera,te,this.type)}K.isPointLightShadow!==!0&&this.type===Ts&&S(K,U),K.needsUpdate=!1}v=this.type,y.needsUpdate=!1,n.setRenderTarget(O,w,B)};function S(R,I){const U=e.update(T);p.defines.VSM_SAMPLES!==R.blurSamples&&(p.defines.VSM_SAMPLES=R.blurSamples,g.defines.VSM_SAMPLES=R.blurSamples,p.needsUpdate=!0,g.needsUpdate=!0),R.mapPass===null&&(R.mapPass=new xi(r.x,r.y)),p.uniforms.shadow_pass.value=R.map.texture,p.uniforms.resolution.value=R.mapSize,p.uniforms.radius.value=R.radius,n.setRenderTarget(R.mapPass),n.clear(),n.renderBufferDirect(I,null,U,p,T,null),g.uniforms.shadow_pass.value=R.mapPass.texture,g.uniforms.resolution.value=R.mapSize,g.uniforms.radius.value=R.radius,n.setRenderTarget(R.map),n.clear(),n.renderBufferDirect(I,null,U,g,T,null)}function E(R,I,U,O){let w=null;const B=U.isPointLight===!0?R.customDistanceMaterial:R.customDepthMaterial;if(B!==void 0)w=B;else if(w=U.isPointLight===!0?l:o,n.localClippingEnabled&&I.clipShadows===!0&&Array.isArray(I.clippingPlanes)&&I.clippingPlanes.length!==0||I.displacementMap&&I.displacementScale!==0||I.alphaMap&&I.alphaTest>0||I.map&&I.alphaTest>0||I.alphaToCoverage===!0){const j=w.uuid,ee=I.uuid;let se=h[j];se===void 0&&(se={},h[j]=se);let ae=se[ee];ae===void 0&&(ae=w.clone(),se[ee]=ae,I.addEventListener("dispose",N)),w=ae}if(w.visible=I.visible,w.wireframe=I.wireframe,O===Ts?w.side=I.shadowSide!==null?I.shadowSide:I.side:w.side=I.shadowSide!==null?I.shadowSide:d[I.side],w.alphaMap=I.alphaMap,w.alphaTest=I.alphaToCoverage===!0?.5:I.alphaTest,w.map=I.map,w.clipShadows=I.clipShadows,w.clippingPlanes=I.clippingPlanes,w.clipIntersection=I.clipIntersection,w.displacementMap=I.displacementMap,w.displacementScale=I.displacementScale,w.displacementBias=I.displacementBias,w.wireframeLinewidth=I.wireframeLinewidth,w.linewidth=I.linewidth,U.isPointLight===!0&&w.isMeshDistanceMaterial===!0){const j=n.properties.get(w);j.light=U}return w}function b(R,I,U,O,w){if(R.visible===!1)return;if(R.layers.test(I.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&w===Ts)&&(!R.frustumCulled||i.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,R.matrixWorld);const ee=e.update(R),se=R.material;if(Array.isArray(se)){const ae=ee.groups;for(let W=0,te=ae.length;W<te;W++){const K=ae[W],oe=se[K.materialIndex];if(oe&&oe.visible){const ie=E(R,oe,O,w);R.onBeforeShadow(n,R,I,U,ee,ie,K),n.renderBufferDirect(U,null,ee,ie,R,K),R.onAfterShadow(n,R,I,U,ee,ie,K)}}}else if(se.visible){const ae=E(R,se,O,w);R.onBeforeShadow(n,R,I,U,ee,ae,null),n.renderBufferDirect(U,null,ee,ae,R,null),R.onAfterShadow(n,R,I,U,ee,ae,null)}}const j=R.children;for(let ee=0,se=j.length;ee<se;ee++)b(j[ee],I,U,O,w)}function N(R){R.target.removeEventListener("dispose",N);for(const U in h){const O=h[U],w=R.target.uuid;w in O&&(O[w].dispose(),delete O[w])}}}const mj={[cx]:u0,[ux]:dx,[hx]:px,[ju]:fx,[u0]:cx,[dx]:ux,[px]:hx,[fx]:ju};function gj(n,e){function t(){let q=!1;const ke=new zt;let me=null;const We=new zt(0,0,0,0);return{setMask:function(Ge){me!==Ge&&!q&&(n.colorMask(Ge,Ge,Ge,Ge),me=Ge)},setLocked:function(Ge){q=Ge},setClear:function(Ge,we,at,St,Gt){Gt===!0&&(Ge*=St,we*=St,at*=St),ke.set(Ge,we,at,St),We.equals(ke)===!1&&(n.clearColor(Ge,we,at,St),We.copy(ke))},reset:function(){q=!1,me=null,We.set(-1,0,0,0)}}}function i(){let q=!1,ke=!1,me=null,We=null,Ge=null;return{setReversed:function(we){if(ke!==we){const at=e.get("EXT_clip_control");we?at.clipControlEXT(at.LOWER_LEFT_EXT,at.ZERO_TO_ONE_EXT):at.clipControlEXT(at.LOWER_LEFT_EXT,at.NEGATIVE_ONE_TO_ONE_EXT),ke=we;const St=Ge;Ge=null,this.setClear(St)}},getReversed:function(){return ke},setTest:function(we){we?Ae(n.DEPTH_TEST):Ze(n.DEPTH_TEST)},setMask:function(we){me!==we&&!q&&(n.depthMask(we),me=we)},setFunc:function(we){if(ke&&(we=mj[we]),We!==we){switch(we){case cx:n.depthFunc(n.NEVER);break;case u0:n.depthFunc(n.ALWAYS);break;case ux:n.depthFunc(n.LESS);break;case ju:n.depthFunc(n.LEQUAL);break;case hx:n.depthFunc(n.EQUAL);break;case fx:n.depthFunc(n.GEQUAL);break;case dx:n.depthFunc(n.GREATER);break;case px:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}We=we}},setLocked:function(we){q=we},setClear:function(we){Ge!==we&&(ke&&(we=1-we),n.clearDepth(we),Ge=we)},reset:function(){q=!1,me=null,We=null,Ge=null,ke=!1}}}function r(){let q=!1,ke=null,me=null,We=null,Ge=null,we=null,at=null,St=null,Gt=null;return{setTest:function(Vt){q||(Vt?Ae(n.STENCIL_TEST):Ze(n.STENCIL_TEST))},setMask:function(Vt){ke!==Vt&&!q&&(n.stencilMask(Vt),ke=Vt)},setFunc:function(Vt,li,ci){(me!==Vt||We!==li||Ge!==ci)&&(n.stencilFunc(Vt,li,ci),me=Vt,We=li,Ge=ci)},setOp:function(Vt,li,ci){(we!==Vt||at!==li||St!==ci)&&(n.stencilOp(Vt,li,ci),we=Vt,at=li,St=ci)},setLocked:function(Vt){q=Vt},setClear:function(Vt){Gt!==Vt&&(n.clearStencil(Vt),Gt=Vt)},reset:function(){q=!1,ke=null,me=null,We=null,Ge=null,we=null,at=null,St=null,Gt=null}}}const a=new t,s=new i,o=new r,l=new WeakMap,h=new WeakMap;let f={},d={},p=new WeakMap,g=[],_=null,T=!1,y=null,v=null,S=null,E=null,b=null,N=null,R=null,I=new qe(0,0,0),U=0,O=!1,w=null,B=null,j=null,ee=null,se=null;const ae=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,te=0;const K=n.getParameter(n.VERSION);K.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(K)[1]),W=te>=1):K.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),W=te>=2);let oe=null,ie={};const Ce=n.getParameter(n.SCISSOR_BOX),Xe=n.getParameter(n.VIEWPORT),nt=new zt().fromArray(Ce),tt=new zt().fromArray(Xe);function gt(q,ke,me,We){const Ge=new Uint8Array(4),we=n.createTexture();n.bindTexture(q,we),n.texParameteri(q,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(q,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let at=0;at<me;at++)q===n.TEXTURE_3D||q===n.TEXTURE_2D_ARRAY?n.texImage3D(ke,0,n.RGBA,1,1,We,0,n.RGBA,n.UNSIGNED_BYTE,Ge):n.texImage2D(ke+at,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ge);return we}const ge={};ge[n.TEXTURE_2D]=gt(n.TEXTURE_2D,n.TEXTURE_2D,1),ge[n.TEXTURE_CUBE_MAP]=gt(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),ge[n.TEXTURE_2D_ARRAY]=gt(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),ge[n.TEXTURE_3D]=gt(n.TEXTURE_3D,n.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),Ae(n.DEPTH_TEST),s.setFunc(ju),be(!1),Ne(uE),Ae(n.CULL_FACE),Te(Er);function Ae(q){f[q]!==!0&&(n.enable(q),f[q]=!0)}function Ze(q){f[q]!==!1&&(n.disable(q),f[q]=!1)}function ue(q,ke){return d[q]!==ke?(n.bindFramebuffer(q,ke),d[q]=ke,q===n.DRAW_FRAMEBUFFER&&(d[n.FRAMEBUFFER]=ke),q===n.FRAMEBUFFER&&(d[n.DRAW_FRAMEBUFFER]=ke),!0):!1}function it(q,ke){let me=g,We=!1;if(q){me=p.get(ke),me===void 0&&(me=[],p.set(ke,me));const Ge=q.textures;if(me.length!==Ge.length||me[0]!==n.COLOR_ATTACHMENT0){for(let we=0,at=Ge.length;we<at;we++)me[we]=n.COLOR_ATTACHMENT0+we;me.length=Ge.length,We=!0}}else me[0]!==n.BACK&&(me[0]=n.BACK,We=!0);We&&n.drawBuffers(me)}function bt(q){return _!==q?(n.useProgram(q),_=q,!0):!1}const ot={[$s]:n.FUNC_ADD,[sU]:n.FUNC_SUBTRACT,[oU]:n.FUNC_REVERSE_SUBTRACT};ot[lU]=n.MIN,ot[cU]=n.MAX;const Ke={[uU]:n.ZERO,[Yf]:n.ONE,[hU]:n.SRC_COLOR,[ox]:n.SRC_ALPHA,[vU]:n.SRC_ALPHA_SATURATE,[mU]:n.DST_COLOR,[dU]:n.DST_ALPHA,[fU]:n.ONE_MINUS_SRC_COLOR,[lx]:n.ONE_MINUS_SRC_ALPHA,[gU]:n.ONE_MINUS_DST_COLOR,[pU]:n.ONE_MINUS_DST_ALPHA,[_U]:n.CONSTANT_COLOR,[xU]:n.ONE_MINUS_CONSTANT_COLOR,[yU]:n.CONSTANT_ALPHA,[SU]:n.ONE_MINUS_CONSTANT_ALPHA};function Te(q,ke,me,We,Ge,we,at,St,Gt,Vt){if(q===Er){T===!0&&(Ze(n.BLEND),T=!1);return}if(T===!1&&(Ae(n.BLEND),T=!0),q!==xb){if(q!==y||Vt!==O){if((v!==$s||b!==$s)&&(n.blendEquation(n.FUNC_ADD),v=$s,b=$s),Vt)switch(q){case zu:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case hE:n.blendFunc(n.ONE,n.ONE);break;case fE:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case dE:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:Bt("WebGLState: Invalid blending: ",q);break}else switch(q){case zu:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case hE:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case fE:Bt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case dE:Bt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Bt("WebGLState: Invalid blending: ",q);break}S=null,E=null,N=null,R=null,I.set(0,0,0),U=0,y=q,O=Vt}return}Ge=Ge||ke,we=we||me,at=at||We,(ke!==v||Ge!==b)&&(n.blendEquationSeparate(ot[ke],ot[Ge]),v=ke,b=Ge),(me!==S||We!==E||we!==N||at!==R)&&(n.blendFuncSeparate(Ke[me],Ke[We],Ke[we],Ke[at]),S=me,E=We,N=we,R=at),(St.equals(I)===!1||Gt!==U)&&(n.blendColor(St.r,St.g,St.b,Gt),I.copy(St),U=Gt),y=q,O=!1}function G(q,ke){q.side===cr?Ze(n.CULL_FACE):Ae(n.CULL_FACE);let me=q.side===Ii;ke&&(me=!me),be(me),q.blending===zu&&q.transparent===!1?Te(Er):Te(q.blending,q.blendEquation,q.blendSrc,q.blendDst,q.blendEquationAlpha,q.blendSrcAlpha,q.blendDstAlpha,q.blendColor,q.blendAlpha,q.premultipliedAlpha),s.setFunc(q.depthFunc),s.setTest(q.depthTest),s.setMask(q.depthWrite),a.setMask(q.colorWrite);const We=q.stencilWrite;o.setTest(We),We&&(o.setMask(q.stencilWriteMask),o.setFunc(q.stencilFunc,q.stencilRef,q.stencilFuncMask),o.setOp(q.stencilFail,q.stencilZFail,q.stencilZPass)),Be(q.polygonOffset,q.polygonOffsetFactor,q.polygonOffsetUnits),q.alphaToCoverage===!0?Ae(n.SAMPLE_ALPHA_TO_COVERAGE):Ze(n.SAMPLE_ALPHA_TO_COVERAGE)}function be(q){w!==q&&(q?n.frontFace(n.CW):n.frontFace(n.CCW),w=q)}function Ne(q){q!==iU?(Ae(n.CULL_FACE),q!==B&&(q===uE?n.cullFace(n.BACK):q===rU?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Ze(n.CULL_FACE),B=q}function Fe(q){q!==j&&(W&&n.lineWidth(q),j=q)}function Be(q,ke,me){q?(Ae(n.POLYGON_OFFSET_FILL),(ee!==ke||se!==me)&&(n.polygonOffset(ke,me),ee=ke,se=me)):Ze(n.POLYGON_OFFSET_FILL)}function $e(q){q?Ae(n.SCISSOR_TEST):Ze(n.SCISSOR_TEST)}function Je(q){q===void 0&&(q=n.TEXTURE0+ae-1),oe!==q&&(n.activeTexture(q),oe=q)}function ct(q,ke,me){me===void 0&&(oe===null?me=n.TEXTURE0+ae-1:me=oe);let We=ie[me];We===void 0&&(We={type:void 0,texture:void 0},ie[me]=We),(We.type!==q||We.texture!==ke)&&(oe!==me&&(n.activeTexture(me),oe=me),n.bindTexture(q,ke||ge[q]),We.type=q,We.texture=ke)}function k(){const q=ie[oe];q!==void 0&&q.type!==void 0&&(n.bindTexture(q.type,null),q.type=void 0,q.texture=void 0)}function P(){try{n.compressedTexImage2D(...arguments)}catch(q){q("WebGLState:",q)}}function ce(){try{n.compressedTexImage3D(...arguments)}catch(q){q("WebGLState:",q)}}function Ee(){try{n.texSubImage2D(...arguments)}catch(q){q("WebGLState:",q)}}function Le(){try{n.texSubImage3D(...arguments)}catch(q){q("WebGLState:",q)}}function ye(){try{n.compressedTexSubImage2D(...arguments)}catch(q){q("WebGLState:",q)}}function vt(){try{n.compressedTexSubImage3D(...arguments)}catch(q){q("WebGLState:",q)}}function je(){try{n.texStorage2D(...arguments)}catch(q){q("WebGLState:",q)}}function xt(){try{n.texStorage3D(...arguments)}catch(q){q("WebGLState:",q)}}function pt(){try{n.texImage2D(...arguments)}catch(q){q("WebGLState:",q)}}function Ie(){try{n.texImage3D(...arguments)}catch(q){q("WebGLState:",q)}}function He(q){nt.equals(q)===!1&&(n.scissor(q.x,q.y,q.z,q.w),nt.copy(q))}function ht(q){tt.equals(q)===!1&&(n.viewport(q.x,q.y,q.z,q.w),tt.copy(q))}function Q(q,ke){let me=h.get(ke);me===void 0&&(me=new WeakMap,h.set(ke,me));let We=me.get(q);We===void 0&&(We=n.getUniformBlockIndex(ke,q.name),me.set(q,We))}function pe(q,ke){const We=h.get(ke).get(q);l.get(ke)!==We&&(n.uniformBlockBinding(ke,We,q.__bindingPointIndex),l.set(ke,We))}function Oe(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),s.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),f={},oe=null,ie={},d={},p=new WeakMap,g=[],_=null,T=!1,y=null,v=null,S=null,E=null,b=null,N=null,R=null,I=new qe(0,0,0),U=0,O=!1,w=null,B=null,j=null,ee=null,se=null,nt.set(0,0,n.canvas.width,n.canvas.height),tt.set(0,0,n.canvas.width,n.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:Ae,disable:Ze,bindFramebuffer:ue,drawBuffers:it,useProgram:bt,setBlending:Te,setMaterial:G,setFlipSided:be,setCullFace:Ne,setLineWidth:Fe,setPolygonOffset:Be,setScissorTest:$e,activeTexture:Je,bindTexture:ct,unbindTexture:k,compressedTexImage2D:P,compressedTexImage3D:ce,texImage2D:pt,texImage3D:Ie,updateUBOMapping:Q,uniformBlockBinding:pe,texStorage2D:je,texStorage3D:xt,texSubImage2D:Ee,texSubImage3D:Le,compressedTexSubImage2D:ye,compressedTexSubImage3D:vt,scissor:He,viewport:ht,reset:Oe}}function vj(n,e,t,i,r,a,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new de,f=new WeakMap;let d;const p=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(k,P){return g?new OffscreenCanvas(k,P):g0("canvas")}function T(k,P,ce){let Ee=1;const Le=ct(k);if((Le.width>ce||Le.height>ce)&&(Ee=ce/Math.max(Le.width,Le.height)),Ee<1)if(typeof HTMLImageElement<"u"&&k instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&k instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&k instanceof ImageBitmap||typeof VideoFrame<"u"&&k instanceof VideoFrame){const ye=Math.floor(Ee*Le.width),vt=Math.floor(Ee*Le.height);d===void 0&&(d=_(ye,vt));const je=P?_(ye,vt):d;return je.width=ye,je.height=vt,je.getContext("2d").drawImage(k,0,0,ye,vt),ut("WebGLRenderer: Texture has been resized from ("+Le.width+"x"+Le.height+") to ("+ye+"x"+vt+")."),je}else return"data"in k&&ut("WebGLRenderer: Image in DataTexture is too big ("+Le.width+"x"+Le.height+")."),k;return k}function y(k){return k.generateMipmaps}function v(k){n.generateMipmap(k)}function S(k){return k.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:k.isWebGL3DRenderTarget?n.TEXTURE_3D:k.isWebGLArrayRenderTarget||k.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function E(k,P,ce,Ee,Le=!1){if(k!==null){if(n[k]!==void 0)return n[k];ut("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+k+"'")}let ye=P;if(P===n.RED&&(ce===n.FLOAT&&(ye=n.R32F),ce===n.HALF_FLOAT&&(ye=n.R16F),ce===n.UNSIGNED_BYTE&&(ye=n.R8)),P===n.RED_INTEGER&&(ce===n.UNSIGNED_BYTE&&(ye=n.R8UI),ce===n.UNSIGNED_SHORT&&(ye=n.R16UI),ce===n.UNSIGNED_INT&&(ye=n.R32UI),ce===n.BYTE&&(ye=n.R8I),ce===n.SHORT&&(ye=n.R16I),ce===n.INT&&(ye=n.R32I)),P===n.RG&&(ce===n.FLOAT&&(ye=n.RG32F),ce===n.HALF_FLOAT&&(ye=n.RG16F),ce===n.UNSIGNED_BYTE&&(ye=n.RG8)),P===n.RG_INTEGER&&(ce===n.UNSIGNED_BYTE&&(ye=n.RG8UI),ce===n.UNSIGNED_SHORT&&(ye=n.RG16UI),ce===n.UNSIGNED_INT&&(ye=n.RG32UI),ce===n.BYTE&&(ye=n.RG8I),ce===n.SHORT&&(ye=n.RG16I),ce===n.INT&&(ye=n.RG32I)),P===n.RGB_INTEGER&&(ce===n.UNSIGNED_BYTE&&(ye=n.RGB8UI),ce===n.UNSIGNED_SHORT&&(ye=n.RGB16UI),ce===n.UNSIGNED_INT&&(ye=n.RGB32UI),ce===n.BYTE&&(ye=n.RGB8I),ce===n.SHORT&&(ye=n.RGB16I),ce===n.INT&&(ye=n.RGB32I)),P===n.RGBA_INTEGER&&(ce===n.UNSIGNED_BYTE&&(ye=n.RGBA8UI),ce===n.UNSIGNED_SHORT&&(ye=n.RGBA16UI),ce===n.UNSIGNED_INT&&(ye=n.RGBA32UI),ce===n.BYTE&&(ye=n.RGBA8I),ce===n.SHORT&&(ye=n.RGBA16I),ce===n.INT&&(ye=n.RGBA32I)),P===n.RGB&&(ce===n.UNSIGNED_INT_5_9_9_9_REV&&(ye=n.RGB9_E5),ce===n.UNSIGNED_INT_10F_11F_11F_REV&&(ye=n.R11F_G11F_B10F)),P===n.RGBA){const vt=Le?p0:en.getTransfer(Ee);ce===n.FLOAT&&(ye=n.RGBA32F),ce===n.HALF_FLOAT&&(ye=n.RGBA16F),ce===n.UNSIGNED_BYTE&&(ye=vt===wn?n.SRGB8_ALPHA8:n.RGBA8),ce===n.UNSIGNED_SHORT_4_4_4_4&&(ye=n.RGBA4),ce===n.UNSIGNED_SHORT_5_5_5_1&&(ye=n.RGB5_A1)}return(ye===n.R16F||ye===n.R32F||ye===n.RG16F||ye===n.RG32F||ye===n.RGBA16F||ye===n.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function b(k,P){let ce;return k?P===null||P===Os||P===Ku?ce=n.DEPTH24_STENCIL8:P===si?ce=n.DEPTH32F_STENCIL8:P===Zu&&(ce=n.DEPTH24_STENCIL8,ut("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):P===null||P===Os||P===Ku?ce=n.DEPTH_COMPONENT24:P===si?ce=n.DEPTH_COMPONENT32F:P===Zu&&(ce=n.DEPTH_COMPONENT16),ce}function N(k,P){return y(k)===!0||k.isFramebufferTexture&&k.minFilter!==Vn&&k.minFilter!==Ht?Math.log2(Math.max(P.width,P.height))+1:k.mipmaps!==void 0&&k.mipmaps.length>0?k.mipmaps.length:k.isCompressedTexture&&Array.isArray(k.image)?P.mipmaps.length:1}function R(k){const P=k.target;P.removeEventListener("dispose",R),U(P),P.isVideoTexture&&f.delete(P)}function I(k){const P=k.target;P.removeEventListener("dispose",I),w(P)}function U(k){const P=i.get(k);if(P.__webglInit===void 0)return;const ce=k.source,Ee=p.get(ce);if(Ee){const Le=Ee[P.__cacheKey];Le.usedTimes--,Le.usedTimes===0&&O(k),Object.keys(Ee).length===0&&p.delete(ce)}i.remove(k)}function O(k){const P=i.get(k);n.deleteTexture(P.__webglTexture);const ce=k.source,Ee=p.get(ce);delete Ee[P.__cacheKey],s.memory.textures--}function w(k){const P=i.get(k);if(k.depthTexture&&(k.depthTexture.dispose(),i.remove(k.depthTexture)),k.isWebGLCubeRenderTarget)for(let Ee=0;Ee<6;Ee++){if(Array.isArray(P.__webglFramebuffer[Ee]))for(let Le=0;Le<P.__webglFramebuffer[Ee].length;Le++)n.deleteFramebuffer(P.__webglFramebuffer[Ee][Le]);else n.deleteFramebuffer(P.__webglFramebuffer[Ee]);P.__webglDepthbuffer&&n.deleteRenderbuffer(P.__webglDepthbuffer[Ee])}else{if(Array.isArray(P.__webglFramebuffer))for(let Ee=0;Ee<P.__webglFramebuffer.length;Ee++)n.deleteFramebuffer(P.__webglFramebuffer[Ee]);else n.deleteFramebuffer(P.__webglFramebuffer);if(P.__webglDepthbuffer&&n.deleteRenderbuffer(P.__webglDepthbuffer),P.__webglMultisampledFramebuffer&&n.deleteFramebuffer(P.__webglMultisampledFramebuffer),P.__webglColorRenderbuffer)for(let Ee=0;Ee<P.__webglColorRenderbuffer.length;Ee++)P.__webglColorRenderbuffer[Ee]&&n.deleteRenderbuffer(P.__webglColorRenderbuffer[Ee]);P.__webglDepthRenderbuffer&&n.deleteRenderbuffer(P.__webglDepthRenderbuffer)}const ce=k.textures;for(let Ee=0,Le=ce.length;Ee<Le;Ee++){const ye=i.get(ce[Ee]);ye.__webglTexture&&(n.deleteTexture(ye.__webglTexture),s.memory.textures--),i.remove(ce[Ee])}i.remove(k)}let B=0;function j(){B=0}function ee(){const k=B;return k>=r.maxTextures&&ut("WebGLTextures: Trying to use "+k+" texture units while this GPU supports only "+r.maxTextures),B+=1,k}function se(k){const P=[];return P.push(k.wrapS),P.push(k.wrapT),P.push(k.wrapR||0),P.push(k.magFilter),P.push(k.minFilter),P.push(k.anisotropy),P.push(k.internalFormat),P.push(k.format),P.push(k.type),P.push(k.generateMipmaps),P.push(k.premultiplyAlpha),P.push(k.flipY),P.push(k.unpackAlignment),P.push(k.colorSpace),P.join()}function ae(k,P){const ce=i.get(k);if(k.isVideoTexture&&$e(k),k.isRenderTargetTexture===!1&&k.isExternalTexture!==!0&&k.version>0&&ce.__version!==k.version){const Ee=k.image;if(Ee===null)ut("WebGLRenderer: Texture marked for update but no image data found.");else if(Ee.complete===!1)ut("WebGLRenderer: Texture marked for update but image is incomplete");else{ge(ce,k,P);return}}else k.isExternalTexture&&(ce.__webglTexture=k.sourceTexture?k.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ce.__webglTexture,n.TEXTURE0+P)}function W(k,P){const ce=i.get(k);if(k.isRenderTargetTexture===!1&&k.version>0&&ce.__version!==k.version){ge(ce,k,P);return}else k.isExternalTexture&&(ce.__webglTexture=k.sourceTexture?k.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ce.__webglTexture,n.TEXTURE0+P)}function te(k,P){const ce=i.get(k);if(k.isRenderTargetTexture===!1&&k.version>0&&ce.__version!==k.version){ge(ce,k,P);return}t.bindTexture(n.TEXTURE_3D,ce.__webglTexture,n.TEXTURE0+P)}function K(k,P){const ce=i.get(k);if(k.version>0&&ce.__version!==k.version){Ae(ce,k,P);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ce.__webglTexture,n.TEXTURE0+P)}const oe={[Mr]:n.REPEAT,[Ui]:n.CLAMP_TO_EDGE,[Td]:n.MIRRORED_REPEAT},ie={[Vn]:n.NEAREST,[P1]:n.NEAREST_MIPMAP_NEAREST,[bu]:n.NEAREST_MIPMAP_LINEAR,[Ht]:n.LINEAR,[sd]:n.LINEAR_MIPMAP_NEAREST,[Aa]:n.LINEAR_MIPMAP_LINEAR},Ce={[zU]:n.NEVER,[kU]:n.ALWAYS,[BU]:n.LESS,[Rb]:n.LEQUAL,[HU]:n.EQUAL,[VU]:n.GEQUAL,[FU]:n.GREATER,[GU]:n.NOTEQUAL};function Xe(k,P){if(P.type===si&&e.has("OES_texture_float_linear")===!1&&(P.magFilter===Ht||P.magFilter===sd||P.magFilter===bu||P.magFilter===Aa||P.minFilter===Ht||P.minFilter===sd||P.minFilter===bu||P.minFilter===Aa)&&ut("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(k,n.TEXTURE_WRAP_S,oe[P.wrapS]),n.texParameteri(k,n.TEXTURE_WRAP_T,oe[P.wrapT]),(k===n.TEXTURE_3D||k===n.TEXTURE_2D_ARRAY)&&n.texParameteri(k,n.TEXTURE_WRAP_R,oe[P.wrapR]),n.texParameteri(k,n.TEXTURE_MAG_FILTER,ie[P.magFilter]),n.texParameteri(k,n.TEXTURE_MIN_FILTER,ie[P.minFilter]),P.compareFunction&&(n.texParameteri(k,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(k,n.TEXTURE_COMPARE_FUNC,Ce[P.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(P.magFilter===Vn||P.minFilter!==bu&&P.minFilter!==Aa||P.type===si&&e.has("OES_texture_float_linear")===!1)return;if(P.anisotropy>1||i.get(P).__currentAnisotropy){const ce=e.get("EXT_texture_filter_anisotropic");n.texParameterf(k,ce.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(P.anisotropy,r.getMaxAnisotropy())),i.get(P).__currentAnisotropy=P.anisotropy}}}function nt(k,P){let ce=!1;k.__webglInit===void 0&&(k.__webglInit=!0,P.addEventListener("dispose",R));const Ee=P.source;let Le=p.get(Ee);Le===void 0&&(Le={},p.set(Ee,Le));const ye=se(P);if(ye!==k.__cacheKey){Le[ye]===void 0&&(Le[ye]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,ce=!0),Le[ye].usedTimes++;const vt=Le[k.__cacheKey];vt!==void 0&&(Le[k.__cacheKey].usedTimes--,vt.usedTimes===0&&O(P)),k.__cacheKey=ye,k.__webglTexture=Le[ye].texture}return ce}function tt(k,P,ce){return Math.floor(Math.floor(k/ce)/P)}function gt(k,P,ce,Ee){const ye=k.updateRanges;if(ye.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,P.width,P.height,ce,Ee,P.data);else{ye.sort((Ie,He)=>Ie.start-He.start);let vt=0;for(let Ie=1;Ie<ye.length;Ie++){const He=ye[vt],ht=ye[Ie],Q=He.start+He.count,pe=tt(ht.start,P.width,4),Oe=tt(He.start,P.width,4);ht.start<=Q+1&&pe===Oe&&tt(ht.start+ht.count-1,P.width,4)===pe?He.count=Math.max(He.count,ht.start+ht.count-He.start):(++vt,ye[vt]=ht)}ye.length=vt+1;const je=n.getParameter(n.UNPACK_ROW_LENGTH),xt=n.getParameter(n.UNPACK_SKIP_PIXELS),pt=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,P.width);for(let Ie=0,He=ye.length;Ie<He;Ie++){const ht=ye[Ie],Q=Math.floor(ht.start/4),pe=Math.ceil(ht.count/4),Oe=Q%P.width,q=Math.floor(Q/P.width),ke=pe,me=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,Oe),n.pixelStorei(n.UNPACK_SKIP_ROWS,q),t.texSubImage2D(n.TEXTURE_2D,0,Oe,q,ke,me,ce,Ee,P.data)}k.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,je),n.pixelStorei(n.UNPACK_SKIP_PIXELS,xt),n.pixelStorei(n.UNPACK_SKIP_ROWS,pt)}}function ge(k,P,ce){let Ee=n.TEXTURE_2D;(P.isDataArrayTexture||P.isCompressedArrayTexture)&&(Ee=n.TEXTURE_2D_ARRAY),P.isData3DTexture&&(Ee=n.TEXTURE_3D);const Le=nt(k,P),ye=P.source;t.bindTexture(Ee,k.__webglTexture,n.TEXTURE0+ce);const vt=i.get(ye);if(ye.version!==vt.__version||Le===!0){t.activeTexture(n.TEXTURE0+ce);const je=en.getPrimaries(en.workingColorSpace),xt=P.colorSpace===Or?null:en.getPrimaries(P.colorSpace),pt=P.colorSpace===Or||je===xt?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,P.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,P.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,pt);let Ie=T(P.image,!1,r.maxTextureSize);Ie=Je(P,Ie);const He=a.convert(P.format,P.colorSpace),ht=a.convert(P.type);let Q=E(P.internalFormat,He,ht,P.colorSpace,P.isVideoTexture);Xe(Ee,P);let pe;const Oe=P.mipmaps,q=P.isVideoTexture!==!0,ke=vt.__version===void 0||Le===!0,me=ye.dataReady,We=N(P,Ie);if(P.isDepthTexture)Q=b(P.format===Qu,P.type),ke&&(q?t.texStorage2D(n.TEXTURE_2D,1,Q,Ie.width,Ie.height):t.texImage2D(n.TEXTURE_2D,0,Q,Ie.width,Ie.height,0,He,ht,null));else if(P.isDataTexture)if(Oe.length>0){q&&ke&&t.texStorage2D(n.TEXTURE_2D,We,Q,Oe[0].width,Oe[0].height);for(let Ge=0,we=Oe.length;Ge<we;Ge++)pe=Oe[Ge],q?me&&t.texSubImage2D(n.TEXTURE_2D,Ge,0,0,pe.width,pe.height,He,ht,pe.data):t.texImage2D(n.TEXTURE_2D,Ge,Q,pe.width,pe.height,0,He,ht,pe.data);P.generateMipmaps=!1}else q?(ke&&t.texStorage2D(n.TEXTURE_2D,We,Q,Ie.width,Ie.height),me&&gt(P,Ie,He,ht)):t.texImage2D(n.TEXTURE_2D,0,Q,Ie.width,Ie.height,0,He,ht,Ie.data);else if(P.isCompressedTexture)if(P.isCompressedArrayTexture){q&&ke&&t.texStorage3D(n.TEXTURE_2D_ARRAY,We,Q,Oe[0].width,Oe[0].height,Ie.depth);for(let Ge=0,we=Oe.length;Ge<we;Ge++)if(pe=Oe[Ge],P.format!==$n)if(He!==null)if(q){if(me)if(P.layerUpdates.size>0){const at=ME(pe.width,pe.height,P.format,P.type);for(const St of P.layerUpdates){const Gt=pe.data.subarray(St*at/pe.data.BYTES_PER_ELEMENT,(St+1)*at/pe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ge,0,0,St,pe.width,pe.height,1,He,Gt)}P.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ge,0,0,0,pe.width,pe.height,Ie.depth,He,pe.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Ge,Q,pe.width,pe.height,Ie.depth,0,pe.data,0,0);else ut("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else q?me&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Ge,0,0,0,pe.width,pe.height,Ie.depth,He,ht,pe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Ge,Q,pe.width,pe.height,Ie.depth,0,He,ht,pe.data)}else{q&&ke&&t.texStorage2D(n.TEXTURE_2D,We,Q,Oe[0].width,Oe[0].height);for(let Ge=0,we=Oe.length;Ge<we;Ge++)pe=Oe[Ge],P.format!==$n?He!==null?q?me&&t.compressedTexSubImage2D(n.TEXTURE_2D,Ge,0,0,pe.width,pe.height,He,pe.data):t.compressedTexImage2D(n.TEXTURE_2D,Ge,Q,pe.width,pe.height,0,pe.data):ut("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):q?me&&t.texSubImage2D(n.TEXTURE_2D,Ge,0,0,pe.width,pe.height,He,ht,pe.data):t.texImage2D(n.TEXTURE_2D,Ge,Q,pe.width,pe.height,0,He,ht,pe.data)}else if(P.isDataArrayTexture)if(q){if(ke&&t.texStorage3D(n.TEXTURE_2D_ARRAY,We,Q,Ie.width,Ie.height,Ie.depth),me)if(P.layerUpdates.size>0){const Ge=ME(Ie.width,Ie.height,P.format,P.type);for(const we of P.layerUpdates){const at=Ie.data.subarray(we*Ge/Ie.data.BYTES_PER_ELEMENT,(we+1)*Ge/Ie.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,we,Ie.width,Ie.height,1,He,ht,at)}P.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Ie.width,Ie.height,Ie.depth,He,ht,Ie.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Q,Ie.width,Ie.height,Ie.depth,0,He,ht,Ie.data);else if(P.isData3DTexture)q?(ke&&t.texStorage3D(n.TEXTURE_3D,We,Q,Ie.width,Ie.height,Ie.depth),me&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Ie.width,Ie.height,Ie.depth,He,ht,Ie.data)):t.texImage3D(n.TEXTURE_3D,0,Q,Ie.width,Ie.height,Ie.depth,0,He,ht,Ie.data);else if(P.isFramebufferTexture){if(ke)if(q)t.texStorage2D(n.TEXTURE_2D,We,Q,Ie.width,Ie.height);else{let Ge=Ie.width,we=Ie.height;for(let at=0;at<We;at++)t.texImage2D(n.TEXTURE_2D,at,Q,Ge,we,0,He,ht,null),Ge>>=1,we>>=1}}else if(Oe.length>0){if(q&&ke){const Ge=ct(Oe[0]);t.texStorage2D(n.TEXTURE_2D,We,Q,Ge.width,Ge.height)}for(let Ge=0,we=Oe.length;Ge<we;Ge++)pe=Oe[Ge],q?me&&t.texSubImage2D(n.TEXTURE_2D,Ge,0,0,He,ht,pe):t.texImage2D(n.TEXTURE_2D,Ge,Q,He,ht,pe);P.generateMipmaps=!1}else if(q){if(ke){const Ge=ct(Ie);t.texStorage2D(n.TEXTURE_2D,We,Q,Ge.width,Ge.height)}me&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,He,ht,Ie)}else t.texImage2D(n.TEXTURE_2D,0,Q,He,ht,Ie);y(P)&&v(Ee),vt.__version=ye.version,P.onUpdate&&P.onUpdate(P)}k.__version=P.version}function Ae(k,P,ce){if(P.image.length!==6)return;const Ee=nt(k,P),Le=P.source;t.bindTexture(n.TEXTURE_CUBE_MAP,k.__webglTexture,n.TEXTURE0+ce);const ye=i.get(Le);if(Le.version!==ye.__version||Ee===!0){t.activeTexture(n.TEXTURE0+ce);const vt=en.getPrimaries(en.workingColorSpace),je=P.colorSpace===Or?null:en.getPrimaries(P.colorSpace),xt=P.colorSpace===Or||vt===je?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,P.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,P.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,xt);const pt=P.isCompressedTexture||P.image[0].isCompressedTexture,Ie=P.image[0]&&P.image[0].isDataTexture,He=[];for(let we=0;we<6;we++)!pt&&!Ie?He[we]=T(P.image[we],!0,r.maxCubemapSize):He[we]=Ie?P.image[we].image:P.image[we],He[we]=Je(P,He[we]);const ht=He[0],Q=a.convert(P.format,P.colorSpace),pe=a.convert(P.type),Oe=E(P.internalFormat,Q,pe,P.colorSpace),q=P.isVideoTexture!==!0,ke=ye.__version===void 0||Ee===!0,me=Le.dataReady;let We=N(P,ht);Xe(n.TEXTURE_CUBE_MAP,P);let Ge;if(pt){q&&ke&&t.texStorage2D(n.TEXTURE_CUBE_MAP,We,Oe,ht.width,ht.height);for(let we=0;we<6;we++){Ge=He[we].mipmaps;for(let at=0;at<Ge.length;at++){const St=Ge[at];P.format!==$n?Q!==null?q?me&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,at,0,0,St.width,St.height,Q,St.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,at,Oe,St.width,St.height,0,St.data):ut("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,at,0,0,St.width,St.height,Q,pe,St.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,at,Oe,St.width,St.height,0,Q,pe,St.data)}}}else{if(Ge=P.mipmaps,q&&ke){Ge.length>0&&We++;const we=ct(He[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,We,Oe,we.width,we.height)}for(let we=0;we<6;we++)if(Ie){q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,He[we].width,He[we].height,Q,pe,He[we].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,Oe,He[we].width,He[we].height,0,Q,pe,He[we].data);for(let at=0;at<Ge.length;at++){const Gt=Ge[at].image[we].image;q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,at+1,0,0,Gt.width,Gt.height,Q,pe,Gt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,at+1,Oe,Gt.width,Gt.height,0,Q,pe,Gt.data)}}else{q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,Q,pe,He[we]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,Oe,Q,pe,He[we]);for(let at=0;at<Ge.length;at++){const St=Ge[at];q?me&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,at+1,0,0,Q,pe,St.image[we]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+we,at+1,Oe,Q,pe,St.image[we])}}}y(P)&&v(n.TEXTURE_CUBE_MAP),ye.__version=Le.version,P.onUpdate&&P.onUpdate(P)}k.__version=P.version}function Ze(k,P,ce,Ee,Le,ye){const vt=a.convert(ce.format,ce.colorSpace),je=a.convert(ce.type),xt=E(ce.internalFormat,vt,je,ce.colorSpace),pt=i.get(P),Ie=i.get(ce);if(Ie.__renderTarget=P,!pt.__hasExternalTextures){const He=Math.max(1,P.width>>ye),ht=Math.max(1,P.height>>ye);Le===n.TEXTURE_3D||Le===n.TEXTURE_2D_ARRAY?t.texImage3D(Le,ye,xt,He,ht,P.depth,0,vt,je,null):t.texImage2D(Le,ye,xt,He,ht,0,vt,je,null)}t.bindFramebuffer(n.FRAMEBUFFER,k),Be(P)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ee,Le,Ie.__webglTexture,0,Fe(P)):(Le===n.TEXTURE_2D||Le>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Le<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Ee,Le,Ie.__webglTexture,ye),t.bindFramebuffer(n.FRAMEBUFFER,null)}function ue(k,P,ce){if(n.bindRenderbuffer(n.RENDERBUFFER,k),P.depthBuffer){const Ee=P.depthTexture,Le=Ee&&Ee.isDepthTexture?Ee.type:null,ye=b(P.stencilBuffer,Le),vt=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,je=Fe(P);Be(P)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,je,ye,P.width,P.height):ce?n.renderbufferStorageMultisample(n.RENDERBUFFER,je,ye,P.width,P.height):n.renderbufferStorage(n.RENDERBUFFER,ye,P.width,P.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,vt,n.RENDERBUFFER,k)}else{const Ee=P.textures;for(let Le=0;Le<Ee.length;Le++){const ye=Ee[Le],vt=a.convert(ye.format,ye.colorSpace),je=a.convert(ye.type),xt=E(ye.internalFormat,vt,je,ye.colorSpace),pt=Fe(P);ce&&Be(P)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,pt,xt,P.width,P.height):Be(P)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,pt,xt,P.width,P.height):n.renderbufferStorage(n.RENDERBUFFER,xt,P.width,P.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function it(k,P){if(P&&P.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,k),!(P.depthTexture&&P.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Ee=i.get(P.depthTexture);Ee.__renderTarget=P,(!Ee.__webglTexture||P.depthTexture.image.width!==P.width||P.depthTexture.image.height!==P.height)&&(P.depthTexture.image.width=P.width,P.depthTexture.image.height=P.height,P.depthTexture.needsUpdate=!0),ae(P.depthTexture,0);const Le=Ee.__webglTexture,ye=Fe(P);if(P.depthTexture.format===Ed)Be(P)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Le,0,ye):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Le,0);else if(P.depthTexture.format===Qu)Be(P)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Le,0,ye):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Le,0);else throw new Error("Unknown depthTexture format")}function bt(k){const P=i.get(k),ce=k.isWebGLCubeRenderTarget===!0;if(P.__boundDepthTexture!==k.depthTexture){const Ee=k.depthTexture;if(P.__depthDisposeCallback&&P.__depthDisposeCallback(),Ee){const Le=()=>{delete P.__boundDepthTexture,delete P.__depthDisposeCallback,Ee.removeEventListener("dispose",Le)};Ee.addEventListener("dispose",Le),P.__depthDisposeCallback=Le}P.__boundDepthTexture=Ee}if(k.depthTexture&&!P.__autoAllocateDepthBuffer){if(ce)throw new Error("target.depthTexture not supported in Cube render targets");const Ee=k.texture.mipmaps;Ee&&Ee.length>0?it(P.__webglFramebuffer[0],k):it(P.__webglFramebuffer,k)}else if(ce){P.__webglDepthbuffer=[];for(let Ee=0;Ee<6;Ee++)if(t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer[Ee]),P.__webglDepthbuffer[Ee]===void 0)P.__webglDepthbuffer[Ee]=n.createRenderbuffer(),ue(P.__webglDepthbuffer[Ee],k,!1);else{const Le=k.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ye=P.__webglDepthbuffer[Ee];n.bindRenderbuffer(n.RENDERBUFFER,ye),n.framebufferRenderbuffer(n.FRAMEBUFFER,Le,n.RENDERBUFFER,ye)}}else{const Ee=k.texture.mipmaps;if(Ee&&Ee.length>0?t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer),P.__webglDepthbuffer===void 0)P.__webglDepthbuffer=n.createRenderbuffer(),ue(P.__webglDepthbuffer,k,!1);else{const Le=k.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ye=P.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,ye),n.framebufferRenderbuffer(n.FRAMEBUFFER,Le,n.RENDERBUFFER,ye)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function ot(k,P,ce){const Ee=i.get(k);P!==void 0&&Ze(Ee.__webglFramebuffer,k,k.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ce!==void 0&&bt(k)}function Ke(k){const P=k.texture,ce=i.get(k),Ee=i.get(P);k.addEventListener("dispose",I);const Le=k.textures,ye=k.isWebGLCubeRenderTarget===!0,vt=Le.length>1;if(vt||(Ee.__webglTexture===void 0&&(Ee.__webglTexture=n.createTexture()),Ee.__version=P.version,s.memory.textures++),ye){ce.__webglFramebuffer=[];for(let je=0;je<6;je++)if(P.mipmaps&&P.mipmaps.length>0){ce.__webglFramebuffer[je]=[];for(let xt=0;xt<P.mipmaps.length;xt++)ce.__webglFramebuffer[je][xt]=n.createFramebuffer()}else ce.__webglFramebuffer[je]=n.createFramebuffer()}else{if(P.mipmaps&&P.mipmaps.length>0){ce.__webglFramebuffer=[];for(let je=0;je<P.mipmaps.length;je++)ce.__webglFramebuffer[je]=n.createFramebuffer()}else ce.__webglFramebuffer=n.createFramebuffer();if(vt)for(let je=0,xt=Le.length;je<xt;je++){const pt=i.get(Le[je]);pt.__webglTexture===void 0&&(pt.__webglTexture=n.createTexture(),s.memory.textures++)}if(k.samples>0&&Be(k)===!1){ce.__webglMultisampledFramebuffer=n.createFramebuffer(),ce.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ce.__webglMultisampledFramebuffer);for(let je=0;je<Le.length;je++){const xt=Le[je];ce.__webglColorRenderbuffer[je]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,ce.__webglColorRenderbuffer[je]);const pt=a.convert(xt.format,xt.colorSpace),Ie=a.convert(xt.type),He=E(xt.internalFormat,pt,Ie,xt.colorSpace,k.isXRRenderTarget===!0),ht=Fe(k);n.renderbufferStorageMultisample(n.RENDERBUFFER,ht,He,k.width,k.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+je,n.RENDERBUFFER,ce.__webglColorRenderbuffer[je])}n.bindRenderbuffer(n.RENDERBUFFER,null),k.depthBuffer&&(ce.__webglDepthRenderbuffer=n.createRenderbuffer(),ue(ce.__webglDepthRenderbuffer,k,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(ye){t.bindTexture(n.TEXTURE_CUBE_MAP,Ee.__webglTexture),Xe(n.TEXTURE_CUBE_MAP,P);for(let je=0;je<6;je++)if(P.mipmaps&&P.mipmaps.length>0)for(let xt=0;xt<P.mipmaps.length;xt++)Ze(ce.__webglFramebuffer[je][xt],k,P,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+je,xt);else Ze(ce.__webglFramebuffer[je],k,P,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+je,0);y(P)&&v(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(vt){for(let je=0,xt=Le.length;je<xt;je++){const pt=Le[je],Ie=i.get(pt);let He=n.TEXTURE_2D;(k.isWebGL3DRenderTarget||k.isWebGLArrayRenderTarget)&&(He=k.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(He,Ie.__webglTexture),Xe(He,pt),Ze(ce.__webglFramebuffer,k,pt,n.COLOR_ATTACHMENT0+je,He,0),y(pt)&&v(He)}t.unbindTexture()}else{let je=n.TEXTURE_2D;if((k.isWebGL3DRenderTarget||k.isWebGLArrayRenderTarget)&&(je=k.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(je,Ee.__webglTexture),Xe(je,P),P.mipmaps&&P.mipmaps.length>0)for(let xt=0;xt<P.mipmaps.length;xt++)Ze(ce.__webglFramebuffer[xt],k,P,n.COLOR_ATTACHMENT0,je,xt);else Ze(ce.__webglFramebuffer,k,P,n.COLOR_ATTACHMENT0,je,0);y(P)&&v(je),t.unbindTexture()}k.depthBuffer&&bt(k)}function Te(k){const P=k.textures;for(let ce=0,Ee=P.length;ce<Ee;ce++){const Le=P[ce];if(y(Le)){const ye=S(k),vt=i.get(Le).__webglTexture;t.bindTexture(ye,vt),v(ye),t.unbindTexture()}}}const G=[],be=[];function Ne(k){if(k.samples>0){if(Be(k)===!1){const P=k.textures,ce=k.width,Ee=k.height;let Le=n.COLOR_BUFFER_BIT;const ye=k.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,vt=i.get(k),je=P.length>1;if(je)for(let pt=0;pt<P.length;pt++)t.bindFramebuffer(n.FRAMEBUFFER,vt.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+pt,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,vt.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+pt,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,vt.__webglMultisampledFramebuffer);const xt=k.texture.mipmaps;xt&&xt.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,vt.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,vt.__webglFramebuffer);for(let pt=0;pt<P.length;pt++){if(k.resolveDepthBuffer&&(k.depthBuffer&&(Le|=n.DEPTH_BUFFER_BIT),k.stencilBuffer&&k.resolveStencilBuffer&&(Le|=n.STENCIL_BUFFER_BIT)),je){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,vt.__webglColorRenderbuffer[pt]);const Ie=i.get(P[pt]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Ie,0)}n.blitFramebuffer(0,0,ce,Ee,0,0,ce,Ee,Le,n.NEAREST),l===!0&&(G.length=0,be.length=0,G.push(n.COLOR_ATTACHMENT0+pt),k.depthBuffer&&k.resolveDepthBuffer===!1&&(G.push(ye),be.push(ye),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,be)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,G))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),je)for(let pt=0;pt<P.length;pt++){t.bindFramebuffer(n.FRAMEBUFFER,vt.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+pt,n.RENDERBUFFER,vt.__webglColorRenderbuffer[pt]);const Ie=i.get(P[pt]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,vt.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+pt,n.TEXTURE_2D,Ie,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,vt.__webglMultisampledFramebuffer)}else if(k.depthBuffer&&k.resolveDepthBuffer===!1&&l){const P=k.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[P])}}}function Fe(k){return Math.min(r.maxSamples,k.samples)}function Be(k){const P=i.get(k);return k.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&P.__useRenderToTexture!==!1}function $e(k){const P=s.render.frame;f.get(k)!==P&&(f.set(k,P),k.update())}function Je(k,P){const ce=k.colorSpace,Ee=k.format,Le=k.type;return k.isCompressedTexture===!0||k.isVideoTexture===!0||ce!==Fn&&ce!==Or&&(en.getTransfer(ce)===wn?(Ee!==$n||Le!==Pi)&&ut("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Bt("WebGLTextures: Unsupported texture color space:",ce)),P}function ct(k){return typeof HTMLImageElement<"u"&&k instanceof HTMLImageElement?(h.width=k.naturalWidth||k.width,h.height=k.naturalHeight||k.height):typeof VideoFrame<"u"&&k instanceof VideoFrame?(h.width=k.displayWidth,h.height=k.displayHeight):(h.width=k.width,h.height=k.height),h}this.allocateTextureUnit=ee,this.resetTextureUnits=j,this.setTexture2D=ae,this.setTexture2DArray=W,this.setTexture3D=te,this.setTextureCube=K,this.rebindTextures=ot,this.setupRenderTarget=Ke,this.updateRenderTargetMipmap=Te,this.updateMultisampleRenderTarget=Ne,this.setupDepthRenderbuffer=bt,this.setupFrameBufferTexture=Ze,this.useMultisampledRTT=Be}function K6(n,e){function t(i,r=Or){let a;const s=en.getTransfer(r);if(i===Pi)return n.UNSIGNED_BYTE;if(i===H1)return n.UNSIGNED_SHORT_4_4_4_4;if(i===F1)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Sb)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Tb)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===z1)return n.BYTE;if(i===B1)return n.SHORT;if(i===Zu)return n.UNSIGNED_SHORT;if(i===H0)return n.INT;if(i===Os)return n.UNSIGNED_INT;if(i===si)return n.FLOAT;if(i===Yn)return n.HALF_FLOAT;if(i===Eb)return n.ALPHA;if(i===Mb)return n.RGB;if(i===$n)return n.RGBA;if(i===Ed)return n.DEPTH_COMPONENT;if(i===Qu)return n.DEPTH_STENCIL;if(i===ws)return n.RED;if(i===F0)return n.RED_INTEGER;if(i===Xo)return n.RG;if(i===G1)return n.RG_INTEGER;if(i===V1)return n.RGBA_INTEGER;if(i===zm||i===Bm||i===Hm||i===Fm)if(s===wn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===zm)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Bm)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Hm)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Fm)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===zm)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Bm)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Hm)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Fm)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===mx||i===gx||i===vx||i===_x)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===mx)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===gx)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===vx)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===_x)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===xx||i===yx||i===Sx)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===xx||i===yx)return s===wn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===Sx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===Tx||i===Ex||i===Mx||i===bx||i===Ax||i===wx||i===Rx||i===Cx||i===Dx||i===Nx||i===Ox||i===Lx||i===Ix||i===Ux)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===Tx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Ex)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Mx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===bx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Ax)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===wx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Rx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Cx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Dx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Nx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Ox)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Lx)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Ix)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Ux)return s===wn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Px||i===zx||i===Bx)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===Px)return s===wn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===zx)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Bx)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Hx||i===Fx||i===Gx||i===Vx)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===Hx)return a.COMPRESSED_RED_RGTC1_EXT;if(i===Fx)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Gx)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Vx)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Ku?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const _j=`
void main() {

	gl_Position = vec4( position, 1.0 );

}`,xj=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;

void main() {

	vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );

	if ( coord.x >= 1.0 ) {

		gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;

	} else {

		gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;

	}

}`;class yj{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Bb(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Vi({vertexShader:_j,fragmentShader:xj,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new oi(new dh(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Sj extends ra{constructor(e,t){super();const i=this;let r=null,a=1,s=null,o="local-floor",l=1,h=null,f=null,d=null,p=null,g=null,_=null;const T=typeof XRWebGLBinding<"u",y=new yj,v={},S=t.getContextAttributes();let E=null,b=null;const N=[],R=[],I=new de;let U=null;const O=new hi;O.viewport=new zt;const w=new hi;w.viewport=new zt;const B=[O,w],j=new z6;let ee=null,se=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ge){let Ae=N[ge];return Ae===void 0&&(Ae=new E_,N[ge]=Ae),Ae.getTargetRaySpace()},this.getControllerGrip=function(ge){let Ae=N[ge];return Ae===void 0&&(Ae=new E_,N[ge]=Ae),Ae.getGripSpace()},this.getHand=function(ge){let Ae=N[ge];return Ae===void 0&&(Ae=new E_,N[ge]=Ae),Ae.getHandSpace()};function ae(ge){const Ae=R.indexOf(ge.inputSource);if(Ae===-1)return;const Ze=N[Ae];Ze!==void 0&&(Ze.update(ge.inputSource,ge.frame,h||s),Ze.dispatchEvent({type:ge.type,data:ge.inputSource}))}function W(){r.removeEventListener("select",ae),r.removeEventListener("selectstart",ae),r.removeEventListener("selectend",ae),r.removeEventListener("squeeze",ae),r.removeEventListener("squeezestart",ae),r.removeEventListener("squeezeend",ae),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",te);for(let ge=0;ge<N.length;ge++){const Ae=R[ge];Ae!==null&&(R[ge]=null,N[ge].disconnect(Ae))}ee=null,se=null,y.reset();for(const ge in v)delete v[ge];e.setRenderTarget(E),g=null,p=null,d=null,r=null,b=null,gt.stop(),i.isPresenting=!1,e.setPixelRatio(U),e.setSize(I.width,I.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ge){a=ge,i.isPresenting===!0&&ut("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ge){o=ge,i.isPresenting===!0&&ut("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||s},this.setReferenceSpace=function(ge){h=ge},this.getBaseLayer=function(){return p!==null?p:g},this.getBinding=function(){return d===null&&T&&(d=new XRWebGLBinding(r,t)),d},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(ge){if(r=ge,r!==null){if(E=e.getRenderTarget(),r.addEventListener("select",ae),r.addEventListener("selectstart",ae),r.addEventListener("selectend",ae),r.addEventListener("squeeze",ae),r.addEventListener("squeezestart",ae),r.addEventListener("squeezeend",ae),r.addEventListener("end",W),r.addEventListener("inputsourceschange",te),S.xrCompatible!==!0&&await t.makeXRCompatible(),U=e.getPixelRatio(),e.getSize(I),T&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ze=null,ue=null,it=null;S.depth&&(it=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ze=S.stencil?Qu:Ed,ue=S.stencil?Ku:Os);const bt={colorFormat:t.RGBA8,depthFormat:it,scaleFactor:a};d=this.getBinding(),p=d.createProjectionLayer(bt),r.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),b=new xi(p.textureWidth,p.textureHeight,{format:$n,type:Pi,depthTexture:new V0(p.textureWidth,p.textureHeight,ue,void 0,void 0,void 0,void 0,void 0,void 0,Ze),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Ze={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};g=new XRWebGLLayer(r,t,Ze),r.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),b=new xi(g.framebufferWidth,g.framebufferHeight,{format:$n,type:Pi,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(l),h=null,s=await r.requestReferenceSpace(o),gt.setContext(r),gt.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function te(ge){for(let Ae=0;Ae<ge.removed.length;Ae++){const Ze=ge.removed[Ae],ue=R.indexOf(Ze);ue>=0&&(R[ue]=null,N[ue].disconnect(Ze))}for(let Ae=0;Ae<ge.added.length;Ae++){const Ze=ge.added[Ae];let ue=R.indexOf(Ze);if(ue===-1){for(let bt=0;bt<N.length;bt++)if(bt>=R.length){R.push(Ze),ue=bt;break}else if(R[bt]===null){R[bt]=Ze,ue=bt;break}if(ue===-1)break}const it=N[ue];it&&it.connect(Ze)}}const K=new L,oe=new L;function ie(ge,Ae,Ze){K.setFromMatrixPosition(Ae.matrixWorld),oe.setFromMatrixPosition(Ze.matrixWorld);const ue=K.distanceTo(oe),it=Ae.projectionMatrix.elements,bt=Ze.projectionMatrix.elements,ot=it[14]/(it[10]-1),Ke=it[14]/(it[10]+1),Te=(it[9]+1)/it[5],G=(it[9]-1)/it[5],be=(it[8]-1)/it[0],Ne=(bt[8]+1)/bt[0],Fe=ot*be,Be=ot*Ne,$e=ue/(-be+Ne),Je=$e*-be;if(Ae.matrixWorld.decompose(ge.position,ge.quaternion,ge.scale),ge.translateX(Je),ge.translateZ($e),ge.matrixWorld.compose(ge.position,ge.quaternion,ge.scale),ge.matrixWorldInverse.copy(ge.matrixWorld).invert(),it[10]===-1)ge.projectionMatrix.copy(Ae.projectionMatrix),ge.projectionMatrixInverse.copy(Ae.projectionMatrixInverse);else{const ct=ot+$e,k=Ke+$e,P=Fe-Je,ce=Be+(ue-Je),Ee=Te*Ke/k*ct,Le=G*Ke/k*ct;ge.projectionMatrix.makePerspective(P,ce,Ee,Le,ct,k),ge.projectionMatrixInverse.copy(ge.projectionMatrix).invert()}}function Ce(ge,Ae){Ae===null?ge.matrixWorld.copy(ge.matrix):ge.matrixWorld.multiplyMatrices(Ae.matrixWorld,ge.matrix),ge.matrixWorldInverse.copy(ge.matrixWorld).invert()}this.updateCamera=function(ge){if(r===null)return;let Ae=ge.near,Ze=ge.far;y.texture!==null&&(y.depthNear>0&&(Ae=y.depthNear),y.depthFar>0&&(Ze=y.depthFar)),j.near=w.near=O.near=Ae,j.far=w.far=O.far=Ze,(ee!==j.near||se!==j.far)&&(r.updateRenderState({depthNear:j.near,depthFar:j.far}),ee=j.near,se=j.far),j.layers.mask=ge.layers.mask|6,O.layers.mask=j.layers.mask&3,w.layers.mask=j.layers.mask&5;const ue=ge.parent,it=j.cameras;Ce(j,ue);for(let bt=0;bt<it.length;bt++)Ce(it[bt],ue);it.length===2?ie(j,O,w):j.projectionMatrix.copy(O.projectionMatrix),Xe(ge,j,ue)};function Xe(ge,Ae,Ze){Ze===null?ge.matrix.copy(Ae.matrixWorld):(ge.matrix.copy(Ze.matrixWorld),ge.matrix.invert(),ge.matrix.multiply(Ae.matrixWorld)),ge.matrix.decompose(ge.position,ge.quaternion,ge.scale),ge.updateMatrixWorld(!0),ge.projectionMatrix.copy(Ae.projectionMatrix),ge.projectionMatrixInverse.copy(Ae.projectionMatrixInverse),ge.isPerspectiveCamera&&(ge.fov=Rd*2*Math.atan(1/ge.projectionMatrix.elements[5]),ge.zoom=1)}this.getCamera=function(){return j},this.getFoveation=function(){if(!(p===null&&g===null))return l},this.setFoveation=function(ge){l=ge,p!==null&&(p.fixedFoveation=ge),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=ge)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(j)},this.getCameraTexture=function(ge){return v[ge]};let nt=null;function tt(ge,Ae){if(f=Ae.getViewerPose(h||s),_=Ae,f!==null){const Ze=f.views;g!==null&&(e.setRenderTargetFramebuffer(b,g.framebuffer),e.setRenderTarget(b));let ue=!1;Ze.length!==j.cameras.length&&(j.cameras.length=0,ue=!0);for(let Ke=0;Ke<Ze.length;Ke++){const Te=Ze[Ke];let G=null;if(g!==null)G=g.getViewport(Te);else{const Ne=d.getViewSubImage(p,Te);G=Ne.viewport,Ke===0&&(e.setRenderTargetTextures(b,Ne.colorTexture,Ne.depthStencilTexture),e.setRenderTarget(b))}let be=B[Ke];be===void 0&&(be=new hi,be.layers.enable(Ke),be.viewport=new zt,B[Ke]=be),be.matrix.fromArray(Te.transform.matrix),be.matrix.decompose(be.position,be.quaternion,be.scale),be.projectionMatrix.fromArray(Te.projectionMatrix),be.projectionMatrixInverse.copy(be.projectionMatrix).invert(),be.viewport.set(G.x,G.y,G.width,G.height),Ke===0&&(j.matrix.copy(be.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale)),ue===!0&&j.cameras.push(be)}const it=r.enabledFeatures;if(it&&it.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&T){d=i.getBinding();const Ke=d.getDepthInformation(Ze[0]);Ke&&Ke.isValid&&Ke.texture&&y.init(Ke,r.renderState)}if(it&&it.includes("camera-access")&&T){e.state.unbindTexture(),d=i.getBinding();for(let Ke=0;Ke<Ze.length;Ke++){const Te=Ze[Ke].camera;if(Te){let G=v[Te];G||(G=new Bb,v[Te]=G);const be=d.getCameraImage(Te);G.sourceTexture=be}}}}for(let Ze=0;Ze<N.length;Ze++){const ue=R[Ze],it=N[Ze];ue!==null&&it!==void 0&&it.update(ue,Ae,h||s)}nt&&nt(ge,Ae),Ae.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:Ae}),_=null}const gt=new X6;gt.setAnimationLoop(tt),this.setAnimationLoop=function(ge){nt=ge},this.dispose=function(){}}}const cu=new zi,Tj=new Ve;function Ej(n,e){function t(y,v){y.matrixAutoUpdate===!0&&y.updateMatrix(),v.value.copy(y.matrix)}function i(y,v){v.color.getRGB(y.fogColor.value,QU(n)),v.isFog?(y.fogNear.value=v.near,y.fogFar.value=v.far):v.isFogExp2&&(y.fogDensity.value=v.density)}function r(y,v,S,E,b){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(y,v):v.isMeshToonMaterial?(a(y,v),d(y,v)):v.isMeshPhongMaterial?(a(y,v),f(y,v)):v.isMeshStandardMaterial?(a(y,v),p(y,v),v.isMeshPhysicalMaterial&&g(y,v,b)):v.isMeshMatcapMaterial?(a(y,v),_(y,v)):v.isMeshDepthMaterial?a(y,v):v.isMeshDistanceMaterial?(a(y,v),T(y,v)):v.isMeshNormalMaterial?a(y,v):v.isLineBasicMaterial?(s(y,v),v.isLineDashedMaterial&&o(y,v)):v.isPointsMaterial?l(y,v,S,E):v.isSpriteMaterial?h(y,v):v.isShadowMaterial?(y.color.value.copy(v.color),y.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(y,v){y.opacity.value=v.opacity,v.color&&y.diffuse.value.copy(v.color),v.emissive&&y.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(y.map.value=v.map,t(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,t(v.alphaMap,y.alphaMapTransform)),v.bumpMap&&(y.bumpMap.value=v.bumpMap,t(v.bumpMap,y.bumpMapTransform),y.bumpScale.value=v.bumpScale,v.side===Ii&&(y.bumpScale.value*=-1)),v.normalMap&&(y.normalMap.value=v.normalMap,t(v.normalMap,y.normalMapTransform),y.normalScale.value.copy(v.normalScale),v.side===Ii&&y.normalScale.value.negate()),v.displacementMap&&(y.displacementMap.value=v.displacementMap,t(v.displacementMap,y.displacementMapTransform),y.displacementScale.value=v.displacementScale,y.displacementBias.value=v.displacementBias),v.emissiveMap&&(y.emissiveMap.value=v.emissiveMap,t(v.emissiveMap,y.emissiveMapTransform)),v.specularMap&&(y.specularMap.value=v.specularMap,t(v.specularMap,y.specularMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest);const S=e.get(v),E=S.envMap,b=S.envMapRotation;E&&(y.envMap.value=E,cu.copy(b),cu.x*=-1,cu.y*=-1,cu.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(cu.y*=-1,cu.z*=-1),y.envMapRotation.value.setFromMatrix4(Tj.makeRotationFromEuler(cu)),y.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=v.reflectivity,y.ior.value=v.ior,y.refractionRatio.value=v.refractionRatio),v.lightMap&&(y.lightMap.value=v.lightMap,y.lightMapIntensity.value=v.lightMapIntensity,t(v.lightMap,y.lightMapTransform)),v.aoMap&&(y.aoMap.value=v.aoMap,y.aoMapIntensity.value=v.aoMapIntensity,t(v.aoMap,y.aoMapTransform))}function s(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,v.map&&(y.map.value=v.map,t(v.map,y.mapTransform))}function o(y,v){y.dashSize.value=v.dashSize,y.totalSize.value=v.dashSize+v.gapSize,y.scale.value=v.scale}function l(y,v,S,E){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.size.value=v.size*S,y.scale.value=E*.5,v.map&&(y.map.value=v.map,t(v.map,y.uvTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,t(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function h(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.rotation.value=v.rotation,v.map&&(y.map.value=v.map,t(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,t(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function f(y,v){y.specular.value.copy(v.specular),y.shininess.value=Math.max(v.shininess,1e-4)}function d(y,v){v.gradientMap&&(y.gradientMap.value=v.gradientMap)}function p(y,v){y.metalness.value=v.metalness,v.metalnessMap&&(y.metalnessMap.value=v.metalnessMap,t(v.metalnessMap,y.metalnessMapTransform)),y.roughness.value=v.roughness,v.roughnessMap&&(y.roughnessMap.value=v.roughnessMap,t(v.roughnessMap,y.roughnessMapTransform)),v.envMap&&(y.envMapIntensity.value=v.envMapIntensity)}function g(y,v,S){y.ior.value=v.ior,v.sheen>0&&(y.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),y.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(y.sheenColorMap.value=v.sheenColorMap,t(v.sheenColorMap,y.sheenColorMapTransform)),v.sheenRoughnessMap&&(y.sheenRoughnessMap.value=v.sheenRoughnessMap,t(v.sheenRoughnessMap,y.sheenRoughnessMapTransform))),v.clearcoat>0&&(y.clearcoat.value=v.clearcoat,y.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(y.clearcoatMap.value=v.clearcoatMap,t(v.clearcoatMap,y.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,t(v.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(y.clearcoatNormalMap.value=v.clearcoatNormalMap,t(v.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Ii&&y.clearcoatNormalScale.value.negate())),v.dispersion>0&&(y.dispersion.value=v.dispersion),v.iridescence>0&&(y.iridescence.value=v.iridescence,y.iridescenceIOR.value=v.iridescenceIOR,y.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(y.iridescenceMap.value=v.iridescenceMap,t(v.iridescenceMap,y.iridescenceMapTransform)),v.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=v.iridescenceThicknessMap,t(v.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),v.transmission>0&&(y.transmission.value=v.transmission,y.transmissionSamplerMap.value=S.texture,y.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(y.transmissionMap.value=v.transmissionMap,t(v.transmissionMap,y.transmissionMapTransform)),y.thickness.value=v.thickness,v.thicknessMap&&(y.thicknessMap.value=v.thicknessMap,t(v.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=v.attenuationDistance,y.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(y.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(y.anisotropyMap.value=v.anisotropyMap,t(v.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=v.specularIntensity,y.specularColor.value.copy(v.specularColor),v.specularColorMap&&(y.specularColorMap.value=v.specularColorMap,t(v.specularColorMap,y.specularColorMapTransform)),v.specularIntensityMap&&(y.specularIntensityMap.value=v.specularIntensityMap,t(v.specularIntensityMap,y.specularIntensityMapTransform))}function _(y,v){v.matcap&&(y.matcap.value=v.matcap)}function T(y,v){const S=e.get(v).light;y.referencePosition.value.setFromMatrixPosition(S.matrixWorld),y.nearDistance.value=S.shadow.camera.near,y.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Mj(n,e,t,i){let r={},a={},s=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,E){const b=E.program;i.uniformBlockBinding(S,b)}function h(S,E){let b=r[S.id];b===void 0&&(_(S),b=f(S),r[S.id]=b,S.addEventListener("dispose",y));const N=E.program;i.updateUBOMapping(S,N);const R=e.render.frame;a[S.id]!==R&&(p(S),a[S.id]=R)}function f(S){const E=d();S.__bindingPointIndex=E;const b=n.createBuffer(),N=S.__size,R=S.usage;return n.bindBuffer(n.UNIFORM_BUFFER,b),n.bufferData(n.UNIFORM_BUFFER,N,R),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,E,b),b}function d(){for(let S=0;S<o;S++)if(s.indexOf(S)===-1)return s.push(S),S;return Bt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(S){const E=r[S.id],b=S.uniforms,N=S.__cache;n.bindBuffer(n.UNIFORM_BUFFER,E);for(let R=0,I=b.length;R<I;R++){const U=Array.isArray(b[R])?b[R]:[b[R]];for(let O=0,w=U.length;O<w;O++){const B=U[O];if(g(B,R,O,N)===!0){const j=B.__offset,ee=Array.isArray(B.value)?B.value:[B.value];let se=0;for(let ae=0;ae<ee.length;ae++){const W=ee[ae],te=T(W);typeof W=="number"||typeof W=="boolean"?(B.__data[0]=W,n.bufferSubData(n.UNIFORM_BUFFER,j+se,B.__data)):W.isMatrix3?(B.__data[0]=W.elements[0],B.__data[1]=W.elements[1],B.__data[2]=W.elements[2],B.__data[3]=0,B.__data[4]=W.elements[3],B.__data[5]=W.elements[4],B.__data[6]=W.elements[5],B.__data[7]=0,B.__data[8]=W.elements[6],B.__data[9]=W.elements[7],B.__data[10]=W.elements[8],B.__data[11]=0):(W.toArray(B.__data,se),se+=te.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,j,B.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function g(S,E,b,N){const R=S.value,I=E+"_"+b;if(N[I]===void 0)return typeof R=="number"||typeof R=="boolean"?N[I]=R:N[I]=R.clone(),!0;{const U=N[I];if(typeof R=="number"||typeof R=="boolean"){if(U!==R)return N[I]=R,!0}else if(U.equals(R)===!1)return U.copy(R),!0}return!1}function _(S){const E=S.uniforms;let b=0;const N=16;for(let I=0,U=E.length;I<U;I++){const O=Array.isArray(E[I])?E[I]:[E[I]];for(let w=0,B=O.length;w<B;w++){const j=O[w],ee=Array.isArray(j.value)?j.value:[j.value];for(let se=0,ae=ee.length;se<ae;se++){const W=ee[se],te=T(W),K=b%N,oe=K%te.boundary,ie=K+oe;b+=oe,ie!==0&&N-ie<te.storage&&(b+=N-ie),j.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=b,b+=te.storage}}}const R=b%N;return R>0&&(b+=N-R),S.__size=b,S.__cache={},this}function T(S){const E={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(E.boundary=4,E.storage=4):S.isVector2?(E.boundary=8,E.storage=8):S.isVector3||S.isColor?(E.boundary=16,E.storage=12):S.isVector4?(E.boundary=16,E.storage=16):S.isMatrix3?(E.boundary=48,E.storage=48):S.isMatrix4?(E.boundary=64,E.storage=64):S.isTexture?ut("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ut("WebGLRenderer: Unsupported uniform value type.",S),E}function y(S){const E=S.target;E.removeEventListener("dispose",y);const b=s.indexOf(E.__bindingPointIndex);s.splice(b,1),n.deleteBuffer(r[E.id]),delete r[E.id],delete a[E.id]}function v(){for(const S in r)n.deleteBuffer(r[S]);s=[],r={},a={}}return{bind:l,update:h,dispose:v}}const bj=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let Uo=null;function Aj(){return Uo===null&&(Uo=new ea(bj,32,32,Xo,Yn),Uo.minFilter=Ht,Uo.magFilter=Ht,Uo.wrapS=Ui,Uo.wrapT=Ui,Uo.generateMipmaps=!1,Uo.needsUpdate=!0),Uo}class lA{constructor(e={}){const{canvas:t=YU(),context:i=null,depth:r=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let g;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=i.getContextAttributes().alpha}else g=s;const _=new Set([V1,G1,F0]),T=new Set([Pi,Os,Zu,Ku,H1,F1]),y=new Uint32Array(4),v=new Int32Array(4);let S=null,E=null;const b=[],N=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=as,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const R=this;let I=!1;this._outputColorSpace=dn;let U=0,O=0,w=null,B=-1,j=null;const ee=new zt,se=new zt;let ae=null;const W=new qe(0);let te=0,K=t.width,oe=t.height,ie=1,Ce=null,Xe=null;const nt=new zt(0,0,K,oe),tt=new zt(0,0,K,oe);let gt=!1;const ge=new Kd;let Ae=!1,Ze=!1;const ue=new Ve,it=new L,bt=new zt,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ke=!1;function Te(){return w===null?ie:1}let G=i;function be(D,V){return t.getContext(D,V)}try{const D={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:h,powerPreference:f,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ds}`),t.addEventListener("webglcontextlost",Ge,!1),t.addEventListener("webglcontextrestored",we,!1),t.addEventListener("webglcontextcreationerror",at,!1),G===null){const V="webgl2";if(G=be(V,D),G===null)throw be(V)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(D){throw D("WebGLRenderer: "+D.message),D}let Ne,Fe,Be,$e,Je,ct,k,P,ce,Ee,Le,ye,vt,je,xt,pt,Ie,He,ht,Q,pe,Oe,q,ke;function me(){Ne=new PY(G),Ne.init(),Oe=new K6(G,Ne),Fe=new wY(G,Ne,e,Oe),Be=new gj(G,Ne),Fe.reversedDepthBuffer&&p&&Be.buffers.depth.setReversed(!0),$e=new HY(G),Je=new ij,ct=new vj(G,Ne,Be,Je,Fe,Oe,$e),k=new CY(R),P=new UY(R),ce=new kk(G),q=new bY(G,ce),Ee=new zY(G,ce,$e,q),Le=new GY(G,Ee,ce,$e),ht=new FY(G,Fe,ct),pt=new RY(Je),ye=new nj(R,k,P,Ne,Fe,q,pt),vt=new Ej(R,Je),je=new aj,xt=new hj(Ne),He=new MY(R,k,P,Be,Le,g,l),Ie=new pj(R,Le,Fe),ke=new Mj(G,$e,Fe,Be),Q=new AY(G,Ne,$e),pe=new BY(G,Ne,$e),$e.programs=ye.programs,R.capabilities=Fe,R.extensions=Ne,R.properties=Je,R.renderLists=je,R.shadowMap=Ie,R.state=Be,R.info=$e}me();const We=new Sj(R,G);this.xr=We,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){const D=Ne.get("WEBGL_lose_context");D&&D.loseContext()},this.forceContextRestore=function(){const D=Ne.get("WEBGL_lose_context");D&&D.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(D){D!==void 0&&(ie=D,this.setSize(K,oe,!1))},this.getSize=function(D){return D.set(K,oe)},this.setSize=function(D,V,Z=!0){if(We.isPresenting){ut("WebGLRenderer: Can't change size while VR device is presenting.");return}K=D,oe=V,t.width=Math.floor(D*ie),t.height=Math.floor(V*ie),Z===!0&&(t.style.width=D+"px",t.style.height=V+"px"),this.setViewport(0,0,D,V)},this.getDrawingBufferSize=function(D){return D.set(K*ie,oe*ie).floor()},this.setDrawingBufferSize=function(D,V,Z){K=D,oe=V,ie=Z,t.width=Math.floor(D*Z),t.height=Math.floor(V*Z),this.setViewport(0,0,D,V)},this.getCurrentViewport=function(D){return D.copy(ee)},this.getViewport=function(D){return D.copy(nt)},this.setViewport=function(D,V,Z,H){D.isVector4?nt.set(D.x,D.y,D.z,D.w):nt.set(D,V,Z,H),Be.viewport(ee.copy(nt).multiplyScalar(ie).round())},this.getScissor=function(D){return D.copy(tt)},this.setScissor=function(D,V,Z,H){D.isVector4?tt.set(D.x,D.y,D.z,D.w):tt.set(D,V,Z,H),Be.scissor(se.copy(tt).multiplyScalar(ie).round())},this.getScissorTest=function(){return gt},this.setScissorTest=function(D){Be.setScissorTest(gt=D)},this.setOpaqueSort=function(D){Ce=D},this.setTransparentSort=function(D){Xe=D},this.getClearColor=function(D){return D.copy(He.getClearColor())},this.setClearColor=function(){He.setClearColor(...arguments)},this.getClearAlpha=function(){return He.getClearAlpha()},this.setClearAlpha=function(){He.setClearAlpha(...arguments)},this.clear=function(D=!0,V=!0,Z=!0){let H=0;if(D){let X=!1;if(w!==null){const ne=w.texture.format;X=_.has(ne)}if(X){const ne=w.texture.type,re=T.has(ne),fe=He.getClearColor(),_e=He.getClearAlpha(),Se=fe.r,Re=fe.g,Pe=fe.b;re?(y[0]=Se,y[1]=Re,y[2]=Pe,y[3]=_e,G.clearBufferuiv(G.COLOR,0,y)):(v[0]=Se,v[1]=Re,v[2]=Pe,v[3]=_e,G.clearBufferiv(G.COLOR,0,v))}else H|=G.COLOR_BUFFER_BIT}V&&(H|=G.DEPTH_BUFFER_BIT),Z&&(H|=G.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G.clear(H)},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",Ge,!1),t.removeEventListener("webglcontextrestored",we,!1),t.removeEventListener("webglcontextcreationerror",at,!1),He.dispose(),je.dispose(),xt.dispose(),Je.dispose(),k.dispose(),P.dispose(),Le.dispose(),q.dispose(),ke.dispose(),ye.dispose(),We.dispose(),We.removeEventListener("sessionstart",Us),We.removeEventListener("sessionend",Ps),Mi.stop()};function Ge(D){D.preventDefault(),v0("WebGLRenderer: Context Lost."),I=!0}function we(){v0("WebGLRenderer: Context Restored."),I=!1;const D=$e.autoReset,V=Ie.enabled,Z=Ie.autoUpdate,H=Ie.needsUpdate,X=Ie.type;me(),$e.autoReset=D,Ie.enabled=V,Ie.autoUpdate=Z,Ie.needsUpdate=H,Ie.type=X}function at(D){Bt("WebGLRenderer: A WebGL context could not be created. Reason: ",D.statusMessage)}function St(D){const V=D.target;V.removeEventListener("dispose",St),Gt(V)}function Gt(D){Vt(D),Je.remove(D)}function Vt(D){const V=Je.get(D).programs;V!==void 0&&(V.forEach(function(Z){ye.releaseProgram(Z)}),D.isShaderMaterial&&ye.releaseShaderCache(D))}this.renderBufferDirect=function(D,V,Z,H,X,ne){V===null&&(V=ot);const re=X.isMesh&&X.matrixWorld.determinant()<0,fe=fo(D,V,Z,H,X);Be.setMaterial(H,re);let _e=Z.index,Se=1;if(H.wireframe===!0){if(_e=Ee.getWireframeAttribute(Z),_e===void 0)return;Se=2}const Re=Z.drawRange,Pe=Z.attributes.position;let ze=Re.start*Se,Ye=(Re.start+Re.count)*Se;ne!==null&&(ze=Math.max(ze,ne.start*Se),Ye=Math.min(Ye,(ne.start+ne.count)*Se)),_e!==null?(ze=Math.max(ze,0),Ye=Math.min(Ye,_e.count)):Pe!=null&&(ze=Math.max(ze,0),Ye=Math.min(Ye,Pe.count));const lt=Ye-ze;if(lt<0||lt===1/0)return;q.setup(X,H,fe,Z,_e);let Tt,At=Q;if(_e!==null&&(Tt=ce.get(_e),At=pe,At.setIndex(Tt)),X.isMesh)H.wireframe===!0?(Be.setLineWidth(H.wireframeLinewidth*Te()),At.setMode(G.LINES)):At.setMode(G.TRIANGLES);else if(X.isLine){let ft=H.linewidth;ft===void 0&&(ft=1),Be.setLineWidth(ft*Te()),X.isLineSegments?At.setMode(G.LINES):X.isLineLoop?At.setMode(G.LINE_LOOP):At.setMode(G.LINE_STRIP)}else X.isPoints?At.setMode(G.POINTS):X.isSprite&&At.setMode(G.TRIANGLES);if(X.isBatchedMesh)if(X._multiDrawInstances!==null)wd("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),At.renderMultiDrawInstances(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount,X._multiDrawInstances);else if(Ne.get("WEBGL_multi_draw"))At.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else{const ft=X._multiDrawStarts,wt=X._multiDrawCounts,st=X._multiDrawCount,Kt=_e?ce.get(_e).bytesPerElement:1,Ln=Je.get(H).currentProgram.getUniforms();for(let Yt=0;Yt<st;Yt++)Ln.setValue(G,"_gl_DrawID",Yt),At.render(ft[Yt]/Kt,wt[Yt])}else if(X.isInstancedMesh)At.renderInstances(ze,lt,X.count);else if(Z.isInstancedBufferGeometry){const ft=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,wt=Math.min(Z.instanceCount,ft);At.renderInstances(ze,lt,wt)}else At.render(ze,lt)};function li(D,V,Z){D.transparent===!0&&D.side===cr&&D.forceSinglePass===!1?(D.side=Ii,D.needsUpdate=!0,Ua(D,V,Z),D.side=Ns,D.needsUpdate=!0,Ua(D,V,Z),D.side=cr):Ua(D,V,Z)}this.compile=function(D,V,Z=null){Z===null&&(Z=D),E=xt.get(Z),E.init(V),N.push(E),Z.traverseVisible(function(X){X.isLight&&X.layers.test(V.layers)&&(E.pushLight(X),X.castShadow&&E.pushShadow(X))}),D!==Z&&D.traverseVisible(function(X){X.isLight&&X.layers.test(V.layers)&&(E.pushLight(X),X.castShadow&&E.pushShadow(X))}),E.setupLights();const H=new Set;return D.traverse(function(X){if(!(X.isMesh||X.isPoints||X.isLine||X.isSprite))return;const ne=X.material;if(ne)if(Array.isArray(ne))for(let re=0;re<ne.length;re++){const fe=ne[re];li(fe,Z,X),H.add(fe)}else li(ne,Z,X),H.add(ne)}),E=N.pop(),H},this.compileAsync=function(D,V,Z=null){const H=this.compile(D,V,Z);return new Promise(X=>{function ne(){if(H.forEach(function(re){Je.get(re).currentProgram.isReady()&&H.delete(re)}),H.size===0){X(D);return}setTimeout(ne,10)}Ne.get("KHR_parallel_shader_compile")!==null?ne():setTimeout(ne,10)})};let ci=null;function ho(D){ci&&ci(D)}function Us(){Mi.stop()}function Ps(){Mi.start()}const Mi=new X6;Mi.setAnimationLoop(ho),typeof self<"u"&&Mi.setContext(self),this.setAnimationLoop=function(D){ci=D,We.setAnimationLoop(D),D===null?Mi.stop():Mi.start()},We.addEventListener("sessionstart",Us),We.addEventListener("sessionend",Ps),this.render=function(D,V){if(V!==void 0&&V.isCamera!==!0){Bt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;if(D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),V.parent===null&&V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(We.cameraAutoUpdate===!0&&We.updateCamera(V),V=We.getCamera()),D.isScene===!0&&D.onBeforeRender(R,D,V,w),E=xt.get(D,N.length),E.init(V),N.push(E),ue.multiplyMatrices(V.projectionMatrix,V.matrixWorldInverse),ge.setFromProjectionMatrix(ue,wa,V.reversedDepth),Ze=this.localClippingEnabled,Ae=pt.init(this.clippingPlanes,Ze),S=je.get(D,b.length),S.init(),b.push(S),We.enabled===!0&&We.isPresenting===!0){const ne=R.xr.getDepthSensingMesh();ne!==null&&zs(ne,V,-1/0,R.sortObjects)}zs(D,V,0,R.sortObjects),S.finish(),R.sortObjects===!0&&S.sort(Ce,Xe),Ke=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,Ke&&He.addToRenderList(S,D),this.info.render.frame++,Ae===!0&&pt.beginShadows();const Z=E.state.shadowsArray;Ie.render(Z,D,V),Ae===!0&&pt.endShadows(),this.info.autoReset===!0&&this.info.reset();const H=S.opaque,X=S.transmissive;if(E.setupLights(),V.isArrayCamera){const ne=V.cameras;if(X.length>0)for(let re=0,fe=ne.length;re<fe;re++){const _e=ne[re];Xi(H,X,D,_e)}Ke&&He.render(D);for(let re=0,fe=ne.length;re<fe;re++){const _e=ne[re];fr(S,D,_e,_e.viewport)}}else X.length>0&&Xi(H,X,D,V),Ke&&He.render(D),fr(S,D,V);w!==null&&O===0&&(ct.updateMultisampleRenderTarget(w),ct.updateRenderTargetMipmap(w)),D.isScene===!0&&D.onAfterRender(R,D,V),q.resetDefaultState(),B=-1,j=null,N.pop(),N.length>0?(E=N[N.length-1],Ae===!0&&pt.setGlobalState(R.clippingPlanes,E.state.camera)):E=null,b.pop(),b.length>0?S=b[b.length-1]:S=null};function zs(D,V,Z,H){if(D.visible===!1)return;if(D.layers.test(V.layers)){if(D.isGroup)Z=D.renderOrder;else if(D.isLOD)D.autoUpdate===!0&&D.update(V);else if(D.isLight)E.pushLight(D),D.castShadow&&E.pushShadow(D);else if(D.isSprite){if(!D.frustumCulled||ge.intersectsSprite(D)){H&&bt.setFromMatrixPosition(D.matrixWorld).applyMatrix4(ue);const re=Le.update(D),fe=D.material;fe.visible&&S.push(D,re,fe,Z,bt.z,null)}}else if((D.isMesh||D.isLine||D.isPoints)&&(!D.frustumCulled||ge.intersectsObject(D))){const re=Le.update(D),fe=D.material;if(H&&(D.boundingSphere!==void 0?(D.boundingSphere===null&&D.computeBoundingSphere(),bt.copy(D.boundingSphere.center)):(re.boundingSphere===null&&re.computeBoundingSphere(),bt.copy(re.boundingSphere.center)),bt.applyMatrix4(D.matrixWorld).applyMatrix4(ue)),Array.isArray(fe)){const _e=re.groups;for(let Se=0,Re=_e.length;Se<Re;Se++){const Pe=_e[Se],ze=fe[Pe.materialIndex];ze&&ze.visible&&S.push(D,re,ze,Z,bt.z,Pe)}}else fe.visible&&S.push(D,re,fe,Z,bt.z,null)}}const ne=D.children;for(let re=0,fe=ne.length;re<fe;re++)zs(ne[re],V,Z,H)}function fr(D,V,Z,H){const{opaque:X,transmissive:ne,transparent:re}=D;E.setupLightsView(Z),Ae===!0&&pt.setGlobalState(R.clippingPlanes,Z),H&&Be.viewport(ee.copy(H)),X.length>0&&Gr(X,V,Z),ne.length>0&&Gr(ne,V,Z),re.length>0&&Gr(re,V,Z),Be.buffers.depth.setTest(!0),Be.buffers.depth.setMask(!0),Be.buffers.color.setMask(!0),Be.setPolygonOffset(!1)}function Xi(D,V,Z,H){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[H.id]===void 0&&(E.state.transmissionRenderTarget[H.id]=new xi(1,1,{generateMipmaps:!0,type:Ne.has("EXT_color_buffer_half_float")||Ne.has("EXT_color_buffer_float")?Yn:Pi,minFilter:Aa,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:en.workingColorSpace}));const ne=E.state.transmissionRenderTarget[H.id],re=H.viewport||ee;ne.setSize(re.z*R.transmissionResolutionScale,re.w*R.transmissionResolutionScale);const fe=R.getRenderTarget(),_e=R.getActiveCubeFace(),Se=R.getActiveMipmapLevel();R.setRenderTarget(ne),R.getClearColor(W),te=R.getClearAlpha(),te<1&&R.setClearColor(16777215,.5),R.clear(),Ke&&He.render(Z);const Re=R.toneMapping;R.toneMapping=as;const Pe=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),E.setupLightsView(H),Ae===!0&&pt.setGlobalState(R.clippingPlanes,H),Gr(D,Z,H),ct.updateMultisampleRenderTarget(ne),ct.updateRenderTargetMipmap(ne),Ne.has("WEBGL_multisampled_render_to_texture")===!1){let ze=!1;for(let Ye=0,lt=V.length;Ye<lt;Ye++){const Tt=V[Ye],{object:At,geometry:ft,material:wt,group:st}=Tt;if(wt.side===cr&&At.layers.test(H.layers)){const Kt=wt.side;wt.side=Ii,wt.needsUpdate=!0,On(At,Z,H,ft,wt,st),wt.side=Kt,wt.needsUpdate=!0,ze=!0}}ze===!0&&(ct.updateMultisampleRenderTarget(ne),ct.updateRenderTargetMipmap(ne))}R.setRenderTarget(fe,_e,Se),R.setClearColor(W,te),Pe!==void 0&&(H.viewport=Pe),R.toneMapping=Re}function Gr(D,V,Z){const H=V.isScene===!0?V.overrideMaterial:null;for(let X=0,ne=D.length;X<ne;X++){const re=D[X],{object:fe,geometry:_e,group:Se}=re;let Re=re.material;Re.allowOverride===!0&&H!==null&&(Re=H),fe.layers.test(Z.layers)&&On(fe,V,Z,_e,Re,Se)}}function On(D,V,Z,H,X,ne){D.onBeforeRender(R,V,Z,H,X,ne),D.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,D.matrixWorld),D.normalMatrix.getNormalMatrix(D.modelViewMatrix),X.onBeforeRender(R,V,Z,H,D,ne),X.transparent===!0&&X.side===cr&&X.forceSinglePass===!1?(X.side=Ii,X.needsUpdate=!0,R.renderBufferDirect(Z,V,H,X,D,ne),X.side=Ns,X.needsUpdate=!0,R.renderBufferDirect(Z,V,H,X,D,ne),X.side=cr):R.renderBufferDirect(Z,V,H,X,D,ne),D.onAfterRender(R,V,Z,H,X,ne)}function Ua(D,V,Z){V.isScene!==!0&&(V=ot);const H=Je.get(D),X=E.state.lights,ne=E.state.shadowsArray,re=X.state.version,fe=ye.getParameters(D,X.state,ne,V,Z),_e=ye.getProgramCacheKey(fe);let Se=H.programs;H.environment=D.isMeshStandardMaterial?V.environment:null,H.fog=V.fog,H.envMap=(D.isMeshStandardMaterial?P:k).get(D.envMap||H.environment),H.envMapRotation=H.environment!==null&&D.envMap===null?V.environmentRotation:D.envMapRotation,Se===void 0&&(D.addEventListener("dispose",St),Se=new Map,H.programs=Se);let Re=Se.get(_e);if(Re!==void 0){if(H.currentProgram===Re&&H.lightsStateVersion===re)return Hs(D,fe),Re}else fe.uniforms=ye.getUniforms(D),D.onBeforeCompile(fe,R),Re=ye.acquireProgram(fe,_e),Se.set(_e,Re),H.uniforms=fe.uniforms;const Pe=H.uniforms;return(!D.isShaderMaterial&&!D.isRawShaderMaterial||D.clipping===!0)&&(Pe.clippingPlanes=pt.uniform),Hs(D,fe),H.needsLights=dr(D),H.lightsStateVersion=re,H.needsLights&&(Pe.ambientLightColor.value=X.state.ambient,Pe.lightProbe.value=X.state.probe,Pe.directionalLights.value=X.state.directional,Pe.directionalLightShadows.value=X.state.directionalShadow,Pe.spotLights.value=X.state.spot,Pe.spotLightShadows.value=X.state.spotShadow,Pe.rectAreaLights.value=X.state.rectArea,Pe.ltc_1.value=X.state.rectAreaLTC1,Pe.ltc_2.value=X.state.rectAreaLTC2,Pe.pointLights.value=X.state.point,Pe.pointLightShadows.value=X.state.pointShadow,Pe.hemisphereLights.value=X.state.hemi,Pe.directionalShadowMap.value=X.state.directionalShadowMap,Pe.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Pe.spotShadowMap.value=X.state.spotShadowMap,Pe.spotLightMatrix.value=X.state.spotLightMatrix,Pe.spotLightMap.value=X.state.spotLightMap,Pe.pointShadowMap.value=X.state.pointShadowMap,Pe.pointShadowMatrix.value=X.state.pointShadowMatrix),H.currentProgram=Re,H.uniformsList=null,Re}function Bs(D){if(D.uniformsList===null){const V=D.currentProgram.getUniforms();D.uniformsList=M_.seqWithValue(V.seq,D.uniforms)}return D.uniformsList}function Hs(D,V){const Z=Je.get(D);Z.outputColorSpace=V.outputColorSpace,Z.batching=V.batching,Z.batchingColor=V.batchingColor,Z.instancing=V.instancing,Z.instancingColor=V.instancingColor,Z.instancingMorph=V.instancingMorph,Z.skinning=V.skinning,Z.morphTargets=V.morphTargets,Z.morphNormals=V.morphNormals,Z.morphColors=V.morphColors,Z.morphTargetsCount=V.morphTargetsCount,Z.numClippingPlanes=V.numClippingPlanes,Z.numIntersection=V.numClipIntersection,Z.vertexAlphas=V.vertexAlphas,Z.vertexTangents=V.vertexTangents,Z.toneMapping=V.toneMapping}function fo(D,V,Z,H,X){V.isScene!==!0&&(V=ot),ct.resetTextureUnits();const ne=V.fog,re=H.isMeshStandardMaterial?V.environment:null,fe=w===null?R.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:Fn,_e=(H.isMeshStandardMaterial?P:k).get(H.envMap||re),Se=H.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,Re=!!Z.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Pe=!!Z.morphAttributes.position,ze=!!Z.morphAttributes.normal,Ye=!!Z.morphAttributes.color;let lt=as;H.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(lt=R.toneMapping);const Tt=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,At=Tt!==void 0?Tt.length:0,ft=Je.get(H),wt=E.state.lights;if(Ae===!0&&(Ze===!0||D!==j)){const Mn=D===j&&H.id===B;pt.setState(H,D,Mn)}let st=!1;H.version===ft.__version?(ft.needsLights&&ft.lightsStateVersion!==wt.state.version||ft.outputColorSpace!==fe||X.isBatchedMesh&&ft.batching===!1||!X.isBatchedMesh&&ft.batching===!0||X.isBatchedMesh&&ft.batchingColor===!0&&X.colorTexture===null||X.isBatchedMesh&&ft.batchingColor===!1&&X.colorTexture!==null||X.isInstancedMesh&&ft.instancing===!1||!X.isInstancedMesh&&ft.instancing===!0||X.isSkinnedMesh&&ft.skinning===!1||!X.isSkinnedMesh&&ft.skinning===!0||X.isInstancedMesh&&ft.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&ft.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&ft.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&ft.instancingMorph===!1&&X.morphTexture!==null||ft.envMap!==_e||H.fog===!0&&ft.fog!==ne||ft.numClippingPlanes!==void 0&&(ft.numClippingPlanes!==pt.numPlanes||ft.numIntersection!==pt.numIntersection)||ft.vertexAlphas!==Se||ft.vertexTangents!==Re||ft.morphTargets!==Pe||ft.morphNormals!==ze||ft.morphColors!==Ye||ft.toneMapping!==lt||ft.morphTargetsCount!==At)&&(st=!0):(st=!0,ft.__version=H.version);let Kt=ft.currentProgram;st===!0&&(Kt=Ua(H,V,X));let Ln=!1,Yt=!1,kt=!1;const Dt=Kt.getUniforms(),Hn=ft.uniforms;if(Be.useProgram(Kt.program)&&(Ln=!0,Yt=!0,kt=!0),H.id!==B&&(B=H.id,Yt=!0),Ln||j!==D){Be.buffers.depth.getReversed()&&D.reversedDepth!==!0&&(D._reversedDepth=!0,D.updateProjectionMatrix()),Dt.setValue(G,"projectionMatrix",D.projectionMatrix),Dt.setValue(G,"viewMatrix",D.matrixWorldInverse);const kn=Dt.map.cameraPosition;kn!==void 0&&kn.setValue(G,it.setFromMatrixPosition(D.matrixWorld)),Fe.logarithmicDepthBuffer&&Dt.setValue(G,"logDepthBufFC",2/(Math.log(D.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Dt.setValue(G,"isOrthographic",D.isOrthographicCamera===!0),j!==D&&(j=D,Yt=!0,kt=!0)}if(X.isSkinnedMesh){Dt.setOptional(G,X,"bindMatrix"),Dt.setOptional(G,X,"bindMatrixInverse");const Mn=X.skeleton;Mn&&(Mn.boneTexture===null&&Mn.computeBoneTexture(),Dt.setValue(G,"boneTexture",Mn.boneTexture,ct))}X.isBatchedMesh&&(Dt.setOptional(G,X,"batchingTexture"),Dt.setValue(G,"batchingTexture",X._matricesTexture,ct),Dt.setOptional(G,X,"batchingIdTexture"),Dt.setValue(G,"batchingIdTexture",X._indirectTexture,ct),Dt.setOptional(G,X,"batchingColorTexture"),X._colorsTexture!==null&&Dt.setValue(G,"batchingColorTexture",X._colorsTexture,ct));const bi=Z.morphAttributes;if((bi.position!==void 0||bi.normal!==void 0||bi.color!==void 0)&&ht.update(X,Z,Kt),(Yt||ft.receiveShadow!==X.receiveShadow)&&(ft.receiveShadow=X.receiveShadow,Dt.setValue(G,"receiveShadow",X.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(Hn.envMap.value=_e,Hn.flipEnvMap.value=_e.isCubeTexture&&_e.isRenderTargetTexture===!1?-1:1),H.isMeshStandardMaterial&&H.envMap===null&&V.environment!==null&&(Hn.envMapIntensity.value=V.environmentIntensity),Hn.dfgLUT!==void 0&&(Hn.dfgLUT.value=Aj()),Yt&&(Dt.setValue(G,"toneMappingExposure",R.toneMappingExposure),ft.needsLights&&la(Hn,kt),ne&&H.fog===!0&&vt.refreshFogUniforms(Hn,ne),vt.refreshMaterialUniforms(Hn,H,ie,oe,E.state.transmissionRenderTarget[D.id]),M_.upload(G,Bs(ft),Hn,ct)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(M_.upload(G,Bs(ft),Hn,ct),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Dt.setValue(G,"center",X.center),Dt.setValue(G,"modelViewMatrix",X.modelViewMatrix),Dt.setValue(G,"normalMatrix",X.normalMatrix),Dt.setValue(G,"modelMatrix",X.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){const Mn=H.uniformsGroups;for(let kn=0,Sh=Mn.length;kn<Sh;kn++){const Pa=Mn[kn];ke.update(Pa,Kt),ke.bind(Pa,Kt)}}return Kt}function la(D,V){D.ambientLightColor.needsUpdate=V,D.lightProbe.needsUpdate=V,D.directionalLights.needsUpdate=V,D.directionalLightShadows.needsUpdate=V,D.pointLights.needsUpdate=V,D.pointLightShadows.needsUpdate=V,D.spotLights.needsUpdate=V,D.spotLightShadows.needsUpdate=V,D.rectAreaLights.needsUpdate=V,D.hemisphereLights.needsUpdate=V}function dr(D){return D.isMeshLambertMaterial||D.isMeshToonMaterial||D.isMeshPhongMaterial||D.isMeshStandardMaterial||D.isShadowMaterial||D.isShaderMaterial&&D.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return O},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(D,V,Z){const H=Je.get(D);H.__autoAllocateDepthBuffer=D.resolveDepthBuffer===!1,H.__autoAllocateDepthBuffer===!1&&(H.__useRenderToTexture=!1),Je.get(D.texture).__webglTexture=V,Je.get(D.depthTexture).__webglTexture=H.__autoAllocateDepthBuffer?void 0:Z,H.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(D,V){const Z=Je.get(D);Z.__webglFramebuffer=V,Z.__useDefaultFramebuffer=V===void 0};const C=G.createFramebuffer();this.setRenderTarget=function(D,V=0,Z=0){w=D,U=V,O=Z;let H=!0,X=null,ne=!1,re=!1;if(D){const _e=Je.get(D);if(_e.__useDefaultFramebuffer!==void 0)Be.bindFramebuffer(G.FRAMEBUFFER,null),H=!1;else if(_e.__webglFramebuffer===void 0)ct.setupRenderTarget(D);else if(_e.__hasExternalTextures)ct.rebindTextures(D,Je.get(D.texture).__webglTexture,Je.get(D.depthTexture).__webglTexture);else if(D.depthBuffer){const Pe=D.depthTexture;if(_e.__boundDepthTexture!==Pe){if(Pe!==null&&Je.has(Pe)&&(D.width!==Pe.image.width||D.height!==Pe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ct.setupDepthRenderbuffer(D)}}const Se=D.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(re=!0);const Re=Je.get(D).__webglFramebuffer;D.isWebGLCubeRenderTarget?(Array.isArray(Re[V])?X=Re[V][Z]:X=Re[V],ne=!0):D.samples>0&&ct.useMultisampledRTT(D)===!1?X=Je.get(D).__webglMultisampledFramebuffer:Array.isArray(Re)?X=Re[Z]:X=Re,ee.copy(D.viewport),se.copy(D.scissor),ae=D.scissorTest}else ee.copy(nt).multiplyScalar(ie).floor(),se.copy(tt).multiplyScalar(ie).floor(),ae=gt;if(Z!==0&&(X=C),Be.bindFramebuffer(G.FRAMEBUFFER,X)&&H&&Be.drawBuffers(D,X),Be.viewport(ee),Be.scissor(se),Be.setScissorTest(ae),ne){const _e=Je.get(D.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+V,_e.__webglTexture,Z)}else if(re){const _e=V;for(let Se=0;Se<D.textures.length;Se++){const Re=Je.get(D.textures[Se]);G.framebufferTextureLayer(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0+Se,Re.__webglTexture,Z,_e)}}else if(D!==null&&Z!==0){const _e=Je.get(D.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,_e.__webglTexture,Z)}B=-1},this.readRenderTargetPixels=function(D,V,Z,H,X,ne,re,fe=0){if(!(D&&D.isWebGLRenderTarget)){Bt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _e=Je.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&re!==void 0&&(_e=_e[re]),_e){Be.bindFramebuffer(G.FRAMEBUFFER,_e);try{const Se=D.textures[fe],Re=Se.format,Pe=Se.type;if(!Fe.textureFormatReadable(Re)){Bt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Fe.textureTypeReadable(Pe)){Bt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V>=0&&V<=D.width-H&&Z>=0&&Z<=D.height-X&&(D.textures.length>1&&G.readBuffer(G.COLOR_ATTACHMENT0+fe),G.readPixels(V,Z,H,X,Oe.convert(Re),Oe.convert(Pe),ne))}finally{const Se=w!==null?Je.get(w).__webglFramebuffer:null;Be.bindFramebuffer(G.FRAMEBUFFER,Se)}}},this.readRenderTargetPixelsAsync=async function(D,V,Z,H,X,ne,re,fe=0){if(!(D&&D.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let _e=Je.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&re!==void 0&&(_e=_e[re]),_e)if(V>=0&&V<=D.width-H&&Z>=0&&Z<=D.height-X){Be.bindFramebuffer(G.FRAMEBUFFER,_e);const Se=D.textures[fe],Re=Se.format,Pe=Se.type;if(!Fe.textureFormatReadable(Re))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Fe.textureTypeReadable(Pe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const ze=G.createBuffer();G.bindBuffer(G.PIXEL_PACK_BUFFER,ze),G.bufferData(G.PIXEL_PACK_BUFFER,ne.byteLength,G.STREAM_READ),D.textures.length>1&&G.readBuffer(G.COLOR_ATTACHMENT0+fe),G.readPixels(V,Z,H,X,Oe.convert(Re),Oe.convert(Pe),0);const Ye=w!==null?Je.get(w).__webglFramebuffer:null;Be.bindFramebuffer(G.FRAMEBUFFER,Ye);const lt=G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE,0);return G.flush(),await eG(G,lt,4),G.bindBuffer(G.PIXEL_PACK_BUFFER,ze),G.getBufferSubData(G.PIXEL_PACK_BUFFER,0,ne),G.deleteBuffer(ze),G.deleteSync(lt),ne}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(D,V=null,Z=0){const H=Math.pow(2,-Z),X=Math.floor(D.image.width*H),ne=Math.floor(D.image.height*H),re=V!==null?V.x:0,fe=V!==null?V.y:0;ct.setTexture2D(D,0),G.copyTexSubImage2D(G.TEXTURE_2D,Z,0,0,re,fe,X,ne),Be.unbindTexture()};const z=G.createFramebuffer(),Y=G.createFramebuffer();this.copyTextureToTexture=function(D,V,Z=null,H=null,X=0,ne=null){ne===null&&(X!==0?(wd("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ne=X,X=0):ne=0);let re,fe,_e,Se,Re,Pe,ze,Ye,lt;const Tt=D.isCompressedTexture?D.mipmaps[ne]:D.image;if(Z!==null)re=Z.max.x-Z.min.x,fe=Z.max.y-Z.min.y,_e=Z.isBox3?Z.max.z-Z.min.z:1,Se=Z.min.x,Re=Z.min.y,Pe=Z.isBox3?Z.min.z:0;else{const bi=Math.pow(2,-X);re=Math.floor(Tt.width*bi),fe=Math.floor(Tt.height*bi),D.isDataArrayTexture?_e=Tt.depth:D.isData3DTexture?_e=Math.floor(Tt.depth*bi):_e=1,Se=0,Re=0,Pe=0}H!==null?(ze=H.x,Ye=H.y,lt=H.z):(ze=0,Ye=0,lt=0);const At=Oe.convert(V.format),ft=Oe.convert(V.type);let wt;V.isData3DTexture?(ct.setTexture3D(V,0),wt=G.TEXTURE_3D):V.isDataArrayTexture||V.isCompressedArrayTexture?(ct.setTexture2DArray(V,0),wt=G.TEXTURE_2D_ARRAY):(ct.setTexture2D(V,0),wt=G.TEXTURE_2D),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,V.flipY),G.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),G.pixelStorei(G.UNPACK_ALIGNMENT,V.unpackAlignment);const st=G.getParameter(G.UNPACK_ROW_LENGTH),Kt=G.getParameter(G.UNPACK_IMAGE_HEIGHT),Ln=G.getParameter(G.UNPACK_SKIP_PIXELS),Yt=G.getParameter(G.UNPACK_SKIP_ROWS),kt=G.getParameter(G.UNPACK_SKIP_IMAGES);G.pixelStorei(G.UNPACK_ROW_LENGTH,Tt.width),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,Tt.height),G.pixelStorei(G.UNPACK_SKIP_PIXELS,Se),G.pixelStorei(G.UNPACK_SKIP_ROWS,Re),G.pixelStorei(G.UNPACK_SKIP_IMAGES,Pe);const Dt=D.isDataArrayTexture||D.isData3DTexture,Hn=V.isDataArrayTexture||V.isData3DTexture;if(D.isDepthTexture){const bi=Je.get(D),Mn=Je.get(V),kn=Je.get(bi.__renderTarget),Sh=Je.get(Mn.__renderTarget);Be.bindFramebuffer(G.READ_FRAMEBUFFER,kn.__webglFramebuffer),Be.bindFramebuffer(G.DRAW_FRAMEBUFFER,Sh.__webglFramebuffer);for(let Pa=0;Pa<_e;Pa++)Dt&&(G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Je.get(D).__webglTexture,X,Pe+Pa),G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Je.get(V).__webglTexture,ne,lt+Pa)),G.blitFramebuffer(Se,Re,re,fe,ze,Ye,re,fe,G.DEPTH_BUFFER_BIT,G.NEAREST);Be.bindFramebuffer(G.READ_FRAMEBUFFER,null),Be.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else if(X!==0||D.isRenderTargetTexture||Je.has(D)){const bi=Je.get(D),Mn=Je.get(V);Be.bindFramebuffer(G.READ_FRAMEBUFFER,z),Be.bindFramebuffer(G.DRAW_FRAMEBUFFER,Y);for(let kn=0;kn<_e;kn++)Dt?G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,bi.__webglTexture,X,Pe+kn):G.framebufferTexture2D(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,bi.__webglTexture,X),Hn?G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Mn.__webglTexture,ne,lt+kn):G.framebufferTexture2D(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,Mn.__webglTexture,ne),X!==0?G.blitFramebuffer(Se,Re,re,fe,ze,Ye,re,fe,G.COLOR_BUFFER_BIT,G.NEAREST):Hn?G.copyTexSubImage3D(wt,ne,ze,Ye,lt+kn,Se,Re,re,fe):G.copyTexSubImage2D(wt,ne,ze,Ye,Se,Re,re,fe);Be.bindFramebuffer(G.READ_FRAMEBUFFER,null),Be.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else Hn?D.isDataTexture||D.isData3DTexture?G.texSubImage3D(wt,ne,ze,Ye,lt,re,fe,_e,At,ft,Tt.data):V.isCompressedArrayTexture?G.compressedTexSubImage3D(wt,ne,ze,Ye,lt,re,fe,_e,At,Tt.data):G.texSubImage3D(wt,ne,ze,Ye,lt,re,fe,_e,At,ft,Tt):D.isDataTexture?G.texSubImage2D(G.TEXTURE_2D,ne,ze,Ye,re,fe,At,ft,Tt.data):D.isCompressedTexture?G.compressedTexSubImage2D(G.TEXTURE_2D,ne,ze,Ye,Tt.width,Tt.height,At,Tt.data):G.texSubImage2D(G.TEXTURE_2D,ne,ze,Ye,re,fe,At,ft,Tt);G.pixelStorei(G.UNPACK_ROW_LENGTH,st),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,Kt),G.pixelStorei(G.UNPACK_SKIP_PIXELS,Ln),G.pixelStorei(G.UNPACK_SKIP_ROWS,Yt),G.pixelStorei(G.UNPACK_SKIP_IMAGES,kt),ne===0&&V.generateMipmaps&&G.generateMipmap(wt),Be.unbindTexture()},this.initRenderTarget=function(D){Je.get(D).__webglFramebuffer===void 0&&ct.setupRenderTarget(D)},this.initTexture=function(D){D.isCubeTexture?ct.setTextureCube(D,0):D.isData3DTexture?ct.setTexture3D(D,0):D.isDataArrayTexture||D.isCompressedArrayTexture?ct.setTexture2DArray(D,0):ct.setTexture2D(D,0),Be.unbindTexture()},this.resetState=function(){U=0,O=0,w=null,Be.reset(),q.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return wa}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=en._getDrawingBufferColorSpace(e),t.unpackColorSpace=en._getUnpackColorSpace()}}const wj=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:yb,AddEquation:$s,AddOperation:EU,AdditiveAnimationBlendMode:Ab,AdditiveBlending:hE,AgXToneMapping:RU,AlphaFormat:Eb,AlwaysCompare:kU,AlwaysDepth:u0,AlwaysStencilFunc:mE,AmbientLight:D6,AnimationAction:F6,AnimationClip:th,AnimationLoader:FV,AnimationMixer:G6,AnimationObjectGroup:uk,AnimationUtils:PV,ArcCurve:s6,ArrayCamera:z6,ArrowHelper:Uk,AttachedBindMode:pE,Audio:B6,AudioAnalyser:ek,AudioContext:iA,AudioListener:QV,AudioLoader:jV,AxesHelper:W6,BackSide:Ii,BasicDepthPacking:bc,BasicShadowMap:aU,BatchedMesh:i6,Bone:j1,BooleanKeyframeTrack:mh,Box2:xk,Box3:tr,Box3Helper:Lk,BoxGeometry:fh,BoxHelper:Ok,BufferAttribute:Ot,BufferGeometry:Ct,BufferGeometryLoader:U6,ByteType:z1,Cache:io,Camera:wc,CameraHelper:Nk,CanvasTexture:aV,CapsuleGeometry:J1,CatmullRomCurve3:o6,CineonToneMapping:AU,CircleGeometry:$1,ClampToEdgeWrapping:Ui,Clock:rA,Color:qe,ColorKeyframeTrack:Kb,ColorManagement:en,CompressedArrayTexture:iV,CompressedCubeTexture:rV,CompressedTexture:Q1,CompressedTextureLoader:GV,ConeGeometry:W0,ConstantAlphaFactor:yU,ConstantColorFactor:_U,Controls:zk,CubeCamera:JU,CubeReflectionMapping:ol,CubeRefractionMapping:_c,CubeTexture:G0,CubeTextureLoader:VV,CubeUVReflectionMapping:jd,CubicBezierCurve:Fb,CubicBezierCurve3:l6,CubicInterpolant:M6,CullFaceBack:uE,CullFaceFront:rU,CullFaceFrontBack:xF,CullFaceNone:iU,Curve:Is,CurvePath:u6,CustomBlending:xb,CustomToneMapping:wU,CylinderGeometry:k0,Cylindrical:_k,Data3DTexture:ss,DataArrayTexture:W1,DataTexture:ea,DataTextureLoader:R6,DataUtils:gE,DecrementStencilOp:CF,DecrementWrapStencilOp:NF,DefaultLoadingManager:w6,DepthFormat:Ed,DepthStencilFormat:Qu,DepthTexture:V0,DetachedBindMode:DU,DirectionalLight:nA,DirectionalLightHelper:Dk,DiscreteInterpolant:b6,DodecahedronGeometry:ey,DoubleSide:cr,DstAlphaFactor:dU,DstColorFactor:mU,DynamicCopyUsage:XF,DynamicDrawUsage:WU,DynamicReadUsage:VF,EdgesGeometry:a6,EllipseCurve:ty,EqualCompare:HU,EqualDepth:hx,EqualStencilFunc:UF,EquirectangularReflectionMapping:h0,EquirectangularRefractionMapping:f0,Euler:zi,EventDispatcher:ra,ExternalTexture:Bb,ExtrudeGeometry:ny,FileLoader:na,Float16BufferAttribute:UG,Float32BufferAttribute:yt,FloatType:si,Fog:Y1,FogExp2:X1,FramebufferTexture:nV,FrontSide:Ns,Frustum:Kd,FrustumArray:Z1,GLBufferAttribute:SE,GLSL1:qF,GLSL3:so,GreaterCompare:FU,GreaterDepth:dx,GreaterEqualCompare:VU,GreaterEqualDepth:fx,GreaterEqualStencilFunc:HF,GreaterStencilFunc:zF,GridHelper:Rk,Group:Pr,HalfFloatType:Yn,HemisphereLight:C6,HemisphereLightHelper:wk,IcosahedronGeometry:iy,ImageBitmapLoader:P6,ImageLoader:Ld,ImageUtils:qU,IncrementStencilOp:RF,IncrementWrapStencilOp:DF,InstancedBufferAttribute:Ju,InstancedBufferGeometry:I6,InstancedInterleavedBuffer:mk,InstancedMesh:Ub,Int16BufferAttribute:LG,Int32BufferAttribute:IG,Int8BufferAttribute:DG,IntType:H0,InterleavedBuffer:Zd,InterleavedBufferAttribute:ll,Interpolant:Qd,InterpolateDiscrete:Md,InterpolateLinear:bd,InterpolateSmooth:T_,InterpolationSamplingMode:KF,InterpolationSamplingType:ZF,InvertStencilOp:OF,KeepStencilOp:Su,KeyframeTrack:us,LOD:n6,LatheGeometry:ry,Layers:Cd,LessCompare:BU,LessDepth:ux,LessEqualCompare:Rb,LessEqualDepth:ju,LessEqualStencilFunc:PF,LessStencilFunc:IF,Light:Dc,LightProbe:L6,Line:oo,Line3:Tk,LineBasicMaterial:Bi,LineCurve:Gb,LineCurve3:c6,LineDashedMaterial:S6,LineLoop:Pb,LineSegments:aa,LinearFilter:Ht,LinearInterpolant:Zb,LinearMipMapLinearFilter:NU,LinearMipMapNearestFilter:TF,LinearMipmapLinearFilter:Aa,LinearMipmapNearestFilter:sd,LinearSRGBColorSpace:Fn,LinearToneMapping:MU,LinearTransfer:p0,Loader:yi,LoaderUtils:fc,LoadingManager:Qb,LoopOnce:bb,LoopPingPong:LU,LoopRepeat:OU,MOUSE:xu,Material:jn,MaterialLoader:hy,MathUtils:tn,Matrix2:oA,Matrix3:Et,Matrix4:Ve,MaxEquation:cU,Mesh:oi,MeshBasicMaterial:Ur,MeshDepthMaterial:Yb,MeshDistanceMaterial:qb,MeshLambertMaterial:x6,MeshMatcapMaterial:y6,MeshNormalMaterial:Xb,MeshPhongMaterial:v6,MeshPhysicalMaterial:cs,MeshStandardMaterial:q0,MeshToonMaterial:_6,MinEquation:lU,MirroredRepeatWrapping:Td,MixOperation:TU,MultiplyBlending:dE,MultiplyOperation:B0,NearestFilter:Vn,NearestMipMapLinearFilter:SF,NearestMipMapNearestFilter:yF,NearestMipmapLinearFilter:bu,NearestMipmapNearestFilter:P1,NeutralToneMapping:CU,NeverCompare:zU,NeverDepth:cx,NeverStencilFunc:LF,NoBlending:Er,NoColorSpace:Or,NoToneMapping:as,NormalAnimationBlendMode:k1,NormalBlending:zu,NotEqualCompare:GU,NotEqualDepth:px,NotEqualStencilFunc:BF,NumberKeyframeTrack:yc,Object3D:Wt,ObjectLoader:YV,ObjectSpaceNormalMap:PU,OctahedronGeometry:X0,OneFactor:Yf,OneMinusConstantAlphaFactor:SU,OneMinusConstantColorFactor:xU,OneMinusDstAlphaFactor:pU,OneMinusDstColorFactor:gU,OneMinusSrcAlphaFactor:lx,OneMinusSrcColorFactor:fU,OrthographicCamera:ao,PCFShadowMap:I1,PCFSoftShadowMap:Pm,PMREMGenerator:bE,Path:qx,PerspectiveCamera:hi,Plane:ko,PlaneGeometry:dh,PlaneHelper:Ik,PointLight:tA,PointLightHelper:bk,Points:zb,PointsMaterial:K1,PolarGridHelper:Ck,PolyhedronGeometry:Cc,PositionalAudio:$V,PropertyBinding:fn,PropertyMixer:H6,QuadraticBezierCurve:Vb,QuadraticBezierCurve3:kb,Quaternion:_t,QuaternionKeyframeTrack:Sc,QuaternionLinearInterpolant:A6,RED_GREEN_RGTC2_Format:Gx,RED_RGTC1_Format:Hx,REVISION:Ds,RGBADepthPacking:UU,RGBAFormat:$n,RGBAIntegerFormat:V1,RGBA_ASTC_10x10_Format:Lx,RGBA_ASTC_10x5_Format:Dx,RGBA_ASTC_10x6_Format:Nx,RGBA_ASTC_10x8_Format:Ox,RGBA_ASTC_12x10_Format:Ix,RGBA_ASTC_12x12_Format:Ux,RGBA_ASTC_4x4_Format:Tx,RGBA_ASTC_5x4_Format:Ex,RGBA_ASTC_5x5_Format:Mx,RGBA_ASTC_6x5_Format:bx,RGBA_ASTC_6x6_Format:Ax,RGBA_ASTC_8x5_Format:wx,RGBA_ASTC_8x6_Format:Rx,RGBA_ASTC_8x8_Format:Cx,RGBA_BPTC_Format:Px,RGBA_ETC2_EAC_Format:Sx,RGBA_PVRTC_2BPPV1_Format:_x,RGBA_PVRTC_4BPPV1_Format:vx,RGBA_S3TC_DXT1_Format:Bm,RGBA_S3TC_DXT3_Format:Hm,RGBA_S3TC_DXT5_Format:Fm,RGBDepthPacking:MF,RGBFormat:Mb,RGBIntegerFormat:EF,RGB_BPTC_SIGNED_Format:zx,RGB_BPTC_UNSIGNED_Format:Bx,RGB_ETC1_Format:xx,RGB_ETC2_Format:yx,RGB_PVRTC_2BPPV1_Format:gx,RGB_PVRTC_4BPPV1_Format:mx,RGB_S3TC_DXT1_Format:zm,RGDepthPacking:bF,RGFormat:Xo,RGIntegerFormat:G1,RawShaderMaterial:ph,Ray:Ac,Raycaster:V6,RectAreaLight:N6,RedFormat:ws,RedIntegerFormat:F0,ReinhardToneMapping:bU,RenderTarget:Db,RenderTarget3D:fk,RepeatWrapping:Mr,ReplaceStencilOp:wF,ReverseSubtractEquation:oU,RingGeometry:ay,SIGNED_RED_GREEN_RGTC2_Format:Vx,SIGNED_RED_RGTC1_Format:Fx,SRGBColorSpace:dn,SRGBTransfer:wn,Scene:Nd,ShaderChunk:Qt,ShaderLib:As,ShaderMaterial:Vi,ShadowMaterial:g6,Shape:Hu,ShapeGeometry:sy,ShapePath:Pk,ShapeUtils:Rs,ShortType:B1,Skeleton:Rc,SkeletonHelper:Mk,SkinnedMesh:q1,Source:ec,Sphere:nr,SphereGeometry:Y0,Spherical:EE,SphericalHarmonics3:O6,SplineCurve:Wb,SpotLight:eA,SpotLightHelper:Ek,Sprite:t6,SpriteMaterial:Ib,SrcAlphaFactor:ox,SrcAlphaSaturateFactor:vU,SrcColorFactor:hU,StaticCopyUsage:WF,StaticDrawUsage:m0,StaticReadUsage:GF,StereoCamera:ZV,StreamCopyUsage:YF,StreamDrawUsage:FF,StreamReadUsage:kF,StringKeyframeTrack:gh,SubtractEquation:sU,SubtractiveBlending:fE,TOUCH:yu,TangentSpaceNormalMap:hl,TetrahedronGeometry:oy,Texture:Nn,TextureLoader:Jb,TextureUtils:Vk,Timer:gk,TimestampQuery:jF,TorusGeometry:ly,TorusKnotGeometry:cy,Triangle:Jr,TriangleFanDrawMode:kx,TriangleStripDrawMode:wb,TrianglesDrawMode:IU,TubeGeometry:uy,UVMapping:U1,Uint16BufferAttribute:Nb,Uint32BufferAttribute:Ob,Uint8BufferAttribute:NG,Uint8ClampedBufferAttribute:OG,Uniform:J,UniformsGroup:pk,UniformsLib:rt,UniformsUtils:Lb,UnsignedByteType:Pi,UnsignedInt101111Type:Tb,UnsignedInt248Type:Ku,UnsignedInt5999Type:Sb,UnsignedIntType:Os,UnsignedShort4444Type:H1,UnsignedShort5551Type:F1,UnsignedShortType:Zu,VSMShadowMap:Ts,Vector2:de,Vector3:L,Vector4:zt,VectorKeyframeTrack:eh,VideoFrameTexture:tV,VideoTexture:r6,WebGL3DRenderTarget:ZU,WebGLArrayRenderTarget:jU,WebGLCoordinateSystem:wa,WebGLCubeRenderTarget:$U,WebGLRenderTarget:xi,WebGLRenderer:lA,WebGLUtils:K6,WebGPUCoordinateSystem:Ad,WebXRController:E_,WireframeGeometry:m6,WrapAroundEnding:d0,ZeroCurvatureEnding:Au,ZeroFactor:uU,ZeroSlopeEnding:wu,ZeroStencilOp:AF,createCanvasElement:YU,error:Bt,getConsoleFunction:$F,log:v0,setConsoleFunction:JF,warn:ut,warnOnce:wd},Symbol.toStringTag,{value:"Module"}));var Q6={exports:{}},J6={},$6={exports:{}},e8={};/**
 * @license React
 * use-sync-external-store-shim.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Id=Me;function Rj(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var Cj=typeof Object.is=="function"?Object.is:Rj,Dj=Id.useState,Nj=Id.useEffect,Oj=Id.useLayoutEffect,Lj=Id.useDebugValue;function Ij(n,e){var t=e(),i=Dj({inst:{value:t,getSnapshot:e}}),r=i[0].inst,a=i[1];return Oj(function(){r.value=t,r.getSnapshot=e,T2(r)&&a({inst:r})},[n,t,e]),Nj(function(){return T2(r)&&a({inst:r}),n(function(){T2(r)&&a({inst:r})})},[n]),Lj(t),t}function T2(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!Cj(n,t)}catch{return!0}}function Uj(n,e){return e()}var Pj=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Uj:Ij;e8.useSyncExternalStore=Id.useSyncExternalStore!==void 0?Id.useSyncExternalStore:Pj;$6.exports=e8;var zj=$6.exports;/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var py=Me,Bj=zj;function Hj(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var Fj=typeof Object.is=="function"?Object.is:Hj,Gj=Bj.useSyncExternalStore,Vj=py.useRef,kj=py.useEffect,Wj=py.useMemo,Xj=py.useDebugValue;J6.useSyncExternalStoreWithSelector=function(n,e,t,i,r){var a=Vj(null);if(a.current===null){var s={hasValue:!1,value:null};a.current=s}else s=a.current;a=Wj(function(){function l(g){if(!h){if(h=!0,f=g,g=i(g),r!==void 0&&s.hasValue){var _=s.value;if(r(_,g))return d=_}return d=g}if(_=d,Fj(f,g))return _;var T=i(g);return r!==void 0&&r(_,T)?(f=g,_):(f=g,d=T)}var h=!1,f,d,p=t===void 0?null:t;return[function(){return l(e())},p===null?void 0:function(){return l(p())}]},[e,t,i,r]);var o=Gj(n,a[0],a[1]);return kj(function(){s.hasValue=!0,s.value=o},[o]),Xj(o),o};Q6.exports=J6;var Yj=Q6.exports;const qj=p1(Yj),jD=n=>{let e;const t=new Set,i=(h,f)=>{const d=typeof h=="function"?h(e):h;if(!Object.is(d,e)){const p=e;e=f??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(g=>g(e,p))}},r=()=>e,o={setState:i,getState:r,getInitialState:()=>l,subscribe:h=>(t.add(h),()=>t.delete(h))},l=e=n(i,r,o);return o},jj=n=>n?jD(n):jD,{useSyncExternalStoreWithSelector:Zj}=qj,Kj=n=>n;function Qj(n,e=Kj,t){const i=Zj(n.subscribe,n.getState,n.getInitialState,e,t);return TM.useDebugValue(i),i}const ZD=(n,e)=>{const t=jj(n),i=(r,a=e)=>Qj(t,r,a);return Object.assign(i,t),i},Jj=(n,e)=>n?ZD(n,e):ZD,$j=n=>typeof n=="object"&&typeof n.then=="function",Cu=[];function t8(n,e,t=(i,r)=>i===r){if(n===e)return!0;if(!n||!e)return!1;const i=n.length;if(e.length!==i)return!1;for(let r=0;r<i;r++)if(!t(n[r],e[r]))return!1;return!0}function n8(n,e=null,t=!1,i={}){e===null&&(e=[n]);for(const a of Cu)if(t8(e,a.keys,a.equal)){if(t)return;if(Object.prototype.hasOwnProperty.call(a,"error"))throw a.error;if(Object.prototype.hasOwnProperty.call(a,"response"))return i.lifespan&&i.lifespan>0&&(a.timeout&&clearTimeout(a.timeout),a.timeout=setTimeout(a.remove,i.lifespan)),a.response;if(!t)throw a.promise}const r={keys:e,equal:i.equal,remove:()=>{const a=Cu.indexOf(r);a!==-1&&Cu.splice(a,1)},promise:($j(n)?n:n(...e)).then(a=>{r.response=a,i.lifespan&&i.lifespan>0&&(r.timeout=setTimeout(r.remove,i.lifespan))}).catch(a=>r.error=a)};if(Cu.push(r),!t)throw r.promise}const eZ=(n,e,t)=>n8(n,e,!1,t),tZ=(n,e,t)=>void n8(n,e,!0,t),nZ=n=>{if(n===void 0||n.length===0)Cu.splice(0,Cu.length);else{const e=Cu.find(t=>t8(n,t.keys,t.equal));e&&e.remove()}};var i8={exports:{}},r8={exports:{}},a8={exports:{}},s8={};/**
 * @license React
 * scheduler.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */(function(n){function e(W,te){var K=W.length;W.push(te);e:for(;0<K;){var oe=K-1>>>1,ie=W[oe];if(0<r(ie,te))W[oe]=te,W[K]=ie,K=oe;else break e}}function t(W){return W.length===0?null:W[0]}function i(W){if(W.length===0)return null;var te=W[0],K=W.pop();if(K!==te){W[0]=K;e:for(var oe=0,ie=W.length,Ce=ie>>>1;oe<Ce;){var Xe=2*(oe+1)-1,nt=W[Xe],tt=Xe+1,gt=W[tt];if(0>r(nt,K))tt<ie&&0>r(gt,nt)?(W[oe]=gt,W[tt]=K,oe=tt):(W[oe]=nt,W[Xe]=K,oe=Xe);else if(tt<ie&&0>r(gt,K))W[oe]=gt,W[tt]=K,oe=tt;else break e}}return te}function r(W,te){var K=W.sortIndex-te.sortIndex;return K!==0?K:W.id-te.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;n.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();n.unstable_now=function(){return s.now()-o}}var l=[],h=[],f=1,d=null,p=3,g=!1,_=!1,T=!1,y=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function E(W){for(var te=t(h);te!==null;){if(te.callback===null)i(h);else if(te.startTime<=W)i(h),te.sortIndex=te.expirationTime,e(l,te);else break;te=t(h)}}function b(W){if(T=!1,E(W),!_)if(t(l)!==null)_=!0,se();else{var te=t(h);te!==null&&ae(b,te.startTime-W)}}var N=!1,R=-1,I=5,U=-1;function O(){return!(n.unstable_now()-U<I)}function w(){if(N){var W=n.unstable_now();U=W;var te=!0;try{e:{_=!1,T&&(T=!1,v(R),R=-1),g=!0;var K=p;try{t:{for(E(W),d=t(l);d!==null&&!(d.expirationTime>W&&O());){var oe=d.callback;if(typeof oe=="function"){d.callback=null,p=d.priorityLevel;var ie=oe(d.expirationTime<=W);if(W=n.unstable_now(),typeof ie=="function"){d.callback=ie,E(W),te=!0;break t}d===t(l)&&i(l),E(W)}else i(l);d=t(l)}if(d!==null)te=!0;else{var Ce=t(h);Ce!==null&&ae(b,Ce.startTime-W),te=!1}}break e}finally{d=null,p=K,g=!1}te=void 0}}finally{te?B():N=!1}}}var B;if(typeof S=="function")B=function(){S(w)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,ee=j.port2;j.port1.onmessage=w,B=function(){ee.postMessage(null)}}else B=function(){y(w,0)};function se(){N||(N=!0,B())}function ae(W,te){R=y(function(){W(n.unstable_now())},te)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(W){W.callback=null},n.unstable_continueExecution=function(){_||g||(_=!0,se())},n.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<W?Math.floor(1e3/W):5},n.unstable_getCurrentPriorityLevel=function(){return p},n.unstable_getFirstCallbackNode=function(){return t(l)},n.unstable_next=function(W){switch(p){case 1:case 2:case 3:var te=3;break;default:te=p}var K=p;p=te;try{return W()}finally{p=K}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(W,te){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var K=p;p=W;try{return te()}finally{p=K}},n.unstable_scheduleCallback=function(W,te,K){var oe=n.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?oe+K:oe):K=oe,W){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=K+ie,W={id:f++,callback:te,priorityLevel:W,startTime:K,expirationTime:ie,sortIndex:-1},K>oe?(W.sortIndex=K,e(h,W),t(l)===null&&W===t(h)&&(T?(v(R),R=-1):T=!0,ae(b,K-oe))):(W.sortIndex=ie,e(l,W),_||g||(_=!0,se())),W},n.unstable_shouldYield=O,n.unstable_wrapCallback=function(W){var te=p;return function(){var K=p;p=te;try{return W.apply(this,arguments)}finally{p=K}}}})(s8);a8.exports=s8;var wE=a8.exports;/**
 * @license React
 * react-reconciler.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */(function(n){n.exports=function(e){function t(c,u,m,x){return new B9(c,u,m,x)}function i(){}function r(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)u+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(c){return c===null||typeof c!="object"?null:(c=hR&&c[hR]||c["@@iterator"],typeof c=="function"?c:null)}function s(c){if(c==null)return null;if(typeof c=="function")return c.$$typeof===W9?null:c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case wh:return"Fragment";case Ah:return"Portal";case vS:return"Profiler";case lR:return"StrictMode";case xS:return"Suspense";case yS:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case xl:return(c.displayName||"Context")+".Provider";case cR:return(c._context.displayName||"Context")+".Consumer";case _S:var u=c.render;return c=c.displayName,c||(c=u.displayName||u.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case SS:return u=c.displayName||null,u!==null?u:s(c.type)||"Memo";case yl:u=c._payload,c=c._init;try{return s(c(u))}catch{}}return null}function o(c){if(TS===void 0)try{throw Error()}catch(m){var u=m.stack.trim().match(/\n( *(at )?)/);TS=u&&u[1]||"",fR=-1<m.stack.indexOf(`
    at`)?" (<anonymous>)":-1<m.stack.indexOf("@")?"@unknown:0:0":""}return`
`+TS+c+fR}function l(c,u){if(!c||ES)return"";ES=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var x={DetermineComponentFrameRoot:function(){try{if(u){var dt=function(){throw Error()};if(Object.defineProperty(dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dt,[])}catch(qt){var mt=qt}Reflect.construct(c,[],dt)}else{try{dt.call()}catch(qt){mt=qt}c.call(dt.prototype)}}else{try{throw Error()}catch(qt){mt=qt}(dt=c())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(qt){if(qt&&mt&&typeof qt.stack=="string")return[qt.stack,mt.stack]}return[null,null]}};x.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var M=Object.getOwnPropertyDescriptor(x.DetermineComponentFrameRoot,"name");M&&M.configurable&&Object.defineProperty(x.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var A=x.DetermineComponentFrameRoot(),F=A[0],$=A[1];if(F&&$){var he=F.split(`
`),De=$.split(`
`);for(M=x=0;x<he.length&&!he[x].includes("DetermineComponentFrameRoot");)x++;for(;M<De.length&&!De[M].includes("DetermineComponentFrameRoot");)M++;if(x===he.length||M===De.length)for(x=he.length-1,M=De.length-1;1<=x&&0<=M&&he[x]!==De[M];)M--;for(;1<=x&&0<=M;x--,M--)if(he[x]!==De[M]){if(x!==1||M!==1)do if(x--,M--,0>M||he[x]!==De[M]){var et=`
`+he[x].replace(" at new "," at ");return c.displayName&&et.includes("<anonymous>")&&(et=et.replace("<anonymous>",c.displayName)),et}while(1<=x&&0<=M);break}}}finally{ES=!1,Error.prepareStackTrace=m}return(m=c?c.displayName||c.name:"")?o(m):""}function h(c){switch(c.tag){case 26:case 27:case 5:return o(c.type);case 16:return o("Lazy");case 13:return o("Suspense");case 19:return o("SuspenseList");case 0:case 15:return c=l(c.type,!1),c;case 11:return c=l(c.type.render,!1),c;case 1:return c=l(c.type,!0),c;default:return""}}function f(c){try{var u="";do u+=h(c),c=c.return;while(c);return u}catch(m){return`
Error generating stack: `+m.message+`
`+m.stack}}function d(c){var u=c,m=c;if(c.alternate)for(;u.return;)u=u.return;else{c=u;do u=c,u.flags&4098&&(m=u.return),c=u.return;while(c)}return u.tag===3?m:null}function p(c){if(d(c)!==c)throw Error(r(188))}function g(c){var u=c.alternate;if(!u){if(u=d(c),u===null)throw Error(r(188));return u!==c?null:c}for(var m=c,x=u;;){var M=m.return;if(M===null)break;var A=M.alternate;if(A===null){if(x=M.return,x!==null){m=x;continue}break}if(M.child===A.child){for(A=M.child;A;){if(A===m)return p(M),c;if(A===x)return p(M),u;A=A.sibling}throw Error(r(188))}if(m.return!==x.return)m=M,x=A;else{for(var F=!1,$=M.child;$;){if($===m){F=!0,m=M,x=A;break}if($===x){F=!0,x=M,m=A;break}$=$.sibling}if(!F){for($=A.child;$;){if($===m){F=!0,m=A,x=M;break}if($===x){F=!0,x=A,m=M;break}$=$.sibling}if(!F)throw Error(r(189))}}if(m.alternate!==x)throw Error(r(190))}if(m.tag!==3)throw Error(r(188));return m.stateNode.current===m?c:u}function _(c){var u=c.tag;if(u===5||u===26||u===27||u===6)return c;for(c=c.child;c!==null;){if(u=_(c),u!==null)return u;c=c.sibling}return null}function T(c){var u=c.tag;if(u===5||u===26||u===27||u===6)return c;for(c=c.child;c!==null;){if(c.tag!==4&&(u=T(c),u!==null))return u;c=c.sibling}return null}function y(c){return{current:c}}function v(c){0>Ch||(c.current=CS[Ch],CS[Ch]=null,Ch--)}function S(c,u){Ch++,CS[Ch]=c.current,c.current=u}function E(c){return c>>>=0,c===0?32:31-(az(c)/sz|0)|0}function b(c){var u=c&42;if(u!==0)return u;switch(c&-c){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128: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 c&4194176;case 4194304:case 8388608:case 16777216:case 33554432:return c&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return c}}function N(c,u){var m=c.pendingLanes;if(m===0)return 0;var x=0,M=c.suspendedLanes,A=c.pingedLanes,F=c.warmLanes;c=c.finishedLanes!==0;var $=m&134217727;return $!==0?(m=$&~M,m!==0?x=b(m):(A&=$,A!==0?x=b(A):c||(F=$&~F,F!==0&&(x=b(F))))):($=m&~M,$!==0?x=b($):A!==0?x=b(A):c||(F=m&~F,F!==0&&(x=b(F)))),x===0?0:u!==0&&u!==x&&!(u&M)&&(M=x&-x,F=u&-u,M>=F||M===32&&(F&4194176)!==0)?u:x}function R(c,u){return(c.pendingLanes&~(c.suspendedLanes&~c.pingedLanes)&u)===0}function I(c,u){switch(c){case 1:case 2:case 4:case 8:return u+250;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 u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function U(){var c=mg;return mg<<=1,!(mg&4194176)&&(mg=128),c}function O(){var c=gg;return gg<<=1,!(gg&62914560)&&(gg=4194304),c}function w(c){for(var u=[],m=0;31>m;m++)u.push(c);return u}function B(c,u){c.pendingLanes|=u,u!==268435456&&(c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0)}function j(c,u,m,x,M,A){var F=c.pendingLanes;c.pendingLanes=m,c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0,c.expiredLanes&=m,c.entangledLanes&=m,c.errorRecoveryDisabledLanes&=m,c.shellSuspendCounter=0;var $=c.entanglements,he=c.expirationTimes,De=c.hiddenUpdates;for(m=F&~m;0<m;){var et=31-pa(m),dt=1<<et;$[et]=0,he[et]=-1;var mt=De[et];if(mt!==null)for(De[et]=null,et=0;et<mt.length;et++){var qt=mt[et];qt!==null&&(qt.lane&=-536870913)}m&=~dt}x!==0&&ee(c,x,0),A!==0&&M===0&&c.tag!==0&&(c.suspendedLanes|=A&~(F&~u))}function ee(c,u,m){c.pendingLanes|=u,c.suspendedLanes&=~u;var x=31-pa(u);c.entangledLanes|=u,c.entanglements[x]=c.entanglements[x]|1073741824|m&4194218}function se(c,u){var m=c.entangledLanes|=u;for(c=c.entanglements;m;){var x=31-pa(m),M=1<<x;M&u|c[x]&u&&(c[x]|=u),m&=~M}}function ae(c){return c&=-c,2<c?8<c?c&134217727?32:268435456:8:2}function W(c){if(ma&&typeof ma.onCommitFiberRoot=="function")try{ma.onCommitFiberRoot(_p,c,void 0,(c.current.flags&128)===128)}catch{}}function te(c){if(typeof hz=="function"&&fz(c),ma&&typeof ma.setStrictMode=="function")try{ma.setStrictMode(_p,c)}catch{}}function K(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}function oe(c,u){if(typeof c=="object"&&c!==null){var m=BR.get(c);return m!==void 0?m:(u={value:c,source:u,stack:f(u)},BR.set(c,u),u)}return{value:c,source:u,stack:f(u)}}function ie(c,u){Nh[Oh++]=xg,Nh[Oh++]=_g,_g=c,xg=u}function Ce(c,u,m){Ha[Fa++]=xo,Ha[Fa++]=yo,Ha[Fa++]=Hc,Hc=c;var x=xo;c=yo;var M=32-pa(x)-1;x&=~(1<<M),m+=1;var A=32-pa(u)+M;if(30<A){var F=M-M%5;A=(x&(1<<F)-1).toString(32),x>>=F,M-=F,xo=1<<32-pa(u)+M|m<<M|x,yo=A+c}else xo=1<<A|m<<M|x,yo=c}function Xe(c){c.return!==null&&(ie(c,1),Ce(c,1,0))}function nt(c){for(;c===_g;)_g=Nh[--Oh],Nh[Oh]=null,xg=Nh[--Oh],Nh[Oh]=null;for(;c===Hc;)Hc=Ha[--Fa],Ha[Fa]=null,yo=Ha[--Fa],Ha[Fa]=null,xo=Ha[--Fa],Ha[Fa]=null}function tt(c,u){S(Tl,u),S(xp,c),S(ar,null),c=q9(u),v(ar),S(ar,c)}function gt(){v(ar),v(xp),v(Tl)}function ge(c){c.memoizedState!==null&&S(yg,c);var u=ar.current,m=j9(u,c.type);u!==m&&(S(xp,c),S(ar,m))}function Ae(c){xp.current===c&&(v(ar),v(xp)),yg.current===c&&(v(yg),_o?Bc._currentValue=Rh:Bc._currentValue2=Rh)}function Ze(c){var u=Error(r(418,""));throw Ke(oe(u,c)),OS}function ue(c,u){if(!za)throw Error(r(175));G7(c.stateNode,c.type,c.memoizedProps,u,c)||Ze(c)}function it(c){for(Ar=c.return;Ar;)switch(Ar.tag){case 3:case 27:Fs=!0;return;case 5:case 13:Fs=!1;return;default:Ar=Ar.return}}function bt(c){if(!za||c!==Ar)return!1;if(!mn)return it(c),mn=!0,!1;var u=!1;if(gr?c.tag!==3&&c.tag!==27&&(c.tag!==5||wR(c.type)&&!pg(c.type,c.memoizedProps))&&(u=!0):c.tag!==3&&(c.tag!==5||wR(c.type)&&!pg(c.type,c.memoizedProps))&&(u=!0),u&&vr&&Ze(c),it(c),c.tag===13){if(!za)throw Error(r(316));if(c=c.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(r(317));vr=W7(c)}else vr=Ar?bR(c.stateNode):null;return!0}function ot(){za&&(vr=Ar=null,mn=!1)}function Ke(c){ds===null?ds=[c]:ds.push(c)}function Te(){for(var c=Lh,u=LS=Lh=0;u<c;){var m=Ga[u];Ga[u++]=null;var x=Ga[u];Ga[u++]=null;var M=Ga[u];Ga[u++]=null;var A=Ga[u];if(Ga[u++]=null,x!==null&&M!==null){var F=x.pending;F===null?M.next=M:(M.next=F.next,F.next=M),x.pending=M}A!==0&&Fe(m,M,A)}}function G(c,u,m,x){Ga[Lh++]=c,Ga[Lh++]=u,Ga[Lh++]=m,Ga[Lh++]=x,LS|=x,c.lanes|=x,c=c.alternate,c!==null&&(c.lanes|=x)}function be(c,u,m,x){return G(c,u,m,x),Be(c)}function Ne(c,u){return G(c,null,null,u),Be(c)}function Fe(c,u,m){c.lanes|=m;var x=c.alternate;x!==null&&(x.lanes|=m);for(var M=!1,A=c.return;A!==null;)A.childLanes|=m,x=A.alternate,x!==null&&(x.childLanes|=m),A.tag===22&&(c=A.stateNode,c===null||c._visibility&1||(M=!0)),c=A,A=A.return;M&&u!==null&&c.tag===3&&(A=c.stateNode,M=31-pa(m),A=A.hiddenUpdates,c=A[M],c===null?A[M]=[u]:c.push(u),u.lane=m|536870912)}function Be(c){if(50<Rp)throw Rp=0,ZS=null,Error(r(185));for(var u=c.return;u!==null;)c=u,u=c.return;return c.tag===3?c.stateNode:null}function $e(c){c!==Ih&&c.next===null&&(Ih===null?Sg=Ih=c:Ih=Ih.next=c),Tg=!0,IS||(IS=!0,Ee(ct))}function Je(c,u){if(!US&&Tg){US=!0;do for(var m=!1,x=Sg;x!==null;){if(c!==0){var M=x.pendingLanes;if(M===0)var A=0;else{var F=x.suspendedLanes,$=x.pingedLanes;A=(1<<31-pa(42|c)+1)-1,A&=M&~(F&~$),A=A&201326677?A&201326677|1:A?A|2:0}A!==0&&(m=!0,ce(x,A))}else A=hn,A=N(x,x===Wn?A:0),!(A&3)||R(x,A)||(m=!0,ce(x,A));x=x.next}while(m);US=!1}}function ct(){Tg=IS=!1;var c=0;Uh!==0&&(n7()&&(c=Uh),Uh=0);for(var u=fs(),m=null,x=Sg;x!==null;){var M=x.next,A=k(x,u);A===0?(x.next=null,m===null?Sg=M:m.next=M,M===null&&(Ih=m)):(m=x,(c!==0||A&3)&&(Tg=!0)),x=M}Je(c)}function k(c,u){for(var m=c.suspendedLanes,x=c.pingedLanes,M=c.expirationTimes,A=c.pendingLanes&-62914561;0<A;){var F=31-pa(A),$=1<<F,he=M[F];he===-1?(!($&m)||$&x)&&(M[F]=I($,u)):he<=u&&(c.expiredLanes|=$),A&=~$}if(u=Wn,m=hn,m=N(c,c===u?m:0),x=c.callbackNode,m===0||c===u&&Xn===2||c.cancelPendingCommit!==null)return x!==null&&x!==null&&DS(x),c.callbackNode=null,c.callbackPriority=0;if(!(m&3)||R(c,m)){if(u=m&-m,u===c.callbackPriority)return u;switch(x!==null&&DS(x),ae(m)){case 2:case 8:m=cz;break;case 32:m=NS;break;case 268435456:m=uz;break;default:m=NS}return x=P.bind(null,c),m=vg(m,x),c.callbackPriority=u,c.callbackNode=m,u}return x!==null&&x!==null&&DS(x),c.callbackPriority=2,c.callbackNode=null,2}function P(c,u){var m=c.callbackNode;if(Uc()&&c.callbackNode!==m)return null;var x=hn;return x=N(c,c===Wn?x:0),x===0?null:(Gw(c,x,u),k(c,fs()),c.callbackNode!=null&&c.callbackNode===m?P.bind(null,c):null)}function ce(c,u){if(Uc())return null;Gw(c,u,!0)}function Ee(c){l7?c7(function(){Un&6?vg(zR,c):c()}):vg(zR,c)}function Le(){return Uh===0&&(Uh=U()),Uh}function ye(c,u){if(yp===null){var m=yp=[];PS=0,Ph=Le(),zh={status:"pending",value:void 0,then:function(x){m.push(x)}}}return PS++,u.then(vt,vt),u}function vt(){if(--PS===0&&yp!==null){zh!==null&&(zh.status="fulfilled");var c=yp;yp=null,Ph=0,zh=null;for(var u=0;u<c.length;u++)(0,c[u])()}}function je(c,u){var m=[],x={status:"pending",value:null,reason:null,then:function(M){m.push(M)}};return c.then(function(){x.status="fulfilled",x.value=u;for(var M=0;M<m.length;M++)(0,m[M])(u)},function(M){for(x.status="rejected",x.reason=M,M=0;M<m.length;M++)(0,m[M])(void 0)}),x}function xt(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function pt(c,u){c=c.updateQueue,u.updateQueue===c&&(u.updateQueue={baseState:c.baseState,firstBaseUpdate:c.firstBaseUpdate,lastBaseUpdate:c.lastBaseUpdate,shared:c.shared,callbacks:null})}function Ie(c){return{lane:c,tag:0,payload:null,callback:null,next:null}}function He(c,u,m){var x=c.updateQueue;if(x===null)return null;if(x=x.shared,Un&2){var M=x.pending;return M===null?u.next=u:(u.next=M.next,M.next=u),x.pending=u,u=Be(c),Fe(c,null,m),u}return G(c,x,u,m),Be(c)}function ht(c,u,m){if(u=u.updateQueue,u!==null&&(u=u.shared,(m&4194176)!==0)){var x=u.lanes;x&=c.pendingLanes,m|=x,u.lanes=m,se(c,m)}}function Q(c,u){var m=c.updateQueue,x=c.alternate;if(x!==null&&(x=x.updateQueue,m===x)){var M=null,A=null;if(m=m.firstBaseUpdate,m!==null){do{var F={lane:m.lane,tag:m.tag,payload:m.payload,callback:null,next:null};A===null?M=A=F:A=A.next=F,m=m.next}while(m!==null);A===null?M=A=u:A=A.next=u}else M=A=u;m={baseState:x.baseState,firstBaseUpdate:M,lastBaseUpdate:A,shared:x.shared,callbacks:x.callbacks},c.updateQueue=m;return}c=m.lastBaseUpdate,c===null?m.firstBaseUpdate=u:c.next=u,m.lastBaseUpdate=u}function pe(){if(zS){var c=zh;if(c!==null)throw c}}function Oe(c,u,m,x){zS=!1;var M=c.updateQueue;El=!1;var A=M.firstBaseUpdate,F=M.lastBaseUpdate,$=M.shared.pending;if($!==null){M.shared.pending=null;var he=$,De=he.next;he.next=null,F===null?A=De:F.next=De,F=he;var et=c.alternate;et!==null&&(et=et.updateQueue,$=et.lastBaseUpdate,$!==F&&($===null?et.firstBaseUpdate=De:$.next=De,et.lastBaseUpdate=he))}if(A!==null){var dt=M.baseState;F=0,et=De=he=null,$=A;do{var mt=$.lane&-536870913,qt=mt!==$.lane;if(qt?(hn&mt)===mt:(x&mt)===mt){mt!==0&&mt===Ph&&(zS=!0),et!==null&&(et=et.next={lane:0,tag:$.tag,payload:$.payload,callback:null,next:null});e:{var Wa=c,Cp=$;mt=u;var jc=m;switch(Cp.tag){case 1:if(Wa=Cp.payload,typeof Wa=="function"){dt=Wa.call(jc,dt,mt);break e}dt=Wa;break e;case 3:Wa.flags=Wa.flags&-65537|128;case 0:if(Wa=Cp.payload,mt=typeof Wa=="function"?Wa.call(jc,dt,mt):Wa,mt==null)break e;dt=gS({},dt,mt);break e;case 2:El=!0}}mt=$.callback,mt!==null&&(c.flags|=64,qt&&(c.flags|=8192),qt=M.callbacks,qt===null?M.callbacks=[mt]:qt.push(mt))}else qt={lane:mt,tag:$.tag,payload:$.payload,callback:$.callback,next:null},et===null?(De=et=qt,he=dt):et=et.next=qt,F|=mt;if($=$.next,$===null){if($=M.shared.pending,$===null)break;qt=$,$=qt.next,qt.next=null,M.lastBaseUpdate=qt,M.shared.pending=null}}while(!0);et===null&&(he=dt),M.baseState=he,M.firstBaseUpdate=De,M.lastBaseUpdate=et,A===null&&(M.shared.lanes=0),Al|=F,c.lanes=F,c.memoizedState=dt}}function q(c,u){if(typeof c!="function")throw Error(r(191,c));c.call(u)}function ke(c,u){var m=c.callbacks;if(m!==null)for(c.callbacks=null,c=0;c<m.length;c++)q(m[c],u)}function me(c,u){if(ga(c,u))return!0;if(typeof c!="object"||c===null||typeof u!="object"||u===null)return!1;var m=Object.keys(c),x=Object.keys(u);if(m.length!==x.length)return!1;for(x=0;x<m.length;x++){var M=m[x];if(!dz.call(u,M)||!ga(c[M],u[M]))return!1}return!0}function We(c){return c=c.status,c==="fulfilled"||c==="rejected"}function Ge(){}function we(c,u,m){switch(m=c[m],m===void 0?c.push(u):m!==u&&(u.then(Ge,Ge),u=m),u.status){case"fulfilled":return u.value;case"rejected":throw c=u.reason,c===Sp?Error(r(483)):c;default:if(typeof u.status=="string")u.then(Ge,Ge);else{if(c=Wn,c!==null&&100<c.shellSuspendCounter)throw Error(r(482));c=u,c.status="pending",c.then(function(x){if(u.status==="pending"){var M=u;M.status="fulfilled",M.value=x}},function(x){if(u.status==="pending"){var M=u;M.status="rejected",M.reason=x}})}switch(u.status){case"fulfilled":return u.value;case"rejected":throw c=u.reason,c===Sp?Error(r(483)):c}throw Bh=u,Sp}}function at(){if(Bh===null)throw Error(r(459));var c=Bh;return Bh=null,c}function St(c){var u=Tp;return Tp+=1,Hh===null&&(Hh=[]),we(Hh,c,u)}function Gt(c,u){u=u.props.ref,c.ref=u!==void 0?u:null}function Vt(c,u){throw u.$$typeof===G9?Error(r(525)):(c=Object.prototype.toString.call(u),Error(r(31,c==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":c)))}function li(c){var u=c._init;return u(c._payload)}function ci(c){function u(ve,le){if(c){var xe=ve.deletions;xe===null?(ve.deletions=[le],ve.flags|=16):xe.push(le)}}function m(ve,le){if(!c)return null;for(;le!==null;)u(ve,le),le=le.sibling;return null}function x(ve){for(var le=new Map;ve!==null;)ve.key!==null?le.set(ve.key,ve):le.set(ve.index,ve),ve=ve.sibling;return le}function M(ve,le){return ve=_l(ve,le),ve.index=0,ve.sibling=null,ve}function A(ve,le,xe){return ve.index=xe,c?(xe=ve.alternate,xe!==null?(xe=xe.index,xe<le?(ve.flags|=33554434,le):xe):(ve.flags|=33554434,le)):(ve.flags|=1048576,le)}function F(ve){return c&&ve.alternate===null&&(ve.flags|=33554434),ve}function $(ve,le,xe,Qe){return le===null||le.tag!==6?(le=dS(xe,ve.mode,Qe),le.return=ve,le):(le=M(le,xe),le.return=ve,le)}function he(ve,le,xe,Qe){var Rt=xe.type;return Rt===wh?et(ve,le,xe.props.children,Qe,xe.key):le!==null&&(le.elementType===Rt||typeof Rt=="object"&&Rt!==null&&Rt.$$typeof===yl&&li(Rt)===le.type)?(le=M(le,xe.props),Gt(le,xe),le.return=ve,le):(le=hg(xe.type,xe.key,xe.props,null,ve.mode,Qe),Gt(le,xe),le.return=ve,le)}function De(ve,le,xe,Qe){return le===null||le.tag!==4||le.stateNode.containerInfo!==xe.containerInfo||le.stateNode.implementation!==xe.implementation?(le=pS(xe,ve.mode,Qe),le.return=ve,le):(le=M(le,xe.children||[]),le.return=ve,le)}function et(ve,le,xe,Qe,Rt){return le===null||le.tag!==7?(le=Pc(xe,ve.mode,Qe,Rt),le.return=ve,le):(le=M(le,xe),le.return=ve,le)}function dt(ve,le,xe){if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return le=dS(""+le,ve.mode,xe),le.return=ve,le;if(typeof le=="object"&&le!==null){switch(le.$$typeof){case fg:return xe=hg(le.type,le.key,le.props,null,ve.mode,xe),Gt(xe,le),xe.return=ve,xe;case Ah:return le=pS(le,ve.mode,xe),le.return=ve,le;case yl:var Qe=le._init;return le=Qe(le._payload),dt(ve,le,xe)}if(dg(le)||a(le))return le=Pc(le,ve.mode,xe,null),le.return=ve,le;if(typeof le.then=="function")return dt(ve,St(le),xe);if(le.$$typeof===xl)return dt(ve,ag(ve,le),xe);Vt(ve,le)}return null}function mt(ve,le,xe,Qe){var Rt=le!==null?le.key:null;if(typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint")return Rt!==null?null:$(ve,le,""+xe,Qe);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case fg:return xe.key===Rt?he(ve,le,xe,Qe):null;case Ah:return xe.key===Rt?De(ve,le,xe,Qe):null;case yl:return Rt=xe._init,xe=Rt(xe._payload),mt(ve,le,xe,Qe)}if(dg(xe)||a(xe))return Rt!==null?null:et(ve,le,xe,Qe,null);if(typeof xe.then=="function")return mt(ve,le,St(xe),Qe);if(xe.$$typeof===xl)return mt(ve,le,ag(ve,xe),Qe);Vt(ve,xe)}return null}function qt(ve,le,xe,Qe,Rt){if(typeof Qe=="string"&&Qe!==""||typeof Qe=="number"||typeof Qe=="bigint")return ve=ve.get(xe)||null,$(le,ve,""+Qe,Rt);if(typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case fg:return ve=ve.get(Qe.key===null?xe:Qe.key)||null,he(le,ve,Qe,Rt);case Ah:return ve=ve.get(Qe.key===null?xe:Qe.key)||null,De(le,ve,Qe,Rt);case yl:var Kn=Qe._init;return Qe=Kn(Qe._payload),qt(ve,le,xe,Qe,Rt)}if(dg(Qe)||a(Qe))return ve=ve.get(xe)||null,et(le,ve,Qe,Rt,null);if(typeof Qe.then=="function")return qt(ve,le,xe,St(Qe),Rt);if(Qe.$$typeof===xl)return qt(ve,le,xe,ag(le,Qe),Rt);Vt(le,Qe)}return null}function Wa(ve,le,xe,Qe){for(var Rt=null,Kn=null,Pt=le,gn=le=0,ji=null;Pt!==null&&gn<xe.length;gn++){Pt.index>gn?(ji=Pt,Pt=null):ji=Pt.sibling;var vn=mt(ve,Pt,xe[gn],Qe);if(vn===null){Pt===null&&(Pt=ji);break}c&&Pt&&vn.alternate===null&&u(ve,Pt),le=A(vn,le,gn),Kn===null?Rt=vn:Kn.sibling=vn,Kn=vn,Pt=ji}if(gn===xe.length)return m(ve,Pt),mn&&ie(ve,gn),Rt;if(Pt===null){for(;gn<xe.length;gn++)Pt=dt(ve,xe[gn],Qe),Pt!==null&&(le=A(Pt,le,gn),Kn===null?Rt=Pt:Kn.sibling=Pt,Kn=Pt);return mn&&ie(ve,gn),Rt}for(Pt=x(Pt);gn<xe.length;gn++)ji=qt(Pt,ve,gn,xe[gn],Qe),ji!==null&&(c&&ji.alternate!==null&&Pt.delete(ji.key===null?gn:ji.key),le=A(ji,le,gn),Kn===null?Rt=ji:Kn.sibling=ji,Kn=ji);return c&&Pt.forEach(function(Rl){return u(ve,Rl)}),mn&&ie(ve,gn),Rt}function Cp(ve,le,xe,Qe){if(xe==null)throw Error(r(151));for(var Rt=null,Kn=null,Pt=le,gn=le=0,ji=null,vn=xe.next();Pt!==null&&!vn.done;gn++,vn=xe.next()){Pt.index>gn?(ji=Pt,Pt=null):ji=Pt.sibling;var Rl=mt(ve,Pt,vn.value,Qe);if(Rl===null){Pt===null&&(Pt=ji);break}c&&Pt&&Rl.alternate===null&&u(ve,Pt),le=A(Rl,le,gn),Kn===null?Rt=Rl:Kn.sibling=Rl,Kn=Rl,Pt=ji}if(vn.done)return m(ve,Pt),mn&&ie(ve,gn),Rt;if(Pt===null){for(;!vn.done;gn++,vn=xe.next())vn=dt(ve,vn.value,Qe),vn!==null&&(le=A(vn,le,gn),Kn===null?Rt=vn:Kn.sibling=vn,Kn=vn);return mn&&ie(ve,gn),Rt}for(Pt=x(Pt);!vn.done;gn++,vn=xe.next())vn=qt(Pt,ve,gn,vn.value,Qe),vn!==null&&(c&&vn.alternate!==null&&Pt.delete(vn.key===null?gn:vn.key),le=A(vn,le,gn),Kn===null?Rt=vn:Kn.sibling=vn,Kn=vn);return c&&Pt.forEach(function(yz){return u(ve,yz)}),mn&&ie(ve,gn),Rt}function jc(ve,le,xe,Qe){if(typeof xe=="object"&&xe!==null&&xe.type===wh&&xe.key===null&&(xe=xe.props.children),typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case fg:e:{for(var Rt=xe.key;le!==null;){if(le.key===Rt){if(Rt=xe.type,Rt===wh){if(le.tag===7){m(ve,le.sibling),Qe=M(le,xe.props.children),Qe.return=ve,ve=Qe;break e}}else if(le.elementType===Rt||typeof Rt=="object"&&Rt!==null&&Rt.$$typeof===yl&&li(Rt)===le.type){m(ve,le.sibling),Qe=M(le,xe.props),Gt(Qe,xe),Qe.return=ve,ve=Qe;break e}m(ve,le);break}else u(ve,le);le=le.sibling}xe.type===wh?(Qe=Pc(xe.props.children,ve.mode,Qe,xe.key),Qe.return=ve,ve=Qe):(Qe=hg(xe.type,xe.key,xe.props,null,ve.mode,Qe),Gt(Qe,xe),Qe.return=ve,ve=Qe)}return F(ve);case Ah:e:{for(Rt=xe.key;le!==null;){if(le.key===Rt)if(le.tag===4&&le.stateNode.containerInfo===xe.containerInfo&&le.stateNode.implementation===xe.implementation){m(ve,le.sibling),Qe=M(le,xe.children||[]),Qe.return=ve,ve=Qe;break e}else{m(ve,le);break}else u(ve,le);le=le.sibling}Qe=pS(xe,ve.mode,Qe),Qe.return=ve,ve=Qe}return F(ve);case yl:return Rt=xe._init,xe=Rt(xe._payload),jc(ve,le,xe,Qe)}if(dg(xe))return Wa(ve,le,xe,Qe);if(a(xe)){if(Rt=a(xe),typeof Rt!="function")throw Error(r(150));return xe=Rt.call(xe),Cp(ve,le,xe,Qe)}if(typeof xe.then=="function")return jc(ve,le,St(xe),Qe);if(xe.$$typeof===xl)return jc(ve,le,ag(ve,xe),Qe);Vt(ve,xe)}return typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint"?(xe=""+xe,le!==null&&le.tag===6?(m(ve,le.sibling),Qe=M(le,xe),Qe.return=ve,ve=Qe):(m(ve,le),Qe=dS(xe,ve.mode,Qe),Qe.return=ve,ve=Qe),F(ve)):m(ve,le)}return function(ve,le,xe,Qe){try{Tp=0;var Rt=jc(ve,le,xe,Qe);return Hh=null,Rt}catch(Pt){if(Pt===Sp)throw Pt;var Kn=t(29,Pt,null,ve.mode);return Kn.lanes=Qe,Kn.return=ve,Kn}finally{}}}function ho(c,u){c=Mo,S(Mg,c),S(Fh,u),Mo=c|u.baseLanes}function Us(){S(Mg,Mo),S(Fh,Fh.current)}function Ps(){Mo=Mg.current,v(Fh),v(Mg)}function Mi(c){var u=c.alternate;S(Hi,Hi.current&1),S(Va,c),Gs===null&&(u===null||Fh.current!==null||u.memoizedState!==null)&&(Gs=c)}function zs(c){if(c.tag===22){if(S(Hi,Hi.current),S(Va,c),Gs===null){var u=c.alternate;u!==null&&u.memoizedState!==null&&(Gs=c)}}else fr()}function fr(){S(Hi,Hi.current),S(Va,Va.current)}function Xi(c){v(Va),Gs===c&&(Gs=null),v(Hi)}function Gr(c){for(var u=c;u!==null;){if(u.tag===13){var m=u.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||AS(m)||wS(m)))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if(u.flags&128)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===c)break;for(;u.sibling===null;){if(u.return===null||u.return===c)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}function On(){throw Error(r(321))}function Ua(c,u){if(u===null)return!1;for(var m=0;m<u.length&&m<c.length;m++)if(!ga(c[m],u[m]))return!1;return!0}function Bs(c,u,m,x,M,A){return Ml=A,$t=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,Ft.H=c===null||c.memoizedState===null?Vc:bl,Gc=!1,A=m(x,M),Gc=!1,Gh&&(A=fo(u,m,x,M)),Hs(c),A}function Hs(c){Ft.H=Vs;var u=In!==null&&In.next!==null;if(Ml=0,Ai=In=$t=null,bg=!1,Ep=0,Vh=null,u)throw Error(r(300));c===null||Yi||(c=c.dependencies,c!==null&&rg(c)&&(Yi=!0))}function fo(c,u,m,x){$t=c;var M=0;do{if(Gh&&(Vh=null),Ep=0,Gh=!1,25<=M)throw Error(r(301));if(M+=1,Ai=In=null,c.updateQueue!=null){var A=c.updateQueue;A.lastEffect=null,A.events=null,A.stores=null,A.memoCache!=null&&(A.memoCache.index=0)}Ft.H=kc,A=u(m,x)}while(Gh);return A}function la(){var c=Ft.H,u=c.useState()[0];return u=typeof u.then=="function"?V(u):u,c=c.useState()[0],(In!==null?In.memoizedState:null)!==c&&($t.flags|=1024),u}function dr(){var c=Ag!==0;return Ag=0,c}function C(c,u,m){u.updateQueue=c.updateQueue,u.flags&=-2053,c.lanes&=~m}function z(c){if(bg){for(c=c.memoizedState;c!==null;){var u=c.queue;u!==null&&(u.pending=null),c=c.next}bg=!1}Ml=0,Ai=In=$t=null,Gh=!1,Ep=Ag=0,Vh=null}function Y(){var c={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ai===null?$t.memoizedState=Ai=c:Ai=Ai.next=c,Ai}function D(){if(In===null){var c=$t.alternate;c=c!==null?c.memoizedState:null}else c=In.next;var u=Ai===null?$t.memoizedState:Ai.next;if(u!==null)Ai=u,In=c;else{if(c===null)throw $t.alternate===null?Error(r(467)):Error(r(310));In=c,c={memoizedState:In.memoizedState,baseState:In.baseState,baseQueue:In.baseQueue,queue:In.queue,next:null},Ai===null?$t.memoizedState=Ai=c:Ai=Ai.next=c}return Ai}function V(c){var u=Ep;return Ep+=1,Vh===null&&(Vh=[]),c=we(Vh,c,u),u=$t,(Ai===null?u.memoizedState:Ai.next)===null&&(u=u.alternate,Ft.H=u===null||u.memoizedState===null?Vc:bl),c}function Z(c){if(c!==null&&typeof c=="object"){if(typeof c.then=="function")return V(c);if(c.$$typeof===xl)return pr(c)}throw Error(r(438,String(c)))}function H(c){var u=null,m=$t.updateQueue;if(m!==null&&(u=m.memoCache),u==null){var x=$t.alternate;x!==null&&(x=x.updateQueue,x!==null&&(x=x.memoCache,x!=null&&(u={data:x.data.map(function(M){return M.slice()}),index:0})))}if(u==null&&(u={data:[],index:0}),m===null&&(m=HS(),$t.updateQueue=m),m.memoCache=u,m=u.data[u.index],m===void 0)for(m=u.data[u.index]=Array(c),x=0;x<c;x++)m[x]=k9;return u.index++,m}function X(c,u){return typeof u=="function"?u(c):u}function ne(c){var u=D();return re(u,In,c)}function re(c,u,m){var x=c.queue;if(x===null)throw Error(r(311));x.lastRenderedReducer=m;var M=c.baseQueue,A=x.pending;if(A!==null){if(M!==null){var F=M.next;M.next=A.next,A.next=F}u.baseQueue=M=A,x.pending=null}if(A=c.baseState,M===null)c.memoizedState=A;else{u=M.next;var $=F=null,he=null,De=u,et=!1;do{var dt=De.lane&-536870913;if(dt!==De.lane?(hn&dt)===dt:(Ml&dt)===dt){var mt=De.revertLane;if(mt===0)he!==null&&(he=he.next={lane:0,revertLane:0,action:De.action,hasEagerState:De.hasEagerState,eagerState:De.eagerState,next:null}),dt===Ph&&(et=!0);else if((Ml&mt)===mt){De=De.next,mt===Ph&&(et=!0);continue}else dt={lane:0,revertLane:De.revertLane,action:De.action,hasEagerState:De.hasEagerState,eagerState:De.eagerState,next:null},he===null?($=he=dt,F=A):he=he.next=dt,$t.lanes|=mt,Al|=mt;dt=De.action,Gc&&m(A,dt),A=De.hasEagerState?De.eagerState:m(A,dt)}else mt={lane:dt,revertLane:De.revertLane,action:De.action,hasEagerState:De.hasEagerState,eagerState:De.eagerState,next:null},he===null?($=he=mt,F=A):he=he.next=mt,$t.lanes|=dt,Al|=dt;De=De.next}while(De!==null&&De!==u);if(he===null?F=A:he.next=$,!ga(A,c.memoizedState)&&(Yi=!0,et&&(m=zh,m!==null)))throw m;c.memoizedState=A,c.baseState=F,c.baseQueue=he,x.lastRenderedState=A}return M===null&&(x.lanes=0),[c.memoizedState,x.dispatch]}function fe(c){var u=D(),m=u.queue;if(m===null)throw Error(r(311));m.lastRenderedReducer=c;var x=m.dispatch,M=m.pending,A=u.memoizedState;if(M!==null){m.pending=null;var F=M=M.next;do A=c(A,F.action),F=F.next;while(F!==M);ga(A,u.memoizedState)||(Yi=!0),u.memoizedState=A,u.baseQueue===null&&(u.baseState=A),m.lastRenderedState=A}return[A,x]}function _e(c,u,m){var x=$t,M=D(),A=mn;if(A){if(m===void 0)throw Error(r(407));m=m()}else m=u();var F=!ga((In||M).memoizedState,m);if(F&&(M.memoizedState=m,Yi=!0),M=M.queue,Cy(Pe.bind(null,x,M,c),[c]),M.getSnapshot!==u||F||Ai!==null&&Ai.memoizedState.tag&1){if(x.flags|=2048,kn(9,Re.bind(null,x,M,m,u),{destroy:void 0},null),Wn===null)throw Error(r(349));A||Ml&60||Se(x,u,m)}return m}function Se(c,u,m){c.flags|=16384,c={getSnapshot:u,value:m},u=$t.updateQueue,u===null?(u=HS(),$t.updateQueue=u,u.stores=[c]):(m=u.stores,m===null?u.stores=[c]:m.push(c))}function Re(c,u,m,x){u.value=m,u.getSnapshot=x,ze(u)&&Ye(c)}function Pe(c,u,m){return m(function(){ze(u)&&Ye(c)})}function ze(c){var u=c.getSnapshot;c=c.value;try{var m=u();return!ga(c,m)}catch{return!0}}function Ye(c){var u=Ne(c,2);u!==null&&br(u,c,2)}function lt(c){var u=Y();if(typeof c=="function"){var m=c;if(c=m(),Gc){te(!0);try{m()}finally{te(!1)}}}return u.memoizedState=u.baseState=c,u.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:X,lastRenderedState:c},u}function Tt(c,u,m,x){return c.baseState=m,re(c,In,typeof x=="function"?x:X)}function At(c,u,m,x,M){if(ng(c))throw Error(r(485));if(c=u.action,c!==null){var A={payload:M,action:c,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(F){A.listeners.push(F)}};Ft.T!==null?m(!0):A.isTransition=!1,x(A),m=u.pending,m===null?(A.next=u.pending=A,ft(u,A)):(A.next=m.next,u.pending=m.next=A)}}function ft(c,u){var m=u.action,x=u.payload,M=c.state;if(u.isTransition){var A=Ft.T,F={};Ft.T=F;try{var $=m(M,x),he=Ft.S;he!==null&&he(F,$),wt(c,u,$)}catch(De){Kt(c,u,De)}finally{Ft.T=A}}else try{A=m(M,x),wt(c,u,A)}catch(De){Kt(c,u,De)}}function wt(c,u,m){m!==null&&typeof m=="object"&&typeof m.then=="function"?m.then(function(x){st(c,u,x)},function(x){return Kt(c,u,x)}):st(c,u,m)}function st(c,u,m){u.status="fulfilled",u.value=m,Ln(u),c.state=m,u=c.pending,u!==null&&(m=u.next,m===u?c.pending=null:(m=m.next,u.next=m,ft(c,m)))}function Kt(c,u,m){var x=c.pending;if(c.pending=null,x!==null){x=x.next;do u.status="rejected",u.reason=m,Ln(u),u=u.next;while(u!==x)}c.action=null}function Ln(c){c=c.listeners;for(var u=0;u<c.length;u++)(0,c[u])()}function Yt(c,u){return u}function kt(c,u){if(mn){var m=Wn.formState;if(m!==null){e:{var x=$t;if(mn){if(vr){var M=I7(vr,Fs);if(M){vr=bR(M),x=U7(M);break e}}Ze(x)}x=!1}x&&(u=m[0])}}m=Y(),m.memoizedState=m.baseState=u,x={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yt,lastRenderedState:u},m.queue=x,m=KA.bind(null,$t,x),x.dispatch=m,x=lt(!1);var A=Ly.bind(null,$t,!1,x.queue);return x=Y(),M={state:u,dispatch:null,action:c,pending:null},x.queue=M,m=At.bind(null,$t,M,A,m),M.dispatch=m,x.memoizedState=c,[u,m,!1]}function Dt(c){var u=D();return Hn(u,In,c)}function Hn(c,u,m){u=re(c,u,Yt)[0],c=ne(X)[0],u=typeof u=="object"&&u!==null&&typeof u.then=="function"?V(u):u;var x=D(),M=x.queue,A=M.dispatch;return m!==x.memoizedState&&($t.flags|=2048,kn(9,bi.bind(null,M,m),{destroy:void 0},null)),[u,A,c]}function bi(c,u){c.action=u}function Mn(c){var u=D(),m=In;if(m!==null)return Hn(u,m,c);D(),u=u.memoizedState,m=D();var x=m.queue.dispatch;return m.memoizedState=c,[u,x,!1]}function kn(c,u,m,x){return c={tag:c,create:u,inst:m,deps:x,next:null},u=$t.updateQueue,u===null&&(u=HS(),$t.updateQueue=u),m=u.lastEffect,m===null?u.lastEffect=c.next=c:(x=m.next,m.next=c,c.next=x,u.lastEffect=c),c}function Sh(){return D().memoizedState}function Pa(c,u,m,x){var M=Y();$t.flags|=c,M.memoizedState=kn(1|u,m,{destroy:void 0},x===void 0?null:x)}function tg(c,u,m,x){var M=D();x=x===void 0?null:x;var A=M.memoizedState.inst;In!==null&&x!==null&&Ua(x,In.memoizedState.deps)?M.memoizedState=kn(u,m,A,x):($t.flags|=c,M.memoizedState=kn(1|u,m,A,x))}function BA(c,u){Pa(8390656,8,c,u)}function Cy(c,u){tg(2048,8,c,u)}function HA(c,u){return tg(4,2,c,u)}function FA(c,u){return tg(4,4,c,u)}function GA(c,u){if(typeof u=="function"){c=c();var m=u(c);return function(){typeof m=="function"?m():u(null)}}if(u!=null)return c=c(),u.current=c,function(){u.current=null}}function VA(c,u,m){m=m!=null?m.concat([c]):null,tg(4,4,GA.bind(null,u,c),m)}function Dy(){}function kA(c,u){var m=D();u=u===void 0?null:u;var x=m.memoizedState;return u!==null&&Ua(u,x[1])?x[0]:(m.memoizedState=[c,u],c)}function WA(c,u){var m=D();u=u===void 0?null:u;var x=m.memoizedState;if(u!==null&&Ua(u,x[1]))return x[0];if(x=c(),Gc){te(!0);try{c()}finally{te(!1)}}return m.memoizedState=[x,u],x}function Ny(c,u,m){return m===void 0||Ml&1073741824?c.memoizedState=u:(c.memoizedState=m,c=Fw(),$t.lanes|=c,Al|=c,m)}function XA(c,u,m,x){return ga(m,u)?m:Fh.current!==null?(c=Ny(c,m,x),ga(c,u)||(Yi=!0),c):Ml&42?(c=Fw(),$t.lanes|=c,Al|=c,u):(Yi=!0,c.memoizedState=m)}function YA(c,u,m,x,M){var A=zc();kr(A!==0&&8>A?A:8);var F=Ft.T,$={};Ft.T=$,Ly(c,!1,u,m);try{var he=M(),De=Ft.S;if(De!==null&&De($,he),he!==null&&typeof he=="object"&&typeof he.then=="function"){var et=je(he,x);op(c,u,et,fa(c))}else op(c,u,x,fa(c))}catch(dt){op(c,u,{then:function(){},status:"rejected",reason:dt},fa())}finally{kr(A),Ft.T=F}}function qA(c){var u=c.memoizedState;if(u!==null)return u;u={memoizedState:Rh,baseState:Rh,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:X,lastRenderedState:Rh},next:null};var m={};return u.next={memoizedState:m,baseState:m,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:X,lastRenderedState:m},next:null},c.memoizedState=u,c=c.alternate,c!==null&&(c.memoizedState=u),u}function Oy(){return pr(Bc)}function jA(){return D().memoizedState}function ZA(){return D().memoizedState}function S9(c){for(var u=c.return;u!==null;){switch(u.tag){case 24:case 3:var m=fa();c=Ie(m);var x=He(u,c,m);x!==null&&(br(x,u,m),ht(x,u,m)),u={cache:Yy()},c.payload=u;return}u=u.return}}function T9(c,u,m){var x=fa();m={lane:x,revertLane:0,action:m,hasEagerState:!1,eagerState:null,next:null},ng(c)?QA(u,m):(m=be(c,u,m,x),m!==null&&(br(m,c,x),JA(m,u,x)))}function KA(c,u,m){var x=fa();op(c,u,m,x)}function op(c,u,m,x){var M={lane:x,revertLane:0,action:m,hasEagerState:!1,eagerState:null,next:null};if(ng(c))QA(u,M);else{var A=c.alternate;if(c.lanes===0&&(A===null||A.lanes===0)&&(A=u.lastRenderedReducer,A!==null))try{var F=u.lastRenderedState,$=A(F,m);if(M.hasEagerState=!0,M.eagerState=$,ga($,F))return G(c,u,M,0),Wn===null&&Te(),!1}catch{}finally{}if(m=be(c,u,M,x),m!==null)return br(m,c,x),JA(m,u,x),!0}return!1}function Ly(c,u,m,x){if(x={lane:2,revertLane:Le(),action:x,hasEagerState:!1,eagerState:null,next:null},ng(c)){if(u)throw Error(r(479))}else u=be(c,m,x,2),u!==null&&br(u,c,2)}function ng(c){var u=c.alternate;return c===$t||u!==null&&u===$t}function QA(c,u){Gh=bg=!0;var m=c.pending;m===null?u.next=u:(u.next=m.next,m.next=u),c.pending=u}function JA(c,u,m){if(m&4194176){var x=u.lanes;x&=c.pendingLanes,m|=x,u.lanes=m,se(c,m)}}function Iy(c,u,m,x){u=c.memoizedState,m=m(x,u),m=m==null?u:gS({},u,m),c.memoizedState=m,c.lanes===0&&(c.updateQueue.baseState=m)}function $A(c,u,m,x,M,A,F){return c=c.stateNode,typeof c.shouldComponentUpdate=="function"?c.shouldComponentUpdate(x,A,F):u.prototype&&u.prototype.isPureReactComponent?!me(m,x)||!me(M,A):!0}function ew(c,u,m,x){c=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(m,x),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(m,x),u.state!==c&&FS.enqueueReplaceState(u,u.state,null)}function Nc(c,u){var m=u;if("ref"in u){m={};for(var x in u)x!=="ref"&&(m[x]=u[x])}if(c=c.defaultProps){m===u&&(m=gS({},m));for(var M in c)m[M]===void 0&&(m[M]=c[M])}return m}function ig(c,u){try{var m=c.onUncaughtError;m(u.value,{componentStack:u.stack})}catch(x){setTimeout(function(){throw x})}}function tw(c,u,m){try{var x=c.onCaughtError;x(m.value,{componentStack:m.stack,errorBoundary:u.tag===1?u.stateNode:null})}catch(M){setTimeout(function(){throw M})}}function Uy(c,u,m){return m=Ie(m),m.tag=3,m.payload={element:null},m.callback=function(){ig(c,u)},m}function nw(c){return c=Ie(c),c.tag=3,c}function iw(c,u,m,x){var M=m.type.getDerivedStateFromError;if(typeof M=="function"){var A=x.value;c.payload=function(){return M(A)},c.callback=function(){tw(u,m,x)}}var F=m.stateNode;F!==null&&typeof F.componentDidCatch=="function"&&(c.callback=function(){tw(u,m,x),typeof M!="function"&&(wl===null?wl=new Set([this]):wl.add(this));var $=x.stack;this.componentDidCatch(x.value,{componentStack:$!==null?$:""})})}function E9(c,u,m,x,M){if(m.flags|=32768,x!==null&&typeof x=="object"&&typeof x.then=="function"){if(u=m.alternate,u!==null&&cp(u,m,M,!0),m=Va.current,m!==null){switch(m.tag){case 13:return Gs===null?cS():m.alternate===null&&mi===0&&(mi=3),m.flags&=-257,m.flags|=65536,m.lanes=M,x===Eg?m.flags|=16384:(u=m.updateQueue,u===null?m.updateQueue=new Set([x]):u.add(x),hS(c,x,M)),!1;case 22:return m.flags|=65536,x===Eg?m.flags|=16384:(u=m.updateQueue,u===null?(u={transitions:null,markerInstances:null,retryQueue:new Set([x])},m.updateQueue=u):(m=u.retryQueue,m===null?u.retryQueue=new Set([x]):m.add(x)),hS(c,x,M)),!1}throw Error(r(435,m.tag))}return hS(c,x,M),cS(),!1}if(mn)return u=Va.current,u!==null?(!(u.flags&65536)&&(u.flags|=256),u.flags|=65536,u.lanes=M,x!==OS&&(c=Error(r(422),{cause:x}),Ke(oe(c,m)))):(x!==OS&&(u=Error(r(423),{cause:x}),Ke(oe(u,m))),c=c.current.alternate,c.flags|=65536,M&=-M,c.lanes|=M,x=oe(x,m),M=Uy(c.stateNode,x,M),Q(c,M),mi!==4&&(mi=2)),!1;var A=Error(r(520),{cause:x});if(A=oe(A,m),bp===null?bp=[A]:bp.push(A),mi!==4&&(mi=2),u===null)return!0;x=oe(x,m),m=u;do{switch(m.tag){case 3:return m.flags|=65536,c=M&-M,m.lanes|=c,c=Uy(m.stateNode,x,c),Q(m,c),!1;case 1:if(u=m.type,A=m.stateNode,(m.flags&128)===0&&(typeof u.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(wl===null||!wl.has(A))))return m.flags|=65536,M&=-M,m.lanes|=M,M=nw(M),iw(M,c,m,x),Q(m,M),!1}m=m.return}while(m!==null);return!1}function rr(c,u,m,x){u.child=c===null?HR(u,null,m,x):Fc(u,c.child,m,x)}function rw(c,u,m,x,M){m=m.render;var A=u.ref;if("ref"in x){var F={};for(var $ in x)$!=="ref"&&(F[$]=x[$])}else F=x;return Oc(u),x=Bs(c,u,m,F,A,M),$=dr(),c!==null&&!Yi?(C(c,u,M),po(c,u,M)):(mn&&$&&Xe(u),u.flags|=1,rr(c,u,x,M),u.child)}function aw(c,u,m,x,M){if(c===null){var A=m.type;return typeof A=="function"&&!fS(A)&&A.defaultProps===void 0&&m.compare===null?(u.tag=15,u.type=A,sw(c,u,A,x,M)):(c=hg(m.type,null,x,u,u.mode,M),c.ref=u.ref,c.return=u,u.child=c)}if(A=c.child,!ky(c,M)){var F=A.memoizedProps;if(m=m.compare,m=m!==null?m:me,m(F,x)&&c.ref===u.ref)return po(c,u,M)}return u.flags|=1,c=_l(A,x),c.ref=u.ref,c.return=u,u.child=c}function sw(c,u,m,x,M){if(c!==null){var A=c.memoizedProps;if(me(A,x)&&c.ref===u.ref)if(Yi=!1,u.pendingProps=x=A,ky(c,M))c.flags&131072&&(Yi=!0);else return u.lanes=c.lanes,po(c,u,M)}return Py(c,u,m,x,M)}function ow(c,u,m){var x=u.pendingProps,M=x.children,A=(u.stateNode._pendingVisibility&2)!==0,F=c!==null?c.memoizedState:null;if(lp(c,u),x.mode==="hidden"||A){if(u.flags&128){if(x=F!==null?F.baseLanes|m:m,c!==null){for(M=u.child=c.child,A=0;M!==null;)A=A|M.lanes|M.childLanes,M=M.sibling;u.childLanes=A&~x}else u.childLanes=0,u.child=null;return lw(c,u,x,m)}if(m&536870912)u.memoizedState={baseLanes:0,cachePool:null},c!==null&&sg(u,F!==null?F.cachePool:null),F!==null?ho(u,F):Us(),zs(u);else return u.lanes=u.childLanes=536870912,lw(c,u,F!==null?F.baseLanes|m:m,m)}else F!==null?(sg(u,F.cachePool),ho(u,F),fr(),u.memoizedState=null):(c!==null&&sg(u,null),Us(),fr());return rr(c,u,M,m),u.child}function lw(c,u,m,x){var M=qy();return M=M===null?null:{parent:_o?di._currentValue:di._currentValue2,pool:M},u.memoizedState={baseLanes:m,cachePool:M},c!==null&&sg(u,null),Us(),zs(u),c!==null&&cp(c,u,x,!0),null}function lp(c,u){var m=u.ref;if(m===null)c!==null&&c.ref!==null&&(u.flags|=2097664);else{if(typeof m!="function"&&typeof m!="object")throw Error(r(284));(c===null||c.ref!==m)&&(u.flags|=2097664)}}function Py(c,u,m,x,M){return Oc(u),m=Bs(c,u,m,x,void 0,M),x=dr(),c!==null&&!Yi?(C(c,u,M),po(c,u,M)):(mn&&x&&Xe(u),u.flags|=1,rr(c,u,m,M),u.child)}function cw(c,u,m,x,M,A){return Oc(u),u.updateQueue=null,m=fo(u,x,m,M),Hs(c),x=dr(),c!==null&&!Yi?(C(c,u,A),po(c,u,A)):(mn&&x&&Xe(u),u.flags|=1,rr(c,u,m,A),u.child)}function uw(c,u,m,x,M){if(Oc(u),u.stateNode===null){var A=Dh,F=m.contextType;typeof F=="object"&&F!==null&&(A=pr(F)),A=new m(x,A),u.memoizedState=A.state!==null&&A.state!==void 0?A.state:null,A.updater=FS,u.stateNode=A,A._reactInternals=u,A=u.stateNode,A.props=x,A.state=u.memoizedState,A.refs={},xt(u),F=m.contextType,A.context=typeof F=="object"&&F!==null?pr(F):Dh,A.state=u.memoizedState,F=m.getDerivedStateFromProps,typeof F=="function"&&(Iy(u,m,F,x),A.state=u.memoizedState),typeof m.getDerivedStateFromProps=="function"||typeof A.getSnapshotBeforeUpdate=="function"||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(F=A.state,typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount(),F!==A.state&&FS.enqueueReplaceState(A,A.state,null),Oe(u,x,A,M),pe(),A.state=u.memoizedState),typeof A.componentDidMount=="function"&&(u.flags|=4194308),x=!0}else if(c===null){A=u.stateNode;var $=u.memoizedProps,he=Nc(m,$);A.props=he;var De=A.context,et=m.contextType;F=Dh,typeof et=="object"&&et!==null&&(F=pr(et));var dt=m.getDerivedStateFromProps;et=typeof dt=="function"||typeof A.getSnapshotBeforeUpdate=="function",$=u.pendingProps!==$,et||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||($||De!==F)&&ew(u,A,x,F),El=!1;var mt=u.memoizedState;A.state=mt,Oe(u,x,A,M),pe(),De=u.memoizedState,$||mt!==De||El?(typeof dt=="function"&&(Iy(u,m,dt,x),De=u.memoizedState),(he=El||$A(u,m,he,x,mt,De,F))?(et||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(u.flags|=4194308)):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=x,u.memoizedState=De),A.props=x,A.state=De,A.context=F,x=he):(typeof A.componentDidMount=="function"&&(u.flags|=4194308),x=!1)}else{A=u.stateNode,pt(c,u),F=u.memoizedProps,et=Nc(m,F),A.props=et,dt=u.pendingProps,mt=A.context,De=m.contextType,he=Dh,typeof De=="object"&&De!==null&&(he=pr(De)),$=m.getDerivedStateFromProps,(De=typeof $=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(F!==dt||mt!==he)&&ew(u,A,x,he),El=!1,mt=u.memoizedState,A.state=mt,Oe(u,x,A,M),pe();var qt=u.memoizedState;F!==dt||mt!==qt||El||c!==null&&c.dependencies!==null&&rg(c.dependencies)?(typeof $=="function"&&(Iy(u,m,$,x),qt=u.memoizedState),(et=El||$A(u,m,et,x,mt,qt,he)||c!==null&&c.dependencies!==null&&rg(c.dependencies))?(De||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(x,qt,he),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(x,qt,he)),typeof A.componentDidUpdate=="function"&&(u.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof A.componentDidUpdate!="function"||F===c.memoizedProps&&mt===c.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||F===c.memoizedProps&&mt===c.memoizedState||(u.flags|=1024),u.memoizedProps=x,u.memoizedState=qt),A.props=x,A.state=qt,A.context=he,x=et):(typeof A.componentDidUpdate!="function"||F===c.memoizedProps&&mt===c.memoizedState||(u.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||F===c.memoizedProps&&mt===c.memoizedState||(u.flags|=1024),x=!1)}return A=x,lp(c,u),x=(u.flags&128)!==0,A||x?(A=u.stateNode,m=x&&typeof m.getDerivedStateFromError!="function"?null:A.render(),u.flags|=1,c!==null&&x?(u.child=Fc(u,c.child,null,M),u.child=Fc(u,null,m,M)):rr(c,u,m,M),u.memoizedState=A.state,c=u.child):c=po(c,u,M),c}function hw(c,u,m,x){return ot(),u.flags|=256,rr(c,u,m,x),u.child}function zy(c){return{baseLanes:c,cachePool:vw()}}function By(c,u,m){return c=c!==null?c.childLanes&~m:0,u&&(c|=ka),c}function fw(c,u,m){var x=u.pendingProps,M=!1,A=(u.flags&128)!==0,F;if((F=A)||(F=c!==null&&c.memoizedState===null?!1:(Hi.current&2)!==0),F&&(M=!0,u.flags&=-129),F=(u.flags&32)!==0,u.flags&=-33,c===null){if(mn){if(M?Mi(u):fr(),mn){var $=vr,he;(he=$)&&($=F7($,Fs),$!==null?(u.memoizedState={dehydrated:$,treeContext:Hc!==null?{id:xo,overflow:yo}:null,retryLane:536870912},he=t(18,null,null,0),he.stateNode=$,he.return=u,u.child=he,Ar=u,vr=null,he=!0):he=!1),he||Ze(u)}if($=u.memoizedState,$!==null&&($=$.dehydrated,$!==null))return wS($)?u.lanes=16:u.lanes=536870912,null;Xi(u)}return $=x.children,x=x.fallback,M?(fr(),M=u.mode,$=Fy({mode:"hidden",children:$},M),x=Pc(x,M,m,null),$.return=u,x.return=u,$.sibling=x,u.child=$,M=u.child,M.memoizedState=zy(m),M.childLanes=By(c,F,m),u.memoizedState=GS,x):(Mi(u),Hy(u,$))}if(he=c.memoizedState,he!==null&&($=he.dehydrated,$!==null)){if(A)u.flags&256?(Mi(u),u.flags&=-257,u=Gy(c,u,m)):u.memoizedState!==null?(fr(),u.child=c.child,u.flags|=128,u=null):(fr(),M=x.fallback,$=u.mode,x=Fy({mode:"visible",children:x.children},$),M=Pc(M,$,m,null),M.flags|=2,x.return=u,M.return=u,x.sibling=M,u.child=x,Fc(u,c.child,null,m),x=u.child,x.memoizedState=zy(m),x.childLanes=By(c,F,m),u.memoizedState=GS,u=M);else if(Mi(u),wS($))F=O7($).digest,x=Error(r(419)),x.stack="",x.digest=F,Ke({value:x,source:null,stack:null}),u=Gy(c,u,m);else if(Yi||cp(c,u,m,!1),F=(m&c.childLanes)!==0,Yi||F){if(F=Wn,F!==null){if(x=m&-m,x&42)x=1;else switch(x){case 2:x=1;break;case 8:x=4;break;case 32:x=16;break;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:x=64;break;case 268435456:x=134217728;break;default:x=0}if(x=x&(F.suspendedLanes|m)?0:x,x!==0&&x!==he.retryLane)throw he.retryLane=x,Ne(c,x),br(F,c,x),GR}AS($)||cS(),u=Gy(c,u,m)}else AS($)?(u.flags|=128,u.child=c.child,u=U9.bind(null,c),L7($,u),u=null):(c=he.treeContext,za&&(vr=z7($),Ar=u,mn=!0,ds=null,Fs=!1,c!==null&&(Ha[Fa++]=xo,Ha[Fa++]=yo,Ha[Fa++]=Hc,xo=c.id,yo=c.overflow,Hc=u)),u=Hy(u,x.children),u.flags|=4096);return u}return M?(fr(),M=x.fallback,$=u.mode,he=c.child,A=he.sibling,x=_l(he,{mode:"hidden",children:x.children}),x.subtreeFlags=he.subtreeFlags&31457280,A!==null?M=_l(A,M):(M=Pc(M,$,m,null),M.flags|=2),M.return=u,x.return=u,x.sibling=M,u.child=x,x=M,M=u.child,$=c.child.memoizedState,$===null?$=zy(m):(he=$.cachePool,he!==null?(A=_o?di._currentValue:di._currentValue2,he=he.parent!==A?{parent:A,pool:A}:he):he=vw(),$={baseLanes:$.baseLanes|m,cachePool:he}),M.memoizedState=$,M.childLanes=By(c,F,m),u.memoizedState=GS,x):(Mi(u),m=c.child,c=m.sibling,m=_l(m,{mode:"visible",children:x.children}),m.return=u,m.sibling=null,c!==null&&(F=u.deletions,F===null?(u.deletions=[c],u.flags|=16):F.push(c)),u.child=m,u.memoizedState=null,m)}function Hy(c,u){return u=Fy({mode:"visible",children:u},c.mode),u.return=c,c.child=u}function Fy(c,u){return nR(c,u,0,null)}function Gy(c,u,m){return Fc(u,c.child,null,m),c=Hy(u,u.pendingProps.children),c.flags|=2,u.memoizedState=null,c}function dw(c,u,m){c.lanes|=u;var x=c.alternate;x!==null&&(x.lanes|=u),Wy(c.return,u,m)}function Vy(c,u,m,x,M){var A=c.memoizedState;A===null?c.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:x,tail:m,tailMode:M}:(A.isBackwards=u,A.rendering=null,A.renderingStartTime=0,A.last=x,A.tail=m,A.tailMode=M)}function pw(c,u,m){var x=u.pendingProps,M=x.revealOrder,A=x.tail;if(rr(c,u,x.children,m),x=Hi.current,x&2)x=x&1|2,u.flags|=128;else{if(c!==null&&c.flags&128)e:for(c=u.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&dw(c,m,u);else if(c.tag===19)dw(c,m,u);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===u)break e;for(;c.sibling===null;){if(c.return===null||c.return===u)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}x&=1}switch(S(Hi,x),M){case"forwards":for(m=u.child,M=null;m!==null;)c=m.alternate,c!==null&&Gr(c)===null&&(M=m),m=m.sibling;m=M,m===null?(M=u.child,u.child=null):(M=m.sibling,m.sibling=null),Vy(u,!1,M,m,A);break;case"backwards":for(m=null,M=u.child,u.child=null;M!==null;){if(c=M.alternate,c!==null&&Gr(c)===null){u.child=M;break}c=M.sibling,M.sibling=m,m=M,M=c}Vy(u,!0,m,null,A);break;case"together":Vy(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function po(c,u,m){if(c!==null&&(u.dependencies=c.dependencies),Al|=u.lanes,!(m&u.childLanes))if(c!==null){if(cp(c,u,m,!1),(m&u.childLanes)===0)return null}else return null;if(c!==null&&u.child!==c.child)throw Error(r(153));if(u.child!==null){for(c=u.child,m=_l(c,c.pendingProps),u.child=m,m.return=u;c.sibling!==null;)c=c.sibling,m=m.sibling=_l(c,c.pendingProps),m.return=u;m.sibling=null}return u.child}function ky(c,u){return c.lanes&u?!0:(c=c.dependencies,!!(c!==null&&rg(c)))}function M9(c,u,m){switch(u.tag){case 3:tt(u,u.stateNode.containerInfo),pl(u,di,c.memoizedState.cache),ot();break;case 27:case 5:ge(u);break;case 4:tt(u,u.stateNode.containerInfo);break;case 10:pl(u,u.type,u.memoizedProps.value);break;case 13:var x=u.memoizedState;if(x!==null)return x.dehydrated!==null?(Mi(u),u.flags|=128,null):m&u.child.childLanes?fw(c,u,m):(Mi(u),c=po(c,u,m),c!==null?c.sibling:null);Mi(u);break;case 19:var M=(c.flags&128)!==0;if(x=(m&u.childLanes)!==0,x||(cp(c,u,m,!1),x=(m&u.childLanes)!==0),M){if(x)return pw(c,u,m);u.flags|=128}if(M=u.memoizedState,M!==null&&(M.rendering=null,M.tail=null,M.lastEffect=null),S(Hi,Hi.current),x)break;return null;case 22:case 23:return u.lanes=0,ow(c,u,m);case 24:pl(u,di,c.memoizedState.cache)}return po(c,u,m)}function mw(c,u,m){if(c!==null)if(c.memoizedProps!==u.pendingProps)Yi=!0;else{if(!ky(c,m)&&!(u.flags&128))return Yi=!1,M9(c,u,m);Yi=!!(c.flags&131072)}else Yi=!1,mn&&u.flags&1048576&&Ce(u,xg,u.index);switch(u.lanes=0,u.tag){case 16:e:{c=u.pendingProps;var x=u.elementType,M=x._init;if(x=M(x._payload),u.type=x,typeof x=="function")fS(x)?(c=Nc(x,c),u.tag=1,u=uw(null,u,x,c,m)):(u.tag=0,u=Py(null,u,x,c,m));else{if(x!=null){if(M=x.$$typeof,M===_S){u.tag=11,u=rw(null,u,x,c,m);break e}else if(M===SS){u.tag=14,u=aw(null,u,x,c,m);break e}}throw u=s(x)||x,Error(r(306,u,""))}}return u;case 0:return Py(c,u,u.type,u.pendingProps,m);case 1:return x=u.type,M=Nc(x,u.pendingProps),uw(c,u,x,M,m);case 3:e:{if(tt(u,u.stateNode.containerInfo),c===null)throw Error(r(387));var A=u.pendingProps;M=u.memoizedState,x=M.element,pt(c,u),Oe(u,A,null,m);var F=u.memoizedState;if(A=F.cache,pl(u,di,A),A!==M.cache&&Xy(u,[di],m,!0),pe(),A=F.element,za&&M.isDehydrated)if(M={element:A,isDehydrated:!1,cache:F.cache},u.updateQueue.baseState=M,u.memoizedState=M,u.flags&256){u=hw(c,u,A,m);break e}else if(A!==x){x=oe(Error(r(424)),u),Ke(x),u=hw(c,u,A,m);break e}else for(za&&(vr=P7(u.stateNode.containerInfo),Ar=u,mn=!0,ds=null,Fs=!0),m=HR(u,null,A,m),u.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(ot(),A===x){u=po(c,u,m);break e}rr(c,u,A,m)}u=u.child}return u;case 26:if(Ba)return lp(c,u),c===null?(m=CR(u.type,null,u.pendingProps,null))?u.memoizedState=m:mn||(u.stateNode=J7(u.type,u.pendingProps,Tl.current,u)):u.memoizedState=CR(u.type,c.memoizedProps,u.pendingProps,c.memoizedState),null;case 27:if(gr)return ge(u),c===null&&gr&&mn&&(x=u.stateNode=UR(u.type,u.pendingProps,Tl.current,ar.current,!1),Ar=u,Fs=!0,vr=AR(x)),x=u.pendingProps.children,c!==null||mn?rr(c,u,x,m):u.child=Fc(u,null,x,m),lp(c,u),u.child;case 5:return c===null&&mn&&(Z7(u.type,u.pendingProps,ar.current),(M=x=vr)&&(x=B7(x,u.type,u.pendingProps,Fs),x!==null?(u.stateNode=x,Ar=u,vr=AR(x),Fs=!1,M=!0):M=!1),M||Ze(u)),ge(u),M=u.type,A=u.pendingProps,F=c!==null?c.memoizedProps:null,x=A.children,pg(M,A)?x=null:F!==null&&pg(M,F)&&(u.flags|=32),u.memoizedState!==null&&(M=Bs(c,u,la,null,null,m),_o?Bc._currentValue=M:Bc._currentValue2=M),lp(c,u),rr(c,u,x,m),u.child;case 6:return c===null&&mn&&(K7(u.pendingProps,ar.current),(c=m=vr)&&(m=H7(m,u.pendingProps,Fs),m!==null?(u.stateNode=m,Ar=u,vr=null,c=!0):c=!1),c||Ze(u)),null;case 13:return fw(c,u,m);case 4:return tt(u,u.stateNode.containerInfo),x=u.pendingProps,c===null?u.child=Fc(u,null,x,m):rr(c,u,x,m),u.child;case 11:return rw(c,u,u.type,u.pendingProps,m);case 7:return rr(c,u,u.pendingProps,m),u.child;case 8:return rr(c,u,u.pendingProps.children,m),u.child;case 12:return rr(c,u,u.pendingProps.children,m),u.child;case 10:return x=u.pendingProps,pl(u,u.type,x.value),rr(c,u,x.children,m),u.child;case 9:return M=u.type._context,x=u.pendingProps.children,Oc(u),M=pr(M),x=x(M),u.flags|=1,rr(c,u,x,m),u.child;case 14:return aw(c,u,u.type,u.pendingProps,m);case 15:return sw(c,u,u.type,u.pendingProps,m);case 19:return pw(c,u,m);case 22:return ow(c,u,m);case 24:return Oc(u),x=pr(di),c===null?(M=qy(),M===null&&(M=Wn,A=Yy(),M.pooledCache=A,A.refCount++,A!==null&&(M.pooledCacheLanes|=m),M=A),u.memoizedState={parent:x,cache:M},xt(u),pl(u,di,M)):(c.lanes&m&&(pt(c,u),Oe(u,null,null,m),pe()),M=c.memoizedState,A=u.memoizedState,M.parent!==x?(M={parent:x,cache:x},u.memoizedState=M,u.lanes===0&&(u.memoizedState=u.updateQueue.baseState=M),pl(u,di,x)):(x=A.cache,pl(u,di,x),x!==M.cache&&Xy(u,[di],m,!0))),rr(c,u,u.pendingProps.children,m),u.child;case 29:throw u.pendingProps}throw Error(r(156,u.tag))}function pl(c,u,m){_o?(S(wg,u._currentValue),u._currentValue=m):(S(wg,u._currentValue2),u._currentValue2=m)}function mo(c){var u=wg.current;_o?c._currentValue=u:c._currentValue2=u,v(wg)}function Wy(c,u,m){for(;c!==null;){var x=c.alternate;if((c.childLanes&u)!==u?(c.childLanes|=u,x!==null&&(x.childLanes|=u)):x!==null&&(x.childLanes&u)!==u&&(x.childLanes|=u),c===m)break;c=c.return}}function Xy(c,u,m,x){var M=c.child;for(M!==null&&(M.return=c);M!==null;){var A=M.dependencies;if(A!==null){var F=M.child;A=A.firstContext;e:for(;A!==null;){var $=A;A=M;for(var he=0;he<u.length;he++)if($.context===u[he]){A.lanes|=m,$=A.alternate,$!==null&&($.lanes|=m),Wy(A.return,m,c),x||(F=null);break e}A=$.next}}else if(M.tag===18){if(F=M.return,F===null)throw Error(r(341));F.lanes|=m,A=F.alternate,A!==null&&(A.lanes|=m),Wy(F,m,c),F=null}else F=M.child;if(F!==null)F.return=M;else for(F=M;F!==null;){if(F===c){F=null;break}if(M=F.sibling,M!==null){M.return=F.return,F=M;break}F=F.return}M=F}}function cp(c,u,m,x){c=null;for(var M=u,A=!1;M!==null;){if(!A){if(M.flags&524288)A=!0;else if(M.flags&262144)break}if(M.tag===10){var F=M.alternate;if(F===null)throw Error(r(387));if(F=F.memoizedProps,F!==null){var $=M.type;ga(M.pendingProps.value,F.value)||(c!==null?c.push($):c=[$])}}else if(M===yg.current){if(F=M.alternate,F===null)throw Error(r(387));F.memoizedState.memoizedState!==M.memoizedState.memoizedState&&(c!==null?c.push(Bc):c=[Bc])}M=M.return}c!==null&&Xy(u,c,m,x),u.flags|=262144}function rg(c){for(c=c.firstContext;c!==null;){var u=c.context;if(!ga(_o?u._currentValue:u._currentValue2,c.memoizedValue))return!0;c=c.next}return!1}function Oc(c){Wc=c,So=null,c=c.dependencies,c!==null&&(c.firstContext=null)}function pr(c){return gw(Wc,c)}function ag(c,u){return Wc===null&&Oc(c),gw(c,u)}function gw(c,u){var m=_o?u._currentValue:u._currentValue2;if(u={context:u,memoizedValue:m,next:null},So===null){if(c===null)throw Error(r(308));So=u,c.dependencies={lanes:0,firstContext:u},c.flags|=524288}else So=So.next=u;return m}function Yy(){return{controller:new mz,data:new Map,refCount:0}}function up(c){c.refCount--,c.refCount===0&&gz(vz,function(){c.controller.abort()})}function qy(){var c=Xc.current;return c!==null?c:Wn.pooledCache}function sg(c,u){u===null?S(Xc,Xc.current):S(Xc,u.pool)}function vw(){var c=qy();return c===null?null:{parent:_o?di._currentValue:di._currentValue2,pool:c}}function ca(c){c.flags|=4}function _w(c,u){if(c!==null&&c.child===u.child)return!1;if(u.flags&16)return!0;for(c=u.child;c!==null;){if(c.flags&13878||c.subtreeFlags&13878)return!0;c=c.sibling}return!1}function jy(c,u,m,x){if(mr)for(m=u.child;m!==null;){if(m.tag===5||m.tag===6)MS(c,m.stateNode);else if(!(m.tag===4||gr&&m.tag===27)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===u)break;for(;m.sibling===null;){if(m.return===null||m.return===u)return;m=m.return}m.sibling.return=m.return,m=m.sibling}else if(Sl)for(var M=u.child;M!==null;){if(M.tag===5){var A=M.stateNode;m&&x&&(A=ER(A,M.type,M.memoizedProps)),MS(c,A)}else if(M.tag===6)A=M.stateNode,m&&x&&(A=MR(A,M.memoizedProps)),MS(c,A);else if(M.tag!==4){if(M.tag===22&&M.memoizedState!==null)A=M.child,A!==null&&(A.return=M),jy(c,M,!0,!0);else if(M.child!==null){M.child.return=M,M=M.child;continue}}if(M===u)break;for(;M.sibling===null;){if(M.return===null||M.return===u)return;M=M.return}M.sibling.return=M.return,M=M.sibling}}function xw(c,u,m,x){if(Sl)for(var M=u.child;M!==null;){if(M.tag===5){var A=M.stateNode;m&&x&&(A=ER(A,M.type,M.memoizedProps)),SR(c,A)}else if(M.tag===6)A=M.stateNode,m&&x&&(A=MR(A,M.memoizedProps)),SR(c,A);else if(M.tag!==4){if(M.tag===22&&M.memoizedState!==null)A=M.child,A!==null&&(A.return=M),xw(c,M,!(M.memoizedProps!==null&&M.memoizedProps.mode==="manual"),!0);else if(M.child!==null){M.child.return=M,M=M.child;continue}}if(M===u)break;for(;M.sibling===null;){if(M.return===null||M.return===u)return;M=M.return}M.sibling.return=M.return,M=M.sibling}}function yw(c,u){if(Sl&&_w(c,u)){c=u.stateNode;var m=c.containerInfo,x=yR();xw(x,u,!1,!1),c.pendingChildren=x,ca(u),N7(m,x)}}function Zy(c,u,m,x){if(mr)c.memoizedProps!==x&&ca(u);else if(Sl){var M=c.stateNode,A=c.memoizedProps;if((c=_w(c,u))||A!==x){var F=ar.current;A=D7(M,m,A,x,!c,null),A===M?u.stateNode=M:(pR(A,m,x,F)&&ca(u),u.stateNode=A,c?jy(A,u,!1,!1):ca(u))}else u.stateNode=M}}function Ky(c,u,m){if(r7(u,m)){if(c.flags|=16777216,!vR(u,m))if(Xw())c.flags|=8192;else throw Bh=Eg,BS}else c.flags&=-16777217}function Sw(c,u){if(ez(u)){if(c.flags|=16777216,!IR(u))if(Xw())c.flags|=8192;else throw Bh=Eg,BS}else c.flags&=-16777217}function og(c,u){u!==null&&(c.flags|=4),c.flags&16384&&(u=c.tag!==22?O():536870912,c.lanes|=u,Xh|=u)}function hp(c,u){if(!mn)switch(c.tailMode){case"hidden":u=c.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?c.tail=null:m.sibling=null;break;case"collapsed":m=c.tail;for(var x=null;m!==null;)m.alternate!==null&&(x=m),m=m.sibling;x===null?u||c.tail===null?c.tail=null:c.tail.sibling=null:x.sibling=null}}function ui(c){var u=c.alternate!==null&&c.alternate.child===c.child,m=0,x=0;if(u)for(var M=c.child;M!==null;)m|=M.lanes|M.childLanes,x|=M.subtreeFlags&31457280,x|=M.flags&31457280,M.return=c,M=M.sibling;else for(M=c.child;M!==null;)m|=M.lanes|M.childLanes,x|=M.subtreeFlags,x|=M.flags,M.return=c,M=M.sibling;return c.subtreeFlags|=x,c.childLanes=m,u}function b9(c,u,m){var x=u.pendingProps;switch(nt(u),u.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ui(u),null;case 1:return ui(u),null;case 3:return m=u.stateNode,x=null,c!==null&&(x=c.memoizedState.cache),u.memoizedState.cache!==x&&(u.flags|=2048),mo(di),gt(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(c===null||c.child===null)&&(bt(u)?ca(u):c===null||c.memoizedState.isDehydrated&&!(u.flags&256)||(u.flags|=1024,ds!==null&&(oS(ds),ds=null))),yw(c,u),ui(u),null;case 26:if(Ba){m=u.type;var M=u.memoizedState;return c===null?(ca(u),M!==null?(ui(u),Sw(u,M)):(ui(u),Ky(u,m,x))):M?M!==c.memoizedState?(ca(u),ui(u),Sw(u,M)):(ui(u),u.flags&=-16777217):(mr?c.memoizedProps!==x&&ca(u):Zy(c,u,m,x),ui(u),Ky(u,m,x)),null}case 27:if(gr){if(Ae(u),m=Tl.current,M=u.type,c!==null&&u.stateNode!=null)mr?c.memoizedProps!==x&&ca(u):Zy(c,u,M,x);else{if(!x){if(u.stateNode===null)throw Error(r(166));return ui(u),null}c=ar.current,bt(u)?ue(u,c):(c=UR(M,x,m,c,!0),u.stateNode=c,ca(u))}return ui(u),null}case 5:if(Ae(u),m=u.type,c!==null&&u.stateNode!=null)Zy(c,u,m,x);else{if(!x){if(u.stateNode===null)throw Error(r(166));return ui(u),null}c=ar.current,bt(u)?ue(u,c):(M=Q9(m,x,Tl.current,c,u),jy(M,u,!1,!1),u.stateNode=M,pR(M,m,x,c)&&ca(u))}return ui(u),Ky(u,u.type,u.pendingProps),null;case 6:if(c&&u.stateNode!=null)m=c.memoizedProps,mr?m!==x&&ca(u):Sl&&(m!==x?(u.stateNode=mR(x,Tl.current,ar.current,u),ca(u)):u.stateNode=c.stateNode);else{if(typeof x!="string"&&u.stateNode===null)throw Error(r(166));if(c=Tl.current,m=ar.current,bt(u)){if(!za)throw Error(r(176));if(c=u.stateNode,m=u.memoizedProps,x=null,M=Ar,M!==null)switch(M.tag){case 27:case 5:x=M.memoizedProps}V7(c,m,u,x)||Ze(u)}else u.stateNode=mR(x,c,m,u)}return ui(u),null;case 13:if(x=u.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(M=bt(u),x!==null&&x.dehydrated!==null){if(c===null){if(!M)throw Error(r(318));if(!za)throw Error(r(344));if(M=u.memoizedState,M=M!==null?M.dehydrated:null,!M)throw Error(r(317));k7(M,u)}else ot(),!(u.flags&128)&&(u.memoizedState=null),u.flags|=4;ui(u),M=!1}else ds!==null&&(oS(ds),ds=null),M=!0;if(!M)return u.flags&256?(Xi(u),u):(Xi(u),null)}if(Xi(u),u.flags&128)return u.lanes=m,u;if(m=x!==null,c=c!==null&&c.memoizedState!==null,m){x=u.child,M=null,x.alternate!==null&&x.alternate.memoizedState!==null&&x.alternate.memoizedState.cachePool!==null&&(M=x.alternate.memoizedState.cachePool.pool);var A=null;x.memoizedState!==null&&x.memoizedState.cachePool!==null&&(A=x.memoizedState.cachePool.pool),A!==M&&(x.flags|=2048)}return m!==c&&m&&(u.child.flags|=8192),og(u,u.updateQueue),ui(u),null;case 4:return gt(),yw(c,u),c===null&&e7(u.stateNode.containerInfo),ui(u),null;case 10:return mo(u.type),ui(u),null;case 19:if(v(Hi),M=u.memoizedState,M===null)return ui(u),null;if(x=(u.flags&128)!==0,A=M.rendering,A===null)if(x)hp(M,!1);else{if(mi!==0||c!==null&&c.flags&128)for(c=u.child;c!==null;){if(A=Gr(c),A!==null){for(u.flags|=128,hp(M,!1),c=A.updateQueue,u.updateQueue=c,og(u,c),u.subtreeFlags=0,c=m,m=u.child;m!==null;)tR(m,c),m=m.sibling;return S(Hi,Hi.current&1|2),u.child}c=c.sibling}M.tail!==null&&fs()>Ap&&(u.flags|=128,x=!0,hp(M,!1),u.lanes=4194304)}else{if(!x)if(c=Gr(A),c!==null){if(u.flags|=128,x=!0,c=c.updateQueue,u.updateQueue=c,og(u,c),hp(M,!0),M.tail===null&&M.tailMode==="hidden"&&!A.alternate&&!mn)return ui(u),null}else 2*fs()-M.renderingStartTime>Ap&&m!==536870912&&(u.flags|=128,x=!0,hp(M,!1),u.lanes=4194304);M.isBackwards?(A.sibling=u.child,u.child=A):(c=M.last,c!==null?c.sibling=A:u.child=A,M.last=A)}return M.tail!==null?(u=M.tail,M.rendering=u,M.tail=u.sibling,M.renderingStartTime=fs(),u.sibling=null,c=Hi.current,S(Hi,x?c&1|2:c&1),u):(ui(u),null);case 22:case 23:return Xi(u),Ps(),x=u.memoizedState!==null,c!==null?c.memoizedState!==null!==x&&(u.flags|=8192):x&&(u.flags|=8192),x?m&536870912&&!(u.flags&128)&&(ui(u),u.subtreeFlags&6&&(u.flags|=8192)):ui(u),m=u.updateQueue,m!==null&&og(u,m.retryQueue),m=null,c!==null&&c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(m=c.memoizedState.cachePool.pool),x=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(x=u.memoizedState.cachePool.pool),x!==m&&(u.flags|=2048),c!==null&&v(Xc),null;case 24:return m=null,c!==null&&(m=c.memoizedState.cache),u.memoizedState.cache!==m&&(u.flags|=2048),mo(di),ui(u),null;case 25:return null}throw Error(r(156,u.tag))}function A9(c,u){switch(nt(u),u.tag){case 1:return c=u.flags,c&65536?(u.flags=c&-65537|128,u):null;case 3:return mo(di),gt(),c=u.flags,c&65536&&!(c&128)?(u.flags=c&-65537|128,u):null;case 26:case 27:case 5:return Ae(u),null;case 13:if(Xi(u),c=u.memoizedState,c!==null&&c.dehydrated!==null){if(u.alternate===null)throw Error(r(340));ot()}return c=u.flags,c&65536?(u.flags=c&-65537|128,u):null;case 19:return v(Hi),null;case 4:return gt(),null;case 10:return mo(u.type),null;case 22:case 23:return Xi(u),Ps(),c!==null&&v(Xc),c=u.flags,c&65536?(u.flags=c&-65537|128,u):null;case 24:return mo(di),null;case 25:return null;default:return null}}function Tw(c,u){switch(nt(u),u.tag){case 3:mo(di),gt();break;case 26:case 27:case 5:Ae(u);break;case 4:gt();break;case 13:Xi(u);break;case 19:v(Hi);break;case 10:mo(u.type);break;case 22:case 23:Xi(u),Ps(),c!==null&&v(Xc);break;case 24:mo(di)}}function fp(c,u){try{var m=u.updateQueue,x=m!==null?m.lastEffect:null;if(x!==null){var M=x.next;m=M;do{if((m.tag&c)===c){x=void 0;var A=m.create,F=m.inst;x=A(),F.destroy=x}m=m.next}while(m!==M)}}catch($){bn(u,u.return,$)}}function ml(c,u,m){try{var x=u.updateQueue,M=x!==null?x.lastEffect:null;if(M!==null){var A=M.next;x=A;do{if((x.tag&c)===c){var F=x.inst,$=F.destroy;if($!==void 0){F.destroy=void 0,M=u;var he=m;try{$()}catch(De){bn(M,he,De)}}}x=x.next}while(x!==A)}}catch(De){bn(u,u.return,De)}}function Ew(c){var u=c.updateQueue;if(u!==null){var m=c.stateNode;try{ke(u,m)}catch(x){bn(c,c.return,x)}}}function Mw(c,u,m){m.props=Nc(c.type,c.memoizedProps),m.state=c.memoizedState;try{m.componentWillUnmount()}catch(x){bn(c,u,x)}}function Lc(c,u){try{var m=c.ref;if(m!==null){var x=c.stateNode;switch(c.tag){case 26:case 27:case 5:var M=mp(x);break;default:M=x}typeof m=="function"?c.refCleanup=m(M):m.current=M}}catch(A){bn(c,u,A)}}function ua(c,u){var m=c.ref,x=c.refCleanup;if(m!==null)if(typeof x=="function")try{x()}catch(M){bn(c,u,M)}finally{c.refCleanup=null,c=c.alternate,c!=null&&(c.refCleanup=null)}else if(typeof m=="function")try{m(null)}catch(M){bn(c,u,M)}else m.current=null}function bw(c){var u=c.type,m=c.memoizedProps,x=c.stateNode;try{x7(x,u,m,c)}catch(M){bn(c,c.return,M)}}function Aw(c,u,m){try{y7(c.stateNode,c.type,m,u,c)}catch(x){bn(c,c.return,x)}}function ww(c){return c.tag===5||c.tag===3||(Ba?c.tag===26:!1)||(gr?c.tag===27:!1)||c.tag===4}function Qy(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||ww(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&(!gr||c.tag!==27)&&c.tag!==18;){if(c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function Jy(c,u,m){var x=c.tag;if(x===5||x===6)c=c.stateNode,u?T7(m,c,u):v7(m,c);else if(!(x===4||gr&&x===27)&&(c=c.child,c!==null))for(Jy(c,u,m),c=c.sibling;c!==null;)Jy(c,u,m),c=c.sibling}function lg(c,u,m){var x=c.tag;if(x===5||x===6)c=c.stateNode,u?S7(m,c,u):g7(m,c);else if(!(x===4||gr&&x===27)&&(c=c.child,c!==null))for(lg(c,u,m),c=c.sibling;c!==null;)lg(c,u,m),c=c.sibling}function Rw(c,u,m){c=c.containerInfo;try{TR(c,m)}catch(x){bn(u,u.return,x)}}function w9(c,u){for(Z9(c.containerInfo),qi=u;qi!==null;)if(c=qi,u=c.child,(c.subtreeFlags&1028)!==0&&u!==null)u.return=c,qi=u;else for(;qi!==null;){c=qi;var m=c.alternate;switch(u=c.flags,c.tag){case 0:break;case 11:case 15:break;case 1:if(u&1024&&m!==null){u=void 0;var x=c,M=m.memoizedProps;m=m.memoizedState;var A=x.stateNode;try{var F=Nc(x.type,M,x.elementType===x.type);u=A.getSnapshotBeforeUpdate(F,m),A.__reactInternalSnapshotBeforeUpdate=u}catch($){bn(x,x.return,$)}}break;case 3:u&1024&&mr&&C7(c.stateNode.containerInfo);break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(u&1024)throw Error(r(163))}if(u=c.sibling,u!==null){u.return=c.return,qi=u;break}qi=c.return}return F=WR,WR=!1,F}function Cw(c,u,m){var x=m.flags;switch(m.tag){case 0:case 11:case 15:go(c,m),x&4&&fp(5,m);break;case 1:if(go(c,m),x&4)if(c=m.stateNode,u===null)try{c.componentDidMount()}catch($){bn(m,m.return,$)}else{var M=Nc(m.type,u.memoizedProps);u=u.memoizedState;try{c.componentDidUpdate(M,u,c.__reactInternalSnapshotBeforeUpdate)}catch($){bn(m,m.return,$)}}x&64&&Ew(m),x&512&&Lc(m,m.return);break;case 3:if(go(c,m),x&64&&(x=m.updateQueue,x!==null)){if(c=null,m.child!==null)switch(m.child.tag){case 27:case 5:c=mp(m.child.stateNode);break;case 1:c=m.child.stateNode}try{ke(x,c)}catch($){bn(m,m.return,$)}}break;case 26:if(Ba){go(c,m),x&512&&Lc(m,m.return);break}case 27:case 5:go(c,m),u===null&&x&4&&bw(m),x&512&&Lc(m,m.return);break;case 12:go(c,m);break;case 13:go(c,m),x&4&&Nw(c,m);break;case 22:if(M=m.memoizedState!==null||To,!M){u=u!==null&&u.memoizedState!==null||pi;var A=To,F=pi;To=M,(pi=u)&&!F?gl(c,m,(m.subtreeFlags&8772)!==0):go(c,m),To=A,pi=F}x&512&&(m.memoizedProps.mode==="manual"?Lc(m,m.return):ua(m,m.return));break;default:go(c,m)}}function Dw(c){var u=c.alternate;u!==null&&(c.alternate=null,Dw(u)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(u=c.stateNode,u!==null&&i7(u)),c.stateNode=null,c.return=null,c.dependencies=null,c.memoizedProps=null,c.memoizedState=null,c.pendingProps=null,c.stateNode=null,c.updateQueue=null}function hs(c,u,m){for(m=m.child;m!==null;)$y(c,u,m),m=m.sibling}function $y(c,u,m){if(ma&&typeof ma.onCommitFiberUnmount=="function")try{ma.onCommitFiberUnmount(_p,m)}catch{}switch(m.tag){case 26:if(Ba){pi||ua(m,u),hs(c,u,m),m.memoizedState?NR(m.memoizedState):m.stateNode&&LR(m.stateNode);break}case 27:if(gr){pi||ua(m,u);var x=wi,M=va;wi=m.stateNode,hs(c,u,m),rz(m.stateNode),wi=x,va=M;break}case 5:pi||ua(m,u);case 6:if(mr){if(x=wi,M=va,wi=null,hs(c,u,m),wi=x,va=M,wi!==null)if(va)try{M7(wi,m.stateNode)}catch(A){bn(m,u,A)}else try{E7(wi,m.stateNode)}catch(A){bn(m,u,A)}}else hs(c,u,m);break;case 18:mr&&wi!==null&&(va?j7(wi,m.stateNode):q7(wi,m.stateNode));break;case 4:mr?(x=wi,M=va,wi=m.stateNode.containerInfo,va=!0,hs(c,u,m),wi=x,va=M):(Sl&&Rw(m.stateNode,m,yR()),hs(c,u,m));break;case 0:case 11:case 14:case 15:pi||ml(2,m,u),pi||ml(4,m,u),hs(c,u,m);break;case 1:pi||(ua(m,u),x=m.stateNode,typeof x.componentWillUnmount=="function"&&Mw(m,u,x)),hs(c,u,m);break;case 21:hs(c,u,m);break;case 22:pi||ua(m,u),pi=(x=pi)||m.memoizedState!==null,hs(c,u,m),pi=x;break;default:hs(c,u,m)}}function Nw(c,u){if(za&&u.memoizedState===null&&(c=u.alternate,c!==null&&(c=c.memoizedState,c!==null&&(c=c.dehydrated,c!==null))))try{Y7(c)}catch(m){bn(u,u.return,m)}}function R9(c){switch(c.tag){case 13:case 19:var u=c.stateNode;return u===null&&(u=c.stateNode=new kR),u;case 22:return c=c.stateNode,u=c._retryCache,u===null&&(u=c._retryCache=new kR),u;default:throw Error(r(435,c.tag))}}function eS(c,u){var m=R9(c);u.forEach(function(x){var M=P9.bind(null,c,x);m.has(x)||(m.add(x),x.then(M,M))})}function Vr(c,u){var m=u.deletions;if(m!==null)for(var x=0;x<m.length;x++){var M=m[x],A=c,F=u;if(mr){var $=F;e:for(;$!==null;){switch($.tag){case 27:case 5:wi=$.stateNode,va=!1;break e;case 3:wi=$.stateNode.containerInfo,va=!0;break e;case 4:wi=$.stateNode.containerInfo,va=!0;break e}$=$.return}if(wi===null)throw Error(r(160));$y(A,F,M),wi=null,va=!1}else $y(A,F,M);A=M.alternate,A!==null&&(A.return=null),M.return=null}if(u.subtreeFlags&13878)for(u=u.child;u!==null;)Ow(u,c),u=u.sibling}function Ow(c,u){var m=c.alternate,x=c.flags;switch(c.tag){case 0:case 11:case 14:case 15:Vr(u,c),ha(c),x&4&&(ml(3,c,c.return),fp(3,c),ml(5,c,c.return));break;case 1:Vr(u,c),ha(c),x&512&&(pi||m===null||ua(m,m.return)),x&64&&To&&(c=c.updateQueue,c!==null&&(x=c.callbacks,x!==null&&(m=c.shared.hiddenCallbacks,c.shared.hiddenCallbacks=m===null?x:m.concat(x))));break;case 26:if(Ba){var M=ps;Vr(u,c),ha(c),x&512&&(pi||m===null||ua(m,m.return)),x&4&&(x=m!==null?m.memoizedState:null,u=c.memoizedState,m===null?u===null?c.stateNode===null?c.stateNode=Q7(M,c.type,c.memoizedProps,c):OR(M,c.type,c.stateNode):c.stateNode=DR(M,u,c.memoizedProps):x!==u?(x===null?m.stateNode!==null&&LR(m.stateNode):NR(x),u===null?OR(M,c.type,c.stateNode):DR(M,u,c.memoizedProps)):u===null&&c.stateNode!==null&&Aw(c,c.memoizedProps,m.memoizedProps));break}case 27:if(gr&&x&4&&c.alternate===null){M=c.stateNode;var A=c.memoizedProps;try{nz(M),iz(c.type,A,M,c)}catch(et){bn(c,c.return,et)}}case 5:if(Vr(u,c),ha(c),x&512&&(pi||m===null||ua(m,m.return)),mr){if(c.flags&32){u=c.stateNode;try{xR(u)}catch(et){bn(c,c.return,et)}}x&4&&c.stateNode!=null&&(u=c.memoizedProps,Aw(c,u,m!==null?m.memoizedProps:u)),x&1024&&(VS=!0)}break;case 6:if(Vr(u,c),ha(c),x&4&&mr){if(c.stateNode===null)throw Error(r(162));x=c.memoizedProps,m=m!==null?m.memoizedProps:x,u=c.stateNode;try{_7(u,m,x)}catch(et){bn(c,c.return,et)}}break;case 3:if(Ba?($7(),M=ps,ps=RS(u.containerInfo),Vr(u,c),ps=M):Vr(u,c),ha(c),x&4){if(mr&&za&&m!==null&&m.memoizedState.isDehydrated)try{X7(u.containerInfo)}catch(et){bn(c,c.return,et)}if(Sl){x=u.containerInfo,m=u.pendingChildren;try{TR(x,m)}catch(et){bn(c,c.return,et)}}}VS&&(VS=!1,Lw(c));break;case 4:Ba?(m=ps,ps=RS(c.stateNode.containerInfo),Vr(u,c),ha(c),ps=m):(Vr(u,c),ha(c)),x&4&&Sl&&Rw(c.stateNode,c,c.stateNode.pendingChildren);break;case 12:Vr(u,c),ha(c);break;case 13:Vr(u,c),ha(c),c.child.flags&8192&&c.memoizedState!==null!=(m!==null&&m.memoizedState!==null)&&(YS=fs()),x&4&&(x=c.updateQueue,x!==null&&(c.updateQueue=null,eS(c,x)));break;case 22:x&512&&(pi||m===null||ua(m,m.return)),M=c.memoizedState!==null;var F=m!==null&&m.memoizedState!==null,$=To,he=pi;if(To=$||M,pi=he||F,Vr(u,c),pi=he,To=$,ha(c),u=c.stateNode,u._current=c,u._visibility&=-3,u._visibility|=u._pendingVisibility&2,x&8192&&(u._visibility=M?u._visibility&-2:u._visibility|1,M&&(u=To||pi,m===null||F||u||Th(c)),mr&&(c.memoizedProps===null||c.memoizedProps.mode!=="manual"))){e:if(m=null,mr)for(u=c;;){if(u.tag===5||Ba&&u.tag===26||gr&&u.tag===27){if(m===null){F=m=u;try{A=F.stateNode,M?b7(A):w7(F.stateNode,F.memoizedProps)}catch(et){bn(F,F.return,et)}}}else if(u.tag===6){if(m===null){F=u;try{var De=F.stateNode;M?A7(De):R7(De,F.memoizedProps)}catch(et){bn(F,F.return,et)}}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===c)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===c)break e;for(;u.sibling===null;){if(u.return===null||u.return===c)break e;m===u&&(m=null),u=u.return}m===u&&(m=null),u.sibling.return=u.return,u=u.sibling}}x&4&&(x=c.updateQueue,x!==null&&(m=x.retryQueue,m!==null&&(x.retryQueue=null,eS(c,m))));break;case 19:Vr(u,c),ha(c),x&4&&(x=c.updateQueue,x!==null&&(c.updateQueue=null,eS(c,x)));break;case 21:break;default:Vr(u,c),ha(c)}}function ha(c){var u=c.flags;if(u&2){try{if(mr&&(!gr||c.tag!==27)){e:{for(var m=c.return;m!==null;){if(ww(m)){var x=m;break e}m=m.return}throw Error(r(160))}switch(x.tag){case 27:if(gr){var M=x.stateNode,A=Qy(c);lg(c,A,M);break}case 5:var F=x.stateNode;x.flags&32&&(xR(F),x.flags&=-33);var $=Qy(c);lg(c,$,F);break;case 3:case 4:var he=x.stateNode.containerInfo,De=Qy(c);Jy(c,De,he);break;default:throw Error(r(161))}}}catch(et){bn(c,c.return,et)}c.flags&=-3}u&4096&&(c.flags&=-4097)}function Lw(c){if(c.subtreeFlags&1024)for(c=c.child;c!==null;){var u=c;Lw(u),u.tag===5&&u.flags&1024&&o7(u.stateNode),c=c.sibling}}function go(c,u){if(u.subtreeFlags&8772)for(u=u.child;u!==null;)Cw(c,u.alternate,u),u=u.sibling}function Th(c){for(c=c.child;c!==null;){var u=c;switch(u.tag){case 0:case 11:case 14:case 15:ml(4,u,u.return),Th(u);break;case 1:ua(u,u.return);var m=u.stateNode;typeof m.componentWillUnmount=="function"&&Mw(u,u.return,m),Th(u);break;case 26:case 27:case 5:ua(u,u.return),Th(u);break;case 22:ua(u,u.return),u.memoizedState===null&&Th(u);break;default:Th(u)}c=c.sibling}}function gl(c,u,m){for(m=m&&(u.subtreeFlags&8772)!==0,u=u.child;u!==null;){var x=u.alternate,M=c,A=u,F=A.flags;switch(A.tag){case 0:case 11:case 15:gl(M,A,m),fp(4,A);break;case 1:if(gl(M,A,m),x=A,M=x.stateNode,typeof M.componentDidMount=="function")try{M.componentDidMount()}catch(De){bn(x,x.return,De)}if(x=A,M=x.updateQueue,M!==null){var $=x.stateNode;try{var he=M.shared.hiddenCallbacks;if(he!==null)for(M.shared.hiddenCallbacks=null,M=0;M<he.length;M++)q(he[M],$)}catch(De){bn(x,x.return,De)}}m&&F&64&&Ew(A),Lc(A,A.return);break;case 26:case 27:case 5:gl(M,A,m),m&&x===null&&F&4&&bw(A),Lc(A,A.return);break;case 12:gl(M,A,m);break;case 13:gl(M,A,m),m&&F&4&&Nw(M,A);break;case 22:A.memoizedState===null&&gl(M,A,m),Lc(A,A.return);break;default:gl(M,A,m)}u=u.sibling}}function tS(c,u){var m=null;c!==null&&c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(m=c.memoizedState.cachePool.pool),c=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(c=u.memoizedState.cachePool.pool),c!==m&&(c!=null&&c.refCount++,m!=null&&up(m))}function nS(c,u){c=null,u.alternate!==null&&(c=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==c&&(u.refCount++,c!=null&&up(c))}function vl(c,u,m,x){if(u.subtreeFlags&10256)for(u=u.child;u!==null;)Iw(c,u,m,x),u=u.sibling}function Iw(c,u,m,x){var M=u.flags;switch(u.tag){case 0:case 11:case 15:vl(c,u,m,x),M&2048&&fp(9,u);break;case 3:vl(c,u,m,x),M&2048&&(c=null,u.alternate!==null&&(c=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==c&&(u.refCount++,c!=null&&up(c)));break;case 12:if(M&2048){vl(c,u,m,x),c=u.stateNode;try{var A=u.memoizedProps,F=A.id,$=A.onPostCommit;typeof $=="function"&&$(F,u.alternate===null?"mount":"update",c.passiveEffectDuration,-0)}catch(he){bn(u,u.return,he)}}else vl(c,u,m,x);break;case 23:break;case 22:A=u.stateNode,u.memoizedState!==null?A._visibility&4?vl(c,u,m,x):dp(c,u):A._visibility&4?vl(c,u,m,x):(A._visibility|=4,Eh(c,u,m,x,(u.subtreeFlags&10256)!==0)),M&2048&&tS(u.alternate,u);break;case 24:vl(c,u,m,x),M&2048&&nS(u.alternate,u);break;default:vl(c,u,m,x)}}function Eh(c,u,m,x,M){for(M=M&&(u.subtreeFlags&10256)!==0,u=u.child;u!==null;){var A=c,F=u,$=m,he=x,De=F.flags;switch(F.tag){case 0:case 11:case 15:Eh(A,F,$,he,M),fp(8,F);break;case 23:break;case 22:var et=F.stateNode;F.memoizedState!==null?et._visibility&4?Eh(A,F,$,he,M):dp(A,F):(et._visibility|=4,Eh(A,F,$,he,M)),M&&De&2048&&tS(F.alternate,F);break;case 24:Eh(A,F,$,he,M),M&&De&2048&&nS(F.alternate,F);break;default:Eh(A,F,$,he,M)}u=u.sibling}}function dp(c,u){if(u.subtreeFlags&10256)for(u=u.child;u!==null;){var m=c,x=u,M=x.flags;switch(x.tag){case 22:dp(m,x),M&2048&&tS(x.alternate,x);break;case 24:dp(m,x),M&2048&&nS(x.alternate,x);break;default:dp(m,x)}u=u.sibling}}function Ic(c){if(c.subtreeFlags&kh)for(c=c.child;c!==null;)Uw(c),c=c.sibling}function Uw(c){switch(c.tag){case 26:Ic(c),c.flags&kh&&(c.memoizedState!==null?tz(ps,c.memoizedState,c.memoizedProps):_R(c.type,c.memoizedProps));break;case 5:Ic(c),c.flags&kh&&_R(c.type,c.memoizedProps);break;case 3:case 4:if(Ba){var u=ps;ps=RS(c.stateNode.containerInfo),Ic(c),ps=u}else Ic(c);break;case 22:c.memoizedState===null&&(u=c.alternate,u!==null&&u.memoizedState!==null?(u=kh,kh=16777216,Ic(c),kh=u):Ic(c));break;default:Ic(c)}}function Pw(c){var u=c.alternate;if(u!==null&&(c=u.child,c!==null)){u.child=null;do u=c.sibling,c.sibling=null,c=u;while(c!==null)}}function pp(c){var u=c.deletions;if(c.flags&16){if(u!==null)for(var m=0;m<u.length;m++){var x=u[m];qi=x,Bw(x,c)}Pw(c)}if(c.subtreeFlags&10256)for(c=c.child;c!==null;)zw(c),c=c.sibling}function zw(c){switch(c.tag){case 0:case 11:case 15:pp(c),c.flags&2048&&ml(9,c,c.return);break;case 3:pp(c);break;case 12:pp(c);break;case 22:var u=c.stateNode;c.memoizedState!==null&&u._visibility&4&&(c.return===null||c.return.tag!==13)?(u._visibility&=-5,cg(c)):pp(c);break;default:pp(c)}}function cg(c){var u=c.deletions;if(c.flags&16){if(u!==null)for(var m=0;m<u.length;m++){var x=u[m];qi=x,Bw(x,c)}Pw(c)}for(c=c.child;c!==null;){switch(u=c,u.tag){case 0:case 11:case 15:ml(8,u,u.return),cg(u);break;case 22:m=u.stateNode,m._visibility&4&&(m._visibility&=-5,cg(u));break;default:cg(u)}c=c.sibling}}function Bw(c,u){for(;qi!==null;){var m=qi;switch(m.tag){case 0:case 11:case 15:ml(8,m,u);break;case 23:case 22:if(m.memoizedState!==null&&m.memoizedState.cachePool!==null){var x=m.memoizedState.cachePool.pool;x!=null&&x.refCount++}break;case 24:up(m.memoizedState.cache)}if(x=m.child,x!==null)x.return=m,qi=x;else e:for(m=c;qi!==null;){x=qi;var M=x.sibling,A=x.return;if(Dw(x),x===m){qi=null;break e}if(M!==null){M.return=A,qi=M;break e}qi=A}}}function iS(c){var u=gR(c);if(u!=null){if(typeof u.memoizedProps["data-testname"]!="string")throw Error(r(364));return u}if(c=u7(c),c===null)throw Error(r(362));return c.stateNode.current}function rS(c,u){var m=c.tag;switch(u.$$typeof){case Rg:if(c.type===u.value)return!0;break;case Cg:e:{for(u=u.value,c=[c,0],m=0;m<c.length;){var x=c[m++],M=x.tag,A=c[m++],F=u[A];if(M!==5&&M!==26&&M!==27||!vp(x)){for(;F!=null&&rS(x,F);)A++,F=u[A];if(A===u.length){u=!0;break e}else for(x=x.child;x!==null;)c.push(x,A),x=x.sibling}}u=!1}return u;case Dg:if((m===5||m===26||m===27)&&d7(c.stateNode,u.value))return!0;break;case Og:if((m===5||m===6||m===26||m===27)&&(c=f7(c),c!==null&&0<=c.indexOf(u.value)))return!0;break;case Ng:if((m===5||m===26||m===27)&&(c=c.memoizedProps["data-testname"],typeof c=="string"&&c.toLowerCase()===u.value.toLowerCase()))return!0;break;default:throw Error(r(365))}return!1}function aS(c){switch(c.$$typeof){case Rg:return"<"+(s(c.value)||"Unknown")+">";case Cg:return":has("+(aS(c)||"")+")";case Dg:return'[role="'+c.value+'"]';case Og:return'"'+c.value+'"';case Ng:return'[data-testname="'+c.value+'"]';default:throw Error(r(365))}}function Hw(c,u){var m=[];c=[c,0];for(var x=0;x<c.length;){var M=c[x++],A=M.tag,F=c[x++],$=u[F];if(A!==5&&A!==26&&A!==27||!vp(M)){for(;$!=null&&rS(M,$);)F++,$=u[F];if(F===u.length)m.push(M);else for(M=M.child;M!==null;)c.push(M,F),M=M.sibling}}return m}function sS(c,u){if(!gp)throw Error(r(363));c=iS(c),c=Hw(c,u),u=[],c=Array.from(c);for(var m=0;m<c.length;){var x=c[m++],M=x.tag;if(M===5||M===26||M===27)vp(x)||u.push(x.stateNode);else for(x=x.child;x!==null;)c.push(x),x=x.sibling}return u}function fa(){if(Un&2&&hn!==0)return hn&-hn;if(Ft.T!==null){var c=Ph;return c!==0?c:Le()}return t7()}function Fw(){ka===0&&(ka=!(hn&536870912)||mn?U():536870912);var c=Va.current;return c!==null&&(c.flags|=32),ka}function br(c,u,m){(c===Wn&&Xn===2||c.cancelPendingCommit!==null)&&(Mh(c,0),vo(c,hn,ka,!1)),B(c,m),(!(Un&2)||c!==Wn)&&(c===Wn&&(!(Un&2)&&(Yc|=m),mi===4&&vo(c,hn,ka,!1)),$e(c))}function Gw(c,u,m){if(Un&6)throw Error(r(327));var x=!m&&(u&60)===0&&(u&c.expiredLanes)===0||R(c,u),M=x?N9(c,u):uS(c,u,!0),A=x;do{if(M===0){Wh&&!x&&vo(c,u,0,!1);break}else if(M===6)vo(c,u,0,!Eo);else{if(m=c.current.alternate,A&&!C9(m)){M=uS(c,u,!1),A=!1;continue}if(M===2){if(A=u,c.errorRecoveryDisabledLanes&A)var F=0;else F=c.pendingLanes&-536870913,F=F!==0?F:F&536870912?536870912:0;if(F!==0){u=F;e:{var $=c;M=bp;var he=za&&$.current.memoizedState.isDehydrated;if(he&&(Mh($,F).flags|=256),F=uS($,F,!1),F!==2){if(kS&&!he){$.errorRecoveryDisabledLanes|=A,Yc|=A,M=4;break e}A=ks,ks=M,A!==null&&oS(A)}M=F}if(A=!1,M!==2)continue}}if(M===1){Mh(c,0),vo(c,u,0,!0);break}e:{switch(x=c,M){case 0:case 1:throw Error(r(345));case 4:if((u&4194176)===u){vo(x,u,ka,!Eo);break e}break;case 2:ks=null;break;case 3:case 5:break;default:throw Error(r(329))}if(x.finishedWork=m,x.finishedLanes=u,(u&62914560)===u&&(A=YS+300-fs(),10<A)){if(vo(x,u,ka,!Eo),N(x,0)!==0)break e;x.timeoutHandle=J9(Vw.bind(null,x,m,ks,Lg,XS,u,ka,Yc,Xh,Eo,2,-0,0),A);break e}Vw(x,m,ks,Lg,XS,u,ka,Yc,Xh,Eo,0,-0,0)}}break}while(!0);$e(c)}function oS(c){ks===null?ks=c:ks.push.apply(ks,c)}function Vw(c,u,m,x,M,A,F,$,he,De,et,dt,mt){var qt=u.subtreeFlags;if((qt&8192||(qt&16785408)===16785408)&&(a7(),Uw(u),u=s7(),u!==null)){c.cancelPendingCommit=u(Qw.bind(null,c,m,x,M,F,$,he,1,dt,mt)),vo(c,A,F,!De);return}Qw(c,m,x,M,F,$,he,et,dt,mt)}function C9(c){for(var u=c;;){var m=u.tag;if((m===0||m===11||m===15)&&u.flags&16384&&(m=u.updateQueue,m!==null&&(m=m.stores,m!==null)))for(var x=0;x<m.length;x++){var M=m[x],A=M.getSnapshot;M=M.value;try{if(!ga(A(),M))return!1}catch{return!1}}if(m=u.child,u.subtreeFlags&16384&&m!==null)m.return=u,u=m;else{if(u===c)break;for(;u.sibling===null;){if(u.return===null||u.return===c)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function vo(c,u,m,x){u&=~WS,u&=~Yc,c.suspendedLanes|=u,c.pingedLanes&=~u,x&&(c.warmLanes|=u),x=c.expirationTimes;for(var M=u;0<M;){var A=31-pa(M),F=1<<A;x[A]=-1,M&=~F}m!==0&&ee(c,m,u)}function kw(){return Un&6?!0:(Je(0),!1)}function lS(){if(rn!==null){if(Xn===0)var c=rn.return;else c=rn,So=Wc=null,z(c),Hh=null,Tp=0,c=rn;for(;c!==null;)Tw(c.alternate,c),c=c.return;rn=null}}function Mh(c,u){c.finishedWork=null,c.finishedLanes=0;var m=c.timeoutHandle;m!==bS&&(c.timeoutHandle=bS,$9(m)),m=c.cancelPendingCommit,m!==null&&(c.cancelPendingCommit=null,m()),lS(),Wn=c,rn=m=_l(c.current,null),hn=u,Xn=0,_a=null,Eo=!1,Wh=R(c,u),kS=!1,Xh=ka=WS=Yc=Al=mi=0,ks=bp=null,XS=!1,u&8&&(u|=u&32);var x=c.entangledLanes;if(x!==0)for(c=c.entanglements,x&=u;0<x;){var M=31-pa(x),A=1<<M;u|=c[M],x&=~A}return Mo=u,Te(),m}function Ww(c,u){$t=null,Ft.H=Vs,u===Sp?(u=at(),Xn=3):u===BS?(u=at(),Xn=4):Xn=u===GR?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,_a=u,rn===null&&(mi=1,ig(c,oe(u,c.current)))}function Xw(){var c=Va.current;return c===null?!0:(hn&4194176)===hn?Gs===null:(hn&62914560)===hn||hn&536870912?c===Gs:!1}function Yw(){var c=Ft.H;return Ft.H=Vs,c===null?Vs:c}function qw(){var c=Ft.A;return Ft.A=_z,c}function cS(){mi=4,Eo||(hn&4194176)!==hn&&Va.current!==null||(Wh=!0),!(Al&134217727)&&!(Yc&134217727)||Wn===null||vo(Wn,hn,ka,!1)}function uS(c,u,m){var x=Un;Un|=2;var M=Yw(),A=qw();(Wn!==c||hn!==u)&&(Lg=null,Mh(c,u)),u=!1;var F=mi;e:do try{if(Xn!==0&&rn!==null){var $=rn,he=_a;switch(Xn){case 8:lS(),F=6;break e;case 3:case 2:case 6:Va.current===null&&(u=!0);var De=Xn;if(Xn=0,_a=null,bh(c,$,he,De),m&&Wh){F=0;break e}break;default:De=Xn,Xn=0,_a=null,bh(c,$,he,De)}}D9(),F=mi;break}catch(et){Ww(c,et)}while(!0);return u&&c.shellSuspendCounter++,So=Wc=null,Un=x,Ft.H=M,Ft.A=A,rn===null&&(Wn=null,hn=0,Te()),F}function D9(){for(;rn!==null;)jw(rn)}function N9(c,u){var m=Un;Un|=2;var x=Yw(),M=qw();Wn!==c||hn!==u?(Lg=null,Ap=fs()+500,Mh(c,u)):Wh=R(c,u);e:do try{if(Xn!==0&&rn!==null){u=rn;var A=_a;t:switch(Xn){case 1:Xn=0,_a=null,bh(c,u,A,1);break;case 2:if(We(A)){Xn=0,_a=null,Zw(u);break}u=function(){Xn===2&&Wn===c&&(Xn=7),$e(c)},A.then(u,u);break e;case 3:Xn=7;break e;case 4:Xn=5;break e;case 7:We(A)?(Xn=0,_a=null,Zw(u)):(Xn=0,_a=null,bh(c,u,A,7));break;case 5:var F=null;switch(rn.tag){case 26:F=rn.memoizedState;case 5:case 27:var $=rn,he=$.type,De=$.pendingProps;if(F?IR(F):vR(he,De)){Xn=0,_a=null;var et=$.sibling;if(et!==null)rn=et;else{var dt=$.return;dt!==null?(rn=dt,ug(dt)):rn=null}break t}}Xn=0,_a=null,bh(c,u,A,5);break;case 6:Xn=0,_a=null,bh(c,u,A,6);break;case 8:lS(),mi=6;break e;default:throw Error(r(462))}}O9();break}catch(mt){Ww(c,mt)}while(!0);return So=Wc=null,Ft.H=x,Ft.A=M,Un=m,rn!==null?0:(Wn=null,hn=0,Te(),mi)}function O9(){for(;rn!==null&&!oz();)jw(rn)}function jw(c){var u=mw(c.alternate,c,Mo);c.memoizedProps=c.pendingProps,u===null?ug(c):rn=u}function Zw(c){var u=c,m=u.alternate;switch(u.tag){case 15:case 0:u=cw(m,u,u.pendingProps,u.type,void 0,hn);break;case 11:u=cw(m,u,u.pendingProps,u.type.render,u.ref,hn);break;case 5:z(u);default:Tw(m,u),u=rn=tR(u,Mo),u=mw(m,u,Mo)}c.memoizedProps=c.pendingProps,u===null?ug(c):rn=u}function bh(c,u,m,x){So=Wc=null,z(u),Hh=null,Tp=0;var M=u.return;try{if(E9(c,M,u,m,hn)){mi=1,ig(c,oe(m,c.current)),rn=null;return}}catch(A){if(M!==null)throw rn=M,A;mi=1,ig(c,oe(m,c.current)),rn=null;return}u.flags&32768?(mn||x===1?c=!0:Wh||hn&536870912?c=!1:(Eo=c=!0,(x===2||x===3||x===6)&&(x=Va.current,x!==null&&x.tag===13&&(x.flags|=16384))),Kw(u,c)):ug(u)}function ug(c){var u=c;do{if(u.flags&32768){Kw(u,Eo);return}c=u.return;var m=b9(u.alternate,u,Mo);if(m!==null){rn=m;return}if(u=u.sibling,u!==null){rn=u;return}rn=u=c}while(u!==null);mi===0&&(mi=5)}function Kw(c,u){do{var m=A9(c.alternate,c);if(m!==null){m.flags&=32767,rn=m;return}if(m=c.return,m!==null&&(m.flags|=32768,m.subtreeFlags=0,m.deletions=null),!u&&(c=c.sibling,c!==null)){rn=c;return}rn=c=m}while(c!==null);mi=6,rn=null}function Qw(c,u,m,x,M,A,F,$,he,De){var et=Ft.T,dt=zc();try{kr(2),Ft.T=null,L9(c,u,m,x,dt,M,A,F,$,he,De)}finally{Ft.T=et,kr(dt)}}function L9(c,u,m,x,M,A,F,$){do Uc();while(qc!==null);if(Un&6)throw Error(r(327));var he=c.finishedWork;if(x=c.finishedLanes,he===null)return null;if(c.finishedWork=null,c.finishedLanes=0,he===c.current)throw Error(r(177));c.callbackNode=null,c.callbackPriority=0,c.cancelPendingCommit=null;var De=he.lanes|he.childLanes;if(De|=LS,j(c,x,De,A,F,$),c===Wn&&(rn=Wn=null,hn=0),!(he.subtreeFlags&10256)&&!(he.flags&10256)||Ig||(Ig=!0,qS=De,jS=m,z9(NS,function(){return Uc(),null})),m=(he.flags&15990)!==0,he.subtreeFlags&15990||m?(m=Ft.T,Ft.T=null,A=zc(),kr(2),F=Un,Un|=4,w9(c,he),Ow(he,c),K9(c.containerInfo),c.current=he,Cw(c,he.alternate,he),lz(),Un=F,kr(A),Ft.T=m):c.current=he,Ig?(Ig=!1,qc=c,wp=x):Jw(c,De),De=c.pendingLanes,De===0&&(wl=null),W(he.stateNode),$e(c),u!==null)for(M=c.onRecoverableError,he=0;he<u.length;he++)De=u[he],M(De.value,{componentStack:De.stack});return wp&3&&Uc(),De=c.pendingLanes,x&4194218&&De&42?c===ZS?Rp++:(Rp=0,ZS=c):Rp=0,Je(0),null}function Jw(c,u){(c.pooledCacheLanes&=u)===0&&(u=c.pooledCache,u!=null&&(c.pooledCache=null,up(u)))}function Uc(){if(qc!==null){var c=qc,u=qS;qS=0;var m=ae(wp),x=32>m?32:m;m=Ft.T;var M=zc();try{if(kr(x),Ft.T=null,qc===null)var A=!1;else{x=jS,jS=null;var F=qc,$=wp;if(qc=null,wp=0,Un&6)throw Error(r(331));var he=Un;if(Un|=4,zw(F.current),Iw(F,F.current,$,x),Un=he,Je(0,!1),ma&&typeof ma.onPostCommitFiberRoot=="function")try{ma.onPostCommitFiberRoot(_p,F)}catch{}A=!0}return A}finally{kr(M),Ft.T=m,Jw(c,u)}}return!1}function $w(c,u,m){u=oe(m,u),u=Uy(c.stateNode,u,2),c=He(c,u,2),c!==null&&(B(c,2),$e(c))}function bn(c,u,m){if(c.tag===3)$w(c,c,m);else for(;u!==null;){if(u.tag===3){$w(u,c,m);break}else if(u.tag===1){var x=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(wl===null||!wl.has(x))){c=oe(m,c),m=nw(2),x=He(u,m,2),x!==null&&(iw(m,x,u,c),B(x,2),$e(x));break}}u=u.return}}function hS(c,u,m){var x=c.pingCache;if(x===null){x=c.pingCache=new xz;var M=new Set;x.set(u,M)}else M=x.get(u),M===void 0&&(M=new Set,x.set(u,M));M.has(m)||(kS=!0,M.add(m),c=I9.bind(null,c,u,m),u.then(c,c))}function I9(c,u,m){var x=c.pingCache;x!==null&&x.delete(u),c.pingedLanes|=c.suspendedLanes&m,c.warmLanes&=~m,Wn===c&&(hn&m)===m&&(mi===4||mi===3&&(hn&62914560)===hn&&300>fs()-YS?!(Un&2)&&Mh(c,0):WS|=m,Xh===hn&&(Xh=0)),$e(c)}function eR(c,u){u===0&&(u=O()),c=Ne(c,u),c!==null&&(B(c,u),$e(c))}function U9(c){var u=c.memoizedState,m=0;u!==null&&(m=u.retryLane),eR(c,m)}function P9(c,u){var m=0;switch(c.tag){case 13:var x=c.stateNode,M=c.memoizedState;M!==null&&(m=M.retryLane);break;case 19:x=c.stateNode;break;case 22:x=c.stateNode._retryCache;break;default:throw Error(r(314))}x!==null&&x.delete(u),eR(c,m)}function z9(c,u){return vg(c,u)}function B9(c,u,m,x){this.tag=c,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fS(c){return c=c.prototype,!(!c||!c.isReactComponent)}function _l(c,u){var m=c.alternate;return m===null?(m=t(c.tag,u,c.key,c.mode),m.elementType=c.elementType,m.type=c.type,m.stateNode=c.stateNode,m.alternate=c,c.alternate=m):(m.pendingProps=u,m.type=c.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=c.flags&31457280,m.childLanes=c.childLanes,m.lanes=c.lanes,m.child=c.child,m.memoizedProps=c.memoizedProps,m.memoizedState=c.memoizedState,m.updateQueue=c.updateQueue,u=c.dependencies,m.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},m.sibling=c.sibling,m.index=c.index,m.ref=c.ref,m.refCleanup=c.refCleanup,m}function tR(c,u){c.flags&=31457282;var m=c.alternate;return m===null?(c.childLanes=0,c.lanes=u,c.child=null,c.subtreeFlags=0,c.memoizedProps=null,c.memoizedState=null,c.updateQueue=null,c.dependencies=null,c.stateNode=null):(c.childLanes=m.childLanes,c.lanes=m.lanes,c.child=m.child,c.subtreeFlags=0,c.deletions=null,c.memoizedProps=m.memoizedProps,c.memoizedState=m.memoizedState,c.updateQueue=m.updateQueue,c.type=m.type,u=m.dependencies,c.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),c}function hg(c,u,m,x,M,A){var F=0;if(x=c,typeof c=="function")fS(c)&&(F=1);else if(typeof c=="string")F=Ba&&gr?RR(c,m,ar.current)?26:PR(c)?27:5:Ba?RR(c,m,ar.current)?26:5:gr&&PR(c)?27:5;else e:switch(c){case wh:return Pc(m.children,M,A,u);case lR:F=8,M|=24;break;case vS:return c=t(12,m,u,M|2),c.elementType=vS,c.lanes=A,c;case xS:return c=t(13,m,u,M),c.elementType=xS,c.lanes=A,c;case yS:return c=t(19,m,u,M),c.elementType=yS,c.lanes=A,c;case uR:return nR(m,M,A,u);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case V9:case xl:F=10;break e;case cR:F=9;break e;case _S:F=11;break e;case SS:F=14;break e;case yl:F=16,x=null;break e}F=29,m=Error(r(130,c===null?"null":typeof c,"")),x=null}return u=t(F,m,u,M),u.elementType=c,u.type=x,u.lanes=A,u}function Pc(c,u,m,x){return c=t(7,c,x,u),c.lanes=m,c}function nR(c,u,m,x){c=t(22,c,x,u),c.elementType=uR,c.lanes=m;var M={_visibility:1,_pendingVisibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null,_current:null,detach:function(){var A=M._current;if(A===null)throw Error(r(456));if(!(M._pendingVisibility&2)){var F=Ne(A,2);F!==null&&(M._pendingVisibility|=2,br(F,A,2))}},attach:function(){var A=M._current;if(A===null)throw Error(r(456));if(M._pendingVisibility&2){var F=Ne(A,2);F!==null&&(M._pendingVisibility&=-3,br(F,A,2))}}};return c.stateNode=M,c}function dS(c,u,m){return c=t(6,c,null,u),c.lanes=m,c}function pS(c,u,m){return u=t(4,c.children!==null?c.children:[],c.key,u),u.lanes=m,u.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},u}function H9(c,u,m,x,M,A,F,$){this.tag=1,this.containerInfo=c,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=bS,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=w(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.finishedLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=w(0),this.hiddenUpdates=w(null),this.identifierPrefix=x,this.onUncaughtError=M,this.onCaughtError=A,this.onRecoverableError=F,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=$,this.incompleteTransitions=new Map}function iR(c,u,m,x,M,A,F,$,he,De,et,dt){return c=new H9(c,u,m,F,$,he,De,dt),u=1,A===!0&&(u|=24),A=t(3,null,null,u),c.current=A,A.stateNode=c,u=Yy(),u.refCount++,c.pooledCache=u,u.refCount++,A.memoizedState={element:x,isDehydrated:m,cache:u},xt(A),c}function rR(c){return c?(c=Dh,c):Dh}function aR(c){var u=c._reactInternals;if(u===void 0)throw typeof c.render=="function"?Error(r(188)):(c=Object.keys(c).join(","),Error(r(268,c)));return c=g(u),c=c!==null?_(c):null,c===null?null:mp(c.stateNode)}function sR(c,u,m,x,M,A){M=rR(M),x.context===null?x.context=M:x.pendingContext=M,x=Ie(u),x.payload={element:m},A=A===void 0?null:A,A!==null&&(x.callback=A),m=He(c,x,u),m!==null&&(br(m,c,u),ht(m,c,u))}function oR(c,u){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var m=c.retryLane;c.retryLane=m!==0&&m<u?m:u}}function mS(c,u){oR(c,u),(c=c.alternate)&&oR(c,u)}var nn={},F9=Me,da=wE,gS=Object.assign,G9=Symbol.for("react.element"),fg=Symbol.for("react.transitional.element"),Ah=Symbol.for("react.portal"),wh=Symbol.for("react.fragment"),lR=Symbol.for("react.strict_mode"),vS=Symbol.for("react.profiler"),V9=Symbol.for("react.provider"),cR=Symbol.for("react.consumer"),xl=Symbol.for("react.context"),_S=Symbol.for("react.forward_ref"),xS=Symbol.for("react.suspense"),yS=Symbol.for("react.suspense_list"),SS=Symbol.for("react.memo"),yl=Symbol.for("react.lazy"),uR=Symbol.for("react.offscreen"),k9=Symbol.for("react.memo_cache_sentinel"),hR=Symbol.iterator,W9=Symbol.for("react.client.reference"),Ft=F9.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,TS,fR,ES=!1,dg=Array.isArray,X9=e.rendererVersion,Y9=e.rendererPackageName,dR=e.extraDevToolsConfig,mp=e.getPublicInstance,q9=e.getRootHostContext,j9=e.getChildHostContext,Z9=e.prepareForCommit,K9=e.resetAfterCommit,Q9=e.createInstance,MS=e.appendInitialChild,pR=e.finalizeInitialChildren,pg=e.shouldSetTextContent,mR=e.createTextInstance,J9=e.scheduleTimeout,$9=e.cancelTimeout,bS=e.noTimeout,_o=e.isPrimaryRenderer;e.warnsIfNotActing;var mr=e.supportsMutation,Sl=e.supportsPersistence,za=e.supportsHydration,gR=e.getInstanceFromNode;e.beforeActiveInstanceBlur,e.afterActiveInstanceBlur;var e7=e.preparePortalMount;e.prepareScopeUpdate,e.getInstanceFromScope;var kr=e.setCurrentUpdatePriority,zc=e.getCurrentUpdatePriority,t7=e.resolveUpdatePriority;e.resolveEventType,e.resolveEventTimeStamp;var n7=e.shouldAttemptEagerTransition,i7=e.detachDeletedInstance;e.requestPostPaintCallback;var r7=e.maySuspendCommit,vR=e.preloadInstance,a7=e.startSuspendingCommit,_R=e.suspendInstance,s7=e.waitForCommitToBeReady,Rh=e.NotPendingTransition,Bc=e.HostTransitionContext,o7=e.resetFormInstance;e.bindToConsole;var l7=e.supportsMicrotasks,c7=e.scheduleMicrotask,gp=e.supportsTestSelectors,u7=e.findFiberRoot,h7=e.getBoundingRect,f7=e.getTextContent,vp=e.isHiddenSubtree,d7=e.matchAccessibilityRole,p7=e.setFocusIfFocusable,m7=e.setupIntersectionObserver,g7=e.appendChild,v7=e.appendChildToContainer,_7=e.commitTextUpdate,x7=e.commitMount,y7=e.commitUpdate,S7=e.insertBefore,T7=e.insertInContainerBefore,E7=e.removeChild,M7=e.removeChildFromContainer,xR=e.resetTextContent,b7=e.hideInstance,A7=e.hideTextInstance,w7=e.unhideInstance,R7=e.unhideTextInstance,C7=e.clearContainer,D7=e.cloneInstance,yR=e.createContainerChildSet,SR=e.appendChildToContainerChildSet,N7=e.finalizeContainerChildren,TR=e.replaceContainerChildren,ER=e.cloneHiddenInstance,MR=e.cloneHiddenTextInstance,AS=e.isSuspenseInstancePending,wS=e.isSuspenseInstanceFallback,O7=e.getSuspenseInstanceFallbackErrorDetails,L7=e.registerSuspenseInstanceRetry,I7=e.canHydrateFormStateMarker,U7=e.isFormStateMarkerMatching,bR=e.getNextHydratableSibling,AR=e.getFirstHydratableChild,P7=e.getFirstHydratableChildWithinContainer,z7=e.getFirstHydratableChildWithinSuspenseInstance,B7=e.canHydrateInstance,H7=e.canHydrateTextInstance,F7=e.canHydrateSuspenseInstance,G7=e.hydrateInstance,V7=e.hydrateTextInstance,k7=e.hydrateSuspenseInstance,W7=e.getNextHydratableInstanceAfterSuspenseInstance,X7=e.commitHydratedContainer,Y7=e.commitHydratedSuspenseInstance,q7=e.clearSuspenseBoundary,j7=e.clearSuspenseBoundaryFromContainer,wR=e.shouldDeleteUnhydratedTailInstances;e.diffHydratedPropsForDevWarnings,e.diffHydratedTextForDevWarnings,e.describeHydratableInstanceForDevWarnings;var Z7=e.validateHydratableInstance,K7=e.validateHydratableTextInstance,Ba=e.supportsResources,RR=e.isHostHoistableType,RS=e.getHoistableRoot,CR=e.getResource,DR=e.acquireResource,NR=e.releaseResource,Q7=e.hydrateHoistable,OR=e.mountHoistable,LR=e.unmountHoistable,J7=e.createHoistableInstance,$7=e.prepareToCommitHoistables,ez=e.mayResourceSuspendCommit,IR=e.preloadResource,tz=e.suspendResource,gr=e.supportsSingletons,UR=e.resolveSingletonInstance,nz=e.clearSingleton,iz=e.acquireSingletonInstance,rz=e.releaseSingletonInstance,PR=e.isHostSingletonType,CS=[],Ch=-1,Dh={},pa=Math.clz32?Math.clz32:E,az=Math.log,sz=Math.LN2,mg=128,gg=4194304,vg=da.unstable_scheduleCallback,DS=da.unstable_cancelCallback,oz=da.unstable_shouldYield,lz=da.unstable_requestPaint,fs=da.unstable_now,zR=da.unstable_ImmediatePriority,cz=da.unstable_UserBlockingPriority,NS=da.unstable_NormalPriority,uz=da.unstable_IdlePriority,hz=da.log,fz=da.unstable_setDisableYieldValue,_p=null,ma=null,ga=typeof Object.is=="function"?Object.is:K,BR=new WeakMap,Nh=[],Oh=0,_g=null,xg=0,Ha=[],Fa=0,Hc=null,xo=1,yo="",ar=y(null),xp=y(null),Tl=y(null),yg=y(null),Ar=null,vr=null,mn=!1,ds=null,Fs=!1,OS=Error(r(519)),Ga=[],Lh=0,LS=0,Sg=null,Ih=null,IS=!1,Tg=!1,US=!1,Uh=0,yp=null,PS=0,Ph=0,zh=null,El=!1,zS=!1,dz=Object.prototype.hasOwnProperty,Sp=Error(r(460)),BS=Error(r(474)),Eg={then:function(){}},Bh=null,Hh=null,Tp=0,Fc=ci(!0),HR=ci(!1),Fh=y(null),Mg=y(0),Va=y(null),Gs=null,Hi=y(0),Ml=0,$t=null,In=null,Ai=null,bg=!1,Gh=!1,Gc=!1,Ag=0,Ep=0,Vh=null,pz=0,HS=function(){return{lastEffect:null,events:null,stores:null,memoCache:null}},Vs={readContext:pr,use:Z,useCallback:On,useContext:On,useEffect:On,useImperativeHandle:On,useLayoutEffect:On,useInsertionEffect:On,useMemo:On,useReducer:On,useRef:On,useState:On,useDebugValue:On,useDeferredValue:On,useTransition:On,useSyncExternalStore:On,useId:On};Vs.useCacheRefresh=On,Vs.useMemoCache=On,Vs.useHostTransitionStatus=On,Vs.useFormState=On,Vs.useActionState=On,Vs.useOptimistic=On;var Vc={readContext:pr,use:Z,useCallback:function(c,u){return Y().memoizedState=[c,u===void 0?null:u],c},useContext:pr,useEffect:BA,useImperativeHandle:function(c,u,m){m=m!=null?m.concat([c]):null,Pa(4194308,4,GA.bind(null,u,c),m)},useLayoutEffect:function(c,u){return Pa(4194308,4,c,u)},useInsertionEffect:function(c,u){Pa(4,2,c,u)},useMemo:function(c,u){var m=Y();u=u===void 0?null:u;var x=c();if(Gc){te(!0);try{c()}finally{te(!1)}}return m.memoizedState=[x,u],x},useReducer:function(c,u,m){var x=Y();if(m!==void 0){var M=m(u);if(Gc){te(!0);try{m(u)}finally{te(!1)}}}else M=u;return x.memoizedState=x.baseState=M,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:M},x.queue=c,c=c.dispatch=T9.bind(null,$t,c),[x.memoizedState,c]},useRef:function(c){var u=Y();return c={current:c},u.memoizedState=c},useState:function(c){c=lt(c);var u=c.queue,m=KA.bind(null,$t,u);return u.dispatch=m,[c.memoizedState,m]},useDebugValue:Dy,useDeferredValue:function(c,u){var m=Y();return Ny(m,c,u)},useTransition:function(){var c=lt(!1);return c=YA.bind(null,$t,c.queue,!0,!1),Y().memoizedState=c,[!1,c]},useSyncExternalStore:function(c,u,m){var x=$t,M=Y();if(mn){if(m===void 0)throw Error(r(407));m=m()}else{if(m=u(),Wn===null)throw Error(r(349));hn&60||Se(x,u,m)}M.memoizedState=m;var A={value:m,getSnapshot:u};return M.queue=A,BA(Pe.bind(null,x,A,c),[c]),x.flags|=2048,kn(9,Re.bind(null,x,A,m,u),{destroy:void 0},null),m},useId:function(){var c=Y(),u=Wn.identifierPrefix;if(mn){var m=yo,x=xo;m=(x&~(1<<32-pa(x)-1)).toString(32)+m,u=":"+u+"R"+m,m=Ag++,0<m&&(u+="H"+m.toString(32)),u+=":"}else m=pz++,u=":"+u+"r"+m.toString(32)+":";return c.memoizedState=u},useCacheRefresh:function(){return Y().memoizedState=S9.bind(null,$t)}};Vc.useMemoCache=H,Vc.useHostTransitionStatus=Oy,Vc.useFormState=kt,Vc.useActionState=kt,Vc.useOptimistic=function(c){var u=Y();u.memoizedState=u.baseState=c;var m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return u.queue=m,u=Ly.bind(null,$t,!0,m),m.dispatch=u,[c,u]};var bl={readContext:pr,use:Z,useCallback:kA,useContext:pr,useEffect:Cy,useImperativeHandle:VA,useInsertionEffect:HA,useLayoutEffect:FA,useMemo:WA,useReducer:ne,useRef:Sh,useState:function(){return ne(X)},useDebugValue:Dy,useDeferredValue:function(c,u){var m=D();return XA(m,In.memoizedState,c,u)},useTransition:function(){var c=ne(X)[0],u=D().memoizedState;return[typeof c=="boolean"?c:V(c),u]},useSyncExternalStore:_e,useId:jA};bl.useCacheRefresh=ZA,bl.useMemoCache=H,bl.useHostTransitionStatus=Oy,bl.useFormState=Dt,bl.useActionState=Dt,bl.useOptimistic=function(c,u){var m=D();return Tt(m,In,c,u)};var kc={readContext:pr,use:Z,useCallback:kA,useContext:pr,useEffect:Cy,useImperativeHandle:VA,useInsertionEffect:HA,useLayoutEffect:FA,useMemo:WA,useReducer:fe,useRef:Sh,useState:function(){return fe(X)},useDebugValue:Dy,useDeferredValue:function(c,u){var m=D();return In===null?Ny(m,c,u):XA(m,In.memoizedState,c,u)},useTransition:function(){var c=fe(X)[0],u=D().memoizedState;return[typeof c=="boolean"?c:V(c),u]},useSyncExternalStore:_e,useId:jA};kc.useCacheRefresh=ZA,kc.useMemoCache=H,kc.useHostTransitionStatus=Oy,kc.useFormState=Mn,kc.useActionState=Mn,kc.useOptimistic=function(c,u){var m=D();return In!==null?Tt(m,In,c,u):(m.baseState=c,[c,m.queue.dispatch])};var FS={isMounted:function(c){return(c=c._reactInternals)?d(c)===c:!1},enqueueSetState:function(c,u,m){c=c._reactInternals;var x=fa(),M=Ie(x);M.payload=u,m!=null&&(M.callback=m),u=He(c,M,x),u!==null&&(br(u,c,x),ht(u,c,x))},enqueueReplaceState:function(c,u,m){c=c._reactInternals;var x=fa(),M=Ie(x);M.tag=1,M.payload=u,m!=null&&(M.callback=m),u=He(c,M,x),u!==null&&(br(u,c,x),ht(u,c,x))},enqueueForceUpdate:function(c,u){c=c._reactInternals;var m=fa(),x=Ie(m);x.tag=2,u!=null&&(x.callback=u),u=He(c,x,m),u!==null&&(br(u,c,m),ht(u,c,m))}},FR=typeof reportError=="function"?reportError:function(c){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var u=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof c=="object"&&c!==null&&typeof c.message=="string"?String(c.message):String(c),error:c});if(!window.dispatchEvent(u))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",c);return}console.error(c)},GR=Error(r(461)),Yi=!1,GS={dehydrated:null,treeContext:null,retryLane:0},wg=y(null),Wc=null,So=null,mz=typeof AbortController<"u"?AbortController:function(){var c=[],u=this.signal={aborted:!1,addEventListener:function(m,x){c.push(x)}};this.abort=function(){u.aborted=!0,c.forEach(function(m){return m()})}},gz=da.unstable_scheduleCallback,vz=da.unstable_NormalPriority,di={$$typeof:xl,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},VR=Ft.S;Ft.S=function(c,u){typeof u=="object"&&u!==null&&typeof u.then=="function"&&ye(c,u),VR!==null&&VR(c,u)};var Xc=y(null),To=!1,pi=!1,VS=!1,kR=typeof WeakSet=="function"?WeakSet:Set,qi=null,WR=!1,wi=null,va=!1,ps=null,kh=8192,_z={getCacheForType:function(c){var u=pr(di),m=u.data.get(c);return m===void 0&&(m=c(),u.data.set(c,m)),m}},Rg=0,Cg=1,Dg=2,Ng=3,Og=4;if(typeof Symbol=="function"&&Symbol.for){var Mp=Symbol.for;Rg=Mp("selector.component"),Cg=Mp("selector.has_pseudo_class"),Dg=Mp("selector.role"),Ng=Mp("selector.test_id"),Og=Mp("selector.text")}var xz=typeof WeakMap=="function"?WeakMap:Map,Un=0,Wn=null,rn=null,hn=0,Xn=0,_a=null,Eo=!1,Wh=!1,kS=!1,Mo=0,mi=0,Al=0,Yc=0,WS=0,ka=0,Xh=0,bp=null,ks=null,XS=!1,YS=0,Ap=1/0,Lg=null,wl=null,Ig=!1,qc=null,wp=0,qS=0,jS=null,Rp=0,ZS=null;return nn.attemptContinuousHydration=function(c){if(c.tag===13){var u=Ne(c,67108864);u!==null&&br(u,c,67108864),mS(c,67108864)}},nn.attemptHydrationAtCurrentPriority=function(c){if(c.tag===13){var u=fa(),m=Ne(c,u);m!==null&&br(m,c,u),mS(c,u)}},nn.attemptSynchronousHydration=function(c){switch(c.tag){case 3:if(c=c.stateNode,c.current.memoizedState.isDehydrated){var u=b(c.pendingLanes);if(u!==0){for(c.pendingLanes|=2,c.entangledLanes|=2;u;){var m=1<<31-pa(u);c.entanglements[1]|=m,u&=~m}$e(c),!(Un&6)&&(Ap=fs()+500,Je(0))}}break;case 13:u=Ne(c,2),u!==null&&br(u,c,2),kw(),mS(c,2)}},nn.batchedUpdates=function(c,u){return c(u)},nn.createComponentSelector=function(c){return{$$typeof:Rg,value:c}},nn.createContainer=function(c,u,m,x,M,A,F,$,he,De){return iR(c,u,!1,null,m,x,A,F,$,he,De,null)},nn.createHasPseudoClassSelector=function(c){return{$$typeof:Cg,value:c}},nn.createHydrationContainer=function(c,u,m,x,M,A,F,$,he,De,et,dt,mt){return c=iR(m,x,!0,c,M,A,$,he,De,et,dt,mt),c.context=rR(null),m=c.current,x=fa(),M=Ie(x),M.callback=u??null,He(m,M,x),c.current.lanes=x,B(c,x),$e(c),c},nn.createPortal=function(c,u,m){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ah,key:x==null?null:""+x,children:c,containerInfo:u,implementation:m}},nn.createRoleSelector=function(c){return{$$typeof:Dg,value:c}},nn.createTestNameSelector=function(c){return{$$typeof:Ng,value:c}},nn.createTextSelector=function(c){return{$$typeof:Og,value:c}},nn.defaultOnCaughtError=function(c){console.error(c)},nn.defaultOnRecoverableError=function(c){FR(c)},nn.defaultOnUncaughtError=function(c){FR(c)},nn.deferredUpdates=function(c){var u=Ft.T,m=zc();try{return kr(32),Ft.T=null,c()}finally{kr(m),Ft.T=u}},nn.discreteUpdates=function(c,u,m,x,M){var A=Ft.T,F=zc();try{return kr(2),Ft.T=null,c(u,m,x,M)}finally{kr(F),Ft.T=A,Un===0&&(Ap=fs()+500)}},nn.findAllNodes=sS,nn.findBoundingRects=function(c,u){if(!gp)throw Error(r(363));u=sS(c,u),c=[];for(var m=0;m<u.length;m++)c.push(h7(u[m]));for(u=c.length-1;0<u;u--){m=c[u];for(var x=m.x,M=x+m.width,A=m.y,F=A+m.height,$=u-1;0<=$;$--)if(u!==$){var he=c[$],De=he.x,et=De+he.width,dt=he.y,mt=dt+he.height;if(x>=De&&A>=dt&&M<=et&&F<=mt){c.splice(u,1);break}else if(x!==De||m.width!==he.width||mt<A||dt>F){if(!(A!==dt||m.height!==he.height||et<x||De>M)){De>x&&(he.width+=De-x,he.x=x),et<M&&(he.width=M-De),c.splice(u,1);break}}else{dt>A&&(he.height+=dt-A,he.y=A),mt<F&&(he.height=F-dt),c.splice(u,1);break}}}return c},nn.findHostInstance=aR,nn.findHostInstanceWithNoPortals=function(c){return c=g(c),c=c!==null?T(c):null,c===null?null:mp(c.stateNode)},nn.findHostInstanceWithWarning=function(c){return aR(c)},nn.flushPassiveEffects=Uc,nn.flushSyncFromReconciler=function(c){var u=Un;Un|=1;var m=Ft.T,x=zc();try{if(kr(2),Ft.T=null,c)return c()}finally{kr(x),Ft.T=m,Un=u,!(Un&6)&&Je(0)}},nn.flushSyncWork=kw,nn.focusWithin=function(c,u){if(!gp)throw Error(r(363));for(c=iS(c),u=Hw(c,u),u=Array.from(u),c=0;c<u.length;){var m=u[c++],x=m.tag;if(!vp(m)){if((x===5||x===26||x===27)&&p7(m.stateNode))return!0;for(m=m.child;m!==null;)u.push(m),m=m.sibling}}return!1},nn.getFindAllNodesFailureDescription=function(c,u){if(!gp)throw Error(r(363));var m=0,x=[];c=[iS(c),0];for(var M=0;M<c.length;){var A=c[M++],F=A.tag,$=c[M++],he=u[$];if((F!==5&&F!==26&&F!==27||!vp(A))&&(rS(A,he)&&(x.push(aS(he)),$++,$>m&&(m=$)),$<u.length))for(A=A.child;A!==null;)c.push(A,$),A=A.sibling}if(m<u.length){for(c=[];m<u.length;m++)c.push(aS(u[m]));return`findAllNodes was able to match part of the selector:
  `+(x.join(" > ")+`

No matching component was found for:
  `)+c.join(" > ")}return null},nn.getPublicRootInstance=function(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 27:case 5:return mp(c.child.stateNode);default:return c.child.stateNode}},nn.injectIntoDevTools=function(){var c={bundleType:0,version:X9,rendererPackageName:Y9,currentDispatcherRef:Ft,findFiberByHostInstance:gR,reconcilerVersion:"19.0.0"};if(dR!==null&&(c.rendererConfig=dR),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")c=!1;else{var u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(u.isDisabled||!u.supportsFiber)c=!0;else{try{_p=u.inject(c),ma=u}catch{}c=!!u.checkDCE}}return c},nn.isAlreadyRendering=function(){return!1},nn.observeVisibleRects=function(c,u,m,x){if(!gp)throw Error(r(363));c=sS(c,u);var M=m7(c,m,x).disconnect;return{disconnect:function(){M()}}},nn.shouldError=function(){return null},nn.shouldSuspend=function(){return!1},nn.startHostTransition=function(c,u,m,x){if(c.tag!==5)throw Error(r(476));var M=qA(c).queue;YA(c,M,u,Rh,m===null?i:function(){var A=qA(c).next.queue;return op(c,A,{},fa()),m(x)})},nn.updateContainer=function(c,u,m,x){var M=u.current,A=fa();return sR(M,A,c,u,m,x),A},nn.updateContainerSync=function(c,u,m,x){return u.tag===0&&Uc(),sR(u.current,2,c,u,m,x),2},nn},n.exports.default=n.exports,Object.defineProperty(n.exports,"__esModule",{value:!0})})(r8);var iZ=r8.exports;i8.exports=iZ;var rZ=i8.exports;const aZ=p1(rZ);function cA(n,e,t){if(!n)return;if(t(n)===!0)return n;let i=e?n.return:n.child;for(;i;){const r=cA(i,e,t);if(r)return r;i=e?null:i.sibling}}function o8(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const uA=o8(Me.createContext(null));let l8=class extends Me.Component{render(){return Me.createElement(uA.Provider,{value:this._reactInternals},this.props.children)}};function c8(){const n=Me.useContext(uA);if(n===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=Me.useId();return Me.useMemo(()=>{for(const t of[n,n==null?void 0:n.alternate]){if(!t)continue;const i=cA(t,!1,r=>{let a=r.memoizedState;for(;a;){if(a.memoizedState===e)return!0;a=a.next}});if(i)return i}},[n,e])}const sZ=Symbol.for("react.context"),oZ=n=>n!==null&&typeof n=="object"&&"$$typeof"in n&&n.$$typeof===sZ;function lZ(){const n=c8(),[e]=Me.useState(()=>new Map);e.clear();let t=n;for(;t;){const i=t.type;oZ(i)&&i!==uA&&!e.has(i)&&e.set(i,Me.use(o8(i))),t=t.return}return e}function cZ(){const n=lZ();return Me.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>i=>Me.createElement(e,null,Me.createElement(t.Provider,{...i,value:n.get(t)})),e=>Me.createElement(l8,{...e})),[n])}function u8(n){let e=n.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const h8=n=>n&&n.isOrthographicCamera,uZ=n=>n&&n.hasOwnProperty("current"),hZ=n=>n!=null&&(typeof n=="string"||typeof n=="number"||n.isColor),j0=((n,e)=>typeof window<"u"&&(((n=window.document)==null?void 0:n.createElement)||((e=window.navigator)==null?void 0:e.product)==="ReactNative"))()?Me.useLayoutEffect:Me.useEffect;function f8(n){const e=Me.useRef(n);return j0(()=>void(e.current=n),[n]),e}function fZ(){const n=c8(),e=cZ();return Me.useMemo(()=>({children:t})=>{const r=!!cA(n,!0,a=>a.type===Me.StrictMode)?Me.StrictMode:Me.Fragment;return Mt.jsx(r,{children:Mt.jsx(e,{children:t})})},[n,e])}function dZ({set:n}){return j0(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}const pZ=(n=>(n=class extends Me.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}},n.getDerivedStateFromError=()=>({error:!0}),n))();function d8(n){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(n)?Math.min(Math.max(n[0],t),n[1]):n}function gf(n){var e;return(e=n.__r3f)==null?void 0:e.root.getState()}const ai={obj:n=>n===Object(n)&&!ai.arr(n)&&typeof n!="function",fun:n=>typeof n=="function",str:n=>typeof n=="string",num:n=>typeof n=="number",boo:n=>typeof n=="boolean",und:n=>n===void 0,nul:n=>n===null,arr:n=>Array.isArray(n),equ(n,e,{arrays:t="shallow",objects:i="reference",strict:r=!0}={}){if(typeof n!=typeof e||!!n!=!!e)return!1;if(ai.str(n)||ai.num(n)||ai.boo(n))return n===e;const a=ai.obj(n);if(a&&i==="reference")return n===e;const s=ai.arr(n);if(s&&t==="reference")return n===e;if((s||a)&&n===e)return!0;let o;for(o in n)if(!(o in e))return!1;if(a&&t==="shallow"&&i==="shallow"){for(o in r?e:n)if(!ai.equ(n[o],e[o],{strict:r,objects:"reference"}))return!1}else for(o in r?e:n)if(n[o]!==e[o])return!1;if(ai.und(o)){if(s&&n.length===0&&e.length===0||a&&Object.keys(n).length===0&&Object.keys(e).length===0)return!0;if(n!==e)return!1}return!0}};function mZ(n){const e={nodes:{},materials:{},meshes:{}};return n&&n.traverse(t=>{t.name&&(e.nodes[t.name]=t),t.material&&!e.materials[t.material.name]&&(e.materials[t.material.name]=t.material),t.isMesh&&!e.meshes[t.name]&&(e.meshes[t.name]=t)}),e}function gZ(n){n.type!=="Scene"&&(n.dispose==null||n.dispose());for(const e in n){const t=n[e];(t==null?void 0:t.type)!=="Scene"&&(t==null||t.dispose==null||t.dispose())}}const p8=["children","key","ref"];function vZ(n){const e={};for(const t in n)p8.includes(t)||(e[t]=n[t]);return e}function jx(n,e,t,i){const r=n;let a=r==null?void 0:r.__r3f;return a||(a={root:e,type:t,parent:null,children:[],props:vZ(i),object:r,eventCount:0,handlers:{},isHidden:!1},r&&(r.__r3f=a)),a}function S0(n,e){if(!e.includes("-"))return{root:n,key:e,target:n[e]};if(e in n)return{root:n,key:e,target:n[e]};let t=n;const i=e.split("-");for(const r of i){if(typeof t!="object"||t===null){if(t!==void 0){const a=i.slice(i.indexOf(r)).join("-");return{root:t,key:a,target:void 0}}return{root:n,key:e,target:void 0}}e=r,n=t,t=t[e]}return{root:n,key:e,target:t}}const KD=/-\d+$/;function Zx(n,e){if(ai.str(e.props.attach)){if(KD.test(e.props.attach)){const r=e.props.attach.replace(KD,""),{root:a,key:s}=S0(n.object,r);Array.isArray(a[s])||(a[s]=[])}const{root:t,key:i}=S0(n.object,e.props.attach);e.previousAttach=t[i],t[i]=e.object}else ai.fun(e.props.attach)&&(e.previousAttach=e.props.attach(n.object,e.object))}function Kx(n,e){if(ai.str(e.props.attach)){const{root:t,key:i}=S0(n.object,e.props.attach),r=e.previousAttach;r===void 0?delete t[i]:t[i]=r}else e.previousAttach==null||e.previousAttach(n.object,e.object);delete e.previousAttach}const RE=[...p8,"args","dispose","attach","object","onUpdate","dispose"],QD=new Map;function _Z(n){let e=QD.get(n.constructor);try{e||(e=new n.constructor,QD.set(n.constructor,e))}catch{}return e}function xZ(n,e){const t={};for(const i in e)if(!RE.includes(i)&&!ai.equ(e[i],n.props[i])){t[i]=e[i];for(const r in e)r.startsWith(`${i}-`)&&(t[r]=e[r])}for(const i in n.props){if(RE.includes(i)||e.hasOwnProperty(i))continue;const{root:r,key:a}=S0(n.object,i);if(r.constructor&&r.constructor.length===0){const s=_Z(r);ai.und(s)||(t[a]=s[a])}else t[a]=0}return t}const yZ=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],SZ=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function jl(n,e){var t;const i=n.__r3f,r=i&&u8(i).getState(),a=i==null?void 0:i.eventCount;for(const o in e){let l=e[o];if(RE.includes(o))continue;if(i&&SZ.test(o)){typeof l=="function"?i.handlers[o]=l:delete i.handlers[o],i.eventCount=Object.keys(i.handlers).length;continue}if(l===void 0)continue;let{root:h,key:f,target:d}=S0(n,o);if(d===void 0&&(typeof h!="object"||h===null))throw Error(`R3F: Cannot set "${o}". Ensure it is an object before setting "${f}".`);if(d instanceof Cd&&l instanceof Cd)d.mask=l.mask;else if(d instanceof qe&&hZ(l))d.set(l);else if(d!==null&&typeof d=="object"&&typeof d.set=="function"&&typeof d.copy=="function"&&l!=null&&l.constructor&&d.constructor===l.constructor)d.copy(l);else if(d!==null&&typeof d=="object"&&typeof d.set=="function"&&Array.isArray(l))typeof d.fromArray=="function"?d.fromArray(l):d.set(...l);else if(d!==null&&typeof d=="object"&&typeof d.set=="function"&&typeof l=="number")typeof d.setScalar=="function"?d.setScalar(l):d.set(l);else{var s;h[f]=l,r&&!r.linear&&yZ.includes(f)&&(s=h[f])!=null&&s.isTexture&&h[f].format===$n&&h[f].type===Pi&&(h[f].colorSpace=dn)}}if(i!=null&&i.parent&&r!=null&&r.internal&&(t=i.object)!=null&&t.isObject3D&&a!==i.eventCount){const o=i.object,l=r.internal.interaction.indexOf(o);l>-1&&r.internal.interaction.splice(l,1),i.eventCount&&o.raycast!==null&&r.internal.interaction.push(o)}return i&&i.props.attach===void 0&&(i.object.isBufferGeometry?i.props.attach="geometry":i.object.isMaterial&&(i.props.attach="material")),i&&$d(i),n}function $d(n){var e;if(!n.parent)return;n.props.onUpdate==null||n.props.onUpdate(n.object);const t=(e=n.root)==null||e.getState==null?void 0:e.getState();t&&t.internal.frames===0&&t.invalidate()}function TZ(n,e){n.manual||(h8(n)?(n.left=e.width/-2,n.right=e.width/2,n.top=e.height/2,n.bottom=e.height/-2):n.aspect=e.width/e.height,n.updateProjectionMatrix())}const Dr=n=>n==null?void 0:n.isObject3D;function Gv(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function m8(n,e,t,i){const r=t.get(e);r&&(t.delete(e),t.size===0&&(n.delete(i),r.target.releasePointerCapture(i)))}function EZ(n,e){const{internal:t}=n.getState();t.interaction=t.interaction.filter(i=>i!==e),t.initialHits=t.initialHits.filter(i=>i!==e),t.hovered.forEach((i,r)=>{(i.eventObject===e||i.object===e)&&t.hovered.delete(r)}),t.capturedMap.forEach((i,r)=>{m8(t.capturedMap,e,i,r)})}function MZ(n){function e(l){const{internal:h}=n.getState(),f=l.offsetX-h.initialClick[0],d=l.offsetY-h.initialClick[1];return Math.round(Math.sqrt(f*f+d*d))}function t(l){return l.filter(h=>["Move","Over","Enter","Out","Leave"].some(f=>{var d;return(d=h.__r3f)==null?void 0:d.handlers["onPointer"+f]}))}function i(l,h){const f=n.getState(),d=new Set,p=[],g=h?h(f.internal.interaction):f.internal.interaction;for(let v=0;v<g.length;v++){const S=gf(g[v]);S&&(S.raycaster.camera=void 0)}f.previousRoot||f.events.compute==null||f.events.compute(l,f);function _(v){const S=gf(v);if(!S||!S.events.enabled||S.raycaster.camera===null)return[];if(S.raycaster.camera===void 0){var E;S.events.compute==null||S.events.compute(l,S,(E=S.previousRoot)==null?void 0:E.getState()),S.raycaster.camera===void 0&&(S.raycaster.camera=null)}return S.raycaster.camera?S.raycaster.intersectObject(v,!0):[]}let T=g.flatMap(_).sort((v,S)=>{const E=gf(v.object),b=gf(S.object);return!E||!b?v.distance-S.distance:b.events.priority-E.events.priority||v.distance-S.distance}).filter(v=>{const S=Gv(v);return d.has(S)?!1:(d.add(S),!0)});f.events.filter&&(T=f.events.filter(T,f));for(const v of T){let S=v.object;for(;S;){var y;(y=S.__r3f)!=null&&y.eventCount&&p.push({...v,eventObject:S}),S=S.parent}}if("pointerId"in l&&f.internal.capturedMap.has(l.pointerId))for(let v of f.internal.capturedMap.get(l.pointerId).values())d.has(Gv(v.intersection))||p.push(v.intersection);return p}function r(l,h,f,d){if(l.length){const p={stopped:!1};for(const g of l){let _=gf(g.object);if(_||g.object.traverseAncestors(T=>{const y=gf(T);if(y)return _=y,!1}),_){const{raycaster:T,pointer:y,camera:v,internal:S}=_,E=new L(y.x,y.y,0).unproject(v),b=O=>{var w,B;return(w=(B=S.capturedMap.get(O))==null?void 0:B.has(g.eventObject))!=null?w:!1},N=O=>{const w={intersection:g,target:h.target};S.capturedMap.has(O)?S.capturedMap.get(O).set(g.eventObject,w):S.capturedMap.set(O,new Map([[g.eventObject,w]])),h.target.setPointerCapture(O)},R=O=>{const w=S.capturedMap.get(O);w&&m8(S.capturedMap,g.eventObject,w,O)};let I={};for(let O in h){let w=h[O];typeof w!="function"&&(I[O]=w)}let U={...g,...I,pointer:y,intersections:l,stopped:p.stopped,delta:f,unprojectedPoint:E,ray:T.ray,camera:v,stopPropagation(){const O="pointerId"in h&&S.capturedMap.get(h.pointerId);if((!O||O.has(g.eventObject))&&(U.stopped=p.stopped=!0,S.hovered.size&&Array.from(S.hovered.values()).find(w=>w.eventObject===g.eventObject))){const w=l.slice(0,l.indexOf(g));a([...w,g])}},target:{hasPointerCapture:b,setPointerCapture:N,releasePointerCapture:R},currentTarget:{hasPointerCapture:b,setPointerCapture:N,releasePointerCapture:R},nativeEvent:h};if(d(U),p.stopped===!0)break}}}return l}function a(l){const{internal:h}=n.getState();for(const f of h.hovered.values())if(!l.length||!l.find(d=>d.object===f.object&&d.index===f.index&&d.instanceId===f.instanceId)){const p=f.eventObject.__r3f;if(h.hovered.delete(Gv(f)),p!=null&&p.eventCount){const g=p.handlers,_={...f,intersections:l};g.onPointerOut==null||g.onPointerOut(_),g.onPointerLeave==null||g.onPointerLeave(_)}}}function s(l,h){for(let f=0;f<h.length;f++){const d=h[f].__r3f;d==null||d.handlers.onPointerMissed==null||d.handlers.onPointerMissed(l)}}function o(l){switch(l){case"onPointerLeave":case"onPointerCancel":return()=>a([]);case"onLostPointerCapture":return h=>{const{internal:f}=n.getState();"pointerId"in h&&f.capturedMap.has(h.pointerId)&&requestAnimationFrame(()=>{f.capturedMap.has(h.pointerId)&&(f.capturedMap.delete(h.pointerId),a([]))})}}return function(f){const{onPointerMissed:d,internal:p}=n.getState();p.lastEvent.current=f;const g=l==="onPointerMove",_=l==="onClick"||l==="onContextMenu"||l==="onDoubleClick",y=i(f,g?t:void 0),v=_?e(f):0;l==="onPointerDown"&&(p.initialClick=[f.offsetX,f.offsetY],p.initialHits=y.map(E=>E.eventObject)),_&&!y.length&&v<=2&&(s(f,p.interaction),d&&d(f)),g&&a(y);function S(E){const b=E.eventObject,N=b.__r3f;if(!(N!=null&&N.eventCount))return;const R=N.handlers;if(g){if(R.onPointerOver||R.onPointerEnter||R.onPointerOut||R.onPointerLeave){const I=Gv(E),U=p.hovered.get(I);U?U.stopped&&E.stopPropagation():(p.hovered.set(I,E),R.onPointerOver==null||R.onPointerOver(E),R.onPointerEnter==null||R.onPointerEnter(E))}R.onPointerMove==null||R.onPointerMove(E)}else{const I=R[l];I?(!_||p.initialHits.includes(b))&&(s(f,p.interaction.filter(U=>!p.initialHits.includes(U))),I(E)):_&&p.initialHits.includes(b)&&s(f,p.interaction.filter(U=>!p.initialHits.includes(U)))}}r(y,f,v,S)}}return{handlePointer:o}}const JD=n=>!!(n!=null&&n.render),g8=Me.createContext(null),bZ=(n,e)=>{const t=Jj((o,l)=>{const h=new L,f=new L,d=new L;function p(v=l().camera,S=f,E=l().size){const{width:b,height:N,top:R,left:I}=E,U=b/N;S.isVector3?d.copy(S):d.set(...S);const O=v.getWorldPosition(h).distanceTo(d);if(h8(v))return{width:b/v.zoom,height:N/v.zoom,top:R,left:I,factor:1,distance:O,aspect:U};{const w=v.fov*Math.PI/180,B=2*Math.tan(w/2)*O,j=B*(b/N);return{width:j,height:B,top:R,left:I,factor:b/j,distance:O,aspect:U}}}let g;const _=v=>o(S=>({performance:{...S.performance,current:v}})),T=new de;return{set:o,get:l,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(v=1)=>n(l(),v),advance:(v,S)=>e(v,S,l()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new rA,pointer:T,mouse:T,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const v=l();g&&clearTimeout(g),v.performance.current!==v.performance.min&&_(v.performance.min),g=setTimeout(()=>_(l().performance.max),v.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:p},setEvents:v=>o(S=>({...S,events:{...S.events,...v}})),setSize:(v,S,E=0,b=0)=>{const N=l().camera,R={width:v,height:S,top:E,left:b};o(I=>({size:R,viewport:{...I.viewport,...p(N,f,R)}}))},setDpr:v=>o(S=>{const E=d8(v);return{viewport:{...S.viewport,dpr:E,initialDpr:S.viewport.initialDpr||E}}}),setFrameloop:(v="always")=>{const S=l().clock;S.stop(),S.elapsedTime=0,v!=="never"&&(S.start(),S.elapsedTime=0),o(()=>({frameloop:v}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:Me.createRef(),active:!1,frames:0,priority:0,subscribe:(v,S,E)=>{const b=l().internal;return b.priority=b.priority+(S>0?1:0),b.subscribers.push({ref:v,priority:S,store:E}),b.subscribers=b.subscribers.sort((N,R)=>N.priority-R.priority),()=>{const N=l().internal;N!=null&&N.subscribers&&(N.priority=N.priority-(S>0?1:0),N.subscribers=N.subscribers.filter(R=>R.ref!==v))}}}}}),i=t.getState();let r=i.size,a=i.viewport.dpr,s=i.camera;return t.subscribe(()=>{const{camera:o,size:l,viewport:h,gl:f,set:d}=t.getState();if(l.width!==r.width||l.height!==r.height||h.dpr!==a){r=l,a=h.dpr,TZ(o,l),h.dpr>0&&f.setPixelRatio(h.dpr);const p=typeof HTMLCanvasElement<"u"&&f.domElement instanceof HTMLCanvasElement;f.setSize(l.width,l.height,p)}o!==s&&(s=o,d(p=>({viewport:{...p.viewport,...p.viewport.getCurrentViewport(o)}})))}),t.subscribe(o=>n(o)),t};function v8(){const n=Me.useContext(g8);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function Ni(n=t=>t,e){return v8()(n,e)}function fl(n,e=0){const t=v8(),i=t.getState().internal.subscribe,r=f8(n);return j0(()=>i(r,e,t),[e,i,t]),null}const $D=new WeakMap,AZ=n=>{var e;return typeof n=="function"&&(n==null||(e=n.prototype)==null?void 0:e.constructor)===n};function _8(n,e){return function(t,...i){let r;return AZ(t)?(r=$D.get(t),r||(r=new t,$D.set(t,r))):r=t,n&&n(r),Promise.all(i.map(a=>new Promise((s,o)=>r.load(a,l=>{Dr(l==null?void 0:l.scene)&&Object.assign(l,mZ(l.scene)),s(l)},e,l=>o(new Error(`Could not load ${a}: ${l==null?void 0:l.message}`))))))}}function Qx(n,e,t,i){const r=Array.isArray(e)?e:[e],a=eZ(_8(t,i),[n,...r],{equal:ai.equ});return Array.isArray(e)?a:a[0]}Qx.preload=function(n,e,t){const i=Array.isArray(e)?e:[e];return tZ(_8(t),[n,...i])};Qx.clear=function(n,e){const t=Array.isArray(e)?e:[e];return nZ([n,...t])};function wZ(n){const e=aZ(n);return e.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:Me.version}),e}const x8=0,Ud={},RZ=/^three(?=[A-Z])/,my=n=>`${n[0].toUpperCase()}${n.slice(1)}`;let CZ=0;const DZ=n=>typeof n=="function";function y8(n){if(DZ(n)){const e=`${CZ++}`;return Ud[e]=n,e}else Object.assign(Ud,n)}function S8(n,e){const t=my(n),i=Ud[t];if(n!=="primitive"&&!i)throw new Error(`R3F: ${t} 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(n==="primitive"&&!e.object)throw new Error("R3F: Primitives without 'object' are invalid!");if(e.args!==void 0&&!Array.isArray(e.args))throw new Error("R3F: The args prop must be an array!")}function NZ(n,e,t){var i;return n=my(n)in Ud?n:n.replace(RZ,""),S8(n,e),n==="primitive"&&(i=e.object)!=null&&i.__r3f&&delete e.object.__r3f,jx(e.object,t,n,e)}function OZ(n){if(!n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Kx(n.parent,n):Dr(n.object)&&(n.object.visible=!1),n.isHidden=!0,$d(n)}}function T8(n){if(n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Zx(n.parent,n):Dr(n.object)&&n.props.visible!==!1&&(n.object.visible=!0),n.isHidden=!1,$d(n)}}function hA(n,e,t){const i=e.root.getState();if(!(!n.parent&&n.object!==i.scene)){if(!e.object){var r,a;const s=Ud[my(e.type)];e.object=(r=e.props.object)!=null?r:new s(...(a=e.props.args)!=null?a:[]),e.object.__r3f=e}if(jl(e.object,e.props),e.props.attach)Zx(n,e);else if(Dr(e.object)&&Dr(n.object)){const s=n.object.children.indexOf(t==null?void 0:t.object);if(t&&s!==-1){const o=n.object.children.indexOf(e.object);if(o!==-1){n.object.children.splice(o,1);const l=o<s?s-1:s;n.object.children.splice(l,0,e.object)}else e.object.parent=n.object,n.object.children.splice(s,0,e.object),e.object.dispatchEvent({type:"added"}),n.object.dispatchEvent({type:"childadded",child:e.object})}else n.object.add(e.object)}for(const s of e.children)hA(e,s);$d(e)}}function E2(n,e){e&&(e.parent=n,n.children.push(e),hA(n,e))}function eN(n,e,t){if(!e||!t)return;e.parent=n;const i=n.children.indexOf(t);i!==-1?n.children.splice(i,0,e):n.children.push(e),hA(n,e,t)}function E8(n){if(typeof n.dispose=="function"){const e=()=>{try{n.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<"u"?e():wE.unstable_scheduleCallback(wE.unstable_IdlePriority,e)}}function CE(n,e,t){if(!e)return;e.parent=null;const i=n.children.indexOf(e);i!==-1&&n.children.splice(i,1),e.props.attach?Kx(n,e):Dr(e.object)&&Dr(n.object)&&(n.object.remove(e.object),EZ(u8(e),e.object));const r=e.props.dispose!==null&&t!==!1;for(let a=e.children.length-1;a>=0;a--){const s=e.children[a];CE(e,s,r)}e.children.length=0,delete e.object.__r3f,r&&e.type!=="primitive"&&e.object.type!=="Scene"&&E8(e.object),t===void 0&&$d(e)}function LZ(n,e){for(const t of[n,n.alternate])if(t!==null)if(typeof t.ref=="function"){t.refCleanup==null||t.refCleanup();const i=t.ref(e);typeof i=="function"&&(t.refCleanup=i)}else t.ref&&(t.ref.current=e)}const b_=[];function IZ(){for(const[t]of b_){const i=t.parent;if(i){t.props.attach?Kx(i,t):Dr(t.object)&&Dr(i.object)&&i.object.remove(t.object);for(const r of t.children)r.props.attach?Kx(t,r):Dr(r.object)&&Dr(t.object)&&t.object.remove(r.object)}t.isHidden&&T8(t),t.object.__r3f&&delete t.object.__r3f,t.type!=="primitive"&&E8(t.object)}for(const[t,i,r]of b_){t.props=i;const a=t.parent;if(a){var n,e;const s=Ud[my(t.type)];t.object=(n=t.props.object)!=null?n:new s(...(e=t.props.args)!=null?e:[]),t.object.__r3f=t,LZ(r,t.object),jl(t.object,t.props),t.props.attach?Zx(a,t):Dr(t.object)&&Dr(a.object)&&a.object.add(t.object);for(const o of t.children)o.props.attach?Zx(t,o):Dr(o.object)&&Dr(t.object)&&t.object.add(o.object);$d(t)}}b_.length=0}const M2=()=>{},tN={};let Vv=x8;const UZ=0,PZ=4,DE=wZ({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:NZ,removeChild:CE,appendChild:E2,appendInitialChild:E2,insertBefore:eN,appendChildToContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||E2(t,e)},removeChildFromContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||CE(t,e)},insertInContainerBefore(n,e,t){const i=n.getState().scene.__r3f;!e||!t||!i||eN(i,e,t)},getRootHostContext:()=>tN,getChildHostContext:()=>tN,commitUpdate(n,e,t,i,r){var a,s,o;S8(e,i);let l=!1;if((n.type==="primitive"&&t.object!==i.object||((a=i.args)==null?void 0:a.length)!==((s=t.args)==null?void 0:s.length)||(o=i.args)!=null&&o.some((f,d)=>{var p;return f!==((p=t.args)==null?void 0:p[d])}))&&(l=!0),l)b_.push([n,{...i},r]);else{const f=xZ(n,i);Object.keys(f).length&&(Object.assign(n.props,f),jl(n.object,f))}(r.sibling===null||(r.flags&PZ)===UZ)&&IZ()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:n=>n==null?void 0:n.object,prepareForCommit:()=>null,preparePortalMount:n=>jx(n.getState().scene,n,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:OZ,unhideInstance:T8,createTextInstance:M2,hideTextInstance:M2,unhideTextInstance:M2,scheduleTimeout:typeof setTimeout=="function"?setTimeout:void 0,cancelTimeout:typeof clearTimeout=="function"?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,startSuspendingCommit(){},suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:Me.createContext(null),setCurrentUpdatePriority(n){Vv=n},getCurrentUpdatePriority(){return Vv},resolveUpdatePriority(){var n;if(Vv!==x8)return Vv;switch(typeof window<"u"&&((n=window.event)==null?void 0:n.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return S_.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return S_.ContinuousEventPriority;default:return S_.DefaultEventPriority}},resetFormInstance(){}}),nh=new Map,vf={objects:"shallow",strict:!1};function zZ(n,e){if(!e&&typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&n.parentElement){const{width:t,height:i,top:r,left:a}=n.parentElement.getBoundingClientRect();return{width:t,height:i,top:r,left:a}}else if(!e&&typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height,top:0,left:0};return{width:0,height:0,top:0,left:0,...e}}function BZ(n){const e=nh.get(n),t=e==null?void 0:e.fiber,i=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const r=typeof reportError=="function"?reportError:console.error,a=i||bZ(LE,iN),s=t||DE.createContainer(a,S_.ConcurrentRoot,null,!1,null,"",r,r,r,null);e||nh.set(n,{fiber:s,store:a});let o,l,h=!1,f=null;return{async configure(d={}){let p;f=new Promise(Ce=>p=Ce);let{gl:g,size:_,scene:T,events:y,onCreated:v,shadows:S=!1,linear:E=!1,flat:b=!1,legacy:N=!1,orthographic:R=!1,frameloop:I="always",dpr:U=[1,2],performance:O,raycaster:w,camera:B,onPointerMissed:j}=d,ee=a.getState(),se=ee.gl;if(!ee.gl){const Ce={canvas:n,powerPreference:"high-performance",antialias:!0,alpha:!0},Xe=typeof g=="function"?await g(Ce):g;JD(Xe)?se=Xe:se=new lA({...Ce,...g}),ee.set({gl:se})}let ae=ee.raycaster;ae||ee.set({raycaster:ae=new V6});const{params:W,...te}=w||{};if(ai.equ(te,ae,vf)||jl(ae,{...te}),ai.equ(W,ae.params,vf)||jl(ae,{params:{...ae.params,...W}}),!ee.camera||ee.camera===l&&!ai.equ(l,B,vf)){l=B;const Ce=B==null?void 0:B.isCamera,Xe=Ce?B:R?new ao(0,0,0,0,.1,1e3):new hi(75,0,.1,1e3);Ce||(Xe.position.z=5,B&&(jl(Xe,B),Xe.manual||("aspect"in B||"left"in B||"right"in B||"bottom"in B||"top"in B)&&(Xe.manual=!0,Xe.updateProjectionMatrix())),!ee.camera&&!(B!=null&&B.rotation)&&Xe.lookAt(0,0,0)),ee.set({camera:Xe}),ae.camera=Xe}if(!ee.scene){let Ce;T!=null&&T.isScene?(Ce=T,jx(Ce,a,"",{})):(Ce=new Nd,jx(Ce,a,"",{}),T&&jl(Ce,T)),ee.set({scene:Ce})}y&&!ee.events.handlers&&ee.set({events:y(a)});const K=zZ(n,_);if(ai.equ(K,ee.size,vf)||ee.setSize(K.width,K.height,K.top,K.left),U&&ee.viewport.dpr!==d8(U)&&ee.setDpr(U),ee.frameloop!==I&&ee.setFrameloop(I),ee.onPointerMissed||ee.set({onPointerMissed:j}),O&&!ai.equ(O,ee.performance,vf)&&ee.set(Ce=>({performance:{...Ce.performance,...O}})),!ee.xr){var oe;const Ce=(tt,gt)=>{const ge=a.getState();ge.frameloop!=="never"&&iN(tt,!0,ge,gt)},Xe=()=>{const tt=a.getState();tt.gl.xr.enabled=tt.gl.xr.isPresenting,tt.gl.xr.setAnimationLoop(tt.gl.xr.isPresenting?Ce:null),tt.gl.xr.isPresenting||LE(tt)},nt={connect(){const tt=a.getState().gl;tt.xr.addEventListener("sessionstart",Xe),tt.xr.addEventListener("sessionend",Xe)},disconnect(){const tt=a.getState().gl;tt.xr.removeEventListener("sessionstart",Xe),tt.xr.removeEventListener("sessionend",Xe)}};typeof((oe=se.xr)==null?void 0:oe.addEventListener)=="function"&&nt.connect(),ee.set({xr:nt})}if(se.shadowMap){const Ce=se.shadowMap.enabled,Xe=se.shadowMap.type;if(se.shadowMap.enabled=!!S,ai.boo(S))se.shadowMap.type=Pm;else if(ai.str(S)){var ie;const nt={basic:aU,percentage:I1,soft:Pm,variance:Ts};se.shadowMap.type=(ie=nt[S])!=null?ie:Pm}else ai.obj(S)&&Object.assign(se.shadowMap,S);(Ce!==se.shadowMap.enabled||Xe!==se.shadowMap.type)&&(se.shadowMap.needsUpdate=!0)}return en.enabled=!N,h||(se.outputColorSpace=E?Fn:dn,se.toneMapping=b?as:yb),ee.legacy!==N&&ee.set(()=>({legacy:N})),ee.linear!==E&&ee.set(()=>({linear:E})),ee.flat!==b&&ee.set(()=>({flat:b})),g&&!ai.fun(g)&&!JD(g)&&!ai.equ(g,se,vf)&&jl(se,g),o=v,h=!0,p(),this},render(d){return!h&&!f&&this.configure(),f.then(()=>{DE.updateContainer(Mt.jsx(HZ,{store:a,children:d,onCreated:o,rootElement:n}),s,null,()=>{})}),a},unmount(){M8(n)}}}function HZ({store:n,children:e,onCreated:t,rootElement:i}){return j0(()=>{const r=n.getState();r.set(a=>({internal:{...a.internal,active:!0}})),t&&t(r),n.getState().events.connected||r.events.connect==null||r.events.connect(i)},[]),Mt.jsx(g8.Provider,{value:n,children:e})}function M8(n,e){const t=nh.get(n),i=t==null?void 0:t.fiber;if(i){const r=t==null?void 0:t.store.getState();r&&(r.internal.active=!1),DE.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{var a,s,o,l;r.events.disconnect==null||r.events.disconnect(),(a=r.gl)==null||(s=a.renderLists)==null||s.dispose==null||s.dispose(),(o=r.gl)==null||o.forceContextLoss==null||o.forceContextLoss(),(l=r.gl)!=null&&l.xr&&r.xr.disconnect(),gZ(r.scene),nh.delete(n)}catch{}},500)})}}const FZ=new Set,GZ=new Set,VZ=new Set;function b2(n,e){if(n.size)for(const{callback:t}of n.values())t(e)}function Wm(n,e){switch(n){case"before":return b2(FZ,e);case"after":return b2(GZ,e);case"tail":return b2(VZ,e)}}let A2,w2;function NE(n,e,t){let i=e.clock.getDelta();e.frameloop==="never"&&typeof n=="number"&&(i=n-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=n),A2=e.internal.subscribers;for(let r=0;r<A2.length;r++)w2=A2[r],w2.ref.current(w2.store.getState(),i,t);return!e.internal.priority&&e.gl.render&&e.gl.render(e.scene,e.camera),e.internal.frames=Math.max(0,e.internal.frames-1),e.frameloop==="always"?1:e.internal.frames}let Jx=!1,OE=!1,R2,nN,_f;function b8(n){nN=requestAnimationFrame(b8),Jx=!0,R2=0,Wm("before",n),OE=!0;for(const t of nh.values()){var e;_f=t.store.getState(),_f.internal.active&&(_f.frameloop==="always"||_f.internal.frames>0)&&!((e=_f.gl.xr)!=null&&e.isPresenting)&&(R2+=NE(n,_f))}if(OE=!1,Wm("after",n),R2===0)return Wm("tail",n),Jx=!1,cancelAnimationFrame(nN)}function LE(n,e=1){var t;if(!n)return nh.forEach(i=>LE(i.store.getState(),e));(t=n.gl.xr)!=null&&t.isPresenting||!n.internal.active||n.frameloop==="never"||(e>1?n.internal.frames=Math.min(60,n.internal.frames+e):OE?n.internal.frames=2:n.internal.frames=1,Jx||(Jx=!0,requestAnimationFrame(b8)))}function iN(n,e=!0,t,i){if(e&&Wm("before",n),t)NE(n,t,i);else for(const r of nh.values())NE(n,r.store.getState());e&&Wm("after",n)}const C2={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 kZ(n){const{handlePointer:e}=MZ(n);return{priority:1,enabled:!0,compute(t,i,r){i.pointer.set(t.offsetX/i.size.width*2-1,-(t.offsetY/i.size.height)*2+1),i.raycaster.setFromCamera(i.pointer,i.camera)},connected:void 0,handlers:Object.keys(C2).reduce((t,i)=>({...t,[i]:e(i)}),{}),update:()=>{var t;const{events:i,internal:r}=n.getState();(t=r.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{const{set:i,events:r}=n.getState();if(r.disconnect==null||r.disconnect(),i(a=>({events:{...a.events,connected:t}})),r.handlers)for(const a in r.handlers){const s=r.handlers[a],[o,l]=C2[a];t.addEventListener(o,s,{passive:l})}},disconnect:()=>{const{set:t,events:i}=n.getState();if(i.connected){if(i.handlers)for(const r in i.handlers){const a=i.handlers[r],[s]=C2[r];i.connected.removeEventListener(s,a)}t(r=>({events:{...r.events,connected:void 0}}))}}}}function rN(n,e){let t;return(...i)=>{window.clearTimeout(t),t=window.setTimeout(()=>n(...i),e)}}function WZ({debounce:n,scroll:e,polyfill:t,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const r=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!r)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[a,s]=Me.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),o=Me.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a,orientationHandler:null}),l=n?typeof n=="number"?n:n.scroll:null,h=n?typeof n=="number"?n:n.resize:null,f=Me.useRef(!1);Me.useEffect(()=>(f.current=!0,()=>void(f.current=!1)));const[d,p,g]=Me.useMemo(()=>{const v=()=>{if(!o.current.element)return;const{left:S,top:E,width:b,height:N,bottom:R,right:I,x:U,y:O}=o.current.element.getBoundingClientRect(),w={left:S,top:E,width:b,height:N,bottom:R,right:I,x:U,y:O};o.current.element instanceof HTMLElement&&i&&(w.height=o.current.element.offsetHeight,w.width=o.current.element.offsetWidth),Object.freeze(w),f.current&&!jZ(o.current.lastBounds,w)&&s(o.current.lastBounds=w)};return[v,h?rN(v,h):v,l?rN(v,l):v]},[s,i,l,h]);function _(){o.current.scrollContainers&&(o.current.scrollContainers.forEach(v=>v.removeEventListener("scroll",g,!0)),o.current.scrollContainers=null),o.current.resizeObserver&&(o.current.resizeObserver.disconnect(),o.current.resizeObserver=null),o.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",o.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",o.current.orientationHandler))}function T(){o.current.element&&(o.current.resizeObserver=new r(g),o.current.resizeObserver.observe(o.current.element),e&&o.current.scrollContainers&&o.current.scrollContainers.forEach(v=>v.addEventListener("scroll",g,{capture:!0,passive:!0})),o.current.orientationHandler=()=>{g()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",o.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",o.current.orientationHandler))}const y=v=>{!v||v===o.current.element||(_(),o.current.element=v,o.current.scrollContainers=A8(v),T())};return YZ(g,!!e),XZ(p),Me.useEffect(()=>{_(),T()},[e,g,p]),Me.useEffect(()=>_,[]),[y,a,d]}function XZ(n){Me.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[n])}function YZ(n,e){Me.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[n,e])}function A8(n){const e=[];if(!n||n===document.body)return e;const{overflow:t,overflowX:i,overflowY:r}=window.getComputedStyle(n);return[t,i,r].some(a=>a==="auto"||a==="scroll")&&e.push(n),[...e,...A8(n.parentElement)]}const qZ=["x","y","top","bottom","left","right","width","height"],jZ=(n,e)=>qZ.every(t=>n[t]===e[t]);function ZZ({ref:n,children:e,fallback:t,resize:i,style:r,gl:a,events:s=kZ,eventSource:o,eventPrefix:l,shadows:h,linear:f,flat:d,legacy:p,orthographic:g,frameloop:_,dpr:T,performance:y,raycaster:v,camera:S,scene:E,onPointerMissed:b,onCreated:N,...R}){Me.useMemo(()=>y8(wj),[]);const I=fZ(),[U,O]=WZ({scroll:!0,debounce:{scroll:50,resize:0},...i}),w=Me.useRef(null),B=Me.useRef(null);Me.useImperativeHandle(n,()=>w.current);const j=f8(b),[ee,se]=Me.useState(!1),[ae,W]=Me.useState(!1);if(ee)throw ee;if(ae)throw ae;const te=Me.useRef(null);j0(()=>{const oe=w.current;if(O.width>0&&O.height>0&&oe){te.current||(te.current=BZ(oe));async function ie(){await te.current.configure({gl:a,scene:E,events:s,shadows:h,linear:f,flat:d,legacy:p,orthographic:g,frameloop:_,dpr:T,performance:y,raycaster:v,camera:S,size:O,onPointerMissed:(...Ce)=>j.current==null?void 0:j.current(...Ce),onCreated:Ce=>{Ce.events.connect==null||Ce.events.connect(o?uZ(o)?o.current:o:B.current),l&&Ce.setEvents({compute:(Xe,nt)=>{const tt=Xe[l+"X"],gt=Xe[l+"Y"];nt.pointer.set(tt/nt.size.width*2-1,-(gt/nt.size.height)*2+1),nt.raycaster.setFromCamera(nt.pointer,nt.camera)}}),N==null||N(Ce)}}),te.current.render(Mt.jsx(I,{children:Mt.jsx(pZ,{set:W,children:Mt.jsx(Me.Suspense,{fallback:Mt.jsx(dZ,{set:se}),children:e??null})})}))}ie()}}),Me.useEffect(()=>{const oe=w.current;if(oe)return()=>M8(oe)},[]);const K=o?"none":"auto";return Mt.jsx("div",{ref:B,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:K,...r},...R,children:Mt.jsx("div",{ref:U,style:{width:"100%",height:"100%"},children:Mt.jsx("canvas",{ref:w,style:{display:"block"},children:t})})})}function w8(n){return Mt.jsx(l8,{children:Mt.jsx(ZZ,{...n})})}function aN(n,e){if(e===IU)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===kx||e===wb){let t=n.getIndex();if(t===null){const s=[],o=n.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)s.push(l);n.setIndex(s),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,r=[];if(e===kx)for(let s=1;s<=i;s++)r.push(t.getX(0)),r.push(t.getX(s)),r.push(t.getX(s+1));else for(let s=0;s<i;s++)s%2===0?(r.push(t.getX(s)),r.push(t.getX(s+1)),r.push(t.getX(s+2))):(r.push(t.getX(s+2)),r.push(t.getX(s+1)),r.push(t.getX(s)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=n.clone();return a.setIndex(r),a.clearGroups(),a}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class sN extends yi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new eK(t)}),this.register(function(t){return new tK(t)}),this.register(function(t){return new uK(t)}),this.register(function(t){return new hK(t)}),this.register(function(t){return new fK(t)}),this.register(function(t){return new iK(t)}),this.register(function(t){return new rK(t)}),this.register(function(t){return new aK(t)}),this.register(function(t){return new sK(t)}),this.register(function(t){return new $Z(t)}),this.register(function(t){return new oK(t)}),this.register(function(t){return new nK(t)}),this.register(function(t){return new cK(t)}),this.register(function(t){return new lK(t)}),this.register(function(t){return new QZ(t)}),this.register(function(t){return new dK(t)}),this.register(function(t){return new pK(t)})}load(e,t,i,r){const a=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const h=fc.extractUrlBase(e);s=fc.resolveURL(h,this.path)}else s=fc.extractUrlBase(e);this.manager.itemStart(e);const o=function(h){r?r(h):console.error(h),a.manager.itemError(e),a.manager.itemEnd(e)},l=new na(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{a.parse(h,s,function(f){t(f),a.manager.itemEnd(e)},o)}catch(f){o(f)}},i,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let a;const s={},o={},l=new TextDecoder;if(typeof e=="string")a=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===R8){try{s[on.KHR_BINARY_GLTF]=new mK(e)}catch(d){r&&r(d);return}a=JSON.parse(s[on.KHR_BINARY_GLTF].content)}else a=JSON.parse(l.decode(e));else a=e;if(a.asset===void 0||a.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new RK(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){const d=this.pluginCallbacks[f](h);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[d.name]=d,s[d.name]=!0}if(a.extensionsUsed)for(let f=0;f<a.extensionsUsed.length;++f){const d=a.extensionsUsed[f],p=a.extensionsRequired||[];switch(d){case on.KHR_MATERIALS_UNLIT:s[d]=new JZ;break;case on.KHR_DRACO_MESH_COMPRESSION:s[d]=new gK(a,this.dracoLoader);break;case on.KHR_TEXTURE_TRANSFORM:s[d]=new vK;break;case on.KHR_MESH_QUANTIZATION:s[d]=new _K;break;default:p.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}h.setExtensions(s),h.setPlugins(o),h.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,a){i.parse(e,t,r,a)})}}function KZ(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const on={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 QZ{constructor(e){this.parser=e,this.name=on.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i];a.extensions&&a.extensions[this.name]&&a.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,a.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let r=t.cache.get(i);if(r)return r;const a=t.json,l=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e];let h;const f=new qe(16777215);l.color!==void 0&&f.setRGB(l.color[0],l.color[1],l.color[2],Fn);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":h=new nA(f),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new tA(f),h.distance=d;break;case"spot":h=new eA(f),h.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,h.angle=l.spot.outerConeAngle,h.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return h.position.set(0,0,0),Zs(h,l),l.intensity!==void 0&&(h.intensity=l.intensity),h.name=t.createUniqueName(l.name||"light_"+e),r=Promise.resolve(h),t.cache.add(i,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,a=i.json.nodes[e],o=(a.extensions&&a.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(l){return i._getNodeRef(t.cache,o,l)})}}class JZ{constructor(){this.name=on.KHR_MATERIALS_UNLIT}getMaterialType(){return Ur}extendParams(e,t,i){const r=[];e.color=new qe(1,1,1),e.opacity=1;const a=t.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){const s=a.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Fn),e.opacity=s[3]}a.baseColorTexture!==void 0&&r.push(i.assignTexture(e,"map",a.baseColorTexture,dn))}return Promise.all(r)}}class $Z{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name].emissiveStrength;return a!==void 0&&(t.emissiveIntensity=a),Promise.resolve()}}class eK{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(a.push(i.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const o=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new de(o,o)}return Promise.all(a)}}class tK{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_DISPERSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name];return t.dispersion=a.dispersion!==void 0?a.dispersion:0,Promise.resolve()}}class nK{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(a)}}class iK{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[];t.sheenColor=new qe(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=r.extensions[this.name];if(s.sheenColorFactor!==void 0){const o=s.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],Fn)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&a.push(i.assignTexture(t,"sheenColorMap",s.sheenColorTexture,dn)),s.sheenRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(a)}}class rK{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&a.push(i.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(a)}}class aK{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&a.push(i.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new qe().setRGB(o[0],o[1],o[2],Fn),Promise.all(a)}}class sK{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=r.extensions[this.name];return t.ior=a.ior!==void 0?a.ior:1.5,Promise.resolve()}}class oK{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&a.push(i.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new qe().setRGB(o[0],o[1],o[2],Fn),s.specularColorTexture!==void 0&&a.push(i.assignTexture(t,"specularColorMap",s.specularColorTexture,dn)),Promise.all(a)}}class lK{constructor(e){this.parser=e,this.name=on.EXT_MATERIALS_BUMP}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&a.push(i.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(a)}}class cK{constructor(e){this.parser=e,this.name=on.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:cs}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&a.push(i.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(a)}}class uK{constructor(e){this.parser=e,this.name=on.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const a=r.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a.source,s)}}class hK{constructor(e){this.parser=e,this.name=on.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const s=a.extensions[t],o=r.images[s.source];let l=i.textureLoader;if(o.uri){const h=i.options.manager.getHandler(o.uri);h!==null&&(l=h)}return i.loadTextureImage(e,s.source,l)}}class fK{constructor(e){this.parser=e,this.name=on.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const s=a.extensions[t],o=r.images[s.source];let l=i.textureLoader;if(o.uri){const h=i.options.manager.getHandler(o.uri);h!==null&&(l=h)}return i.loadTextureImage(e,s.source,l)}}class dK{constructor(e){this.name=on.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],a=this.parser.getDependency("buffer",r.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 a.then(function(o){const l=r.byteOffset||0,h=r.byteLength||0,f=r.count,d=r.byteStride,p=new Uint8Array(o,l,h);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(f,d,p,r.mode,r.filter).then(function(g){return g.buffer}):s.ready.then(function(){const g=new ArrayBuffer(f*d);return s.decodeGltfBuffer(new Uint8Array(g),f,d,p,r.mode,r.filter),g})})}else return null}}class pK{constructor(e){this.name=on.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const h of r.primitives)if(h.mode!==ja.TRIANGLES&&h.mode!==ja.TRIANGLE_STRIP&&h.mode!==ja.TRIANGLE_FAN&&h.mode!==void 0)return null;const s=i.extensions[this.name].attributes,o=[],l={};for(const h in s)o.push(this.parser.getDependency("accessor",s[h]).then(f=>(l[h]=f,l[h])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(h=>{const f=h.pop(),d=f.isGroup?f.children:[f],p=h[0].count,g=[];for(const _ of d){const T=new Ve,y=new L,v=new _t,S=new L(1,1,1),E=new Ub(_.geometry,_.material,p);for(let b=0;b<p;b++)l.TRANSLATION&&y.fromBufferAttribute(l.TRANSLATION,b),l.ROTATION&&v.fromBufferAttribute(l.ROTATION,b),l.SCALE&&S.fromBufferAttribute(l.SCALE,b),E.setMatrixAt(b,T.compose(y,v,S));for(const b in l)if(b==="_COLOR_0"){const N=l[b];E.instanceColor=new Ju(N.array,N.itemSize,N.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&_.geometry.setAttribute(b,l[b]);Wt.prototype.copy.call(E,_),this.parser.assignFinalMaterial(E),g.push(E)}return f.isGroup?(f.clear(),f.add(...g),f):g[0]}))}}const R8="glTF",Kp=12,oN={JSON:1313821514,BIN:5130562};class mK{constructor(e){this.name=on.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Kp),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==R8)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-Kp,a=new DataView(e,Kp);let s=0;for(;s<r;){const o=a.getUint32(s,!0);s+=4;const l=a.getUint32(s,!0);if(s+=4,l===oN.JSON){const h=new Uint8Array(e,Kp+s,o);this.content=i.decode(h)}else if(l===oN.BIN){const h=Kp+s;this.body=e.slice(h,h+o)}s+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class gK{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=on.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,r=this.dracoLoader,a=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},l={},h={};for(const f in s){const d=IE[f]||f.toLowerCase();o[d]=s[f]}for(const f in e.attributes){const d=IE[f]||f.toLowerCase();if(s[f]!==void 0){const p=i.accessors[e.attributes[f]],g=ld[p.componentType];h[d]=g.name,l[d]=p.normalized===!0}}return t.getDependency("bufferView",a).then(function(f){return new Promise(function(d,p){r.decodeDracoFile(f,function(g){for(const _ in g.attributes){const T=g.attributes[_],y=l[_];y!==void 0&&(T.normalized=y)}d(g)},o,h,Fn,p)})})}}class vK{constructor(){this.name=on.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class _K{constructor(){this.name=on.KHR_MESH_QUANTIZATION}}class C8 extends Qd{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r*3+r;for(let s=0;s!==r;s++)t[s]=i[a+s];return t}interpolate_(e,t,i,r){const a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,l=o*2,h=o*3,f=r-t,d=(i-t)/f,p=d*d,g=p*d,_=e*h,T=_-h,y=-2*g+3*p,v=g-p,S=1-y,E=v-p+d;for(let b=0;b!==o;b++){const N=s[T+b+o],R=s[T+b+l]*f,I=s[_+b+o],U=s[_+b]*f;a[b]=S*N+E*R+y*I+v*U}return a}}const xK=new _t;class yK extends C8{interpolate_(e,t,i,r){const a=super.interpolate_(e,t,i,r);return xK.fromArray(a).normalize().toArray(a),a}}const ja={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ld={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},lN={9728:Vn,9729:Ht,9984:P1,9985:sd,9986:bu,9987:Aa},cN={33071:Ui,33648:Td,10497:Mr},D2={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},IE={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"},zl={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},SK={CUBICSPLINE:void 0,LINEAR:bd,STEP:Md},N2={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function TK(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new q0({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Ns})),n.DefaultMaterial}function uu(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function Zs(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function EK(n,e,t){let i=!1,r=!1,a=!1;for(let h=0,f=e.length;h<f;h++){const d=e[h];if(d.POSITION!==void 0&&(i=!0),d.NORMAL!==void 0&&(r=!0),d.COLOR_0!==void 0&&(a=!0),i&&r&&a)break}if(!i&&!r&&!a)return Promise.resolve(n);const s=[],o=[],l=[];for(let h=0,f=e.length;h<f;h++){const d=e[h];if(i){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):n.attributes.position;s.push(p)}if(r){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):n.attributes.normal;o.push(p)}if(a){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):n.attributes.color;l.push(p)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(l)]).then(function(h){const f=h[0],d=h[1],p=h[2];return i&&(n.morphAttributes.position=f),r&&(n.morphAttributes.normal=d),a&&(n.morphAttributes.color=p),n.morphTargetsRelative=!0,n})}function MK(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function bK(n){let e;const t=n.extensions&&n.extensions[on.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+O2(t.attributes):e=n.indices+":"+O2(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,r=n.targets.length;i<r;i++)e+=":"+O2(n.targets[i]);return e}function O2(n){let e="";const t=Object.keys(n).sort();for(let i=0,r=t.length;i<r;i++)e+=t[i]+":"+n[t[i]]+";";return e}function UE(n){switch(n){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.")}}function AK(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":n.search(/\.ktx2($|\?)/i)>0||n.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const wK=new Ve;class RK{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new KZ,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 i=!1,r=-1,a=!1,s=-1;if(typeof navigator<"u"){const o=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);r=i&&l?parseInt(l[1],10):-1,a=o.indexOf("Firefox")>-1,s=a?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&r<17||a&&s<98?this.textureLoader=new Jb(this.options.manager):this.textureLoader=new P6(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new na(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,r=this.json,a=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(s){const o={scene:s[0][r.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:r.asset,parser:i,userData:{}};return uu(a,o,r),Zs(o,r),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,a=t.length;r<a;r++){const s=t[r].joints;for(let o=0,l=s.length;o<l;o++)e[s[o]].isBone=!0}for(let r=0,a=e.length;r<a;r++){const s=e[r];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(i[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const r=i.clone(),a=(s,o)=>{const l=this.associations.get(s);l!=null&&this.associations.set(o,l);for(const[h,f]of s.children.entries())a(f,o.children[h])};return a(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const r=e(t[i]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let r=0;r<t.length;r++){const a=e(t[r]);a&&i.push(a)}return i}getDependency(e,t){const i=e+":"+t;let r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(a){return a.loadNode&&a.loadNode(t)});break;case"mesh":r=this._invokeOne(function(a){return a.loadMesh&&a.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(a){return a.loadBufferView&&a.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(a){return a.loadMaterial&&a.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(a){return a.loadTexture&&a.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(a){return a.loadAnimation&&a.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(a){return a!=this&&a.getDependency&&a.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(a,s){return i.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[on.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(a,s){i.load(fc.resolveURL(t.uri,r.path),a,void 0,function(){s(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(i){const r=t.byteLength||0,a=t.byteOffset||0;return i.slice(a,a+r)})}loadAccessor(e){const t=this,i=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const s=D2[r.type],o=ld[r.componentType],l=r.normalized===!0,h=new o(r.count*s);return Promise.resolve(new Ot(h,s,l))}const a=[];return r.bufferView!==void 0?a.push(this.getDependency("bufferView",r.bufferView)):a.push(null),r.sparse!==void 0&&(a.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(a).then(function(s){const o=s[0],l=D2[r.type],h=ld[r.componentType],f=h.BYTES_PER_ELEMENT,d=f*l,p=r.byteOffset||0,g=r.bufferView!==void 0?i.bufferViews[r.bufferView].byteStride:void 0,_=r.normalized===!0;let T,y;if(g&&g!==d){const v=Math.floor(p/g),S="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+v+":"+r.count;let E=t.cache.get(S);E||(T=new h(o,v*g,r.count*g/f),E=new Zd(T,g/f),t.cache.add(S,E)),y=new ll(E,l,p%g/f,_)}else o===null?T=new h(r.count*l):T=new h(o,p,r.count*l),y=new Ot(T,l,_);if(r.sparse!==void 0){const v=D2.SCALAR,S=ld[r.sparse.indices.componentType],E=r.sparse.indices.byteOffset||0,b=r.sparse.values.byteOffset||0,N=new S(s[1],E,r.sparse.count*v),R=new h(s[2],b,r.sparse.count*l);o!==null&&(y=new Ot(y.array.slice(),y.itemSize,y.normalized)),y.normalized=!1;for(let I=0,U=N.length;I<U;I++){const O=N[I];if(y.setX(O,R[I*l]),l>=2&&y.setY(O,R[I*l+1]),l>=3&&y.setZ(O,R[I*l+2]),l>=4&&y.setW(O,R[I*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}y.normalized=_}return y})}loadTexture(e){const t=this.json,i=this.options,a=t.textures[e].source,s=t.images[a];let o=this.textureLoader;if(s.uri){const l=i.manager.getHandler(s.uri);l!==null&&(o=l)}return this.loadTextureImage(e,a,o)}loadTextureImage(e,t,i){const r=this,a=this.json,s=a.textures[e],o=a.images[t],l=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[l])return this.textureCache[l];const h=this.loadImageSource(t,i).then(function(f){f.flipY=!1,f.name=s.name||o.name||"",f.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(f.name=o.uri);const p=(a.samplers||{})[s.sampler]||{};return f.magFilter=lN[p.magFilter]||Ht,f.minFilter=lN[p.minFilter]||Aa,f.wrapS=cN[p.wrapS]||Mr,f.wrapT=cN[p.wrapT]||Mr,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==Vn&&f.minFilter!==Ht,r.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[l]=h,h}loadImageSource(e,t){const i=this,r=this.json,a=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const s=r.images[e],o=self.URL||self.webkitURL;let l=s.uri||"",h=!1;if(s.bufferView!==void 0)l=i.getDependency("bufferView",s.bufferView).then(function(d){h=!0;const p=new Blob([d],{type:s.mimeType});return l=o.createObjectURL(p),l});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(l).then(function(d){return new Promise(function(p,g){let _=p;t.isImageBitmapLoader===!0&&(_=function(T){const y=new Nn(T);y.needsUpdate=!0,p(y)}),t.load(fc.resolveURL(d,a.path),_,void 0,g)})}).then(function(d){return h===!0&&o.revokeObjectURL(l),Zs(d,s),d.userData.mimeType=s.mimeType||AK(s.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=f,f}assignTexture(e,t,i,r){const a=this;return this.getDependency("texture",i.index).then(function(s){if(!s)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(s=s.clone(),s.channel=i.texCoord),a.extensions[on.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[on.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=a.associations.get(s);s=a.extensions[on.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),a.associations.set(s,l)}}return r!==void 0&&(s.colorSpace=r),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,a=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new K1,jn.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(o,l)),i=l}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new Bi,jn.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(o,l)),i=l}if(r||a||s){let o="ClonedMaterial:"+i.uuid+":";r&&(o+="derivative-tangents:"),a&&(o+="vertex-colors:"),s&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=i.clone(),a&&(l.vertexColors=!0),s&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return q0}loadMaterial(e){const t=this,i=this.json,r=this.extensions,a=i.materials[e];let s;const o={},l=a.extensions||{},h=[];if(l[on.KHR_MATERIALS_UNLIT]){const d=r[on.KHR_MATERIALS_UNLIT];s=d.getMaterialType(),h.push(d.extendParams(o,a,t))}else{const d=a.pbrMetallicRoughness||{};if(o.color=new qe(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;o.color.setRGB(p[0],p[1],p[2],Fn),o.opacity=p[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(o,"map",d.baseColorTexture,dn)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(o,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(o,"roughnessMap",d.metallicRoughnessTexture))),s=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,o)})))}a.doubleSided===!0&&(o.side=cr);const f=a.alphaMode||N2.OPAQUE;if(f===N2.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,f===N2.MASK&&(o.alphaTest=a.alphaCutoff!==void 0?a.alphaCutoff:.5)),a.normalTexture!==void 0&&s!==Ur&&(h.push(t.assignTexture(o,"normalMap",a.normalTexture)),o.normalScale=new de(1,1),a.normalTexture.scale!==void 0)){const d=a.normalTexture.scale;o.normalScale.set(d,d)}if(a.occlusionTexture!==void 0&&s!==Ur&&(h.push(t.assignTexture(o,"aoMap",a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&s!==Ur){const d=a.emissiveFactor;o.emissive=new qe().setRGB(d[0],d[1],d[2],Fn)}return a.emissiveTexture!==void 0&&s!==Ur&&h.push(t.assignTexture(o,"emissiveMap",a.emissiveTexture,dn)),Promise.all(h).then(function(){const d=new s(o);return a.name&&(d.name=a.name),Zs(d,a),t.associations.set(d,{materials:e}),a.extensions&&uu(r,d,a),d})}createUniqueName(e){const t=fn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function a(o){return i[on.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return uN(l,o,t)})}const s=[];for(let o=0,l=e.length;o<l;o++){const h=e[o],f=bK(h),d=r[f];if(d)s.push(d.promise);else{let p;h.extensions&&h.extensions[on.KHR_DRACO_MESH_COMPRESSION]?p=a(h):p=uN(new Ct,h,t),r[f]={primitive:h,promise:p},s.push(p)}}return Promise.all(s)}loadMesh(e){const t=this,i=this.json,r=this.extensions,a=i.meshes[e],s=a.primitives,o=[];for(let l=0,h=s.length;l<h;l++){const f=s[l].material===void 0?TK(this.cache):this.getDependency("material",s[l].material);o.push(f)}return o.push(t.loadGeometries(s)),Promise.all(o).then(function(l){const h=l.slice(0,l.length-1),f=l[l.length-1],d=[];for(let g=0,_=f.length;g<_;g++){const T=f[g],y=s[g];let v;const S=h[g];if(y.mode===ja.TRIANGLES||y.mode===ja.TRIANGLE_STRIP||y.mode===ja.TRIANGLE_FAN||y.mode===void 0)v=a.isSkinnedMesh===!0?new q1(T,S):new oi(T,S),v.isSkinnedMesh===!0&&v.normalizeSkinWeights(),y.mode===ja.TRIANGLE_STRIP?v.geometry=aN(v.geometry,wb):y.mode===ja.TRIANGLE_FAN&&(v.geometry=aN(v.geometry,kx));else if(y.mode===ja.LINES)v=new aa(T,S);else if(y.mode===ja.LINE_STRIP)v=new oo(T,S);else if(y.mode===ja.LINE_LOOP)v=new Pb(T,S);else if(y.mode===ja.POINTS)v=new zb(T,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(v.geometry.morphAttributes).length>0&&MK(v,a),v.name=t.createUniqueName(a.name||"mesh_"+e),Zs(v,a),y.extensions&&uu(r,v,y),t.assignFinalMaterial(v),d.push(v)}for(let g=0,_=d.length;g<_;g++)t.associations.set(d[g],{meshes:e,primitives:g});if(d.length===1)return a.extensions&&uu(r,d[0],a),d[0];const p=new Pr;a.extensions&&uu(r,p,a),t.associations.set(p,{meshes:e});for(let g=0,_=d.length;g<_;g++)p.add(d[g]);return p})}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new hi(tn.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new ao(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Zs(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let r=0,a=t.joints.length;r<a;r++)i.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(r){const a=r.pop(),s=r,o=[],l=[];for(let h=0,f=s.length;h<f;h++){const d=s[h];if(d){o.push(d);const p=new Ve;a!==null&&p.fromArray(a.array,h*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new Rc(o,l)})}loadAnimation(e){const t=this.json,i=this,r=t.animations[e],a=r.name?r.name:"animation_"+e,s=[],o=[],l=[],h=[],f=[];for(let d=0,p=r.channels.length;d<p;d++){const g=r.channels[d],_=r.samplers[g.sampler],T=g.target,y=T.node,v=r.parameters!==void 0?r.parameters[_.input]:_.input,S=r.parameters!==void 0?r.parameters[_.output]:_.output;T.node!==void 0&&(s.push(this.getDependency("node",y)),o.push(this.getDependency("accessor",v)),l.push(this.getDependency("accessor",S)),h.push(_),f.push(T))}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(l),Promise.all(h),Promise.all(f)]).then(function(d){const p=d[0],g=d[1],_=d[2],T=d[3],y=d[4],v=[];for(let E=0,b=p.length;E<b;E++){const N=p[E],R=g[E],I=_[E],U=T[E],O=y[E];if(N===void 0)continue;N.updateMatrix&&N.updateMatrix();const w=i._createAnimationTracks(N,R,I,U,O);if(w)for(let B=0;B<w.length;B++)v.push(w[B])}const S=new th(a,void 0,v);return Zs(S,r),S})}createNodeMesh(e){const t=this.json,i=this,r=t.nodes[e];return r.mesh===void 0?null:i.getDependency("mesh",r.mesh).then(function(a){const s=i._getNodeRef(i.meshCache,r.mesh,a);return r.weights!==void 0&&s.traverse(function(o){if(o.isMesh)for(let l=0,h=r.weights.length;l<h;l++)o.morphTargetInfluences[l]=r.weights[l]}),s})}loadNode(e){const t=this.json,i=this,r=t.nodes[e],a=i._loadNodeShallow(e),s=[],o=r.children||[];for(let h=0,f=o.length;h<f;h++)s.push(i.getDependency("node",o[h]));const l=r.skin===void 0?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([a,Promise.all(s),l]).then(function(h){const f=h[0],d=h[1],p=h[2];p!==null&&f.traverse(function(g){g.isSkinnedMesh&&g.bind(p,wK)});for(let g=0,_=d.length;g<_;g++)f.add(d[g]);return f})}_loadNodeShallow(e){const t=this.json,i=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const a=t.nodes[e],s=a.name?r.createUniqueName(a.name):"",o=[],l=r._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return l&&o.push(l),a.camera!==void 0&&o.push(r.getDependency("camera",a.camera).then(function(h){return r._getNodeRef(r.cameraCache,a.camera,h)})),r._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){o.push(h)}),this.nodeCache[e]=Promise.all(o).then(function(h){let f;if(a.isBone===!0?f=new j1:h.length>1?f=new Pr:h.length===1?f=h[0]:f=new Wt,f!==h[0])for(let d=0,p=h.length;d<p;d++)f.add(h[d]);if(a.name&&(f.userData.name=a.name,f.name=s),Zs(f,a),a.extensions&&uu(i,f,a),a.matrix!==void 0){const d=new Ve;d.fromArray(a.matrix),f.applyMatrix4(d)}else a.translation!==void 0&&f.position.fromArray(a.translation),a.rotation!==void 0&&f.quaternion.fromArray(a.rotation),a.scale!==void 0&&f.scale.fromArray(a.scale);if(!r.associations.has(f))r.associations.set(f,{});else if(a.mesh!==void 0&&r.meshCache.refs[a.mesh]>1){const d=r.associations.get(f);r.associations.set(f,{...d})}return r.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,a=new Pr;i.name&&(a.name=r.createUniqueName(i.name)),Zs(a,i),i.extensions&&uu(t,a,i);const s=i.nodes||[],o=[];for(let l=0,h=s.length;l<h;l++)o.push(r.getDependency("node",s[l]));return Promise.all(o).then(function(l){for(let f=0,d=l.length;f<d;f++)a.add(l[f]);const h=f=>{const d=new Map;for(const[p,g]of r.associations)(p instanceof jn||p instanceof Nn)&&d.set(p,g);return f.traverse(p=>{const g=r.associations.get(p);g!=null&&d.set(p,g)}),d};return r.associations=h(a),a})}_createAnimationTracks(e,t,i,r,a){const s=[],o=e.name?e.name:e.uuid,l=[];zl[a.path]===zl.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(o);let h;switch(zl[a.path]){case zl.weights:h=yc;break;case zl.rotation:h=Sc;break;case zl.translation:case zl.scale:h=eh;break;default:switch(i.itemSize){case 1:h=yc;break;case 2:case 3:default:h=eh;break}break}const f=r.interpolation!==void 0?SK[r.interpolation]:bd,d=this._getArrayFromAccessor(i);for(let p=0,g=l.length;p<g;p++){const _=new h(l[p]+"."+zl[a.path],t.array,d,f);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),s.push(_)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=UE(t.constructor),r=new Float32Array(t.length);for(let a=0,s=t.length;a<s;a++)r[a]=t[a]*i;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const r=this instanceof Sc?yK:C8;return new r(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function CK(n,e,t){const i=e.attributes,r=new tr;if(i.POSITION!==void 0){const o=t.json.accessors[i.POSITION],l=o.min,h=o.max;if(l!==void 0&&h!==void 0){if(r.set(new L(l[0],l[1],l[2]),new L(h[0],h[1],h[2])),o.normalized){const f=UE(ld[o.componentType]);r.min.multiplyScalar(f),r.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const a=e.targets;if(a!==void 0){const o=new L,l=new L;for(let h=0,f=a.length;h<f;h++){const d=a[h];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],g=p.min,_=p.max;if(g!==void 0&&_!==void 0){if(l.setX(Math.max(Math.abs(g[0]),Math.abs(_[0]))),l.setY(Math.max(Math.abs(g[1]),Math.abs(_[1]))),l.setZ(Math.max(Math.abs(g[2]),Math.abs(_[2]))),p.normalized){const T=UE(ld[p.componentType]);l.multiplyScalar(T)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(o)}n.boundingBox=r;const s=new nr;r.getCenter(s.center),s.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=s}function uN(n,e,t){const i=e.attributes,r=[];function a(s,o){return t.getDependency("accessor",s).then(function(l){n.setAttribute(o,l)})}for(const s in i){const o=IE[s]||s.toLowerCase();o in n.attributes||r.push(a(i[s],o))}if(e.indices!==void 0&&!n.index){const s=t.getDependency("accessor",e.indices).then(function(o){n.setIndex(o)});r.push(s)}return en.workingColorSpace!==Fn&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${en.workingColorSpace}" not supported.`),Zs(n,e),CK(n,e,t),Promise.all(r).then(function(){return e.targets!==void 0?EK(n,e.targets,t):n})}/*!
 * @pixiv/three-vrm v3.4.4
 * VRM file loader for three.js.
 *
 * Copyright (c) 2019-2025 pixiv Inc.
 * @pixiv/three-vrm is distributed under MIT License
 * https://github.com/pixiv/three-vrm/blob/release/LICENSE
 */var kv=(n,e,t)=>new Promise((i,r)=>{var a=l=>{try{o(t.next(l))}catch(h){r(h)}},s=l=>{try{o(t.throw(l))}catch(h){r(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((t=t.apply(n,e)).next())}),_n=(n,e,t)=>new Promise((i,r)=>{var a=l=>{try{o(t.next(l))}catch(h){r(h)}},s=l=>{try{o(t.throw(l))}catch(h){r(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((t=t.apply(n,e)).next())}),hN=class extends Wt{constructor(n){super(),this.weight=0,this.isBinary=!1,this.overrideBlink="none",this.overrideLookAt="none",this.overrideMouth="none",this._binds=[],this.name=`VRMExpression_${n}`,this.expressionName=n,this.type="VRMExpression",this.visible=!1}get binds(){return this._binds}get overrideBlinkAmount(){return this.overrideBlink==="block"?0<this.outputWeight?1:0:this.overrideBlink==="blend"?this.outputWeight:0}get overrideLookAtAmount(){return this.overrideLookAt==="block"?0<this.outputWeight?1:0:this.overrideLookAt==="blend"?this.outputWeight:0}get overrideMouthAmount(){return this.overrideMouth==="block"?0<this.outputWeight?1:0:this.overrideMouth==="blend"?this.outputWeight:0}get outputWeight(){return this.isBinary?this.weight>.5?1:0:this.weight}addBind(n){this._binds.push(n)}deleteBind(n){const e=this._binds.indexOf(n);e>=0&&this._binds.splice(e,1)}applyWeight(n){var e;let t=this.outputWeight;t*=(e=n==null?void 0:n.multiplier)!=null?e:1,this.isBinary&&t<1&&(t=0),this._binds.forEach(i=>i.applyWeight(t))}clearAppliedWeight(){this._binds.forEach(n=>n.clearAppliedWeight())}};function D8(n,e,t){var i,r;const a=n.parser.json,s=(i=a.nodes)==null?void 0:i[e];if(s==null)return console.warn(`extractPrimitivesInternal: Attempt to use nodes[${e}] of glTF but the node doesn't exist`),null;const o=s.mesh;if(o==null)return null;const l=(r=a.meshes)==null?void 0:r[o];if(l==null)return console.warn(`extractPrimitivesInternal: Attempt to use meshes[${o}] of glTF but the mesh doesn't exist`),null;const h=l.primitives.length,f=[];return t.traverse(d=>{f.length<h&&d.isMesh&&f.push(d)}),f}function fN(n,e){return _n(this,null,function*(){const t=yield n.parser.getDependency("node",e);return D8(n,e,t)})}function dN(n){return _n(this,null,function*(){const e=yield n.parser.getDependencies("node"),t=new Map;return e.forEach((i,r)=>{const a=D8(n,r,i);a!=null&&t.set(r,a)}),t})}var PE={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 N8(n){return Math.max(Math.min(n,1),0)}var pN=class O8{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(PE));return Object.entries(this._expressionMap).forEach(([i,r])=>{t.has(i)&&(e[i]=r)}),e}get customExpressionMap(){const e={},t=new Set(Object.values(PE));return Object.entries(this._expressionMap).forEach(([i,r])=>{t.has(i)||(e[i]=r)}),e}copy(e){return this._expressions.concat().forEach(i=>{this.unregisterExpression(i)}),e._expressions.forEach(i=>{this.registerExpression(i)}),this.blinkExpressionNames=e.blinkExpressionNames.concat(),this.lookAtExpressionNames=e.lookAtExpressionNames.concat(),this.mouthExpressionNames=e.mouthExpressionNames.concat(),this}clone(){return new O8().copy(this)}getExpression(e){var t;return(t=this._expressionMap[e])!=null?t:null}registerExpression(e){this._expressions.push(e),this._expressionMap[e.expressionName]=e}unregisterExpression(e){const t=this._expressions.indexOf(e);t===-1&&console.warn("VRMExpressionManager: The specified expressions is not registered"),this._expressions.splice(t,1),delete this._expressionMap[e.expressionName]}getValue(e){var t;const i=this.getExpression(e);return(t=i==null?void 0:i.weight)!=null?t:null}setValue(e,t){const i=this.getExpression(e);i&&(i.weight=N8(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(t=>{t.clearAppliedWeight()}),this._expressions.forEach(t=>{let i=1;const r=t.expressionName;this.blinkExpressionNames.indexOf(r)!==-1&&(i*=e.blink),this.lookAtExpressionNames.indexOf(r)!==-1&&(i*=e.lookAt),this.mouthExpressionNames.indexOf(r)!==-1&&(i*=e.mouth),t.applyWeight({multiplier:i})})}_calculateWeightMultipliers(){let e=1,t=1,i=1;return this._expressions.forEach(r=>{e-=r.overrideBlinkAmount,t-=r.overrideLookAtAmount,i-=r.overrideMouthAmount}),e=Math.max(0,e),t=Math.max(0,t),i=Math.max(0,i),{blink:e,lookAt:t,mouth:i}}},Qp={Color:"color",EmissionColor:"emissionColor",ShadeColor:"shadeColor",RimColor:"rimColor",OutlineColor:"outlineColor"},DK={_Color:Qp.Color,_EmissionColor:Qp.EmissionColor,_ShadeColor:Qp.ShadeColor,_RimColor:Qp.RimColor,_OutlineColor:Qp.OutlineColor},NK=new qe,L8=class I8{constructor({material:e,type:t,targetValue:i,targetAlpha:r}){this.material=e,this.type=t,this.targetValue=i,this.targetAlpha=r??1;const a=this._initColorBindState(),s=this._initAlphaBindState();this._state={color:a,alpha:s}}applyWeight(e){const{color:t,alpha:i}=this._state;if(t!=null){const{propertyName:r,deltaValue:a}=t,s=this.material[r];s!=null&&s.add(NK.copy(a).multiplyScalar(e))}if(i!=null){const{propertyName:r,deltaValue:a}=i;this.material[r]!=null&&(this.material[r]+=a*e)}}clearAppliedWeight(){const{color:e,alpha:t}=this._state;if(e!=null){const{propertyName:i,initialValue:r}=e,a=this.material[i];a!=null&&a.copy(r)}if(t!=null){const{propertyName:i,initialValue:r}=t;this.material[i]!=null&&(this.material[i]=r)}}_initColorBindState(){var e,t,i;const{material:r,type:a,targetValue:s}=this,o=this._getPropertyNameMap(),l=(t=(e=o==null?void 0:o[a])==null?void 0:e[0])!=null?t:null;if(l==null)return console.warn(`Tried to add a material color bind to the material ${(i=r.name)!=null?i:"(no name)"}, the type ${a} but the material or the type is not supported.`),null;const f=r[l].clone(),d=new qe(s.r-f.r,s.g-f.g,s.b-f.b);return{propertyName:l,initialValue:f,deltaValue:d}}_initAlphaBindState(){var e,t,i;const{material:r,type:a,targetAlpha:s}=this,o=this._getPropertyNameMap(),l=(t=(e=o==null?void 0:o[a])==null?void 0:e[1])!=null?t:null;if(l==null&&s!==1)return console.warn(`Tried to add a material alpha bind to the material ${(i=r.name)!=null?i:"(no name)"}, the type ${a} but the material or the type does not support alpha.`),null;if(l==null)return null;const h=r[l],f=s-h;return{propertyName:l,initialValue:h,deltaValue:f}}_getPropertyNameMap(){var e,t;return(t=(e=Object.entries(I8._propertyNameMapMap).find(([i])=>this.material[i]===!0))==null?void 0:e[1])!=null?t:null}};L8._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 mN=L8,$x=class{constructor({primitives:n,index:e,weight:t}){this.primitives=n,this.index=e,this.weight=t}applyWeight(n){this.primitives.forEach(e=>{var t;((t=e.morphTargetInfluences)==null?void 0:t[this.index])!=null&&(e.morphTargetInfluences[this.index]+=this.weight*n)})}clearAppliedWeight(){this.primitives.forEach(n=>{var e;((e=n.morphTargetInfluences)==null?void 0:e[this.index])!=null&&(n.morphTargetInfluences[this.index]=0)})}},gN=new de,U8=class P8{constructor({material:e,scale:t,offset:i}){var r,a;this.material=e,this.scale=t,this.offset=i;const s=(r=Object.entries(P8._propertyNamesMap).find(([o])=>e[o]===!0))==null?void 0:r[1];s==null?(console.warn(`Tried to add a texture transform bind to the material ${(a=e.name)!=null?a:"(no name)"} but the material is not supported.`),this._properties=[]):(this._properties=[],s.forEach(o=>{var l;const h=(l=e[o])==null?void 0:l.clone();if(!h)return null;e[o]=h;const f=h.offset.clone(),d=h.repeat.clone(),p=i.clone().sub(f),g=t.clone().sub(d);this._properties.push({name:o,initialOffset:f,deltaOffset:p,initialScale:d,deltaScale:g})}))}applyWeight(e){this._properties.forEach(t=>{const i=this.material[t.name];i!==void 0&&(i.offset.add(gN.copy(t.deltaOffset).multiplyScalar(e)),i.repeat.add(gN.copy(t.deltaScale).multiplyScalar(e)))})}clearAppliedWeight(){this._properties.forEach(e=>{const t=this.material[e.name];t!==void 0&&(t.offset.copy(e.initialOffset),t.repeat.copy(e.initialScale))})}};U8._propertyNamesMap={isMeshStandardMaterial:["map","emissiveMap","bumpMap","normalMap","displacementMap","roughnessMap","metalnessMap","alphaMap"],isMeshBasicMaterial:["map","specularMap","alphaMap"],isMToonMaterial:["map","normalMap","emissiveMap","shadeMultiplyTexture","rimMultiplyTexture","outlineWidthMultiplyTexture","uvAnimationMaskTexture"]};var vN=U8,OK=new Set(["1.0","1.0-beta"]),z8=class B8{get name(){return"VRMExpressionLoaderPlugin"}constructor(e){this.parser=e}afterRoot(e){return _n(this,null,function*(){e.userData.vrmExpressionManager=yield this._import(e)})}_import(e){return _n(this,null,function*(){const t=yield this._v1Import(e);if(t)return t;const i=yield this._v0Import(e);return i||null})}_v1Import(e){return _n(this,null,function*(){var t,i;const r=this.parser.json;if(!(((t=r.extensionsUsed)==null?void 0:t.indexOf("VRMC_vrm"))!==-1))return null;const s=(i=r.extensions)==null?void 0:i.VRMC_vrm;if(!s)return null;const o=s.specVersion;if(!OK.has(o))return console.warn(`VRMExpressionLoaderPlugin: Unknown VRMC_vrm specVersion "${o}"`),null;const l=s.expressions;if(!l)return null;const h=new Set(Object.values(PE)),f=new Map;l.preset!=null&&Object.entries(l.preset).forEach(([p,g])=>{if(g!=null){if(!h.has(p)){console.warn(`VRMExpressionLoaderPlugin: Unknown preset name "${p}" detected. Ignoring the expression`);return}f.set(p,g)}}),l.custom!=null&&Object.entries(l.custom).forEach(([p,g])=>{if(h.has(p)){console.warn(`VRMExpressionLoaderPlugin: Custom expression cannot have preset name "${p}". Ignoring the expression`);return}f.set(p,g)});const d=new pN;return yield Promise.all(Array.from(f.entries()).map(p=>_n(this,[p],function*([g,_]){var T,y,v,S,E,b,N;const R=new hN(g);if(e.scene.add(R),R.isBinary=(T=_.isBinary)!=null?T:!1,R.overrideBlink=(y=_.overrideBlink)!=null?y:"none",R.overrideLookAt=(v=_.overrideLookAt)!=null?v:"none",R.overrideMouth=(S=_.overrideMouth)!=null?S:"none",(E=_.morphTargetBinds)==null||E.forEach(I=>_n(this,null,function*(){var U;if(I.node===void 0||I.index===void 0)return;const O=yield fN(e,I.node),w=I.index;if(!O.every(B=>Array.isArray(B.morphTargetInfluences)&&w<B.morphTargetInfluences.length)){console.warn(`VRMExpressionLoaderPlugin: ${_.name} attempts to index morph #${w} but not found.`);return}R.addBind(new $x({primitives:O,index:w,weight:(U=I.weight)!=null?U:1}))})),_.materialColorBinds||_.textureTransformBinds){const I=[];e.scene.traverse(U=>{const O=U.material;O&&(Array.isArray(O)?I.push(...O):I.push(O))}),(b=_.materialColorBinds)==null||b.forEach(U=>_n(this,null,function*(){I.filter(w=>{var B;const j=(B=this.parser.associations.get(w))==null?void 0:B.materials;return U.material===j}).forEach(w=>{R.addBind(new mN({material:w,type:U.type,targetValue:new qe().fromArray(U.targetValue),targetAlpha:U.targetValue[3]}))})})),(N=_.textureTransformBinds)==null||N.forEach(U=>_n(this,null,function*(){I.filter(w=>{var B;const j=(B=this.parser.associations.get(w))==null?void 0:B.materials;return U.material===j}).forEach(w=>{var B,j;R.addBind(new vN({material:w,offset:new de().fromArray((B=U.offset)!=null?B:[0,0]),scale:new de().fromArray((j=U.scale)!=null?j:[1,1])}))})}))}d.registerExpression(R)}))),d})}_v0Import(e){return _n(this,null,function*(){var t;const i=this.parser.json,r=(t=i.extensions)==null?void 0:t.VRM;if(!r)return null;const a=r.blendShapeMaster;if(!a)return null;const s=new pN,o=a.blendShapeGroups;if(!o)return s;const l=new Set;return yield Promise.all(o.map(h=>_n(this,null,function*(){var f;const d=h.presetName,p=d!=null&&B8.v0v1PresetNameMap[d]||null,g=p??h.name;if(g==null){console.warn("VRMExpressionLoaderPlugin: One of custom expressions has no name. Ignoring the expression");return}if(l.has(g)){console.warn(`VRMExpressionLoaderPlugin: An expression preset ${d} has duplicated entries. Ignoring the expression`);return}l.add(g);const _=new hN(g);e.scene.add(_),_.isBinary=(f=h.isBinary)!=null?f:!1,h.binds&&h.binds.forEach(y=>_n(this,null,function*(){var v;if(y.mesh===void 0||y.index===void 0)return;const S=[];(v=i.nodes)==null||v.forEach((b,N)=>{b.mesh===y.mesh&&S.push(N)});const E=y.index;yield Promise.all(S.map(b=>_n(this,null,function*(){var N;const R=yield fN(e,b);if(!R.every(I=>Array.isArray(I.morphTargetInfluences)&&E<I.morphTargetInfluences.length)){console.warn(`VRMExpressionLoaderPlugin: ${h.name} attempts to index ${E}th morph but not found.`);return}_.addBind(new $x({primitives:R,index:E,weight:.01*((N=y.weight)!=null?N:100)}))})))}));const T=h.materialValues;T&&T.length!==0&&T.forEach(y=>{if(y.materialName===void 0||y.propertyName===void 0||y.targetValue===void 0)return;const v=[];e.scene.traverse(E=>{if(E.material){const b=E.material;Array.isArray(b)?v.push(...b.filter(N=>(N.name===y.materialName||N.name===y.materialName+" (Outline)")&&v.indexOf(N)===-1)):b.name===y.materialName&&v.indexOf(b)===-1&&v.push(b)}});const S=y.propertyName;v.forEach(E=>{if(S==="_MainTex_ST"){const N=new de(y.targetValue[0],y.targetValue[1]),R=new de(y.targetValue[2],y.targetValue[3]);R.y=1-R.y-N.y,_.addBind(new vN({material:E,scale:N,offset:R}));return}const b=DK[S];if(b){_.addBind(new mN({material:E,type:b,targetValue:new qe().fromArray(y.targetValue),targetAlpha:y.targetValue[3]}));return}console.warn(S+" is not supported")})}),s.registerExpression(_)}))),s})}};z8.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 LK=z8,fA=class Of{constructor(e,t){this._firstPersonOnlyLayer=Of.DEFAULT_FIRSTPERSON_ONLY_LAYER,this._thirdPersonOnlyLayer=Of.DEFAULT_THIRDPERSON_ONLY_LAYER,this._initializedLayers=!1,this.humanoid=e,this.meshAnnotations=t}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(t=>({meshes:t.meshes.concat(),type:t.type})),this}clone(){return new Of(this.humanoid,this.meshAnnotations).copy(this)}get firstPersonOnlyLayer(){return this._firstPersonOnlyLayer}get thirdPersonOnlyLayer(){return this._thirdPersonOnlyLayer}setup({firstPersonOnlyLayer:e=Of.DEFAULT_FIRSTPERSON_ONLY_LAYER,thirdPersonOnlyLayer:t=Of.DEFAULT_THIRDPERSON_ONLY_LAYER}={}){this._initializedLayers||(this._firstPersonOnlyLayer=e,this._thirdPersonOnlyLayer=t,this.meshAnnotations.forEach(i=>{i.meshes.forEach(r=>{i.type==="firstPersonOnly"?(r.layers.set(this._firstPersonOnlyLayer),r.traverse(a=>a.layers.set(this._firstPersonOnlyLayer))):i.type==="thirdPersonOnly"?(r.layers.set(this._thirdPersonOnlyLayer),r.traverse(a=>a.layers.set(this._thirdPersonOnlyLayer))):i.type==="auto"&&this._createHeadlessModel(r)})}),this._initializedLayers=!0)}_excludeTriangles(e,t,i,r){let a=0;if(t!=null&&t.length>0)for(let s=0;s<e.length;s+=3){const o=e[s],l=e[s+1],h=e[s+2],f=t[o],d=i[o];if(f[0]>0&&r.includes(d[0])||f[1]>0&&r.includes(d[1])||f[2]>0&&r.includes(d[2])||f[3]>0&&r.includes(d[3]))continue;const p=t[l],g=i[l];if(p[0]>0&&r.includes(g[0])||p[1]>0&&r.includes(g[1])||p[2]>0&&r.includes(g[2])||p[3]>0&&r.includes(g[3]))continue;const _=t[h],T=i[h];_[0]>0&&r.includes(T[0])||_[1]>0&&r.includes(T[1])||_[2]>0&&r.includes(T[2])||_[3]>0&&r.includes(T[3])||(e[a++]=o,e[a++]=l,e[a++]=h)}return a}_createErasedMesh(e,t){const i=new q1(e.geometry.clone(),e.material);i.name=`${e.name}(erase)`,i.frustumCulled=e.frustumCulled,i.layers.set(this._firstPersonOnlyLayer);const r=i.geometry,a=r.getAttribute("skinIndex"),s=a instanceof SE?[]:a.array,o=[];for(let T=0;T<s.length;T+=4)o.push([s[T],s[T+1],s[T+2],s[T+3]]);const l=r.getAttribute("skinWeight"),h=l instanceof SE?[]:l.array,f=[];for(let T=0;T<h.length;T+=4)f.push([h[T],h[T+1],h[T+2],h[T+3]]);const d=r.getIndex();if(!d)throw new Error("The geometry doesn't have an index buffer");const p=Array.from(d.array),g=this._excludeTriangles(p,f,o,t),_=[];for(let T=0;T<g;T++)_[T]=p[T];return r.setIndex(_),e.onBeforeRender&&(i.onBeforeRender=e.onBeforeRender),i.bind(new Rc(e.skeleton.bones,e.skeleton.boneInverses),new Ve),i}_createHeadlessModelForSkinnedMesh(e,t){const i=[];if(t.skeleton.bones.forEach((a,s)=>{this._isEraseTarget(a)&&i.push(s)}),!i.length){t.layers.enable(this._thirdPersonOnlyLayer),t.layers.enable(this._firstPersonOnlyLayer);return}t.layers.set(this._thirdPersonOnlyLayer);const r=this._createErasedMesh(t,i);e.add(r)}_createHeadlessModel(e){if(e.type==="Group")if(e.layers.set(this._thirdPersonOnlyLayer),this._isEraseTarget(e))e.traverse(t=>t.layers.set(this._thirdPersonOnlyLayer));else{const t=new Pr;t.name=`_headless_${e.name}`,t.layers.set(this._firstPersonOnlyLayer),e.parent.add(t),e.children.filter(i=>i.type==="SkinnedMesh").forEach(i=>{const r=i;this._createHeadlessModelForSkinnedMesh(t,r)})}else if(e.type==="SkinnedMesh"){const t=e;this._createHeadlessModelForSkinnedMesh(e.parent,t)}else this._isEraseTarget(e)&&(e.layers.set(this._thirdPersonOnlyLayer),e.traverse(t=>t.layers.set(this._thirdPersonOnlyLayer)))}_isEraseTarget(e){return e===this.humanoid.getRawBoneNode("head")?!0:e.parent?this._isEraseTarget(e.parent):!1}};fA.DEFAULT_FIRSTPERSON_ONLY_LAYER=9;fA.DEFAULT_THIRDPERSON_ONLY_LAYER=10;var _N=fA,IK=new Set(["1.0","1.0-beta"]),UK=class{get name(){return"VRMFirstPersonLoaderPlugin"}constructor(n){this.parser=n}afterRoot(n){return _n(this,null,function*(){const e=n.userData.vrmHumanoid;if(e!==null){if(e===void 0)throw new Error("VRMFirstPersonLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");n.userData.vrmFirstPerson=yield this._import(n,e)}})}_import(n,e){return _n(this,null,function*(){if(e==null)return null;const t=yield this._v1Import(n,e);if(t)return t;const i=yield this._v0Import(n,e);return i||null})}_v1Import(n,e){return _n(this,null,function*(){var t,i;const r=this.parser.json;if(!(((t=r.extensionsUsed)==null?void 0:t.indexOf("VRMC_vrm"))!==-1))return null;const s=(i=r.extensions)==null?void 0:i.VRMC_vrm;if(!s)return null;const o=s.specVersion;if(!IK.has(o))return console.warn(`VRMFirstPersonLoaderPlugin: Unknown VRMC_vrm specVersion "${o}"`),null;const l=s.firstPerson,h=[],f=yield dN(n);return Array.from(f.entries()).forEach(([d,p])=>{var g,_;const T=(g=l==null?void 0:l.meshAnnotations)==null?void 0:g.find(y=>y.node===d);h.push({meshes:p,type:(_=T==null?void 0:T.type)!=null?_:"auto"})}),new _N(e,h)})}_v0Import(n,e){return _n(this,null,function*(){var t;const i=this.parser.json,r=(t=i.extensions)==null?void 0:t.VRM;if(!r)return null;const a=r.firstPerson;if(!a)return null;const s=[],o=yield dN(n);return Array.from(o.entries()).forEach(([l,h])=>{const f=i.nodes[l],d=a.meshAnnotations?a.meshAnnotations.find(p=>p.mesh===f.mesh):void 0;s.push({meshes:h,type:this._convertV0FlagToV1Type(d==null?void 0:d.firstPersonFlag)})}),new _N(e,s)})}_convertV0FlagToV1Type(n){return n==="FirstPersonOnly"?"firstPersonOnly":n==="ThirdPersonOnly"?"thirdPersonOnly":n==="Both"?"both":"auto"}},xN=new L,yN=new L,PK=new _t,SN=class extends Pr{constructor(n){super(),this.vrmHumanoid=n,this._boneAxesMap=new Map,Object.values(n.humanBones).forEach(e=>{const t=new W6(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(n=>{n.geometry.dispose(),n.material.dispose()})}updateMatrixWorld(n){Array.from(this._boneAxesMap.entries()).forEach(([e,t])=>{e.node.updateWorldMatrix(!0,!1),e.node.matrixWorld.decompose(xN,PK,yN);const i=xN.set(.1,.1,.1).divide(yN);t.matrix.copy(e.node.matrixWorld).scale(i)}),super.updateMatrixWorld(n)}},L2=["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"],zK={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 H8(n){return n.invert?n.invert():n.inverse(),n}var hu=new L,fu=new _t,zE=class{constructor(n){this.humanBones=n,this.restPose=this.getAbsolutePose()}getAbsolutePose(){const n={};return Object.keys(this.humanBones).forEach(e=>{const t=e,i=this.getBoneNode(t);i&&(hu.copy(i.position),fu.copy(i.quaternion),n[t]={position:hu.toArray(),rotation:fu.toArray()})}),n}getPose(){const n={};return Object.keys(this.humanBones).forEach(e=>{const t=e,i=this.getBoneNode(t);if(!i)return;hu.set(0,0,0),fu.identity();const r=this.restPose[t];r!=null&&r.position&&hu.fromArray(r.position).negate(),r!=null&&r.rotation&&H8(fu.fromArray(r.rotation)),hu.add(i.position),fu.premultiply(i.quaternion),n[t]={position:hu.toArray(),rotation:fu.toArray()}}),n}setPose(n){Object.entries(n).forEach(([e,t])=>{const i=e,r=this.getBoneNode(i);if(!r)return;const a=this.restPose[i];a&&(t!=null&&t.position&&(r.position.fromArray(t.position),a.position&&r.position.add(hu.fromArray(a.position))),t!=null&&t.rotation&&(r.quaternion.fromArray(t.rotation),a.rotation&&r.quaternion.multiply(fu.fromArray(a.rotation))))})}resetPose(){Object.entries(this.restPose).forEach(([n,e])=>{const t=this.getBoneNode(n);t&&(e!=null&&e.position&&t.position.fromArray(e.position),e!=null&&e.rotation&&t.quaternion.fromArray(e.rotation))})}getBone(n){var e;return(e=this.humanBones[n])!=null?e:void 0}getBoneNode(n){var e,t;return(t=(e=this.humanBones[n])==null?void 0:e.node)!=null?t:null}},I2=new L,BK=new _t,HK=new L,TN=class F8 extends zE{static _setupTransforms(e){const t=new Wt;t.name="VRMHumanoidRig";const i={},r={},a={};L2.forEach(o=>{var l;const h=e.getBoneNode(o);if(h){const f=new L,d=new _t;h.updateWorldMatrix(!0,!1),h.matrixWorld.decompose(f,d,I2),i[o]=f,r[o]=h.quaternion.clone();const p=new _t;(l=h.parent)==null||l.matrixWorld.decompose(I2,p,I2),a[o]=p}});const s={};return L2.forEach(o=>{var l;const h=e.getBoneNode(o);if(h){const f=i[o];let d=o,p;for(;p==null&&(d=zK[d],d!=null);)p=i[d];const g=new Wt;g.name="Normalized_"+h.name,(d?(l=s[d])==null?void 0:l.node:t).add(g),g.position.copy(f),p&&g.position.sub(p),s[o]={node:g}}}),{rigBones:s,root:t,parentWorldRotations:a,boneRotations:r}}constructor(e){const{rigBones:t,root:i,parentWorldRotations:r,boneRotations:a}=F8._setupTransforms(e);super(t),this.original=e,this.root=i,this._parentWorldRotations=r,this._boneRotations=a}update(){L2.forEach(e=>{const t=this.original.getBoneNode(e);if(t!=null){const i=this.getBoneNode(e),r=this._parentWorldRotations[e],a=BK.copy(r).invert(),s=this._boneRotations[e];if(t.quaternion.copy(i.quaternion).multiply(r).premultiply(a).multiply(s),e==="hips"){const o=i.getWorldPosition(HK);t.parent.updateWorldMatrix(!0,!1);const l=t.parent.matrixWorld,h=o.applyMatrix4(l.invert());t.position.copy(h)}}})}},EN=class G8{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 i;this.autoUpdateHumanBones=(i=t==null?void 0:t.autoUpdateHumanBones)!=null?i:!0,this._rawHumanBones=new zE(e),this._normalizedHumanBones=new TN(this._rawHumanBones)}copy(e){return this.autoUpdateHumanBones=e.autoUpdateHumanBones,this._rawHumanBones=new zE(e.humanBones),this._normalizedHumanBones=new TN(this._rawHumanBones),this}clone(){return new G8(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()}},FK={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"},GK=new Set(["1.0","1.0-beta"]),MN={leftThumbProximal:"leftThumbMetacarpal",leftThumbIntermediate:"leftThumbProximal",rightThumbProximal:"rightThumbMetacarpal",rightThumbIntermediate:"rightThumbProximal"},VK=class{get name(){return"VRMHumanoidLoaderPlugin"}constructor(n,e){this.parser=n,this.helperRoot=e==null?void 0:e.helperRoot,this.autoUpdateHumanBones=e==null?void 0:e.autoUpdateHumanBones}afterRoot(n){return _n(this,null,function*(){n.userData.vrmHumanoid=yield this._import(n)})}_import(n){return _n(this,null,function*(){const e=yield this._v1Import(n);if(e)return e;const t=yield this._v0Import(n);return t||null})}_v1Import(n){return _n(this,null,function*(){var e,t;const i=this.parser.json;if(!(((e=i.extensionsUsed)==null?void 0:e.indexOf("VRMC_vrm"))!==-1))return null;const a=(t=i.extensions)==null?void 0:t.VRMC_vrm;if(!a)return null;const s=a.specVersion;if(!GK.has(s))return console.warn(`VRMHumanoidLoaderPlugin: Unknown VRMC_vrm specVersion "${s}"`),null;const o=a.humanoid;if(!o)return null;const l=o.humanBones.leftThumbIntermediate!=null||o.humanBones.rightThumbIntermediate!=null,h={};o.humanBones!=null&&(yield Promise.all(Object.entries(o.humanBones).map(d=>_n(this,[d],function*([p,g]){let _=p;const T=g.node;if(l){const v=MN[_];v!=null&&(_=v)}const y=yield this.parser.getDependency("node",T);if(y==null){console.warn(`A glTF node bound to the humanoid bone ${_} (index = ${T}) does not exist`);return}h[_]={node:y}}))));const f=new EN(this._ensureRequiredBonesExist(h),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(n.scene.add(f.normalizedHumanBonesRoot),this.helperRoot){const d=new SN(f);this.helperRoot.add(d),d.renderOrder=this.helperRoot.renderOrder}return f})}_v0Import(n){return _n(this,null,function*(){var e;const i=(e=this.parser.json.extensions)==null?void 0:e.VRM;if(!i)return null;const r=i.humanoid;if(!r)return null;const a={};r.humanBones!=null&&(yield Promise.all(r.humanBones.map(o=>_n(this,null,function*(){const l=o.bone,h=o.node;if(l==null||h==null)return;const f=yield this.parser.getDependency("node",h);if(f==null){console.warn(`A glTF node bound to the humanoid bone ${l} (index = ${h}) does not exist`);return}const d=MN[l],p=d??l;if(a[p]!=null){console.warn(`Multiple bone entries for ${p} detected (index = ${h}), ignoring duplicated entries.`);return}a[p]={node:f}}))));const s=new EN(this._ensureRequiredBonesExist(a),{autoUpdateHumanBones:this.autoUpdateHumanBones});if(n.scene.add(s.normalizedHumanBonesRoot),this.helperRoot){const o=new SN(s);this.helperRoot.add(o),o.renderOrder=this.helperRoot.renderOrder}return s})}_ensureRequiredBonesExist(n){const e=Object.values(FK).filter(t=>n[t]==null);if(e.length>0)throw new Error(`VRMHumanoidLoaderPlugin: These humanoid bones are required but not exist: ${e.join(", ")}`);return n}},bN=class extends Ct{constructor(){super(),this._currentTheta=0,this._currentRadius=0,this.theta=0,this.radius=0,this._currentTheta=0,this._currentRadius=0,this._attrPos=new Ot(new Float32Array(65*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(3*63),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;this._currentTheta!==this.theta&&(this._currentTheta=this.theta,n=!0),this._currentRadius!==this.radius&&(this._currentRadius=this.radius,n=!0),n&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,0,0,0);for(let n=0;n<64;n++){const e=n/63*this._currentTheta;this._attrPos.setXYZ(n+1,this._currentRadius*Math.sin(e),0,this._currentRadius*Math.cos(e))}this._attrPos.needsUpdate=!0}_buildIndex(){for(let n=0;n<63;n++)this._attrIndex.setXYZ(n*3,0,n+1,n+2);this._attrIndex.needsUpdate=!0}},kK=class extends Ct{constructor(){super(),this.radius=0,this._currentRadius=0,this.tail=new L,this._currentTail=new L,this._attrPos=new Ot(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;this._currentRadius!==this.radius&&(this._currentRadius=this.radius,n=!0),this._currentTail.equals(this.tail)||(this._currentTail.copy(this.tail),n=!0),n&&this._buildPosition()}_buildPosition(){for(let n=0;n<32;n++){const e=n/16*Math.PI;this._attrPos.setXYZ(n,Math.cos(e),Math.sin(e),0),this._attrPos.setXYZ(32+n,0,Math.cos(e),Math.sin(e)),this._attrPos.setXYZ(64+n,Math.sin(e),0,Math.cos(e))}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 n=0;n<32;n++){const e=(n+1)%32;this._attrIndex.setXY(n*2,n,e),this._attrIndex.setXY(64+n*2,32+n,32+e),this._attrIndex.setXY(128+n*2,64+n,64+e)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},Wv=new _t,AN=new _t,Jp=new L,wN=new L,RN=Math.sqrt(2)/2,WK=new _t(0,0,-RN,RN),XK=new L(0,1,0),YK=class extends Pr{constructor(n){super(),this.matrixAutoUpdate=!1,this.vrmLookAt=n;{const e=new bN;e.radius=.5;const t=new Ur({color:65280,transparent:!0,opacity:.5,side:cr,depthTest:!1,depthWrite:!1});this._meshPitch=new oi(e,t),this.add(this._meshPitch)}{const e=new bN;e.radius=.5;const t=new Ur({color:16711680,transparent:!0,opacity:.5,side:cr,depthTest:!1,depthWrite:!1});this._meshYaw=new oi(e,t),this.add(this._meshYaw)}{const e=new kK;e.radius=.1;const t=new Bi({color:16777215,depthTest:!1,depthWrite:!1});this._lineTarget=new aa(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(n){const e=tn.DEG2RAD*this.vrmLookAt.yaw;this._meshYaw.geometry.theta=e,this._meshYaw.geometry.update();const t=tn.DEG2RAD*this.vrmLookAt.pitch;this._meshPitch.geometry.theta=t,this._meshPitch.geometry.update(),this.vrmLookAt.getLookAtWorldPosition(Jp),this.vrmLookAt.getLookAtWorldQuaternion(Wv),Wv.multiply(this.vrmLookAt.getFaceFrontQuaternion(AN)),this._meshYaw.position.copy(Jp),this._meshYaw.quaternion.copy(Wv),this._meshPitch.position.copy(Jp),this._meshPitch.quaternion.copy(Wv),this._meshPitch.quaternion.multiply(AN.setFromAxisAngle(XK,e)),this._meshPitch.quaternion.multiply(WK);const{target:i,autoUpdate:r}=this.vrmLookAt;i!=null&&r&&(i.getWorldPosition(wN).sub(Jp),this._lineTarget.geometry.tail.copy(wN),this._lineTarget.geometry.update(),this._lineTarget.position.copy(Jp)),super.updateMatrixWorld(n)}},qK=new L,jK=new L;function BE(n,e){return n.matrixWorld.decompose(qK,e,jK),e}function A_(n){return[Math.atan2(-n.z,n.x),Math.atan2(n.y,Math.sqrt(n.x*n.x+n.z*n.z))]}function CN(n){const e=Math.round(n/2/Math.PI);return n-2*Math.PI*e}var DN=new L(0,0,1),ZK=new L,KK=new L,QK=new L,JK=new _t,U2=new _t,NN=new _t,$K=new _t,P2=new zi,V8=class k8{constructor(e,t){this.offsetFromHeadBone=new L,this.autoUpdate=!0,this.faceFront=new L(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new _t)}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 zi)}getEuler(e){return e.set(tn.DEG2RAD*this._pitch,tn.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 k8(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){const t=this.humanoid.getRawBoneNode("head");return BE(t,e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(DN)<.01)return e.copy(this._restHeadWorldQuaternion).invert();const[t,i]=A_(this.faceFront);return P2.set(0,.5*Math.PI+t,i,"YZX"),e.setFromEuler(P2).premultiply($K.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(U2),this.getFaceFrontQuaternion(NN),e.copy(DN).applyQuaternion(U2).applyQuaternion(NN).applyEuler(this.getEuler(P2))}lookAt(e){const t=JK.copy(this._restHeadWorldQuaternion).multiply(H8(this.getLookAtWorldQuaternion(U2))),i=this.getLookAtWorldPosition(KK),r=QK.copy(e).sub(i).applyQuaternion(t).normalize(),[a,s]=A_(this.faceFront),[o,l]=A_(r),h=CN(o-a),f=CN(s-l);this._yaw=tn.RAD2DEG*h,this._pitch=tn.RAD2DEG*f,this._needsUpdate=!0}update(e){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(ZK)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};V8.EULER_ORDER="YXZ";var eQ=V8,tQ=new L(0,0,1),Ys=new _t,xf=new _t,Ya=new zi(0,0,0,"YXZ"),w_=class{constructor(n,e,t,i,r){this.humanoid=n,this.rangeMapHorizontalInner=e,this.rangeMapHorizontalOuter=t,this.rangeMapVerticalDown=i,this.rangeMapVerticalUp=r,this.faceFront=new L(0,0,1),this._restQuatLeftEye=new _t,this._restQuatRightEye=new _t,this._restLeftEyeParentWorldQuat=new _t,this._restRightEyeParentWorldQuat=new _t;const a=this.humanoid.getRawBoneNode("leftEye"),s=this.humanoid.getRawBoneNode("rightEye");a&&(this._restQuatLeftEye.copy(a.quaternion),BE(a.parent,this._restLeftEyeParentWorldQuat)),s&&(this._restQuatRightEye.copy(s.quaternion),BE(s.parent,this._restRightEyeParentWorldQuat))}applyYawPitch(n,e){const t=this.humanoid.getRawBoneNode("leftEye"),i=this.humanoid.getRawBoneNode("rightEye"),r=this.humanoid.getNormalizedBoneNode("leftEye"),a=this.humanoid.getNormalizedBoneNode("rightEye");t&&(e<0?Ya.x=-tn.DEG2RAD*this.rangeMapVerticalDown.map(-e):Ya.x=tn.DEG2RAD*this.rangeMapVerticalUp.map(e),n<0?Ya.y=-tn.DEG2RAD*this.rangeMapHorizontalInner.map(-n):Ya.y=tn.DEG2RAD*this.rangeMapHorizontalOuter.map(n),Ys.setFromEuler(Ya),this._getWorldFaceFrontQuat(xf),r.quaternion.copy(xf).multiply(Ys).multiply(xf.invert()),Ys.copy(this._restLeftEyeParentWorldQuat),t.quaternion.copy(r.quaternion).multiply(Ys).premultiply(Ys.invert()).multiply(this._restQuatLeftEye)),i&&(e<0?Ya.x=-tn.DEG2RAD*this.rangeMapVerticalDown.map(-e):Ya.x=tn.DEG2RAD*this.rangeMapVerticalUp.map(e),n<0?Ya.y=-tn.DEG2RAD*this.rangeMapHorizontalOuter.map(-n):Ya.y=tn.DEG2RAD*this.rangeMapHorizontalInner.map(n),Ys.setFromEuler(Ya),this._getWorldFaceFrontQuat(xf),a.quaternion.copy(xf).multiply(Ys).multiply(xf.invert()),Ys.copy(this._restRightEyeParentWorldQuat),i.quaternion.copy(a.quaternion).multiply(Ys).premultiply(Ys.invert()).multiply(this._restQuatRightEye))}lookAt(n){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const e=tn.RAD2DEG*n.y,t=tn.RAD2DEG*n.x;this.applyYawPitch(e,t)}_getWorldFaceFrontQuat(n){if(this.faceFront.distanceToSquared(tQ)<.01)return n.identity();const[e,t]=A_(this.faceFront);return Ya.set(0,.5*Math.PI+e,t,"YZX"),n.setFromEuler(Ya)}};w_.type="bone";var HE=class{constructor(n,e,t,i,r){this.expressions=n,this.rangeMapHorizontalInner=e,this.rangeMapHorizontalOuter=t,this.rangeMapVerticalDown=i,this.rangeMapVerticalUp=r}applyYawPitch(n,e){e<0?(this.expressions.setValue("lookDown",0),this.expressions.setValue("lookUp",this.rangeMapVerticalUp.map(-e))):(this.expressions.setValue("lookUp",0),this.expressions.setValue("lookDown",this.rangeMapVerticalDown.map(e))),n<0?(this.expressions.setValue("lookLeft",0),this.expressions.setValue("lookRight",this.rangeMapHorizontalOuter.map(-n))):(this.expressions.setValue("lookRight",0),this.expressions.setValue("lookLeft",this.rangeMapHorizontalOuter.map(n)))}lookAt(n){console.warn("VRMLookAtBoneApplier: lookAt() is deprecated. use apply() instead.");const e=tn.RAD2DEG*n.y,t=tn.RAD2DEG*n.x;this.applyYawPitch(e,t)}};HE.type="expression";var ON=class{constructor(n,e){this.inputMaxValue=n,this.outputScale=e}map(n){return this.outputScale*N8(n/this.inputMaxValue)}},nQ=new Set(["1.0","1.0-beta"]),Xv=.01,iQ=class{get name(){return"VRMLookAtLoaderPlugin"}constructor(n,e){this.parser=n,this.helperRoot=e==null?void 0:e.helperRoot}afterRoot(n){return _n(this,null,function*(){const e=n.userData.vrmHumanoid;if(e===null)return;if(e===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmHumanoid is undefined. VRMHumanoidLoaderPlugin have to be used first");const t=n.userData.vrmExpressionManager;if(t!==null){if(t===void 0)throw new Error("VRMLookAtLoaderPlugin: vrmExpressionManager is undefined. VRMExpressionLoaderPlugin have to be used first");n.userData.vrmLookAt=yield this._import(n,e,t)}})}_import(n,e,t){return _n(this,null,function*(){if(e==null||t==null)return null;const i=yield this._v1Import(n,e,t);if(i)return i;const r=yield this._v0Import(n,e,t);return r||null})}_v1Import(n,e,t){return _n(this,null,function*(){var i,r,a;const s=this.parser.json;if(!(((i=s.extensionsUsed)==null?void 0:i.indexOf("VRMC_vrm"))!==-1))return null;const l=(r=s.extensions)==null?void 0:r.VRMC_vrm;if(!l)return null;const h=l.specVersion;if(!nQ.has(h))return console.warn(`VRMLookAtLoaderPlugin: Unknown VRMC_vrm specVersion "${h}"`),null;const f=l.lookAt;if(!f)return null;const d=f.type==="expression"?1:10,p=this._v1ImportRangeMap(f.rangeMapHorizontalInner,d),g=this._v1ImportRangeMap(f.rangeMapHorizontalOuter,d),_=this._v1ImportRangeMap(f.rangeMapVerticalDown,d),T=this._v1ImportRangeMap(f.rangeMapVerticalUp,d);let y;f.type==="expression"?y=new HE(t,p,g,_,T):y=new w_(e,p,g,_,T);const v=this._importLookAt(e,y);return v.offsetFromHeadBone.fromArray((a=f.offsetFromHeadBone)!=null?a:[0,.06,0]),v})}_v1ImportRangeMap(n,e){var t,i;let r=(t=n==null?void 0:n.inputMaxValue)!=null?t:90;const a=(i=n==null?void 0:n.outputScale)!=null?i:e;return r<Xv&&(console.warn("VRMLookAtLoaderPlugin: inputMaxValue of a range map is too small. Consider reviewing the range map!"),r=Xv),new ON(r,a)}_v0Import(n,e,t){return _n(this,null,function*(){var i,r,a,s;const l=(i=this.parser.json.extensions)==null?void 0:i.VRM;if(!l)return null;const h=l.firstPerson;if(!h)return null;const f=h.lookAtTypeName==="BlendShape"?1:10,d=this._v0ImportDegreeMap(h.lookAtHorizontalInner,f),p=this._v0ImportDegreeMap(h.lookAtHorizontalOuter,f),g=this._v0ImportDegreeMap(h.lookAtVerticalDown,f),_=this._v0ImportDegreeMap(h.lookAtVerticalUp,f);let T;h.lookAtTypeName==="BlendShape"?T=new HE(t,d,p,g,_):T=new w_(e,d,p,g,_);const y=this._importLookAt(e,T);return h.firstPersonBoneOffset?y.offsetFromHeadBone.set((r=h.firstPersonBoneOffset.x)!=null?r:0,(a=h.firstPersonBoneOffset.y)!=null?a:.06,-((s=h.firstPersonBoneOffset.z)!=null?s:0)):y.offsetFromHeadBone.set(0,.06,0),y.faceFront.set(0,0,-1),T instanceof w_&&T.faceFront.set(0,0,-1),y})}_v0ImportDegreeMap(n,e){var t,i;const r=n==null?void 0:n.curve;JSON.stringify(r)!=="[0,0,0,1,1,1,1,0]"&&console.warn("Curves of LookAtDegreeMap defined in VRM 0.0 are not supported");let a=(t=n==null?void 0:n.xRange)!=null?t:90;const s=(i=n==null?void 0:n.yRange)!=null?i:e;return a<Xv&&(console.warn("VRMLookAtLoaderPlugin: xRange of a degree map is too small. Consider reviewing the degree map!"),a=Xv),new ON(a,s)}_importLookAt(n,e){const t=new eQ(n,e);if(this.helperRoot){const i=new YK(t);this.helperRoot.add(i),i.renderOrder=this.helperRoot.renderOrder}return t}};function rQ(n,e){return typeof n!="string"||n===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(n)&&(e=e.replace(/(^https?:\/\/[^/]+).*/i,"$1")),/^(https?:)?\/\//i.test(n)||/^data:.*,.*$/i.test(n)||/^blob:.*$/i.test(n)?n:e+n)}var aQ=new Set(["1.0","1.0-beta"]),sQ=class{get name(){return"VRMMetaLoaderPlugin"}constructor(n,e){var t,i,r;this.parser=n,this.needThumbnailImage=(t=e==null?void 0:e.needThumbnailImage)!=null?t:!1,this.acceptLicenseUrls=(i=e==null?void 0:e.acceptLicenseUrls)!=null?i:["https://vrm.dev/licenses/1.0/"],this.acceptV0Meta=(r=e==null?void 0:e.acceptV0Meta)!=null?r:!0}afterRoot(n){return _n(this,null,function*(){n.userData.vrmMeta=yield this._import(n)})}_import(n){return _n(this,null,function*(){const e=yield this._v1Import(n);if(e!=null)return e;const t=yield this._v0Import(n);return t??null})}_v1Import(n){return _n(this,null,function*(){var e,t,i;const r=this.parser.json;if(!(((e=r.extensionsUsed)==null?void 0:e.indexOf("VRMC_vrm"))!==-1))return null;const s=(t=r.extensions)==null?void 0:t.VRMC_vrm;if(s==null)return null;const o=s.specVersion;if(!aQ.has(o))return console.warn(`VRMMetaLoaderPlugin: Unknown VRMC_vrm specVersion "${o}"`),null;const l=s.meta;if(!l)return null;const h=l.licenseUrl;if(!new Set(this.acceptLicenseUrls).has(h))throw new Error(`VRMMetaLoaderPlugin: The license url "${h}" is not accepted`);let d;return this.needThumbnailImage&&l.thumbnailImage!=null&&(d=(i=yield this._extractGLTFImage(l.thumbnailImage))!=null?i:void 0),{metaVersion:"1",name:l.name,version:l.version,authors:l.authors,copyrightInformation:l.copyrightInformation,contactInformation:l.contactInformation,references:l.references,thirdPartyLicenses:l.thirdPartyLicenses,thumbnailImage:d,licenseUrl:l.licenseUrl,avatarPermission:l.avatarPermission,allowExcessivelyViolentUsage:l.allowExcessivelyViolentUsage,allowExcessivelySexualUsage:l.allowExcessivelySexualUsage,commercialUsage:l.commercialUsage,allowPoliticalOrReligiousUsage:l.allowPoliticalOrReligiousUsage,allowAntisocialOrHateUsage:l.allowAntisocialOrHateUsage,creditNotation:l.creditNotation,allowRedistribution:l.allowRedistribution,modification:l.modification,otherLicenseUrl:l.otherLicenseUrl}})}_v0Import(n){return _n(this,null,function*(){var e;const i=(e=this.parser.json.extensions)==null?void 0:e.VRM;if(!i)return null;const r=i.meta;if(!r)return null;if(!this.acceptV0Meta)throw new Error("VRMMetaLoaderPlugin: Attempted to load VRM0.0 meta but acceptV0Meta is false");let a;return this.needThumbnailImage&&r.texture!=null&&r.texture!==-1&&(a=yield this.parser.getDependency("texture",r.texture)),{metaVersion:"0",allowedUserName:r.allowedUserName,author:r.author,commercialUssageName:r.commercialUssageName,contactInformation:r.contactInformation,licenseName:r.licenseName,otherLicenseUrl:r.otherLicenseUrl,otherPermissionUrl:r.otherPermissionUrl,reference:r.reference,sexualUssageName:r.sexualUssageName,texture:a??void 0,title:r.title,version:r.version,violentUssageName:r.violentUssageName}})}_extractGLTFImage(n){return _n(this,null,function*(){var e;const i=(e=this.parser.json.images)==null?void 0:e[n];if(i==null)return console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${n}] of glTF as a thumbnail but the image doesn't exist`),null;let r=i.uri;if(i.bufferView!=null){const s=yield this.parser.getDependency("bufferView",i.bufferView),o=new Blob([s],{type:i.mimeType});r=URL.createObjectURL(o)}return r==null?(console.warn(`VRMMetaLoaderPlugin: Attempt to use images[${n}] of glTF as a thumbnail but the image couldn't load properly`),null):yield new Ld().loadAsync(rQ(r,this.parser.options.path)).catch(s=>(console.error(s),console.warn("VRMMetaLoaderPlugin: Failed to load a thumbnail image"),null))})}},oQ=class{constructor(n){this.scene=n.scene,this.meta=n.meta,this.humanoid=n.humanoid,this.expressionManager=n.expressionManager,this.firstPerson=n.firstPerson,this.lookAt=n.lookAt}update(n){this.humanoid.update(),this.lookAt&&this.lookAt.update(n),this.expressionManager&&this.expressionManager.update()}},lQ=class extends oQ{constructor(n){super(n),this.materials=n.materials,this.springBoneManager=n.springBoneManager,this.nodeConstraintManager=n.nodeConstraintManager}update(n){super.update(n),this.nodeConstraintManager&&this.nodeConstraintManager.update(),this.springBoneManager&&this.springBoneManager.update(n),this.materials&&this.materials.forEach(e=>{e.update&&e.update(n)})}},cQ=Object.defineProperty,LN=Object.getOwnPropertySymbols,uQ=Object.prototype.hasOwnProperty,hQ=Object.prototype.propertyIsEnumerable,IN=(n,e,t)=>e in n?cQ(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,UN=(n,e)=>{for(var t in e||(e={}))uQ.call(e,t)&&IN(n,t,e[t]);if(LN)for(var t of LN(e))hQ.call(e,t)&&IN(n,t,e[t]);return n},Du=(n,e,t)=>new Promise((i,r)=>{var a=l=>{try{o(t.next(l))}catch(h){r(h)}},s=l=>{try{o(t.throw(l))}catch(h){r(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((t=t.apply(n,e)).next())}),fQ={"":3e3,srgb:3001};function dQ(n,e){parseInt(Ds,10)>=152?n.colorSpace=e:n.encoding=fQ[e]}var pQ=class{get pending(){return Promise.all(this._pendings)}constructor(n,e){this._parser=n,this._materialParams=e,this._pendings=[]}assignPrimitive(n,e){e!=null&&(this._materialParams[n]=e)}assignColor(n,e,t){if(e!=null){const i=new qe().fromArray(e);t&&i.convertSRGBToLinear(),this._materialParams[n]=i}}assignTexture(n,e,t){return Du(this,null,function*(){const i=Du(this,null,function*(){e!=null&&(yield this._parser.assignTexture(this._materialParams,n,e),t&&dQ(this._materialParams[n],"srgb"))});return this._pendings.push(i),i})}assignTextureByIndex(n,e,t){return Du(this,null,function*(){return this.assignTexture(n,e!=null?{index:e}:void 0,t)})}},mQ=`// #define PHONG

varying vec3 vViewPosition;

#ifndef FLAT_SHADED
  varying vec3 vNormal;
#endif

#include <common>

// #include <uv_pars_vertex>
#ifdef MTOON_USE_UV
  varying vec2 vUv;

  // COMPAT: pre-r151 uses a common uvTransform
  #if THREE_VRM_THREE_REVISION < 151
    uniform mat3 uvTransform;
  #endif
#endif

// #include <uv2_pars_vertex>
// COMAPT: pre-r151 uses uv2 for lightMap and aoMap
#if THREE_VRM_THREE_REVISION < 151
  #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
    attribute vec2 uv2;
    varying vec2 vUv2;
    uniform mat3 uv2Transform;
  #endif
#endif

// #include <displacementmap_pars_vertex>
// #include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>

#ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE
  uniform sampler2D outlineWidthMultiplyTexture;
  uniform mat3 outlineWidthMultiplyTextureUvTransform;
#endif

uniform float outlineWidthFactor;

void main() {

  // #include <uv_vertex>
  #ifdef MTOON_USE_UV
    // COMPAT: pre-r151 uses a common uvTransform
    #if THREE_VRM_THREE_REVISION >= 151
      vUv = uv;
    #else
      vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
    #endif
  #endif

  // #include <uv2_vertex>
  // COMAPT: pre-r151 uses uv2 for lightMap and aoMap
  #if THREE_VRM_THREE_REVISION < 151
    #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
      vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
    #endif
  #endif

  #include <color_vertex>

  #include <beginnormal_vertex>
  #include <morphnormal_vertex>
  #include <skinbase_vertex>
  #include <skinnormal_vertex>

  // we need this to compute the outline properly
  objectNormal = normalize( objectNormal );

  #include <defaultnormal_vertex>

  #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
    vNormal = normalize( transformedNormal );
  #endif

  #include <begin_vertex>

  #include <morphtarget_vertex>
  #include <skinning_vertex>
  // #include <displacementmap_vertex>
  #include <project_vertex>
  #include <logdepthbuf_vertex>
  #include <clipping_planes_vertex>

  vViewPosition = - mvPosition.xyz;

  #ifdef OUTLINE
    float worldNormalLength = length( transformedNormal );
    vec3 outlineOffset = outlineWidthFactor * worldNormalLength * objectNormal;

    #ifdef USE_OUTLINEWIDTHMULTIPLYTEXTURE
      vec2 outlineWidthMultiplyTextureUv = ( outlineWidthMultiplyTextureUvTransform * vec3( vUv, 1 ) ).xy;
      float outlineTex = texture2D( outlineWidthMultiplyTexture, outlineWidthMultiplyTextureUv ).g;
      outlineOffset *= outlineTex;
    #endif

    #ifdef OUTLINE_WIDTH_SCREEN
      outlineOffset *= vViewPosition.z / projectionMatrix[ 1 ].y;
    #endif

    gl_Position = projectionMatrix * modelViewMatrix * vec4( outlineOffset + transformed, 1.0 );

    gl_Position.z += 1E-6 * gl_Position.w; // anti-artifact magic
  #endif

  #include <worldpos_vertex>
  // #include <envmap_vertex>
  #include <shadowmap_vertex>
  #include <fog_vertex>

}`,gQ=`// #define PHONG

uniform vec3 litFactor;

uniform float opacity;

uniform vec3 shadeColorFactor;
#ifdef USE_SHADEMULTIPLYTEXTURE
  uniform sampler2D shadeMultiplyTexture;
  uniform mat3 shadeMultiplyTextureUvTransform;
#endif

uniform float shadingShiftFactor;
uniform float shadingToonyFactor;

#ifdef USE_SHADINGSHIFTTEXTURE
  uniform sampler2D shadingShiftTexture;
  uniform mat3 shadingShiftTextureUvTransform;
  uniform float shadingShiftTextureScale;
#endif

uniform float giEqualizationFactor;

uniform vec3 parametricRimColorFactor;
#ifdef USE_RIMMULTIPLYTEXTURE
  uniform sampler2D rimMultiplyTexture;
  uniform mat3 rimMultiplyTextureUvTransform;
#endif
uniform float rimLightingMixFactor;
uniform float parametricRimFresnelPowerFactor;
uniform float parametricRimLiftFactor;

#ifdef USE_MATCAPTEXTURE
  uniform vec3 matcapFactor;
  uniform sampler2D matcapTexture;
  uniform mat3 matcapTextureUvTransform;
#endif

uniform vec3 emissive;
uniform float emissiveIntensity;

uniform vec3 outlineColorFactor;
uniform float outlineLightingMixFactor;

#ifdef USE_UVANIMATIONMASKTEXTURE
  uniform sampler2D uvAnimationMaskTexture;
  uniform mat3 uvAnimationMaskTextureUvTransform;
#endif

uniform float uvAnimationScrollXOffset;
uniform float uvAnimationScrollYOffset;
uniform float uvAnimationRotationPhase;

#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>

// #include <uv_pars_fragment>
#if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )
  varying vec2 vUv;
#endif

// #include <uv2_pars_fragment>
// COMAPT: pre-r151 uses uv2 for lightMap and aoMap
#if THREE_VRM_THREE_REVISION < 151
  #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
    varying vec2 vUv2;
  #endif
#endif

#include <map_pars_fragment>

#ifdef USE_MAP
  uniform mat3 mapUvTransform;
#endif

// #include <alphamap_pars_fragment>

#include <alphatest_pars_fragment>

#include <aomap_pars_fragment>
// #include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>

#ifdef USE_EMISSIVEMAP
  uniform mat3 emissiveMapUvTransform;
#endif

// #include <envmap_common_pars_fragment>
// #include <envmap_pars_fragment>
// #include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>

// #include <bsdfs>
// COMPAT: pre-r151 doesn't have BRDF_Lambert in <common>
#if THREE_VRM_THREE_REVISION < 151
  vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
    return RECIPROCAL_PI * diffuseColor;
  }
#endif

#include <lights_pars_begin>

#include <normal_pars_fragment>

// #include <lights_phong_pars_fragment>
varying vec3 vViewPosition;

struct MToonMaterial {
  vec3 diffuseColor;
  vec3 shadeColor;
  float shadingShift;
};

float linearstep( float a, float b, float t ) {
  return clamp( ( t - a ) / ( b - a ), 0.0, 1.0 );
}

/**
 * Convert NdotL into toon shading factor using shadingShift and shadingToony
 */
float getShading(
  const in float dotNL,
  const in float shadow,
  const in float shadingShift
) {
  float shading = dotNL;
  shading = shading + shadingShift;
  shading = linearstep( -1.0 + shadingToonyFactor, 1.0 - shadingToonyFactor, shading );
  shading *= shadow;
  return shading;
}

/**
 * Mix diffuseColor and shadeColor using shading factor and light color
 */
vec3 getDiffuse(
  const in MToonMaterial material,
  const in float shading,
  in vec3 lightColor
) {
  #ifdef DEBUG_LITSHADERATE
    return vec3( BRDF_Lambert( shading * lightColor ) );
  #endif

  vec3 col = lightColor * BRDF_Lambert( mix( material.shadeColor, material.diffuseColor, shading ) );

  // The "comment out if you want to PBR absolutely" line
  #ifdef V0_COMPAT_SHADE
    col = min( col, material.diffuseColor );
  #endif

  return col;
}

// COMPAT: pre-r156 uses a struct GeometricContext
#if THREE_VRM_THREE_REVISION >= 157
  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 ) {
    float dotNL = clamp( dot( geometryNormal, directLight.direction ), -1.0, 1.0 );
    vec3 irradiance = directLight.color;

    // directSpecular will be used for rim lighting, not an actual specular
    reflectedLight.directSpecular += irradiance;

    irradiance *= dotNL;

    float shading = getShading( dotNL, shadow, material.shadingShift );

    // toon shaded diffuse
    reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );
  }

  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 ) {
    // indirect diffuse will use diffuseColor, no shadeColor involved
    reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );

    // directSpecular will be used for rim lighting, not an actual specular
    reflectedLight.directSpecular += irradiance;
  }
#else
  void RE_Direct_MToon( const in IncidentLight directLight, const in GeometricContext geometry, const in MToonMaterial material, const in float shadow, inout ReflectedLight reflectedLight ) {
    float dotNL = clamp( dot( geometry.normal, directLight.direction ), -1.0, 1.0 );
    vec3 irradiance = directLight.color;

    // directSpecular will be used for rim lighting, not an actual specular
    reflectedLight.directSpecular += irradiance;

    irradiance *= dotNL;

    float shading = getShading( dotNL, shadow, material.shadingShift );

    // toon shaded diffuse
    reflectedLight.directDiffuse += getDiffuse( material, shading, directLight.color );
  }

  void RE_IndirectDiffuse_MToon( const in vec3 irradiance, const in GeometricContext geometry, const in MToonMaterial material, inout ReflectedLight reflectedLight ) {
    // indirect diffuse will use diffuseColor, no shadeColor involved
    reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );

    // directSpecular will be used for rim lighting, not an actual specular
    reflectedLight.directSpecular += irradiance;
  }
#endif

#define RE_Direct RE_Direct_MToon
#define RE_IndirectDiffuse RE_IndirectDiffuse_MToon
#define Material_LightProbeLOD( material ) (0)

#include <shadowmap_pars_fragment>
// #include <bumpmap_pars_fragment>

// #include <normalmap_pars_fragment>
#ifdef USE_NORMALMAP

  uniform sampler2D normalMap;
  uniform mat3 normalMapUvTransform;
  uniform vec2 normalScale;

#endif

// COMPAT: pre-r151
// USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151
#if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )

  uniform mat3 normalMatrix;

#endif

// COMPAT: pre-r151
// USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( TANGENTSPACE_NORMALMAP ) )

  // Per-Pixel Tangent Space Normal Mapping
  // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html

  // three-vrm specific change: it requires \`uv\` as an input in order to support uv scrolls

  // Temporary compat against shader change @ Three.js r126, r151
  #if THREE_VRM_THREE_REVISION >= 151

    mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {

      vec3 q0 = dFdx( eye_pos.xyz );
      vec3 q1 = dFdy( eye_pos.xyz );
      vec2 st0 = dFdx( uv.st );
      vec2 st1 = dFdy( uv.st );

      vec3 N = surf_norm;

      vec3 q1perp = cross( q1, N );
      vec3 q0perp = cross( N, q0 );

      vec3 T = q1perp * st0.x + q0perp * st1.x;
      vec3 B = q1perp * st0.y + q0perp * st1.y;

      float det = max( dot( T, T ), dot( B, B ) );
      float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );

      return mat3( T * scale, B * scale, N );

    }

  #else

    vec3 perturbNormal2Arb( vec2 uv, vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {

      vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
      vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
      vec2 st0 = dFdx( uv.st );
      vec2 st1 = dFdy( uv.st );

      vec3 N = normalize( surf_norm );

      vec3 q1perp = cross( q1, N );
      vec3 q0perp = cross( N, q0 );

      vec3 T = q1perp * st0.x + q0perp * st1.x;
      vec3 B = q1perp * st0.y + q0perp * st1.y;

      // three-vrm specific change: Workaround for the issue that happens when delta of uv = 0.0
      // TODO: Is this still required? Or shall I make a PR about it?
      if ( length( T ) == 0.0 || length( B ) == 0.0 ) {
        return surf_norm;
      }

      float det = max( dot( T, T ), dot( B, B ) );
      float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );

      return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );

    }

  #endif

#endif

// #include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

// == post correction ==========================================================
void postCorrection() {
  #include <tonemapping_fragment>
  #include <colorspace_fragment>
  #include <fog_fragment>
  #include <premultiplied_alpha_fragment>
  #include <dithering_fragment>
}

// == main procedure ===========================================================
void main() {
  #include <clipping_planes_fragment>

  vec2 uv = vec2(0.5, 0.5);

  #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )
    uv = vUv;

    float uvAnimMask = 1.0;
    #ifdef USE_UVANIMATIONMASKTEXTURE
      vec2 uvAnimationMaskTextureUv = ( uvAnimationMaskTextureUvTransform * vec3( uv, 1 ) ).xy;
      uvAnimMask = texture2D( uvAnimationMaskTexture, uvAnimationMaskTextureUv ).b;
    #endif

    float uvRotCos = cos( uvAnimationRotationPhase * uvAnimMask );
    float uvRotSin = sin( uvAnimationRotationPhase * uvAnimMask );
    uv = mat2( uvRotCos, -uvRotSin, uvRotSin, uvRotCos ) * ( uv - 0.5 ) + 0.5;
    uv = uv + vec2( uvAnimationScrollXOffset, uvAnimationScrollYOffset ) * uvAnimMask;
  #endif

  #ifdef DEBUG_UV
    gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
    #if ( defined( MTOON_USE_UV ) && !defined( MTOON_UVS_VERTEX_ONLY ) )
      gl_FragColor = vec4( uv, 0.0, 1.0 );
    #endif
    return;
  #endif

  vec4 diffuseColor = vec4( litFactor, opacity );
  ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  vec3 totalEmissiveRadiance = emissive * emissiveIntensity;

  #include <logdepthbuf_fragment>

  // #include <map_fragment>
  #ifdef USE_MAP
    vec2 mapUv = ( mapUvTransform * vec3( uv, 1 ) ).xy;
    vec4 sampledDiffuseColor = texture2D( map, mapUv );
    #ifdef DECODE_VIDEO_TEXTURE
      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 );
    #endif
    diffuseColor *= sampledDiffuseColor;
  #endif

  // #include <color_fragment>
  #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )
    diffuseColor.rgb *= vColor;
  #endif

  // #include <alphamap_fragment>

  #include <alphatest_fragment>

  // #include <specularmap_fragment>

  // #include <normal_fragment_begin>
  float faceDirection = gl_FrontFacing ? 1.0 : -1.0;

  #ifdef FLAT_SHADED

    vec3 fdx = dFdx( vViewPosition );
    vec3 fdy = dFdy( vViewPosition );
    vec3 normal = normalize( cross( fdx, fdy ) );

  #else

    vec3 normal = normalize( vNormal );

    #ifdef DOUBLE_SIDED

      normal *= faceDirection;

    #endif

  #endif

  #ifdef USE_NORMALMAP

    vec2 normalMapUv = ( normalMapUvTransform * vec3( uv, 1 ) ).xy;

  #endif

  #ifdef USE_NORMALMAP_TANGENTSPACE

    #ifdef USE_TANGENT

      mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );

    #else

      mat3 tbn = getTangentFrame( - vViewPosition, normal, normalMapUv );

    #endif

    #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )

      tbn[0] *= faceDirection;
      tbn[1] *= faceDirection;

    #endif

  #endif

  #ifdef USE_CLEARCOAT_NORMALMAP

    #ifdef USE_TANGENT

      mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );

    #else

      mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );

    #endif

    #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )

      tbn2[0] *= faceDirection;
      tbn2[1] *= faceDirection;

    #endif

  #endif

  // non perturbed normal for clearcoat among others

  vec3 nonPerturbedNormal = normal;

  #ifdef OUTLINE
    normal *= -1.0;
  #endif

  // #include <normal_fragment_maps>

  // COMPAT: pre-r151
  // USE_NORMALMAP_OBJECTSPACE used to be OBJECTSPACE_NORMALMAP in pre-r151
  #if defined( USE_NORMALMAP_OBJECTSPACE ) || defined( OBJECTSPACE_NORMALMAP )

    normal = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals

    #ifdef FLIP_SIDED

      normal = - normal;

    #endif

    #ifdef DOUBLE_SIDED

      normal = normal * faceDirection;

    #endif

    normal = normalize( normalMatrix * normal );

  // COMPAT: pre-r151
  // USE_NORMALMAP_TANGENTSPACE used to be TANGENTSPACE_NORMALMAP in pre-r151
  #elif defined( USE_NORMALMAP_TANGENTSPACE ) || defined( TANGENTSPACE_NORMALMAP )

    vec3 mapN = texture2D( normalMap, normalMapUv ).xyz * 2.0 - 1.0;
    mapN.xy *= normalScale;

    // COMPAT: pre-r151
    #if THREE_VRM_THREE_REVISION >= 151 || defined( USE_TANGENT )

      normal = normalize( tbn * mapN );

    #else

      normal = perturbNormal2Arb( uv, -vViewPosition, normal, mapN, faceDirection );

    #endif

  #endif

  // #include <emissivemap_fragment>
  #ifdef USE_EMISSIVEMAP
    vec2 emissiveMapUv = ( emissiveMapUvTransform * vec3( uv, 1 ) ).xy;
    totalEmissiveRadiance *= texture2D( emissiveMap, emissiveMapUv ).rgb;
  #endif

  #ifdef DEBUG_NORMAL
    gl_FragColor = vec4( 0.5 + 0.5 * normal, 1.0 );
    return;
  #endif

  // -- MToon: lighting --------------------------------------------------------
  // accumulation
  // #include <lights_phong_fragment>
  MToonMaterial material;

  material.diffuseColor = diffuseColor.rgb;

  material.shadeColor = shadeColorFactor;
  #ifdef USE_SHADEMULTIPLYTEXTURE
    vec2 shadeMultiplyTextureUv = ( shadeMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;
    material.shadeColor *= texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv ).rgb;
  #endif

  #if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )
    material.shadeColor.rgb *= vColor;
  #endif

  material.shadingShift = shadingShiftFactor;
  #ifdef USE_SHADINGSHIFTTEXTURE
    vec2 shadingShiftTextureUv = ( shadingShiftTextureUvTransform * vec3( uv, 1 ) ).xy;
    material.shadingShift += texture2D( shadingShiftTexture, shadingShiftTextureUv ).r * shadingShiftTextureScale;
  #endif

  // #include <lights_fragment_begin>

  // MToon Specific changes:
  // Since we want to take shadows into account of shading instead of irradiance,
  // we had to modify the codes that multiplies the results of shadowmap into color of direct lights.

  // COMPAT: pre-r156 uses a struct GeometricContext
  #if THREE_VRM_THREE_REVISION >= 157
    vec3 geometryPosition = - vViewPosition;
    vec3 geometryNormal = normal;
    vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );

    vec3 geometryClearcoatNormal;

    #ifdef USE_CLEARCOAT

      geometryClearcoatNormal = clearcoatNormal;

    #endif
  #else
    GeometricContext geometry;

    geometry.position = - vViewPosition;
    geometry.normal = normal;
    geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );

    #ifdef USE_CLEARCOAT

      geometry.clearcoatNormal = clearcoatNormal;

    #endif
  #endif

  IncidentLight directLight;

  // since these variables will be used in unrolled loop, we have to define in prior
  float shadow;

  #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )

    PointLight pointLight;
    #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
    PointLightShadow pointLightShadow;
    #endif

    #pragma unroll_loop_start
    for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {

      pointLight = pointLights[ i ];

      // COMPAT: pre-r156 uses a struct GeometricContext
      #if THREE_VRM_THREE_REVISION >= 157
        getPointLightInfo( pointLight, geometryPosition, directLight );
      #else
        getPointLightInfo( pointLight, geometry, directLight );
      #endif

      shadow = 1.0;
      #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
      pointLightShadow = pointLightShadows[ i ];
      // COMPAT: pre-r166
      // r166 introduced shadowIntensity
      #if THREE_VRM_THREE_REVISION >= 166
        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;
      #else
        shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
      #endif
      #endif

      // COMPAT: pre-r156 uses a struct GeometricContext
      #if THREE_VRM_THREE_REVISION >= 157
        RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );
      #else
        RE_Direct( directLight, geometry, material, shadow, reflectedLight );
      #endif

    }
    #pragma unroll_loop_end

  #endif

  #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )

    SpotLight spotLight;
    #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
    SpotLightShadow spotLightShadow;
    #endif

    #pragma unroll_loop_start
    for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {

      spotLight = spotLights[ i ];

      // COMPAT: pre-r156 uses a struct GeometricContext
      #if THREE_VRM_THREE_REVISION >= 157
        getSpotLightInfo( spotLight, geometryPosition, directLight );
      #else
        getSpotLightInfo( spotLight, geometry, directLight );
      #endif

      shadow = 1.0;
      #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
      spotLightShadow = spotLightShadows[ i ];
      // COMPAT: pre-r166
      // r166 introduced shadowIntensity
      #if THREE_VRM_THREE_REVISION >= 166
        shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
      #else
        shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
      #endif
      #endif

      // COMPAT: pre-r156 uses a struct GeometricContext
      #if THREE_VRM_THREE_REVISION >= 157
        RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );
      #else
        RE_Direct( directLight, geometry, material, shadow, reflectedLight );
      #endif

    }
    #pragma unroll_loop_end

  #endif

  #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )

    DirectionalLight directionalLight;
    #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
    DirectionalLightShadow directionalLightShadow;
    #endif

    #pragma unroll_loop_start
    for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {

      directionalLight = directionalLights[ i ];

      // COMPAT: pre-r156 uses a struct GeometricContext
      #if THREE_VRM_THREE_REVISION >= 157
        getDirectionalLightInfo( directionalLight, directLight );
      #else
        getDirectionalLightInfo( directionalLight, geometry, directLight );
      #endif

      shadow = 1.0;
      #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
      directionalLightShadow = directionalLightShadows[ i ];
      // COMPAT: pre-r166
      // r166 introduced shadowIntensity
      #if THREE_VRM_THREE_REVISION >= 166
        shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
      #else
        shadow = all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
      #endif
      #endif

      // COMPAT: pre-r156 uses a struct GeometricContext
      #if THREE_VRM_THREE_REVISION >= 157
        RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, shadow, reflectedLight );
      #else
        RE_Direct( directLight, geometry, material, shadow, reflectedLight );
      #endif

    }
    #pragma unroll_loop_end

  #endif

  // #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )

  //   RectAreaLight rectAreaLight;

  //   #pragma unroll_loop_start
  //   for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {

  //     rectAreaLight = rectAreaLights[ i ];
  //     RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );

  //   }
  //   #pragma unroll_loop_end

  // #endif

  #if defined( RE_IndirectDiffuse )

    vec3 iblIrradiance = vec3( 0.0 );

    vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );

    // COMPAT: pre-r156 uses a struct GeometricContext
    // COMPAT: pre-r156 doesn't have a define USE_LIGHT_PROBES
    #if THREE_VRM_THREE_REVISION >= 157
      #if defined( USE_LIGHT_PROBES )
        irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
      #endif
    #else
      irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
    #endif

    #if ( NUM_HEMI_LIGHTS > 0 )

      #pragma unroll_loop_start
      for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {

        // COMPAT: pre-r156 uses a struct GeometricContext
        #if THREE_VRM_THREE_REVISION >= 157
          irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
        #else
          irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
        #endif

      }
      #pragma unroll_loop_end

    #endif

  #endif

  // #if defined( RE_IndirectSpecular )

  //   vec3 radiance = vec3( 0.0 );
  //   vec3 clearcoatRadiance = vec3( 0.0 );

  // #endif

  #include <lights_fragment_maps>
  #include <lights_fragment_end>

  // modulation
  #include <aomap_fragment>

  vec3 col = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;

  #ifdef DEBUG_LITSHADERATE
    gl_FragColor = vec4( col, diffuseColor.a );
    postCorrection();
    return;
  #endif

  // -- MToon: rim lighting -----------------------------------------
  vec3 viewDir = normalize( vViewPosition );

  #ifndef PHYSICALLY_CORRECT_LIGHTS
    reflectedLight.directSpecular /= PI;
  #endif
  vec3 rimMix = mix( vec3( 1.0 ), reflectedLight.directSpecular, 1.0 );

  vec3 rim = parametricRimColorFactor * pow( saturate( 1.0 - dot( viewDir, normal ) + parametricRimLiftFactor ), parametricRimFresnelPowerFactor );

  #ifdef USE_MATCAPTEXTURE
    {
      vec3 x = normalize( vec3( viewDir.z, 0.0, -viewDir.x ) );
      vec3 y = cross( viewDir, x ); // guaranteed to be normalized
      vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) );
      sphereUv = ( matcapTextureUvTransform * vec3( sphereUv, 1 ) ).xy;
      vec3 matcap = texture2D( matcapTexture, sphereUv ).rgb;
      rim += matcapFactor * matcap;
    }
  #endif

  #ifdef USE_RIMMULTIPLYTEXTURE
    vec2 rimMultiplyTextureUv = ( rimMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;
    rim *= texture2D( rimMultiplyTexture, rimMultiplyTextureUv ).rgb;
  #endif

  col += rimMix * rim;

  // -- MToon: Emission --------------------------------------------------------
  col += totalEmissiveRadiance;

  // #include <envmap_fragment>

  // -- Almost done! -----------------------------------------------------------
  #if defined( OUTLINE )
    col = outlineColorFactor.rgb * mix( vec3( 1.0 ), col, outlineLightingMixFactor );
  #endif

  #ifdef OPAQUE
    diffuseColor.a = 1.0;
  #endif

  gl_FragColor = vec4( col, diffuseColor.a );
  postCorrection();
}
`,vQ={None:"none"},PN={None:"none",ScreenCoordinates:"screenCoordinates"},_Q={3e3:"",3001:"srgb"};function z2(n){return parseInt(Ds,10)>=152?n.colorSpace:_Q[n.encoding]}var xQ=class extends Vi{constructor(n={}){var e;super({vertexShader:mQ,fragmentShader:gQ}),this.uvAnimationScrollXSpeedFactor=0,this.uvAnimationScrollYSpeedFactor=0,this.uvAnimationRotationSpeedFactor=0,this.fog=!0,this.normalMapType=hl,this._ignoreVertexColor=!0,this._v0CompatShade=!1,this._debugMode=vQ.None,this._outlineWidthMode=PN.None,this._isOutline=!1,n.transparentWithZWrite&&(n.depthWrite=!0),delete n.transparentWithZWrite,n.fog=!0,n.lights=!0,n.clipping=!0,this.uniforms=Lb.merge([rt.common,rt.normalmap,rt.emissivemap,rt.fog,rt.lights,{litFactor:{value:new qe(1,1,1)},mapUvTransform:{value:new Et},colorAlpha:{value:1},normalMapUvTransform:{value:new Et},shadeColorFactor:{value:new qe(0,0,0)},shadeMultiplyTexture:{value:null},shadeMultiplyTextureUvTransform:{value:new Et},shadingShiftFactor:{value:0},shadingShiftTexture:{value:null},shadingShiftTextureUvTransform:{value:new Et},shadingShiftTextureScale:{value:1},shadingToonyFactor:{value:.9},giEqualizationFactor:{value:.9},matcapFactor:{value:new qe(1,1,1)},matcapTexture:{value:null},matcapTextureUvTransform:{value:new Et},parametricRimColorFactor:{value:new qe(0,0,0)},rimMultiplyTexture:{value:null},rimMultiplyTextureUvTransform:{value:new Et},rimLightingMixFactor:{value:1},parametricRimFresnelPowerFactor:{value:5},parametricRimLiftFactor:{value:0},emissive:{value:new qe(0,0,0)},emissiveIntensity:{value:1},emissiveMapUvTransform:{value:new Et},outlineWidthMultiplyTexture:{value:null},outlineWidthMultiplyTextureUvTransform:{value:new Et},outlineWidthFactor:{value:0},outlineColorFactor:{value:new qe(0,0,0)},outlineLightingMixFactor:{value:1},uvAnimationMaskTexture:{value:null},uvAnimationMaskTextureUvTransform:{value:new Et},uvAnimationScrollXOffset:{value:0},uvAnimationScrollYOffset:{value:0},uvAnimationRotationPhase:{value:0}},(e=n.uniforms)!=null?e:{}]),this.setValues(n),this._uploadUniformsWorkaround(),this.customProgramCacheKey=()=>[...Object.entries(this._generateDefines()).map(([t,i])=>`${t}:${i}`),this.matcapTexture?`matcapTextureColorSpace:${z2(this.matcapTexture)}`:"",this.shadeMultiplyTexture?`shadeMultiplyTextureColorSpace:${z2(this.shadeMultiplyTexture)}`:"",this.rimMultiplyTexture?`rimMultiplyTextureColorSpace:${z2(this.rimMultiplyTexture)}`:""].join(","),this.onBeforeCompile=t=>{const i=parseInt(Ds,10),r=Object.entries(UN(UN({},this._generateDefines()),this.defines)).filter(([a,s])=>!!s).map(([a,s])=>`#define ${a} ${s}`).join(`
`)+`
`;t.vertexShader=r+t.vertexShader,t.fragmentShader=r+t.fragmentShader,i<154&&(t.fragmentShader=t.fragmentShader.replace("#include <colorspace_fragment>","#include <encodings_fragment>"))}}get color(){return this.uniforms.litFactor.value}set color(n){this.uniforms.litFactor.value=n}get map(){return this.uniforms.map.value}set map(n){this.uniforms.map.value=n}get normalMap(){return this.uniforms.normalMap.value}set normalMap(n){this.uniforms.normalMap.value=n}get normalScale(){return this.uniforms.normalScale.value}set normalScale(n){this.uniforms.normalScale.value=n}get emissive(){return this.uniforms.emissive.value}set emissive(n){this.uniforms.emissive.value=n}get emissiveIntensity(){return this.uniforms.emissiveIntensity.value}set emissiveIntensity(n){this.uniforms.emissiveIntensity.value=n}get emissiveMap(){return this.uniforms.emissiveMap.value}set emissiveMap(n){this.uniforms.emissiveMap.value=n}get shadeColorFactor(){return this.uniforms.shadeColorFactor.value}set shadeColorFactor(n){this.uniforms.shadeColorFactor.value=n}get shadeMultiplyTexture(){return this.uniforms.shadeMultiplyTexture.value}set shadeMultiplyTexture(n){this.uniforms.shadeMultiplyTexture.value=n}get shadingShiftFactor(){return this.uniforms.shadingShiftFactor.value}set shadingShiftFactor(n){this.uniforms.shadingShiftFactor.value=n}get shadingShiftTexture(){return this.uniforms.shadingShiftTexture.value}set shadingShiftTexture(n){this.uniforms.shadingShiftTexture.value=n}get shadingShiftTextureScale(){return this.uniforms.shadingShiftTextureScale.value}set shadingShiftTextureScale(n){this.uniforms.shadingShiftTextureScale.value=n}get shadingToonyFactor(){return this.uniforms.shadingToonyFactor.value}set shadingToonyFactor(n){this.uniforms.shadingToonyFactor.value=n}get giEqualizationFactor(){return this.uniforms.giEqualizationFactor.value}set giEqualizationFactor(n){this.uniforms.giEqualizationFactor.value=n}get matcapFactor(){return this.uniforms.matcapFactor.value}set matcapFactor(n){this.uniforms.matcapFactor.value=n}get matcapTexture(){return this.uniforms.matcapTexture.value}set matcapTexture(n){this.uniforms.matcapTexture.value=n}get parametricRimColorFactor(){return this.uniforms.parametricRimColorFactor.value}set parametricRimColorFactor(n){this.uniforms.parametricRimColorFactor.value=n}get rimMultiplyTexture(){return this.uniforms.rimMultiplyTexture.value}set rimMultiplyTexture(n){this.uniforms.rimMultiplyTexture.value=n}get rimLightingMixFactor(){return this.uniforms.rimLightingMixFactor.value}set rimLightingMixFactor(n){this.uniforms.rimLightingMixFactor.value=n}get parametricRimFresnelPowerFactor(){return this.uniforms.parametricRimFresnelPowerFactor.value}set parametricRimFresnelPowerFactor(n){this.uniforms.parametricRimFresnelPowerFactor.value=n}get parametricRimLiftFactor(){return this.uniforms.parametricRimLiftFactor.value}set parametricRimLiftFactor(n){this.uniforms.parametricRimLiftFactor.value=n}get outlineWidthMultiplyTexture(){return this.uniforms.outlineWidthMultiplyTexture.value}set outlineWidthMultiplyTexture(n){this.uniforms.outlineWidthMultiplyTexture.value=n}get outlineWidthFactor(){return this.uniforms.outlineWidthFactor.value}set outlineWidthFactor(n){this.uniforms.outlineWidthFactor.value=n}get outlineColorFactor(){return this.uniforms.outlineColorFactor.value}set outlineColorFactor(n){this.uniforms.outlineColorFactor.value=n}get outlineLightingMixFactor(){return this.uniforms.outlineLightingMixFactor.value}set outlineLightingMixFactor(n){this.uniforms.outlineLightingMixFactor.value=n}get uvAnimationMaskTexture(){return this.uniforms.uvAnimationMaskTexture.value}set uvAnimationMaskTexture(n){this.uniforms.uvAnimationMaskTexture.value=n}get uvAnimationScrollXOffset(){return this.uniforms.uvAnimationScrollXOffset.value}set uvAnimationScrollXOffset(n){this.uniforms.uvAnimationScrollXOffset.value=n}get uvAnimationScrollYOffset(){return this.uniforms.uvAnimationScrollYOffset.value}set uvAnimationScrollYOffset(n){this.uniforms.uvAnimationScrollYOffset.value=n}get uvAnimationRotationPhase(){return this.uniforms.uvAnimationRotationPhase.value}set uvAnimationRotationPhase(n){this.uniforms.uvAnimationRotationPhase.value=n}get ignoreVertexColor(){return this._ignoreVertexColor}set ignoreVertexColor(n){this._ignoreVertexColor=n,this.needsUpdate=!0}get v0CompatShade(){return this._v0CompatShade}set v0CompatShade(n){this._v0CompatShade=n,this.needsUpdate=!0}get debugMode(){return this._debugMode}set debugMode(n){this._debugMode=n,this.needsUpdate=!0}get outlineWidthMode(){return this._outlineWidthMode}set outlineWidthMode(n){this._outlineWidthMode=n,this.needsUpdate=!0}get isOutline(){return this._isOutline}set isOutline(n){this._isOutline=n,this.needsUpdate=!0}get isMToonMaterial(){return!0}update(n){this._uploadUniformsWorkaround(),this._updateUVAnimation(n)}copy(n){return super.copy(n),this.map=n.map,this.normalMap=n.normalMap,this.emissiveMap=n.emissiveMap,this.shadeMultiplyTexture=n.shadeMultiplyTexture,this.shadingShiftTexture=n.shadingShiftTexture,this.matcapTexture=n.matcapTexture,this.rimMultiplyTexture=n.rimMultiplyTexture,this.outlineWidthMultiplyTexture=n.outlineWidthMultiplyTexture,this.uvAnimationMaskTexture=n.uvAnimationMaskTexture,this.normalMapType=n.normalMapType,this.uvAnimationScrollXSpeedFactor=n.uvAnimationScrollXSpeedFactor,this.uvAnimationScrollYSpeedFactor=n.uvAnimationScrollYSpeedFactor,this.uvAnimationRotationSpeedFactor=n.uvAnimationRotationSpeedFactor,this.ignoreVertexColor=n.ignoreVertexColor,this.v0CompatShade=n.v0CompatShade,this.debugMode=n.debugMode,this.outlineWidthMode=n.outlineWidthMode,this.isOutline=n.isOutline,this.needsUpdate=!0,this}_updateUVAnimation(n){this.uniforms.uvAnimationScrollXOffset.value+=n*this.uvAnimationScrollXSpeedFactor,this.uniforms.uvAnimationScrollYOffset.value+=n*this.uvAnimationScrollYSpeedFactor,this.uniforms.uvAnimationRotationPhase.value+=n*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 n=parseInt(Ds,10),e=this.outlineWidthMultiplyTexture!==null,t=this.map!==null||this.normalMap!==null||this.emissiveMap!==null||this.shadeMultiplyTexture!==null||this.shadingShiftTexture!==null||this.rimMultiplyTexture!==null||this.uvAnimationMaskTexture!==null;return{THREE_VRM_THREE_REVISION:n,OUTLINE:this._isOutline,MTOON_USE_UV:e||t,MTOON_UVS_VERTEX_ONLY:e&&!t,V0_COMPAT_SHADE:this._v0CompatShade,USE_SHADEMULTIPLYTEXTURE:this.shadeMultiplyTexture!==null,USE_SHADINGSHIFTTEXTURE:this.shadingShiftTexture!==null,USE_MATCAPTEXTURE:this.matcapTexture!==null,USE_RIMMULTIPLYTEXTURE:this.rimMultiplyTexture!==null,USE_OUTLINEWIDTHMULTIPLYTEXTURE:this._isOutline&&this.outlineWidthMultiplyTexture!==null,USE_UVANIMATIONMASKTEXTURE:this.uvAnimationMaskTexture!==null,IGNORE_VERTEX_COLOR:this._ignoreVertexColor===!0,DEBUG_NORMAL:this._debugMode==="normal",DEBUG_LITSHADERATE:this._debugMode==="litShadeRate",DEBUG_UV:this._debugMode==="uv",OUTLINE_WIDTH_SCREEN:this._isOutline&&this._outlineWidthMode===PN.ScreenCoordinates}}_updateTextureMatrix(n,e){n.value&&(n.value.matrixAutoUpdate&&n.value.updateMatrix(),e.value.copy(n.value.matrix))}},yQ=new Set(["1.0","1.0-beta"]),W8=class R_{get name(){return R_.EXTENSION_NAME}constructor(e,t={}){var i,r,a,s;this.parser=e,this.materialType=(i=t.materialType)!=null?i:xQ,this.renderOrderOffset=(r=t.renderOrderOffset)!=null?r:0,this.v0CompatShade=(a=t.v0CompatShade)!=null?a:!1,this.debugMode=(s=t.debugMode)!=null?s:"none",this._mToonMaterialSet=new Set}beforeRoot(){return Du(this,null,function*(){this._removeUnlitExtensionIfMToonExists()})}afterRoot(e){return Du(this,null,function*(){e.userData.vrmMToonMaterials=Array.from(this._mToonMaterialSet)})}getMaterialType(e){return this._getMToonExtension(e)?this.materialType:null}extendMaterialParams(e,t){const i=this._getMToonExtension(e);return i?this._extendMaterialParams(i,t):null}loadMesh(e){return Du(this,null,function*(){var t;const i=this.parser,a=(t=i.json.meshes)==null?void 0:t[e];if(a==null)throw new Error(`MToonMaterialLoaderPlugin: Attempt to use meshes[${e}] of glTF but the mesh doesn't exist`);const s=a.primitives,o=yield i.loadMesh(e);if(s.length===1){const l=o,h=s[0].material;h!=null&&this._setupPrimitive(l,h)}else{const l=o;for(let h=0;h<s.length;h++){const f=l.children[h],d=s[h].material;d!=null&&this._setupPrimitive(f,d)}}return o})}_removeUnlitExtensionIfMToonExists(){const i=this.parser.json.materials;i==null||i.map((r,a)=>{var s;this._getMToonExtension(a)&&((s=r.extensions)!=null&&s.KHR_materials_unlit)&&delete r.extensions.KHR_materials_unlit})}_getMToonExtension(e){var t,i;const s=(t=this.parser.json.materials)==null?void 0:t[e];if(s==null){console.warn(`MToonMaterialLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}const o=(i=s.extensions)==null?void 0:i[R_.EXTENSION_NAME];if(o==null)return;const l=o.specVersion;if(!yQ.has(l)){console.warn(`MToonMaterialLoaderPlugin: Unknown ${R_.EXTENSION_NAME} specVersion "${l}"`);return}return o}_extendMaterialParams(e,t){return Du(this,null,function*(){var i;delete t.metalness,delete t.roughness;const r=new pQ(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",(i=e.shadingShiftTexture)==null?void 0:i.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 i=this._getMToonExtension(t);if(i){const r=this._parseRenderOrder(i);e.renderOrder=r+this.renderOrderOffset,this._generateOutline(e),this._addToMaterialSet(e);return}}_shouldGenerateOutline(e){return typeof e.outlineWidthMode=="string"&&e.outlineWidthMode!=="none"&&typeof e.outlineWidthFactor=="number"&&e.outlineWidthFactor>0}_generateOutline(e){const t=e.material;if(!(t instanceof jn)||!this._shouldGenerateOutline(t))return;e.material=[t];const i=t.clone();i.name+=" (Outline)",i.isOutline=!0,i.side=Ii,e.material.push(i);const r=e.geometry,a=r.index?r.index.count:r.attributes.position.count/3;r.addGroup(0,a,0),r.addGroup(0,a,1)}_addToMaterialSet(e){const t=e.material,i=new Set;Array.isArray(t)?t.forEach(r=>i.add(r)):i.add(t);for(const r of i)this._mToonMaterialSet.add(r)}_parseRenderOrder(e){var t;return(e.transparentWithZWrite?0:19)+((t=e.renderQueueOffsetNumber)!=null?t:0)}};W8.EXTENSION_NAME="VRMC_materials_mtoon";var SQ=W8,TQ=(n,e,t)=>new Promise((i,r)=>{var a=l=>{try{o(t.next(l))}catch(h){r(h)}},s=l=>{try{o(t.throw(l))}catch(h){r(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((t=t.apply(n,e)).next())}),X8=class FE{get name(){return FE.EXTENSION_NAME}constructor(e){this.parser=e}extendMaterialParams(e,t){return TQ(this,null,function*(){const i=this._getHDREmissiveMultiplierExtension(e);if(i==null)return;console.warn("VRMMaterialsHDREmissiveMultiplierLoaderPlugin: `VRMC_materials_hdr_emissiveMultiplier` is archived. Use `KHR_materials_emissive_strength` instead.");const r=i.emissiveMultiplier;t.emissiveIntensity=r})}_getHDREmissiveMultiplierExtension(e){var t,i;const s=(t=this.parser.json.materials)==null?void 0:t[e];if(s==null){console.warn(`VRMMaterialsHDREmissiveMultiplierLoaderPlugin: Attempt to use materials[${e}] of glTF but the material doesn't exist`);return}const o=(i=s.extensions)==null?void 0:i[FE.EXTENSION_NAME];if(o!=null)return o}};X8.EXTENSION_NAME="VRMC_materials_hdr_emissiveMultiplier";var EQ=X8,MQ=Object.defineProperty,bQ=Object.defineProperties,AQ=Object.getOwnPropertyDescriptors,zN=Object.getOwnPropertySymbols,wQ=Object.prototype.hasOwnProperty,RQ=Object.prototype.propertyIsEnumerable,BN=(n,e,t)=>e in n?MQ(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,qs=(n,e)=>{for(var t in e||(e={}))wQ.call(e,t)&&BN(n,t,e[t]);if(zN)for(var t of zN(e))RQ.call(e,t)&&BN(n,t,e[t]);return n},HN=(n,e)=>bQ(n,AQ(e)),CQ=(n,e,t)=>new Promise((i,r)=>{var a=l=>{try{o(t.next(l))}catch(h){r(h)}},s=l=>{try{o(t.throw(l))}catch(h){r(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((t=t.apply(n,e)).next())});function yf(n){return Math.pow(n,2.2)}var DQ=class{get name(){return"VRMMaterialsV0CompatPlugin"}constructor(n){var e;this.parser=n,this._renderQueueMapTransparent=new Map,this._renderQueueMapTransparentZWrite=new Map;const t=this.parser.json;t.extensionsUsed=(e=t.extensionsUsed)!=null?e:[],t.extensionsUsed.indexOf("KHR_texture_transform")===-1&&t.extensionsUsed.push("KHR_texture_transform")}beforeRoot(){return CQ(this,null,function*(){var n;const e=this.parser.json,t=(n=e.extensions)==null?void 0:n.VRM,i=t==null?void 0:t.materialProperties;i&&(this._populateRenderQueueMap(i),i.forEach((r,a)=>{var s,o;const l=(s=e.materials)==null?void 0:s[a];if(l==null){console.warn(`VRMMaterialsV0CompatPlugin: Attempt to use materials[${a}] of glTF but the material doesn't exist`);return}if(r.shader==="VRM/MToon"){const h=this._parseV0MToonProperties(r,l);e.materials[a]=h}else if((o=r.shader)!=null&&o.startsWith("VRM/Unlit")){const h=this._parseV0UnlitProperties(r,l);e.materials[a]=h}else r.shader==="VRM_USE_GLTFSHADER"||console.warn(`VRMMaterialsV0CompatPlugin: Unknown shader: ${r.shader}`)}))})}_parseV0MToonProperties(n,e){var t,i,r,a,s,o,l,h,f,d,p,g,_,T,y,v,S,E,b,N,R,I,U,O,w,B,j,ee,se,ae,W,te,K,oe,ie,Ce,Xe,nt,tt,gt,ge,Ae,Ze,ue,it,bt,ot,Ke,Te,G,be,Ne,Fe,Be,$e;const Je=(i=(t=n.keywordMap)==null?void 0:t._ALPHABLEND_ON)!=null?i:!1,k=((r=n.floatProperties)==null?void 0:r._ZWrite)===1&&Je,P=this._v0ParseRenderQueue(n),ce=(s=(a=n.keywordMap)==null?void 0:a._ALPHATEST_ON)!=null?s:!1,Ee=Je?"BLEND":ce?"MASK":"OPAQUE",Le=ce?(l=(o=n.floatProperties)==null?void 0:o._Cutoff)!=null?l:.5:void 0,vt=((f=(h=n.floatProperties)==null?void 0:h._CullMode)!=null?f:2)===0,je=this._portTextureTransform(n),xt=((p=(d=n.vectorProperties)==null?void 0:d._Color)!=null?p:[1,1,1,1]).map((D,V)=>V===3?D:yf(D)),pt=(g=n.textureProperties)==null?void 0:g._MainTex,Ie=pt!=null?{index:pt,extensions:qs({},je)}:void 0,He=(T=(_=n.floatProperties)==null?void 0:_._BumpScale)!=null?T:1,ht=(y=n.textureProperties)==null?void 0:y._BumpMap,Q=ht!=null?{index:ht,scale:He,extensions:qs({},je)}:void 0,pe=((S=(v=n.vectorProperties)==null?void 0:v._EmissionColor)!=null?S:[0,0,0,1]).map(yf),Oe=(E=n.textureProperties)==null?void 0:E._EmissionMap,q=Oe!=null?{index:Oe,extensions:qs({},je)}:void 0,ke=((N=(b=n.vectorProperties)==null?void 0:b._ShadeColor)!=null?N:[.97,.81,.86,1]).map(yf),me=(R=n.textureProperties)==null?void 0:R._ShadeTexture,We=me!=null?{index:me,extensions:qs({},je)}:void 0;let Ge=(U=(I=n.floatProperties)==null?void 0:I._ShadeShift)!=null?U:0,we=(w=(O=n.floatProperties)==null?void 0:O._ShadeToony)!=null?w:.9;we=tn.lerp(we,1,.5+.5*Ge),Ge=-Ge-(1-we);const at=(j=(B=n.floatProperties)==null?void 0:B._IndirectLightIntensity)!=null?j:.1,St=at?1-at:void 0,Gt=(ee=n.textureProperties)==null?void 0:ee._SphereAdd,Vt=Gt!=null?[1,1,1]:void 0,li=Gt!=null?{index:Gt}:void 0,ci=(ae=(se=n.floatProperties)==null?void 0:se._RimLightingMix)!=null?ae:0,ho=(W=n.textureProperties)==null?void 0:W._RimTexture,Us=ho!=null?{index:ho,extensions:qs({},je)}:void 0,Ps=((K=(te=n.vectorProperties)==null?void 0:te._RimColor)!=null?K:[0,0,0,1]).map(yf),Mi=(ie=(oe=n.floatProperties)==null?void 0:oe._RimFresnelPower)!=null?ie:1,zs=(Xe=(Ce=n.floatProperties)==null?void 0:Ce._RimLift)!=null?Xe:0,fr=["none","worldCoordinates","screenCoordinates"][(tt=(nt=n.floatProperties)==null?void 0:nt._OutlineWidthMode)!=null?tt:0];let Xi=(ge=(gt=n.floatProperties)==null?void 0:gt._OutlineWidth)!=null?ge:0;Xi=.01*Xi;const Gr=(Ae=n.textureProperties)==null?void 0:Ae._OutlineWidthTexture,On=Gr!=null?{index:Gr,extensions:qs({},je)}:void 0,Ua=((ue=(Ze=n.vectorProperties)==null?void 0:Ze._OutlineColor)!=null?ue:[0,0,0]).map(yf),Hs=((bt=(it=n.floatProperties)==null?void 0:it._OutlineColorMode)!=null?bt:0)===1?(Ke=(ot=n.floatProperties)==null?void 0:ot._OutlineLightingMix)!=null?Ke:1:0,fo=(Te=n.textureProperties)==null?void 0:Te._UvAnimMaskTexture,la=fo!=null?{index:fo,extensions:qs({},je)}:void 0,dr=(be=(G=n.floatProperties)==null?void 0:G._UvAnimScrollX)!=null?be:0;let C=(Fe=(Ne=n.floatProperties)==null?void 0:Ne._UvAnimScrollY)!=null?Fe:0;C!=null&&(C=-C);const z=($e=(Be=n.floatProperties)==null?void 0:Be._UvAnimRotation)!=null?$e:0,Y={specVersion:"1.0",transparentWithZWrite:k,renderQueueOffsetNumber:P,shadeColorFactor:ke,shadeMultiplyTexture:We,shadingShiftFactor:Ge,shadingToonyFactor:we,giEqualizationFactor:St,matcapFactor:Vt,matcapTexture:li,rimLightingMixFactor:ci,rimMultiplyTexture:Us,parametricRimColorFactor:Ps,parametricRimFresnelPowerFactor:Mi,parametricRimLiftFactor:zs,outlineWidthMode:fr,outlineWidthFactor:Xi,outlineWidthMultiplyTexture:On,outlineColorFactor:Ua,outlineLightingMixFactor:Hs,uvAnimationMaskTexture:la,uvAnimationScrollXSpeedFactor:dr,uvAnimationScrollYSpeedFactor:C,uvAnimationRotationSpeedFactor:z};return HN(qs({},e),{pbrMetallicRoughness:{baseColorFactor:xt,baseColorTexture:Ie},normalTexture:Q,emissiveTexture:q,emissiveFactor:pe,alphaMode:Ee,alphaCutoff:Le,doubleSided:vt,extensions:{VRMC_materials_mtoon:Y}})}_parseV0UnlitProperties(n,e){var t,i,r,a,s;const o=n.shader==="VRM/UnlitTransparentZWrite",l=n.shader==="VRM/UnlitTransparent"||o,h=this._v0ParseRenderQueue(n),f=n.shader==="VRM/UnlitCutout",d=l?"BLEND":f?"MASK":"OPAQUE",p=f?(i=(t=n.floatProperties)==null?void 0:t._Cutoff)!=null?i:.5:void 0,g=this._portTextureTransform(n),_=((a=(r=n.vectorProperties)==null?void 0:r._Color)!=null?a:[1,1,1,1]).map(yf),T=(s=n.textureProperties)==null?void 0:s._MainTex,y=T!=null?{index:T,extensions:qs({},g)}:void 0,v={specVersion:"1.0",transparentWithZWrite:o,renderQueueOffsetNumber:h,shadeColorFactor:_,shadeMultiplyTexture:y};return HN(qs({},e),{pbrMetallicRoughness:{baseColorFactor:_,baseColorTexture:y},alphaMode:d,alphaCutoff:p,extensions:{VRMC_materials_mtoon:v}})}_portTextureTransform(n){var e,t,i,r,a;const s=(e=n.vectorProperties)==null?void 0:e._MainTex;if(s==null)return{};const o=[(t=s==null?void 0:s[0])!=null?t:0,(i=s==null?void 0:s[1])!=null?i:0],l=[(r=s==null?void 0:s[2])!=null?r:1,(a=s==null?void 0:s[3])!=null?a:1];return o[1]=1-l[1]-o[1],{KHR_texture_transform:{offset:o,scale:l}}}_v0ParseRenderQueue(n){var e,t;const i=n.shader==="VRM/UnlitTransparentZWrite",r=((e=n.keywordMap)==null?void 0:e._ALPHABLEND_ON)!=null||n.shader==="VRM/UnlitTransparent"||i,a=((t=n.floatProperties)==null?void 0:t._ZWrite)===1||i;let s=0;if(r){const o=n.renderQueue;o!=null&&(a?s=this._renderQueueMapTransparentZWrite.get(o):s=this._renderQueueMapTransparent.get(o))}return s}_populateRenderQueueMap(n){const e=new Set,t=new Set;n.forEach(i=>{var r,a;const s=i.shader==="VRM/UnlitTransparentZWrite",o=((r=i.keywordMap)==null?void 0:r._ALPHABLEND_ON)!=null||i.shader==="VRM/UnlitTransparent"||s,l=((a=i.floatProperties)==null?void 0:a._ZWrite)===1||s;if(o){const h=i.renderQueue;h!=null&&(l?t.add(h):e.add(h))}}),e.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${e.size} render queues for Transparent materials while VRM 1.0 only supports up to 10 render queues. The model might not be rendered correctly.`),t.size>10&&console.warn(`VRMMaterialsV0CompatPlugin: This VRM uses ${t.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(e).sort().forEach((i,r)=>{const a=Math.min(Math.max(r-e.size+1,-9),0);this._renderQueueMapTransparent.set(i,a)}),Array.from(t).sort().forEach((i,r)=>{const a=Math.min(Math.max(r,0),9);this._renderQueueMapTransparentZWrite.set(i,a)})}},FN=(n,e,t)=>new Promise((i,r)=>{var a=l=>{try{o(t.next(l))}catch(h){r(h)}},s=l=>{try{o(t.throw(l))}catch(h){r(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((t=t.apply(n,e)).next())}),Bl=new L,B2=class extends Pr{constructor(n){super(),this._attrPosition=new Ot(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(WU);const e=new Ct;e.setAttribute("position",this._attrPosition);const t=new Bi({color:16711935,depthTest:!1,depthWrite:!1});this._line=new oo(e,t),this.add(this._line),this.constraint=n}updateMatrixWorld(n){Bl.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,Bl.x,Bl.y,Bl.z),this.constraint.source&&Bl.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,Bl.x,Bl.y,Bl.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(n)}};function GN(n,e){return e.set(n.elements[12],n.elements[13],n.elements[14])}var NQ=new L,OQ=new L;function LQ(n,e){return n.decompose(NQ,e,OQ),e}function e1(n){return n.invert?n.invert():n.inverse(),n}var dA=class{constructor(n,e){this.destination=n,this.source=e,this.weight=1}},IQ=new L,UQ=new L,PQ=new L,zQ=new _t,BQ=new _t,HQ=new _t,FQ=class extends dA{get aimAxis(){return this._aimAxis}set aimAxis(n){this._aimAxis=n,this._v3AimAxis.set(n==="PositiveX"?1:n==="NegativeX"?-1:0,n==="PositiveY"?1:n==="NegativeY"?-1:0,n==="PositiveZ"?1:n==="NegativeZ"?-1:0)}get dependencies(){const n=new Set([this.source]);return this.destination.parent&&n.add(this.destination.parent),n}constructor(n,e){super(n,e),this._aimAxis="PositiveX",this._v3AimAxis=new L(1,0,0),this._dstRestQuat=new _t}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);const n=zQ.identity(),e=BQ.identity();this.destination.parent&&(LQ(this.destination.parent.matrixWorld,n),e1(e.copy(n)));const t=IQ.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(n),i=GN(this.source.matrixWorld,UQ).sub(GN(this.destination.matrixWorld,PQ)).normalize(),r=HQ.setFromUnitVectors(t,i).premultiply(e).multiply(n).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function GQ(n,e){const t=[n];let i=n.parent;for(;i!==null;)t.unshift(i),i=i.parent;t.forEach(r=>{e(r)})}var VQ=class{constructor(){this._constraints=new Set,this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(n){this._constraints.add(n);let e=this._objectConstraintsMap.get(n.destination);e==null&&(e=new Set,this._objectConstraintsMap.set(n.destination,e)),e.add(n)}deleteConstraint(n){this._constraints.delete(n),this._objectConstraintsMap.get(n.destination).delete(n)}setInitState(){const n=new Set,e=new Set;for(const t of this._constraints)this._processConstraint(t,n,e,i=>i.setInitState())}update(){const n=new Set,e=new Set;for(const t of this._constraints)this._processConstraint(t,n,e,i=>i.update())}_processConstraint(n,e,t,i){if(t.has(n))return;if(e.has(n))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");e.add(n);const r=n.dependencies;for(const a of r)GQ(a,s=>{const o=this._objectConstraintsMap.get(s);if(o)for(const l of o)this._processConstraint(l,e,t,i)});i(n),t.add(n)}},kQ=new _t,WQ=new _t,XQ=class extends dA{get dependencies(){return new Set([this.source])}constructor(n,e){super(n,e),this._dstRestQuat=new _t,this._invSrcRestQuat=new _t}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),e1(this._invSrcRestQuat.copy(this.source.quaternion))}update(){const n=kQ.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=WQ.copy(this._dstRestQuat).multiply(n);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}},YQ=new L,qQ=new _t,jQ=new _t,ZQ=class extends dA{get rollAxis(){return this._rollAxis}set rollAxis(n){this._rollAxis=n,this._v3RollAxis.set(n==="X"?1:0,n==="Y"?1:0,n==="Z"?1:0)}get dependencies(){return new Set([this.source])}constructor(n,e){super(n,e),this._rollAxis="X",this._v3RollAxis=new L(1,0,0),this._dstRestQuat=new _t,this._invDstRestQuat=new _t,this._invSrcRestQuatMulDstRestQuat=new _t}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),e1(this._invDstRestQuat.copy(this._dstRestQuat)),e1(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){const n=qQ.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=YQ.copy(this._v3RollAxis).applyQuaternion(n),i=jQ.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(n);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}},KQ=new Set(["1.0","1.0-beta"]),Y8=class vm{get name(){return vm.EXTENSION_NAME}constructor(e,t){this.parser=e,this.helperRoot=t==null?void 0:t.helperRoot}afterRoot(e){return FN(this,null,function*(){e.userData.vrmNodeConstraintManager=yield this._import(e)})}_import(e){return FN(this,null,function*(){var t;const i=this.parser.json;if(!(((t=i.extensionsUsed)==null?void 0:t.indexOf(vm.EXTENSION_NAME))!==-1))return null;const a=new VQ,s=yield this.parser.getDependencies("node");return s.forEach((o,l)=>{var h;const f=i.nodes[l],d=(h=f==null?void 0:f.extensions)==null?void 0:h[vm.EXTENSION_NAME];if(d==null)return;const p=d.specVersion;if(!KQ.has(p)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${vm.EXTENSION_NAME} specVersion "${p}"`);return}const g=d.constraint;if(g.roll!=null){const _=this._importRollConstraint(o,s,g.roll);a.addConstraint(_)}else if(g.aim!=null){const _=this._importAimConstraint(o,s,g.aim);a.addConstraint(_)}else if(g.rotation!=null){const _=this._importRotationConstraint(o,s,g.rotation);a.addConstraint(_)}}),e.scene.updateMatrixWorld(),a.setInitState(),a})}_importRollConstraint(e,t,i){const{source:r,rollAxis:a,weight:s}=i,o=t[r],l=new ZQ(e,o);if(a!=null&&(l.rollAxis=a),s!=null&&(l.weight=s),this.helperRoot){const h=new B2(l);this.helperRoot.add(h)}return l}_importAimConstraint(e,t,i){const{source:r,aimAxis:a,weight:s}=i,o=t[r],l=new FQ(e,o);if(a!=null&&(l.aimAxis=a),s!=null&&(l.weight=s),this.helperRoot){const h=new B2(l);this.helperRoot.add(h)}return l}_importRotationConstraint(e,t,i){const{source:r,weight:a}=i,s=t[r],o=new XQ(e,s);if(a!=null&&(o.weight=a),this.helperRoot){const l=new B2(o);this.helperRoot.add(l)}return o}};Y8.EXTENSION_NAME="VRMC_node_constraint";var QQ=Y8,Yv=(n,e,t)=>new Promise((i,r)=>{var a=l=>{try{o(t.next(l))}catch(h){r(h)}},s=l=>{try{o(t.throw(l))}catch(h){r(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((t=t.apply(n,e)).next())}),pA=class{},H2=new L,du=new L,q8=class extends pA{get type(){return"capsule"}constructor(n){var e,t,i,r;super(),this.offset=(e=n==null?void 0:n.offset)!=null?e:new L(0,0,0),this.tail=(t=n==null?void 0:n.tail)!=null?t:new L(0,0,0),this.radius=(i=n==null?void 0:n.radius)!=null?i:0,this.inside=(r=n==null?void 0:n.inside)!=null?r:!1}calculateCollision(n,e,t,i){H2.setFromMatrixPosition(n),du.subVectors(this.tail,this.offset).applyMatrix4(n),du.sub(H2);const r=du.lengthSq();i.copy(e).sub(H2);const a=du.dot(i);a<=0||(r<=a||du.multiplyScalar(a/r),i.sub(du));const s=i.length(),o=this.inside?this.radius-t-s:s-t-this.radius;return o<0&&(i.multiplyScalar(1/s),this.inside&&i.negate()),o}},F2=new L,VN=new Et,j8=class extends pA{get type(){return"plane"}constructor(n){var e,t;super(),this.offset=(e=n==null?void 0:n.offset)!=null?e:new L(0,0,0),this.normal=(t=n==null?void 0:n.normal)!=null?t:new L(0,0,1)}calculateCollision(n,e,t,i){i.setFromMatrixPosition(n),i.negate().add(e),VN.getNormalMatrix(n),F2.copy(this.normal).applyNormalMatrix(VN).normalize();const r=i.dot(F2)-t;return i.copy(F2),r}},JQ=new L,Z8=class extends pA{get type(){return"sphere"}constructor(n){var e,t,i;super(),this.offset=(e=n==null?void 0:n.offset)!=null?e:new L(0,0,0),this.radius=(t=n==null?void 0:n.radius)!=null?t:0,this.inside=(i=n==null?void 0:n.inside)!=null?i:!1}calculateCollision(n,e,t,i){i.subVectors(e,JQ.setFromMatrixPosition(n));const r=i.length(),a=this.inside?this.radius-t-r:r-t-this.radius;return a<0&&(i.multiplyScalar(1/r),this.inside&&i.negate()),a}},js=new L,$Q=class extends Ct{constructor(n){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new L,this._currentTail=new L,this._shape=n,this._attrPos=new Ot(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;const e=this._shape.radius/this.worldScale;this._currentRadius!==e&&(this._currentRadius=e,n=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),n=!0);const t=js.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(t)>1e-10&&(this._currentTail.copy(t),n=!0),n&&this._buildPosition()}_buildPosition(){js.copy(this._currentTail).sub(this._currentOffset);const n=js.length()/this._currentRadius;for(let i=0;i<=16;i++){const r=i/16*Math.PI;this._attrPos.setXYZ(i,-Math.sin(r),-Math.cos(r),0),this._attrPos.setXYZ(17+i,n+Math.sin(r),Math.cos(r),0),this._attrPos.setXYZ(34+i,-Math.sin(r),0,-Math.cos(r)),this._attrPos.setXYZ(51+i,n+Math.sin(r),0,Math.cos(r))}for(let i=0;i<32;i++){const r=i/16*Math.PI;this._attrPos.setXYZ(68+i,0,Math.sin(r),Math.cos(r)),this._attrPos.setXYZ(100+i,n,Math.sin(r),Math.cos(r))}const e=Math.atan2(js.y,Math.sqrt(js.x*js.x+js.z*js.z)),t=-Math.atan2(js.z,js.x);this.rotateZ(e),this.rotateY(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 n=0;n<34;n++){const e=(n+1)%34;this._attrIndex.setXY(n*2,n,e),this._attrIndex.setXY(68+n*2,34+n,34+e)}for(let n=0;n<32;n++){const e=(n+1)%32;this._attrIndex.setXY(136+n*2,68+n,68+e),this._attrIndex.setXY(200+n*2,100+n,100+e)}this._attrIndex.needsUpdate=!0}},eJ=class extends Ct{constructor(n){super(),this.worldScale=1,this._currentOffset=new L,this._currentNormal=new L,this._shape=n,this._attrPos=new Ot(new Float32Array(6*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),n=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),n=!0),n&&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}},tJ=class extends Ct{constructor(n){super(),this.worldScale=1,this._currentRadius=0,this._currentOffset=new L,this._shape=n,this._attrPos=new Ot(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(64*3),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;const e=this._shape.radius/this.worldScale;this._currentRadius!==e&&(this._currentRadius=e,n=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),n=!0),n&&this._buildPosition()}_buildPosition(){for(let n=0;n<32;n++){const e=n/16*Math.PI;this._attrPos.setXYZ(n,Math.cos(e),Math.sin(e),0),this._attrPos.setXYZ(32+n,0,Math.cos(e),Math.sin(e)),this._attrPos.setXYZ(64+n,Math.sin(e),0,Math.cos(e))}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 n=0;n<32;n++){const e=(n+1)%32;this._attrIndex.setXY(n*2,n,e),this._attrIndex.setXY(64+n*2,32+n,32+e),this._attrIndex.setXY(128+n*2,64+n,64+e)}this._attrIndex.needsUpdate=!0}},nJ=new L,G2=class extends Pr{constructor(n){if(super(),this.matrixAutoUpdate=!1,this.collider=n,this.collider.shape instanceof Z8)this._geometry=new tJ(this.collider.shape);else if(this.collider.shape instanceof q8)this._geometry=new $Q(this.collider.shape);else if(this.collider.shape instanceof j8)this._geometry=new eJ(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");const e=new Bi({color:16711935,depthTest:!1,depthWrite:!1});this._line=new aa(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(n){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);const e=this.matrix.elements;this._geometry.worldScale=nJ.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(n)}},iJ=class extends Ct{constructor(n){super(),this.worldScale=1,this._currentRadius=0,this._currentTail=new L,this._springBone=n,this._attrPos=new Ot(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Ot(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let n=!1;const e=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==e&&(this._currentRadius=e,n=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),n=!0),n&&this._buildPosition()}_buildPosition(){for(let n=0;n<32;n++){const e=n/16*Math.PI;this._attrPos.setXYZ(n,Math.cos(e),Math.sin(e),0),this._attrPos.setXYZ(32+n,0,Math.cos(e),Math.sin(e)),this._attrPos.setXYZ(64+n,Math.sin(e),0,Math.cos(e))}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 n=0;n<32;n++){const e=(n+1)%32;this._attrIndex.setXY(n*2,n,e),this._attrIndex.setXY(64+n*2,32+n,32+e),this._attrIndex.setXY(128+n*2,64+n,64+e)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}},rJ=new L,aJ=class extends Pr{constructor(n){super(),this.matrixAutoUpdate=!1,this.springBone=n,this._geometry=new iJ(this.springBone);const e=new Bi({color:16776960,depthTest:!1,depthWrite:!1});this._line=new aa(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(n){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);const e=this.matrix.elements;this._geometry.worldScale=rJ.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(n)}},V2=class extends Wt{constructor(n){super(),this.colliderMatrix=new Ve,this.shape=n}updateWorldMatrix(n,e){super.updateWorldMatrix(n,e),sJ(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function sJ(n,e,t){const i=e.elements;n.copy(e),t&&(n.elements[12]=i[0]*t.x+i[4]*t.y+i[8]*t.z+i[12],n.elements[13]=i[1]*t.x+i[5]*t.y+i[9]*t.z+i[13],n.elements[14]=i[2]*t.x+i[6]*t.y+i[10]*t.z+i[14])}var oJ=new Ve;function lJ(n){return n.invert?n.invert():n.getInverse(oJ.copy(n)),n}var cJ=class{constructor(n){this._inverseCache=new Ve,this._shouldUpdateInverse=!0,this.matrix=n;const e={set:(t,i,r)=>(this._shouldUpdateInverse=!0,t[i]=r,!0)};this._originalElements=n.elements,n.elements=new Proxy(n.elements,e)}get inverse(){return this._shouldUpdateInverse&&(lJ(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}},k2=new Ve,Sf=new L,$p=new L,em=new L,tm=new L,uJ=new Ve,hJ=class{constructor(n,e,t={},i=[]){this._currentTail=new L,this._prevTail=new L,this._boneAxis=new L,this._worldSpaceBoneLength=0,this._center=null,this._initialLocalMatrix=new Ve,this._initialLocalRotation=new _t,this._initialLocalChildPosition=new L;var r,a,s,o,l,h;this.bone=n,this.bone.matrixAutoUpdate=!1,this.child=e,this.settings={hitRadius:(r=t.hitRadius)!=null?r:0,stiffness:(a=t.stiffness)!=null?a:1,gravityPower:(s=t.gravityPower)!=null?s:0,gravityDir:(l=(o=t.gravityDir)==null?void 0:o.clone())!=null?l:new L(0,-1,0),dragForce:(h=t.dragForce)!=null?h:.4},this.colliderGroups=i}get dependencies(){const n=new Set,e=this.bone.parent;e&&n.add(e);for(let t=0;t<this.colliderGroups.length;t++)for(let i=0;i<this.colliderGroups[t].colliders.length;i++)n.add(this.colliderGroups[t].colliders[i]);return n}get center(){return this._center}set center(n){var e;(e=this._center)!=null&&e.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=n,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new cJ(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:k2}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 n=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(n),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 n=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(n),this._prevTail.copy(this._currentTail)}update(n){if(n<=0)return;this._calcWorldSpaceBoneLength();const e=$p.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);tm.copy(this._currentTail).add(Sf.subVectors(this._currentTail,this._prevTail).multiplyScalar(1-this.settings.dragForce)).applyMatrix4(this._getMatrixCenterToWorld()).addScaledVector(e,this.settings.stiffness*n).addScaledVector(this.settings.gravityDir,this.settings.gravityPower*n),em.setFromMatrixPosition(this.bone.matrixWorld),tm.sub(em).normalize().multiplyScalar(this._worldSpaceBoneLength).add(em),this._collision(tm),this._prevTail.copy(this._currentTail),this._currentTail.copy(tm).applyMatrix4(this._getMatrixWorldToCenter());const t=uJ.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,Sf.copy(tm).applyMatrix4(t).normalize()).premultiply(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(n){for(let e=0;e<this.colliderGroups.length;e++)for(let t=0;t<this.colliderGroups[e].colliders.length;t++){const i=this.colliderGroups[e].colliders[t],r=i.shape.calculateCollision(i.colliderMatrix,n,this.settings.hitRadius,Sf);if(r<0){n.addScaledVector(Sf,-r),n.sub(em);const a=n.length();n.multiplyScalar(this._worldSpaceBoneLength/a).add(em)}}}_calcWorldSpaceBoneLength(){Sf.setFromMatrixPosition(this.bone.matrixWorld),this.child?$p.setFromMatrixPosition(this.child.matrixWorld):($p.copy(this._initialLocalChildPosition),$p.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=Sf.sub($p).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:k2}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:k2}};function fJ(n,e){const t=[];let i=n;for(;i!==null;)t.unshift(i),i=i.parent;t.forEach(r=>{e(r)})}function GE(n,e){n.children.forEach(t=>{e(t)||GE(t,e)})}function dJ(n){var e;const t=new Map;for(const i of n){let r=i;do{const a=((e=t.get(r))!=null?e:0)+1;if(a===n.size)return r;t.set(r,a),r=r.parent}while(r!==null)}return null}var kN=class{constructor(){this._joints=new Set,this._sortedJoints=[],this._hasWarnedCircularDependency=!1,this._ancestors=[],this._objectSpringBonesMap=new Map,this._isSortedJointsDirty=!1,this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){const n=new Set;return this._joints.forEach(e=>{e.colliderGroups.forEach(t=>{n.add(t)})}),Array.from(n)}get colliders(){const n=new Set;return this.colliderGroups.forEach(e=>{e.colliders.forEach(t=>{n.add(t)})}),Array.from(n)}addJoint(n){this._joints.add(n);let e=this._objectSpringBonesMap.get(n.bone);e==null&&(e=new Set,this._objectSpringBonesMap.set(n.bone,e)),e.add(n),this._isSortedJointsDirty=!0}addSpringBone(n){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(n)}deleteJoint(n){this._joints.delete(n),this._objectSpringBonesMap.get(n.bone).delete(n),this._isSortedJointsDirty=!0}deleteSpringBone(n){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(n)}setInitState(){this._sortJoints();for(let n=0;n<this._sortedJoints.length;n++){const e=this._sortedJoints[n];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.setInitState()}}reset(){this._sortJoints();for(let n=0;n<this._sortedJoints.length;n++){const e=this._sortedJoints[n];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.reset()}}update(n){this._sortJoints();for(let e=0;e<this._ancestors.length;e++)this._ancestors[e].updateWorldMatrix(e===0,!1);for(let e=0;e<this._sortedJoints.length;e++){const t=this._sortedJoints[e];t.bone.updateMatrix(),t.bone.updateWorldMatrix(!1,!1),t.update(n),GE(t.bone,this._relevantChildrenUpdated)}}_sortJoints(){if(!this._isSortedJointsDirty)return;const n=[],e=new Set,t=new Set,i=new Set;for(const a of this._joints)this._insertJointSort(a,e,t,n,i);this._sortedJoints=n;const r=dJ(i);this._ancestors=[],r&&(this._ancestors.push(r),GE(r,a=>{var s,o;return((o=(s=this._objectSpringBonesMap.get(a))==null?void 0:s.size)!=null?o:0)>0?!0:(this._ancestors.push(a),!1)})),this._isSortedJointsDirty=!1}_insertJointSort(n,e,t,i,r){if(t.has(n))return;if(e.has(n)){this._hasWarnedCircularDependency||(console.warn("VRMSpringBoneManager: Circular dependency detected"),this._hasWarnedCircularDependency=!0);return}e.add(n);const a=n.dependencies;for(const s of a){let o=!1,l=null;fJ(s,h=>{const f=this._objectSpringBonesMap.get(h);if(f)for(const d of f)o=!0,this._insertJointSort(d,e,t,i,r);else o||(l=h)}),l&&r.add(l)}i.push(n),t.add(n)}_relevantChildrenUpdated(n){var e,t;return((t=(e=this._objectSpringBonesMap.get(n))==null?void 0:e.size)!=null?t:0)>0?!0:(n.updateWorldMatrix(!1,!1),!1)}},WN="VRMC_springBone_extended_collider",pJ=new Set(["1.0","1.0-beta"]),mJ=new Set(["1.0"]),K8=class Lf{get name(){return Lf.EXTENSION_NAME}constructor(e,t){var i;this.parser=e,this.jointHelperRoot=t==null?void 0:t.jointHelperRoot,this.colliderHelperRoot=t==null?void 0:t.colliderHelperRoot,this.useExtendedColliders=(i=t==null?void 0:t.useExtendedColliders)!=null?i:!0}afterRoot(e){return Yv(this,null,function*(){e.userData.vrmSpringBoneManager=yield this._import(e)})}_import(e){return Yv(this,null,function*(){const t=yield this._v1Import(e);if(t!=null)return t;const i=yield this._v0Import(e);return i??null})}_v1Import(e){return Yv(this,null,function*(){var t,i,r,a,s;const o=e.parser.json;if(!(((t=o.extensionsUsed)==null?void 0:t.indexOf(Lf.EXTENSION_NAME))!==-1))return null;const h=new kN,f=yield e.parser.getDependencies("node"),d=(i=o.extensions)==null?void 0:i[Lf.EXTENSION_NAME];if(!d)return null;const p=d.specVersion;if(!pJ.has(p))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Lf.EXTENSION_NAME} specVersion "${p}"`),null;const g=(r=d.colliders)==null?void 0:r.map((T,y)=>{var v,S,E,b,N,R,I,U,O,w,B,j,ee,se,ae;const W=f[T.node];if(W==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${y} attempted to use the node #${T.node} but not found`),null;const te=T.shape,K=(v=T.extensions)==null?void 0:v[WN];if(this.useExtendedColliders&&K!=null){const oe=K.specVersion;if(!mJ.has(oe))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${WN} specVersion "${oe}". Fallbacking to the ${Lf.EXTENSION_NAME} definition`);else{const ie=K.shape;if(ie.sphere)return this._importSphereCollider(W,{offset:new L().fromArray((S=ie.sphere.offset)!=null?S:[0,0,0]),radius:(E=ie.sphere.radius)!=null?E:0,inside:(b=ie.sphere.inside)!=null?b:!1});if(ie.capsule)return this._importCapsuleCollider(W,{offset:new L().fromArray((N=ie.capsule.offset)!=null?N:[0,0,0]),radius:(R=ie.capsule.radius)!=null?R:0,tail:new L().fromArray((I=ie.capsule.tail)!=null?I:[0,0,0]),inside:(U=ie.capsule.inside)!=null?U:!1});if(ie.plane)return this._importPlaneCollider(W,{offset:new L().fromArray((O=ie.plane.offset)!=null?O:[0,0,0]),normal:new L().fromArray((w=ie.plane.normal)!=null?w:[0,0,1])})}}if(te.sphere)return this._importSphereCollider(W,{offset:new L().fromArray((B=te.sphere.offset)!=null?B:[0,0,0]),radius:(j=te.sphere.radius)!=null?j:0,inside:!1});if(te.capsule)return this._importCapsuleCollider(W,{offset:new L().fromArray((ee=te.capsule.offset)!=null?ee:[0,0,0]),radius:(se=te.capsule.radius)!=null?se:0,tail:new L().fromArray((ae=te.capsule.tail)!=null?ae:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${y} has no valid shape`)}),_=(a=d.colliderGroups)==null?void 0:a.map((T,y)=>{var v;return{colliders:((v=T.colliders)!=null?v:[]).flatMap(E=>{const b=g==null?void 0:g[E];return b??(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${y} attempted to use a collider #${E} but not found`),[])}),name:T.name}});return(s=d.springs)==null||s.forEach((T,y)=>{var v;const S=T.joints,E=(v=T.colliderGroups)==null?void 0:v.map(R=>{const I=_==null?void 0:_[R];if(I==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${y} attempted to use a colliderGroup ${R} but not found`);return I}),b=T.center!=null?f[T.center]:void 0;let N;S.forEach(R=>{if(N){const I=N.node,U=f[I],O=R.node,w=f[O],B={hitRadius:N.hitRadius,dragForce:N.dragForce,gravityPower:N.gravityPower,stiffness:N.stiffness,gravityDir:N.gravityDir!=null?new L().fromArray(N.gravityDir):void 0},j=this._importJoint(U,w,B,E);b&&(j.center=b),h.addJoint(j)}N=R})}),h.setInitState(),h})}_v0Import(e){return Yv(this,null,function*(){var t,i,r;const a=e.parser.json;if(!(((t=a.extensionsUsed)==null?void 0:t.indexOf("VRM"))!==-1))return null;const o=(i=a.extensions)==null?void 0:i.VRM,l=o==null?void 0:o.secondaryAnimation;if(!l)return null;const h=l==null?void 0:l.boneGroups;if(!h)return null;const f=new kN,d=yield e.parser.getDependencies("node"),p=(r=l.colliderGroups)==null?void 0:r.map(g=>{var _;const T=d[g.node];return{colliders:((_=g.colliders)!=null?_:[]).map((v,S)=>{var E,b,N;const R=new L(0,0,0);return v.offset&&R.set((E=v.offset.x)!=null?E:0,(b=v.offset.y)!=null?b:0,v.offset.z?-v.offset.z:0),this._importSphereCollider(T,{offset:R,radius:(N=v.radius)!=null?N:0,inside:!1})})}});return h==null||h.forEach((g,_)=>{const T=g.bones;T&&T.forEach(y=>{var v,S,E,b;const N=d[y],R=new L;g.gravityDir?R.set((v=g.gravityDir.x)!=null?v:0,(S=g.gravityDir.y)!=null?S:0,(E=g.gravityDir.z)!=null?E:0):R.set(0,-1,0);const I=g.center!=null?d[g.center]:void 0,U={hitRadius:g.hitRadius,dragForce:g.dragForce,gravityPower:g.gravityPower,stiffness:g.stiffiness,gravityDir:R},O=(b=g.colliderGroups)==null?void 0:b.map(w=>{const B=p==null?void 0:p[w];if(B==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${_} attempted to use a colliderGroup ${w} but not found`);return B});N.traverse(w=>{var B;const j=(B=w.children[0])!=null?B:null,ee=this._importJoint(w,j,U,O);I&&(ee.center=I),f.addJoint(ee)})})}),e.scene.updateMatrixWorld(),f.setInitState(),f})}_importJoint(e,t,i,r){const a=new hJ(e,t,i,r);if(this.jointHelperRoot){const s=new aJ(a);this.jointHelperRoot.add(s),s.renderOrder=this.jointHelperRoot.renderOrder}return a}_importSphereCollider(e,t){const i=new Z8(t),r=new V2(i);if(e.add(r),this.colliderHelperRoot){const a=new G2(r);this.colliderHelperRoot.add(a),a.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importCapsuleCollider(e,t){const i=new q8(t),r=new V2(i);if(e.add(r),this.colliderHelperRoot){const a=new G2(r);this.colliderHelperRoot.add(a),a.renderOrder=this.colliderHelperRoot.renderOrder}return r}_importPlaneCollider(e,t){const i=new j8(t),r=new V2(i);if(e.add(r),this.colliderHelperRoot){const a=new G2(r);this.colliderHelperRoot.add(a),a.renderOrder=this.colliderHelperRoot.renderOrder}return r}};K8.EXTENSION_NAME="VRMC_springBone";var gJ=K8,vJ=class{get name(){return"VRMLoaderPlugin"}constructor(n,e){var t,i,r,a,s,o,l,h,f,d;this.parser=n;const p=e==null?void 0:e.helperRoot,g=e==null?void 0:e.autoUpdateHumanBones;this.expressionPlugin=(t=e==null?void 0:e.expressionPlugin)!=null?t:new LK(n),this.firstPersonPlugin=(i=e==null?void 0:e.firstPersonPlugin)!=null?i:new UK(n),this.humanoidPlugin=(r=e==null?void 0:e.humanoidPlugin)!=null?r:new VK(n,{helperRoot:p,autoUpdateHumanBones:g}),this.lookAtPlugin=(a=e==null?void 0:e.lookAtPlugin)!=null?a:new iQ(n,{helperRoot:p}),this.metaPlugin=(s=e==null?void 0:e.metaPlugin)!=null?s:new sQ(n),this.mtoonMaterialPlugin=(o=e==null?void 0:e.mtoonMaterialPlugin)!=null?o:new SQ(n),this.materialsHDREmissiveMultiplierPlugin=(l=e==null?void 0:e.materialsHDREmissiveMultiplierPlugin)!=null?l:new EQ(n),this.materialsV0CompatPlugin=(h=e==null?void 0:e.materialsV0CompatPlugin)!=null?h:new DQ(n),this.springBonePlugin=(f=e==null?void 0:e.springBonePlugin)!=null?f:new gJ(n,{colliderHelperRoot:p,jointHelperRoot:p}),this.nodeConstraintPlugin=(d=e==null?void 0:e.nodeConstraintPlugin)!=null?d:new QQ(n,{helperRoot:p})}beforeRoot(){return kv(this,null,function*(){yield this.materialsV0CompatPlugin.beforeRoot(),yield this.mtoonMaterialPlugin.beforeRoot()})}loadMesh(n){return kv(this,null,function*(){return yield this.mtoonMaterialPlugin.loadMesh(n)})}getMaterialType(n){const e=this.mtoonMaterialPlugin.getMaterialType(n);return e??null}extendMaterialParams(n,e){return kv(this,null,function*(){yield this.materialsHDREmissiveMultiplierPlugin.extendMaterialParams(n,e),yield this.mtoonMaterialPlugin.extendMaterialParams(n,e)})}afterRoot(n){return kv(this,null,function*(){yield this.metaPlugin.afterRoot(n),yield this.humanoidPlugin.afterRoot(n),yield this.expressionPlugin.afterRoot(n),yield this.lookAtPlugin.afterRoot(n),yield this.firstPersonPlugin.afterRoot(n),yield this.springBonePlugin.afterRoot(n),yield this.nodeConstraintPlugin.afterRoot(n),yield this.mtoonMaterialPlugin.afterRoot(n);const e=n.userData.vrmMeta,t=n.userData.vrmHumanoid;if(e&&t){const i=new lQ({scene:n.scene,expressionManager:n.userData.vrmExpressionManager,firstPerson:n.userData.vrmFirstPerson,humanoid:t,lookAt:n.userData.vrmLookAt,meta:e,materials:n.userData.vrmMToonMaterials,springBoneManager:n.userData.vrmSpringBoneManager,nodeConstraintManager:n.userData.vrmNodeConstraintManager});n.userData.vrm=i}})}};function _J(n){const e=new Set;return n.traverse(t=>{if(!t.isMesh)return;const i=t;e.add(i)}),e}function XN(n,e,t){if(e.size===1){const s=e.values().next().value;if(s.weight===1)return n[s.index]}const i=new Float32Array(n[0].count*3);let r=0;if(t)r=1;else for(const s of e)r+=s.weight;for(const s of e){const o=n[s.index],l=s.weight/r;for(let h=0;h<o.count;h++)i[h*3+0]+=o.getX(h)*l,i[h*3+1]+=o.getY(h)*l,i[h*3+2]+=o.getZ(h)*l}return new Ot(i,3)}function xJ(n){var e;const t=_J(n.scene),i=new Map,r=(e=n.expressionManager)==null?void 0:e.expressionMap;if(r!=null)for(const[a,s]of Object.entries(r)){const o=new Set;for(const l of s.binds)if(l instanceof $x){if(l.weight!==0)for(const h of l.primitives){let f=i.get(h);f==null&&(f=new Map,i.set(h,f));let d=f.get(a);d==null&&(d=new Set,f.set(a,d)),d.add(l)}o.add(l)}for(const l of o)s.deleteBind(l)}for(const a of t){const s=i.get(a);if(s==null)continue;const o=a.geometry.morphAttributes;a.geometry.morphAttributes={};const l=a.geometry.clone();a.geometry=l;const h=l.morphTargetsRelative,f=o.position!=null,d=o.normal!=null,p={},g={},_=[];if(f||d){f&&(p.position=[]),d&&(p.normal=[]);let T=0;for(const[y,v]of s)f&&(p.position[T]=XN(o.position,v,h)),d&&(p.normal[T]=XN(o.normal,v,h)),r==null||r[y].addBind(new $x({index:T,weight:1,primitives:[a]})),g[y]=T,_.push(0),T++}l.morphAttributes=p,a.morphTargetDictionary=g,a.morphTargetInfluences=_}}function t1(n,e,t){if(n.getComponent)return n.getComponent(e,t);{let i=n.array[e*n.itemSize+t];return n.normalized&&(i=tn.denormalize(i,n.array)),i}}function Q8(n,e,t,i){n.setComponent?n.setComponent(e,t,i):(n.normalized&&(i=tn.normalize(i,n.array)),n.array[e*n.itemSize+t]=i)}function yJ(n){var e;const t=SJ(n),i=new Set;for(const d of t)i.has(d.geometry)&&(d.geometry=wJ(d.geometry)),i.add(d.geometry);const r=new Map;for(const d of i){const p=d.getAttribute("skinIndex"),g=(e=r.get(p))!=null?e:new Map;r.set(p,g);const _=d.getAttribute("skinWeight"),T=TJ(p,_);g.set(_,T)}const a=new Map;for(const d of t){const p=EJ(d,r);a.set(d,p)}const s=[];for(const[d,p]of a){let g=!1;for(const _ of s)if(MJ(p,_.boneInverseMap)){g=!0,_.meshes.add(d);for(const[y,v]of p)_.boneInverseMap.set(y,v);break}g||s.push({boneInverseMap:p,meshes:new Set([d])})}const o=new Map,l=new W2,h=new W2,f=new W2;for(const d of s){const{boneInverseMap:p,meshes:g}=d,_=Array.from(p.keys()),T=Array.from(p.values()),y=new Rc(_,T),v=h.getOrCreate(y);for(const S of g){const E=S.geometry.getAttribute("skinIndex"),b=l.getOrCreate(E),N=S.skeleton.bones,R=N.map(O=>f.getOrCreate(O)).join(","),I=`${b};${v};${R}`;let U=o.get(I);U==null&&(U=E.clone(),bJ(U,N,_),o.set(I,U)),S.geometry.setAttribute("skinIndex",U)}for(const S of g)S.bind(y,new Ve)}}function SJ(n){const e=new Set;return n.traverse(t=>{if(!t.isSkinnedMesh)return;const i=t;e.add(i)}),e}function TJ(n,e){const t=new Set;for(let i=0;i<n.count;i++)for(let r=0;r<n.itemSize;r++){const a=t1(n,i,r);t1(e,i,r)!==0&&t.add(a)}return t}function EJ(n,e){const t=new Map,i=n.skeleton,r=n.geometry,a=r.getAttribute("skinIndex"),s=r.getAttribute("skinWeight"),o=e.get(a),l=o==null?void 0:o.get(s);if(!l)throw new Error("Unreachable. attributeUsedIndexSetMap does not know the skin index attribute or the skin weight attribute.");for(const h of l)t.set(i.bones[h],i.boneInverses[h]);return t}function MJ(n,e){for(const[t,i]of n.entries()){const r=e.get(t);if(r!=null&&!AJ(i,r))return!1}return!0}function bJ(n,e,t){const i=new Map;for(const a of e)i.set(a,i.size);const r=new Map;for(const[a,s]of t.entries()){const o=i.get(s);r.set(o,a)}for(let a=0;a<n.count;a++)for(let s=0;s<n.itemSize;s++){const o=t1(n,a,s),l=r.get(o);Q8(n,a,s,l)}n.needsUpdate=!0}function AJ(n,e,t){if(t=t||1e-4,n.elements.length!=e.elements.length)return!1;for(let i=0,r=n.elements.length;i<r;i++)if(Math.abs(n.elements[i]-e.elements[i])>t)return!1;return!0}var W2=class{constructor(){this._objectIndexMap=new Map,this._index=0}get(n){return this._objectIndexMap.get(n)}getOrCreate(n){let e=this._objectIndexMap.get(n);return e==null&&(e=this._index,this._objectIndexMap.set(n,e),this._index++),e}};function wJ(n){var e,t,i,r;const a=new Ct;a.name=n.name,a.setIndex(n.index);for(const[s,o]of Object.entries(n.attributes))a.setAttribute(s,o);for(const[s,o]of Object.entries(n.morphAttributes)){const l=s;a.morphAttributes[l]=o.concat()}a.morphTargetsRelative=n.morphTargetsRelative,a.groups=[];for(const s of n.groups)a.addGroup(s.start,s.count,s.materialIndex);return a.boundingSphere=(t=(e=n.boundingSphere)==null?void 0:e.clone())!=null?t:null,a.boundingBox=(r=(i=n.boundingBox)==null?void 0:i.clone())!=null?r:null,a.drawRange.start=n.drawRange.start,a.drawRange.count=n.drawRange.count,a.userData=n.userData,a}function YN(n){if(Object.values(n).forEach(e=>{e!=null&&e.isTexture&&e.dispose()}),n.isShaderMaterial){const e=n.uniforms;e&&Object.values(e).forEach(t=>{const i=t.value;i!=null&&i.isTexture&&i.dispose()})}n.dispose()}function RJ(n){const e=n.geometry;e&&e.dispose();const t=n.skeleton;t&&t.dispose();const i=n.material;i&&(Array.isArray(i)?i.forEach(r=>YN(r)):i&&YN(i))}function CJ(n){n.traverse(RJ)}function DJ(n,e){var t,i;console.warn("VRMUtils.removeUnnecessaryJoints: removeUnnecessaryJoints is deprecated. Use combineSkeletons instead. combineSkeletons contributes more to the performance improvement. This function will be removed in the next major version.");const r=(t=e==null?void 0:e.experimentalSameBoneCounts)!=null?t:!1,a=[];n.traverse(l=>{l.type==="SkinnedMesh"&&a.push(l)});const s=new Map;let o=0;for(const l of a){const f=l.geometry.getAttribute("skinIndex");if(s.has(f))continue;const d=new Map,p=new Map;for(let g=0;g<f.count;g++)for(let _=0;_<f.itemSize;_++){const T=t1(f,g,_);let y=d.get(T);y==null&&(y=d.size,d.set(T,y),p.set(y,T)),Q8(f,g,_,y)}f.needsUpdate=!0,s.set(f,p),o=Math.max(o,d.size)}for(const l of a){const f=l.geometry.getAttribute("skinIndex"),d=s.get(f),p=[],g=[],_=r?o:d.size;for(let y=0;y<_;y++){const v=(i=d.get(y))!=null?i:0;p.push(l.skeleton.bones[v]),g.push(l.skeleton.boneInverses[v])}const T=new Rc(p,g);l.bind(T,new Ve)}}function NJ(n){const e=new Map;n.traverse(t=>{var i,r,a,s;if(!t.isMesh)return;const o=t,l=o.geometry,h=l.index;if(h==null)return;const f=e.get(l);if(f!=null){o.geometry=f;return}const d=Object.values(l.attributes)[0].count,p=new Array(d);let g=0;const _=h.array;for(let b=0;b<_.length;b++){const N=_[b];p[N]||(p[N]=!0,g++)}if(g===d)return;const T=[],y=[];let v=0;for(let b=0;b<p.length;b++)if(p[b]){const N=v++;T[b]=N,y[N]=b}const S=new Ct;S.name=l.name,S.morphTargetsRelative=l.morphTargetsRelative,l.groups.forEach(b=>{S.addGroup(b.start,b.count,b.materialIndex)}),S.boundingBox=(r=(i=l.boundingBox)==null?void 0:i.clone())!=null?r:null,S.boundingSphere=(s=(a=l.boundingSphere)==null?void 0:a.clone())!=null?s:null,S.setDrawRange(l.drawRange.start,l.drawRange.count),S.userData=l.userData,e.set(l,S);{const b=h.array,N=new b.constructor(b.length);for(let R=0;R<b.length;R++){const I=b[R],U=T[I];N[R]=U}S.setIndex(new Ot(N,1,!1))}Object.keys(l.attributes).forEach(b=>{const N=l.attributes[b];if(N.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const R=N.array,{itemSize:I,normalized:U}=N,O=new R.constructor(y.length*I);y.forEach((w,B)=>{for(let j=0;j<I;j++)O[B*I+j]=R[w*I+j]}),S.setAttribute(b,new Ot(O,I,U))});let E=!0;for(const[b,N]of Object.entries(l.morphAttributes)){const R=b;S.morphAttributes[R]=[];for(let I=0;I<N.length;I++){const U=N[I];if(U.isInterleavedBufferAttribute)throw new Error("removeUnnecessaryVertices: InterleavedBufferAttribute is not supported");const O=U.array,{itemSize:w,normalized:B}=U,j=new O.constructor(y.length*w);y.forEach((ee,se)=>{for(let ae=0;ae<w;ae++)j[se*w+ae]=O[ee*w+ae]}),E=E&&j.every(ee=>ee===0),S.morphAttributes[R][I]=new Ot(j,w,B)}}E&&(S.morphAttributes={}),o.geometry=S}),Array.from(e.keys()).forEach(t=>{t.dispose()})}function OJ(n){var e;((e=n.meta)==null?void 0:e.metaVersion)==="0"&&(n.scene.rotation.y=Math.PI)}var vh=class{constructor(){}};vh.combineMorphs=xJ;vh.combineSkeletons=yJ;vh.deepDispose=CJ;vh.removeUnnecessaryJoints=DJ;vh.removeUnnecessaryVertices=NJ;vh.rotateVRM0=OJ;/*!
 * @pixiv/three-vrm-core v3.4.4
 * The implementation of core features of VRM, for @pixiv/three-vrm
 *
 * Copyright (c) 2019-2025 pixiv Inc.
 * @pixiv/three-vrm-core is distributed under MIT License
 * https://github.com/pixiv/three-vrm/blob/release/LICENSE
 *//*!
 * @pixiv/three-vrm-materials-mtoon v3.4.4
 * MToon (toon material) module for @pixiv/three-vrm
 *
 * Copyright (c) 2019-2025 pixiv Inc.
 * @pixiv/three-vrm-materials-mtoon is distributed under MIT License
 * https://github.com/pixiv/three-vrm/blob/release/LICENSE
 *//*!
 * @pixiv/three-vrm-materials-hdr-emissive-multiplier v3.4.4
 * Support VRMC_hdr_emissiveMultiplier for @pixiv/three-vrm
 *
 * Copyright (c) 2019-2025 pixiv Inc.
 * @pixiv/three-vrm-materials-hdr-emissive-multiplier is distributed under MIT License
 * https://github.com/pixiv/three-vrm/blob/release/LICENSE
 *//*!
 * @pixiv/three-vrm-materials-v0compat v3.4.4
 * VRM0.0 materials compatibility layer plugin for @pixiv/three-vrm
 *
 * Copyright (c) 2019-2025 pixiv Inc.
 * @pixiv/three-vrm-materials-v0compat is distributed under MIT License
 * https://github.com/pixiv/three-vrm/blob/release/LICENSE
 *//*!
 * @pixiv/three-vrm-node-constraint v3.4.4
 * Node constraint module for @pixiv/three-vrm
 *
 * Copyright (c) 2019-2025 pixiv Inc.
 * @pixiv/three-vrm-node-constraint is distributed under MIT License
 * https://github.com/pixiv/three-vrm/blob/release/LICENSE
 *//*!
 * @pixiv/three-vrm-springbone v3.4.4
 * Spring bone module for @pixiv/three-vrm
 *
 * Copyright (c) 2019-2025 pixiv Inc.
 * @pixiv/three-vrm-springbone is distributed under MIT License
 * https://github.com/pixiv/three-vrm/blob/release/LICENSE
 *//*!
 * @pixiv/three-vrm-animation v3.4.4
 * The implementation of VRM Animation
 *
 * Copyright (c) 2019-2025 pixiv Inc.
 * @pixiv/three-vrm-animation is distributed under MIT License
 * https://github.com/pixiv/three-vrm/blob/release/LICENSE
 */var qN=(n,e,t)=>new Promise((i,r)=>{var a=l=>{try{o(t.next(l))}catch(h){r(h)}},s=l=>{try{o(t.throw(l))}catch(h){r(h)}},o=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,s);o((t=t.apply(n,e)).next())}),LJ={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"};new qe;new de;new L;new L;var jN={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 IJ(n){return n.invert?n.invert():n.inverse(),n}new L;new L;new L;new L;new L;new L(0,1,0);var UJ=new L,PJ=new L;function zJ(n,e){return n.matrixWorld.decompose(UJ,e,PJ),e}function X2(n){return[Math.atan2(-n.z,n.x),Math.atan2(n.y,Math.sqrt(n.x*n.x+n.z*n.z))]}function ZN(n){const e=Math.round(n/2/Math.PI);return n-2*Math.PI*e}var KN=new L(0,0,1),BJ=new L,HJ=new L,FJ=new L,GJ=new _t,Y2=new _t,QN=new _t,VJ=new _t,q2=new zi,J8=class $8{constructor(e,t){this.offsetFromHeadBone=new L,this.autoUpdate=!0,this.faceFront=new L(0,0,1),this.humanoid=e,this.applier=t,this._yaw=0,this._pitch=0,this._needsUpdate=!0,this._restHeadWorldQuaternion=this.getLookAtWorldQuaternion(new _t)}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 zi)}getEuler(e){return e.set(tn.DEG2RAD*this._pitch,tn.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 $8(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){const t=this.humanoid.getRawBoneNode("head");return zJ(t,e)}getFaceFrontQuaternion(e){if(this.faceFront.distanceToSquared(KN)<.01)return e.copy(this._restHeadWorldQuaternion).invert();const[t,i]=X2(this.faceFront);return q2.set(0,.5*Math.PI+t,i,"YZX"),e.setFromEuler(q2).premultiply(VJ.copy(this._restHeadWorldQuaternion).invert())}getLookAtWorldDirection(e){return this.getLookAtWorldQuaternion(Y2),this.getFaceFrontQuaternion(QN),e.copy(KN).applyQuaternion(Y2).applyQuaternion(QN).applyEuler(this.getEuler(q2))}lookAt(e){const t=GJ.copy(this._restHeadWorldQuaternion).multiply(IJ(this.getLookAtWorldQuaternion(Y2))),i=this.getLookAtWorldPosition(HJ),r=FJ.copy(e).sub(i).applyQuaternion(t).normalize(),[a,s]=X2(this.faceFront),[o,l]=X2(r),h=ZN(o-a),f=ZN(s-l);this._yaw=tn.RAD2DEG*h,this._pitch=tn.RAD2DEG*f,this._needsUpdate=!0}update(e){this.target!=null&&this.autoUpdate&&this.lookAt(this.target.getWorldPosition(BJ)),this._needsUpdate&&(this._needsUpdate=!1,this.applier.applyYawPitch(this._yaw,this._pitch))}};J8.EULER_ORDER="YXZ";var kJ=J8;new L(0,0,1);new zi(0,0,0,"YXZ");var JN=180/Math.PI,j2=new zi,$N=class extends Wt{constructor(n){super(),this.vrmLookAt=n,this.type="VRMLookAtQuaternionProxy";const e=this.rotation._onChangeCallback;this.rotation._onChange(()=>{e(),this._applyToLookAt()});const t=this.quaternion._onChangeCallback;this.quaternion._onChange(()=>{t(),this._applyToLookAt()})}_applyToLookAt(){j2.setFromQuaternion(this.quaternion,kJ.EULER_ORDER),this.vrmLookAt.yaw=JN*j2.y,this.vrmLookAt.pitch=JN*j2.x}};function WJ(n,e,t){var i,r;const a=new Map,s=new Map;for(const[o,l]of n.humanoidTracks.rotation.entries()){const h=(i=e.getNormalizedBoneNode(o))==null?void 0:i.name;if(h!=null){const f=new Sc(`${h}.quaternion`,l.times,l.values.map((d,p)=>t==="0"&&p%2===0?-d:d));s.set(o,f)}}for(const[o,l]of n.humanoidTracks.translation.entries()){const h=(r=e.getNormalizedBoneNode(o))==null?void 0:r.name;if(h!=null){const f=n.restHipsPosition.y,p=e.normalizedRestPose.hips.position[1]/f,g=l.clone();g.values=g.values.map((_,T)=>(t==="0"&&T%3!==1?-_:_)*p),g.name=`${h}.position`,a.set(o,g)}}return{translation:a,rotation:s}}function XJ(n,e){const t=new Map,i=new Map;for(const[r,a]of n.expressionTracks.preset.entries()){const s=e.getExpressionTrackName(r);if(s!=null){const o=a.clone();o.name=s,t.set(r,o)}}for(const[r,a]of n.expressionTracks.custom.entries()){const s=e.getExpressionTrackName(r);if(s!=null){const o=a.clone();o.name=s,i.set(r,o)}}return{preset:t,custom:i}}function YJ(n,e){if(n.lookAtTrack==null)return null;const t=n.lookAtTrack.clone();return t.name=e,t}function qJ(n,e){const t=[],i=WJ(n,e.humanoid,e.meta.metaVersion);if(t.push(...i.translation.values()),t.push(...i.rotation.values()),e.expressionManager!=null){const r=XJ(n,e.expressionManager);t.push(...r.preset.values()),t.push(...r.custom.values())}if(e.lookAt!=null){let r=e.scene.children.find(s=>s instanceof $N);r==null?(console.warn("createVRMAnimationClip: VRMLookAtQuaternionProxy is not found. Creating a new one automatically. To suppress this warning, create a VRMLookAtQuaternionProxy manually"),r=new $N(e.lookAt),r.name="VRMLookAtQuaternionProxy",e.scene.add(r)):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 a=YJ(n,`${r.name}.quaternion`);a!=null&&t.push(a)}return new th("Clip",n.duration,t)}var jJ=class{constructor(){this.duration=0,this.restHipsPosition=new L,this.humanoidTracks={translation:new Map,rotation:new Map},this.expressionTracks={preset:new Map,custom:new Map},this.lookAtTrack=null}};function eO(n,e){const t=n.length,i=[];let r=[],a=0;for(let s=0;s<t;s++){const o=n[s];a<=0&&(a=e,r=[],i.push(r)),r.push(o),a--}return i}var ZJ=new Ve,nm=new L,Z2=new _t,tO=new _t,KJ=new _t,QJ=new Set(["1.0","1.0-draft"]),JJ=new Set(Object.values(LJ)),$J=class{constructor(n){this.parser=n}get name(){return"VRMC_vrm_animation"}afterRoot(n){return qN(this,null,function*(){var e,t,i;const r=n.parser.json,a=r.extensionsUsed;if(a==null||a.indexOf(this.name)==-1)return;const s=(e=r.extensions)==null?void 0:e[this.name];if(s==null)return;const o=s.specVersion;if(o==null)console.warn("VRMAnimationLoaderPlugin: specVersion of the VRMA is not defined. Consider updating the animation file. Assuming the spec version is 1.0.");else{if(!QJ.has(o)){console.warn(`VRMAnimationLoaderPlugin: Unknown VRMC_vrm_animation spec version: ${o}`);return}o==="1.0-draft"&&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(s),h=yield this._createBoneWorldMatrixMap(n,s),f=(i=(t=s.humanoid)==null?void 0:t.humanBones.hips)==null?void 0:i.node,d=f!=null?yield n.parser.getDependency("node",f):null,p=new L;d==null||d.getWorldPosition(p),p.y<.001&&console.warn("VRMAnimationLoaderPlugin: The loaded VRM Animation might violate the VRM T-pose (The y component of the rest hips position is approximately zero or below.)");const _=n.animations.map((T,y)=>{const v=r.animations[y],S=this._parseAnimation(T,v,l,h);return S.restHipsPosition=p,S});n.userData.vrmAnimations=_})}_createNodeMap(n){var e,t,i,r,a;const s=new Map,o=new Map,l=(e=n.humanoid)==null?void 0:e.humanBones;l&&Object.entries(l).forEach(([p,g])=>{const _=g==null?void 0:g.node;_!=null&&s.set(_,p)});const h=(t=n.expressions)==null?void 0:t.preset;h&&Object.entries(h).forEach(([p,g])=>{const _=g==null?void 0:g.node;_!=null&&o.set(_,p)});const f=(i=n.expressions)==null?void 0:i.custom;f&&Object.entries(f).forEach(([p,g])=>{const{node:_}=g;o.set(_,p)});const d=(a=(r=n.lookAt)==null?void 0:r.node)!=null?a:null;return{humanoidIndexToName:s,expressionsIndexToName:o,lookAtIndex:d}}_createBoneWorldMatrixMap(n,e){return qN(this,null,function*(){var t,i;n.scene.updateWorldMatrix(!1,!0);const r=yield n.parser.getDependencies("node"),a=new Map;if(e.humanoid==null)return a;for(const[s,o]of Object.entries(e.humanoid.humanBones)){const l=o==null?void 0:o.node;if(l!=null){const h=r[l];a.set(s,h.matrixWorld),s==="hips"&&a.set("hipsParent",(i=(t=h.parent)==null?void 0:t.matrixWorld)!=null?i:ZJ)}}return a})}_parseAnimation(n,e,t,i){const r=n.tracks,a=e.channels,s=new jJ;return s.duration=n.duration,a.forEach((o,l)=>{const{node:h,path:f}=o.target,d=r[l];if(h==null)return;const p=t.humanoidIndexToName.get(h);if(p!=null){let _=jN[p];for(;_!=null&&i.get(_)==null;)_=jN[_];if(_==null&&(_="hipsParent"),f==="translation")if(p!=="hips")console.warn(`The loading animation contains a translation track for ${p}, which is not permitted in the VRMC_vrm_animation spec. ignoring the track`);else{const T=i.get("hipsParent"),y=eO(d.values,3).flatMap(S=>nm.fromArray(S).applyMatrix4(T).toArray()),v=d.clone();v.values=new Float32Array(y),s.humanoidTracks.translation.set(p,v)}else if(f==="rotation"){const T=i.get(p),y=i.get(_);T.decompose(nm,Z2,nm),Z2.invert(),y.decompose(nm,tO,nm);const v=eO(d.values,4).flatMap(E=>KJ.fromArray(E).premultiply(tO).multiply(Z2).toArray()),S=d.clone();S.values=new Float32Array(v),s.humanoidTracks.rotation.set(p,S)}else throw new Error(`Invalid path "${f}"`);return}const g=t.expressionsIndexToName.get(h);if(g!=null){if(f==="translation"){const _=d.times,T=new Float32Array(d.values.length/3);for(let v=0;v<T.length;v++)T[v]=d.values[3*v];const y=new yc(`${g}.weight`,_,T);JJ.has(g)?s.expressionTracks.preset.set(g,y):s.expressionTracks.custom.set(g,y)}else throw new Error(`Invalid path "${f}"`);return}if(h===t.lookAtIndex)if(f==="rotation")s.lookAtTrack=d;else throw new Error(`Invalid path "${f}"`)}),s}};/*!
 * @pixiv/three-vrm-core v3.4.4
 * The implementation of core features of VRM, for @pixiv/three-vrm
 *
 * Copyright (c) 2019-2025 pixiv Inc.
 * @pixiv/three-vrm-core is distributed under MIT License
 * https://github.com/pixiv/three-vrm/blob/release/LICENSE
 */function n1(){return n1=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},n1.apply(null,arguments)}var e$=Object.defineProperty,t$=(n,e,t)=>e in n?e$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,n$=(n,e,t)=>(t$(n,e+"",t),t);class i${constructor(){n$(this,"_listeners")}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let a=0,s=r.length;a<s;a++)r[a].call(this,e);e.target=null}}}var r$=Object.defineProperty,a$=(n,e,t)=>e in n?r$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Nt=(n,e,t)=>(a$(n,typeof e!="symbol"?e+"":e,t),t);const qv=new Ac,nO=new ko,s$=Math.cos(70*(Math.PI/180)),iO=(n,e)=>(n%e+e)%e;let o$=class extends i${constructor(e,t){super(),Nt(this,"object"),Nt(this,"domElement"),Nt(this,"enabled",!0),Nt(this,"target",new L),Nt(this,"minDistance",0),Nt(this,"maxDistance",1/0),Nt(this,"minZoom",0),Nt(this,"maxZoom",1/0),Nt(this,"minPolarAngle",0),Nt(this,"maxPolarAngle",Math.PI),Nt(this,"minAzimuthAngle",-1/0),Nt(this,"maxAzimuthAngle",1/0),Nt(this,"enableDamping",!1),Nt(this,"dampingFactor",.05),Nt(this,"enableZoom",!0),Nt(this,"zoomSpeed",1),Nt(this,"enableRotate",!0),Nt(this,"rotateSpeed",1),Nt(this,"enablePan",!0),Nt(this,"panSpeed",1),Nt(this,"screenSpacePanning",!0),Nt(this,"keyPanSpeed",7),Nt(this,"zoomToCursor",!1),Nt(this,"autoRotate",!1),Nt(this,"autoRotateSpeed",2),Nt(this,"reverseOrbit",!1),Nt(this,"reverseHorizontalOrbit",!1),Nt(this,"reverseVerticalOrbit",!1),Nt(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Nt(this,"mouseButtons",{LEFT:xu.ROTATE,MIDDLE:xu.DOLLY,RIGHT:xu.PAN}),Nt(this,"touches",{ONE:yu.ROTATE,TWO:yu.DOLLY_PAN}),Nt(this,"target0"),Nt(this,"position0"),Nt(this,"zoom0"),Nt(this,"_domElementKeyEvents",null),Nt(this,"getPolarAngle"),Nt(this,"getAzimuthalAngle"),Nt(this,"setPolarAngle"),Nt(this,"setAzimuthalAngle"),Nt(this,"getDistance"),Nt(this,"getZoomScale"),Nt(this,"listenToKeyEvents"),Nt(this,"stopListenToKeyEvents"),Nt(this,"saveState"),Nt(this,"reset"),Nt(this,"update"),Nt(this,"connect"),Nt(this,"dispose"),Nt(this,"dollyIn"),Nt(this,"dollyOut"),Nt(this,"getScale"),Nt(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>f.phi,this.getAzimuthalAngle=()=>f.theta,this.setPolarAngle=Q=>{let pe=iO(Q,2*Math.PI),Oe=f.phi;Oe<0&&(Oe+=2*Math.PI),pe<0&&(pe+=2*Math.PI);let q=Math.abs(pe-Oe);2*Math.PI-q<q&&(pe<Oe?pe+=2*Math.PI:Oe+=2*Math.PI),d.phi=pe-Oe,i.update()},this.setAzimuthalAngle=Q=>{let pe=iO(Q,2*Math.PI),Oe=f.theta;Oe<0&&(Oe+=2*Math.PI),pe<0&&(pe+=2*Math.PI);let q=Math.abs(pe-Oe);2*Math.PI-q<q&&(pe<Oe?pe+=2*Math.PI:Oe+=2*Math.PI),d.theta=pe-Oe,i.update()},this.getDistance=()=>i.object.position.distanceTo(i.target),this.listenToKeyEvents=Q=>{Q.addEventListener("keydown",ye),this._domElementKeyEvents=Q},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",ye),this._domElementKeyEvents=null},this.saveState=()=>{i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=()=>{i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(r),i.update(),l=o.NONE},this.update=(()=>{const Q=new L,pe=new L(0,1,0),Oe=new _t().setFromUnitVectors(e.up,pe),q=Oe.clone().invert(),ke=new L,me=new _t,We=2*Math.PI;return function(){const we=i.object.position;Oe.setFromUnitVectors(e.up,pe),q.copy(Oe).invert(),Q.copy(we).sub(i.target),Q.applyQuaternion(Oe),f.setFromVector3(Q),i.autoRotate&&l===o.NONE&&se(j()),i.enableDamping?(f.theta+=d.theta*i.dampingFactor,f.phi+=d.phi*i.dampingFactor):(f.theta+=d.theta,f.phi+=d.phi);let at=i.minAzimuthAngle,St=i.maxAzimuthAngle;isFinite(at)&&isFinite(St)&&(at<-Math.PI?at+=We:at>Math.PI&&(at-=We),St<-Math.PI?St+=We:St>Math.PI&&(St-=We),at<=St?f.theta=Math.max(at,Math.min(St,f.theta)):f.theta=f.theta>(at+St)/2?Math.max(at,f.theta):Math.min(St,f.theta)),f.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,f.phi)),f.makeSafe(),i.enableDamping===!0?i.target.addScaledVector(g,i.dampingFactor):i.target.add(g),i.zoomToCursor&&O||i.object.isOrthographicCamera?f.radius=nt(f.radius):f.radius=nt(f.radius*p),Q.setFromSpherical(f),Q.applyQuaternion(q),we.copy(i.target).add(Q),i.object.matrixAutoUpdate||i.object.updateMatrix(),i.object.lookAt(i.target),i.enableDamping===!0?(d.theta*=1-i.dampingFactor,d.phi*=1-i.dampingFactor,g.multiplyScalar(1-i.dampingFactor)):(d.set(0,0,0),g.set(0,0,0));let Gt=!1;if(i.zoomToCursor&&O){let Vt=null;if(i.object instanceof hi&&i.object.isPerspectiveCamera){const li=Q.length();Vt=nt(li*p);const ci=li-Vt;i.object.position.addScaledVector(I,ci),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){const li=new L(U.x,U.y,0);li.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/p)),i.object.updateProjectionMatrix(),Gt=!0;const ci=new L(U.x,U.y,0);ci.unproject(i.object),i.object.position.sub(ci).add(li),i.object.updateMatrixWorld(),Vt=Q.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;Vt!==null&&(i.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(Vt).add(i.object.position):(qv.origin.copy(i.object.position),qv.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(qv.direction))<s$?e.lookAt(i.target):(nO.setFromNormalAndCoplanarPoint(i.object.up,i.target),qv.intersectPlane(nO,i.target))))}else i.object instanceof ao&&i.object.isOrthographicCamera&&(Gt=p!==1,Gt&&(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/p)),i.object.updateProjectionMatrix()));return p=1,O=!1,Gt||ke.distanceToSquared(i.object.position)>h||8*(1-me.dot(i.object.quaternion))>h?(i.dispatchEvent(r),ke.copy(i.object.position),me.copy(i.object.quaternion),Gt=!1,!0):!1}})(),this.connect=Q=>{i.domElement=Q,i.domElement.style.touchAction="none",i.domElement.addEventListener("contextmenu",xt),i.domElement.addEventListener("pointerdown",ct),i.domElement.addEventListener("pointercancel",P),i.domElement.addEventListener("wheel",Le)},this.dispose=()=>{var Q,pe,Oe,q,ke,me;i.domElement&&(i.domElement.style.touchAction="auto"),(Q=i.domElement)==null||Q.removeEventListener("contextmenu",xt),(pe=i.domElement)==null||pe.removeEventListener("pointerdown",ct),(Oe=i.domElement)==null||Oe.removeEventListener("pointercancel",P),(q=i.domElement)==null||q.removeEventListener("wheel",Le),(ke=i.domElement)==null||ke.ownerDocument.removeEventListener("pointermove",k),(me=i.domElement)==null||me.ownerDocument.removeEventListener("pointerup",P),i._domElementKeyEvents!==null&&i._domElementKeyEvents.removeEventListener("keydown",ye)};const i=this,r={type:"change"},a={type:"start"},s={type:"end"},o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=o.NONE;const h=1e-6,f=new EE,d=new EE;let p=1;const g=new L,_=new de,T=new de,y=new de,v=new de,S=new de,E=new de,b=new de,N=new de,R=new de,I=new L,U=new de;let O=!1;const w=[],B={};function j(){return 2*Math.PI/60/60*i.autoRotateSpeed}function ee(){return Math.pow(.95,i.zoomSpeed)}function se(Q){i.reverseOrbit||i.reverseHorizontalOrbit?d.theta+=Q:d.theta-=Q}function ae(Q){i.reverseOrbit||i.reverseVerticalOrbit?d.phi+=Q:d.phi-=Q}const W=(()=>{const Q=new L;return function(Oe,q){Q.setFromMatrixColumn(q,0),Q.multiplyScalar(-Oe),g.add(Q)}})(),te=(()=>{const Q=new L;return function(Oe,q){i.screenSpacePanning===!0?Q.setFromMatrixColumn(q,1):(Q.setFromMatrixColumn(q,0),Q.crossVectors(i.object.up,Q)),Q.multiplyScalar(Oe),g.add(Q)}})(),K=(()=>{const Q=new L;return function(Oe,q){const ke=i.domElement;if(ke&&i.object instanceof hi&&i.object.isPerspectiveCamera){const me=i.object.position;Q.copy(me).sub(i.target);let We=Q.length();We*=Math.tan(i.object.fov/2*Math.PI/180),W(2*Oe*We/ke.clientHeight,i.object.matrix),te(2*q*We/ke.clientHeight,i.object.matrix)}else ke&&i.object instanceof ao&&i.object.isOrthographicCamera?(W(Oe*(i.object.right-i.object.left)/i.object.zoom/ke.clientWidth,i.object.matrix),te(q*(i.object.top-i.object.bottom)/i.object.zoom/ke.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function oe(Q){i.object instanceof hi&&i.object.isPerspectiveCamera||i.object instanceof ao&&i.object.isOrthographicCamera?p=Q:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function ie(Q){oe(p/Q)}function Ce(Q){oe(p*Q)}function Xe(Q){if(!i.zoomToCursor||!i.domElement)return;O=!0;const pe=i.domElement.getBoundingClientRect(),Oe=Q.clientX-pe.left,q=Q.clientY-pe.top,ke=pe.width,me=pe.height;U.x=Oe/ke*2-1,U.y=-(q/me)*2+1,I.set(U.x,U.y,1).unproject(i.object).sub(i.object.position).normalize()}function nt(Q){return Math.max(i.minDistance,Math.min(i.maxDistance,Q))}function tt(Q){_.set(Q.clientX,Q.clientY)}function gt(Q){Xe(Q),b.set(Q.clientX,Q.clientY)}function ge(Q){v.set(Q.clientX,Q.clientY)}function Ae(Q){T.set(Q.clientX,Q.clientY),y.subVectors(T,_).multiplyScalar(i.rotateSpeed);const pe=i.domElement;pe&&(se(2*Math.PI*y.x/pe.clientHeight),ae(2*Math.PI*y.y/pe.clientHeight)),_.copy(T),i.update()}function Ze(Q){N.set(Q.clientX,Q.clientY),R.subVectors(N,b),R.y>0?ie(ee()):R.y<0&&Ce(ee()),b.copy(N),i.update()}function ue(Q){S.set(Q.clientX,Q.clientY),E.subVectors(S,v).multiplyScalar(i.panSpeed),K(E.x,E.y),v.copy(S),i.update()}function it(Q){Xe(Q),Q.deltaY<0?Ce(ee()):Q.deltaY>0&&ie(ee()),i.update()}function bt(Q){let pe=!1;switch(Q.code){case i.keys.UP:K(0,i.keyPanSpeed),pe=!0;break;case i.keys.BOTTOM:K(0,-i.keyPanSpeed),pe=!0;break;case i.keys.LEFT:K(i.keyPanSpeed,0),pe=!0;break;case i.keys.RIGHT:K(-i.keyPanSpeed,0),pe=!0;break}pe&&(Q.preventDefault(),i.update())}function ot(){if(w.length==1)_.set(w[0].pageX,w[0].pageY);else{const Q=.5*(w[0].pageX+w[1].pageX),pe=.5*(w[0].pageY+w[1].pageY);_.set(Q,pe)}}function Ke(){if(w.length==1)v.set(w[0].pageX,w[0].pageY);else{const Q=.5*(w[0].pageX+w[1].pageX),pe=.5*(w[0].pageY+w[1].pageY);v.set(Q,pe)}}function Te(){const Q=w[0].pageX-w[1].pageX,pe=w[0].pageY-w[1].pageY,Oe=Math.sqrt(Q*Q+pe*pe);b.set(0,Oe)}function G(){i.enableZoom&&Te(),i.enablePan&&Ke()}function be(){i.enableZoom&&Te(),i.enableRotate&&ot()}function Ne(Q){if(w.length==1)T.set(Q.pageX,Q.pageY);else{const Oe=ht(Q),q=.5*(Q.pageX+Oe.x),ke=.5*(Q.pageY+Oe.y);T.set(q,ke)}y.subVectors(T,_).multiplyScalar(i.rotateSpeed);const pe=i.domElement;pe&&(se(2*Math.PI*y.x/pe.clientHeight),ae(2*Math.PI*y.y/pe.clientHeight)),_.copy(T)}function Fe(Q){if(w.length==1)S.set(Q.pageX,Q.pageY);else{const pe=ht(Q),Oe=.5*(Q.pageX+pe.x),q=.5*(Q.pageY+pe.y);S.set(Oe,q)}E.subVectors(S,v).multiplyScalar(i.panSpeed),K(E.x,E.y),v.copy(S)}function Be(Q){const pe=ht(Q),Oe=Q.pageX-pe.x,q=Q.pageY-pe.y,ke=Math.sqrt(Oe*Oe+q*q);N.set(0,ke),R.set(0,Math.pow(N.y/b.y,i.zoomSpeed)),ie(R.y),b.copy(N)}function $e(Q){i.enableZoom&&Be(Q),i.enablePan&&Fe(Q)}function Je(Q){i.enableZoom&&Be(Q),i.enableRotate&&Ne(Q)}function ct(Q){var pe,Oe;i.enabled!==!1&&(w.length===0&&((pe=i.domElement)==null||pe.ownerDocument.addEventListener("pointermove",k),(Oe=i.domElement)==null||Oe.ownerDocument.addEventListener("pointerup",P)),pt(Q),Q.pointerType==="touch"?vt(Q):ce(Q))}function k(Q){i.enabled!==!1&&(Q.pointerType==="touch"?je(Q):Ee(Q))}function P(Q){var pe,Oe,q;Ie(Q),w.length===0&&((pe=i.domElement)==null||pe.releasePointerCapture(Q.pointerId),(Oe=i.domElement)==null||Oe.ownerDocument.removeEventListener("pointermove",k),(q=i.domElement)==null||q.ownerDocument.removeEventListener("pointerup",P)),i.dispatchEvent(s),l=o.NONE}function ce(Q){let pe;switch(Q.button){case 0:pe=i.mouseButtons.LEFT;break;case 1:pe=i.mouseButtons.MIDDLE;break;case 2:pe=i.mouseButtons.RIGHT;break;default:pe=-1}switch(pe){case xu.DOLLY:if(i.enableZoom===!1)return;gt(Q),l=o.DOLLY;break;case xu.ROTATE:if(Q.ctrlKey||Q.metaKey||Q.shiftKey){if(i.enablePan===!1)return;ge(Q),l=o.PAN}else{if(i.enableRotate===!1)return;tt(Q),l=o.ROTATE}break;case xu.PAN:if(Q.ctrlKey||Q.metaKey||Q.shiftKey){if(i.enableRotate===!1)return;tt(Q),l=o.ROTATE}else{if(i.enablePan===!1)return;ge(Q),l=o.PAN}break;default:l=o.NONE}l!==o.NONE&&i.dispatchEvent(a)}function Ee(Q){if(i.enabled!==!1)switch(l){case o.ROTATE:if(i.enableRotate===!1)return;Ae(Q);break;case o.DOLLY:if(i.enableZoom===!1)return;Ze(Q);break;case o.PAN:if(i.enablePan===!1)return;ue(Q);break}}function Le(Q){i.enabled===!1||i.enableZoom===!1||l!==o.NONE&&l!==o.ROTATE||(Q.preventDefault(),i.dispatchEvent(a),it(Q),i.dispatchEvent(s))}function ye(Q){i.enabled===!1||i.enablePan===!1||bt(Q)}function vt(Q){switch(He(Q),w.length){case 1:switch(i.touches.ONE){case yu.ROTATE:if(i.enableRotate===!1)return;ot(),l=o.TOUCH_ROTATE;break;case yu.PAN:if(i.enablePan===!1)return;Ke(),l=o.TOUCH_PAN;break;default:l=o.NONE}break;case 2:switch(i.touches.TWO){case yu.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;G(),l=o.TOUCH_DOLLY_PAN;break;case yu.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;be(),l=o.TOUCH_DOLLY_ROTATE;break;default:l=o.NONE}break;default:l=o.NONE}l!==o.NONE&&i.dispatchEvent(a)}function je(Q){switch(He(Q),l){case o.TOUCH_ROTATE:if(i.enableRotate===!1)return;Ne(Q),i.update();break;case o.TOUCH_PAN:if(i.enablePan===!1)return;Fe(Q),i.update();break;case o.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;$e(Q),i.update();break;case o.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Je(Q),i.update();break;default:l=o.NONE}}function xt(Q){i.enabled!==!1&&Q.preventDefault()}function pt(Q){w.push(Q)}function Ie(Q){delete B[Q.pointerId];for(let pe=0;pe<w.length;pe++)if(w[pe].pointerId==Q.pointerId){w.splice(pe,1);return}}function He(Q){let pe=B[Q.pointerId];pe===void 0&&(pe=new de,B[Q.pointerId]=pe),pe.set(Q.pageX,Q.pageY)}function ht(Q){const pe=Q.pointerId===w[0].pointerId?w[1]:w[0];return B[pe.pointerId]}this.dollyIn=(Q=ee())=>{Ce(Q),i.update()},this.dollyOut=(Q=ee())=>{ie(Q),i.update()},this.getScale=()=>p,this.setScale=Q=>{oe(Q),i.update()},this.getZoomScale=()=>ee(),t!==void 0&&this.connect(t),this.update()}};function l$(n,e,t){const i=Ni(g=>g.size),r=Ni(g=>g.viewport),a=typeof n=="number"?n:i.width*r.dpr,s=i.height*r.dpr,o=(typeof n=="number"?t:n)||{},{samples:l=0,depth:h,...f}=o,d=h??o.depthBuffer,p=Me.useMemo(()=>{const g=new xi(a,s,{minFilter:Ht,magFilter:Ht,type:Yn,...f});return d&&(g.depthTexture=new V0(a,s,si)),g.samples=l,g},[]);return Me.useLayoutEffect(()=>{p.setSize(a,s),l&&(p.samples=l)},[l,p,a,s]),Me.useEffect(()=>()=>p.dispose(),[]),p}const c$=n=>typeof n=="function",eP=Me.forwardRef(({envMap:n,resolution:e=256,frames:t=1/0,makeDefault:i,children:r,...a},s)=>{const o=Ni(({set:y})=>y),l=Ni(({camera:y})=>y),h=Ni(({size:y})=>y),f=Me.useRef(null);Me.useImperativeHandle(s,()=>f.current,[]);const d=Me.useRef(null),p=l$(e);Me.useLayoutEffect(()=>{a.manual||(f.current.aspect=h.width/h.height)},[h,a]),Me.useLayoutEffect(()=>{f.current.updateProjectionMatrix()});let g=0,_=null;const T=c$(r);return fl(y=>{T&&(t===1/0||g<t)&&(d.current.visible=!1,y.gl.setRenderTarget(p),_=y.scene.background,n&&(y.scene.background=n),y.gl.render(y.scene,f.current),y.scene.background=_,y.gl.setRenderTarget(null),d.current.visible=!0,g++)}),Me.useLayoutEffect(()=>{if(i){const y=l;return o(()=>({camera:f.current})),()=>o(()=>({camera:y}))}},[f,i,o]),Me.createElement(Me.Fragment,null,Me.createElement("perspectiveCamera",n1({ref:f},a),!T&&r),Me.createElement("group",{ref:d},T&&r(p.texture)))}),u$=Me.forwardRef(({makeDefault:n,camera:e,regress:t,domElement:i,enableDamping:r=!0,keyEvents:a=!1,onChange:s,onStart:o,onEnd:l,...h},f)=>{const d=Ni(R=>R.invalidate),p=Ni(R=>R.camera),g=Ni(R=>R.gl),_=Ni(R=>R.events),T=Ni(R=>R.setEvents),y=Ni(R=>R.set),v=Ni(R=>R.get),S=Ni(R=>R.performance),E=e||p,b=i||_.connected||g.domElement,N=Me.useMemo(()=>new o$(E),[E]);return fl(()=>{N.enabled&&N.update()},-1),Me.useEffect(()=>(a&&N.connect(a===!0?b:a),N.connect(b),()=>void N.dispose()),[a,b,t,N,d]),Me.useEffect(()=>{const R=O=>{d(),t&&S.regress(),s&&s(O)},I=O=>{o&&o(O)},U=O=>{l&&l(O)};return N.addEventListener("change",R),N.addEventListener("start",I),N.addEventListener("end",U),()=>{N.removeEventListener("start",I),N.removeEventListener("end",U),N.removeEventListener("change",R)}},[s,o,l,N,d,T]),Me.useEffect(()=>{if(n){const R=v().controls;return y({controls:N}),()=>y({controls:R})}},[n,N]),Me.createElement("primitive",n1({ref:f,object:N,enableDamping:r},h))});/**
 * postprocessing v6.38.0 build Sat Nov 08 2025
 * https://github.com/pmndrs/postprocessing
 * Copyright 2015-2025 Raoul van Rüschen
 * @license Zlib
 */var K2=1/1e3,h$=1e3,f$=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(n){typeof document<"u"&&document.hidden!==void 0&&(n?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this._autoReset=n)}get delta(){return this._delta*K2}get fixedDelta(){return this._fixedDelta*K2}set fixedDelta(n){this._fixedDelta=n*h$}get elapsed(){return this._elapsed*K2}update(n){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(n!==void 0?n: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(n){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},d$=(()=>{const n=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]),t=new Ct;return t.setAttribute("position",new Ot(n,3)),t.setAttribute("uv",new Ot(e,2)),t})(),Br=class VE{static get fullscreenGeometry(){return d$}constructor(e="Pass",t=new Nd,i=new ao){this.name=e,this.renderer=null,this.scene=t,this.camera=i,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;t!==null&&(t.needsUpdate=!0),this.rtt=!e}}set mainScene(e){}set mainCamera(e){}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(e){let t=this.screen;t!==null?t.material=e:(t=new oi(VE.fullscreenGeometry,e),t.frustumCulled=!1,this.scene===null&&(this.scene=new Nd),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=bc){}render(e,t,i,r,a){throw new Error("Render method not implemented!")}setSize(e,t){}initialize(e,t,i){}dispose(){for(const e of Object.keys(this)){const t=this[e];(t instanceof xi||t instanceof jn||t instanceof Nn||t instanceof VE)&&this[e].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},p$=class extends Br{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(n,e,t,i,r){const a=n.state.buffers.stencil;a.setLocked(!1),a.setTest(!1)}},m$=`#ifdef COLOR_WRITE
#include <common>
#include <dithering_pars_fragment>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#endif
#ifdef DEPTH_WRITE
#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}
#endif
#ifdef USE_WEIGHTS
uniform vec4 channelWeights;
#endif
uniform float opacity;varying vec2 vUv;void main(){
#ifdef COLOR_WRITE
vec4 texel=texture2D(inputBuffer,vUv);
#ifdef USE_WEIGHTS
texel*=channelWeights;
#endif
gl_FragColor=opacity*texel;
#ifdef COLOR_SPACE_CONVERSION
#include <colorspace_fragment>
#endif
#include <dithering_fragment>
#else
gl_FragColor=vec4(0.0);
#endif
#ifdef DEPTH_WRITE
gl_FragDepth=readDepth(vUv);
#endif
}`,mA="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",g$=class extends Vi{constructor(){super({name:"CopyMaterial",defines:{DEPTH_PACKING:"0",COLOR_WRITE:"1"},uniforms:{inputBuffer:new J(null),depthBuffer:new J(null),channelWeights:new J(null),opacity:new J(1)},blending:Er,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:m$,vertexShader:mA}),this.depthFunc=u0}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(n){const e=n!==null;this.colorWrite!==e&&(e?this.defines.COLOR_WRITE=!0:delete this.defines.COLOR_WRITE,this.colorWrite=e,this.needsUpdate=!0),this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){const e=n!==null;this.depthWrite!==e&&(e?this.defines.DEPTH_WRITE=!0:delete this.defines.DEPTH_WRITE,this.depthTest=e,this.depthWrite=e,this.needsUpdate=!0),this.uniforms.depthBuffer.value=n}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}get channelWeights(){return this.uniforms.channelWeights.value}set channelWeights(n){n!==null?(this.defines.USE_WEIGHTS="1",this.uniforms.channelWeights.value=n):delete this.defines.USE_WEIGHTS,this.needsUpdate=!0}setInputBuffer(n){this.uniforms.inputBuffer.value=n}getOpacity(n){return this.uniforms.opacity.value}setOpacity(n){this.uniforms.opacity.value=n}},tP=class extends Br{constructor(n,e=!0){super("CopyPass"),this.fullscreenMaterial=new g$,this.needsSwap=!1,this.renderTarget=n,n===void 0&&(this.renderTarget=new xi(1,1,{minFilter:Ht,magFilter:Ht,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=e}get resize(){return this.autoResize}set resize(n){this.autoResize=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(n){this.autoResize=n}render(n,e,t,i,r){this.fullscreenMaterial.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){this.autoResize&&this.renderTarget.setSize(n,e)}initialize(n,e,t){t!==void 0&&(this.renderTarget.texture.type=t,t!==Pi?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":n!==null&&n.outputColorSpace===dn&&(this.renderTarget.texture.colorSpace=dn))}},rO=new qe,nP=class extends Br{constructor(n=!0,e=!0,t=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=n,this.depth=e,this.stencil=t,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(n,e,t){this.color=n,this.depth=e,this.stencil=t}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(n){this.overrideClearColor=n}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(n){this.overrideClearAlpha=n}render(n,e,t,i,r){const a=this.overrideClearColor,s=this.overrideClearAlpha,o=n.getClearAlpha(),l=a!==null,h=s>=0;l?(n.getClearColor(rO),n.setClearColor(a,h?s:o)):h&&n.setClearAlpha(s),n.setRenderTarget(this.renderToScreen?null:e),n.clear(this.color,this.depth,this.stencil),l?n.setClearColor(rO,o):h&&n.setClearAlpha(o)}},v$=class extends Br{constructor(n,e){super("MaskPass",n,e),this.needsSwap=!1,this.clearPass=new nP(!1,!1,!0),this.inverse=!1}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get inverted(){return this.inverse}set inverted(n){this.inverse=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(n){this.inverted=n}render(n,e,t,i,r){const a=n.getContext(),s=n.state.buffers,o=this.scene,l=this.camera,h=this.clearPass,f=this.inverted?0:1,d=1-f;s.color.setMask(!1),s.depth.setMask(!1),s.color.setLocked(!0),s.depth.setLocked(!0),s.stencil.setTest(!0),s.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),s.stencil.setFunc(a.ALWAYS,f,4294967295),s.stencil.setClear(d),s.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?h.render(n,null):(h.render(n,e),h.render(n,t))),this.renderToScreen?(n.setRenderTarget(null),n.render(o,l)):(n.setRenderTarget(e),n.render(o,l),n.setRenderTarget(t),n.render(o,l)),s.color.setLocked(!1),s.depth.setLocked(!1),s.stencil.setLocked(!1),s.stencil.setFunc(a.EQUAL,1,4294967295),s.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),s.stencil.setLocked(!0)}},_$=class{constructor(n=null,{depthBuffer:e=!0,stencilBuffer:t=!1,multisampling:i=0,frameBufferType:r}={}){this.renderer=null,this.inputBuffer=this.createBuffer(e,t,r,i),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new tP,this.depthTexture=null,this.passes=[],this.timer=new f$,this.autoRenderToScreen=!0,this.setRenderer(n)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(n){const e=this.inputBuffer,t=this.multisampling;t>0&&n>0?(this.inputBuffer.samples=n,this.outputBuffer.samples=n,this.inputBuffer.dispose(),this.outputBuffer.dispose()):t!==n&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(e.depthBuffer,e.stencilBuffer,e.texture.type,n),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(n){if(this.renderer=n,n!==null){const e=n.getSize(new de),t=n.getContext().getContextAttributes().alpha,i=this.inputBuffer.texture.type;i===Pi&&n.outputColorSpace===dn&&(this.inputBuffer.texture.colorSpace=dn,this.outputBuffer.texture.colorSpace=dn,this.inputBuffer.dispose(),this.outputBuffer.dispose()),n.autoClear=!1,this.setSize(e.width,e.height);for(const r of this.passes)r.initialize(n,t,i)}}replaceRenderer(n,e=!0){const t=this.renderer,i=t.domElement.parentNode;return this.setRenderer(n),e&&i!==null&&(i.removeChild(t.domElement),i.appendChild(n.domElement)),t}createDepthTexture(){const n=this.depthTexture=new V0;return this.inputBuffer.depthTexture=n,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(n.format=Qu,n.type=Ku):n.type=Os,n}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(const n of this.passes)n.setDepthTexture(null)}}createBuffer(n,e,t,i){const r=this.renderer,a=r===null?new de:r.getDrawingBufferSize(new de),s={minFilter:Ht,magFilter:Ht,stencilBuffer:e,depthBuffer:n,type:t},o=new xi(a.width,a.height,s);return i>0&&(o.samples=i),t===Pi&&r!==null&&r.outputColorSpace===dn&&(o.texture.colorSpace=dn),o.texture.name="EffectComposer.Buffer",o.texture.generateMipmaps=!1,o}setMainScene(n){for(const e of this.passes)e.mainScene=n}setMainCamera(n){for(const e of this.passes)e.mainCamera=n}addPass(n,e){const t=this.passes,i=this.renderer,r=i.getDrawingBufferSize(new de),a=i.getContext().getContextAttributes().alpha,s=this.inputBuffer.texture.type;if(n.setRenderer(i),n.setSize(r.width,r.height),n.initialize(i,a,s),this.autoRenderToScreen&&(t.length>0&&(t[t.length-1].renderToScreen=!1),n.renderToScreen&&(this.autoRenderToScreen=!1)),e!==void 0?t.splice(e,0,n):t.push(n),this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!0),n.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){const o=this.createDepthTexture();for(n of t)n.setDepthTexture(o)}else n.setDepthTexture(this.depthTexture)}removePass(n){const e=this.passes,t=e.indexOf(n);if(t!==-1&&e.splice(t,1).length>0){if(this.depthTexture!==null){const a=(o,l)=>o||l.needsDepthTexture;e.reduce(a,!1)||(n.getDepthTexture()===this.depthTexture&&n.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&t===e.length&&(n.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){const n=this.passes;this.deleteDepthTexture(),n.length>0&&(this.autoRenderToScreen&&(n[n.length-1].renderToScreen=!1),this.passes=[])}render(n){const e=this.renderer,t=this.copyPass;let i=this.inputBuffer,r=this.outputBuffer,a=!1,s,o,l;n===void 0&&(this.timer.update(),n=this.timer.getDelta());for(const h of this.passes)h.enabled&&(h.render(e,i,r,n,a),h.needsSwap&&(a&&(t.renderToScreen=h.renderToScreen,s=e.getContext(),o=e.state.buffers.stencil,o.setFunc(s.NOTEQUAL,1,4294967295),t.render(e,i,r,n,a),o.setFunc(s.EQUAL,1,4294967295)),l=i,i=r,r=l),h instanceof v$?a=!0:h instanceof p$&&(a=!1))}setSize(n,e,t){const i=this.renderer,r=i.getSize(new de);(n===void 0||e===void 0)&&(n=r.width,e=r.height),(r.width!==n||r.height!==e)&&i.setSize(n,e,t);const a=i.getDrawingBufferSize(new de);this.inputBuffer.setSize(a.width,a.height),this.outputBuffer.setSize(a.width,a.height);for(const s of this.passes)s.setSize(a.width,a.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(const n of this.passes)n.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose(),Br.fullscreenGeometry.dispose()}},tl={NONE:0,DEPTH:1,CONVOLUTION:2},xn={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"},x$=class{constructor(){this.shaderParts=new Map([[xn.FRAGMENT_HEAD,null],[xn.FRAGMENT_MAIN_UV,null],[xn.FRAGMENT_MAIN_IMAGE,null],[xn.VERTEX_HEAD,null],[xn.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=tl.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=Fn}},Q2=!1,aO=class{constructor(n=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(n),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case cr:t=this.materialsFlatShadedDoubleSide;break;case Ii:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case cr:t=this.materialsDoubleSide;break;case Ii:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}cloneMaterial(n){if(!(n instanceof Vi))return n.clone();const e=n.uniforms,t=new Map;for(const r in e){const a=e[r].value;a.isRenderTargetTexture&&(e[r].value=null,t.set(r,a))}const i=n.clone();for(const r of t)e[r[0]].value=r[1],i.uniforms[r[0]].value=r[1];return i}setMaterial(n){if(this.disposeMaterials(),this.material=n,n!==null){const e=this.materials=[this.cloneMaterial(n),this.cloneMaterial(n),this.cloneMaterial(n)];for(const t of e)t.uniforms=Object.assign({},n.uniforms),t.side=Ns;e[2].skinning=!0,this.materialsBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=Ii,i}),this.materialsDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=cr,i}),this.materialsFlatShaded=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i}),this.materialsFlatShadedBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=Ii,i}),this.materialsFlatShadedDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=cr,i})}}render(n,e,t){const i=n.shadowMap.enabled;if(n.shadowMap.enabled=!1,Q2){const r=this.originalMaterials;this.meshCount=0,e.traverse(this.replaceMaterial),n.render(e,t);for(const a of r)a[0].material=a[1];this.meshCount!==r.size&&r.clear()}else{const r=e.overrideMaterial;e.overrideMaterial=this.material,n.render(e,t),e.overrideMaterial=r}n.shadowMap.enabled=i}disposeMaterials(){if(this.material!==null){const n=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(const e of n)e.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return Q2}static set workaroundEnabled(n){Q2=n}},Hl=-1,os=class extends ra{constructor(n,e=Hl,t=Hl,i=1){super(),this.resizable=n,this.baseSize=new de(1,1),this.preferredSize=new de(e,t),this.target=this.preferredSize,this.s=i,this.effectiveSize=new de,this.addEventListener("change",()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){const n=this.baseSize,e=this.preferredSize,t=this.effectiveSize,i=this.scale;e.width!==Hl?t.width=e.width:e.height!==Hl?t.width=Math.round(e.height*(n.width/Math.max(n.height,1))):t.width=Math.round(n.width*i),e.height!==Hl?t.height=e.height:e.width!==Hl?t.height=Math.round(e.width/Math.max(n.width/Math.max(n.height,1),1)):t.height=Math.round(n.height*i)}get width(){return this.effectiveSize.width}set width(n){this.preferredWidth=n}get height(){return this.effectiveSize.height}set height(n){this.preferredHeight=n}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(n){this.s!==n&&(this.s=n,this.preferredSize.setScalar(Hl),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getScale(){return this.scale}setScale(n){this.scale=n}get baseWidth(){return this.baseSize.width}set baseWidth(n){this.baseSize.width!==n&&(this.baseSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseWidth(){return this.baseWidth}setBaseWidth(n){this.baseWidth=n}get baseHeight(){return this.baseSize.height}set baseHeight(n){this.baseSize.height!==n&&(this.baseSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(n){this.baseHeight=n}setBaseSize(n,e){(this.baseSize.width!==n||this.baseSize.height!==e)&&(this.baseSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(n){this.preferredSize.width!==n&&(this.preferredSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(n){this.preferredWidth=n}get preferredHeight(){return this.preferredSize.height}set preferredHeight(n){this.preferredSize.height!==n&&(this.preferredSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(n){this.preferredHeight=n}setPreferredSize(n,e){(this.preferredSize.width!==n||this.preferredSize.height!==e)&&(this.preferredSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}copy(n){this.s=n.scale,this.baseSize.set(n.baseWidth,n.baseHeight),this.preferredSize.set(n.preferredWidth,n.preferredHeight),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height)}static get AUTO_SIZE(){return Hl}},ln={ADD:0,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},y$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb+y.rgb,y.a),y.a*opacity);}",S$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4((x.rgb+y.rgb)*0.5,y.a),y.a*opacity);}",T$="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.xy,xHSL.z));return mix(x,vec4(z,y.a),y.a*opacity);}",E$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb,b=y.rgb;vec3 z=mix(step(0.0,b)*(1.0-min(vec3(1.0),(1.0-a)/b)),vec3(1.0),step(1.0,a));return mix(x,vec4(z,y.a),y.a*opacity);}",M$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb,b=y.rgb;vec3 z=step(0.0,a)*mix(min(vec3(1.0),a/max(1.0-b,1e-9)),vec3(1.0),step(1.0,b));return mix(x,vec4(z,y.a),y.a*opacity);}",b$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(min(x.rgb,y.rgb),y.a),y.a*opacity);}",A$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(abs(x.rgb-y.rgb),y.a),y.a*opacity);}",w$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb/max(y.rgb,1e-12),y.a),y.a*opacity);}",R$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4((x.rgb+y.rgb-2.0*x.rgb*y.rgb),y.a),y.a*opacity);}",C$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=min(x.rgb,1.0);vec3 b=min(y.rgb,1.0);vec3 z=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,b));return mix(x,vec4(z,y.a),y.a*opacity);}",D$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(step(1.0,x.rgb+y.rgb),y.a),y.a*opacity);}",N$="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.x,xHSL.yz));return mix(x,vec4(z,y.a),y.a*opacity);}",O$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(1.0-y.rgb,y.a),y.a*opacity);}",L$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(y.rgb*(1.0-x.rgb),y.a),y.a*opacity);}",I$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(max(x.rgb,y.rgb),y.a),y.a*opacity);}",U$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(clamp(y.rgb+x.rgb-1.0,0.0,1.0),y.a),y.a*opacity);}",P$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(min(x.rgb+y.rgb,1.0),y.a),y.a*opacity);}",z$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(clamp(2.0*y.rgb+x.rgb-1.0,0.0,1.0),y.a),y.a*opacity);}",B$="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.xy,yHSL.z));return mix(x,vec4(z,y.a),y.a*opacity);}",H$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb*y.rgb,y.a),y.a*opacity);}",F$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(1.0-abs(1.0-x.rgb-y.rgb),y.a),y.a*opacity);}",G$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,y.a*opacity);}",V$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(2.0*y.rgb*x.rgb,1.0-2.0*(1.0-y.rgb)*(1.0-x.rgb),step(0.5,x.rgb));return mix(x,vec4(z,y.a),y.a*opacity);}",k$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 y2=2.0*y.rgb;vec3 z=mix(mix(y2,x.rgb,step(0.5*x.rgb,y.rgb)),max(y2-1.0,vec3(0.0)),step(x.rgb,y2-1.0));return mix(x,vec4(z,y.a),y.a*opacity);}",W$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(min(x.rgb*x.rgb/max(1.0-y.rgb,1e-12),1.0),y.rgb,step(1.0,y.rgb));return mix(x,vec4(z,y.a),y.a*opacity);}",X$="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.x,yHSL.y,xHSL.z));return mix(x,vec4(z,y.a),y.a*opacity);}",Y$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(x.rgb+y.rgb-min(x.rgb*y.rgb,1.0),y.a),y.a*opacity);}",q$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 a=x.rgb;vec3 b=y.rgb;vec3 y2=2.0*b;vec3 w=step(0.5,b);vec3 c=a-(1.0-y2)*a*(1.0-a);vec3 d=mix(a+(y2-1.0)*(sqrt(a)-a),a+(y2-1.0)*a*((16.0*a-12.0)*a+3.0),w*(1.0-step(0.25,a)));vec3 z=mix(c,d,w);return mix(x,vec4(z,y.a),y.a*opacity);}",j$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y;}",Z$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,vec4(max(x.rgb+y.rgb-1.0,0.0),y.a),y.a*opacity);}",K$="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec3 z=mix(max(1.0-min((1.0-x.rgb)/(2.0*y.rgb),1.0),0.0),min(x.rgb/(2.0*(1.0-y.rgb)),1.0),step(0.5,y.rgb));return mix(x,vec4(z,y.a),y.a*opacity);}",Q$=new Map([[ln.ADD,y$],[ln.AVERAGE,S$],[ln.COLOR,T$],[ln.COLOR_BURN,E$],[ln.COLOR_DODGE,M$],[ln.DARKEN,b$],[ln.DIFFERENCE,A$],[ln.DIVIDE,w$],[ln.DST,null],[ln.EXCLUSION,R$],[ln.HARD_LIGHT,C$],[ln.HARD_MIX,D$],[ln.HUE,N$],[ln.INVERT,O$],[ln.INVERT_RGB,L$],[ln.LIGHTEN,I$],[ln.LINEAR_BURN,U$],[ln.LINEAR_DODGE,P$],[ln.LINEAR_LIGHT,z$],[ln.LUMINOSITY,B$],[ln.MULTIPLY,H$],[ln.NEGATION,F$],[ln.NORMAL,G$],[ln.OVERLAY,V$],[ln.PIN_LIGHT,k$],[ln.REFLECT,W$],[ln.SATURATION,X$],[ln.SCREEN,Y$],[ln.SOFT_LIGHT,q$],[ln.SRC,j$],[ln.SUBTRACT,Z$],[ln.VIVID_LIGHT,K$]]),J$=class extends ra{constructor(n,e=1){super(),this._blendFunction=n,this.opacity=new J(e)}getOpacity(){return this.opacity.value}setOpacity(n){this.opacity.value=n}get blendFunction(){return this._blendFunction}set blendFunction(n){this._blendFunction=n,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(n){this.blendFunction=n}getShaderCode(){return Q$.get(this.blendFunction)}},T0=class extends ra{constructor(n,e,{attributes:t=tl.NONE,blendFunction:i=ln.NORMAL,defines:r=new Map,uniforms:a=new Map,extensions:s=null,vertexShader:o=null}={}){super(),this.name=n,this.renderer=null,this.attributes=t,this.fragmentShader=e,this.vertexShader=o,this.defines=r,this.uniforms=a,this.extensions=s,this.blendMode=new J$(i),this.blendMode.addEventListener("change",l=>this.setChanged()),this._inputColorSpace=Fn,this._outputColorSpace=Or}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(n){this._inputColorSpace=n,this.setChanged()}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(n){this._outputColorSpace=n,this.setChanged()}set mainScene(n){}set mainCamera(n){}getName(){return this.name}setRenderer(n){this.renderer=n}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(n){this.attributes=n,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(n){this.fragmentShader=n,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(n){this.vertexShader=n,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(n,e=bc){}update(n,e,t){}setSize(n,e){}initialize(n,e,t){}dispose(){for(const n of Object.keys(this)){const e=this[n];(e instanceof xi||e instanceof jn||e instanceof Nn||e instanceof Br)&&this[n].dispose()}}},$$=`#include <common>
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#ifdef RANGE
uniform vec2 range;
#elif defined(THRESHOLD)
uniform float threshold;uniform float smoothing;
#endif
varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);float mask=1.0;
#ifdef RANGE
float low=step(range.x,l);float high=step(l,range.y);mask=low*high;
#elif defined(THRESHOLD)
mask=smoothstep(threshold,threshold+smoothing,l);
#endif
#ifdef COLOR
gl_FragColor=texel*mask;
#else
gl_FragColor=vec4(l*mask);
#endif
}`,eee=class extends Vi{constructor(n=!1,e=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:Ds.replace(/\D+/g,"")},uniforms:{inputBuffer:new J(null),threshold:new J(0),smoothing:new J(1),range:new J(null)},blending:Er,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:$$,vertexShader:mA}),this.colorOutput=n,this.luminanceRange=e}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get threshold(){return this.uniforms.threshold.value}set threshold(n){this.smoothing>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=n}getThreshold(){return this.threshold}setThreshold(n){this.threshold=n}get smoothing(){return this.uniforms.smoothing.value}set smoothing(n){this.threshold>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=n}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(n){this.smoothing=n}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(n){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(n){n?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(n){return this.colorOutput}setColorOutputEnabled(n){this.colorOutput=n}get useRange(){return this.luminanceRange!==null}set useRange(n){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(n){n!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=n,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(n){this.luminanceRange=n}},tee=class extends Br{constructor({renderTarget:n,luminanceRange:e,colorOutput:t,resolutionScale:i=1,width:r=os.AUTO_SIZE,height:a=os.AUTO_SIZE,resolutionX:s=r,resolutionY:o=a}={}){super("LuminancePass"),this.fullscreenMaterial=new eee(t,e),this.needsSwap=!1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new xi(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target");const l=this.resolution=new os(this,s,o,i);l.addEventListener("change",h=>this.setSize(l.baseWidth,l.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(n,e,t,i,r){const a=this.fullscreenMaterial;a.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}initialize(n,e,t){t!==void 0&&t!==Pi&&(this.renderTarget.texture.type=t,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},kE=class extends Br{constructor(n,e="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=n,this.input=e}setInput(n){this.input=n}render(n,e,t,i,r){const a=this.fullscreenMaterial.uniforms;e!==null&&a!==void 0&&a[this.input]!==void 0&&(a[this.input].value=e.texture),n.setRenderTarget(this.renderToScreen?null:t),n.render(this.scene,this.camera)}initialize(n,e,t){t!==void 0&&t!==Pi&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},gA=class extends Br{constructor(n,e,t=null){super("RenderPass",n,e),this.needsSwap=!1,this.clearPass=new nP,this.overrideMaterialManager=t===null?null:new aO(t),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get renderToScreen(){return super.renderToScreen}set renderToScreen(n){super.renderToScreen=n,this.clearPass.renderToScreen=n}get overrideMaterial(){const n=this.overrideMaterialManager;return n!==null?n.material:null}set overrideMaterial(n){const e=this.overrideMaterialManager;n!==null?e!==null?e.setMaterial(n):this.overrideMaterialManager=new aO(n):e!==null&&(e.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(n){this.overrideMaterial=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getSelection(){return this.selection}setSelection(n){this.selection=n}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(n){this.ignoreBackground=n}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(n){this.skipShadowMapUpdate=n}getClearPass(){return this.clearPass}render(n,e,t,i,r){const a=this.scene,s=this.camera,o=this.selection,l=s.layers.mask,h=a.background,f=n.shadowMap.autoUpdate,d=this.renderToScreen?null:e;o!==null&&s.layers.set(o.getLayer()),this.skipShadowMapUpdate&&(n.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(a.background=null),this.clearPass.enabled&&this.clearPass.render(n,e),n.setRenderTarget(d),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(n,a,s):n.render(a,s),s.layers.mask=l,a.background=h,n.shadowMap.autoUpdate=f}},jr={LINEAR:0,REINHARD:1,REINHARD2:2,REINHARD2_ADAPTIVE:3,OPTIMIZED_CINEON:5,CINEON:5,ACES_FILMIC:6,AGX:7,NEUTRAL:8},nee=`#include <packing>
#ifdef GL_FRAGMENT_PRECISION_HIGH
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
#ifdef DOWNSAMPLE_NORMALS
uniform lowp sampler2D normalBuffer;
#endif
varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
return unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
return texture2D(depthBuffer,uv).r;
#endif
}int findBestDepth(const in float samples[4]){float c=(samples[0]+samples[1]+samples[2]+samples[3])*0.25;float distances[4];distances[0]=abs(c-samples[0]);distances[1]=abs(c-samples[1]);distances[2]=abs(c-samples[2]);distances[3]=abs(c-samples[3]);float maxDistance=max(max(distances[0],distances[1]),max(distances[2],distances[3]));int remaining[3];int rejected[3];int i,j,k;for(i=0,j=0,k=0;i<4;++i){if(distances[i]<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);
#ifdef DOWNSAMPLE_NORMALS
vec3 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;
#else
vec3 n[4];n[0]=vec3(0.0);n[1]=vec3(0.0);n[2]=vec3(0.0);n[3]=vec3(0.0);
#endif
gl_FragColor=vec4(n[index],d[index]);}`,iee="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);}",ree=class extends Vi{constructor(){super({name:"DepthDownsamplingMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new J(null),normalBuffer:new J(null),texelSize:new J(new de)},blending:Er,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:nee,vertexShader:iee})}set depthBuffer(n){this.uniforms.depthBuffer.value=n}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,e=bc){this.depthBuffer=n,this.depthPacking=e}set normalBuffer(n){this.uniforms.normalBuffer.value=n,n!==null?this.defines.DOWNSAMPLE_NORMALS="1":delete this.defines.DOWNSAMPLE_NORMALS,this.needsUpdate=!0}setNormalBuffer(n){this.normalBuffer=n}setTexelSize(n,e){this.uniforms.texelSize.value.set(n,e)}setSize(n,e){this.uniforms.texelSize.value.set(1/n,1/e)}},aee=class extends Br{constructor({normalBuffer:n=null,resolutionScale:e=.5,width:t=os.AUTO_SIZE,height:i=os.AUTO_SIZE,resolutionX:r=t,resolutionY:a=i}={}){super("DepthDownsamplingPass");const s=new ree;s.normalBuffer=n,this.fullscreenMaterial=s,this.needsDepthTexture=!0,this.needsSwap=!1,this.renderTarget=new xi(1,1,{minFilter:Vn,magFilter:Vn,depthBuffer:!1,type:si}),this.renderTarget.texture.name="DepthDownsamplingPass.Target",this.renderTarget.texture.generateMipmaps=!1;const o=this.resolution=new os(this,r,a,e);o.addEventListener("change",l=>this.setSize(o.baseWidth,o.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(n,e=bc){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e}render(n,e,t,i,r){n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height),this.fullscreenMaterial.setSize(n,e)}initialize(n,e,t){const i=n.getContext();if(!(i.getExtension("EXT_color_buffer_float")||i.getExtension("EXT_color_buffer_half_float")))throw new Error("Rendering to float texture is not supported.")}},see=`#include <packing>
#define packFloatToRGBA(v) packDepthToRGBA(v)
#define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
uniform lowp sampler2D luminanceBuffer0;uniform lowp sampler2D luminanceBuffer1;uniform float minLuminance;uniform float deltaTime;uniform float tau;varying vec2 vUv;void main(){float l0=unpackRGBAToFloat(texture2D(luminanceBuffer0,vUv));
#if __VERSION__ < 300
float l1=texture2DLodEXT(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r;
#else
float l1=textureLod(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r;
#endif
l0=max(minLuminance,l0);l1=max(minLuminance,l1);float adaptedLum=l0+(l1-l0)*(1.0-exp(-deltaTime*tau));gl_FragColor=(adaptedLum==1.0)?vec4(1.0):packFloatToRGBA(adaptedLum);}`,oee=class extends Vi{constructor(){super({name:"AdaptiveLuminanceMaterial",defines:{MIP_LEVEL_1X1:"0.0"},uniforms:{luminanceBuffer0:new J(null),luminanceBuffer1:new J(null),minLuminance:new J(.01),deltaTime:new J(0),tau:new J(1)},extensions:{shaderTextureLOD:!0},blending:Er,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:see,vertexShader:mA})}set luminanceBuffer0(n){this.uniforms.luminanceBuffer0.value=n}setLuminanceBuffer0(n){this.uniforms.luminanceBuffer0.value=n}set luminanceBuffer1(n){this.uniforms.luminanceBuffer1.value=n}setLuminanceBuffer1(n){this.uniforms.luminanceBuffer1.value=n}set mipLevel1x1(n){this.defines.MIP_LEVEL_1X1=n.toFixed(1),this.needsUpdate=!0}setMipLevel1x1(n){this.mipLevel1x1=n}set deltaTime(n){this.uniforms.deltaTime.value=n}setDeltaTime(n){this.uniforms.deltaTime.value=n}get minLuminance(){return this.uniforms.minLuminance.value}set minLuminance(n){this.uniforms.minLuminance.value=n}getMinLuminance(){return this.uniforms.minLuminance.value}setMinLuminance(n){this.uniforms.minLuminance.value=n}get adaptationRate(){return this.uniforms.tau.value}set adaptationRate(n){this.uniforms.tau.value=n}getAdaptationRate(){return this.uniforms.tau.value}setAdaptationRate(n){this.uniforms.tau.value=n}},lee=class extends Br{constructor(n,{minLuminance:e=.01,adaptationRate:t=1}={}){super("AdaptiveLuminancePass"),this.fullscreenMaterial=new oee,this.needsSwap=!1,this.renderTargetPrevious=new xi(1,1,{minFilter:Vn,magFilter:Vn,depthBuffer:!1}),this.renderTargetPrevious.texture.name="Luminance.Previous";const i=this.fullscreenMaterial;i.luminanceBuffer0=this.renderTargetPrevious.texture,i.luminanceBuffer1=n,i.minLuminance=e,i.adaptationRate=t,this.renderTargetAdapted=this.renderTargetPrevious.clone(),this.renderTargetAdapted.texture.name="Luminance.Adapted",this.copyPass=new tP(this.renderTargetPrevious,!1)}get texture(){return this.renderTargetAdapted.texture}getTexture(){return this.renderTargetAdapted.texture}set mipLevel1x1(n){this.fullscreenMaterial.mipLevel1x1=n}get adaptationRate(){return this.fullscreenMaterial.adaptationRate}set adaptationRate(n){this.fullscreenMaterial.adaptationRate=n}render(n,e,t,i,r){this.fullscreenMaterial.deltaTime=i,n.setRenderTarget(this.renderToScreen?null:this.renderTargetAdapted),n.render(this.scene,this.camera),this.copyPass.render(n,this.renderTargetAdapted)}},cee=`#include <tonemapping_pars_fragment>
uniform float whitePoint;
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
uniform float middleGrey;
#if TONE_MAPPING_MODE == 3
uniform lowp sampler2D luminanceBuffer;
#else
uniform float averageLuminance;
#endif
vec3 Reinhard2ToneMapping(vec3 color){color*=toneMappingExposure;float l=luminance(color);
#if TONE_MAPPING_MODE == 3
float lumAvg=unpackRGBAToFloat(texture2D(luminanceBuffer,vec2(0.5)));
#else
float lumAvg=averageLuminance;
#endif
float lumScaled=(l*middleGrey)/max(lumAvg,1e-6);float lumCompressed=lumScaled*(1.0+lumScaled/(whitePoint*whitePoint));lumCompressed/=(1.0+lumScaled);return clamp(lumCompressed*color,0.0,1.0);}
#elif TONE_MAPPING_MODE == 4
#define A 0.15
#define B 0.50
#define C 0.10
#define D 0.20
#define E 0.02
#define F 0.30
vec3 Uncharted2Helper(const in vec3 x){return((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}vec3 Uncharted2ToneMapping(vec3 color){color*=toneMappingExposure;return clamp(Uncharted2Helper(color)/Uncharted2Helper(vec3(whitePoint)),0.0,1.0);}
#endif
void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
outputColor=vec4(Reinhard2ToneMapping(inputColor.rgb),inputColor.a);
#elif TONE_MAPPING_MODE == 4
outputColor=vec4(Uncharted2ToneMapping(inputColor.rgb),inputColor.a);
#else
outputColor=vec4(toneMapping(inputColor.rgb),inputColor.a);
#endif
}`,uee=class extends T0{constructor({blendFunction:n=ln.SRC,adaptive:e=!1,mode:t=e?jr.REINHARD2_ADAPTIVE:jr.AGX,resolution:i=256,maxLuminance:r=4,whitePoint:a=r,middleGrey:s=.6,minLuminance:o=.01,averageLuminance:l=1,adaptationRate:h=1}={}){super("ToneMappingEffect",cee,{blendFunction:n,uniforms:new Map([["luminanceBuffer",new J(null)],["maxLuminance",new J(r)],["whitePoint",new J(a)],["middleGrey",new J(s)],["averageLuminance",new J(l)]])}),this.renderTargetLuminance=new xi(1,1,{minFilter:Aa,depthBuffer:!1}),this.renderTargetLuminance.texture.generateMipmaps=!0,this.renderTargetLuminance.texture.name="Luminance",this.luminancePass=new tee({renderTarget:this.renderTargetLuminance}),this.adaptiveLuminancePass=new lee(this.luminancePass.texture,{minLuminance:o,adaptationRate:h}),this.uniforms.get("luminanceBuffer").value=this.adaptiveLuminancePass.texture,this.resolution=i,this.mode=t}get mode(){return Number(this.defines.get("TONE_MAPPING_MODE"))}set mode(n){if(this.mode===n)return;const t=Ds.replace(/\D+/g,"")>=168?"CineonToneMapping(texel)":"OptimizedCineonToneMapping(texel)";switch(this.defines.clear(),this.defines.set("TONE_MAPPING_MODE",n.toFixed(0)),n){case jr.LINEAR:this.defines.set("toneMapping(texel)","LinearToneMapping(texel)");break;case jr.REINHARD:this.defines.set("toneMapping(texel)","ReinhardToneMapping(texel)");break;case jr.CINEON:case jr.OPTIMIZED_CINEON:this.defines.set("toneMapping(texel)",t);break;case jr.ACES_FILMIC:this.defines.set("toneMapping(texel)","ACESFilmicToneMapping(texel)");break;case jr.AGX:this.defines.set("toneMapping(texel)","AgXToneMapping(texel)");break;case jr.NEUTRAL:this.defines.set("toneMapping(texel)","NeutralToneMapping(texel)");break;default:this.defines.set("toneMapping(texel)","texel");break}this.adaptiveLuminancePass.enabled=n===jr.REINHARD2_ADAPTIVE,this.setChanged()}getMode(){return this.mode}setMode(n){this.mode=n}get whitePoint(){return this.uniforms.get("whitePoint").value}set whitePoint(n){this.uniforms.get("whitePoint").value=n}get middleGrey(){return this.uniforms.get("middleGrey").value}set middleGrey(n){this.uniforms.get("middleGrey").value=n}get averageLuminance(){return this.uniforms.get("averageLuminance").value}set averageLuminance(n){this.uniforms.get("averageLuminance").value=n}get adaptiveLuminanceMaterial(){return this.adaptiveLuminancePass.fullscreenMaterial}getAdaptiveLuminanceMaterial(){return this.adaptiveLuminanceMaterial}get resolution(){return this.luminancePass.resolution.width}set resolution(n){const e=Math.max(0,Math.ceil(Math.log2(n))),t=Math.pow(2,e);this.luminancePass.resolution.setPreferredSize(t,t),this.adaptiveLuminanceMaterial.mipLevel1x1=e}getResolution(){return this.resolution}setResolution(n){this.resolution=n}get adaptive(){return this.mode===jr.REINHARD2_ADAPTIVE}set adaptive(n){this.mode=n?jr.REINHARD2_ADAPTIVE:jr.REINHARD2}get adaptationRate(){return this.adaptiveLuminanceMaterial.adaptationRate}set adaptationRate(n){this.adaptiveLuminanceMaterial.adaptationRate=n}get distinction(){return console.warn(this.name,"distinction was removed."),1}set distinction(n){console.warn(this.name,"distinction was removed.")}update(n,e,t){this.adaptiveLuminancePass.enabled&&(this.luminancePass.render(n,e),this.adaptiveLuminancePass.render(n,null,null,t))}initialize(n,e,t){this.adaptiveLuminancePass.initialize(n,e,t)}},hee=`#include <common>
#include <packing>
#include <dithering_pars_fragment>
#define packFloatToRGBA(v) packDepthToRGBA(v)
#define unpackRGBAToFloat(v) unpackRGBAToDepth(v)
#ifdef FRAMEBUFFER_PRECISION_HIGH
uniform mediump sampler2D inputBuffer;
#else
uniform lowp sampler2D inputBuffer;
#endif
#if DEPTH_PACKING == 3201
uniform lowp sampler2D depthBuffer;
#elif defined(GL_FRAGMENT_PRECISION_HIGH)
uniform highp sampler2D depthBuffer;
#else
uniform mediump sampler2D depthBuffer;
#endif
uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;vec4 sRGBToLinear(const in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);}float readDepth(const in vec2 uv){
#if DEPTH_PACKING == 3201
float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv));
#else
float depth=texture2D(depthBuffer,uv).r;
#endif
#if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH)
float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d;
#elif defined(USE_REVERSED_DEPTH_BUFFER)
depth=1.0-depth;
#endif
return depth;}float getViewZ(const in float depth){
#ifdef PERSPECTIVE_CAMERA
return perspectiveDepthToViewZ(depth,cameraNear,cameraFar);
#else
return orthographicDepthToViewZ(depth,cameraNear,cameraFar);
#endif
}vec3 RGBToHCV(const in vec3 RGB){vec4 P=mix(vec4(RGB.bg,-1.0,2.0/3.0),vec4(RGB.gb,0.0,-1.0/3.0),step(RGB.b,RGB.g));vec4 Q=mix(vec4(P.xyw,RGB.r),vec4(RGB.r,P.yzx),step(P.x,RGB.r));float C=Q.x-min(Q.w,Q.y);float H=abs((Q.w-Q.y)/(6.0*C+EPSILON)+Q.z);return vec3(H,C,Q.x);}vec3 RGBToHSL(const in vec3 RGB){vec3 HCV=RGBToHCV(RGB);float L=HCV.z-HCV.y*0.5;float S=HCV.y/(1.0-abs(L*2.0-1.0)+EPSILON);return vec3(HCV.x,S,L);}vec3 HueToRGB(const in float H){float R=abs(H*6.0-3.0)-1.0;float G=2.0-abs(H*6.0-2.0);float B=2.0-abs(H*6.0-4.0);return clamp(vec3(R,G,B),0.0,1.0);}vec3 HSLToRGB(const in vec3 HSL){vec3 RGB=HueToRGB(HSL.x);float C=(1.0-abs(2.0*HSL.z-1.0))*HSL.y;return(RGB-0.5)*C+HSL.z;}FRAGMENT_HEAD void main(){FRAGMENT_MAIN_UV vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGE color0.a=clamp(color0.a,0.0,1.0);gl_FragColor=color0;
#ifdef ENCODE_OUTPUT
#include <colorspace_fragment>
#endif
#include <dithering_fragment>
}`,fee="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);}",dee=class extends Vi{constructor(n,e,t,i,r=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:Ds.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new J(null),depthBuffer:new J(null),resolution:new J(new de),texelSize:new J(new de),cameraNear:new J(.3),cameraFar:new J(1e3),aspect:new J(1),time:new J(0)},blending:Er,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:r}),n&&this.setShaderParts(n),e&&this.setDefines(e),t&&this.setUniforms(t),this.copyCameraSettings(i)}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){this.uniforms.depthBuffer.value=n}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,e=bc){this.depthBuffer=n,this.depthPacking=e}setShaderData(n){this.setShaderParts(n.shaderParts),this.setDefines(n.defines),this.setUniforms(n.uniforms),this.setExtensions(n.extensions)}setShaderParts(n){return this.fragmentShader=hee.replace(xn.FRAGMENT_HEAD,n.get(xn.FRAGMENT_HEAD)||"").replace(xn.FRAGMENT_MAIN_UV,n.get(xn.FRAGMENT_MAIN_UV)||"").replace(xn.FRAGMENT_MAIN_IMAGE,n.get(xn.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader=fee.replace(xn.VERTEX_HEAD,n.get(xn.VERTEX_HEAD)||"").replace(xn.VERTEX_MAIN_SUPPORT,n.get(xn.VERTEX_MAIN_SUPPORT)||""),this.needsUpdate=!0,this}setDefines(n){for(const e of n.entries())this.defines[e[0]]=e[1];return this.needsUpdate=!0,this}setUniforms(n){for(const e of n.entries())this.uniforms[e[0]]=e[1];return this}setExtensions(n){this.extensions={};for(const e of n)this.extensions[e]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(n){this.encodeOutput!==n&&(n?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(n){return this.encodeOutput}setOutputEncodingEnabled(n){this.encodeOutput=n}get time(){return this.uniforms.time.value}set time(n){this.uniforms.time.value=n}setDeltaTime(n){this.uniforms.time.value+=n}adoptCameraSettings(n){this.copyCameraSettings(n)}copyCameraSettings(n){n&&(this.uniforms.cameraNear.value=n.near,this.uniforms.cameraFar.value=n.far,n instanceof hi?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(n,e){const t=this.uniforms;t.resolution.value.set(n,e),t.texelSize.value.set(1/n,1/e),t.aspect.value=n/e}static get Section(){return xn}};function sO(n,e,t){for(const i of e){const r="$1"+n+i.charAt(0).toUpperCase()+i.slice(1),a=new RegExp("([^\\.])(\\b"+i+"\\b)","g");for(const s of t.entries())s[1]!==null&&t.set(s[0],s[1].replace(a,r))}}function pee(n,e,t){let i=e.getFragmentShader(),r=e.getVertexShader();const a=i!==void 0&&/mainImage/.test(i),s=i!==void 0&&/mainUv/.test(i);if(t.attributes|=e.getAttributes(),i===void 0)throw new Error(`Missing fragment shader (${e.name})`);if(s&&t.attributes&tl.CONVOLUTION)throw new Error(`Effects that transform UVs are incompatible with convolution effects (${e.name})`);if(!a&&!s)throw new Error(`Could not find mainImage or mainUv function (${e.name})`);{const o=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,l=t.shaderParts;let h=l.get(xn.FRAGMENT_HEAD)||"",f=l.get(xn.FRAGMENT_MAIN_UV)||"",d=l.get(xn.FRAGMENT_MAIN_IMAGE)||"",p=l.get(xn.VERTEX_HEAD)||"",g=l.get(xn.VERTEX_MAIN_SUPPORT)||"";const _=new Set,T=new Set;if(s&&(f+=`	${n}MainUv(UV);
`,t.uvTransformation=!0),r!==null&&/mainSupport/.test(r)){const S=/mainSupport *\([\w\s]*?uv\s*?\)/.test(r);g+=`	${n}MainSupport(`,g+=S?`vUv);
`:`);
`;for(const E of r.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(const b of E[1].split(/\s*,\s*/))t.varyings.add(b),_.add(b),T.add(b);for(const E of r.matchAll(o))T.add(E[1])}for(const S of i.matchAll(o))T.add(S[1]);for(const S of e.defines.keys())T.add(S.replace(/\([\w\s,]*\)/g,""));for(const S of e.uniforms.keys())T.add(S);T.delete("while"),T.delete("for"),T.delete("if"),e.uniforms.forEach((S,E)=>t.uniforms.set(n+E.charAt(0).toUpperCase()+E.slice(1),S)),e.defines.forEach((S,E)=>t.defines.set(n+E.charAt(0).toUpperCase()+E.slice(1),S));const y=new Map([["fragment",i],["vertex",r]]);sO(n,T,t.defines),sO(n,T,y),i=y.get("fragment"),r=y.get("vertex");const v=e.blendMode;if(t.blendModes.set(v.blendFunction,v),a){e.inputColorSpace!==null&&e.inputColorSpace!==t.colorSpace&&(d+=e.inputColorSpace===dn?`color0 = sRGBTransferOETF(color0);
	`:`color0 = sRGBToLinear(color0);
	`),e.outputColorSpace!==Or?t.colorSpace=e.outputColorSpace:e.inputColorSpace!==null&&(t.colorSpace=e.inputColorSpace);const S=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;d+=`${n}MainImage(color0, UV, `,t.attributes&tl.DEPTH&&S.test(i)&&(d+="depth, ",t.readDepth=!0),d+=`color1);
	`;const E=n+"BlendOpacity";t.uniforms.set(E,v.opacity),d+=`color0 = blend${v.blendFunction}(color0, color1, ${E});

	`,h+=`uniform float ${E};

`}if(h+=i+`
`,r!==null&&(p+=r+`
`),l.set(xn.FRAGMENT_HEAD,h),l.set(xn.FRAGMENT_MAIN_UV,f),l.set(xn.FRAGMENT_MAIN_IMAGE,d),l.set(xn.VERTEX_HEAD,p),l.set(xn.VERTEX_MAIN_SUPPORT,g),e.extensions!==null)for(const S of e.extensions)t.extensions.add(S)}}var mee=class extends Br{constructor(n,...e){super("EffectPass"),this.fullscreenMaterial=new dee(null,null,null,n),this.listener=t=>this.handleEvent(t),this.effects=[],this.setEffects(e),this.skipRendering=!1,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY,this.timeScale=1}set mainScene(n){for(const e of this.effects)e.mainScene=n}set mainCamera(n){this.fullscreenMaterial.copyCameraSettings(n);for(const e of this.effects)e.mainCamera=n}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(n){this.fullscreenMaterial.encodeOutput=n}get dithering(){return this.fullscreenMaterial.dithering}set dithering(n){const e=this.fullscreenMaterial;e.dithering=n,e.needsUpdate=!0}setEffects(n){for(const e of this.effects)e.removeEventListener("change",this.listener);this.effects=n.sort((e,t)=>t.attributes-e.attributes);for(const e of this.effects)e.addEventListener("change",this.listener)}updateMaterial(){const n=new x$;let e=0;for(const s of this.effects)if(s.blendMode.blendFunction===ln.DST)n.attributes|=s.getAttributes()&tl.DEPTH;else{if(n.attributes&s.getAttributes()&tl.CONVOLUTION)throw new Error(`Convolution effects cannot be merged (${s.name})`);pee("e"+e++,s,n)}let t=n.shaderParts.get(xn.FRAGMENT_HEAD),i=n.shaderParts.get(xn.FRAGMENT_MAIN_IMAGE),r=n.shaderParts.get(xn.FRAGMENT_MAIN_UV);const a=/\bblend\b/g;for(const s of n.blendModes.values())t+=s.getShaderCode().replace(a,`blend${s.blendFunction}`)+`
`;n.attributes&tl.DEPTH?(n.readDepth&&(i=`float depth = readDepth(UV);

	`+i),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,n.colorSpace===dn&&(i+=`color0 = sRGBToLinear(color0);
	`),n.uvTransformation?(r=`vec2 transformedUv = vUv;
`+r,n.defines.set("UV","transformedUv")):n.defines.set("UV","vUv"),n.shaderParts.set(xn.FRAGMENT_HEAD,t),n.shaderParts.set(xn.FRAGMENT_MAIN_IMAGE,i),n.shaderParts.set(xn.FRAGMENT_MAIN_UV,r);for(const[s,o]of n.shaderParts)o!==null&&n.shaderParts.set(s,o.trim().replace(/^#/,`
#`));this.skipRendering=e===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(n)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(n,e=bc){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e;for(const t of this.effects)t.setDepthTexture(n,e)}render(n,e,t,i,r){for(const a of this.effects)a.update(n,e,i);if(!this.skipRendering||this.renderToScreen){const a=this.fullscreenMaterial;a.inputBuffer=e.texture,a.time+=i*this.timeScale,n.setRenderTarget(this.renderToScreen?null:t),n.render(this.scene,this.camera)}}setSize(n,e){this.fullscreenMaterial.setSize(n,e);for(const t of this.effects)t.setSize(n,e)}initialize(n,e,t){this.renderer=n;for(const i of this.effects)i.initialize(n,e,t);this.updateMaterial(),t!==void 0&&t!==Pi&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const n of this.effects)n.removeEventListener("change",this.listener),n.dispose()}handleEvent(n){switch(n.type){case"change":this.recompile();break}}},gee=class extends Br{constructor(n,e,{renderTarget:t,resolutionScale:i=1,width:r=os.AUTO_SIZE,height:a=os.AUTO_SIZE,resolutionX:s=r,resolutionY:o=a}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new gA(n,e,new Xb);const l=this.renderPass;l.ignoreBackground=!0,l.skipShadowMapUpdate=!0;const h=l.getClearPass();h.overrideClearColor=new qe(7829503),h.overrideClearAlpha=1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new xi(1,1,{minFilter:Vn,magFilter:Vn}),this.renderTarget.texture.name="NormalPass.Target");const f=this.resolution=new os(this,s,o,i);f.addEventListener("change",d=>this.setSize(f.baseWidth,f.baseHeight))}set mainScene(n){this.renderPass.mainScene=n}set mainCamera(n){this.renderPass.mainCamera=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,e,t,i,r){const a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(n,a,a)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}};function Xm(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}new de;new de;function iP(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}var qa=function n(e,t,i){var r=this;iP(this,n),Xm(this,"dot2",function(a,s){return r.x*a+r.y*s}),Xm(this,"dot3",function(a,s,o){return r.x*a+r.y*s+r.z*o}),this.x=e,this.y=t,this.z=i},vee=[new qa(1,1,0),new qa(-1,1,0),new qa(1,-1,0),new qa(-1,-1,0),new qa(1,0,1),new qa(-1,0,1),new qa(1,0,-1),new qa(-1,0,-1),new qa(0,1,1),new qa(0,-1,1),new qa(0,1,-1),new qa(0,-1,-1)],oO=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],lO=new Array(512),cO=new Array(512),_ee=function(e){e>0&&e<1&&(e*=65536),e=Math.floor(e),e<256&&(e|=e<<8);for(var t=0;t<256;t++){var i;t&1?i=oO[t]^e&255:i=oO[t]^e>>8&255,lO[t]=lO[t+256]=i,cO[t]=cO[t+256]=vee[i%12]}};_ee(0);function xee(n){if(typeof n=="number")n=Math.abs(n);else if(typeof n=="string"){var e=n;n=0;for(var t=0;t<e.length;t++)n=(n+(t+1)*(e.charCodeAt(t)%96))%2147483647}return n===0&&(n=311),n}function uO(n){var e=xee(n);return function(){var t=e*48271%2147483647;return e=t,t/2147483647}}var yee=function n(e){var t=this;iP(this,n),Xm(this,"seed",0),Xm(this,"init",function(i){t.seed=i,t.value=uO(i)}),Xm(this,"value",uO(this.seed)),this.init(e)};new yee(Math.random());const vA=Me.createContext(null),hO=n=>(n.getAttributes()&2)===2,See=Me.memo(Me.forwardRef(({children:n,camera:e,scene:t,resolutionScale:i,enabled:r=!0,renderPriority:a=1,autoClear:s=!0,depthBuffer:o,enableNormalPass:l,stencilBuffer:h,multisampling:f=8,frameBufferType:d=Yn},p)=>{const{gl:g,scene:_,camera:T,size:y}=Ni(),v=t||_,S=e||T,[E,b,N]=Me.useMemo(()=>{const U=new _$(g,{depthBuffer:o,stencilBuffer:h,multisampling:f,frameBufferType:d});U.addPass(new gA(v,S));let O=null,w=null;return l&&(w=new gee(v,S),w.enabled=!1,U.addPass(w),i!==void 0&&(O=new aee({normalBuffer:w.texture,resolutionScale:i}),O.enabled=!1,U.addPass(O))),[U,w,O]},[S,g,o,h,f,d,v,l,i]);Me.useEffect(()=>E==null?void 0:E.setSize(y.width,y.height),[E,y]),fl((U,O)=>{if(r){const w=g.autoClear;g.autoClear=s,h&&!s&&g.clearStencil(),E.render(O),g.autoClear=w}},r?a:0);const R=Me.useRef(null);Me.useLayoutEffect(()=>{var w;const U=[],O=R.current.__r3f;if(O&&E){const B=O.children;for(let j=0;j<B.length;j++){const ee=B[j].object;if(ee instanceof T0){const se=[ee];if(!hO(ee)){let W=null;for(;(W=(w=B[j+1])==null?void 0:w.object)instanceof T0&&!hO(W);)se.push(W),j++}const ae=new mee(S,...se);U.push(ae)}else ee instanceof Br&&U.push(ee)}for(const j of U)E==null||E.addPass(j);b&&(b.enabled=!0),N&&(N.enabled=!0)}return()=>{for(const B of U)E==null||E.removePass(B);b&&(b.enabled=!1),N&&(N.enabled=!1)}},[E,n,S,b,N]),Me.useEffect(()=>{const U=g.toneMapping;return g.toneMapping=as,()=>{g.toneMapping=U}},[g]);const I=Me.useMemo(()=>({composer:E,normalPass:b,downSamplingPass:N,resolutionScale:i,camera:S,scene:v}),[E,b,N,i,S,v]);return Me.useImperativeHandle(p,()=>E,[E]),Mt.jsx(vA.Provider,{value:I,children:Mt.jsx("group",{ref:R,children:n})})}));let Tee=0;const fO=new WeakMap,Eee=(n,e)=>function({blendFunction:t=e==null?void 0:e.blendFunction,opacity:i=e==null?void 0:e.opacity,...r}){let a=fO.get(n);if(!a){const l=`@react-three/postprocessing/${n.name}-${Tee++}`;y8({[l]:n}),fO.set(n,a=l)}const s=Ni(l=>l.camera),o=TM.useMemo(()=>[...(e==null?void 0:e.args)??[],...r.args??[{...e,...r}]],[JSON.stringify(r)]);return Mt.jsx(a,{camera:s,"blendMode-blendFunction":t,"blendMode-opacity-value":i,...r,args:o})},Mee=Eee(uee);var bee="Invariant failed";function i1(n,e){if(!n)throw new Error(bee)}const Aee=new L;function rP(n,e,t=new L,i){const{x:r,y:a,z:s}=n,o=e.x,l=e.y,h=e.z,f=r*r*o,d=a*a*l,p=s*s*h,g=f+d+p,_=Math.sqrt(1/g);if(!Number.isFinite(_))return;const T=Aee.copy(n).multiplyScalar(_);if(g<((i==null?void 0:i.centerTolerance)??.1))return t.copy(T);const y=T.multiply(e).multiplyScalar(2);let v=(1-_)*n.length()/(y.length()/2),S=0,E,b,N,R;do{v-=S,E=1/(1+v*o),b=1/(1+v*l),N=1/(1+v*h);const I=E*E,U=b*b,O=N*N,w=I*E,B=U*b,j=O*N;R=f*I+d*U+p*O-1,S=R/((f*w*o+d*B*l+p*j*h)*-2)}while(Math.abs(R)>1e-12);return t.set(r*E,a*b,s*N)}const Tf=new L,J2=new L,$2=new L,WE=class{constructor(e,t,i){this.radii=new L(e,t,i)}get minimumRadius(){return Math.min(this.radii.x,this.radii.y,this.radii.z)}get maximumRadius(){return Math.max(this.radii.x,this.radii.y,this.radii.z)}get flattening(){return 1-this.minimumRadius/this.maximumRadius}get eccentricity(){return Math.sqrt(this.eccentricitySquared)}get eccentricitySquared(){const e=this.maximumRadius**2,t=this.minimumRadius**2;return(e-t)/e}reciprocalRadii(e=new L){const{x:t,y:i,z:r}=this.radii;return e.set(1/t,1/i,1/r)}reciprocalRadiiSquared(e=new L){const{x:t,y:i,z:r}=this.radii;return e.set(1/t**2,1/i**2,1/r**2)}projectOnSurface(e,t=new L,i){return rP(e,this.reciprocalRadiiSquared(),t,i)}getSurfaceNormal(e,t=new L){return t.multiplyVectors(this.reciprocalRadiiSquared(Tf),e).normalize()}getEastNorthUpVectors(e,t=new L,i=new L,r=new L){this.getSurfaceNormal(e,r),t.set(-e.y,e.x,0).normalize(),i.crossVectors(r,t).normalize()}getEastNorthUpFrame(e,t=new Ve){const i=Tf,r=J2,a=$2;return this.getEastNorthUpVectors(e,i,r,a),t.makeBasis(i,r,a).setPosition(e)}getNorthUpEastFrame(e,t=new Ve){const i=Tf,r=J2,a=$2;return this.getEastNorthUpVectors(e,i,r,a),t.makeBasis(r,a,i).setPosition(e)}getIntersection(e,t=new L){const i=this.reciprocalRadii(Tf),r=J2.copy(i).multiply(e.origin),a=$2.copy(i).multiply(e.direction),s=r.lengthSq(),o=a.lengthSq(),l=r.dot(a),h=l**2-o*(s-1);if(s===1)return t.copy(e.origin);if(s>1){if(l>=0||h<0)return;const f=Math.sqrt(h),d=(-l-f)/o,p=(-l+f)/o;return e.at(Math.min(d,p),t)}if(s<1){const f=l**2-o*(s-1),d=Math.sqrt(f),p=(-l+d)/o;return e.at(p,t)}if(l<0)return e.at(-l/o,t)}getOsculatingSphereCenter(e,t,i=new L){i1(this.radii.x===this.radii.y);const r=this.radii.x**2,a=this.radii.z**2,s=Tf.set(e.x/r,e.y/r,e.z/a).normalize();return i.copy(s.multiplyScalar(-t).add(e))}getNormalAtHorizon(e,t,i=new L){i1(this.radii.x===this.radii.y);const r=this.radii.x**2,a=this.radii.z**2,s=e,o=t;let l=(s.x*o.x+s.y*o.y)/r+s.z*o.z/a;l/=(s.x**2+s.y**2)/r+s.z**2/a;const h=Tf.copy(o).multiplyScalar(-l).add(e);return i.set(h.x/r,h.y/r,h.z/a).normalize()}};WE.WGS84=new WE(6378137,6378137,6356752314245179e-9);let ih=WE;const jv=new L,dO=new L,_m=class XE{constructor(e=0,t=0,i=0){this.longitude=e,this.latitude=t,this.height=i}set(e,t,i){return this.longitude=e,this.latitude=t,i!=null&&(this.height=i),this}clone(){return new XE(this.longitude,this.latitude,this.height)}copy(e){return this.longitude=e.longitude,this.latitude=e.latitude,this.height=e.height,this}equals(e){return e.longitude===this.longitude&&e.latitude===this.latitude&&e.height===this.height}setLongitude(e){return this.longitude=e,this}setLatitude(e){return this.latitude=e,this}setHeight(e){return this.height=e,this}normalize(){return this.longitude<XE.MIN_LONGITUDE&&(this.longitude+=Math.PI*2),this}setFromECEF(e,t){const i=((t==null?void 0:t.ellipsoid)??ih.WGS84).reciprocalRadiiSquared(jv),r=rP(e,i,dO,t);if(r==null)throw new Error(`Could not project position to ellipsoid surface: ${e.toArray()}`);const a=jv.multiplyVectors(r,i).normalize();this.longitude=Math.atan2(a.y,a.x),this.latitude=Math.asin(a.z);const s=jv.subVectors(e,r);return this.height=Math.sign(s.dot(e))*s.length(),this}toECEF(e=new L,t){const i=(t==null?void 0:t.ellipsoid)??ih.WGS84,r=jv.multiplyVectors(i.radii,i.radii),a=Math.cos(this.latitude),s=dO.set(a*Math.cos(this.longitude),a*Math.sin(this.longitude),Math.sin(this.latitude)).normalize();return e.multiplyVectors(r,s),e.divideScalar(Math.sqrt(s.dot(e))).add(s.multiplyScalar(this.height))}fromArray(e,t=0){return this.longitude=e[t],this.latitude=e[t+1],this.height=e[t+2],this}toArray(e=[],t=0){return e[t]=this.longitude,e[t+1]=this.latitude,e[t+2]=this.height,e}*[Symbol.iterator](){yield this.longitude,yield this.latitude,yield this.height}};_m.MIN_LONGITUDE=-Math.PI,_m.MAX_LONGITUDE=Math.PI,_m.MIN_LATITUDE=-Math.PI/2,_m.MAX_LATITUDE=Math.PI/2;let E0=_m;/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.8.2
*/var ns=Uint8Array,jf=Uint16Array,wee=Int32Array,aP=new ns([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),sP=new ns([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ree=new ns([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),oP=function(n,e){for(var t=new jf(31),i=0;i<31;++i)t[i]=e+=1<<n[i-1];for(var r=new wee(t[30]),i=1;i<30;++i)for(var a=t[i];a<t[i+1];++a)r[a]=a-t[i]<<5|i;return{b:t,r}},lP=oP(aP,2),cP=lP.b,Cee=lP.r;cP[28]=258,Cee[258]=28;var Dee=oP(sP,0),Nee=Dee.b,YE=new jf(32768);for(var ei=0;ei<32768;++ei){var Fl=(ei&43690)>>1|(ei&21845)<<1;Fl=(Fl&52428)>>2|(Fl&13107)<<2,Fl=(Fl&61680)>>4|(Fl&3855)<<4,YE[ei]=((Fl&65280)>>8|(Fl&255)<<8)>>1}var Ym=function(n,e,t){for(var i=n.length,r=0,a=new jf(e);r<i;++r)n[r]&&++a[n[r]-1];var s=new jf(e);for(r=1;r<e;++r)s[r]=s[r-1]+a[r-1]<<1;var o;if(t){o=new jf(1<<e);var l=15-e;for(r=0;r<i;++r)if(n[r])for(var h=r<<4|n[r],f=e-n[r],d=s[n[r]-1]++<<f,p=d|(1<<f)-1;d<=p;++d)o[YE[d]>>l]=h}else for(o=new jf(i),r=0;r<i;++r)n[r]&&(o[r]=YE[s[n[r]-1]++]>>15-n[r]);return o},Z0=new ns(288);for(var ei=0;ei<144;++ei)Z0[ei]=8;for(var ei=144;ei<256;++ei)Z0[ei]=9;for(var ei=256;ei<280;++ei)Z0[ei]=7;for(var ei=280;ei<288;++ei)Z0[ei]=8;var uP=new ns(32);for(var ei=0;ei<32;++ei)uP[ei]=5;var Oee=Ym(Z0,9,1),Lee=Ym(uP,5,1),e3=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},xs=function(n,e,t){var i=e/8|0;return(n[i]|n[i+1]<<8)>>(e&7)&t},t3=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},Iee=function(n){return(n+7)/8|0},Uee=function(n,e,t){return(t==null||t>n.length)&&(t=n.length),new ns(n.subarray(e,t))},Pee=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Es=function(n,e,t){var i=new Error(e||Pee[n]);if(i.code=n,Error.captureStackTrace&&Error.captureStackTrace(i,Es),!t)throw i;return i},zee=function(n,e,t,i){var r=n.length,a=0;if(!r||e.f&&!e.l)return t||new ns(0);var s=!t,o=s||e.i!=2,l=e.i;s&&(t=new ns(r*3));var h=function(bt){var ot=t.length;if(bt>ot){var Ke=new ns(Math.max(ot*2,bt));Ke.set(t),t=Ke}},f=e.f||0,d=e.p||0,p=e.b||0,g=e.l,_=e.d,T=e.m,y=e.n,v=r*8;do{if(!g){f=xs(n,d,1);var S=xs(n,d+1,3);if(d+=3,S)if(S==1)g=Oee,_=Lee,T=9,y=5;else if(S==2){var R=xs(n,d,31)+257,I=xs(n,d+10,15)+4,U=R+xs(n,d+5,31)+1;d+=14;for(var O=new ns(U),w=new ns(19),B=0;B<I;++B)w[Ree[B]]=xs(n,d+B*3,7);d+=I*3;for(var j=e3(w),ee=(1<<j)-1,se=Ym(w,j,1),B=0;B<U;){var ae=se[xs(n,d,ee)];d+=ae&15;var E=ae>>4;if(E<16)O[B++]=E;else{var W=0,te=0;for(E==16?(te=3+xs(n,d,3),d+=2,W=O[B-1]):E==17?(te=3+xs(n,d,7),d+=3):E==18&&(te=11+xs(n,d,127),d+=7);te--;)O[B++]=W}}var K=O.subarray(0,R),oe=O.subarray(R);T=e3(K),y=e3(oe),g=Ym(K,T,1),_=Ym(oe,y,1)}else Es(1);else{var E=Iee(d)+4,b=n[E-4]|n[E-3]<<8,N=E+b;if(N>r){l&&Es(0);break}o&&h(p+b),t.set(n.subarray(E,N),p),e.b=p+=b,e.p=d=N*8,e.f=f;continue}if(d>v){l&&Es(0);break}}o&&h(p+131072);for(var ie=(1<<T)-1,Ce=(1<<y)-1,Xe=d;;Xe=d){var W=g[t3(n,d)&ie],nt=W>>4;if(d+=W&15,d>v){l&&Es(0);break}if(W||Es(2),nt<256)t[p++]=nt;else if(nt==256){Xe=d,g=null;break}else{var tt=nt-254;if(nt>264){var B=nt-257,gt=aP[B];tt=xs(n,d,(1<<gt)-1)+cP[B],d+=gt}var ge=_[t3(n,d)&Ce],Ae=ge>>4;ge||Es(3),d+=ge&15;var oe=Nee[Ae];if(Ae>3){var gt=sP[Ae];oe+=t3(n,d)&(1<<gt)-1,d+=gt}if(d>v){l&&Es(0);break}o&&h(p+131072);var Ze=p+tt;if(p<oe){var ue=a-oe,it=Math.min(oe,Ze);for(ue+p<0&&Es(3);p<it;++p)t[p]=i[ue+p]}for(;p<Ze;++p)t[p]=t[p-oe]}}e.l=g,e.p=Xe,e.b=p,e.f=f,g&&(f=1,e.m=T,e.d=_,e.n=y)}while(!f);return p!=t.length&&s?Uee(t,0,p):t.subarray(0,p)},Bee=new ns(0),Hee=function(n,e){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&Es(6,"invalid zlib data"),(n[1]>>5&1)==1&&Es(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Zv(n,e){return zee(n.subarray(Hee(n),-4),{i:2},e,e)}var Fee=typeof TextDecoder<"u"&&new TextDecoder,Gee=0;try{Fee.decode(Bee,{stream:!0}),Gee=1}catch{}class hP extends R6{constructor(e){super(e),this.type=Yn,this.outputFormat=$n}parse(e){const O=Math.pow(2.7182818,2.2);function w(C,z){let Y=0;for(let V=0;V<65536;++V)(V==0||C[V>>3]&1<<(V&7))&&(z[Y++]=V);const D=Y-1;for(;Y<65536;)z[Y++]=0;return D}function B(C){for(let z=0;z<16384;z++)C[z]={},C[z].len=0,C[z].lit=0,C[z].p=null}const j={l:0,c:0,lc:0};function ee(C,z,Y,D,V){for(;Y<C;)z=z<<8|Q(D,V),Y+=8;Y-=C,j.l=z>>Y&(1<<C)-1,j.c=z,j.lc=Y}const se=new Array(59);function ae(C){for(let Y=0;Y<=58;++Y)se[Y]=0;for(let Y=0;Y<65537;++Y)se[C[Y]]+=1;let z=0;for(let Y=58;Y>0;--Y){const D=z+se[Y]>>1;se[Y]=z,z=D}for(let Y=0;Y<65537;++Y){const D=C[Y];D>0&&(C[Y]=D|se[D]++<<6)}}function W(C,z,Y,D,V,Z){const H=z;let X=0,ne=0;for(;D<=V;D++){if(H.value-z.value>Y)return!1;ee(6,X,ne,C,H);const re=j.l;if(X=j.c,ne=j.lc,Z[D]=re,re==63){if(H.value-z.value>Y)throw new Error("Something wrong with hufUnpackEncTable");ee(8,X,ne,C,H);let fe=j.l+6;if(X=j.c,ne=j.lc,D+fe>V+1)throw new Error("Something wrong with hufUnpackEncTable");for(;fe--;)Z[D++]=0;D--}else if(re>=59){let fe=re-59+2;if(D+fe>V+1)throw new Error("Something wrong with hufUnpackEncTable");for(;fe--;)Z[D++]=0;D--}}ae(Z)}function te(C){return C&63}function K(C){return C>>6}function oe(C,z,Y,D){for(;z<=Y;z++){const V=K(C[z]),Z=te(C[z]);if(V>>Z)throw new Error("Invalid table entry");if(Z>14){const H=D[V>>Z-14];if(H.len)throw new Error("Invalid table entry");if(H.lit++,H.p){const X=H.p;H.p=new Array(H.lit);for(let ne=0;ne<H.lit-1;++ne)H.p[ne]=X[ne]}else H.p=new Array(1);H.p[H.lit-1]=z}else if(Z){let H=0;for(let X=1<<14-Z;X>0;X--){const ne=D[(V<<14-Z)+H];if(ne.len||ne.p)throw new Error("Invalid table entry");ne.len=Z,ne.lit=z,H++}}}return!0}const ie={c:0,lc:0};function Ce(C,z,Y,D){C=C<<8|Q(Y,D),z+=8,ie.c=C,ie.lc=z}const Xe={c:0,lc:0};function nt(C,z,Y,D,V,Z,H,X,ne){if(C==z){D<8&&(Ce(Y,D,V,Z),Y=ie.c,D=ie.lc),D-=8;let re=Y>>D;if(re=new Uint8Array([re])[0],X.value+re>ne)return!1;const fe=H[X.value-1];for(;re-- >0;)H[X.value++]=fe}else if(X.value<ne)H[X.value++]=C;else return!1;Xe.c=Y,Xe.lc=D}function tt(C){return C&65535}function gt(C){const z=tt(C);return z>32767?z-65536:z}const ge={a:0,b:0};function Ae(C,z){const Y=gt(C),V=gt(z),Z=Y+(V&1)+(V>>1),H=Z,X=Z-V;ge.a=H,ge.b=X}function Ze(C,z){const Y=tt(C),D=tt(z),V=Y-(D>>1)&65535,Z=D+V-32768&65535;ge.a=Z,ge.b=V}function ue(C,z,Y,D,V,Z,H){const X=H<16384,ne=Y>V?V:Y;let re=1,fe,_e;for(;re<=ne;)re<<=1;for(re>>=1,fe=re,re>>=1;re>=1;){_e=0;const Se=_e+Z*(V-fe),Re=Z*re,Pe=Z*fe,ze=D*re,Ye=D*fe;let lt,Tt,At,ft;for(;_e<=Se;_e+=Pe){let wt=_e;const st=_e+D*(Y-fe);for(;wt<=st;wt+=Ye){const Kt=wt+ze,Ln=wt+Re,Yt=Ln+ze;X?(Ae(C[wt+z],C[Ln+z]),lt=ge.a,At=ge.b,Ae(C[Kt+z],C[Yt+z]),Tt=ge.a,ft=ge.b,Ae(lt,Tt),C[wt+z]=ge.a,C[Kt+z]=ge.b,Ae(At,ft),C[Ln+z]=ge.a,C[Yt+z]=ge.b):(Ze(C[wt+z],C[Ln+z]),lt=ge.a,At=ge.b,Ze(C[Kt+z],C[Yt+z]),Tt=ge.a,ft=ge.b,Ze(lt,Tt),C[wt+z]=ge.a,C[Kt+z]=ge.b,Ze(At,ft),C[Ln+z]=ge.a,C[Yt+z]=ge.b)}if(Y&re){const Kt=wt+Re;X?Ae(C[wt+z],C[Kt+z]):Ze(C[wt+z],C[Kt+z]),lt=ge.a,C[Kt+z]=ge.b,C[wt+z]=lt}}if(V&re){let wt=_e;const st=_e+D*(Y-fe);for(;wt<=st;wt+=Ye){const Kt=wt+ze;X?Ae(C[wt+z],C[Kt+z]):Ze(C[wt+z],C[Kt+z]),lt=ge.a,C[Kt+z]=ge.b,C[wt+z]=lt}}fe=re,re>>=1}return _e}function it(C,z,Y,D,V,Z,H,X,ne){let re=0,fe=0;const _e=H,Se=Math.trunc(D.value+(V+7)/8);for(;D.value<Se;)for(Ce(re,fe,Y,D),re=ie.c,fe=ie.lc;fe>=14;){const Pe=re>>fe-14&16383,ze=z[Pe];if(ze.len)fe-=ze.len,nt(ze.lit,Z,re,fe,Y,D,X,ne,_e),re=Xe.c,fe=Xe.lc;else{if(!ze.p)throw new Error("hufDecode issues");let Ye;for(Ye=0;Ye<ze.lit;Ye++){const lt=te(C[ze.p[Ye]]);for(;fe<lt&&D.value<Se;)Ce(re,fe,Y,D),re=ie.c,fe=ie.lc;if(fe>=lt&&K(C[ze.p[Ye]])==(re>>fe-lt&(1<<lt)-1)){fe-=lt,nt(ze.p[Ye],Z,re,fe,Y,D,X,ne,_e),re=Xe.c,fe=Xe.lc;break}}if(Ye==ze.lit)throw new Error("hufDecode issues")}}const Re=8-V&7;for(re>>=Re,fe-=Re;fe>0;){const Pe=z[re<<14-fe&16383];if(Pe.len)fe-=Pe.len,nt(Pe.lit,Z,re,fe,Y,D,X,ne,_e),re=Xe.c,fe=Xe.lc;else throw new Error("hufDecode issues")}return!0}function bt(C,z,Y,D,V,Z){const H={value:0},X=Y.value,ne=ht(z,Y),re=ht(z,Y);Y.value+=4;const fe=ht(z,Y);if(Y.value+=4,ne<0||ne>=65537||re<0||re>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const _e=new Array(65537),Se=new Array(16384);B(Se);const Re=D-(Y.value-X);if(W(C,Y,Re,ne,re,_e),fe>8*(D-(Y.value-X)))throw new Error("Something wrong with hufUncompress");oe(_e,ne,re,Se),it(_e,Se,C,Y,fe,re,Z,V,H)}function ot(C,z,Y){for(let D=0;D<Y;++D)z[D]=C[z[D]]}function Ke(C){for(let z=1;z<C.length;z++){const Y=C[z-1]+C[z]-128;C[z]=Y}}function Te(C,z){let Y=0,D=Math.floor((C.length+1)/2),V=0;const Z=C.length-1;for(;!(V>Z||(z[V++]=C[Y++],V>Z));)z[V++]=C[D++]}function G(C){let z=C.byteLength;const Y=new Array;let D=0;const V=new DataView(C);for(;z>0;){const Z=V.getInt8(D++);if(Z<0){const H=-Z;z-=H+1;for(let X=0;X<H;X++)Y.push(V.getUint8(D++))}else{const H=Z;z-=2;const X=V.getUint8(D++);for(let ne=0;ne<H+1;ne++)Y.push(X)}}return Y}function be(C,z,Y,D,V,Z){let H=new DataView(Z.buffer);const X=Y[C.idx[0]].width,ne=Y[C.idx[0]].height,re=3,fe=Math.floor(X/8),_e=Math.ceil(X/8),Se=Math.ceil(ne/8),Re=X-(_e-1)*8,Pe=ne-(Se-1)*8,ze={value:0},Ye=new Array(re),lt=new Array(re),Tt=new Array(re),At=new Array(re),ft=new Array(re);for(let st=0;st<re;++st)ft[st]=z[C.idx[st]],Ye[st]=st<1?0:Ye[st-1]+_e*Se,lt[st]=new Float32Array(64),Tt[st]=new Uint16Array(64),At[st]=new Uint16Array(_e*64);for(let st=0;st<Se;++st){let Kt=8;st==Se-1&&(Kt=Pe);let Ln=8;for(let kt=0;kt<_e;++kt){kt==_e-1&&(Ln=Re);for(let Dt=0;Dt<re;++Dt)Tt[Dt].fill(0),Tt[Dt][0]=V[Ye[Dt]++],Fe(ze,D,Tt[Dt]),Be(Tt[Dt],lt[Dt]),$e(lt[Dt]);Je(lt);for(let Dt=0;Dt<re;++Dt)ct(lt[Dt],At[Dt],kt*64)}let Yt=0;for(let kt=0;kt<re;++kt){const Dt=Y[C.idx[kt]].type;for(let Hn=8*st;Hn<8*st+Kt;++Hn){Yt=ft[kt][Hn];for(let bi=0;bi<fe;++bi){const Mn=bi*64+(Hn&7)*8;H.setUint16(Yt+0*2*Dt,At[kt][Mn+0],!0),H.setUint16(Yt+1*2*Dt,At[kt][Mn+1],!0),H.setUint16(Yt+2*2*Dt,At[kt][Mn+2],!0),H.setUint16(Yt+3*2*Dt,At[kt][Mn+3],!0),H.setUint16(Yt+4*2*Dt,At[kt][Mn+4],!0),H.setUint16(Yt+5*2*Dt,At[kt][Mn+5],!0),H.setUint16(Yt+6*2*Dt,At[kt][Mn+6],!0),H.setUint16(Yt+7*2*Dt,At[kt][Mn+7],!0),Yt+=8*2*Dt}}if(fe!=_e)for(let Hn=8*st;Hn<8*st+Kt;++Hn){const bi=ft[kt][Hn]+8*fe*2*Dt,Mn=fe*64+(Hn&7)*8;for(let kn=0;kn<Ln;++kn)H.setUint16(bi+kn*2*Dt,At[kt][Mn+kn],!0)}}}const wt=new Uint16Array(X);H=new DataView(Z.buffer);for(let st=0;st<re;++st){Y[C.idx[st]].decoded=!0;const Kt=Y[C.idx[st]].type;if(Y[st].type==2)for(let Ln=0;Ln<ne;++Ln){const Yt=ft[st][Ln];for(let kt=0;kt<X;++kt)wt[kt]=H.getUint16(Yt+kt*2*Kt,!0);for(let kt=0;kt<X;++kt)H.setFloat32(Yt+kt*2*Kt,me(wt[kt]),!0)}}}function Ne(C,z,Y,D,V,Z){const H=new DataView(Z.buffer),X=Y[C],ne=X.width,re=X.height,fe=Math.ceil(ne/8),_e=Math.ceil(re/8),Se=Math.floor(ne/8),Re=ne-(fe-1)*8,Pe=re-(_e-1)*8,ze={value:0};let Ye=0;const lt=new Float32Array(64),Tt=new Uint16Array(64),At=new Uint16Array(fe*64);for(let ft=0;ft<_e;++ft){let wt=8;ft==_e-1&&(wt=Pe);for(let st=0;st<fe;++st)Tt.fill(0),Tt[0]=V[Ye++],Fe(ze,D,Tt),Be(Tt,lt),$e(lt),ct(lt,At,st*64);for(let st=8*ft;st<8*ft+wt;++st){let Kt=z[C][st];for(let Ln=0;Ln<Se;++Ln){const Yt=Ln*64+(st&7)*8;for(let kt=0;kt<8;++kt)H.setUint16(Kt+kt*2*X.type,At[Yt+kt],!0);Kt+=8*2*X.type}if(fe!=Se){const Ln=Se*64+(st&7)*8;for(let Yt=0;Yt<Re;++Yt)H.setUint16(Kt+Yt*2*X.type,At[Ln+Yt],!0)}}}X.decoded=!0}function Fe(C,z,Y){let D,V=1;for(;V<64;)D=z[C.value],D==65280?V=64:D>>8==255?V+=D&255:(Y[V]=D,V++),C.value++}function Be(C,z){z[0]=me(C[0]),z[1]=me(C[1]),z[2]=me(C[5]),z[3]=me(C[6]),z[4]=me(C[14]),z[5]=me(C[15]),z[6]=me(C[27]),z[7]=me(C[28]),z[8]=me(C[2]),z[9]=me(C[4]),z[10]=me(C[7]),z[11]=me(C[13]),z[12]=me(C[16]),z[13]=me(C[26]),z[14]=me(C[29]),z[15]=me(C[42]),z[16]=me(C[3]),z[17]=me(C[8]),z[18]=me(C[12]),z[19]=me(C[17]),z[20]=me(C[25]),z[21]=me(C[30]),z[22]=me(C[41]),z[23]=me(C[43]),z[24]=me(C[9]),z[25]=me(C[11]),z[26]=me(C[18]),z[27]=me(C[24]),z[28]=me(C[31]),z[29]=me(C[40]),z[30]=me(C[44]),z[31]=me(C[53]),z[32]=me(C[10]),z[33]=me(C[19]),z[34]=me(C[23]),z[35]=me(C[32]),z[36]=me(C[39]),z[37]=me(C[45]),z[38]=me(C[52]),z[39]=me(C[54]),z[40]=me(C[20]),z[41]=me(C[22]),z[42]=me(C[33]),z[43]=me(C[38]),z[44]=me(C[46]),z[45]=me(C[51]),z[46]=me(C[55]),z[47]=me(C[60]),z[48]=me(C[21]),z[49]=me(C[34]),z[50]=me(C[37]),z[51]=me(C[47]),z[52]=me(C[50]),z[53]=me(C[56]),z[54]=me(C[59]),z[55]=me(C[61]),z[56]=me(C[35]),z[57]=me(C[36]),z[58]=me(C[48]),z[59]=me(C[49]),z[60]=me(C[57]),z[61]=me(C[58]),z[62]=me(C[62]),z[63]=me(C[63])}function $e(C){const z=.5*Math.cos(.7853975),Y=.5*Math.cos(3.14159/16),D=.5*Math.cos(3.14159/8),V=.5*Math.cos(3*3.14159/16),Z=.5*Math.cos(5*3.14159/16),H=.5*Math.cos(3*3.14159/8),X=.5*Math.cos(7*3.14159/16),ne=new Array(4),re=new Array(4),fe=new Array(4),_e=new Array(4);for(let Se=0;Se<8;++Se){const Re=Se*8;ne[0]=D*C[Re+2],ne[1]=H*C[Re+2],ne[2]=D*C[Re+6],ne[3]=H*C[Re+6],re[0]=Y*C[Re+1]+V*C[Re+3]+Z*C[Re+5]+X*C[Re+7],re[1]=V*C[Re+1]-X*C[Re+3]-Y*C[Re+5]-Z*C[Re+7],re[2]=Z*C[Re+1]-Y*C[Re+3]+X*C[Re+5]+V*C[Re+7],re[3]=X*C[Re+1]-Z*C[Re+3]+V*C[Re+5]-Y*C[Re+7],fe[0]=z*(C[Re+0]+C[Re+4]),fe[3]=z*(C[Re+0]-C[Re+4]),fe[1]=ne[0]+ne[3],fe[2]=ne[1]-ne[2],_e[0]=fe[0]+fe[1],_e[1]=fe[3]+fe[2],_e[2]=fe[3]-fe[2],_e[3]=fe[0]-fe[1],C[Re+0]=_e[0]+re[0],C[Re+1]=_e[1]+re[1],C[Re+2]=_e[2]+re[2],C[Re+3]=_e[3]+re[3],C[Re+4]=_e[3]-re[3],C[Re+5]=_e[2]-re[2],C[Re+6]=_e[1]-re[1],C[Re+7]=_e[0]-re[0]}for(let Se=0;Se<8;++Se)ne[0]=D*C[16+Se],ne[1]=H*C[16+Se],ne[2]=D*C[48+Se],ne[3]=H*C[48+Se],re[0]=Y*C[8+Se]+V*C[24+Se]+Z*C[40+Se]+X*C[56+Se],re[1]=V*C[8+Se]-X*C[24+Se]-Y*C[40+Se]-Z*C[56+Se],re[2]=Z*C[8+Se]-Y*C[24+Se]+X*C[40+Se]+V*C[56+Se],re[3]=X*C[8+Se]-Z*C[24+Se]+V*C[40+Se]-Y*C[56+Se],fe[0]=z*(C[Se]+C[32+Se]),fe[3]=z*(C[Se]-C[32+Se]),fe[1]=ne[0]+ne[3],fe[2]=ne[1]-ne[2],_e[0]=fe[0]+fe[1],_e[1]=fe[3]+fe[2],_e[2]=fe[3]-fe[2],_e[3]=fe[0]-fe[1],C[0+Se]=_e[0]+re[0],C[8+Se]=_e[1]+re[1],C[16+Se]=_e[2]+re[2],C[24+Se]=_e[3]+re[3],C[32+Se]=_e[3]-re[3],C[40+Se]=_e[2]-re[2],C[48+Se]=_e[1]-re[1],C[56+Se]=_e[0]-re[0]}function Je(C){for(let z=0;z<64;++z){const Y=C[0][z],D=C[1][z],V=C[2][z];C[0][z]=Y+1.5747*V,C[1][z]=Y-.1873*D-.4682*V,C[2][z]=Y+1.8556*D}}function ct(C,z,Y){for(let D=0;D<64;++D)z[Y+D]=gE.toHalfFloat(k(C[D]))}function k(C){return C<=1?Math.sign(C)*Math.pow(Math.abs(C),2.2):Math.sign(C)*Math.pow(O,Math.abs(C)-1)}function P(C){return new DataView(C.array.buffer,C.offset.value,C.size)}function ce(C){const z=C.viewer.buffer.slice(C.offset.value,C.offset.value+C.size),Y=new Uint8Array(G(z)),D=new Uint8Array(Y.length);return Ke(Y),Te(Y,D),new DataView(D.buffer)}function Ee(C){const z=C.array.slice(C.offset.value,C.offset.value+C.size),Y=Zv(z),D=new Uint8Array(Y.length);return Ke(Y),Te(Y,D),new DataView(D.buffer)}function Le(C){const z=C.viewer,Y={value:C.offset.value},D=new Uint16Array(C.columns*C.lines*(C.inputChannels.length*C.type)),V=new Uint8Array(8192);let Z=0;const H=new Array(C.inputChannels.length);for(let Pe=0,ze=C.inputChannels.length;Pe<ze;Pe++)H[Pe]={},H[Pe].start=Z,H[Pe].end=H[Pe].start,H[Pe].nx=C.columns,H[Pe].ny=C.lines,H[Pe].size=C.type,Z+=H[Pe].nx*H[Pe].ny*H[Pe].size;const X=We(z,Y),ne=We(z,Y);if(ne>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(X<=ne)for(let Pe=0;Pe<ne-X+1;Pe++)V[Pe+X]=pe(z,Y);const re=new Uint16Array(65536),fe=w(V,re),_e=ht(z,Y);bt(C.array,z,Y,_e,D,Z);for(let Pe=0;Pe<C.inputChannels.length;++Pe){const ze=H[Pe];for(let Ye=0;Ye<H[Pe].size;++Ye)ue(D,ze.start+Ye,ze.nx,ze.size,ze.ny,ze.nx*ze.size,fe)}ot(re,D,Z);let Se=0;const Re=new Uint8Array(D.buffer.byteLength);for(let Pe=0;Pe<C.lines;Pe++)for(let ze=0;ze<C.inputChannels.length;ze++){const Ye=H[ze],lt=Ye.nx*Ye.size,Tt=new Uint8Array(D.buffer,Ye.end*2,lt*2);Re.set(Tt,Se),Se+=lt*2,Ye.end+=lt}return new DataView(Re.buffer)}function ye(C){const z=C.array.slice(C.offset.value,C.offset.value+C.size),Y=Zv(z),D=C.inputChannels.length*C.lines*C.columns*C.totalBytes,V=new ArrayBuffer(D),Z=new DataView(V);let H=0,X=0;const ne=new Array(4);for(let re=0;re<C.lines;re++)for(let fe=0;fe<C.inputChannels.length;fe++){let _e=0;switch(C.inputChannels[fe].pixelType){case 1:ne[0]=H,ne[1]=ne[0]+C.columns,H=ne[1]+C.columns;for(let Re=0;Re<C.columns;++Re){const Pe=Y[ne[0]++]<<8|Y[ne[1]++];_e+=Pe,Z.setUint16(X,_e,!0),X+=2}break;case 2:ne[0]=H,ne[1]=ne[0]+C.columns,ne[2]=ne[1]+C.columns,H=ne[2]+C.columns;for(let Re=0;Re<C.columns;++Re){const Pe=Y[ne[0]++]<<24|Y[ne[1]++]<<16|Y[ne[2]++]<<8;_e+=Pe,Z.setUint32(X,_e,!0),X+=4}break}}return Z}function vt(C){const z=C.viewer,Y={value:C.offset.value},D=new Uint8Array(C.columns*C.lines*(C.inputChannels.length*C.type*2)),V={version:Oe(z,Y),unknownUncompressedSize:Oe(z,Y),unknownCompressedSize:Oe(z,Y),acCompressedSize:Oe(z,Y),dcCompressedSize:Oe(z,Y),rleCompressedSize:Oe(z,Y),rleUncompressedSize:Oe(z,Y),rleRawSize:Oe(z,Y),totalAcUncompressedCount:Oe(z,Y),totalDcUncompressedCount:Oe(z,Y),acCompression:Oe(z,Y)};if(V.version<2)throw new Error("EXRLoader.parse: "+la.compression+" version "+V.version+" is unsupported");const Z=new Array;let H=We(z,Y)-2;for(;H>0;){const ze=je(z.buffer,Y),Ye=pe(z,Y),lt=Ye>>2&3,Tt=(Ye>>4)-1,At=new Int8Array([Tt])[0],ft=pe(z,Y);Z.push({name:ze,index:At,type:ft,compression:lt}),H-=ze.length+3}const X=la.channels,ne=new Array(C.inputChannels.length);for(let ze=0;ze<C.inputChannels.length;++ze){const Ye=ne[ze]={},lt=X[ze];Ye.name=lt.name,Ye.compression=0,Ye.decoded=!1,Ye.type=lt.pixelType,Ye.pLinear=lt.pLinear,Ye.width=C.columns,Ye.height=C.lines}const re={idx:new Array(3)};for(let ze=0;ze<C.inputChannels.length;++ze){const Ye=ne[ze];for(let lt=0;lt<Z.length;++lt){const Tt=Z[lt];Ye.name==Tt.name&&(Ye.compression=Tt.compression,Tt.index>=0&&(re.idx[Tt.index]=ze),Ye.offset=ze)}}let fe,_e,Se;if(V.acCompressedSize>0)switch(V.acCompression){case 0:fe=new Uint16Array(V.totalAcUncompressedCount),bt(C.array,z,Y,V.acCompressedSize,fe,V.totalAcUncompressedCount);break;case 1:const ze=C.array.slice(Y.value,Y.value+V.totalAcUncompressedCount),Ye=Zv(ze);fe=new Uint16Array(Ye.buffer),Y.value+=V.totalAcUncompressedCount;break}if(V.dcCompressedSize>0){const ze={array:C.array,offset:Y,size:V.dcCompressedSize};_e=new Uint16Array(Ee(ze).buffer),Y.value+=V.dcCompressedSize}if(V.rleRawSize>0){const ze=C.array.slice(Y.value,Y.value+V.rleCompressedSize),Ye=Zv(ze);Se=G(Ye.buffer),Y.value+=V.rleCompressedSize}let Re=0;const Pe=new Array(ne.length);for(let ze=0;ze<Pe.length;++ze)Pe[ze]=new Array;for(let ze=0;ze<C.lines;++ze)for(let Ye=0;Ye<ne.length;++Ye)Pe[Ye].push(Re),Re+=ne[Ye].width*C.type*2;re.idx[0]!==void 0&&ne[re.idx[0]]&&be(re,Pe,ne,fe,_e,D);for(let ze=0;ze<ne.length;++ze){const Ye=ne[ze];if(!Ye.decoded)switch(Ye.compression){case 2:let lt=0,Tt=0;for(let At=0;At<C.lines;++At){let ft=Pe[ze][lt];for(let wt=0;wt<Ye.width;++wt){for(let st=0;st<2*Ye.type;++st)D[ft++]=Se[Tt+st*Ye.width*Ye.height];Tt++}lt++}break;case 1:Ne(ze,Pe,ne,fe,_e,D);break;default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(D.buffer)}function je(C,z){const Y=new Uint8Array(C);let D=0;for(;Y[z.value+D]!=0;)D+=1;const V=new TextDecoder().decode(Y.slice(z.value,z.value+D));return z.value=z.value+D+1,V}function xt(C,z,Y){const D=new TextDecoder().decode(new Uint8Array(C).slice(z.value,z.value+Y));return z.value=z.value+Y,D}function pt(C,z){const Y=He(C,z),D=ht(C,z);return[Y,D]}function Ie(C,z){const Y=ht(C,z),D=ht(C,z);return[Y,D]}function He(C,z){const Y=C.getInt32(z.value,!0);return z.value=z.value+4,Y}function ht(C,z){const Y=C.getUint32(z.value,!0);return z.value=z.value+4,Y}function Q(C,z){const Y=C[z.value];return z.value=z.value+1,Y}function pe(C,z){const Y=C.getUint8(z.value);return z.value=z.value+1,Y}const Oe=function(C,z){let Y;return"getBigInt64"in DataView.prototype?Y=Number(C.getBigInt64(z.value,!0)):Y=C.getUint32(z.value+4,!0)+Number(C.getUint32(z.value,!0)<<32),z.value+=8,Y};function q(C,z){const Y=C.getFloat32(z.value,!0);return z.value+=4,Y}function ke(C,z){return gE.toHalfFloat(q(C,z))}function me(C){const z=(C&31744)>>10,Y=C&1023;return(C>>15?-1:1)*(z?z===31?Y?NaN:1/0:Math.pow(2,z-15)*(1+Y/1024):6103515625e-14*(Y/1024))}function We(C,z){const Y=C.getUint16(z.value,!0);return z.value+=2,Y}function Ge(C,z){return me(We(C,z))}function we(C,z,Y,D){const V=Y.value,Z=[];for(;Y.value<V+D-1;){const H=je(z,Y),X=He(C,Y),ne=pe(C,Y);Y.value+=3;const re=He(C,Y),fe=He(C,Y);Z.push({name:H,pixelType:X,pLinear:ne,xSampling:re,ySampling:fe})}return Y.value+=1,Z}function at(C,z){const Y=q(C,z),D=q(C,z),V=q(C,z),Z=q(C,z),H=q(C,z),X=q(C,z),ne=q(C,z),re=q(C,z);return{redX:Y,redY:D,greenX:V,greenY:Z,blueX:H,blueY:X,whiteX:ne,whiteY:re}}function St(C,z){const Y=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],D=pe(C,z);return Y[D]}function Gt(C,z){const Y=He(C,z),D=He(C,z),V=He(C,z),Z=He(C,z);return{xMin:Y,yMin:D,xMax:V,yMax:Z}}function Vt(C,z){const Y=["INCREASING_Y","DECREASING_Y","RANDOM_Y"],D=pe(C,z);return Y[D]}function li(C,z){const Y=["ENVMAP_LATLONG","ENVMAP_CUBE"],D=pe(C,z);return Y[D]}function ci(C,z){const Y=["ONE_LEVEL","MIPMAP_LEVELS","RIPMAP_LEVELS"],D=["ROUND_DOWN","ROUND_UP"],V=ht(C,z),Z=ht(C,z),H=pe(C,z);return{xSize:V,ySize:Z,levelMode:Y[H&15],roundingMode:D[H>>4]}}function ho(C,z){const Y=q(C,z),D=q(C,z);return[Y,D]}function Us(C,z){const Y=q(C,z),D=q(C,z),V=q(C,z);return[Y,D,V]}function Ps(C,z,Y,D,V){if(D==="string"||D==="stringvector"||D==="iccProfile")return xt(z,Y,V);if(D==="chlist")return we(C,z,Y,V);if(D==="chromaticities")return at(C,Y);if(D==="compression")return St(C,Y);if(D==="box2i")return Gt(C,Y);if(D==="envmap")return li(C,Y);if(D==="tiledesc")return ci(C,Y);if(D==="lineOrder")return Vt(C,Y);if(D==="float")return q(C,Y);if(D==="v2f")return ho(C,Y);if(D==="v3f")return Us(C,Y);if(D==="int")return He(C,Y);if(D==="rational")return pt(C,Y);if(D==="timecode")return Ie(C,Y);if(D==="preview")return Y.value+=V,"skipped";Y.value+=V}function Mi(C,z){const Y=Math.log2(C);return z=="ROUND_DOWN"?Math.floor(Y):Math.ceil(Y)}function zs(C,z,Y){let D=0;switch(C.levelMode){case"ONE_LEVEL":D=1;break;case"MIPMAP_LEVELS":D=Mi(Math.max(z,Y),C.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return D}function fr(C,z,Y,D){const V=new Array(C);for(let Z=0;Z<C;Z++){const H=1<<Z;let X=z/H|0;D=="ROUND_UP"&&X*H<z&&(X+=1);const ne=Math.max(X,1);V[Z]=(ne+Y-1)/Y|0}return V}function Xi(){const C=this,z=C.offset,Y={value:0};for(let D=0;D<C.tileCount;D++){const V=He(C.viewer,z),Z=He(C.viewer,z);z.value+=8,C.size=ht(C.viewer,z);const H=V*C.blockWidth,X=Z*C.blockHeight;C.columns=H+C.blockWidth>C.width?C.width-H:C.blockWidth,C.lines=X+C.blockHeight>C.height?C.height-X:C.blockHeight;const ne=C.columns*C.totalBytes,fe=C.size<C.lines*ne?C.uncompress(C):P(C);z.value+=C.size;for(let _e=0;_e<C.lines;_e++){const Se=_e*C.columns*C.totalBytes;for(let Re=0;Re<C.inputChannels.length;Re++){const Pe=la.channels[Re].name,ze=C.channelByteOffsets[Pe]*C.columns,Ye=C.decodeChannels[Pe];if(Ye===void 0)continue;Y.value=Se+ze;const lt=(C.height-(1+X+_e))*C.outLineWidth;for(let Tt=0;Tt<C.columns;Tt++){const At=lt+(Tt+H)*C.outputChannels+Ye;C.byteArray[At]=C.getter(fe,Y)}}}}}function Gr(){const C=this,z=C.offset,Y={value:0};for(let D=0;D<C.height/C.blockHeight;D++){const V=He(C.viewer,z)-la.dataWindow.yMin;C.size=ht(C.viewer,z),C.lines=V+C.blockHeight>C.height?C.height-V:C.blockHeight;const Z=C.columns*C.totalBytes,X=C.size<C.lines*Z?C.uncompress(C):P(C);z.value+=C.size;for(let ne=0;ne<C.blockHeight;ne++){const re=D*C.blockHeight,fe=ne+C.scanOrder(re);if(fe>=C.height)continue;const _e=ne*Z,Se=(C.height-1-fe)*C.outLineWidth;for(let Re=0;Re<C.inputChannels.length;Re++){const Pe=la.channels[Re].name,ze=C.channelByteOffsets[Pe]*C.columns,Ye=C.decodeChannels[Pe];if(Ye!==void 0){Y.value=_e+ze;for(let lt=0;lt<C.columns;lt++){const Tt=Se+lt*C.outputChannels+Ye;C.byteArray[Tt]=C.getter(X,Y)}}}}}}function On(C,z,Y){const D={};if(C.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");D.version=C.getUint8(4);const V=C.getUint8(5);D.spec={singleTile:!!(V&2),longName:!!(V&4),deepFormat:!!(V&8),multiPart:!!(V&16)},Y.value=8;let Z=!0;for(;Z;){const H=je(z,Y);if(H==="")Z=!1;else{const X=je(z,Y),ne=ht(C,Y),re=Ps(C,z,Y,X,ne);re===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${X}'.`):D[H]=re}}if(V&-7)throw console.error("THREE.EXRHeader:",D),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return D}function Ua(C,z,Y,D,V,Z){const H={size:0,viewer:z,array:Y,offset:D,width:C.dataWindow.xMax-C.dataWindow.xMin+1,height:C.dataWindow.yMax-C.dataWindow.yMin+1,inputChannels:C.channels,channelByteOffsets:{},shouldExpand:!1,scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:Fn};switch(C.compression){case"NO_COMPRESSION":H.blockHeight=1,H.uncompress=P;break;case"RLE_COMPRESSION":H.blockHeight=1,H.uncompress=ce;break;case"ZIPS_COMPRESSION":H.blockHeight=1,H.uncompress=Ee;break;case"ZIP_COMPRESSION":H.blockHeight=16,H.uncompress=Ee;break;case"PIZ_COMPRESSION":H.blockHeight=32,H.uncompress=Le;break;case"PXR24_COMPRESSION":H.blockHeight=16,H.uncompress=ye;break;case"DWAA_COMPRESSION":H.blockHeight=32,H.uncompress=vt;break;case"DWAB_COMPRESSION":H.blockHeight=256,H.uncompress=vt;break;default:throw new Error("EXRLoader.parse: "+C.compression+" is unsupported")}const X={};for(const Se of C.channels)switch(Se.name){case"Y":case"R":case"G":case"B":case"A":X[Se.name]=!0,H.type=Se.pixelType}let ne=!1,re=!1;if(X.R&&X.G&&X.B)H.outputChannels=4;else if(X.Y)H.outputChannels=1;else throw new Error("EXRLoader.parse: file contains unsupported data channels.");switch(H.outputChannels){case 4:Z==$n?(ne=!X.A,H.format=$n,H.colorSpace=Fn,H.outputChannels=4,H.decodeChannels={R:0,G:1,B:2,A:3}):Z==Xo?(H.format=Xo,H.colorSpace=Fn,H.outputChannels=2,H.decodeChannels={R:0,G:1}):Z==ws?(H.format=ws,H.colorSpace=Fn,H.outputChannels=1,H.decodeChannels={R:0}):re=!0;break;case 1:Z==$n?(ne=!0,H.format=$n,H.colorSpace=Fn,H.outputChannels=4,H.shouldExpand=!0,H.decodeChannels={Y:0}):Z==Xo?(H.format=Xo,H.colorSpace=Fn,H.outputChannels=2,H.shouldExpand=!0,H.decodeChannels={Y:0}):Z==ws?(H.format=ws,H.colorSpace=Fn,H.outputChannels=1,H.decodeChannels={Y:0}):re=!0;break;default:re=!0}if(re)throw new Error("EXRLoader.parse: invalid output format for specified file.");if(H.type==1)switch(V){case si:H.getter=Ge;break;case Yn:H.getter=We;break}else if(H.type==2)switch(V){case si:H.getter=q;break;case Yn:H.getter=ke}else throw new Error("EXRLoader.parse: unsupported pixelType "+H.type+" for "+C.compression+".");H.columns=H.width;const fe=H.width*H.height*H.outputChannels;switch(V){case si:H.byteArray=new Float32Array(fe),ne&&H.byteArray.fill(1,0,fe);break;case Yn:H.byteArray=new Uint16Array(fe),ne&&H.byteArray.fill(15360,0,fe);break;default:console.error("THREE.EXRLoader: unsupported type: ",V);break}let _e=0;for(const Se of C.channels)H.decodeChannels[Se.name]!==void 0&&(H.channelByteOffsets[Se.name]=_e),_e+=Se.pixelType*2;if(H.totalBytes=_e,H.outLineWidth=H.width*H.outputChannels,C.lineOrder==="INCREASING_Y"?H.scanOrder=Se=>Se:H.scanOrder=Se=>H.height-1-Se,C.spec.singleTile){H.blockHeight=C.tiles.ySize,H.blockWidth=C.tiles.xSize;const Se=zs(C.tiles,H.width,H.height),Re=fr(Se,H.width,C.tiles.xSize,C.tiles.roundingMode),Pe=fr(Se,H.height,C.tiles.ySize,C.tiles.roundingMode);H.tileCount=Re[0]*Pe[0];for(let ze=0;ze<Se;ze++)for(let Ye=0;Ye<Pe[ze];Ye++)for(let lt=0;lt<Re[ze];lt++)Oe(z,D);H.decode=Xi.bind(H)}else{H.blockWidth=H.width;const Se=Math.ceil(H.height/H.blockHeight);for(let Re=0;Re<Se;Re++)Oe(z,D);H.decode=Gr.bind(H)}return H}const Bs={value:0},Hs=new DataView(e),fo=new Uint8Array(e),la=On(Hs,e,Bs),dr=Ua(la,Hs,fo,Bs,this.type,this.outputFormat);if(dr.decode(),dr.shouldExpand){const C=dr.byteArray;if(this.outputFormat==$n)for(let z=0;z<C.length;z+=4)C[z+2]=C[z+1]=C[z];else if(this.outputFormat==Xo)for(let z=0;z<C.length;z+=2)C[z+1]=C[z]}return{header:la,width:dr.width,height:dr.height,data:dr.byteArray,format:dr.format,colorSpace:dr.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}setOutputFormat(e){return this.outputFormat=e,this}load(e,t,i,r){function a(s,o){s.colorSpace=o.colorSpace,s.minFilter=Ht,s.magFilter=Ht,s.generateMipmaps=!1,s.flipY=!1,t&&t(s,o)}return super.load(e,a,i,r)}}let Vee=class extends yi{load(e,t,i,r){const a=new na(this.manager);a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(this.withCredentials),a.load(e,s=>{i1(s instanceof ArrayBuffer);try{t(s)}catch(o){r!=null?r(o):console.error(o),this.manager.itemError(e)}},i,r)}};function fP(n){var e,t;return n instanceof lA?n.getContext().getExtension("OES_texture_float_linear")!=null:((t=(e=n.backend).hasFeature)==null?void 0:t.call(e,"float32-filterable"))??!1}const kee=128,Wee=128,Xee=64,Yee="9627216cc50057994c98a2118f3c4a23765d43b9",dP=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${Yee}/packages/core/assets/stbn.bin`,qee="This is not an object",jee="This is not a Float16Array object",pO="This constructor is not a subclass of Float16Array",pP="The constructor property value is not an object",Zee="Species constructor didn't return TypedArray object",Kee="Derived constructor created TypedArray object which was too small length",qm="Attempting to access detached ArrayBuffer",qE="Cannot convert undefined or null to object",jE="Cannot mix BigInt and other types, use explicit conversions",mO="@@iterator property is not callable",gO="Reduce of empty array with no initial value",Qee="The comparison function must be either a function or undefined",n3="Offset is out of bounds";function Zn(n){return(e,...t)=>Zr(n,e,t)}function ep(n,e){return Zn(Pd(n,e).get)}const{apply:Zr,construct:xm,defineProperty:Jee,get:i3,getOwnPropertyDescriptor:Pd,getPrototypeOf:K0,has:ZE,ownKeys:mP,set:vO,setPrototypeOf:gP}=Reflect,$ee=Proxy,{EPSILON:ete,MAX_SAFE_INTEGER:_O,isFinite:vP,isNaN:zd}=Number,{iterator:lo,species:tte,toStringTag:_A,for:nte}=Symbol,Bd=Object,{create:gy,defineProperty:Q0,freeze:ite,is:xO}=Bd,KE=Bd.prototype,rte=KE.__lookupGetter__?Zn(KE.__lookupGetter__):(n,e)=>{if(n==null)throw ri(qE);let t=Bd(n);do{const i=Pd(t,e);if(i!==void 0)return qo(i,"get")?i.get:void 0}while((t=K0(t))!==null)},qo=Bd.hasOwn||Zn(KE.hasOwnProperty),_P=Array,xP=_P.isArray,vy=_P.prototype,ate=Zn(vy.join),ste=Zn(vy.push),ote=Zn(vy.toLocaleString),xA=vy[lo],lte=Zn(xA),{abs:cte,trunc:yP}=Math,_y=ArrayBuffer,ute=_y.isView,SP=_y.prototype,hte=Zn(SP.slice),fte=ep(SP,"byteLength"),QE=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:null,dte=QE&&ep(QE.prototype,"byteLength"),yA=K0(Uint8Array),pte=yA.from,ir=yA.prototype,mte=ir[lo],gte=Zn(ir.keys),vte=Zn(ir.values),_te=Zn(ir.entries),xte=Zn(ir.set),yO=Zn(ir.reverse),yte=Zn(ir.fill),Ste=Zn(ir.copyWithin),SO=Zn(ir.sort),im=Zn(ir.slice),Tte=Zn(ir.subarray),Ki=ep(ir,"buffer"),pu=ep(ir,"byteOffset"),En=ep(ir,"length"),TP=ep(ir,_A),Ete=Uint8Array,Sa=Uint16Array,TO=(...n)=>Zr(pte,Sa,n),SA=Uint32Array,Mte=Float32Array,rh=K0([][lo]()),xy=Zn(rh.next),bte=Zn(function*(){}().next),Ate=K0(rh),wte=DataView.prototype,Rte=Zn(wte.getUint16),ri=TypeError,r3=RangeError,EP=WeakSet,MP=EP.prototype,Cte=Zn(MP.add),Dte=Zn(MP.has),yy=WeakMap,TA=yy.prototype,r1=Zn(TA.get),Nte=Zn(TA.has),EA=Zn(TA.set),bP=new yy,Ote=gy(null,{next:{value:function(){const n=r1(bP,this);return xy(n)}},[lo]:{value:function(){return this}}});function ym(n){if(n[lo]===xA&&rh.next===xy)return n;const e=gy(Ote);return EA(bP,e,lte(n)),e}const AP=new yy,wP=gy(Ate,{next:{value:function(){const n=r1(AP,this);return bte(n)},writable:!0,configurable:!0}});for(const n of mP(rh))n!=="next"&&Q0(wP,n,Pd(rh,n));function EO(n){const e=gy(wP);return EA(AP,e,n),e}function a1(n){return n!==null&&typeof n=="object"||typeof n=="function"}function MO(n){return n!==null&&typeof n=="object"}function s1(n){return TP(n)!==void 0}function JE(n){const e=TP(n);return e==="BigInt64Array"||e==="BigUint64Array"}function Lte(n){try{return xP(n)?!1:(fte(n),!0)}catch{return!1}}function RP(n){if(QE===null)return!1;try{return dte(n),!0}catch{return!1}}function Ite(n){return Lte(n)||RP(n)}function bO(n){return xP(n)?n[lo]===xA&&rh.next===xy:!1}function Ute(n){return s1(n)?n[lo]===mte&&rh.next===xy:!1}function Kv(n){if(typeof n!="string")return!1;const e=+n;return n!==e+""||!vP(e)?!1:e===yP(e)}const o1=nte("__Float16Array__");function Pte(n){if(!MO(n))return!1;const e=K0(n);if(!MO(e))return!1;const t=e.constructor;if(t===void 0)return!1;if(!a1(t))throw ri(pP);return ZE(t,o1)}const $E=1/ete;function zte(n){return n+$E-$E}const CP=6103515625e-14,Bte=65504,DP=.0009765625,AO=DP*CP,Hte=DP*$E;function Fte(n){const e=+n;if(!vP(e)||e===0)return e;const t=e>0?1:-1,i=cte(e);if(i<CP)return t*zte(i/AO)*AO;const r=(1+Hte)*i,a=r-(r-i);return a>Bte||zd(a)?t*(1/0):t*a}const NP=new _y(4),OP=new Mte(NP),LP=new SA(NP),ys=new Sa(512),Ss=new Ete(512);for(let n=0;n<256;++n){const e=n-127;e<-24?(ys[n]=0,ys[n|256]=32768,Ss[n]=24,Ss[n|256]=24):e<-14?(ys[n]=1024>>-e-14,ys[n|256]=1024>>-e-14|32768,Ss[n]=-e-1,Ss[n|256]=-e-1):e<=15?(ys[n]=e+15<<10,ys[n|256]=e+15<<10|32768,Ss[n]=13,Ss[n|256]=13):e<128?(ys[n]=31744,ys[n|256]=64512,Ss[n]=24,Ss[n|256]=24):(ys[n]=31744,ys[n|256]=64512,Ss[n]=13,Ss[n|256]=13)}function Ks(n){OP[0]=Fte(n);const e=LP[0],t=e>>23&511;return ys[t]+((e&8388607)>>Ss[t])}const MA=new SA(2048);for(let n=1;n<1024;++n){let e=n<<13,t=0;for(;!(e&8388608);)e<<=1,t-=8388608;e&=-8388609,t+=947912704,MA[n]=e|t}for(let n=1024;n<2048;++n)MA[n]=939524096+(n-1024<<13);const tp=new SA(64);for(let n=1;n<31;++n)tp[n]=n<<23;tp[31]=1199570944;tp[32]=2147483648;for(let n=33;n<63;++n)tp[n]=2147483648+(n-32<<23);tp[63]=3347054592;const IP=new Sa(64);for(let n=1;n<64;++n)n!==32&&(IP[n]=1024);function An(n){const e=n>>10;return LP[0]=MA[IP[e]+(n&1023)]+tp[e],OP[0]}function Ho(n){const e=+n;return zd(e)||e===0?0:yP(e)}function a3(n){const e=Ho(n);return e<0?0:e<_O?e:_O}function Qv(n,e){if(!a1(n))throw ri(qee);const t=n.constructor;if(t===void 0)return e;if(!a1(t))throw ri(pP);return t[tte]??e}function jm(n){if(RP(n))return!1;try{return hte(n,0,0),!1}catch{}return!0}function wO(n,e){const t=zd(n),i=zd(e);if(t&&i)return 0;if(t)return 1;if(i||n<e)return-1;if(n>e)return 1;if(n===0&&e===0){const r=xO(n,0),a=xO(e,0);if(!r&&a)return-1;if(r&&!a)return 1}return 0}const bA=2,l1=new yy;function Zf(n){return Nte(l1,n)||!ute(n)&&Pte(n)}function Tn(n){if(!Zf(n))throw ri(jee)}function Jv(n,e){const t=Zf(n),i=s1(n);if(!t&&!i)throw ri(Zee);if(typeof e=="number"){let r;if(t){const a=Jt(n);r=En(a)}else r=En(n);if(r<e)throw ri(Kee)}if(JE(n))throw ri(jE)}function Jt(n){const e=r1(l1,n);if(e!==void 0){const r=Ki(e);if(jm(r))throw ri(qm);return e}const t=n.buffer;if(jm(t))throw ri(qm);const i=xm(dl,[t,n.byteOffset,n.length],n.constructor);return r1(l1,i)}function RO(n){const e=En(n),t=[];for(let i=0;i<e;++i)t[i]=An(n[i]);return t}const UP=new EP;for(const n of mP(ir)){if(n===_A)continue;const e=Pd(ir,n);qo(e,"get")&&typeof e.get=="function"&&Cte(UP,e.get)}const Gte=ite({get(n,e,t){return Kv(e)&&qo(n,e)?An(i3(n,e)):Dte(UP,rte(n,e))?i3(n,e):i3(n,e,t)},set(n,e,t,i){return Kv(e)&&qo(n,e)?vO(n,e,Ks(t)):vO(n,e,t,i)},getOwnPropertyDescriptor(n,e){if(Kv(e)&&qo(n,e)){const t=Pd(n,e);return t.value=An(t.value),t}return Pd(n,e)},defineProperty(n,e,t){return Kv(e)&&qo(n,e)&&qo(t,"value")&&(t.value=Ks(t.value)),Jee(n,e,t)}});let dl=class Qi{constructor(e,t,i){let r;if(Zf(e))r=xm(Sa,[Jt(e)],new.target);else if(a1(e)&&!Ite(e)){let s,o;if(s1(e)){s=e,o=En(e);const l=Ki(e);if(jm(l))throw ri(qm);if(JE(e))throw ri(jE);const h=new _y(o*bA);r=xm(Sa,[h],new.target)}else{const l=e[lo];if(l!=null&&typeof l!="function")throw ri(mO);l!=null?bO(e)?(s=e,o=e.length):(s=[...e],o=s.length):(s=e,o=a3(s.length)),r=xm(Sa,[o],new.target)}for(let l=0;l<o;++l)r[l]=Ks(s[l])}else r=xm(Sa,arguments,new.target);const a=new $ee(r,Gte);return EA(l1,a,r),a}static from(e,...t){const i=this;if(!ZE(i,o1))throw ri(pO);if(i===Qi){if(Zf(e)&&t.length===0){const f=Jt(e),d=new Sa(Ki(f),pu(f),En(f));return new Qi(Ki(im(d)))}if(t.length===0)return new Qi(Ki(TO(e,Ks)));const l=t[0],h=t[1];return new Qi(Ki(TO(e,function(f,...d){return Ks(Zr(l,this,[f,...ym(d)]))},h)))}let r,a;const s=e[lo];if(s!=null&&typeof s!="function")throw ri(mO);if(s!=null)bO(e)?(r=e,a=e.length):Ute(e)?(r=e,a=En(e)):(r=[...e],a=r.length);else{if(e==null)throw ri(qE);r=Bd(e),a=a3(r.length)}const o=new i(a);if(t.length===0)for(let l=0;l<a;++l)o[l]=r[l];else{const l=t[0],h=t[1];for(let f=0;f<a;++f)o[f]=Zr(l,h,[r[f],f])}return o}static of(...e){const t=this;if(!ZE(t,o1))throw ri(pO);const i=e.length;if(t===Qi){const a=new Qi(i),s=Jt(a);for(let o=0;o<i;++o)s[o]=Ks(e[o]);return a}const r=new t(i);for(let a=0;a<i;++a)r[a]=e[a];return r}keys(){Tn(this);const e=Jt(this);return gte(e)}values(){Tn(this);const e=Jt(this);return EO(function*(){for(const t of vte(e))yield An(t)}())}entries(){Tn(this);const e=Jt(this);return EO(function*(){for(const[t,i]of _te(e))yield[t,An(i)]}())}at(e){Tn(this);const t=Jt(this),i=En(t),r=Ho(e),a=r>=0?r:i+r;if(!(a<0||a>=i))return An(t[a])}with(e,t){Tn(this);const i=Jt(this),r=En(i),a=Ho(e),s=a>=0?a:r+a,o=+t;if(s<0||s>=r)throw r3(n3);const l=new Sa(Ki(i),pu(i),En(i)),h=new Qi(Ki(im(l))),f=Jt(h);return f[s]=Ks(o),h}map(e,...t){Tn(this);const i=Jt(this),r=En(i),a=t[0],s=Qv(i,Qi);if(s===Qi){const l=new Qi(r),h=Jt(l);for(let f=0;f<r;++f){const d=An(i[f]);h[f]=Ks(Zr(e,a,[d,f,this]))}return l}const o=new s(r);Jv(o,r);for(let l=0;l<r;++l){const h=An(i[l]);o[l]=Zr(e,a,[h,l,this])}return o}filter(e,...t){Tn(this);const i=Jt(this),r=En(i),a=t[0],s=[];for(let h=0;h<r;++h){const f=An(i[h]);Zr(e,a,[f,h,this])&&ste(s,f)}const o=Qv(i,Qi),l=new o(s);return Jv(l),l}reduce(e,...t){Tn(this);const i=Jt(this),r=En(i);if(r===0&&t.length===0)throw ri(gO);let a,s;t.length===0?(a=An(i[0]),s=1):(a=t[0],s=0);for(let o=s;o<r;++o)a=e(a,An(i[o]),o,this);return a}reduceRight(e,...t){Tn(this);const i=Jt(this),r=En(i);if(r===0&&t.length===0)throw ri(gO);let a,s;t.length===0?(a=An(i[r-1]),s=r-2):(a=t[0],s=r-1);for(let o=s;o>=0;--o)a=e(a,An(i[o]),o,this);return a}forEach(e,...t){Tn(this);const i=Jt(this),r=En(i),a=t[0];for(let s=0;s<r;++s)Zr(e,a,[An(i[s]),s,this])}find(e,...t){Tn(this);const i=Jt(this),r=En(i),a=t[0];for(let s=0;s<r;++s){const o=An(i[s]);if(Zr(e,a,[o,s,this]))return o}}findIndex(e,...t){Tn(this);const i=Jt(this),r=En(i),a=t[0];for(let s=0;s<r;++s){const o=An(i[s]);if(Zr(e,a,[o,s,this]))return s}return-1}findLast(e,...t){Tn(this);const i=Jt(this),r=En(i),a=t[0];for(let s=r-1;s>=0;--s){const o=An(i[s]);if(Zr(e,a,[o,s,this]))return o}}findLastIndex(e,...t){Tn(this);const i=Jt(this),r=En(i),a=t[0];for(let s=r-1;s>=0;--s){const o=An(i[s]);if(Zr(e,a,[o,s,this]))return s}return-1}every(e,...t){Tn(this);const i=Jt(this),r=En(i),a=t[0];for(let s=0;s<r;++s)if(!Zr(e,a,[An(i[s]),s,this]))return!1;return!0}some(e,...t){Tn(this);const i=Jt(this),r=En(i),a=t[0];for(let s=0;s<r;++s)if(Zr(e,a,[An(i[s]),s,this]))return!0;return!1}set(e,...t){Tn(this);const i=Jt(this),r=Ho(t[0]);if(r<0)throw r3(n3);if(e==null)throw ri(qE);if(JE(e))throw ri(jE);if(Zf(e))return xte(Jt(this),Jt(e),r);if(s1(e)){const l=Ki(e);if(jm(l))throw ri(qm)}const a=En(i),s=Bd(e),o=a3(s.length);if(r===1/0||o+r>a)throw r3(n3);for(let l=0;l<o;++l)i[l+r]=Ks(s[l])}reverse(){Tn(this);const e=Jt(this);return yO(e),this}toReversed(){Tn(this);const e=Jt(this),t=new Sa(Ki(e),pu(e),En(e)),i=new Qi(Ki(im(t))),r=Jt(i);return yO(r),i}fill(e,...t){Tn(this);const i=Jt(this);return yte(i,Ks(e),...ym(t)),this}copyWithin(e,t,...i){Tn(this);const r=Jt(this);return Ste(r,e,t,...ym(i)),this}sort(e){Tn(this);const t=Jt(this),i=e!==void 0?e:wO;return SO(t,(r,a)=>i(An(r),An(a))),this}toSorted(e){Tn(this);const t=Jt(this);if(e!==void 0&&typeof e!="function")throw new ri(Qee);const i=e!==void 0?e:wO,r=new Sa(Ki(t),pu(t),En(t)),a=new Qi(Ki(im(r))),s=Jt(a);return SO(s,(o,l)=>i(An(o),An(l))),a}slice(e,t){Tn(this);const i=Jt(this),r=Qv(i,Qi);if(r===Qi){const _=new Sa(Ki(i),pu(i),En(i));return new Qi(Ki(im(_,e,t)))}const a=En(i),s=Ho(e),o=t===void 0?a:Ho(t);let l;s===-1/0?l=0:s<0?l=a+s>0?a+s:0:l=a<s?a:s;let h;o===-1/0?h=0:o<0?h=a+o>0?a+o:0:h=a<o?a:o;const f=h-l>0?h-l:0,d=new r(f);if(Jv(d,f),f===0)return d;const p=Ki(i);if(jm(p))throw ri(qm);let g=0;for(;l<h;)d[g]=An(i[l]),++l,++g;return d}subarray(e,t){Tn(this);const i=Jt(this),r=Qv(i,Qi),a=new Sa(Ki(i),pu(i),En(i)),s=Tte(a,e,t),o=new r(Ki(s),pu(s),En(s));return Jv(o),o}indexOf(e,...t){Tn(this);const i=Jt(this),r=En(i);let a=Ho(t[0]);if(a===1/0)return-1;a<0&&(a+=r,a<0&&(a=0));for(let s=a;s<r;++s)if(qo(i,s)&&An(i[s])===e)return s;return-1}lastIndexOf(e,...t){Tn(this);const i=Jt(this),r=En(i);let a=t.length>=1?Ho(t[0]):r-1;if(a===-1/0)return-1;a>=0?a=a<r-1?a:r-1:a+=r;for(let s=a;s>=0;--s)if(qo(i,s)&&An(i[s])===e)return s;return-1}includes(e,...t){Tn(this);const i=Jt(this),r=En(i);let a=Ho(t[0]);if(a===1/0)return!1;a<0&&(a+=r,a<0&&(a=0));const s=zd(e);for(let o=a;o<r;++o){const l=An(i[o]);if(s&&zd(l)||l===e)return!0}return!1}join(e){Tn(this);const t=Jt(this),i=RO(t);return ate(i,e)}toLocaleString(...e){Tn(this);const t=Jt(this),i=RO(t);return ote(i,...ym(e))}get[_A](){if(Zf(this))return"Float16Array"}};Q0(dl,"BYTES_PER_ELEMENT",{value:bA});Q0(dl,o1,{});gP(dl,yA);const c1=dl.prototype;Q0(c1,"BYTES_PER_ELEMENT",{value:bA});Q0(c1,lo,{value:c1.values,writable:!0,configurable:!0});gP(c1,ir);function Vte(n,e,...t){return An(Rte(n,e,...ym(t)))}let kte=class extends yi{constructor(e,t){super(t),this.parser=e}load(e,t,i,r){const a=new Vee(this.manager);a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(this.withCredentials),a.load(e,s=>{try{t(this.parser(s))}catch(o){r!=null?r(o):console.error(o),this.manager.itemError(e)}},i,r)}};function Wte(n){const e=n instanceof Int8Array?z1:n instanceof Uint8Array||n instanceof Uint8ClampedArray?Pi:n instanceof Int16Array?B1:n instanceof Uint16Array?Zu:n instanceof Int32Array?H0:n instanceof Uint32Array?Os:n instanceof dl?Yn:n instanceof Float32Array||n instanceof Float64Array?si:null;return i1(e!=null),e}let Mu=class extends yi{constructor(e,t,i={},r){super(r),this.textureClass=e,this.parser=t,this.options={format:$n,minFilter:Ht,magFilter:Ht,...i}}load(e,t,i,r){const a=new this.textureClass,s=new kte(this.parser,this.manager);return s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(this.withCredentials),s.load(e,o=>{a.image.data=o instanceof dl?new Uint16Array(o.buffer):o;const{width:l,height:h,depth:f,...d}=this.options;l!=null&&(a.image.width=l),h!=null&&(a.image.height=h),"depth"in a.image&&f!=null&&(a.image.depth=f),a.type=Wte(o),Object.assign(a,d),a.needsUpdate=!0,t==null||t(a)},i,r),a}};const M0=tn.clamp;tn.euclideanModulo;tn.inverseLerp;const PP=tn.lerp,Tu=tn.degToRad;tn.radToDeg;tn.isPowerOfTwo;tn.ceilPowerOfTwo;tn.floorPowerOfTwo;tn.normalize;function Xte(n,e,t,i=0,r=1){return tn.mapLinear(n,e,t,i,r)}function Yte(n){return Math.min(Math.max(n,0),1)}function pn(n){return(e,t)=>{e instanceof jn?Object.defineProperty(e,t,{enumerable:!0,get(){var i;return((i=this.defines)==null?void 0:i[n])!=null},set(i){var r;i!==this[t]&&(i?(this.defines??(this.defines={}),this.defines[n]="1"):(r=this.defines)==null||delete r[n],this.needsUpdate=!0)}}):Object.defineProperty(e,t,{enumerable:!0,get(){return this.defines.has(n)},set(i){i!==this[t]&&(i?this.defines.set(n,"1"):this.defines.delete(n),this.setChanged())}})}}function _h(n,{min:e=Number.MIN_SAFE_INTEGER,max:t=Number.MAX_SAFE_INTEGER}={}){return(i,r)=>{i instanceof jn?Object.defineProperty(i,r,{enumerable:!0,get(){var s;const a=(s=this.defines)==null?void 0:s[n];return a!=null?parseInt(a,10):0},set(a){const s=this[r];a!==s&&(this.defines??(this.defines={}),this.defines[n]=M0(a,e,t).toFixed(0),this.needsUpdate=!0)}}):Object.defineProperty(i,r,{enumerable:!0,get(){const a=this.defines.get(n);return a!=null?parseInt(a,10):0},set(a){const s=this[r];a!==s&&(this.defines.set(n,M0(a,e,t).toFixed(0)),this.setChanged())}})}}function AA(n,{min:e=-1/0,max:t=1/0,precision:i=7}={}){return(r,a)=>{r instanceof jn?Object.defineProperty(r,a,{enumerable:!0,get(){var o;const s=(o=this.defines)==null?void 0:o[n];return s!=null?parseFloat(s):0},set(s){const o=this[a];s!==o&&(this.defines??(this.defines={}),this.defines[n]=M0(s,e,t).toFixed(i),this.needsUpdate=!0)}}):Object.defineProperty(r,a,{enumerable:!0,get(){const s=this.defines.get(n);return s!=null?parseFloat(s):0},set(s){const o=this[a];s!==o&&(this.defines.set(n,M0(s,e,t).toFixed(i)),this.setChanged())}})}}function zP(n,{validate:e}={}){return(t,i)=>{t instanceof jn?Object.defineProperty(t,i,{enumerable:!0,get(){var r;return((r=this.defines)==null?void 0:r[n])??""},set(r){if(r!==this[i]){if((e==null?void 0:e(r))===!1){console.error(`Expression validation failed: ${r}`);return}this.defines??(this.defines={}),this.defines[n]=r,this.needsUpdate=!0}}}):Object.defineProperty(t,i,{enumerable:!0,get(){return this.defines.get(n)??""},set(r){if(r!==this[i]){if((e==null?void 0:e(r))===!1){console.error(`Expression validation failed: ${r}`);return}this.defines.set(n,r),this.setChanged()}}})}}function CO(n,...e){const t={};for(let i=0;i<e.length;i+=2){const r=e[i],a=e[i+1];for(const s of a)t[s]={enumerable:!0,get:()=>r[s],set:o=>{r[s]=o}}}return Object.defineProperties(n,t),n}function DO(n,e,t){const i={};for(const r of t)i[r]={enumerable:!0,get:()=>e.uniforms[r].value,set:a=>{e.uniforms[r].value=a}};return Object.defineProperties(n,i),n}class s3 extends yi{constructor(e={},t){super(t),this.options=e}load(e,t,i,r){const{width:a,height:s,depth:o}=this.options,l=new ss(null,a,s,o),h=new hP(this.manager);return h.setRequestHeader(this.requestHeader),h.setPath(this.path),h.setWithCredentials(this.withCredentials),h.load(e,f=>{const{image:d}=f;l.image={data:d.data,width:a??d.width,height:s??d.height,depth:o??Math.sqrt(d.height)},l.type=f.type,l.format=f.format,l.colorSpace=f.colorSpace,l.needsUpdate=!0;try{t==null||t(l)}catch(p){r!=null?r(p):console.error(p),this.manager.itemError(e)}},i,r),l}}class NO extends yi{constructor(e={},t){super(t),this.options=e}load(e,t,i,r){const{width:a,height:s}=this.options,o=new ea(null,a,s),l=new hP(this.manager);return l.setRequestHeader(this.requestHeader),l.setPath(this.path),l.setWithCredentials(this.withCredentials),l.load(e,h=>{const{image:f}=h;o.image={data:f.data,width:a??f.width,height:s??f.height},o.type=h.type,o.format=h.format,o.colorSpace=h.colorSpace,o.needsUpdate=!0;try{t==null||t(o)}catch(d){r!=null?r(d):console.error(d),this.manager.itemError(e)}},i,r),o}}const o3=1e-6,$v=new L,e_=new L,Po=new L,rm=new L,l3=new L,qte=new L,jte=new Ve,Zte=new _t,Kte=new Ac;let Qte=class BP{constructor(e=0,t=0,i=0,r=0){this.distance=e,this.heading=t,this.pitch=i,this.roll=r}get distance(){return this._distance}set distance(e){this._distance=Math.max(e,o3)}get pitch(){return this._pitch}set pitch(e){this._pitch=M0(e,-Math.PI/2+o3,Math.PI/2-o3)}set(e,t,i,r){return this.distance=e,this.heading=t,this.pitch=i,r!=null&&(this.roll=r),this}clone(){return new BP(this.distance,this.heading,this.pitch,this.roll)}copy(e){return this.distance=e.distance,this.heading=e.heading,this.pitch=e.pitch,this.roll=e.roll,this}equals(e){return e.distance===this.distance&&e.heading===this.heading&&e.pitch===this.pitch&&e.roll===this.roll}decompose(e,t,i,r,a=ih.WGS84){a.getEastNorthUpVectors(e,$v,e_,Po),r==null||r.copy(Po);const s=rm.copy($v).multiplyScalar(Math.cos(this.heading)).add(l3.copy(e_).multiplyScalar(Math.sin(this.heading))).multiplyScalar(Math.cos(this.pitch)).add(l3.copy(Po).multiplyScalar(Math.sin(this.pitch))).normalize().multiplyScalar(this.distance);if(t.copy(e).sub(s),this.roll!==0){const o=rm.copy(e).sub(t).normalize();Po.applyQuaternion(Zte.setFromAxisAngle(o,this.roll))}i.setFromRotationMatrix(jte.lookAt(t,e,Po))}setFromCamera(e,t=ih.WGS84){const i=rm.setFromMatrixPosition(e.matrixWorld),r=l3.set(0,0,.5).unproject(e).sub(i).normalize(),a=t.getIntersection(Kte.set(i,r));if(a==null)return;this.distance=i.distanceTo(a),t.getEastNorthUpVectors(a,$v,e_,Po),this.heading=Math.atan2(e_.dot(r),$v.dot(r)),this.pitch=Math.asin(Po.dot(r));const s=rm.copy(e.up).applyQuaternion(e.quaternion),o=qte.copy(r).multiplyScalar(-s.dot(r)).add(s).normalize(),l=rm.copy(r).multiplyScalar(-Po.dot(r)).add(Po).normalize(),h=l.dot(o),f=r.dot(l.cross(o));return this.roll=Math.atan2(f,h),this}};const Jte=/^[ \t]*#include +"([\w\d./]+)"/gm;function Nr(n,e){return n.replace(Jte,(t,i)=>{const r=i.split("/").reduce((a,s)=>typeof a!="string"&&a!=null?a[s]:void 0,e);if(typeof r!="string")throw new Error(`Could not find include for ${i}.`);return Nr(r,e)})}let t_;function $te(){if(t_!=null)return t_;const n=new Uint32Array([268435456]);return t_=new Uint8Array(n.buffer,n.byteOffset,n.byteLength)[0]===0,t_}function ene(n,e,t,i=!0){if(i===$te())return new e(n);const r=Object.assign(new DataView(n),{getFloat16(s,o){return Vte(this,s,o)}}),a=new e(r.byteLength/e.BYTES_PER_ELEMENT);for(let s=0,o=0;s<a.length;++s,o+=e.BYTES_PER_ELEMENT)a[s]=r[t](o,i);return a}const HP=n=>new Uint8Array(n),am=(n,e)=>ene(n,dl,"getFloat16",e);class FP extends Mu{constructor(e){super(ss,HP,{format:ws,minFilter:Vn,magFilter:Vn,wrapS:Mr,wrapT:Mr,wrapR:Mr,width:kee,height:Wee,depth:Xee},e)}}const tne=/#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*i)\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function nne(n,e,t,i){let r="";for(let a=parseInt(e,10);a<parseInt(t,10);++a)r+=i.replace(/\[\s*i\s*\]/g,"["+a+"]").replace(/UNROLLED_LOOP_INDEX/g,`${a}`);return r}function J0(n){return n.replace(tne,nne)}const ine=`// Reference: https://github.com/mrdoob/three.js/blob/r171/examples/jsm/csm/CSMShader.js

#ifndef SHADOW_CASCADE_COUNT
#error "SHADOW_CASCADE_COUNT macro must be defined."
#endif // SHADOW_CASCADE_COUNT

int getCascadeIndex(
  const mat4 viewMatrix,
  const vec3 worldPosition,
  const vec2 intervals[SHADOW_CASCADE_COUNT],
  const float near,
  const float far
) {
  vec4 viewPosition = viewMatrix * vec4(worldPosition, 1.0);
  float depth = viewZToOrthographicDepth(viewPosition.z, near, far);
  vec2 interval;
  #pragma unroll_loop_start
  for (int i = 0; i < 4; ++i) {
    #if UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT
    interval = intervals[i];
    if (depth >= interval.x && depth < interval.y) {
      return UNROLLED_LOOP_INDEX;
    }
    #endif // UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT
  }
  #pragma unroll_loop_end
  return SHADOW_CASCADE_COUNT - 1;
}

int getFadedCascadeIndex(
  const mat4 viewMatrix,
  const vec3 worldPosition,
  const vec2 intervals[SHADOW_CASCADE_COUNT],
  const float near,
  const float far,
  const float jitter
) {
  vec4 viewPosition = viewMatrix * vec4(worldPosition, 1.0);
  float depth = viewZToOrthographicDepth(viewPosition.z, near, far);

  vec2 interval;
  float intervalCenter;
  float closestEdge;
  float margin;
  int nextIndex = -1;
  int prevIndex = -1;
  float alpha;

  #pragma unroll_loop_start
  for (int i = 0; i < 4; ++i) {
    #if UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT
    interval = intervals[i];
    intervalCenter = (interval.x + interval.y) * 0.5;
    closestEdge = depth < intervalCenter ? interval.x : interval.y;
    margin = closestEdge * closestEdge * 0.5;
    interval += margin * vec2(-0.5, 0.5);

    #if UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT - 1
    if (depth >= interval.x && depth < interval.y) {
      prevIndex = nextIndex;
      nextIndex = UNROLLED_LOOP_INDEX;
      alpha = saturate(min(depth - interval.x, interval.y - depth) / margin);
    }
    #else // UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT - 1
    // Don't fade out the last cascade.
    if (depth >= interval.x) {
      prevIndex = nextIndex;
      nextIndex = UNROLLED_LOOP_INDEX;
      alpha = saturate((depth - interval.x) / margin);
    }
    #endif // UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT - 1
    #endif // UNROLLED_LOOP_INDEX < SHADOW_CASCADE_COUNT
  }
  #pragma unroll_loop_end

  return jitter <= alpha
    ? nextIndex
    : prevIndex;
}
`,rne=`// cSpell:words logdepthbuf

float reverseLogDepth(const float depth, const float near, const float far) {
  #if defined(USE_LOGDEPTHBUF) || defined(USE_LOGARITHMIC_DEPTH_BUFFER)
  float d = pow(2.0, depth * log2(far + 1.0)) - 1.0;
  float a = far / (far - near);
  float b = far * near / (near - far);
  return a + b / d;
  #else // defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(USE_LOGARITHMIC_DEPTH_BUFFER)
  return depth;
  #endif // defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(USE_LOGARITHMIC_DEPTH_BUFFER)
}

float linearizeDepth(const float depth, const float near, const float far) {
  float ndc = depth * 2.0 - 1.0;
  return 2.0 * near * far / (far + near - ndc * (far - near));
}
`,ane=`float checker(const vec2 uv, const vec2 repeats) {
  vec2 c = floor(repeats * uv);
  float result = mod(c.x + c.y, 2.0);
  return sign(result);
}

float checker(const vec2 uv, const float repeats) {
  return checker(uv, vec2(repeats));
}
`,sne=`// Reference: https://advances.realtimerendering.com/s2014/index.html#_NEXT_GENERATION_POST

float interleavedGradientNoise(const vec2 coord) {
  const vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
  return fract(magic.z * fract(dot(coord, magic.xy)));
}
`,one=`#if !defined(saturate)
#define saturate(a) clamp(a, 0.0, 1.0)
#endif // !defined(saturate)

float remap(const float x, const float min1, const float max1, const float min2, const float max2) {
  return min2 + (x - min1) / (max1 - min1) * (max2 - min2);
}

vec2 remap(const vec2 x, const vec2 min1, const vec2 max1, const vec2 min2, const vec2 max2) {
  return min2 + (x - min1) / (max1 - min1) * (max2 - min2);
}

vec3 remap(const vec3 x, const vec3 min1, const vec3 max1, const vec3 min2, const vec3 max2) {
  return min2 + (x - min1) / (max1 - min1) * (max2 - min2);
}

vec4 remap(const vec4 x, const vec4 min1, const vec4 max1, const vec4 min2, const vec4 max2) {
  return min2 + (x - min1) / (max1 - min1) * (max2 - min2);
}

float remapClamped(
  const float x,
  const float min1,
  const float max1,
  const float min2,
  const float max2
) {
  return clamp(min2 + (x - min1) / (max1 - min1) * (max2 - min2), min2, max2);
}

vec2 remapClamped(
  const vec2 x,
  const vec2 min1,
  const vec2 max1,
  const vec2 min2,
  const vec2 max2
) {
  return clamp(min2 + (x - min1) / (max1 - min1) * (max2 - min2), min2, max2);
}

vec3 remapClamped(
  const vec3 x,
  const vec3 min1,
  const vec3 max1,
  const vec3 min2,
  const vec3 max2
) {
  return clamp(min2 + (x - min1) / (max1 - min1) * (max2 - min2), min2, max2);
}

vec4 remapClamped(
  const vec4 x,
  const vec4 min1,
  const vec4 max1,
  const vec4 min2,
  const vec4 max2
) {
  return clamp(min2 + (x - min1) / (max1 - min1) * (max2 - min2), min2, max2);
}

// Implicitly remap to 0 and 1
float remap(const float x, const float min1, const float max1) {
  return (x - min1) / (max1 - min1);
}

vec2 remap(const vec2 x, const vec2 min1, const vec2 max1) {
  return (x - min1) / (max1 - min1);
}

vec3 remap(const vec3 x, const vec3 min1, const vec3 max1) {
  return (x - min1) / (max1 - min1);
}

vec4 remap(const vec4 x, const vec4 min1, const vec4 max1) {
  return (x - min1) / (max1 - min1);
}

float remapClamped(const float x, const float min1, const float max1) {
  return saturate((x - min1) / (max1 - min1));
}

vec2 remapClamped(const vec2 x, const vec2 min1, const vec2 max1) {
  return saturate((x - min1) / (max1 - min1));
}

vec3 remapClamped(const vec3 x, const vec3 min1, const vec3 max1) {
  return saturate((x - min1) / (max1 - min1));
}

vec4 remapClamped(const vec4 x, const vec4 min1, const vec4 max1) {
  return saturate((x - min1) / (max1 - min1));
}
`,lne=`// Reference: https://jcgt.org/published/0003/02/01/paper.pdf

vec2 signNotZero(vec2 v) {
  return vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);
}

vec2 packNormalToVec2(vec3 v) {
  vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));
  return v.z <= 0.0
    ? (1.0 - abs(p.yx)) * signNotZero(p)
    : p;
}

vec3 unpackVec2ToNormal(vec2 e) {
  vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y));
  if (v.z < 0.0) {
    v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);
  }
  return normalize(v);
}
`,cne=`float raySphereFirstIntersection(
  const vec3 origin,
  const vec3 direction,
  const vec3 center,
  const float radius
) {
  vec3 a = origin - center;
  float b = 2.0 * dot(direction, a);
  float c = dot(a, a) - radius * radius;
  float discriminant = b * b - 4.0 * c;
  return discriminant < 0.0
    ? -1.0
    : (-b - sqrt(discriminant)) * 0.5;
}

float raySphereFirstIntersection(const vec3 origin, const vec3 direction, const float radius) {
  return raySphereFirstIntersection(origin, direction, vec3(0.0), radius);
}

vec4 raySphereFirstIntersection(
  const vec3 origin,
  const vec3 direction,
  const vec3 center,
  const vec4 radius
) {
  vec3 a = origin - center;
  float b = 2.0 * dot(direction, a);
  vec4 c = dot(a, a) - radius * radius;
  vec4 discriminant = b * b - 4.0 * c;
  vec4 mask = step(discriminant, vec4(0.0));
  return mix((-b - sqrt(max(vec4(0.0), discriminant))) * 0.5, vec4(-1.0), mask);
}

vec4 raySphereFirstIntersection(const vec3 origin, const vec3 direction, const vec4 radius) {
  return raySphereFirstIntersection(origin, direction, vec3(0.0), radius);
}

float raySphereSecondIntersection(
  const vec3 origin,
  const vec3 direction,
  const vec3 center,
  const float radius
) {
  vec3 a = origin - center;
  float b = 2.0 * dot(direction, a);
  float c = dot(a, a) - radius * radius;
  float discriminant = b * b - 4.0 * c;
  return discriminant < 0.0
    ? -1.0
    : (-b + sqrt(discriminant)) * 0.5;
}

float raySphereSecondIntersection(const vec3 origin, const vec3 direction, const float radius) {
  return raySphereSecondIntersection(origin, direction, vec3(0.0), radius);
}

vec4 raySphereSecondIntersection(
  const vec3 origin,
  const vec3 direction,
  const vec3 center,
  const vec4 radius
) {
  vec3 a = origin - center;
  float b = 2.0 * dot(direction, a);
  vec4 c = dot(a, a) - radius * radius;
  vec4 discriminant = b * b - 4.0 * c;
  vec4 mask = step(discriminant, vec4(0.0));
  return mix((-b + sqrt(max(vec4(0.0), discriminant))) * 0.5, vec4(-1.0), mask);
}

vec4 raySphereSecondIntersection(const vec3 origin, const vec3 direction, const vec4 radius) {
  return raySphereSecondIntersection(origin, direction, vec3(0.0), radius);
}

void raySphereIntersections(
  const vec3 origin,
  const vec3 direction,
  const vec3 center,
  const float radius,
  out float intersection1,
  out float intersection2
) {
  vec3 a = origin - center;
  float b = 2.0 * dot(direction, a);
  float c = dot(a, a) - radius * radius;
  float discriminant = b * b - 4.0 * c;
  if (discriminant < 0.0) {
    intersection1 = -1.0;
    intersection2 = -1.0;
    return;
  } else {
    float Q = sqrt(discriminant);
    intersection1 = (-b - Q) * 0.5;
    intersection2 = (-b + Q) * 0.5;
  }
}

void raySphereIntersections(
  const vec3 origin,
  const vec3 direction,
  const float radius,
  out float intersection1,
  out float intersection2
) {
  raySphereIntersections(origin, direction, vec3(0.0), radius, intersection1, intersection2);
}

void raySphereIntersections(
  const vec3 origin,
  const vec3 direction,
  const vec3 center,
  const vec4 radius,
  out vec4 intersection1,
  out vec4 intersection2
) {
  vec3 a = origin - center;
  float b = 2.0 * dot(direction, a);
  vec4 c = dot(a, a) - radius * radius;
  vec4 discriminant = b * b - 4.0 * c;
  vec4 mask = step(discriminant, vec4(0.0));
  vec4 Q = sqrt(max(vec4(0.0), discriminant));
  intersection1 = mix((-b - Q) * 0.5, vec4(-1.0), mask);
  intersection2 = mix((-b + Q) * 0.5, vec4(-1.0), mask);
}

void raySphereIntersections(
  const vec3 origin,
  const vec3 direction,
  const vec4 radius,
  out vec4 intersection1,
  out vec4 intersection2
) {
  raySphereIntersections(origin, direction, vec3(0.0), radius, intersection1, intersection2);
}
`,une=`vec3 screenToView(
  const vec2 uv,
  const float depth,
  const float viewZ,
  const mat4 projectionMatrix,
  const mat4 inverseProjectionMatrix
) {
  vec4 clip = vec4(vec3(uv, depth) * 2.0 - 1.0, 1.0);
  float clipW = projectionMatrix[2][3] * viewZ + projectionMatrix[3][3];
  clip *= clipW;
  return (inverseProjectionMatrix * clip).xyz;
}
`,hne=`// A fifth-order polynomial approximation of Turbo color map.
// See: https://observablehq.com/@mbostock/turbo
// prettier-ignore
vec3 turbo(const float x) {
  float r = 0.1357 + x * (4.5974 - x * (42.3277 - x * (130.5887 - x * (150.5666 - x * 58.1375))));
  float g = 0.0914 + x * (2.1856 + x * (4.8052 - x * (14.0195 - x * (4.2109 + x * 2.7747))));
  float b = 0.1067 + x * (12.5925 - x * (60.1097 - x * (109.0745 - x * (88.5066 - x * 26.8183))));
  return vec3(r, g, b);
}
`,fne=`// Reference: https://www.gamedev.net/tutorials/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/

vec2 vogelDisk(const int index, const int sampleCount, const float phi) {
  const float goldenAngle = 2.39996322972865332;
  float r = sqrt(float(index) + 0.5) / sqrt(float(sampleCount));
  float theta = float(index) * goldenAngle + phi;
  return r * vec2(cos(theta), sin(theta));
}
`,GP=ine,VP=rne,dne=ane,kP=sne,wA=one,pne=lne,Sy=cne,mne=une,WP=hne,XP=fne,np=64,ip=16,Ty=32,Ey=128,My=32,by=8,Fu=by*My,Gu=Ey,Vu=Ty,rp=256,ap=64,u1=1/1e3,gne=new L;function RA(n,e,t,i){const r=t.projectOnSurface(n,gne);return r!=null?t.getOsculatingSphereCenter(r,e,i).negate():i.setScalar(0)}var vne="Invariant failed";function _ne(n,e){if(!n)throw new Error(vne)}const OO=typeof window<"u"&&window.requestIdleCallback!=null?window.requestIdleCallback:function(n,e={}){const t=e.timeout??1,i=performance.now();return setTimeout(function(){n({get didTimeout(){return e.timeout!=null?!1:performance.now()-i-1>t},timeRemaining:function(){return Math.max(0,1+(performance.now()-i))}})},1)},Qs=`// Based on: https://github.com/ebruneton/precomputed_atmospheric_scattering/blob/master/atmosphere/functions.glsl

/**
 * Copyright (c) 2017 Eric Bruneton
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Precomputed Atmospheric Scattering
 * Copyright (c) 2008 INRIA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

Number ClampCosine(const Number mu) {
  return clamp(mu, Number(-1.0), Number(1.0));
}

Length ClampDistance(const Length d) {
  return max(d, 0.0 * m);
}

Length ClampRadius(const AtmosphereParameters atmosphere, const Length r) {
  return clamp(r, atmosphere.bottom_radius, atmosphere.top_radius);
}

Length SafeSqrt(const Area a) {
  return sqrt(max(a, 0.0 * m2));
}

Length DistanceToTopAtmosphereBoundary(const AtmosphereParameters atmosphere,
    const Length r, const Number mu) {
  assert(r <= atmosphere.top_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  Area discriminant = r * r * (mu * mu - 1.0) +
      atmosphere.top_radius * atmosphere.top_radius;
  return ClampDistance(-r * mu + SafeSqrt(discriminant));
}

Length DistanceToBottomAtmosphereBoundary(const AtmosphereParameters atmosphere,
    const Length r, const Number mu) {
  assert(r >= atmosphere.bottom_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  Area discriminant = r * r * (mu * mu - 1.0) +
      atmosphere.bottom_radius * atmosphere.bottom_radius;
  return ClampDistance(-r * mu - SafeSqrt(discriminant));
}

bool RayIntersectsGround(const AtmosphereParameters atmosphere,
    const Length r, const Number mu) {
  assert(r >= atmosphere.bottom_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  return mu < 0.0 && r * r * (mu * mu - 1.0) +
      atmosphere.bottom_radius * atmosphere.bottom_radius >= 0.0 * m2;
}

Number GetTextureCoordFromUnitRange(const Number x, const int texture_size) {
  return 0.5 / Number(texture_size) + x * (1.0 - 1.0 / Number(texture_size));
}

vec2 GetTransmittanceTextureUvFromRMu(const AtmosphereParameters atmosphere,
    const Length r, const Number mu) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  // Distance to top atmosphere boundary for a horizontal ray at ground level.
  Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
      atmosphere.bottom_radius * atmosphere.bottom_radius);
  // Distance to the horizon.
  Length rho =
      SafeSqrt(r * r - atmosphere.bottom_radius * atmosphere.bottom_radius);
  // Distance to the top atmosphere boundary for the ray (r,mu), and its minimum
  // and maximum values over all mu - obtained for (r,1) and (r,mu_horizon).
  Length d = DistanceToTopAtmosphereBoundary(atmosphere, r, mu);
  Length d_min = atmosphere.top_radius - r;
  Length d_max = rho + H;
  Number x_mu = (d - d_min) / (d_max - d_min);
  Number x_r = rho / H;
  return vec2(GetTextureCoordFromUnitRange(x_mu, TRANSMITTANCE_TEXTURE_WIDTH),
              GetTextureCoordFromUnitRange(x_r, TRANSMITTANCE_TEXTURE_HEIGHT));
}

DimensionlessSpectrum GetTransmittanceToTopAtmosphereBoundary(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const Length r, const Number mu) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  vec2 uv = GetTransmittanceTextureUvFromRMu(atmosphere, r, mu);
  // @shotamatsuda: Added for the precomputation stage in half-float precision.
  #ifdef TRANSMITTANCE_PRECISION_LOG
  // Manually interpolate the transmittance instead of the optical depth.
  const vec2 size = vec2(TRANSMITTANCE_TEXTURE_WIDTH, TRANSMITTANCE_TEXTURE_HEIGHT);
  const vec3 texel_size = vec3(1.0 / size, 0.0);
  vec2 coord = (uv * size) - 0.5;
  vec2 i = (floor(coord) + 0.5) * texel_size.xy;
  vec2 f = fract(coord);
  vec4 t1 = exp(-texture(transmittance_texture, i));
  vec4 t2 = exp(-texture(transmittance_texture, i + texel_size.xz));
  vec4 t3 = exp(-texture(transmittance_texture, i + texel_size.zy));
  vec4 t4 = exp(-texture(transmittance_texture, i + texel_size.xy));
  return DimensionlessSpectrum(mix(mix(t1, t2, f.x), mix(t3, t4, f.x), f.y));
  #else // TRANSMITTANCE_PRECISION_LOG
  return DimensionlessSpectrum(texture(transmittance_texture, uv));
  #endif // TRANSMITTANCE_PRECISION_LOG
}

DimensionlessSpectrum GetTransmittance(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const Length r, const Number mu, const Length d,
    const bool ray_r_mu_intersects_ground) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  assert(d >= 0.0 * m);

  Length r_d = ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
  Number mu_d = ClampCosine((r * mu + d) / r_d);

  if (ray_r_mu_intersects_ground) {
    return min(
        GetTransmittanceToTopAtmosphereBoundary(
            atmosphere, transmittance_texture, r_d, -mu_d) /
        GetTransmittanceToTopAtmosphereBoundary(
            atmosphere, transmittance_texture, r, -mu),
        DimensionlessSpectrum(1.0));
  } else {
    return min(
        GetTransmittanceToTopAtmosphereBoundary(
            atmosphere, transmittance_texture, r, mu) /
        GetTransmittanceToTopAtmosphereBoundary(
            atmosphere, transmittance_texture, r_d, mu_d),
        DimensionlessSpectrum(1.0));
  }
}

DimensionlessSpectrum GetTransmittanceToSun(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const Length r, const Number mu_s) {
  Number sin_theta_h = atmosphere.bottom_radius / r;
  Number cos_theta_h = -sqrt(max(1.0 - sin_theta_h * sin_theta_h, 0.0));
  return GetTransmittanceToTopAtmosphereBoundary(
          atmosphere, transmittance_texture, r, mu_s) *
      smoothstep(-sin_theta_h * atmosphere.sun_angular_radius / rad,
                 sin_theta_h * atmosphere.sun_angular_radius / rad,
                 mu_s - cos_theta_h);
}

InverseSolidAngle RayleighPhaseFunction(const Number nu) {
  InverseSolidAngle k = 3.0 / (16.0 * PI * sr);
  return k * (1.0 + nu * nu);
}

InverseSolidAngle MiePhaseFunction(const Number g, const Number nu) {
  InverseSolidAngle k = 3.0 / (8.0 * PI * sr) * (1.0 - g * g) / (2.0 + g * g);
  return k * (1.0 + nu * nu) / pow(1.0 + g * g - 2.0 * g * nu, 1.5);
}

vec4 GetScatteringTextureUvwzFromRMuMuSNu(const AtmosphereParameters atmosphere,
    const Length r, const Number mu, const Number mu_s, const Number nu,
    const bool ray_r_mu_intersects_ground) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  assert(mu_s >= -1.0 && mu_s <= 1.0);
  assert(nu >= -1.0 && nu <= 1.0);

  // Distance to top atmosphere boundary for a horizontal ray at ground level.
  Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
      atmosphere.bottom_radius * atmosphere.bottom_radius);
  // Distance to the horizon.
  Length rho =
      SafeSqrt(r * r - atmosphere.bottom_radius * atmosphere.bottom_radius);
  Number u_r = GetTextureCoordFromUnitRange(rho / H, SCATTERING_TEXTURE_R_SIZE);

  // Discriminant of the quadratic equation for the intersections of the ray
  // (r,mu) with the ground (see RayIntersectsGround).
  Length r_mu = r * mu;
  Area discriminant =
      r_mu * r_mu - r * r + atmosphere.bottom_radius * atmosphere.bottom_radius;
  Number u_mu;
  if (ray_r_mu_intersects_ground) {
    // Distance to the ground for the ray (r,mu), and its minimum and maximum
    // values over all mu - obtained for (r,-1) and (r,mu_horizon).
    Length d = -r_mu - SafeSqrt(discriminant);
    Length d_min = r - atmosphere.bottom_radius;
    Length d_max = rho;
    u_mu = 0.5 - 0.5 * GetTextureCoordFromUnitRange(d_max == d_min ? 0.0 :
        (d - d_min) / (d_max - d_min), SCATTERING_TEXTURE_MU_SIZE / 2);
  } else {
    // Distance to the top atmosphere boundary for the ray (r,mu), and its
    // minimum and maximum values over all mu - obtained for (r,1) and
    // (r,mu_horizon).
    Length d = -r_mu + SafeSqrt(discriminant + H * H);
    Length d_min = atmosphere.top_radius - r;
    Length d_max = rho + H;
    u_mu = 0.5 + 0.5 * GetTextureCoordFromUnitRange(
        (d - d_min) / (d_max - d_min), SCATTERING_TEXTURE_MU_SIZE / 2);
  }

  Length d = DistanceToTopAtmosphereBoundary(
      atmosphere, atmosphere.bottom_radius, mu_s);
  Length d_min = atmosphere.top_radius - atmosphere.bottom_radius;
  Length d_max = H;
  Number a = (d - d_min) / (d_max - d_min);
  Length D = DistanceToTopAtmosphereBoundary(
      atmosphere, atmosphere.bottom_radius, atmosphere.mu_s_min);
  Number A = (D - d_min) / (d_max - d_min);
  // An ad-hoc function equal to 0 for mu_s = mu_s_min (because then d = D and
  // thus a = A), equal to 1 for mu_s = 1 (because then d = d_min and thus
  // a = 0), and with a large slope around mu_s = 0, to get more texture
  // samples near the horizon.
  Number u_mu_s = GetTextureCoordFromUnitRange(
      max(1.0 - a / A, 0.0) / (1.0 + a), SCATTERING_TEXTURE_MU_S_SIZE);

  Number u_nu = (nu + 1.0) / 2.0;
  return vec4(u_nu, u_mu_s, u_mu, u_r);
}

vec2 GetIrradianceTextureUvFromRMuS(const AtmosphereParameters atmosphere,
    const Length r, const Number mu_s) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu_s >= -1.0 && mu_s <= 1.0);
  Number x_r = (r - atmosphere.bottom_radius) /
      (atmosphere.top_radius - atmosphere.bottom_radius);
  Number x_mu_s = mu_s * 0.5 + 0.5;
  return vec2(GetTextureCoordFromUnitRange(x_mu_s, IRRADIANCE_TEXTURE_WIDTH),
              GetTextureCoordFromUnitRange(x_r, IRRADIANCE_TEXTURE_HEIGHT));
}

IrradianceSpectrum GetIrradiance(
    const AtmosphereParameters atmosphere,
    const IrradianceTexture irradiance_texture,
    const Length r, const Number mu_s) {
  vec2 uv = GetIrradianceTextureUvFromRMuS(atmosphere, r, mu_s);
  return IrradianceSpectrum(texture(irradiance_texture, uv));
}
`,Js=`// Based on: https://github.com/ebruneton/precomputed_atmospheric_scattering/blob/master/atmosphere/definitions.glsl

/**
 * Copyright (c) 2017 Eric Bruneton
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

#define assert(x)

#define Length float
#define Wavelength float
#define Angle float
#define SolidAngle float
#define Power float
#define LuminousPower float

#define Number float
#define InverseLength float
#define Area float
#define Volume float
#define NumberDensity float
#define Irradiance float
#define Radiance float
#define SpectralPower float
#define SpectralIrradiance float
#define SpectralRadiance float
#define SpectralRadianceDensity float
#define ScatteringCoefficient float
#define InverseSolidAngle float
#define LuminousIntensity float
#define Luminance float
#define Illuminance float

// A generic function from Wavelength to some other type.
#define AbstractSpectrum vec3
// A function from Wavelength to Number.
#define DimensionlessSpectrum vec3
// A function from Wavelength to SpectralPower.
#define PowerSpectrum vec3
// A function from Wavelength to SpectralIrradiance.
#define IrradianceSpectrum vec3
// A function from Wavelength to SpectralRadiance.
#define RadianceSpectrum vec3
// A function from Wavelength to SpectralRadianceDensity.
#define RadianceDensitySpectrum vec3
// A function from Wavelength to ScatteringCoefficient.
#define ScatteringSpectrum vec3

// A position in 3D (3 length values).
#define Position vec3
// A unit direction vector in 3D (3 unit-less values).
#define Direction vec3
// A vector of 3 luminance values.
#define Luminance3 vec3
// A vector of 3 illuminance values.
#define Illuminance3 vec3

#define TransmittanceTexture sampler2D
#define AbstractScatteringTexture sampler3D
#define ReducedScatteringTexture sampler3D
#define ScatteringTexture sampler3D
#define ScatteringDensityTexture sampler3D
#define IrradianceTexture sampler2D

const Length m = 1.0;
const Wavelength nm = 1.0;
const Angle rad = 1.0;
const SolidAngle sr = 1.0;
const Power watt = 1.0;
const LuminousPower lm = 1.0;

#if !defined(PI)
const float PI = 3.14159265358979323846;
#endif // !defined(PI)

const Length km = 1000.0 * m;
const Area m2 = m * m;
const Volume m3 = m * m * m;
const Angle pi = PI * rad;
const Angle deg = pi / 180.0;
const Irradiance watt_per_square_meter = watt / m2;
const Radiance watt_per_square_meter_per_sr = watt / (m2 * sr);
const SpectralIrradiance watt_per_square_meter_per_nm = watt / (m2 * nm);
const SpectralRadiance watt_per_square_meter_per_sr_per_nm = watt / (m2 * sr * nm);
const SpectralRadianceDensity watt_per_cubic_meter_per_sr_per_nm = watt / (m3 * sr * nm);
const LuminousIntensity cd = lm / sr;
const LuminousIntensity kcd = 1000.0 * cd;
const Luminance cd_per_square_meter = cd / m2;
const Luminance kcd_per_square_meter = kcd / m2;

struct DensityProfileLayer {
  Length width;
  Number exp_term;
  InverseLength exp_scale;
  InverseLength linear_term;
  Number constant_term;
};

struct DensityProfile {
  DensityProfileLayer layers[2];
};

// See AtmosphereParameter.ts for further details.
struct AtmosphereParameters {
  IrradianceSpectrum solar_irradiance;
  Angle sun_angular_radius;
  Length bottom_radius;
  Length top_radius;
  DensityProfile rayleigh_density;
  ScatteringSpectrum rayleigh_scattering;
  DensityProfile mie_density;
  ScatteringSpectrum mie_scattering;
  ScatteringSpectrum mie_extinction;
  Number mie_phase_function_g;
  DensityProfile absorption_density;
  ScatteringSpectrum absorption_extinction;
  DimensionlessSpectrum ground_albedo;
  Number mu_s_min;
};
`,Ay=`// Based on: https://github.com/ebruneton/precomputed_atmospheric_scattering/blob/master/atmosphere/functions.glsl

/**
 * Copyright (c) 2017 Eric Bruneton
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Precomputed Atmospheric Scattering
 * Copyright (c) 2008 INRIA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef COMBINED_SCATTERING_TEXTURES
vec3 GetExtrapolatedSingleMieScattering(
    const AtmosphereParameters atmosphere, const vec4 scattering) {
  // Algebraically this can never be negative, but rounding errors can produce
  // that effect for sufficiently short view rays.
  // @shotamatsuda: Avoid division by infinitesimal values.
  // See https://github.com/takram-design-engineering/three-geospatial/issues/47
  if (scattering.r < 1e-5) {
    return vec3(0.0);
  }
  return scattering.rgb * scattering.a / scattering.r *
	    (atmosphere.rayleigh_scattering.r / atmosphere.mie_scattering.r) *
	    (atmosphere.mie_scattering / atmosphere.rayleigh_scattering);
}
#endif // COMBINED_SCATTERING_TEXTURES

IrradianceSpectrum GetCombinedScattering(
    const AtmosphereParameters atmosphere,
    const ReducedScatteringTexture scattering_texture,
    const ReducedScatteringTexture single_mie_scattering_texture,
    const Length r, const Number mu, const Number mu_s, const Number nu,
    const bool ray_r_mu_intersects_ground,
    out IrradianceSpectrum single_mie_scattering) {
  vec4 uvwz = GetScatteringTextureUvwzFromRMuMuSNu(
      atmosphere, r, mu, mu_s, nu, ray_r_mu_intersects_ground);
  Number tex_coord_x = uvwz.x * Number(SCATTERING_TEXTURE_NU_SIZE - 1);
  Number tex_x = floor(tex_coord_x);
  Number lerp = tex_coord_x - tex_x;
  vec3 uvw0 = vec3((tex_x + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
      uvwz.z, uvwz.w);
  vec3 uvw1 = vec3((tex_x + 1.0 + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
      uvwz.z, uvwz.w);
#ifdef COMBINED_SCATTERING_TEXTURES
  vec4 combined_scattering =
      texture(scattering_texture, uvw0) * (1.0 - lerp) +
      texture(scattering_texture, uvw1) * lerp;
  IrradianceSpectrum scattering = IrradianceSpectrum(combined_scattering);
  single_mie_scattering =
      GetExtrapolatedSingleMieScattering(atmosphere, combined_scattering);
#else // COMBINED_SCATTERING_TEXTURES
  IrradianceSpectrum scattering = IrradianceSpectrum(
      texture(scattering_texture, uvw0) * (1.0 - lerp) +
      texture(scattering_texture, uvw1) * lerp);
  single_mie_scattering = IrradianceSpectrum(
      texture(single_mie_scattering_texture, uvw0) * (1.0 - lerp) +
      texture(single_mie_scattering_texture, uvw1) * lerp);
#endif // COMBINED_SCATTERING_TEXTURES
  return scattering;
}

// @shotamatsuda: Added for reading higher-order scattering texture.
#ifdef HAS_HIGHER_ORDER_SCATTERING_TEXTURE
IrradianceSpectrum GetScattering(
    const AtmosphereParameters atmosphere,
    const ReducedScatteringTexture scattering_texture,
    const Length r, const Number mu, const Number mu_s, const Number nu,
    const bool ray_r_mu_intersects_ground) {
  vec4 uvwz = GetScatteringTextureUvwzFromRMuMuSNu(
      atmosphere, r, mu, mu_s, nu, ray_r_mu_intersects_ground);
  Number tex_coord_x = uvwz.x * Number(SCATTERING_TEXTURE_NU_SIZE - 1);
  Number tex_x = floor(tex_coord_x);
  Number lerp = tex_coord_x - tex_x;
  vec3 uvw0 = vec3((tex_x + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
      uvwz.z, uvwz.w);
  vec3 uvw1 = vec3((tex_x + 1.0 + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
      uvwz.z, uvwz.w);
  IrradianceSpectrum scattering = IrradianceSpectrum(
      texture(scattering_texture, uvw0) * (1.0 - lerp) +
      texture(scattering_texture, uvw1) * lerp);
  return scattering;
}
#endif // HAS_HIGHER_ORDER_SCATTERING_TEXTURE

RadianceSpectrum GetSkyRadiance(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const ReducedScatteringTexture scattering_texture,
    const ReducedScatteringTexture single_mie_scattering_texture,
    Position camera, const Direction view_ray, const Length shadow_length,
    const Direction sun_direction,
    out DimensionlessSpectrum transmittance) {
  // Compute the distance to the top atmosphere boundary along the view ray,
  // assuming the viewer is in space (or NaN if the view ray does not intersect
  // the atmosphere).
  Length r = length(camera);
  Length rmu = dot(camera, view_ray);
  // @shotamatsuda: Use SafeSqrt instead.
  // See: https://github.com/takram-design-engineering/three-geospatial/pull/26
  Length distance_to_top_atmosphere_boundary = -rmu -
      SafeSqrt(rmu * rmu - r * r +
          atmosphere.top_radius * atmosphere.top_radius);
  // If the viewer is in space and the view ray intersects the atmosphere, move
  // the viewer to the top atmosphere boundary (along the view ray):
  if (distance_to_top_atmosphere_boundary > 0.0 * m) {
    camera = camera + view_ray * distance_to_top_atmosphere_boundary;
    r = atmosphere.top_radius;
    rmu += distance_to_top_atmosphere_boundary;
  } else if (r > atmosphere.top_radius) {
    // If the view ray does not intersect the atmosphere, simply return 0.
    transmittance = DimensionlessSpectrum(1.0);
    return RadianceSpectrum(0.0 * watt_per_square_meter_per_sr_per_nm);
  }
  // Compute the r, mu, mu_s and nu parameters needed for the texture lookups.
  Number mu = rmu / r;
  Number mu_s = dot(camera, sun_direction) / r;
  Number nu = dot(view_ray, sun_direction);

  // @shotamatsuda: For rendering points below the bottom atmosphere.
  #ifdef GROUND
  bool ray_r_mu_intersects_ground = RayIntersectsGround(atmosphere, r, mu);
  #else // GROUND
  bool ray_r_mu_intersects_ground = false;
  #endif // GROUND

  transmittance = ray_r_mu_intersects_ground ? DimensionlessSpectrum(0.0) :
      GetTransmittanceToTopAtmosphereBoundary(
          atmosphere, transmittance_texture, r, mu);
  IrradianceSpectrum single_mie_scattering;
  IrradianceSpectrum scattering;
  if (shadow_length == 0.0 * m) {
    scattering = GetCombinedScattering(
        atmosphere, scattering_texture, single_mie_scattering_texture,
        r, mu, mu_s, nu, ray_r_mu_intersects_ground,
        single_mie_scattering);
  } else {
    // Case of light shafts (shadow_length is the total length noted l in our
    // paper): we omit the scattering between the camera and the point at
    // distance l, by implementing Eq. (18) of the paper (shadow_transmittance
    // is the T(x,x_s) term, scattering is the S|x_s=x+lv term).
    Length d = shadow_length;
    Length r_p =
        ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
    Number mu_p = (r * mu + d) / r_p;
    Number mu_s_p = (r * mu_s + d * nu) / r_p;

    scattering = GetCombinedScattering(
        atmosphere, scattering_texture, single_mie_scattering_texture,
        r_p, mu_p, mu_s_p, nu, ray_r_mu_intersects_ground,
        single_mie_scattering);
    DimensionlessSpectrum shadow_transmittance =
        GetTransmittance(atmosphere, transmittance_texture,
            r, mu, shadow_length, ray_r_mu_intersects_ground);
    // @shotamatsuda: Occlude only single Rayleigh scattering by the shadow.
#ifdef HAS_HIGHER_ORDER_SCATTERING_TEXTURE
    IrradianceSpectrum higher_order_scattering = GetScattering(
        atmosphere, higher_order_scattering_texture,
        r_p, mu_p, mu_s_p, nu, ray_r_mu_intersects_ground);
    IrradianceSpectrum single_scattering = scattering - higher_order_scattering;
    scattering = single_scattering * shadow_transmittance + higher_order_scattering;
#else // HAS_HIGHER_ORDER_SCATTERING_TEXTURE
    scattering = scattering * shadow_transmittance;
#endif // HAS_HIGHER_ORDER_SCATTERING_TEXTURE
    single_mie_scattering = single_mie_scattering * shadow_transmittance;
  }
  return scattering * RayleighPhaseFunction(nu) + single_mie_scattering *
      MiePhaseFunction(atmosphere.mie_phase_function_g, nu);
}

// @shotamatsuda: Returns the point on the ray closest to the origin.
vec3 ClosestPointOnRay(const Position camera, const Position point) {
  Position ray = point - camera;
  Number t = clamp(-dot(camera, ray) / dot(ray, ray), 0.0, 1.0);
  return camera + t * ray;
}

vec2 RaySphereIntersections(
    const Position camera, const Direction direction, const Length radius) {
  float b = 2.0 * dot(direction, camera);
  float c = dot(camera, camera) - radius * radius;
  float discriminant = b * b - 4.0 * c;
  float Q = sqrt(discriminant);
  return vec2(-b - Q, -b + Q) * 0.5;
}

// @shotamatsuda: Clip the view ray at the bottom atmosphere boundary.
bool ClipAtBottomAtmosphere(
    const AtmosphereParameters atmosphere,
    const Direction view_ray, inout Position camera, inout Position point) {
  const Length eps = 0.0;
  Length bottom_radius = atmosphere.bottom_radius + eps;
  Length r_camera = length(camera);
  Length r_point = length(point);
  bool camera_below = r_camera < bottom_radius;
  bool point_below = r_point < bottom_radius;

  vec2 t = RaySphereIntersections(camera, view_ray, bottom_radius);
  Position intersection = camera + view_ray * (camera_below ? t.y : t.x);
  camera = camera_below ? intersection : camera;
  point = point_below ? intersection : point;

  return camera_below && point_below;
}

RadianceSpectrum GetSkyRadianceToPoint(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const ReducedScatteringTexture scattering_texture,
    const ReducedScatteringTexture single_mie_scattering_texture,
    Position camera, Position point, const Length shadow_length,
    const Direction sun_direction, out DimensionlessSpectrum transmittance) {
  // @shotamatsuda: Avoid artifacts when the ray does not intersect the top
  // atmosphere boundary.
  if (length(ClosestPointOnRay(camera, point)) > atmosphere.top_radius) {
    transmittance = vec3(1.0);
    return vec3(0.0);
  }

  Direction view_ray = normalize(point - camera);
  if (ClipAtBottomAtmosphere(atmosphere, view_ray, camera, point)) {
    transmittance = vec3(1.0);
    return vec3(0.0);
  }

  // Compute the distance to the top atmosphere boundary along the view ray,
  // assuming the viewer is in space (or NaN if the view ray does not intersect
  // the atmosphere).
  Length r = length(camera);
  Length rmu = dot(camera, view_ray);
  // @shotamatsuda: Use SafeSqrt instead.
  // See: https://github.com/takram-design-engineering/three-geospatial/pull/26
  Length distance_to_top_atmosphere_boundary = -rmu -
      SafeSqrt(rmu * rmu - r * r +
          atmosphere.top_radius * atmosphere.top_radius);
  // If the viewer is in space and the view ray intersects the atmosphere, move
  // the viewer to the top atmosphere boundary (along the view ray):
  if (distance_to_top_atmosphere_boundary > 0.0 * m) {
    camera = camera + view_ray * distance_to_top_atmosphere_boundary;
    r = atmosphere.top_radius;
    rmu += distance_to_top_atmosphere_boundary;
  }

  // Compute the r, mu, mu_s and nu parameters for the first texture lookup.
  Number mu = rmu / r;
  Number mu_s = dot(camera, sun_direction) / r;
  Number nu = dot(view_ray, sun_direction);
  Length d = length(point - camera);
  bool ray_r_mu_intersects_ground = RayIntersectsGround(atmosphere, r, mu);

  // @shotamatsuda: Hack to avoid rendering artifacts near the horizon, due to
  // finite atmosphere texture resolution and finite floating point precision.
  // See: https://github.com/ebruneton/precomputed_atmospheric_scattering/pull/32
  if (!ray_r_mu_intersects_ground) {
    Number mu_horizon = -SafeSqrt(1.0 -
        (atmosphere.bottom_radius * atmosphere.bottom_radius) / (r * r));
    const Number eps = 0.004;
    mu = max(mu, mu_horizon + eps);
  }

  transmittance = GetTransmittance(atmosphere, transmittance_texture,
      r, mu, d, ray_r_mu_intersects_ground);

  IrradianceSpectrum single_mie_scattering;
  IrradianceSpectrum scattering = GetCombinedScattering(
      atmosphere, scattering_texture, single_mie_scattering_texture,
      r, mu, mu_s, nu, ray_r_mu_intersects_ground,
      single_mie_scattering);

  // Compute the r, mu, mu_s and nu parameters for the second texture lookup.
  // If shadow_length is not 0 (case of light shafts), we want to ignore the
  // scattering along the last shadow_length meters of the view ray, which we
  // do by subtracting shadow_length from d (this way scattering_p is equal to
  // the S|x_s=x_0-lv term in Eq. (17) of our paper).
  d = max(d - shadow_length, 0.0 * m);
  Length r_p = ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
  Number mu_p = (r * mu + d) / r_p;
  Number mu_s_p = (r * mu_s + d * nu) / r_p;

  IrradianceSpectrum single_mie_scattering_p;
  IrradianceSpectrum scattering_p = GetCombinedScattering(
      atmosphere, scattering_texture, single_mie_scattering_texture,
      r_p, mu_p, mu_s_p, nu, ray_r_mu_intersects_ground,
      single_mie_scattering_p);

  // Combine the lookup results to get the scattering between camera and point.
  DimensionlessSpectrum shadow_transmittance = transmittance;
  if (shadow_length > 0.0 * m) {
    // This is the T(x,x_s) term in Eq. (17) of our paper, for light shafts.
    shadow_transmittance = GetTransmittance(atmosphere, transmittance_texture,
        r, mu, d, ray_r_mu_intersects_ground);
  }
  // @shotamatsuda: Occlude only single Rayleigh scattering by the shadow.
#ifdef HAS_HIGHER_ORDER_SCATTERING_TEXTURE
  IrradianceSpectrum higher_order_scattering = GetScattering(
      atmosphere, higher_order_scattering_texture,
      r, mu, mu_s, nu, ray_r_mu_intersects_ground);
  IrradianceSpectrum single_scattering = scattering - higher_order_scattering;
  IrradianceSpectrum higher_order_scattering_p = GetScattering(
      atmosphere, higher_order_scattering_texture,
      r_p, mu_p, mu_s_p, nu, ray_r_mu_intersects_ground);
  IrradianceSpectrum single_scattering_p =
      scattering_p - higher_order_scattering_p;
  scattering =
      single_scattering - shadow_transmittance * single_scattering_p +
      higher_order_scattering - transmittance * higher_order_scattering_p;
#else // HAS_HIGHER_ORDER_SCATTERING_TEXTURE
  scattering = scattering - shadow_transmittance * scattering_p;
#endif // HAS_HIGHER_ORDER_SCATTERING_TEXTURE

  single_mie_scattering =
      single_mie_scattering - shadow_transmittance * single_mie_scattering_p;
#ifdef COMBINED_SCATTERING_TEXTURES
  single_mie_scattering = GetExtrapolatedSingleMieScattering(
      atmosphere, vec4(scattering, single_mie_scattering.r));
#endif // COMBINED_SCATTERING_TEXTURES

  // Hack to avoid rendering artifacts when the sun is below the horizon.
  single_mie_scattering = single_mie_scattering *
      smoothstep(Number(0.0), Number(0.01), mu_s);

  return scattering * RayleighPhaseFunction(nu) + single_mie_scattering *
      MiePhaseFunction(atmosphere.mie_phase_function_g, nu);
}

IrradianceSpectrum GetSunAndSkyIrradiance(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const IrradianceTexture irradiance_texture,
    const Position point, const Direction normal, const Direction sun_direction,
    out IrradianceSpectrum sky_irradiance) {
  Length r = length(point);
  Number mu_s = dot(point, sun_direction) / r;

  // Indirect irradiance (approximated if the surface is not horizontal).
  sky_irradiance = GetIrradiance(atmosphere, irradiance_texture, r, mu_s) *
      (1.0 + dot(normal, point) / r) * 0.5;

  // Direct irradiance.
  return atmosphere.solar_irradiance *
      GetTransmittanceToSun(
          atmosphere, transmittance_texture, r, mu_s) *
      max(dot(normal, sun_direction), 0.0);
}

// @shotamatsuda: Added for the clouds.
IrradianceSpectrum GetSunAndSkyScalarIrradiance(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const IrradianceTexture irradiance_texture,
    const Position point, const Direction sun_direction,
    out IrradianceSpectrum sky_irradiance) {
  Length r = length(point);
  Number mu_s = dot(point, sun_direction) / r;

  // Indirect irradiance. Integral over sphere yields 2π.
  sky_irradiance = GetIrradiance(atmosphere, irradiance_texture, r, mu_s) *
      2.0 * PI;

  // Direct irradiance. Omit the cosine term.
  return atmosphere.solar_irradiance *
      GetTransmittanceToSun(atmosphere, transmittance_texture, r, mu_s);
}

Luminance3 GetSolarLuminance() {
  return ATMOSPHERE.solar_irradiance /
      (PI * ATMOSPHERE.sun_angular_radius * ATMOSPHERE.sun_angular_radius) *
      SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
}

Luminance3 GetSkyLuminance(
    const Position camera, Direction view_ray, const Length shadow_length,
    const Direction sun_direction, out DimensionlessSpectrum transmittance) {
  return GetSkyRadiance(ATMOSPHERE, transmittance_texture,
      scattering_texture, single_mie_scattering_texture,
      camera, view_ray, shadow_length, sun_direction,
      transmittance) * SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
}

Luminance3 GetSkyLuminanceToPoint(
    const Position camera, const Position point, const Length shadow_length,
    const Direction sun_direction, out DimensionlessSpectrum transmittance) {
  return GetSkyRadianceToPoint(ATMOSPHERE, transmittance_texture,
      scattering_texture, single_mie_scattering_texture,
      camera, point, shadow_length, sun_direction, transmittance) *
      SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
}

Illuminance3 GetSunAndSkyIlluminance(
    const Position p, const Direction normal, const Direction sun_direction,
    out IrradianceSpectrum sky_irradiance) {
  IrradianceSpectrum sun_irradiance = GetSunAndSkyIrradiance(
      ATMOSPHERE, transmittance_texture, irradiance_texture, p, normal,
      sun_direction, sky_irradiance);
  sky_irradiance *= SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
  return sun_irradiance * SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
}

// @shotamatsuda: Added for the clouds.
Illuminance3 GetSunAndSkyScalarIlluminance(
    const Position p, const Direction sun_direction,
    out IrradianceSpectrum sky_irradiance) {
  IrradianceSpectrum sun_irradiance = GetSunAndSkyScalarIrradiance(
      ATMOSPHERE, transmittance_texture, irradiance_texture, p,
      sun_direction, sky_irradiance);
  sky_irradiance *= SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;
  return sun_irradiance * SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
}

#define GetSolarRadiance GetSolarLuminance
#define GetSkyRadiance GetSkyLuminance
#define GetSkyRadianceToPoint GetSkyLuminanceToPoint
#define GetSunAndSkyIrradiance GetSunAndSkyIlluminance
#define GetSunAndSkyScalarIrradiance GetSunAndSkyScalarIlluminance
`,Ef=`// Based on: https://github.com/ebruneton/precomputed_atmospheric_scattering/blob/master/atmosphere/functions.glsl

/**
 * Copyright (c) 2017 Eric Bruneton
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Precomputed Atmospheric Scattering
 * Copyright (c) 2008 INRIA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

Number GetLayerDensity(const DensityProfileLayer layer, const Length altitude) {
  Number density = layer.exp_term * exp(layer.exp_scale * altitude) +
      layer.linear_term * altitude + layer.constant_term;
  return clamp(density, Number(0.0), Number(1.0));
}

Number GetProfileDensity(const DensityProfile profile, const Length altitude) {
  DensityProfileLayer layers[2] = profile.layers;
  return altitude < layers[0].width
    ? GetLayerDensity(layers[0], altitude)
    : GetLayerDensity(layers[1], altitude);
}

Length ComputeOpticalLengthToTopAtmosphereBoundary(
    const AtmosphereParameters atmosphere, const DensityProfile profile,
    const Length r, const Number mu) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  // Number of intervals for the numerical integration.
  const int SAMPLE_COUNT = 500;
  // The integration step, i.e. the length of each integration interval.
  Length dx =
      DistanceToTopAtmosphereBoundary(atmosphere, r, mu) / Number(SAMPLE_COUNT);
  // Integration loop.
  Length result = 0.0 * m;
  for (int i = 0; i <= SAMPLE_COUNT; ++i) {
    Length d_i = Number(i) * dx;
    // Distance between the current sample point and the planet center.
    Length r_i = sqrt(d_i * d_i + 2.0 * r * mu * d_i + r * r);
    // Number density at the current sample point (divided by the number density
    // at the bottom of the atmosphere, yielding a dimensionless number).
    Number y_i = GetProfileDensity(profile, r_i - atmosphere.bottom_radius);
    // Sample weight (from the trapezoidal rule).
    Number weight_i = i == 0 || i == SAMPLE_COUNT ? 0.5 : 1.0;
    result += y_i * weight_i * dx;
  }
  return result;
}

DimensionlessSpectrum ComputeTransmittanceToTopAtmosphereBoundary(
    const AtmosphereParameters atmosphere, const Length r, const Number mu) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  vec3 optical_depth = (
      atmosphere.rayleigh_scattering *
          ComputeOpticalLengthToTopAtmosphereBoundary(
              atmosphere, atmosphere.rayleigh_density, r, mu) +
      atmosphere.mie_extinction *
          ComputeOpticalLengthToTopAtmosphereBoundary(
              atmosphere, atmosphere.mie_density, r, mu) +
      atmosphere.absorption_extinction *
          ComputeOpticalLengthToTopAtmosphereBoundary(
              atmosphere, atmosphere.absorption_density, r, mu));
  // @shotamatsuda: Added for the precomputation stage in half-float precision.
  #ifdef TRANSMITTANCE_PRECISION_LOG
  return optical_depth;
  #else // TRANSMITTANCE_PRECISION_LOG
  return exp(-optical_depth);
  #endif // TRANSMITTANCE_PRECISION_LOG
}

Number GetUnitRangeFromTextureCoord(const Number u, const int texture_size) {
  return (u - 0.5 / Number(texture_size)) / (1.0 - 1.0 / Number(texture_size));
}

void GetRMuFromTransmittanceTextureUv(const AtmosphereParameters atmosphere,
    const vec2 uv, out Length r, out Number mu) {
  assert(uv.x >= 0.0 && uv.x <= 1.0);
  assert(uv.y >= 0.0 && uv.y <= 1.0);
  Number x_mu = GetUnitRangeFromTextureCoord(uv.x, TRANSMITTANCE_TEXTURE_WIDTH);
  Number x_r = GetUnitRangeFromTextureCoord(uv.y, TRANSMITTANCE_TEXTURE_HEIGHT);
  // Distance to top atmosphere boundary for a horizontal ray at ground level.
  Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
      atmosphere.bottom_radius * atmosphere.bottom_radius);
  // Distance to the horizon, from which we can compute r:
  Length rho = H * x_r;
  r = sqrt(rho * rho + atmosphere.bottom_radius * atmosphere.bottom_radius);
  // Distance to the top atmosphere boundary for the ray (r,mu), and its minimum
  // and maximum values over all mu - obtained for (r,1) and (r,mu_horizon) -
  // from which we can recover mu:
  Length d_min = atmosphere.top_radius - r;
  Length d_max = rho + H;
  Length d = d_min + x_mu * (d_max - d_min);
  mu = d == 0.0 * m ? Number(1.0) : (H * H - rho * rho - d * d) / (2.0 * r * d);
  mu = ClampCosine(mu);
}

DimensionlessSpectrum ComputeTransmittanceToTopAtmosphereBoundaryTexture(
    const AtmosphereParameters atmosphere, const vec2 frag_coord) {
  const vec2 TRANSMITTANCE_TEXTURE_SIZE =
      vec2(TRANSMITTANCE_TEXTURE_WIDTH, TRANSMITTANCE_TEXTURE_HEIGHT);
  Length r;
  Number mu;
  GetRMuFromTransmittanceTextureUv(
      atmosphere, frag_coord / TRANSMITTANCE_TEXTURE_SIZE, r, mu);
  return ComputeTransmittanceToTopAtmosphereBoundary(atmosphere, r, mu);
}

void ComputeSingleScatteringIntegrand(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const Length r, const Number mu, const Number mu_s, const Number nu,
    const Length d, const bool ray_r_mu_intersects_ground,
    out DimensionlessSpectrum rayleigh, out DimensionlessSpectrum mie) {
  Length r_d = ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
  Number mu_s_d = ClampCosine((r * mu_s + d * nu) / r_d);
  DimensionlessSpectrum transmittance =
      GetTransmittance(
          atmosphere, transmittance_texture, r, mu, d,
          ray_r_mu_intersects_ground) *
      GetTransmittanceToSun(
          atmosphere, transmittance_texture, r_d, mu_s_d);
  rayleigh = transmittance * GetProfileDensity(
      atmosphere.rayleigh_density, r_d - atmosphere.bottom_radius);
  mie = transmittance * GetProfileDensity(
      atmosphere.mie_density, r_d - atmosphere.bottom_radius);
}

Length DistanceToNearestAtmosphereBoundary(const AtmosphereParameters atmosphere,
    Length r, Number mu, bool ray_r_mu_intersects_ground) {
  if (ray_r_mu_intersects_ground) {
    return DistanceToBottomAtmosphereBoundary(atmosphere, r, mu);
  } else {
    return DistanceToTopAtmosphereBoundary(atmosphere, r, mu);
  }
}

void ComputeSingleScattering(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const Length r, const Number mu, const Number mu_s, const Number nu,
    const bool ray_r_mu_intersects_ground,
    out IrradianceSpectrum rayleigh, out IrradianceSpectrum mie) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  assert(mu_s >= -1.0 && mu_s <= 1.0);
  assert(nu >= -1.0 && nu <= 1.0);

  // Number of intervals for the numerical integration.
  const int SAMPLE_COUNT = 50;
  // The integration step, i.e. the length of each integration interval.
  Length dx =
      DistanceToNearestAtmosphereBoundary(atmosphere, r, mu,
          ray_r_mu_intersects_ground) / Number(SAMPLE_COUNT);
  // Integration loop.
  DimensionlessSpectrum rayleigh_sum = DimensionlessSpectrum(0.0);
  DimensionlessSpectrum mie_sum = DimensionlessSpectrum(0.0);
  for (int i = 0; i <= SAMPLE_COUNT; ++i) {
    Length d_i = Number(i) * dx;
    // The Rayleigh and Mie single scattering at the current sample point.
    DimensionlessSpectrum rayleigh_i;
    DimensionlessSpectrum mie_i;
    ComputeSingleScatteringIntegrand(atmosphere, transmittance_texture,
        r, mu, mu_s, nu, d_i, ray_r_mu_intersects_ground, rayleigh_i, mie_i);
    // Sample weight (from the trapezoidal rule).
    Number weight_i = (i == 0 || i == SAMPLE_COUNT) ? 0.5 : 1.0;
    rayleigh_sum += rayleigh_i * weight_i;
    mie_sum += mie_i * weight_i;
  }
  rayleigh = rayleigh_sum * dx * atmosphere.solar_irradiance *
      atmosphere.rayleigh_scattering;
  mie = mie_sum * dx * atmosphere.solar_irradiance * atmosphere.mie_scattering;
}

void GetRMuMuSNuFromScatteringTextureUvwz(const AtmosphereParameters atmosphere,
    const vec4 uvwz, out Length r, out Number mu, out Number mu_s,
    out Number nu, out bool ray_r_mu_intersects_ground) {
  assert(uvwz.x >= 0.0 && uvwz.x <= 1.0);
  assert(uvwz.y >= 0.0 && uvwz.y <= 1.0);
  assert(uvwz.z >= 0.0 && uvwz.z <= 1.0);
  assert(uvwz.w >= 0.0 && uvwz.w <= 1.0);

  // Distance to top atmosphere boundary for a horizontal ray at ground level.
  Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
      atmosphere.bottom_radius * atmosphere.bottom_radius);
  // Distance to the horizon.
  Length rho =
      H * GetUnitRangeFromTextureCoord(uvwz.w, SCATTERING_TEXTURE_R_SIZE);
  r = sqrt(rho * rho + atmosphere.bottom_radius * atmosphere.bottom_radius);

  if (uvwz.z < 0.5) {
    // Distance to the ground for the ray (r,mu), and its minimum and maximum
    // values over all mu - obtained for (r,-1) and (r,mu_horizon) - from which
    // we can recover mu:
    Length d_min = r - atmosphere.bottom_radius;
    Length d_max = rho;
    Length d = d_min + (d_max - d_min) * GetUnitRangeFromTextureCoord(
        1.0 - 2.0 * uvwz.z, SCATTERING_TEXTURE_MU_SIZE / 2);
    mu = d == 0.0 * m ? Number(-1.0) :
        ClampCosine(-(rho * rho + d * d) / (2.0 * r * d));
    ray_r_mu_intersects_ground = true;
  } else {
    // Distance to the top atmosphere boundary for the ray (r,mu), and its
    // minimum and maximum values over all mu - obtained for (r,1) and
    // (r,mu_horizon) - from which we can recover mu:
    Length d_min = atmosphere.top_radius - r;
    Length d_max = rho + H;
    Length d = d_min + (d_max - d_min) * GetUnitRangeFromTextureCoord(
        2.0 * uvwz.z - 1.0, SCATTERING_TEXTURE_MU_SIZE / 2);
    mu = d == 0.0 * m ? Number(1.0) :
        ClampCosine((H * H - rho * rho - d * d) / (2.0 * r * d));
    ray_r_mu_intersects_ground = false;
  }

  Number x_mu_s =
      GetUnitRangeFromTextureCoord(uvwz.y, SCATTERING_TEXTURE_MU_S_SIZE);
  Length d_min = atmosphere.top_radius - atmosphere.bottom_radius;
  Length d_max = H;
  Length D = DistanceToTopAtmosphereBoundary(
      atmosphere, atmosphere.bottom_radius, atmosphere.mu_s_min);
  Number A = (D - d_min) / (d_max - d_min);
  Number a = (A - x_mu_s * A) / (1.0 + x_mu_s * A);
  Length d = d_min + min(a, A) * (d_max - d_min);
  mu_s = d == 0.0 * m ? Number(1.0) :
     ClampCosine((H * H - d * d) / (2.0 * atmosphere.bottom_radius * d));

  nu = ClampCosine(uvwz.x * 2.0 - 1.0);
}

void GetRMuMuSNuFromScatteringTextureFragCoord(
    const AtmosphereParameters atmosphere, const vec3 frag_coord,
    out Length r, out Number mu, out Number mu_s, out Number nu,
    out bool ray_r_mu_intersects_ground) {
  const vec4 SCATTERING_TEXTURE_SIZE = vec4(
      SCATTERING_TEXTURE_NU_SIZE - 1,
      SCATTERING_TEXTURE_MU_S_SIZE,
      SCATTERING_TEXTURE_MU_SIZE,
      SCATTERING_TEXTURE_R_SIZE);
  Number frag_coord_nu =
      floor(frag_coord.x / Number(SCATTERING_TEXTURE_MU_S_SIZE));
  Number frag_coord_mu_s =
      mod(frag_coord.x, Number(SCATTERING_TEXTURE_MU_S_SIZE));
  vec4 uvwz =
      vec4(frag_coord_nu, frag_coord_mu_s, frag_coord.y, frag_coord.z) /
          SCATTERING_TEXTURE_SIZE;
  GetRMuMuSNuFromScatteringTextureUvwz(
      atmosphere, uvwz, r, mu, mu_s, nu, ray_r_mu_intersects_ground);
  // Clamp nu to its valid range of values, given mu and mu_s.
  nu = clamp(nu, mu * mu_s - sqrt((1.0 - mu * mu) * (1.0 - mu_s * mu_s)),
      mu * mu_s + sqrt((1.0 - mu * mu) * (1.0 - mu_s * mu_s)));
}

void ComputeSingleScatteringTexture(const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture, const vec3 frag_coord,
    out IrradianceSpectrum rayleigh, out IrradianceSpectrum mie) {
  Length r;
  Number mu;
  Number mu_s;
  Number nu;
  bool ray_r_mu_intersects_ground;
  GetRMuMuSNuFromScatteringTextureFragCoord(atmosphere, frag_coord,
      r, mu, mu_s, nu, ray_r_mu_intersects_ground);
  ComputeSingleScattering(atmosphere, transmittance_texture,
      r, mu, mu_s, nu, ray_r_mu_intersects_ground, rayleigh, mie);
}

AbstractSpectrum GetScattering(
    const AtmosphereParameters atmosphere,
    const AbstractScatteringTexture scattering_texture,
    const Length r, const Number mu, const Number mu_s, const Number nu,
    const bool ray_r_mu_intersects_ground) {
  vec4 uvwz = GetScatteringTextureUvwzFromRMuMuSNu(
      atmosphere, r, mu, mu_s, nu, ray_r_mu_intersects_ground);
  Number tex_coord_x = uvwz.x * Number(SCATTERING_TEXTURE_NU_SIZE - 1);
  Number tex_x = floor(tex_coord_x);
  Number lerp = tex_coord_x - tex_x;
  vec3 uvw0 = vec3((tex_x + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
      uvwz.z, uvwz.w);
  vec3 uvw1 = vec3((tex_x + 1.0 + uvwz.y) / Number(SCATTERING_TEXTURE_NU_SIZE),
      uvwz.z, uvwz.w);
  return AbstractSpectrum(texture(scattering_texture, uvw0) * (1.0 - lerp) +
      texture(scattering_texture, uvw1) * lerp);
}

RadianceSpectrum GetScattering(
    const AtmosphereParameters atmosphere,
    const ReducedScatteringTexture single_rayleigh_scattering_texture,
    const ReducedScatteringTexture single_mie_scattering_texture,
    const ScatteringTexture multiple_scattering_texture,
    const Length r, const Number mu, const Number mu_s, const Number nu,
    const bool ray_r_mu_intersects_ground,
    const int scattering_order) {
  if (scattering_order == 1) {
    IrradianceSpectrum rayleigh = GetScattering(
        atmosphere, single_rayleigh_scattering_texture, r, mu, mu_s, nu,
        ray_r_mu_intersects_ground);
    IrradianceSpectrum mie = GetScattering(
        atmosphere, single_mie_scattering_texture, r, mu, mu_s, nu,
        ray_r_mu_intersects_ground);
    return rayleigh * RayleighPhaseFunction(nu) +
        mie * MiePhaseFunction(atmosphere.mie_phase_function_g, nu);
  } else {
    return GetScattering(
        atmosphere, multiple_scattering_texture, r, mu, mu_s, nu,
        ray_r_mu_intersects_ground);
  }
}

IrradianceSpectrum GetIrradiance(
    const AtmosphereParameters atmosphere,
    const IrradianceTexture irradiance_texture,
    const Length r, const Number mu_s);

RadianceDensitySpectrum ComputeScatteringDensity(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const ReducedScatteringTexture single_rayleigh_scattering_texture,
    const ReducedScatteringTexture single_mie_scattering_texture,
    const ScatteringTexture multiple_scattering_texture,
    const IrradianceTexture irradiance_texture,
    const Length r, const Number mu, const Number mu_s, const Number nu,
    const int scattering_order) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  assert(mu_s >= -1.0 && mu_s <= 1.0);
  assert(nu >= -1.0 && nu <= 1.0);
  assert(scattering_order >= 2);

  // Compute unit direction vectors for the zenith, the view direction omega and
  // and the sun direction omega_s, such that the cosine of the view-zenith
  // angle is mu, the cosine of the sun-zenith angle is mu_s, and the cosine of
  // the view-sun angle is nu. The goal is to simplify computations below.
  vec3 zenith_direction = vec3(0.0, 0.0, 1.0);
  vec3 omega = vec3(sqrt(1.0 - mu * mu), 0.0, mu);
  Number sun_dir_x = omega.x == 0.0 ? 0.0 : (nu - mu * mu_s) / omega.x;
  Number sun_dir_y = sqrt(max(1.0 - sun_dir_x * sun_dir_x - mu_s * mu_s, 0.0));
  vec3 omega_s = vec3(sun_dir_x, sun_dir_y, mu_s);

  const int SAMPLE_COUNT = 16;
  const Angle dphi = pi / Number(SAMPLE_COUNT);
  const Angle dtheta = pi / Number(SAMPLE_COUNT);
  RadianceDensitySpectrum rayleigh_mie =
      RadianceDensitySpectrum(0.0 * watt_per_cubic_meter_per_sr_per_nm);

  // Nested loops for the integral over all the incident directions omega_i.
  for (int l = 0; l < SAMPLE_COUNT; ++l) {
    Angle theta = (Number(l) + 0.5) * dtheta;
    Number cos_theta = cos(theta);
    Number sin_theta = sin(theta);
    bool ray_r_theta_intersects_ground =
        RayIntersectsGround(atmosphere, r, cos_theta);

    // The distance and transmittance to the ground only depend on theta, so we
    // can compute them in the outer loop for efficiency.
    Length distance_to_ground = 0.0 * m;
    DimensionlessSpectrum transmittance_to_ground = DimensionlessSpectrum(0.0);
    DimensionlessSpectrum ground_albedo = DimensionlessSpectrum(0.0);
    if (ray_r_theta_intersects_ground) {
      distance_to_ground =
          DistanceToBottomAtmosphereBoundary(atmosphere, r, cos_theta);
      transmittance_to_ground =
          GetTransmittance(atmosphere, transmittance_texture, r, cos_theta,
              distance_to_ground, true /* ray_intersects_ground */);
      ground_albedo = atmosphere.ground_albedo;
    }

    for (int m = 0; m < 2 * SAMPLE_COUNT; ++m) {
      Angle phi = (Number(m) + 0.5) * dphi;
      vec3 omega_i =
          vec3(cos(phi) * sin_theta, sin(phi) * sin_theta, cos_theta);
      SolidAngle domega_i = (dtheta / rad) * (dphi / rad) * sin(theta) * sr;

      // The radiance L_i arriving from direction omega_i after n-1 bounces is
      // the sum of a term given by the precomputed scattering texture for the
      // (n-1)-th order:
      Number nu1 = dot(omega_s, omega_i);
      RadianceSpectrum incident_radiance = GetScattering(atmosphere,
          single_rayleigh_scattering_texture, single_mie_scattering_texture,
          multiple_scattering_texture, r, omega_i.z, mu_s, nu1,
          ray_r_theta_intersects_ground, scattering_order - 1);

      // and of the contribution from the light paths with n-1 bounces and whose
      // last bounce is on the ground. This contribution is the product of the
      // transmittance to the ground, the ground albedo, the ground BRDF, and
      // the irradiance received on the ground after n-2 bounces.
      vec3 ground_normal =
          normalize(zenith_direction * r + omega_i * distance_to_ground);
      IrradianceSpectrum ground_irradiance = GetIrradiance(
          atmosphere, irradiance_texture, atmosphere.bottom_radius,
          dot(ground_normal, omega_s));
      incident_radiance += transmittance_to_ground *
          ground_albedo * (1.0 / (PI * sr)) * ground_irradiance;

      // The radiance finally scattered from direction omega_i towards direction
      // -omega is the product of the incident radiance, the scattering
      // coefficient, and the phase function for directions omega and omega_i
      // (all this summed over all particle types, i.e. Rayleigh and Mie).
      Number nu2 = dot(omega, omega_i);
      Number rayleigh_density = GetProfileDensity(
          atmosphere.rayleigh_density, r - atmosphere.bottom_radius);
      Number mie_density = GetProfileDensity(
          atmosphere.mie_density, r - atmosphere.bottom_radius);
      rayleigh_mie += incident_radiance * (
          atmosphere.rayleigh_scattering * rayleigh_density *
              RayleighPhaseFunction(nu2) +
          atmosphere.mie_scattering * mie_density *
              MiePhaseFunction(atmosphere.mie_phase_function_g, nu2)) *
          domega_i;
    }
  }
  return rayleigh_mie;
}

RadianceSpectrum ComputeMultipleScattering(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const ScatteringDensityTexture scattering_density_texture,
    const Length r, const Number mu, const Number mu_s, const Number nu,
    const bool ray_r_mu_intersects_ground) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu >= -1.0 && mu <= 1.0);
  assert(mu_s >= -1.0 && mu_s <= 1.0);
  assert(nu >= -1.0 && nu <= 1.0);

  // Number of intervals for the numerical integration.
  const int SAMPLE_COUNT = 50;
  // The integration step, i.e. the length of each integration interval.
  Length dx =
      DistanceToNearestAtmosphereBoundary(
          atmosphere, r, mu, ray_r_mu_intersects_ground) /
              Number(SAMPLE_COUNT);
  // Integration loop.
  RadianceSpectrum rayleigh_mie_sum =
      RadianceSpectrum(0.0 * watt_per_square_meter_per_sr_per_nm);
  for (int i = 0; i <= SAMPLE_COUNT; ++i) {
    Length d_i = Number(i) * dx;

    // The r, mu and mu_s parameters at the current integration point (see the
    // single scattering section for a detailed explanation).
    Length r_i =
        ClampRadius(atmosphere, sqrt(d_i * d_i + 2.0 * r * mu * d_i + r * r));
    Number mu_i = ClampCosine((r * mu + d_i) / r_i);
    Number mu_s_i = ClampCosine((r * mu_s + d_i * nu) / r_i);

    // The Rayleigh and Mie multiple scattering at the current sample point.
    RadianceSpectrum rayleigh_mie_i =
        GetScattering(
            atmosphere, scattering_density_texture, r_i, mu_i, mu_s_i, nu,
            ray_r_mu_intersects_ground) *
        GetTransmittance(
            atmosphere, transmittance_texture, r, mu, d_i,
            ray_r_mu_intersects_ground) *
        dx;
    // Sample weight (from the trapezoidal rule).
    Number weight_i = (i == 0 || i == SAMPLE_COUNT) ? 0.5 : 1.0;
    rayleigh_mie_sum += rayleigh_mie_i * weight_i;
  }
  return rayleigh_mie_sum;
}

RadianceDensitySpectrum ComputeScatteringDensityTexture(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const ReducedScatteringTexture single_rayleigh_scattering_texture,
    const ReducedScatteringTexture single_mie_scattering_texture,
    const ScatteringTexture multiple_scattering_texture,
    const IrradianceTexture irradiance_texture,
    const vec3 frag_coord, const int scattering_order) {
  Length r;
  Number mu;
  Number mu_s;
  Number nu;
  bool ray_r_mu_intersects_ground;
  GetRMuMuSNuFromScatteringTextureFragCoord(atmosphere, frag_coord,
      r, mu, mu_s, nu, ray_r_mu_intersects_ground);
  return ComputeScatteringDensity(atmosphere, transmittance_texture,
      single_rayleigh_scattering_texture, single_mie_scattering_texture,
      multiple_scattering_texture, irradiance_texture, r, mu, mu_s, nu,
      scattering_order);
}

RadianceSpectrum ComputeMultipleScatteringTexture(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const ScatteringDensityTexture scattering_density_texture,
    const vec3 frag_coord, out Number nu) {
  Length r;
  Number mu;
  Number mu_s;
  bool ray_r_mu_intersects_ground;
  GetRMuMuSNuFromScatteringTextureFragCoord(atmosphere, frag_coord,
      r, mu, mu_s, nu, ray_r_mu_intersects_ground);
  return ComputeMultipleScattering(atmosphere, transmittance_texture,
      scattering_density_texture, r, mu, mu_s, nu,
      ray_r_mu_intersects_ground);
}

IrradianceSpectrum ComputeDirectIrradiance(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const Length r, const Number mu_s) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu_s >= -1.0 && mu_s <= 1.0);

  Number alpha_s = atmosphere.sun_angular_radius / rad;
  // Approximate average of the cosine factor mu_s over the visible fraction of
  // the Sun disc.
  Number average_cosine_factor =
    mu_s < -alpha_s ? 0.0 : (mu_s > alpha_s ? mu_s :
        (mu_s + alpha_s) * (mu_s + alpha_s) / (4.0 * alpha_s));

  return atmosphere.solar_irradiance *
      GetTransmittanceToTopAtmosphereBoundary(
          atmosphere, transmittance_texture, r, mu_s) * average_cosine_factor;

}

IrradianceSpectrum ComputeIndirectIrradiance(
    const AtmosphereParameters atmosphere,
    const ReducedScatteringTexture single_rayleigh_scattering_texture,
    const ReducedScatteringTexture single_mie_scattering_texture,
    const ScatteringTexture multiple_scattering_texture,
    const Length r, const Number mu_s, const int scattering_order) {
  assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
  assert(mu_s >= -1.0 && mu_s <= 1.0);
  assert(scattering_order >= 1);

  const int SAMPLE_COUNT = 32;
  const Angle dphi = pi / Number(SAMPLE_COUNT);
  const Angle dtheta = pi / Number(SAMPLE_COUNT);

  IrradianceSpectrum result =
      IrradianceSpectrum(0.0 * watt_per_square_meter_per_nm);
  vec3 omega_s = vec3(sqrt(1.0 - mu_s * mu_s), 0.0, mu_s);
  for (int j = 0; j < SAMPLE_COUNT / 2; ++j) {
    Angle theta = (Number(j) + 0.5) * dtheta;
    for (int i = 0; i < 2 * SAMPLE_COUNT; ++i) {
      Angle phi = (Number(i) + 0.5) * dphi;
      vec3 omega =
          vec3(cos(phi) * sin(theta), sin(phi) * sin(theta), cos(theta));
      SolidAngle domega = (dtheta / rad) * (dphi / rad) * sin(theta) * sr;

      Number nu = dot(omega, omega_s);
      result += GetScattering(atmosphere, single_rayleigh_scattering_texture,
          single_mie_scattering_texture, multiple_scattering_texture,
          r, omega.z, mu_s, nu, false /* ray_r_theta_intersects_ground */,
          scattering_order) *
              omega.z * domega;
    }
  }
  return result;
}

void GetRMuSFromIrradianceTextureUv(const AtmosphereParameters atmosphere,
    const vec2 uv, out Length r, out Number mu_s) {
  assert(uv.x >= 0.0 && uv.x <= 1.0);
  assert(uv.y >= 0.0 && uv.y <= 1.0);
  Number x_mu_s = GetUnitRangeFromTextureCoord(uv.x, IRRADIANCE_TEXTURE_WIDTH);
  Number x_r = GetUnitRangeFromTextureCoord(uv.y, IRRADIANCE_TEXTURE_HEIGHT);
  r = atmosphere.bottom_radius +
      x_r * (atmosphere.top_radius - atmosphere.bottom_radius);
  mu_s = ClampCosine(2.0 * x_mu_s - 1.0);
}

const vec2 IRRADIANCE_TEXTURE_SIZE =
    vec2(IRRADIANCE_TEXTURE_WIDTH, IRRADIANCE_TEXTURE_HEIGHT);

IrradianceSpectrum ComputeDirectIrradianceTexture(
    const AtmosphereParameters atmosphere,
    const TransmittanceTexture transmittance_texture,
    const vec2 frag_coord) {
  Length r;
  Number mu_s;
  GetRMuSFromIrradianceTextureUv(
      atmosphere, frag_coord / IRRADIANCE_TEXTURE_SIZE, r, mu_s);
  return ComputeDirectIrradiance(atmosphere, transmittance_texture, r, mu_s);
}

IrradianceSpectrum ComputeIndirectIrradianceTexture(
    const AtmosphereParameters atmosphere,
    const ReducedScatteringTexture single_rayleigh_scattering_texture,
    const ReducedScatteringTexture single_mie_scattering_texture,
    const ScatteringTexture multiple_scattering_texture,
    const vec2 frag_coord, const int scattering_order) {
  Length r;
  Number mu_s;
  GetRMuSFromIrradianceTextureUv(
      atmosphere, frag_coord / IRRADIANCE_TEXTURE_SIZE, r, mu_s);
  return ComputeIndirectIrradiance(atmosphere,
      single_rayleigh_scattering_texture, single_mie_scattering_texture,
      multiple_scattering_texture, r, mu_s, scattering_order);
}
`,xne=new L(.2126,.7152,.0722),yne=["solarIrradiance","sunAngularRadius","bottomRadius","topRadius","rayleighDensity","rayleighScattering","mieDensity","mieScattering","mieExtinction","miePhaseFunctionG","absorptionDensity","absorptionExtinction","groundAlbedo","muSMin","skyRadianceToLuminance","sunRadianceToLuminance"];function Sne(n,e){if(e!=null)for(const t of yne){const i=e[t];i!=null&&(n[t]instanceof L?n[t].copy(i):n[t]=i)}}class Mf{constructor(e,t,i,r,a){this.width=e,this.expTerm=t,this.expScale=i,this.linearTerm=r,this.constantTerm=a}toUniform(){return new J({width:this.width,exp_term:this.expTerm,exp_scale:this.expScale,linear_term:this.linearTerm,constant_term:this.constantTerm})}}const eM=class{constructor(e){this.solarIrradiance=new L(1.474,1.8504,1.91198),this.sunAngularRadius=.004675,this.bottomRadius=636e4,this.topRadius=642e4,this.rayleighDensity=[new Mf(0,0,0,0,0),new Mf(0,1,-.125,0,0)],this.rayleighScattering=new L(.005802,.013558,.0331),this.mieDensity=[new Mf(0,0,0,0,0),new Mf(0,1,-.833333,0,0)],this.mieScattering=new L(.003996,.003996,.003996),this.mieExtinction=new L(.00444,.00444,.00444),this.miePhaseFunctionG=.8,this.absorptionDensity=[new Mf(25,0,0,1/15,-2/3),new Mf(0,0,0,-1/15,8/3)],this.absorptionExtinction=new L(65e-5,.001881,85e-6),this.groundAlbedo=new qe().setScalar(.1),this.muSMin=Math.cos(Tu(120)),this.sunRadianceToLuminance=new L(98242.786222,69954.398112,66475.012354),this.skyRadianceToLuminance=new L(114974.916437,71305.954816,65310.548555),this.sunRadianceToRelativeLuminance=new L,this.skyRadianceToRelativeLuminance=new L,Sne(this,e);const t=xne.dot(this.sunRadianceToLuminance);this.sunRadianceToRelativeLuminance.copy(this.sunRadianceToLuminance).divideScalar(t),this.skyRadianceToRelativeLuminance.copy(this.skyRadianceToLuminance).divideScalar(t)}toUniform(){return new J({solar_irradiance:this.solarIrradiance,sun_angular_radius:this.sunAngularRadius,bottom_radius:this.bottomRadius*u1,top_radius:this.topRadius*u1,rayleigh_density:{layers:this.rayleighDensity.map(e=>e.toUniform().value)},rayleigh_scattering:this.rayleighScattering,mie_density:{layers:this.mieDensity.map(e=>e.toUniform().value)},mie_scattering:this.mieScattering,mie_extinction:this.mieExtinction,mie_phase_function_g:this.miePhaseFunctionG,absorption_density:{layers:this.absorptionDensity.map(e=>e.toUniform().value)},absorption_extinction:this.absorptionExtinction,ground_albedo:this.groundAlbedo,mu_s_min:this.muSMin})}};eM.DEFAULT=new eM;let $0=eM;const Tne=`precision highp sampler2DArray;

#include "core/depth"
#include "core/math"
#include "core/packing"
#include "core/transform"
#ifdef HAS_SHADOW
#include "core/raySphereIntersection"
#include "core/cascadedShadowMaps"
#include "core/interleavedGradientNoise"
#include "core/vogelDisk"
#endif // HAS_SHADOW

#include "bruneton/definitions"

uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;

uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;

#include "bruneton/common"
#include "bruneton/runtime"

#include "sky"

uniform sampler2D normalBuffer;

uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 inverseProjectionMatrix;
uniform mat4 inverseViewMatrix;
uniform float bottomRadius;
uniform mat4 worldToECEFMatrix;
uniform float geometricErrorCorrectionAmount;
uniform vec3 sunDirection;
uniform vec3 moonDirection;
uniform float moonAngularRadius;
uniform float lunarRadianceScale;
uniform float albedoScale;

#ifdef HAS_LIGHTING_MASK
uniform sampler2D lightingMaskBuffer;
#endif // HAS_LIGHTING_MASK

// prettier-ignore
#define LIGHTING_MASK_CHANNEL_ LIGHTING_MASK_CHANNEL

#ifdef HAS_OVERLAY
uniform sampler2D overlayBuffer;
#endif // HAS_OVERLAY

#ifdef HAS_SHADOW
uniform sampler2DArray shadowBuffer;
uniform vec2 shadowIntervals[SHADOW_CASCADE_COUNT];
uniform mat4 shadowMatrices[SHADOW_CASCADE_COUNT];
uniform mat4 inverseShadowMatrices[SHADOW_CASCADE_COUNT];
uniform float shadowFar;
uniform float shadowTopHeight;
uniform float shadowRadius;
uniform sampler3D stbnTexture;
uniform int frame;
#endif // HAS_SHADOW

#ifdef HAS_SHADOW_LENGTH
uniform sampler2D shadowLengthBuffer;
#endif // HAS_SHADOW_LENGTH

varying vec3 vCameraPosition;
varying vec3 vRayDirection;
varying vec3 vGeometryAltitudeCorrection;
varying vec3 vEllipsoidRadiiSquared;

vec3 readNormal(const vec2 uv) {
  #ifdef OCT_ENCODED_NORMAL
  return unpackVec2ToNormal(texture(normalBuffer, uv).xy);
  #else // OCT_ENCODED_NORMAL
  return 2.0 * texture(normalBuffer, uv).xyz - 1.0;
  #endif // OCT_ENCODED_NORMAL
}

void correctGeometricError(inout vec3 positionECEF, inout vec3 normalECEF) {
  // TODO: The error is pronounced at the edge of the ellipsoid due to the
  // large difference between the sphere position and the unprojected position
  // at the current fragment. Calculating the sphere position from the fragment
  // UV may resolve this.

  // Correct way is slerp, but this will be small-angle interpolation anyways.
  vec3 sphereNormal = normalize(positionECEF / vEllipsoidRadiiSquared);
  vec3 spherePosition = ATMOSPHERE.bottom_radius * sphereNormal;
  normalECEF = mix(normalECEF, sphereNormal, geometricErrorCorrectionAmount);
  positionECEF = mix(positionECEF, spherePosition, geometricErrorCorrectionAmount);
}

#if defined(SUN_LIGHT) || defined(SKY_LIGHT)

vec3 getSunSkyIrradiance(
  const vec3 positionECEF,
  const vec3 normal,
  const vec3 inputColor,
  const float sunTransmittance
) {
  // Assume lambertian BRDF. If both SUN_LIGHT and SKY_LIGHT are not defined,
  // regard the inputColor as radiance at the texel.
  vec3 diffuse = inputColor * albedoScale * RECIPROCAL_PI;
  vec3 skyIrradiance;
  vec3 sunIrradiance = GetSunAndSkyIrradiance(positionECEF, normal, sunDirection, skyIrradiance);

  #ifdef HAS_SHADOW
  sunIrradiance *= sunTransmittance;
  #endif // HAS_SHADOW

  #if defined(SUN_LIGHT) && defined(SKY_LIGHT)
  return diffuse * (sunIrradiance + skyIrradiance);
  #elif defined(SUN_LIGHT)
  return diffuse * sunIrradiance;
  #elif defined(SKY_LIGHT)
  return diffuse * skyIrradiance;
  #endif // defined(SUN_LIGHT) && defined(SKY_LIGHT)
}

#endif // defined(SUN_LIGHT) || defined(SKY_LIGHT)

#if defined(TRANSMITTANCE) || defined(INSCATTER)

void applyTransmittanceInscatter(const vec3 positionECEF, float shadowLength, inout vec3 radiance) {
  vec3 transmittance;
  vec3 inscatter = GetSkyRadianceToPoint(
    vCameraPosition,
    positionECEF,
    shadowLength,
    sunDirection,
    transmittance
  );
  #ifdef TRANSMITTANCE
  radiance = radiance * transmittance;
  #endif // TRANSMITTANCE
  #ifdef INSCATTER
  radiance = radiance + inscatter;
  #endif // INSCATTER
}

#endif // defined(TRANSMITTANCE) || defined(INSCATTER)

#ifdef HAS_SHADOW

float getSTBN() {
  ivec3 size = textureSize(stbnTexture, 0);
  vec3 scale = 1.0 / vec3(size);
  return texture(stbnTexture, vec3(gl_FragCoord.xy, float(frame % size.z)) * scale).r;
}

vec2 getShadowUv(const vec3 worldPosition, const int cascadeIndex) {
  vec4 clip = shadowMatrices[cascadeIndex] * vec4(worldPosition, 1.0);
  clip /= clip.w;
  return clip.xy * 0.5 + 0.5;
}

float getDistanceToShadowTop(const vec3 positionECEF) {
  // Distance to the top of the shadows along the sun direction, which matches
  // the ray origin of BSM.
  return raySphereSecondIntersection(
    positionECEF / METER_TO_LENGTH_UNIT, // TODO: Make units consistent
    sunDirection,
    vec3(0.0),
    bottomRadius + shadowTopHeight
  );
}

float readShadowOpticalDepth(const vec2 uv, const float distanceToTop, const int cascadeIndex) {
  // r: frontDepth, g: meanExtinction, b: maxOpticalDepth, a: maxOpticalDepthTail
  vec4 shadow = texture(shadowBuffer, vec3(uv, float(cascadeIndex)));
  // Omit adding maxOpticalDepthTail to avoid pronounced aliasing. Ground
  // shadow will be attenuated by inscatter anyways.
  return min(shadow.b, shadow.g * max(0.0, distanceToTop - shadow.r));
}

float sampleShadowOpticalDepthPCF(
  const vec3 worldPosition,
  const float distanceToTop,
  const float radius,
  const int cascadeIndex
) {
  vec2 uv = getShadowUv(worldPosition, cascadeIndex);
  if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
    return 0.0;
  }

  vec2 texelSize = vec2(1.0) / vec2(textureSize(shadowBuffer, 0).xy);
  float sum = 0.0;
  vec2 offset;
  #pragma unroll_loop_start
  for (int i = 0; i < 16; ++i) {
    #if UNROLLED_LOOP_INDEX < SHADOW_SAMPLE_COUNT
    offset = vogelDisk(
      UNROLLED_LOOP_INDEX,
      SHADOW_SAMPLE_COUNT,
      interleavedGradientNoise(gl_FragCoord.xy) * PI2
    );
    sum += readShadowOpticalDepth(uv + offset * radius * texelSize, distanceToTop, cascadeIndex);
    #endif // UNROLLED_LOOP_INDEX < SHADOW_SAMPLE_COUNT
  }
  #pragma unroll_loop_end
  return sum / float(SHADOW_SAMPLE_COUNT);
}

float sampleShadowOpticalDepth(
  const vec3 worldPosition,
  const vec3 positionECEF,
  const float radius,
  const float jitter
) {
  float distanceToTop = getDistanceToShadowTop(positionECEF);
  if (distanceToTop <= 0.0) {
    return 0.0;
  }
  int cascadeIndex = getFadedCascadeIndex(
    viewMatrix,
    worldPosition,
    shadowIntervals,
    cameraNear,
    shadowFar,
    jitter
  );
  return cascadeIndex >= 0
    ? sampleShadowOpticalDepthPCF(worldPosition, distanceToTop, radius, cascadeIndex)
    : 0.0;
}

float getShadowRadius(const vec3 worldPosition) {
  vec4 clip = shadowMatrices[0] * vec4(worldPosition, 1.0);
  clip /= clip.w;

  // Offset by 1px in each direction in shadow's clip coordinates.
  vec2 shadowSize = vec2(textureSize(shadowBuffer, 0));
  vec3 offset = vec3(2.0 / shadowSize, 0.0);
  vec4 clipX = clip + offset.xzzz;
  vec4 clipY = clip + offset.zyzz;

  // Convert back to world space.
  vec4 worldX = inverseShadowMatrices[0] * clipX;
  vec4 worldY = inverseShadowMatrices[0] * clipY;

  // Project into the main camera's clip space.
  mat4 viewProjectionMatrix = projectionMatrix * viewMatrix;
  vec4 projected = viewProjectionMatrix * vec4(worldPosition, 1.0);
  vec4 projectedX = viewProjectionMatrix * worldX;
  vec4 projectedY = viewProjectionMatrix * worldY;
  projected /= projected.w;
  projectedX /= projectedX.w;
  projectedY /= projectedY.w;

  // Take the mean of pixel sizes.
  vec2 center = (projected.xy * 0.5 + 0.5) * resolution;
  vec2 offsetX = (projectedX.xy * 0.5 + 0.5) * resolution;
  vec2 offsetY = (projectedY.xy * 0.5 + 0.5) * resolution;
  float size = max(length(offsetX - center), length(offsetY - center));

  return remapClamped(size, 10.0, 50.0, 0.0, shadowRadius);
}

#endif // HAS_SHADOW

void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
  #if defined(HAS_LIGHTING_MASK) && defined(DEBUG_SHOW_LIGHTING_MASK)
  outputColor.rgb = vec3(texture(lightingMaskBuffer, uv).LIGHTING_MASK_CHANNEL_);
  outputColor.a = 1.0;
  return;
  #endif // defined(HAS_LIGHTING_MASK) && defined(DEBUG_SHOW_LIGHTING_MASK)

  float shadowLength = 0.0;
  #ifdef HAS_SHADOW_LENGTH
  shadowLength = texture(shadowLengthBuffer, uv).r;
  #endif // HAS_SHADOW_LENGTH

  #ifdef HAS_OVERLAY
  vec4 overlay = texture(overlayBuffer, uv);
  if (overlay.a == 1.0) {
    outputColor = overlay;
    return;
  }
  #endif // HAS_OVERLAY

  float depth = readDepth(uv);
  if (depth >= 1.0 - 1e-8) {
    #ifdef SKY
    vec3 rayDirection = normalize(vRayDirection);
    outputColor.rgb = getSkyRadiance(
      vCameraPosition,
      rayDirection,
      shadowLength,
      sunDirection,
      moonDirection,
      moonAngularRadius,
      lunarRadianceScale
    );
    outputColor.a = 1.0;
    #else // SKY
    outputColor = inputColor;
    #endif // SKY

    #ifdef HAS_OVERLAY
    outputColor.rgb = outputColor.rgb * (1.0 - overlay.a) + overlay.rgb;
    #endif // HAS_OVERLAY
    return;
  }
  depth = reverseLogDepth(depth, cameraNear, cameraFar);

  // Reconstruct position and normal in world space.
  vec3 viewPosition = screenToView(
    uv,
    depth,
    getViewZ(depth),
    projectionMatrix,
    inverseProjectionMatrix
  );
  vec3 viewNormal;
  #ifdef RECONSTRUCT_NORMAL
  vec3 dx = dFdx(viewPosition);
  vec3 dy = dFdy(viewPosition);
  viewNormal = normalize(cross(dx, dy));
  #else // RECONSTRUCT_NORMAL
  viewNormal = readNormal(uv);
  #endif // RECONSTRUCT_NORMAL

  vec3 worldPosition = (inverseViewMatrix * vec4(viewPosition, 1.0)).xyz;
  vec3 worldNormal = (inverseViewMatrix * vec4(viewNormal, 0.0)).xyz;
  vec3 positionECEF = (worldToECEFMatrix * vec4(worldPosition, 1.0)).xyz;
  positionECEF = positionECEF * METER_TO_LENGTH_UNIT + vGeometryAltitudeCorrection;
  vec3 normalECEF = (worldToECEFMatrix * vec4(worldNormal, 0.0)).xyz;

  #ifdef CORRECT_GEOMETRIC_ERROR
  correctGeometricError(positionECEF, normalECEF);
  #endif // CORRECT_GEOMETRIC_ERROR

  #ifdef HAS_SHADOW
  float stbn = getSTBN();
  float radius = getShadowRadius(worldPosition);
  float opticalDepth = sampleShadowOpticalDepth(worldPosition, positionECEF, radius, stbn);
  float sunTransmittance = exp(-opticalDepth);
  #else // HAS_SHADOW
  float sunTransmittance = 1.0;
  #endif // HAS_SHADOW

  vec3 radiance;
  #if defined(SUN_LIGHT) || defined(SKY_LIGHT)
  radiance = getSunSkyIrradiance(positionECEF, normalECEF, inputColor.rgb, sunTransmittance);
  #ifdef HAS_LIGHTING_MASK
  float lightingMask = texture(lightingMaskBuffer, uv).LIGHTING_MASK_CHANNEL_;
  radiance = mix(inputColor.rgb, radiance, lightingMask);
  #endif // HAS_LIGHTING_MASK
  #else // defined(SUN_LIGHT) || defined(SKY_LIGHT)
  radiance = inputColor.rgb;
  #endif // defined(SUN_LIGHT) || defined(SKY_LIGHT)

  #if defined(TRANSMITTANCE) || defined(INSCATTER)
  applyTransmittanceInscatter(positionECEF, shadowLength, radiance);
  #endif // defined(TRANSMITTANCE) || defined(INSCATTER)

  outputColor = vec4(radiance, inputColor.a);

  #ifdef HAS_OVERLAY
  outputColor.rgb = outputColor.rgb * (1.0 - overlay.a) + overlay.rgb;
  #endif // HAS_OVERLAY
}
`,Ene=`uniform mat4 inverseViewMatrix;
uniform mat4 inverseProjectionMatrix;
uniform vec3 cameraPosition;
uniform mat4 worldToECEFMatrix;
uniform vec3 altitudeCorrection;
uniform float geometricErrorCorrectionAmount;
uniform vec3 ellipsoidRadii;

varying vec3 vCameraPosition;
varying vec3 vRayDirection;
varying vec3 vGeometryAltitudeCorrection;
varying vec3 vEllipsoidRadiiSquared;

void getCameraRay(out vec3 origin, out vec3 direction) {
  bool isPerspective = inverseProjectionMatrix[2][3] != 0.0; // 4th entry in the 3rd column

  if (isPerspective) {
    // Calculate the camera ray for a perspective camera.
    vec4 viewPosition = inverseProjectionMatrix * vec4(position, 1.0);
    vec4 worldDirection = inverseViewMatrix * vec4(viewPosition.xyz, 0.0);
    origin = cameraPosition;
    direction = worldDirection.xyz;
  } else {
    // Unprojected points to calculate direction.
    vec4 nearPoint = inverseProjectionMatrix * vec4(position.xy, -1.0, 1.0);
    vec4 farPoint = inverseProjectionMatrix * vec4(position.xy, -0.9, 1.0);
    nearPoint /= nearPoint.w;
    farPoint /= farPoint.w;

    // Calculate world values.
    vec4 worldDirection = inverseViewMatrix * vec4(farPoint.xyz - nearPoint.xyz, 0.0);
    vec4 worldOrigin = inverseViewMatrix * nearPoint;

    // Outputs
    direction = worldDirection.xyz;
    origin = worldOrigin.xyz;
  }
}

void mainSupport() {
  vec3 direction, origin;
  getCameraRay(origin, direction);

  vec3 cameraPositionECEF = (worldToECEFMatrix * vec4(origin, 1.0)).xyz;
  vCameraPosition = (cameraPositionECEF + altitudeCorrection) * METER_TO_LENGTH_UNIT;
  vRayDirection = (worldToECEFMatrix * vec4(direction, 0.0)).xyz;

  vGeometryAltitudeCorrection = altitudeCorrection * METER_TO_LENGTH_UNIT;
  // Gradually turn off the altitude correction on geometries as the geometric
  // error correction takes effect, because that on the ideal sphere will be
  // over corrected.
  // See: https://github.com/takram-design-engineering/three-geospatial/pull/23#issuecomment-2542914656
  #ifdef CORRECT_GEOMETRIC_ERROR
  vGeometryAltitudeCorrection *= 1.0 - geometricErrorCorrectionAmount;
  #endif // CORRECT_GEOMETRIC_ERROR

  vec3 radii = ellipsoidRadii * METER_TO_LENGTH_UNIT;
  vEllipsoidRadiiSquared = radii * radii;
}
`,YP=`vec3 getLunarRadiance(const float moonAngularRadius) {
  // Not a physical number but the order of 10^-6 relative to the sun may fit.
  vec3 radiance =
    ATMOSPHERE.solar_irradiance *
    0.000002 /
    (PI * moonAngularRadius * moonAngularRadius) *
    SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
  return radiance;
}

float intersectSphere(const vec3 ray, const vec3 point, const float radius) {
  vec3 P = -point;
  float PoR = dot(P, ray);
  float D = dot(P, P) - radius * radius;
  return -PoR - sqrt(PoR * PoR - D);
}

float orenNayarDiffuse(const vec3 L, const vec3 V, const vec3 N) {
  float NoL = dot(N, L);
  float NoV = dot(N, V);
  float s = dot(L, V) - NoL * NoV;
  float t = mix(1.0, max(NoL, NoV), step(0.0, s));
  return max(0.0, NoL) * (0.62406015 + 0.41284404 * s / t);
}

vec3 getSkyRadiance(
  const vec3 cameraPosition,
  const vec3 rayDirection,
  const float shadowLength,
  const vec3 sunDirection,
  const vec3 moonDirection,
  const float moonAngularRadius,
  const float lunarRadianceScale
) {
  vec3 transmittance;
  vec3 radiance = GetSkyRadiance(
    cameraPosition,
    rayDirection,
    shadowLength,
    sunDirection,
    transmittance
  );

  // Rendering celestial objects without perspective doesn't make sense.
  #ifdef PERSPECTIVE_CAMERA

  #if defined(SUN) || defined(MOON)
  vec3 ddx = dFdx(rayDirection);
  vec3 ddy = dFdy(rayDirection);
  float fragmentAngle = length(ddx + ddy) / length(rayDirection);
  #endif // defined(SUN) || defined(MOON)

  #ifdef SUN
  float viewDotSun = dot(rayDirection, sunDirection);
  if (viewDotSun > cos(ATMOSPHERE.sun_angular_radius)) {
    float angle = acos(clamp(viewDotSun, -1.0, 1.0));
    float antialias = smoothstep(
      ATMOSPHERE.sun_angular_radius,
      ATMOSPHERE.sun_angular_radius - fragmentAngle,
      angle
    );
    radiance += transmittance * GetSolarRadiance() * antialias;
  }
  #endif // SUN

  #ifdef MOON
  float intersection = intersectSphere(rayDirection, moonDirection, moonAngularRadius);
  if (intersection > 0.0) {
    vec3 normal = normalize(moonDirection - rayDirection * intersection);
    float diffuse = orenNayarDiffuse(-sunDirection, rayDirection, normal);
    float viewDotMoon = dot(rayDirection, moonDirection);
    float angle = acos(clamp(viewDotMoon, -1.0, 1.0));
    float antialias = smoothstep(moonAngularRadius, moonAngularRadius - fragmentAngle, angle);
    radiance +=
      transmittance *
      getLunarRadiance(moonAngularRadius) *
      lunarRadianceScale *
      diffuse *
      antialias;
  }
  #endif // MOON

  #endif // PERSPECTIVE_CAMERA

  return radiance;
}
`;var Mne=Object.defineProperty,sa=(n,e,t,i)=>{for(var r=void 0,a=n.length-1,s;a>=0;a--)(s=n[a])&&(r=s(e,t,r)||r);return r&&Mne(e,t,r),r};const bne=new L,Ane=new L,wne=new E0,qP={blendFunction:ln.NORMAL,octEncodedNormal:!1,reconstructNormal:!1,ellipsoid:ih.WGS84,correctAltitude:!0,correctGeometricError:!0,sunLight:!1,skyLight:!1,transmittance:!0,inscatter:!0,albedoScale:1,sky:!1,sun:!0,moon:!0,moonAngularRadius:.0045,lunarRadianceScale:1,ground:!0};let Hr=class extends T0{constructor(e=new wc,t,i=$0.DEFAULT){const{blendFunction:r,normalBuffer:a=null,octEncodedNormal:s,reconstructNormal:o,irradianceTexture:l=null,scatteringTexture:h=null,transmittanceTexture:f=null,singleMieScatteringTexture:d=null,higherOrderScatteringTexture:p=null,ellipsoid:g,correctAltitude:_,correctGeometricError:T,sunDirection:y,sunIrradiance:v,sunLight:S,skyIrradiance:E,skyLight:b,transmittance:N,inscatter:R,irradianceScale:I,albedoScale:U,sky:O,sun:w,moon:B,moonDirection:j,moonAngularRadius:ee,lunarRadianceScale:se,ground:ae}={...qP,...t};super("AerialPerspectiveEffect",J0(Nr(Tne,{core:{depth:VP,packing:pne,math:wA,transform:mne,raySphereIntersection:Sy,cascadedShadowMaps:GP,interleavedGradientNoise:kP,vogelDisk:XP},bruneton:{common:Qs,definitions:Js,runtime:Ay},sky:YP})),{blendFunction:r,vertexShader:Ene,attributes:tl.DEPTH,uniforms:new Map(Object.entries({normalBuffer:new J(a),projectionMatrix:new J(new Ve),viewMatrix:new J(new Ve),inverseProjectionMatrix:new J(new Ve),inverseViewMatrix:new J(new Ve),cameraPosition:new J(new L),bottomRadius:new J(i.bottomRadius),ellipsoidRadii:new J(new L),worldToECEFMatrix:new J(new Ve),altitudeCorrection:new J(new L),geometricErrorCorrectionAmount:new J(0),sunDirection:new J((y==null?void 0:y.clone())??new L),albedoScale:new J(I??U),moonDirection:new J((j==null?void 0:j.clone())??new L),moonAngularRadius:new J(ee),lunarRadianceScale:new J(se),overlayBuffer:new J(null),shadowBuffer:new J(null),shadowMapSize:new J(new de),shadowIntervals:new J([]),shadowMatrices:new J([]),inverseShadowMatrices:new J([]),shadowFar:new J(0),shadowTopHeight:new J(0),shadowRadius:new J(3),stbnTexture:new J(null),frame:new J(0),shadowLengthBuffer:new J(null),lightingMaskBuffer:new J(null),ATMOSPHERE:i.toUniform(),SUN_SPECTRAL_RADIANCE_TO_LUMINANCE:new J(i.sunRadianceToRelativeLuminance),SKY_SPECTRAL_RADIANCE_TO_LUMINANCE:new J(i.skyRadianceToRelativeLuminance),irradiance_texture:new J(l),scattering_texture:new J(h),transmittance_texture:new J(f),single_mie_scattering_texture:new J(null),higher_order_scattering_texture:new J(null)})),defines:new Map([["TRANSMITTANCE_TEXTURE_WIDTH",rp.toFixed(0)],["TRANSMITTANCE_TEXTURE_HEIGHT",ap.toFixed(0)],["SCATTERING_TEXTURE_R_SIZE",Ty.toFixed(0)],["SCATTERING_TEXTURE_MU_SIZE",Ey.toFixed(0)],["SCATTERING_TEXTURE_MU_S_SIZE",My.toFixed(0)],["SCATTERING_TEXTURE_NU_SIZE",by.toFixed(0)],["IRRADIANCE_TEXTURE_WIDTH",np.toFixed(0)],["IRRADIANCE_TEXTURE_HEIGHT",ip.toFixed(0)],["METER_TO_LENGTH_UNIT",u1.toFixed(7)]])}),this.camera=e,this.atmosphere=i,this.overlay=null,this.shadow=null,this.shadowLength=null,this.lightingMask=null,this.combinedScatteringTextures=!1,this.hasHigherOrderScatteringTexture=!1,this.shadowSampleCount=8,this.octEncodedNormal=s,this.reconstructNormal=o,this.singleMieScatteringTexture=d,this.higherOrderScatteringTexture=p,this.ellipsoid=g,this.correctAltitude=_,this.correctGeometricError=T,this.sunLight=v??S,this.skyLight=E??b,this.transmittance=N,this.inscatter=R,this.sky=O,this.sun=w,this.moon=B,this.ground=ae}get mainCamera(){return this.camera}set mainCamera(e){this.camera=e}copyCameraSettings(e){const{projectionMatrix:t,matrixWorldInverse:i,projectionMatrixInverse:r,matrixWorld:a}=e,s=this.uniforms;s.get("projectionMatrix").value.copy(t),s.get("viewMatrix").value.copy(i),s.get("inverseProjectionMatrix").value.copy(r),s.get("inverseViewMatrix").value.copy(a);const o=e.getWorldPosition(s.get("cameraPosition").value),l=s.get("worldToECEFMatrix").value,h=bne.copy(o).applyMatrix4(l);try{const d=wne.setFromECEF(h).height,p=Ane.set(0,this.ellipsoid.maximumRadius,-Math.max(0,d)).applyMatrix4(t);s.get("geometricErrorCorrectionAmount").value=Yte(Xte(p.y,41.5,13.8,0,1))}catch{return}const f=s.get("altitudeCorrection");this.correctAltitude?RA(h,this.atmosphere.bottomRadius,this.ellipsoid,f.value):f.value.setScalar(0)}updateOverlay(){let e=!1;const{uniforms:t,defines:i,overlay:r}=this,a=i.has("HAS_OVERLAY"),s=r!=null;return s!==a&&(s?i.set("HAS_OVERLAY","1"):(i.delete("HAS_OVERLAY"),t.get("overlayBuffer").value=null),e=!0),s&&(t.get("overlayBuffer").value=r.map),e}updateShadow(){let e=!1;const{uniforms:t,defines:i,shadow:r}=this,a=i.has("HAS_SHADOW"),s=r!=null;if(s!==a&&(s?i.set("HAS_SHADOW","1"):(i.delete("HAS_SHADOW"),t.get("shadowBuffer").value=null),e=!0),s){const o=i.get("SHADOW_CASCADE_COUNT"),l=`${r.cascadeCount}`;o!==l&&(i.set("SHADOW_CASCADE_COUNT",r.cascadeCount.toFixed(0)),e=!0),t.get("shadowBuffer").value=r.map,t.get("shadowMapSize").value=r.mapSize,t.get("shadowIntervals").value=r.intervals,t.get("shadowMatrices").value=r.matrices,t.get("inverseShadowMatrices").value=r.inverseMatrices,t.get("shadowFar").value=r.far,t.get("shadowTopHeight").value=r.topHeight}return e}updateShadowLength(){let e=!1;const{uniforms:t,defines:i,shadowLength:r}=this,a=i.has("HAS_SHADOW_LENGTH"),s=r!=null;return s!==a&&(s?i.set("HAS_SHADOW_LENGTH","1"):(i.delete("HAS_SHADOW_LENGTH"),t.get("shadowLengthBuffer").value=null),e=!0),s&&(t.get("shadowLengthBuffer").value=r.map),e}updateLightingMask(){let e=!1;const{uniforms:t,defines:i,lightingMask:r}=this,a=i.has("HAS_LIGHTING_MASK"),s=r!=null;if(s!==a&&(s?i.set("HAS_LIGHTING_MASK","1"):(i.delete("HAS_LIGHTING_MASK"),t.get("lightingMaskBuffer").value=null),e=!0),s){t.get("lightingMaskBuffer").value=r.map;const o=i.get("LIGHTING_MASK_CHANNEL"),l=r.channel;l!==o&&(/^[rgba]$/.test(l)?(i.set("LIGHTING_MASK_CHANNEL",l),e=!0):console.error(`Expression validation failed: ${l}`))}return e}update(e,t,i){this.copyCameraSettings(this.camera);let r=!1;r||(r=this.updateOverlay()),r||(r=this.updateShadow()),r||(r=this.updateShadowLength()),r||(r=this.updateLightingMask()),r&&this.setChanged(),++this.uniforms.get("frame").value}get normalBuffer(){return this.uniforms.get("normalBuffer").value}set normalBuffer(e){this.uniforms.get("normalBuffer").value=e}get irradianceTexture(){return this.uniforms.get("irradiance_texture").value}set irradianceTexture(e){this.uniforms.get("irradiance_texture").value=e}get scatteringTexture(){return this.uniforms.get("scattering_texture").value}set scatteringTexture(e){this.uniforms.get("scattering_texture").value=e}get transmittanceTexture(){return this.uniforms.get("transmittance_texture").value}set transmittanceTexture(e){this.uniforms.get("transmittance_texture").value=e}get singleMieScatteringTexture(){return this.uniforms.get("single_mie_scattering_texture").value}set singleMieScatteringTexture(e){this.uniforms.get("single_mie_scattering_texture").value=e,this.combinedScatteringTextures=e==null}get higherOrderScatteringTexture(){return this.uniforms.get("higher_order_scattering_texture").value}set higherOrderScatteringTexture(e){this.uniforms.get("higher_order_scattering_texture").value=e,this.hasHigherOrderScatteringTexture=e!=null}get ellipsoid(){return this._ellipsoid}set ellipsoid(e){this._ellipsoid=e,this.uniforms.get("ellipsoidRadii").value.copy(e.radii)}get worldToECEFMatrix(){return this.uniforms.get("worldToECEFMatrix").value}get sunDirection(){return this.uniforms.get("sunDirection").value}get sunIrradiance(){return this.sunLight}set sunIrradiance(e){this.sunLight=e}get skyIrradiance(){return this.skyLight}set skyIrradiance(e){this.skyLight=e}get irradianceScale(){return this.albedoScale}set irradianceScale(e){this.albedoScale=e}get albedoScale(){return this.uniforms.get("albedoScale").value}set albedoScale(e){this.uniforms.get("albedoScale").value=e}get moonDirection(){return this.uniforms.get("moonDirection").value}get moonAngularRadius(){return this.uniforms.get("moonAngularRadius").value}set moonAngularRadius(e){this.uniforms.get("moonAngularRadius").value=e}get lunarRadianceScale(){return this.uniforms.get("lunarRadianceScale").value}set lunarRadianceScale(e){this.uniforms.get("lunarRadianceScale").value=e}get stbnTexture(){return this.uniforms.get("stbnTexture").value}set stbnTexture(e){this.uniforms.get("stbnTexture").value=e}get shadowRadius(){return this.uniforms.get("shadowRadius").value}set shadowRadius(e){this.uniforms.get("shadowRadius").value=e}};sa([pn("OCT_ENCODED_NORMAL")],Hr.prototype,"octEncodedNormal");sa([pn("RECONSTRUCT_NORMAL")],Hr.prototype,"reconstructNormal");sa([pn("COMBINED_SCATTERING_TEXTURES")],Hr.prototype,"combinedScatteringTextures");sa([pn("HAS_HIGHER_ORDER_SCATTERING_TEXTURE")],Hr.prototype,"hasHigherOrderScatteringTexture");sa([pn("CORRECT_GEOMETRIC_ERROR")],Hr.prototype,"correctGeometricError");sa([pn("SUN_LIGHT")],Hr.prototype,"sunLight");sa([pn("SKY_LIGHT")],Hr.prototype,"skyLight");sa([pn("TRANSMITTANCE")],Hr.prototype,"transmittance");sa([pn("INSCATTER")],Hr.prototype,"inscatter");sa([pn("SKY")],Hr.prototype,"sky");sa([pn("SUN")],Hr.prototype,"sun");sa([pn("MOON")],Hr.prototype,"moon");sa([pn("GROUND")],Hr.prototype,"ground");sa([_h("SHADOW_SAMPLE_COUNT",{min:1,max:16})],Hr.prototype,"shadowSampleCount");var Rne=Object.defineProperty,jP=(n,e,t,i)=>{for(var r=void 0,a=n.length-1,s;a>=0;a--)(s=n[a])&&(r=s(e,t,r)||r);return r&&Rne(e,t,r),r};const Cne=new L;function Dne(n,e){let t="",i="";for(let r=1;r<e;++r)t+=`layout(location = ${r}) out float renderTarget${r};
`,i+=`renderTarget${r} = 0.0;
`;return n.replace("#include <mrt_layout>",t).replace("#include <mrt_output>",i)}const CA={ellipsoid:ih.WGS84,correctAltitude:!0,renderTargetCount:1};class eg extends ph{constructor(e,t=$0.DEFAULT){const{irradianceTexture:i=null,scatteringTexture:r=null,transmittanceTexture:a=null,singleMieScatteringTexture:s=null,higherOrderScatteringTexture:o=null,ellipsoid:l,correctAltitude:h,sunDirection:f,sunAngularRadius:d,renderTargetCount:p,...g}={...CA,...e};super({toneMapped:!1,depthWrite:!1,depthTest:!1,...g,uniforms:{cameraPosition:new J(new L),worldToECEFMatrix:new J(new Ve),altitudeCorrection:new J(new L),sunDirection:new J((f==null?void 0:f.clone())??new L),ATMOSPHERE:t.toUniform(),SUN_SPECTRAL_RADIANCE_TO_LUMINANCE:new J(t.sunRadianceToRelativeLuminance),SKY_SPECTRAL_RADIANCE_TO_LUMINANCE:new J(t.skyRadianceToRelativeLuminance),irradiance_texture:new J(i),scattering_texture:new J(r),transmittance_texture:new J(a),single_mie_scattering_texture:new J(null),higher_order_scattering_texture:new J(null),...g.uniforms},defines:{PI:`${Math.PI}`,TRANSMITTANCE_TEXTURE_WIDTH:rp.toFixed(0),TRANSMITTANCE_TEXTURE_HEIGHT:ap.toFixed(0),SCATTERING_TEXTURE_R_SIZE:Ty.toFixed(0),SCATTERING_TEXTURE_MU_SIZE:Ey.toFixed(0),SCATTERING_TEXTURE_MU_S_SIZE:My.toFixed(0),SCATTERING_TEXTURE_NU_SIZE:by.toFixed(0),IRRADIANCE_TEXTURE_WIDTH:np.toFixed(0),IRRADIANCE_TEXTURE_HEIGHT:ip.toFixed(0),METER_TO_LENGTH_UNIT:u1.toFixed(7),...g.defines}}),this.atmosphere=t,this.combinedScatteringTextures=!1,this.hasHigherOrderScatteringTexture=!1,this.singleMieScatteringTexture=s,this.higherOrderScatteringTexture=o,this.ellipsoid=l,this.correctAltitude=h,d!=null&&(this.sunAngularRadius=d),this.renderTargetCount=p}copyCameraSettings(e){const t=this.uniforms,i=e.getWorldPosition(t.cameraPosition.value),r=Cne.copy(i).applyMatrix4(t.worldToECEFMatrix.value),a=t.altitudeCorrection.value;this.correctAltitude?RA(r,this.atmosphere.bottomRadius,this.ellipsoid,a):a.setScalar(0)}onBeforeCompile(e,t){e.fragmentShader=Dne(e.fragmentShader,this.renderTargetCount)}onBeforeRender(e,t,i,r,a,s){this.copyCameraSettings(i)}get irradianceTexture(){return this.uniforms.irradiance_texture.value}set irradianceTexture(e){this.uniforms.irradiance_texture.value=e}get scatteringTexture(){return this.uniforms.scattering_texture.value}set scatteringTexture(e){this.uniforms.scattering_texture.value=e}get transmittanceTexture(){return this.uniforms.transmittance_texture.value}set transmittanceTexture(e){this.uniforms.transmittance_texture.value=e}get singleMieScatteringTexture(){return this.uniforms.single_mie_scattering_texture.value}set singleMieScatteringTexture(e){this.uniforms.single_mie_scattering_texture.value=e,this.combinedScatteringTextures=e==null}get higherOrderScatteringTexture(){return this.uniforms.higher_order_scattering_texture.value}set higherOrderScatteringTexture(e){this.uniforms.higher_order_scattering_texture.value=e,this.hasHigherOrderScatteringTexture=e!=null}get worldToECEFMatrix(){return this.uniforms.worldToECEFMatrix.value}get sunDirection(){return this.uniforms.sunDirection.value}get sunAngularRadius(){return this.uniforms.ATMOSPHERE.value.sun_angular_radius}set sunAngularRadius(e){this.uniforms.ATMOSPHERE.value.sun_angular_radius=e}get renderTargetCount(){return this._renderTargetCount}set renderTargetCount(e){e!==this.renderTargetCount&&(this._renderTargetCount=e,this.needsUpdate=!0)}}jP([pn("COMBINED_SCATTERING_TEXTURES")],eg.prototype,"combinedScatteringTextures");jP([pn("HAS_HIGHER_ORDER_SCATTERING_TEXTURE")],eg.prototype,"hasHigherOrderScatteringTexture");/**
    @preserve

    Astronomy library for JavaScript (browser and Node.js).
    https://github.com/cosinekitty/astronomy

    MIT License

    Copyright (c) 2019-2023 Don Cross <cosinekitty@gmail.com>

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
*//**
 * @fileoverview Astronomy calculation library for browser scripting and Node.js.
 * @author Don Cross <cosinekitty@gmail.com>
 * @license MIT
 */const Nne=173.1446326846693,One=14959787069098932e-8,ah=.017453292519943295,Lne=365.24217,LO=new Date("2000-01-01T12:00:00Z"),Fo=2*Math.PI,Gl=3600*(180/Math.PI),Kf=484813681109536e-20,Ine=10800*60,Une=2*Ine,Pne=6378.1366,zne=Pne/One,Bne=81.30056,DA=.0002959122082855911,tM=2825345909524226e-22,nM=8459715185680659e-23,iM=1292024916781969e-23,rM=1524358900784276e-23;function C_(n){if(!Number.isFinite(n))throw console.trace(),`Value is not a finite number: ${n}`;return n}function bf(n){return n-Math.floor(n)}var Bn;(function(n){n.Sun="Sun",n.Moon="Moon",n.Mercury="Mercury",n.Venus="Venus",n.Earth="Earth",n.Mars="Mars",n.Jupiter="Jupiter",n.Saturn="Saturn",n.Uranus="Uranus",n.Neptune="Neptune",n.Pluto="Pluto",n.SSB="SSB",n.EMB="EMB",n.Star1="Star1",n.Star2="Star2",n.Star3="Star3",n.Star4="Star4",n.Star5="Star5",n.Star6="Star6",n.Star7="Star7",n.Star8="Star8"})(Bn||(Bn={}));const Hne=[Bn.Star1,Bn.Star2,Bn.Star3,Bn.Star4,Bn.Star5,Bn.Star6,Bn.Star7,Bn.Star8],Fne=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function Gne(n){const e=Hne.indexOf(n);return e>=0?Fne[e]:null}function ZP(n){const e=Gne(n);return e&&e.dist>0?e:null}var cl;(function(n){n[n.From2000=0]="From2000",n[n.Into2000=1]="Into2000"})(cl||(cl={}));const Qf={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function Vne(n){var e,t,i,r,a,s,o;const l=2e3+(n-14)/Lne;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/100,t=e*e,i=e*t,r=t*t,a=t*i,s=i*i,10583.6-1014.41*e+33.78311*t-5.952053*i-.1798452*r+.022174192*a+.0090316521*s):l<1600?(e=(l-1e3)/100,t=e*e,i=e*t,r=t*t,a=t*i,s=i*i,1574.2-556.01*e+71.23472*t+.319781*i-.8503463*r-.005050998*a+.0083572073*s):l<1700?(e=l-1600,t=e*e,i=e*t,120-.9808*e-.01532*t+i/7129):l<1800?(e=l-1700,t=e*e,i=e*t,r=t*t,8.83+.1603*e-.0059285*t+13336e-8*i-r/1174e3):l<1860?(e=l-1800,t=e*e,i=e*t,r=t*t,a=t*i,s=i*i,o=i*r,13.72-.332447*e+.0068612*t+.0041116*i-37436e-8*r+121272e-10*a-1699e-10*s+875e-12*o):l<1900?(e=l-1860,t=e*e,i=e*t,r=t*t,a=t*i,7.62+.5737*e-.251754*t+.01680668*i-.0004473624*r+a/233174):l<1920?(e=l-1900,t=e*e,i=e*t,r=t*t,-2.79+1.494119*e-.0598939*t+.0061966*i-197e-6*r):l<1941?(e=l-1920,t=e*e,i=e*t,21.2+.84493*e-.0761*t+.0020936*i):l<1961?(e=l-1950,t=e*e,i=e*t,29.07+.407*e-t/233+i/2547):l<1986?(e=l-1975,t=e*e,i=e*t,45.45+1.067*e-t/260-i/718):l<2005?(e=l-2e3,t=e*e,i=e*t,r=t*t,a=t*i,63.86+.3345*e-.060374*t+.0017275*i+651814e-9*r+2373599e-11*a):l<2050?(e=l-2e3,62.92+.32217*e+.005589*e*e):l<2150?(e=(l-1820)/100,-20+32*e*e-.5628*(2150-l)):(e=(l-1820)/100,-20+32*e*e)}let kne=Vne;function IO(n){return n+kne(n)/86400}class dc{constructor(e){if(e instanceof dc){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-LO.getTime())/t,this.tt=IO(this.ut);return}if(Number.isFinite(e)){this.date=new Date(LO.getTime()+e*t),this.ut=e,this.tt=IO(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new dc(e);for(;;){const i=e-t.tt;if(Math.abs(i)<1e-12)return t;t=t.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(e){return new dc(this.ut+e)}}function xh(n){return n instanceof dc?n:new dc(n)}function Wne(n){function e(p){return p%Une*Kf}const t=n.tt/36525,i=e(128710479305e-5+t*1295965810481e-4),r=e(335779.526232+t*17395272628478e-4),a=e(107226070369e-5+t*1602961601209e-3),s=e(450160.398036-t*69628905431e-4);let o=Math.sin(s),l=Math.cos(s),h=(-172064161-174666*t)*o+33386*l,f=(92052331+9086*t)*l+15377*o,d=2*(r-a+s);return o=Math.sin(d),l=Math.cos(d),h+=(-13170906-1675*t)*o-13696*l,f+=(5730336-3015*t)*l-4587*o,d=2*(r+s),o=Math.sin(d),l=Math.cos(d),h+=(-2276413-234*t)*o+2796*l,f+=(978459-485*t)*l+1374*o,d=2*s,o=Math.sin(d),l=Math.cos(d),h+=(2074554+207*t)*o-698*l,f+=(-897492+470*t)*l-291*o,o=Math.sin(i),l=Math.cos(i),h+=(1475877-3633*t)*o+11817*l,f+=(73871-184*t)*l-1924*o,{dpsi:-135e-6+h*1e-7,deps:388e-6+f*1e-7}}function KP(n){var e=n.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var n_;function QP(n){if(!n_||Math.abs(n_.tt-n.tt)>1e-6){const e=Wne(n),t=KP(n),i=t+e.deps/3600;n_={tt:n.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*ah)/15,mobl:t,tobl:i}}return n_}function Xne(n,e){const t=n*ah,i=Math.cos(t),r=Math.sin(t);return[e[0],e[1]*i-e[2]*r,e[1]*r+e[2]*i]}function Yne(n,e){return Xne(KP(n),e)}function qne(n){const e=n.tt/36525;function t(ot,Ke){const Te=[];let G;for(G=0;G<=Ke-ot;++G)Te.push(0);return{min:ot,array:Te}}function i(ot,Ke,Te,G){const be=[];for(let Ne=0;Ne<=Ke-ot;++Ne)be.push(t(Te,G));return{min:ot,array:be}}function r(ot,Ke,Te){const G=ot.array[Ke-ot.min];return G.array[Te-G.min]}function a(ot,Ke,Te,G){const be=ot.array[Ke-ot.min];be.array[Te-be.min]=G}let s,o,l,h,f,d,p,g,_,T,y,v,S,E,b,N,R,I,U,O,w,B,j,ee=i(-6,6,1,4),se=i(-6,6,1,4);function ae(ot,Ke){return r(ee,ot,Ke)}function W(ot,Ke){return r(se,ot,Ke)}function te(ot,Ke,Te){return a(ee,ot,Ke,Te)}function K(ot,Ke,Te){return a(se,ot,Ke,Te)}function oe(ot,Ke,Te,G,be){be(ot*Te-Ke*G,Ke*Te+ot*G)}function ie(ot){return Math.sin(Fo*ot)}p=e*e,_=0,j=0,y=0,v=3422.7;var Ce=ie(.19833+.05611*e),Xe=ie(.27869+.04508*e),nt=ie(.16827-.36903*e),tt=ie(.34734-5.37261*e),gt=ie(.10498-5.37899*e),ge=ie(.42681-.41855*e),Ae=ie(.14943-5.37511*e);for(I=.84*Ce+.31*Xe+14.27*nt+7.26*tt+.28*gt+.24*ge,U=2.94*Ce+.31*Xe+14.27*nt+9.34*tt+1.12*gt+.83*ge,O=-6.4*Ce-1.89*ge,w=.21*Ce+.31*Xe+14.27*nt-88.7*tt-15.3*gt+.24*ge-1.86*Ae,B=I-O,g=-3332e-9*ie(.59734-5.37261*e)-539e-9*ie(.35498-5.37899*e)-64e-9*ie(.39943-5.37511*e),S=Fo*bf(.60643382+1336.85522467*e-313e-8*p)+I/Gl,E=Fo*bf(.37489701+1325.55240982*e+2565e-8*p)+U/Gl,b=Fo*bf(.99312619+99.99735956*e-44e-8*p)+O/Gl,N=Fo*bf(.25909118+1342.2278298*e-892e-8*p)+w/Gl,R=Fo*bf(.82736186+1236.85308708*e-397e-8*p)+B/Gl,f=1;f<=4;++f){switch(f){case 1:l=E,o=4,h=1.000002208;break;case 2:l=b,o=3,h=.997504612-.002495388*e;break;case 3:l=N,o=4,h=1.000002708+139.978*g;break;case 4:l=R,o=6,h=1;break;default:throw`Internal error: I = ${f}`}for(te(0,f,1),te(1,f,Math.cos(l)*h),K(0,f,0),K(1,f,Math.sin(l)*h),d=2;d<=o;++d)oe(ae(d-1,f),W(d-1,f),ae(1,f),W(1,f),(ot,Ke)=>(te(d,f,ot),K(d,f,Ke)));for(d=1;d<=o;++d)te(-d,f,ae(d,f)),K(-d,f,-W(d,f))}function Ze(ot,Ke,Te,G){for(var be={x:1,y:0},Ne=[0,ot,Ke,Te,G],Fe=1;Fe<=4;++Fe)Ne[Fe]!==0&&oe(be.x,be.y,ae(Ne[Fe],Fe),W(Ne[Fe],Fe),(Be,$e)=>(be.x=Be,be.y=$e));return be}function ue(ot,Ke,Te,G,be,Ne,Fe,Be){var $e=Ze(be,Ne,Fe,Be);_+=ot*$e.y,j+=Ke*$e.y,y+=Te*$e.x,v+=G*$e.x}ue(13.902,14.06,-.001,.2607,0,0,0,4),ue(.403,-4.01,.394,.0023,0,0,0,3),ue(2369.912,2373.36,.601,28.2333,0,0,0,2),ue(-125.154,-112.79,-.725,-.9781,0,0,0,1),ue(1.979,6.98,-.445,.0433,1,0,0,4),ue(191.953,192.72,.029,3.0861,1,0,0,2),ue(-8.466,-13.51,.455,-.1093,1,0,0,1),ue(22639.5,22609.07,.079,186.5398,1,0,0,0),ue(18.609,3.59,-.094,.0118,1,0,0,-1),ue(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),ue(3.215,5.44,.192,-.0386,1,0,0,-3),ue(-38.428,-38.64,.001,.6008,1,0,0,-4),ue(-.393,-1.43,-.092,.0086,1,0,0,-6),ue(-.289,-1.59,.123,-.0053,0,1,0,4),ue(-24.42,-25.1,.04,-.3,0,1,0,2),ue(18.023,17.93,.007,.1494,0,1,0,1),ue(-668.146,-126.98,-1.302,-.3997,0,1,0,0),ue(.56,.32,-.001,-.0037,0,1,0,-1),ue(-165.145,-165.06,.054,1.9178,0,1,0,-2),ue(-1.877,-6.46,-.416,.0339,0,1,0,-4),ue(.213,1.02,-.074,.0054,2,0,0,4),ue(14.387,14.78,-.017,.2833,2,0,0,2),ue(-.586,-1.2,.054,-.01,2,0,0,1),ue(769.016,767.96,.107,10.1657,2,0,0,0),ue(1.75,2.01,-.018,.0155,2,0,0,-1),ue(-211.656,-152.53,5.679,-.3039,2,0,0,-2),ue(1.225,.91,-.03,-.0088,2,0,0,-3),ue(-30.773,-34.07,-.308,.3722,2,0,0,-4),ue(-.57,-1.4,-.074,.0109,2,0,0,-6),ue(-2.921,-11.75,.787,-.0484,1,1,0,2),ue(1.267,1.52,-.022,.0164,1,1,0,1),ue(-109.673,-115.18,.461,-.949,1,1,0,0),ue(-205.962,-182.36,2.056,1.4437,1,1,0,-2),ue(.233,.36,.012,-.0025,1,1,0,-3),ue(-4.391,-9.66,-.471,.0673,1,1,0,-4),ue(.283,1.53,-.111,.006,1,-1,0,4),ue(14.577,31.7,-1.54,.2302,1,-1,0,2),ue(147.687,138.76,.679,1.1528,1,-1,0,0),ue(-1.089,.55,.021,0,1,-1,0,-1),ue(28.475,23.59,-.443,-.2257,1,-1,0,-2),ue(-.276,-.38,-.006,-.0036,1,-1,0,-3),ue(.636,2.27,.146,-.0102,1,-1,0,-4),ue(-.189,-1.68,.131,-.0028,0,2,0,2),ue(-7.486,-.66,-.037,-.0086,0,2,0,0),ue(-8.096,-16.35,-.74,.0918,0,2,0,-2),ue(-5.741,-.04,0,-9e-4,0,0,2,2),ue(.255,0,0,0,0,0,2,1),ue(-411.608,-.2,0,-.0124,0,0,2,0),ue(.584,.84,0,.0071,0,0,2,-1),ue(-55.173,-52.14,0,-.1052,0,0,2,-2),ue(.254,.25,0,-.0017,0,0,2,-3),ue(.025,-1.67,0,.0031,0,0,2,-4),ue(1.06,2.96,-.166,.0243,3,0,0,2),ue(36.124,50.64,-1.3,.6215,3,0,0,0),ue(-13.193,-16.4,.258,-.1187,3,0,0,-2),ue(-1.187,-.74,.042,.0074,3,0,0,-4),ue(-.293,-.31,-.002,.0046,3,0,0,-6),ue(-.29,-1.45,.116,-.0051,2,1,0,2),ue(-7.649,-10.56,.259,-.1038,2,1,0,0),ue(-8.627,-7.59,.078,-.0192,2,1,0,-2),ue(-2.74,-2.54,.022,.0324,2,1,0,-4),ue(1.181,3.32,-.212,.0213,2,-1,0,2),ue(9.703,11.67,-.151,.1268,2,-1,0,0),ue(-.352,-.37,.001,-.0028,2,-1,0,-1),ue(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),ue(.36,.2,-.012,-.0043,2,-1,0,-4),ue(-1.167,-1.25,.008,-.0106,1,2,0,0),ue(-7.412,-6.12,.117,.0484,1,2,0,-2),ue(-.311,-.65,-.032,.0044,1,2,0,-4),ue(.757,1.82,-.105,.0112,1,-2,0,2),ue(2.58,2.32,.027,.0196,1,-2,0,0),ue(2.533,2.4,-.014,-.0212,1,-2,0,-2),ue(-.344,-.57,-.025,.0036,0,3,0,-2),ue(-.992,-.02,0,0,1,0,2,2),ue(-45.099,-.02,0,-.001,1,0,2,0),ue(-.179,-9.52,0,-.0833,1,0,2,-2),ue(-.301,-.33,0,.0014,1,0,2,-4),ue(-6.382,-3.37,0,-.0481,1,0,-2,2),ue(39.528,85.13,0,-.7136,1,0,-2,0),ue(9.366,.71,0,-.0112,1,0,-2,-2),ue(.202,.02,0,0,1,0,-2,-4),ue(.415,.1,0,.0013,0,1,2,0),ue(-2.152,-2.26,0,-.0066,0,1,2,-2),ue(-1.44,-1.3,0,.0014,0,1,-2,2),ue(.384,-.04,0,0,0,1,-2,-2),ue(1.938,3.6,-.145,.0401,4,0,0,0),ue(-.952,-1.58,.052,-.013,4,0,0,-2),ue(-.551,-.94,.032,-.0097,3,1,0,0),ue(-.482,-.57,.005,-.0045,3,1,0,-2),ue(.681,.96,-.026,.0115,3,-1,0,0),ue(-.297,-.27,.002,-9e-4,2,2,0,-2),ue(.254,.21,-.003,0,2,-2,0,-2),ue(-.25,-.22,.004,.0014,1,3,0,-2),ue(-3.996,0,0,4e-4,2,0,2,0),ue(.557,-.75,0,-.009,2,0,2,-2),ue(-.459,-.38,0,-.0053,2,0,-2,2),ue(-1.298,.74,0,4e-4,2,0,-2,0),ue(.538,1.14,0,-.0141,2,0,-2,-2),ue(.263,.02,0,0,1,1,2,0),ue(.426,.07,0,-6e-4,1,1,-2,-2),ue(-.304,.03,0,3e-4,1,-1,2,0),ue(-.372,-.19,0,-.0027,1,-1,-2,2),ue(.418,0,0,0,0,0,4,0),ue(-.33,-.04,0,0,3,0,2,0);function it(ot,Ke,Te,G,be){return ot*Ze(Ke,Te,G,be).y}T=0,T+=it(-526.069,0,0,1,-2),T+=it(-3.352,0,0,1,-4),T+=it(44.297,1,0,1,-2),T+=it(-6,1,0,1,-4),T+=it(20.599,-1,0,1,0),T+=it(-30.598,-1,0,1,-2),T+=it(-24.649,-2,0,1,0),T+=it(-2,-2,0,1,-2),T+=it(-22.571,0,1,1,-2),T+=it(10.985,0,-1,1,-2),_+=.82*ie(.7736-62.5512*e)+.31*ie(.0466-125.1025*e)+.35*ie(.5785-25.1042*e)+.66*ie(.4591+1335.8075*e)+.64*ie(.313-91.568*e)+1.14*ie(.148+1331.2898*e)+.21*ie(.5918+1056.5859*e)+.44*ie(.5784+1322.8595*e)+.24*ie(.2275-5.7374*e)+.28*ie(.2965+2.6929*e)+.33*ie(.3132+6.3368*e),s=N+j/Gl;let bt=(1.000002708+139.978*g)*(18518.511+1.189+y)*Math.sin(s)-6.24*Math.sin(3*s)+T;return{geo_eclip_lon:Fo*bf((S+_/Gl)/Fo),geo_eclip_lat:Math.PI/(180*3600)*bt,distance_au:Gl*zne/(.999953253*v)}}function jne(n,e){return[n.rot[0][0]*e[0]+n.rot[1][0]*e[1]+n.rot[2][0]*e[2],n.rot[0][1]*e[0]+n.rot[1][1]*e[1]+n.rot[2][1]*e[2],n.rot[0][2]*e[0]+n.rot[1][2]*e[1]+n.rot[2][2]*e[2]]}function Zne(n,e,t){const i=JP(e,t);return jne(i,n)}function JP(n,e){const t=n.tt/36525;let i=84381.406,r=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,a=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+i,s=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;i*=Kf,r*=Kf,a*=Kf,s*=Kf;const o=Math.sin(i),l=Math.cos(i),h=Math.sin(-r),f=Math.cos(-r),d=Math.sin(-a),p=Math.cos(-a),g=Math.sin(s),_=Math.cos(s),T=_*f-h*g*p,y=_*h*l+g*p*f*l-o*g*d,v=_*h*o+g*p*f*o+l*g*d,S=-g*f-h*_*p,E=-g*h*l+_*p*f*l-o*_*d,b=-g*h*o+_*p*f*o+l*_*d,N=h*d,R=-d*f*l-o*p,I=-d*f*o+p*l;if(e===cl.Into2000)return new Hd([[T,y,v],[S,E,b],[N,R,I]]);if(e===cl.From2000)return new Hd([[T,S,N],[y,E,R],[v,b,I]]);throw"Invalid precess direction"}function Kne(n){const e=.779057273264+.00273781191135448*n.ut,t=n.ut%1;let i=360*((e+t)%1);return i<0&&(i+=360),i}let i_;function Qne(n){if(!i_||i_.tt!==n.tt){const e=n.tt/36525;let t=15*QP(n).ee;const i=Kne(n);let r=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+i)%360/15;r<0&&(r+=24),i_={tt:n.tt,st:r}}return i_.st}function Jne(n){const e=xh(n);return Qne(e)}function $ne(n,e){const t=QP(n),i=t.mobl*ah,r=t.tobl*ah,a=t.dpsi*Kf,s=Math.cos(i),o=Math.sin(i),l=Math.cos(r),h=Math.sin(r),f=Math.cos(a),d=Math.sin(a),p=f,g=-d*s,_=-d*o,T=d*l,y=f*s*l+o*h,v=f*o*l-s*h,S=d*h,E=f*s*h-o*l,b=f*o*h+s*l;if(e===cl.From2000)return new Hd([[p,T,S],[g,y,E],[_,v,b]]);if(e===cl.Into2000)return new Hd([[p,g,_],[T,y,v],[S,E,b]]);throw"Invalid precess direction"}class Cs{constructor(e,t,i,r){this.x=e,this.y=t,this.z=i,this.t=r}Length(){return Math.hypot(this.x,this.y,this.z)}}class eie{constructor(e,t,i,r,a,s,o){this.x=e,this.y=t,this.z=i,this.vx=r,this.vy=a,this.vz=s,this.t=o}}let tie=class{constructor(e,t,i){this.lat=C_(e),this.lon=C_(t),this.dist=C_(i)}};class Hd{constructor(e){this.rot=e}}function aM(n){const e=xh(n),t=qne(e),i=t.distance_au*Math.cos(t.geo_eclip_lat),r=[i*Math.cos(t.geo_eclip_lon),i*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],a=Yne(e,r),s=Zne(a,e,cl.Into2000);return new Cs(s[0],s[1],s[2],e)}function cd(n,e,t){let i=1,r=0;for(let a of n){let s=0;for(let[l,h,f]of a)s+=l*Math.cos(h+e*f);let o=i*s;t&&(o%=Fo),r+=o,i*=e}return r}function c3(n,e){let t=1,i=0,r=0,a=0;for(let s of n){let o=0,l=0;for(let[h,f,d]of s){let p=f+e*d;o+=h*d*Math.sin(p),a>0&&(l+=h*Math.cos(p))}r+=a*i*l-t*o,i=t,t*=e,++a}return r}const Sm=365250,sM=0,oM=1,lM=2;function cM(n){return new Tr(n[0]+44036e-11*n[1]-190919e-12*n[2],-479966e-12*n[0]+.917482137087*n[1]-.397776982902*n[2],.397776982902*n[1]+.917482137087*n[2])}function $P(n,e,t){const i=t*Math.cos(e),r=Math.cos(n),a=Math.sin(n);return[i*r,i*a,t*Math.sin(e)]}function D_(n,e){const t=e.tt/Sm,i=cd(n[sM],t,!0),r=cd(n[oM],t,!1),a=cd(n[lM],t,!1),s=$P(i,r,a);return cM(s).ToAstroVector(e)}function nie(n,e){const t=e/Sm,i=cd(n[sM],t,!0),r=cd(n[oM],t,!1),a=cd(n[lM],t,!1),s=c3(n[sM],t),o=c3(n[oM],t),l=c3(n[lM],t),h=Math.cos(i),f=Math.sin(i),d=Math.cos(r),p=Math.sin(r),g=+(l*d*h)-a*p*h*o-a*d*f*s,_=+(l*d*f)-a*p*f*o+a*d*h*s,T=+(l*p)+a*d*o,y=$P(i,r,a),v=[g/Sm,_/Sm,T/Sm],S=cM(y),E=cM(v);return new sh(e,S,E)}function r_(n,e,t,i){const r=i/(i+DA),a=D_(Qf[t],e);n.x+=r*a.x,n.y+=r*a.y,n.z+=r*a.z}function iie(n){const e=new Cs(0,0,0,n);return r_(e,n,Bn.Jupiter,tM),r_(e,n,Bn.Saturn,nM),r_(e,n,Bn.Uranus,iM),r_(e,n,Bn.Neptune,rM),e}const uM=51,rie=29200,Jf=146,Go=201,Nu=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Tr{constructor(e,t,i){this.x=e,this.y=t,this.z=i}clone(){return new Tr(this.x,this.y,this.z)}ToAstroVector(e){return new Cs(this.x,this.y,this.z,e)}static zero(){return new Tr(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Tr(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Tr(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new Tr(e*this.x,e*this.y,e*this.z)}div(e){return new Tr(this.x/e,this.y/e,this.z/e)}mean(e){return new Tr((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Tr(-this.x,-this.y,-this.z)}}class sh{constructor(e,t,i){this.tt=e,this.r=t,this.v=i}clone(){return new sh(this.tt,this.r,this.v)}sub(e){return new sh(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function aie(n){let[e,[t,i,r],[a,s,o]]=n;return new sh(e,new Tr(t,i,r),new Tr(a,s,o))}function a_(n,e,t,i){const r=i/(i+DA),a=nie(Qf[t],e);return n.r.incr(a.r.mul(r)),n.v.incr(a.v.mul(r)),a}function sm(n,e,t){const i=t.sub(n),r=i.quadrature();return i.mul(e/(r*Math.sqrt(r)))}class NA{constructor(e){let t=new sh(e,new Tr(0,0,0),new Tr(0,0,0));this.Jupiter=a_(t,e,Bn.Jupiter,tM),this.Saturn=a_(t,e,Bn.Saturn,nM),this.Uranus=a_(t,e,Bn.Uranus,iM),this.Neptune=a_(t,e,Bn.Neptune,rM),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new sh(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=sm(e,DA,this.Sun.r);return t.incr(sm(e,tM,this.Jupiter.r)),t.incr(sm(e,nM,this.Saturn.r)),t.incr(sm(e,iM,this.Uranus.r)),t.incr(sm(e,rM,this.Neptune.r)),t}}let e9=class t9{constructor(e,t,i,r){this.tt=e,this.r=t,this.v=i,this.a=r}clone(){return new t9(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}},n9=class{constructor(e,t){this.bary=e,this.grav=t}};function h1(n,e,t,i){return new Tr(e.x+n*(t.x+n*i.x/2),e.y+n*(t.y+n*i.y/2),e.z+n*(t.z+n*i.z/2))}function UO(n,e,t){return new Tr(e.x+n*t.x,e.y+n*t.y,e.z+n*t.z)}function hM(n,e){const t=n-e.tt,i=new NA(n),r=h1(t,e.r,e.v,e.a),a=i.Acceleration(r).mean(e.a),s=h1(t,e.r,e.v,a),o=e.v.add(a.mul(t)),l=i.Acceleration(s),h=new e9(n,s,o,l);return new n9(i,h)}const sie=[];function i9(n,e){const t=Math.floor(n);return t<0?0:t>=e?e-1:t}function fM(n){const e=aie(n),t=new NA(e.tt),i=e.r.add(t.Sun.r),r=e.v.add(t.Sun.v),a=t.Acceleration(i),s=new e9(e.tt,i,r,a);return new n9(t,s)}function oie(n,e){const t=Nu[0][0];if(e<t||e>Nu[uM-1][0])return null;const i=i9((e-t)/rie,uM-1);if(!n[i]){const a=n[i]=[];a[0]=fM(Nu[i]).grav,a[Go-1]=fM(Nu[i+1]).grav;let s,o=a[0].tt;for(s=1;s<Go-1;++s)a[s]=hM(o+=Jf,a[s-1]).grav;o=a[Go-1].tt;var r=[];for(r[Go-1]=a[Go-1],s=Go-2;s>0;--s)r[s]=hM(o-=Jf,r[s+1]).grav;for(s=Go-2;s>0;--s){const l=s/(Go-1);a[s].r=a[s].r.mul(1-l).add(r[s].r.mul(l)),a[s].v=a[s].v.mul(1-l).add(r[s].v.mul(l)),a[s].a=a[s].a.mul(1-l).add(r[s].a.mul(l))}}return n[i]}function PO(n,e,t){let i=fM(n);const r=Math.ceil((e-i.grav.tt)/t);for(let a=0;a<r;++a)i=hM(a+1===r?e:i.grav.tt+t,i.grav);return i}function lie(n,e){let t,i,r;const a=oie(sie,n.tt);if(a){const s=i9((n.tt-a[0].tt)/Jf,Go-1),o=a[s],l=a[s+1],h=o.a.mean(l.a),f=h1(n.tt-o.tt,o.r,o.v,h),d=UO(n.tt-o.tt,o.v,h),p=h1(n.tt-l.tt,l.r,l.v,h),g=UO(n.tt-l.tt,l.v,h),_=(n.tt-o.tt)/Jf;t=f.mul(1-_).add(p.mul(_)),i=d.mul(1-_).add(g.mul(_))}else{let s;n.tt<Nu[0][0]?s=PO(Nu[0],n.tt,-Jf):s=PO(Nu[uM-1],n.tt,+Jf),t=s.grav.r,i=s.grav.v,r=s.bary}return r||(r=new NA(n.tt)),t=t.sub(r.Sun.r),i=i.sub(r.Sun.v),new eie(t.x,t.y,t.z,i.x,i.y,i.z,n)}function Zm(n,e){var t=xh(e);if(n in Qf)return D_(Qf[n],t);if(n===Bn.Pluto){const s=lie(t);return new Cs(s.x,s.y,s.z,t)}if(n===Bn.Sun)return new Cs(0,0,0,t);if(n===Bn.Moon){var i=D_(Qf.Earth,t),r=aM(t);return new Cs(i.x+r.x,i.y+r.y,i.z+r.z,t)}if(n===Bn.EMB){const s=D_(Qf.Earth,t),o=aM(t),l=1+Bne;return new Cs(s.x+o.x/l,s.y+o.y/l,s.z+o.z/l,t)}if(n===Bn.SSB)return iie(t);const a=ZP(n);if(a){const s=new tie(a.dec,15*a.ra,a.dist);return mie(s,t)}throw`HelioVector: Unknown body "${n}"`}function cie(n,e){let t=e,i=0;for(let r=0;r<10;++r){const a=n(t),s=a.Length()/Nne;if(s>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-s);if(i=Math.abs(o.tt-t.tt),i<1e-9)return a;t=o}throw`Light-travel time solver did not converge: dt = ${i}`}class uie{constructor(e,t,i,r){this.observerBody=e,this.targetBody=t,this.aberration=i,this.observerPos=r}Position(e){this.aberration&&(this.observerPos=Zm(this.observerBody,e));const t=Zm(this.targetBody,e);return new Cs(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function hie(n,e,t,i){const r=xh(n);if(ZP(t)){const o=Zm(t,r),l=Zm(e,r);return new Cs(o.x-l.x,o.y-l.y,o.z-l.z,r)}let a;a=Zm(e,r);const s=new uie(e,t,i,a);return cie(o=>s.Position(o),r)}function fie(n,e,t){const i=xh(e);switch(n){case Bn.Earth:return new Cs(0,0,0,i);case Bn.Moon:return aM(i);default:const r=hie(i,Bn.Earth,n,t);return r.t=i,r}}var zO;(function(n){n[n.Pericenter=0]="Pericenter",n[n.Apocenter=1]="Apocenter"})(zO||(zO={}));function die(n,e){return new Hd([[e.rot[0][0]*n.rot[0][0]+e.rot[1][0]*n.rot[0][1]+e.rot[2][0]*n.rot[0][2],e.rot[0][1]*n.rot[0][0]+e.rot[1][1]*n.rot[0][1]+e.rot[2][1]*n.rot[0][2],e.rot[0][2]*n.rot[0][0]+e.rot[1][2]*n.rot[0][1]+e.rot[2][2]*n.rot[0][2]],[e.rot[0][0]*n.rot[1][0]+e.rot[1][0]*n.rot[1][1]+e.rot[2][0]*n.rot[1][2],e.rot[0][1]*n.rot[1][0]+e.rot[1][1]*n.rot[1][1]+e.rot[2][1]*n.rot[1][2],e.rot[0][2]*n.rot[1][0]+e.rot[1][2]*n.rot[1][1]+e.rot[2][2]*n.rot[1][2]],[e.rot[0][0]*n.rot[2][0]+e.rot[1][0]*n.rot[2][1]+e.rot[2][0]*n.rot[2][2],e.rot[0][1]*n.rot[2][0]+e.rot[1][1]*n.rot[2][1]+e.rot[2][1]*n.rot[2][2],e.rot[0][2]*n.rot[2][0]+e.rot[1][2]*n.rot[2][1]+e.rot[2][2]*n.rot[2][2]]])}function pie(n,e,t){const i=C_(t)*ah,r=Math.cos(i),a=Math.sin(i),s=(e+1)%3,o=(e+2)%3,l=e;let h=[[0,0,0],[0,0,0],[0,0,0]];return h[s][s]=r*n.rot[s][s]-a*n.rot[s][o],h[s][o]=a*n.rot[s][s]+r*n.rot[s][o],h[s][l]=n.rot[s][l],h[o][s]=r*n.rot[o][s]-a*n.rot[o][o],h[o][o]=a*n.rot[o][s]+r*n.rot[o][o],h[o][l]=n.rot[o][l],h[l][s]=r*n.rot[l][s]-a*n.rot[l][o],h[l][o]=a*n.rot[l][s]+r*n.rot[l][o],h[l][l]=n.rot[l][l],new Hd(h)}function mie(n,e){e=xh(e);const t=n.lat*ah,i=n.lon*ah,r=n.dist*Math.cos(t);return new Cs(r*Math.cos(i),r*Math.sin(i),n.dist*Math.sin(t),e)}function gie(n){n=xh(n);const e=JP(n,cl.From2000),t=$ne(n,cl.From2000);return die(e,t)}var BO;(function(n){n.Penumbral="penumbral",n.Partial="partial",n.Annular="annular",n.Total="total"})(BO||(BO={}));var HO;(function(n){n[n.Invalid=0]="Invalid",n[n.Ascending=1]="Ascending",n[n.Descending=-1]="Descending"})(HO||(HO={}));function OA(n){return n instanceof dc?n:new dc(n instanceof Date?n:new Date(n))}function vie(n,e=new L){const{x:t,y:i,z:r}=n;return e.set(t,i,r)}function _ie(n,e=new Ve){const[t,i,r]=n.rot;return e.set(t[0],i[0],r[0],0,t[1],i[1],r[1],0,t[2],i[2],r[2],0,0,0,0,1)}function xie(n,e=new Ve){const t=OA(n),i=pie(gie(t),2,-15*Jne(t));return _ie(i,e)}function r9(n,e,t,i,r){const a=fie(n,e,!1);return vie(a,t),i!=null,t.normalize()}function yie(n,e=new L,t){return r9(Bn.Sun,OA(n),e,t)}function Sie(n,e=new L,t){return r9(Bn.Moon,OA(n),e,t)}const Tie=`precision highp float;
precision highp sampler3D;

#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"

uniform AtmosphereParameters ATMOSPHERE;

uniform sampler2D transmittanceTexture;

layout(location = 0) out vec4 outputColor;

void main() {
  vec3 deltaIrradiance;
  vec3 irradiance;
  deltaIrradiance = ComputeDirectIrradianceTexture(
    ATMOSPHERE,
    transmittanceTexture,
    gl_FragCoord.xy
  );
  irradiance = vec3(0.0);
  outputColor = vec4(OUTPUT, 1.0);
}
`,Eie=`precision highp float;
precision highp sampler3D;

#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"

uniform AtmosphereParameters ATMOSPHERE;

uniform mat3 luminanceFromRadiance;
uniform sampler3D singleRayleighScatteringTexture;
uniform sampler3D singleMieScatteringTexture;
uniform sampler3D multipleScatteringTexture;
uniform int scatteringOrder;

layout(location = 0) out vec4 outputColor;

void main() {
  vec3 deltaIrradiance;
  vec3 irradiance;
  deltaIrradiance = ComputeIndirectIrradianceTexture(
    ATMOSPHERE,
    singleRayleighScatteringTexture,
    singleMieScatteringTexture,
    multipleScatteringTexture,
    gl_FragCoord.xy,
    scatteringOrder
  );
  irradiance = luminanceFromRadiance * deltaIrradiance;
  outputColor = vec4(OUTPUT, 1.0);
}
`,Mie=`precision highp float;
precision highp sampler3D;

#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"

uniform AtmosphereParameters ATMOSPHERE;

uniform mat3 luminanceFromRadiance;
uniform sampler2D transmittanceTexture;
uniform sampler3D scatteringDensityTexture;
uniform int layer;

layout(location = 0) out vec4 outputColor;

void main() {
  vec4 deltaMultipleScattering;
  vec4 scattering;
  float nu;
  deltaMultipleScattering.rgb = ComputeMultipleScatteringTexture(
    ATMOSPHERE,
    transmittanceTexture,
    scatteringDensityTexture,
    vec3(gl_FragCoord.xy, float(layer) + 0.5),
    nu
  );
  deltaMultipleScattering.a = 1.0;
  scattering = vec4(
    luminanceFromRadiance * deltaMultipleScattering.rgb / RayleighPhaseFunction(nu),
    0.0
  );
  outputColor = OUTPUT;
}
`,bie=`precision highp float;
precision highp sampler3D;

#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"

uniform AtmosphereParameters ATMOSPHERE;

uniform sampler2D transmittanceTexture;
uniform sampler3D singleRayleighScatteringTexture;
uniform sampler3D singleMieScatteringTexture;
uniform sampler3D multipleScatteringTexture;
uniform sampler2D irradianceTexture;
uniform int scatteringOrder;
uniform int layer;

layout(location = 0) out vec4 scatteringDensity;

void main() {
  scatteringDensity.rgb = ComputeScatteringDensityTexture(
    ATMOSPHERE,
    transmittanceTexture,
    singleRayleighScatteringTexture,
    singleMieScatteringTexture,
    multipleScatteringTexture,
    irradianceTexture,
    vec3(gl_FragCoord.xy, float(layer) + 0.5),
    scatteringOrder
  );
  scatteringDensity.a = 1.0;
}
`,Aie=`precision highp float;
precision highp sampler3D;

#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"

uniform AtmosphereParameters ATMOSPHERE;

uniform mat3 luminanceFromRadiance;
uniform sampler2D transmittanceTexture;
uniform int layer;

layout(location = 0) out vec4 outputColor;

void main() {
  vec4 deltaRayleigh;
  vec4 deltaMie;
  vec4 scattering;
  vec4 singleMieScattering;
  ComputeSingleScatteringTexture(
    ATMOSPHERE,
    transmittanceTexture,
    vec3(gl_FragCoord.xy, float(layer) + 0.5),
    deltaRayleigh.rgb,
    deltaMie.rgb
  );
  deltaRayleigh.a = 1.0;
  deltaMie.a = 1.0;
  scattering = vec4(
    luminanceFromRadiance * deltaRayleigh.rgb,
    (luminanceFromRadiance * deltaMie.rgb).r
  );
  singleMieScattering.rgb = luminanceFromRadiance * deltaMie.rgb;
  singleMieScattering.a = 1.0;
  outputColor = OUTPUT;
}
`,wie=`precision highp float;
precision highp sampler3D;

#include "bruneton/definitions"
#include "bruneton/common"
#include "bruneton/precompute"

uniform AtmosphereParameters ATMOSPHERE;

layout(location = 0) out vec4 transmittance;

void main() {
  transmittance.rgb = ComputeTransmittanceToTopAtmosphereBoundaryTexture(
    ATMOSPHERE,
    gl_FragCoord.xy
  );
  transmittance.a = 1.0;
}
`,Rie=`
  precision highp float;
  in vec2 position;
  void main() {
    gl_Position = vec4(position, 1.0, 1.0);
  }
`;function f1(n,e,t){const i=new xi(e,t,{depthBuffer:!1,type:n,format:$n}),r=i.texture;return r.minFilter=Ht,r.magFilter=Ht,r.wrapS=Ui,r.wrapT=Ui,r.colorSpace=Or,i}function ud(n,e,t,i){const r=new ZU(e,t,i,{depthBuffer:!1,type:n,format:$n}),a=r.texture;return a.minFilter=Ht,a.magFilter=Ht,a.wrapS=Ui,a.wrapT=Ui,a.wrapR=Ui,a.colorSpace=Or,r}function Cie(n){const e=n[Symbol.iterator]();return new Promise((t,i)=>{const r=()=>{try{const{value:a,done:s}=e.next();s===!0?t(a):OO(r)}catch(a){i(a instanceof Error?a:new Error)}};OO(r)})}async function FO(n,e,t){const{width:i,height:r}=e,a=t.type===Yn?new Uint16Array(i*r*4):new Float32Array(i*r*4);await n.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,a),t.userData.imageData=a}class Die{constructor(e){this.lambdas=new L,this.luminanceFromRadiance=new Et,e===Yn&&(this.opticalDepth=f1(e,rp,ap)),this.deltaIrradiance=f1(e,np,ip),this.deltaRayleighScattering=ud(e,Fu,Gu,Vu),this.deltaMieScattering=ud(e,Fu,Gu,Vu),this.deltaScatteringDensity=ud(e,Fu,Gu,Vu),this.deltaMultipleScattering=this.deltaRayleighScattering}dispose(){var e;(e=this.opticalDepth)==null||e.dispose(),this.deltaIrradiance.dispose(),this.deltaRayleighScattering.dispose(),this.deltaMieScattering.dispose(),this.deltaScatteringDensity.dispose()}}class Af extends ph{constructor(e){super({glslVersion:so,vertexShader:Rie,...e,defines:{TRANSMITTANCE_TEXTURE_WIDTH:rp.toFixed(0),TRANSMITTANCE_TEXTURE_HEIGHT:ap.toFixed(0),SCATTERING_TEXTURE_R_SIZE:Ty.toFixed(0),SCATTERING_TEXTURE_MU_SIZE:Ey.toFixed(0),SCATTERING_TEXTURE_MU_S_SIZE:My.toFixed(0),SCATTERING_TEXTURE_NU_SIZE:by.toFixed(0),IRRADIANCE_TEXTURE_WIDTH:np.toFixed(0),IRRADIANCE_TEXTURE_HEIGHT:ip.toFixed(0),...e.defines}})}set additive(e){this.transparent=e,this.blending=e?xb:Er,this.blendEquation=$s,this.blendEquationAlpha=$s,this.blendSrc=Yf,this.blendDst=Yf,this.blendSrcAlpha=Yf,this.blendDstAlpha=Yf}setUniforms(e){const t=this.uniforms;t.luminanceFromRadiance!=null&&t.luminanceFromRadiance.value.copy(e.luminanceFromRadiance),t.singleRayleighScatteringTexture!=null&&(t.singleRayleighScatteringTexture.value=e.deltaRayleighScattering.texture),t.singleMieScatteringTexture!=null&&(t.singleMieScatteringTexture.value=e.deltaMieScattering.texture),t.multipleScatteringTexture!=null&&(t.multipleScatteringTexture.value=e.deltaMultipleScattering.texture),t.scatteringDensityTexture!=null&&(t.scatteringDensityTexture.value=e.deltaScatteringDensity.texture),t.irradianceTexture!=null&&(t.irradianceTexture.value=e.deltaIrradiance.texture)}}class Nie{constructor(e,{type:t=fP(e)?si:Yn,combinedScattering:i=!0,higherOrderScattering:r=!0}={}){var a,s;this.transmittanceMaterial=new Af({fragmentShader:Nr(wie,{bruneton:{common:Qs,definitions:Js,precompute:Ef}})}),this.directIrradianceMaterial=new Af({fragmentShader:Nr(Tie,{bruneton:{common:Qs,definitions:Js,precompute:Ef}}),uniforms:{transmittanceTexture:new J(null)}}),this.singleScatteringMaterial=new Af({fragmentShader:Nr(Aie,{bruneton:{common:Qs,definitions:Js,precompute:Ef}}),uniforms:{luminanceFromRadiance:new J(new Et),transmittanceTexture:new J(null),layer:new J(0)}}),this.scatteringDensityMaterial=new Af({fragmentShader:Nr(bie,{bruneton:{common:Qs,definitions:Js,precompute:Ef}}),uniforms:{transmittanceTexture:new J(null),singleRayleighScatteringTexture:new J(null),singleMieScatteringTexture:new J(null),multipleScatteringTexture:new J(null),irradianceTexture:new J(null),scatteringOrder:new J(0),layer:new J(0)}}),this.indirectIrradianceMaterial=new Af({fragmentShader:Nr(Eie,{bruneton:{common:Qs,definitions:Js,precompute:Ef}}),uniforms:{luminanceFromRadiance:new J(new Et),singleRayleighScatteringTexture:new J(null),singleMieScatteringTexture:new J(null),multipleScatteringTexture:new J(null),scatteringOrder:new J(0)}}),this.multipleScatteringMaterial=new Af({fragmentShader:Nr(Mie,{bruneton:{common:Qs,definitions:Js,precompute:Ef}}),uniforms:{luminanceFromRadiance:new J(new Et),transmittanceTexture:new J(null),scatteringDensityTexture:new J(null),layer:new J(0)}}),this.mesh=new oi(new dh(2,2)),this.scene=new Nd().add(this.mesh),this.camera=new wc,this.updating=!1,this.renderer=e,this.type=t,this.transmittanceRenderTarget=f1(t,rp,ap),this.scatteringRenderTarget=ud(t,Fu,Gu,Vu),this.irradianceRenderTarget=f1(t,np,ip),i||(this.singleMieScatteringRenderTarget=ud(t,Fu,Gu,Vu)),r&&(this.higherOrderScatteringRenderTarget=ud(t,Fu,Gu,Vu)),this.textures={transmittanceTexture:this.transmittanceRenderTarget.texture,scatteringTexture:this.scatteringRenderTarget.texture,irradianceTexture:this.irradianceRenderTarget.texture,singleMieScatteringTexture:(a=this.singleMieScatteringRenderTarget)==null?void 0:a.texture,higherOrderScatteringTexture:(s=this.higherOrderScatteringRenderTarget)==null?void 0:s.texture}}render3DRenderTarget(e,t){for(let i=0;i<e.depth;++i)t.uniforms.layer.value=i,this.renderer.setRenderTarget(e,i),this.renderer.render(this.scene,this.camera)}computeTransmittance(e){const t=this.transmittanceMaterial;delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeOpticalDepth(e){const t=this.transmittanceMaterial;t.defines.TRANSMITTANCE_PRECISION_LOG="1",t.needsUpdate=!0,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeDirectIrradiance(e){var r;const t=this.directIrradianceMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,this.type===Yn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((r=e.context.opticalDepth)==null?void 0:r.texture)??this.transmittanceRenderTarget.texture,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeSingleScattering(e){var r;const t=this.singleScatteringMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,this.type===Yn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((r=e.context.opticalDepth)==null?void 0:r.texture)??this.transmittanceRenderTarget.texture,t.setUniforms(e.context),this.mesh.material=t,this.render3DRenderTarget(e.renderTarget,t)}computeScatteringDensity(e){var r;const t=this.scatteringDensityMaterial;this.type===Yn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((r=e.context.opticalDepth)==null?void 0:r.texture)??this.transmittanceRenderTarget.texture,i.scatteringOrder.value=e.scatteringOrder,t.setUniforms(e.context),this.mesh.material=t,this.render3DRenderTarget(e.renderTarget,t)}computeIndirectIrradiance(e){const t=this.indirectIrradianceMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,t.needsUpdate=!0;const i=t.uniforms;i.scatteringOrder.value=e.scatteringOrder-1,t.setUniforms(e.context),this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeMultipleScattering(e){var r;const t=this.multipleScatteringMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,this.type===Yn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((r=e.context.opticalDepth)==null?void 0:r.texture)??this.transmittanceRenderTarget.texture,t.setUniforms(e.context),this.mesh.material=t,this.render3DRenderTarget(e.renderTarget,t)}*precompute(e,t){this.computeTransmittance({renderTarget:this.transmittanceRenderTarget}),this.type===Yn&&(_ne(e.opticalDepth!=null),this.computeOpticalDepth({renderTarget:e.opticalDepth})),this.computeDirectIrradiance({renderTarget:e.deltaIrradiance,context:e,output:"deltaIrradiance",additive:!1}),this.computeDirectIrradiance({renderTarget:this.irradianceRenderTarget,context:e,output:"irradiance",additive:t}),this.renderer.setRenderTarget(null),yield,this.computeSingleScattering({renderTarget:e.deltaRayleighScattering,context:e,output:"deltaRayleigh",additive:!1}),this.computeSingleScattering({renderTarget:e.deltaMieScattering,context:e,output:"deltaMie",additive:!1}),this.computeSingleScattering({renderTarget:this.scatteringRenderTarget,context:e,output:"scattering",additive:t}),this.singleMieScatteringRenderTarget!=null&&this.computeSingleScattering({renderTarget:this.singleMieScatteringRenderTarget,context:e,output:"singleMieScattering",additive:t}),this.renderer.setRenderTarget(null),yield;for(let i=2;i<=4;++i)this.computeScatteringDensity({renderTarget:e.deltaScatteringDensity,context:e,scatteringOrder:i}),this.computeIndirectIrradiance({renderTarget:e.deltaIrradiance,context:e,scatteringOrder:i,output:"deltaIrradiance",additive:!1}),this.computeIndirectIrradiance({renderTarget:this.irradianceRenderTarget,context:e,scatteringOrder:i,output:"irradiance",additive:!0}),this.computeMultipleScattering({renderTarget:e.deltaMultipleScattering,context:e,output:"deltaMultipleScattering",additive:!1}),this.computeMultipleScattering({renderTarget:this.scatteringRenderTarget,context:e,output:"scattering",additive:!0}),this.higherOrderScatteringRenderTarget!=null&&this.computeMultipleScattering({renderTarget:this.higherOrderScatteringRenderTarget,context:e,output:"scattering",additive:!0}),this.renderer.setRenderTarget(null),yield}async update(e=$0.DEFAULT){var s;this.updating=!0;const t=e.toUniform();this.transmittanceMaterial.uniforms.ATMOSPHERE=t,this.directIrradianceMaterial.uniforms.ATMOSPHERE=t,this.singleScatteringMaterial.uniforms.ATMOSPHERE=t,this.scatteringDensityMaterial.uniforms.ATMOSPHERE=t,this.indirectIrradianceMaterial.uniforms.ATMOSPHERE=t,this.multipleScatteringMaterial.uniforms.ATMOSPHERE=t;const i=this.renderer,r=new Die(this.type);r.lambdas.set(680,550,440),r.luminanceFromRadiance.identity();const a=i.autoClear;return i.autoClear=!1,await Cie(this.precompute(r,!1)),i.autoClear=a,r.dispose(),await FO(this.renderer,this.transmittanceRenderTarget,this.transmittanceRenderTarget.texture),await FO(this.renderer,this.irradianceRenderTarget,this.irradianceRenderTarget.texture),this.updating=!1,(s=this.disposeQueue)==null||s.call(this),this.textures}dispose(e={}){var i,r,a,s;if(this.updating){this.disposeQueue=()=>{this.dispose(e),this.disposeQueue=void 0};return}const{textures:t=!0}=e;t||(this.transmittanceRenderTarget.textures.splice(0,1),this.scatteringRenderTarget.textures.splice(0,1),this.irradianceRenderTarget.textures.splice(0,1),(i=this.singleMieScatteringRenderTarget)==null||i.textures.splice(0,1),(r=this.higherOrderScatteringRenderTarget)==null||r.textures.splice(0,1)),this.transmittanceRenderTarget.dispose(),this.scatteringRenderTarget.dispose(),this.irradianceRenderTarget.dispose(),(a=this.singleMieScatteringRenderTarget)==null||a.dispose(),(s=this.higherOrderScatteringRenderTarget)==null||s.dispose(),this.transmittanceMaterial.dispose(),this.directIrradianceMaterial.dispose(),this.singleScatteringMaterial.dispose(),this.scatteringDensityMaterial.dispose(),this.indirectIrradianceMaterial.dispose(),this.multipleScatteringMaterial.dispose(),this.mesh.geometry.dispose()}}function Oie(n){var e=[];if(n.length===0)return"";if(typeof n[0]!="string")throw new TypeError("Url must be a string. Received "+n[0]);if(n[0].match(/^[^/:]+:\/*$/)&&n.length>1){var t=n.shift();n[0]=t+n[0]}n[0].match(/^file:\/\/\//)?n[0]=n[0].replace(/^([^/:]+):\/*/,"$1:///"):n[0]=n[0].replace(/^([^/:]+):\/*/,"$1://");for(var i=0;i<n.length;i++){var r=n[i];if(typeof r!="string")throw new TypeError("Url must be a string. Received "+r);r!==""&&(i>0&&(r=r.replace(/^[\/]+/,"")),i<n.length-1?r=r.replace(/[\/]+$/,""):r=r.replace(/[\/]+$/,"/"),e.push(r))}var a=e.join("/");a=a.replace(/\/(\?|&|#[^!])/g,"$1");var s=a.split("?");return a=s.shift()+(s.length>0?"?":"")+s.join("&"),a}function Lie(){var n;return typeof arguments[0]=="object"?n=arguments[0]:n=[].slice.call(arguments),Oie(n)}const GO={width:rp,height:ap},wf={width:Fu,height:Gu,depth:Vu},VO={width:np,height:ip};class a9 extends yi{constructor({format:e="exr",type:t=Yn,combinedScattering:i=!0,higherOrderScattering:r=!0}={},a){super(a),this.format=e,this.type=t,this.combinedScattering=i,this.higherOrderScattering=r}setType(e){return this.type=fP(e)?si:Yn,this}setTypeFromRenderer(e){return this.setType(e)}load(e,t,i,r){const a={},s=({key:o,loader:l,path:h})=>(l.setRequestHeader(this.requestHeader),l.setPath(this.path),l.setWithCredentials(this.withCredentials),l.load(Lie(e,h),f=>{f.type=this.type,this.type===si&&(f.image.data=new Float32Array(new dl(f.image.data.buffer))),f.minFilter=Ht,f.magFilter=Ht,a[`${o}Texture`]=f,a.irradianceTexture!=null&&a.scatteringTexture!=null&&a.transmittanceTexture!=null&&(this.combinedScattering||a.singleMieScatteringTexture!=null)&&(!this.higherOrderScattering||a.higherOrderScatteringTexture!=null)&&(t==null||t(a))},i,r));return this.format==="exr"?{transmittanceTexture:s({key:"transmittance",loader:new NO(GO,this.manager),path:"transmittance.exr"}),scatteringTexture:s({key:"scattering",loader:new s3(wf,this.manager),path:"scattering.exr"}),irradianceTexture:s({key:"irradiance",loader:new NO(VO,this.manager),path:"irradiance.exr"}),singleMieScatteringTexture:this.combinedScattering?void 0:s({key:"singleMieScattering",loader:new s3(wf,this.manager),path:"single_mie_scattering.exr"}),higherOrderScatteringTexture:this.higherOrderScattering?s({key:"higherOrderScattering",loader:new s3(wf,this.manager),path:"higher_order_scattering.exr"}):void 0}:{transmittanceTexture:s({key:"transmittance",loader:new Mu(ea,am,GO,this.manager),path:"transmittance.bin"}),scatteringTexture:s({key:"scattering",loader:new Mu(ss,am,wf,this.manager),path:"scattering.bin"}),irradianceTexture:s({key:"irradiance",loader:new Mu(ea,am,VO,this.manager),path:"irradiance.bin"}),singleMieScatteringTexture:this.combinedScattering?void 0:s({key:"singleMieScattering",loader:new Mu(ss,am,wf,this.manager),path:"single_mie_scattering.bin"}),higherOrderScatteringTexture:this.higherOrderScattering?s({key:"higherOrderScattering",loader:new Mu(ss,am,wf,this.manager),path:"higher_order_scattering.bin"}):void 0}}}const Iie=`precision highp float;
precision highp sampler3D;

#define RECIPROCAL_PI 0.3183098861837907

#include "core/raySphereIntersection"

#include "bruneton/definitions"

uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;

uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;

#include "bruneton/common"
#include "bruneton/runtime"

#include "sky"

uniform vec3 sunDirection;
uniform vec3 moonDirection;
uniform float moonAngularRadius;
uniform float lunarRadianceScale;
uniform vec3 groundAlbedo;

#ifdef HAS_SHADOW_LENGTH
uniform sampler2D shadowLengthBuffer;
#endif // HAS_SHADOW_LENGTH

in vec2 vUv;
in vec3 vCameraPosition;
in vec3 vRayDirection;

layout(location = 0) out vec4 outputColor;

#include <mrt_layout>

void main() {
  float shadowLength = 0.0;
  #ifdef HAS_SHADOW_LENGTH
  shadowLength = texture(shadowLengthBuffer, vUv).r;
  #endif // HAS_SHADOW_LENGTH

  vec3 cameraPosition = vCameraPosition;
  vec3 rayDirection = normalize(vRayDirection);

  #ifdef GROUND_ALBEDO

  float r = length(cameraPosition);
  float mu = dot(cameraPosition, rayDirection) / r;
  bool intersectsGround = RayIntersectsGround(ATMOSPHERE, r, mu);
  if (intersectsGround) {
    float distanceToGround = raySphereFirstIntersection(
      cameraPosition,
      rayDirection,
      ATMOSPHERE.bottom_radius
    );
    vec3 groundPosition = rayDirection * distanceToGround + cameraPosition;
    vec3 surfaceNormal = normalize(groundPosition);
    vec3 skyIrradiance;
    vec3 sunIrradiance = GetSunAndSkyIrradiance(
      cameraPosition,
      surfaceNormal,
      sunDirection,
      skyIrradiance
    );
    vec3 transmittance;
    vec3 inscatter = GetSkyRadianceToPoint(
      cameraPosition,
      ATMOSPHERE.bottom_radius * surfaceNormal,
      shadowLength,
      sunDirection,
      transmittance
    );
    vec3 radiance = groundAlbedo * RECIPROCAL_PI * (sunIrradiance + skyIrradiance);
    outputColor.rgb = radiance * transmittance + inscatter;
  } else {
    outputColor.rgb = getSkyRadiance(
      cameraPosition,
      rayDirection,
      shadowLength,
      sunDirection,
      moonDirection,
      moonAngularRadius,
      lunarRadianceScale
    );
  }

  #else // GROUND_ALBEDO

  outputColor.rgb = getSkyRadiance(
    cameraPosition,
    rayDirection,
    shadowLength,
    sunDirection,
    moonDirection,
    moonAngularRadius,
    lunarRadianceScale
  );

  #endif // GROUND_ALBEDO

  outputColor.a = 1.0;

  #include <mrt_output>
}
`,Uie=`precision highp float;
precision highp sampler3D;

uniform mat4 inverseProjectionMatrix;
uniform mat4 inverseViewMatrix;
uniform vec3 cameraPosition;
uniform mat4 worldToECEFMatrix;
uniform vec3 altitudeCorrection;

layout(location = 0) in vec3 position;

out vec2 vUv;
out vec3 vCameraPosition;
out vec3 vRayDirection;

void getCameraRay(out vec3 origin, out vec3 direction) {
  bool isPerspective = inverseProjectionMatrix[2][3] != 0.0; // 4th entry in the 3rd column

  if (isPerspective) {
    // Calculate the camera ray for a perspective camera.
    vec4 viewPosition = inverseProjectionMatrix * vec4(position, 1.0);
    vec4 worldDirection = inverseViewMatrix * vec4(viewPosition.xyz, 0.0);
    origin = cameraPosition;
    direction = worldDirection.xyz;
  } else {
    // Unprojected points to calculate direction.
    vec4 nearPoint = inverseProjectionMatrix * vec4(position.xy, -1.0, 1.0);
    vec4 farPoint = inverseProjectionMatrix * vec4(position.xy, -0.9, 1.0);
    nearPoint /= nearPoint.w;
    farPoint /= farPoint.w;

    // Calculate world values
    vec4 worldDirection = inverseViewMatrix * vec4(farPoint.xyz - nearPoint.xyz, 0.0);
    vec4 worldOrigin = inverseViewMatrix * nearPoint;

    // Outputs
    direction = worldDirection.xyz;
    origin = worldOrigin.xyz;
  }
}

void main() {
  vUv = position.xy * 0.5 + 0.5;

  vec3 direction, origin;
  getCameraRay(origin, direction);

  vec3 cameraPositionECEF = (worldToECEFMatrix * vec4(origin, 1.0)).xyz;
  vCameraPosition = (cameraPositionECEF + altitudeCorrection) * METER_TO_LENGTH_UNIT;
  vRayDirection = (worldToECEFMatrix * vec4(direction, 0.0)).xyz;

  gl_Position = vec4(position.xy, 1.0, 1.0);
}
`;var Pie=Object.defineProperty,LA=(n,e,t,i)=>{for(var r=void 0,a=n.length-1,s;a>=0;a--)(s=n[a])&&(r=s(e,t,r)||r);return r&&Pie(e,t,r),r};const zie={...CA,sun:!0,moon:!0,moonAngularRadius:.0045,lunarRadianceScale:1,ground:!0,groundAlbedo:new qe(0)};class IA extends eg{constructor(e){const{sun:t,moon:i,moonDirection:r,moonAngularRadius:a,lunarRadianceScale:s,ground:o,groundAlbedo:l,...h}={...zie,...e};super({name:"SkyMaterial",glslVersion:so,vertexShader:Uie,fragmentShader:Nr(Iie,{core:{raySphereIntersection:Sy},bruneton:{common:Qs,definitions:Js,runtime:Ay},sky:YP}),...h,uniforms:{inverseProjectionMatrix:new J(new Ve),inverseViewMatrix:new J(new Ve),moonDirection:new J((r==null?void 0:r.clone())??new L),moonAngularRadius:new J(a),lunarRadianceScale:new J(s),groundAlbedo:new J(l.clone()),shadowLengthBuffer:new J(null),...h.uniforms},defines:{PERSPECTIVE_CAMERA:"1"},depthTest:!0}),this.shadowLength=null,this.sun=t,this.moon=i,this.ground=o}onBeforeRender(e,t,i,r,a,s){super.onBeforeRender(e,t,i,r,a,s);const{uniforms:o,defines:l}=this;o.inverseProjectionMatrix.value.copy(i.projectionMatrixInverse),o.inverseViewMatrix.value.copy(i.matrixWorld);const h=l.PERSPECTIVE_CAMERA!=null,f=i.isPerspectiveCamera===!0;f!==h&&(f?l.PERSPECTIVE_CAMERA="1":delete l.PERSPECTIVE_CAMERA,this.needsUpdate=!0);const d=this.groundAlbedo,p=l.GROUND_ALBEDO!=null,g=d.r!==0||d.g!==0||d.b!==0;g!==p&&(g?this.defines.GROUND_ALBEDO="1":delete this.defines.GROUND_ALBEDO,this.needsUpdate=!0);const _=this.shadowLength,T=l.HAS_SHADOW_LENGTH!=null,y=_!=null;y!==T&&(y?l.HAS_SHADOW_LENGTH="1":(delete l.HAS_SHADOW_LENGTH,o.shadowLengthBuffer.value=null),this.needsUpdate=!0),y&&(o.shadowLengthBuffer.value=_.map)}get moonDirection(){return this.uniforms.moonDirection.value}get moonAngularRadius(){return this.uniforms.moonAngularRadius.value}set moonAngularRadius(e){this.uniforms.moonAngularRadius.value=e}get lunarRadianceScale(){return this.uniforms.lunarRadianceScale.value}set lunarRadianceScale(e){this.uniforms.lunarRadianceScale.value=e}get groundAlbedo(){return this.uniforms.groundAlbedo.value}}LA([pn("SUN")],IA.prototype,"sun");LA([pn("MOON")],IA.prototype,"moon");LA([pn("GROUND")],IA.prototype,"ground");const Bie=`precision highp float;
precision highp sampler3D;

#include "bruneton/definitions"

uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;

uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;

#include "bruneton/common"
#include "bruneton/runtime"

uniform vec3 sunDirection;

in vec3 vCameraPosition;
in vec3 vRayDirection;

layout(location = 0) out vec4 outputColor;

#include <mrt_layout>

in vec3 vColor;

void main() {
  #if !defined(PERSPECTIVE_CAMERA)
  outputColor = vec4(0.0);
  discard; // Rendering celestial objects without perspective doesn't make sense.
  #endif // !defined(PERSPECTIVE_CAMERA)

  #ifdef BACKGROUND
  vec3 rayDirection = normalize(vRayDirection);
  float r = length(vCameraPosition);
  float mu = dot(vCameraPosition, rayDirection) / r;

  if (RayIntersectsGround(ATMOSPHERE, r, mu)) {
    discard;
  }

  vec3 transmittance;
  vec3 radiance = GetSkyRadiance(
    vCameraPosition,
    normalize(vRayDirection),
    0.0, // Shadow length
    sunDirection,
    transmittance
  );
  radiance += transmittance * vColor;
  outputColor = vec4(radiance, 1.0);
  #else // BACKGROUND
  outputColor = vec4(vColor, 1.0);
  #endif // BACKGROUND

  #include <mrt_output>
}
`,Hie=`precision highp float;
precision highp sampler3D;

#define saturate(x) clamp(x, 0.0, 1.0)

uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 viewMatrix;
uniform mat4 matrixWorld;
uniform vec3 cameraPosition;
uniform float cameraFar;
uniform mat4 worldToECEFMatrix;
uniform vec3 altitudeCorrection;
uniform float pointSize;
uniform vec2 magnitudeRange;
uniform float intensity;

layout(location = 0) in vec3 position;
layout(location = 1) in float magnitude;
layout(location = 2) in vec3 color;

out vec3 vCameraPosition;
out vec3 vRayDirection;
out vec3 vEllipsoidCenter;
out vec3 vColor;

void main() {
  // Magnitude is stored between 0 to 1 within the given range.
  float m = mix(magnitudeRange.x, magnitudeRange.y, magnitude);
  vec3 v = pow(vec3(10.0), -vec3(magnitudeRange, m) / 2.5);
  vColor = vec3(intensity * color);
  vColor *= saturate((v.z - v.y) / (v.x - v.y));

  #ifdef BACKGROUND
  vec3 worldDirection = normalize(matrixWorld * vec4(position, 1.0)).xyz;
  vec3 cameraPositionECEF = (worldToECEFMatrix * vec4(cameraPosition, 1.0)).xyz;
  vCameraPosition = (cameraPositionECEF + altitudeCorrection) * METER_TO_LENGTH_UNIT;
  vRayDirection = (worldToECEFMatrix * vec4(worldDirection, 0.0)).xyz;
  gl_Position =
    projectionMatrix * viewMatrix * vec4(cameraPosition + worldDirection * cameraFar, 1.0);
  #else // BACKGROUND
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
  #endif // BACKGROUND

  gl_PointSize = pointSize;
}
`;var Fie=Object.defineProperty,s9=(n,e,t,i)=>{for(var r=void 0,a=n.length-1,s;a>=0;a--)(s=n[a])&&(r=s(e,t,r)||r);return r&&Fie(e,t,r),r};const Gie={...CA,pointSize:1,intensity:1,background:!0,ground:!0};let o9=class extends eg{constructor(e){const{pointSize:t,radianceScale:i,intensity:r,background:a,ground:s,...o}={...Gie,...e};super({name:"StarsMaterial",glslVersion:so,vertexShader:Hie,fragmentShader:Nr(Bie,{bruneton:{common:Qs,definitions:Js,runtime:Ay}}),...o,uniforms:{projectionMatrix:new J(new Ve),modelViewMatrix:new J(new Ve),viewMatrix:new J(new Ve),matrixWorld:new J(new Ve),cameraFar:new J(0),pointSize:new J(0),magnitudeRange:new J(new de(-2,8)),intensity:new J(i??r),...o.uniforms},defines:{PERSPECTIVE_CAMERA:"1"}}),this.pointSize=t,this.background=a,this.ground=s}onBeforeRender(e,t,i,r,a,s){super.onBeforeRender(e,t,i,r,a,s);const o=this.uniforms;o.projectionMatrix.value.copy(i.projectionMatrix),o.modelViewMatrix.value.copy(i.modelViewMatrix),o.viewMatrix.value.copy(i.matrixWorldInverse),o.matrixWorld.value.copy(a.matrixWorld),o.cameraFar.value=i.far,o.pointSize.value=this.pointSize*e.getPixelRatio();const l=i.isPerspectiveCamera===!0;this.defines.PERSPECTIVE_CAMERA!=null!==l&&(l?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}get magnitudeRange(){return this.uniforms.magnitudeRange.value}get radianceScale(){return this.intensity}set radianceScale(e){this.intensity=e}get intensity(){return this.uniforms.intensity.value}set intensity(e){this.uniforms.intensity.value=e}};s9([pn("BACKGROUND")],o9.prototype,"background");s9([pn("GROUND")],o9.prototype,"ground");const UA=Me.createContext({}),Vie=({ref:n,textures:e,ellipsoid:t=ih.WGS84,correctAltitude:i=!0,ground:r=!0,date:a,children:s})=>{const o=Me.useRef({sunDirection:new L,moonDirection:new L,worldToECEFMatrix:new Ve,inertialToECEFMatrix:new Ve,overlay:null,shadow:null,shadowLength:null,lightingMask:null}),l=Ni(({gl:T})=>T),h=Me.useMemo(()=>typeof e=="string"?new a9().setType(l).load(e):void 0,[e,l]);Me.useEffect(()=>{if(h!=null)return()=>{for(const T of Object.values(h))T==null||T.dispose()}},[h]);const f=Me.useMemo(()=>e==null?new Nie(l):void 0,[e,l]);Me.useEffect(()=>{if(f!=null)return f.update().catch(T=>{console.error(T)}),()=>{f.dispose()}},[f]);const d=(f==null?void 0:f.textures)??(typeof e=="string"?h:e),p=Me.useMemo(()=>({textures:d,ellipsoid:t,correctAltitude:i,ground:r,transientStates:o.current}),[d,t,i,r]),g=Me.useMemo(()=>{const{sunDirection:T,moonDirection:y,inertialToECEFMatrix:v}=o.current;return S=>{xie(S,v),yie(S,T).applyMatrix4(v),Sie(S,y).applyMatrix4(v)}},[]),_=a!=null&&!isNaN(+a)?+a:void 0;return Me.useEffect(()=>{_!=null&&g(_)},[_,g]),Me.useImperativeHandle(n,()=>({...o.current,textures:d,updateByDate:g}),[d,g]),Mt.jsx(UA.Provider,{value:p,children:s})};function l9(n){const{irradianceTexture:e,scatteringTexture:t,transmittanceTexture:i,singleMieScatteringTexture:r,higherOrderScatteringTexture:a,ellipsoid:s,correctAltitude:o,sunDirection:l,sunAngularRadius:h,ground:f,renderTargetCount:d,...p}=n;return[{irradianceTexture:e,scatteringTexture:t,transmittanceTexture:i,singleMieScatteringTexture:r,higherOrderScatteringTexture:a,ellipsoid:s,correctAltitude:o,sunDirection:l,sunAngularRadius:h,ground:f,renderTargetCount:d},p]}function kie(n){const e=Me.useMemo(()=>typeof n=="string"?new FP().load(n):void 0,[n]);return Me.useEffect(()=>{if(e!=null)return()=>{e.dispose()}},[e]),(typeof n=="string"?e:n)??null}const Wie=({ref:n,stbnTexture:e=dP,...t})=>{const{textures:i,transientStates:r,...a}=Me.useContext(UA),[s,{blendFunction:o,...l}]=l9({...qP,...a,...i,...t}),h=Me.useContext(vA),{normalPass:f,camera:d}=h,p="geometryPass"in h&&h.geometryPass instanceof gA&&"geometryTexture"in h.geometryPass&&h.geometryPass.geometryTexture instanceof Nn?h.geometryPass.geometryTexture:void 0,g=Me.useMemo(()=>new Hr(void 0,{blendFunction:o}),[o]);Me.useEffect(()=>()=>{g.dispose()},[g]);const[_,T]=Me.useState(!1);fl(()=>{r!=null&&(g.sunDirection.copy(r.sunDirection),g.moonDirection.copy(r.moonDirection),g.worldToECEFMatrix.copy(r.worldToECEFMatrix),g.overlay=r.overlay,g.shadow=r.shadow,g.shadowLength=r.shadowLength,g.lightingMask=r.lightingMask,!_&&g.shadow!=null&&T(!0))});const y=kie(_?e:void 0);return Mt.jsx("primitive",{ref:n,object:g,mainCamera:d,normalBuffer:p??(f==null?void 0:f.texture)??null,...s,...l,stbnTexture:y,octEncodedNormal:p!=null})};function Xie(n){return e=>{for(const t of n)dM(t,e)}}function Yie(n){return e=>{const t=[];for(const i of n){const r=dM(i,e),a=typeof r=="function";t.push(a?r:()=>dM(i,null))}return()=>{for(const i of t)i()}}}function dM(n,e){if(typeof n=="function")return n(e);n&&(n.current=e)}parseInt(Me.version.split(".")[0],10)>=19;new a9;const kO=Ay,WO=Qs,XO=Js;class wy{constructor(e=0,t=0,i=0,r=0){this.expTerm=e,this.exponent=t,this.linearTerm=i,this.constantTerm=r}set(e=0,t=0,i=0,r=0){return this.expTerm=e,this.exponent=t,this.linearTerm=i,this.constantTerm=r,this}clone(){return new wy(this.expTerm,this.exponent,this.linearTerm,this.constantTerm)}copy(e){return this.expTerm=e.expTerm,this.exponent=e.exponent,this.linearTerm=e.linearTerm,this.constantTerm=e.constantTerm,this}}const qie=["channel","altitude","height","densityScale","shapeAmount","shapeDetailAmount","weatherExponent","shapeAlteringBias","coverageFilterWidth","shadow","densityProfile"];function jie(n,e){if(e!=null)for(const t of qie){const i=e[t];i!=null&&(n[t]instanceof wy?n[t].copy(i):n[t]=i)}}const pM=class c9{constructor(e){this.channel="r",this.altitude=0,this.height=0,this.densityScale=.2,this.shapeAmount=1,this.shapeDetailAmount=1,this.weatherExponent=1,this.shapeAlteringBias=.35,this.coverageFilterWidth=.6,this.densityProfile=new wy(0,0,.75,.25),this.shadow=!1,this.set(e)}set(e){return jie(this,e),this}clone(){return new c9(this)}copy(e){return this.channel=e.channel,this.altitude=e.altitude,this.height=e.height,this.densityScale=e.densityScale,this.shapeAmount=e.shapeAmount,this.shapeDetailAmount=e.shapeDetailAmount,this.weatherExponent=e.weatherExponent,this.shapeAlteringBias=e.shapeAlteringBias,this.coverageFilterWidth=e.coverageFilterWidth,this.densityProfile.copy(e.densityProfile),this.shadow=e.shadow,this}};pM.DEFAULT=new pM;let Ms=pM;const Rf=Array.from({length:8},()=>({value:0,flag:0})),om=Array.from({length:3},()=>({min:0,max:0}));function Zie(n,e){return n.value!==e.value?n.value-e.value:n.flag-e.flag}const mM=class u9 extends Array{constructor(e){super(new Ms(e==null?void 0:e[0]),new Ms(e==null?void 0:e[1]),new Ms(e==null?void 0:e[2]),new Ms(e==null?void 0:e[3]))}set(e){return this[0].set(e==null?void 0:e[0]),this[1].set(e==null?void 0:e[1]),this[2].set(e==null?void 0:e[2]),this[3].set(e==null?void 0:e[3]),this}reset(){return this[0].copy(Ms.DEFAULT),this[1].copy(Ms.DEFAULT),this[2].copy(Ms.DEFAULT),this[3].copy(Ms.DEFAULT),this}clone(){return new u9(this)}copy(e){return this[0].copy(e[0]),this[1].copy(e[1]),this[2].copy(e[2]),this[3].copy(e[3]),this}get localWeatherChannels(){return this[0].channel+this[1].channel+this[2].channel+this[3].channel}packValues(e,t){return t.set(this[0][e],this[1][e],this[2][e],this[3][e])}packSums(e,t,i){return i.set(this[0][e]+this[0][t],this[1][e]+this[1][t],this[2][e]+this[2][t],this[3][e]+this[3][t])}packDensityProfiles(e,t){return t.set(this[0].densityProfile[e],this[1].densityProfile[e],this[2].densityProfile[e],this[3].densityProfile[e])}packIntervalHeights(e,t){for(let s=0;s<4;++s){const o=this[s];let l=Rf[s];l.value=o.altitude,l.flag=0,l=Rf[s+4],l.value=o.altitude+o.height,l.flag=1}Rf.sort(Zie);let i=0,r=0;for(let s=0;s<Rf.length;++s){const{value:o,flag:l}=Rf[s];if(r===0&&s>0){const h=om[i++];h.min=Rf[s-1].value,h.max=o}r+=l===0?1:-1}for(;i<3;++i){const s=om[i];s.min=0,s.max=0}let a=om[0];e.x=a.min,t.x=a.max,a=om[1],e.y=a.min,t.y=a.max,a=om[2],e.z=a.min,t.z=a.max}};mM.DEFAULT=new mM([{channel:"r",altitude:750,height:650,densityScale:.2,shapeAmount:1,shapeDetailAmount:1,weatherExponent:1,shapeAlteringBias:.35,coverageFilterWidth:.6,shadow:!0},{channel:"g",altitude:1e3,height:1200,densityScale:.2,shapeAmount:1,shapeDetailAmount:1,weatherExponent:1,shapeAlteringBias:.35,coverageFilterWidth:.6,shadow:!0},{channel:"b",altitude:7500,height:500,densityScale:.003,shapeAmount:.4,shapeDetailAmount:0,weatherExponent:1,shapeAlteringBias:.35,coverageFilterWidth:.5},{channel:"a"}]);let d1=mM;var Kie="Invariant failed";function nc(n,e){if(!n)throw new Error(Kie)}class b0{constructor(e,t){this.near=[new L,new L,new L,new L],this.far=[new L,new L,new L,new L],e!=null&&t!=null&&this.setFromCamera(e,t)}clone(){return new b0().copy(this)}copy(e){for(let t=0;t<4;++t)this.near[t].copy(e.near[t]),this.far[t].copy(e.far[t]);return this}setFromCamera(e,t){const i=e.isOrthographicCamera===!0,r=e.projectionMatrixInverse;this.near[0].set(1,1,-1),this.near[1].set(1,-1,-1),this.near[2].set(-1,-1,-1),this.near[3].set(-1,1,-1);for(let a=0;a<4;++a)this.near[a].applyMatrix4(r);this.far[0].set(1,1,1),this.far[1].set(1,-1,1),this.far[2].set(-1,-1,1),this.far[3].set(-1,1,1);for(let a=0;a<4;++a){const s=this.far[a];s.applyMatrix4(r);const o=Math.abs(s.z);i?s.z*=Math.min(t/o,1):s.multiplyScalar(Math.min(t/o,1))}return this}split(e,t=[]){for(let i=0;i<e.length;++i){const r=t[i]??(t[i]=new b0);if(i===0)for(let a=0;a<4;++a)r.near[a].copy(this.near[a]);else for(let a=0;a<4;++a)r.near[a].lerpVectors(this.near[a],this.far[a],e[i-1]);if(i===e.length-1)for(let a=0;a<4;++a)r.far[a].copy(this.far[a]);else for(let a=0;a<4;++a)r.far[a].lerpVectors(this.near[a],this.far[a],e[i])}return t.length=e.length,t}applyMatrix4(e){for(let t=0;t<4;++t)this.near[t].applyMatrix4(e),this.far[t].applyMatrix4(e);return this}}const Qie={uniform:(n,e,t,i,r=[])=>{for(let a=0;a<n;++a)r[a]=(e+(t-e)*(a+1)/n)/t;return r.length=n,r},logarithmic:(n,e,t,i,r=[])=>{for(let a=0;a<n;++a)r[a]=e*(t/e)**((a+1)/n)/t;return r.length=n,r},practical:(n,e,t,i=.5,r=[])=>{for(let a=0;a<n;++a){const s=(e+(t-e)*(a+1)/n)/t,o=e*(t/e)**((a+1)/n)/t;r[a]=PP(s,o,i)}return r.length=n,r}};function Jie(n,e,t,i,r,a=[]){return Qie[n](e,t,i,r,a)}const YO=new L,qO=new L,$ie=new Ve,jO=new Ve,ere=new b0,tre=new tr,nre={maxFar:null,farScale:1,splitMode:"practical",splitLambda:.5,margin:0,fade:!0};class ire{constructor(e){this.cascades=[],this.mapSize=new de,this.cameraFrustum=new b0,this.frusta=[],this.splits=[],this._far=0;const{cascadeCount:t,mapSize:i,maxFar:r,farScale:a,splitMode:s,splitLambda:o,margin:l,fade:h}={...nre,...e};this.cascadeCount=t,this.mapSize.copy(i),this.maxFar=r,this.farScale=a,this.splitMode=s,this.splitLambda=o,this.margin=l,this.fade=h}get cascadeCount(){return this.cascades.length}set cascadeCount(e){var t;if(e!==this.cascadeCount){for(let i=0;i<e;++i)(t=this.cascades)[i]??(t[i]={interval:new de,matrix:new Ve,inverseMatrix:new Ve,projectionMatrix:new Ve,inverseProjectionMatrix:new Ve,viewMatrix:new Ve,inverseViewMatrix:new Ve});this.cascades.length=e}}get far(){return this._far}updateIntervals(e){const t=this.cascadeCount,i=this.splits,r=this.far;Jie(this.splitMode,t,e.near,r,this.splitLambda,i),this.cameraFrustum.setFromCamera(e,r),this.cameraFrustum.split(i,this.frusta);const a=this.cascades;for(let s=0;s<t;++s)a[s].interval.set(i[s-1]??0,i[s]??0)}getFrustumRadius(e,t){const i=t.near,r=t.far;let a=Math.max(r[0].distanceTo(r[2]),r[0].distanceTo(i[2]));if(this.fade){const s=e.near,o=this.far,l=r[0].z/(o-s);a+=.25*l**2*(o-s)}return a*.5}updateMatrices(e,t,i=1){const r=$ie.lookAt(YO.setScalar(0),qO.copy(t).multiplyScalar(-1),Wt.DEFAULT_UP),a=jO.multiplyMatrices(jO.copy(r).invert(),e.matrixWorld),s=this.frusta,o=this.cascades;nc(s.length===o.length);const l=this.margin,h=this.mapSize;for(let f=0;f<s.length;++f){const d=s[f],p=o[f],g=this.getFrustumRadius(e,s[f]),_=-g,T=g,y=g,v=-g;p.projectionMatrix.makeOrthographic(_,T,y,v,-this.margin,g*2+this.margin);const{near:S,far:E}=ere.copy(d).applyMatrix4(a),b=tre.makeEmpty();for(let O=0;O<4;O++)b.expandByPoint(S[O]),b.expandByPoint(E[O]);const N=b.getCenter(YO);N.z=b.max.z+l;const R=(T-_)/h.width,I=(y-v)/h.height;N.x=Math.round(N.x/R)*R,N.y=Math.round(N.y/I)*I,N.applyMatrix4(r);const U=qO.copy(t).multiplyScalar(i).add(N);p.inverseViewMatrix.lookAt(N,U,Wt.DEFAULT_UP).setPosition(U)}}update(e,t,i){this._far=this.maxFar!=null?Math.min(this.maxFar,e.far*this.farScale):e.far*this.farScale,this.updateIntervals(e),this.updateMatrices(e,t,i);const r=this.cascades,a=this.cascadeCount;for(let s=0;s<a;++s){const{matrix:o,inverseMatrix:l,projectionMatrix:h,inverseProjectionMatrix:f,viewMatrix:d,inverseViewMatrix:p}=r[s];f.copy(h).invert(),d.copy(p).invert(),o.copy(h).multiply(d),l.copy(p).multiply(f)}}}const ZO=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5],h9=ZO.reduce((n,e,t)=>{const i=new de;for(let r=0;r<16;++r)if(ZO[r]===t){i.set((r%4+.5)/4,(Math.floor(r/4)+.5)/4);break}return[...n,i]},[]),rre={resolutionScale:1,lightShafts:!0,shapeDetail:!0,turbulence:!0,haze:!0,clouds:{multiScatteringOctaves:8,accurateSunSkyLight:!0,accuratePhaseFunction:!1,maxIterationCount:500,minStepSize:50,maxStepSize:1e3,maxRayDistance:2e5,perspectiveStepScale:1.01,minDensity:1e-5,minExtinction:1e-5,minTransmittance:.01,maxIterationCountToGround:3,maxIterationCountToSun:2,minSecondaryStepSize:100,secondaryStepScale:2,maxShadowLengthIterationCount:500,minShadowLengthStepSize:50,maxShadowLengthRayDistance:2e5},shadow:{cascadeCount:3,mapSize:new de(512,512),maxIterationCount:50,minStepSize:100,maxStepSize:1e3,minDensity:1e-5,minExtinction:1e-5,minTransmittance:1e-4}},It=rre,are={low:{...It,lightShafts:!1,shapeDetail:!1,turbulence:!1,clouds:{...It.clouds,accurateSunSkyLight:!1,maxIterationCount:200,minStepSize:100,maxRayDistance:1e5,minDensity:1e-4,minExtinction:1e-4,minTransmittance:.1,maxIterationCountToGround:0,maxIterationCountToSun:1},shadow:{...It.shadow,maxIterationCount:25,minDensity:1e-4,minExtinction:1e-4,minTransmittance:.01,cascadeCount:2,mapSize:new de(256,256)}},medium:{...It,lightShafts:!1,turbulence:!1,clouds:{...It.clouds,minDensity:1e-4,minExtinction:1e-4,accurateSunSkyLight:!1,maxIterationCountToSun:2,maxIterationCountToGround:1},shadow:{...It.shadow,minDensity:1e-4,minExtinction:1e-4,mapSize:new de(256,256)}},high:It,ultra:{...It,clouds:{...It.clouds,minStepSize:10},shadow:{...It.shadow,mapSize:new de(1024,1024)}}},sre=`precision highp float;
precision highp sampler3D;
precision highp sampler2DArray;

#include <common>
#include <packing>

#include "core/depth"
#include "core/math"
#include "core/turbo"
#include "core/generators"
#include "core/raySphereIntersection"
#include "core/cascadedShadowMaps"
#include "core/interleavedGradientNoise"
#include "core/vogelDisk"

#include "atmosphere/bruneton/definitions"

uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;

uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;

#include "atmosphere/bruneton/common"
#include "atmosphere/bruneton/runtime"

#include "types"
#include "parameters"
#include "clouds"

#if !defined(RECIPROCAL_PI4)
#define RECIPROCAL_PI4 0.07957747154594767
#endif // !defined(RECIPROCAL_PI4)

uniform sampler2D depthBuffer;
uniform mat4 viewMatrix;
uniform mat4 reprojectionMatrix;
uniform mat4 viewReprojectionMatrix;
uniform float cameraNear;
uniform float cameraFar;
uniform float cameraHeight;
uniform vec2 temporalJitter;
uniform vec2 targetUvScale;
uniform float mipLevelScale;

// Scattering
const vec2 scatterAnisotropy = vec2(SCATTER_ANISOTROPY_1, SCATTER_ANISOTROPY_2);
const float scatterAnisotropyMix = SCATTER_ANISOTROPY_MIX;
uniform float skyLightScale;
uniform float groundBounceScale;
uniform float powderScale;
uniform float powderExponent;

// Primary raymarch
uniform int maxIterationCount;
uniform float minStepSize;
uniform float maxStepSize;
uniform float maxRayDistance;
uniform float perspectiveStepScale;

// Secondary raymarch
uniform int maxIterationCountToSun;
uniform int maxIterationCountToGround;
uniform float minSecondaryStepSize;
uniform float secondaryStepScale;

// Beer shadow map
uniform sampler2DArray shadowBuffer;
uniform vec2 shadowTexelSize;
uniform vec2 shadowIntervals[SHADOW_CASCADE_COUNT];
uniform mat4 shadowMatrices[SHADOW_CASCADE_COUNT];
uniform float shadowFar;
uniform float maxShadowFilterRadius;

// Shadow length
#ifdef SHADOW_LENGTH
uniform int maxShadowLengthIterationCount;
uniform float minShadowLengthStepSize;
uniform float maxShadowLengthRayDistance;
#endif // SHADOW_LENGTH

in vec2 vUv;
in vec3 vCameraPosition;
in vec3 vCameraDirection; // Direction to the center of screen
in vec3 vRayDirection; // Direction to the texel
in vec3 vViewPosition;
in GroundIrradiance vGroundIrradiance;
in CloudsIrradiance vCloudsIrradiance;

layout(location = 0) out vec4 outputColor;
layout(location = 1) out vec3 outputDepthVelocity;
#ifdef SHADOW_LENGTH
layout(location = 2) out float outputShadowLength;
#endif // SHADOW_LENGTH

float readDepth(const vec2 uv) {
  #if DEPTH_PACKING == 3201
  return unpackRGBAToDepth(texture(depthBuffer, uv));
  #else // DEPTH_PACKING == 3201
  return texture(depthBuffer, uv).r;
  #endif // DEPTH_PACKING == 3201
}

float getViewZ(const float depth) {
  #ifdef PERSPECTIVE_CAMERA
  return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
  #else // PERSPECTIVE_CAMERA
  return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
  #endif // PERSPECTIVE_CAMERA
}

vec3 ecefToWorld(const vec3 positionECEF) {
  return (ecefToWorldMatrix * vec4(positionECEF - altitudeCorrection, 1.0)).xyz;
}

vec2 getShadowUv(const vec3 worldPosition, const int cascadeIndex) {
  vec4 clip = shadowMatrices[cascadeIndex] * vec4(worldPosition, 1.0);
  clip /= clip.w;
  return clip.xy * 0.5 + 0.5;
}

float getDistanceToShadowTop(const vec3 rayPosition) {
  // Distance to the top of the shadows along the sun direction, which matches
  // the ray origin of BSM.
  return raySphereSecondIntersection(
    rayPosition,
    sunDirection,
    vec3(0.0),
    bottomRadius + shadowTopHeight
  );
}

#ifdef DEBUG_SHOW_CASCADES

const vec3 cascadeColors[4] = vec3[4](
  vec3(1.0, 0.0, 0.0),
  vec3(0.0, 1.0, 0.0),
  vec3(0.0, 0.0, 1.0),
  vec3(1.0, 1.0, 0.0)
);

vec3 getCascadeColor(const vec3 rayPosition) {
  vec3 worldPosition = ecefToWorld(rayPosition);
  int cascadeIndex = getCascadeIndex(
    viewMatrix,
    worldPosition,
    shadowIntervals,
    cameraNear,
    shadowFar
  );
  vec2 uv = getShadowUv(worldPosition, cascadeIndex);
  if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
    return vec3(1.0);
  }
  return cascadeColors[cascadeIndex];
}

vec3 getFadedCascadeColor(const vec3 rayPosition, const float jitter) {
  vec3 worldPosition = ecefToWorld(rayPosition);
  int cascadeIndex = getFadedCascadeIndex(
    viewMatrix,
    worldPosition,
    shadowIntervals,
    cameraNear,
    shadowFar,
    jitter
  );
  return cascadeIndex >= 0
    ? cascadeColors[cascadeIndex]
    : vec3(1.0);
}

#endif // DEBUG_SHOW_CASCADES

float readShadowOpticalDepth(
  const vec2 uv,
  const float distanceToTop,
  const float distanceOffset,
  const int cascadeIndex
) {
  // r: frontDepth, g: meanExtinction, b: maxOpticalDepth, a: maxOpticalDepthTail
  // Also see the discussion here: https://x.com/shotamatsuda/status/1885322308908442106
  vec4 shadow = texture(shadowBuffer, vec3(uv, float(cascadeIndex)));
  float distanceToFront = max(0.0, distanceToTop - distanceOffset - shadow.r);
  return min(shadow.b + shadow.a, shadow.g * distanceToFront);
}

float sampleShadowOpticalDepthPCF(
  const vec3 worldPosition,
  const float distanceToTop,
  const float distanceOffset,
  const float radius,
  const int cascadeIndex
) {
  vec2 uv = getShadowUv(worldPosition, cascadeIndex);
  if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {
    return 0.0;
  }
  if (radius < 0.1) {
    return readShadowOpticalDepth(uv, distanceToTop, distanceOffset, cascadeIndex);
  }
  float sum = 0.0;
  vec2 offset;
  #pragma unroll_loop_start
  for (int i = 0; i < 16; ++i) {
    #if UNROLLED_LOOP_INDEX < SHADOW_SAMPLE_COUNT
    offset = vogelDisk(
      UNROLLED_LOOP_INDEX,
      SHADOW_SAMPLE_COUNT,
      interleavedGradientNoise(gl_FragCoord.xy + temporalJitter * resolution) * PI2
    );
    sum += readShadowOpticalDepth(
      uv + offset * radius * shadowTexelSize,
      distanceToTop,
      distanceOffset,
      cascadeIndex
    );
    #endif // UNROLLED_LOOP_INDEX < SHADOW_SAMPLE_COUNT
  }
  #pragma unroll_loop_end
  return sum / float(SHADOW_SAMPLE_COUNT);
}

float sampleShadowOpticalDepth(
  const vec3 rayPosition,
  const float distanceOffset,
  const float radius,
  const float jitter
) {
  float distanceToTop = getDistanceToShadowTop(rayPosition);
  if (distanceToTop <= 0.0) {
    return 0.0;
  }
  vec3 worldPosition = ecefToWorld(rayPosition);
  int cascadeIndex = getFadedCascadeIndex(
    viewMatrix,
    worldPosition,
    shadowIntervals,
    cameraNear,
    shadowFar,
    jitter
  );
  return cascadeIndex >= 0
    ? sampleShadowOpticalDepthPCF(
      worldPosition,
      distanceToTop,
      distanceOffset,
      radius,
      cascadeIndex
    )
    : 0.0;
}

#ifdef DEBUG_SHOW_SHADOW_MAP
vec4 getCascadedShadowMaps(vec2 uv) {
  vec4 coord = vec4(vUv, vUv - 0.5) * 2.0;
  vec4 shadow = vec4(0.0);
  if (uv.y > 0.5) {
    if (uv.x < 0.5) {
      shadow = texture(shadowBuffer, vec3(coord.xw, 0.0));
    } else {
      #if SHADOW_CASCADE_COUNT > 1
      shadow = texture(shadowBuffer, vec3(coord.zw, 1.0));
      #endif // SHADOW_CASCADE_COUNT > 1
    }
  } else {
    if (uv.x < 0.5) {
      #if SHADOW_CASCADE_COUNT > 2
      shadow = texture(shadowBuffer, vec3(coord.xy, 2.0));
      #endif // SHADOW_CASCADE_COUNT > 2
    } else {
      #if SHADOW_CASCADE_COUNT > 3
      shadow = texture(shadowBuffer, vec3(coord.zy, 3.0));
      #endif // SHADOW_CASCADE_COUNT > 3
    }
  }

  #if !defined(DEBUG_SHOW_SHADOW_MAP_TYPE)
  #define DEBUG_SHOW_SHADOW_MAP_TYPE 0
  #endif // !defined(DEBUG_SHOW_SHADOW_MAP_TYPE

  const float frontDepthScale = 1e-5;
  const float meanExtinctionScale = 10.0;
  const float maxOpticalDepthScale = 0.01;
  vec3 color;
  #if DEBUG_SHOW_SHADOW_MAP_TYPE == 1
  color = vec3(shadow.r * frontDepthScale);
  #elif DEBUG_SHOW_SHADOW_MAP_TYPE == 2
  color = vec3(shadow.g * meanExtinctionScale);
  #elif DEBUG_SHOW_SHADOW_MAP_TYPE == 3
  color = vec3((shadow.b + shadow.a) * maxOpticalDepthScale);
  #else // DEBUG_SHOW_SHADOW_MAP_TYPE
  color =
    (shadow.rgb + vec3(0.0, 0.0, shadow.a)) *
    vec3(frontDepthScale, meanExtinctionScale, maxOpticalDepthScale);
  #endif // DEBUG_SHOW_SHADOW_MAP_TYPE
  return vec4(color, 1.0);
}
#endif // DEBUG_SHOW_SHADOW_MAP

vec2 henyeyGreenstein(const vec2 g, const float cosTheta) {
  vec2 g2 = g * g;
  // prettier-ignore
  return RECIPROCAL_PI4 *
    ((1.0 - g2) / max(vec2(1e-7), pow(1.0 + g2 - 2.0 * g * cosTheta, vec2(1.5))));
}

#ifdef ACCURATE_PHASE_FUNCTION

float draine(float u, float g, float a) {
  float g2 = g * g;
  // prettier-ignore
  return (1.0 - g2) *
    (1.0 + a * u * u) /
    (4.0 * (1.0 + a * (1.0 + 2.0 * g2) / 3.0) * PI * pow(1.0 + g2 - 2.0 * g * u, 1.5));
}

// Numerically-fitted large particles (d=10) phase function It won't be
// plausible without a more precise multiple scattering.
// Reference: https://research.nvidia.com/labs/rtr/approximate-mie/
float phaseFunction(const float cosTheta, const float attenuation) {
  const float gHG = 0.988176691700256; // exp(-0.0990567/(d-1.67154))
  const float gD = 0.5556712547839497; // exp(-2.20679/(d+3.91029) - 0.428934)
  const float alpha = 21.995520856274638; // exp(3.62489 - 8.29288/(d+5.52825))
  const float weight = 0.4819554318404214; // exp(-0.599085/(d-0.641583)-0.665888)
  return mix(
    henyeyGreenstein(vec2(gHG) * attenuation, cosTheta).x,
    draine(cosTheta, gD * attenuation, alpha),
    weight
  );
}

#else // ACCURATE_PHASE_FUNCTION

float phaseFunction(const float cosTheta, const float attenuation) {
  const vec2 g = scatterAnisotropy;
  const vec2 weights = vec2(1.0 - scatterAnisotropyMix, scatterAnisotropyMix);
  // A similar approximation is described in the Frostbite's paper, where phase
  // angle is attenuated instead of anisotropy.
  return dot(henyeyGreenstein(g * attenuation, cosTheta), weights);
}

#endif // ACCURATE_PHASE_FUNCTION

float phaseFunction(const float cosTheta) {
  return phaseFunction(cosTheta, 1.0);
}

float marchOpticalDepth(
  const vec3 rayOrigin,
  const vec3 rayDirection,
  const int maxIterationCount,
  const float mipLevel,
  const float jitter,
  out float rayDistance
) {
  int iterationCount = int(
    max(0.0, remap(mipLevel, 0.0, 1.0, float(maxIterationCount + 1), 1.0) - jitter)
  );
  if (iterationCount == 0) {
    // Fudge factor to approximate the mean optical depth.
    // TODO: Remove it.
    return 0.5;
  }
  float stepSize = minSecondaryStepSize / float(iterationCount);
  float nextDistance = stepSize * jitter;
  float opticalDepth = 0.0;
  for (int i = 0; i < iterationCount; ++i) {
    rayDistance = nextDistance;
    vec3 position = rayDistance * rayDirection + rayOrigin;
    vec2 uv = getGlobeUv(position);
    float height = length(position) - bottomRadius;
    WeatherSample weather = sampleWeather(uv, height, mipLevel);
    MediaSample media = sampleMedia(weather, position, uv, mipLevel, jitter);
    opticalDepth += media.extinction * stepSize;
    nextDistance += stepSize;
    stepSize *= secondaryStepScale;
  }
  return opticalDepth;
}

float marchOpticalDepth(
  const vec3 rayOrigin,
  const vec3 rayDirection,
  const int maxIterationCount,
  const float mipLevel,
  const float jitter
) {
  float rayDistance;
  return marchOpticalDepth(
    rayOrigin,
    rayDirection,
    maxIterationCount,
    mipLevel,
    jitter,
    rayDistance
  );
}

float approximateMultipleScattering(const float opticalDepth, const float cosTheta) {
  // Multiple scattering approximation
  // See: https://fpsunflower.github.io/ckulla/data/oz_volumes.pdf
  // a: attenuation, b: contribution, c: phase attenuation
  vec3 coeffs = vec3(1.0); // [a, b, c]
  const vec3 attenuation = vec3(0.5, 0.5, 0.5); // Should satisfy a <= b
  float scattering = 0.0;
  float beerLambert;
  #pragma unroll_loop_start
  for (int i = 0; i < 12; ++i) {
    #if UNROLLED_LOOP_INDEX < MULTI_SCATTERING_OCTAVES
    beerLambert = exp(-opticalDepth * coeffs.y);
    scattering += coeffs.x * beerLambert * phaseFunction(cosTheta, coeffs.z);
    coeffs *= attenuation;
    #endif // UNROLLED_LOOP_INDEX < MULTI_SCATTERING_OCTAVES
  }
  #pragma unroll_loop_end
  return scattering;
}

// TODO: Construct spherical harmonics of degree 2 using 2 sample points
// positioned near the horizon occlusion points on the sun direction plane.
vec3 getGroundSunSkyIrradiance(
  const vec3 position,
  const vec3 surfaceNormal,
  const float height,
  out vec3 skyIrradiance
) {
  #ifdef ACCURATE_SUN_SKY_LIGHT
  return GetSunAndSkyIrradiance(
    (position - surfaceNormal * height) * METER_TO_LENGTH_UNIT,
    surfaceNormal,
    sunDirection,
    skyIrradiance
  );
  #else // ACCURATE_SUN_SKY_LIGHT
  skyIrradiance = vGroundIrradiance.sky;
  return vGroundIrradiance.sun;
  #endif // ACCURATE_SUN_SKY_LIGHT
}

vec3 getCloudsSunSkyIrradiance(const vec3 position, const float height, out vec3 skyIrradiance) {
  #ifdef ACCURATE_SUN_SKY_LIGHT
  return GetSunAndSkyScalarIrradiance(position * METER_TO_LENGTH_UNIT, sunDirection, skyIrradiance);
  #else // ACCURATE_SUN_SKY_LIGHT
  float alpha = remapClamped(height, minHeight, maxHeight);
  skyIrradiance = mix(vCloudsIrradiance.minSky, vCloudsIrradiance.maxSky, alpha);
  return mix(vCloudsIrradiance.minSun, vCloudsIrradiance.maxSun, alpha);
  #endif // ACCURATE_SUN_SKY_LIGHT
}

#ifdef GROUND_BOUNCE
vec3 approximateRadianceFromGround(
  const vec3 position,
  const vec3 surfaceNormal,
  const float height,
  const float mipLevel,
  const float jitter
) {
  float opticalDepthToGround = marchOpticalDepth(
    position,
    -surfaceNormal,
    maxIterationCountToGround,
    mipLevel,
    jitter
  );
  vec3 skyIrradiance;
  vec3 sunIrradiance = getGroundSunSkyIrradiance(position, surfaceNormal, height, skyIrradiance);
  const float groundAlbedo = 0.3;
  vec3 groundIrradiance = skyIrradiance + (1.0 - coverage) * sunIrradiance;
  vec3 bouncedRadiance = groundAlbedo * RECIPROCAL_PI * groundIrradiance;
  return bouncedRadiance * exp(-opticalDepthToGround);
}
#endif // GROUND_BOUNCE

vec4 marchClouds(
  const vec3 rayOrigin,
  const vec3 rayDirection,
  const vec2 rayNearFar,
  const float cosTheta,
  const float jitter,
  const float rayStartTexelsPerPixel,
  out float frontDepth,
  out ivec3 sampleCount
) {
  vec3 radianceIntegral = vec3(0.0);
  float transmittanceIntegral = 1.0;
  float weightedDistanceSum = 0.0;
  float transmittanceSum = 0.0;

  float maxRayDistance = rayNearFar.y - rayNearFar.x;
  float stepSize = minStepSize + (perspectiveStepScale - 1.0) * rayNearFar.x;
  // I don't understand why spatial aliasing remains unless doubling the jitter.
  float rayDistance = stepSize * jitter * 2.0;

  for (int i = 0; i < maxIterationCount; ++i) {
    if (rayDistance > maxRayDistance) {
      break; // Termination
    }

    vec3 position = rayDistance * rayDirection + rayOrigin;
    float height = length(position) - bottomRadius;
    float mipLevel = log2(max(1.0, rayStartTexelsPerPixel + rayDistance * 1e-5));

    #if !defined(DEBUG_MARCH_INTERVALS)
    if (insideLayerIntervals(height)) {
      stepSize *= perspectiveStepScale;
      rayDistance += mix(stepSize, maxStepSize, min(1.0, mipLevel));
      continue;
    }
    #endif // !defined(DEBUG_MARCH_INTERVALS)

    // Sample rough weather.
    vec2 uv = getGlobeUv(position);
    WeatherSample weather = sampleWeather(uv, height, mipLevel);

    #ifdef DEBUG_SHOW_SAMPLE_COUNT
    ++sampleCount.x;
    #endif // DEBUG_SHOW_SAMPLE_COUNT

    if (!any(greaterThan(weather.density, vec4(minDensity)))) {
      // Step longer in empty space.
      // TODO: This produces banding artifacts.
      // Possible improvement: Binary search refinement
      stepSize *= perspectiveStepScale;
      rayDistance += mix(stepSize, maxStepSize, min(1.0, mipLevel));
      continue;
    }

    // Sample detailed participating media.
    MediaSample media = sampleMedia(weather, position, uv, mipLevel, jitter, sampleCount);

    if (media.extinction > minExtinction) {
      vec3 skyIrradiance;
      vec3 sunIrradiance = getCloudsSunSkyIrradiance(position, height, skyIrradiance);
      vec3 surfaceNormal = normalize(position);

      // March optical depth to the sun for finer details, which BSM lacks.
      float sunRayDistance = 0.0;
      float opticalDepth = marchOpticalDepth(
        position,
        sunDirection,
        maxIterationCountToSun,
        mipLevel,
        jitter,
        sunRayDistance
      );

      if (height < shadowTopHeight) {
        // Obtain the optical depth from BSM at the ray position.
        opticalDepth += sampleShadowOpticalDepth(
          position,
          // Take account of only positions further than the marched ray
          // distance.
          sunRayDistance,
          // Apply PCF only when the sun is close to the horizon.
          maxShadowFilterRadius * remapClamped(dot(sunDirection, surfaceNormal), 0.1, 0.0),
          jitter
        );
      }

      vec3 radiance = sunIrradiance * approximateMultipleScattering(opticalDepth, cosTheta);

      #ifdef GROUND_BOUNCE
      // Fudge factor for the irradiance from ground.
      if (height < shadowTopHeight && mipLevel < 0.5) {
        vec3 groundRadiance = approximateRadianceFromGround(
          position,
          surfaceNormal,
          height,
          mipLevel,
          jitter
        );
        radiance += groundRadiance * RECIPROCAL_PI4 * groundBounceScale;
      }
      #endif // GROUND_BOUNCE

      // Crude approximation of sky gradient. Better than none in the shadows.
      float skyGradient = dot(weather.heightFraction * 0.5 + 0.5, media.weight);
      radiance += skyIrradiance * RECIPROCAL_PI4 * skyGradient * skyLightScale;

      // Finally multiply by scattering.
      radiance *= media.scattering;

      #ifdef POWDER
      radiance *= 1.0 - powderScale * exp(-media.extinction * powderExponent);
      #endif // POWDER

      #ifdef DEBUG_SHOW_CASCADES
      if (height < shadowTopHeight) {
        radiance = 1e-3 * getFadedCascadeColor(position, jitter);
      }
      #endif // DEBUG_SHOW_CASCADES

      // Energy-conserving analytical integration of scattered light
      // See 5.6.3 in https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/s2016-pbs-frostbite-sky-clouds-new.pdf
      float transmittance = exp(-media.extinction * stepSize);
      float clampedExtinction = max(media.extinction, 1e-7);
      vec3 scatteringIntegral = (radiance - radiance * transmittance) / clampedExtinction;
      radianceIntegral += transmittanceIntegral * scatteringIntegral;
      transmittanceIntegral *= transmittance;

      // Aerial perspective affecting clouds
      // See 5.9.1 in https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/s2016-pbs-frostbite-sky-clouds-new.pdf
      weightedDistanceSum += rayDistance * transmittanceIntegral;
      transmittanceSum += transmittanceIntegral;
    }

    if (transmittanceIntegral <= minTransmittance) {
      break; // Early termination
    }

    // Take a shorter step because we've already hit the clouds.
    stepSize *= perspectiveStepScale;
    rayDistance += stepSize;
  }

  // The final product of 5.9.1 and we'll evaluate this in aerial perspective.
  frontDepth = transmittanceSum > 0.0 ? weightedDistanceSum / transmittanceSum : -1.0;

  return vec4(radianceIntegral, remapClamped(transmittanceIntegral, 1.0, minTransmittance));
}

#ifdef SHADOW_LENGTH

float marchShadowLength(
  const vec3 rayOrigin,
  const vec3 rayDirection,
  const vec2 rayNearFar,
  const float jitter
) {
  float shadowLength = 0.0;
  float maxRayDistance = rayNearFar.y - rayNearFar.x;
  float stepSize = minShadowLengthStepSize;
  float rayDistance = stepSize * jitter;
  const float attenuationFactor = 1.0 - 5e-4;
  float attenuation = 1.0;

  // TODO: This march is closed, and sample resolution can be much lower.
  // Refining the termination by binary search will make it much more efficient.
  for (int i = 0; i < maxShadowLengthIterationCount; ++i) {
    if (rayDistance > maxRayDistance) {
      break; // Termination
    }
    vec3 position = rayDistance * rayDirection + rayOrigin;
    float opticalDepth = sampleShadowOpticalDepth(position, 0.0, 0.0, jitter);
    shadowLength += (1.0 - exp(-opticalDepth)) * stepSize * attenuation;
    stepSize *= perspectiveStepScale;
    rayDistance += stepSize;
  }
  return shadowLength;
}

#endif // SHADOW_LENGTH

#ifdef HAZE

vec4 approximateHaze(
  const vec3 rayOrigin,
  const vec3 rayDirection,
  const float maxRayDistance,
  const float cosTheta,
  const float shadowLength
) {
  float modulation = remapClamped(coverage, 0.2, 0.4);
  if (cameraHeight * modulation < 0.0) {
    return vec4(0.0);
  }
  float density = modulation * hazeDensityScale * exp(-cameraHeight * hazeExponent);
  if (density < 1e-7) {
    return vec4(0.0); // Prevent artifact in views from space
  }

  // Blend two normals by the difference in angle so that normal near the
  // ground becomes that of the origin, and in the sky that of the horizon.
  vec3 normalAtOrigin = normalize(rayOrigin);
  vec3 normalAtHorizon = (rayOrigin - dot(rayOrigin, rayDirection) * rayDirection) / bottomRadius;
  float alpha = remapClamped(dot(normalAtOrigin, normalAtHorizon), 0.9, 1.0);
  vec3 normal = mix(normalAtOrigin, normalAtHorizon, alpha);

  // Analytical optical depth where density exponentially decreases with height.
  // Based on: https://iquilezles.org/articles/fog/
  float angle = max(dot(normal, rayDirection), 1e-5);
  float exponent = angle * hazeExponent;
  float linearTerm = density / hazeExponent / angle;

  // Derive the optical depths separately for with and without shadow length.
  float expTerm = 1.0 - exp(-maxRayDistance * exponent);
  float shadowExpTerm = 1.0 - exp(-min(maxRayDistance, shadowLength) * exponent);
  float opticalDepth = expTerm * linearTerm;
  float shadowOpticalDepth = max((expTerm - shadowExpTerm) * linearTerm, 0.0);
  float transmittance = saturate(1.0 - exp(-opticalDepth));
  float shadowTransmittance = saturate(1.0 - exp(-shadowOpticalDepth));

  vec3 skyIrradiance = vGroundIrradiance.sky;
  vec3 sunIrradiance = vGroundIrradiance.sun;
  vec3 inscatter = sunIrradiance * phaseFunction(cosTheta) * shadowTransmittance;
  inscatter += skyIrradiance * RECIPROCAL_PI4 * skyLightScale * transmittance;
  inscatter *= hazeScatteringCoefficient / (hazeAbsorptionCoefficient + hazeScatteringCoefficient);
  return vec4(inscatter, transmittance);
}

#endif // HAZE

void applyAerialPerspective(
  const vec3 cameraPosition,
  const vec3 frontPosition,
  const float shadowLength,
  inout vec4 color
) {
  vec3 transmittance;
  vec3 inscatter = GetSkyRadianceToPoint(
    cameraPosition * METER_TO_LENGTH_UNIT,
    frontPosition * METER_TO_LENGTH_UNIT,
    shadowLength * METER_TO_LENGTH_UNIT,
    sunDirection,
    transmittance
  );
  color.rgb = color.rgb * transmittance + inscatter * color.a;
}

bool rayIntersectsGround(const vec3 cameraPosition, const vec3 rayDirection) {
  float r = length(cameraPosition);
  float mu = dot(cameraPosition, rayDirection) / r;
  return mu < 0.0 && r * r * (mu * mu - 1.0) + bottomRadius * bottomRadius >= 0.0;
}

struct IntersectionResult {
  bool ground;
  vec4 first;
  vec4 second;
};

IntersectionResult getIntersections(const vec3 cameraPosition, const vec3 rayDirection) {
  IntersectionResult intersections;
  intersections.ground = rayIntersectsGround(cameraPosition, rayDirection);
  raySphereIntersections(
    cameraPosition,
    rayDirection,
    bottomRadius + vec4(0.0, minHeight, maxHeight, shadowTopHeight),
    intersections.first,
    intersections.second
  );
  return intersections;
}

vec2 getRayNearFar(const IntersectionResult intersections) {
  vec2 nearFar;
  if (cameraHeight < minHeight) {
    // View below the clouds
    if (intersections.ground) {
      nearFar = vec2(-1.0); // No clouds to the ground
    } else {
      nearFar = vec2(intersections.second.y, intersections.second.z);
      nearFar.y = min(nearFar.y, maxRayDistance);
    }
  } else if (cameraHeight < maxHeight) {
    // View inside the total cloud layer
    if (intersections.ground) {
      nearFar = vec2(cameraNear, intersections.first.y);
    } else {
      nearFar = vec2(cameraNear, intersections.second.z);
    }
  } else {
    // View above the clouds
    nearFar = vec2(intersections.first.z, intersections.second.z);
    if (intersections.ground) {
      // Clamp the ray at the min height.
      nearFar.y = intersections.first.y;
    }
  }
  return nearFar;
}

#ifdef SHADOW_LENGTH
vec2 getShadowRayNearFar(const IntersectionResult intersections) {
  vec2 nearFar;
  if (cameraHeight < shadowTopHeight) {
    if (intersections.ground) {
      nearFar = vec2(cameraNear, intersections.first.x);
    } else {
      nearFar = vec2(cameraNear, intersections.second.w);
    }
  } else {
    nearFar = vec2(intersections.first.w, intersections.second.w);
    if (intersections.ground) {
      // Clamp the ray at the ground.
      nearFar.y = intersections.first.x;
    }
  }
  nearFar.y = min(nearFar.y, maxShadowLengthRayDistance);
  return nearFar;
}
#endif // SHADOW_LENGTH

#ifdef HAZE
vec2 getHazeRayNearFar(const IntersectionResult intersections) {
  vec2 nearFar;
  if (cameraHeight < maxHeight) {
    if (intersections.ground) {
      nearFar = vec2(cameraNear, intersections.first.x);
    } else {
      nearFar = vec2(cameraNear, intersections.second.z);
    }
  } else {
    nearFar = vec2(cameraNear, intersections.second.z);
    if (intersections.ground) {
      // Clamp the ray at the ground.
      nearFar.y = intersections.first.x;
    }
  }
  return nearFar;
}
#endif // HAZE

float getRayDistanceToScene(const vec3 rayDirection, out float viewZ) {
  float depth = readDepth(vUv * targetUvScale + temporalJitter);
  if (depth < 1.0 - 1e-7) {
    depth = reverseLogDepth(depth, cameraNear, cameraFar);
    viewZ = getViewZ(depth);
    return -viewZ / dot(rayDirection, vCameraDirection);
  }
  viewZ = 0.0;
  return 0.0;
}

void main() {
  #ifdef DEBUG_SHOW_SHADOW_MAP
  outputColor = getCascadedShadowMaps(vUv);
  outputDepthVelocity = vec3(0.0);
  #ifdef SHADOW_LENGTH
  outputShadowLength = 0.0;
  #endif // SHADOW_LENGTH
  return;
  #endif // DEBUG_SHOW_SHADOW_MAP

  vec3 cameraPosition = vCameraPosition + altitudeCorrection;
  vec3 rayDirection = normalize(vRayDirection);
  float cosTheta = dot(sunDirection, rayDirection);

  IntersectionResult intersections = getIntersections(cameraPosition, rayDirection);
  vec2 rayNearFar = getRayNearFar(intersections);
  #ifdef SHADOW_LENGTH
  vec2 shadowRayNearFar = getShadowRayNearFar(intersections);
  #endif // SHADOW_LENGTH
  #ifdef HAZE
  vec2 hazeRayNearFar = getHazeRayNearFar(intersections);
  #endif // HAZE

  float sceneViewZ;
  float rayDistanceToScene = getRayDistanceToScene(rayDirection, sceneViewZ);
  if (rayDistanceToScene > 0.0) {
    rayNearFar.y = min(rayNearFar.y, rayDistanceToScene);
    #ifdef SHADOW_LENGTH
    shadowRayNearFar.y = min(shadowRayNearFar.y, rayDistanceToScene);
    #endif // SHADOW_LENGTH
    #ifdef HAZE
    hazeRayNearFar.y = min(hazeRayNearFar.y, rayDistanceToScene);
    #endif // HAZE
  }

  bool intersectsGround = any(lessThan(rayNearFar, vec2(0.0)));
  bool intersectsScene = rayNearFar.y < rayNearFar.x;

  float stbn = getSTBN();

  vec4 color = vec4(0.0);
  float frontDepth = rayNearFar.y;
  vec3 depthVelocity = vec3(0.0);
  float shadowLength = 0.0;
  bool hitClouds = false;

  if (!intersectsGround && !intersectsScene) {
    vec3 rayOrigin = rayNearFar.x * rayDirection + cameraPosition;

    vec2 globeUv = getGlobeUv(rayOrigin);
    #ifdef DEBUG_SHOW_UV
    outputColor = vec4(vec3(checker(globeUv, localWeatherRepeat + localWeatherOffset)), 1.0);
    outputDepthVelocity = vec3(0.0);
    #ifdef SHADOW_LENGTH
    outputShadowLength = 0.0;
    #endif // SHADOW_LENGTH
    return;
    #endif // DEBUG_SHOW_UV

    float mipLevel = getMipLevel(globeUv * localWeatherRepeat) * mipLevelScale;
    mipLevel = mix(0.0, mipLevel, min(1.0, 0.2 * cameraHeight / maxHeight));

    float marchedFrontDepth;
    ivec3 sampleCount = ivec3(0);
    color = marchClouds(
      rayOrigin,
      rayDirection,
      rayNearFar,
      cosTheta,
      stbn,
      pow(2.0, mipLevel),
      marchedFrontDepth,
      sampleCount
    );

    #ifdef DEBUG_SHOW_SAMPLE_COUNT
    outputColor = vec4(vec3(sampleCount) / vec3(500.0, 5.0, 5.0), 1.0);
    outputDepthVelocity = vec3(0.0);
    #ifdef SHADOW_LENGTH
    outputShadowLength = 0.0;
    #endif // SHADOW_LENGTH
    return;
    #endif // DEBUG_SHOW_SAMPLE_COUNT

    // Front depth will be -1.0 when no samples are accumulated.
    hitClouds = marchedFrontDepth >= 0.0;
    if (hitClouds) {
      frontDepth = rayNearFar.x + marchedFrontDepth;

      #ifdef SHADOW_LENGTH
      // Clamp the shadow length ray at the clouds.
      shadowRayNearFar.y = mix(
        shadowRayNearFar.y,
        min(frontDepth, shadowRayNearFar.y),
        color.a // Interpolate by the alpha for smoother edges.
      );

      // Shadow length must be computed before applying aerial perspective.
      if (all(greaterThanEqual(shadowRayNearFar, vec2(0.0)))) {
        shadowLength = marchShadowLength(
          shadowRayNearFar.x * rayDirection + cameraPosition,
          rayDirection,
          shadowRayNearFar,
          stbn
        );
      }
      #endif // SHADOW_LENGTH

      #ifdef HAZE
      // Clamp the haze ray at the clouds.
      hazeRayNearFar.y = mix(
        hazeRayNearFar.y,
        min(frontDepth, hazeRayNearFar.y),
        color.a // Interpolate by the alpha for smoother edges.
      );
      #endif // HAZE

      // Apply aerial perspective.
      vec3 frontPosition = cameraPosition + frontDepth * rayDirection;
      applyAerialPerspective(cameraPosition, frontPosition, shadowLength, color);

      // Velocity for temporal resolution.
      vec3 frontPositionWorld = ecefToWorld(frontPosition);
      vec4 prevClip = reprojectionMatrix * vec4(frontPositionWorld, 1.0);
      prevClip /= prevClip.w;
      vec2 prevUv = prevClip.xy * 0.5 + 0.5;
      vec2 velocity = vUv - prevUv;
      depthVelocity = vec3(frontDepth, velocity);
    }
  }

  if (!hitClouds) {
    #ifdef SHADOW_LENGTH
    if (all(greaterThanEqual(shadowRayNearFar, vec2(0.0)))) {
      shadowLength = marchShadowLength(
        shadowRayNearFar.x * rayDirection + cameraPosition,
        rayDirection,
        shadowRayNearFar,
        stbn
      );
    }
    #endif // SHADOW_LENGTH

    // Velocity for temporal resolution. Here reproject in the view space for
    // greatly reducing the precision errors.
    frontDepth = sceneViewZ < 0.0 ? -sceneViewZ : cameraFar;
    vec3 frontView = vViewPosition * frontDepth;
    vec4 prevClip = viewReprojectionMatrix * vec4(frontView, 1.0);
    prevClip /= prevClip.w;
    vec2 prevUv = prevClip.xy * 0.5 + 0.5;
    vec2 velocity = vUv - prevUv;
    depthVelocity = vec3(frontDepth, velocity);
  }

  #ifdef DEBUG_SHOW_FRONT_DEPTH
  outputColor = vec4(turbo(frontDepth / maxRayDistance), 1.0);
  outputDepthVelocity = vec3(0.0);
  #ifdef SHADOW_LENGTH
  outputShadowLength = 0.0;
  #endif // SHADOW_LENGTH
  return;
  #endif // DEBUG_SHOW_FRONT_DEPTH

  #ifdef HAZE
  vec4 haze = approximateHaze(
    cameraNear * rayDirection + cameraPosition,
    rayDirection,
    hazeRayNearFar.y - hazeRayNearFar.x,
    cosTheta,
    shadowLength
  );
  color.rgb = mix(color.rgb, haze.rgb, haze.a);
  color.a = color.a * (1.0 - haze.a) + haze.a;
  #endif // HAZE

  outputColor = color;
  outputDepthVelocity = depthVelocity;
  #ifdef SHADOW_LENGTH
  outputShadowLength = shadowLength * METER_TO_LENGTH_UNIT;
  #endif // SHADOW_LENGTH
}
`,f9=`float getSTBN() {
  ivec3 size = textureSize(stbnTexture, 0);
  vec3 scale = 1.0 / vec3(size);
  return texture(stbnTexture, vec3(gl_FragCoord.xy, float(frame % size.z)) * scale).r;
}

// Straightforward spherical mapping
vec2 getSphericalUv(const vec3 position) {
  vec2 st = normalize(position.yx);
  float phi = atan(st.x, st.y);
  float theta = asin(normalize(position).z);
  return vec2(phi * RECIPROCAL_PI2 + 0.5, theta * RECIPROCAL_PI + 0.5);
}

vec2 getCubeSphereUv(const vec3 position) {
  // Cube-sphere relaxation by: http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html
  // TODO: Tile and fix seams.
  // Possible improvements:
  // https://iquilezles.org/articles/texturerepetition/
  // https://gamedev.stackexchange.com/questions/184388/fragment-shader-map-dot-texture-repeatedly-over-the-sphere
  // https://github.com/mmikk/hextile-demo

  vec3 n = normalize(position);
  vec3 f = abs(n);
  vec3 c = n / max(f.x, max(f.y, f.z));
  vec2 m;
  if (all(greaterThan(f.yy, f.xz))) {
    m = c.y > 0.0 ? vec2(-n.x, n.z) : n.xz;
  } else if (all(greaterThan(f.xx, f.yz))) {
    m = c.x > 0.0 ? n.yz : vec2(-n.y, n.z);
  } else {
    m = c.z > 0.0 ? n.xy : vec2(n.x, -n.y);
  }

  vec2 m2 = m * m;
  float q = dot(m2.xy, vec2(-2.0, 2.0)) - 3.0;
  float q2 = q * q;
  vec2 uv;
  uv.x = sqrt(1.5 + m2.x - m2.y - 0.5 * sqrt(-24.0 * m2.x + q2)) * (m.x > 0.0 ? 1.0 : -1.0);
  uv.y = sqrt(6.0 / (3.0 - uv.x * uv.x)) * m.y;
  return uv * 0.5 + 0.5;
}

vec2 getGlobeUv(const vec3 position) {
  return getCubeSphereUv(position);
}

float getMipLevel(const vec2 uv) {
  const float mipLevelScale = 0.1;
  vec2 coord = uv * resolution;
  vec2 ddx = dFdx(coord);
  vec2 ddy = dFdy(coord);
  float deltaMaxSqr = max(dot(ddx, ddx), dot(ddy, ddy)) * mipLevelScale;
  return max(0.0, 0.5 * log2(max(1.0, deltaMaxSqr)));
}

bool insideLayerIntervals(const float height) {
  bvec3 gt = greaterThan(vec3(height), minIntervalHeights);
  bvec3 lt = lessThan(vec3(height), maxIntervalHeights);
  return any(bvec3(gt.x && lt.x, gt.y && lt.y, gt.z && lt.z));
}

struct WeatherSample {
  vec4 heightFraction; // Normalized height of each layer
  vec4 density;
};

vec4 shapeAlteringFunction(const vec4 heightFraction, const vec4 bias) {
  // Apply a semi-circle transform to round the clouds towards the top.
  vec4 biased = pow(heightFraction, bias);
  vec4 x = clamp(biased * 2.0 - 1.0, -1.0, 1.0);
  return 1.0 - x * x;
}

WeatherSample sampleWeather(const vec2 uv, const float height, const float mipLevel) {
  WeatherSample weather;
  weather.heightFraction = remapClamped(vec4(height), minLayerHeights, maxLayerHeights);

  vec4 localWeather = pow(
    textureLod(
      localWeatherTexture,
      uv * localWeatherRepeat + localWeatherOffset,
      mipLevel
    ).LOCAL_WEATHER_CHANNELS,
    weatherExponents
  );
  #ifdef SHADOW
  localWeather *= shadowLayerMask;
  #endif // SHADOW

  vec4 heightScale = shapeAlteringFunction(weather.heightFraction, shapeAlteringBiases);

  // Modulation to control weather by coverage parameter.
  // Reference: https://github.com/Prograda/Skybolt/blob/master/Assets/Core/Shaders/Clouds.h#L63
  vec4 factor = 1.0 - coverage * heightScale;
  weather.density = remapClamped(
    mix(localWeather, vec4(1.0), coverageFilterWidths),
    factor,
    factor + coverageFilterWidths
  );

  return weather;
}

vec4 getLayerDensity(const vec4 heightFraction) {
  // prettier-ignore
  return densityProfile.expTerms * exp(densityProfile.exponents * heightFraction) +
    densityProfile.linearTerms * heightFraction +
    densityProfile.constantTerms;
}

struct MediaSample {
  float density;
  vec4 weight;
  float scattering;
  float extinction;
};

MediaSample sampleMedia(
  const WeatherSample weather,
  const vec3 position,
  const vec2 uv,
  const float mipLevel,
  const float jitter,
  out ivec3 sampleCount
) {
  vec4 density = weather.density;

  // TODO: Define in physical length.
  vec3 surfaceNormal = normalize(position);
  float localWeatherSpeed = length(localWeatherOffset);
  vec3 evolution = -surfaceNormal * localWeatherSpeed * 2e4;

  vec3 turbulence = vec3(0.0);
  #ifdef TURBULENCE
  vec2 turbulenceUv = uv * localWeatherRepeat * turbulenceRepeat;
  turbulence =
    turbulenceDisplacement *
    (texture(turbulenceTexture, turbulenceUv).rgb * 2.0 - 1.0) *
    dot(density, remapClamped(weather.heightFraction, vec4(0.3), vec4(0.0)));
  #endif // TURBULENCE

  vec3 shapePosition = (position + evolution + turbulence) * shapeRepeat + shapeOffset;
  float shape = texture(shapeTexture, shapePosition).r;
  density = remapClamped(density, vec4(1.0 - shape) * shapeAmounts, vec4(1.0));

  #ifdef DEBUG_SHOW_SAMPLE_COUNT
  ++sampleCount.y;
  #endif // DEBUG_SHOW_SAMPLE_COUNT

  #ifdef SHAPE_DETAIL
  if (mipLevel * 0.5 + (jitter - 0.5) * 0.5 < 0.5) {
    vec3 detailPosition = (position + turbulence) * shapeDetailRepeat + shapeDetailOffset;
    float detail = texture(shapeDetailTexture, detailPosition).r;
    // Fluffy at the top and whippy at the bottom.
    vec4 modifier = mix(
      vec4(pow(detail, 6.0)),
      vec4(1.0 - detail),
      remapClamped(weather.heightFraction, vec4(0.2), vec4(0.4))
    );
    modifier = mix(vec4(0.0), modifier, shapeDetailAmounts);
    density = remapClamped(density * 2.0, vec4(modifier * 0.5), vec4(1.0));

    #ifdef DEBUG_SHOW_SAMPLE_COUNT
    ++sampleCount.z;
    #endif // DEBUG_SHOW_SAMPLE_COUNT
  }
  #endif // SHAPE_DETAIL

  // Apply the density profiles.
  density = saturate(density * densityScales * getLayerDensity(weather.heightFraction));

  MediaSample media;
  float densitySum = density.x + density.y + density.z + density.w;
  media.weight = density / densitySum;
  media.scattering = densitySum * scatteringCoefficient;
  media.extinction = densitySum * absorptionCoefficient + media.scattering;
  return media;
}

MediaSample sampleMedia(
  const WeatherSample weather,
  const vec3 position,
  const vec2 uv,
  const float mipLevel,
  const float jitter
) {
  ivec3 sampleCount;
  return sampleMedia(weather, position, uv, mipLevel, jitter, sampleCount);
}
`,ore=`precision highp float;
precision highp sampler3D;

#include "atmosphere/bruneton/definitions"

uniform AtmosphereParameters ATMOSPHERE;
uniform vec3 SUN_SPECTRAL_RADIANCE_TO_LUMINANCE;
uniform vec3 SKY_SPECTRAL_RADIANCE_TO_LUMINANCE;

uniform sampler2D transmittance_texture;
uniform sampler3D scattering_texture;
uniform sampler2D irradiance_texture;
uniform sampler3D single_mie_scattering_texture;
uniform sampler3D higher_order_scattering_texture;

#include "atmosphere/bruneton/common"
#include "atmosphere/bruneton/runtime"

#include "types"

uniform mat4 inverseProjectionMatrix;
uniform mat4 inverseViewMatrix;
uniform vec3 cameraPosition;
uniform mat4 worldToECEFMatrix;
uniform vec3 altitudeCorrection;

// Atmosphere
uniform float bottomRadius;
uniform vec3 sunDirection;

// Cloud layers
uniform float minHeight;
uniform float maxHeight;

layout(location = 0) in vec3 position;

out vec2 vUv;
out vec3 vCameraPosition;
out vec3 vCameraDirection; // Direction to the center of screen
out vec3 vRayDirection; // Direction to the texel
out vec3 vViewPosition;

out GroundIrradiance vGroundIrradiance;
out CloudsIrradiance vCloudsIrradiance;

void sampleSunSkyIrradiance(const vec3 positionECEF) {
  vGroundIrradiance.sun = GetSunAndSkyScalarIrradiance(
    positionECEF * METER_TO_LENGTH_UNIT,
    sunDirection,
    vGroundIrradiance.sky
  );

  vec3 surfaceNormal = normalize(positionECEF);
  vec2 radii = (bottomRadius + vec2(minHeight, maxHeight)) * METER_TO_LENGTH_UNIT;
  vCloudsIrradiance.minSun = GetSunAndSkyScalarIrradiance(
    surfaceNormal * radii.x,
    sunDirection,
    vCloudsIrradiance.minSky
  );
  vCloudsIrradiance.maxSun = GetSunAndSkyScalarIrradiance(
    surfaceNormal * radii.y,
    sunDirection,
    vCloudsIrradiance.maxSky
  );
}

void main() {
  vUv = position.xy * 0.5 + 0.5;

  vec3 viewPosition = (inverseProjectionMatrix * vec4(position, 1.0)).xyz;
  vec3 worldDirection = (inverseViewMatrix * vec4(viewPosition.xyz, 0.0)).xyz;
  vec3 cameraDirection = normalize((inverseViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz);
  vCameraPosition = (worldToECEFMatrix * vec4(cameraPosition, 1.0)).xyz;
  vCameraDirection = (worldToECEFMatrix * vec4(cameraDirection, 0.0)).xyz;
  vRayDirection = (worldToECEFMatrix * vec4(worldDirection, 0.0)).xyz;
  vViewPosition = viewPosition;

  sampleSunSkyIrradiance(vCameraPosition + altitudeCorrection);

  gl_Position = vec4(position.xy, 1.0, 1.0);
}
`,d9=`uniform vec2 resolution;
uniform int frame;
uniform sampler3D stbnTexture;

// Atmosphere
uniform float bottomRadius;
uniform mat4 worldToECEFMatrix;
uniform mat4 ecefToWorldMatrix;
uniform vec3 altitudeCorrection;
uniform vec3 sunDirection;

// Participating medium
uniform float scatteringCoefficient;
uniform float absorptionCoefficient;

// Primary raymarch
uniform float minDensity;
uniform float minExtinction;
uniform float minTransmittance;

// Shape and weather
uniform sampler2D localWeatherTexture;
uniform vec2 localWeatherRepeat;
uniform vec2 localWeatherOffset;
uniform float coverage;
uniform sampler3D shapeTexture;
uniform vec3 shapeRepeat;
uniform vec3 shapeOffset;

#ifdef SHAPE_DETAIL
uniform sampler3D shapeDetailTexture;
uniform vec3 shapeDetailRepeat;
uniform vec3 shapeDetailOffset;
#endif // SHAPE_DETAIL

#ifdef TURBULENCE
uniform sampler2D turbulenceTexture;
uniform vec2 turbulenceRepeat;
uniform float turbulenceDisplacement;
#endif // TURBULENCE

// Haze
#ifdef HAZE
uniform float hazeDensityScale;
uniform float hazeExponent;
uniform float hazeScatteringCoefficient;
uniform float hazeAbsorptionCoefficient;
#endif // HAZE

// Cloud layers
uniform vec4 minLayerHeights;
uniform vec4 maxLayerHeights;
uniform vec3 minIntervalHeights;
uniform vec3 maxIntervalHeights;
uniform vec4 densityScales;
uniform vec4 shapeAmounts;
uniform vec4 shapeDetailAmounts;
uniform vec4 weatherExponents;
uniform vec4 shapeAlteringBiases;
uniform vec4 coverageFilterWidths;
uniform float minHeight;
uniform float maxHeight;
uniform float shadowTopHeight;
uniform float shadowBottomHeight;
uniform vec4 shadowLayerMask;
uniform CloudDensityProfile densityProfile;
`,gM=`struct GroundIrradiance {
  vec3 sun;
  vec3 sky;
};

struct CloudsIrradiance {
  vec3 minSun;
  vec3 minSky;
  vec3 maxSun;
  vec3 maxSky;
};

struct CloudDensityProfile {
  vec4 expTerms;
  vec4 exponents;
  vec4 linearTerms;
  vec4 constantTerms;
};
`;var lre=Object.defineProperty,oa=(n,e,t,i)=>{for(var r=void 0,a=n.length-1,s;a>=0;a--)(s=n[a])&&(r=s(e,t,r)||r);return r&&lre(e,t,r),r};const cre=new L,ure=new E0;let Fr=class extends eg{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i},r=$0.DEFAULT){super({name:"CloudsMaterial",glslVersion:so,vertexShader:Nr(ore,{atmosphere:{bruneton:{common:WO,definitions:XO,runtime:kO}},types:gM}),fragmentShader:J0(Nr(sre,{core:{depth:VP,math:wA,turbo:WP,generators:dne,raySphereIntersection:Sy,cascadedShadowMaps:GP,interleavedGradientNoise:kP,vogelDisk:XP},atmosphere:{bruneton:{common:WO,definitions:XO,runtime:kO}},types:gM,parameters:d9,clouds:f9})),uniforms:{...e,...t,...i,depthBuffer:new J(null),viewMatrix:new J(new Ve),inverseProjectionMatrix:new J(new Ve),inverseViewMatrix:new J(new Ve),reprojectionMatrix:new J(new Ve),viewReprojectionMatrix:new J(new Ve),resolution:new J(new de),cameraNear:new J(0),cameraFar:new J(0),cameraHeight:new J(0),frame:new J(0),temporalJitter:new J(new de),targetUvScale:new J(new de),mipLevelScale:new J(1),stbnTexture:new J(null),skyLightScale:new J(1),groundBounceScale:new J(1),powderScale:new J(.8),powderExponent:new J(150),maxIterationCount:new J(It.clouds.maxIterationCount),minStepSize:new J(It.clouds.minStepSize),maxStepSize:new J(It.clouds.maxStepSize),maxRayDistance:new J(It.clouds.maxRayDistance),perspectiveStepScale:new J(It.clouds.perspectiveStepScale),minDensity:new J(It.clouds.minDensity),minExtinction:new J(It.clouds.minExtinction),minTransmittance:new J(It.clouds.minTransmittance),maxIterationCountToSun:new J(It.clouds.maxIterationCountToSun),maxIterationCountToGround:new J(It.clouds.maxIterationCountToGround),minSecondaryStepSize:new J(It.clouds.minSecondaryStepSize),secondaryStepScale:new J(It.clouds.secondaryStepScale),shadowBuffer:new J(null),shadowTexelSize:new J(new de),shadowIntervals:new J(Array.from({length:4},()=>new de)),shadowMatrices:new J(Array.from({length:4},()=>new Ve)),shadowFar:new J(0),maxShadowFilterRadius:new J(6),shadowLayerMask:new J(new zt().setScalar(1)),maxShadowLengthIterationCount:new J(It.clouds.maxShadowLengthIterationCount),minShadowLengthStepSize:new J(It.clouds.minShadowLengthStepSize),maxShadowLengthRayDistance:new J(It.clouds.maxShadowLengthRayDistance),hazeDensityScale:new J(3e-5),hazeExponent:new J(.001),hazeScatteringCoefficient:new J(.9),hazeAbsorptionCoefficient:new J(.5)}},r),this.temporalUpscale=!0,this.depthPacking=0,this.localWeatherChannels="rgba",this.shapeDetail=It.shapeDetail,this.turbulence=It.turbulence,this.shadowLength=It.lightShafts,this.haze=It.haze,this.multiScatteringOctaves=It.clouds.multiScatteringOctaves,this.accurateSunSkyLight=It.clouds.accurateSunSkyLight,this.accuratePhaseFunction=It.clouds.accuratePhaseFunction,this.shadowCascadeCount=It.shadow.cascadeCount,this.shadowSampleCount=8,this.scatterAnisotropy1=.7,this.scatterAnisotropy2=-.2,this.scatterAnisotropyMix=.5}onBeforeRender(e,t,i,r,a,s){const o=this.defines.USE_LOGARITHMIC_DEPTH_BUFFER!=null,l=e.capabilities.logarithmicDepthBuffer;l!==o&&(l?this.defines.USE_LOGARITHMIC_DEPTH_BUFFER="1":delete this.defines.USE_LOGARITHMIC_DEPTH_BUFFER);const h=this.defines.POWDER!=null,f=this.uniforms.powderScale.value>0;f!==h&&(f?this.defines.POWDER="1":delete this.defines.POWDER,this.needsUpdate=!0);const d=this.defines.GROUND_BOUNCE!=null;(this.uniforms.groundBounceScale.value>0&&this.uniforms.maxIterationCountToGround.value>0)!==d&&(f?this.defines.GROUND_BOUNCE="1":delete this.defines.GROUND_BOUNCE,this.needsUpdate=!0)}copyCameraSettings(e){e.isPerspectiveCamera===!0?this.defines.PERSPECTIVE_CAMERA!=="1"&&(this.defines.PERSPECTIVE_CAMERA="1",this.needsUpdate=!0):this.defines.PERSPECTIVE_CAMERA!=null&&(delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0);const t=this.uniforms;t.viewMatrix.value.copy(e.matrixWorldInverse),t.inverseViewMatrix.value.copy(e.matrixWorld);const i=this.previousProjectionMatrix??e.projectionMatrix,r=this.previousViewMatrix??e.matrixWorldInverse,a=t.inverseProjectionMatrix.value,s=t.inverseViewMatrix.value,o=t.reprojectionMatrix.value,l=t.viewReprojectionMatrix.value;if(this.temporalUpscale){const d=t.frame.value%16,p=t.resolution.value,g=h9[d],_=(g.x-.5)/p.x*4,T=(g.y-.5)/p.y*4;t.temporalJitter.value.set(_,T),t.mipLevelScale.value=.25,a.copy(e.projectionMatrix),a.elements[8]+=_*2,a.elements[9]+=T*2,a.invert(),o.copy(i),o.elements[8]+=_*2,o.elements[9]+=T*2,o.multiply(r),l.copy(o).multiply(s)}else t.temporalJitter.value.setScalar(0),t.mipLevelScale.value=1,a.copy(e.projectionMatrixInverse),o.copy(i).multiply(r),l.copy(o).multiply(s);t.cameraNear.value=e.near,t.cameraFar.value=e.far;const h=e.getWorldPosition(t.cameraPosition.value),f=cre.copy(h).applyMatrix4(t.worldToECEFMatrix.value);try{t.cameraHeight.value=ure.setFromECEF(f).height}catch{}}copyReprojectionMatrix(e){this.previousProjectionMatrix??(this.previousProjectionMatrix=new Ve),this.previousViewMatrix??(this.previousViewMatrix=new Ve),this.previousProjectionMatrix.copy(e.projectionMatrix),this.previousViewMatrix.copy(e.matrixWorldInverse)}setSize(e,t,i,r){this.uniforms.resolution.value.set(e,t),i!=null&&r!=null?this.uniforms.targetUvScale.value.set(e/i,t/r):this.uniforms.targetUvScale.value.setScalar(1),this.previousProjectionMatrix=void 0,this.previousViewMatrix=void 0}setShadowSize(e,t){this.uniforms.shadowTexelSize.value.set(1/e,1/t)}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(e){this.uniforms.depthBuffer.value=e}get accurateSunSkyIrradiance(){return this.accurateSunSkyLight}set accurateSunSkyIrradiance(e){this.accurateSunSkyLight=e}};oa([_h("DEPTH_PACKING")],Fr.prototype,"depthPacking");oa([zP("LOCAL_WEATHER_CHANNELS",{validate:n=>/^[rgba]{4}$/.test(n)})],Fr.prototype,"localWeatherChannels");oa([pn("SHAPE_DETAIL")],Fr.prototype,"shapeDetail");oa([pn("TURBULENCE")],Fr.prototype,"turbulence");oa([pn("SHADOW_LENGTH")],Fr.prototype,"shadowLength");oa([pn("HAZE")],Fr.prototype,"haze");oa([_h("MULTI_SCATTERING_OCTAVES",{min:1,max:12})],Fr.prototype,"multiScatteringOctaves");oa([pn("ACCURATE_SUN_SKY_LIGHT")],Fr.prototype,"accurateSunSkyLight");oa([pn("ACCURATE_PHASE_FUNCTION")],Fr.prototype,"accuratePhaseFunction");oa([_h("SHADOW_CASCADE_COUNT",{min:1,max:4})],Fr.prototype,"shadowCascadeCount");oa([_h("SHADOW_SAMPLE_COUNT",{min:1,max:16})],Fr.prototype,"shadowSampleCount");oa([AA("SCATTER_ANISOTROPY_1")],Fr.prototype,"scatterAnisotropy1");oa([AA("SCATTER_ANISOTROPY_2")],Fr.prototype,"scatterAnisotropy2");oa([AA("SCATTER_ANISOTROPY_MIX")],Fr.prototype,"scatterAnisotropyMix");const hre=`// Taken from https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1
// TODO: Use 5-taps version: https://www.shadertoy.com/view/MtVGWz
// Or even 4 taps (requires preprocessing in the input buffer):
// https://www.shadertoy.com/view/4tyGDD

/**
 * MIT License
 *
 * Copyright (c) 2019 MJP
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

vec4 textureCatmullRom(sampler2D tex, vec2 uv) {
  vec2 texSize = vec2(textureSize(tex, 0));

  // We're going to sample a a 4x4 grid of texels surrounding the target UV
  // coordinate. We'll do this by rounding down the sample location to get the
  // exact center of our "starting" texel. The starting texel will be at
  // location [1, 1] in the grid, where [0, 0] is the top left corner.
  vec2 samplePos = uv * texSize;
  vec2 texPos1 = floor(samplePos - 0.5) + 0.5;

  // Compute the fractional offset from our starting texel to our original
  // sample location, which we'll feed into the Catmull-Rom spline function to
  // get our filter weights.
  vec2 f = samplePos - texPos1;

  // Compute the Catmull-Rom weights using the fractional offset that we
  // calculated earlier. These equations are pre-expanded based on our knowledge
  // of where the texels will be located, which lets us avoid having to evaluate
  // a piece-wise function.
  vec2 w0 = f * (-0.5 + f * (1.0 - 0.5 * f));
  vec2 w1 = 1.0 + f * f * (-2.5 + 1.5 * f);
  vec2 w2 = f * (0.5 + f * (2.0 - 1.5 * f));
  vec2 w3 = f * f * (-0.5 + 0.5 * f);

  // Work out weighting factors and sampling offsets that will let us use
  // bilinear filtering to simultaneously evaluate the middle 2 samples from the
  // 4x4 grid.
  vec2 w12 = w1 + w2;
  vec2 offset12 = w2 / (w1 + w2);

  // Compute the final UV coordinates we'll use for sampling the texture
  vec2 texPos0 = texPos1 - 1.0;
  vec2 texPos3 = texPos1 + 2.0;
  vec2 texPos12 = texPos1 + offset12;

  texPos0 /= texSize;
  texPos3 /= texSize;
  texPos12 /= texSize;

  vec4 result = vec4(0.0);
  result += texture(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y;
  result += texture(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y;
  result += texture(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y;

  result += texture(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y;
  result += texture(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y;
  result += texture(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y;

  result += texture(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y;
  result += texture(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y;
  result += texture(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y;

  return result;
}

vec4 textureCatmullRom(sampler2DArray tex, vec3 uv) {
  vec2 texSize = vec2(textureSize(tex, 0));
  vec2 samplePos = uv.xy * texSize;
  vec2 texPos1 = floor(samplePos - 0.5) + 0.5;
  vec2 f = samplePos - texPos1;
  vec2 w0 = f * (-0.5 + f * (1.0 - 0.5 * f));
  vec2 w1 = 1.0 + f * f * (-2.5 + 1.5 * f);
  vec2 w2 = f * (0.5 + f * (2.0 - 1.5 * f));
  vec2 w3 = f * f * (-0.5 + 0.5 * f);
  vec2 w12 = w1 + w2;
  vec2 offset12 = w2 / (w1 + w2);
  vec2 texPos0 = texPos1 - 1.0;
  vec2 texPos3 = texPos1 + 2.0;
  vec2 texPos12 = texPos1 + offset12;
  texPos0 /= texSize;
  texPos3 /= texSize;
  texPos12 /= texSize;
  vec4 result = vec4(0.0);
  result += texture(tex, vec3(texPos0.x, texPos0.y, uv.z)) * w0.x * w0.y;
  result += texture(tex, vec3(texPos12.x, texPos0.y, uv.z)) * w12.x * w0.y;
  result += texture(tex, vec3(texPos3.x, texPos0.y, uv.z)) * w3.x * w0.y;
  result += texture(tex, vec3(texPos0.x, texPos12.y, uv.z)) * w0.x * w12.y;
  result += texture(tex, vec3(texPos12.x, texPos12.y, uv.z)) * w12.x * w12.y;
  result += texture(tex, vec3(texPos3.x, texPos12.y, uv.z)) * w3.x * w12.y;
  result += texture(tex, vec3(texPos0.x, texPos3.y, uv.z)) * w0.x * w3.y;
  result += texture(tex, vec3(texPos12.x, texPos3.y, uv.z)) * w12.x * w3.y;
  result += texture(tex, vec3(texPos3.x, texPos3.y, uv.z)) * w3.x * w3.y;
  return result;
}
`,fre=`precision highp float;
precision highp sampler2DArray;

#include "core/turbo"
#include "catmullRomSampling"
#include "varianceClipping"

uniform sampler2D colorBuffer;
uniform sampler2D depthVelocityBuffer;
uniform sampler2D colorHistoryBuffer;

#ifdef SHADOW_LENGTH
uniform sampler2D shadowLengthBuffer;
uniform sampler2D shadowLengthHistoryBuffer;
#endif // SHADOW_LENGTH

uniform vec2 texelSize;
uniform int frame;
uniform float varianceGamma;
uniform float temporalAlpha;
uniform vec2 jitterOffset;

in vec2 vUv;

layout(location = 0) out vec4 outputColor;
#ifdef SHADOW_LENGTH
layout(location = 1) out float outputShadowLength;
#endif // SHADOW_LENGTH

const ivec2 neighborOffsets[9] = ivec2[9](
  ivec2(-1, -1),
  ivec2(-1, 0),
  ivec2(-1, 1),
  ivec2(0, -1),
  ivec2(0, 0),
  ivec2(0, 1),
  ivec2(1, -1),
  ivec2(1, 0),
  ivec2(1, 1)
);

const ivec4[4] bayerIndices = ivec4[4](
  ivec4(0, 12, 3, 15),
  ivec4(8, 4, 11, 7),
  ivec4(2, 14, 1, 13),
  ivec4(10, 6, 9, 5)
);

vec4 getClosestFragment(const ivec2 coord) {
  vec4 result = vec4(1e7, 0.0, 0.0, 0.0);
  vec4 neighbor;
  #pragma unroll_loop_start
  for (int i = 0; i < 9; ++i) {
    neighbor = texelFetchOffset(depthVelocityBuffer, coord, 0, neighborOffsets[i]);
    if (neighbor.r < result.r) {
      result = neighbor;
    }
  }
  #pragma unroll_loop_end
  return result;
}

void temporalUpscale(
  const ivec2 coord,
  const ivec2 lowResCoord,
  const bool currentFrame,
  out vec4 outputColor,
  out float outputShadowLength
) {
  vec4 currentColor = texelFetch(colorBuffer, lowResCoord, 0);
  #ifdef SHADOW_LENGTH
  vec4 currentShadowLength = vec4(texelFetch(shadowLengthBuffer, lowResCoord, 0).rgb, 1.0);
  #endif // SHADOW_LENGTH

  if (currentFrame) {
    // Use the texel just rendered without any accumulation.
    outputColor = currentColor;
    #ifdef SHADOW_LENGTH
    outputShadowLength = currentShadowLength.r;
    #endif // SHADOW_LENGTH
    return;
  }

  vec4 depthVelocity = getClosestFragment(lowResCoord);
  vec2 velocity = depthVelocity.gb;
  vec2 prevUv = vUv - velocity;
  if (prevUv.x < 0.0 || prevUv.x > 1.0 || prevUv.y < 0.0 || prevUv.y > 1.0) {
    outputColor = currentColor;
    #ifdef SHADOW_LENGTH
    outputShadowLength = currentShadowLength.r;
    #endif // SHADOW_LENGTH
    return; // Rejection
  }

  // Variance clipping with a large variance gamma seems to work fine for
  // upsampling. This increases ghosting, of course, but it's hard to notice on
  // clouds.
  // vec4 historyColor = textureCatmullRom(colorHistoryBuffer, prevUv);
  vec4 historyColor = texture(colorHistoryBuffer, prevUv);
  vec4 clippedColor = varianceClipping(colorBuffer, vUv, currentColor, historyColor, varianceGamma);
  outputColor = clippedColor;

  #ifdef SHADOW_LENGTH
  // Sampling the shadow length history using scene depth doesn't make much
  // sense, but it's too hard to derive it properly. At least this approach
  // resolves the edges of scene objects.
  // vec4 historyShadowLength = vec4(textureCatmullRom(shadowLengthHistoryBuffer, prevUv).rgb, 1.0);
  vec4 historyShadowLength = vec4(texture(shadowLengthHistoryBuffer, prevUv).rgb, 1.0);
  vec4 clippedShadowLength = varianceClipping(
    shadowLengthBuffer,
    vUv,
    currentShadowLength,
    historyShadowLength,
    varianceGamma
  );
  outputShadowLength = clippedShadowLength.r;
  #endif // SHADOW_LENGTH
}

void temporalAntialiasing(const ivec2 coord, out vec4 outputColor, out float outputShadowLength) {
  vec4 currentColor = texelFetch(colorBuffer, coord, 0);
  #ifdef SHADOW_LENGTH
  vec4 currentShadowLength = vec4(texelFetch(shadowLengthBuffer, coord, 0).rgb, 1.0);
  #endif // SHADOW_LENGTH

  vec4 depthVelocity = getClosestFragment(coord);
  vec2 velocity = depthVelocity.gb;

  vec2 prevUv = vUv - velocity;
  if (prevUv.x < 0.0 || prevUv.x > 1.0 || prevUv.y < 0.0 || prevUv.y > 1.0) {
    outputColor = currentColor;
    #ifdef SHADOW_LENGTH
    outputShadowLength = currentShadowLength.r;
    #endif // SHADOW_LENGTH
    return; // Rejection
  }

  vec4 historyColor = texture(colorHistoryBuffer, prevUv);
  vec4 clippedColor = varianceClipping(colorBuffer, coord, currentColor, historyColor);
  outputColor = mix(clippedColor, currentColor, temporalAlpha);

  #ifdef SHADOW_LENGTH
  vec4 historyShadowLength = vec4(texture(shadowLengthHistoryBuffer, prevUv).rgb, 1.0);
  vec4 clippedShadowLength = varianceClipping(
    shadowLengthBuffer,
    coord,
    currentShadowLength,
    historyShadowLength
  );
  outputShadowLength = mix(clippedShadowLength.r, currentShadowLength.r, temporalAlpha);
  #endif // SHADOW_LENGTH
}

void main() {
  ivec2 coord = ivec2(gl_FragCoord.xy);

  #if !defined(SHADOW_LENGTH)
  float outputShadowLength;
  #endif // !defined(SHADOW_LENGTH)

  #ifdef TEMPORAL_UPSCALE
  ivec2 lowResCoord = coord / 4;
  int bayerValue = bayerIndices[coord.x % 4][coord.y % 4];
  bool currentFrame = bayerValue == frame % 16;
  temporalUpscale(coord, lowResCoord, currentFrame, outputColor, outputShadowLength);
  #else // TEMPORAL_UPSCALE
  temporalAntialiasing(coord, outputColor, outputShadowLength);
  #endif // TEMPORAL_UPSCALE

  #if defined(SHADOW_LENGTH) && defined(DEBUG_SHOW_SHADOW_LENGTH)
  outputColor = vec4(turbo(outputShadowLength * 0.05), 1.0);
  #endif // defined(SHADOW_LENGTH) && defined(DEBUG_SHOW_SHADOW_LENGTH)

  #ifdef DEBUG_SHOW_VELOCITY
  outputColor.rgb = outputColor.rgb + vec3(abs(texture(depthVelocityBuffer, vUv).gb) * 10.0, 0.0);
  #endif // DEBUG_SHOW_VELOCITY
}
`,dre=`precision highp float;

layout(location = 0) in vec3 position;

out vec2 vUv;

void main() {
  vUv = position.xy * 0.5 + 0.5;
  gl_Position = vec4(position.xy, 1.0, 1.0);
}
`,p9=`#ifdef VARIANCE_9_SAMPLES
#define VARIANCE_OFFSET_COUNT 8
const ivec2 varianceOffsets[8] = ivec2[8](
  ivec2(-1, -1),
  ivec2(-1, 1),
  ivec2(1, -1),
  ivec2(1, 1),
  ivec2(1, 0),
  ivec2(0, -1),
  ivec2(0, 1),
  ivec2(-1, 0)
);
#else // VARIANCE_9_SAMPLES
#define VARIANCE_OFFSET_COUNT 4
const ivec2 varianceOffsets[4] = ivec2[4](ivec2(1, 0), ivec2(0, -1), ivec2(0, 1), ivec2(-1, 0));
#endif // VARIANCE_9_SAMPLES

// Reference: https://github.com/playdeadgames/temporal
vec4 clipAABB(const vec4 current, const vec4 history, const vec4 minColor, const vec4 maxColor) {
  vec3 pClip = 0.5 * (maxColor.rgb + minColor.rgb);
  vec3 eClip = 0.5 * (maxColor.rgb - minColor.rgb) + 1e-7;
  vec4 vClip = history - vec4(pClip, current.a);
  vec3 vUnit = vClip.xyz / eClip;
  vec3 aUnit = abs(vUnit);
  float maUnit = max(aUnit.x, max(aUnit.y, aUnit.z));
  if (maUnit > 1.0) {
    return vec4(pClip, current.a) + vClip / maUnit;
  }
  return history;
}

#ifdef VARIANCE_SAMPLER_ARRAY
#define VARIANCE_SAMPLER sampler2DArray
#define VARIANCE_SAMPLER_COORD ivec3
#else // VARIANCE_SAMPLER_ARRAY
#define VARIANCE_SAMPLER sampler2D
#define VARIANCE_SAMPLER_COORD ivec2
#endif // VARIANCE_SAMPLER_ARRAY

// Variance clipping
// Reference: https://developer.download.nvidia.com/gameworks/events/GDC2016/msalvi_temporal_supersampling.pdf
vec4 varianceClipping(
  const VARIANCE_SAMPLER inputBuffer,
  const VARIANCE_SAMPLER_COORD coord,
  const vec4 current,
  const vec4 history,
  const float gamma
) {
  vec4 moment1 = current;
  vec4 moment2 = current * current;
  vec4 neighbor;
  #pragma unroll_loop_start
  for (int i = 0; i < 8; ++i) {
    #if UNROLLED_LOOP_INDEX < VARIANCE_OFFSET_COUNT
    neighbor = texelFetchOffset(inputBuffer, coord, 0, varianceOffsets[i]);
    moment1 += neighbor;
    moment2 += neighbor * neighbor;
    #endif // UNROLLED_LOOP_INDEX < VARIANCE_OFFSET_COUNT
  }
  #pragma unroll_loop_end

  const float N = float(VARIANCE_OFFSET_COUNT + 1);
  vec4 mean = moment1 / N;
  vec4 varianceGamma = sqrt(max(moment2 / N - mean * mean, 0.0)) * gamma;
  vec4 minColor = mean - varianceGamma;
  vec4 maxColor = mean + varianceGamma;
  return clipAABB(clamp(mean, minColor, maxColor), history, minColor, maxColor);
}

vec4 varianceClipping(
  const VARIANCE_SAMPLER inputBuffer,
  const VARIANCE_SAMPLER_COORD coord,
  const vec4 current,
  const vec4 history
) {
  return varianceClipping(inputBuffer, coord, current, history, 1.0);
}

vec4 varianceClipping(
  const sampler2D inputBuffer,
  const vec2 coord,
  const vec4 current,
  const vec4 history,
  const float gamma
) {
  vec4 moment1 = current;
  vec4 moment2 = current * current;
  vec4 neighbor;
  #pragma unroll_loop_start
  for (int i = 0; i < 8; ++i) {
    #if UNROLLED_LOOP_INDEX < VARIANCE_OFFSET_COUNT
    neighbor = textureOffset(inputBuffer, coord, varianceOffsets[i]);
    moment1 += neighbor;
    moment2 += neighbor * neighbor;
    #endif // UNROLLED_LOOP_INDEX < VARIANCE_OFFSET_COUNT
  }
  #pragma unroll_loop_end

  const float N = float(VARIANCE_OFFSET_COUNT + 1);
  vec4 mean = moment1 / N;
  vec4 varianceGamma = sqrt(max(moment2 / N - mean * mean, 0.0)) * gamma;
  vec4 minColor = mean - varianceGamma;
  vec4 maxColor = mean + varianceGamma;
  return clipAABB(clamp(mean, minColor, maxColor), history, minColor, maxColor);
}

vec4 varianceClipping(
  const sampler2D inputBuffer,
  const vec2 coord,
  const vec4 current,
  const vec4 history
) {
  return varianceClipping(inputBuffer, coord, current, history, 1.0);
}
`;var pre=Object.defineProperty,m9=(n,e,t,i)=>{for(var r=void 0,a=n.length-1,s;a>=0;a--)(s=n[a])&&(r=s(e,t,r)||r);return r&&pre(e,t,r),r};class PA extends ph{constructor({colorBuffer:e=null,depthVelocityBuffer:t=null,shadowLengthBuffer:i=null,colorHistoryBuffer:r=null,shadowLengthHistoryBuffer:a=null}={}){super({name:"CloudsResolveMaterial",glslVersion:so,vertexShader:dre,fragmentShader:J0(Nr(fre,{core:{turbo:WP},catmullRomSampling:hre,varianceClipping:p9})),uniforms:{colorBuffer:new J(e),depthVelocityBuffer:new J(t),shadowLengthBuffer:new J(i),colorHistoryBuffer:new J(r),shadowLengthHistoryBuffer:new J(a),texelSize:new J(new de),frame:new J(0),jitterOffset:new J(new de),varianceGamma:new J(2),temporalAlpha:new J(.1)}}),this.temporalUpscale=!0,this.shadowLength=!0}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}onBeforeRender(e,t,i,r,a,s){const o=this.uniforms.frame.value%16,l=h9[o],h=(l.x-.5)*4,f=(l.y-.5)*4;this.uniforms.jitterOffset.value.set(h,f)}}m9([pn("TEMPORAL_UPSCALE")],PA.prototype,"temporalUpscale");m9([pn("SHADOW_LENGTH")],PA.prototype,"shadowLength");class g9 extends Br{constructor(e,t){super(e),this._mainCamera=new wc;const{shadow:i}=t;this.shadow=i}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e}}function u3(n,{depthVelocity:e,shadowLength:t}){const i=new xi(1,1,{depthBuffer:!1,type:Yn});i.texture.minFilter=Ht,i.texture.magFilter=Ht,i.texture.name=n;let r;e&&(r=i.texture.clone(),r.isRenderTargetTexture=!0,i.depthVelocity=r,i.textures.push(r));let a;return t&&(a=i.texture.clone(),a.isRenderTargetTexture=!0,a.format=ws,i.shadowLength=a,i.textures.push(a)),Object.assign(i,{depthVelocity:r??null,shadowLength:a??null})}class mre extends g9{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i,...r},a){super("CloudsPass",r),this.atmosphere=a,this.width=0,this.height=0,this.currentMaterial=new Fr({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i},a),this.currentPass=new kE(this.currentMaterial),this.resolveMaterial=new PA,this.resolvePass=new kE(this.resolveMaterial),this.initRenderTargets({depthVelocity:!0,shadowLength:It.lightShafts})}copyCameraSettings(e){this.currentMaterial.copyCameraSettings(e)}initialize(e,t,i){this.currentPass.initialize(e,t,i),this.resolvePass.initialize(e,t,i)}initRenderTargets(e){var s,o,l;(s=this.currentRenderTarget)==null||s.dispose(),(o=this.resolveRenderTarget)==null||o.dispose(),(l=this.historyRenderTarget)==null||l.dispose();const t=u3("Clouds",e),i=u3("Clouds.A",{...e,depthVelocity:!1}),r=u3("Clouds.B",{...e,depthVelocity:!1});this.currentRenderTarget=t,this.resolveRenderTarget=i,this.historyRenderTarget=r;const a=this.resolveMaterial.uniforms;a.colorBuffer.value=t.texture,a.depthVelocityBuffer.value=t.depthVelocity,a.shadowLengthBuffer.value=t.shadowLength,a.colorHistoryBuffer.value=r.texture,a.shadowLengthHistoryBuffer.value=r.shadowLength}copyShadow(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let i=0;i<e.cascadeCount;++i){const r=e.cascades[i];t.shadowIntervals.value[i].copy(r.interval),t.shadowMatrices.value[i].copy(r.matrix)}t.shadowFar.value=e.far}copyReprojection(){this.currentMaterial.copyReprojectionMatrix(this.mainCamera)}swapBuffers(){const e=this.historyRenderTarget,t=this.resolveRenderTarget;this.resolveRenderTarget=e,this.historyRenderTarget=t;const i=this.resolveMaterial.uniforms;i.colorHistoryBuffer.value=t.texture,i.shadowLengthHistoryBuffer.value=t.shadowLength}update(e,t,i){this.currentMaterial.uniforms.frame.value=t,this.resolveMaterial.uniforms.frame.value=t,this.copyCameraSettings(this.mainCamera),this.copyShadow(),this.currentPass.render(e,null,this.currentRenderTarget),this.resolvePass.render(e,null,this.resolveRenderTarget),this.copyReprojection(),this.swapBuffers()}setSize(e,t){if(this.width=e,this.height=t,this.temporalUpscale){const i=Math.ceil(e/4),r=Math.ceil(t/4);this.currentRenderTarget.setSize(i,r),this.currentMaterial.setSize(i*4,r*4,e,t)}else this.currentRenderTarget.setSize(e,t),this.currentMaterial.setSize(e,t);this.resolveRenderTarget.setSize(e,t),this.resolveMaterial.setSize(e,t),this.historyRenderTarget.setSize(e,t)}setShadowSize(e,t,i){this.currentMaterial.shadowCascadeCount=i,this.currentMaterial.setShadowSize(e,t)}setDepthTexture(e,t){this.currentMaterial.depthBuffer=e,this.currentMaterial.depthPacking=t??0}get outputBuffer(){return this.historyRenderTarget.texture}get shadowBuffer(){return this.currentMaterial.uniforms.shadowBuffer.value}set shadowBuffer(e){this.currentMaterial.uniforms.shadowBuffer.value=e}get shadowLengthBuffer(){return this.historyRenderTarget.shadowLength}get temporalUpscale(){return this.currentMaterial.temporalUpscale}set temporalUpscale(e){e!==this.temporalUpscale&&(this.currentMaterial.temporalUpscale=e,this.resolveMaterial.temporalUpscale=e,this.setSize(this.width,this.height))}get lightShafts(){return this.currentMaterial.shadowLength}set lightShafts(e){e!==this.lightShafts&&(this.currentMaterial.shadowLength=e,this.resolveMaterial.shadowLength=e,this.initRenderTargets({depthVelocity:!0,shadowLength:e}),this.setSize(this.width,this.height))}}function gre(n,e){const t=n.properties.get(e.texture).__webglTexture,i=n.getContext();nc(i instanceof WebGL2RenderingContext),n.setRenderTarget(e);const r=[];if(t!=null)for(let a=0;a<e.depth;++a)i.framebufferTextureLayer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,t,0,a),r.push(i.COLOR_ATTACHMENT0+a);i.drawBuffers(r)}let KO=class extends kE{render(e,t,i,r,a){const s=this.fullscreenMaterial.uniforms;t!==null&&(s==null?void 0:s[this.input])!=null&&(s[this.input].value=t.texture),gre(e,i),e.render(this.scene,this.camera)}};const vre=`precision highp float;
precision highp sampler3D;

#include <common>

#include "core/math"
#include "core/raySphereIntersection"
#include "types"
#include "parameters"
#include "structuredSampling"
#include "clouds"

uniform mat4 inverseShadowMatrices[CASCADE_COUNT];
uniform mat4 reprojectionMatrices[CASCADE_COUNT];

// Primary raymarch
uniform int maxIterationCount;
uniform float minStepSize;
uniform float maxStepSize;
uniform float opticalDepthTailScale;

in vec2 vUv;

layout(location = 0) out vec4 outputColor[CASCADE_COUNT];

// Redundant notation for prettier.
#if CASCADE_COUNT == 1
layout(location = 1) out vec3 outputDepthVelocity[CASCADE_COUNT];
#elif CASCADE_COUNT == 2
layout(location = 2) out vec3 outputDepthVelocity[CASCADE_COUNT];
#elif CASCADE_COUNT == 3
layout(location = 3) out vec3 outputDepthVelocity[CASCADE_COUNT];
#elif CASCADE_COUNT == 4
layout(location = 4) out vec3 outputDepthVelocity[CASCADE_COUNT];
#endif // CASCADE_COUNT

vec4 marchClouds(
  const vec3 rayOrigin,
  const vec3 rayDirection,
  const float maxRayDistance,
  const float jitter,
  const float mipLevel
) {
  // Setup structured volume sampling (SVS).
  // While SVS introduces spatial aliasing, it is indeed temporally stable,
  // which is important for lower-resolution shadow maps where a flickering
  // single pixel can be highly noticeable.
  vec3 normal = getStructureNormal(rayDirection, jitter);
  float rayDistance;
  float stepSize;
  intersectStructuredPlanes(
    normal,
    rayOrigin,
    rayDirection,
    clamp(maxRayDistance / float(maxIterationCount), minStepSize, maxStepSize),
    rayDistance,
    stepSize
  );

  #ifdef TEMPORAL_JITTER
  rayDistance -= stepSize * jitter;
  #endif // TEMPORAL_JITTER

  float extinctionSum = 0.0;
  float maxOpticalDepth = 0.0;
  float maxOpticalDepthTail = 0.0;
  float transmittanceIntegral = 1.0;
  float weightedDistanceSum = 0.0;
  float transmittanceSum = 0.0;

  int sampleCount = 0;
  for (int i = 0; i < maxIterationCount; ++i) {
    if (rayDistance > maxRayDistance) {
      break; // Termination
    }

    vec3 position = rayDistance * rayDirection + rayOrigin;
    float height = length(position) - bottomRadius;

    #if !defined(DEBUG_MARCH_INTERVALS)
    if (insideLayerIntervals(height)) {
      rayDistance += stepSize;
      continue;
    }
    #endif // !defined(DEBUG_MARCH_INTERVALS)

    // Sample rough weather.
    vec2 uv = getGlobeUv(position);
    WeatherSample weather = sampleWeather(uv, height, mipLevel);

    if (any(greaterThan(weather.density, vec4(minDensity)))) {
      // Sample detailed participating media.
      // Note this assumes an homogeneous medium.
      MediaSample media = sampleMedia(weather, position, uv, mipLevel, jitter);
      if (media.extinction > minExtinction) {
        extinctionSum += media.extinction;
        maxOpticalDepth += media.extinction * stepSize;
        transmittanceIntegral *= exp(-media.extinction * stepSize);
        weightedDistanceSum += rayDistance * transmittanceIntegral;
        transmittanceSum += transmittanceIntegral;
        ++sampleCount;
      }
    }

    if (transmittanceIntegral <= minTransmittance) {
      // A large amount of optical depth accumulates in the tail, beyond the
      // point of minimum transmittance. The expected optical depth seems to
      // decrease exponentially with the number of samples taken before reaching
      // the minimum transmittance.
      // See the discussion here: https://x.com/shotamatsuda/status/1886259549931520437
      maxOpticalDepthTail = min(
        opticalDepthTailScale * stepSize * exp(float(1 - sampleCount)),
        stepSize * 0.5 // Excessive optical depth only introduces aliasing.
      );
      break; // Early termination
    }
    rayDistance += stepSize;
  }

  if (sampleCount == 0) {
    return vec4(maxRayDistance, 0.0, 0.0, 0.0);
  }
  float frontDepth = min(weightedDistanceSum / transmittanceSum, maxRayDistance);
  float meanExtinction = extinctionSum / float(sampleCount);
  return vec4(frontDepth, meanExtinction, maxOpticalDepth, maxOpticalDepthTail);
}

void getRayNearFar(
  const vec3 sunPosition,
  const vec3 rayDirection,
  out float rayNear,
  out float rayFar
) {
  vec4 firstIntersections = raySphereFirstIntersection(
    sunPosition,
    rayDirection,
    vec3(0.0),
    bottomRadius + vec4(shadowTopHeight, shadowBottomHeight, 0.0, 0.0)
  );
  rayNear = max(0.0, firstIntersections.x);
  rayFar = firstIntersections.y;
  if (rayFar < 0.0) {
    rayFar = 1e6;
  }
}

void cascade(
  const int cascadeIndex,
  const float mipLevel,
  out vec4 outputColor,
  out vec3 outputDepthVelocity
) {
  vec2 clip = vUv * 2.0 - 1.0;
  vec4 point = inverseShadowMatrices[cascadeIndex] * vec4(clip.xy, -1.0, 1.0);
  point /= point.w;
  vec3 sunPosition = (worldToECEFMatrix * vec4(point.xyz, 1.0)).xyz + altitudeCorrection;

  vec3 rayDirection = normalize(-sunDirection);
  float rayNear;
  float rayFar;
  getRayNearFar(sunPosition, rayDirection, rayNear, rayFar);

  vec3 rayOrigin = rayNear * rayDirection + sunPosition;
  float stbn = getSTBN();
  vec4 color = marchClouds(rayOrigin, rayDirection, rayFar - rayNear, stbn, mipLevel);
  outputColor = color;

  // Velocity for temporal resolution.
  #ifdef TEMPORAL_PASS
  vec3 frontPosition = color.x * rayDirection + rayOrigin;
  vec3 frontPositionWorld = (ecefToWorldMatrix * vec4(frontPosition - altitudeCorrection, 1.0)).xyz;
  vec4 prevClip = reprojectionMatrices[cascadeIndex] * vec4(frontPositionWorld, 1.0);
  prevClip /= prevClip.w;
  vec2 prevUv = prevClip.xy * 0.5 + 0.5;
  vec2 velocity = (vUv - prevUv) * resolution;
  outputDepthVelocity = vec3(color.x, velocity);
  #else // TEMPORAL_PASS
  outputDepthVelocity = vec3(0.0);
  #endif // TEMPORAL_PASS
}

// TODO: Calculate from the main camera frustum perhaps?
const float mipLevels[4] = float[4](0.0, 0.5, 1.0, 2.0);

void main() {
  #pragma unroll_loop_start
  for (int i = 0; i < 4; ++i) {
    #if UNROLLED_LOOP_INDEX < CASCADE_COUNT
    cascade(UNROLLED_LOOP_INDEX, mipLevels[i], outputColor[i], outputDepthVelocity[i]);
    #endif // UNROLLED_LOOP_INDEX < CASCADE_COUNT
  }
  #pragma unroll_loop_end
}
`,_re=`precision highp float;

layout(location = 0) in vec3 position;

out vec2 vUv;

void main() {
  vUv = position.xy * 0.5 + 0.5;
  gl_Position = vec4(position.xy, 1.0, 1.0);
}
`,xre=`// Implements Structured Volume Sampling in fragment shader:
// https://github.com/huwb/volsample
// Implementation reference:
// https://www.shadertoy.com/view/ttVfDc

void getIcosahedralVertices(const vec3 direction, out vec3 v1, out vec3 v2, out vec3 v3) {
  // Normalization scalers to fit dodecahedron to unit sphere.
  const float a = 0.85065080835204; // phi / sqrt(2 + phi)
  const float b = 0.5257311121191336; // 1 / sqrt(2 + phi)

  // Derive the vertices of icosahedron where triangle intersects the direction.
  // See: https://www.ppsloan.org/publications/AmbientDice.pdf
  const float kT = 0.6180339887498948; // 1 / phi
  const float kT2 = 0.38196601125010515; // 1 / phi^2
  vec3 absD = abs(direction);
  float selector1 = dot(absD, vec3(1.0, kT2, -kT));
  float selector2 = dot(absD, vec3(-kT, 1.0, kT2));
  float selector3 = dot(absD, vec3(kT2, -kT, 1.0));
  v1 = selector1 > 0.0 ? vec3(a, b, 0.0) : vec3(-b, 0.0, a);
  v2 = selector2 > 0.0 ? vec3(0.0, a, b) : vec3(a, -b, 0.0);
  v3 = selector3 > 0.0 ? vec3(b, 0.0, a) : vec3(0.0, a, -b);
  vec3 octantSign = sign(direction);
  v1 *= octantSign;
  v2 *= octantSign;
  v3 *= octantSign;
}

void swapIfBigger(inout vec4 a, inout vec4 b) {
  if (a.w > b.w) {
    vec4 t = a;
    a = b;
    b = t;
  }
}

void sortVertices(inout vec3 a, inout vec3 b, inout vec3 c) {
  const vec3 base = vec3(0.5, 0.5, 1.0);
  vec4 aw = vec4(a, dot(a, base));
  vec4 bw = vec4(b, dot(b, base));
  vec4 cw = vec4(c, dot(c, base));
  swapIfBigger(aw, bw);
  swapIfBigger(bw, cw);
  swapIfBigger(aw, bw);
  a = aw.xyz;
  b = bw.xyz;
  c = cw.xyz;
}

vec3 getPentagonalWeights(const vec3 direction, const vec3 v1, const vec3 v2, const vec3 v3) {
  float d1 = dot(v1, direction);
  float d2 = dot(v2, direction);
  float d3 = dot(v3, direction);
  vec3 w = exp(vec3(d1, d2, d3) * 40.0);
  return w / (w.x + w.y + w.z);
}

vec3 getStructureNormal(
  const vec3 direction,
  const float jitter,
  out vec3 a,
  out vec3 b,
  out vec3 c,
  out vec3 weights
) {
  getIcosahedralVertices(direction, a, b, c);
  sortVertices(a, b, c);
  weights = getPentagonalWeights(direction, a, b, c);
  return jitter < weights.x
    ? a
    : jitter < weights.x + weights.y
      ? b
      : c;
}

vec3 getStructureNormal(const vec3 direction, const float jitter) {
  vec3 a, b, c, weights;
  return getStructureNormal(direction, jitter, a, b, c, weights);
}

// Reference: https://github.com/huwb/volsample/blob/master/src/unity/Assets/Shaders/RayMarchCore.cginc
void intersectStructuredPlanes(
  const vec3 normal,
  const vec3 rayOrigin,
  const vec3 rayDirection,
  const float samplePeriod,
  out float stepOffset,
  out float stepSize
) {
  float NoD = dot(rayDirection, normal);
  stepSize = samplePeriod / abs(NoD);

  // Skips leftover bit to get from rayOrigin to first strata plane.
  stepOffset = -mod(dot(rayOrigin, normal), samplePeriod) / NoD;

  // mod() gives different results depending on if the arg is negative or
  // positive. This line makes it consistent, and ensures the first sample is in
  // front of the viewer.
  if (stepOffset < 0.0) {
    stepOffset += stepSize;
  }
}
`;var yre=Object.defineProperty,sp=(n,e,t,i)=>{for(var r=void 0,a=n.length-1,s;a>=0;a--)(s=n[a])&&(r=s(e,t,r)||r);return r&&yre(e,t,r),r};class yh extends ph{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i}){super({name:"ShadowMaterial",glslVersion:so,vertexShader:_re,fragmentShader:J0(Nr(vre,{core:{math:wA,raySphereIntersection:Sy},types:gM,parameters:d9,structuredSampling:xre,clouds:f9})),uniforms:{...e,...t,...i,inverseShadowMatrices:new J(Array.from({length:4},()=>new Ve)),reprojectionMatrices:new J(Array.from({length:4},()=>new Ve)),resolution:new J(new de),frame:new J(0),stbnTexture:new J(null),maxIterationCount:new J(It.shadow.maxIterationCount),minStepSize:new J(It.shadow.minStepSize),maxStepSize:new J(It.shadow.maxStepSize),minDensity:new J(It.shadow.minDensity),minExtinction:new J(It.shadow.minExtinction),minTransmittance:new J(It.shadow.minTransmittance),opticalDepthTailScale:new J(2)},defines:{SHADOW:"1",TEMPORAL_PASS:"1",TEMPORAL_JITTER:"1"}}),this.localWeatherChannels="rgba",this.cascadeCount=It.shadow.cascadeCount,this.temporalPass=!0,this.temporalJitter=!0,this.shapeDetail=It.shapeDetail,this.turbulence=It.turbulence,this.cascadeCount=It.shadow.cascadeCount}setSize(e,t){this.uniforms.resolution.value.set(e,t)}}sp([zP("LOCAL_WEATHER_CHANNELS",{validate:n=>/^[rgba]{4}$/.test(n)})],yh.prototype,"localWeatherChannels");sp([_h("CASCADE_COUNT",{min:1,max:4})],yh.prototype,"cascadeCount");sp([pn("TEMPORAL_PASS")],yh.prototype,"temporalPass");sp([pn("TEMPORAL_JITTER")],yh.prototype,"temporalJitter");sp([pn("SHAPE_DETAIL")],yh.prototype,"shapeDetail");sp([pn("TURBULENCE")],yh.prototype,"turbulence");const Sre=`precision highp float;
precision highp sampler2DArray;

#define VARIANCE_9_SAMPLES 1
#define VARIANCE_SAMPLER_ARRAY 1

#include "varianceClipping"

uniform sampler2DArray inputBuffer;
uniform sampler2DArray historyBuffer;

uniform vec2 texelSize;
uniform float varianceGamma;
uniform float temporalAlpha;

in vec2 vUv;

layout(location = 0) out vec4 outputColor[CASCADE_COUNT];

const ivec2 neighborOffsets[9] = ivec2[9](
  ivec2(-1, -1),
  ivec2(-1, 0),
  ivec2(-1, 1),
  ivec2(0, -1),
  ivec2(0, 0),
  ivec2(0, 1),
  ivec2(1, -1),
  ivec2(1, 0),
  ivec2(1, 1)
);

vec4 getClosestFragment(const ivec3 coord) {
  vec4 result = vec4(1e7, 0.0, 0.0, 0.0);
  vec4 neighbor;
  #pragma unroll_loop_start
  for (int i = 0; i < 9; ++i) {
    neighbor = texelFetchOffset(
      inputBuffer,
      coord + ivec3(0, 0, CASCADE_COUNT),
      0,
      neighborOffsets[i]
    );
    if (neighbor.r < result.r) {
      result = neighbor;
    }
  }
  #pragma unroll_loop_end
  return result;
}

void cascade(const int cascadeIndex, out vec4 outputColor) {
  ivec3 coord = ivec3(gl_FragCoord.xy, cascadeIndex);
  vec4 current = texelFetch(inputBuffer, coord, 0);

  vec4 depthVelocity = getClosestFragment(coord);
  vec2 velocity = depthVelocity.gb * texelSize;
  vec2 prevUv = vUv - velocity;
  if (prevUv.x < 0.0 || prevUv.x > 1.0 || prevUv.y < 0.0 || prevUv.y > 1.0) {
    outputColor = current;
    return; // Rejection
  }

  vec4 history = texture(historyBuffer, vec3(prevUv, float(cascadeIndex)));
  vec4 clippedHistory = varianceClipping(inputBuffer, coord, current, history, varianceGamma);
  outputColor = mix(clippedHistory, current, temporalAlpha);
}

void main() {
  #pragma unroll_loop_start
  for (int i = 0; i < 4; ++i) {
    #if UNROLLED_LOOP_INDEX < CASCADE_COUNT
    cascade(UNROLLED_LOOP_INDEX, outputColor[i]);
    #endif // UNROLLED_LOOP_INDEX < CASCADE_COUNT
  }
  #pragma unroll_loop_end
}
`,Tre=`precision highp float;

layout(location = 0) in vec3 position;

out vec2 vUv;

void main() {
  vUv = position.xy * 0.5 + 0.5;
  gl_Position = vec4(position.xy, 1.0, 1.0);
}
`;var Ere=Object.defineProperty,Mre=(n,e,t,i)=>{for(var r=void 0,a=n.length-1,s;a>=0;a--)(s=n[a])&&(r=s(e,t,r)||r);return r&&Ere(e,t,r),r};class v9 extends ph{constructor({inputBuffer:e=null,historyBuffer:t=null}={}){super({name:"ShadowResolveMaterial",glslVersion:so,vertexShader:Tre,fragmentShader:J0(Nr(Sre,{varianceClipping:p9})),uniforms:{inputBuffer:new J(e),historyBuffer:new J(t),texelSize:new J(new de),varianceGamma:new J(1),temporalAlpha:new J(.01)},defines:{}}),this.cascadeCount=It.shadow.cascadeCount}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}}Mre([_h("CASCADE_COUNT",{min:1,max:4})],v9.prototype,"cascadeCount");function h3(n){const e=new jU(1,1,1,{depthBuffer:!1});return e.texture.type=Yn,e.texture.minFilter=Ht,e.texture.magFilter=Ht,e.texture.name=n,e}class bre extends g9{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i,...r}){super("ShadowPass",r),this.width=0,this.height=0,this.currentMaterial=new yh({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i}),this.currentPass=new KO(this.currentMaterial),this.resolveMaterial=new v9,this.resolvePass=new KO(this.resolveMaterial),this.initRenderTargets()}initialize(e,t,i){this.currentPass.initialize(e,t,i),this.resolvePass.initialize(e,t,i)}initRenderTargets(){var a,s,o;(a=this.currentRenderTarget)==null||a.dispose(),(s=this.resolveRenderTarget)==null||s.dispose(),(o=this.historyRenderTarget)==null||o.dispose();const e=h3("Shadow"),t=this.temporalPass?h3("Shadow.A"):null,i=this.temporalPass?h3("Shadow.B"):null;this.currentRenderTarget=e,this.resolveRenderTarget=t,this.historyRenderTarget=i;const r=this.resolveMaterial.uniforms;r.inputBuffer.value=e.texture,r.historyBuffer.value=(i==null?void 0:i.texture)??null}copyShadow(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let i=0;i<e.cascadeCount;++i){const r=e.cascades[i];t.inverseShadowMatrices.value[i].copy(r.inverseMatrix)}}copyReprojection(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let i=0;i<e.cascadeCount;++i){const r=e.cascades[i];t.reprojectionMatrices.value[i].copy(r.matrix)}}swapBuffers(){nc(this.historyRenderTarget!=null),nc(this.resolveRenderTarget!=null);const e=this.historyRenderTarget,t=this.resolveRenderTarget;this.resolveRenderTarget=e,this.historyRenderTarget=t,this.resolveMaterial.uniforms.historyBuffer.value=t.texture}update(e,t,i){this.currentMaterial.uniforms.frame.value=t,this.copyShadow(),this.currentPass.render(e,null,this.currentRenderTarget),this.temporalPass&&(nc(this.resolveRenderTarget!=null),this.resolvePass.render(e,null,this.resolveRenderTarget),this.copyReprojection(),this.swapBuffers())}setSize(e,t,i=this.shadow.cascadeCount){var r,a;this.width=e,this.height=t,this.currentMaterial.cascadeCount=i,this.resolveMaterial.cascadeCount=i,this.currentMaterial.setSize(e,t),this.resolveMaterial.setSize(e,t),this.currentRenderTarget.setSize(e,t,this.temporalPass?i*2:i),(r=this.resolveRenderTarget)==null||r.setSize(e,t,i),(a=this.historyRenderTarget)==null||a.setSize(e,t,i)}get outputBuffer(){return this.temporalPass?(nc(this.historyRenderTarget!=null),this.historyRenderTarget.texture):this.currentRenderTarget.texture}get temporalPass(){return this.currentMaterial.temporalPass}set temporalPass(e){e!==this.temporalPass&&(this.currentMaterial.temporalPass=e,this.initRenderTargets(),this.setSize(this.width,this.height))}}function Are(n){return{scatteringCoefficient:new J(1),absorptionCoefficient:new J(0),coverage:new J(.3),localWeatherTexture:new J(n.localWeatherTexture),localWeatherRepeat:new J(n.localWeatherRepeat),localWeatherOffset:new J(n.localWeatherOffset),shapeTexture:new J(n.shapeTexture),shapeRepeat:new J(n.shapeRepeat),shapeOffset:new J(n.shapeOffset),shapeDetailTexture:new J(n.shapeDetailTexture),shapeDetailRepeat:new J(n.shapeDetailRepeat),shapeDetailOffset:new J(n.shapeDetailOffset),turbulenceTexture:new J(n.turbulenceTexture),turbulenceRepeat:new J(n.turbulenceRepeat),turbulenceDisplacement:new J(350)}}function wre(){return{minLayerHeights:new J(new zt),maxLayerHeights:new J(new zt),minIntervalHeights:new J(new L),maxIntervalHeights:new J(new L),densityScales:new J(new zt),shapeAmounts:new J(new zt),shapeDetailAmounts:new J(new zt),weatherExponents:new J(new zt),shapeAlteringBiases:new J(new zt),coverageFilterWidths:new J(new zt),minHeight:new J(0),maxHeight:new J(0),shadowTopHeight:new J(0),shadowBottomHeight:new J(0),shadowLayerMask:new J(new zt),densityProfile:new J({expTerms:new zt,exponents:new zt,linearTerms:new zt,constantTerms:new zt})}}const f3=[0,0,0,0];function Rre(n,e){e.packValues("altitude",n.minLayerHeights.value),e.packSums("altitude","height",n.maxLayerHeights.value),e.packIntervalHeights(n.minIntervalHeights.value,n.maxIntervalHeights.value),e.packValues("densityScale",n.densityScales.value),e.packValues("shapeAmount",n.shapeAmounts.value),e.packValues("shapeDetailAmount",n.shapeDetailAmounts.value),e.packValues("weatherExponent",n.weatherExponents.value),e.packValues("shapeAlteringBias",n.shapeAlteringBiases.value),e.packValues("coverageFilterWidth",n.coverageFilterWidths.value);const t=n.densityProfile.value;e.packDensityProfiles("expTerm",t.expTerms),e.packDensityProfiles("exponent",t.exponents),e.packDensityProfiles("linearTerm",t.linearTerms),e.packDensityProfiles("constantTerm",t.constantTerms);let i=1/0,r=0,a=1/0,s=0;f3.fill(0);for(let o=0;o<e.length;++o){const{altitude:l,height:h,shadow:f}=e[o],d=l+h;h>0&&(l<i&&(i=l),f&&l<a&&(a=l),d>r&&(r=d),f&&d>s&&(s=d)),f3[o]=f?1:0}i!==1/0?(n.minHeight.value=i,n.maxHeight.value=r):(nc(r===0),n.minHeight.value=0),a!==1/0?(n.shadowBottomHeight.value=a,n.shadowTopHeight.value=s):(nc(s===0),n.shadowBottomHeight.value=0),n.shadowLayerMask.value.fromArray(f3)}function Cre(n,e){return{bottomRadius:new J(n.bottomRadius),topRadius:new J(n.topRadius),worldToECEFMatrix:new J(e.worldToECEFMatrix),ecefToWorldMatrix:new J(e.ecefToWorldMatrix),altitudeCorrection:new J(e.altitudeCorrection),sunDirection:new J(e.sunDirection)}}const Dre=`uniform sampler2D cloudsBuffer;

void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
  #ifdef SKIP_RENDERING
  outputColor = inputColor;
  #else // SKIP_RENDERING
  vec4 clouds = texture(cloudsBuffer, uv);
  outputColor.rgb = inputColor.rgb * (1.0 - clouds.a) + clouds.rgb;
  outputColor.a = inputColor.a * (1.0 - clouds.a) + clouds.a;
  #endif // SKIP_RENDERING
}
`;var Nre=Object.defineProperty,Ore=(n,e,t,i)=>{for(var r=void 0,a=n.length-1,s;a>=0;a--)(s=n[a])&&(r=s(e,t,r)||r);return r&&Nre(e,t,r),r};const lm=new L,Lre=new de,Ire=new Et,Ure=["maxIterationCount","minStepSize","maxStepSize","maxRayDistance","perspectiveStepScale","minDensity","minExtinction","minTransmittance","maxIterationCountToSun","maxIterationCountToGround","minSecondaryStepSize","secondaryStepScale","maxShadowFilterRadius","maxShadowLengthIterationCount","minShadowLengthStepSize","maxShadowLengthRayDistance","hazeDensityScale","hazeExponent","hazeScatteringCoefficient","hazeAbsorptionCoefficient"],Pre=["multiScatteringOctaves","accurateSunSkyLight","accuratePhaseFunction"],zre=["maxIterationCount","minStepSize","maxStepSize","minDensity","minExtinction","minTransmittance","opticalDepthTailScale"],Bre=["temporalJitter"],Hre=["temporalPass"],Fre=["cascadeCount","mapSize","maxFar","farScale","splitMode","splitLambda"],zo={type:"change"},_9={resolutionScale:It.resolutionScale,width:os.AUTO_SIZE,height:os.AUTO_SIZE};class x9 extends T0{constructor(e=new wc,t,i=$0.DEFAULT){var f,d,p,g;super("CloudsEffect",Dre,{attributes:tl.DEPTH,uniforms:new Map([["cloudsBuffer",new J(null)]])}),this.camera=e,this.atmosphere=i,this.cloudLayers=d1.DEFAULT.clone(),this.correctAltitude=!0,this.localWeatherRepeat=new de().setScalar(100),this.localWeatherOffset=new de,this.shapeRepeat=new L().setScalar(3e-4),this.shapeOffset=new L,this.shapeDetailRepeat=new L().setScalar(.006),this.shapeDetailOffset=new L,this.turbulenceRepeat=new de().setScalar(20),this.worldToECEFMatrix=new Ve,this.ecefToWorldMatrix=new Ve,this.altitudeCorrection=new L,this.sunDirection=new L,this.localWeatherVelocity=new de,this.shapeVelocity=new L,this.shapeDetailVelocity=new L,this._atmosphereOverlay=null,this._atmosphereShadow=null,this._atmosphereShadowLength=null,this.events=new ra,this.frame=0,this.shadowCascadeCount=0,this.shadowMapSize=new de,this.onResolutionChange=()=>{this.setSize(this.resolution.baseWidth,this.resolution.baseHeight)},this.skipRendering=!0;const{resolutionScale:r,width:a,height:s,resolutionX:o=a,resolutionY:l=s}={..._9,...t};this.shadowMaps=new ire({cascadeCount:It.shadow.cascadeCount,mapSize:It.shadow.mapSize,splitLambda:.6}),this.parameterUniforms=Are({localWeatherTexture:((f=this.proceduralLocalWeather)==null?void 0:f.texture)??null,localWeatherRepeat:this.localWeatherRepeat,localWeatherOffset:this.localWeatherOffset,shapeTexture:((d=this.proceduralShape)==null?void 0:d.texture)??null,shapeRepeat:this.shapeRepeat,shapeOffset:this.shapeOffset,shapeDetailTexture:((p=this.proceduralShapeDetail)==null?void 0:p.texture)??null,shapeDetailRepeat:this.shapeDetailRepeat,shapeDetailOffset:this.shapeDetailOffset,turbulenceTexture:((g=this.proceduralTurbulence)==null?void 0:g.texture)??null,turbulenceRepeat:this.turbulenceRepeat}),this.layerUniforms=wre(),this.atmosphereUniforms=Cre(i,{worldToECEFMatrix:this.worldToECEFMatrix,ecefToWorldMatrix:this.ecefToWorldMatrix,altitudeCorrection:this.altitudeCorrection,sunDirection:this.sunDirection});const h={shadow:this.shadowMaps,parameterUniforms:this.parameterUniforms,layerUniforms:this.layerUniforms,atmosphereUniforms:this.atmosphereUniforms};this.shadowPass=new bre(h),this.shadowPass.mainCamera=e,this.cloudsPass=new mre(h,i),this.cloudsPass.mainCamera=e,this.clouds=CO(DO({},this.cloudsPass.currentMaterial,Ure),this.cloudsPass.currentMaterial,Pre),this.shadow=CO(DO({},this.shadowPass.currentMaterial,zre),this.shadowPass.currentMaterial,Bre,this.shadowPass,Hre,this.shadowMaps,Fre),this.resolution=new os(this,o,l,r),this.resolution.addEventListener("change",this.onResolutionChange)}get mainCamera(){return this.camera}set mainCamera(e){this.camera=e,this.shadowPass.mainCamera=e,this.cloudsPass.mainCamera=e}initialize(e,t,i){this.shadowPass.initialize(e,t,i),this.cloudsPass.initialize(e,t,i)}updateSharedUniforms(e){Rre(this.layerUniforms,this.cloudLayers);const{parameterUniforms:t}=this;t.localWeatherOffset.value.add(Lre.copy(this.localWeatherVelocity).multiplyScalar(e)),t.shapeOffset.value.add(lm.copy(this.shapeVelocity).multiplyScalar(e)),t.shapeDetailOffset.value.add(lm.copy(this.shapeDetailVelocity).multiplyScalar(e));const i=this.worldToECEFMatrix;this.ecefToWorldMatrix.copy(i).invert();const r=this.camera.getWorldPosition(lm).applyMatrix4(this.worldToECEFMatrix),a=this.altitudeCorrection;this.correctAltitude?RA(r,this.atmosphere.bottomRadius,this.ellipsoid,a):a.setScalar(0);const s=this.ellipsoid.getSurfaceNormal(r,lm),o=this.sunDirection.dot(s),l=PP(1e6,1e3,o),h=Ire.setFromMatrix4(i).transpose();this.shadowMaps.update(this.camera,lm.copy(this.sunDirection).applyMatrix3(h),l)}updateWeatherTextureChannels(){const e=this.cloudLayers.localWeatherChannels;this.cloudsPass.currentMaterial.localWeatherChannels=e,this.shadowPass.currentMaterial.localWeatherChannels=e}updateAtmosphereComposition(){const{shadowMaps:e,shadowPass:t,cloudsPass:i}=this,r=t.currentMaterial.uniforms,a=i.currentMaterial.uniforms,s=this._atmosphereOverlay,o=Object.assign(this._atmosphereOverlay??{},{map:i.outputBuffer});s!==o&&(this._atmosphereOverlay=o,zo.target=this,zo.property="atmosphereOverlay",this.events.dispatchEvent(zo));const l=this._atmosphereShadow,h=Object.assign(this._atmosphereShadow??{},{map:t.outputBuffer,mapSize:e.mapSize,cascadeCount:e.cascadeCount,intervals:a.shadowIntervals.value,matrices:a.shadowMatrices.value,inverseMatrices:r.inverseShadowMatrices.value,far:e.far,topHeight:a.shadowTopHeight.value});l!==h&&(this._atmosphereShadow=h,zo.target=this,zo.property="atmosphereShadow",this.events.dispatchEvent(zo));const f=this._atmosphereShadowLength,d=i.shadowLengthBuffer!=null?Object.assign(this._atmosphereShadowLength??{},{map:i.shadowLengthBuffer}):null;f!==d&&(this._atmosphereShadowLength=d,zo.target=this,zo.property="atmosphereShadowLength",this.events.dispatchEvent(zo))}update(e,t,i=0){var o,l,h,f;const{shadowMaps:r,shadowPass:a,cloudsPass:s}=this;if(r.cascadeCount!==this.shadowCascadeCount||!r.mapSize.equals(this.shadowMapSize)){const{width:d,height:p}=r.mapSize,g=r.cascadeCount;this.shadowMapSize.set(d,p),this.shadowCascadeCount=g,a.setSize(d,p,g),s.setShadowSize(d,p,g)}(o=this.proceduralLocalWeather)==null||o.render(e,i),(l=this.proceduralShape)==null||l.render(e,i),(h=this.proceduralShapeDetail)==null||h.render(e,i),(f=this.proceduralTurbulence)==null||f.render(e,i),++this.frame,this.updateSharedUniforms(i),this.updateWeatherTextureChannels(),a.update(e,this.frame,i),s.shadowBuffer=a.outputBuffer,s.update(e,this.frame,i),this.updateAtmosphereComposition(),this.uniforms.get("cloudsBuffer").value=this.cloudsPass.outputBuffer}setSize(e,t){const{resolution:i}=this;i.setBaseSize(e,t);const{width:r,height:a}=i;this.cloudsPass.setSize(r,a)}setDepthTexture(e,t){this.shadowPass.setDepthTexture(e,t),this.cloudsPass.setDepthTexture(e,t)}set qualityPreset(e){const{clouds:t,shadow:i,...r}=are[e];Object.assign(this,r),Object.assign(this.clouds,t),Object.assign(this.shadow,i)}get localWeatherTexture(){return this.proceduralLocalWeather??this.parameterUniforms.localWeatherTexture.value}set localWeatherTexture(e){e instanceof Nn||e==null?(this.proceduralLocalWeather=void 0,this.parameterUniforms.localWeatherTexture.value=e):(this.proceduralLocalWeather=e,this.parameterUniforms.localWeatherTexture.value=e.texture)}get shapeTexture(){return this.proceduralShape??this.parameterUniforms.shapeTexture.value}set shapeTexture(e){e instanceof ss||e==null?(this.proceduralShape=void 0,this.parameterUniforms.shapeTexture.value=e):(this.proceduralShape=e,this.parameterUniforms.shapeTexture.value=e.texture)}get shapeDetailTexture(){return this.proceduralShapeDetail??this.parameterUniforms.shapeDetailTexture.value}set shapeDetailTexture(e){e instanceof ss||e==null?(this.proceduralShapeDetail=void 0,this.parameterUniforms.shapeDetailTexture.value=e):(this.proceduralShapeDetail=e,this.parameterUniforms.shapeDetailTexture.value=e.texture)}get turbulenceTexture(){return this.proceduralTurbulence??this.parameterUniforms.turbulenceTexture.value}set turbulenceTexture(e){e instanceof Nn||e==null?(this.proceduralTurbulence=void 0,this.parameterUniforms.turbulenceTexture.value=e):(this.proceduralTurbulence=e,this.parameterUniforms.turbulenceTexture.value=e.texture)}get stbnTexture(){return this.cloudsPass.currentMaterial.uniforms.stbnTexture.value}set stbnTexture(e){this.cloudsPass.currentMaterial.uniforms.stbnTexture.value=e,this.shadowPass.currentMaterial.uniforms.stbnTexture.value=e}get resolutionScale(){return this.resolution.scale}set resolutionScale(e){this.resolution.scale=e}get temporalUpscale(){return this.cloudsPass.temporalUpscale}set temporalUpscale(e){this.cloudsPass.temporalUpscale=e}get lightShafts(){return this.cloudsPass.lightShafts}set lightShafts(e){this.cloudsPass.lightShafts=e}get shapeDetail(){return this.cloudsPass.currentMaterial.shapeDetail}set shapeDetail(e){this.cloudsPass.currentMaterial.shapeDetail=e,this.shadowPass.currentMaterial.shapeDetail=e}get turbulence(){return this.cloudsPass.currentMaterial.turbulence}set turbulence(e){this.cloudsPass.currentMaterial.turbulence=e,this.shadowPass.currentMaterial.turbulence=e}get haze(){return this.cloudsPass.currentMaterial.haze}set haze(e){this.cloudsPass.currentMaterial.haze=e}get scatteringCoefficient(){return this.parameterUniforms.scatteringCoefficient.value}set scatteringCoefficient(e){this.parameterUniforms.scatteringCoefficient.value=e}get absorptionCoefficient(){return this.parameterUniforms.absorptionCoefficient.value}set absorptionCoefficient(e){this.parameterUniforms.absorptionCoefficient.value=e}get coverage(){return this.parameterUniforms.coverage.value}set coverage(e){this.parameterUniforms.coverage.value=e}get turbulenceDisplacement(){return this.parameterUniforms.turbulenceDisplacement.value}set turbulenceDisplacement(e){this.parameterUniforms.turbulenceDisplacement.value=e}get scatterAnisotropy1(){return this.cloudsPass.currentMaterial.scatterAnisotropy1}set scatterAnisotropy1(e){this.cloudsPass.currentMaterial.scatterAnisotropy1=e}get scatterAnisotropy2(){return this.cloudsPass.currentMaterial.scatterAnisotropy2}set scatterAnisotropy2(e){this.cloudsPass.currentMaterial.scatterAnisotropy2=e}get scatterAnisotropyMix(){return this.cloudsPass.currentMaterial.scatterAnisotropyMix}set scatterAnisotropyMix(e){this.cloudsPass.currentMaterial.scatterAnisotropyMix=e}get skyIrradianceScale(){return this.skyLightScale}set skyIrradianceScale(e){this.skyLightScale=e}get skyLightScale(){return this.cloudsPass.currentMaterial.uniforms.skyLightScale.value}set skyLightScale(e){this.cloudsPass.currentMaterial.uniforms.skyLightScale.value=e}get groundIrradianceScale(){return this.groundBounceScale}set groundIrradianceScale(e){this.groundBounceScale=e}get groundBounceScale(){return this.cloudsPass.currentMaterial.uniforms.groundBounceScale.value}set groundBounceScale(e){this.cloudsPass.currentMaterial.uniforms.groundBounceScale.value=e}get powderScale(){return this.cloudsPass.currentMaterial.uniforms.powderScale.value}set powderScale(e){this.cloudsPass.currentMaterial.uniforms.powderScale.value=e}get powderExponent(){return this.cloudsPass.currentMaterial.uniforms.powderExponent.value}set powderExponent(e){this.cloudsPass.currentMaterial.uniforms.powderExponent.value=e}get atmosphereOverlay(){return this._atmosphereOverlay}get atmosphereShadow(){return this._atmosphereShadow}get atmosphereShadowLength(){return this._atmosphereShadowLength}get irradianceTexture(){return this.cloudsPass.currentMaterial.irradianceTexture}set irradianceTexture(e){this.cloudsPass.currentMaterial.irradianceTexture=e}get scatteringTexture(){return this.cloudsPass.currentMaterial.scatteringTexture}set scatteringTexture(e){this.cloudsPass.currentMaterial.scatteringTexture=e}get transmittanceTexture(){return this.cloudsPass.currentMaterial.transmittanceTexture}set transmittanceTexture(e){this.cloudsPass.currentMaterial.transmittanceTexture=e}get singleMieScatteringTexture(){return this.cloudsPass.currentMaterial.singleMieScatteringTexture}set singleMieScatteringTexture(e){this.cloudsPass.currentMaterial.singleMieScatteringTexture=e}get higherOrderScatteringTexture(){return this.cloudsPass.currentMaterial.higherOrderScatteringTexture}set higherOrderScatteringTexture(e){this.cloudsPass.currentMaterial.higherOrderScatteringTexture=e}get ellipsoid(){return this.cloudsPass.currentMaterial.ellipsoid}set ellipsoid(e){this.cloudsPass.currentMaterial.ellipsoid=e}get sunAngularRadius(){return this.cloudsPass.currentMaterial.sunAngularRadius}set sunAngularRadius(e){this.cloudsPass.currentMaterial.sunAngularRadius=e}}Ore([pn("SKIP_RENDERING")],x9.prototype,"skipRendering");const Gre=128,Vre=32,Ry="45a1c6c1bb9fd38b3680fd120795ff4c32df68ff",kre=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${Ry}/packages/clouds/assets/local_weather.png`,Wre=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${Ry}/packages/clouds/assets/shape.bin`,Xre=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${Ry}/packages/clouds/assets/shape_detail.bin`,Yre=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${Ry}/packages/clouds/assets/turbulence.png`,y9=Me.createContext(null),qre=({layers:n,disableDefault:e=!1,children:t})=>{const[i,r]=Me.useState();return Me.useLayoutEffect(()=>{n.set(e?Array(4).fill(Ms.DEFAULT):d1.DEFAULT),r({layers:n,indexPool:[0,1,2,3],disableDefault:e})},[n,e]),i!=null&&Mt.jsx(y9.Provider,{value:i,children:t})};function QO(n,e){const t=Me.useMemo(()=>typeof n=="string"?new Jb().load(n,i=>{i.minFilter=NU,i.magFilter=Ht,i.wrapS=Mr,i.wrapT=Mr,i.colorSpace=Or,i.needsUpdate=!0}):void 0,[n]);return Me.useEffect(()=>{if(t!=null)return()=>{t.dispose()}},[t]),(typeof n=="string"?t:n)??null}function JO(n,e){const t=Me.useMemo(()=>typeof n=="string"?new Mu(ss,HP,{width:e,height:e,depth:e,format:ws,minFilter:Ht,magFilter:Ht,wrapS:Mr,wrapT:Mr,wrapR:Mr,colorSpace:Or}).load(n):void 0,[n,e]);return Me.useEffect(()=>{if(t!=null)return()=>{t.dispose()}},[t]),(typeof n=="string"?t:n)??null}function jre(n){const e=Me.useMemo(()=>typeof n=="string"?new FP().load(n):void 0,[n]);return Me.useEffect(()=>{if(e!=null)return()=>{e.dispose()}},[e]),(typeof n=="string"?e:n)??null}const Zre=({ref:n,disableDefaultLayers:e=!1,localWeatherTexture:t=kre,shapeTexture:i=Wre,shapeDetailTexture:r=Xre,turbulenceTexture:a=Yre,stbnTexture:s=dP,children:o,...l})=>{const{textures:h,transientStates:f,...d}=Me.useContext(UA),[p,g]=l9({..._9,...d,...h,...l}),_=Me.useMemo(()=>new x9,[]);Me.useEffect(()=>()=>{_.dispose()},[_]),fl(()=>{f!=null&&(_.sunDirection.copy(f.sunDirection),_.worldToECEFMatrix.copy(f.worldToECEFMatrix))}),Me.useEffect(()=>{if(f!=null)return f.overlay=_.atmosphereOverlay,f.shadow=_.atmosphereShadow,f.shadowLength=_.atmosphereShadowLength,()=>{f.overlay=null,f.shadow=null,f.shadowLength=null}},[_,f]);const T=Me.useCallback(R=>{if(f!=null)switch(R.property){case"atmosphereOverlay":f.overlay=_.atmosphereOverlay;break;case"atmosphereShadow":f.shadow=_.atmosphereShadow;break;case"atmosphereShadowLength":f.shadowLength=_.atmosphereShadowLength;break}},[_,f]);Me.useEffect(()=>(_.events.addEventListener("change",T),()=>{_.events.removeEventListener("change",T)}),[_,T]),Ni(({gl:R})=>R);const y=QO(t),v=JO(i,Gre),S=JO(r,Vre),E=QO(a),b=jre(s),{camera:N}=Me.useContext(vA);return Mt.jsxs(Mt.Fragment,{children:[Mt.jsx("primitive",{ref:n,object:_,mainCamera:N,...p,localWeatherTexture:y,shapeTexture:v,shapeDetailTexture:S,turbulenceTexture:E,stbnTexture:b,...g}),Mt.jsx(qre,{layers:_.cloudLayers,disableDefault:e,children:o})]})},Kre=({ref:n,index:e,...t})=>{const i=Me.useContext(y9);if(i==null)throw new Error("CloudLayer can only be used within the Clouds component!");const{layers:r,indexPool:a,disableDefault:s}=i,[o,l]=Me.useState();if(Me.useLayoutEffect(()=>{if(e!=null){const h=a.indexOf(e);if(h!==-1)return a.splice(h,1),l(e),()=>{a.push(e),l(void 0)}}else{const h=a.sort((f,d)=>f-d).shift();if(h!=null)return l(h),()=>{a.push(h),l(void 0)}}},[e,r,a]),Me.useLayoutEffect(()=>{if(o==null)return;const h=r[o];return()=>{h.copy(s?Ms.DEFAULT:d1.DEFAULT[o])}},[r,o,s]),Me.useEffect(()=>{o!=null&&(typeof n=="function"?n(r[o]):n!=null&&(n.current=r[o]))},[n,r,o]),o!=null){const h=r[o];h.copy(s?Ms.DEFAULT:d1.DEFAULT[o]),h.set(t)}return null},d3=new WeakMap;class Qre extends yi{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,i,r){const a=new na(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,s=>{this.parse(s,t,r)},i,r)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,dn,i).catch(i)}decodeDracoFile(e,t,i,r,a=Fn,s=()=>{}){const o={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:a};return this.decodeGeometry(e,o).then(t).catch(s)}decodeGeometry(e,t){const i=JSON.stringify(t);if(d3.has(e)){const l=d3.get(e);if(l.key===i)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const a=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(a,s).then(l=>(r=l,new Promise((h,f)=>{r._callbacks[a]={resolve:h,reject:f},r.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{r&&a&&this._releaseTask(r,a)}),d3.set(e,{key:i,promise:o}),o}_createGeometry(e){const t=new Ct;e.index&&t.setIndex(new Ot(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:r,array:a,itemSize:s,stride:o,vertexColorSpace:l}=e.attributes[i];let h;if(s===o)h=new Ot(a,s);else{const f=new Zd(a,o);h=new ll(f,s,0)}r==="color"&&(this._assignVertexColorSpace(h,l),h.normalized=!(a instanceof Float32Array)),t.setAttribute(r,h)}return t}_assignVertexColorSpace(e,t){if(t!==dn)return;const i=new qe;for(let r=0,a=e.count;r<a;r++)i.fromBufferAttribute(e,r),en.colorSpaceToWorking(i,dn),e.setXYZ(r,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new na(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,a)=>{i.load(e,r,void 0,a)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{const r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const a=Jre.toString(),s=["/* draco decoder */",r,"","/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
`);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(a){const s=a.data;switch(s.type){case"decode":r._callbacks[s.id].resolve(s);break;case"error":r._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,a){return r._taskLoad>a._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_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.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Jre(){let n,e;onmessage=function(s){const o=s.data;switch(o.type){case"init":n=o.decoderConfig,e=new Promise(function(f){n.onModuleLoaded=function(d){f({draco:d})},DracoDecoderModule(n)});break;case"decode":const l=o.buffer,h=o.taskConfig;e.then(f=>{const d=f.draco,p=new d.Decoder;try{const g=t(d,p,new Int8Array(l),h),_=g.attributes.map(T=>T.array.buffer);g.index&&_.push(g.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:g},_)}catch(g){console.error(g),self.postMessage({type:"error",id:o.id,error:g.message})}finally{d.destroy(p)}});break}};function t(s,o,l,h){const f=h.attributeIDs,d=h.attributeTypes;let p,g;const _=o.GetEncodedGeometryType(l);if(_===s.TRIANGULAR_MESH)p=new s.Mesh,g=o.DecodeArrayToMesh(l,l.byteLength,p);else if(_===s.POINT_CLOUD)p=new s.PointCloud,g=o.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!g.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());const T={index:null,attributes:[]};for(const y in f){const v=self[d[y]];let S,E;if(h.useUniqueIDs)E=f[y],S=o.GetAttributeByUniqueId(p,E);else{if(E=o.GetAttributeId(p,s[f[y]]),E===-1)continue;S=o.GetAttribute(p,E)}const b=r(s,o,p,y,v,S);y==="color"&&(b.vertexColorSpace=h.vertexColorSpace),T.attributes.push(b)}return _===s.TRIANGULAR_MESH&&(T.index=i(s,o,p)),s.destroy(p),T}function i(s,o,l){const f=l.num_faces()*3,d=f*4,p=s._malloc(d);o.GetTrianglesUInt32Array(l,d,p);const g=new Uint32Array(s.HEAPF32.buffer,p,f).slice();return s._free(p),{array:g,itemSize:1}}function r(s,o,l,h,f,d){const p=l.num_points(),g=d.num_components(),_=a(s,f),T=g*f.BYTES_PER_ELEMENT,y=Math.ceil(T/4)*4,v=y/f.BYTES_PER_ELEMENT,S=p*T,E=p*y,b=s._malloc(S);o.GetAttributeDataArrayForAllPoints(l,d,_,S,b);const N=new f(s.HEAPF32.buffer,b,S/f.BYTES_PER_ELEMENT);let R;if(T===y)R=N.slice();else{R=new f(E/f.BYTES_PER_ELEMENT);let I=0;for(let U=0,O=N.length;U<O;U++){for(let w=0;w<g;w++)R[I+w]=N[U*g+w];I+=v}}return s._free(b),{name:h,count:p,itemSize:g,array:R,stride:v}}function a(s,o){switch(o){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}const N_="/pkg/atmosphere/",$re=`${N_}ai.vrm`,eae=6378137,tae=5*60*1e3,nae=100,iae=new Date("2024-06-21T12:00:00"),$O=[{name:"Clear (快晴)",coverage:.1,layers:[{channel:"r",altitude:1500,height:500,densityScale:0},{channel:"g",altitude:2500,height:800,densityScale:0},{channel:"b",altitude:7500,height:500,densityScale:.1}]},{name:"Sunny (晴れ)",coverage:.4,layers:[{channel:"r",altitude:1500,height:500,densityScale:.4},{channel:"g",altitude:2500,height:800,densityScale:0},{channel:"b",altitude:7500,height:500,densityScale:.2}]},{name:"Cloudy (曇り)",coverage:.75,layers:[{channel:"r",altitude:1500,height:500,densityScale:.6},{channel:"g",altitude:2e3,height:1e3,densityScale:.5},{channel:"b",altitude:7500,height:500,densityScale:0}]}],rae=[{name:"Tokyo",longitude:139.7671,latitude:35.6812,heading:180,pitch:-5,distance:1100},{name:"Fuji",longitude:138.7278,latitude:35.3206,heading:0,pitch:-10,distance:4e3},{name:"Space",longitude:139.7671,latitude:35.6812,heading:0,pitch:-90,distance:1e5}],Sr={position:new L(0,eae+1e5,0),quaternion:new _t,speed:1e3};function zA(n){if(!n)return new _t;window.geodeticLogged||(console.log("Geodetic prototype:",E0.prototype),window.geodeticLogged=!0);const e=n.clone().normalize();return e.lengthSq()<.1?new _t:new _t().setFromUnitVectors(new L(0,1,0),e)}function aae(n){const t=6356752314245e-6,i=n.length();if(i<100)return 6378137;const a=n.z/i,o=6378137*Math.sqrt(1-a*a),l=t*a,h=6378137*o*(6378137*o)+t*l*(t*l),f=o*o+l*l;return Math.sqrt(h/f)}function sae(n){const{longitude:e,latitude:t,heading:i,pitch:r,distance:a}=n,s=new L,o=new _t,l=new L(0,1,0),h=new E0(Tu(e),Tu(t),a).toECEF();new Qte(a,Tu(i),Tu(r)).decompose(new E0(Tu(e),Tu(t)).toECEF(),s,o,l),console.log(`[Teleport] ${n.name} -> Altitude: ${a}, TruePosLength: ${h.length()}`),Sr.position.copy(h);const d=zA(h).clone().invert();Sr.quaternion.copy(d.multiply(o))}const Cn={w:!1,a:!1,s:!1,d:!1,q:!1,e:!1,Shift:!1,Space:!1};typeof window<"u"&&(window.addEventListener("keydown",n=>{const e=n.key.toLowerCase();Cn.hasOwnProperty(e)&&(Cn[e]=!0),n.key==="Shift"&&(Cn.Shift=!0),n.key===" "&&(Cn.Space=!0)}),window.addEventListener("keyup",n=>{const e=n.key.toLowerCase();Cn.hasOwnProperty(e)&&(Cn[e]=!1),n.key==="Shift"&&(Cn.Shift=!1),n.key===" "&&(Cn.Space=!1)}));const oae=new Qre;oae.setDecoderPath("https://www.gstatic.com/draco/v1/decoders/");function lae(){return null}function cae(){const{gl:n}=Ni(),e=Me.useRef(),t=Me.useRef(),i=Me.useRef(new Date(iae)),[r,a]=Me.useState($O[1]);return Me.useEffect(()=>{n.toneMapping=as,n.toneMappingExposure=10},[n]),Me.useEffect(()=>{const s=setInterval(()=>{a(o=>{const l=$O.filter(f=>f.name!==o.name),h=l[Math.floor(Math.random()*l.length)];return console.log(`[Weather] Changing to: ${h.name}`),h})},tae);return()=>clearInterval(s)},[]),fl((s,o)=>{const l=i.current,h=o*nae*1e3;if(l.setTime(l.getTime()+h),t.current){t.current.updateByDate(l);const f=t.current.sunDirection;e.current&&f&&(e.current.position.copy(f),e.current.intensity=3,f.y<-.1&&(e.current.intensity=.1))}}),Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(eP,{makeDefault:!0,near:10,far:1e7,fov:45}),Mt.jsx(uae,{}),Mt.jsx("directionalLight",{ref:e,position:[0,1,0],intensity:3,castShadow:!0}),Mt.jsxs(Vie,{ref:t,children:[Mt.jsx(lae,{}),Mt.jsxs(See,{multisampling:0,disableNormalPass:!1,children:[Mt.jsx(Zre,{disableDefaultLayers:!0,coverage:r.coverage,children:r.layers.map((s,o)=>Mt.jsx(Kre,{channel:s.channel,altitude:s.altitude,height:s.height,densityScale:s.densityScale,shapeAmount:.5},o))}),Mt.jsx(Wie,{sky:!0}),Mt.jsx(Mee,{mode:jr.AGX})]})]})]})}function uae(){return fl(n=>{if(!Sr.position)return;const e=zA(Sr.position);n.camera.position.copy(Sr.position),n.camera.quaternion.copy(e).multiply(Sr.quaternion)}),null}function hae(){const n=Me.useRef(null),e=Me.useRef(null),{camera:t}=Ni(),i=Me.useRef({}),r=Me.useRef(null),a=Qx(sN,$re,h=>{h.register(f=>new vJ(f))}),[s,o,l]=Qx(sN,[`${N_}fly.vrma`,`${N_}fly_stop.vrma`,`${N_}fly_idle.vrma`],h=>{h.register(f=>new $J(f))});return Me.useEffect(()=>{const h=a.userData.vrm;e.current=h,vh.removeUnnecessaryJoints(h.scene),h.humanoid.resetPose(),h.scene.rotation.y=Math.PI;const f=new G6(h.scene);n.current=f;const d=(y,v)=>{var S;if((S=y.userData.vrmAnimations)!=null&&S[0]){const E=qJ(y.userData.vrmAnimations[0],h),b=f.clipAction(E);return b.name=v,b}return null},p=d(s,"fly"),g=d(o,"fly_stop"),_=d(l,"fly_idle");i.current={fly:p,fly_stop:g,fly_idle:_},g&&(g.setLoop(bb),g.clampWhenFinished=!0),_?(_.play(),r.current="fly_idle"):p&&(p.play(),r.current="fly");const T=y=>{y.action===g&&i.current.fly_idle&&(g.fadeOut(.5),i.current.fly_idle.reset().fadeIn(.5).play(),r.current="fly_idle")};return f.addEventListener("finished",T),()=>{f.removeEventListener("finished",T)}},[a,s,o,l]),fl((h,f)=>{var _,T;(_=n.current)==null||_.update(f),(T=e.current)==null||T.update(f);const d=Cn.w||Cn.s||Cn.a||Cn.d,p=i.current,g=r.current;if(p.fly&&p.fly_stop&&p.fly_idle)if(d){if(g!=="fly"){const y=p[g];y&&y.fadeOut(.5),p.fly.reset().fadeIn(.5).play(),r.current="fly"}}else g==="fly"&&(p.fly.fadeOut(.5),p.fly_stop.reset().fadeIn(.5).play(),r.current="fly_stop");if(e.current){const y=e.current.scene,v=new L(0,0,0);if(Cn.w&&(v.z-=1),Cn.s&&(v.z+=1),Cn.a&&(v.x-=1),Cn.d&&(v.x+=1),v.lengthSq()>0){v.normalize();const S=t.quaternion.clone();v.applyQuaternion(S);const E=y.position.clone().sub(v),b=new Wt;b.position.copy(y.position),b.lookAt(E),y.quaternion.slerp(b.quaternion,10*f)}}}),Mt.jsx("primitive",{object:a.scene})}function fae(){const{camera:n}=Ni();new L;const e=Me.useRef(0),t=10,i=2;return fl((r,a)=>{Sr.quaternion.copy(n.quaternion);const s=zA(Sr.position),o=Cn.w||Cn.s||Cn.a||Cn.d||Cn.q||Cn.e,l=Sr.speed*(Cn.Shift?2:1)*a,h=new L;Cn.w&&(h.z-=1),Cn.s&&(h.z+=1),Cn.a&&(h.x-=1),Cn.d&&(h.x+=1);const f=Sr.position.clone().normalize();Cn.e&&Sr.position.addScaledVector(f,l),Cn.q&&Sr.position.addScaledVector(f,-l),h.lengthSq()>0&&(h.normalize(),h.applyQuaternion(n.quaternion),h.applyQuaternion(s),Sr.position.addScaledVector(h,l));const d=Sr.position.length(),p=aae(Sr.position),g=p+10;r.clock.elapsedTime%1<.02&&console.log(`[CameraSync] Dist: ${d.toFixed(1)}, LocalR: ${p.toFixed(1)}, Alt: ${(d-p).toFixed(1)}`),d<g&&Sr.position.setLength(g);const y=((o?t:0)-e.current)*i*a;e.current+=y,n.translateZ(y)}),null}function dae(){return Mt.jsxs(w8,{gl:{alpha:!0,antialias:!0},children:[Mt.jsx(eP,{makeDefault:!0,position:[0,1.5,3],fov:40}),Mt.jsx(fae,{}),Mt.jsx("directionalLight",{position:[-1,1,1],intensity:1.5}),Mt.jsx("ambientLight",{intensity:1}),Mt.jsx("spotLight",{position:[0,2,-2],intensity:3,color:"#ffdcb4"}),Mt.jsx(Me.Suspense,{fallback:null,children:Mt.jsx(hae,{})}),Mt.jsx(u$,{target:[0,1.2,0],minDistance:2,maxDistance:10})]})}function pae(){return Mt.jsx("div",{style:{position:"absolute",top:"20px",left:"20px",zIndex:100,display:"flex",gap:"10px",flexWrap:"wrap"},children:rae.map(n=>Mt.jsx("button",{onClick:()=>sae(n),style:{padding:"10px 20px",background:"rgba(0, 0, 0, 0.6)",color:"white",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"8px",cursor:"pointer",fontSize:"14px",backdropFilter:"blur(4px)",transition:"background 0.2s"},onMouseOver:e=>e.currentTarget.style.background="rgba(0, 0, 0, 0.8)",onMouseOut:e=>e.currentTarget.style.background="rgba(0, 0, 0, 0.6)",children:n.name},n.name))})}function mae(){return Mt.jsx(w8,{gl:{alpha:!0,antialias:!0},children:Mt.jsx(cae,{})})}function gae(){const n={position:"absolute",top:0,left:0,width:"100%",height:"100%"};return Mt.jsxs("div",{style:{position:"relative",width:"100vw",height:"100vh",background:"#000"},children:[Mt.jsx(pae,{}),Mt.jsx("div",{style:{...n,zIndex:0},children:Mt.jsx(mae,{})}),Mt.jsx("div",{style:{...n,zIndex:1,pointerEvents:"none"},children:Mt.jsx("div",{style:{width:"100%",height:"100%",pointerEvents:"auto"},children:Mt.jsx(dae,{})})})]})}_F.createRoot(document.getElementById("root")).render(Mt.jsx(TM.StrictMode,{children:Mt.jsx(gae,{})}));
