1
0
Files
web/static/pkg/atmosphere/assets/index-BwPYqd7E.js
2025-11-20 12:57:07 +09:00

10079 lines
1.6 MiB

var AL=Object.defineProperty;var EL=(n,e,t)=>e in n?AL(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ei=(n,e,t)=>EL(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const r of a)if(r.type==="childList")for(const s of r.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function t(a){const r={};return a.integrity&&(r.integrity=a.integrity),a.referrerPolicy&&(r.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?r.credentials="include":a.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(a){if(a.ep)return;a.ep=!0;const r=t(a);fetch(a.href,r)}})();function Zx(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var _N={exports:{}},jx={};/**
* @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 TL=Symbol.for("react.transitional.element"),bL=Symbol.for("react.fragment");function SN(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 a in e)a!=="key"&&(t[a]=e[a])}else t=e;return e=t.ref,{$$typeof:TL,type:n,key:i,ref:e!==void 0?e:null,props:t}}jx.Fragment=bL;jx.jsx=SN;jx.jsxs=SN;_N.exports=jx;var It=_N.exports,AN={exports:{}},an={};/**
* @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 RT=Symbol.for("react.transitional.element"),ML=Symbol.for("react.portal"),CL=Symbol.for("react.fragment"),RL=Symbol.for("react.strict_mode"),wL=Symbol.for("react.profiler"),DL=Symbol.for("react.consumer"),NL=Symbol.for("react.context"),OL=Symbol.for("react.forward_ref"),IL=Symbol.for("react.suspense"),BL=Symbol.for("react.memo"),EN=Symbol.for("react.lazy"),oR=Symbol.iterator;function UL(n){return n===null||typeof n!="object"?null:(n=oR&&n[oR]||n["@@iterator"],typeof n=="function"?n:null)}var TN={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},bN=Object.assign,MN={};function Dd(n,e,t){this.props=n,this.context=e,this.refs=MN,this.updater=t||TN}Dd.prototype.isReactComponent={};Dd.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")};Dd.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function CN(){}CN.prototype=Dd.prototype;function wT(n,e,t){this.props=n,this.context=e,this.refs=MN,this.updater=t||TN}var DT=wT.prototype=new CN;DT.constructor=wT;bN(DT,Dd.prototype);DT.isPureReactComponent=!0;var lR=Array.isArray,gi={H:null,A:null,T:null,S:null},RN=Object.prototype.hasOwnProperty;function NT(n,e,t,i,a,r){return t=r.ref,{$$typeof:RT,type:n,key:e,ref:t!==void 0?t:null,props:r}}function LL(n,e){return NT(n.type,e,void 0,void 0,void 0,n.props)}function OT(n){return typeof n=="object"&&n!==null&&n.$$typeof===RT}function PL(n){var e={"=":"=0",":":"=2"};return"$"+n.replace(/[=:]/g,function(t){return e[t]})}var cR=/\/+/g;function OS(n,e){return typeof n=="object"&&n!==null&&n.key!=null?PL(""+n.key):e.toString(36)}function uR(){}function FL(n){switch(n.status){case"fulfilled":return n.value;case"rejected":throw n.reason;default:switch(typeof n.status=="string"?n.then(uR,uR):(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 _f(n,e,t,i,a){var r=typeof n;(r==="undefined"||r==="boolean")&&(n=null);var s=!1;if(n===null)s=!0;else switch(r){case"bigint":case"string":case"number":s=!0;break;case"object":switch(n.$$typeof){case RT:case ML:s=!0;break;case EN:return s=n._init,_f(s(n._payload),e,t,i,a)}}if(s)return a=a(n),s=i===""?"."+OS(n,0):i,lR(a)?(t="",s!=null&&(t=s.replace(cR,"$&/")+"/"),_f(a,e,t,"",function(h){return h})):a!=null&&(OT(a)&&(a=LL(a,t+(a.key==null||n&&n.key===a.key?"":(""+a.key).replace(cR,"$&/")+"/")+s)),e.push(a)),1;s=0;var o=i===""?".":i+":";if(lR(n))for(var c=0;c<n.length;c++)i=n[c],r=o+OS(i,c),s+=_f(i,e,t,r,a);else if(c=UL(n),typeof c=="function")for(n=c.call(n),c=0;!(i=n.next()).done;)i=i.value,r=o+OS(i,c++),s+=_f(i,e,t,r,a);else if(r==="object"){if(typeof n.then=="function")return _f(FL(n),e,t,i,a);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 Rg(n,e,t){if(n==null)return n;var i=[],a=0;return _f(n,i,"","",function(r){return e.call(t,r,a++)}),i}function HL(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 hR=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)};function zL(){}an.Children={map:Rg,forEach:function(n,e,t){Rg(n,function(){e.apply(this,arguments)},t)},count:function(n){var e=0;return Rg(n,function(){e++}),e},toArray:function(n){return Rg(n,function(e){return e})||[]},only:function(n){if(!OT(n))throw Error("React.Children.only expected to receive a single React element child.");return n}};an.Component=Dd;an.Fragment=CL;an.Profiler=wL;an.PureComponent=wT;an.StrictMode=RL;an.Suspense=IL;an.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=gi;an.act=function(){throw Error("act(...) is not supported in production builds of React.")};an.cache=function(n){return function(){return n.apply(null,arguments)}};an.cloneElement=function(n,e,t){if(n==null)throw Error("The argument must be a React element, but you passed "+n+".");var i=bN({},n.props),a=n.key,r=void 0;if(e!=null)for(s in e.ref!==void 0&&(r=void 0),e.key!==void 0&&(a=""+e.key),e)!RN.call(e,s)||s==="key"||s==="__self"||s==="__source"||s==="ref"&&e.ref===void 0||(i[s]=e[s]);var s=arguments.length-2;if(s===1)i.children=t;else if(1<s){for(var o=Array(s),c=0;c<s;c++)o[c]=arguments[c+2];i.children=o}return NT(n.type,a,void 0,void 0,r,i)};an.createContext=function(n){return n={$$typeof:NL,_currentValue:n,_currentValue2:n,_threadCount:0,Provider:null,Consumer:null},n.Provider=n,n.Consumer={$$typeof:DL,_context:n},n};an.createElement=function(n,e,t){var i,a={},r=null;if(e!=null)for(i in e.key!==void 0&&(r=""+e.key),e)RN.call(e,i)&&i!=="key"&&i!=="__self"&&i!=="__source"&&(a[i]=e[i]);var s=arguments.length-2;if(s===1)a.children=t;else if(1<s){for(var o=Array(s),c=0;c<s;c++)o[c]=arguments[c+2];a.children=o}if(n&&n.defaultProps)for(i in s=n.defaultProps,s)a[i]===void 0&&(a[i]=s[i]);return NT(n,r,void 0,void 0,null,a)};an.createRef=function(){return{current:null}};an.forwardRef=function(n){return{$$typeof:OL,render:n}};an.isValidElement=OT;an.lazy=function(n){return{$$typeof:EN,_payload:{_status:-1,_result:n},_init:HL}};an.memo=function(n,e){return{$$typeof:BL,type:n,compare:e===void 0?null:e}};an.startTransition=function(n){var e=gi.T,t={};gi.T=t;try{var i=n(),a=gi.S;a!==null&&a(t,i),typeof i=="object"&&i!==null&&typeof i.then=="function"&&i.then(zL,hR)}catch(r){hR(r)}finally{gi.T=e}};an.unstable_useCacheRefresh=function(){return gi.H.useCacheRefresh()};an.use=function(n){return gi.H.use(n)};an.useActionState=function(n,e,t){return gi.H.useActionState(n,e,t)};an.useCallback=function(n,e){return gi.H.useCallback(n,e)};an.useContext=function(n){return gi.H.useContext(n)};an.useDebugValue=function(){};an.useDeferredValue=function(n,e){return gi.H.useDeferredValue(n,e)};an.useEffect=function(n,e){return gi.H.useEffect(n,e)};an.useId=function(){return gi.H.useId()};an.useImperativeHandle=function(n,e,t){return gi.H.useImperativeHandle(n,e,t)};an.useInsertionEffect=function(n,e){return gi.H.useInsertionEffect(n,e)};an.useLayoutEffect=function(n,e){return gi.H.useLayoutEffect(n,e)};an.useMemo=function(n,e){return gi.H.useMemo(n,e)};an.useOptimistic=function(n,e){return gi.H.useOptimistic(n,e)};an.useReducer=function(n,e,t){return gi.H.useReducer(n,e,t)};an.useRef=function(n){return gi.H.useRef(n)};an.useState=function(n){return gi.H.useState(n)};an.useSyncExternalStore=function(n,e,t){return gi.H.useSyncExternalStore(n,e,t)};an.useTransition=function(){return gi.H.useTransition()};an.version="19.0.0";AN.exports=an;var he=AN.exports;const IT=Zx(he);var wN={exports:{}},Kx={},DN={exports:{}},NN={};/**
* @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(q,te){var ee=q.length;q.push(te);e:for(;0<ee;){var de=ee-1>>>1,ue=q[de];if(0<a(ue,te))q[de]=te,q[ee]=ue,ee=de;else break e}}function t(q){return q.length===0?null:q[0]}function i(q){if(q.length===0)return null;var te=q[0],ee=q.pop();if(ee!==te){q[0]=ee;e:for(var de=0,ue=q.length,Pe=ue>>>1;de<Pe;){var He=2*(de+1)-1,Ke=q[He],nt=He+1,xt=q[nt];if(0>a(Ke,ee))nt<ue&&0>a(xt,Ke)?(q[de]=xt,q[nt]=ee,de=nt):(q[de]=Ke,q[He]=ee,de=He);else if(nt<ue&&0>a(xt,ee))q[de]=xt,q[nt]=ee,de=nt;else break e}}return te}function a(q,te){var ee=q.sortIndex-te.sortIndex;return ee!==0?ee:q.id-te.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;n.unstable_now=function(){return r.now()}}else{var s=Date,o=s.now();n.unstable_now=function(){return s.now()-o}}var c=[],h=[],f=1,d=null,m=3,g=!1,y=!1,E=!1,S=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function A(q){for(var te=t(h);te!==null;){if(te.callback===null)i(h);else if(te.startTime<=q)i(h),te.sortIndex=te.expirationTime,e(c,te);else break;te=t(h)}}function b(q){if(E=!1,A(q),!y)if(t(c)!==null)y=!0,se();else{var te=t(h);te!==null&&le(b,te.startTime-q)}}var O=!1,N=-1,L=5,B=-1;function w(){return!(n.unstable_now()-B<L)}function D(){if(O){var q=n.unstable_now();B=q;var te=!0;try{e:{y=!1,E&&(E=!1,v(N),N=-1),g=!0;var ee=m;try{t:{for(A(q),d=t(c);d!==null&&!(d.expirationTime>q&&w());){var de=d.callback;if(typeof de=="function"){d.callback=null,m=d.priorityLevel;var ue=de(d.expirationTime<=q);if(q=n.unstable_now(),typeof ue=="function"){d.callback=ue,A(q),te=!0;break t}d===t(c)&&i(c),A(q)}else i(c);d=t(c)}if(d!==null)te=!0;else{var Pe=t(h);Pe!==null&&le(b,Pe.startTime-q),te=!1}}break e}finally{d=null,m=ee,g=!1}te=void 0}}finally{te?G():O=!1}}}var G;if(typeof _=="function")G=function(){_(D)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,$=J.port2;J.port1.onmessage=D,G=function(){$.postMessage(null)}}else G=function(){S(D,0)};function se(){O||(O=!0,G())}function le(q,te){N=S(function(){q(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(q){q.callback=null},n.unstable_continueExecution=function(){y||g||(y=!0,se())},n.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<q?Math.floor(1e3/q):5},n.unstable_getCurrentPriorityLevel=function(){return m},n.unstable_getFirstCallbackNode=function(){return t(c)},n.unstable_next=function(q){switch(m){case 1:case 2:case 3:var te=3;break;default:te=m}var ee=m;m=te;try{return q()}finally{m=ee}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(q,te){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var ee=m;m=q;try{return te()}finally{m=ee}},n.unstable_scheduleCallback=function(q,te,ee){var de=n.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?de+ee:de):ee=de,q){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=ee+ue,q={id:f++,callback:te,priorityLevel:q,startTime:ee,expirationTime:ue,sortIndex:-1},ee>de?(q.sortIndex=ee,e(h,q),t(c)===null&&q===t(h)&&(E?(v(N),N=-1):E=!0,le(b,ee-de))):(q.sortIndex=ue,e(c,q),y||g||(y=!0,se())),q},n.unstable_shouldYield=w,n.unstable_wrapCallback=function(q){var te=m;return function(){var ee=m;m=te;try{return q.apply(this,arguments)}finally{m=ee}}}})(NN);DN.exports=NN;var GL=DN.exports,ON={exports:{}},Fa={};/**
* @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 VL=he;function IN(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 Ua={d:{f:Cl,r:function(){throw Error(IN(522))},D:Cl,C:Cl,L:Cl,m:Cl,X:Cl,S:Cl,M:Cl},p:0,findDOMNode:null},kL=Symbol.for("react.portal");function XL(n,e,t){var i=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:kL,key:i==null?null:""+i,children:n,containerInfo:e,implementation:t}}var sm=VL.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function Jx(n,e){if(n==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}Fa.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Ua;Fa.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(IN(299));return XL(n,e,null,t)};Fa.flushSync=function(n){var e=sm.T,t=Ua.p;try{if(sm.T=null,Ua.p=2,n)return n()}finally{sm.T=e,Ua.p=t,Ua.d.f()}};Fa.preconnect=function(n,e){typeof n=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,Ua.d.C(n,e))};Fa.prefetchDNS=function(n){typeof n=="string"&&Ua.d.D(n)};Fa.preinit=function(n,e){if(typeof n=="string"&&e&&typeof e.as=="string"){var t=e.as,i=Jx(t,e.crossOrigin),a=typeof e.integrity=="string"?e.integrity:void 0,r=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;t==="style"?Ua.d.S(n,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:i,integrity:a,fetchPriority:r}):t==="script"&&Ua.d.X(n,{crossOrigin:i,integrity:a,fetchPriority:r,nonce:typeof e.nonce=="string"?e.nonce:void 0})}};Fa.preinitModule=function(n,e){if(typeof n=="string")if(typeof e=="object"&&e!==null){if(e.as==null||e.as==="script"){var t=Jx(e.as,e.crossOrigin);Ua.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&&Ua.d.M(n)};Fa.preload=function(n,e){if(typeof n=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){var t=e.as,i=Jx(t,e.crossOrigin);Ua.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})}};Fa.preloadModule=function(n,e){if(typeof n=="string")if(e){var t=Jx(e.as,e.crossOrigin);Ua.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 Ua.d.m(n)};Fa.requestFormReset=function(n){Ua.d.r(n)};Fa.unstable_batchedUpdates=function(n,e){return n(e)};Fa.useFormState=function(n,e,t){return sm.H.useFormState(n,e,t)};Fa.useFormStatus=function(){return sm.H.useHostTransitionStatus()};Fa.version="19.0.0";function BN(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(BN)}catch(n){console.error(n)}}BN(),ON.exports=Fa;var WL=ON.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 qi=GL,UN=he,YL=WL;function qe(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 LN(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}var qL=Symbol.for("react.element"),wg=Symbol.for("react.transitional.element"),Zp=Symbol.for("react.portal"),Tf=Symbol.for("react.fragment"),PN=Symbol.for("react.strict_mode"),O2=Symbol.for("react.profiler"),ZL=Symbol.for("react.provider"),FN=Symbol.for("react.consumer"),ko=Symbol.for("react.context"),BT=Symbol.for("react.forward_ref"),I2=Symbol.for("react.suspense"),B2=Symbol.for("react.suspense_list"),UT=Symbol.for("react.memo"),Vl=Symbol.for("react.lazy"),HN=Symbol.for("react.offscreen"),jL=Symbol.for("react.memo_cache_sentinel"),fR=Symbol.iterator;function yp(n){return n===null||typeof n!="object"?null:(n=fR&&n[fR]||n["@@iterator"],typeof n=="function"?n:null)}var KL=Symbol.for("react.client.reference");function U2(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===KL?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Tf:return"Fragment";case Zp:return"Portal";case O2:return"Profiler";case PN:return"StrictMode";case I2:return"Suspense";case B2:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case ko:return(n.displayName||"Context")+".Provider";case FN:return(n._context.displayName||"Context")+".Consumer";case BT:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case UT:return e=n.displayName||null,e!==null?e:U2(n.type)||"Memo";case Vl:e=n._payload,n=n._init;try{return U2(n(e))}catch{}}return null}var Qt=UN.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,si=Object.assign,IS,dR;function jp(n){if(IS===void 0)try{throw Error()}catch(t){var e=t.stack.trim().match(/\n( *(at )?)/);IS=e&&e[1]||"",dR=-1<t.stack.indexOf(`
at`)?" (<anonymous>)":-1<t.stack.indexOf("@")?"@unknown:0:0":""}return`
`+IS+n+dR}var BS=!1;function US(n,e){if(!n||BS)return"";BS=!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 m=g}Reflect.construct(n,[],d)}else{try{d.call()}catch(g){m=g}n.call(d.prototype)}}else{try{throw Error()}catch(g){m=g}(d=n())&&typeof d.catch=="function"&&d.catch(function(){})}}catch(g){if(g&&m&&typeof g.stack=="string")return[g.stack,m.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var r=i.DetermineComponentFrameRoot(),s=r[0],o=r[1];if(s&&o){var c=s.split(`
`),h=o.split(`
`);for(a=i=0;i<c.length&&!c[i].includes("DetermineComponentFrameRoot");)i++;for(;a<h.length&&!h[a].includes("DetermineComponentFrameRoot");)a++;if(i===c.length||a===h.length)for(i=c.length-1,a=h.length-1;1<=i&&0<=a&&c[i]!==h[a];)a--;for(;1<=i&&0<=a;i--,a--)if(c[i]!==h[a]){if(i!==1||a!==1)do if(i--,a--,0>a||c[i]!==h[a]){var f=`
`+c[i].replace(" at new "," at ");return n.displayName&&f.includes("<anonymous>")&&(f=f.replace("<anonymous>",n.displayName)),f}while(1<=i&&0<=a);break}}}finally{BS=!1,Error.prepareStackTrace=t}return(t=n?n.displayName||n.name:"")?jp(t):""}function JL(n){switch(n.tag){case 26:case 27:case 5:return jp(n.type);case 16:return jp("Lazy");case 13:return jp("Suspense");case 19:return jp("SuspenseList");case 0:case 15:return n=US(n.type,!1),n;case 11:return n=US(n.type.render,!1),n;case 1:return n=US(n.type,!0),n;default:return""}}function pR(n){try{var e="";do e+=JL(n),n=n.return;while(n);return e}catch(t){return`
Error generating stack: `+t.message+`
`+t.stack}}function Nd(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 zN(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 mR(n){if(Nd(n)!==n)throw Error(qe(188))}function QL(n){var e=n.alternate;if(!e){if(e=Nd(n),e===null)throw Error(qe(188));return e!==n?null:n}for(var t=n,i=e;;){var a=t.return;if(a===null)break;var r=a.alternate;if(r===null){if(i=a.return,i!==null){t=i;continue}break}if(a.child===r.child){for(r=a.child;r;){if(r===t)return mR(a),n;if(r===i)return mR(a),e;r=r.sibling}throw Error(qe(188))}if(t.return!==i.return)t=a,i=r;else{for(var s=!1,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){for(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)throw Error(qe(189))}}if(t.alternate!==i)throw Error(qe(190))}if(t.tag!==3)throw Error(qe(188));return t.stateNode.current===t?n:e}function GN(n){var e=n.tag;if(e===5||e===26||e===27||e===6)return n;for(n=n.child;n!==null;){if(e=GN(n),e!==null)return e;n=n.sibling}return null}var Kp=Array.isArray,ai=YL.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Eu={pending:!1,data:null,method:null,action:null},L2=[],bf=-1;function ao(n){return{current:n}}function ra(n){0>bf||(n.current=L2[bf],L2[bf]=null,bf--)}function ui(n,e){bf++,L2[bf]=n.current,n.current=e}var Qs=ao(null),Pm=ao(null),ec=ao(null),g1=ao(null);function v1(n,e){switch(ui(ec,e),ui(Pm,n),ui(Qs,null),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)&&(e=e.namespaceURI)?gw(e):0;break;default:if(n=n===8?e.parentNode:e,e=n.tagName,n=n.namespaceURI)n=gw(n),e=$I(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ra(Qs),ui(Qs,e)}function nd(){ra(Qs),ra(Pm),ra(ec)}function P2(n){n.memoizedState!==null&&ui(g1,n);var e=Qs.current,t=$I(e,n.type);e!==t&&(ui(Pm,n),ui(Qs,t))}function x1(n){Pm.current===n&&(ra(Qs),ra(Pm)),g1.current===n&&(ra(g1),Zm._currentValue=Eu)}var F2=Object.prototype.hasOwnProperty,LT=qi.unstable_scheduleCallback,LS=qi.unstable_cancelCallback,$L=qi.unstable_shouldYield,eP=qi.unstable_requestPaint,$s=qi.unstable_now,tP=qi.unstable_getCurrentPriorityLevel,VN=qi.unstable_ImmediatePriority,kN=qi.unstable_UserBlockingPriority,y1=qi.unstable_NormalPriority,nP=qi.unstable_LowPriority,XN=qi.unstable_IdlePriority,iP=qi.log,aP=qi.unstable_setDisableYieldValue,d0=null,Tr=null;function rP(n){if(Tr&&typeof Tr.onCommitFiberRoot=="function")try{Tr.onCommitFiberRoot(d0,n,void 0,(n.current.flags&128)===128)}catch{}}function Zl(n){if(typeof iP=="function"&&aP(n),Tr&&typeof Tr.setStrictMode=="function")try{Tr.setStrictMode(d0,n)}catch{}}var br=Math.clz32?Math.clz32:lP,sP=Math.log,oP=Math.LN2;function lP(n){return n>>>=0,n===0?32:31-(sP(n)/oP|0)|0}var Dg=128,Ng=4194304;function su(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: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 n&4194176;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 Qx(n,e){var t=n.pendingLanes;if(t===0)return 0;var i=0,a=n.suspendedLanes,r=n.pingedLanes,s=n.warmLanes;n=n.finishedLanes!==0;var o=t&134217727;return o!==0?(t=o&~a,t!==0?i=su(t):(r&=o,r!==0?i=su(r):n||(s=o&~s,s!==0&&(i=su(s))))):(o=t&~a,o!==0?i=su(o):r!==0?i=su(r):n||(s=t&~s,s!==0&&(i=su(s)))),i===0?0:e!==0&&e!==i&&!(e&a)&&(a=i&-i,s=e&-e,a>=s||a===32&&(s&4194176)!==0)?e:i}function p0(n,e){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&e)===0}function cP(n,e){switch(n){case 1:case 2:case 4:case 8:return e+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 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 WN(){var n=Dg;return Dg<<=1,!(Dg&4194176)&&(Dg=128),n}function YN(){var n=Ng;return Ng<<=1,!(Ng&62914560)&&(Ng=4194304),n}function PS(n){for(var e=[],t=0;31>t;t++)e.push(n);return e}function m0(n,e){n.pendingLanes|=e,e!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function uP(n,e,t,i,a,r){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,c=n.expirationTimes,h=n.hiddenUpdates;for(t=s&~t;0<t;){var f=31-br(t),d=1<<f;o[f]=0,c[f]=-1;var m=h[f];if(m!==null)for(h[f]=null,f=0;f<m.length;f++){var g=m[f];g!==null&&(g.lane&=-536870913)}t&=~d}i!==0&&qN(n,i,0),r!==0&&a===0&&n.tag!==0&&(n.suspendedLanes|=r&~(s&~e))}function qN(n,e,t){n.pendingLanes|=e,n.suspendedLanes&=~e;var i=31-br(e);n.entangledLanes|=e,n.entanglements[i]=n.entanglements[i]|1073741824|t&4194218}function ZN(n,e){var t=n.entangledLanes|=e;for(n=n.entanglements;t;){var i=31-br(t),a=1<<i;a&e|n[i]&e&&(n[i]|=e),t&=~a}}function jN(n){return n&=-n,2<n?8<n?n&134217727?32:268435456:8:2}function KN(){var n=ai.p;return n!==0?n:(n=window.event,n===void 0?32:c5(n.type))}function hP(n,e){var t=ai.p;try{return ai.p=n,e()}finally{ai.p=t}}var vc=Math.random().toString(36).slice(2),ba="__reactFiber$"+vc,$a="__reactProps$"+vc,Od="__reactContainer$"+vc,H2="__reactEvents$"+vc,fP="__reactListeners$"+vc,dP="__reactHandles$"+vc,gR="__reactResources$"+vc,Fm="__reactMarker$"+vc;function PT(n){delete n[ba],delete n[$a],delete n[H2],delete n[fP],delete n[dP]}function pu(n){var e=n[ba];if(e)return e;for(var t=n.parentNode;t;){if(e=t[Od]||t[ba]){if(t=e.alternate,e.child!==null||t!==null&&t.child!==null)for(n=xw(n);n!==null;){if(t=n[ba])return t;n=xw(n)}return e}n=t,t=n.parentNode}return null}function Id(n){if(n=n[ba]||n[Od]){var e=n.tag;if(e===5||e===6||e===13||e===26||e===27||e===3)return n}return null}function Jp(n){var e=n.tag;if(e===5||e===26||e===27||e===6)return n.stateNode;throw Error(qe(33))}function Vf(n){var e=n[gR];return e||(e=n[gR]={hoistableStyles:new Map,hoistableScripts:new Map}),e}function ia(n){n[Fm]=!0}var JN=new Set,QN={};function th(n,e){id(n,e),id(n+"Capture",e)}function id(n,e){for(QN[n]=e,n=0;n<e.length;n++)JN.add(e[n])}var el=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),pP=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]*$"),vR={},xR={};function mP(n){return F2.call(xR,n)?!0:F2.call(vR,n)?!1:pP.test(n)?xR[n]=!0:(vR[n]=!0,!1)}function Jv(n,e,t){if(mP(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 Og(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 yo(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 qr(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function $N(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function gP(n){var e=$N(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),i=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var a=t.get,r=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return a.call(this)},set:function(s){i=""+s,r.call(this,s)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return i},setValue:function(s){i=""+s},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function _1(n){n._valueTracker||(n._valueTracker=gP(n))}function eO(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),i="";return n&&(i=$N(n)?n.checked?"true":"false":n.value),n=i,n!==t?(e.setValue(n),!0):!1}function S1(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 vP=/[\n"\\]/g;function Kr(n){return n.replace(vP,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function z2(n,e,t,i,a,r,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=""+qr(e)):n.value!==""+qr(e)&&(n.value=""+qr(e)):s!=="submit"&&s!=="reset"||n.removeAttribute("value"),e!=null?G2(n,s,qr(e)):t!=null?G2(n,s,qr(t)):i!=null&&n.removeAttribute("value"),a==null&&r!=null&&(n.defaultChecked=!!r),a!=null&&(n.checked=a&&typeof a!="function"&&typeof a!="symbol"),o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"?n.name=""+qr(o):n.removeAttribute("name")}function tO(n,e,t,i,a,r,s,o){if(r!=null&&typeof r!="function"&&typeof r!="symbol"&&typeof r!="boolean"&&(n.type=r),e!=null||t!=null){if(!(r!=="submit"&&r!=="reset"||e!=null))return;t=t!=null?""+qr(t):"",e=e!=null?""+qr(e):t,o||e===n.value||(n.value=e),n.defaultValue=e}i=i??a,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)}function G2(n,e,t){e==="number"&&S1(n.ownerDocument)===n||n.defaultValue===""+t||(n.defaultValue=""+t)}function kf(n,e,t,i){if(n=n.options,e){e={};for(var a=0;a<t.length;a++)e["$"+t[a]]=!0;for(t=0;t<n.length;t++)a=e.hasOwnProperty("$"+n[t].value),n[t].selected!==a&&(n[t].selected=a),a&&i&&(n[t].defaultSelected=!0)}else{for(t=""+qr(t),e=null,a=0;a<n.length;a++){if(n[a].value===t){n[a].selected=!0,i&&(n[a].defaultSelected=!0);return}e!==null||n[a].disabled||(e=n[a])}e!==null&&(e.selected=!0)}}function nO(n,e,t){if(e!=null&&(e=""+qr(e),e!==n.value&&(n.value=e),t==null)){n.defaultValue!==e&&(n.defaultValue=e);return}n.defaultValue=t!=null?""+qr(t):""}function iO(n,e,t,i){if(e==null){if(i!=null){if(t!=null)throw Error(qe(92));if(Kp(i)){if(1<i.length)throw Error(qe(93));i=i[0]}t=i}t==null&&(t=""),e=t}t=qr(e),n.defaultValue=t,i=n.textContent,i===t&&i!==""&&i!==null&&(n.value=i)}function ad(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var xP=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 yR(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||xP.has(e)?e==="float"?n.cssFloat=t:n[e]=(""+t).trim():n[e]=t+"px"}function aO(n,e,t){if(e!=null&&typeof e!="object")throw Error(qe(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 a in e)i=e[a],e.hasOwnProperty(a)&&t[a]!==i&&yR(n,a,i)}else for(var r in e)e.hasOwnProperty(r)&&yR(n,r,e[r])}function FT(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 yP=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"]]),_P=/^[\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 Qv(n){return _P.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}var V2=null;function HT(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Mf=null,Xf=null;function _R(n){var e=Id(n);if(e&&(n=e.stateNode)){var t=n[$a]||null;e:switch(n=e.stateNode,e.type){case"input":if(z2(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="'+Kr(""+e)+'"][type="radio"]'),e=0;e<t.length;e++){var i=t[e];if(i!==n&&i.form===n.form){var a=i[$a]||null;if(!a)throw Error(qe(90));z2(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(e=0;e<t.length;e++)i=t[e],i.form===n.form&&eO(i)}break e;case"textarea":nO(n,t.value,t.defaultValue);break e;case"select":e=t.value,e!=null&&kf(n,!!t.multiple,e,!1)}}}var FS=!1;function rO(n,e,t){if(FS)return n(e,t);FS=!0;try{var i=n(e);return i}finally{if(FS=!1,(Mf!==null||Xf!==null)&&(ly(),Mf&&(e=Mf,n=Xf,Xf=Mf=null,_R(e),n)))for(e=0;e<n.length;e++)_R(n[e])}}function Hm(n,e){var t=n.stateNode;if(t===null)return null;var i=t[$a]||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(qe(231,e,typeof t));return t}var k2=!1;if(el)try{var _p={};Object.defineProperty(_p,"passive",{get:function(){k2=!0}}),window.addEventListener("test",_p,_p),window.removeEventListener("test",_p,_p)}catch{k2=!1}var jl=null,zT=null,$v=null;function sO(){if($v)return $v;var n,e=zT,t=e.length,i,a="value"in jl?jl.value:jl.textContent,r=a.length;for(n=0;n<t&&e[n]===a[n];n++);var s=t-n;for(i=1;i<=s&&e[t-i]===a[r-i];i++);return $v=a.slice(n,1<i?1-i:void 0)}function e1(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 Ig(){return!0}function SR(){return!1}function er(n){function e(t,i,a,r,s){this._reactName=t,this._targetInst=a,this.type=i,this.nativeEvent=r,this.target=s,this.currentTarget=null;for(var o in n)n.hasOwnProperty(o)&&(t=n[o],this[o]=t?t(r):r[o]);return this.isDefaultPrevented=(r.defaultPrevented!=null?r.defaultPrevented:r.returnValue===!1)?Ig:SR,this.isPropagationStopped=SR,this}return si(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=Ig)},stopPropagation:function(){var t=this.nativeEvent;t&&(t.stopPropagation?t.stopPropagation():typeof t.cancelBubble!="unknown"&&(t.cancelBubble=!0),this.isPropagationStopped=Ig)},persist:function(){},isPersistent:Ig}),e}var nh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},$x=er(nh),g0=si({},nh,{view:0,detail:0}),SP=er(g0),HS,zS,Sp,ey=si({},g0,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:GT,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!==Sp&&(Sp&&n.type==="mousemove"?(HS=n.screenX-Sp.screenX,zS=n.screenY-Sp.screenY):zS=HS=0,Sp=n),HS)},movementY:function(n){return"movementY"in n?n.movementY:zS}}),AR=er(ey),AP=si({},ey,{dataTransfer:0}),EP=er(AP),TP=si({},g0,{relatedTarget:0}),GS=er(TP),bP=si({},nh,{animationName:0,elapsedTime:0,pseudoElement:0}),MP=er(bP),CP=si({},nh,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),RP=er(CP),wP=si({},nh,{data:0}),ER=er(wP),DP={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},NP={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"},OP={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function IP(n){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(n):(n=OP[n])?!!e[n]:!1}function GT(){return IP}var BP=si({},g0,{key:function(n){if(n.key){var e=DP[n.key]||n.key;if(e!=="Unidentified")return e}return n.type==="keypress"?(n=e1(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?NP[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:GT,charCode:function(n){return n.type==="keypress"?e1(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?e1(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),UP=er(BP),LP=si({},ey,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),TR=er(LP),PP=si({},g0,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:GT}),FP=er(PP),HP=si({},nh,{propertyName:0,elapsedTime:0,pseudoElement:0}),zP=er(HP),GP=si({},ey,{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}),VP=er(GP),kP=si({},nh,{newState:0,oldState:0}),XP=er(kP),WP=[9,13,27,32],VT=el&&"CompositionEvent"in window,om=null;el&&"documentMode"in document&&(om=document.documentMode);var YP=el&&"TextEvent"in window&&!om,oO=el&&(!VT||om&&8<om&&11>=om),bR=" ",MR=!1;function lO(n,e){switch(n){case"keyup":return WP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cO(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Cf=!1;function qP(n,e){switch(n){case"compositionend":return cO(e);case"keypress":return e.which!==32?null:(MR=!0,bR);case"textInput":return n=e.data,n===bR&&MR?null:n;default:return null}}function ZP(n,e){if(Cf)return n==="compositionend"||!VT&&lO(n,e)?(n=sO(),$v=zT=jl=null,Cf=!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 oO&&e.locale!=="ko"?null:e.data;default:return null}}var jP={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 CR(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e==="input"?!!jP[n.type]:e==="textarea"}function uO(n,e,t,i){Mf?Xf?Xf.push(i):Xf=[i]:Mf=i,e=P1(e,"onChange"),0<e.length&&(t=new $x("onChange","change",null,t,i),n.push({event:t,listeners:e}))}var lm=null,zm=null;function KP(n){KI(n,0)}function ty(n){var e=Jp(n);if(eO(e))return n}function RR(n,e){if(n==="change")return e}var hO=!1;if(el){var VS;if(el){var kS="oninput"in document;if(!kS){var wR=document.createElement("div");wR.setAttribute("oninput","return;"),kS=typeof wR.oninput=="function"}VS=kS}else VS=!1;hO=VS&&(!document.documentMode||9<document.documentMode)}function DR(){lm&&(lm.detachEvent("onpropertychange",fO),zm=lm=null)}function fO(n){if(n.propertyName==="value"&&ty(zm)){var e=[];uO(e,zm,n,HT(n)),rO(KP,e)}}function JP(n,e,t){n==="focusin"?(DR(),lm=e,zm=t,lm.attachEvent("onpropertychange",fO)):n==="focusout"&&DR()}function QP(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return ty(zm)}function $P(n,e){if(n==="click")return ty(e)}function e7(n,e){if(n==="input"||n==="change")return ty(e)}function t7(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var wr=typeof Object.is=="function"?Object.is:t7;function Gm(n,e){if(wr(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 a=t[i];if(!F2.call(e,a)||!wr(n[a],e[a]))return!1}return!0}function NR(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function OR(n,e){var t=NR(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=NR(t)}}function dO(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?dO(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function pO(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var e=S1(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=S1(n.document)}return e}function kT(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")}function n7(n,e){var t=pO(e);e=n.focusedElem;var i=n.selectionRange;if(t!==e&&e&&e.ownerDocument&&dO(e.ownerDocument.documentElement,e)){if(i!==null&&kT(e)){if(n=i.start,t=i.end,t===void 0&&(t=n),"selectionStart"in e)e.selectionStart=n,e.selectionEnd=Math.min(t,e.value.length);else if(t=(n=e.ownerDocument||document)&&n.defaultView||window,t.getSelection){t=t.getSelection();var a=e.textContent.length,r=Math.min(i.start,a);i=i.end===void 0?r:Math.min(i.end,a),!t.extend&&r>i&&(a=i,i=r,r=a),a=OR(e,r);var s=OR(e,i);a&&s&&(t.rangeCount!==1||t.anchorNode!==a.node||t.anchorOffset!==a.offset||t.focusNode!==s.node||t.focusOffset!==s.offset)&&(n=n.createRange(),n.setStart(a.node,a.offset),t.removeAllRanges(),r>i?(t.addRange(n),t.extend(s.node,s.offset)):(n.setEnd(s.node,s.offset),t.addRange(n)))}}for(n=[],t=e;t=t.parentNode;)t.nodeType===1&&n.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof e.focus=="function"&&e.focus(),e=0;e<n.length;e++)t=n[e],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var i7=el&&"documentMode"in document&&11>=document.documentMode,Rf=null,X2=null,cm=null,W2=!1;function IR(n,e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;W2||Rf==null||Rf!==S1(i)||(i=Rf,"selectionStart"in i&&kT(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}),cm&&Gm(cm,i)||(cm=i,i=P1(X2,"onSelect"),0<i.length&&(e=new $x("onSelect","select",null,e,t),n.push({event:e,listeners:i}),e.target=Rf)))}function kc(n,e){var t={};return t[n.toLowerCase()]=e.toLowerCase(),t["Webkit"+n]="webkit"+e,t["Moz"+n]="moz"+e,t}var wf={animationend:kc("Animation","AnimationEnd"),animationiteration:kc("Animation","AnimationIteration"),animationstart:kc("Animation","AnimationStart"),transitionrun:kc("Transition","TransitionRun"),transitionstart:kc("Transition","TransitionStart"),transitioncancel:kc("Transition","TransitionCancel"),transitionend:kc("Transition","TransitionEnd")},XS={},mO={};el&&(mO=document.createElement("div").style,"AnimationEvent"in window||(delete wf.animationend.animation,delete wf.animationiteration.animation,delete wf.animationstart.animation),"TransitionEvent"in window||delete wf.transitionend.transition);function ih(n){if(XS[n])return XS[n];if(!wf[n])return n;var e=wf[n],t;for(t in e)if(e.hasOwnProperty(t)&&t in mO)return XS[n]=e[t];return n}var gO=ih("animationend"),vO=ih("animationiteration"),xO=ih("animationstart"),a7=ih("transitionrun"),r7=ih("transitionstart"),s7=ih("transitioncancel"),yO=ih("transitionend"),_O=new Map,BR="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 scrollEnd toggle touchMove waiting wheel".split(" ");function Os(n,e){_O.set(n,e),th(e,[n])}var Yr=[],Df=0,XT=0;function ny(){for(var n=Df,e=XT=Df=0;e<n;){var t=Yr[e];Yr[e++]=null;var i=Yr[e];Yr[e++]=null;var a=Yr[e];Yr[e++]=null;var r=Yr[e];if(Yr[e++]=null,i!==null&&a!==null){var s=i.pending;s===null?a.next=a:(a.next=s.next,s.next=a),i.pending=a}r!==0&&SO(t,a,r)}}function iy(n,e,t,i){Yr[Df++]=n,Yr[Df++]=e,Yr[Df++]=t,Yr[Df++]=i,XT|=i,n.lanes|=i,n=n.alternate,n!==null&&(n.lanes|=i)}function WT(n,e,t,i){return iy(n,e,t,i),A1(n)}function uc(n,e){return iy(n,null,null,e),A1(n)}function SO(n,e,t){n.lanes|=t;var i=n.alternate;i!==null&&(i.lanes|=t);for(var a=!1,r=n.return;r!==null;)r.childLanes|=t,i=r.alternate,i!==null&&(i.childLanes|=t),r.tag===22&&(n=r.stateNode,n===null||n._visibility&1||(a=!0)),n=r,r=r.return;a&&e!==null&&n.tag===3&&(r=n.stateNode,a=31-br(t),r=r.hiddenUpdates,n=r[a],n===null?r[a]=[e]:n.push(e),e.lane=t|536870912)}function A1(n){if(50<Sm)throw Sm=0,dE=null,Error(qe(185));for(var e=n.return;e!==null;)n=e,e=n.return;return n.tag===3?n.stateNode:null}var Nf={},UR=new WeakMap;function Jr(n,e){if(typeof n=="object"&&n!==null){var t=UR.get(n);return t!==void 0?t:(e={value:n,source:e,stack:pR(e)},UR.set(n,e),e)}return{value:n,source:e,stack:pR(e)}}var Of=[],If=0,E1=null,T1=0,Zr=[],jr=0,Tu=null,Xo=1,Wo="";function ou(n,e){Of[If++]=T1,Of[If++]=E1,E1=n,T1=e}function AO(n,e,t){Zr[jr++]=Xo,Zr[jr++]=Wo,Zr[jr++]=Tu,Tu=n;var i=Xo;n=Wo;var a=32-br(i)-1;i&=~(1<<a),t+=1;var r=32-br(e)+a;if(30<r){var s=a-a%5;r=(i&(1<<s)-1).toString(32),i>>=s,a-=s,Xo=1<<32-br(e)+a|t<<a|i,Wo=r+n}else Xo=1<<r|t<<a|i,Wo=n}function YT(n){n.return!==null&&(ou(n,1),AO(n,1,0))}function qT(n){for(;n===E1;)E1=Of[--If],Of[If]=null,T1=Of[--If],Of[If]=null;for(;n===Tu;)Tu=Zr[--jr],Zr[jr]=null,Wo=Zr[--jr],Zr[jr]=null,Xo=Zr[--jr],Zr[jr]=null}var Ia=null,fa=null,Cn=!1,Ms=null,qs=!1,Y2=Error(qe(519));function Uu(n){var e=Error(qe(418,""));throw Vm(Jr(e,n)),Y2}function LR(n){var e=n.stateNode,t=n.type,i=n.memoizedProps;switch(e[ba]=n,e[$a]=i,t){case"dialog":mn("cancel",e),mn("close",e);break;case"iframe":case"object":case"embed":mn("load",e);break;case"video":case"audio":for(t=0;t<Wm.length;t++)mn(Wm[t],e);break;case"source":mn("error",e);break;case"img":case"image":case"link":mn("error",e),mn("load",e);break;case"details":mn("toggle",e);break;case"input":mn("invalid",e),tO(e,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0),_1(e);break;case"select":mn("invalid",e);break;case"textarea":mn("invalid",e),iO(e,i.value,i.defaultValue,i.children),_1(e)}t=i.children,typeof t!="string"&&typeof t!="number"&&typeof t!="bigint"||e.textContent===""+t||i.suppressHydrationWarning===!0||QI(e.textContent,t)?(i.popover!=null&&(mn("beforetoggle",e),mn("toggle",e)),i.onScroll!=null&&mn("scroll",e),i.onScrollEnd!=null&&mn("scrollend",e),i.onClick!=null&&(e.onclick=uy),e=!0):e=!1,e||Uu(n)}function PR(n){for(Ia=n.return;Ia;)switch(Ia.tag){case 3:case 27:qs=!0;return;case 5:case 13:qs=!1;return;default:Ia=Ia.return}}function Ap(n){if(n!==Ia)return!1;if(!Cn)return PR(n),Cn=!0,!1;var e=!1,t;if((t=n.tag!==3&&n.tag!==27)&&((t=n.tag===5)&&(t=n.type,t=!(t!=="form"&&t!=="button")||_E(n.type,n.memoizedProps)),t=!t),t&&(e=!0),e&&fa&&Uu(n),PR(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(qe(317));e:{for(n=n.nextSibling,e=0;n;){if(n.nodeType===8)if(t=n.data,t==="/$"){if(e===0){fa=Ds(n.nextSibling);break e}e--}else t!=="$"&&t!=="$!"&&t!=="$?"||e++;n=n.nextSibling}fa=null}}else fa=Ia?Ds(n.stateNode.nextSibling):null;return!0}function v0(){fa=Ia=null,Cn=!1}function Vm(n){Ms===null?Ms=[n]:Ms.push(n)}var um=Error(qe(460)),EO=Error(qe(474)),q2={then:function(){}};function FR(n){return n=n.status,n==="fulfilled"||n==="rejected"}function Bg(){}function TO(n,e,t){switch(t=n[t],t===void 0?n.push(e):t!==e&&(e.then(Bg,Bg),e=t),e.status){case"fulfilled":return e.value;case"rejected":throw n=e.reason,n===um?Error(qe(483)):n;default:if(typeof e.status=="string")e.then(Bg,Bg);else{if(n=Qn,n!==null&&100<n.shellSuspendCounter)throw Error(qe(482));n=e,n.status="pending",n.then(function(i){if(e.status==="pending"){var a=e;a.status="fulfilled",a.value=i}},function(i){if(e.status==="pending"){var a=e;a.status="rejected",a.reason=i}})}switch(e.status){case"fulfilled":return e.value;case"rejected":throw n=e.reason,n===um?Error(qe(483)):n}throw hm=e,um}}var hm=null;function HR(){if(hm===null)throw Error(qe(459));var n=hm;return hm=null,n}var Wf=null,km=0;function Ug(n){var e=km;return km+=1,Wf===null&&(Wf=[]),TO(Wf,n,e)}function Ep(n,e){e=e.props.ref,n.ref=e!==void 0?e:null}function Lg(n,e){throw e.$$typeof===qL?Error(qe(525)):(n=Object.prototype.toString.call(e),Error(qe(31,n==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":n)))}function zR(n){var e=n._init;return e(n._payload)}function bO(n){function e(v,_){if(n){var A=v.deletions;A===null?(v.deletions=[_],v.flags|=16):A.push(_)}}function t(v,_){if(!n)return null;for(;_!==null;)e(v,_),_=_.sibling;return null}function i(v){for(var _=new Map;v!==null;)v.key!==null?_.set(v.key,v):_.set(v.index,v),v=v.sibling;return _}function a(v,_){return v=ic(v,_),v.index=0,v.sibling=null,v}function r(v,_,A){return v.index=A,n?(A=v.alternate,A!==null?(A=A.index,A<_?(v.flags|=33554434,_):A):(v.flags|=33554434,_)):(v.flags|=1048576,_)}function s(v){return n&&v.alternate===null&&(v.flags|=33554434),v}function o(v,_,A,b){return _===null||_.tag!==6?(_=nA(A,v.mode,b),_.return=v,_):(_=a(_,A),_.return=v,_)}function c(v,_,A,b){var O=A.type;return O===Tf?f(v,_,A.props.children,b,A.key):_!==null&&(_.elementType===O||typeof O=="object"&&O!==null&&O.$$typeof===Vl&&zR(O)===_.type)?(_=a(_,A.props),Ep(_,A),_.return=v,_):(_=r1(A.type,A.key,A.props,null,v.mode,b),Ep(_,A),_.return=v,_)}function h(v,_,A,b){return _===null||_.tag!==4||_.stateNode.containerInfo!==A.containerInfo||_.stateNode.implementation!==A.implementation?(_=iA(A,v.mode,b),_.return=v,_):(_=a(_,A.children||[]),_.return=v,_)}function f(v,_,A,b,O){return _===null||_.tag!==7?(_=Mu(A,v.mode,b,O),_.return=v,_):(_=a(_,A),_.return=v,_)}function d(v,_,A){if(typeof _=="string"&&_!==""||typeof _=="number"||typeof _=="bigint")return _=nA(""+_,v.mode,A),_.return=v,_;if(typeof _=="object"&&_!==null){switch(_.$$typeof){case wg:return A=r1(_.type,_.key,_.props,null,v.mode,A),Ep(A,_),A.return=v,A;case Zp:return _=iA(_,v.mode,A),_.return=v,_;case Vl:var b=_._init;return _=b(_._payload),d(v,_,A)}if(Kp(_)||yp(_))return _=Mu(_,v.mode,A,null),_.return=v,_;if(typeof _.then=="function")return d(v,Ug(_),A);if(_.$$typeof===ko)return d(v,Pg(v,_),A);Lg(v,_)}return null}function m(v,_,A,b){var O=_!==null?_.key:null;if(typeof A=="string"&&A!==""||typeof A=="number"||typeof A=="bigint")return O!==null?null:o(v,_,""+A,b);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case wg:return A.key===O?c(v,_,A,b):null;case Zp:return A.key===O?h(v,_,A,b):null;case Vl:return O=A._init,A=O(A._payload),m(v,_,A,b)}if(Kp(A)||yp(A))return O!==null?null:f(v,_,A,b,null);if(typeof A.then=="function")return m(v,_,Ug(A),b);if(A.$$typeof===ko)return m(v,_,Pg(v,A),b);Lg(v,A)}return null}function g(v,_,A,b,O){if(typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint")return v=v.get(A)||null,o(_,v,""+b,O);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case wg:return v=v.get(b.key===null?A:b.key)||null,c(_,v,b,O);case Zp:return v=v.get(b.key===null?A:b.key)||null,h(_,v,b,O);case Vl:var N=b._init;return b=N(b._payload),g(v,_,A,b,O)}if(Kp(b)||yp(b))return v=v.get(A)||null,f(_,v,b,O,null);if(typeof b.then=="function")return g(v,_,A,Ug(b),O);if(b.$$typeof===ko)return g(v,_,A,Pg(_,b),O);Lg(_,b)}return null}function y(v,_,A,b){for(var O=null,N=null,L=_,B=_=0,w=null;L!==null&&B<A.length;B++){L.index>B?(w=L,L=null):w=L.sibling;var D=m(v,L,A[B],b);if(D===null){L===null&&(L=w);break}n&&L&&D.alternate===null&&e(v,L),_=r(D,_,B),N===null?O=D:N.sibling=D,N=D,L=w}if(B===A.length)return t(v,L),Cn&&ou(v,B),O;if(L===null){for(;B<A.length;B++)L=d(v,A[B],b),L!==null&&(_=r(L,_,B),N===null?O=L:N.sibling=L,N=L);return Cn&&ou(v,B),O}for(L=i(L);B<A.length;B++)w=g(L,v,B,A[B],b),w!==null&&(n&&w.alternate!==null&&L.delete(w.key===null?B:w.key),_=r(w,_,B),N===null?O=w:N.sibling=w,N=w);return n&&L.forEach(function(G){return e(v,G)}),Cn&&ou(v,B),O}function E(v,_,A,b){if(A==null)throw Error(qe(151));for(var O=null,N=null,L=_,B=_=0,w=null,D=A.next();L!==null&&!D.done;B++,D=A.next()){L.index>B?(w=L,L=null):w=L.sibling;var G=m(v,L,D.value,b);if(G===null){L===null&&(L=w);break}n&&L&&G.alternate===null&&e(v,L),_=r(G,_,B),N===null?O=G:N.sibling=G,N=G,L=w}if(D.done)return t(v,L),Cn&&ou(v,B),O;if(L===null){for(;!D.done;B++,D=A.next())D=d(v,D.value,b),D!==null&&(_=r(D,_,B),N===null?O=D:N.sibling=D,N=D);return Cn&&ou(v,B),O}for(L=i(L);!D.done;B++,D=A.next())D=g(L,v,B,D.value,b),D!==null&&(n&&D.alternate!==null&&L.delete(D.key===null?B:D.key),_=r(D,_,B),N===null?O=D:N.sibling=D,N=D);return n&&L.forEach(function(J){return e(v,J)}),Cn&&ou(v,B),O}function S(v,_,A,b){if(typeof A=="object"&&A!==null&&A.type===Tf&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case wg:e:{for(var O=A.key;_!==null;){if(_.key===O){if(O=A.type,O===Tf){if(_.tag===7){t(v,_.sibling),b=a(_,A.props.children),b.return=v,v=b;break e}}else if(_.elementType===O||typeof O=="object"&&O!==null&&O.$$typeof===Vl&&zR(O)===_.type){t(v,_.sibling),b=a(_,A.props),Ep(b,A),b.return=v,v=b;break e}t(v,_);break}else e(v,_);_=_.sibling}A.type===Tf?(b=Mu(A.props.children,v.mode,b,A.key),b.return=v,v=b):(b=r1(A.type,A.key,A.props,null,v.mode,b),Ep(b,A),b.return=v,v=b)}return s(v);case Zp:e:{for(O=A.key;_!==null;){if(_.key===O)if(_.tag===4&&_.stateNode.containerInfo===A.containerInfo&&_.stateNode.implementation===A.implementation){t(v,_.sibling),b=a(_,A.children||[]),b.return=v,v=b;break e}else{t(v,_);break}else e(v,_);_=_.sibling}b=iA(A,v.mode,b),b.return=v,v=b}return s(v);case Vl:return O=A._init,A=O(A._payload),S(v,_,A,b)}if(Kp(A))return y(v,_,A,b);if(yp(A)){if(O=yp(A),typeof O!="function")throw Error(qe(150));return A=O.call(A),E(v,_,A,b)}if(typeof A.then=="function")return S(v,_,Ug(A),b);if(A.$$typeof===ko)return S(v,_,Pg(v,A),b);Lg(v,A)}return typeof A=="string"&&A!==""||typeof A=="number"||typeof A=="bigint"?(A=""+A,_!==null&&_.tag===6?(t(v,_.sibling),b=a(_,A),b.return=v,v=b):(t(v,_),b=nA(A,v.mode,b),b.return=v,v=b),s(v)):t(v,_)}return function(v,_,A,b){try{km=0;var O=S(v,_,A,b);return Wf=null,O}catch(L){if(L===um)throw L;var N=es(29,L,null,v.mode);return N.lanes=b,N.return=v,N}finally{}}}var Lu=bO(!0),MO=bO(!1),rd=ao(null),b1=ao(0);function GR(n,e){n=il,ui(b1,n),ui(rd,e),il=n|e.baseLanes}function Z2(){ui(b1,il),ui(rd,rd.current)}function ZT(){il=b1.current,ra(rd),ra(b1)}var rs=ao(null),eo=null;function Xl(n){var e=n.alternate;ui(Xi,Xi.current&1),ui(rs,n),eo===null&&(e===null||rd.current!==null||e.memoizedState!==null)&&(eo=n)}function CO(n){if(n.tag===22){if(ui(Xi,Xi.current),ui(rs,n),eo===null){var e=n.alternate;e!==null&&e.memoizedState!==null&&(eo=n)}}else Wl()}function Wl(){ui(Xi,Xi.current),ui(rs,rs.current)}function Yo(n){ra(rs),eo===n&&(eo=null),ra(Xi)}var Xi=ao(0);function M1(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){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 o7=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()})}},l7=qi.unstable_scheduleCallback,c7=qi.unstable_NormalPriority,Vi={$$typeof:ko,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function jT(){return{controller:new o7,data:new Map,refCount:0}}function x0(n){n.refCount--,n.refCount===0&&l7(c7,function(){n.controller.abort()})}var fm=null,j2=0,sd=0,Yf=null;function u7(n,e){if(fm===null){var t=fm=[];j2=0,sd=x3(),Yf={status:"pending",value:void 0,then:function(i){t.push(i)}}}return j2++,e.then(VR,VR),e}function VR(){if(--j2===0&&fm!==null){Yf!==null&&(Yf.status="fulfilled");var n=fm;fm=null,sd=0,Yf=null;for(var e=0;e<n.length;e++)(0,n[e])()}}function h7(n,e){var t=[],i={status:"pending",value:null,reason:null,then:function(a){t.push(a)}};return n.then(function(){i.status="fulfilled",i.value=e;for(var a=0;a<t.length;a++)(0,t[a])(e)},function(a){for(i.status="rejected",i.reason=a,a=0;a<t.length;a++)(0,t[a])(void 0)}),i}var kR=Qt.S;Qt.S=function(n,e){typeof e=="object"&&e!==null&&typeof e.then=="function"&&u7(n,e),kR!==null&&kR(n,e)};var bu=ao(null);function KT(){var n=bu.current;return n!==null?n:Qn.pooledCache}function t1(n,e){e===null?ui(bu,bu.current):ui(bu,e.pool)}function RO(){var n=KT();return n===null?null:{parent:Vi._currentValue,pool:n}}var hc=0,on=null,zn=null,Pi=null,C1=!1,qf=!1,Pu=!1,R1=0,Xm=0,Zf=null,f7=0;function Ri(){throw Error(qe(321))}function JT(n,e){if(e===null)return!1;for(var t=0;t<e.length&&t<n.length;t++)if(!wr(n[t],e[t]))return!1;return!0}function QT(n,e,t,i,a,r){return hc=r,on=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,Qt.H=n===null||n.memoizedState===null?ah:xc,Pu=!1,r=t(i,a),Pu=!1,qf&&(r=DO(e,t,i,a)),wO(n),r}function wO(n){Qt.H=to;var e=zn!==null&&zn.next!==null;if(hc=0,Pi=zn=on=null,C1=!1,Xm=0,Zf=null,e)throw Error(qe(300));n===null||aa||(n=n.dependencies,n!==null&&N1(n)&&(aa=!0))}function DO(n,e,t,i){on=n;var a=0;do{if(qf&&(Zf=null),Xm=0,qf=!1,25<=a)throw Error(qe(301));if(a+=1,Pi=zn=null,n.updateQueue!=null){var r=n.updateQueue;r.lastEffect=null,r.events=null,r.stores=null,r.memoCache!=null&&(r.memoCache.index=0)}Qt.H=rh,r=e(t,i)}while(qf);return r}function d7(){var n=Qt.H,e=n.useState()[0];return e=typeof e.then=="function"?y0(e):e,n=n.useState()[0],(zn!==null?zn.memoizedState:null)!==n&&(on.flags|=1024),e}function $T(){var n=R1!==0;return R1=0,n}function e3(n,e,t){e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~t}function t3(n){if(C1){for(n=n.memoizedState;n!==null;){var e=n.queue;e!==null&&(e.pending=null),n=n.next}C1=!1}hc=0,Pi=zn=on=null,qf=!1,Xm=R1=0,Zf=null}function Ka(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Pi===null?on.memoizedState=Pi=n:Pi=Pi.next=n,Pi}function Hi(){if(zn===null){var n=on.alternate;n=n!==null?n.memoizedState:null}else n=zn.next;var e=Pi===null?on.memoizedState:Pi.next;if(e!==null)Pi=e,zn=n;else{if(n===null)throw on.alternate===null?Error(qe(467)):Error(qe(310));zn=n,n={memoizedState:zn.memoizedState,baseState:zn.baseState,baseQueue:zn.baseQueue,queue:zn.queue,next:null},Pi===null?on.memoizedState=Pi=n:Pi=Pi.next=n}return Pi}var ay;ay=function(){return{lastEffect:null,events:null,stores:null,memoCache:null}};function y0(n){var e=Xm;return Xm+=1,Zf===null&&(Zf=[]),n=TO(Zf,n,e),e=on,(Pi===null?e.memoizedState:Pi.next)===null&&(e=e.alternate,Qt.H=e===null||e.memoizedState===null?ah:xc),n}function ry(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return y0(n);if(n.$$typeof===ko)return Ma(n)}throw Error(qe(438,String(n)))}function n3(n){var e=null,t=on.updateQueue;if(t!==null&&(e=t.memoCache),e==null){var i=on.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(e={data:i.data.map(function(a){return a.slice()}),index:0})))}if(e==null&&(e={data:[],index:0}),t===null&&(t=ay(),on.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]=jL;return e.index++,t}function tl(n,e){return typeof e=="function"?e(n):e}function n1(n){var e=Hi();return i3(e,zn,n)}function i3(n,e,t){var i=n.queue;if(i===null)throw Error(qe(311));i.lastRenderedReducer=t;var a=n.baseQueue,r=i.pending;if(r!==null){if(a!==null){var s=a.next;a.next=r.next,r.next=s}e.baseQueue=a=r,i.pending=null}if(r=n.baseState,a===null)n.memoizedState=r;else{e=a.next;var o=s=null,c=null,h=e,f=!1;do{var d=h.lane&-536870913;if(d!==h.lane?(_n&d)===d:(hc&d)===d){var m=h.revertLane;if(m===0)c!==null&&(c=c.next={lane:0,revertLane:0,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null}),d===sd&&(f=!0);else if((hc&m)===m){h=h.next,m===sd&&(f=!0);continue}else d={lane:0,revertLane:h.revertLane,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null},c===null?(o=c=d,s=r):c=c.next=d,on.lanes|=m,dc|=m;d=h.action,Pu&&t(r,d),r=h.hasEagerState?h.eagerState:t(r,d)}else m={lane:d,revertLane:h.revertLane,action:h.action,hasEagerState:h.hasEagerState,eagerState:h.eagerState,next:null},c===null?(o=c=m,s=r):c=c.next=m,on.lanes|=d,dc|=d;h=h.next}while(h!==null&&h!==e);if(c===null?s=r:c.next=o,!wr(r,n.memoizedState)&&(aa=!0,f&&(t=Yf,t!==null)))throw t;n.memoizedState=r,n.baseState=s,n.baseQueue=c,i.lastRenderedState=r}return a===null&&(i.lanes=0),[n.memoizedState,i.dispatch]}function WS(n){var e=Hi(),t=e.queue;if(t===null)throw Error(qe(311));t.lastRenderedReducer=n;var i=t.dispatch,a=t.pending,r=e.memoizedState;if(a!==null){t.pending=null;var s=a=a.next;do r=n(r,s.action),s=s.next;while(s!==a);wr(r,e.memoizedState)||(aa=!0),e.memoizedState=r,e.baseQueue===null&&(e.baseState=r),t.lastRenderedState=r}return[r,i]}function NO(n,e,t){var i=on,a=Hi(),r=Cn;if(r){if(t===void 0)throw Error(qe(407));t=t()}else t=e();var s=!wr((zn||a).memoizedState,t);if(s&&(a.memoizedState=t,aa=!0),a=a.queue,a3(BO.bind(null,i,a,n),[n]),a.getSnapshot!==e||s||Pi!==null&&Pi.memoizedState.tag&1){if(i.flags|=2048,od(9,IO.bind(null,i,a,t,e),{destroy:void 0},null),Qn===null)throw Error(qe(349));r||hc&60||OO(i,e,t)}return t}function OO(n,e,t){n.flags|=16384,n={getSnapshot:e,value:t},e=on.updateQueue,e===null?(e=ay(),on.updateQueue=e,e.stores=[n]):(t=e.stores,t===null?e.stores=[n]:t.push(n))}function IO(n,e,t,i){e.value=t,e.getSnapshot=i,UO(e)&&LO(n)}function BO(n,e,t){return t(function(){UO(e)&&LO(n)})}function UO(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!wr(n,t)}catch{return!0}}function LO(n){var e=uc(n,2);e!==null&&La(e,n,2)}function K2(n){var e=Ka();if(typeof n=="function"){var t=n;if(n=t(),Pu){Zl(!0);try{t()}finally{Zl(!1)}}}return e.memoizedState=e.baseState=n,e.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:n},e}function PO(n,e,t,i){return n.baseState=t,i3(n,zn,typeof i=="function"?i:tl)}function p7(n,e,t,i,a){if(oy(n))throw Error(qe(485));if(n=e.action,n!==null){var r={payload:a,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){r.listeners.push(s)}};Qt.T!==null?t(!0):r.isTransition=!1,i(r),t=e.pending,t===null?(r.next=e.pending=r,FO(e,r)):(r.next=t.next,e.pending=t.next=r)}}function FO(n,e){var t=e.action,i=e.payload,a=n.state;if(e.isTransition){var r=Qt.T,s={};Qt.T=s;try{var o=t(a,i),c=Qt.S;c!==null&&c(s,o),XR(n,e,o)}catch(h){J2(n,e,h)}finally{Qt.T=r}}else try{r=t(a,i),XR(n,e,r)}catch(h){J2(n,e,h)}}function XR(n,e,t){t!==null&&typeof t=="object"&&typeof t.then=="function"?t.then(function(i){WR(n,e,i)},function(i){return J2(n,e,i)}):WR(n,e,t)}function WR(n,e,t){e.status="fulfilled",e.value=t,HO(e),n.state=t,e=n.pending,e!==null&&(t=e.next,t===e?n.pending=null:(t=t.next,e.next=t,FO(n,t)))}function J2(n,e,t){var i=n.pending;if(n.pending=null,i!==null){i=i.next;do e.status="rejected",e.reason=t,HO(e),e=e.next;while(e!==i)}n.action=null}function HO(n){n=n.listeners;for(var e=0;e<n.length;e++)(0,n[e])()}function zO(n,e){return e}function GO(n,e){if(Cn){var t=Qn.formState;if(t!==null){e:{var i=on;if(Cn){if(fa){t:{for(var a=fa,r=qs;a.nodeType!==8;){if(!r){a=null;break t}if(a=Ds(a.nextSibling),a===null){a=null;break t}}r=a.data,a=r==="F!"||r==="F"?a:null}if(a){fa=Ds(a.nextSibling),i=a.data==="F!";break e}}Uu(i)}i=!1}i&&(e=t[0])}}return t=Ka(),t.memoizedState=t.baseState=e,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:zO,lastRenderedState:e},t.queue=i,t=aI.bind(null,on,i),i.dispatch=t,i=K2(!1),r=l3.bind(null,on,!1,i.queue),i=Ka(),a={state:e,dispatch:null,action:n,pending:null},i.queue=a,t=p7.bind(null,on,a,r,t),a.dispatch=t,i.memoizedState=n,[e,t,!1]}function VO(n){var e=Hi();return kO(e,zn,n)}function kO(n,e,t){e=i3(n,e,zO)[0],n=n1(tl)[0],e=typeof e=="object"&&e!==null&&typeof e.then=="function"?y0(e):e;var i=Hi(),a=i.queue,r=a.dispatch;return t!==i.memoizedState&&(on.flags|=2048,od(9,m7.bind(null,a,t),{destroy:void 0},null)),[e,r,n]}function m7(n,e){n.action=e}function XO(n){var e=Hi(),t=zn;if(t!==null)return kO(e,t,n);Hi(),e=e.memoizedState,t=Hi();var i=t.queue.dispatch;return t.memoizedState=n,[e,i,!1]}function od(n,e,t,i){return n={tag:n,create:e,inst:t,deps:i,next:null},e=on.updateQueue,e===null&&(e=ay(),on.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 WO(){return Hi().memoizedState}function i1(n,e,t,i){var a=Ka();on.flags|=n,a.memoizedState=od(1|e,t,{destroy:void 0},i===void 0?null:i)}function sy(n,e,t,i){var a=Hi();i=i===void 0?null:i;var r=a.memoizedState.inst;zn!==null&&i!==null&&JT(i,zn.memoizedState.deps)?a.memoizedState=od(e,t,r,i):(on.flags|=n,a.memoizedState=od(1|e,t,r,i))}function YR(n,e){i1(8390656,8,n,e)}function a3(n,e){sy(2048,8,n,e)}function YO(n,e){return sy(4,2,n,e)}function qO(n,e){return sy(4,4,n,e)}function ZO(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 jO(n,e,t){t=t!=null?t.concat([n]):null,sy(4,4,ZO.bind(null,e,n),t)}function r3(){}function KO(n,e){var t=Hi();e=e===void 0?null:e;var i=t.memoizedState;return e!==null&&JT(e,i[1])?i[0]:(t.memoizedState=[n,e],n)}function JO(n,e){var t=Hi();e=e===void 0?null:e;var i=t.memoizedState;if(e!==null&&JT(e,i[1]))return i[0];if(i=n(),Pu){Zl(!0);try{n()}finally{Zl(!1)}}return t.memoizedState=[i,e],i}function s3(n,e,t){return t===void 0||hc&1073741824?n.memoizedState=e:(n.memoizedState=t,n=HI(),on.lanes|=n,dc|=n,t)}function QO(n,e,t,i){return wr(t,e)?t:rd.current!==null?(n=s3(n,t,i),wr(n,e)||(aa=!0),n):hc&42?(n=HI(),on.lanes|=n,dc|=n,e):(aa=!0,n.memoizedState=t)}function $O(n,e,t,i,a){var r=ai.p;ai.p=r!==0&&8>r?r:8;var s=Qt.T,o={};Qt.T=o,l3(n,!1,e,t);try{var c=a(),h=Qt.S;if(h!==null&&h(o,c),c!==null&&typeof c=="object"&&typeof c.then=="function"){var f=h7(c,i);dm(n,e,f,Mr(n))}else dm(n,e,i,Mr(n))}catch(d){dm(n,e,{then:function(){},status:"rejected",reason:d},Mr())}finally{ai.p=r,Qt.T=s}}function g7(){}function Q2(n,e,t,i){if(n.tag!==5)throw Error(qe(476));var a=eI(n).queue;$O(n,a,e,Eu,t===null?g7:function(){return tI(n),t(i)})}function eI(n){var e=n.memoizedState;if(e!==null)return e;e={memoizedState:Eu,baseState:Eu,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:Eu},next:null};var t={};return e.next={memoizedState:t,baseState:t,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:t},next:null},n.memoizedState=e,n=n.alternate,n!==null&&(n.memoizedState=e),e}function tI(n){var e=eI(n).next.queue;dm(n,e,{},Mr())}function o3(){return Ma(Zm)}function nI(){return Hi().memoizedState}function iI(){return Hi().memoizedState}function v7(n){for(var e=n.return;e!==null;){switch(e.tag){case 24:case 3:var t=Mr();n=tc(t);var i=nc(e,n,t);i!==null&&(La(i,e,t),mm(i,e,t)),e={cache:jT()},n.payload=e;return}e=e.return}}function x7(n,e,t){var i=Mr();t={lane:i,revertLane:0,action:t,hasEagerState:!1,eagerState:null,next:null},oy(n)?rI(e,t):(t=WT(n,e,t,i),t!==null&&(La(t,n,i),sI(t,e,i)))}function aI(n,e,t){var i=Mr();dm(n,e,t,i)}function dm(n,e,t,i){var a={lane:i,revertLane:0,action:t,hasEagerState:!1,eagerState:null,next:null};if(oy(n))rI(e,a);else{var r=n.alternate;if(n.lanes===0&&(r===null||r.lanes===0)&&(r=e.lastRenderedReducer,r!==null))try{var s=e.lastRenderedState,o=r(s,t);if(a.hasEagerState=!0,a.eagerState=o,wr(o,s))return iy(n,e,a,0),Qn===null&&ny(),!1}catch{}finally{}if(t=WT(n,e,a,i),t!==null)return La(t,n,i),sI(t,e,i),!0}return!1}function l3(n,e,t,i){if(i={lane:2,revertLane:x3(),action:i,hasEagerState:!1,eagerState:null,next:null},oy(n)){if(e)throw Error(qe(479))}else e=WT(n,t,i,2),e!==null&&La(e,n,2)}function oy(n){var e=n.alternate;return n===on||e!==null&&e===on}function rI(n,e){qf=C1=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function sI(n,e,t){if(t&4194176){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,ZN(n,t)}}var to={readContext:Ma,use:ry,useCallback:Ri,useContext:Ri,useEffect:Ri,useImperativeHandle:Ri,useLayoutEffect:Ri,useInsertionEffect:Ri,useMemo:Ri,useReducer:Ri,useRef:Ri,useState:Ri,useDebugValue:Ri,useDeferredValue:Ri,useTransition:Ri,useSyncExternalStore:Ri,useId:Ri};to.useCacheRefresh=Ri;to.useMemoCache=Ri;to.useHostTransitionStatus=Ri;to.useFormState=Ri;to.useActionState=Ri;to.useOptimistic=Ri;var ah={readContext:Ma,use:ry,useCallback:function(n,e){return Ka().memoizedState=[n,e===void 0?null:e],n},useContext:Ma,useEffect:YR,useImperativeHandle:function(n,e,t){t=t!=null?t.concat([n]):null,i1(4194308,4,ZO.bind(null,e,n),t)},useLayoutEffect:function(n,e){return i1(4194308,4,n,e)},useInsertionEffect:function(n,e){i1(4,2,n,e)},useMemo:function(n,e){var t=Ka();e=e===void 0?null:e;var i=n();if(Pu){Zl(!0);try{n()}finally{Zl(!1)}}return t.memoizedState=[i,e],i},useReducer:function(n,e,t){var i=Ka();if(t!==void 0){var a=t(e);if(Pu){Zl(!0);try{t(e)}finally{Zl(!1)}}}else a=e;return i.memoizedState=i.baseState=a,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:a},i.queue=n,n=n.dispatch=x7.bind(null,on,n),[i.memoizedState,n]},useRef:function(n){var e=Ka();return n={current:n},e.memoizedState=n},useState:function(n){n=K2(n);var e=n.queue,t=aI.bind(null,on,e);return e.dispatch=t,[n.memoizedState,t]},useDebugValue:r3,useDeferredValue:function(n,e){var t=Ka();return s3(t,n,e)},useTransition:function(){var n=K2(!1);return n=$O.bind(null,on,n.queue,!0,!1),Ka().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,e,t){var i=on,a=Ka();if(Cn){if(t===void 0)throw Error(qe(407));t=t()}else{if(t=e(),Qn===null)throw Error(qe(349));_n&60||OO(i,e,t)}a.memoizedState=t;var r={value:t,getSnapshot:e};return a.queue=r,YR(BO.bind(null,i,r,n),[n]),i.flags|=2048,od(9,IO.bind(null,i,r,t,e),{destroy:void 0},null),t},useId:function(){var n=Ka(),e=Qn.identifierPrefix;if(Cn){var t=Wo,i=Xo;t=(i&~(1<<32-br(i)-1)).toString(32)+t,e=":"+e+"R"+t,t=R1++,0<t&&(e+="H"+t.toString(32)),e+=":"}else t=f7++,e=":"+e+"r"+t.toString(32)+":";return n.memoizedState=e},useCacheRefresh:function(){return Ka().memoizedState=v7.bind(null,on)}};ah.useMemoCache=n3;ah.useHostTransitionStatus=o3;ah.useFormState=GO;ah.useActionState=GO;ah.useOptimistic=function(n){var e=Ka();e.memoizedState=e.baseState=n;var t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return e.queue=t,e=l3.bind(null,on,!0,t),t.dispatch=e,[n,e]};var xc={readContext:Ma,use:ry,useCallback:KO,useContext:Ma,useEffect:a3,useImperativeHandle:jO,useInsertionEffect:YO,useLayoutEffect:qO,useMemo:JO,useReducer:n1,useRef:WO,useState:function(){return n1(tl)},useDebugValue:r3,useDeferredValue:function(n,e){var t=Hi();return QO(t,zn.memoizedState,n,e)},useTransition:function(){var n=n1(tl)[0],e=Hi().memoizedState;return[typeof n=="boolean"?n:y0(n),e]},useSyncExternalStore:NO,useId:nI};xc.useCacheRefresh=iI;xc.useMemoCache=n3;xc.useHostTransitionStatus=o3;xc.useFormState=VO;xc.useActionState=VO;xc.useOptimistic=function(n,e){var t=Hi();return PO(t,zn,n,e)};var rh={readContext:Ma,use:ry,useCallback:KO,useContext:Ma,useEffect:a3,useImperativeHandle:jO,useInsertionEffect:YO,useLayoutEffect:qO,useMemo:JO,useReducer:WS,useRef:WO,useState:function(){return WS(tl)},useDebugValue:r3,useDeferredValue:function(n,e){var t=Hi();return zn===null?s3(t,n,e):QO(t,zn.memoizedState,n,e)},useTransition:function(){var n=WS(tl)[0],e=Hi().memoizedState;return[typeof n=="boolean"?n:y0(n),e]},useSyncExternalStore:NO,useId:nI};rh.useCacheRefresh=iI;rh.useMemoCache=n3;rh.useHostTransitionStatus=o3;rh.useFormState=XO;rh.useActionState=XO;rh.useOptimistic=function(n,e){var t=Hi();return zn!==null?PO(t,zn,n,e):(t.baseState=n,[n,t.queue.dispatch])};function YS(n,e,t,i){e=n.memoizedState,t=t(i,e),t=t==null?e:si({},e,t),n.memoizedState=t,n.lanes===0&&(n.updateQueue.baseState=t)}var $2={isMounted:function(n){return(n=n._reactInternals)?Nd(n)===n:!1},enqueueSetState:function(n,e,t){n=n._reactInternals;var i=Mr(),a=tc(i);a.payload=e,t!=null&&(a.callback=t),e=nc(n,a,i),e!==null&&(La(e,n,i),mm(e,n,i))},enqueueReplaceState:function(n,e,t){n=n._reactInternals;var i=Mr(),a=tc(i);a.tag=1,a.payload=e,t!=null&&(a.callback=t),e=nc(n,a,i),e!==null&&(La(e,n,i),mm(e,n,i))},enqueueForceUpdate:function(n,e){n=n._reactInternals;var t=Mr(),i=tc(t);i.tag=2,e!=null&&(i.callback=e),e=nc(n,i,t),e!==null&&(La(e,n,t),mm(e,n,t))}};function qR(n,e,t,i,a,r,s){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(i,r,s):e.prototype&&e.prototype.isPureReactComponent?!Gm(t,i)||!Gm(a,r):!0}function ZR(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&&$2.enqueueReplaceState(e,e.state,null)}function Fu(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=si({},t));for(var a in n)t[a]===void 0&&(t[a]=n[a])}return t}var w1=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)};function oI(n){w1(n)}function lI(n){console.error(n)}function cI(n){w1(n)}function D1(n,e){try{var t=n.onUncaughtError;t(e.value,{componentStack:e.stack})}catch(i){setTimeout(function(){throw i})}}function jR(n,e,t){try{var i=n.onCaughtError;i(t.value,{componentStack:t.stack,errorBoundary:e.tag===1?e.stateNode:null})}catch(a){setTimeout(function(){throw a})}}function eE(n,e,t){return t=tc(t),t.tag=3,t.payload={element:null},t.callback=function(){D1(n,e)},t}function uI(n){return n=tc(n),n.tag=3,n}function hI(n,e,t,i){var a=t.type.getDerivedStateFromError;if(typeof a=="function"){var r=i.value;n.payload=function(){return a(r)},n.callback=function(){jR(e,t,i)}}var s=t.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){jR(e,t,i),typeof a!="function"&&(ac===null?ac=new Set([this]):ac.add(this));var o=i.stack;this.componentDidCatch(i.value,{componentStack:o!==null?o:""})})}function y7(n,e,t,i,a){if(t.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(e=t.alternate,e!==null&&_0(e,t,a,!0),t=rs.current,t!==null){switch(t.tag){case 13:return eo===null?mE():t.alternate===null&&Mi===0&&(Mi=3),t.flags&=-257,t.flags|=65536,t.lanes=a,i===q2?t.flags|=16384:(e=t.updateQueue,e===null?t.updateQueue=new Set([i]):e.add(i),rA(n,i,a)),!1;case 22:return t.flags|=65536,i===q2?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)),rA(n,i,a)),!1}throw Error(qe(435,t.tag))}return rA(n,i,a),mE(),!1}if(Cn)return e=rs.current,e!==null?(!(e.flags&65536)&&(e.flags|=256),e.flags|=65536,e.lanes=a,i!==Y2&&(n=Error(qe(422),{cause:i}),Vm(Jr(n,t)))):(i!==Y2&&(e=Error(qe(423),{cause:i}),Vm(Jr(e,t))),n=n.current.alternate,n.flags|=65536,a&=-a,n.lanes|=a,i=Jr(i,t),a=eE(n.stateNode,i,a),QS(n,a),Mi!==4&&(Mi=2)),!1;var r=Error(qe(520),{cause:i});if(r=Jr(r,t),ym===null?ym=[r]:ym.push(r),Mi!==4&&(Mi=2),e===null)return!0;i=Jr(i,t),t=e;do{switch(t.tag){case 3:return t.flags|=65536,n=a&-a,t.lanes|=n,n=eE(t.stateNode,i,n),QS(t,n),!1;case 1:if(e=t.type,r=t.stateNode,(t.flags&128)===0&&(typeof e.getDerivedStateFromError=="function"||r!==null&&typeof r.componentDidCatch=="function"&&(ac===null||!ac.has(r))))return t.flags|=65536,a&=-a,t.lanes|=a,a=uI(a),hI(a,n,t,i),QS(t,a),!1}t=t.return}while(t!==null);return!1}var fI=Error(qe(461)),aa=!1;function ha(n,e,t,i){e.child=n===null?MO(e,null,t,i):Lu(e,n.child,t,i)}function KR(n,e,t,i,a){t=t.render;var r=e.ref;if("ref"in i){var s={};for(var o in i)o!=="ref"&&(s[o]=i[o])}else s=i;return Hu(e),i=QT(n,e,t,s,r,a),o=$T(),n!==null&&!aa?(e3(n,e,a),nl(n,e,a)):(Cn&&o&&YT(e),e.flags|=1,ha(n,e,i,a),e.child)}function JR(n,e,t,i,a){if(n===null){var r=t.type;return typeof r=="function"&&!d3(r)&&r.defaultProps===void 0&&t.compare===null?(e.tag=15,e.type=r,dI(n,e,r,i,a)):(n=r1(t.type,null,i,e,e.mode,a),n.ref=e.ref,n.return=e,e.child=n)}if(r=n.child,!c3(n,a)){var s=r.memoizedProps;if(t=t.compare,t=t!==null?t:Gm,t(s,i)&&n.ref===e.ref)return nl(n,e,a)}return e.flags|=1,n=ic(r,i),n.ref=e.ref,n.return=e,e.child=n}function dI(n,e,t,i,a){if(n!==null){var r=n.memoizedProps;if(Gm(r,i)&&n.ref===e.ref)if(aa=!1,e.pendingProps=i=r,c3(n,a))n.flags&131072&&(aa=!0);else return e.lanes=n.lanes,nl(n,e,a)}return tE(n,e,t,i,a)}function pI(n,e,t){var i=e.pendingProps,a=i.children,r=(e.stateNode._pendingVisibility&2)!==0,s=n!==null?n.memoizedState:null;if(pm(n,e),i.mode==="hidden"||r){if(e.flags&128){if(i=s!==null?s.baseLanes|t:t,n!==null){for(a=e.child=n.child,r=0;a!==null;)r=r|a.lanes|a.childLanes,a=a.sibling;e.childLanes=r&~i}else e.childLanes=0,e.child=null;return QR(n,e,i,t)}if(t&536870912)e.memoizedState={baseLanes:0,cachePool:null},n!==null&&t1(e,s!==null?s.cachePool:null),s!==null?GR(e,s):Z2(),CO(e);else return e.lanes=e.childLanes=536870912,QR(n,e,s!==null?s.baseLanes|t:t,t)}else s!==null?(t1(e,s.cachePool),GR(e,s),Wl(),e.memoizedState=null):(n!==null&&t1(e,null),Z2(),Wl());return ha(n,e,a,t),e.child}function QR(n,e,t,i){var a=KT();return a=a===null?null:{parent:Vi._currentValue,pool:a},e.memoizedState={baseLanes:t,cachePool:a},n!==null&&t1(e,null),Z2(),CO(e),n!==null&&_0(n,e,i,!0),null}function pm(n,e){var t=e.ref;if(t===null)n!==null&&n.ref!==null&&(e.flags|=2097664);else{if(typeof t!="function"&&typeof t!="object")throw Error(qe(284));(n===null||n.ref!==t)&&(e.flags|=2097664)}}function tE(n,e,t,i,a){return Hu(e),t=QT(n,e,t,i,void 0,a),i=$T(),n!==null&&!aa?(e3(n,e,a),nl(n,e,a)):(Cn&&i&&YT(e),e.flags|=1,ha(n,e,t,a),e.child)}function $R(n,e,t,i,a,r){return Hu(e),e.updateQueue=null,t=DO(e,i,t,a),wO(n),i=$T(),n!==null&&!aa?(e3(n,e,r),nl(n,e,r)):(Cn&&i&&YT(e),e.flags|=1,ha(n,e,t,r),e.child)}function ew(n,e,t,i,a){if(Hu(e),e.stateNode===null){var r=Nf,s=t.contextType;typeof s=="object"&&s!==null&&(r=Ma(s)),r=new t(i,r),e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=$2,e.stateNode=r,r._reactInternals=e,r=e.stateNode,r.props=i,r.state=e.memoizedState,r.refs={},u3(e),s=t.contextType,r.context=typeof s=="object"&&s!==null?Ma(s):Nf,r.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(YS(e,t,s,i),r.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(s=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),s!==r.state&&$2.enqueueReplaceState(r,r.state,null),vm(e,i,r,a),gm(),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.flags|=4194308),i=!0}else if(n===null){r=e.stateNode;var o=e.memoizedProps,c=Fu(t,o);r.props=c;var h=r.context,f=t.contextType;s=Nf,typeof f=="object"&&f!==null&&(s=Ma(f));var d=t.getDerivedStateFromProps;f=typeof d=="function"||typeof r.getSnapshotBeforeUpdate=="function",o=e.pendingProps!==o,f||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(o||h!==s)&&ZR(e,r,i,s),kl=!1;var m=e.memoizedState;r.state=m,vm(e,i,r,a),gm(),h=e.memoizedState,o||m!==h||kl?(typeof d=="function"&&(YS(e,t,d,i),h=e.memoizedState),(c=kl||qR(e,t,c,i,m,h,s))?(f||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount()),typeof r.componentDidMount=="function"&&(e.flags|=4194308)):(typeof r.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=i,e.memoizedState=h),r.props=i,r.state=h,r.context=s,i=c):(typeof r.componentDidMount=="function"&&(e.flags|=4194308),i=!1)}else{r=e.stateNode,oE(n,e),s=e.memoizedProps,f=Fu(t,s),r.props=f,d=e.pendingProps,m=r.context,h=t.contextType,c=Nf,typeof h=="object"&&h!==null&&(c=Ma(h)),o=t.getDerivedStateFromProps,(h=typeof o=="function"||typeof r.getSnapshotBeforeUpdate=="function")||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(s!==d||m!==c)&&ZR(e,r,i,c),kl=!1,m=e.memoizedState,r.state=m,vm(e,i,r,a),gm();var g=e.memoizedState;s!==d||m!==g||kl||n!==null&&n.dependencies!==null&&N1(n.dependencies)?(typeof o=="function"&&(YS(e,t,o,i),g=e.memoizedState),(f=kl||qR(e,t,f,i,m,g,c)||n!==null&&n.dependencies!==null&&N1(n.dependencies))?(h||typeof r.UNSAFE_componentWillUpdate!="function"&&typeof r.componentWillUpdate!="function"||(typeof r.componentWillUpdate=="function"&&r.componentWillUpdate(i,g,c),typeof r.UNSAFE_componentWillUpdate=="function"&&r.UNSAFE_componentWillUpdate(i,g,c)),typeof r.componentDidUpdate=="function"&&(e.flags|=4),typeof r.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof r.componentDidUpdate!="function"||s===n.memoizedProps&&m===n.memoizedState||(e.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===n.memoizedProps&&m===n.memoizedState||(e.flags|=1024),e.memoizedProps=i,e.memoizedState=g),r.props=i,r.state=g,r.context=c,i=f):(typeof r.componentDidUpdate!="function"||s===n.memoizedProps&&m===n.memoizedState||(e.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===n.memoizedProps&&m===n.memoizedState||(e.flags|=1024),i=!1)}return r=i,pm(n,e),i=(e.flags&128)!==0,r||i?(r=e.stateNode,t=i&&typeof t.getDerivedStateFromError!="function"?null:r.render(),e.flags|=1,n!==null&&i?(e.child=Lu(e,n.child,null,a),e.child=Lu(e,null,t,a)):ha(n,e,t,a),e.memoizedState=r.state,n=e.child):n=nl(n,e,a),n}function tw(n,e,t,i){return v0(),e.flags|=256,ha(n,e,t,i),e.child}var qS={dehydrated:null,treeContext:null,retryLane:0};function ZS(n){return{baseLanes:n,cachePool:RO()}}function jS(n,e,t){return n=n!==null?n.childLanes&~t:0,e&&(n|=ts),n}function mI(n,e,t){var i=e.pendingProps,a=!1,r=(e.flags&128)!==0,s;if((s=r)||(s=n!==null&&n.memoizedState===null?!1:(Xi.current&2)!==0),s&&(a=!0,e.flags&=-129),s=(e.flags&32)!==0,e.flags&=-33,n===null){if(Cn){if(a?Xl(e):Wl(),Cn){var o=fa,c;if(c=o){e:{for(c=o,o=qs;c.nodeType!==8;){if(!o){o=null;break e}if(c=Ds(c.nextSibling),c===null){o=null;break e}}o=c}o!==null?(e.memoizedState={dehydrated:o,treeContext:Tu!==null?{id:Xo,overflow:Wo}:null,retryLane:536870912},c=es(18,null,null,0),c.stateNode=o,c.return=e,e.child=c,Ia=e,fa=null,c=!0):c=!1}c||Uu(e)}if(o=e.memoizedState,o!==null&&(o=o.dehydrated,o!==null))return o.data==="$!"?e.lanes=16:e.lanes=536870912,null;Yo(e)}return o=i.children,i=i.fallback,a?(Wl(),a=e.mode,o=iE({mode:"hidden",children:o},a),i=Mu(i,a,t,null),o.return=e,i.return=e,o.sibling=i,e.child=o,a=e.child,a.memoizedState=ZS(t),a.childLanes=jS(n,s,t),e.memoizedState=qS,i):(Xl(e),nE(e,o))}if(c=n.memoizedState,c!==null&&(o=c.dehydrated,o!==null)){if(r)e.flags&256?(Xl(e),e.flags&=-257,e=KS(n,e,t)):e.memoizedState!==null?(Wl(),e.child=n.child,e.flags|=128,e=null):(Wl(),a=i.fallback,o=e.mode,i=iE({mode:"visible",children:i.children},o),a=Mu(a,o,t,null),a.flags|=2,i.return=e,a.return=e,i.sibling=a,e.child=i,Lu(e,n.child,null,t),i=e.child,i.memoizedState=ZS(t),i.childLanes=jS(n,s,t),e.memoizedState=qS,e=a);else if(Xl(e),o.data==="$!"){if(s=o.nextSibling&&o.nextSibling.dataset,s)var h=s.dgst;s=h,i=Error(qe(419)),i.stack="",i.digest=s,Vm({value:i,source:null,stack:null}),e=KS(n,e,t)}else if(aa||_0(n,e,t,!1),s=(t&n.childLanes)!==0,aa||s){if(s=Qn,s!==null){if(i=t&-t,i&42)i=1;else switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=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:i=64;break;case 268435456:i=134217728;break;default:i=0}if(i=i&(s.suspendedLanes|t)?0:i,i!==0&&i!==c.retryLane)throw c.retryLane=i,uc(n,i),La(s,n,i),fI}o.data==="$?"||mE(),e=KS(n,e,t)}else o.data==="$?"?(e.flags|=128,e.child=n.child,e=B7.bind(null,n),o._reactRetry=e,e=null):(n=c.treeContext,fa=Ds(o.nextSibling),Ia=e,Cn=!0,Ms=null,qs=!1,n!==null&&(Zr[jr++]=Xo,Zr[jr++]=Wo,Zr[jr++]=Tu,Xo=n.id,Wo=n.overflow,Tu=e),e=nE(e,i.children),e.flags|=4096);return e}return a?(Wl(),a=i.fallback,o=e.mode,c=n.child,h=c.sibling,i=ic(c,{mode:"hidden",children:i.children}),i.subtreeFlags=c.subtreeFlags&31457280,h!==null?a=ic(h,a):(a=Mu(a,o,t,null),a.flags|=2),a.return=e,i.return=e,i.sibling=a,e.child=i,i=a,a=e.child,o=n.child.memoizedState,o===null?o=ZS(t):(c=o.cachePool,c!==null?(h=Vi._currentValue,c=c.parent!==h?{parent:h,pool:h}:c):c=RO(),o={baseLanes:o.baseLanes|t,cachePool:c}),a.memoizedState=o,a.childLanes=jS(n,s,t),e.memoizedState=qS,i):(Xl(e),t=n.child,n=t.sibling,t=ic(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 nE(n,e){return e=iE({mode:"visible",children:e},n.mode),e.return=n,n.child=e}function iE(n,e){return PI(n,e,0,null)}function KS(n,e,t){return Lu(e,n.child,null,t),n=nE(e,e.pendingProps.children),n.flags|=2,e.memoizedState=null,n}function nw(n,e,t){n.lanes|=e;var i=n.alternate;i!==null&&(i.lanes|=e),rE(n.return,e,t)}function JS(n,e,t,i,a){var r=n.memoizedState;r===null?n.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:i,tail:t,tailMode:a}:(r.isBackwards=e,r.rendering=null,r.renderingStartTime=0,r.last=i,r.tail=t,r.tailMode=a)}function gI(n,e,t){var i=e.pendingProps,a=i.revealOrder,r=i.tail;if(ha(n,e,i.children,t),i=Xi.current,i&2)i=i&1|2,e.flags|=128;else{if(n!==null&&n.flags&128)e:for(n=e.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&nw(n,t,e);else if(n.tag===19)nw(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}i&=1}switch(ui(Xi,i),a){case"forwards":for(t=e.child,a=null;t!==null;)n=t.alternate,n!==null&&M1(n)===null&&(a=t),t=t.sibling;t=a,t===null?(a=e.child,e.child=null):(a=t.sibling,t.sibling=null),JS(e,!1,a,t,r);break;case"backwards":for(t=null,a=e.child,e.child=null;a!==null;){if(n=a.alternate,n!==null&&M1(n)===null){e.child=a;break}n=a.sibling,a.sibling=t,t=a,a=n}JS(e,!0,t,null,r);break;case"together":JS(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function nl(n,e,t){if(n!==null&&(e.dependencies=n.dependencies),dc|=e.lanes,!(t&e.childLanes))if(n!==null){if(_0(n,e,t,!1),(t&e.childLanes)===0)return null}else return null;if(n!==null&&e.child!==n.child)throw Error(qe(153));if(e.child!==null){for(n=e.child,t=ic(n,n.pendingProps),e.child=t,t.return=e;n.sibling!==null;)n=n.sibling,t=t.sibling=ic(n,n.pendingProps),t.return=e;t.sibling=null}return e.child}function c3(n,e){return n.lanes&e?!0:(n=n.dependencies,!!(n!==null&&N1(n)))}function _7(n,e,t){switch(e.tag){case 3:v1(e,e.stateNode.containerInfo),Yl(e,Vi,n.memoizedState.cache),v0();break;case 27:case 5:P2(e);break;case 4:v1(e,e.stateNode.containerInfo);break;case 10:Yl(e,e.type,e.memoizedProps.value);break;case 13:var i=e.memoizedState;if(i!==null)return i.dehydrated!==null?(Xl(e),e.flags|=128,null):t&e.child.childLanes?mI(n,e,t):(Xl(e),n=nl(n,e,t),n!==null?n.sibling:null);Xl(e);break;case 19:var a=(n.flags&128)!==0;if(i=(t&e.childLanes)!==0,i||(_0(n,e,t,!1),i=(t&e.childLanes)!==0),a){if(i)return gI(n,e,t);e.flags|=128}if(a=e.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),ui(Xi,Xi.current),i)break;return null;case 22:case 23:return e.lanes=0,pI(n,e,t);case 24:Yl(e,Vi,n.memoizedState.cache)}return nl(n,e,t)}function vI(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps)aa=!0;else{if(!c3(n,t)&&!(e.flags&128))return aa=!1,_7(n,e,t);aa=!!(n.flags&131072)}else aa=!1,Cn&&e.flags&1048576&&AO(e,T1,e.index);switch(e.lanes=0,e.tag){case 16:e:{n=e.pendingProps;var i=e.elementType,a=i._init;if(i=a(i._payload),e.type=i,typeof i=="function")d3(i)?(n=Fu(i,n),e.tag=1,e=ew(null,e,i,n,t)):(e.tag=0,e=tE(null,e,i,n,t));else{if(i!=null){if(a=i.$$typeof,a===BT){e.tag=11,e=KR(null,e,i,n,t);break e}else if(a===UT){e.tag=14,e=JR(null,e,i,n,t);break e}}throw e=U2(i)||i,Error(qe(306,e,""))}}return e;case 0:return tE(n,e,e.type,e.pendingProps,t);case 1:return i=e.type,a=Fu(i,e.pendingProps),ew(n,e,i,a,t);case 3:e:{if(v1(e,e.stateNode.containerInfo),n===null)throw Error(qe(387));var r=e.pendingProps;a=e.memoizedState,i=a.element,oE(n,e),vm(e,r,null,t);var s=e.memoizedState;if(r=s.cache,Yl(e,Vi,r),r!==a.cache&&sE(e,[Vi],t,!0),gm(),r=s.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:s.cache},e.updateQueue.baseState=a,e.memoizedState=a,e.flags&256){e=tw(n,e,r,t);break e}else if(r!==i){i=Jr(Error(qe(424)),e),Vm(i),e=tw(n,e,r,t);break e}else for(fa=Ds(e.stateNode.containerInfo.firstChild),Ia=e,Cn=!0,Ms=null,qs=!0,t=MO(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(v0(),r===i){e=nl(n,e,t);break e}ha(n,e,r,t)}e=e.child}return e;case 26:return pm(n,e),n===null?(t=_w(e.type,null,e.pendingProps,null))?e.memoizedState=t:Cn||(t=e.type,n=e.pendingProps,i=F1(ec.current).createElement(t),i[ba]=e,i[$a]=n,ma(i,t,n),ia(i),e.stateNode=i):e.memoizedState=_w(e.type,n.memoizedProps,e.pendingProps,n.memoizedState),null;case 27:return P2(e),n===null&&Cn&&(i=e.stateNode=t5(e.type,e.pendingProps,ec.current),Ia=e,qs=!0,fa=Ds(i.firstChild)),i=e.pendingProps.children,n!==null||Cn?ha(n,e,i,t):e.child=Lu(e,null,i,t),pm(n,e),e.child;case 5:return n===null&&Cn&&((a=i=fa)&&(i=K7(i,e.type,e.pendingProps,qs),i!==null?(e.stateNode=i,Ia=e,fa=Ds(i.firstChild),qs=!1,a=!0):a=!1),a||Uu(e)),P2(e),a=e.type,r=e.pendingProps,s=n!==null?n.memoizedProps:null,i=r.children,_E(a,r)?i=null:s!==null&&_E(a,s)&&(e.flags|=32),e.memoizedState!==null&&(a=QT(n,e,d7,null,null,t),Zm._currentValue=a),pm(n,e),ha(n,e,i,t),e.child;case 6:return n===null&&Cn&&((n=t=fa)&&(t=J7(t,e.pendingProps,qs),t!==null?(e.stateNode=t,Ia=e,fa=null,n=!0):n=!1),n||Uu(e)),null;case 13:return mI(n,e,t);case 4:return v1(e,e.stateNode.containerInfo),i=e.pendingProps,n===null?e.child=Lu(e,null,i,t):ha(n,e,i,t),e.child;case 11:return KR(n,e,e.type,e.pendingProps,t);case 7:return ha(n,e,e.pendingProps,t),e.child;case 8:return ha(n,e,e.pendingProps.children,t),e.child;case 12:return ha(n,e,e.pendingProps.children,t),e.child;case 10:return i=e.pendingProps,Yl(e,e.type,i.value),ha(n,e,i.children,t),e.child;case 9:return a=e.type._context,i=e.pendingProps.children,Hu(e),a=Ma(a),i=i(a),e.flags|=1,ha(n,e,i,t),e.child;case 14:return JR(n,e,e.type,e.pendingProps,t);case 15:return dI(n,e,e.type,e.pendingProps,t);case 19:return gI(n,e,t);case 22:return pI(n,e,t);case 24:return Hu(e),i=Ma(Vi),n===null?(a=KT(),a===null&&(a=Qn,r=jT(),a.pooledCache=r,r.refCount++,r!==null&&(a.pooledCacheLanes|=t),a=r),e.memoizedState={parent:i,cache:a},u3(e),Yl(e,Vi,a)):(n.lanes&t&&(oE(n,e),vm(e,null,null,t),gm()),a=n.memoizedState,r=e.memoizedState,a.parent!==i?(a={parent:i,cache:i},e.memoizedState=a,e.lanes===0&&(e.memoizedState=e.updateQueue.baseState=a),Yl(e,Vi,i)):(i=r.cache,Yl(e,Vi,i),i!==a.cache&&sE(e,[Vi],t,!0))),ha(n,e,e.pendingProps.children,t),e.child;case 29:throw e.pendingProps}throw Error(qe(156,e.tag))}var aE=ao(null),sh=null,qo=null;function Yl(n,e,t){ui(aE,e._currentValue),e._currentValue=t}function Ko(n){n._currentValue=aE.current,ra(aE)}function rE(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 sE(n,e,t,i){var a=n.child;for(a!==null&&(a.return=n);a!==null;){var r=a.dependencies;if(r!==null){var s=a.child;r=r.firstContext;e:for(;r!==null;){var o=r;r=a;for(var c=0;c<e.length;c++)if(o.context===e[c]){r.lanes|=t,o=r.alternate,o!==null&&(o.lanes|=t),rE(r.return,t,n),i||(s=null);break e}r=o.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(qe(341));s.lanes|=t,r=s.alternate,r!==null&&(r.lanes|=t),rE(s,t,n),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===n){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function _0(n,e,t,i){n=null;for(var a=e,r=!1;a!==null;){if(!r){if(a.flags&524288)r=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(qe(387));if(s=s.memoizedProps,s!==null){var o=a.type;wr(a.pendingProps.value,s.value)||(n!==null?n.push(o):n=[o])}}else if(a===g1.current){if(s=a.alternate,s===null)throw Error(qe(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(n!==null?n.push(Zm):n=[Zm])}a=a.return}n!==null&&sE(e,n,t,i),e.flags|=262144}function N1(n){for(n=n.firstContext;n!==null;){if(!wr(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Hu(n){sh=n,qo=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function Ma(n){return xI(sh,n)}function Pg(n,e){return sh===null&&Hu(n),xI(n,e)}function xI(n,e){var t=e._currentValue;if(e={context:e,memoizedValue:t,next:null},qo===null){if(n===null)throw Error(qe(308));qo=e,n.dependencies={lanes:0,firstContext:e},n.flags|=524288}else qo=qo.next=e;return t}var kl=!1;function u3(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function oE(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 tc(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function nc(n,e,t){var i=n.updateQueue;if(i===null)return null;if(i=i.shared,vi&2){var a=i.pending;return a===null?e.next=e:(e.next=a.next,a.next=e),i.pending=e,e=A1(n),SO(n,null,t),e}return iy(n,i,e,t),A1(n)}function mm(n,e,t){if(e=e.updateQueue,e!==null&&(e=e.shared,(t&4194176)!==0)){var i=e.lanes;i&=n.pendingLanes,t|=i,e.lanes=t,ZN(n,t)}}function QS(n,e){var t=n.updateQueue,i=n.alternate;if(i!==null&&(i=i.updateQueue,t===i)){var a=null,r=null;if(t=t.firstBaseUpdate,t!==null){do{var s={lane:t.lane,tag:t.tag,payload:t.payload,callback:null,next:null};r===null?a=r=s:r=r.next=s,t=t.next}while(t!==null);r===null?a=r=e:r=r.next=e}else a=r=e;t={baseState:i.baseState,firstBaseUpdate:a,lastBaseUpdate:r,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 lE=!1;function gm(){if(lE){var n=Yf;if(n!==null)throw n}}function vm(n,e,t,i){lE=!1;var a=n.updateQueue;kl=!1;var r=a.firstBaseUpdate,s=a.lastBaseUpdate,o=a.shared.pending;if(o!==null){a.shared.pending=null;var c=o,h=c.next;c.next=null,s===null?r=h:s.next=h,s=c;var f=n.alternate;f!==null&&(f=f.updateQueue,o=f.lastBaseUpdate,o!==s&&(o===null?f.firstBaseUpdate=h:o.next=h,f.lastBaseUpdate=c))}if(r!==null){var d=a.baseState;s=0,f=h=c=null,o=r;do{var m=o.lane&-536870913,g=m!==o.lane;if(g?(_n&m)===m:(i&m)===m){m!==0&&m===sd&&(lE=!0),f!==null&&(f=f.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var y=n,E=o;m=e;var S=t;switch(E.tag){case 1:if(y=E.payload,typeof y=="function"){d=y.call(S,d,m);break e}d=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=E.payload,m=typeof y=="function"?y.call(S,d,m):y,m==null)break e;d=si({},d,m);break e;case 2:kl=!0}}m=o.callback,m!==null&&(n.flags|=64,g&&(n.flags|=8192),g=a.callbacks,g===null?a.callbacks=[m]:g.push(m))}else g={lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},f===null?(h=f=g,c=d):f=f.next=g,s|=m;if(o=o.next,o===null){if(o=a.shared.pending,o===null)break;g=o,o=g.next,g.next=null,a.lastBaseUpdate=g,a.shared.pending=null}}while(!0);f===null&&(c=d),a.baseState=c,a.firstBaseUpdate=h,a.lastBaseUpdate=f,r===null&&(a.shared.lanes=0),dc|=s,n.lanes=s,n.memoizedState=d}}function yI(n,e){if(typeof n!="function")throw Error(qe(191,n));n.call(e)}function _I(n,e){var t=n.callbacks;if(t!==null)for(n.callbacks=null,n=0;n<t.length;n++)yI(t[n],e)}function S0(n,e){try{var t=e.updateQueue,i=t!==null?t.lastEffect:null;if(i!==null){var a=i.next;t=a;do{if((t.tag&n)===n){i=void 0;var r=t.create,s=t.inst;i=r(),s.destroy=i}t=t.next}while(t!==a)}}catch(o){kn(e,e.return,o)}}function fc(n,e,t){try{var i=e.updateQueue,a=i!==null?i.lastEffect:null;if(a!==null){var r=a.next;i=r;do{if((i.tag&n)===n){var s=i.inst,o=s.destroy;if(o!==void 0){s.destroy=void 0,a=e;var c=t;try{o()}catch(h){kn(a,c,h)}}}i=i.next}while(i!==r)}}catch(h){kn(e,e.return,h)}}function SI(n){var e=n.updateQueue;if(e!==null){var t=n.stateNode;try{_I(e,t)}catch(i){kn(n,n.return,i)}}}function AI(n,e,t){t.props=Fu(n.type,n.memoizedProps),t.state=n.memoizedState;try{t.componentWillUnmount()}catch(i){kn(n,e,i)}}function mu(n,e){try{var t=n.ref;if(t!==null){var i=n.stateNode;switch(n.tag){case 26:case 27:case 5:var a=i;break;default:a=i}typeof t=="function"?n.refCleanup=t(a):t.current=a}}catch(r){kn(n,e,r)}}function _r(n,e){var t=n.ref,i=n.refCleanup;if(t!==null)if(typeof i=="function")try{i()}catch(a){kn(n,e,a)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof t=="function")try{t(null)}catch(a){kn(n,e,a)}else t.current=null}function EI(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(a){kn(n,n.return,a)}}function iw(n,e,t){try{var i=n.stateNode;W7(i,n.type,t,e),i[$a]=e}catch(a){kn(n,n.return,a)}}function TI(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27||n.tag===4}function $S(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||TI(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==27&&n.tag!==18;){if(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 cE(n,e,t){var i=n.tag;if(i===5||i===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=uy));else if(i!==4&&i!==27&&(n=n.child,n!==null))for(cE(n,e,t),n=n.sibling;n!==null;)cE(n,e,t),n=n.sibling}function O1(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&&(n=n.child,n!==null))for(O1(n,e,t),n=n.sibling;n!==null;)O1(n,e,t),n=n.sibling}var Po=!1,bi=!1,eA=!1,aw=typeof WeakSet=="function"?WeakSet:Set,na=null,rw=!1;function S7(n,e){if(n=n.containerInfo,xE=V1,n=pO(n),kT(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 a=i.anchorOffset,r=i.focusNode;i=i.focusOffset;try{t.nodeType,r.nodeType}catch{t=null;break e}var s=0,o=-1,c=-1,h=0,f=0,d=n,m=null;t:for(;;){for(var g;d!==t||a!==0&&d.nodeType!==3||(o=s+a),d!==r||i!==0&&d.nodeType!==3||(c=s+i),d.nodeType===3&&(s+=d.nodeValue.length),(g=d.firstChild)!==null;)m=d,d=g;for(;;){if(d===n)break t;if(m===t&&++h===a&&(o=s),m===r&&++f===i&&(c=s),(g=d.nextSibling)!==null)break;d=m,m=d.parentNode}d=g}t=o===-1||c===-1?null:{start:o,end:c}}else t=null}t=t||{start:0,end:0}}else t=null;for(yE={focusedElem:n,selectionRange:t},V1=!1,na=e;na!==null;)if(e=na,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,na=n;else for(;na!==null;){switch(e=na,r=e.alternate,n=e.flags,e.tag){case 0:break;case 11:case 15:break;case 1:if(n&1024&&r!==null){n=void 0,t=e,a=r.memoizedProps,r=r.memoizedState,i=t.stateNode;try{var y=Fu(t.type,a,t.elementType===t.type);n=i.getSnapshotBeforeUpdate(y,r),i.__reactInternalSnapshotBeforeUpdate=n}catch(E){kn(t,t.return,E)}}break;case 3:if(n&1024){if(n=e.stateNode.containerInfo,t=n.nodeType,t===9)SE(n);else if(t===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":SE(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(qe(163))}if(n=e.sibling,n!==null){n.return=e.return,na=n;break}na=e.return}return y=rw,rw=!1,y}function bI(n,e,t){var i=t.flags;switch(t.tag){case 0:case 11:case 15:So(n,t),i&4&&S0(5,t);break;case 1:if(So(n,t),i&4)if(n=t.stateNode,e===null)try{n.componentDidMount()}catch(o){kn(t,t.return,o)}else{var a=Fu(t.type,e.memoizedProps);e=e.memoizedState;try{n.componentDidUpdate(a,e,n.__reactInternalSnapshotBeforeUpdate)}catch(o){kn(t,t.return,o)}}i&64&&SI(t),i&512&&mu(t,t.return);break;case 3:if(So(n,t),i&64&&(i=t.updateQueue,i!==null)){if(n=null,t.child!==null)switch(t.child.tag){case 27:case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}try{_I(i,n)}catch(o){kn(t,t.return,o)}}break;case 26:So(n,t),i&512&&mu(t,t.return);break;case 27:case 5:So(n,t),e===null&&i&4&&EI(t),i&512&&mu(t,t.return);break;case 12:So(n,t);break;case 13:So(n,t),i&4&&RI(n,t);break;case 22:if(a=t.memoizedState!==null||Po,!a){e=e!==null&&e.memoizedState!==null||bi;var r=Po,s=bi;Po=a,(bi=e)&&!s?Gl(n,t,(t.subtreeFlags&8772)!==0):So(n,t),Po=r,bi=s}i&512&&(t.memoizedProps.mode==="manual"?mu(t,t.return):_r(t,t.return));break;default:So(n,t)}}function MI(n){var e=n.alternate;e!==null&&(n.alternate=null,MI(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&PT(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 Li=null,xr=!1;function _o(n,e,t){for(t=t.child;t!==null;)CI(n,e,t),t=t.sibling}function CI(n,e,t){if(Tr&&typeof Tr.onCommitFiberUnmount=="function")try{Tr.onCommitFiberUnmount(d0,t)}catch{}switch(t.tag){case 26:bi||_r(t,e),_o(n,e,t),t.memoizedState?t.memoizedState.count--:t.stateNode&&(t=t.stateNode,t.parentNode.removeChild(t));break;case 27:bi||_r(t,e);var i=Li,a=xr;for(Li=t.stateNode,_o(n,e,t),t=t.stateNode,e=t.attributes;e.length;)t.removeAttributeNode(e[0]);PT(t),Li=i,xr=a;break;case 5:bi||_r(t,e);case 6:a=Li;var r=xr;if(Li=null,_o(n,e,t),Li=a,xr=r,Li!==null)if(xr)try{n=Li,i=t.stateNode,n.nodeType===8?n.parentNode.removeChild(i):n.removeChild(i)}catch(s){kn(t,e,s)}else try{Li.removeChild(t.stateNode)}catch(s){kn(t,e,s)}break;case 18:Li!==null&&(xr?(e=Li,t=t.stateNode,e.nodeType===8?fA(e.parentNode,t):e.nodeType===1&&fA(e,t),Jm(e)):fA(Li,t.stateNode));break;case 4:i=Li,a=xr,Li=t.stateNode.containerInfo,xr=!0,_o(n,e,t),Li=i,xr=a;break;case 0:case 11:case 14:case 15:bi||fc(2,t,e),bi||fc(4,t,e),_o(n,e,t);break;case 1:bi||(_r(t,e),i=t.stateNode,typeof i.componentWillUnmount=="function"&&AI(t,e,i)),_o(n,e,t);break;case 21:_o(n,e,t);break;case 22:bi||_r(t,e),bi=(i=bi)||t.memoizedState!==null,_o(n,e,t),bi=i;break;default:_o(n,e,t)}}function RI(n,e){if(e.memoizedState===null&&(n=e.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{Jm(n)}catch(t){kn(e,e.return,t)}}function A7(n){switch(n.tag){case 13:case 19:var e=n.stateNode;return e===null&&(e=n.stateNode=new aw),e;case 22:return n=n.stateNode,e=n._retryCache,e===null&&(e=n._retryCache=new aw),e;default:throw Error(qe(435,n.tag))}}function tA(n,e){var t=A7(n);e.forEach(function(i){var a=U7.bind(null,n,i);t.has(i)||(t.add(i),i.then(a,a))})}function Gr(n,e){var t=e.deletions;if(t!==null)for(var i=0;i<t.length;i++){var a=t[i],r=n,s=e,o=s;e:for(;o!==null;){switch(o.tag){case 27:case 5:Li=o.stateNode,xr=!1;break e;case 3:Li=o.stateNode.containerInfo,xr=!0;break e;case 4:Li=o.stateNode.containerInfo,xr=!0;break e}o=o.return}if(Li===null)throw Error(qe(160));CI(r,s,a),Li=null,xr=!1,r=a.alternate,r!==null&&(r.return=null),a.return=null}if(e.subtreeFlags&13878)for(e=e.child;e!==null;)wI(e,n),e=e.sibling}var bs=null;function wI(n,e){var t=n.alternate,i=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:Gr(e,n),Vr(n),i&4&&(fc(3,n,n.return),S0(3,n),fc(5,n,n.return));break;case 1:Gr(e,n),Vr(n),i&512&&(bi||t===null||_r(t,t.return)),i&64&&Po&&(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 a=bs;if(Gr(e,n),Vr(n),i&512&&(bi||t===null||_r(t,t.return)),i&4){var r=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,a=a.ownerDocument||a;t:switch(i){case"title":r=a.getElementsByTagName("title")[0],(!r||r[Fm]||r[ba]||r.namespaceURI==="http://www.w3.org/2000/svg"||r.hasAttribute("itemprop"))&&(r=a.createElement(i),a.head.insertBefore(r,a.querySelector("head > title"))),ma(r,i,t),r[ba]=n,ia(r),i=r;break e;case"link":var s=Aw("link","href",a).get(i+(t.href||""));if(s){for(var o=0;o<s.length;o++)if(r=s[o],r.getAttribute("href")===(t.href==null?null:t.href)&&r.getAttribute("rel")===(t.rel==null?null:t.rel)&&r.getAttribute("title")===(t.title==null?null:t.title)&&r.getAttribute("crossorigin")===(t.crossOrigin==null?null:t.crossOrigin)){s.splice(o,1);break t}}r=a.createElement(i),ma(r,i,t),a.head.appendChild(r);break;case"meta":if(s=Aw("meta","content",a).get(i+(t.content||""))){for(o=0;o<s.length;o++)if(r=s[o],r.getAttribute("content")===(t.content==null?null:""+t.content)&&r.getAttribute("name")===(t.name==null?null:t.name)&&r.getAttribute("property")===(t.property==null?null:t.property)&&r.getAttribute("http-equiv")===(t.httpEquiv==null?null:t.httpEquiv)&&r.getAttribute("charset")===(t.charSet==null?null:t.charSet)){s.splice(o,1);break t}}r=a.createElement(i),ma(r,i,t),a.head.appendChild(r);break;default:throw Error(qe(468,i))}r[ba]=n,ia(r),i=r}n.stateNode=i}else Ew(a,n.type,n.stateNode);else n.stateNode=Sw(a,i,n.memoizedProps);else r!==i?(r===null?t.stateNode!==null&&(t=t.stateNode,t.parentNode.removeChild(t)):r.count--,i===null?Ew(a,n.type,n.stateNode):Sw(a,i,n.memoizedProps)):i===null&&n.stateNode!==null&&iw(n,n.memoizedProps,t.memoizedProps)}break;case 27:if(i&4&&n.alternate===null){a=n.stateNode,r=n.memoizedProps;try{for(var c=a.firstChild;c;){var h=c.nextSibling,f=c.nodeName;c[Fm]||f==="HEAD"||f==="BODY"||f==="SCRIPT"||f==="STYLE"||f==="LINK"&&c.rel.toLowerCase()==="stylesheet"||a.removeChild(c),c=h}for(var d=n.type,m=a.attributes;m.length;)a.removeAttributeNode(m[0]);ma(a,d,r),a[ba]=n,a[$a]=r}catch(y){kn(n,n.return,y)}}case 5:if(Gr(e,n),Vr(n),i&512&&(bi||t===null||_r(t,t.return)),n.flags&32){a=n.stateNode;try{ad(a,"")}catch(y){kn(n,n.return,y)}}i&4&&n.stateNode!=null&&(a=n.memoizedProps,iw(n,a,t!==null?t.memoizedProps:a)),i&1024&&(eA=!0);break;case 6:if(Gr(e,n),Vr(n),i&4){if(n.stateNode===null)throw Error(qe(162));i=n.memoizedProps,t=n.stateNode;try{t.nodeValue=i}catch(y){kn(n,n.return,y)}}break;case 3:if(o1=null,a=bs,bs=H1(e.containerInfo),Gr(e,n),bs=a,Vr(n),i&4&&t!==null&&t.memoizedState.isDehydrated)try{Jm(e.containerInfo)}catch(y){kn(n,n.return,y)}eA&&(eA=!1,DI(n));break;case 4:i=bs,bs=H1(n.stateNode.containerInfo),Gr(e,n),Vr(n),bs=i;break;case 12:Gr(e,n),Vr(n);break;case 13:Gr(e,n),Vr(n),n.child.flags&8192&&n.memoizedState!==null!=(t!==null&&t.memoizedState!==null)&&(g3=$s()),i&4&&(i=n.updateQueue,i!==null&&(n.updateQueue=null,tA(n,i)));break;case 22:if(i&512&&(bi||t===null||_r(t,t.return)),c=n.memoizedState!==null,h=t!==null&&t.memoizedState!==null,f=Po,d=bi,Po=f||c,bi=d||h,Gr(e,n),bi=d,Po=f,Vr(n),e=n.stateNode,e._current=n,e._visibility&=-3,e._visibility|=e._pendingVisibility&2,i&8192&&(e._visibility=c?e._visibility&-2:e._visibility|1,c&&(e=Po||bi,t===null||h||e||Sf(n)),n.memoizedProps===null||n.memoizedProps.mode!=="manual"))e:for(t=null,e=n;;){if(e.tag===5||e.tag===26||e.tag===27){if(t===null){h=t=e;try{if(a=h.stateNode,c)r=a.style,typeof r.setProperty=="function"?r.setProperty("display","none","important"):r.display="none";else{s=h.stateNode,o=h.memoizedProps.style;var g=o!=null&&o.hasOwnProperty("display")?o.display:null;s.style.display=g==null||typeof g=="boolean"?"":(""+g).trim()}}catch(y){kn(h,h.return,y)}}}else if(e.tag===6){if(t===null){h=e;try{h.stateNode.nodeValue=c?"":h.memoizedProps}catch(y){kn(h,h.return,y)}}}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,tA(n,t))));break;case 19:Gr(e,n),Vr(n),i&4&&(i=n.updateQueue,i!==null&&(n.updateQueue=null,tA(n,i)));break;case 21:break;default:Gr(e,n),Vr(n)}}function Vr(n){var e=n.flags;if(e&2){try{if(n.tag!==27){e:{for(var t=n.return;t!==null;){if(TI(t)){var i=t;break e}t=t.return}throw Error(qe(160))}switch(i.tag){case 27:var a=i.stateNode,r=$S(n);O1(n,r,a);break;case 5:var s=i.stateNode;i.flags&32&&(ad(s,""),i.flags&=-33);var o=$S(n);O1(n,o,s);break;case 3:case 4:var c=i.stateNode.containerInfo,h=$S(n);cE(n,h,c);break;default:throw Error(qe(161))}}}catch(f){kn(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 So(n,e){if(e.subtreeFlags&8772)for(e=e.child;e!==null;)bI(n,e.alternate,e),e=e.sibling}function Sf(n){for(n=n.child;n!==null;){var e=n;switch(e.tag){case 0:case 11:case 14:case 15:fc(4,e,e.return),Sf(e);break;case 1:_r(e,e.return);var t=e.stateNode;typeof t.componentWillUnmount=="function"&&AI(e,e.return,t),Sf(e);break;case 26:case 27:case 5:_r(e,e.return),Sf(e);break;case 22:_r(e,e.return),e.memoizedState===null&&Sf(e);break;default:Sf(e)}n=n.sibling}}function Gl(n,e,t){for(t=t&&(e.subtreeFlags&8772)!==0,e=e.child;e!==null;){var i=e.alternate,a=n,r=e,s=r.flags;switch(r.tag){case 0:case 11:case 15:Gl(a,r,t),S0(4,r);break;case 1:if(Gl(a,r,t),i=r,a=i.stateNode,typeof a.componentDidMount=="function")try{a.componentDidMount()}catch(h){kn(i,i.return,h)}if(i=r,a=i.updateQueue,a!==null){var o=i.stateNode;try{var c=a.shared.hiddenCallbacks;if(c!==null)for(a.shared.hiddenCallbacks=null,a=0;a<c.length;a++)yI(c[a],o)}catch(h){kn(i,i.return,h)}}t&&s&64&&SI(r),mu(r,r.return);break;case 26:case 27:case 5:Gl(a,r,t),t&&i===null&&s&4&&EI(r),mu(r,r.return);break;case 12:Gl(a,r,t);break;case 13:Gl(a,r,t),t&&s&4&&RI(a,r);break;case 22:r.memoizedState===null&&Gl(a,r,t),mu(r,r.return);break;default:Gl(a,r,t)}e=e.sibling}}function h3(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&&x0(t))}function f3(n,e){n=null,e.alternate!==null&&(n=e.alternate.memoizedState.cache),e=e.memoizedState.cache,e!==n&&(e.refCount++,n!=null&&x0(n))}function Rl(n,e,t,i){if(e.subtreeFlags&10256)for(e=e.child;e!==null;)NI(n,e,t,i),e=e.sibling}function NI(n,e,t,i){var a=e.flags;switch(e.tag){case 0:case 11:case 15:Rl(n,e,t,i),a&2048&&S0(9,e);break;case 3:Rl(n,e,t,i),a&2048&&(n=null,e.alternate!==null&&(n=e.alternate.memoizedState.cache),e=e.memoizedState.cache,e!==n&&(e.refCount++,n!=null&&x0(n)));break;case 12:if(a&2048){Rl(n,e,t,i),n=e.stateNode;try{var r=e.memoizedProps,s=r.id,o=r.onPostCommit;typeof o=="function"&&o(s,e.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(c){kn(e,e.return,c)}}else Rl(n,e,t,i);break;case 23:break;case 22:r=e.stateNode,e.memoizedState!==null?r._visibility&4?Rl(n,e,t,i):xm(n,e):r._visibility&4?Rl(n,e,t,i):(r._visibility|=4,Af(n,e,t,i,(e.subtreeFlags&10256)!==0)),a&2048&&h3(e.alternate,e);break;case 24:Rl(n,e,t,i),a&2048&&f3(e.alternate,e);break;default:Rl(n,e,t,i)}}function Af(n,e,t,i,a){for(a=a&&(e.subtreeFlags&10256)!==0,e=e.child;e!==null;){var r=n,s=e,o=t,c=i,h=s.flags;switch(s.tag){case 0:case 11:case 15:Af(r,s,o,c,a),S0(8,s);break;case 23:break;case 22:var f=s.stateNode;s.memoizedState!==null?f._visibility&4?Af(r,s,o,c,a):xm(r,s):(f._visibility|=4,Af(r,s,o,c,a)),a&&h&2048&&h3(s.alternate,s);break;case 24:Af(r,s,o,c,a),a&&h&2048&&f3(s.alternate,s);break;default:Af(r,s,o,c,a)}e=e.sibling}}function xm(n,e){if(e.subtreeFlags&10256)for(e=e.child;e!==null;){var t=n,i=e,a=i.flags;switch(i.tag){case 22:xm(t,i),a&2048&&h3(i.alternate,i);break;case 24:xm(t,i),a&2048&&f3(i.alternate,i);break;default:xm(t,i)}e=e.sibling}}var Qp=8192;function zh(n){if(n.subtreeFlags&Qp)for(n=n.child;n!==null;)OI(n),n=n.sibling}function OI(n){switch(n.tag){case 26:zh(n),n.flags&Qp&&n.memoizedState!==null&&uF(bs,n.memoizedState,n.memoizedProps);break;case 5:zh(n);break;case 3:case 4:var e=bs;bs=H1(n.stateNode.containerInfo),zh(n),bs=e;break;case 22:n.memoizedState===null&&(e=n.alternate,e!==null&&e.memoizedState!==null?(e=Qp,Qp=16777216,zh(n),Qp=e):zh(n));break;default:zh(n)}}function II(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 Tp(n){var e=n.deletions;if(n.flags&16){if(e!==null)for(var t=0;t<e.length;t++){var i=e[t];na=i,UI(i,n)}II(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)BI(n),n=n.sibling}function BI(n){switch(n.tag){case 0:case 11:case 15:Tp(n),n.flags&2048&&fc(9,n,n.return);break;case 3:Tp(n);break;case 12:Tp(n);break;case 22:var e=n.stateNode;n.memoizedState!==null&&e._visibility&4&&(n.return===null||n.return.tag!==13)?(e._visibility&=-5,a1(n)):Tp(n);break;default:Tp(n)}}function a1(n){var e=n.deletions;if(n.flags&16){if(e!==null)for(var t=0;t<e.length;t++){var i=e[t];na=i,UI(i,n)}II(n)}for(n=n.child;n!==null;){switch(e=n,e.tag){case 0:case 11:case 15:fc(8,e,e.return),a1(e);break;case 22:t=e.stateNode,t._visibility&4&&(t._visibility&=-5,a1(e));break;default:a1(e)}n=n.sibling}}function UI(n,e){for(;na!==null;){var t=na;switch(t.tag){case 0:case 11:case 15:fc(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:x0(t.memoizedState.cache)}if(i=t.child,i!==null)i.return=t,na=i;else e:for(t=n;na!==null;){i=na;var a=i.sibling,r=i.return;if(MI(i),i===t){na=null;break e}if(a!==null){a.return=r,na=a;break e}na=r}}}function E7(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 es(n,e,t,i){return new E7(n,e,t,i)}function d3(n){return n=n.prototype,!(!n||!n.isReactComponent)}function ic(n,e){var t=n.alternate;return t===null?(t=es(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&31457280,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 LI(n,e){n.flags&=31457282;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 r1(n,e,t,i,a,r){var s=0;if(i=n,typeof n=="function")d3(n)&&(s=1);else if(typeof n=="string")s=lF(n,t,Qs.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case Tf:return Mu(t.children,a,r,e);case PN:s=8,a|=24;break;case O2:return n=es(12,t,e,a|2),n.elementType=O2,n.lanes=r,n;case I2:return n=es(13,t,e,a),n.elementType=I2,n.lanes=r,n;case B2:return n=es(19,t,e,a),n.elementType=B2,n.lanes=r,n;case HN:return PI(t,a,r,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case ZL:case ko:s=10;break e;case FN:s=9;break e;case BT:s=11;break e;case UT:s=14;break e;case Vl:s=16,i=null;break e}s=29,t=Error(qe(130,n===null?"null":typeof n,"")),i=null}return e=es(s,t,e,a),e.elementType=n,e.type=i,e.lanes=r,e}function Mu(n,e,t,i){return n=es(7,n,i,e),n.lanes=t,n}function PI(n,e,t,i){n=es(22,n,i,e),n.elementType=HN,n.lanes=t;var a={_visibility:1,_pendingVisibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null,_current:null,detach:function(){var r=a._current;if(r===null)throw Error(qe(456));if(!(a._pendingVisibility&2)){var s=uc(r,2);s!==null&&(a._pendingVisibility|=2,La(s,r,2))}},attach:function(){var r=a._current;if(r===null)throw Error(qe(456));if(a._pendingVisibility&2){var s=uc(r,2);s!==null&&(a._pendingVisibility&=-3,La(s,r,2))}}};return n.stateNode=a,n}function nA(n,e,t){return n=es(6,n,null,e),n.lanes=t,n}function iA(n,e,t){return e=es(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function Ao(n){n.flags|=4}function sw(n,e){if(e.type!=="stylesheet"||e.state.loading&4)n.flags&=-16777217;else if(n.flags|=16777216,!a5(e)){if(e=rs.current,e!==null&&((_n&4194176)===_n?eo!==null:(_n&62914560)!==_n&&!(_n&536870912)||e!==eo))throw hm=q2,EO;n.flags|=8192}}function Fg(n,e){e!==null&&(n.flags|=4),n.flags&16384&&(e=n.tag!==22?YN():536870912,n.lanes|=e,ld|=e)}function bp(n,e){if(!Cn)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 pi(n){var e=n.alternate!==null&&n.alternate.child===n.child,t=0,i=0;if(e)for(var a=n.child;a!==null;)t|=a.lanes|a.childLanes,i|=a.subtreeFlags&31457280,i|=a.flags&31457280,a.return=n,a=a.sibling;else for(a=n.child;a!==null;)t|=a.lanes|a.childLanes,i|=a.subtreeFlags,i|=a.flags,a.return=n,a=a.sibling;return n.subtreeFlags|=i,n.childLanes=t,e}function T7(n,e,t){var i=e.pendingProps;switch(qT(e),e.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return pi(e),null;case 1:return pi(e),null;case 3:return t=e.stateNode,i=null,n!==null&&(i=n.memoizedState.cache),e.memoizedState.cache!==i&&(e.flags|=2048),Ko(Vi),nd(),t.pendingContext&&(t.context=t.pendingContext,t.pendingContext=null),(n===null||n.child===null)&&(Ap(e)?Ao(e):n===null||n.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Ms!==null&&(pE(Ms),Ms=null))),pi(e),null;case 26:return t=e.memoizedState,n===null?(Ao(e),t!==null?(pi(e),sw(e,t)):(pi(e),e.flags&=-16777217)):t?t!==n.memoizedState?(Ao(e),pi(e),sw(e,t)):(pi(e),e.flags&=-16777217):(n.memoizedProps!==i&&Ao(e),pi(e),e.flags&=-16777217),null;case 27:x1(e),t=ec.current;var a=e.type;if(n!==null&&e.stateNode!=null)n.memoizedProps!==i&&Ao(e);else{if(!i){if(e.stateNode===null)throw Error(qe(166));return pi(e),null}n=Qs.current,Ap(e)?LR(e):(n=t5(a,i,t),e.stateNode=n,Ao(e))}return pi(e),null;case 5:if(x1(e),t=e.type,n!==null&&e.stateNode!=null)n.memoizedProps!==i&&Ao(e);else{if(!i){if(e.stateNode===null)throw Error(qe(166));return pi(e),null}if(n=Qs.current,Ap(e))LR(e);else{switch(a=F1(ec.current),n){case 1:n=a.createElementNS("http://www.w3.org/2000/svg",t);break;case 2:n=a.createElementNS("http://www.w3.org/1998/Math/MathML",t);break;default:switch(t){case"svg":n=a.createElementNS("http://www.w3.org/2000/svg",t);break;case"math":n=a.createElementNS("http://www.w3.org/1998/Math/MathML",t);break;case"script":n=a.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild);break;case"select":n=typeof i.is=="string"?a.createElement("select",{is:i.is}):a.createElement("select"),i.multiple?n.multiple=!0:i.size&&(n.size=i.size);break;default:n=typeof i.is=="string"?a.createElement(t,{is:i.is}):a.createElement(t)}}n[ba]=e,n[$a]=i;e:for(a=e.child;a!==null;){if(a.tag===5||a.tag===6)n.appendChild(a.stateNode);else if(a.tag!==4&&a.tag!==27&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===e)break e;for(;a.sibling===null;){if(a.return===null||a.return===e)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}e.stateNode=n;e:switch(ma(n,t,i),t){case"button":case"input":case"select":case"textarea":n=!!i.autoFocus;break e;case"img":n=!0;break e;default:n=!1}n&&Ao(e)}}return pi(e),e.flags&=-16777217,null;case 6:if(n&&e.stateNode!=null)n.memoizedProps!==i&&Ao(e);else{if(typeof i!="string"&&e.stateNode===null)throw Error(qe(166));if(n=ec.current,Ap(e)){if(n=e.stateNode,t=e.memoizedProps,i=null,a=Ia,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}n[ba]=e,n=!!(n.nodeValue===t||i!==null&&i.suppressHydrationWarning===!0||QI(n.nodeValue,t)),n||Uu(e)}else n=F1(n).createTextNode(i),n[ba]=e,e.stateNode=n}return pi(e),null;case 13:if(i=e.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(a=Ap(e),i!==null&&i.dehydrated!==null){if(n===null){if(!a)throw Error(qe(318));if(a=e.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(qe(317));a[ba]=e}else v0(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;pi(e),a=!1}else Ms!==null&&(pE(Ms),Ms=null),a=!0;if(!a)return e.flags&256?(Yo(e),e):(Yo(e),null)}if(Yo(e),e.flags&128)return e.lanes=t,e;if(t=i!==null,n=n!==null&&n.memoizedState!==null,t){i=e.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool);var r=null;i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(r=i.memoizedState.cachePool.pool),r!==a&&(i.flags|=2048)}return t!==n&&t&&(e.child.flags|=8192),Fg(e,e.updateQueue),pi(e),null;case 4:return nd(),n===null&&y3(e.stateNode.containerInfo),pi(e),null;case 10:return Ko(e.type),pi(e),null;case 19:if(ra(Xi),a=e.memoizedState,a===null)return pi(e),null;if(i=(e.flags&128)!==0,r=a.rendering,r===null)if(i)bp(a,!1);else{if(Mi!==0||n!==null&&n.flags&128)for(n=e.child;n!==null;){if(r=M1(n),r!==null){for(e.flags|=128,bp(a,!1),n=r.updateQueue,e.updateQueue=n,Fg(e,n),e.subtreeFlags=0,n=t,t=e.child;t!==null;)LI(t,n),t=t.sibling;return ui(Xi,Xi.current&1|2),e.child}n=n.sibling}a.tail!==null&&$s()>I1&&(e.flags|=128,i=!0,bp(a,!1),e.lanes=4194304)}else{if(!i)if(n=M1(r),n!==null){if(e.flags|=128,i=!0,n=n.updateQueue,e.updateQueue=n,Fg(e,n),bp(a,!0),a.tail===null&&a.tailMode==="hidden"&&!r.alternate&&!Cn)return pi(e),null}else 2*$s()-a.renderingStartTime>I1&&t!==536870912&&(e.flags|=128,i=!0,bp(a,!1),e.lanes=4194304);a.isBackwards?(r.sibling=e.child,e.child=r):(n=a.last,n!==null?n.sibling=r:e.child=r,a.last=r)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=$s(),e.sibling=null,n=Xi.current,ui(Xi,i?n&1|2:n&1),e):(pi(e),null);case 22:case 23:return Yo(e),ZT(),i=e.memoizedState!==null,n!==null?n.memoizedState!==null!==i&&(e.flags|=8192):i&&(e.flags|=8192),i?t&536870912&&!(e.flags&128)&&(pi(e),e.subtreeFlags&6&&(e.flags|=8192)):pi(e),t=e.updateQueue,t!==null&&Fg(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&&ra(bu),null;case 24:return t=null,n!==null&&(t=n.memoizedState.cache),e.memoizedState.cache!==t&&(e.flags|=2048),Ko(Vi),pi(e),null;case 25:return null}throw Error(qe(156,e.tag))}function b7(n,e){switch(qT(e),e.tag){case 1:return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return Ko(Vi),nd(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 26:case 27:case 5:return x1(e),null;case 13:if(Yo(e),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(qe(340));v0()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return ra(Xi),null;case 4:return nd(),null;case 10:return Ko(e.type),null;case 22:case 23:return Yo(e),ZT(),n!==null&&ra(bu),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 24:return Ko(Vi),null;case 25:return null;default:return null}}function FI(n,e){switch(qT(e),e.tag){case 3:Ko(Vi),nd();break;case 26:case 27:case 5:x1(e);break;case 4:nd();break;case 13:Yo(e);break;case 19:ra(Xi);break;case 10:Ko(e.type);break;case 22:case 23:Yo(e),ZT(),n!==null&&ra(bu);break;case 24:Ko(Vi)}}var M7={getCacheForType:function(n){var e=Ma(Vi),t=e.data.get(n);return t===void 0&&(t=n(),e.data.set(n,t)),t}},C7=typeof WeakMap=="function"?WeakMap:Map,vi=0,Qn=null,un=null,_n=0,Zn=0,yr=null,Fo=!1,Bd=!1,p3=!1,il=0,Mi=0,dc=0,Cu=0,m3=0,ts=0,ld=0,ym=null,Zs=null,uE=!1,g3=0,I1=1/0,B1=null,ac=null,Hg=!1,hu=null,_m=0,hE=0,fE=null,Sm=0,dE=null;function Mr(){if(vi&2&&_n!==0)return _n&-_n;if(Qt.T!==null){var n=sd;return n!==0?n:x3()}return KN()}function HI(){ts===0&&(ts=!(_n&536870912)||Cn?WN():536870912);var n=rs.current;return n!==null&&(n.flags|=32),ts}function La(n,e,t){(n===Qn&&Zn===2||n.cancelPendingCommit!==null)&&(cd(n,0),Ho(n,_n,ts,!1)),m0(n,t),(!(vi&2)||n!==Qn)&&(n===Qn&&(!(vi&2)&&(Cu|=t),Mi===4&&Ho(n,_n,ts,!1)),ro(n))}function zI(n,e,t){if(vi&6)throw Error(qe(327));var i=!t&&(e&60)===0&&(e&n.expiredLanes)===0||p0(n,e),a=i?D7(n,e):aA(n,e,!0),r=i;do{if(a===0){Bd&&!i&&Ho(n,e,0,!1);break}else if(a===6)Ho(n,e,0,!Fo);else{if(t=n.current.alternate,r&&!R7(t)){a=aA(n,e,!1),r=!1;continue}if(a===2){if(r=e,n.errorRecoveryDisabledLanes&r)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;a=ym;var c=o.current.memoizedState.isDehydrated;if(c&&(cd(o,s).flags|=256),s=aA(o,s,!1),s!==2){if(p3&&!c){o.errorRecoveryDisabledLanes|=r,Cu|=r,a=4;break e}r=Zs,Zs=a,r!==null&&pE(r)}a=s}if(r=!1,a!==2)continue}}if(a===1){cd(n,0),Ho(n,e,0,!0);break}e:{switch(i=n,a){case 0:case 1:throw Error(qe(345));case 4:if((e&4194176)===e){Ho(i,e,ts,!Fo);break e}break;case 2:Zs=null;break;case 3:case 5:break;default:throw Error(qe(329))}if(i.finishedWork=t,i.finishedLanes=e,(e&62914560)===e&&(r=g3+300-$s(),10<r)){if(Ho(i,e,ts,!Fo),Qx(i,0)!==0)break e;i.timeoutHandle=e5(ow.bind(null,i,t,Zs,B1,uE,e,ts,Cu,ld,Fo,2,-0,0),r);break e}ow(i,t,Zs,B1,uE,e,ts,Cu,ld,Fo,0,-0,0)}}break}while(!0);ro(n)}function pE(n){Zs===null?Zs=n:Zs.push.apply(Zs,n)}function ow(n,e,t,i,a,r,s,o,c,h,f,d,m){var g=e.subtreeFlags;if((g&8192||(g&16785408)===16785408)&&(qm={stylesheets:null,count:0,unsuspend:cF},OI(e),e=hF(),e!==null)){n.cancelPendingCommit=e(cw.bind(null,n,t,i,a,s,o,c,1,d,m)),Ho(n,r,s,!h);return}cw(n,t,i,a,s,o,c,f,d,m)}function R7(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 a=t[i],r=a.getSnapshot;a=a.value;try{if(!wr(r(),a))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 Ho(n,e,t,i){e&=~m3,e&=~Cu,n.suspendedLanes|=e,n.pingedLanes&=~e,i&&(n.warmLanes|=e),i=n.expirationTimes;for(var a=e;0<a;){var r=31-br(a),s=1<<r;i[r]=-1,a&=~s}t!==0&&qN(n,t,e)}function ly(){return vi&6?!0:(A0(0),!1)}function v3(){if(un!==null){if(Zn===0)var n=un.return;else n=un,qo=sh=null,t3(n),Wf=null,km=0,n=un;for(;n!==null;)FI(n.alternate,n),n=n.return;un=null}}function cd(n,e){n.finishedWork=null,n.finishedLanes=0;var t=n.timeoutHandle;t!==-1&&(n.timeoutHandle=-1,q7(t)),t=n.cancelPendingCommit,t!==null&&(n.cancelPendingCommit=null,t()),v3(),Qn=n,un=t=ic(n.current,null),_n=e,Zn=0,yr=null,Fo=!1,Bd=p0(n,e),p3=!1,ld=ts=m3=Cu=dc=Mi=0,Zs=ym=null,uE=!1,e&8&&(e|=e&32);var i=n.entangledLanes;if(i!==0)for(n=n.entanglements,i&=e;0<i;){var a=31-br(i),r=1<<a;e|=n[a],i&=~r}return il=e,ny(),t}function GI(n,e){on=null,Qt.H=to,e===um?(e=HR(),Zn=3):e===EO?(e=HR(),Zn=4):Zn=e===fI?8:e!==null&&typeof e=="object"&&typeof e.then=="function"?6:1,yr=e,un===null&&(Mi=1,D1(n,Jr(e,n.current)))}function VI(){var n=Qt.H;return Qt.H=to,n===null?to:n}function kI(){var n=Qt.A;return Qt.A=M7,n}function mE(){Mi=4,Fo||(_n&4194176)!==_n&&rs.current!==null||(Bd=!0),!(dc&134217727)&&!(Cu&134217727)||Qn===null||Ho(Qn,_n,ts,!1)}function aA(n,e,t){var i=vi;vi|=2;var a=VI(),r=kI();(Qn!==n||_n!==e)&&(B1=null,cd(n,e)),e=!1;var s=Mi;e:do try{if(Zn!==0&&un!==null){var o=un,c=yr;switch(Zn){case 8:v3(),s=6;break e;case 3:case 2:case 6:rs.current===null&&(e=!0);var h=Zn;if(Zn=0,yr=null,Bf(n,o,c,h),t&&Bd){s=0;break e}break;default:h=Zn,Zn=0,yr=null,Bf(n,o,c,h)}}w7(),s=Mi;break}catch(f){GI(n,f)}while(!0);return e&&n.shellSuspendCounter++,qo=sh=null,vi=i,Qt.H=a,Qt.A=r,un===null&&(Qn=null,_n=0,ny()),s}function w7(){for(;un!==null;)XI(un)}function D7(n,e){var t=vi;vi|=2;var i=VI(),a=kI();Qn!==n||_n!==e?(B1=null,I1=$s()+500,cd(n,e)):Bd=p0(n,e);e:do try{if(Zn!==0&&un!==null){e=un;var r=yr;t:switch(Zn){case 1:Zn=0,yr=null,Bf(n,e,r,1);break;case 2:if(FR(r)){Zn=0,yr=null,lw(e);break}e=function(){Zn===2&&Qn===n&&(Zn=7),ro(n)},r.then(e,e);break e;case 3:Zn=7;break e;case 4:Zn=5;break e;case 7:FR(r)?(Zn=0,yr=null,lw(e)):(Zn=0,yr=null,Bf(n,e,r,7));break;case 5:var s=null;switch(un.tag){case 26:s=un.memoizedState;case 5:case 27:var o=un;if(!s||a5(s)){Zn=0,yr=null;var c=o.sibling;if(c!==null)un=c;else{var h=o.return;h!==null?(un=h,cy(h)):un=null}break t}}Zn=0,yr=null,Bf(n,e,r,5);break;case 6:Zn=0,yr=null,Bf(n,e,r,6);break;case 8:v3(),Mi=6;break e;default:throw Error(qe(462))}}N7();break}catch(f){GI(n,f)}while(!0);return qo=sh=null,Qt.H=i,Qt.A=a,vi=t,un!==null?0:(Qn=null,_n=0,ny(),Mi)}function N7(){for(;un!==null&&!$L();)XI(un)}function XI(n){var e=vI(n.alternate,n,il);n.memoizedProps=n.pendingProps,e===null?cy(n):un=e}function lw(n){var e=n,t=e.alternate;switch(e.tag){case 15:case 0:e=$R(t,e,e.pendingProps,e.type,void 0,_n);break;case 11:e=$R(t,e,e.pendingProps,e.type.render,e.ref,_n);break;case 5:t3(e);default:FI(t,e),e=un=LI(e,il),e=vI(t,e,il)}n.memoizedProps=n.pendingProps,e===null?cy(n):un=e}function Bf(n,e,t,i){qo=sh=null,t3(e),Wf=null,km=0;var a=e.return;try{if(y7(n,a,e,t,_n)){Mi=1,D1(n,Jr(t,n.current)),un=null;return}}catch(r){if(a!==null)throw un=a,r;Mi=1,D1(n,Jr(t,n.current)),un=null;return}e.flags&32768?(Cn||i===1?n=!0:Bd||_n&536870912?n=!1:(Fo=n=!0,(i===2||i===3||i===6)&&(i=rs.current,i!==null&&i.tag===13&&(i.flags|=16384))),WI(e,n)):cy(e)}function cy(n){var e=n;do{if(e.flags&32768){WI(e,Fo);return}n=e.return;var t=T7(e.alternate,e,il);if(t!==null){un=t;return}if(e=e.sibling,e!==null){un=e;return}un=e=n}while(e!==null);Mi===0&&(Mi=5)}function WI(n,e){do{var t=b7(n.alternate,n);if(t!==null){t.flags&=32767,un=t;return}if(t=n.return,t!==null&&(t.flags|=32768,t.subtreeFlags=0,t.deletions=null),!e&&(n=n.sibling,n!==null)){un=n;return}un=n=t}while(n!==null);Mi=6,un=null}function cw(n,e,t,i,a,r,s,o,c,h){var f=Qt.T,d=ai.p;try{ai.p=2,Qt.T=null,O7(n,e,t,i,d,a,r,s,o,c,h)}finally{Qt.T=f,ai.p=d}}function O7(n,e,t,i,a,r,s,o){do jf();while(hu!==null);if(vi&6)throw Error(qe(327));var c=n.finishedWork;if(i=n.finishedLanes,c===null)return null;if(n.finishedWork=null,n.finishedLanes=0,c===n.current)throw Error(qe(177));n.callbackNode=null,n.callbackPriority=0,n.cancelPendingCommit=null;var h=c.lanes|c.childLanes;if(h|=XT,uP(n,i,h,r,s,o),n===Qn&&(un=Qn=null,_n=0),!(c.subtreeFlags&10256)&&!(c.flags&10256)||Hg||(Hg=!0,hE=h,fE=t,L7(y1,function(){return jf(),null})),t=(c.flags&15990)!==0,c.subtreeFlags&15990||t?(t=Qt.T,Qt.T=null,r=ai.p,ai.p=2,s=vi,vi|=4,S7(n,c),wI(c,n),n7(yE,n.containerInfo),V1=!!xE,yE=xE=null,n.current=c,bI(n,c.alternate,c),eP(),vi=s,ai.p=r,Qt.T=t):n.current=c,Hg?(Hg=!1,hu=n,_m=i):YI(n,h),h=n.pendingLanes,h===0&&(ac=null),rP(c.stateNode),ro(n),e!==null)for(a=n.onRecoverableError,c=0;c<e.length;c++)h=e[c],a(h.value,{componentStack:h.stack});return _m&3&&jf(),h=n.pendingLanes,i&4194218&&h&42?n===dE?Sm++:(Sm=0,dE=n):Sm=0,A0(0),null}function YI(n,e){(n.pooledCacheLanes&=e)===0&&(e=n.pooledCache,e!=null&&(n.pooledCache=null,x0(e)))}function jf(){if(hu!==null){var n=hu,e=hE;hE=0;var t=jN(_m),i=Qt.T,a=ai.p;try{if(ai.p=32>t?32:t,Qt.T=null,hu===null)var r=!1;else{t=fE,fE=null;var s=hu,o=_m;if(hu=null,_m=0,vi&6)throw Error(qe(331));var c=vi;if(vi|=4,BI(s.current),NI(s,s.current,o,t),vi=c,A0(0,!1),Tr&&typeof Tr.onPostCommitFiberRoot=="function")try{Tr.onPostCommitFiberRoot(d0,s)}catch{}r=!0}return r}finally{ai.p=a,Qt.T=i,YI(n,e)}}return!1}function uw(n,e,t){e=Jr(t,e),e=eE(n.stateNode,e,2),n=nc(n,e,2),n!==null&&(m0(n,2),ro(n))}function kn(n,e,t){if(n.tag===3)uw(n,n,t);else for(;e!==null;){if(e.tag===3){uw(e,n,t);break}else if(e.tag===1){var i=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(ac===null||!ac.has(i))){n=Jr(t,n),t=uI(2),i=nc(e,t,2),i!==null&&(hI(t,i,e,n),m0(i,2),ro(i));break}}e=e.return}}function rA(n,e,t){var i=n.pingCache;if(i===null){i=n.pingCache=new C7;var a=new Set;i.set(e,a)}else a=i.get(e),a===void 0&&(a=new Set,i.set(e,a));a.has(t)||(p3=!0,a.add(t),n=I7.bind(null,n,e,t),e.then(n,n))}function I7(n,e,t){var i=n.pingCache;i!==null&&i.delete(e),n.pingedLanes|=n.suspendedLanes&t,n.warmLanes&=~t,Qn===n&&(_n&t)===t&&(Mi===4||Mi===3&&(_n&62914560)===_n&&300>$s()-g3?!(vi&2)&&cd(n,0):m3|=t,ld===_n&&(ld=0)),ro(n)}function qI(n,e){e===0&&(e=YN()),n=uc(n,e),n!==null&&(m0(n,e),ro(n))}function B7(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),qI(n,t)}function U7(n,e){var t=0;switch(n.tag){case 13:var i=n.stateNode,a=n.memoizedState;a!==null&&(t=a.retryLane);break;case 19:i=n.stateNode;break;case 22:i=n.stateNode._retryCache;break;default:throw Error(qe(314))}i!==null&&i.delete(e),qI(n,t)}function L7(n,e){return LT(n,e)}var U1=null,Ef=null,gE=!1,L1=!1,sA=!1,Ru=0;function ro(n){n!==Ef&&n.next===null&&(Ef===null?U1=Ef=n:Ef=Ef.next=n),L1=!0,gE||(gE=!0,F7(P7))}function A0(n,e){if(!sA&&L1){sA=!0;do for(var t=!1,i=U1;i!==null;){if(n!==0){var a=i.pendingLanes;if(a===0)var r=0;else{var s=i.suspendedLanes,o=i.pingedLanes;r=(1<<31-br(42|n)+1)-1,r&=a&~(s&~o),r=r&201326677?r&201326677|1:r?r|2:0}r!==0&&(t=!0,hw(i,r))}else r=_n,r=Qx(i,i===Qn?r:0),!(r&3)||p0(i,r)||(t=!0,hw(i,r));i=i.next}while(t);sA=!1}}function P7(){L1=gE=!1;var n=0;Ru!==0&&(Y7()&&(n=Ru),Ru=0);for(var e=$s(),t=null,i=U1;i!==null;){var a=i.next,r=ZI(i,e);r===0?(i.next=null,t===null?U1=a:t.next=a,a===null&&(Ef=t)):(t=i,(n!==0||r&3)&&(L1=!0)),i=a}A0(n)}function ZI(n,e){for(var t=n.suspendedLanes,i=n.pingedLanes,a=n.expirationTimes,r=n.pendingLanes&-62914561;0<r;){var s=31-br(r),o=1<<s,c=a[s];c===-1?(!(o&t)||o&i)&&(a[s]=cP(o,e)):c<=e&&(n.expiredLanes|=o),r&=~o}if(e=Qn,t=_n,t=Qx(n,n===e?t:0),i=n.callbackNode,t===0||n===e&&Zn===2||n.cancelPendingCommit!==null)return i!==null&&i!==null&&LS(i),n.callbackNode=null,n.callbackPriority=0;if(!(t&3)||p0(n,t)){if(e=t&-t,e===n.callbackPriority)return e;switch(i!==null&&LS(i),jN(t)){case 2:case 8:t=kN;break;case 32:t=y1;break;case 268435456:t=XN;break;default:t=y1}return i=jI.bind(null,n),t=LT(t,i),n.callbackPriority=e,n.callbackNode=t,e}return i!==null&&i!==null&&LS(i),n.callbackPriority=2,n.callbackNode=null,2}function jI(n,e){var t=n.callbackNode;if(jf()&&n.callbackNode!==t)return null;var i=_n;return i=Qx(n,n===Qn?i:0),i===0?null:(zI(n,i,e),ZI(n,$s()),n.callbackNode!=null&&n.callbackNode===t?jI.bind(null,n):null)}function hw(n,e){if(jf())return null;zI(n,e,!0)}function F7(n){Z7(function(){vi&6?LT(VN,n):n()})}function x3(){return Ru===0&&(Ru=WN()),Ru}function fw(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:Qv(""+n)}function dw(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 H7(n,e,t,i,a){if(e==="submit"&&t&&t.stateNode===a){var r=fw((a[$a]||null).action),s=i.submitter;s&&(e=(e=s[$a]||null)?fw(e.formAction):s.getAttribute("formAction"),e!==null&&(r=e,s=null));var o=new $x("action","action",null,i,a);n.push({event:o,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Ru!==0){var c=s?dw(a,s):new FormData(a);Q2(t,{pending:!0,data:c,method:a.method,action:r},null,c)}}else typeof r=="function"&&(o.preventDefault(),c=s?dw(a,s):new FormData(a),Q2(t,{pending:!0,data:c,method:a.method,action:r},r,c))},currentTarget:a}]})}}for(var oA=0;oA<BR.length;oA++){var lA=BR[oA],z7=lA.toLowerCase(),G7=lA[0].toUpperCase()+lA.slice(1);Os(z7,"on"+G7)}Os(gO,"onAnimationEnd");Os(vO,"onAnimationIteration");Os(xO,"onAnimationStart");Os("dblclick","onDoubleClick");Os("focusin","onFocus");Os("focusout","onBlur");Os(a7,"onTransitionRun");Os(r7,"onTransitionStart");Os(s7,"onTransitionCancel");Os(yO,"onTransitionEnd");id("onMouseEnter",["mouseout","mouseover"]);id("onMouseLeave",["mouseout","mouseover"]);id("onPointerEnter",["pointerout","pointerover"]);id("onPointerLeave",["pointerout","pointerover"]);th("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));th("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));th("onBeforeInput",["compositionend","keypress","textInput","paste"]);th("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));th("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));th("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Wm="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(" "),V7=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Wm));function KI(n,e){e=(e&4)!==0;for(var t=0;t<n.length;t++){var i=n[t],a=i.event;i=i.listeners;e:{var r=void 0;if(e)for(var s=i.length-1;0<=s;s--){var o=i[s],c=o.instance,h=o.currentTarget;if(o=o.listener,c!==r&&a.isPropagationStopped())break e;r=o,a.currentTarget=h;try{r(a)}catch(f){w1(f)}a.currentTarget=null,r=c}else for(s=0;s<i.length;s++){if(o=i[s],c=o.instance,h=o.currentTarget,o=o.listener,c!==r&&a.isPropagationStopped())break e;r=o,a.currentTarget=h;try{r(a)}catch(f){w1(f)}a.currentTarget=null,r=c}}}}function mn(n,e){var t=e[H2];t===void 0&&(t=e[H2]=new Set);var i=n+"__bubble";t.has(i)||(JI(e,n,2,!1),t.add(i))}function cA(n,e,t){var i=0;e&&(i|=4),JI(t,n,i,e)}var zg="_reactListening"+Math.random().toString(36).slice(2);function y3(n){if(!n[zg]){n[zg]=!0,JN.forEach(function(t){t!=="selectionchange"&&(V7.has(t)||cA(t,!1,n),cA(t,!0,n))});var e=n.nodeType===9?n:n.ownerDocument;e===null||e[zg]||(e[zg]=!0,cA("selectionchange",!1,e))}}function JI(n,e,t,i){switch(c5(e)){case 2:var a=pF;break;case 8:a=mF;break;default:a=E3}t=a.bind(null,e,t,n),a=void 0,!k2||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(a=!0),i?a!==void 0?n.addEventListener(e,t,{capture:!0,passive:a}):n.addEventListener(e,t,!0):a!==void 0?n.addEventListener(e,t,{passive:a}):n.addEventListener(e,t,!1)}function uA(n,e,t,i,a){var r=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===a||o.nodeType===8&&o.parentNode===a)break;if(s===4)for(s=i.return;s!==null;){var c=s.tag;if((c===3||c===4)&&(c=s.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;s=s.return}for(;o!==null;){if(s=pu(o),s===null)return;if(c=s.tag,c===5||c===6||c===26||c===27){i=r=s;continue e}o=o.parentNode}}i=i.return}rO(function(){var h=r,f=HT(t),d=[];e:{var m=_O.get(n);if(m!==void 0){var g=$x,y=n;switch(n){case"keypress":if(e1(t)===0)break e;case"keydown":case"keyup":g=UP;break;case"focusin":y="focus",g=GS;break;case"focusout":y="blur",g=GS;break;case"beforeblur":case"afterblur":g=GS;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=AR;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":g=EP;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":g=FP;break;case gO:case vO:case xO:g=MP;break;case yO:g=zP;break;case"scroll":case"scrollend":g=SP;break;case"wheel":g=VP;break;case"copy":case"cut":case"paste":g=RP;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":g=TR;break;case"toggle":case"beforetoggle":g=XP}var E=(e&4)!==0,S=!E&&(n==="scroll"||n==="scrollend"),v=E?m!==null?m+"Capture":null:m;E=[];for(var _=h,A;_!==null;){var b=_;if(A=b.stateNode,b=b.tag,b!==5&&b!==26&&b!==27||A===null||v===null||(b=Hm(_,v),b!=null&&E.push(Ym(_,b,A))),S)break;_=_.return}0<E.length&&(m=new g(m,y,null,t,f),d.push({event:m,listeners:E}))}}if(!(e&7)){e:{if(m=n==="mouseover"||n==="pointerover",g=n==="mouseout"||n==="pointerout",m&&t!==V2&&(y=t.relatedTarget||t.fromElement)&&(pu(y)||y[Od]))break e;if((g||m)&&(m=f.window===f?f:(m=f.ownerDocument)?m.defaultView||m.parentWindow:window,g?(y=t.relatedTarget||t.toElement,g=h,y=y?pu(y):null,y!==null&&(S=Nd(y),E=y.tag,y!==S||E!==5&&E!==27&&E!==6)&&(y=null)):(g=null,y=h),g!==y)){if(E=AR,b="onMouseLeave",v="onMouseEnter",_="mouse",(n==="pointerout"||n==="pointerover")&&(E=TR,b="onPointerLeave",v="onPointerEnter",_="pointer"),S=g==null?m:Jp(g),A=y==null?m:Jp(y),m=new E(b,_+"leave",g,t,f),m.target=S,m.relatedTarget=A,b=null,pu(f)===h&&(E=new E(v,_+"enter",y,t,f),E.target=A,E.relatedTarget=S,b=E),S=b,g&&y)t:{for(E=g,v=y,_=0,A=E;A;A=Gh(A))_++;for(A=0,b=v;b;b=Gh(b))A++;for(;0<_-A;)E=Gh(E),_--;for(;0<A-_;)v=Gh(v),A--;for(;_--;){if(E===v||v!==null&&E===v.alternate)break t;E=Gh(E),v=Gh(v)}E=null}else E=null;g!==null&&pw(d,m,g,E,!1),y!==null&&S!==null&&pw(d,S,y,E,!0)}}e:{if(m=h?Jp(h):window,g=m.nodeName&&m.nodeName.toLowerCase(),g==="select"||g==="input"&&m.type==="file")var O=RR;else if(CR(m))if(hO)O=e7;else{O=QP;var N=JP}else g=m.nodeName,!g||g.toLowerCase()!=="input"||m.type!=="checkbox"&&m.type!=="radio"?h&&FT(h.elementType)&&(O=RR):O=$P;if(O&&(O=O(n,h))){uO(d,O,t,f);break e}N&&N(n,m,h),n==="focusout"&&h&&m.type==="number"&&h.memoizedProps.value!=null&&G2(m,"number",m.value)}switch(N=h?Jp(h):window,n){case"focusin":(CR(N)||N.contentEditable==="true")&&(Rf=N,X2=h,cm=null);break;case"focusout":cm=X2=Rf=null;break;case"mousedown":W2=!0;break;case"contextmenu":case"mouseup":case"dragend":W2=!1,IR(d,t,f);break;case"selectionchange":if(i7)break;case"keydown":case"keyup":IR(d,t,f)}var L;if(VT)e:{switch(n){case"compositionstart":var B="onCompositionStart";break e;case"compositionend":B="onCompositionEnd";break e;case"compositionupdate":B="onCompositionUpdate";break e}B=void 0}else Cf?lO(n,t)&&(B="onCompositionEnd"):n==="keydown"&&t.keyCode===229&&(B="onCompositionStart");B&&(oO&&t.locale!=="ko"&&(Cf||B!=="onCompositionStart"?B==="onCompositionEnd"&&Cf&&(L=sO()):(jl=f,zT="value"in jl?jl.value:jl.textContent,Cf=!0)),N=P1(h,B),0<N.length&&(B=new ER(B,n,null,t,f),d.push({event:B,listeners:N}),L?B.data=L:(L=cO(t),L!==null&&(B.data=L)))),(L=YP?qP(n,t):ZP(n,t))&&(B=P1(h,"onBeforeInput"),0<B.length&&(N=new ER("onBeforeInput","beforeinput",null,t,f),d.push({event:N,listeners:B}),N.data=L)),H7(d,n,h,t,f)}KI(d,e)})}function Ym(n,e,t){return{instance:n,listener:e,currentTarget:t}}function P1(n,e){for(var t=e+"Capture",i=[];n!==null;){var a=n,r=a.stateNode;a=a.tag,a!==5&&a!==26&&a!==27||r===null||(a=Hm(n,t),a!=null&&i.unshift(Ym(n,a,r)),a=Hm(n,e),a!=null&&i.push(Ym(n,a,r))),n=n.return}return i}function Gh(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function pw(n,e,t,i,a){for(var r=e._reactName,s=[];t!==null&&t!==i;){var o=t,c=o.alternate,h=o.stateNode;if(o=o.tag,c!==null&&c===i)break;o!==5&&o!==26&&o!==27||h===null||(c=h,a?(h=Hm(t,r),h!=null&&s.unshift(Ym(t,h,c))):a||(h=Hm(t,r),h!=null&&s.push(Ym(t,h,c)))),t=t.return}s.length!==0&&n.push({event:e,listeners:s})}var k7=/\r\n?/g,X7=/\u0000|\uFFFD/g;function mw(n){return(typeof n=="string"?n:""+n).replace(k7,`
`).replace(X7,"")}function QI(n,e){return e=mw(e),mw(n)===e}function uy(){}function Hn(n,e,t,i,a,r){switch(t){case"children":typeof i=="string"?e==="body"||e==="textarea"&&i===""||ad(n,i):(typeof i=="number"||typeof i=="bigint")&&e!=="body"&&ad(n,""+i);break;case"className":Og(n,"class",i);break;case"tabIndex":Og(n,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Og(n,t,i);break;case"style":aO(n,i,r);break;case"data":if(e!=="object"){Og(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=Qv(""+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 r=="function"&&(t==="formAction"?(e!=="input"&&Hn(n,e,"name",a.name,a,null),Hn(n,e,"formEncType",a.formEncType,a,null),Hn(n,e,"formMethod",a.formMethod,a,null),Hn(n,e,"formTarget",a.formTarget,a,null)):(Hn(n,e,"encType",a.encType,a,null),Hn(n,e,"method",a.method,a,null),Hn(n,e,"target",a.target,a,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){n.removeAttribute(t);break}i=Qv(""+i),n.setAttribute(t,i);break;case"onClick":i!=null&&(n.onclick=uy);break;case"onScroll":i!=null&&mn("scroll",n);break;case"onScrollEnd":i!=null&&mn("scrollend",n);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(qe(61));if(t=i.__html,t!=null){if(a.children!=null)throw Error(qe(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=Qv(""+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":mn("beforetoggle",n),mn("toggle",n),Jv(n,"popover",i);break;case"xlinkActuate":yo(n,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":yo(n,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":yo(n,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":yo(n,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":yo(n,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":yo(n,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":yo(n,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":yo(n,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":yo(n,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":Jv(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=yP.get(t)||t,Jv(n,t,i))}}function vE(n,e,t,i,a,r){switch(t){case"style":aO(n,i,r);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(qe(61));if(t=i.__html,t!=null){if(a.children!=null)throw Error(qe(60));n.innerHTML=t}}break;case"children":typeof i=="string"?ad(n,i):(typeof i=="number"||typeof i=="bigint")&&ad(n,""+i);break;case"onScroll":i!=null&&mn("scroll",n);break;case"onScrollEnd":i!=null&&mn("scrollend",n);break;case"onClick":i!=null&&(n.onclick=uy);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!QN.hasOwnProperty(t))e:{if(t[0]==="o"&&t[1]==="n"&&(a=t.endsWith("Capture"),e=t.slice(2,a?t.length-7:void 0),r=n[$a]||null,r=r!=null?r[t]:null,typeof r=="function"&&n.removeEventListener(e,r,a),typeof i=="function")){typeof r!="function"&&r!==null&&(t in n?n[t]=null:n.hasAttribute(t)&&n.removeAttribute(t)),n.addEventListener(e,i,a);break e}t in n?n[t]=i:i===!0?n.setAttribute(t,""):Jv(n,t,i)}}}function ma(n,e,t){switch(e){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":mn("error",n),mn("load",n);var i=!1,a=!1,r;for(r in t)if(t.hasOwnProperty(r)){var s=t[r];if(s!=null)switch(r){case"src":i=!0;break;case"srcSet":a=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(qe(137,e));default:Hn(n,e,r,s,t,null)}}a&&Hn(n,e,"srcSet",t.srcSet,t,null),i&&Hn(n,e,"src",t.src,t,null);return;case"input":mn("invalid",n);var o=r=s=a=null,c=null,h=null;for(i in t)if(t.hasOwnProperty(i)){var f=t[i];if(f!=null)switch(i){case"name":a=f;break;case"type":s=f;break;case"checked":c=f;break;case"defaultChecked":h=f;break;case"value":r=f;break;case"defaultValue":o=f;break;case"children":case"dangerouslySetInnerHTML":if(f!=null)throw Error(qe(137,e));break;default:Hn(n,e,i,f,t,null)}}tO(n,r,o,c,h,s,a,!1),_1(n);return;case"select":mn("invalid",n),i=s=r=null;for(a in t)if(t.hasOwnProperty(a)&&(o=t[a],o!=null))switch(a){case"value":r=o;break;case"defaultValue":s=o;break;case"multiple":i=o;default:Hn(n,e,a,o,t,null)}e=r,t=s,n.multiple=!!i,e!=null?kf(n,!!i,e,!1):t!=null&&kf(n,!!i,t,!0);return;case"textarea":mn("invalid",n),r=a=i=null;for(s in t)if(t.hasOwnProperty(s)&&(o=t[s],o!=null))switch(s){case"value":i=o;break;case"defaultValue":a=o;break;case"children":r=o;break;case"dangerouslySetInnerHTML":if(o!=null)throw Error(qe(91));break;default:Hn(n,e,s,o,t,null)}iO(n,i,a,r),_1(n);return;case"option":for(c in t)if(t.hasOwnProperty(c)&&(i=t[c],i!=null))switch(c){case"selected":n.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:Hn(n,e,c,i,t,null)}return;case"dialog":mn("cancel",n),mn("close",n);break;case"iframe":case"object":mn("load",n);break;case"video":case"audio":for(i=0;i<Wm.length;i++)mn(Wm[i],n);break;case"image":mn("error",n),mn("load",n);break;case"details":mn("toggle",n);break;case"embed":case"source":case"link":mn("error",n),mn("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(qe(137,e));default:Hn(n,e,h,i,t,null)}return;default:if(FT(e)){for(f in t)t.hasOwnProperty(f)&&(i=t[f],i!==void 0&&vE(n,e,f,i,t,void 0));return}}for(o in t)t.hasOwnProperty(o)&&(i=t[o],i!=null&&Hn(n,e,o,i,t,null))}function W7(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 a=null,r=null,s=null,o=null,c=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":c=d;default:i.hasOwnProperty(g)||Hn(n,e,g,null,i,d)}}for(var m in i){var g=i[m];if(d=t[m],i.hasOwnProperty(m)&&(g!=null||d!=null))switch(m){case"type":r=g;break;case"name":a=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(qe(137,e));break;default:g!==d&&Hn(n,e,m,g,i,d)}}z2(n,s,o,c,h,f,r,a);return;case"select":g=s=o=m=null;for(r in t)if(c=t[r],t.hasOwnProperty(r)&&c!=null)switch(r){case"value":break;case"multiple":g=c;default:i.hasOwnProperty(r)||Hn(n,e,r,null,i,c)}for(a in i)if(r=i[a],c=t[a],i.hasOwnProperty(a)&&(r!=null||c!=null))switch(a){case"value":m=r;break;case"defaultValue":o=r;break;case"multiple":s=r;default:r!==c&&Hn(n,e,a,r,i,c)}e=o,t=s,i=g,m!=null?kf(n,!!t,m,!1):!!i!=!!t&&(e!=null?kf(n,!!t,e,!0):kf(n,!!t,t?[]:"",!1));return;case"textarea":g=m=null;for(o in t)if(a=t[o],t.hasOwnProperty(o)&&a!=null&&!i.hasOwnProperty(o))switch(o){case"value":break;case"children":break;default:Hn(n,e,o,null,i,a)}for(s in i)if(a=i[s],r=t[s],i.hasOwnProperty(s)&&(a!=null||r!=null))switch(s){case"value":m=a;break;case"defaultValue":g=a;break;case"children":break;case"dangerouslySetInnerHTML":if(a!=null)throw Error(qe(91));break;default:a!==r&&Hn(n,e,s,a,i,r)}nO(n,m,g);return;case"option":for(var y in t)if(m=t[y],t.hasOwnProperty(y)&&m!=null&&!i.hasOwnProperty(y))switch(y){case"selected":n.selected=!1;break;default:Hn(n,e,y,null,i,m)}for(c in i)if(m=i[c],g=t[c],i.hasOwnProperty(c)&&m!==g&&(m!=null||g!=null))switch(c){case"selected":n.selected=m&&typeof m!="function"&&typeof m!="symbol";break;default:Hn(n,e,c,m,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 E in t)m=t[E],t.hasOwnProperty(E)&&m!=null&&!i.hasOwnProperty(E)&&Hn(n,e,E,null,i,m);for(h in i)if(m=i[h],g=t[h],i.hasOwnProperty(h)&&m!==g&&(m!=null||g!=null))switch(h){case"children":case"dangerouslySetInnerHTML":if(m!=null)throw Error(qe(137,e));break;default:Hn(n,e,h,m,i,g)}return;default:if(FT(e)){for(var S in t)m=t[S],t.hasOwnProperty(S)&&m!==void 0&&!i.hasOwnProperty(S)&&vE(n,e,S,void 0,i,m);for(f in i)m=i[f],g=t[f],!i.hasOwnProperty(f)||m===g||m===void 0&&g===void 0||vE(n,e,f,m,i,g);return}}for(var v in t)m=t[v],t.hasOwnProperty(v)&&m!=null&&!i.hasOwnProperty(v)&&Hn(n,e,v,null,i,m);for(d in i)m=i[d],g=t[d],!i.hasOwnProperty(d)||m===g||m==null&&g==null||Hn(n,e,d,m,i,g)}var xE=null,yE=null;function F1(n){return n.nodeType===9?n:n.ownerDocument}function gw(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 $I(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 _E(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 hA=null;function Y7(){var n=window.event;return n&&n.type==="popstate"?n===hA?!1:(hA=n,!0):(hA=null,!1)}var e5=typeof setTimeout=="function"?setTimeout:void 0,q7=typeof clearTimeout=="function"?clearTimeout:void 0,vw=typeof Promise=="function"?Promise:void 0,Z7=typeof queueMicrotask=="function"?queueMicrotask:typeof vw<"u"?function(n){return vw.resolve(null).then(n).catch(j7)}:e5;function j7(n){setTimeout(function(){throw n})}function fA(n,e){var t=e,i=0;do{var a=t.nextSibling;if(n.removeChild(t),a&&a.nodeType===8)if(t=a.data,t==="/$"){if(i===0){n.removeChild(a),Jm(e);return}i--}else t!=="$"&&t!=="$?"&&t!=="$!"||i++;t=a}while(t);Jm(e)}function SE(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":SE(t),PT(t);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(t.rel.toLowerCase()==="stylesheet")continue}n.removeChild(t)}}function K7(n,e,t,i){for(;n.nodeType===1;){var a=t;if(n.nodeName.toLowerCase()!==e.toLowerCase()){if(!i&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(i){if(!n[Fm])switch(e){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(r=n.getAttribute("rel"),r==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(r!==a.rel||n.getAttribute("href")!==(a.href==null?null:a.href)||n.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin)||n.getAttribute("title")!==(a.title==null?null:a.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(r=n.getAttribute("src"),(r!==(a.src==null?null:a.src)||n.getAttribute("type")!==(a.type==null?null:a.type)||n.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin))&&r&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(e==="input"&&n.type==="hidden"){var r=a.name==null?null:""+a.name;if(a.type==="hidden"&&n.getAttribute("name")===r)return n}else return n;if(n=Ds(n.nextSibling),n===null)break}return null}function J7(n,e,t){if(e==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!t||(n=Ds(n.nextSibling),n===null))return null;return n}function Ds(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==="F!"||e==="F")break;if(e==="/$")return null}}return n}function xw(n){n=n.previousSibling;for(var e=0;n;){if(n.nodeType===8){var t=n.data;if(t==="$"||t==="$!"||t==="$?"){if(e===0)return n;e--}else t==="/$"&&e++}n=n.previousSibling}return null}function t5(n,e,t){switch(e=F1(t),n){case"html":if(n=e.documentElement,!n)throw Error(qe(452));return n;case"head":if(n=e.head,!n)throw Error(qe(453));return n;case"body":if(n=e.body,!n)throw Error(qe(454));return n;default:throw Error(qe(451))}}var ss=new Map,yw=new Set;function H1(n){return typeof n.getRootNode=="function"?n.getRootNode():n.ownerDocument}var ll=ai.d;ai.d={f:Q7,r:$7,D:eF,C:tF,L:nF,m:iF,X:rF,S:aF,M:sF};function Q7(){var n=ll.f(),e=ly();return n||e}function $7(n){var e=Id(n);e!==null&&e.tag===5&&e.type==="form"?tI(e):ll.r(n)}var Ud=typeof document>"u"?null:document;function n5(n,e,t){var i=Ud;if(i&&typeof e=="string"&&e){var a=Kr(e);a='link[rel="'+n+'"][href="'+a+'"]',typeof t=="string"&&(a+='[crossorigin="'+t+'"]'),yw.has(a)||(yw.add(a),n={rel:n,crossOrigin:t,href:e},i.querySelector(a)===null&&(e=i.createElement("link"),ma(e,"link",n),ia(e),i.head.appendChild(e)))}}function eF(n){ll.D(n),n5("dns-prefetch",n,null)}function tF(n,e){ll.C(n,e),n5("preconnect",n,e)}function nF(n,e,t){ll.L(n,e,t);var i=Ud;if(i&&n&&e){var a='link[rel="preload"][as="'+Kr(e)+'"]';e==="image"&&t&&t.imageSrcSet?(a+='[imagesrcset="'+Kr(t.imageSrcSet)+'"]',typeof t.imageSizes=="string"&&(a+='[imagesizes="'+Kr(t.imageSizes)+'"]')):a+='[href="'+Kr(n)+'"]';var r=a;switch(e){case"style":r=ud(n);break;case"script":r=Ld(n)}ss.has(r)||(n=si({rel:"preload",href:e==="image"&&t&&t.imageSrcSet?void 0:n,as:e},t),ss.set(r,n),i.querySelector(a)!==null||e==="style"&&i.querySelector(E0(r))||e==="script"&&i.querySelector(T0(r))||(e=i.createElement("link"),ma(e,"link",n),ia(e),i.head.appendChild(e)))}}function iF(n,e){ll.m(n,e);var t=Ud;if(t&&n){var i=e&&typeof e.as=="string"?e.as:"script",a='link[rel="modulepreload"][as="'+Kr(i)+'"][href="'+Kr(n)+'"]',r=a;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=Ld(n)}if(!ss.has(r)&&(n=si({rel:"modulepreload",href:n},e),ss.set(r,n),t.querySelector(a)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(t.querySelector(T0(r)))return}i=t.createElement("link"),ma(i,"link",n),ia(i),t.head.appendChild(i)}}}function aF(n,e,t){ll.S(n,e,t);var i=Ud;if(i&&n){var a=Vf(i).hoistableStyles,r=ud(n);e=e||"default";var s=a.get(r);if(!s){var o={loading:0,preload:null};if(s=i.querySelector(E0(r)))o.loading=5;else{n=si({rel:"stylesheet",href:n,"data-precedence":e},t),(t=ss.get(r))&&_3(n,t);var c=s=i.createElement("link");ia(c),ma(c,"link",n),c._p=new Promise(function(h,f){c.onload=h,c.onerror=f}),c.addEventListener("load",function(){o.loading|=1}),c.addEventListener("error",function(){o.loading|=2}),o.loading|=4,s1(s,e,i)}s={type:"stylesheet",instance:s,count:1,state:o},a.set(r,s)}}}function rF(n,e){ll.X(n,e);var t=Ud;if(t&&n){var i=Vf(t).hoistableScripts,a=Ld(n),r=i.get(a);r||(r=t.querySelector(T0(a)),r||(n=si({src:n,async:!0},e),(e=ss.get(a))&&S3(n,e),r=t.createElement("script"),ia(r),ma(r,"link",n),t.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},i.set(a,r))}}function sF(n,e){ll.M(n,e);var t=Ud;if(t&&n){var i=Vf(t).hoistableScripts,a=Ld(n),r=i.get(a);r||(r=t.querySelector(T0(a)),r||(n=si({src:n,async:!0,type:"module"},e),(e=ss.get(a))&&S3(n,e),r=t.createElement("script"),ia(r),ma(r,"link",n),t.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},i.set(a,r))}}function _w(n,e,t,i){var a=(a=ec.current)?H1(a):null;if(!a)throw Error(qe(446));switch(n){case"meta":case"title":return null;case"style":return typeof t.precedence=="string"&&typeof t.href=="string"?(e=ud(t.href),t=Vf(a).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=ud(t.href);var r=Vf(a).hoistableStyles,s=r.get(n);if(s||(a=a.ownerDocument||a,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},r.set(n,s),(r=a.querySelector(E0(n)))&&!r._p&&(s.instance=r,s.state.loading=5),ss.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},ss.set(n,t),r||oF(a,n,t,s.state))),e&&i===null)throw Error(qe(528,""));return s}if(e&&i!==null)throw Error(qe(529,""));return null;case"script":return e=t.async,t=t.src,typeof t=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=Ld(t),t=Vf(a).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(qe(444,n))}}function ud(n){return'href="'+Kr(n)+'"'}function E0(n){return'link[rel="stylesheet"]['+n+"]"}function i5(n){return si({},n,{"data-precedence":n.precedence,precedence:null})}function oF(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}),ma(e,"link",t),ia(e),n.head.appendChild(e))}function Ld(n){return'[src="'+Kr(n)+'"]'}function T0(n){return"script[async]"+n}function Sw(n,e,t){if(e.count++,e.instance===null)switch(e.type){case"style":var i=n.querySelector('style[data-href~="'+Kr(t.href)+'"]');if(i)return e.instance=i,ia(i),i;var a=si({},t,{"data-href":t.href,"data-precedence":t.precedence,href:null,precedence:null});return i=(n.ownerDocument||n).createElement("style"),ia(i),ma(i,"style",a),s1(i,t.precedence,n),e.instance=i;case"stylesheet":a=ud(t.href);var r=n.querySelector(E0(a));if(r)return e.state.loading|=4,e.instance=r,ia(r),r;i=i5(t),(a=ss.get(a))&&_3(i,a),r=(n.ownerDocument||n).createElement("link"),ia(r);var s=r;return s._p=new Promise(function(o,c){s.onload=o,s.onerror=c}),ma(r,"link",i),e.state.loading|=4,s1(r,t.precedence,n),e.instance=r;case"script":return r=Ld(t.src),(a=n.querySelector(T0(r)))?(e.instance=a,ia(a),a):(i=t,(a=ss.get(r))&&(i=si({},t),S3(i,a)),n=n.ownerDocument||n,a=n.createElement("script"),ia(a),ma(a,"link",i),n.head.appendChild(a),e.instance=a);case"void":return null;default:throw Error(qe(443,e.type))}else e.type==="stylesheet"&&!(e.state.loading&4)&&(i=e.instance,e.state.loading|=4,s1(i,t.precedence,n));return e.instance}function s1(n,e,t){for(var i=t.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=i.length?i[i.length-1]:null,r=a,s=0;s<i.length;s++){var o=i[s];if(o.dataset.precedence===e)r=o;else if(r!==a)break}r?r.parentNode.insertBefore(n,r.nextSibling):(e=t.nodeType===9?t.head:t,e.insertBefore(n,e.firstChild))}function _3(n,e){n.crossOrigin==null&&(n.crossOrigin=e.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=e.referrerPolicy),n.title==null&&(n.title=e.title)}function S3(n,e){n.crossOrigin==null&&(n.crossOrigin=e.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=e.referrerPolicy),n.integrity==null&&(n.integrity=e.integrity)}var o1=null;function Aw(n,e,t){if(o1===null){var i=new Map,a=o1=new Map;a.set(t,i)}else a=o1,i=a.get(t),i||(i=new Map,a.set(t,i));if(i.has(n))return i;for(i.set(n,null),t=t.getElementsByTagName(n),a=0;a<t.length;a++){var r=t[a];if(!(r[Fm]||r[ba]||n==="link"&&r.getAttribute("rel")==="stylesheet")&&r.namespaceURI!=="http://www.w3.org/2000/svg"){var s=r.getAttribute(e)||"";s=n+s;var o=i.get(s);o?o.push(r):i.set(s,[r])}}return i}function Ew(n,e,t){n=n.ownerDocument||n,n.head.insertBefore(t,e==="title"?n.querySelector("head > title"):null)}function lF(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 a5(n){return!(n.type==="stylesheet"&&!(n.state.loading&3))}var qm=null;function cF(){}function uF(n,e,t){if(qm===null)throw Error(qe(475));var i=qm;if(e.type==="stylesheet"&&(typeof t.media!="string"||matchMedia(t.media).matches!==!1)&&!(e.state.loading&4)){if(e.instance===null){var a=ud(t.href),r=n.querySelector(E0(a));if(r){n=r._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(i.count++,i=z1.bind(i),n.then(i,i)),e.state.loading|=4,e.instance=r,ia(r);return}r=n.ownerDocument||n,t=i5(t),(a=ss.get(a))&&_3(t,a),r=r.createElement("link"),ia(r);var s=r;s._p=new Promise(function(o,c){s.onload=o,s.onerror=c}),ma(r,"link",t),e.instance=r}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(e,n),(n=e.state.preload)&&!(e.state.loading&3)&&(i.count++,e=z1.bind(i),n.addEventListener("load",e),n.addEventListener("error",e))}}function hF(){if(qm===null)throw Error(qe(475));var n=qm;return n.stylesheets&&n.count===0&&AE(n,n.stylesheets),0<n.count?function(e){var t=setTimeout(function(){if(n.stylesheets&&AE(n,n.stylesheets),n.unsuspend){var i=n.unsuspend;n.unsuspend=null,i()}},6e4);return n.unsuspend=e,function(){n.unsuspend=null,clearTimeout(t)}}:null}function z1(){if(this.count--,this.count===0){if(this.stylesheets)AE(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var G1=null;function AE(n,e){n.stylesheets=null,n.unsuspend!==null&&(n.count++,G1=new Map,e.forEach(fF,n),G1=null,z1.call(n))}function fF(n,e){if(!(e.state.loading&4)){var t=G1.get(n);if(t)var i=t.get(null);else{t=new Map,G1.set(n,t);for(var a=n.querySelectorAll("link[data-precedence],style[data-precedence]"),r=0;r<a.length;r++){var s=a[r];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(t.set(s.dataset.precedence,s),i=s)}i&&t.set(null,i)}a=e.instance,s=a.getAttribute("data-precedence"),r=t.get(s)||i,r===i&&t.set(null,a),t.set(s,a),this.count++,i=z1.bind(this),a.addEventListener("load",i),a.addEventListener("error",i),r?r.parentNode.insertBefore(a,r.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(a,n.firstChild)),e.state.loading|=4}}var Zm={$$typeof:ko,Provider:null,Consumer:null,_currentValue:Eu,_currentValue2:Eu,_threadCount:0};function dF(n,e,t,i,a,r,s,o){this.tag=1,this.containerInfo=n,this.finishedWork=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=PS(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.finishedLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=PS(0),this.hiddenUpdates=PS(null),this.identifierPrefix=i,this.onUncaughtError=a,this.onCaughtError=r,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=o,this.incompleteTransitions=new Map}function r5(n,e,t,i,a,r,s,o,c,h,f,d){return n=new dF(n,e,t,s,o,c,h,d),e=1,r===!0&&(e|=24),r=es(3,null,null,e),n.current=r,r.stateNode=n,e=jT(),e.refCount++,n.pooledCache=e,e.refCount++,r.memoizedState={element:i,isDehydrated:t,cache:e},u3(r),n}function s5(n){return n?(n=Nf,n):Nf}function o5(n,e,t,i,a,r){a=s5(a),i.context===null?i.context=a:i.pendingContext=a,i=tc(e),i.payload={element:t},r=r===void 0?null:r,r!==null&&(i.callback=r),t=nc(n,i,e),t!==null&&(La(t,n,e),mm(t,n,e))}function Tw(n,e){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var t=n.retryLane;n.retryLane=t!==0&&t<e?t:e}}function A3(n,e){Tw(n,e),(n=n.alternate)&&Tw(n,e)}function l5(n){if(n.tag===13){var e=uc(n,67108864);e!==null&&La(e,n,67108864),A3(n,67108864)}}var V1=!0;function pF(n,e,t,i){var a=Qt.T;Qt.T=null;var r=ai.p;try{ai.p=2,E3(n,e,t,i)}finally{ai.p=r,Qt.T=a}}function mF(n,e,t,i){var a=Qt.T;Qt.T=null;var r=ai.p;try{ai.p=8,E3(n,e,t,i)}finally{ai.p=r,Qt.T=a}}function E3(n,e,t,i){if(V1){var a=EE(i);if(a===null)uA(n,e,i,k1,t),bw(n,i);else if(vF(a,n,e,t,i))i.stopPropagation();else if(bw(n,i),e&4&&-1<gF.indexOf(n)){for(;a!==null;){var r=Id(a);if(r!==null)switch(r.tag){case 3:if(r=r.stateNode,r.current.memoizedState.isDehydrated){var s=su(r.pendingLanes);if(s!==0){var o=r;for(o.pendingLanes|=2,o.entangledLanes|=2;s;){var c=1<<31-br(s);o.entanglements[1]|=c,s&=~c}ro(r),!(vi&6)&&(I1=$s()+500,A0(0))}}break;case 13:o=uc(r,2),o!==null&&La(o,r,2),ly(),A3(r,2)}if(r=EE(i),r===null&&uA(n,e,i,k1,t),r===a)break;a=r}a!==null&&i.stopPropagation()}else uA(n,e,i,null,t)}}function EE(n){return n=HT(n),T3(n)}var k1=null;function T3(n){if(k1=null,n=pu(n),n!==null){var e=Nd(n);if(e===null)n=null;else{var t=e.tag;if(t===13){if(n=zN(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 k1=n,null}function c5(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(tP()){case VN:return 2;case kN:return 8;case y1:case nP:return 32;case XN:return 268435456;default:return 32}default:return 32}}var TE=!1,rc=null,sc=null,oc=null,jm=new Map,Km=new Map,ql=[],gF="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 bw(n,e){switch(n){case"focusin":case"focusout":rc=null;break;case"dragenter":case"dragleave":sc=null;break;case"mouseover":case"mouseout":oc=null;break;case"pointerover":case"pointerout":jm.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":Km.delete(e.pointerId)}}function Mp(n,e,t,i,a,r){return n===null||n.nativeEvent!==r?(n={blockedOn:e,domEventName:t,eventSystemFlags:i,nativeEvent:r,targetContainers:[a]},e!==null&&(e=Id(e),e!==null&&l5(e)),n):(n.eventSystemFlags|=i,e=n.targetContainers,a!==null&&e.indexOf(a)===-1&&e.push(a),n)}function vF(n,e,t,i,a){switch(e){case"focusin":return rc=Mp(rc,n,e,t,i,a),!0;case"dragenter":return sc=Mp(sc,n,e,t,i,a),!0;case"mouseover":return oc=Mp(oc,n,e,t,i,a),!0;case"pointerover":var r=a.pointerId;return jm.set(r,Mp(jm.get(r)||null,n,e,t,i,a)),!0;case"gotpointercapture":return r=a.pointerId,Km.set(r,Mp(Km.get(r)||null,n,e,t,i,a)),!0}return!1}function u5(n){var e=pu(n.target);if(e!==null){var t=Nd(e);if(t!==null){if(e=t.tag,e===13){if(e=zN(t),e!==null){n.blockedOn=e,hP(n.priority,function(){if(t.tag===13){var i=Mr(),a=uc(t,i);a!==null&&La(a,t,i),A3(t,i)}});return}}else if(e===3&&t.stateNode.current.memoizedState.isDehydrated){n.blockedOn=t.tag===3?t.stateNode.containerInfo:null;return}}}n.blockedOn=null}function l1(n){if(n.blockedOn!==null)return!1;for(var e=n.targetContainers;0<e.length;){var t=EE(n.nativeEvent);if(t===null){t=n.nativeEvent;var i=new t.constructor(t.type,t);V2=i,t.target.dispatchEvent(i),V2=null}else return e=Id(t),e!==null&&l5(e),n.blockedOn=t,!1;e.shift()}return!0}function Mw(n,e,t){l1(n)&&t.delete(e)}function xF(){TE=!1,rc!==null&&l1(rc)&&(rc=null),sc!==null&&l1(sc)&&(sc=null),oc!==null&&l1(oc)&&(oc=null),jm.forEach(Mw),Km.forEach(Mw)}function Gg(n,e){n.blockedOn===e&&(n.blockedOn=null,TE||(TE=!0,qi.unstable_scheduleCallback(qi.unstable_NormalPriority,xF)))}var Vg=null;function Cw(n){Vg!==n&&(Vg=n,qi.unstable_scheduleCallback(qi.unstable_NormalPriority,function(){Vg===n&&(Vg=null);for(var e=0;e<n.length;e+=3){var t=n[e],i=n[e+1],a=n[e+2];if(typeof i!="function"){if(T3(i||t)===null)continue;break}var r=Id(t);r!==null&&(n.splice(e,3),e-=3,Q2(r,{pending:!0,data:a,method:t.method,action:i},i,a))}}))}function Jm(n){function e(c){return Gg(c,n)}rc!==null&&Gg(rc,n),sc!==null&&Gg(sc,n),oc!==null&&Gg(oc,n),jm.forEach(e),Km.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);)u5(t),t.blockedOn===null&&ql.shift();if(t=(n.ownerDocument||n).$$reactFormReplay,t!=null)for(i=0;i<t.length;i+=3){var a=t[i],r=t[i+1],s=a[$a]||null;if(typeof r=="function")s||Cw(t);else if(s){var o=null;if(r&&r.hasAttribute("formAction")){if(a=r,s=r[$a]||null)o=s.formAction;else if(T3(a)!==null)continue}else o=s.action;typeof o=="function"?t[i+1]=o:(t.splice(i,3),i-=3),Cw(t)}}}function b3(n){this._internalRoot=n}hy.prototype.render=b3.prototype.render=function(n){var e=this._internalRoot;if(e===null)throw Error(qe(409));var t=e.current,i=Mr();o5(t,i,n,e,null,null)};hy.prototype.unmount=b3.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var e=n.containerInfo;n.tag===0&&jf(),o5(n.current,2,null,n,null,null),ly(),e[Od]=null}};function hy(n){this._internalRoot=n}hy.prototype.unstable_scheduleHydration=function(n){if(n){var e=KN();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&&u5(n)}};var Rw=UN.version;if(Rw!=="19.0.0")throw Error(qe(527,Rw,"19.0.0"));ai.findDOMNode=function(n){var e=n._reactInternals;if(e===void 0)throw typeof n.render=="function"?Error(qe(188)):(n=Object.keys(n).join(","),Error(qe(268,n)));return n=QL(e),n=n!==null?GN(n):null,n=n===null?null:n.stateNode,n};var yF={bundleType:0,version:"19.0.0",rendererPackageName:"react-dom",currentDispatcherRef:Qt,findFiberByHostInstance:pu,reconcilerVersion:"19.0.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var kg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!kg.isDisabled&&kg.supportsFiber)try{d0=kg.inject(yF),Tr=kg}catch{}}Kx.createRoot=function(n,e){if(!LN(n))throw Error(qe(299));var t=!1,i="",a=oI,r=lI,s=cI,o=null;return e!=null&&(e.unstable_strictMode===!0&&(t=!0),e.identifierPrefix!==void 0&&(i=e.identifierPrefix),e.onUncaughtError!==void 0&&(a=e.onUncaughtError),e.onCaughtError!==void 0&&(r=e.onCaughtError),e.onRecoverableError!==void 0&&(s=e.onRecoverableError),e.unstable_transitionCallbacks!==void 0&&(o=e.unstable_transitionCallbacks)),e=r5(n,1,!1,null,null,t,i,a,r,s,o,null),n[Od]=e.current,y3(n.nodeType===8?n.parentNode:n),new b3(e)};Kx.hydrateRoot=function(n,e,t){if(!LN(n))throw Error(qe(299));var i=!1,a="",r=oI,s=lI,o=cI,c=null,h=null;return t!=null&&(t.unstable_strictMode===!0&&(i=!0),t.identifierPrefix!==void 0&&(a=t.identifierPrefix),t.onUncaughtError!==void 0&&(r=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(o=t.onRecoverableError),t.unstable_transitionCallbacks!==void 0&&(c=t.unstable_transitionCallbacks),t.formState!==void 0&&(h=t.formState)),e=r5(n,1,!0,e,t??null,i,a,r,s,o,c,h),e.context=s5(null),t=e.current,i=Mr(),a=tc(i),a.callback=null,nc(t,a,i),e.current.lanes=i,m0(e,i),ro(e),n[Od]=e.current,y3(n),new hy(e)};Kx.version="19.0.0";function h5(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(h5)}catch(n){console.error(n)}}h5(),wN.exports=Kx;var f5=wN.exports;const _F=Zx(f5);var d5={exports:{}},yc={};/**
* @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.
*/yc.ConcurrentRoot=1;yc.ContinuousEventPriority=8;yc.DefaultEventPriority=32;yc.DiscreteEventPriority=2;yc.IdleEventPriority=268435456;yc.LegacyRoot=0;yc.NoEventPriority=0;d5.exports=yc;var c1=d5.exports;/**
* @license
* Copyright 2010-2025 Three.js Authors
* SPDX-License-Identifier: MIT
*/const _c="181",lu={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},cu={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},p5=0,bE=1,m5=2,SF=3,g5=0,fy=1,Am=2,Es=3,os=0,Wi=1,da=2,ga=0,wu=1,ME=2,CE=3,RE=4,M3=5,js=100,v5=101,x5=102,y5=103,_5=104,S5=200,Uf=201,A5=202,E5=203,X1=204,W1=205,T5=206,b5=207,M5=208,C5=209,R5=210,w5=211,D5=212,N5=213,O5=214,Y1=0,Qm=1,q1=2,zu=3,Z1=4,j1=5,K1=6,J1=7,b0=0,I5=1,B5=2,ns=0,U5=1,L5=2,P5=3,C3=4,F5=5,H5=6,z5=7,wE="attached",G5="detached",pc=300,no=301,mc=302,hd=303,$m=304,Pd=306,wi=1e3,Vn=1001,fd=1002,$n=1003,dy=1004,AF=1004,gu=1005,EF=1005,Bt=1006,Kf=1007,TF=1007,Sr=1008,e0=1008,xi=1009,M0=1010,C0=1011,Gu=1012,Fd=1013,ls=1014,Sn=1015,sn=1016,py=1017,my=1018,Vu=1020,R3=35902,w3=35899,D3=1021,N3=1022,Rn=1023,dd=1026,ku=1027,Ar=1028,R0=1029,zo=1030,gy=1031,bF=1032,vy=1033,Em=33776,Tm=33777,bm=33778,Mm=33779,Q1=35840,$1=35841,ex=35842,tx=35843,nx=36196,ix=37492,ax=37496,rx=37808,sx=37809,ox=37810,lx=37811,cx=37812,ux=37813,hx=37814,fx=37815,dx=37816,px=37817,mx=37818,gx=37819,vx=37820,xx=37821,yx=36492,_x=36494,Sx=36495,Ax=36283,Ex=36284,Tx=36285,bx=36286,V5=2200,k5=2201,X5=2202,pd=2300,md=2301,u1=2302,vu=2400,xu=2401,t0=2402,xy=2500,O3=2501,W5=0,I3=1,Mx=2,Sc=3200,Y5=3201,MF=3202,CF=3203,Ac=0,q5=1,pa="",Kn="srgb",Fi="srgb-linear",n0="linear",Un="srgb",RF=0,uu=7680,wF=7681,DF=7682,NF=7683,OF=34055,IF=34056,BF=5386,UF=512,LF=513,PF=514,FF=515,HF=516,zF=517,GF=518,DE=519,Z5=512,j5=513,K5=514,B3=515,J5=516,Q5=517,$5=518,eB=519,i0=35044,VF=35048,kF=35040,XF=35045,WF=35049,YF=35041,qF=35046,ZF=35050,jF=35042,KF="100",cs="300 es",Er=2e3,gd=2001,JF={COMPUTE:"compute",RENDER:"render"},QF={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},$F={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function tB(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const eH={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Lf(n,e){return new eH[n](e)}function a0(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function nB(){const n=a0("canvas");return n.style.display="block",n}const ww={};let gc=null;function tH(n){gc=n}function nH(){return gc}function r0(...n){const e="THREE."+n.shift();gc?gc("log",e,...n):console.log(e,...n)}function _t(...n){const e="THREE."+n.shift();gc?gc("warn",e,...n):console.warn(e,...n)}function qt(...n){const e="THREE."+n.shift();gc?gc("error",e,...n):console.error(e,...n)}function vd(...n){const e=n.join(" ");e in ww||(ww[e]=!0,_t(...n))}function iH(n,e,t){return new Promise(function(i,a){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:a();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}let tr=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 a=i[e];if(a!==void 0){const r=a.indexOf(t);r!==-1&&a.splice(r,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 a=i.slice(0);for(let r=0,s=a.length;r<s;r++)a[r].call(this,e);e.target=null}}};const Sa=["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 Dw=1234567;const Du=Math.PI/180,xd=180/Math.PI;function Cr(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Sa[n&255]+Sa[n>>8&255]+Sa[n>>16&255]+Sa[n>>24&255]+"-"+Sa[e&255]+Sa[e>>8&255]+"-"+Sa[e>>16&15|64]+Sa[e>>24&255]+"-"+Sa[t&63|128]+Sa[t>>8&255]+"-"+Sa[t>>16&255]+Sa[t>>24&255]+Sa[i&255]+Sa[i>>8&255]+Sa[i>>16&255]+Sa[i>>24&255]).toLowerCase()}function Gt(n,e,t){return Math.max(e,Math.min(t,n))}function U3(n,e){return(n%e+e)%e}function aH(n,e,t,i,a){return i+(n-e)*(a-i)/(t-e)}function rH(n,e,t){return n!==e?(t-n)/(e-n):0}function Cm(n,e,t){return(1-t)*n+t*e}function sH(n,e,t,i){return Cm(n,e,1-Math.exp(-t*i))}function oH(n,e=1){return e-Math.abs(U3(n,e*2)-e)}function lH(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function cH(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function uH(n,e){return n+Math.floor(Math.random()*(e-n+1))}function hH(n,e){return n+Math.random()*(e-n)}function fH(n){return n*(.5-Math.random())}function dH(n){n!==void 0&&(Dw=n);let e=Dw+=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 pH(n){return n*Du}function mH(n){return n*xd}function gH(n){return(n&n-1)===0&&n!==0}function vH(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function xH(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function yH(n,e,t,i,a){const r=Math.cos,s=Math.sin,o=r(t/2),c=s(t/2),h=r((e+i)/2),f=s((e+i)/2),d=r((e-i)/2),m=s((e-i)/2),g=r((i-e)/2),y=s((i-e)/2);switch(a){case"XYX":n.set(o*f,c*d,c*m,o*h);break;case"YZY":n.set(c*m,o*f,c*d,o*h);break;case"ZXZ":n.set(c*d,c*m,o*f,o*h);break;case"XZX":n.set(o*f,c*y,c*g,o*h);break;case"YXY":n.set(c*g,o*f,c*y,o*h);break;case"ZYZ":n.set(c*y,c*g,o*f,o*h);break;default:_t("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+a)}}function Ba(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 Nr={DEG2RAD:Du,RAD2DEG:xd,generateUUID:Cr,clamp:Gt,euclideanModulo:U3,mapLinear:aH,inverseLerp:rH,lerp:Cm,damp:sH,pingpong:oH,smoothstep:lH,smootherstep:cH,randInt:uH,randFloat:hH,randFloatSpread:fH,seededRandom:dH,degToRad:pH,radToDeg:mH,isPowerOfTwo:gH,ceilPowerOfTwo:vH,floorPowerOfTwo:xH,setQuaternionFromProperEuler:yH,normalize:Jt,denormalize:Ba};class Ee{constructor(e=0,t=0){Ee.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,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6],this.y=a[1]*t+a[4]*i+a[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=Gt(this.x,e.x,t.x),this.y=Gt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Gt(this.x,e,t),this.y=Gt(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(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(Gt(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),a=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*i-s*a+e.x,this.y=r*a+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 Yi{constructor(e=0,t=0,i=0,a=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=a}static slerpFlat(e,t,i,a,r,s,o){let c=i[a+0],h=i[a+1],f=i[a+2],d=i[a+3],m=r[s+0],g=r[s+1],y=r[s+2],E=r[s+3];if(o<=0){e[t+0]=c,e[t+1]=h,e[t+2]=f,e[t+3]=d;return}if(o>=1){e[t+0]=m,e[t+1]=g,e[t+2]=y,e[t+3]=E;return}if(d!==E||c!==m||h!==g||f!==y){let S=c*m+h*g+f*y+d*E;S<0&&(m=-m,g=-g,y=-y,E=-E,S=-S);let v=1-o;if(S<.9995){const _=Math.acos(S),A=Math.sin(_);v=Math.sin(v*_)/A,o=Math.sin(o*_)/A,c=c*v+m*o,h=h*v+g*o,f=f*v+y*o,d=d*v+E*o}else{c=c*v+m*o,h=h*v+g*o,f=f*v+y*o,d=d*v+E*o;const _=1/Math.sqrt(c*c+h*h+f*f+d*d);c*=_,h*=_,f*=_,d*=_}}e[t]=c,e[t+1]=h,e[t+2]=f,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,a,r,s){const o=i[a],c=i[a+1],h=i[a+2],f=i[a+3],d=r[s],m=r[s+1],g=r[s+2],y=r[s+3];return e[t]=o*y+f*d+c*g-h*m,e[t+1]=c*y+f*m+h*d-o*g,e[t+2]=h*y+f*g+o*m-c*d,e[t+3]=f*y-o*d-c*m-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,a){return this._x=e,this._y=t,this._z=i,this._w=a,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,a=e._y,r=e._z,s=e._order,o=Math.cos,c=Math.sin,h=o(i/2),f=o(a/2),d=o(r/2),m=c(i/2),g=c(a/2),y=c(r/2);switch(s){case"XYZ":this._x=m*f*d+h*g*y,this._y=h*g*d-m*f*y,this._z=h*f*y+m*g*d,this._w=h*f*d-m*g*y;break;case"YXZ":this._x=m*f*d+h*g*y,this._y=h*g*d-m*f*y,this._z=h*f*y-m*g*d,this._w=h*f*d+m*g*y;break;case"ZXY":this._x=m*f*d-h*g*y,this._y=h*g*d+m*f*y,this._z=h*f*y+m*g*d,this._w=h*f*d-m*g*y;break;case"ZYX":this._x=m*f*d-h*g*y,this._y=h*g*d+m*f*y,this._z=h*f*y-m*g*d,this._w=h*f*d+m*g*y;break;case"YZX":this._x=m*f*d+h*g*y,this._y=h*g*d+m*f*y,this._z=h*f*y-m*g*d,this._w=h*f*d-m*g*y;break;case"XZY":this._x=m*f*d-h*g*y,this._y=h*g*d-m*f*y,this._z=h*f*y+m*g*d,this._w=h*f*d+m*g*y;break;default:_t("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,a=Math.sin(i);return this._x=e.x*a,this._y=e.y*a,this._z=e.z*a,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],a=t[4],r=t[8],s=t[1],o=t[5],c=t[9],h=t[2],f=t[6],d=t[10],m=i+o+d;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(f-c)*g,this._y=(r-h)*g,this._z=(s-a)*g}else if(i>o&&i>d){const g=2*Math.sqrt(1+i-o-d);this._w=(f-c)/g,this._x=.25*g,this._y=(a+s)/g,this._z=(r+h)/g}else if(o>d){const g=2*Math.sqrt(1+o-i-d);this._w=(r-h)/g,this._x=(a+s)/g,this._y=.25*g,this._z=(c+f)/g}else{const g=2*Math.sqrt(1+d-i-o);this._w=(s-a)/g,this._x=(r+h)/g,this._y=(c+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(Gt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const a=Math.min(1,t/i);return this.slerp(e,a),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,a=e._y,r=e._z,s=e._w,o=t._x,c=t._y,h=t._z,f=t._w;return this._x=i*f+s*o+a*h-r*c,this._y=a*f+s*c+r*o-i*h,this._z=r*f+s*h+i*c-a*o,this._w=s*f-i*o-a*c-r*h,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,a=e._y,r=e._z,s=e._w,o=this.dot(e);o<0&&(i=-i,a=-a,r=-r,s=-s,o=-o);let c=1-t;if(o<.9995){const h=Math.acos(o),f=Math.sin(h);c=Math.sin(c*h)/f,t=Math.sin(t*h)/f,this._x=this._x*c+i*t,this._y=this._y*c+a*t,this._z=this._z*c+r*t,this._w=this._w*c+s*t,this._onChangeCallback()}else this._x=this._x*c+i*t,this._y=this._y*c+a*t,this._z=this._z*c+r*t,this._w=this._w*c+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(),a=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(a*Math.sin(e),a*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class H{constructor(e=0,t=0,i=0){H.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(Nw.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Nw.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,a=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*a,this.y=r[1]*t+r[4]*i+r[7]*a,this.z=r[2]*t+r[5]*i+r[8]*a,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,a=this.z,r=e.elements,s=1/(r[3]*t+r[7]*i+r[11]*a+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*a+r[12])*s,this.y=(r[1]*t+r[5]*i+r[9]*a+r[13])*s,this.z=(r[2]*t+r[6]*i+r[10]*a+r[14])*s,this}applyQuaternion(e){const t=this.x,i=this.y,a=this.z,r=e.x,s=e.y,o=e.z,c=e.w,h=2*(s*a-o*i),f=2*(o*t-r*a),d=2*(r*i-s*t);return this.x=t+c*h+s*d-o*f,this.y=i+c*f+o*h-r*d,this.z=a+c*d+r*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,a=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*a,this.y=r[1]*t+r[5]*i+r[9]*a,this.z=r[2]*t+r[6]*i+r[10]*a,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=Gt(this.x,e.x,t.x),this.y=Gt(this.y,e.y,t.y),this.z=Gt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Gt(this.x,e,t),this.y=Gt(this.y,e,t),this.z=Gt(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(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,a=e.y,r=e.z,s=t.x,o=t.y,c=t.z;return this.x=a*c-r*o,this.y=r*s-i*c,this.z=i*o-a*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 dA.copy(this).projectOnVector(e),this.sub(dA)}reflect(e){return this.sub(dA.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(Gt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,a=this.z-e.z;return t*t+i*i+a*a}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 a=Math.sin(t)*e;return this.x=a*Math.sin(i),this.y=Math.cos(t)*e,this.z=a*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(),a=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=a,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 dA=new H,Nw=new Yi;class kt{constructor(e,t,i,a,r,s,o,c,h){kt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,a,r,s,o,c,h)}set(e,t,i,a,r,s,o,c,h){const f=this.elements;return f[0]=e,f[1]=a,f[2]=o,f[3]=t,f[4]=r,f[5]=c,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,a=t.elements,r=this.elements,s=i[0],o=i[3],c=i[6],h=i[1],f=i[4],d=i[7],m=i[2],g=i[5],y=i[8],E=a[0],S=a[3],v=a[6],_=a[1],A=a[4],b=a[7],O=a[2],N=a[5],L=a[8];return r[0]=s*E+o*_+c*O,r[3]=s*S+o*A+c*N,r[6]=s*v+o*b+c*L,r[1]=h*E+f*_+d*O,r[4]=h*S+f*A+d*N,r[7]=h*v+f*b+d*L,r[2]=m*E+g*_+y*O,r[5]=m*S+g*A+y*N,r[8]=m*v+g*b+y*L,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],a=e[2],r=e[3],s=e[4],o=e[5],c=e[6],h=e[7],f=e[8];return t*s*f-t*o*h-i*r*f+i*o*c+a*r*h-a*s*c}invert(){const e=this.elements,t=e[0],i=e[1],a=e[2],r=e[3],s=e[4],o=e[5],c=e[6],h=e[7],f=e[8],d=f*s-o*h,m=o*c-f*r,g=h*r-s*c,y=t*d+i*m+a*g;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const E=1/y;return e[0]=d*E,e[1]=(a*h-f*i)*E,e[2]=(o*i-a*s)*E,e[3]=m*E,e[4]=(f*t-a*c)*E,e[5]=(a*r-o*t)*E,e[6]=g*E,e[7]=(i*c-h*t)*E,e[8]=(s*t-i*r)*E,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,a,r,s,o){const c=Math.cos(r),h=Math.sin(r);return this.set(i*c,i*h,-i*(c*s+h*o)+s+e,-a*h,a*c,-a*(-h*s+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(pA.makeScale(e,t)),this}rotate(e){return this.premultiply(pA.makeRotation(-e)),this}translate(e,t){return this.premultiply(pA.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 a=0;a<9;a++)if(t[a]!==i[a])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 pA=new kt,Ow=new kt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Iw=new kt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function _H(){const n={enabled:!0,workingColorSpace:Fi,spaces:{},convert:function(a,r,s){return this.enabled===!1||r===s||!r||!s||(this.spaces[r].transfer===Un&&(a.r=Jo(a.r),a.g=Jo(a.g),a.b=Jo(a.b)),this.spaces[r].primaries!==this.spaces[s].primaries&&(a.applyMatrix3(this.spaces[r].toXYZ),a.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===Un&&(a.r=Jf(a.r),a.g=Jf(a.g),a.b=Jf(a.b))),a},workingToColorSpace:function(a,r){return this.convert(a,this.workingColorSpace,r)},colorSpaceToWorking:function(a,r){return this.convert(a,r,this.workingColorSpace)},getPrimaries:function(a){return this.spaces[a].primaries},getTransfer:function(a){return a===pa?n0:this.spaces[a].transfer},getToneMappingMode:function(a){return this.spaces[a].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(a,r=this.workingColorSpace){return a.fromArray(this.spaces[r].luminanceCoefficients)},define:function(a){Object.assign(this.spaces,a)},_getMatrix:function(a,r,s){return a.copy(this.spaces[r].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(a){return this.spaces[a].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(a=this.workingColorSpace){return this.spaces[a].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(a,r){return vd("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(a,r)},toWorkingColorSpace:function(a,r){return vd("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(a,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Fi]:{primaries:e,whitePoint:i,transfer:n0,toXYZ:Ow,fromXYZ:Iw,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Kn},outputColorSpaceConfig:{drawingBufferColorSpace:Kn}},[Kn]:{primaries:e,whitePoint:i,transfer:Un,toXYZ:Ow,fromXYZ:Iw,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Kn}}}),n}const gn=_H();function Jo(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Jf(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Vh;class iB{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{Vh===void 0&&(Vh=a0("canvas")),Vh.width=e.width,Vh.height=e.height;const a=Vh.getContext("2d");e instanceof ImageData?a.putImageData(e,0,0):a.drawImage(e,0,0,e.width,e.height),i=Vh}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=a0("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const a=i.getImageData(0,0,e.width,e.height),r=a.data;for(let s=0;s<r.length;s++)r[s]=Jo(r[s]/255)*255;return i.putImageData(a,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(Jo(t[i]/255)*255):t[i]=Jo(t[i]);return{data:t,width:e.width,height:e.height}}else return _t("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let SH=0;class Kl{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:SH++}),this.uuid=Cr(),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:""},a=this.data;if(a!==null){let r;if(Array.isArray(a)){r=[];for(let s=0,o=a.length;s<o;s++)a[s].isDataTexture?r.push(mA(a[s].image)):r.push(mA(a[s]))}else r=mA(a);i.url=r}return t||(e.images[this.uuid]=i),i}}function mA(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?iB.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(_t("Texture: Unable to serialize Texture."),{})}let AH=0;const gA=new H;class vn extends tr{constructor(e=vn.DEFAULT_IMAGE,t=vn.DEFAULT_MAPPING,i=Vn,a=Vn,r=Bt,s=Sr,o=Rn,c=xi,h=vn.DEFAULT_ANISOTROPY,f=pa){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:AH++}),this.uuid=Cr(),this.name="",this.source=new Kl(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=a,this.magFilter=r,this.minFilter=s,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ee(0,0),this.repeat=new Ee(1,1),this.center=new Ee(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new kt,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(gA).x}get height(){return this.source.getSize(gA).y}get depth(){return this.source.getSize(gA).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){_t(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const a=this[t];if(a===void 0){_t(`Texture.setValues(): property '${t}' does not exist.`);continue}a&&i&&a.isVector2&&i.isVector2||a&&i&&a.isVector3&&i.isVector3||a&&i&&a.isMatrix3&&i.isMatrix3?a.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!==pc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case wi:e.x=e.x-Math.floor(e.x);break;case Vn:e.x=e.x<0?0:1;break;case fd: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 wi:e.y=e.y-Math.floor(e.y);break;case Vn:e.y=e.y<0?0:1;break;case fd: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++}}vn.DEFAULT_IMAGE=null;vn.DEFAULT_MAPPING=pc;vn.DEFAULT_ANISOTROPY=1;class Yt{constructor(e=0,t=0,i=0,a=1){Yt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=a}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,a){return this.x=e,this.y=t,this.z=i,this.w=a,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,a=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*a+s[12]*r,this.y=s[1]*t+s[5]*i+s[9]*a+s[13]*r,this.z=s[2]*t+s[6]*i+s[10]*a+s[14]*r,this.w=s[3]*t+s[7]*i+s[11]*a+s[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);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,a,r;const c=e.elements,h=c[0],f=c[4],d=c[8],m=c[1],g=c[5],y=c[9],E=c[2],S=c[6],v=c[10];if(Math.abs(f-m)<.01&&Math.abs(d-E)<.01&&Math.abs(y-S)<.01){if(Math.abs(f+m)<.1&&Math.abs(d+E)<.1&&Math.abs(y+S)<.1&&Math.abs(h+g+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const A=(h+1)/2,b=(g+1)/2,O=(v+1)/2,N=(f+m)/4,L=(d+E)/4,B=(y+S)/4;return A>b&&A>O?A<.01?(i=0,a=.707106781,r=.707106781):(i=Math.sqrt(A),a=N/i,r=L/i):b>O?b<.01?(i=.707106781,a=0,r=.707106781):(a=Math.sqrt(b),i=N/a,r=B/a):O<.01?(i=.707106781,a=.707106781,r=0):(r=Math.sqrt(O),i=L/r,a=B/r),this.set(i,a,r,t),this}let _=Math.sqrt((S-y)*(S-y)+(d-E)*(d-E)+(m-f)*(m-f));return Math.abs(_)<.001&&(_=1),this.x=(S-y)/_,this.y=(d-E)/_,this.z=(m-f)/_,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=Gt(this.x,e.x,t.x),this.y=Gt(this.y,e.y,t.y),this.z=Gt(this.z,e.z,t.z),this.w=Gt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Gt(this.x,e,t),this.y=Gt(this.y,e,t),this.z=Gt(this.z,e,t),this.w=Gt(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Gt(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 L3 extends tr{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Bt,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 Yt(0,0,e,t),this.scissorTest=!1,this.viewport=new Yt(0,0,e,t);const a={width:e,height:t,depth:i.depth},r=new vn(a);this.textures=[];const s=i.count;for(let o=0;o<s;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(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:Bt,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 a=0,r=this.textures.length;a<r;a++)this.textures[a].image.width=e,this.textures[a].image.height=t,this.textures[a].image.depth=i,this.textures[a].isData3DTexture!==!0&&(this.textures[a].isArrayTexture=this.textures[a].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 a=Object.assign({},e.textures[t].image);this.textures[t].source=new Kl(a)}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 oi extends L3{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class yy extends vn{constructor(e=null,t=1,i=1,a=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:a},this.magFilter=$n,this.minFilter=$n,this.wrapR=Vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class aB extends oi{constructor(e=1,t=1,i=1,a={}){super(e,t,a),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new yy(null,e,t,i),this._setTextureOptions(a),this.texture.isRenderTargetTexture=!0}}class is extends vn{constructor(e=null,t=1,i=1,a=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:a},this.magFilter=$n,this.minFilter=$n,this.wrapR=Vn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class P3 extends oi{constructor(e=1,t=1,i=1,a={}){super(e,t,a),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new is(null,e,t,i),this._setTextureOptions(a),this.texture.isRenderTargetTexture=!0}}class sa{constructor(e=new H(1/0,1/0,1/0),t=new H(-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 r=i.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=r.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,gs):gs.fromBufferAttribute(r,s),gs.applyMatrix4(e.matrixWorld),this.expandByPoint(gs);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Xg.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Xg.copy(i.boundingBox)),Xg.applyMatrix4(e.matrixWorld),this.union(Xg)}const a=e.children;for(let r=0,s=a.length;r<s;r++)this.expandByObject(a[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,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(Cp),Wg.subVectors(this.max,Cp),kh.subVectors(e.a,Cp),Xh.subVectors(e.b,Cp),Wh.subVectors(e.c,Cp),wl.subVectors(Xh,kh),Dl.subVectors(Wh,Xh),Xc.subVectors(kh,Wh);let t=[0,-wl.z,wl.y,0,-Dl.z,Dl.y,0,-Xc.z,Xc.y,wl.z,0,-wl.x,Dl.z,0,-Dl.x,Xc.z,0,-Xc.x,-wl.y,wl.x,0,-Dl.y,Dl.x,0,-Xc.y,Xc.x,0];return!vA(t,kh,Xh,Wh,Wg)||(t=[1,0,0,0,1,0,0,0,1],!vA(t,kh,Xh,Wh,Wg))?!1:(Yg.crossVectors(wl,Dl),t=[Yg.x,Yg.y,Yg.z],vA(t,kh,Xh,Wh,Wg))}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:(Eo[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Eo[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Eo[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Eo[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Eo[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Eo[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Eo[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Eo[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Eo),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 Eo=[new H,new H,new H,new H,new H,new H,new H,new H],gs=new H,Xg=new sa,kh=new H,Xh=new H,Wh=new H,wl=new H,Dl=new H,Xc=new H,Cp=new H,Wg=new H,Yg=new H,Wc=new H;function vA(n,e,t,i,a){for(let r=0,s=n.length-3;r<=s;r+=3){Wc.fromArray(n,r);const o=a.x*Math.abs(Wc.x)+a.y*Math.abs(Wc.y)+a.z*Math.abs(Wc.z),c=e.dot(Wc),h=t.dot(Wc),f=i.dot(Wc);if(Math.max(-Math.max(c,h,f),Math.min(c,h,f))>o)return!1}return!0}const EH=new sa,Rp=new H,xA=new H;class zi{constructor(e=new H,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):EH.setFromPoints(e).getCenter(i);let a=0;for(let r=0,s=e.length;r<s;r++)a=Math.max(a,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(a),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;Rp.subVectors(e,this.center);const t=Rp.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),a=(i-this.radius)*.5;this.center.addScaledVector(Rp,a/i),this.radius+=a}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):(xA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Rp.copy(e.center).add(xA)),this.expandByPoint(Rp.copy(e.center).sub(xA))),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 To=new H,yA=new H,qg=new H,Nl=new H,_A=new H,Zg=new H,SA=new H;class oh{constructor(e=new H,t=new H(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,To)),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=To.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(To.copy(this.origin).addScaledVector(this.direction,t),To.distanceToSquared(e))}distanceSqToSegment(e,t,i,a){yA.copy(e).add(t).multiplyScalar(.5),qg.copy(t).sub(e).normalize(),Nl.copy(this.origin).sub(yA);const r=e.distanceTo(t)*.5,s=-this.direction.dot(qg),o=Nl.dot(this.direction),c=-Nl.dot(qg),h=Nl.lengthSq(),f=Math.abs(1-s*s);let d,m,g,y;if(f>0)if(d=s*c-o,m=s*o-c,y=r*f,d>=0)if(m>=-y)if(m<=y){const E=1/f;d*=E,m*=E,g=d*(d+s*m+2*o)+m*(s*d+m+2*c)+h}else m=r,d=Math.max(0,-(s*m+o)),g=-d*d+m*(m+2*c)+h;else m=-r,d=Math.max(0,-(s*m+o)),g=-d*d+m*(m+2*c)+h;else m<=-y?(d=Math.max(0,-(-s*r+o)),m=d>0?-r:Math.min(Math.max(-r,-c),r),g=-d*d+m*(m+2*c)+h):m<=y?(d=0,m=Math.min(Math.max(-r,-c),r),g=m*(m+2*c)+h):(d=Math.max(0,-(s*r+o)),m=d>0?r:Math.min(Math.max(-r,-c),r),g=-d*d+m*(m+2*c)+h);else m=s>0?-r:r,d=Math.max(0,-(s*m+o)),g=-d*d+m*(m+2*c)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,d),a&&a.copy(yA).addScaledVector(qg,m),g}intersectSphere(e,t){To.subVectors(e.center,this.origin);const i=To.dot(this.direction),a=To.dot(To)-i*i,r=e.radius*e.radius;if(a>r)return null;const s=Math.sqrt(r-a),o=i-s,c=i+s;return c<0?null:o<0?this.at(c,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,a,r,s,o,c;const h=1/this.direction.x,f=1/this.direction.y,d=1/this.direction.z,m=this.origin;return h>=0?(i=(e.min.x-m.x)*h,a=(e.max.x-m.x)*h):(i=(e.max.x-m.x)*h,a=(e.min.x-m.x)*h),f>=0?(r=(e.min.y-m.y)*f,s=(e.max.y-m.y)*f):(r=(e.max.y-m.y)*f,s=(e.min.y-m.y)*f),i>s||r>a||((r>i||isNaN(i))&&(i=r),(s<a||isNaN(a))&&(a=s),d>=0?(o=(e.min.z-m.z)*d,c=(e.max.z-m.z)*d):(o=(e.max.z-m.z)*d,c=(e.min.z-m.z)*d),i>c||o>a)||((o>i||i!==i)&&(i=o),(c<a||a!==a)&&(a=c),a<0)?null:this.at(i>=0?i:a,t)}intersectsBox(e){return this.intersectBox(e,To)!==null}intersectTriangle(e,t,i,a,r){_A.subVectors(t,e),Zg.subVectors(i,e),SA.crossVectors(_A,Zg);let s=this.direction.dot(SA),o;if(s>0){if(a)return null;o=1}else if(s<0)o=-1,s=-s;else return null;Nl.subVectors(this.origin,e);const c=o*this.direction.dot(Zg.crossVectors(Nl,Zg));if(c<0)return null;const h=o*this.direction.dot(_A.cross(Nl));if(h<0||c+h>s)return null;const f=-o*Nl.dot(SA);return f<0?null:this.at(f/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class lt{constructor(e,t,i,a,r,s,o,c,h,f,d,m,g,y,E,S){lt.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,a,r,s,o,c,h,f,d,m,g,y,E,S)}set(e,t,i,a,r,s,o,c,h,f,d,m,g,y,E,S){const v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=a,v[1]=r,v[5]=s,v[9]=o,v[13]=c,v[2]=h,v[6]=f,v[10]=d,v[14]=m,v[3]=g,v[7]=y,v[11]=E,v[15]=S,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 lt().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,a=1/Yh.setFromMatrixColumn(e,0).length(),r=1/Yh.setFromMatrixColumn(e,1).length(),s=1/Yh.setFromMatrixColumn(e,2).length();return t[0]=i[0]*a,t[1]=i[1]*a,t[2]=i[2]*a,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,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,a=e.y,r=e.z,s=Math.cos(i),o=Math.sin(i),c=Math.cos(a),h=Math.sin(a),f=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const m=s*f,g=s*d,y=o*f,E=o*d;t[0]=c*f,t[4]=-c*d,t[8]=h,t[1]=g+y*h,t[5]=m-E*h,t[9]=-o*c,t[2]=E-m*h,t[6]=y+g*h,t[10]=s*c}else if(e.order==="YXZ"){const m=c*f,g=c*d,y=h*f,E=h*d;t[0]=m+E*o,t[4]=y*o-g,t[8]=s*h,t[1]=s*d,t[5]=s*f,t[9]=-o,t[2]=g*o-y,t[6]=E+m*o,t[10]=s*c}else if(e.order==="ZXY"){const m=c*f,g=c*d,y=h*f,E=h*d;t[0]=m-E*o,t[4]=-s*d,t[8]=y+g*o,t[1]=g+y*o,t[5]=s*f,t[9]=E-m*o,t[2]=-s*h,t[6]=o,t[10]=s*c}else if(e.order==="ZYX"){const m=s*f,g=s*d,y=o*f,E=o*d;t[0]=c*f,t[4]=y*h-g,t[8]=m*h+E,t[1]=c*d,t[5]=E*h+m,t[9]=g*h-y,t[2]=-h,t[6]=o*c,t[10]=s*c}else if(e.order==="YZX"){const m=s*c,g=s*h,y=o*c,E=o*h;t[0]=c*f,t[4]=E-m*d,t[8]=y*d+g,t[1]=d,t[5]=s*f,t[9]=-o*f,t[2]=-h*f,t[6]=g*d+y,t[10]=m-E*d}else if(e.order==="XZY"){const m=s*c,g=s*h,y=o*c,E=o*h;t[0]=c*f,t[4]=-d,t[8]=h*f,t[1]=m*d+E,t[5]=s*f,t[9]=g*d-y,t[2]=y*d-g,t[6]=o*f,t[10]=E*d+m}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(TH,e,bH)}lookAt(e,t,i){const a=this.elements;return mr.subVectors(e,t),mr.lengthSq()===0&&(mr.z=1),mr.normalize(),Ol.crossVectors(i,mr),Ol.lengthSq()===0&&(Math.abs(i.z)===1?mr.x+=1e-4:mr.z+=1e-4,mr.normalize(),Ol.crossVectors(i,mr)),Ol.normalize(),jg.crossVectors(mr,Ol),a[0]=Ol.x,a[4]=jg.x,a[8]=mr.x,a[1]=Ol.y,a[5]=jg.y,a[9]=mr.y,a[2]=Ol.z,a[6]=jg.z,a[10]=mr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,a=t.elements,r=this.elements,s=i[0],o=i[4],c=i[8],h=i[12],f=i[1],d=i[5],m=i[9],g=i[13],y=i[2],E=i[6],S=i[10],v=i[14],_=i[3],A=i[7],b=i[11],O=i[15],N=a[0],L=a[4],B=a[8],w=a[12],D=a[1],G=a[5],J=a[9],$=a[13],se=a[2],le=a[6],q=a[10],te=a[14],ee=a[3],de=a[7],ue=a[11],Pe=a[15];return r[0]=s*N+o*D+c*se+h*ee,r[4]=s*L+o*G+c*le+h*de,r[8]=s*B+o*J+c*q+h*ue,r[12]=s*w+o*$+c*te+h*Pe,r[1]=f*N+d*D+m*se+g*ee,r[5]=f*L+d*G+m*le+g*de,r[9]=f*B+d*J+m*q+g*ue,r[13]=f*w+d*$+m*te+g*Pe,r[2]=y*N+E*D+S*se+v*ee,r[6]=y*L+E*G+S*le+v*de,r[10]=y*B+E*J+S*q+v*ue,r[14]=y*w+E*$+S*te+v*Pe,r[3]=_*N+A*D+b*se+O*ee,r[7]=_*L+A*G+b*le+O*de,r[11]=_*B+A*J+b*q+O*ue,r[15]=_*w+A*$+b*te+O*Pe,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],a=e[8],r=e[12],s=e[1],o=e[5],c=e[9],h=e[13],f=e[2],d=e[6],m=e[10],g=e[14],y=e[3],E=e[7],S=e[11],v=e[15];return y*(+r*c*d-a*h*d-r*o*m+i*h*m+a*o*g-i*c*g)+E*(+t*c*g-t*h*m+r*s*m-a*s*g+a*h*f-r*c*f)+S*(+t*h*d-t*o*g-r*s*d+i*s*g+r*o*f-i*h*f)+v*(-a*o*f-t*c*d+t*o*m+a*s*d-i*s*m+i*c*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 a=this.elements;return e.isVector3?(a[12]=e.x,a[13]=e.y,a[14]=e.z):(a[12]=e,a[13]=t,a[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],a=e[2],r=e[3],s=e[4],o=e[5],c=e[6],h=e[7],f=e[8],d=e[9],m=e[10],g=e[11],y=e[12],E=e[13],S=e[14],v=e[15],_=d*S*h-E*m*h+E*c*g-o*S*g-d*c*v+o*m*v,A=y*m*h-f*S*h-y*c*g+s*S*g+f*c*v-s*m*v,b=f*E*h-y*d*h+y*o*g-s*E*g-f*o*v+s*d*v,O=y*d*c-f*E*c-y*o*m+s*E*m+f*o*S-s*d*S,N=t*_+i*A+a*b+r*O;if(N===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/N;return e[0]=_*L,e[1]=(E*m*r-d*S*r-E*a*g+i*S*g+d*a*v-i*m*v)*L,e[2]=(o*S*r-E*c*r+E*a*h-i*S*h-o*a*v+i*c*v)*L,e[3]=(d*c*r-o*m*r-d*a*h+i*m*h+o*a*g-i*c*g)*L,e[4]=A*L,e[5]=(f*S*r-y*m*r+y*a*g-t*S*g-f*a*v+t*m*v)*L,e[6]=(y*c*r-s*S*r-y*a*h+t*S*h+s*a*v-t*c*v)*L,e[7]=(s*m*r-f*c*r+f*a*h-t*m*h-s*a*g+t*c*g)*L,e[8]=b*L,e[9]=(y*d*r-f*E*r-y*i*g+t*E*g+f*i*v-t*d*v)*L,e[10]=(s*E*r-y*o*r+y*i*h-t*E*h-s*i*v+t*o*v)*L,e[11]=(f*o*r-s*d*r-f*i*h+t*d*h+s*i*g-t*o*g)*L,e[12]=O*L,e[13]=(f*E*a-y*d*a+y*i*m-t*E*m-f*i*S+t*d*S)*L,e[14]=(y*o*a-s*E*a-y*i*c+t*E*c+s*i*S-t*o*S)*L,e[15]=(s*d*a-f*o*a+f*i*c-t*d*c-s*i*m+t*o*m)*L,this}scale(e){const t=this.elements,i=e.x,a=e.y,r=e.z;return t[0]*=i,t[4]*=a,t[8]*=r,t[1]*=i,t[5]*=a,t[9]*=r,t[2]*=i,t[6]*=a,t[10]*=r,t[3]*=i,t[7]*=a,t[11]*=r,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],a=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,a))}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),a=Math.sin(t),r=1-i,s=e.x,o=e.y,c=e.z,h=r*s,f=r*o;return this.set(h*s+i,h*o-a*c,h*c+a*o,0,h*o+a*c,f*o+i,f*c-a*s,0,h*c-a*o,f*c+a*s,r*c*c+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,a,r,s){return this.set(1,i,r,0,e,1,s,0,t,a,1,0,0,0,0,1),this}compose(e,t,i){const a=this.elements,r=t._x,s=t._y,o=t._z,c=t._w,h=r+r,f=s+s,d=o+o,m=r*h,g=r*f,y=r*d,E=s*f,S=s*d,v=o*d,_=c*h,A=c*f,b=c*d,O=i.x,N=i.y,L=i.z;return a[0]=(1-(E+v))*O,a[1]=(g+b)*O,a[2]=(y-A)*O,a[3]=0,a[4]=(g-b)*N,a[5]=(1-(m+v))*N,a[6]=(S+_)*N,a[7]=0,a[8]=(y+A)*L,a[9]=(S-_)*L,a[10]=(1-(m+E))*L,a[11]=0,a[12]=e.x,a[13]=e.y,a[14]=e.z,a[15]=1,this}decompose(e,t,i){const a=this.elements;let r=Yh.set(a[0],a[1],a[2]).length();const s=Yh.set(a[4],a[5],a[6]).length(),o=Yh.set(a[8],a[9],a[10]).length();this.determinant()<0&&(r=-r),e.x=a[12],e.y=a[13],e.z=a[14],vs.copy(this);const h=1/r,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=r,i.y=s,i.z=o,this}makePerspective(e,t,i,a,r,s,o=Er,c=!1){const h=this.elements,f=2*r/(t-e),d=2*r/(i-a),m=(t+e)/(t-e),g=(i+a)/(i-a);let y,E;if(c)y=r/(s-r),E=s*r/(s-r);else if(o===Er)y=-(s+r)/(s-r),E=-2*s*r/(s-r);else if(o===gd)y=-s/(s-r),E=-s*r/(s-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return h[0]=f,h[4]=0,h[8]=m,h[12]=0,h[1]=0,h[5]=d,h[9]=g,h[13]=0,h[2]=0,h[6]=0,h[10]=y,h[14]=E,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,i,a,r,s,o=Er,c=!1){const h=this.elements,f=2/(t-e),d=2/(i-a),m=-(t+e)/(t-e),g=-(i+a)/(i-a);let y,E;if(c)y=1/(s-r),E=s/(s-r);else if(o===Er)y=-2/(s-r),E=-(s+r)/(s-r);else if(o===gd)y=-1/(s-r),E=-r/(s-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return h[0]=f,h[4]=0,h[8]=0,h[12]=m,h[1]=0,h[5]=d,h[9]=0,h[13]=g,h[2]=0,h[6]=0,h[10]=y,h[14]=E,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let a=0;a<16;a++)if(t[a]!==i[a])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 Yh=new H,vs=new lt,TH=new H(0,0,0),bH=new H(1,1,1),Ol=new H,jg=new H,mr=new H,Bw=new lt,Uw=new Yi;class Dr{constructor(e=0,t=0,i=0,a=Dr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=a}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,a=this._order){return this._x=e,this._y=t,this._z=i,this._order=a,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 a=e.elements,r=a[0],s=a[4],o=a[8],c=a[1],h=a[5],f=a[9],d=a[2],m=a[6],g=a[10];switch(t){case"XYZ":this._y=Math.asin(Gt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,g),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(m,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Gt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Gt(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-d,g),this._z=Math.atan2(-s,h)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Gt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-s,h));break;case"YZX":this._z=Math.asin(Gt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-f,h),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-Gt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(m,h),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-f,g),this._y=0);break;default:_t("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Bw.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Bw,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Uw.setFromEuler(this),this.setFromQuaternion(Uw,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}}Dr.DEFAULT_ORDER="XYZ";class yd{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 MH=0;const Lw=new H,qh=new Yi,bo=new lt,Kg=new H,wp=new H,CH=new H,RH=new Yi,Pw=new H(1,0,0),Fw=new H(0,1,0),Hw=new H(0,0,1),zw={type:"added"},wH={type:"removed"},Zh={type:"childadded",child:null},AA={type:"childremoved",child:null};class fn extends tr{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:MH++}),this.uuid=Cr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=fn.DEFAULT_UP.clone();const e=new H,t=new Dr,i=new Yi,a=new H(1,1,1);function r(){i.setFromEuler(t,!1)}function s(){t.setFromQuaternion(i,void 0,!1)}t._onChange(r),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:a},modelViewMatrix:{value:new lt},normalMatrix:{value:new kt}}),this.matrix=new lt,this.matrixWorld=new lt,this.matrixAutoUpdate=fn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=fn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new yd,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 qh.setFromAxisAngle(e,t),this.quaternion.multiply(qh),this}rotateOnWorldAxis(e,t){return qh.setFromAxisAngle(e,t),this.quaternion.premultiply(qh),this}rotateX(e){return this.rotateOnAxis(Pw,e)}rotateY(e){return this.rotateOnAxis(Fw,e)}rotateZ(e){return this.rotateOnAxis(Hw,e)}translateOnAxis(e,t){return Lw.copy(e).applyQuaternion(this.quaternion),this.position.add(Lw.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Pw,e)}translateY(e){return this.translateOnAxis(Fw,e)}translateZ(e){return this.translateOnAxis(Hw,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(bo.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Kg.copy(e):Kg.set(e,t,i);const a=this.parent;this.updateWorldMatrix(!0,!1),wp.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?bo.lookAt(wp,Kg,this.up):bo.lookAt(Kg,wp,this.up),this.quaternion.setFromRotationMatrix(bo),a&&(bo.extractRotation(a.matrixWorld),qh.setFromRotationMatrix(bo),this.quaternion.premultiply(qh.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(qt("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(zw),Zh.child=e,this.dispatchEvent(Zh),Zh.child=null):qt("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(wH),AA.child=e,this.dispatchEvent(AA),AA.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),bo.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),bo.multiply(e.parent.matrixWorld)),e.applyMatrix4(bo),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(zw),Zh.child=e,this.dispatchEvent(Zh),Zh.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,a=this.children.length;i<a;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 a=this.children;for(let r=0,s=a.length;r<s;r++)a[r].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(wp,e,CH),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wp,RH,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,a=t.length;i<a;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,a=t.length;i<a;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,a=t.length;i<a;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 a=this.children;for(let r=0,s=a.length;r<s;r++)a[r].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 a={};a.uuid=this.uuid,a.type=this.type,this.name!==""&&(a.name=this.name),this.castShadow===!0&&(a.castShadow=!0),this.receiveShadow===!0&&(a.receiveShadow=!0),this.visible===!1&&(a.visible=!1),this.frustumCulled===!1&&(a.frustumCulled=!1),this.renderOrder!==0&&(a.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(a.userData=this.userData),a.layers=this.layers.mask,a.matrix=this.matrix.toArray(),a.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(a.matrixAutoUpdate=!1),this.isInstancedMesh&&(a.type="InstancedMesh",a.count=this.count,a.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(a.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(a.type="BatchedMesh",a.perObjectFrustumCulled=this.perObjectFrustumCulled,a.sortObjects=this.sortObjects,a.drawRanges=this._drawRanges,a.reservedRanges=this._reservedRanges,a.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),a.instanceInfo=this._instanceInfo.map(o=>({...o})),a.availableInstanceIds=this._availableInstanceIds.slice(),a.availableGeometryIds=this._availableGeometryIds.slice(),a.nextIndexStart=this._nextIndexStart,a.nextVertexStart=this._nextVertexStart,a.geometryCount=this._geometryCount,a.maxInstanceCount=this._maxInstanceCount,a.maxVertexCount=this._maxVertexCount,a.maxIndexCount=this._maxIndexCount,a.geometryInitialized=this._geometryInitialized,a.matricesTexture=this._matricesTexture.toJSON(e),a.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(a.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(a.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(a.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?a.background=this.background.toJSON():this.background.isTexture&&(a.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(a.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){a.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let h=0,f=c.length;h<f;h++){const d=c[h];r(e.shapes,d)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(a.bindMode=this.bindMode,a.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),a.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,h=this.material.length;c<h;c++)o.push(r(e.materials,this.material[c]));a.material=o}else a.material=r(e.materials,this.material);if(this.children.length>0){a.children=[];for(let o=0;o<this.children.length;o++)a.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){a.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];a.animations.push(r(e.animations,c))}}if(t){const o=s(e.geometries),c=s(e.materials),h=s(e.textures),f=s(e.images),d=s(e.shapes),m=s(e.skeletons),g=s(e.animations),y=s(e.nodes);o.length>0&&(i.geometries=o),c.length>0&&(i.materials=c),h.length>0&&(i.textures=h),f.length>0&&(i.images=f),d.length>0&&(i.shapes=d),m.length>0&&(i.skeletons=m),g.length>0&&(i.animations=g),y.length>0&&(i.nodes=y)}return i.object=a,i;function s(o){const c=[];for(const h in o){const f=o[h];delete f.metadata,c.push(f)}return c}}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 a=e.children[i];this.add(a.clone())}return this}}fn.DEFAULT_UP=new H(0,1,0);fn.DEFAULT_MATRIX_AUTO_UPDATE=!0;fn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const xs=new H,Mo=new H,EA=new H,Co=new H,jh=new H,Kh=new H,Gw=new H,TA=new H,bA=new H,MA=new H,CA=new Yt,RA=new Yt,wA=new Yt;class Ja{constructor(e=new H,t=new H,i=new H){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,a){a.subVectors(i,t),xs.subVectors(e,t),a.cross(xs);const r=a.lengthSq();return r>0?a.multiplyScalar(1/Math.sqrt(r)):a.set(0,0,0)}static getBarycoord(e,t,i,a,r){xs.subVectors(a,t),Mo.subVectors(i,t),EA.subVectors(e,t);const s=xs.dot(xs),o=xs.dot(Mo),c=xs.dot(EA),h=Mo.dot(Mo),f=Mo.dot(EA),d=s*h-o*o;if(d===0)return r.set(0,0,0),null;const m=1/d,g=(h*c-o*f)*m,y=(s*f-o*c)*m;return r.set(1-g-y,y,g)}static containsPoint(e,t,i,a){return this.getBarycoord(e,t,i,a,Co)===null?!1:Co.x>=0&&Co.y>=0&&Co.x+Co.y<=1}static getInterpolation(e,t,i,a,r,s,o,c){return this.getBarycoord(e,t,i,a,Co)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Co.x),c.addScaledVector(s,Co.y),c.addScaledVector(o,Co.z),c)}static getInterpolatedAttribute(e,t,i,a,r,s){return CA.setScalar(0),RA.setScalar(0),wA.setScalar(0),CA.fromBufferAttribute(e,t),RA.fromBufferAttribute(e,i),wA.fromBufferAttribute(e,a),s.setScalar(0),s.addScaledVector(CA,r.x),s.addScaledVector(RA,r.y),s.addScaledVector(wA,r.z),s}static isFrontFacing(e,t,i,a){return xs.subVectors(i,t),Mo.subVectors(e,t),xs.cross(Mo).dot(a)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,a){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[a]),this}setFromAttributeAndIndices(e,t,i,a){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,a),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 xs.subVectors(this.c,this.b),Mo.subVectors(this.a,this.b),xs.cross(Mo).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ja.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ja.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,a,r){return Ja.getInterpolation(e,this.a,this.b,this.c,t,i,a,r)}containsPoint(e){return Ja.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ja.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,a=this.b,r=this.c;let s,o;jh.subVectors(a,i),Kh.subVectors(r,i),TA.subVectors(e,i);const c=jh.dot(TA),h=Kh.dot(TA);if(c<=0&&h<=0)return t.copy(i);bA.subVectors(e,a);const f=jh.dot(bA),d=Kh.dot(bA);if(f>=0&&d<=f)return t.copy(a);const m=c*d-f*h;if(m<=0&&c>=0&&f<=0)return s=c/(c-f),t.copy(i).addScaledVector(jh,s);MA.subVectors(e,r);const g=jh.dot(MA),y=Kh.dot(MA);if(y>=0&&g<=y)return t.copy(r);const E=g*h-c*y;if(E<=0&&h>=0&&y<=0)return o=h/(h-y),t.copy(i).addScaledVector(Kh,o);const S=f*y-g*d;if(S<=0&&d-f>=0&&g-y>=0)return Gw.subVectors(r,a),o=(d-f)/(d-f+(g-y)),t.copy(a).addScaledVector(Gw,o);const v=1/(S+E+m);return s=E*v,o=m*v,t.copy(i).addScaledVector(jh,s).addScaledVector(Kh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const rB={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},Jg={h:0,s:0,l:0};function DA(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 dt{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 a=e;a&&a.isColor?this.copy(a):typeof a=="number"?this.setHex(a):typeof a=="string"&&this.setStyle(a)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Kn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,gn.colorSpaceToWorking(this,t),this}setRGB(e,t,i,a=gn.workingColorSpace){return this.r=e,this.g=t,this.b=i,gn.colorSpaceToWorking(this,a),this}setHSL(e,t,i,a=gn.workingColorSpace){if(e=U3(e,1),t=Gt(t,0,1),i=Gt(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,s=2*i-r;this.r=DA(s,r,e+1/3),this.g=DA(s,r,e),this.b=DA(s,r,e-1/3)}return gn.colorSpaceToWorking(this,a),this}setStyle(e,t=Kn){function i(r){r!==void 0&&parseFloat(r)<1&&_t("Color: Alpha component of "+e+" will be ignored.")}let a;if(a=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const s=a[1],o=a[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:_t("Color: Unknown color model "+e)}}else if(a=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=a[1],s=r.length;if(s===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(s===6)return this.setHex(parseInt(r,16),t);_t("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Kn){const i=rB[e.toLowerCase()];return i!==void 0?this.setHex(i,t):_t("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=Jo(e.r),this.g=Jo(e.g),this.b=Jo(e.b),this}copyLinearToSRGB(e){return this.r=Jf(e.r),this.g=Jf(e.g),this.b=Jf(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Kn){return gn.workingToColorSpace(Aa.copy(this),e),Math.round(Gt(Aa.r*255,0,255))*65536+Math.round(Gt(Aa.g*255,0,255))*256+Math.round(Gt(Aa.b*255,0,255))}getHexString(e=Kn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=gn.workingColorSpace){gn.workingToColorSpace(Aa.copy(this),t);const i=Aa.r,a=Aa.g,r=Aa.b,s=Math.max(i,a,r),o=Math.min(i,a,r);let c,h;const f=(o+s)/2;if(o===s)c=0,h=0;else{const d=s-o;switch(h=f<=.5?d/(s+o):d/(2-s-o),s){case i:c=(a-r)/d+(a<r?6:0);break;case a:c=(r-i)/d+2;break;case r:c=(i-a)/d+4;break}c/=6}return e.h=c,e.s=h,e.l=f,e}getRGB(e,t=gn.workingColorSpace){return gn.workingToColorSpace(Aa.copy(this),t),e.r=Aa.r,e.g=Aa.g,e.b=Aa.b,e}getStyle(e=Kn){gn.workingToColorSpace(Aa.copy(this),e);const t=Aa.r,i=Aa.g,a=Aa.b;return e!==Kn?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${a.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(a*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(Jg);const i=Cm(Il.h,Jg.h,t),a=Cm(Il.s,Jg.s,t),r=Cm(Il.l,Jg.l,t);return this.setHSL(i,a,r),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,a=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*a,this.g=r[1]*t+r[4]*i+r[7]*a,this.b=r[2]*t+r[5]*i+r[8]*a,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 Aa=new dt;dt.NAMES=rB;let DH=0;class ri extends tr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:DH++}),this.uuid=Cr(),this.name="",this.type="Material",this.blending=wu,this.side=os,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=X1,this.blendDst=W1,this.blendEquation=js,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new dt(0,0,0),this.blendAlpha=0,this.depthFunc=zu,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=DE,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=uu,this.stencilZFail=uu,this.stencilZPass=uu,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){_t(`Material: parameter '${t}' has value of undefined.`);continue}const a=this[t];if(a===void 0){_t(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}a&&a.isColor?a.set(i):a&&a.isVector3&&i&&i.isVector3?a.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!==wu&&(i.blending=this.blending),this.side!==os&&(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!==X1&&(i.blendSrc=this.blendSrc),this.blendDst!==W1&&(i.blendDst=this.blendDst),this.blendEquation!==js&&(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!==zu&&(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!==DE&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==uu&&(i.stencilFail=this.stencilFail),this.stencilZFail!==uu&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==uu&&(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 a(r){const s=[];for(const o in r){const c=r[o];delete c.metadata,s.push(c)}return s}if(t){const r=a(e.textures),s=a(e.images);r.length>0&&(i.textures=r),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 a=t.length;i=new Array(a);for(let r=0;r!==a;++r)i[r]=t[r].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 Qa extends ri{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new dt(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 Dr,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 Go=NH();function NH(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),a=new Uint32Array(512);for(let c=0;c<256;++c){const h=c-127;h<-27?(i[c]=0,i[c|256]=32768,a[c]=24,a[c|256]=24):h<-14?(i[c]=1024>>-h-14,i[c|256]=1024>>-h-14|32768,a[c]=-h-1,a[c|256]=-h-1):h<=15?(i[c]=h+15<<10,i[c|256]=h+15<<10|32768,a[c]=13,a[c|256]=13):h<128?(i[c]=31744,i[c|256]=64512,a[c]=24,a[c|256]=24):(i[c]=31744,i[c|256]=64512,a[c]=13,a[c|256]=13)}const r=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let h=c<<13,f=0;for(;!(h&8388608);)h<<=1,f-=8388608;h&=-8388609,f+=947912704,r[c]=h|f}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)s[c]=c<<23;s[31]=1199570944,s[32]=2147483648;for(let c=33;c<63;++c)s[c]=2147483648+(c-32<<23);s[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:a,mantissaTable:r,exponentTable:s,offsetTable:o}}function qa(n){Math.abs(n)>65504&&_t("DataUtils.toHalfFloat(): Value out of range."),n=Gt(n,-65504,65504),Go.floatView[0]=n;const e=Go.uint32View[0],t=e>>23&511;return Go.baseTable[t]+((e&8388607)>>Go.shiftTable[t])}function $p(n){const e=n>>10;return Go.uint32View[0]=Go.mantissaTable[Go.offsetTable[e]+(n&1023)]+Go.exponentTable[e],Go.floatView[0]}class Zo{static toHalfFloat(e){return qa(e)}static fromHalfFloat(e){return $p(e)}}const Ui=new H,Qg=new Ee;let OH=0;class pn{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:OH++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=i0,this.updateRanges=[],this.gpuType=Sn,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 a=0,r=this.itemSize;a<r;a++)this.array[e+a]=t.array[i+a];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++)Qg.fromBufferAttribute(this,t),Qg.applyMatrix3(e),this.setXY(t,Qg.x,Qg.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.applyMatrix3(e),this.setXYZ(t,Ui.x,Ui.y,Ui.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.applyMatrix4(e),this.setXYZ(t,Ui.x,Ui.y,Ui.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.applyNormalMatrix(e),this.setXYZ(t,Ui.x,Ui.y,Ui.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.transformDirection(e),this.setXYZ(t,Ui.x,Ui.y,Ui.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=Ba(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=Ba(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=Ba(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=Ba(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=Ba(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,a){return e*=this.itemSize,this.normalized&&(t=Jt(t,this.array),i=Jt(i,this.array),a=Jt(a,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=a,this}setXYZW(e,t,i,a,r){return e*=this.itemSize,this.normalized&&(t=Jt(t,this.array),i=Jt(i,this.array),a=Jt(a,this.array),r=Jt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=a,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){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!==i0&&(e.usage=this.usage),e}}class IH extends pn{constructor(e,t,i){super(new Int8Array(e),t,i)}}class BH extends pn{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class UH extends pn{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class LH extends pn{constructor(e,t,i){super(new Int16Array(e),t,i)}}class F3 extends pn{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class PH extends pn{constructor(e,t,i){super(new Int32Array(e),t,i)}}class H3 extends pn{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class FH extends pn{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=$p(this.array[e*this.itemSize]);return this.normalized&&(t=Ba(t,this.array)),t}setX(e,t){return this.normalized&&(t=Jt(t,this.array)),this.array[e*this.itemSize]=qa(t),this}getY(e){let t=$p(this.array[e*this.itemSize+1]);return this.normalized&&(t=Ba(t,this.array)),t}setY(e,t){return this.normalized&&(t=Jt(t,this.array)),this.array[e*this.itemSize+1]=qa(t),this}getZ(e){let t=$p(this.array[e*this.itemSize+2]);return this.normalized&&(t=Ba(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Jt(t,this.array)),this.array[e*this.itemSize+2]=qa(t),this}getW(e){let t=$p(this.array[e*this.itemSize+3]);return this.normalized&&(t=Ba(t,this.array)),t}setW(e,t){return this.normalized&&(t=Jt(t,this.array)),this.array[e*this.itemSize+3]=qa(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]=qa(t),this.array[e+1]=qa(i),this}setXYZ(e,t,i,a){return e*=this.itemSize,this.normalized&&(t=Jt(t,this.array),i=Jt(i,this.array),a=Jt(a,this.array)),this.array[e+0]=qa(t),this.array[e+1]=qa(i),this.array[e+2]=qa(a),this}setXYZW(e,t,i,a,r){return e*=this.itemSize,this.normalized&&(t=Jt(t,this.array),i=Jt(i,this.array),a=Jt(a,this.array),r=Jt(r,this.array)),this.array[e+0]=qa(t),this.array[e+1]=qa(i),this.array[e+2]=qa(a),this.array[e+3]=qa(r),this}}class Dt extends pn{constructor(e,t,i){super(new Float32Array(e),t,i)}}let HH=0;const kr=new lt,NA=new fn,Jh=new H,gr=new sa,Dp=new sa,$i=new H;class Xt extends tr{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:HH++}),this.uuid=Cr(),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(tB(e)?H3:F3)(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 r=new kt().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const a=this.attributes.tangent;return a!==void 0&&(a.transformDirection(e),a.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return kr.makeRotationFromQuaternion(e),this.applyMatrix4(kr),this}rotateX(e){return kr.makeRotationX(e),this.applyMatrix4(kr),this}rotateY(e){return kr.makeRotationY(e),this.applyMatrix4(kr),this}rotateZ(e){return kr.makeRotationZ(e),this.applyMatrix4(kr),this}translate(e,t,i){return kr.makeTranslation(e,t,i),this.applyMatrix4(kr),this}scale(e,t,i){return kr.makeScale(e,t,i),this.applyMatrix4(kr),this}lookAt(e){return NA.lookAt(e),NA.updateMatrix(),this.applyMatrix4(NA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Jh).negate(),this.translate(Jh.x,Jh.y,Jh.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let a=0,r=e.length;a<r;a++){const s=e[a];i.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Dt(i,3))}else{const i=Math.min(e.length,t.count);for(let a=0;a<i;a++){const r=e[a];t.setXYZ(a,r.x,r.y,r.z||0)}e.length>t.count&&_t("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 sa);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new H(-1/0,-1/0,-1/0),new H(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,a=t.length;i<a;i++){const r=t[i];gr.setFromBufferAttribute(r),this.morphTargetsRelative?($i.addVectors(this.boundingBox.min,gr.min),this.boundingBox.expandByPoint($i),$i.addVectors(this.boundingBox.max,gr.max),this.boundingBox.expandByPoint($i)):(this.boundingBox.expandByPoint(gr.min),this.boundingBox.expandByPoint(gr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&qt('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 zi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new H,1/0);return}if(e){const i=this.boundingSphere.center;if(gr.setFromBufferAttribute(e),t)for(let r=0,s=t.length;r<s;r++){const o=t[r];Dp.setFromBufferAttribute(o),this.morphTargetsRelative?($i.addVectors(gr.min,Dp.min),gr.expandByPoint($i),$i.addVectors(gr.max,Dp.max),gr.expandByPoint($i)):(gr.expandByPoint(Dp.min),gr.expandByPoint(Dp.max))}gr.getCenter(i);let a=0;for(let r=0,s=e.count;r<s;r++)$i.fromBufferAttribute(e,r),a=Math.max(a,i.distanceToSquared($i));if(t)for(let r=0,s=t.length;r<s;r++){const o=t[r],c=this.morphTargetsRelative;for(let h=0,f=o.count;h<f;h++)$i.fromBufferAttribute(o,h),c&&(Jh.fromBufferAttribute(e,h),$i.add(Jh)),a=Math.max(a,i.distanceToSquared($i))}this.boundingSphere.radius=Math.sqrt(a),isNaN(this.boundingSphere.radius)&&qt('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){qt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,a=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new pn(new Float32Array(4*i.count),4));const s=this.getAttribute("tangent"),o=[],c=[];for(let B=0;B<i.count;B++)o[B]=new H,c[B]=new H;const h=new H,f=new H,d=new H,m=new Ee,g=new Ee,y=new Ee,E=new H,S=new H;function v(B,w,D){h.fromBufferAttribute(i,B),f.fromBufferAttribute(i,w),d.fromBufferAttribute(i,D),m.fromBufferAttribute(r,B),g.fromBufferAttribute(r,w),y.fromBufferAttribute(r,D),f.sub(h),d.sub(h),g.sub(m),y.sub(m);const G=1/(g.x*y.y-y.x*g.y);isFinite(G)&&(E.copy(f).multiplyScalar(y.y).addScaledVector(d,-g.y).multiplyScalar(G),S.copy(d).multiplyScalar(g.x).addScaledVector(f,-y.x).multiplyScalar(G),o[B].add(E),o[w].add(E),o[D].add(E),c[B].add(S),c[w].add(S),c[D].add(S))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let B=0,w=_.length;B<w;++B){const D=_[B],G=D.start,J=D.count;for(let $=G,se=G+J;$<se;$+=3)v(e.getX($+0),e.getX($+1),e.getX($+2))}const A=new H,b=new H,O=new H,N=new H;function L(B){O.fromBufferAttribute(a,B),N.copy(O);const w=o[B];A.copy(w),A.sub(O.multiplyScalar(O.dot(w))).normalize(),b.crossVectors(N,w);const G=b.dot(c[B])<0?-1:1;s.setXYZW(B,A.x,A.y,A.z,G)}for(let B=0,w=_.length;B<w;++B){const D=_[B],G=D.start,J=D.count;for(let $=G,se=G+J;$<se;$+=3)L(e.getX($+0)),L(e.getX($+1)),L(e.getX($+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 pn(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let m=0,g=i.count;m<g;m++)i.setXYZ(m,0,0,0);const a=new H,r=new H,s=new H,o=new H,c=new H,h=new H,f=new H,d=new H;if(e)for(let m=0,g=e.count;m<g;m+=3){const y=e.getX(m+0),E=e.getX(m+1),S=e.getX(m+2);a.fromBufferAttribute(t,y),r.fromBufferAttribute(t,E),s.fromBufferAttribute(t,S),f.subVectors(s,r),d.subVectors(a,r),f.cross(d),o.fromBufferAttribute(i,y),c.fromBufferAttribute(i,E),h.fromBufferAttribute(i,S),o.add(f),c.add(f),h.add(f),i.setXYZ(y,o.x,o.y,o.z),i.setXYZ(E,c.x,c.y,c.z),i.setXYZ(S,h.x,h.y,h.z)}else for(let m=0,g=t.count;m<g;m+=3)a.fromBufferAttribute(t,m+0),r.fromBufferAttribute(t,m+1),s.fromBufferAttribute(t,m+2),f.subVectors(s,r),d.subVectors(a,r),f.cross(d),i.setXYZ(m+0,f.x,f.y,f.z),i.setXYZ(m+1,f.x,f.y,f.z),i.setXYZ(m+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++)$i.fromBufferAttribute(e,t),$i.normalize(),e.setXYZ(t,$i.x,$i.y,$i.z)}toNonIndexed(){function e(o,c){const h=o.array,f=o.itemSize,d=o.normalized,m=new h.constructor(c.length*f);let g=0,y=0;for(let E=0,S=c.length;E<S;E++){o.isInterleavedBufferAttribute?g=c[E]*o.data.stride+o.offset:g=c[E]*f;for(let v=0;v<f;v++)m[y++]=h[g++]}return new pn(m,f,d)}if(this.index===null)return _t("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Xt,i=this.index.array,a=this.attributes;for(const o in a){const c=a[o],h=e(c,i);t.setAttribute(o,h)}const r=this.morphAttributes;for(const o in r){const c=[],h=r[o];for(let f=0,d=h.length;f<d;f++){const m=h[f],g=e(m,i);c.push(g)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;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 c=this.parameters;for(const h in c)c[h]!==void 0&&(e[h]=c[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 c in i){const h=i[c];e.data.attributes[c]=h.toJSON(e.data)}const a={};let r=!1;for(const c in this.morphAttributes){const h=this.morphAttributes[c],f=[];for(let d=0,m=h.length;d<m;d++){const g=h[d];f.push(g.toJSON(e.data))}f.length>0&&(a[c]=f,r=!0)}r&&(e.data.morphAttributes=a,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 a=e.attributes;for(const h in a){const f=a[h];this.setAttribute(h,f.clone(t))}const r=e.morphAttributes;for(const h in r){const f=[],d=r[h];for(let m=0,g=d.length;m<g;m++)f.push(d[m].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 c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Vw=new lt,Yc=new oh,$g=new zi,kw=new H,ev=new H,tv=new H,nv=new H,OA=new H,iv=new H,Xw=new H,av=new H;class Xn extends fn{constructor(e=new Xt,t=new Qa){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 a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=a.length;r<s;r++){const o=a[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const i=this.geometry,a=i.attributes.position,r=i.morphAttributes.position,s=i.morphTargetsRelative;t.fromBufferAttribute(a,e);const o=this.morphTargetInfluences;if(r&&o){iv.set(0,0,0);for(let c=0,h=r.length;c<h;c++){const f=o[c],d=r[c];f!==0&&(OA.fromBufferAttribute(d,e),s?iv.addScaledVector(OA,f):iv.addScaledVector(OA.sub(t),f))}t.add(iv)}return t}raycast(e,t){const i=this.geometry,a=this.material,r=this.matrixWorld;a!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),$g.copy(i.boundingSphere),$g.applyMatrix4(r),Yc.copy(e.ray).recast(e.near),!($g.containsPoint(Yc.origin)===!1&&(Yc.intersectSphere($g,kw)===null||Yc.origin.distanceToSquared(kw)>(e.far-e.near)**2))&&(Vw.copy(r).invert(),Yc.copy(e.ray).applyMatrix4(Vw),!(i.boundingBox!==null&&Yc.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yc)))}_computeIntersections(e,t,i){let a;const r=this.geometry,s=this.material,o=r.index,c=r.attributes.position,h=r.attributes.uv,f=r.attributes.uv1,d=r.attributes.normal,m=r.groups,g=r.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,E=m.length;y<E;y++){const S=m[y],v=s[S.materialIndex],_=Math.max(S.start,g.start),A=Math.min(o.count,Math.min(S.start+S.count,g.start+g.count));for(let b=_,O=A;b<O;b+=3){const N=o.getX(b),L=o.getX(b+1),B=o.getX(b+2);a=rv(this,v,e,i,h,f,d,N,L,B),a&&(a.faceIndex=Math.floor(b/3),a.face.materialIndex=S.materialIndex,t.push(a))}}else{const y=Math.max(0,g.start),E=Math.min(o.count,g.start+g.count);for(let S=y,v=E;S<v;S+=3){const _=o.getX(S),A=o.getX(S+1),b=o.getX(S+2);a=rv(this,s,e,i,h,f,d,_,A,b),a&&(a.faceIndex=Math.floor(S/3),t.push(a))}}else if(c!==void 0)if(Array.isArray(s))for(let y=0,E=m.length;y<E;y++){const S=m[y],v=s[S.materialIndex],_=Math.max(S.start,g.start),A=Math.min(c.count,Math.min(S.start+S.count,g.start+g.count));for(let b=_,O=A;b<O;b+=3){const N=b,L=b+1,B=b+2;a=rv(this,v,e,i,h,f,d,N,L,B),a&&(a.faceIndex=Math.floor(b/3),a.face.materialIndex=S.materialIndex,t.push(a))}}else{const y=Math.max(0,g.start),E=Math.min(c.count,g.start+g.count);for(let S=y,v=E;S<v;S+=3){const _=S,A=S+1,b=S+2;a=rv(this,s,e,i,h,f,d,_,A,b),a&&(a.faceIndex=Math.floor(S/3),t.push(a))}}}}function zH(n,e,t,i,a,r,s,o){let c;if(e.side===Wi?c=i.intersectTriangle(s,r,a,!0,o):c=i.intersectTriangle(a,r,s,e.side===os,o),c===null)return null;av.copy(o),av.applyMatrix4(n.matrixWorld);const h=t.ray.origin.distanceTo(av);return h<t.near||h>t.far?null:{distance:h,point:av.clone(),object:n}}function rv(n,e,t,i,a,r,s,o,c,h){n.getVertexPosition(o,ev),n.getVertexPosition(c,tv),n.getVertexPosition(h,nv);const f=zH(n,e,t,i,ev,tv,nv,Xw);if(f){const d=new H;Ja.getBarycoord(Xw,ev,tv,nv,d),a&&(f.uv=Ja.getInterpolatedAttribute(a,o,c,h,d,new Ee)),r&&(f.uv1=Ja.getInterpolatedAttribute(r,o,c,h,d,new Ee)),s&&(f.normal=Ja.getInterpolatedAttribute(s,o,c,h,d,new H),f.normal.dot(i.direction)>0&&f.normal.multiplyScalar(-1));const m={a:o,b:c,c:h,normal:new H,materialIndex:0};Ja.getNormal(ev,tv,nv,m.normal),f.face=m,f.barycoord=d}return f}class lh extends Xt{constructor(e=1,t=1,i=1,a=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:a,heightSegments:r,depthSegments:s};const o=this;a=Math.floor(a),r=Math.floor(r),s=Math.floor(s);const c=[],h=[],f=[],d=[];let m=0,g=0;y("z","y","x",-1,-1,i,t,e,s,r,0),y("z","y","x",1,-1,i,t,-e,s,r,1),y("x","z","y",1,1,e,i,t,a,s,2),y("x","z","y",1,-1,e,i,-t,a,s,3),y("x","y","z",1,-1,e,t,i,a,r,4),y("x","y","z",-1,-1,e,t,-i,a,r,5),this.setIndex(c),this.setAttribute("position",new Dt(h,3)),this.setAttribute("normal",new Dt(f,3)),this.setAttribute("uv",new Dt(d,2));function y(E,S,v,_,A,b,O,N,L,B,w){const D=b/L,G=O/B,J=b/2,$=O/2,se=N/2,le=L+1,q=B+1;let te=0,ee=0;const de=new H;for(let ue=0;ue<q;ue++){const Pe=ue*G-$;for(let He=0;He<le;He++){const Ke=He*D-J;de[E]=Ke*_,de[S]=Pe*A,de[v]=se,h.push(de.x,de.y,de.z),de[E]=0,de[S]=0,de[v]=N>0?1:-1,f.push(de.x,de.y,de.z),d.push(He/L),d.push(1-ue/B),te+=1}}for(let ue=0;ue<B;ue++)for(let Pe=0;Pe<L;Pe++){const He=m+Pe+le*ue,Ke=m+Pe+le*(ue+1),nt=m+(Pe+1)+le*(ue+1),xt=m+(Pe+1)+le*ue;c.push(He,Ke,xt),c.push(Ke,nt,xt),ee+=6}o.addGroup(g,ee,w),g+=ee,m+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new lh(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function _d(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const a=n[t][i];a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)?a.isRenderTargetTexture?(_t("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=a.clone():Array.isArray(a)?e[t][i]=a.slice():e[t][i]=a}}return e}function Na(n){const e={};for(let t=0;t<n.length;t++){const i=_d(n[t]);for(const a in i)e[a]=i[a]}return e}function GH(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function sB(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:gn.workingColorSpace}const oB={clone:_d,merge:Na};var VH=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,kH=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class Di extends ri{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=VH,this.fragmentShader=kH,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=_d(e.uniforms),this.uniformsGroups=GH(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 a in this.uniforms){const s=this.uniforms[a].value;s&&s.isTexture?t.uniforms[a]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[a]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[a]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[a]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[a]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[a]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[a]={type:"m4",value:s.toArray()}:t.uniforms[a]={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 a in this.extensions)this.extensions[a]===!0&&(i[a]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class so extends fn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new lt,this.projectionMatrix=new lt,this.projectionMatrixInverse=new lt,this.coordinateSystem=Er,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 Bl=new H,Ww=new Ee,Yw=new Ee;let Jn=class extends so{constructor(e=50,t=1,i=.1,a=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=a,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=xd*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Du*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return xd*2*Math.atan(Math.tan(Du*.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){Bl.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Bl.x,Bl.y).multiplyScalar(-e/Bl.z),Bl.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Bl.x,Bl.y).multiplyScalar(-e/Bl.z)}getViewSize(e,t){return this.getViewBounds(e,Ww,Yw),t.subVectors(Yw,Ww)}setViewOffset(e,t,i,a,r,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=a,this.view.width=r,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(Du*.5*this.fov)/this.zoom,i=2*t,a=this.aspect*i,r=-.5*a;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,h=s.fullHeight;r+=s.offsetX*a/c,t-=s.offsetY*i/h,a*=s.width/c,i*=s.height/h}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+a,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 Qh=-90,$h=1;class lB extends fn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const a=new Jn(Qh,$h,e,t);a.layers=this.layers,this.add(a);const r=new Jn(Qh,$h,e,t);r.layers=this.layers,this.add(r);const s=new Jn(Qh,$h,e,t);s.layers=this.layers,this.add(s);const o=new Jn(Qh,$h,e,t);o.layers=this.layers,this.add(o);const c=new Jn(Qh,$h,e,t);c.layers=this.layers,this.add(c);const h=new Jn(Qh,$h,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,a,r,s,o,c]=t;for(const h of t)this.remove(h);if(e===Er)i.up.set(0,1,0),i.lookAt(1,0,0),a.up.set(0,1,0),a.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===gd)i.up.set(0,-1,0),i.lookAt(-1,0,0),a.up.set(0,-1,0),a.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.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:a}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,s,o,c,h,f]=this.children,d=e.getRenderTarget(),m=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;const E=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,a),e.render(t,r),e.setRenderTarget(i,1,a),e.render(t,s),e.setRenderTarget(i,2,a),e.render(t,o),e.setRenderTarget(i,3,a),e.render(t,c),e.setRenderTarget(i,4,a),e.render(t,h),i.texture.generateMipmaps=E,e.setRenderTarget(i,5,a),e.render(t,f),e.setRenderTarget(d,m,g),e.xr.enabled=y,i.texture.needsPMREMUpdate=!0}}class w0 extends vn{constructor(e=[],t=no,i,a,r,s,o,c,h,f){super(e,t,i,a,r,s,o,c,h,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class z3 extends oi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},a=[i,i,i,i,i,i];this.texture=new w0(a),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 );
}
`},a=new lh(5,5,5),r=new Di({name:"CubemapFromEquirect",uniforms:_d(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Wi,blending:ga});r.uniforms.tEquirect.value=t;const s=new Xn(a,r),o=t.minFilter;return t.minFilter===Sr&&(t.minFilter=Bt),new lB(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,i=!0,a=!0){const r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,a);e.setRenderTarget(r)}}class jo extends fn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const XH={type:"move"};class h1{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new jo,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 jo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new H,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new H),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new jo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new H,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new H),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 a=null,r=null,s=null;const o=this._targetRay,c=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){s=!0;for(const E of e.hand.values()){const S=t.getJointPose(E,i),v=this._getHandJoint(h,E);S!==null&&(v.matrix.fromArray(S.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=S.radius),v.visible=S!==null}const f=h.joints["index-finger-tip"],d=h.joints["thumb-tip"],m=f.position.distanceTo(d.position),g=.02,y=.005;h.inputState.pinching&&m>g+y?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&m<=g-y&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(a=t.getPose(e.targetRaySpace,i),a===null&&r!==null&&(a=r),a!==null&&(o.matrix.fromArray(a.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,a.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(a.linearVelocity)):o.hasLinearVelocity=!1,a.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(a.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(XH)))}return o!==null&&(o.visible=a!==null),c!==null&&(c.visible=r!==null),h!==null&&(h.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new jo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class _y{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new dt(e),this.density=t}clone(){return new _y(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Sy{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new dt(e),this.near=t,this.far=i}clone(){return new Sy(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}let al=class extends fn{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 Dr,this.environmentIntensity=1,this.environmentRotation=new Dr,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 Xu{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=i0,this.updateRanges=[],this.version=0,this.uuid=Cr()}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 a=0,r=this.stride;a<r;a++)this.array[e+a]=t.array[i+a];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=Cr()),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=Cr()),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 Da=new H;class Ns{constructor(e,t,i,a=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=a}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++)Da.fromBufferAttribute(this,t),Da.applyMatrix4(e),this.setXYZ(t,Da.x,Da.y,Da.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Da.fromBufferAttribute(this,t),Da.applyNormalMatrix(e),this.setXYZ(t,Da.x,Da.y,Da.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Da.fromBufferAttribute(this,t),Da.transformDirection(e),this.setXYZ(t,Da.x,Da.y,Da.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Ba(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=Ba(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ba(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ba(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ba(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,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=Jt(t,this.array),i=Jt(i,this.array),a=Jt(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=a,this}setXYZW(e,t,i,a,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Jt(t,this.array),i=Jt(i,this.array),a=Jt(a,this.array),r=Jt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=a,this.data.array[e+3]=r,this}clone(e){if(e===void 0){r0("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const a=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[a+r])}return new pn(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 Ns(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){r0("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const a=i*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[a+r])}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 G3 extends ri{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new dt(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 ef;const Np=new H,tf=new H,nf=new H,af=new Ee,Op=new Ee,cB=new lt,sv=new H,Ip=new H,ov=new H,qw=new Ee,IA=new Ee,Zw=new Ee;class uB extends fn{constructor(e=new G3){if(super(),this.isSprite=!0,this.type="Sprite",ef===void 0){ef=new Xt;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 Xu(t,5);ef.setIndex([0,1,2,0,2,3]),ef.setAttribute("position",new Ns(i,3,0,!1)),ef.setAttribute("uv",new Ns(i,2,3,!1))}this.geometry=ef,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&qt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),tf.setFromMatrixScale(this.matrixWorld),cB.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),nf.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&tf.multiplyScalar(-nf.z);const i=this.material.rotation;let a,r;i!==0&&(r=Math.cos(i),a=Math.sin(i));const s=this.center;lv(sv.set(-.5,-.5,0),nf,s,tf,a,r),lv(Ip.set(.5,-.5,0),nf,s,tf,a,r),lv(ov.set(.5,.5,0),nf,s,tf,a,r),qw.set(0,0),IA.set(1,0),Zw.set(1,1);let o=e.ray.intersectTriangle(sv,Ip,ov,!1,Np);if(o===null&&(lv(Ip.set(-.5,.5,0),nf,s,tf,a,r),IA.set(0,1),o=e.ray.intersectTriangle(sv,ov,Ip,!1,Np),o===null))return;const c=e.ray.origin.distanceTo(Np);c<e.near||c>e.far||t.push({distance:c,point:Np.clone(),uv:Ja.getInterpolation(Np,sv,Ip,ov,qw,IA,Zw,new Ee),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 lv(n,e,t,i,a,r){af.subVectors(n,t).addScalar(.5).multiply(i),a!==void 0?(Op.x=r*af.x-a*af.y,Op.y=a*af.x+r*af.y):Op.copy(af),n.copy(e),n.x+=Op.x,n.y+=Op.y,n.applyMatrix4(cB)}const cv=new H,jw=new H;class hB extends fn{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,a=t.length;i<a;i++){const r=t[i];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const a=this.levels;let r;for(r=0;r<a.length&&!(t<a[r].distance);r++);return a.splice(r,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 a=t.splice(i,1);return this.remove(a[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,a;for(i=1,a=t.length;i<a;i++){let r=t[i].distance;if(t[i].object.visible&&(r-=r*t[i].hysteresis),e<r)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){cv.setFromMatrixPosition(this.matrixWorld);const a=e.ray.origin.distanceTo(cv);this.getObjectForDistance(a).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){cv.setFromMatrixPosition(e.matrixWorld),jw.setFromMatrixPosition(this.matrixWorld);const i=cv.distanceTo(jw)/e.zoom;t[0].object.visible=!0;let a,r;for(a=1,r=t.length;a<r;a++){let s=t[a].distance;if(t[a].object.visible&&(s-=s*t[a].hysteresis),i>=s)t[a-1].object.visible=!1,t[a].object.visible=!0;else break}for(this._currentLevel=a-1;a<r;a++)t[a].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 a=0,r=i.length;a<r;a++){const s=i[a];t.object.levels.push({object:s.object.uuid,distance:s.distance,hysteresis:s.hysteresis})}return t}}const Kw=new H,Jw=new Yt,Qw=new Yt,WH=new H,$w=new lt,uv=new H,BA=new zi,e4=new lt,UA=new oh;class V3 extends Xn{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=wE,this.bindMatrix=new lt,this.bindMatrixInverse=new lt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new sa),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,uv),this.boundingBox.expandByPoint(uv)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new zi),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,uv),this.boundingSphere.expandByPoint(uv)}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,a=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),BA.copy(this.boundingSphere),BA.applyMatrix4(a),e.ray.intersectsSphere(BA)!==!1&&(e4.copy(a).invert(),UA.copy(e.ray).applyMatrix4(e4),!(this.boundingBox!==null&&UA.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,UA)))}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 Yt,t=this.geometry.attributes.skinWeight;for(let i=0,a=t.count;i<a;i++){e.fromBufferAttribute(t,i);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===wE?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===G5?this.bindMatrixInverse.copy(this.bindMatrix).invert():_t("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,a=this.geometry;Jw.fromBufferAttribute(a.attributes.skinIndex,e),Qw.fromBufferAttribute(a.attributes.skinWeight,e),Kw.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const s=Qw.getComponent(r);if(s!==0){const o=Jw.getComponent(r);$w.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(WH.copy(Kw).applyMatrix4($w),s)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Ay extends fn{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Pa extends vn{constructor(e=null,t=1,i=1,a,r,s,o,c,h=$n,f=$n,d,m){super(null,s,o,c,h,f,a,r,d,m),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const t4=new lt,YH=new lt;class D0{constructor(e=[],t=[]){this.uuid=Cr(),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){_t("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,a=this.bones.length;i<a;i++)this.boneInverses.push(new lt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new lt;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,a=this.boneTexture;for(let r=0,s=e.length;r<s;r++){const o=e[r]?e[r].matrixWorld:YH;t4.multiplyMatrices(o,t[r]),t4.toArray(i,r*16)}a!==null&&(a.needsUpdate=!0)}clone(){return new D0(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 Pa(t,e,e,Rn,Sn);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 a=this.bones[t];if(a.name===e)return a}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,a=e.bones.length;i<a;i++){const r=e.bones[i];let s=t[r];s===void 0&&(_t("Skeleton: No bone found with UUID:",r),s=new Ay),this.bones.push(s),this.boneInverses.push(new lt().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 a=0,r=t.length;a<r;a++){const s=t[a];e.bones.push(s.uuid);const o=i[a];e.boneInverses.push(o.toArray())}return e}}class Wu extends pn{constructor(e,t,i,a=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=a}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 rf=new lt,n4=new lt,hv=[],i4=new sa,qH=new lt,Bp=new Xn,Up=new zi;class k3 extends Xn{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Wu(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let a=0;a<i;a++)this.setMatrixAt(a,qH)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new sa),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,rf),i4.copy(e.boundingBox).applyMatrix4(rf),this.boundingBox.union(i4)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new zi),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,rf),Up.copy(e.boundingSphere).applyMatrix4(rf),this.boundingSphere.union(Up)}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,a=this.morphTexture.source.data.data,r=i.length+1,s=e*r+1;for(let o=0;o<i.length;o++)i[o]=a[s+o]}raycast(e,t){const i=this.matrixWorld,a=this.count;if(Bp.geometry=this.geometry,Bp.material=this.material,Bp.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Up.copy(this.boundingSphere),Up.applyMatrix4(i),e.ray.intersectsSphere(Up)!==!1))for(let r=0;r<a;r++){this.getMatrixAt(r,rf),n4.multiplyMatrices(i,rf),Bp.matrixWorld=n4,Bp.raycast(e,hv);for(let s=0,o=hv.length;s<o;s++){const c=hv[s];c.instanceId=r,c.object=this,t.push(c)}hv.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Wu(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,a=i.length+1;this.morphTexture===null&&(this.morphTexture=new Pa(new Float32Array(a*this.count),a,this.count,Ar,Sn));const r=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,c=a*e;r[c]=o,r.set(i,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const LA=new H,ZH=new H,jH=new kt;class Lo{constructor(e=new H(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,a){return this.normal.set(e,t,i),this.constant=a,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const a=LA.subVectors(i,t).cross(ZH.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(a,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(LA),a=this.normal.dot(i);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/a;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}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||jH.getNormalMatrix(e),a=this.coplanarPoint(LA).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-a.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const qc=new zi,KH=new Ee(.5,.5),fv=new H;class Hd{constructor(e=new Lo,t=new Lo,i=new Lo,a=new Lo,r=new Lo,s=new Lo){this.planes=[e,t,i,a,r,s]}set(e,t,i,a,r,s){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(a),o[4].copy(r),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=Er,i=!1){const a=this.planes,r=e.elements,s=r[0],o=r[1],c=r[2],h=r[3],f=r[4],d=r[5],m=r[6],g=r[7],y=r[8],E=r[9],S=r[10],v=r[11],_=r[12],A=r[13],b=r[14],O=r[15];if(a[0].setComponents(h-s,g-f,v-y,O-_).normalize(),a[1].setComponents(h+s,g+f,v+y,O+_).normalize(),a[2].setComponents(h+o,g+d,v+E,O+A).normalize(),a[3].setComponents(h-o,g-d,v-E,O-A).normalize(),i)a[4].setComponents(c,m,S,b).normalize(),a[5].setComponents(h-c,g-m,v-S,O-b).normalize();else if(a[4].setComponents(h-c,g-m,v-S,O-b).normalize(),t===Er)a[5].setComponents(h+c,g+m,v+S,O+b).normalize();else if(t===gd)a[5].setComponents(c,m,S,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(),qc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),qc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(qc)}intersectsSprite(e){qc.center.set(0,0,0);const t=KH.distanceTo(e.center);return qc.radius=.7071067811865476+t,qc.applyMatrix4(e.matrixWorld),this.intersectsSphere(qc)}intersectsSphere(e){const t=this.planes,i=e.center,a=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<a)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const a=t[i];if(fv.x=a.normal.x>0?e.max.x:e.min.x,fv.y=a.normal.y>0?e.max.y:e.min.y,fv.z=a.normal.z>0?e.max.z:e.min.z,a.distanceToPoint(fv)<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 Vs=new lt,ks=new Hd;class Ey{constructor(){this.coordinateSystem=Er}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i<t.cameras.length;i++){const a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.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 a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.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 a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.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 a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.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 a=t.cameras[i];if(Vs.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),ks.setFromProjectionMatrix(Vs,a.coordinateSystem,a.reversedDepth),ks.containsPoint(e))return!0}return!1}clone(){return new Ey}}function PA(n,e){return n-e}function JH(n,e){return n.z-e.z}function QH(n,e){return e.z-n.z}class $H{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i,a){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const o=r[this.index];s.push(o),this.index++,o.start=e,o.count=t,o.z=i,o.index=a}reset(){this.list.length=0,this.index=0}}const Ya=new lt,ez=new dt(1,1,1),a4=new Hd,tz=new Ey,dv=new sa,Zc=new zi,Lp=new H,r4=new H,nz=new H,FA=new $H,Ea=new Xn,pv=[];function iz(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const a=n.count;for(let r=0;r<a;r++)for(let s=0;s<i;s++)e.setComponent(r+t,s,n.getComponent(r,s))}else e.array.set(n.array,t*i);e.needsUpdate=!0}function jc(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 fB extends Xn{constructor(e,t,i=t*2,a){super(new Xt,a),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 Pa(t,e,e,Rn,Sn);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new Pa(t,e,e,R0,ls);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 Pa(t,e,e,Rn,Sn);i.colorSpace=gn.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const r in e.attributes){const s=e.getAttribute(r),{array:o,itemSize:c,normalized:h}=s,f=new o.constructor(i*c),d=new pn(f,c,h);t.setAttribute(r,d)}if(e.getIndex()!==null){const r=i>65535?new Uint32Array(a):new Uint16Array(a);t.setIndex(new pn(r,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 a=e.getAttribute(i),r=t.getAttribute(i);if(a.itemSize!==r.itemSize||a.normalized!==r.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 sa);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,a=t.length;i<a;i++){if(t[i].active===!1)continue;const r=t[i].geometryIndex;this.getMatrixAt(i,Ya),this.getBoundingBoxAt(r,dv).applyMatrix4(Ya),e.union(dv)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new zi);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let i=0,a=t.length;i<a;i++){if(t[i].active===!1)continue;const r=t[i].geometryIndex;this.getMatrixAt(i,Ya),this.getBoundingSphereAt(r,Zc).applyMatrix4(Ya),e.union(Zc)}}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 a=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(PA),a=this._availableInstanceIds.shift(),this._instanceInfo[a]=i):(a=this._instanceInfo.length,this._instanceInfo.push(i));const r=this._matricesTexture;Ya.identity().toArray(r.image.data,a*16),r.needsUpdate=!0;const s=this._colorsTexture;return s&&(ez.toArray(s.image.data,a*4),s.needsUpdate=!0),this._visibilityChanged=!0,a}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const a={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;a.vertexStart=this._nextVertexStart,a.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const s=e.getIndex();if(s!==null&&(a.indexStart=this._nextIndexStart,a.reservedIndexCount=i===-1?s.count:i),a.indexStart!==-1&&a.indexStart+a.reservedIndexCount>this._maxIndexCount||a.vertexStart+a.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(PA),c=this._availableGeometryIds.shift(),r[c]=a):(c=this._geometryCount,this._geometryCount++,r.push(a)),this.setGeometryAt(c,e),this._nextIndexStart=a.indexStart+a.reservedIndexCount,this._nextVertexStart=a.vertexStart+a.reservedVertexCount,c}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,a=i.getIndex()!==null,r=i.getIndex(),s=t.getIndex(),o=this._geometryInfo[e];if(a&&s.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const c=o.vertexStart,h=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const f in i.attributes){const d=t.getAttribute(f),m=i.getAttribute(f);iz(d,m,c);const g=d.itemSize;for(let y=d.count,E=h;y<E;y++){const S=c+y;for(let v=0;v<g;v++)m.setComponent(S,v,0)}m.needsUpdate=!0,m.addUpdateRange(c*g,h*g)}if(a){const f=o.indexStart,d=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let m=0;m<s.count;m++)r.setX(f+m,c+s.getX(m));for(let m=s.count,g=d;m<g;m++)r.setX(f+m,c);r.needsUpdate=!0,r.addUpdateRange(f,o.reservedIndexCount)}return o.start=a?o.indexStart:o.vertexStart,o.count=a?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 a=0,r=i.length;a<r;a++)i[a].active&&i[a].geometryIndex===e&&this.deleteInstance(a);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,a=i.map((s,o)=>o).sort((s,o)=>i[s].vertexStart-i[o].vertexStart),r=this.geometry;for(let s=0,o=i.length;s<o;s++){const c=a[s],h=i[c];if(h.active!==!1){if(r.index!==null){if(h.indexStart!==t){const{indexStart:f,vertexStart:d,reservedIndexCount:m}=h,g=r.index,y=g.array,E=e-d;for(let S=f;S<f+m;S++)y[S]=y[S]+E;g.array.copyWithin(t,f,f+m),g.addUpdateRange(t,m),h.indexStart=t}t+=h.reservedIndexCount}if(h.vertexStart!==e){const{vertexStart:f,reservedVertexCount:d}=h,m=r.attributes;for(const g in m){const y=m[g],{array:E,itemSize:S}=y;E.copyWithin(e*S,f*S,(f+d)*S),y.addUpdateRange(e*S,d*S)}h.vertexStart=e}e+=h.reservedVertexCount,h.start=r.index?h.indexStart:h.vertexStart,this._nextIndexStart=r.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,a=this._geometryInfo[e];if(a.boundingBox===null){const r=new sa,s=i.index,o=i.attributes.position;for(let c=a.start,h=a.start+a.count;c<h;c++){let f=c;s&&(f=s.getX(f)),r.expandByPoint(Lp.fromBufferAttribute(o,f))}a.boundingBox=r}return t.copy(a.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this.geometry,a=this._geometryInfo[e];if(a.boundingSphere===null){const r=new zi;this.getBoundingBoxAt(e,dv),dv.getCenter(r.center);const s=i.index,o=i.attributes.position;let c=0;for(let h=a.start,f=a.start+a.count;h<f;h++){let d=h;s&&(d=s.getX(d)),Lp.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(Lp))}r.radius=Math.sqrt(c),a.boundingSphere=r}return t.copy(a.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const i=this._matricesTexture,a=this._matricesTexture.image.data;return t.toArray(a,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(PA);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 a=new Int32Array(e),r=new Int32Array(e);jc(this._multiDrawCounts,a),jc(this._multiDrawStarts,r),this._multiDrawCounts=a,this._multiDrawStarts=r,this._maxInstanceCount=e;const s=this._indirectTexture,o=this._matricesTexture,c=this._colorsTexture;s.dispose(),this._initIndirectTexture(),jc(s.image.data,this._indirectTexture.image.data),o.dispose(),this._initMatricesTexture(),jc(o.image.data,this._matricesTexture.image.data),c&&(c.dispose(),this._initColorsTexture(),jc(c.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(c=>c.indexStart+c.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Xt,this._initializeGeometry(r));const s=this.geometry;r.index&&jc(r.index.array,s.index.array);for(const o in r.attributes)jc(r.attributes[o].array,s.attributes[o].array)}raycast(e,t){const i=this._instanceInfo,a=this._geometryInfo,r=this.matrixWorld,s=this.geometry;Ea.material=this.material,Ea.geometry.index=s.index,Ea.geometry.attributes=s.attributes,Ea.geometry.boundingBox===null&&(Ea.geometry.boundingBox=new sa),Ea.geometry.boundingSphere===null&&(Ea.geometry.boundingSphere=new zi);for(let o=0,c=i.length;o<c;o++){if(!i[o].visible||!i[o].active)continue;const h=i[o].geometryIndex,f=a[h];Ea.geometry.setDrawRange(f.start,f.count),this.getMatrixAt(o,Ea.matrixWorld).premultiply(r),this.getBoundingBoxAt(h,Ea.geometry.boundingBox),this.getBoundingSphereAt(h,Ea.geometry.boundingSphere),Ea.raycast(e,pv);for(let d=0,m=pv.length;d<m;d++){const g=pv[d];g.object=this,g.batchId=o,t.push(g)}pv.length=0}Ea.material=null,Ea.geometry.index=null,Ea.geometry.attributes={},Ea.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,a,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=a.getIndex(),o=s===null?1:s.array.BYTES_PER_ELEMENT,c=this._instanceInfo,h=this._multiDrawStarts,f=this._multiDrawCounts,d=this._geometryInfo,m=this.perObjectFrustumCulled,g=this._indirectTexture,y=g.image.data,E=i.isArrayCamera?tz:a4;m&&!i.isArrayCamera&&(Ya.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),a4.setFromProjectionMatrix(Ya,i.coordinateSystem,i.reversedDepth));let S=0;if(this.sortObjects){Ya.copy(this.matrixWorld).invert(),Lp.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Ya),r4.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(Ya);for(let A=0,b=c.length;A<b;A++)if(c[A].visible&&c[A].active){const O=c[A].geometryIndex;this.getMatrixAt(A,Ya),this.getBoundingSphereAt(O,Zc).applyMatrix4(Ya);let N=!1;if(m&&(N=!E.intersectsSphere(Zc,i)),!N){const L=d[O],B=nz.subVectors(Zc.center,Lp).dot(r4);FA.push(L.start,L.count,B,A)}}const v=FA.list,_=this.customSort;_===null?v.sort(r.transparent?QH:JH):_.call(this,v,i);for(let A=0,b=v.length;A<b;A++){const O=v[A];h[S]=O.start*o,f[S]=O.count,y[S]=O.index,S++}FA.reset()}else for(let v=0,_=c.length;v<_;v++)if(c[v].visible&&c[v].active){const A=c[v].geometryIndex;let b=!1;if(m&&(this.getMatrixAt(v,Ya),this.getBoundingSphereAt(A,Zc).applyMatrix4(Ya),b=!E.intersectsSphere(Zc,i)),!b){const O=d[A];h[S]=O.start*o,f[S]=O.count,y[S]=v,S++}}g.needsUpdate=!0,this._multiDrawCount=S,this._visibilityChanged=!1}onBeforeShadow(e,t,i,a,r,s){this.onBeforeRender(e,null,a,r,s)}}class Ca extends ri{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new dt(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 Cx=new H,Rx=new H,s4=new lt,Pp=new oh,mv=new zi,HA=new H,o4=new H;class rl extends fn{constructor(e=new Xt,t=new Ca){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 a=1,r=t.count;a<r;a++)Cx.fromBufferAttribute(t,a-1),Rx.fromBufferAttribute(t,a),i[a]=i[a-1],i[a]+=Cx.distanceTo(Rx);e.setAttribute("lineDistance",new Dt(i,1))}else _t("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,a=this.matrixWorld,r=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),mv.copy(i.boundingSphere),mv.applyMatrix4(a),mv.radius+=r,e.ray.intersectsSphere(mv)===!1)return;s4.copy(a).invert(),Pp.copy(e.ray).applyMatrix4(s4);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,h=this.isLineSegments?2:1,f=i.index,m=i.attributes.position;if(f!==null){const g=Math.max(0,s.start),y=Math.min(f.count,s.start+s.count);for(let E=g,S=y-1;E<S;E+=h){const v=f.getX(E),_=f.getX(E+1),A=gv(this,e,Pp,c,v,_,E);A&&t.push(A)}if(this.isLineLoop){const E=f.getX(y-1),S=f.getX(g),v=gv(this,e,Pp,c,E,S,y-1);v&&t.push(v)}}else{const g=Math.max(0,s.start),y=Math.min(m.count,s.start+s.count);for(let E=g,S=y-1;E<S;E+=h){const v=gv(this,e,Pp,c,E,E+1,E);v&&t.push(v)}if(this.isLineLoop){const E=gv(this,e,Pp,c,y-1,g,y-1);E&&t.push(E)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=a.length;r<s;r++){const o=a[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function gv(n,e,t,i,a,r,s){const o=n.geometry.attributes.position;if(Cx.fromBufferAttribute(o,a),Rx.fromBufferAttribute(o,r),t.distanceSqToSegment(Cx,Rx,HA,o4)>i)return;HA.applyMatrix4(n.matrixWorld);const h=e.ray.origin.distanceTo(HA);if(!(h<e.near||h>e.far))return{distance:h,point:o4.clone().applyMatrix4(n.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:n}}const l4=new H,c4=new H;class Is extends rl{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 a=0,r=t.count;a<r;a+=2)l4.fromBufferAttribute(t,a),c4.fromBufferAttribute(t,a+1),i[a]=a===0?0:i[a-1],i[a+1]=i[a]+l4.distanceTo(c4);e.setAttribute("lineDistance",new Dt(i,1))}else _t("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class X3 extends rl{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Ty extends ri{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new dt(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 u4=new lt,NE=new oh,vv=new zi,xv=new H;class W3 extends fn{constructor(e=new Xt,t=new Ty){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,a=this.matrixWorld,r=e.params.Points.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),vv.copy(i.boundingSphere),vv.applyMatrix4(a),vv.radius+=r,e.ray.intersectsSphere(vv)===!1)return;u4.copy(a).invert(),NE.copy(e.ray).applyMatrix4(u4);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,h=i.index,d=i.attributes.position;if(h!==null){const m=Math.max(0,s.start),g=Math.min(h.count,s.start+s.count);for(let y=m,E=g;y<E;y++){const S=h.getX(y);xv.fromBufferAttribute(d,S),h4(xv,S,c,a,e,t,this)}}else{const m=Math.max(0,s.start),g=Math.min(d.count,s.start+s.count);for(let y=m,E=g;y<E;y++)xv.fromBufferAttribute(d,y),h4(xv,y,c,a,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=a.length;r<s;r++){const o=a[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function h4(n,e,t,i,a,r,s){const o=NE.distanceSqToPoint(n);if(o<t){const c=new H;NE.closestPointToPoint(n,c),c.applyMatrix4(i);const h=a.ray.origin.distanceTo(c);if(h<a.near||h>a.far)return;r.push({distance:h,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:s})}}class dB extends vn{constructor(e,t,i,a,r=Bt,s=Bt,o,c,h){super(e,t,i,a,r,s,o,c,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 az extends dB{constructor(e,t,i,a,r,s,o,c){super({},e,t,i,a,r,s,o,c),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class rz extends vn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=$n,this.minFilter=$n,this.generateMipmaps=!1,this.needsUpdate=!0}}class by extends vn{constructor(e,t,i,a,r,s,o,c,h,f,d,m){super(null,s,o,c,h,f,a,r,d,m),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class sz extends by{constructor(e,t,i,a,r,s){super(e,t,i,r,s),this.isCompressedArrayTexture=!0,this.image.depth=a,this.wrapR=Vn,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class oz extends by{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,no),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class lz extends vn{constructor(e,t,i,a,r,s,o,c,h){super(e,t,i,a,r,s,o,c,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class N0 extends vn{constructor(e,t,i=ls,a,r,s,o=$n,c=$n,h,f=dd,d=1){if(f!==dd&&f!==ku)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:t,depth:d};super(m,a,r,s,o,c,f,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Kl(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 Y3 extends vn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class My extends Xt{constructor(e=1,t=1,i=4,a=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:a,heightSegments:r},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),a=Math.max(3,Math.floor(a)),r=Math.max(1,Math.floor(r));const s=[],o=[],c=[],h=[],f=t/2,d=Math.PI/2*e,m=t,g=2*d+m,y=i*2+r,E=a+1,S=new H,v=new H;for(let _=0;_<=y;_++){let A=0,b=0,O=0,N=0;if(_<=i){const w=_/i,D=w*Math.PI/2;b=-f-e*Math.cos(D),O=e*Math.sin(D),N=-e*Math.cos(D),A=w*d}else if(_<=i+r){const w=(_-i)/r;b=-f+w*t,O=e,N=0,A=d+w*m}else{const w=(_-i-r)/i,D=w*Math.PI/2;b=f+e*Math.sin(D),O=e*Math.cos(D),N=e*Math.sin(D),A=d+m+w*d}const L=Math.max(0,Math.min(1,A/g));let B=0;_===0?B=.5/a:_===y&&(B=-.5/a);for(let w=0;w<=a;w++){const D=w/a,G=D*Math.PI*2,J=Math.sin(G),$=Math.cos(G);v.x=-O*$,v.y=b,v.z=O*J,o.push(v.x,v.y,v.z),S.set(-O*$,N,O*J),S.normalize(),c.push(S.x,S.y,S.z),h.push(D+B,L)}if(_>0){const w=(_-1)*E;for(let D=0;D<a;D++){const G=w+D,J=w+D+1,$=_*E+D,se=_*E+D+1;s.push(G,J,$),s.push(J,se,$)}}}this.setIndex(s),this.setAttribute("position",new Dt(o,3)),this.setAttribute("normal",new Dt(c,3)),this.setAttribute("uv",new Dt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new My(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class Cy extends Xt{constructor(e=1,t=32,i=0,a=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:a},t=Math.max(3,t);const r=[],s=[],o=[],c=[],h=new H,f=new Ee;s.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let d=0,m=3;d<=t;d++,m+=3){const g=i+d/t*a;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[m]/e+1)/2,f.y=(s[m+1]/e+1)/2,c.push(f.x,f.y)}for(let d=1;d<=t;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new Dt(s,3)),this.setAttribute("normal",new Dt(o,3)),this.setAttribute("uv",new Dt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Cy(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class O0 extends Xt{constructor(e=1,t=1,i=1,a=32,r=1,s=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:a,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:c};const h=this;a=Math.floor(a),r=Math.floor(r);const f=[],d=[],m=[],g=[];let y=0;const E=[],S=i/2;let v=0;_(),s===!1&&(e>0&&A(!0),t>0&&A(!1)),this.setIndex(f),this.setAttribute("position",new Dt(d,3)),this.setAttribute("normal",new Dt(m,3)),this.setAttribute("uv",new Dt(g,2));function _(){const b=new H,O=new H;let N=0;const L=(t-e)/i;for(let B=0;B<=r;B++){const w=[],D=B/r,G=D*(t-e)+e;for(let J=0;J<=a;J++){const $=J/a,se=$*c+o,le=Math.sin(se),q=Math.cos(se);O.x=G*le,O.y=-D*i+S,O.z=G*q,d.push(O.x,O.y,O.z),b.set(le,L,q).normalize(),m.push(b.x,b.y,b.z),g.push($,1-D),w.push(y++)}E.push(w)}for(let B=0;B<a;B++)for(let w=0;w<r;w++){const D=E[w][B],G=E[w+1][B],J=E[w+1][B+1],$=E[w][B+1];(e>0||w!==0)&&(f.push(D,G,$),N+=3),(t>0||w!==r-1)&&(f.push(G,J,$),N+=3)}h.addGroup(v,N,0),v+=N}function A(b){const O=y,N=new Ee,L=new H;let B=0;const w=b===!0?e:t,D=b===!0?1:-1;for(let J=1;J<=a;J++)d.push(0,S*D,0),m.push(0,D,0),g.push(.5,.5),y++;const G=y;for(let J=0;J<=a;J++){const se=J/a*c+o,le=Math.cos(se),q=Math.sin(se);L.x=w*q,L.y=S*D,L.z=w*le,d.push(L.x,L.y,L.z),m.push(0,D,0),N.x=le*.5+.5,N.y=q*.5*D+.5,g.push(N.x,N.y),y++}for(let J=0;J<a;J++){const $=O+J,se=G+J;b===!0?f.push(se,se+1,$):f.push(se+1,se,$),B+=3}h.addGroup(v,B,b===!0?1:2),v+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new O0(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class I0 extends O0{constructor(e=1,t=1,i=32,a=1,r=!1,s=0,o=Math.PI*2){super(0,e,t,i,a,r,s,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:a,openEnded:r,thetaStart:s,thetaLength:o}}static fromJSON(e){return new I0(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ec extends Xt{constructor(e=[],t=[],i=1,a=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:a};const r=[],s=[];o(a),h(i),f(),this.setAttribute("position",new Dt(r,3)),this.setAttribute("normal",new Dt(r.slice(),3)),this.setAttribute("uv",new Dt(s,2)),a===0?this.computeVertexNormals():this.normalizeNormals();function o(_){const A=new H,b=new H,O=new H;for(let N=0;N<t.length;N+=3)g(t[N+0],A),g(t[N+1],b),g(t[N+2],O),c(A,b,O,_)}function c(_,A,b,O){const N=O+1,L=[];for(let B=0;B<=N;B++){L[B]=[];const w=_.clone().lerp(b,B/N),D=A.clone().lerp(b,B/N),G=N-B;for(let J=0;J<=G;J++)J===0&&B===N?L[B][J]=w:L[B][J]=w.clone().lerp(D,J/G)}for(let B=0;B<N;B++)for(let w=0;w<2*(N-B)-1;w++){const D=Math.floor(w/2);w%2===0?(m(L[B][D+1]),m(L[B+1][D]),m(L[B][D])):(m(L[B][D+1]),m(L[B+1][D+1]),m(L[B+1][D]))}}function h(_){const A=new H;for(let b=0;b<r.length;b+=3)A.x=r[b+0],A.y=r[b+1],A.z=r[b+2],A.normalize().multiplyScalar(_),r[b+0]=A.x,r[b+1]=A.y,r[b+2]=A.z}function f(){const _=new H;for(let A=0;A<r.length;A+=3){_.x=r[A+0],_.y=r[A+1],_.z=r[A+2];const b=S(_)/2/Math.PI+.5,O=v(_)/Math.PI+.5;s.push(b,1-O)}y(),d()}function d(){for(let _=0;_<s.length;_+=6){const A=s[_+0],b=s[_+2],O=s[_+4],N=Math.max(A,b,O),L=Math.min(A,b,O);N>.9&&L<.1&&(A<.2&&(s[_+0]+=1),b<.2&&(s[_+2]+=1),O<.2&&(s[_+4]+=1))}}function m(_){r.push(_.x,_.y,_.z)}function g(_,A){const b=_*3;A.x=e[b+0],A.y=e[b+1],A.z=e[b+2]}function y(){const _=new H,A=new H,b=new H,O=new H,N=new Ee,L=new Ee,B=new Ee;for(let w=0,D=0;w<r.length;w+=9,D+=6){_.set(r[w+0],r[w+1],r[w+2]),A.set(r[w+3],r[w+4],r[w+5]),b.set(r[w+6],r[w+7],r[w+8]),N.set(s[D+0],s[D+1]),L.set(s[D+2],s[D+3]),B.set(s[D+4],s[D+5]),O.copy(_).add(A).add(b).divideScalar(3);const G=S(O);E(N,D+0,_,G),E(L,D+2,A,G),E(B,D+4,b,G)}}function E(_,A,b,O){O<0&&_.x===1&&(s[A]=_.x-1),b.x===0&&b.z===0&&(s[A]=O/2/Math.PI+.5)}function S(_){return Math.atan2(_.z,-_.x)}function v(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ec(e.vertices,e.indices,e.radius,e.details)}}class Ry extends Ec{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,a=1/i,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,0,-a,-i,0,-a,i,0,a,-i,0,a,i,-a,-i,0,-a,i,0,a,-i,0,a,i,0,-i,0,-a,i,0,-a,-i,0,a,i,0,a],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(r,s,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ry(e.radius,e.detail)}}const yv=new H,_v=new H,zA=new H,Sv=new Ja;class pB extends Xt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const a=Math.pow(10,4),r=Math.cos(Du*t),s=e.getIndex(),o=e.getAttribute("position"),c=s?s.count:o.count,h=[0,0,0],f=["a","b","c"],d=new Array(3),m={},g=[];for(let y=0;y<c;y+=3){s?(h[0]=s.getX(y),h[1]=s.getX(y+1),h[2]=s.getX(y+2)):(h[0]=y,h[1]=y+1,h[2]=y+2);const{a:E,b:S,c:v}=Sv;if(E.fromBufferAttribute(o,h[0]),S.fromBufferAttribute(o,h[1]),v.fromBufferAttribute(o,h[2]),Sv.getNormal(zA),d[0]=`${Math.round(E.x*a)},${Math.round(E.y*a)},${Math.round(E.z*a)}`,d[1]=`${Math.round(S.x*a)},${Math.round(S.y*a)},${Math.round(S.z*a)}`,d[2]=`${Math.round(v.x*a)},${Math.round(v.y*a)},${Math.round(v.z*a)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let _=0;_<3;_++){const A=(_+1)%3,b=d[_],O=d[A],N=Sv[f[_]],L=Sv[f[A]],B=`${b}_${O}`,w=`${O}_${b}`;w in m&&m[w]?(zA.dot(m[w].normal)<=r&&(g.push(N.x,N.y,N.z),g.push(L.x,L.y,L.z)),m[w]=null):B in m||(m[B]={index0:h[_],index1:h[A],normal:zA.clone()})}}for(const y in m)if(m[y]){const{index0:E,index1:S}=m[y];yv.fromBufferAttribute(o,E),_v.fromBufferAttribute(o,S),g.push(yv.x,yv.y,yv.z),g.push(_v.x,_v.y,_v.z)}this.setAttribute("position",new Dt(g,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Bs{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){_t("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,a=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),r+=i.distanceTo(a),t.push(r),a=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const i=this.getLengths();let a=0;const r=i.length;let s;t?s=t:s=e*i[r-1];let o=0,c=r-1,h;for(;o<=c;)if(a=Math.floor(o+(c-o)/2),h=i[a]-s,h<0)o=a+1;else if(h>0)c=a-1;else{c=a;break}if(a=c,i[a]===s)return a/(r-1);const f=i[a],m=i[a+1]-f,g=(s-f)/m;return(a+g)/(r-1)}getTangent(e,t){let a=e-1e-4,r=e+1e-4;a<0&&(a=0),r>1&&(r=1);const s=this.getPoint(a),o=this.getPoint(r),c=t||(s.isVector2?new Ee:new H);return c.copy(o).sub(s).normalize(),c}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new H,a=[],r=[],s=[],o=new H,c=new lt;for(let g=0;g<=e;g++){const y=g/e;a[g]=this.getTangentAt(y,new H)}r[0]=new H,s[0]=new H;let h=Number.MAX_VALUE;const f=Math.abs(a[0].x),d=Math.abs(a[0].y),m=Math.abs(a[0].z);f<=h&&(h=f,i.set(1,0,0)),d<=h&&(h=d,i.set(0,1,0)),m<=h&&i.set(0,0,1),o.crossVectors(a[0],i).normalize(),r[0].crossVectors(a[0],o),s[0].crossVectors(a[0],r[0]);for(let g=1;g<=e;g++){if(r[g]=r[g-1].clone(),s[g]=s[g-1].clone(),o.crossVectors(a[g-1],a[g]),o.length()>Number.EPSILON){o.normalize();const y=Math.acos(Gt(a[g-1].dot(a[g]),-1,1));r[g].applyMatrix4(c.makeRotationAxis(o,y))}s[g].crossVectors(a[g],r[g])}if(t===!0){let g=Math.acos(Gt(r[0].dot(r[e]),-1,1));g/=e,a[0].dot(o.crossVectors(r[0],r[e]))>0&&(g=-g);for(let y=1;y<=e;y++)r[y].applyMatrix4(c.makeRotationAxis(a[y],g*y)),s[y].crossVectors(a[y],r[y])}return{tangents:a,normals:r,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 wy extends Bs{constructor(e=0,t=0,i=1,a=1,r=0,s=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=a,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=o,this.aRotation=c}getPoint(e,t=new Ee){const i=t,a=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=a;for(;r>a;)r-=a;r<Number.EPSILON&&(s?r=0:r=a),this.aClockwise===!0&&!s&&(r===a?r=-a:r=r-a);const o=this.aStartAngle+e*r;let c=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),m=c-this.aX,g=h-this.aY;c=m*f-g*d+this.aX,h=m*d+g*f+this.aY}return i.set(c,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 mB extends wy{constructor(e,t,i,a,r,s){super(e,t,i,i,a,r,s),this.isArcCurve=!0,this.type="ArcCurve"}}function q3(){let n=0,e=0,t=0,i=0;function a(r,s,o,c){n=r,e=o,t=-3*r+3*s-2*o-c,i=2*r-2*s+o+c}return{initCatmullRom:function(r,s,o,c,h){a(s,o,h*(o-r),h*(c-s))},initNonuniformCatmullRom:function(r,s,o,c,h,f,d){let m=(s-r)/h-(o-r)/(h+f)+(o-s)/f,g=(o-s)/f-(c-s)/(f+d)+(c-o)/d;m*=f,g*=f,a(s,o,m,g)},calc:function(r){const s=r*r,o=s*r;return n+e*r+t*s+i*o}}}const Av=new H,GA=new q3,VA=new q3,kA=new q3;class gB extends Bs{constructor(e=[],t=!1,i="centripetal",a=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=a}getPoint(e,t=new H){const i=t,a=this.points,r=a.length,s=(r-(this.closed?0:1))*e;let o=Math.floor(s),c=s-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:c===0&&o===r-1&&(o=r-2,c=1);let h,f;this.closed||o>0?h=a[(o-1)%r]:(Av.subVectors(a[0],a[1]).add(a[0]),h=Av);const d=a[o%r],m=a[(o+1)%r];if(this.closed||o+2<r?f=a[(o+2)%r]:(Av.subVectors(a[r-1],a[r-2]).add(a[r-1]),f=Av),this.curveType==="centripetal"||this.curveType==="chordal"){const g=this.curveType==="chordal"?.5:.25;let y=Math.pow(h.distanceToSquared(d),g),E=Math.pow(d.distanceToSquared(m),g),S=Math.pow(m.distanceToSquared(f),g);E<1e-4&&(E=1),y<1e-4&&(y=E),S<1e-4&&(S=E),GA.initNonuniformCatmullRom(h.x,d.x,m.x,f.x,y,E,S),VA.initNonuniformCatmullRom(h.y,d.y,m.y,f.y,y,E,S),kA.initNonuniformCatmullRom(h.z,d.z,m.z,f.z,y,E,S)}else this.curveType==="catmullrom"&&(GA.initCatmullRom(h.x,d.x,m.x,f.x,this.tension),VA.initCatmullRom(h.y,d.y,m.y,f.y,this.tension),kA.initCatmullRom(h.z,d.z,m.z,f.z,this.tension));return i.set(GA.calc(c),VA.calc(c),kA.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const a=e.points[t];this.points.push(a.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 a=this.points[t];e.points.push(a.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 a=e.points[t];this.points.push(new H().fromArray(a))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function f4(n,e,t,i,a){const r=(i-e)*.5,s=(a-t)*.5,o=n*n,c=n*o;return(2*t-2*i+r+s)*c+(-3*t+3*i-2*r-s)*o+r*n+t}function cz(n,e){const t=1-n;return t*t*e}function uz(n,e){return 2*(1-n)*n*e}function hz(n,e){return n*n*e}function Rm(n,e,t,i){return cz(n,e)+uz(n,t)+hz(n,i)}function fz(n,e){const t=1-n;return t*t*t*e}function dz(n,e){const t=1-n;return 3*t*t*n*e}function pz(n,e){return 3*(1-n)*n*n*e}function mz(n,e){return n*n*n*e}function wm(n,e,t,i,a){return fz(n,e)+dz(n,t)+pz(n,i)+mz(n,a)}class Z3 extends Bs{constructor(e=new Ee,t=new Ee,i=new Ee,a=new Ee){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=a}getPoint(e,t=new Ee){const i=t,a=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(wm(e,a.x,r.x,s.x,o.x),wm(e,a.y,r.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 vB extends Bs{constructor(e=new H,t=new H,i=new H,a=new H){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=a}getPoint(e,t=new H){const i=t,a=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(wm(e,a.x,r.x,s.x,o.x),wm(e,a.y,r.y,s.y,o.y),wm(e,a.z,r.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 j3 extends Bs{constructor(e=new Ee,t=new Ee){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ee){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 Ee){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 xB extends Bs{constructor(e=new H,t=new H){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new H){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 H){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 K3 extends Bs{constructor(e=new Ee,t=new Ee,i=new Ee){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Ee){const i=t,a=this.v0,r=this.v1,s=this.v2;return i.set(Rm(e,a.x,r.x,s.x),Rm(e,a.y,r.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 J3 extends Bs{constructor(e=new H,t=new H,i=new H){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new H){const i=t,a=this.v0,r=this.v1,s=this.v2;return i.set(Rm(e,a.x,r.x,s.x),Rm(e,a.y,r.y,s.y),Rm(e,a.z,r.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 Q3 extends Bs{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ee){const i=t,a=this.points,r=(a.length-1)*e,s=Math.floor(r),o=r-s,c=a[s===0?s:s-1],h=a[s],f=a[s>a.length-2?a.length-1:s+1],d=a[s>a.length-3?a.length-1:s+2];return i.set(f4(o,c.x,h.x,f.x,d.x),f4(o,c.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 a=e.points[t];this.points.push(a.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const a=this.points[t];e.points.push(a.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const a=e.points[t];this.points.push(new Ee().fromArray(a))}return this}}var wx=Object.freeze({__proto__:null,ArcCurve:mB,CatmullRomCurve3:gB,CubicBezierCurve:Z3,CubicBezierCurve3:vB,EllipseCurve:wy,LineCurve:j3,LineCurve3:xB,QuadraticBezierCurve:K3,QuadraticBezierCurve3:J3,SplineCurve:Q3});class yB extends Bs{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 wx[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),a=this.getCurveLengths();let r=0;for(;r<a.length;){if(a[r]>=i){const s=a[r]-i,o=this.curves[r],c=o.getLength(),h=c===0?0:1-s/c;return o.getPointAt(h,t)}r++}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,a=this.curves.length;i<a;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 a=0,r=this.curves;a<r.length;a++){const s=r[a],o=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,c=s.getPoints(o);for(let h=0;h<c.length;h++){const f=c[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 a=e.curves[t];this.curves.push(a.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 a=this.curves[t];e.curves.push(a.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 a=e.curves[t];this.curves.push(new wx[a.type]().fromJSON(a))}return this}}class Dx extends yB{constructor(e){super(),this.type="Path",this.currentPoint=new Ee,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 j3(this.currentPoint.clone(),new Ee(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,a){const r=new K3(this.currentPoint.clone(),new Ee(e,t),new Ee(i,a));return this.curves.push(r),this.currentPoint.set(i,a),this}bezierCurveTo(e,t,i,a,r,s){const o=new Z3(this.currentPoint.clone(),new Ee(e,t),new Ee(i,a),new Ee(r,s));return this.curves.push(o),this.currentPoint.set(r,s),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Q3(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,a,r,s){const o=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+o,t+c,i,a,r,s),this}absarc(e,t,i,a,r,s){return this.absellipse(e,t,i,i,a,r,s),this}ellipse(e,t,i,a,r,s,o,c){const h=this.currentPoint.x,f=this.currentPoint.y;return this.absellipse(e+h,t+f,i,a,r,s,o,c),this}absellipse(e,t,i,a,r,s,o,c){const h=new wy(e,t,i,a,r,s,o,c);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 Nu extends Dx{constructor(e){super(e),this.uuid=Cr(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,a=this.holes.length;i<a;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 a=e.holes[t];this.holes.push(a.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 a=this.holes[t];e.holes.push(a.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 a=e.holes[t];this.holes.push(new Dx().fromJSON(a))}return this}}function gz(n,e,t=2){const i=e&&e.length,a=i?e[0]*t:n.length;let r=_B(n,0,a,t,!0);const s=[];if(!r||r.next===r.prev)return s;let o,c,h;if(i&&(r=Sz(n,e,r,t)),n.length>80*t){o=n[0],c=n[1];let f=o,d=c;for(let m=t;m<a;m+=t){const g=n[m],y=n[m+1];g<o&&(o=g),y<c&&(c=y),g>f&&(f=g),y>d&&(d=y)}h=Math.max(f-o,d-c),h=h!==0?32767/h:0}return s0(r,s,t,o,c,h,0),s}function _B(n,e,t,i,a){let r;if(a===Oz(n,e,t,i)>0)for(let s=e;s<t;s+=i)r=d4(s/i|0,n[s],n[s+1],r);else for(let s=t-i;s>=e;s-=i)r=d4(s/i|0,n[s],n[s+1],r);return r&&Sd(r,r.next)&&(l0(r),r=r.next),r}function Yu(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Sd(t,t.next)||mi(t.prev,t,t.next)===0)){if(l0(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function s0(n,e,t,i,a,r,s){if(!n)return;!s&&r&&Mz(n,i,a,r);let o=n;for(;n.prev!==n.next;){const c=n.prev,h=n.next;if(r?xz(n,i,a,r):vz(n)){e.push(c.i,n.i,h.i),l0(n),n=h.next,o=h.next;continue}if(n=h,n===o){s?s===1?(n=yz(Yu(n),e),s0(n,e,t,i,a,r,2)):s===2&&_z(n,e,t,i,a,r):s0(Yu(n),e,t,i,a,r,1);break}}}function vz(n){const e=n.prev,t=n,i=n.next;if(mi(e,t,i)>=0)return!1;const a=e.x,r=t.x,s=i.x,o=e.y,c=t.y,h=i.y,f=Math.min(a,r,s),d=Math.min(o,c,h),m=Math.max(a,r,s),g=Math.max(o,c,h);let y=i.next;for(;y!==e;){if(y.x>=f&&y.x<=m&&y.y>=d&&y.y<=g&&em(a,o,r,c,s,h,y.x,y.y)&&mi(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function xz(n,e,t,i){const a=n.prev,r=n,s=n.next;if(mi(a,r,s)>=0)return!1;const o=a.x,c=r.x,h=s.x,f=a.y,d=r.y,m=s.y,g=Math.min(o,c,h),y=Math.min(f,d,m),E=Math.max(o,c,h),S=Math.max(f,d,m),v=OE(g,y,e,t,i),_=OE(E,S,e,t,i);let A=n.prevZ,b=n.nextZ;for(;A&&A.z>=v&&b&&b.z<=_;){if(A.x>=g&&A.x<=E&&A.y>=y&&A.y<=S&&A!==a&&A!==s&&em(o,f,c,d,h,m,A.x,A.y)&&mi(A.prev,A,A.next)>=0||(A=A.prevZ,b.x>=g&&b.x<=E&&b.y>=y&&b.y<=S&&b!==a&&b!==s&&em(o,f,c,d,h,m,b.x,b.y)&&mi(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;A&&A.z>=v;){if(A.x>=g&&A.x<=E&&A.y>=y&&A.y<=S&&A!==a&&A!==s&&em(o,f,c,d,h,m,A.x,A.y)&&mi(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;b&&b.z<=_;){if(b.x>=g&&b.x<=E&&b.y>=y&&b.y<=S&&b!==a&&b!==s&&em(o,f,c,d,h,m,b.x,b.y)&&mi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function yz(n,e){let t=n;do{const i=t.prev,a=t.next.next;!Sd(i,a)&&AB(i,t,t.next,a)&&o0(i,a)&&o0(a,i)&&(e.push(i.i,t.i,a.i),l0(t),l0(t.next),t=n=a),t=t.next}while(t!==n);return Yu(t)}function _z(n,e,t,i,a,r){let s=n;do{let o=s.next.next;for(;o!==s.prev;){if(s.i!==o.i&&wz(s,o)){let c=EB(s,o);s=Yu(s,s.next),c=Yu(c,c.next),s0(s,e,t,i,a,r,0),s0(c,e,t,i,a,r,0);return}o=o.next}s=s.next}while(s!==n)}function Sz(n,e,t,i){const a=[];for(let r=0,s=e.length;r<s;r++){const o=e[r]*i,c=r<s-1?e[r+1]*i:n.length,h=_B(n,o,c,i,!1);h===h.next&&(h.steiner=!0),a.push(Rz(h))}a.sort(Az);for(let r=0;r<a.length;r++)t=Ez(a[r],t);return t}function Az(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),a=(e.next.y-e.y)/(e.next.x-e.x);t=i-a}return t}function Ez(n,e){const t=Tz(n,e);if(!t)return e;const i=EB(t,n);return Yu(i,i.next),Yu(t,t.next)}function Tz(n,e){let t=e;const i=n.x,a=n.y;let r=-1/0,s;if(Sd(n,t))return t;do{if(Sd(n,t.next))return t.next;if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=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,c=s.x,h=s.y;let f=1/0;t=s;do{if(i>=t.x&&t.x>=c&&i!==t.x&&SB(a<h?i:r,a,c,h,a<h?r:i,a,t.x,t.y)){const d=Math.abs(a-t.y)/(i-t.x);o0(t,n)&&(d<f||d===f&&(t.x>s.x||t.x===s.x&&bz(s,t)))&&(s=t,f=d)}t=t.next}while(t!==o);return s}function bz(n,e){return mi(n.prev,n,e.prev)<0&&mi(e.next,n,n.next)<0}function Mz(n,e,t,i){let a=n;do a.z===0&&(a.z=OE(a.x,a.y,e,t,i)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==n);a.prevZ.nextZ=null,a.prevZ=null,Cz(a)}function Cz(n){let e,t=1;do{let i=n,a;n=null;let r=null;for(e=0;i;){e++;let s=i,o=0;for(let h=0;h<t&&(o++,s=s.nextZ,!!s);h++);let c=t;for(;o>0||c>0&&s;)o!==0&&(c===0||!s||i.z<=s.z)?(a=i,i=i.nextZ,o--):(a=s,s=s.nextZ,c--),r?r.nextZ=a:n=a,a.prevZ=r,r=a;i=s}r.nextZ=null,t*=2}while(e>1);return n}function OE(n,e,t,i,a){return n=(n-t)*a|0,e=(e-i)*a|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 Rz(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 SB(n,e,t,i,a,r,s,o){return(a-s)*(e-o)>=(n-s)*(r-o)&&(n-s)*(i-o)>=(t-s)*(e-o)&&(t-s)*(r-o)>=(a-s)*(i-o)}function em(n,e,t,i,a,r,s,o){return!(n===s&&e===o)&&SB(n,e,t,i,a,r,s,o)}function wz(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Dz(n,e)&&(o0(n,e)&&o0(e,n)&&Nz(n,e)&&(mi(n.prev,n,e.prev)||mi(n,e.prev,e))||Sd(n,e)&&mi(n.prev,n,n.next)>0&&mi(e.prev,e,e.next)>0)}function mi(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Sd(n,e){return n.x===e.x&&n.y===e.y}function AB(n,e,t,i){const a=Tv(mi(n,e,t)),r=Tv(mi(n,e,i)),s=Tv(mi(t,i,n)),o=Tv(mi(t,i,e));return!!(a!==r&&s!==o||a===0&&Ev(n,t,e)||r===0&&Ev(n,i,e)||s===0&&Ev(t,n,i)||o===0&&Ev(t,e,i))}function Ev(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 Tv(n){return n>0?1:n<0?-1:0}function Dz(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&&AB(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function o0(n,e){return mi(n.prev,n,n.next)<0?mi(n,e,n.next)>=0&&mi(n,n.prev,e)>=0:mi(n,e,n.prev)<0||mi(n,n.next,e)<0}function Nz(n,e){let t=n,i=!1;const a=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&a<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function EB(n,e){const t=IE(n.i,n.x,n.y),i=IE(e.i,e.x,e.y),a=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=a,a.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function d4(n,e,t,i){const a=IE(n,e,t);return i?(a.next=i.next,a.prev=i,i.next.prev=a,i.next=a):(a.prev=a,a.next=a),a}function l0(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 IE(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Oz(n,e,t,i){let a=0;for(let r=e,s=t-i;r<t;r+=i)a+=(n[s]-n[r])*(n[r+1]+n[s+1]),s=r;return a}class Iz{static triangulate(e,t,i=2){return gz(e,t,i)}}class Rs{static area(e){const t=e.length;let i=0;for(let a=t-1,r=0;r<t;a=r++)i+=e[a].x*e[r].y-e[r].x*e[a].y;return i*.5}static isClockWise(e){return Rs.area(e)<0}static triangulateShape(e,t){const i=[],a=[],r=[];p4(e),m4(i,e);let s=e.length;t.forEach(p4);for(let c=0;c<t.length;c++)a.push(s),s+=t[c].length,m4(i,t[c]);const o=Iz.triangulate(i,a);for(let c=0;c<o.length;c+=3)r.push(o.slice(c,c+3));return r}}function p4(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function m4(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class Dy extends Xt{constructor(e=new Nu([new Ee(.5,.5),new Ee(-.5,.5),new Ee(-.5,-.5),new Ee(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,a=[],r=[];for(let o=0,c=e.length;o<c;o++){const h=e[o];s(h)}this.setAttribute("position",new Dt(a,3)),this.setAttribute("uv",new Dt(r,2)),this.computeVertexNormals();function s(o){const c=[],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 m=t.bevelEnabled!==void 0?t.bevelEnabled:!0,g=t.bevelThickness!==void 0?t.bevelThickness:.2,y=t.bevelSize!==void 0?t.bevelSize:g-.1,E=t.bevelOffset!==void 0?t.bevelOffset:0,S=t.bevelSegments!==void 0?t.bevelSegments:3;const v=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:Bz;let A,b=!1,O,N,L,B;v&&(A=v.getSpacedPoints(f),b=!0,m=!1,O=v.computeFrenetFrames(f,!1),N=new H,L=new H,B=new H),m||(S=0,g=0,y=0,E=0);const w=o.extractPoints(h);let D=w.shape;const G=w.holes;if(!Rs.isClockWise(D)){D=D.reverse();for(let Re=0,Z=G.length;Re<Z;Re++){const Ue=G[Re];Rs.isClockWise(Ue)&&(G[Re]=Ue.reverse())}}function $(Re){const Ue=10000000000000001e-36;let ze=Re[0];for(let Qe=1;Qe<=Re.length;Qe++){const Ye=Qe%Re.length,ot=Re[Ye],rt=ot.x-ze.x,mt=ot.y-ze.y,j=rt*rt+mt*mt,P=Math.max(Math.abs(ot.x),Math.abs(ot.y),Math.abs(ze.x),Math.abs(ze.y)),pe=Ue*P*P;if(j<=pe){Re.splice(Ye,1),Qe--;continue}ze=ot}}$(D),G.forEach($);const se=G.length,le=D;for(let Re=0;Re<se;Re++){const Z=G[Re];D=D.concat(Z)}function q(Re,Z,Ue){return Z||qt("ExtrudeGeometry: vec does not exist"),Re.clone().addScaledVector(Z,Ue)}const te=D.length;function ee(Re,Z,Ue){let ze,Qe,Ye;const ot=Re.x-Z.x,rt=Re.y-Z.y,mt=Ue.x-Re.x,j=Ue.y-Re.y,P=ot*ot+rt*rt,pe=ot*j-rt*mt;if(Math.abs(pe)>Number.EPSILON){const Ie=Math.sqrt(P),Ge=Math.sqrt(mt*mt+j*j),we=Z.x-rt/Ie,Tt=Z.y+ot/Ie,ut=Ue.x-j/Ge,wt=Ue.y+mt/Ge,bt=((ut-we)*j-(wt-Tt)*mt)/(ot*j-rt*mt);ze=we+ot*bt-Re.x,Qe=Tt+rt*bt-Re.y;const ke=ze*ze+Qe*Qe;if(ke<=2)return new Ee(ze,Qe);Ye=Math.sqrt(ke/2)}else{let Ie=!1;ot>Number.EPSILON?mt>Number.EPSILON&&(Ie=!0):ot<-Number.EPSILON?mt<-Number.EPSILON&&(Ie=!0):Math.sign(rt)===Math.sign(j)&&(Ie=!0),Ie?(ze=-rt,Qe=ot,Ye=Math.sqrt(P)):(ze=ot,Qe=rt,Ye=Math.sqrt(P/2))}return new Ee(ze/Ye,Qe/Ye)}const de=[];for(let Re=0,Z=le.length,Ue=Z-1,ze=Re+1;Re<Z;Re++,Ue++,ze++)Ue===Z&&(Ue=0),ze===Z&&(ze=0),de[Re]=ee(le[Re],le[Ue],le[ze]);const ue=[];let Pe,He=de.concat();for(let Re=0,Z=se;Re<Z;Re++){const Ue=G[Re];Pe=[];for(let ze=0,Qe=Ue.length,Ye=Qe-1,ot=ze+1;ze<Qe;ze++,Ye++,ot++)Ye===Qe&&(Ye=0),ot===Qe&&(ot=0),Pe[ze]=ee(Ue[ze],Ue[Ye],Ue[ot]);ue.push(Pe),He=He.concat(Pe)}let Ke;if(S===0)Ke=Rs.triangulateShape(le,G);else{const Re=[],Z=[];for(let Ue=0;Ue<S;Ue++){const ze=Ue/S,Qe=g*Math.cos(ze*Math.PI/2),Ye=y*Math.sin(ze*Math.PI/2)+E;for(let ot=0,rt=le.length;ot<rt;ot++){const mt=q(le[ot],de[ot],Ye);ve(mt.x,mt.y,-Qe),ze===0&&Re.push(mt)}for(let ot=0,rt=se;ot<rt;ot++){const mt=G[ot];Pe=ue[ot];const j=[];for(let P=0,pe=mt.length;P<pe;P++){const Ie=q(mt[P],Pe[P],Ye);ve(Ie.x,Ie.y,-Qe),ze===0&&j.push(Ie)}ze===0&&Z.push(j)}}Ke=Rs.triangulateShape(Re,Z)}const nt=Ke.length,xt=y+E;for(let Re=0;Re<te;Re++){const Z=m?q(D[Re],He[Re],xt):D[Re];b?(L.copy(O.normals[0]).multiplyScalar(Z.x),N.copy(O.binormals[0]).multiplyScalar(Z.y),B.copy(A[0]).add(L).add(N),ve(B.x,B.y,B.z)):ve(Z.x,Z.y,0)}for(let Re=1;Re<=f;Re++)for(let Z=0;Z<te;Z++){const Ue=m?q(D[Z],He[Z],xt):D[Z];b?(L.copy(O.normals[Re]).multiplyScalar(Ue.x),N.copy(O.binormals[Re]).multiplyScalar(Ue.y),B.copy(A[Re]).add(L).add(N),ve(B.x,B.y,B.z)):ve(Ue.x,Ue.y,d/f*Re)}for(let Re=S-1;Re>=0;Re--){const Z=Re/S,Ue=g*Math.cos(Z*Math.PI/2),ze=y*Math.sin(Z*Math.PI/2)+E;for(let Qe=0,Ye=le.length;Qe<Ye;Qe++){const ot=q(le[Qe],de[Qe],ze);ve(ot.x,ot.y,d+Ue)}for(let Qe=0,Ye=G.length;Qe<Ye;Qe++){const ot=G[Qe];Pe=ue[Qe];for(let rt=0,mt=ot.length;rt<mt;rt++){const j=q(ot[rt],Pe[rt],ze);b?ve(j.x,j.y+A[f-1].y,A[f-1].x+Ue):ve(j.x,j.y,d+Ue)}}}fe(),Be();function fe(){const Re=a.length/3;if(m){let Z=0,Ue=te*Z;for(let ze=0;ze<nt;ze++){const Qe=Ke[ze];at(Qe[2]+Ue,Qe[1]+Ue,Qe[0]+Ue)}Z=f+S*2,Ue=te*Z;for(let ze=0;ze<nt;ze++){const Qe=Ke[ze];at(Qe[0]+Ue,Qe[1]+Ue,Qe[2]+Ue)}}else{for(let Z=0;Z<nt;Z++){const Ue=Ke[Z];at(Ue[2],Ue[1],Ue[0])}for(let Z=0;Z<nt;Z++){const Ue=Ke[Z];at(Ue[0]+te*f,Ue[1]+te*f,Ue[2]+te*f)}}i.addGroup(Re,a.length/3-Re,0)}function Be(){const Re=a.length/3;let Z=0;Je(le,Z),Z+=le.length;for(let Ue=0,ze=G.length;Ue<ze;Ue++){const Qe=G[Ue];Je(Qe,Z),Z+=Qe.length}i.addGroup(Re,a.length/3-Re,1)}function Je(Re,Z){let Ue=Re.length;for(;--Ue>=0;){const ze=Ue;let Qe=Ue-1;Qe<0&&(Qe=Re.length-1);for(let Ye=0,ot=f+S*2;Ye<ot;Ye++){const rt=te*Ye,mt=te*(Ye+1),j=Z+ze+rt,P=Z+Qe+rt,pe=Z+Qe+mt,Ie=Z+ze+mt;ft(j,P,pe,Ie)}}}function ve(Re,Z,Ue){c.push(Re),c.push(Z),c.push(Ue)}function at(Re,Z,Ue){ht(Re),ht(Z),ht(Ue);const ze=a.length/3,Qe=_.generateTopUV(i,a,ze-3,ze-2,ze-1);et(Qe[0]),et(Qe[1]),et(Qe[2])}function ft(Re,Z,Ue,ze){ht(Re),ht(Z),ht(ze),ht(Z),ht(Ue),ht(ze);const Qe=a.length/3,Ye=_.generateSideWallUV(i,a,Qe-6,Qe-3,Qe-2,Qe-1);et(Ye[0]),et(Ye[1]),et(Ye[3]),et(Ye[1]),et(Ye[2]),et(Ye[3])}function ht(Re){a.push(c[Re*3+0]),a.push(c[Re*3+1]),a.push(c[Re*3+2])}function et(Re){r.push(Re.x),r.push(Re.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 Uz(t,i,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const o=t[e.shapes[r]];i.push(o)}const a=e.options.extrudePath;return a!==void 0&&(e.options.extrudePath=new wx[a.type]().fromJSON(a)),new Dy(i,e.options)}}const Bz={generateTopUV:function(n,e,t,i,a){const r=e[t*3],s=e[t*3+1],o=e[i*3],c=e[i*3+1],h=e[a*3],f=e[a*3+1];return[new Ee(r,s),new Ee(o,c),new Ee(h,f)]},generateSideWallUV:function(n,e,t,i,a,r){const s=e[t*3],o=e[t*3+1],c=e[t*3+2],h=e[i*3],f=e[i*3+1],d=e[i*3+2],m=e[a*3],g=e[a*3+1],y=e[a*3+2],E=e[r*3],S=e[r*3+1],v=e[r*3+2];return Math.abs(o-f)<Math.abs(s-h)?[new Ee(s,1-c),new Ee(h,1-d),new Ee(m,1-y),new Ee(E,1-v)]:[new Ee(o,1-c),new Ee(f,1-d),new Ee(g,1-y),new Ee(S,1-v)]}};function Uz(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,a=n.length;i<a;i++){const r=n[i];t.shapes.push(r.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 B0 extends Ec{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,a=[-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],r=[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(a,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new B0(e.radius,e.detail)}}class Ny extends Xt{constructor(e=[new Ee(0,-.5),new Ee(.5,0),new Ee(0,.5)],t=12,i=0,a=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:a},t=Math.floor(t),a=Gt(a,0,Math.PI*2);const r=[],s=[],o=[],c=[],h=[],f=1/t,d=new H,m=new Ee,g=new H,y=new H,E=new H;let S=0,v=0;for(let _=0;_<=e.length-1;_++)switch(_){case 0:S=e[_+1].x-e[_].x,v=e[_+1].y-e[_].y,g.x=v*1,g.y=-S,g.z=v*0,E.copy(g),g.normalize(),c.push(g.x,g.y,g.z);break;case e.length-1:c.push(E.x,E.y,E.z);break;default:S=e[_+1].x-e[_].x,v=e[_+1].y-e[_].y,g.x=v*1,g.y=-S,g.z=v*0,y.copy(g),g.x+=E.x,g.y+=E.y,g.z+=E.z,g.normalize(),c.push(g.x,g.y,g.z),E.copy(y)}for(let _=0;_<=t;_++){const A=i+_*f*a,b=Math.sin(A),O=Math.cos(A);for(let N=0;N<=e.length-1;N++){d.x=e[N].x*b,d.y=e[N].y,d.z=e[N].x*O,s.push(d.x,d.y,d.z),m.x=_/t,m.y=N/(e.length-1),o.push(m.x,m.y);const L=c[3*N+0]*b,B=c[3*N+1],w=c[3*N+0]*O;h.push(L,B,w)}}for(let _=0;_<t;_++)for(let A=0;A<e.length-1;A++){const b=A+_*e.length,O=b,N=b+e.length,L=b+e.length+1,B=b+1;r.push(O,N,B),r.push(L,B,N)}this.setIndex(r),this.setAttribute("position",new Dt(s,3)),this.setAttribute("uv",new Dt(o,2)),this.setAttribute("normal",new Dt(h,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ny(e.points,e.segments,e.phiStart,e.phiLength)}}class U0 extends Ec{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],a=[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,a,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new U0(e.radius,e.detail)}}class Us extends Xt{constructor(e=1,t=1,i=1,a=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:a};const r=e/2,s=t/2,o=Math.floor(i),c=Math.floor(a),h=o+1,f=c+1,d=e/o,m=t/c,g=[],y=[],E=[],S=[];for(let v=0;v<f;v++){const _=v*m-s;for(let A=0;A<h;A++){const b=A*d-r;y.push(b,-_,0),E.push(0,0,1),S.push(A/o),S.push(1-v/c)}}for(let v=0;v<c;v++)for(let _=0;_<o;_++){const A=_+h*v,b=_+h*(v+1),O=_+1+h*(v+1),N=_+1+h*v;g.push(A,b,N),g.push(b,O,N)}this.setIndex(g),this.setAttribute("position",new Dt(y,3)),this.setAttribute("normal",new Dt(E,3)),this.setAttribute("uv",new Dt(S,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Us(e.width,e.height,e.widthSegments,e.heightSegments)}}class Oy extends Xt{constructor(e=.5,t=1,i=32,a=1,r=0,s=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:a,thetaStart:r,thetaLength:s},i=Math.max(3,i),a=Math.max(1,a);const o=[],c=[],h=[],f=[];let d=e;const m=(t-e)/a,g=new H,y=new Ee;for(let E=0;E<=a;E++){for(let S=0;S<=i;S++){const v=r+S/i*s;g.x=d*Math.cos(v),g.y=d*Math.sin(v),c.push(g.x,g.y,g.z),h.push(0,0,1),y.x=(g.x/t+1)/2,y.y=(g.y/t+1)/2,f.push(y.x,y.y)}d+=m}for(let E=0;E<a;E++){const S=E*(i+1);for(let v=0;v<i;v++){const _=v+S,A=_,b=_+i+1,O=_+i+2,N=_+1;o.push(A,b,N),o.push(b,O,N)}}this.setIndex(o),this.setAttribute("position",new Dt(c,3)),this.setAttribute("normal",new Dt(h,3)),this.setAttribute("uv",new Dt(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Oy(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Iy extends Xt{constructor(e=new Nu([new Ee(0,.5),new Ee(-.5,-.5),new Ee(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],a=[],r=[],s=[];let o=0,c=0;if(Array.isArray(e)===!1)h(e);else for(let f=0;f<e.length;f++)h(e[f]),this.addGroup(o,c,f),o+=c,c=0;this.setIndex(i),this.setAttribute("position",new Dt(a,3)),this.setAttribute("normal",new Dt(r,3)),this.setAttribute("uv",new Dt(s,2));function h(f){const d=a.length/3,m=f.extractPoints(t);let g=m.shape;const y=m.holes;Rs.isClockWise(g)===!1&&(g=g.reverse());for(let S=0,v=y.length;S<v;S++){const _=y[S];Rs.isClockWise(_)===!0&&(y[S]=_.reverse())}const E=Rs.triangulateShape(g,y);for(let S=0,v=y.length;S<v;S++){const _=y[S];g=g.concat(_)}for(let S=0,v=g.length;S<v;S++){const _=g[S];a.push(_.x,_.y,0),r.push(0,0,1),s.push(_.x,_.y)}for(let S=0,v=E.length;S<v;S++){const _=E[S],A=_[0]+d,b=_[1]+d,O=_[2]+d;i.push(A,b,O),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Lz(t,e)}static fromJSON(e,t){const i=[];for(let a=0,r=e.shapes.length;a<r;a++){const s=t[e.shapes[a]];i.push(s)}return new Iy(i,e.curveSegments)}}function Lz(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const a=n[t];e.shapes.push(a.uuid)}else e.shapes.push(n.uuid);return e}class L0 extends Xt{constructor(e=1,t=32,i=16,a=0,r=Math.PI*2,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:a,phiLength:r,thetaStart:s,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const c=Math.min(s+o,Math.PI);let h=0;const f=[],d=new H,m=new H,g=[],y=[],E=[],S=[];for(let v=0;v<=i;v++){const _=[],A=v/i;let b=0;v===0&&s===0?b=.5/t:v===i&&c===Math.PI&&(b=-.5/t);for(let O=0;O<=t;O++){const N=O/t;d.x=-e*Math.cos(a+N*r)*Math.sin(s+A*o),d.y=e*Math.cos(s+A*o),d.z=e*Math.sin(a+N*r)*Math.sin(s+A*o),y.push(d.x,d.y,d.z),m.copy(d).normalize(),E.push(m.x,m.y,m.z),S.push(N+b,1-A),_.push(h++)}f.push(_)}for(let v=0;v<i;v++)for(let _=0;_<t;_++){const A=f[v][_+1],b=f[v][_],O=f[v+1][_],N=f[v+1][_+1];(v!==0||s>0)&&g.push(A,b,N),(v!==i-1||c<Math.PI)&&g.push(b,O,N)}this.setIndex(g),this.setAttribute("position",new Dt(y,3)),this.setAttribute("normal",new Dt(E,3)),this.setAttribute("uv",new Dt(S,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new L0(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class By extends Ec{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],a=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,a,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new By(e.radius,e.detail)}}class Uy extends Xt{constructor(e=1,t=.4,i=12,a=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:a,arc:r},i=Math.floor(i),a=Math.floor(a);const s=[],o=[],c=[],h=[],f=new H,d=new H,m=new H;for(let g=0;g<=i;g++)for(let y=0;y<=a;y++){const E=y/a*r,S=g/i*Math.PI*2;d.x=(e+t*Math.cos(S))*Math.cos(E),d.y=(e+t*Math.cos(S))*Math.sin(E),d.z=t*Math.sin(S),o.push(d.x,d.y,d.z),f.x=e*Math.cos(E),f.y=e*Math.sin(E),m.subVectors(d,f).normalize(),c.push(m.x,m.y,m.z),h.push(y/a),h.push(g/i)}for(let g=1;g<=i;g++)for(let y=1;y<=a;y++){const E=(a+1)*g+y-1,S=(a+1)*(g-1)+y-1,v=(a+1)*(g-1)+y,_=(a+1)*g+y;s.push(E,S,_),s.push(S,v,_)}this.setIndex(s),this.setAttribute("position",new Dt(o,3)),this.setAttribute("normal",new Dt(c,3)),this.setAttribute("uv",new Dt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Uy(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Ly extends Xt{constructor(e=1,t=.4,i=64,a=8,r=2,s=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:a,p:r,q:s},i=Math.floor(i),a=Math.floor(a);const o=[],c=[],h=[],f=[],d=new H,m=new H,g=new H,y=new H,E=new H,S=new H,v=new H;for(let A=0;A<=i;++A){const b=A/i*r*Math.PI*2;_(b,r,s,e,g),_(b+.01,r,s,e,y),S.subVectors(y,g),v.addVectors(y,g),E.crossVectors(S,v),v.crossVectors(E,S),E.normalize(),v.normalize();for(let O=0;O<=a;++O){const N=O/a*Math.PI*2,L=-t*Math.cos(N),B=t*Math.sin(N);d.x=g.x+(L*v.x+B*E.x),d.y=g.y+(L*v.y+B*E.y),d.z=g.z+(L*v.z+B*E.z),c.push(d.x,d.y,d.z),m.subVectors(d,g).normalize(),h.push(m.x,m.y,m.z),f.push(A/i),f.push(O/a)}}for(let A=1;A<=i;A++)for(let b=1;b<=a;b++){const O=(a+1)*(A-1)+(b-1),N=(a+1)*A+(b-1),L=(a+1)*A+b,B=(a+1)*(A-1)+b;o.push(O,N,B),o.push(N,L,B)}this.setIndex(o),this.setAttribute("position",new Dt(c,3)),this.setAttribute("normal",new Dt(h,3)),this.setAttribute("uv",new Dt(f,2));function _(A,b,O,N,L){const B=Math.cos(A),w=Math.sin(A),D=O/b*A,G=Math.cos(D);L.x=N*(2+G)*.5*B,L.y=N*(2+G)*w*.5,L.z=N*Math.sin(D)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ly(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Py extends Xt{constructor(e=new J3(new H(-1,-1,0),new H(-1,1,0),new H(1,1,0)),t=64,i=1,a=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:a,closed:r};const s=e.computeFrenetFrames(t,r);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const o=new H,c=new H,h=new Ee;let f=new H;const d=[],m=[],g=[],y=[];E(),this.setIndex(y),this.setAttribute("position",new Dt(d,3)),this.setAttribute("normal",new Dt(m,3)),this.setAttribute("uv",new Dt(g,2));function E(){for(let A=0;A<t;A++)S(A);S(r===!1?t:0),_(),v()}function S(A){f=e.getPointAt(A/t,f);const b=s.normals[A],O=s.binormals[A];for(let N=0;N<=a;N++){const L=N/a*Math.PI*2,B=Math.sin(L),w=-Math.cos(L);c.x=w*b.x+B*O.x,c.y=w*b.y+B*O.y,c.z=w*b.z+B*O.z,c.normalize(),m.push(c.x,c.y,c.z),o.x=f.x+i*c.x,o.y=f.y+i*c.y,o.z=f.z+i*c.z,d.push(o.x,o.y,o.z)}}function v(){for(let A=1;A<=t;A++)for(let b=1;b<=a;b++){const O=(a+1)*(A-1)+(b-1),N=(a+1)*A+(b-1),L=(a+1)*A+b,B=(a+1)*(A-1)+b;y.push(O,N,B),y.push(N,L,B)}}function _(){for(let A=0;A<=t;A++)for(let b=0;b<=a;b++)h.x=A/t,h.y=b/a,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 Py(new wx[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class TB extends Xt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,a=new H,r=new H;if(e.index!==null){const s=e.attributes.position,o=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:o.count,materialIndex:0}]);for(let h=0,f=c.length;h<f;++h){const d=c[h],m=d.start,g=d.count;for(let y=m,E=m+g;y<E;y+=3)for(let S=0;S<3;S++){const v=o.getX(y+S),_=o.getX(y+(S+1)%3);a.fromBufferAttribute(s,v),r.fromBufferAttribute(s,_),g4(a,r,i)===!0&&(t.push(a.x,a.y,a.z),t.push(r.x,r.y,r.z))}}}else{const s=e.attributes.position;for(let o=0,c=s.count/3;o<c;o++)for(let h=0;h<3;h++){const f=3*o+h,d=3*o+(h+1)%3;a.fromBufferAttribute(s,f),r.fromBufferAttribute(s,d),g4(a,r,i)===!0&&(t.push(a.x,a.y,a.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new Dt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function g4(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,a=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(a)===!0?!1:(t.add(i),t.add(a),!0)}var v4=Object.freeze({__proto__:null,BoxGeometry:lh,CapsuleGeometry:My,CircleGeometry:Cy,ConeGeometry:I0,CylinderGeometry:O0,DodecahedronGeometry:Ry,EdgesGeometry:pB,ExtrudeGeometry:Dy,IcosahedronGeometry:B0,LatheGeometry:Ny,OctahedronGeometry:U0,PlaneGeometry:Us,PolyhedronGeometry:Ec,RingGeometry:Oy,ShapeGeometry:Iy,SphereGeometry:L0,TetrahedronGeometry:By,TorusGeometry:Uy,TorusKnotGeometry:Ly,TubeGeometry:Py,WireframeGeometry:TB});class bB extends ri{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new dt(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 cl extends Di{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class P0 extends ri{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new dt(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 dt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new Ee(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 Dr,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 us extends P0{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 Ee(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Gt(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 dt(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 dt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new dt(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 MB extends ri{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new dt(16777215),this.specular=new dt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new dt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new Ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Dr,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 CB extends ri{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new dt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new dt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new Ee(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 $3 extends ri{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new Ee(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 RB extends ri{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new dt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new dt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new Ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Dr,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 eb extends ri{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Sc,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 tb extends ri{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 wB extends ri{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new dt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ac,this.normalScale=new Ee(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 DB extends Ca{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 yu(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function NB(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function OB(n){function e(a,r){return n[a]-n[r]}const t=n.length,i=new Array(t);for(let a=0;a!==t;++a)i[a]=a;return i.sort(e),i}function BE(n,e,t){const i=n.length,a=new n.constructor(i);for(let r=0,s=0;s!==i;++r){const o=t[r]*e;for(let c=0;c!==e;++c)a[s++]=n[o+c]}return a}function nb(n,e,t,i){let a=1,r=n[0];for(;r!==void 0&&r[i]===void 0;)r=n[a++];if(r===void 0)return;let s=r[i];if(s!==void 0)if(Array.isArray(s))do s=r[i],s!==void 0&&(e.push(r.time),t.push(...s)),r=n[a++];while(r!==void 0);else if(s.toArray!==void 0)do s=r[i],s!==void 0&&(e.push(r.time),s.toArray(t,t.length)),r=n[a++];while(r!==void 0);else do s=r[i],s!==void 0&&(e.push(r.time),t.push(s)),r=n[a++];while(r!==void 0)}function Pz(n,e,t,i,a=30){const r=n.clone();r.name=e;const s=[];for(let c=0;c<r.tracks.length;++c){const h=r.tracks[c],f=h.getValueSize(),d=[],m=[];for(let g=0;g<h.times.length;++g){const y=h.times[g]*a;if(!(y<t||y>=i)){d.push(h.times[g]);for(let E=0;E<f;++E)m.push(h.values[g*f+E])}}d.length!==0&&(h.times=yu(d,h.times.constructor),h.values=yu(m,h.values.constructor),s.push(h))}r.tracks=s;let o=1/0;for(let c=0;c<r.tracks.length;++c)o>r.tracks[c].times[0]&&(o=r.tracks[c].times[0]);for(let c=0;c<r.tracks.length;++c)r.tracks[c].shift(-1*o);return r.resetDuration(),r}function Fz(n,e=0,t=n,i=30){i<=0&&(i=30);const a=t.tracks.length,r=e/i;for(let s=0;s<a;++s){const o=t.tracks[s],c=o.ValueTypeName;if(c==="bool"||c==="string")continue;const h=n.tracks.find(function(v){return v.name===o.name&&v.ValueTypeName===c});if(h===void 0)continue;let f=0;const d=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);let m=0;const g=h.getValueSize();h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(m=g/3);const y=o.times.length-1;let E;if(r<=o.times[0]){const v=f,_=d-f;E=o.values.slice(v,_)}else if(r>=o.times[y]){const v=y*d+f,_=v+d-f;E=o.values.slice(v,_)}else{const v=o.createInterpolant(),_=f,A=d-f;v.evaluate(r),E=v.resultBuffer.slice(_,A)}c==="quaternion"&&new Yi().fromArray(E).normalize().conjugate().toArray(E);const S=h.times.length;for(let v=0;v<S;++v){const _=v*g+m;if(c==="quaternion")Yi.multiplyQuaternionsFlat(h.values,_,E,0,h.values,_);else{const A=g-m*2;for(let b=0;b<A;++b)h.values[_+b]-=E[b]}}}return n.blendMode=O3,n}class Hz{static convertArray(e,t){return yu(e,t)}static isTypedArray(e){return NB(e)}static getKeyframeOrder(e){return OB(e)}static sortedArray(e,t,i){return BE(e,t,i)}static flattenJSON(e,t,i,a){nb(e,t,i,a)}static subclip(e,t,i,a,r=30){return Pz(e,t,i,a,r)}static makeClipAdditive(e,t=0,i=e,a=30){return Fz(e,t,i,a)}}class zd{constructor(e,t,i,a){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=a!==void 0?a: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,a=t[i],r=t[i-1];e:{t:{let s;n:{i:if(!(e<a)){for(let o=i+2;;){if(a===void 0){if(e<r)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(r=a,a=t[++i],e<a)break t}s=t.length;break n}if(!(e>=r)){const o=t[1];e<o&&(i=2,r=o);for(let c=i-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(a=r,r=t[--i-1],e>=r)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(a=t[i],r=t[i-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(a===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,a)}return this.interpolate_(i,r,e,a)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,a=this.valueSize,r=e*a;for(let s=0;s!==a;++s)t[s]=i[r+s];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class IB extends zd{constructor(e,t,i,a){super(e,t,i,a),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:vu,endingEnd:vu}}intervalChanged_(e,t,i){const a=this.parameterPositions;let r=e-2,s=e+1,o=a[r],c=a[s];if(o===void 0)switch(this.getSettings_().endingStart){case xu:r=e,o=2*t-i;break;case t0:r=a.length-2,o=t+a[r]-a[r+1];break;default:r=e,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case xu:s=e,c=2*i-t;break;case t0:s=1,c=i+a[1]-a[0];break;default:s=e-1,c=t}const h=(i-t)*.5,f=this.valueSize;this._weightPrev=h/(t-o),this._weightNext=h/(c-i),this._offsetPrev=r*f,this._offsetNext=s*f}interpolate_(e,t,i,a){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,c=e*o,h=c-o,f=this._offsetPrev,d=this._offsetNext,m=this._weightPrev,g=this._weightNext,y=(i-t)/(a-t),E=y*y,S=E*y,v=-m*S+2*m*E-m*y,_=(1+m)*S+(-1.5-2*m)*E+(-.5+m)*y+1,A=(-1-g)*S+(1.5+g)*E+.5*y,b=g*S-g*E;for(let O=0;O!==o;++O)r[O]=v*s[f+O]+_*s[h+O]+A*s[c+O]+b*s[d+O];return r}}class ib extends zd{constructor(e,t,i,a){super(e,t,i,a)}interpolate_(e,t,i,a){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,c=e*o,h=c-o,f=(i-t)/(a-t),d=1-f;for(let m=0;m!==o;++m)r[m]=s[h+m]*d+s[c+m]*f;return r}}class BB extends zd{constructor(e,t,i,a){super(e,t,i,a)}interpolate_(e){return this.copySampleValue_(e-1)}}class hs{constructor(e,t,i,a){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=yu(t,this.TimeBufferType),this.values=yu(i,this.ValueBufferType),this.setInterpolation(a||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:yu(e.times,Array),values:yu(e.values,Array)};const a=e.getInterpolation();a!==e.DefaultInterpolation&&(i.interpolation=a)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new BB(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new ib(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new IB(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case pd:t=this.InterpolantFactoryMethodDiscrete;break;case md:t=this.InterpolantFactoryMethodLinear;break;case u1: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 _t("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return pd;case this.InterpolantFactoryMethodLinear:return md;case this.InterpolantFactoryMethodSmooth:return u1}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,a=t.length;i!==a;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,a=t.length;i!==a;++i)t[i]*=e}return this}trim(e,t){const i=this.times,a=i.length;let r=0,s=a-1;for(;r!==a&&i[r]<e;)++r;for(;s!==-1&&i[s]>t;)--s;if(++s,r!==0||s!==a){r>=s&&(s=Math.max(s,1),r=s-1);const o=this.getValueSize();this.times=i.slice(r,s),this.values=this.values.slice(r*o,s*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(qt("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,a=this.values,r=i.length;r===0&&(qt("KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let o=0;o!==r;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){qt("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(s!==null&&s>c){qt("KeyframeTrack: Out of order keys.",this,o,c,s),e=!1;break}s=c}if(a!==void 0&&NB(a))for(let o=0,c=a.length;o!==c;++o){const h=a[o];if(isNaN(h)){qt("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(),a=this.getInterpolation()===u1,r=e.length-1;let s=1;for(let o=1;o<r;++o){let c=!1;const h=e[o],f=e[o+1];if(h!==f&&(o!==1||h!==e[0]))if(a)c=!0;else{const d=o*i,m=d-i,g=d+i;for(let y=0;y!==i;++y){const E=t[d+y];if(E!==t[m+y]||E!==t[g+y]){c=!0;break}}}if(c){if(o!==s){e[s]=e[o];const d=o*i,m=s*i;for(let g=0;g!==i;++g)t[m+g]=t[d+g]}++s}}if(r>0){e[s]=e[r];for(let o=r*i,c=s*i,h=0;h!==i;++h)t[c+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,a=new i(this.name,e,t);return a.createInterpolant=this.createInterpolant,a}}hs.prototype.ValueTypeName="";hs.prototype.TimeBufferType=Float32Array;hs.prototype.ValueBufferType=Float32Array;hs.prototype.DefaultInterpolation=md;class ch extends hs{constructor(e,t,i){super(e,t,i)}}ch.prototype.ValueTypeName="bool";ch.prototype.ValueBufferType=Array;ch.prototype.DefaultInterpolation=pd;ch.prototype.InterpolantFactoryMethodLinear=void 0;ch.prototype.InterpolantFactoryMethodSmooth=void 0;class ab extends hs{constructor(e,t,i,a){super(e,t,i,a)}}ab.prototype.ValueTypeName="color";class qu extends hs{constructor(e,t,i,a){super(e,t,i,a)}}qu.prototype.ValueTypeName="number";class UB extends zd{constructor(e,t,i,a){super(e,t,i,a)}interpolate_(e,t,i,a){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,c=(i-t)/(a-t);let h=e*o;for(let f=h+o;h!==f;h+=4)Yi.slerpFlat(r,0,s,h-o,s,h,c);return r}}class Zu extends hs{constructor(e,t,i,a){super(e,t,i,a)}InterpolantFactoryMethodLinear(e){return new UB(this.times,this.values,this.getValueSize(),e)}}Zu.prototype.ValueTypeName="quaternion";Zu.prototype.InterpolantFactoryMethodSmooth=void 0;class uh extends hs{constructor(e,t,i){super(e,t,i)}}uh.prototype.ValueTypeName="string";uh.prototype.ValueBufferType=Array;uh.prototype.DefaultInterpolation=pd;uh.prototype.InterpolantFactoryMethodLinear=void 0;uh.prototype.InterpolantFactoryMethodSmooth=void 0;class ju extends hs{constructor(e,t,i,a){super(e,t,i,a)}}ju.prototype.ValueTypeName="vector";class Ad{constructor(e="",t=-1,i=[],a=xy){this.name=e,this.tracks=i,this.duration=t,this.blendMode=a,this.uuid=Cr(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,a=1/(e.fps||1);for(let s=0,o=i.length;s!==o;++s)t.push(Gz(i[s]).scale(a));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],i=e.tracks,a={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,s=i.length;r!==s;++r)t.push(hs.toJSON(i[r]));return a}static CreateFromMorphTargetSequence(e,t,i,a){const r=t.length,s=[];for(let o=0;o<r;o++){let c=[],h=[];c.push((o+r-1)%r,o,(o+1)%r),h.push(0,1,0);const f=OB(c);c=BE(c,1,f),h=BE(h,1,f),!a&&c[0]===0&&(c.push(r),h.push(h[0])),s.push(new qu(".morphTargetInfluences["+t[o].name+"]",c,h).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const a=e;i=a.geometry&&a.geometry.animations||a.animations}for(let a=0;a<i.length;a++)if(i[a].name===t)return i[a];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const a={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const h=e[o],f=h.name.match(r);if(f&&f.length>1){const d=f[1];let m=a[d];m||(a[d]=m=[]),m.push(h)}}const s=[];for(const o in a)s.push(this.CreateFromMorphTargetSequence(o,a[o],t,i));return s}static parseAnimation(e,t){if(_t("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return qt("AnimationClip: No animation in JSONLoader data."),null;const i=function(d,m,g,y,E){if(g.length!==0){const S=[],v=[];nb(g,S,v,y),S.length!==0&&E.push(new d(m,S,v))}},a=[],r=e.name||"default",s=e.fps||30,o=e.blendMode;let c=e.length||-1;const h=e.hierarchy||[];for(let d=0;d<h.length;d++){const m=h[d].keys;if(!(!m||m.length===0))if(m[0].morphTargets){const g={};let y;for(y=0;y<m.length;y++)if(m[y].morphTargets)for(let E=0;E<m[y].morphTargets.length;E++)g[m[y].morphTargets[E]]=-1;for(const E in g){const S=[],v=[];for(let _=0;_!==m[y].morphTargets.length;++_){const A=m[y];S.push(A.time),v.push(A.morphTarget===E?1:0)}a.push(new qu(".morphTargetInfluence["+E+"]",S,v))}c=g.length*s}else{const g=".bones["+t[d].name+"]";i(ju,g+".position",m,"pos",a),i(Zu,g+".quaternion",m,"rot",a),i(ju,g+".scale",m,"scl",a)}}return a.length===0?null:new this(r,c,a,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,a=e.length;i!==a;++i){const r=this.tracks[i];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){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 zz(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return qu;case"vector":case"vector2":case"vector3":case"vector4":return ju;case"color":return ab;case"quaternion":return Zu;case"bool":case"boolean":return ch;case"string":return uh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function Gz(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=zz(n.type);if(n.times===void 0){const t=[],i=[];nb(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 Js={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 Fy{constructor(e,t,i){const a=this;let r=!1,s=0,o=0,c;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(f){o++,r===!1&&a.onStart!==void 0&&a.onStart(f,s,o),r=!0},this.itemEnd=function(f){s++,a.onProgress!==void 0&&a.onProgress(f,s,o),s===o&&(r=!1,a.onLoad!==void 0&&a.onLoad())},this.itemError=function(f){a.onError!==void 0&&a.onError(f)},this.resolveURL=function(f){return c?c(f):f},this.setURLModifier=function(f){return c=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,m=h.length;d<m;d+=2){const g=h[d],y=h[d+1];if(g.global&&(g.lastIndex=0),g.test(f))return y}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 LB=new Fy;class yi{constructor(e){this.manager=e!==void 0?e:LB,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(a,r){i.load(e,a,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}yi.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ro={};class Vz extends Error{constructor(e,t){super(e),this.response=t}}class oa extends yi{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,i,a){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Js.get(`file:${e}`);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Ro[e]!==void 0){Ro[e].push({onLoad:t,onProgress:i,onError:a});return}Ro[e]=[],Ro[e].push({onLoad:t,onProgress:i,onError:a});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,c=this.responseType;fetch(s).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&_t("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const f=Ro[e],d=h.body.getReader(),m=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),g=m?parseInt(m):0,y=g!==0;let E=0;const S=new ReadableStream({start(v){_();function _(){d.read().then(({done:A,value:b})=>{if(A)v.close();else{E+=b.byteLength;const O=new ProgressEvent("progress",{lengthComputable:y,loaded:E,total:g});for(let N=0,L=f.length;N<L;N++){const B=f[N];B.onProgress&&B.onProgress(O)}v.enqueue(b),_()}},A=>{v.error(A)})}}});return new Response(S)}else throw new Vz(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(c){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),m=d&&d[1]?d[1].toLowerCase():void 0,g=new TextDecoder(m);return h.arrayBuffer().then(y=>g.decode(y))}}}).then(h=>{Js.add(`file:${e}`,h);const f=Ro[e];delete Ro[e];for(let d=0,m=f.length;d<m;d++){const g=f[d];g.onLoad&&g.onLoad(h)}}).catch(h=>{const f=Ro[e];if(f===void 0)throw this.manager.itemError(e),h;delete Ro[e];for(let d=0,m=f.length;d<m;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 kz extends yi{constructor(e){super(e)}load(e,t,i,a){const r=this,s=new oa(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(c){a?a(c):qt(c),r.manager.itemError(e)}},i,a)}parse(e){const t=[];for(let i=0;i<e.length;i++){const a=Ad.parse(e[i]);t.push(a)}return t}}class Xz extends yi{constructor(e){super(e)}load(e,t,i,a){const r=this,s=[],o=new by,c=new oa(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(r.withCredentials);let h=0;function f(d){c.load(e[d],function(m){const g=r.parse(m,!0);s[d]={width:g.width,height:g.height,format:g.format,mipmaps:g.mipmaps},h+=1,h===6&&(g.mipmapCount===1&&(o.minFilter=Bt),o.image=s,o.format=g.format,o.needsUpdate=!0,t&&t(o))},i,a)}if(Array.isArray(e))for(let d=0,m=e.length;d<m;++d)f(d);else c.load(e,function(d){const m=r.parse(d,!0);if(m.isCubemap){const g=m.mipmaps.length/m.mipmapCount;for(let y=0;y<g;y++){s[y]={mipmaps:[]};for(let E=0;E<m.mipmapCount;E++)s[y].mipmaps.push(m.mipmaps[y*m.mipmapCount+E]),s[y].format=m.format,s[y].width=m.width,s[y].height=m.height}o.image=s}else o.image.width=m.width,o.image.height=m.height,o.mipmaps=m.mipmaps;m.mipmapCount===1&&(o.minFilter=Bt),o.format=m.format,o.needsUpdate=!0,t&&t(o)},i,a);return o}}const sf=new WeakMap;class c0 extends yi{constructor(e){super(e)}load(e,t,i,a){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=Js.get(`image:${e}`);if(s!==void 0){if(s.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(s),r.manager.itemEnd(e)},0);else{let d=sf.get(s);d===void 0&&(d=[],sf.set(s,d)),d.push({onLoad:t,onError:a})}return s}const o=a0("img");function c(){f(),t&&t(this);const d=sf.get(this)||[];for(let m=0;m<d.length;m++){const g=d[m];g.onLoad&&g.onLoad(this)}sf.delete(this),r.manager.itemEnd(e)}function h(d){f(),a&&a(d),Js.remove(`image:${e}`);const m=sf.get(this)||[];for(let g=0;g<m.length;g++){const y=m[g];y.onError&&y.onError(d)}sf.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function f(){o.removeEventListener("load",c,!1),o.removeEventListener("error",h,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Js.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class PB extends yi{constructor(e){super(e)}load(e,t,i,a){const r=new w0;r.colorSpace=Kn;const s=new c0(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let o=0;function c(h){s.load(e[h],function(f){r.images[h]=f,o++,o===6&&(r.needsUpdate=!0,t&&t(r))},void 0,a)}for(let h=0;h<e.length;++h)c(h);return r}}class Hy extends yi{constructor(e){super(e)}load(e,t,i,a){const r=this,s=new Pa,o=new oa(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,function(c){let h;try{h=r.parse(c)}catch(f){if(a!==void 0)a(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:Vn,s.wrapT=h.wrapT!==void 0?h.wrapT:Vn,s.magFilter=h.magFilter!==void 0?h.magFilter:Bt,s.minFilter=h.minFilter!==void 0?h.minFilter:Bt,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=Sr),h.mipmapCount===1&&(s.minFilter=Bt),h.generateMipmaps!==void 0&&(s.generateMipmaps=h.generateMipmaps),s.needsUpdate=!0,t&&t(s,h)},i,a),s}}class rb extends yi{constructor(e){super(e)}load(e,t,i,a){const r=new vn,s=new c0(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},i,a),r}}class Tc extends fn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new dt(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 FB extends Tc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(fn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new dt(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const XA=new lt,x4=new H,y4=new H;class sb{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ee(512,512),this.mapType=xi,this.map=null,this.mapPass=null,this.matrix=new lt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Hd,this._frameExtents=new Ee(1,1),this._viewportCount=1,this._viewports=[new Yt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;x4.setFromMatrixPosition(e.matrixWorld),t.position.copy(x4),y4.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(y4),t.updateMatrixWorld(),XA.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(XA,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(XA)}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 Wz extends sb{constructor(){super(new Jn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,i=xd*2*e.angle*this.focus,a=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(i!==t.fov||a!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=a,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class ob extends Tc{constructor(e,t,i=0,a=Math.PI/3,r=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(fn.DEFAULT_UP),this.updateMatrix(),this.target=new fn,this.distance=i,this.angle=a,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Wz}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 _4=new lt,Fp=new H,WA=new H;class Yz extends sb{constructor(){super(new Jn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ee(4,2),this._viewportCount=6,this._viewports=[new Yt(2,1,1,1),new Yt(0,1,1,1),new Yt(3,1,1,1),new Yt(1,1,1,1),new Yt(3,0,1,1),new Yt(1,0,1,1)],this._cubeDirections=[new H(1,0,0),new H(-1,0,0),new H(0,0,1),new H(0,0,-1),new H(0,1,0),new H(0,-1,0)],this._cubeUps=[new H(0,1,0),new H(0,1,0),new H(0,1,0),new H(0,1,0),new H(0,0,1),new H(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,a=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),Fp.setFromMatrixPosition(e.matrixWorld),i.position.copy(Fp),WA.copy(i.position),WA.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(WA),i.updateMatrixWorld(),a.makeTranslation(-Fp.x,-Fp.y,-Fp.z),_4.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_4,i.coordinateSystem,i.reversedDepth)}}class lb extends Tc{constructor(e,t,i=0,a=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=a,this.shadow=new Yz}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 Rr extends so{constructor(e=-1,t=1,i=1,a=-1,r=.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=a,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,a,r,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=a,this.view.width=r,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,a=(this.top+this.bottom)/2;let r=i-e,s=i+e,o=a+t,c=a-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;r+=h*this.view.offsetX,s=r+h*this.view.width,o-=f*this.view.offsetY,c=o-f*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,c,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 qz extends sb{constructor(){super(new Rr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class cb extends Tc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(fn.DEFAULT_UP),this.updateMatrix(),this.target=new fn,this.shadow=new qz}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class HB extends Tc{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class zB extends Tc{constructor(e,t,i=10,a=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=a}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 GB{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new H)}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,a=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*a),t.addScaledVector(s[2],.488603*r),t.addScaledVector(s[3],.488603*i),t.addScaledVector(s[4],1.092548*(i*a)),t.addScaledVector(s[5],1.092548*(a*r)),t.addScaledVector(s[6],.315392*(3*r*r-1)),t.addScaledVector(s[7],1.092548*(i*r)),t.addScaledVector(s[8],.546274*(i*i-a*a)),t}getIrradianceAt(e,t){const i=e.x,a=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],2*.511664*a),t.addScaledVector(s[2],2*.511664*r),t.addScaledVector(s[3],2*.511664*i),t.addScaledVector(s[4],2*.429043*i*a),t.addScaledVector(s[5],2*.429043*a*r),t.addScaledVector(s[6],.743125*r*r-.247708),t.addScaledVector(s[7],2*.429043*i*r),t.addScaledVector(s[8],.429043*(i*i-a*a)),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 a=0;a<9;a++)i[a].fromArray(e,t+a*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let a=0;a<9;a++)i[a].toArray(e,t+a*3);return e}static getBasisAt(e,t){const i=e.x,a=e.y,r=e.z;t[0]=.282095,t[1]=.488603*a,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*a,t[5]=1.092548*a*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-a*a)}}class VB extends Tc{constructor(e=new GB,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 zy extends yi{constructor(e){super(e),this.textures={}}load(e,t,i,a){const r=this,s=new oa(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(c){a?a(c):qt(c),r.manager.itemError(e)}},i,a)}parse(e){const t=this.textures;function i(r){return t[r]===void 0&&_t("MaterialLoader: Undefined texture",r),t[r]}const a=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(a.uuid=e.uuid),e.name!==void 0&&(a.name=e.name),e.color!==void 0&&a.color!==void 0&&a.color.setHex(e.color),e.roughness!==void 0&&(a.roughness=e.roughness),e.metalness!==void 0&&(a.metalness=e.metalness),e.sheen!==void 0&&(a.sheen=e.sheen),e.sheenColor!==void 0&&(a.sheenColor=new dt().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(a.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&a.emissive!==void 0&&a.emissive.setHex(e.emissive),e.specular!==void 0&&a.specular!==void 0&&a.specular.setHex(e.specular),e.specularIntensity!==void 0&&(a.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&a.specularColor!==void 0&&a.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(a.shininess=e.shininess),e.clearcoat!==void 0&&(a.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(a.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(a.dispersion=e.dispersion),e.iridescence!==void 0&&(a.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(a.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(a.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(a.transmission=e.transmission),e.thickness!==void 0&&(a.thickness=e.thickness),e.attenuationDistance!==void 0&&(a.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&a.attenuationColor!==void 0&&a.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(a.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(a.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(a.fog=e.fog),e.flatShading!==void 0&&(a.flatShading=e.flatShading),e.blending!==void 0&&(a.blending=e.blending),e.combine!==void 0&&(a.combine=e.combine),e.side!==void 0&&(a.side=e.side),e.shadowSide!==void 0&&(a.shadowSide=e.shadowSide),e.opacity!==void 0&&(a.opacity=e.opacity),e.transparent!==void 0&&(a.transparent=e.transparent),e.alphaTest!==void 0&&(a.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(a.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(a.depthFunc=e.depthFunc),e.depthTest!==void 0&&(a.depthTest=e.depthTest),e.depthWrite!==void 0&&(a.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(a.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(a.blendSrc=e.blendSrc),e.blendDst!==void 0&&(a.blendDst=e.blendDst),e.blendEquation!==void 0&&(a.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(a.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(a.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(a.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&a.blendColor!==void 0&&a.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(a.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(a.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(a.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(a.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(a.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(a.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(a.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(a.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(a.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(a.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(a.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(a.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(a.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(a.rotation=e.rotation),e.linewidth!==void 0&&(a.linewidth=e.linewidth),e.dashSize!==void 0&&(a.dashSize=e.dashSize),e.gapSize!==void 0&&(a.gapSize=e.gapSize),e.scale!==void 0&&(a.scale=e.scale),e.polygonOffset!==void 0&&(a.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(a.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(a.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(a.dithering=e.dithering),e.alphaToCoverage!==void 0&&(a.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(a.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(a.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(a.visible=e.visible),e.toneMapped!==void 0&&(a.toneMapped=e.toneMapped),e.userData!==void 0&&(a.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?a.vertexColors=e.vertexColors>0:a.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const s=e.uniforms[r];switch(a.uniforms[r]={},s.type){case"t":a.uniforms[r].value=i(s.value);break;case"c":a.uniforms[r].value=new dt().setHex(s.value);break;case"v2":a.uniforms[r].value=new Ee().fromArray(s.value);break;case"v3":a.uniforms[r].value=new H().fromArray(s.value);break;case"v4":a.uniforms[r].value=new Yt().fromArray(s.value);break;case"m3":a.uniforms[r].value=new kt().fromArray(s.value);break;case"m4":a.uniforms[r].value=new lt().fromArray(s.value);break;default:a.uniforms[r].value=s.value}}if(e.defines!==void 0&&(a.defines=e.defines),e.vertexShader!==void 0&&(a.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(a.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(a.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)a.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(a.lights=e.lights),e.clipping!==void 0&&(a.clipping=e.clipping),e.size!==void 0&&(a.size=e.size),e.sizeAttenuation!==void 0&&(a.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(a.map=i(e.map)),e.matcap!==void 0&&(a.matcap=i(e.matcap)),e.alphaMap!==void 0&&(a.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(a.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(a.bumpScale=e.bumpScale),e.normalMap!==void 0&&(a.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(a.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),a.normalScale=new Ee().fromArray(r)}return e.displacementMap!==void 0&&(a.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(a.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(a.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(a.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(a.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(a.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(a.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(a.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(a.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(a.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(a.envMap=i(e.envMap)),e.envMapRotation!==void 0&&a.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(a.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(a.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(a.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(a.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(a.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(a.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(a.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(a.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(a.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(a.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(a.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(a.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(a.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(a.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(a.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(a.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(a.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(a.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(a.sheenRoughnessMap=i(e.sheenRoughnessMap)),a}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return zy.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:bB,SpriteMaterial:G3,RawShaderMaterial:cl,ShaderMaterial:Di,PointsMaterial:Ty,MeshPhysicalMaterial:us,MeshStandardMaterial:P0,MeshPhongMaterial:MB,MeshToonMaterial:CB,MeshNormalMaterial:$3,MeshLambertMaterial:RB,MeshDepthMaterial:eb,MeshDistanceMaterial:tb,MeshBasicMaterial:Qa,MeshMatcapMaterial:wB,LineDashedMaterial:DB,LineBasicMaterial:Ca,Material:ri};return new t[e]}}class lc{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 kB extends Xt{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 XB extends yi{constructor(e){super(e)}load(e,t,i,a){const r=this,s=new oa(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(o){try{t(r.parse(JSON.parse(o)))}catch(c){a?a(c):qt(c),r.manager.itemError(e)}},i,a)}parse(e){const t={},i={};function a(g,y){if(t[y]!==void 0)return t[y];const S=g.interleavedBuffers[y],v=r(g,S.buffer),_=Lf(S.type,v),A=new Xu(_,S.stride);return A.uuid=S.uuid,t[y]=A,A}function r(g,y){if(i[y]!==void 0)return i[y];const S=g.arrayBuffers[y],v=new Uint32Array(S).buffer;return i[y]=v,v}const s=e.isInstancedBufferGeometry?new kB:new Xt,o=e.data.index;if(o!==void 0){const g=Lf(o.type,o.array);s.setIndex(new pn(g,1))}const c=e.data.attributes;for(const g in c){const y=c[g];let E;if(y.isInterleavedBufferAttribute){const S=a(e.data,y.data);E=new Ns(S,y.itemSize,y.offset,y.normalized)}else{const S=Lf(y.type,y.array),v=y.isInstancedBufferAttribute?Wu:pn;E=new v(S,y.itemSize,y.normalized)}y.name!==void 0&&(E.name=y.name),y.usage!==void 0&&E.setUsage(y.usage),s.setAttribute(g,E)}const h=e.data.morphAttributes;if(h)for(const g in h){const y=h[g],E=[];for(let S=0,v=y.length;S<v;S++){const _=y[S];let A;if(_.isInterleavedBufferAttribute){const b=a(e.data,_.data);A=new Ns(b,_.itemSize,_.offset,_.normalized)}else{const b=Lf(_.type,_.array);A=new pn(b,_.itemSize,_.normalized)}_.name!==void 0&&(A.name=_.name),E.push(A)}s.morphAttributes[g]=E}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,y=d.length;g!==y;++g){const E=d[g];s.addGroup(E.start,E.count,E.materialIndex)}const m=e.data.boundingSphere;return m!==void 0&&(s.boundingSphere=new zi().fromJSON(m)),e.name&&(s.name=e.name),e.userData&&(s.userData=e.userData),s}}class Zz extends yi{constructor(e){super(e)}load(e,t,i,a){const r=this,s=this.path===""?lc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;const o=new oa(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){let h=null;try{h=JSON.parse(c)}catch(d){a!==void 0&&a(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"){a!==void 0&&a(new Error("THREE.ObjectLoader: Can't load "+e)),qt("ObjectLoader: Can't load "+e);return}r.parse(h,t)},i,a)}async loadAsync(e,t){const i=this,a=this.path===""?lc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const r=new oa(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const s=await r.loadAsync(e,t),o=JSON.parse(s),c=o.metadata;if(c===void 0||c.type===void 0||c.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),a=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,a),s=this.parseImages(e.images,function(){t!==void 0&&t(h)}),o=this.parseTextures(e.textures,s),c=this.parseMaterials(e.materials,o),h=this.parseObject(e.object,r,c,o,i),f=this.parseSkeletons(e.skeletons,h);if(this.bindSkeletons(h,f),this.bindLightTargets(h),t!==void 0){let d=!1;for(const m in s)if(s[m].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),a=this.parseGeometries(e.geometries,i),r=await this.parseImagesAsync(e.images),s=this.parseTextures(e.textures,r),o=this.parseMaterials(e.materials,s),c=this.parseObject(e.object,a,o,s,t),h=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,h),this.bindLightTargets(c),c}parseShapes(e){const t={};if(e!==void 0)for(let i=0,a=e.length;i<a;i++){const r=new Nu().fromJSON(e[i]);t[r.uuid]=r}return t}parseSkeletons(e,t){const i={},a={};if(t.traverse(function(r){r.isBone&&(a[r.uuid]=r)}),e!==void 0)for(let r=0,s=e.length;r<s;r++){const o=new D0().fromJSON(e[r],a);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const a=new XB;for(let r=0,s=e.length;r<s;r++){let o;const c=e[r];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":o=a.parse(c);break;default:c.type in v4?o=v4[c.type].fromJSON(c,t):_t(`ObjectLoader: Unsupported geometry type "${c.type}"`)}o.uuid=c.uuid,c.name!==void 0&&(o.name=c.name),c.userData!==void 0&&(o.userData=c.userData),i[c.uuid]=o}}return i}parseMaterials(e,t){const i={},a={};if(e!==void 0){const r=new zy;r.setTextures(t);for(let s=0,o=e.length;s<o;s++){const c=e[s];i[c.uuid]===void 0&&(i[c.uuid]=r.parse(c)),a[c.uuid]=i[c.uuid]}}return a}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const a=e[i],r=Ad.parse(a);t[r.uuid]=r}return t}parseImages(e,t){const i=this,a={};let r;function s(c){return i.manager.itemStart(c),r.load(c,function(){i.manager.itemEnd(c)},void 0,function(){i.manager.itemError(c),i.manager.itemEnd(c)})}function o(c){if(typeof c=="string"){const h=c,f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h)?h:i.resourcePath+h;return s(f)}else return c.data?{data:Lf(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){const c=new Fy(t);r=new c0(c),r.setCrossOrigin(this.crossOrigin);for(let h=0,f=e.length;h<f;h++){const d=e[h],m=d.url;if(Array.isArray(m)){const g=[];for(let y=0,E=m.length;y<E;y++){const S=m[y],v=o(S);v!==null&&(v instanceof HTMLImageElement?g.push(v):g.push(new Pa(v.data,v.width,v.height)))}a[d.uuid]=new Kl(g)}else{const g=o(d.url);a[d.uuid]=new Kl(g)}}}return a}async parseImagesAsync(e){const t=this,i={};let a;async function r(s){if(typeof s=="string"){const o=s,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await a.loadAsync(c)}else return s.data?{data:Lf(s.type,s.data),width:s.width,height:s.height}:null}if(e!==void 0&&e.length>0){a=new c0(this.manager),a.setCrossOrigin(this.crossOrigin);for(let s=0,o=e.length;s<o;s++){const c=e[s],h=c.url;if(Array.isArray(h)){const f=[];for(let d=0,m=h.length;d<m;d++){const g=h[d],y=await r(g);y!==null&&(y instanceof HTMLImageElement?f.push(y):f.push(new Pa(y.data,y.width,y.height)))}i[c.uuid]=new Kl(f)}else{const f=await r(c.url);i[c.uuid]=new Kl(f)}}}return i}parseTextures(e,t){function i(r,s){return typeof r=="number"?r:(_t("ObjectLoader.parseTexture: Constant should be in numeric form.",r),s[r])}const a={};if(e!==void 0)for(let r=0,s=e.length;r<s;r++){const o=e[r];o.image===void 0&&_t('ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&_t("ObjectLoader: Undefined image",o.image);const c=t[o.image],h=c.data;let f;Array.isArray(h)?(f=new w0,h.length===6&&(f.needsUpdate=!0)):(h&&h.data?f=new Pa:f=new vn,h&&(f.needsUpdate=!0)),f.source=c,f.uuid=o.uuid,o.name!==void 0&&(f.name=o.name),o.mapping!==void 0&&(f.mapping=i(o.mapping,jz)),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],S4),f.wrapT=i(o.wrap[1],S4)),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,A4)),o.magFilter!==void 0&&(f.magFilter=i(o.magFilter,A4)),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),a[o.uuid]=f}return a}parseObject(e,t,i,a,r){let s;function o(m){return t[m]===void 0&&_t("ObjectLoader: Undefined geometry",m),t[m]}function c(m){if(m!==void 0){if(Array.isArray(m)){const g=[];for(let y=0,E=m.length;y<E;y++){const S=m[y];i[S]===void 0&&_t("ObjectLoader: Undefined material",S),g.push(i[S])}return g}return i[m]===void 0&&_t("ObjectLoader: Undefined material",m),i[m]}}function h(m){return a[m]===void 0&&_t("ObjectLoader: Undefined texture",m),a[m]}let f,d;switch(e.type){case"Scene":s=new al,e.background!==void 0&&(Number.isInteger(e.background)?s.background=new dt(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 Sy(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(s.fog=new _y(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 Jn(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 Rr(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 HB(e.color,e.intensity);break;case"DirectionalLight":s=new cb(e.color,e.intensity),s.target=e.target||"";break;case"PointLight":s=new lb(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":s=new zB(e.color,e.intensity,e.width,e.height);break;case"SpotLight":s=new ob(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),s.target=e.target||"";break;case"HemisphereLight":s=new FB(e.color,e.groundColor,e.intensity);break;case"LightProbe":s=new VB().fromJSON(e);break;case"SkinnedMesh":f=o(e.geometry),d=c(e.material),s=new V3(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=c(e.material),s=new Xn(f,d);break;case"InstancedMesh":f=o(e.geometry),d=c(e.material);const m=e.count,g=e.instanceMatrix,y=e.instanceColor;s=new k3(f,d,m),s.instanceMatrix=new Wu(new Float32Array(g.array),16),y!==void 0&&(s.instanceColor=new Wu(new Float32Array(y.array),y.itemSize));break;case"BatchedMesh":f=o(e.geometry),d=c(e.material),s=new fB(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(E=>{let S=null,v=null;return E.boundingBox!==void 0&&(S=new sa().fromJSON(E.boundingBox)),E.boundingSphere!==void 0&&(v=new zi().fromJSON(E.boundingSphere)),{...E,boundingBox:S,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 zi().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(s.boundingBox=new sa().fromJSON(e.boundingBox));break;case"LOD":s=new hB;break;case"Line":s=new rl(o(e.geometry),c(e.material));break;case"LineLoop":s=new X3(o(e.geometry),c(e.material));break;case"LineSegments":s=new Is(o(e.geometry),c(e.material));break;case"PointCloud":case"Points":s=new W3(o(e.geometry),c(e.material));break;case"Sprite":s=new uB(c(e.material));break;case"Group":s=new jo;break;case"Bone":s=new Ay;break;default:s=new fn}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 m=e.children;for(let g=0;g<m.length;g++)s.add(this.parseObject(m[g],t,i,a,r))}if(e.animations!==void 0){const m=e.animations;for(let g=0;g<m.length;g++){const y=m[g];s.animations.push(r[y])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(s.autoUpdate=e.autoUpdate);const m=e.levels;for(let g=0;g<m.length;g++){const y=m[g],E=s.getObjectByProperty("uuid",y.object);E!==void 0&&s.addLevel(E,y.distance,y.hysteresis)}}return s}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const a=t[i.skeleton];a===void 0?_t("ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(a,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,a=e.getObjectByProperty("uuid",i);a!==void 0?t.target=a:t.target=new fn}})}}const jz={UVMapping:pc,CubeReflectionMapping:no,CubeRefractionMapping:mc,EquirectangularReflectionMapping:hd,EquirectangularRefractionMapping:$m,CubeUVReflectionMapping:Pd},S4={RepeatWrapping:wi,ClampToEdgeWrapping:Vn,MirroredRepeatWrapping:fd},A4={NearestFilter:$n,NearestMipmapNearestFilter:dy,NearestMipmapLinearFilter:gu,LinearFilter:Bt,LinearMipmapNearestFilter:Kf,LinearMipmapLinearFilter:Sr},YA=new WeakMap;class WB extends yi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&_t("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&_t("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,a){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=Js.get(`image-bitmap:${e}`);if(s!==void 0){if(r.manager.itemStart(e),s.then){s.then(h=>{if(YA.has(s)===!0)a&&a(YA.get(s)),r.manager.itemError(e),r.manager.itemEnd(e);else return t&&t(h),r.manager.itemEnd(e),h});return}return setTimeout(function(){t&&t(s),r.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 c=fetch(e,o).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(h){return Js.add(`image-bitmap:${e}`,h),t&&t(h),r.manager.itemEnd(e),h}).catch(function(h){a&&a(h),YA.set(c,h),Js.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Js.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let bv;class ub{static getContext(){return bv===void 0&&(bv=new(window.AudioContext||window.webkitAudioContext)),bv}static setContext(e){bv=e}}class Kz extends yi{constructor(e){super(e)}load(e,t,i,a){const r=this,s=new oa(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(c){try{const h=c.slice(0);ub.getContext().decodeAudioData(h,function(d){t(d)}).catch(o)}catch(h){o(h)}},i,a);function o(c){a?a(c):qt(c),r.manager.itemError(e)}}}const E4=new lt,T4=new lt,Kc=new lt;class Jz{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Jn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Jn,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,Kc.copy(e.projectionMatrix);const a=t.eyeSep/2,r=a*t.near/t.focus,s=t.near*Math.tan(Du*t.fov*.5)/t.zoom;let o,c;T4.elements[12]=-a,E4.elements[12]=a,o=-s*t.aspect+r,c=s*t.aspect+r,Kc.elements[0]=2*t.near/(c-o),Kc.elements[8]=(c+o)/(c-o),this.cameraL.projectionMatrix.copy(Kc),o=-s*t.aspect-r,c=s*t.aspect-r,Kc.elements[0]=2*t.near/(c-o),Kc.elements[8]=(c+o)/(c-o),this.cameraR.projectionMatrix.copy(Kc)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(T4),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(E4)}}class YB extends Jn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class hb{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 Jc=new H,qA=new Yi,Qz=new H,Qc=new H,$c=new H;class $z extends fn{constructor(){super(),this.type="AudioListener",this.context=ub.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new hb}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(Jc,qA,Qz),Qc.set(0,0,-1).applyQuaternion(qA),$c.set(0,1,0).applyQuaternion(qA),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Jc.x,i),t.positionY.linearRampToValueAtTime(Jc.y,i),t.positionZ.linearRampToValueAtTime(Jc.z,i),t.forwardX.linearRampToValueAtTime(Qc.x,i),t.forwardY.linearRampToValueAtTime(Qc.y,i),t.forwardZ.linearRampToValueAtTime(Qc.z,i),t.upX.linearRampToValueAtTime($c.x,i),t.upY.linearRampToValueAtTime($c.y,i),t.upZ.linearRampToValueAtTime($c.z,i)}else t.setPosition(Jc.x,Jc.y,Jc.z),t.setOrientation(Qc.x,Qc.y,Qc.z,$c.x,$c.y,$c.z)}}class qB extends fn{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){_t("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){_t("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){_t("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){_t("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){_t("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?(_t("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){_t("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"?(_t("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 eu=new H,b4=new Yi,eG=new H,tu=new H;class tG extends qB{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(eu,b4,eG),tu.set(0,0,1).applyQuaternion(b4);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(eu.x,i),t.positionY.linearRampToValueAtTime(eu.y,i),t.positionZ.linearRampToValueAtTime(eu.z,i),t.orientationX.linearRampToValueAtTime(tu.x,i),t.orientationY.linearRampToValueAtTime(tu.y,i),t.orientationZ.linearRampToValueAtTime(tu.z,i)}else t.setPosition(eu.x,eu.y,eu.z),t.setOrientation(tu.x,tu.y,tu.z)}}class nG{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 ZB{constructor(e,t,i){this.binding=e,this.valueSize=i;let a,r,s;switch(t){case"quaternion":a=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":a=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:a=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=a,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,a=this.valueSize,r=e*a+a;let s=this.cumulativeWeight;if(s===0){for(let o=0;o!==a;++o)i[r+o]=i[o];s=t}else{s+=t;const o=t/s;this._mixBufferRegion(i,r,0,o,a)}this.cumulativeWeight=s}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,a=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,a,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,a=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const c=t*this._origIndex;this._mixBufferRegion(i,a,c,1-r,t)}s>0&&this._mixBufferRegionAdditive(i,a,this._addIndex*t,1,t);for(let c=t,h=t+t;c!==h;++c)if(i[c]!==i[c+t]){o.setValue(i,a);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,a=i*this._origIndex;e.getValue(t,a);for(let r=i,s=a;r!==s;++r)t[r]=t[a+r%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,a,r){if(a>=.5)for(let s=0;s!==r;++s)e[t+s]=e[i+s]}_slerp(e,t,i,a){Yi.slerpFlat(e,t,e,t,e,i,a)}_slerpAdditive(e,t,i,a,r){const s=this._workIndex*r;Yi.multiplyQuaternionsFlat(e,s,e,t,e,i),Yi.slerpFlat(e,t,e,t,e,s,a)}_lerp(e,t,i,a,r){const s=1-a;for(let o=0;o!==r;++o){const c=t+o;e[c]=e[c]*s+e[i+o]*a}}_lerpAdditive(e,t,i,a,r){for(let s=0;s!==r;++s){const o=t+s;e[o]=e[o]+e[i+s]*a}}}const fb="\\[\\]\\.:\\/",iG=new RegExp("["+fb+"]","g"),db="[^"+fb+"]",aG="[^"+fb.replace("\\.","")+"]",rG=/((?:WC+[\/:])*)/.source.replace("WC",db),sG=/(WCOD+)?/.source.replace("WCOD",aG),oG=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",db),lG=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",db),cG=new RegExp("^"+rG+sG+oG+lG+"$"),uG=["material","materials","bones","map"];class hG{constructor(e,t,i){const a=i||yn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,a)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,a=this._bindings[i];a!==void 0&&a.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let a=this._targetGroup.nCachedObjects_,r=i.length;a!==r;++a)i[a].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 yn{constructor(e,t,i){this.path=t,this.parsedPath=i||yn.parseTrackName(t),this.node=yn.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 yn.Composite(e,t,i):new yn(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(iG,"")}static parseTrackName(e){const t=cG.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]},a=i.nodeName&&i.nodeName.lastIndexOf(".");if(a!==void 0&&a!==-1){const r=i.nodeName.substring(a+1);uG.indexOf(r)!==-1&&(i.nodeName=i.nodeName.substring(0,a),i.objectName=r)}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(r){for(let s=0;s<r.length;s++){const o=r[s];if(o.name===t||o.uuid===t)return o;const c=i(o.children);if(c)return c}return null},a=i(e.children);if(a)return a}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 a=0,r=i.length;a!==r;++a)e[t++]=i[a]}_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 a=0,r=i.length;a!==r;++a)i[a]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let a=0,r=i.length;a!==r;++a)i[a]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let a=0,r=i.length;a!==r;++a)i[a]=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,a=t.propertyName;let r=t.propertyIndex;if(e||(e=yn.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){_t("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let h=t.objectIndex;switch(i){case"materials":if(!e.material){qt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){qt("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){qt("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){qt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){qt("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){qt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(h!==void 0){if(e[h]===void 0){qt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[h]}}const s=e[a];if(s===void 0){const h=t.nodeName;qt("PropertyBinding: Trying to update property for track: "+h+"."+a+" 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 c=this.BindingType.Direct;if(r!==void 0){if(a==="morphTargetInfluences"){if(!e.geometry){qt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){qt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else s.fromArray!==void 0&&s.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(c=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=a;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}yn.Composite=hG;yn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};yn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};yn.prototype.GetterByBindingType=[yn.prototype._getValue_direct,yn.prototype._getValue_array,yn.prototype._getValue_arrayElement,yn.prototype._getValue_toArray];yn.prototype.SetterByBindingTypeAndVersioning=[[yn.prototype._setValue_direct,yn.prototype._setValue_direct_setNeedsUpdate,yn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[yn.prototype._setValue_array,yn.prototype._setValue_array_setNeedsUpdate,yn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[yn.prototype._setValue_arrayElement,yn.prototype._setValue_arrayElement_setNeedsUpdate,yn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[yn.prototype._setValue_fromArray,yn.prototype._setValue_fromArray_setNeedsUpdate,yn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class fG{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Cr(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,a=arguments.length;i!==a;++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,a=this._parsedPaths,r=this._bindings,s=r.length;let o,c=e.length,h=this.nCachedObjects_;for(let f=0,d=arguments.length;f!==d;++f){const m=arguments[f],g=m.uuid;let y=t[g];if(y===void 0){y=c++,t[g]=y,e.push(m);for(let E=0,S=s;E!==S;++E)r[E].push(new yn(m,i[E],a[E]))}else if(y<h){o=e[y];const E=--h,S=e[E];t[S.uuid]=y,e[y]=S,t[g]=E,e[E]=m;for(let v=0,_=s;v!==_;++v){const A=r[v],b=A[E];let O=A[y];A[y]=b,O===void 0&&(O=new yn(m,i[v],a[v])),A[E]=O}}else e[y]!==o&&qt("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,a=i.length;let r=this.nCachedObjects_;for(let s=0,o=arguments.length;s!==o;++s){const c=arguments[s],h=c.uuid,f=t[h];if(f!==void 0&&f>=r){const d=r++,m=e[d];t[m.uuid]=f,e[f]=m,t[h]=d,e[d]=c;for(let g=0,y=a;g!==y;++g){const E=i[g],S=E[d],v=E[f];E[f]=S,E[d]=v}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,a=i.length;let r=this.nCachedObjects_,s=e.length;for(let o=0,c=arguments.length;o!==c;++o){const h=arguments[o],f=h.uuid,d=t[f];if(d!==void 0)if(delete t[f],d<r){const m=--r,g=e[m],y=--s,E=e[y];t[g.uuid]=d,e[d]=g,t[E.uuid]=m,e[m]=E,e.pop();for(let S=0,v=a;S!==v;++S){const _=i[S],A=_[m],b=_[y];_[d]=A,_[m]=b,_.pop()}}else{const m=--s,g=e[m];m>0&&(t[g.uuid]=d),e[d]=g,e.pop();for(let y=0,E=a;y!==E;++y){const S=i[y];S[d]=S[m],S.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const i=this._bindingsIndicesByPath;let a=i[e];const r=this._bindings;if(a!==void 0)return r[a];const s=this._paths,o=this._parsedPaths,c=this._objects,h=c.length,f=this.nCachedObjects_,d=new Array(h);a=r.length,i[e]=a,s.push(e),o.push(t),r.push(d);for(let m=f,g=c.length;m!==g;++m){const y=c[m];d[m]=new yn(y,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const a=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length-1,c=s[o],h=e[o];t[h]=i,s[i]=c,s.pop(),r[i]=r[o],r.pop(),a[i]=a[o],a.pop()}}}class jB{constructor(e,t,i=null,a=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=a;const r=t.tracks,s=r.length,o=new Array(s),c={endingStart:vu,endingEnd:vu};for(let h=0;h!==s;++h){const f=r[h].createInterpolant(null);o[h]=f,f.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=k5,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 a=this._clip.duration,r=e._clip.duration,s=r/a,o=a/r;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 a=this._mixer,r=a.time,s=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=a._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,h=o.sampleValues;return c[0]=r,c[1]=r+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,a){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const c=(e-r)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);const s=this._updateTime(t),o=this._updateWeight(e);if(o>0){const c=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case O3:for(let f=0,d=c.length;f!==d;++f)c[f].evaluate(s),h[f].accumulateAdditive(o);break;case xy:default:for(let f=0,d=c.length;f!==d;++f)c[f].evaluate(s),h[f].accumulate(a,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const a=i.evaluate(e)[0];t*=a,e>i.parameterPositions[1]&&(this.stopFading(),a===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 a=i.evaluate(e)[0];t*=a,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 a=this.time+e,r=this._loopCount;const s=i===X5;if(e===0)return r===-1?a:s&&(r&1)===1?t-a:a;if(i===V5){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(a>=t)a=t;else if(a<0)a=0;else{this.time=a;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,s)):this._setEndings(this.repetitions===0,!0,s)),a>=t||a<0){const o=Math.floor(a/t);a-=t*o,r+=Math.abs(o);const c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a=e>0?t:0,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const h=e<0;this._setEndings(h,!h,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=a,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=a;if(s&&(r&1)===1)return t-a}return a}_setEndings(e,t,i){const a=this._interpolantSettings;i?(a.endingStart=xu,a.endingEnd=xu):(e?a.endingStart=this.zeroSlopeAtStart?xu:vu:a.endingStart=t0,t?a.endingEnd=this.zeroSlopeAtEnd?xu:vu:a.endingEnd=t0)}_scheduleFading(e,t,i){const a=this._mixer,r=a.time;let s=this._weightInterpolant;s===null&&(s=a._lendControlInterpolant(),this._weightInterpolant=s);const o=s.parameterPositions,c=s.sampleValues;return o[0]=r,c[0]=t,o[1]=r+e,c[1]=i,this}}const dG=new Float32Array(1);class pG extends tr{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,a=e._clip.tracks,r=a.length,s=e._propertyBindings,o=e._interpolants,c=i.uuid,h=this._bindingsByRootAndName;let f=h[c];f===void 0&&(f={},h[c]=f);for(let d=0;d!==r;++d){const m=a[d],g=m.name;let y=f[g];if(y!==void 0)++y.referenceCount,s[d]=y;else{if(y=s[d],y!==void 0){y._cacheIndex===null&&(++y.referenceCount,this._addInactiveBinding(y,c,g));continue}const E=t&&t._propertyBindings[d].binding.parsedPath;y=new ZB(yn.create(i,g,E),m.ValueTypeName,m.getValueSize()),++y.referenceCount,this._addInactiveBinding(y,c,g),s[d]=y}o[d].resultBuffer=y.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,a=e._clip.uuid,r=this._actionsByClip[a];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,a,i)}const t=e._propertyBindings;for(let i=0,a=t.length;i!==a;++i){const r=t[i];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,a=t.length;i!==a;++i){const r=t[i];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;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 a=this._actions,r=this._actionsByClip;let s=r[t];if(s===void 0)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{const o=s.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=a.length,a.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],a=e._cacheIndex;i._cacheIndex=a,t[a]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,s=this._actionsByClip,o=s[r],c=o.knownActions,h=c[c.length-1],f=e._byClipCacheIndex;h._byClipCacheIndex=f,c[f]=h,c.pop(),e._byClipCacheIndex=null;const d=o.actionByRoot,m=(e._localRoot||this._root).uuid;delete d[m],c.length===0&&delete s[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,a=t.length;i!==a;++i){const r=t[i];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,a=this._nActiveActions++,r=t[a];e._cacheIndex=a,t[a]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,a=--this._nActiveActions,r=t[a];e._cacheIndex=a,t[a]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const a=this._bindingsByRootAndName,r=this._bindings;let s=a[t];s===void 0&&(s={},a[t]=s),s[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,a=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,o=s[a],c=t[t.length-1],h=e._cacheIndex;c._cacheIndex=h,t[h]=c,t.pop(),delete o[r],Object.keys(o).length===0&&delete s[a]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,a=this._nActiveBindings++,r=t[a];e._cacheIndex=a,t[a]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,a=--this._nActiveBindings,r=t[a];e._cacheIndex=a,t[a]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new ib(new Float32Array(2),new Float32Array(2),1,dG),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,a=--this._nActiveControlInterpolants,r=t[a];e.__cacheIndex=a,t[a]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const a=t||this._root,r=a.uuid;let s=typeof e=="string"?Ad.findByName(a,e):e;const o=s!==null?s.uuid:e,c=this._actionsByClip[o];let h=null;if(i===void 0&&(s!==null?i=s.blendMode:i=xy),c!==void 0){const d=c.actionByRoot[r];if(d!==void 0&&d.blendMode===i)return d;h=c.knownActions[0],s===null&&(s=h._clip)}if(s===null)return null;const f=new jB(this,s,t,i);return this._bindAction(f,h),this._addInactiveAction(f,o,r),f}existingAction(e,t){const i=t||this._root,a=i.uuid,r=typeof e=="string"?Ad.findByName(i,e):e,s=r?r.uuid:e,o=this._actionsByClip[s];return o!==void 0&&o.actionByRoot[a]||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,a=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let h=0;h!==i;++h)t[h]._update(a,e,r,s);const o=this._bindings,c=this._nActiveBindings;for(let h=0;h!==c;++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,a=this._actionsByClip,r=a[i];if(r!==void 0){const s=r.knownActions;for(let o=0,c=s.length;o!==c;++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 a[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const s in i){const o=i[s].actionByRoot,c=o[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const a=this._bindingsByRootAndName,r=a[t];if(r!==void 0)for(const s in r){const o=r[s];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class mG extends L3{constructor(e=1,t=1,i=1,a={}){super(e,t,a),this.isRenderTarget3D=!0,this.depth=i,this.texture=new is(null,e,t,i),this._setTextureOptions(a),this.texture.isRenderTargetTexture=!0}}class ie{constructor(e){this.value=e}clone(){return new ie(this.value.clone===void 0?this.value:this.value.clone())}}let gG=0;class vG extends tr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:gG++}),this.name="",this.usage=i0,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,a=t.length;i<a;i++){const r=Array.isArray(t[i])?t[i]:[t[i]];for(let s=0;s<r.length;s++)this.uniforms.push(r[s].clone())}return this}clone(){return new this.constructor().copy(this)}}class xG extends Xu{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 yG{constructor(e,t,i,a,r,s=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=a,this.count=r,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 M4=new lt;class pb{constructor(e,t,i=0,a=1/0){this.ray=new oh(e,t),this.near=i,this.far=a,this.camera=null,this.layers=new yd,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):qt("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return M4.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(M4),this}intersectObject(e,t=!0,i=[]){return UE(e,this,i,t),i.sort(C4),i}intersectObjects(e,t=!0,i=[]){for(let a=0,r=e.length;a<r;a++)UE(e[a],this,i,t);return i.sort(C4),i}}function C4(n,e){return n.distance-e.distance}function UE(n,e,t,i){let a=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(a=!1),a===!0&&i===!0){const r=n.children;for(let s=0,o=r.length;s<o;s++)UE(r[s],e,t,!0)}}let _G=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=SG.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 SG(){this._document.hidden===!1&&this.reset()}class LE{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=Gt(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(Gt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class AG{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 mb{constructor(e,t,i,a){mb.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,a)}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,a){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=a,this}}const R4=new Ee;class EG{constructor(e=new Ee(1/0,1/0),t=new Ee(-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=R4.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,R4).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 w4=new H,Mv=new H,of=new H,lf=new H,ZA=new H,TG=new H,bG=new H;class MG{constructor(e=new H,t=new H){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){w4.subVectors(e,this.start),Mv.subVectors(this.end,this.start);const i=Mv.dot(Mv);let r=Mv.dot(w4)/i;return t&&(r=Gt(r,0,1)),r}closestPointToPoint(e,t,i){const a=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(a).add(this.start)}distanceSqToLine3(e,t=TG,i=bG){const a=10000000000000001e-32;let r,s;const o=this.start,c=e.start,h=this.end,f=e.end;of.subVectors(h,o),lf.subVectors(f,c),ZA.subVectors(o,c);const d=of.dot(of),m=lf.dot(lf),g=lf.dot(ZA);if(d<=a&&m<=a)return t.copy(o),i.copy(c),t.sub(i),t.dot(t);if(d<=a)r=0,s=g/m,s=Gt(s,0,1);else{const y=of.dot(ZA);if(m<=a)s=0,r=Gt(-y/d,0,1);else{const E=of.dot(lf),S=d*m-E*E;S!==0?r=Gt((E*g-y*m)/S,0,1):r=0,s=(E*r+g)/m,s<0?(s=0,r=Gt(-y/d,0,1)):s>1&&(s=1,r=Gt((E-y)/d,0,1))}}return t.copy(o).add(of.multiplyScalar(r)),i.copy(c).add(lf.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 D4=new H;class CG extends fn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new Xt,a=[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,c=32;s<c;s++,o++){const h=s/c*Math.PI*2,f=o/c*Math.PI*2;a.push(Math.cos(h),Math.sin(h),1,Math.cos(f),Math.sin(f),1)}i.setAttribute("position",new Dt(a,3));const r=new Ca({fog:!1,toneMapped:!1});this.cone=new Is(i,r),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),D4.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(D4),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Ul=new H,Cv=new lt,jA=new lt;class RG extends Is{constructor(e){const t=KB(e),i=new Xt,a=[],r=[];for(let h=0;h<t.length;h++){const f=t[h];f.parent&&f.parent.isBone&&(a.push(0,0,0),a.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}i.setAttribute("position",new Dt(a,3)),i.setAttribute("color",new Dt(r,3));const s=new Ca({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 dt(255),c=new dt(65280);this.setColors(o,c)}updateMatrixWorld(e){const t=this.bones,i=this.geometry,a=i.getAttribute("position");jA.copy(this.root.matrixWorld).invert();for(let r=0,s=0;r<t.length;r++){const o=t[r];o.parent&&o.parent.isBone&&(Cv.multiplyMatrices(jA,o.matrixWorld),Ul.setFromMatrixPosition(Cv),a.setXYZ(s,Ul.x,Ul.y,Ul.z),Cv.multiplyMatrices(jA,o.parent.matrixWorld),Ul.setFromMatrixPosition(Cv),a.setXYZ(s+1,Ul.x,Ul.y,Ul.z),s+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const a=this.geometry.getAttribute("color");for(let r=0;r<a.count;r+=2)a.setXYZ(r,e.r,e.g,e.b),a.setXYZ(r+1,t.r,t.g,t.b);return a.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function KB(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push(...KB(n.children[t]));return e}class wG extends Xn{constructor(e,t,i){const a=new L0(t,4,2),r=new Qa({wireframe:!0,fog:!1,toneMapped:!1});super(a,r),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 DG=new H,N4=new dt,O4=new dt;class NG extends fn{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const a=new U0(t);a.rotateY(Math.PI*.5),this.material=new Qa({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const r=a.getAttribute("position"),s=new Float32Array(r.count*3);a.setAttribute("color",new pn(s,3)),this.add(new Xn(a,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");N4.copy(this.light.color),O4.copy(this.light.groundColor);for(let i=0,a=t.count;i<a;i++){const r=i<a/2?N4:O4;t.setXYZ(i,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(DG.setFromMatrixPosition(this.light.matrixWorld).negate())}}class OG extends Is{constructor(e=10,t=10,i=4473924,a=8947848){i=new dt(i),a=new dt(a);const r=t/2,s=e/t,o=e/2,c=[],h=[];for(let m=0,g=0,y=-o;m<=t;m++,y+=s){c.push(-o,0,y,o,0,y),c.push(y,0,-o,y,0,o);const E=m===r?i:a;E.toArray(h,g),g+=3,E.toArray(h,g),g+=3,E.toArray(h,g),g+=3,E.toArray(h,g),g+=3}const f=new Xt;f.setAttribute("position",new Dt(c,3)),f.setAttribute("color",new Dt(h,3));const d=new Ca({vertexColors:!0,toneMapped:!1});super(f,d),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class IG extends Is{constructor(e=10,t=16,i=8,a=64,r=4473924,s=8947848){r=new dt(r),s=new dt(s);const o=[],c=[];if(t>1)for(let d=0;d<t;d++){const m=d/t*(Math.PI*2),g=Math.sin(m)*e,y=Math.cos(m)*e;o.push(0,0,0),o.push(g,0,y);const E=d&1?r:s;c.push(E.r,E.g,E.b),c.push(E.r,E.g,E.b)}for(let d=0;d<i;d++){const m=d&1?r:s,g=e-e/i*d;for(let y=0;y<a;y++){let E=y/a*(Math.PI*2),S=Math.sin(E)*g,v=Math.cos(E)*g;o.push(S,0,v),c.push(m.r,m.g,m.b),E=(y+1)/a*(Math.PI*2),S=Math.sin(E)*g,v=Math.cos(E)*g,o.push(S,0,v),c.push(m.r,m.g,m.b)}}const h=new Xt;h.setAttribute("position",new Dt(o,3)),h.setAttribute("color",new Dt(c,3));const f=new Ca({vertexColors:!0,toneMapped:!1});super(h,f),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const I4=new H,Rv=new H,B4=new H;class BG extends fn{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 a=new Xt;a.setAttribute("position",new Dt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Ca({fog:!1,toneMapped:!1});this.lightPlane=new rl(a,r),this.add(this.lightPlane),a=new Xt,a.setAttribute("position",new Dt([0,0,0,0,0,1],3)),this.targetLine=new rl(a,r),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),I4.setFromMatrixPosition(this.light.matrixWorld),Rv.setFromMatrixPosition(this.light.target.matrixWorld),B4.subVectors(Rv,I4),this.lightPlane.lookAt(Rv),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(Rv),this.targetLine.scale.z=B4.length()}}const wv=new H,Ti=new so;class UG extends Is{constructor(e){const t=new Xt,i=new Ca({color:16777215,vertexColors:!0,toneMapped:!1}),a=[],r=[],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(y,E){c(y),c(E)}function c(y){a.push(0,0,0),r.push(0,0,0),s[y]===void 0&&(s[y]=[]),s[y].push(a.length/3-1)}t.setAttribute("position",new Dt(a,3)),t.setAttribute("color",new Dt(r,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 dt(16755200),f=new dt(16711680),d=new dt(43775),m=new dt(16777215),g=new dt(3355443);this.setColors(h,f,d,m,g)}setColors(e,t,i,a,r){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,a.r,a.g,a.b),o.setXYZ(39,a.r,a.g,a.b),o.setXYZ(40,r.r,r.g,r.b),o.setXYZ(41,r.r,r.g,r.b),o.setXYZ(42,r.r,r.g,r.b),o.setXYZ(43,r.r,r.g,r.b),o.setXYZ(44,r.r,r.g,r.b),o.setXYZ(45,r.r,r.g,r.b),o.setXYZ(46,r.r,r.g,r.b),o.setXYZ(47,r.r,r.g,r.b),o.setXYZ(48,r.r,r.g,r.b),o.setXYZ(49,r.r,r.g,r.b),o.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap,i=1,a=1;let r,s;if(Ti.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)r=1,s=0;else if(this.camera.coordinateSystem===Er)r=-1,s=1;else if(this.camera.coordinateSystem===gd)r=0,s=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);Ci("c",t,e,Ti,0,0,r),Ci("t",t,e,Ti,0,0,s),Ci("n1",t,e,Ti,-i,-a,r),Ci("n2",t,e,Ti,i,-a,r),Ci("n3",t,e,Ti,-i,a,r),Ci("n4",t,e,Ti,i,a,r),Ci("f1",t,e,Ti,-i,-a,s),Ci("f2",t,e,Ti,i,-a,s),Ci("f3",t,e,Ti,-i,a,s),Ci("f4",t,e,Ti,i,a,s),Ci("u1",t,e,Ti,i*.7,a*1.1,r),Ci("u2",t,e,Ti,-i*.7,a*1.1,r),Ci("u3",t,e,Ti,0,a*2,r),Ci("cf1",t,e,Ti,-i,0,s),Ci("cf2",t,e,Ti,i,0,s),Ci("cf3",t,e,Ti,0,-a,s),Ci("cf4",t,e,Ti,0,a,s),Ci("cn1",t,e,Ti,-i,0,r),Ci("cn2",t,e,Ti,i,0,r),Ci("cn3",t,e,Ti,0,-a,r),Ci("cn4",t,e,Ti,0,a,r),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Ci(n,e,t,i,a,r,s){wv.set(a,r,s).unproject(i);const o=e[n];if(o!==void 0){const c=t.getAttribute("position");for(let h=0,f=o.length;h<f;h++)c.setXYZ(o[h],wv.x,wv.y,wv.z)}}const Dv=new sa;class LG extends Is{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]),a=new Float32Array(8*3),r=new Xt;r.setIndex(new pn(i,1)),r.setAttribute("position",new pn(a,3)),super(r,new Ca({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Dv.setFromObject(this.object),Dv.isEmpty())return;const e=Dv.min,t=Dv.max,i=this.geometry.attributes.position,a=i.array;a[0]=t.x,a[1]=t.y,a[2]=t.z,a[3]=e.x,a[4]=t.y,a[5]=t.z,a[6]=e.x,a[7]=e.y,a[8]=t.z,a[9]=t.x,a[10]=e.y,a[11]=t.z,a[12]=t.x,a[13]=t.y,a[14]=e.z,a[15]=e.x,a[16]=t.y,a[17]=e.z,a[18]=e.x,a[19]=e.y,a[20]=e.z,a[21]=t.x,a[22]=e.y,a[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 PG extends Is{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]),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],r=new Xt;r.setIndex(new pn(i,1)),r.setAttribute("position",new Dt(a,3)),super(r,new Ca({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 FG extends rl{constructor(e,t=1,i=16776960){const a=i,r=[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 Xt;s.setAttribute("position",new Dt(r,3)),s.computeBoundingSphere(),super(s,new Ca({color:a,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],c=new Xt;c.setAttribute("position",new Dt(o,3)),c.computeBoundingSphere(),this.add(new Xn(c,new Qa({color:a,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 U4=new H;let Nv,KA;class HG extends fn{constructor(e=new H(0,0,1),t=new H(0,0,0),i=1,a=16776960,r=i*.2,s=r*.2){super(),this.type="ArrowHelper",Nv===void 0&&(Nv=new Xt,Nv.setAttribute("position",new Dt([0,0,0,0,1,0],3)),KA=new I0(.5,1,5,1),KA.translate(0,-.5,0)),this.position.copy(t),this.line=new rl(Nv,new Ca({color:a,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Xn(KA,new Qa({color:a,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,r,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{U4.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(U4,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 zG extends Is{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],a=new Xt;a.setAttribute("position",new Dt(t,3)),a.setAttribute("color",new Dt(i,3));const r=new Ca({vertexColors:!0,toneMapped:!1});super(a,r),this.type="AxesHelper"}setColors(e,t,i){const a=new dt,r=this.geometry.attributes.color.array;return a.set(e),a.toArray(r,0),a.toArray(r,3),a.set(t),a.toArray(r,6),a.toArray(r,9),a.set(i),a.toArray(r,12),a.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class GG{constructor(){this.type="ShapePath",this.color=new dt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Dx,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,a){return this.currentPath.quadraticCurveTo(e,t,i,a),this}bezierCurveTo(e,t,i,a,r,s){return this.currentPath.bezierCurveTo(e,t,i,a,r,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(v){const _=[];for(let A=0,b=v.length;A<b;A++){const O=v[A],N=new Nu;N.curves=O.curves,_.push(N)}return _}function i(v,_){const A=_.length;let b=!1;for(let O=A-1,N=0;N<A;O=N++){let L=_[O],B=_[N],w=B.x-L.x,D=B.y-L.y;if(Math.abs(D)>Number.EPSILON){if(D<0&&(L=_[N],w=-w,B=_[O],D=-D),v.y<L.y||v.y>B.y)continue;if(v.y===L.y){if(v.x===L.x)return!0}else{const G=D*(v.x-L.x)-w*(v.y-L.y);if(G===0)return!0;if(G<0)continue;b=!b}}else{if(v.y!==L.y)continue;if(B.x<=v.x&&v.x<=L.x||L.x<=v.x&&v.x<=B.x)return!0}}return b}const a=Rs.isClockWise,r=this.subPaths;if(r.length===0)return[];let s,o,c;const h=[];if(r.length===1)return o=r[0],c=new Nu,c.curves=o.curves,h.push(c),h;let f=!a(r[0].getPoints());f=e?!f:f;const d=[],m=[];let g=[],y=0,E;m[y]=void 0,g[y]=[];for(let v=0,_=r.length;v<_;v++)o=r[v],E=o.getPoints(),s=a(E),s=e?!s:s,s?(!f&&m[y]&&y++,m[y]={s:new Nu,p:E},m[y].s.curves=o.curves,f&&y++,g[y]=[]):g[y].push({h:o,p:E[0]});if(!m[0])return t(r);if(m.length>1){let v=!1,_=0;for(let A=0,b=m.length;A<b;A++)d[A]=[];for(let A=0,b=m.length;A<b;A++){const O=g[A];for(let N=0;N<O.length;N++){const L=O[N];let B=!0;for(let w=0;w<m.length;w++)i(L.p,m[w].p)&&(A!==w&&_++,B?(B=!1,d[w].push(L)):v=!0);B&&d[A].push(L)}}_>0&&v===!1&&(g=d)}let S;for(let v=0,_=m.length;v<_;v++){c=m[v].s,h.push(c),S=g[v];for(let A=0,b=S.length;A<b;A++)c.holes.push(S[A].h)}return h}}class VG extends tr{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){_t("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function kG(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 XG(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 WG(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function PE(n,e,t,i){const a=YG(i);switch(t){case D3:return n*e;case Ar:return n*e/a.components*a.byteLength;case R0:return n*e/a.components*a.byteLength;case zo:return n*e*2/a.components*a.byteLength;case gy:return n*e*2/a.components*a.byteLength;case N3:return n*e*3/a.components*a.byteLength;case Rn:return n*e*4/a.components*a.byteLength;case vy:return n*e*4/a.components*a.byteLength;case Em:case Tm:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case bm:case Mm:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case $1:case tx:return Math.max(n,16)*Math.max(e,8)/4;case Q1:case ex:return Math.max(n,8)*Math.max(e,8)/2;case nx:case ix:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ax:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case rx:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case sx:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case ox:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case lx:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case cx:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case ux:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case hx:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case fx: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 px:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case mx:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case gx:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case vx:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case xx:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case yx:case _x:case Sx:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Ax:case Ex:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Tx:case bx:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function YG(n){switch(n){case xi:case M0:return{byteLength:1,components:1};case Gu:case C0:case sn:return{byteLength:2,components:1};case py:case my:return{byteLength:2,components:4};case ls:case Fd:case Sn:return{byteLength:4,components:1};case R3:case w3:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}class qG{static contain(e,t){return kG(e,t)}static cover(e,t){return XG(e,t)}static fill(e){return WG(e)}static getByteLength(e,t,i,a){return PE(e,t,i,a)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_c}}));typeof window<"u"&&(window.__THREE__?_t("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_c);/**
* @license
* Copyright 2010-2025 Three.js Authors
* SPDX-License-Identifier: MIT
*/function JB(){let n=null,e=!1,t=null,i=null;function a(r,s){t(r,s),i=n.requestAnimationFrame(a)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(a),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function ZG(n){const e=new WeakMap;function t(o,c){const h=o.array,f=o.usage,d=h.byteLength,m=n.createBuffer();n.bindBuffer(c,m),n.bufferData(c,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:m,type:g,bytesPerElement:h.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,c,h){const f=c.array,d=c.updateRanges;if(n.bindBuffer(h,o),d.length===0)n.bufferSubData(h,0,f);else{d.sort((g,y)=>g.start-y.start);let m=0;for(let g=1;g<d.length;g++){const y=d[m],E=d[g];E.start<=y.start+y.count+1?y.count=Math.max(y.count,E.start+E.count-y.start):(++m,d[m]=E)}d.length=m+1;for(let g=0,y=d.length;g<y;g++){const E=d[g];n.bufferSubData(h,E.start*f.BYTES_PER_ELEMENT,f,E.start,E.count)}c.clearUpdateRanges()}c.onUploadCallback()}function a(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(n.deleteBuffer(c.buffer),e.delete(o))}function s(o,c){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,c));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,c),h.version=o.version}}return{get:a,remove:r,update:s}}var jG=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,KG=`#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`,JG=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,QG=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,$G=`#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`,eV=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,tV=`#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`,nV=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,iV=`#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`,aV=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,rV=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,sV=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,oV=`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`,lV=`#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`,cV=`#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`,uV=`#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`,hV=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,fV=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,dV=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,pV=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,mV=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,gV=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
#endif`,vV=`#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`,xV=`#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`,yV=`#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`,_V=`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`,SV=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,AV=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,EV=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,TV=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,bV="gl_FragColor = linearToOutputTexel( gl_FragColor );",MV=`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 );
}`,CV=`#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`,RV=`#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`,wV=`#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`,DV=`#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`,NV=`#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`,OV=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,IV=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,BV=`#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`,UV=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,LV=`#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
}`,PV=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,FV=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,HV=`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`,zV=`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`,GV=`#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`,VV=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,kV=`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`,XV=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,WV=`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`,YV=`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`,qV=`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 );
}`,ZV=`
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`,jV=`#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`,KV=`#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`,JV=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,QV=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,$V=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,ek=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,tk=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,nk=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,ik=`#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`,ak=`#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`,rk=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,sk=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,ok=`#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`,lk=`#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`,ck=`#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`,uk=`#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`,hk=`#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`,fk=`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;`,dk=`#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`,pk=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,mk=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,gk=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,vk=`#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`,xk=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,yk=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,_k=`#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`,Sk=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,Ak=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ek=`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 );
}`,Tk=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,bk=`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;`,Mk=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,Ck=`#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`,Rk=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,wk=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,Dk=`#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`,Nk=`#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`,Ok=`#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`,Ik=`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;
}`,Bk=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,Uk=`#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`,Lk=`#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`,Pk=`#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`,Fk=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,Hk=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,zk=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,Gk=`#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; }`,Vk=`#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`,kk=`#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`,Xk=`#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`,Wk=`#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`,Yk=`#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`,qk=`#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 Zk=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,jk=`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>
}`,Kk=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,Jk=`#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>
}`,Qk=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,$k=`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>
}`,eX=`#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;
}`,tX=`#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
}`,nX=`#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;
}`,iX=`#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 );
}`,aX=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,rX=`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>
}`,sX=`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>
}`,oX=`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>
}`,lX=`#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>
}`,cX=`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>
}`,uX=`#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>
}`,hX=`#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>
}`,fX=`#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;
}`,dX=`#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>
}`,pX=`#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
}`,mX=`#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
}`,gX=`#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>
}`,vX=`#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>
}`,xX=`#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
}`,yX=`#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>
}`,_X=`#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>
}`,SX=`#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>
}`,AX=`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>
}`,EX=`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>
}`,TX=`#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>
}`,bX=`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>
}`,MX=`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>
}`,CX=`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>
}`,tn={alphahash_fragment:jG,alphahash_pars_fragment:KG,alphamap_fragment:JG,alphamap_pars_fragment:QG,alphatest_fragment:$G,alphatest_pars_fragment:eV,aomap_fragment:tV,aomap_pars_fragment:nV,batching_pars_vertex:iV,batching_vertex:aV,begin_vertex:rV,beginnormal_vertex:sV,bsdfs:oV,iridescence_fragment:lV,bumpmap_pars_fragment:cV,clipping_planes_fragment:uV,clipping_planes_pars_fragment:hV,clipping_planes_pars_vertex:fV,clipping_planes_vertex:dV,color_fragment:pV,color_pars_fragment:mV,color_pars_vertex:gV,color_vertex:vV,common:xV,cube_uv_reflection_fragment:yV,defaultnormal_vertex:_V,displacementmap_pars_vertex:SV,displacementmap_vertex:AV,emissivemap_fragment:EV,emissivemap_pars_fragment:TV,colorspace_fragment:bV,colorspace_pars_fragment:MV,envmap_fragment:CV,envmap_common_pars_fragment:RV,envmap_pars_fragment:wV,envmap_pars_vertex:DV,envmap_physical_pars_fragment:GV,envmap_vertex:NV,fog_vertex:OV,fog_pars_vertex:IV,fog_fragment:BV,fog_pars_fragment:UV,gradientmap_pars_fragment:LV,lightmap_pars_fragment:PV,lights_lambert_fragment:FV,lights_lambert_pars_fragment:HV,lights_pars_begin:zV,lights_toon_fragment:VV,lights_toon_pars_fragment:kV,lights_phong_fragment:XV,lights_phong_pars_fragment:WV,lights_physical_fragment:YV,lights_physical_pars_fragment:qV,lights_fragment_begin:ZV,lights_fragment_maps:jV,lights_fragment_end:KV,logdepthbuf_fragment:JV,logdepthbuf_pars_fragment:QV,logdepthbuf_pars_vertex:$V,logdepthbuf_vertex:ek,map_fragment:tk,map_pars_fragment:nk,map_particle_fragment:ik,map_particle_pars_fragment:ak,metalnessmap_fragment:rk,metalnessmap_pars_fragment:sk,morphinstance_vertex:ok,morphcolor_vertex:lk,morphnormal_vertex:ck,morphtarget_pars_vertex:uk,morphtarget_vertex:hk,normal_fragment_begin:fk,normal_fragment_maps:dk,normal_pars_fragment:pk,normal_pars_vertex:mk,normal_vertex:gk,normalmap_pars_fragment:vk,clearcoat_normal_fragment_begin:xk,clearcoat_normal_fragment_maps:yk,clearcoat_pars_fragment:_k,iridescence_pars_fragment:Sk,opaque_fragment:Ak,packing:Ek,premultiplied_alpha_fragment:Tk,project_vertex:bk,dithering_fragment:Mk,dithering_pars_fragment:Ck,roughnessmap_fragment:Rk,roughnessmap_pars_fragment:wk,shadowmap_pars_fragment:Dk,shadowmap_pars_vertex:Nk,shadowmap_vertex:Ok,shadowmask_pars_fragment:Ik,skinbase_vertex:Bk,skinning_pars_vertex:Uk,skinning_vertex:Lk,skinnormal_vertex:Pk,specularmap_fragment:Fk,specularmap_pars_fragment:Hk,tonemapping_fragment:zk,tonemapping_pars_fragment:Gk,transmission_fragment:Vk,transmission_pars_fragment:kk,uv_pars_fragment:Xk,uv_pars_vertex:Wk,uv_vertex:Yk,worldpos_vertex:qk,background_vert:Zk,background_frag:jk,backgroundCube_vert:Kk,backgroundCube_frag:Jk,cube_vert:Qk,cube_frag:$k,depth_vert:eX,depth_frag:tX,distanceRGBA_vert:nX,distanceRGBA_frag:iX,equirect_vert:aX,equirect_frag:rX,linedashed_vert:sX,linedashed_frag:oX,meshbasic_vert:lX,meshbasic_frag:cX,meshlambert_vert:uX,meshlambert_frag:hX,meshmatcap_vert:fX,meshmatcap_frag:dX,meshnormal_vert:pX,meshnormal_frag:mX,meshphong_vert:gX,meshphong_frag:vX,meshphysical_vert:xX,meshphysical_frag:yX,meshtoon_vert:_X,meshtoon_frag:SX,points_vert:AX,points_frag:EX,shadow_vert:TX,shadow_frag:bX,sprite_vert:MX,sprite_frag:CX},yt={common:{diffuse:{value:new dt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new kt}},envmap:{envMap:{value:null},envMapRotation:{value:new kt},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 kt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new kt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new kt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new kt},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new kt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new kt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new kt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new kt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new dt(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 dt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0},uvTransform:{value:new kt}},sprite:{diffuse:{value:new dt(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}}},Cs={basic:{uniforms:Na([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.fog]),vertexShader:tn.meshbasic_vert,fragmentShader:tn.meshbasic_frag},lambert:{uniforms:Na([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new dt(0)}}]),vertexShader:tn.meshlambert_vert,fragmentShader:tn.meshlambert_frag},phong:{uniforms:Na([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new dt(0)},specular:{value:new dt(1118481)},shininess:{value:30}}]),vertexShader:tn.meshphong_vert,fragmentShader:tn.meshphong_frag},standard:{uniforms:Na([yt.common,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.roughnessmap,yt.metalnessmap,yt.fog,yt.lights,{emissive:{value:new dt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:tn.meshphysical_vert,fragmentShader:tn.meshphysical_frag},toon:{uniforms:Na([yt.common,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.gradientmap,yt.fog,yt.lights,{emissive:{value:new dt(0)}}]),vertexShader:tn.meshtoon_vert,fragmentShader:tn.meshtoon_frag},matcap:{uniforms:Na([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,{matcap:{value:null}}]),vertexShader:tn.meshmatcap_vert,fragmentShader:tn.meshmatcap_frag},points:{uniforms:Na([yt.points,yt.fog]),vertexShader:tn.points_vert,fragmentShader:tn.points_frag},dashed:{uniforms:Na([yt.common,yt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:tn.linedashed_vert,fragmentShader:tn.linedashed_frag},depth:{uniforms:Na([yt.common,yt.displacementmap]),vertexShader:tn.depth_vert,fragmentShader:tn.depth_frag},normal:{uniforms:Na([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,{opacity:{value:1}}]),vertexShader:tn.meshnormal_vert,fragmentShader:tn.meshnormal_frag},sprite:{uniforms:Na([yt.sprite,yt.fog]),vertexShader:tn.sprite_vert,fragmentShader:tn.sprite_frag},background:{uniforms:{uvTransform:{value:new kt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:tn.background_vert,fragmentShader:tn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new kt}},vertexShader:tn.backgroundCube_vert,fragmentShader:tn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:tn.cube_vert,fragmentShader:tn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:tn.equirect_vert,fragmentShader:tn.equirect_frag},distanceRGBA:{uniforms:Na([yt.common,yt.displacementmap,{referencePosition:{value:new H},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:tn.distanceRGBA_vert,fragmentShader:tn.distanceRGBA_frag},shadow:{uniforms:Na([yt.lights,yt.fog,{color:{value:new dt(0)},opacity:{value:1}}]),vertexShader:tn.shadow_vert,fragmentShader:tn.shadow_frag}};Cs.physical={uniforms:Na([Cs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new kt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new kt},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new kt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new kt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new kt},sheen:{value:0},sheenColor:{value:new dt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new kt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new kt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new kt},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new kt},attenuationDistance:{value:0},attenuationColor:{value:new dt(0)},specularColor:{value:new dt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new kt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new kt},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new kt}}]),vertexShader:tn.meshphysical_vert,fragmentShader:tn.meshphysical_frag};const Ov={r:0,b:0,g:0},nu=new Dr,RX=new lt;function wX(n,e,t,i,a,r,s){const o=new dt(0);let c=r===!0?0:1,h,f,d=null,m=0,g=null;function y(A){let b=A.isScene===!0?A.background:null;return b&&b.isTexture&&(b=(A.backgroundBlurriness>0?t:e).get(b)),b}function E(A){let b=!1;const O=y(A);O===null?v(o,c):O&&O.isColor&&(v(O,1),b=!0);const N=n.xr.getEnvironmentBlendMode();N==="additive"?i.buffers.color.setClear(0,0,0,1,s):N==="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 S(A,b){const O=y(b);O&&(O.isCubeTexture||O.mapping===Pd)?(f===void 0&&(f=new Xn(new lh(1,1,1),new Di({name:"BackgroundCubeMaterial",uniforms:_d(Cs.backgroundCube.uniforms),vertexShader:Cs.backgroundCube.vertexShader,fragmentShader:Cs.backgroundCube.fragmentShader,side:Wi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),f.geometry.deleteAttribute("normal"),f.geometry.deleteAttribute("uv"),f.onBeforeRender=function(N,L,B){this.matrixWorld.copyPosition(B.matrixWorld)},Object.defineProperty(f.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(f)),nu.copy(b.backgroundRotation),nu.x*=-1,nu.y*=-1,nu.z*=-1,O.isCubeTexture&&O.isRenderTargetTexture===!1&&(nu.y*=-1,nu.z*=-1),f.material.uniforms.envMap.value=O,f.material.uniforms.flipEnvMap.value=O.isCubeTexture&&O.isRenderTargetTexture===!1?-1:1,f.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,f.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,f.material.uniforms.backgroundRotation.value.setFromMatrix4(RX.makeRotationFromEuler(nu)),f.material.toneMapped=gn.getTransfer(O.colorSpace)!==Un,(d!==O||m!==O.version||g!==n.toneMapping)&&(f.material.needsUpdate=!0,d=O,m=O.version,g=n.toneMapping),f.layers.enableAll(),A.unshift(f,f.geometry,f.material,0,0,null)):O&&O.isTexture&&(h===void 0&&(h=new Xn(new Us(2,2),new Di({name:"BackgroundMaterial",uniforms:_d(Cs.background.uniforms),vertexShader:Cs.background.vertexShader,fragmentShader:Cs.background.fragmentShader,side:os,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(h)),h.material.uniforms.t2D.value=O,h.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,h.material.toneMapped=gn.getTransfer(O.colorSpace)!==Un,O.matrixAutoUpdate===!0&&O.updateMatrix(),h.material.uniforms.uvTransform.value.copy(O.matrix),(d!==O||m!==O.version||g!==n.toneMapping)&&(h.material.needsUpdate=!0,d=O,m=O.version,g=n.toneMapping),h.layers.enableAll(),A.unshift(h,h.geometry,h.material,0,0,null))}function v(A,b){A.getRGB(Ov,sB(n)),i.buffers.color.setClear(Ov.r,Ov.g,Ov.b,b,s)}function _(){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(A,b=1){o.set(A),c=b,v(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(A){c=A,v(o,c)},render:E,addToRenderList:S,dispose:_}}function DX(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},a=m(null);let r=a,s=!1;function o(D,G,J,$,se){let le=!1;const q=d($,J,G);r!==q&&(r=q,h(r.object)),le=g(D,$,J,se),le&&y(D,$,J,se),se!==null&&e.update(se,n.ELEMENT_ARRAY_BUFFER),(le||s)&&(s=!1,b(D,G,J,$),se!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(se).buffer))}function c(){return n.createVertexArray()}function h(D){return n.bindVertexArray(D)}function f(D){return n.deleteVertexArray(D)}function d(D,G,J){const $=J.wireframe===!0;let se=i[D.id];se===void 0&&(se={},i[D.id]=se);let le=se[G.id];le===void 0&&(le={},se[G.id]=le);let q=le[$];return q===void 0&&(q=m(c()),le[$]=q),q}function m(D){const G=[],J=[],$=[];for(let se=0;se<t;se++)G[se]=0,J[se]=0,$[se]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:G,enabledAttributes:J,attributeDivisors:$,object:D,attributes:{},index:null}}function g(D,G,J,$){const se=r.attributes,le=G.attributes;let q=0;const te=J.getAttributes();for(const ee in te)if(te[ee].location>=0){const ue=se[ee];let Pe=le[ee];if(Pe===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(Pe=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(Pe=D.instanceColor)),ue===void 0||ue.attribute!==Pe||Pe&&ue.data!==Pe.data)return!0;q++}return r.attributesNum!==q||r.index!==$}function y(D,G,J,$){const se={},le=G.attributes;let q=0;const te=J.getAttributes();for(const ee in te)if(te[ee].location>=0){let ue=le[ee];ue===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(ue=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(ue=D.instanceColor));const Pe={};Pe.attribute=ue,ue&&ue.data&&(Pe.data=ue.data),se[ee]=Pe,q++}r.attributes=se,r.attributesNum=q,r.index=$}function E(){const D=r.newAttributes;for(let G=0,J=D.length;G<J;G++)D[G]=0}function S(D){v(D,0)}function v(D,G){const J=r.newAttributes,$=r.enabledAttributes,se=r.attributeDivisors;J[D]=1,$[D]===0&&(n.enableVertexAttribArray(D),$[D]=1),se[D]!==G&&(n.vertexAttribDivisor(D,G),se[D]=G)}function _(){const D=r.newAttributes,G=r.enabledAttributes;for(let J=0,$=G.length;J<$;J++)G[J]!==D[J]&&(n.disableVertexAttribArray(J),G[J]=0)}function A(D,G,J,$,se,le,q){q===!0?n.vertexAttribIPointer(D,G,J,se,le):n.vertexAttribPointer(D,G,J,$,se,le)}function b(D,G,J,$){E();const se=$.attributes,le=J.getAttributes(),q=G.defaultAttributeValues;for(const te in le){const ee=le[te];if(ee.location>=0){let de=se[te];if(de===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(de=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(de=D.instanceColor)),de!==void 0){const ue=de.normalized,Pe=de.itemSize,He=e.get(de);if(He===void 0)continue;const Ke=He.buffer,nt=He.type,xt=He.bytesPerElement,fe=nt===n.INT||nt===n.UNSIGNED_INT||de.gpuType===Fd;if(de.isInterleavedBufferAttribute){const Be=de.data,Je=Be.stride,ve=de.offset;if(Be.isInstancedInterleavedBuffer){for(let at=0;at<ee.locationSize;at++)v(ee.location+at,Be.meshPerAttribute);D.isInstancedMesh!==!0&&$._maxInstanceCount===void 0&&($._maxInstanceCount=Be.meshPerAttribute*Be.count)}else for(let at=0;at<ee.locationSize;at++)S(ee.location+at);n.bindBuffer(n.ARRAY_BUFFER,Ke);for(let at=0;at<ee.locationSize;at++)A(ee.location+at,Pe/ee.locationSize,nt,ue,Je*xt,(ve+Pe/ee.locationSize*at)*xt,fe)}else{if(de.isInstancedBufferAttribute){for(let Be=0;Be<ee.locationSize;Be++)v(ee.location+Be,de.meshPerAttribute);D.isInstancedMesh!==!0&&$._maxInstanceCount===void 0&&($._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let Be=0;Be<ee.locationSize;Be++)S(ee.location+Be);n.bindBuffer(n.ARRAY_BUFFER,Ke);for(let Be=0;Be<ee.locationSize;Be++)A(ee.location+Be,Pe/ee.locationSize,nt,ue,Pe*xt,Pe/ee.locationSize*Be*xt,fe)}}else if(q!==void 0){const ue=q[te];if(ue!==void 0)switch(ue.length){case 2:n.vertexAttrib2fv(ee.location,ue);break;case 3:n.vertexAttrib3fv(ee.location,ue);break;case 4:n.vertexAttrib4fv(ee.location,ue);break;default:n.vertexAttrib1fv(ee.location,ue)}}}}_()}function O(){B();for(const D in i){const G=i[D];for(const J in G){const $=G[J];for(const se in $)f($[se].object),delete $[se];delete G[J]}delete i[D]}}function N(D){if(i[D.id]===void 0)return;const G=i[D.id];for(const J in G){const $=G[J];for(const se in $)f($[se].object),delete $[se];delete G[J]}delete i[D.id]}function L(D){for(const G in i){const J=i[G];if(J[D.id]===void 0)continue;const $=J[D.id];for(const se in $)f($[se].object),delete $[se];delete J[D.id]}}function B(){w(),s=!0,r!==a&&(r=a,h(r.object))}function w(){a.geometry=null,a.program=null,a.wireframe=!1}return{setup:o,reset:B,resetDefaultState:w,dispose:O,releaseStatesOfGeometry:N,releaseStatesOfProgram:L,initAttributes:E,enableAttribute:S,disableUnusedAttributes:_}}function NX(n,e,t){let i;function a(h){i=h}function r(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 y=0;y<d;y++)g+=f[y];t.update(g,i,1)}function c(h,f,d,m){if(d===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let y=0;y<h.length;y++)s(h[y],f[y],m[y]);else{g.multiDrawArraysInstancedWEBGL(i,h,0,f,0,m,0,d);let y=0;for(let E=0;E<d;E++)y+=f[E]*m[E];t.update(y,i,1)}}this.setMode=a,this.render=r,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function OX(n,e,t,i){let a;function r(){if(a!==void 0)return a;if(e.has("EXT_texture_filter_anisotropic")===!0){const L=e.get("EXT_texture_filter_anisotropic");a=n.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else a=0;return a}function s(L){return!(L!==Rn&&i.convert(L)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(L){const B=L===sn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(L!==xi&&i.convert(L)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&L!==Sn&&!B)}function c(L){if(L==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";L="mediump"}return L==="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=c(h);f!==h&&(_t("WebGLRenderer:",h,"not supported, using",f,"instead."),h=f);const d=t.logarithmicDepthBuffer===!0,m=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),g=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),E=n.getParameter(n.MAX_TEXTURE_SIZE),S=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),v=n.getParameter(n.MAX_VERTEX_ATTRIBS),_=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),A=n.getParameter(n.MAX_VARYING_VECTORS),b=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),O=y>0,N=n.getParameter(n.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:s,textureTypeReadable:o,precision:h,logarithmicDepthBuffer:d,reversedDepthBuffer:m,maxTextures:g,maxVertexTextures:y,maxTextureSize:E,maxCubemapSize:S,maxAttributes:v,maxVertexUniforms:_,maxVaryings:A,maxFragmentUniforms:b,vertexTextures:O,maxSamples:N}}function IX(n){const e=this;let t=null,i=0,a=!1,r=!1;const s=new Lo,o=new kt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,m){const g=d.length!==0||m||i!==0||a;return a=m,i=d.length,g},this.beginShadows=function(){r=!0,f(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,m){t=f(d,m,0)},this.setState=function(d,m,g){const y=d.clippingPlanes,E=d.clipIntersection,S=d.clipShadows,v=n.get(d);if(!a||y===null||y.length===0||r&&!S)r?f(null):h();else{const _=r?0:i,A=_*4;let b=v.clippingState||null;c.value=b,b=f(y,m,A,g);for(let O=0;O!==A;++O)b[O]=t[O];v.clippingState=b,this.numIntersection=E?this.numPlanes:0,this.numPlanes+=_}};function h(){c.value!==t&&(c.value=t,c.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function f(d,m,g,y){const E=d!==null?d.length:0;let S=null;if(E!==0){if(S=c.value,y!==!0||S===null){const v=g+E*4,_=m.matrixWorldInverse;o.getNormalMatrix(_),(S===null||S.length<v)&&(S=new Float32Array(v));for(let A=0,b=g;A!==E;++A,b+=4)s.copy(d[A]).applyMatrix4(_,o),s.normal.toArray(S,b),S[b+3]=s.constant}c.value=S,c.needsUpdate=!0}return e.numPlanes=E,e.numIntersection=0,S}}function BX(n){let e=new WeakMap;function t(s,o){return o===hd?s.mapping=no:o===$m&&(s.mapping=mc),s}function i(s){if(s&&s.isTexture){const o=s.mapping;if(o===hd||o===$m)if(e.has(s)){const c=e.get(s).texture;return t(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const h=new z3(c.height);return h.fromEquirectangularTexture(n,s),e.set(s,h),s.addEventListener("dispose",a),t(h.texture,s.mapping)}else return null}}return s}function a(s){const o=s.target;o.removeEventListener("dispose",a);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function r(){e=new WeakMap}return{get:i,dispose:r}}const Jl=4,L4=[.125,.215,.35,.446,.526,.582],fu=20,UX=256,Hp=new Rr,P4=new dt;let JA=null,QA=0,$A=0,e2=!1;const LX=new H;class FE{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,a=100,r={}){const{size:s=256,position:o=LX}=r;JA=this._renderer.getRenderTarget(),QA=this._renderer.getActiveCubeFace(),$A=this._renderer.getActiveMipmapLevel(),e2=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,i,a,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=z4(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=H4(),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(JA,QA,$A),this._renderer.xr.enabled=e2,e.scissorTest=!1,cf(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===no||e.mapping===mc?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),JA=this._renderer.getRenderTarget(),QA=this._renderer.getActiveCubeFace(),$A=this._renderer.getActiveMipmapLevel(),e2=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:Bt,minFilter:Bt,generateMipmaps:!1,type:sn,format:Rn,colorSpace:Fi,depthBuffer:!1},a=F4(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=F4(e,t,i);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=PX(r)),this._blurMaterial=HX(r,e,t),this._ggxMaterial=FX(r,e,t)}return a}_compileMaterial(e){const t=new Xn(new Xt,e);this._renderer.compile(t,Hp)}_sceneToCubeUV(e,t,i,a,r){const c=new Jn(90,1,t,i),h=[1,-1,1,1,1,1],f=[1,1,1,-1,-1,-1],d=this._renderer,m=d.autoClear,g=d.toneMapping;d.getClearColor(P4),d.toneMapping=ns,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(a),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Xn(new lh,new Qa({name:"PMREM.Background",side:Wi,depthWrite:!1,depthTest:!1})));const E=this._backgroundBox,S=E.material;let v=!1;const _=e.background;_?_.isColor&&(S.color.copy(_),e.background=null,v=!0):(S.color.copy(P4),v=!0);for(let A=0;A<6;A++){const b=A%3;b===0?(c.up.set(0,h[A],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+f[A],r.y,r.z)):b===1?(c.up.set(0,0,h[A]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+f[A],r.z)):(c.up.set(0,h[A],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+f[A]));const O=this._cubeSize;cf(a,b*O,A>2?O:0,O,O),d.setRenderTarget(a),v&&d.render(E,c),d.render(e,c)}d.toneMapping=g,d.autoClear=m,e.background=_}_textureToCubeUV(e,t){const i=this._renderer,a=e.mapping===no||e.mapping===mc;a?(this._cubemapMaterial===null&&(this._cubemapMaterial=z4()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=H4());const r=a?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;cf(t,0,0,3*c,2*c),i.setRenderTarget(t),i.render(s,Hp)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const a=this._lodMeshes.length;for(let r=1;r<a;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=i}_applyGGXFilter(e,t,i){const a=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[i];o.material=s;const c=s.uniforms,h=i/(this._lodMeshes.length-1),f=t/(this._lodMeshes.length-1),d=Math.sqrt(h*h-f*f),m=.05+h*.95,g=d*m,{_lodMax:y}=this,E=this._sizeLods[i],S=3*E*(i>y-Jl?i-y+Jl:0),v=4*(this._cubeSize-E);c.envMap.value=e.texture,c.roughness.value=g,c.mipInt.value=y-t,cf(r,S,v,3*E,2*E),a.setRenderTarget(r),a.render(o,Hp),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=y-i,cf(e,S,v,3*E,2*E),a.setRenderTarget(e),a.render(o,Hp)}_blur(e,t,i,a,r){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,i,a,"latitudinal",r),this._halfBlur(s,e,i,i,a,"longitudinal",r)}_halfBlur(e,t,i,a,r,s,o){const c=this._renderer,h=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&qt("blur direction must be either latitudinal or longitudinal!");const f=3,d=this._lodMeshes[a];d.material=h;const m=h.uniforms,g=this._sizeLods[i]-1,y=isFinite(r)?Math.PI/(2*g):2*Math.PI/(2*fu-1),E=r/y,S=isFinite(r)?1+Math.floor(f*E):fu;S>fu&&_t(`sigmaRadians, ${r}, is too large and will clip, as it requested ${S} samples when the maximum is set to ${fu}`);const v=[];let _=0;for(let L=0;L<fu;++L){const B=L/E,w=Math.exp(-B*B/2);v.push(w),L===0?_+=w:L<S&&(_+=2*w)}for(let L=0;L<v.length;L++)v[L]=v[L]/_;m.envMap.value=e.texture,m.samples.value=S,m.weights.value=v,m.latitudinal.value=s==="latitudinal",o&&(m.poleAxis.value=o);const{_lodMax:A}=this;m.dTheta.value=y,m.mipInt.value=A-i;const b=this._sizeLods[a],O=3*b*(a>A-Jl?a-A+Jl:0),N=4*(this._cubeSize-b);cf(t,O,N,3*b,2*b),c.setRenderTarget(t),c.render(d,Hp)}}function PX(n){const e=[],t=[],i=[];let a=n;const r=n-Jl+1+L4.length;for(let s=0;s<r;s++){const o=Math.pow(2,a);e.push(o);let c=1/o;s>n-Jl?c=L4[s-n+Jl-1]:s===0&&(c=0),t.push(c);const h=1/(o-2),f=-h,d=1+h,m=[f,f,d,f,d,d,f,f,d,d,f,d],g=6,y=6,E=3,S=2,v=1,_=new Float32Array(E*y*g),A=new Float32Array(S*y*g),b=new Float32Array(v*y*g);for(let N=0;N<g;N++){const L=N%3*2/3-1,B=N>2?0:-1,w=[L,B,0,L+2/3,B,0,L+2/3,B+1,0,L,B,0,L+2/3,B+1,0,L,B+1,0];_.set(w,E*y*N),A.set(m,S*y*N);const D=[N,N,N,N,N,N];b.set(D,v*y*N)}const O=new Xt;O.setAttribute("position",new pn(_,E)),O.setAttribute("uv",new pn(A,S)),O.setAttribute("faceIndex",new pn(b,v)),i.push(new Xn(O,null)),a>Jl&&a--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function F4(n,e,t){const i=new oi(n,e,t);return i.texture.mapping=Pd,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function cf(n,e,t,i,a){n.viewport.set(e,t,i,a),n.scissor.set(e,t,i,a)}function FX(n,e,t){return new Di({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:UX,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:Gy(),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:ga,depthTest:!1,depthWrite:!1})}function HX(n,e,t){const i=new Float32Array(fu),a=new H(0,1,0);return new Di({name:"SphericalGaussianBlur",defines:{n:fu,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:a}},vertexShader:Gy(),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:ga,depthTest:!1,depthWrite:!1})}function H4(){return new Di({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Gy(),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:ga,depthTest:!1,depthWrite:!1})}function z4(){return new Di({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Gy(),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:ga,depthTest:!1,depthWrite:!1})}function Gy(){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 zX(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const c=o.mapping,h=c===hd||c===$m,f=c===no||c===mc;if(h||f){let d=e.get(o);const m=d!==void 0?d.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==m)return t===null&&(t=new FE(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&&a(g)?(t===null&&(t=new FE(n)),d=h?t.fromEquirectangular(o):t.fromCubemap(o),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),o.addEventListener("dispose",r),d.texture):null}}}return o}function a(o){let c=0;const h=6;for(let f=0;f<h;f++)o[f]!==void 0&&c++;return c===h}function r(o){const c=o.target;c.removeEventListener("dispose",r);const h=e.get(c);h!==void 0&&(e.delete(c),h.dispose())}function s(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:s}}function GX(n){const e={};function t(i){if(e[i]!==void 0)return e[i];const a=n.getExtension(i);return e[i]=a,a}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 a=t(i);return a===null&&vd("WebGLRenderer: "+i+" extension not supported."),a}}}function VX(n,e,t,i){const a={},r=new WeakMap;function s(d){const m=d.target;m.index!==null&&e.remove(m.index);for(const y in m.attributes)e.remove(m.attributes[y]);m.removeEventListener("dispose",s),delete a[m.id];const g=r.get(m);g&&(e.remove(g),r.delete(m)),i.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,t.memory.geometries--}function o(d,m){return a[m.id]===!0||(m.addEventListener("dispose",s),a[m.id]=!0,t.memory.geometries++),m}function c(d){const m=d.attributes;for(const g in m)e.update(m[g],n.ARRAY_BUFFER)}function h(d){const m=[],g=d.index,y=d.attributes.position;let E=0;if(g!==null){const _=g.array;E=g.version;for(let A=0,b=_.length;A<b;A+=3){const O=_[A+0],N=_[A+1],L=_[A+2];m.push(O,N,N,L,L,O)}}else if(y!==void 0){const _=y.array;E=y.version;for(let A=0,b=_.length/3-1;A<b;A+=3){const O=A+0,N=A+1,L=A+2;m.push(O,N,N,L,L,O)}}else return;const S=new(tB(m)?H3:F3)(m,1);S.version=E;const v=r.get(d);v&&e.remove(v),r.set(d,S)}function f(d){const m=r.get(d);if(m){const g=d.index;g!==null&&m.version<g.version&&h(d)}else h(d);return r.get(d)}return{get:o,update:c,getWireframeAttribute:f}}function kX(n,e,t){let i;function a(m){i=m}let r,s;function o(m){r=m.type,s=m.bytesPerElement}function c(m,g){n.drawElements(i,g,r,m*s),t.update(g,i,1)}function h(m,g,y){y!==0&&(n.drawElementsInstanced(i,g,r,m*s,y),t.update(g,i,y))}function f(m,g,y){if(y===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,g,0,r,m,0,y);let S=0;for(let v=0;v<y;v++)S+=g[v];t.update(S,i,1)}function d(m,g,y,E){if(y===0)return;const S=e.get("WEBGL_multi_draw");if(S===null)for(let v=0;v<m.length;v++)h(m[v]/s,g[v],E[v]);else{S.multiDrawElementsInstancedWEBGL(i,g,0,r,m,0,E,0,y);let v=0;for(let _=0;_<y;_++)v+=g[_]*E[_];t.update(v,i,1)}}this.setMode=a,this.setIndex=o,this.render=c,this.renderInstances=h,this.renderMultiDraw=f,this.renderMultiDrawInstances=d}function XX(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(r,s,o){switch(t.calls++,s){case n.TRIANGLES:t.triangles+=o*(r/3);break;case n.LINES:t.lines+=o*(r/2);break;case n.LINE_STRIP:t.lines+=o*(r-1);break;case n.LINE_LOOP:t.lines+=o*r;break;case n.POINTS:t.points+=o*r;break;default:qt("WebGLInfo: Unknown draw mode:",s);break}}function a(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:a,update:i}}function WX(n,e,t){const i=new WeakMap,a=new Yt;function r(s,o,c){const h=s.morphTargetInfluences,f=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=f!==void 0?f.length:0;let m=i.get(o);if(m===void 0||m.count!==d){let D=function(){B.dispose(),i.delete(o),o.removeEventListener("dispose",D)};var g=D;m!==void 0&&m.texture.dispose();const y=o.morphAttributes.position!==void 0,E=o.morphAttributes.normal!==void 0,S=o.morphAttributes.color!==void 0,v=o.morphAttributes.position||[],_=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let b=0;y===!0&&(b=1),E===!0&&(b=2),S===!0&&(b=3);let O=o.attributes.position.count*b,N=1;O>e.maxTextureSize&&(N=Math.ceil(O/e.maxTextureSize),O=e.maxTextureSize);const L=new Float32Array(O*N*4*d),B=new yy(L,O,N,d);B.type=Sn,B.needsUpdate=!0;const w=b*4;for(let G=0;G<d;G++){const J=v[G],$=_[G],se=A[G],le=O*N*4*G;for(let q=0;q<J.count;q++){const te=q*w;y===!0&&(a.fromBufferAttribute(J,q),L[le+te+0]=a.x,L[le+te+1]=a.y,L[le+te+2]=a.z,L[le+te+3]=0),E===!0&&(a.fromBufferAttribute($,q),L[le+te+4]=a.x,L[le+te+5]=a.y,L[le+te+6]=a.z,L[le+te+7]=0),S===!0&&(a.fromBufferAttribute(se,q),L[le+te+8]=a.x,L[le+te+9]=a.y,L[le+te+10]=a.z,L[le+te+11]=se.itemSize===4?a.w:1)}}m={count:d,texture:B,size:new Ee(O,N)},i.set(o,m),o.addEventListener("dispose",D)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)c.getUniforms().setValue(n,"morphTexture",s.morphTexture,t);else{let y=0;for(let S=0;S<h.length;S++)y+=h[S];const E=o.morphTargetsRelative?1:1-y;c.getUniforms().setValue(n,"morphTargetBaseInfluence",E),c.getUniforms().setValue(n,"morphTargetInfluences",h)}c.getUniforms().setValue(n,"morphTargetsTexture",m.texture,t),c.getUniforms().setValue(n,"morphTargetsTextureSize",m.size)}return{update:r}}function YX(n,e,t,i){let a=new WeakMap;function r(c){const h=i.render.frame,f=c.geometry,d=e.get(c,f);if(a.get(d)!==h&&(e.update(d),a.set(d,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),a.get(c)!==h&&(t.update(c.instanceMatrix,n.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,n.ARRAY_BUFFER),a.set(c,h))),c.isSkinnedMesh){const m=c.skeleton;a.get(m)!==h&&(m.update(),a.set(m,h))}return d}function s(){a=new WeakMap}function o(c){const h=c.target;h.removeEventListener("dispose",o),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:r,dispose:s}}const QB=new vn,G4=new N0(1,1),$B=new yy,e8=new is,t8=new w0,V4=[],k4=[],X4=new Float32Array(16),W4=new Float32Array(9),Y4=new Float32Array(4);function Gd(n,e,t){const i=n[0];if(i<=0||i>0)return n;const a=e*t;let r=V4[a];if(r===void 0&&(r=new Float32Array(a),V4[a]=r),e!==0){i.toArray(r,0);for(let s=1,o=0;s!==e;++s)o+=t,n[s].toArray(r,o)}return r}function Zi(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 ji(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Vy(n,e){let t=k4[e];t===void 0&&(t=new Int32Array(e),k4[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function qX(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function ZX(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(Zi(t,e))return;n.uniform2fv(this.addr,e),ji(t,e)}}function jX(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(Zi(t,e))return;n.uniform3fv(this.addr,e),ji(t,e)}}function KX(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(Zi(t,e))return;n.uniform4fv(this.addr,e),ji(t,e)}}function JX(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zi(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),ji(t,e)}else{if(Zi(t,i))return;Y4.set(i),n.uniformMatrix2fv(this.addr,!1,Y4),ji(t,i)}}function QX(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zi(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),ji(t,e)}else{if(Zi(t,i))return;W4.set(i),n.uniformMatrix3fv(this.addr,!1,W4),ji(t,i)}}function $X(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Zi(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),ji(t,e)}else{if(Zi(t,i))return;X4.set(i),n.uniformMatrix4fv(this.addr,!1,X4),ji(t,i)}}function eW(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function tW(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(Zi(t,e))return;n.uniform2iv(this.addr,e),ji(t,e)}}function nW(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(Zi(t,e))return;n.uniform3iv(this.addr,e),ji(t,e)}}function iW(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(Zi(t,e))return;n.uniform4iv(this.addr,e),ji(t,e)}}function aW(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function rW(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(Zi(t,e))return;n.uniform2uiv(this.addr,e),ji(t,e)}}function sW(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(Zi(t,e))return;n.uniform3uiv(this.addr,e),ji(t,e)}}function oW(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(Zi(t,e))return;n.uniform4uiv(this.addr,e),ji(t,e)}}function lW(n,e,t){const i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a);let r;this.type===n.SAMPLER_2D_SHADOW?(G4.compareFunction=B3,r=G4):r=QB,t.setTexture2D(e||r,a)}function cW(n,e,t){const i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.setTexture3D(e||e8,a)}function uW(n,e,t){const i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.setTextureCube(e||t8,a)}function hW(n,e,t){const i=this.cache,a=t.allocateTextureUnit();i[0]!==a&&(n.uniform1i(this.addr,a),i[0]=a),t.setTexture2DArray(e||$B,a)}function fW(n){switch(n){case 5126:return qX;case 35664:return ZX;case 35665:return jX;case 35666:return KX;case 35674:return JX;case 35675:return QX;case 35676:return $X;case 5124:case 35670:return eW;case 35667:case 35671:return tW;case 35668:case 35672:return nW;case 35669:case 35673:return iW;case 5125:return aW;case 36294:return rW;case 36295:return sW;case 36296:return oW;case 35678:case 36198:case 36298:case 36306:case 35682:return lW;case 35679:case 36299:case 36307:return cW;case 35680:case 36300:case 36308:case 36293:return uW;case 36289:case 36303:case 36311:case 36292:return hW}}function dW(n,e){n.uniform1fv(this.addr,e)}function pW(n,e){const t=Gd(e,this.size,2);n.uniform2fv(this.addr,t)}function mW(n,e){const t=Gd(e,this.size,3);n.uniform3fv(this.addr,t)}function gW(n,e){const t=Gd(e,this.size,4);n.uniform4fv(this.addr,t)}function vW(n,e){const t=Gd(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function xW(n,e){const t=Gd(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function yW(n,e){const t=Gd(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function _W(n,e){n.uniform1iv(this.addr,e)}function SW(n,e){n.uniform2iv(this.addr,e)}function AW(n,e){n.uniform3iv(this.addr,e)}function EW(n,e){n.uniform4iv(this.addr,e)}function TW(n,e){n.uniform1uiv(this.addr,e)}function bW(n,e){n.uniform2uiv(this.addr,e)}function MW(n,e){n.uniform3uiv(this.addr,e)}function CW(n,e){n.uniform4uiv(this.addr,e)}function RW(n,e,t){const i=this.cache,a=e.length,r=Vy(t,a);Zi(i,r)||(n.uniform1iv(this.addr,r),ji(i,r));for(let s=0;s!==a;++s)t.setTexture2D(e[s]||QB,r[s])}function wW(n,e,t){const i=this.cache,a=e.length,r=Vy(t,a);Zi(i,r)||(n.uniform1iv(this.addr,r),ji(i,r));for(let s=0;s!==a;++s)t.setTexture3D(e[s]||e8,r[s])}function DW(n,e,t){const i=this.cache,a=e.length,r=Vy(t,a);Zi(i,r)||(n.uniform1iv(this.addr,r),ji(i,r));for(let s=0;s!==a;++s)t.setTextureCube(e[s]||t8,r[s])}function NW(n,e,t){const i=this.cache,a=e.length,r=Vy(t,a);Zi(i,r)||(n.uniform1iv(this.addr,r),ji(i,r));for(let s=0;s!==a;++s)t.setTexture2DArray(e[s]||$B,r[s])}function OW(n){switch(n){case 5126:return dW;case 35664:return pW;case 35665:return mW;case 35666:return gW;case 35674:return vW;case 35675:return xW;case 35676:return yW;case 5124:case 35670:return _W;case 35667:case 35671:return SW;case 35668:case 35672:return AW;case 35669:case 35673:return EW;case 5125:return TW;case 36294:return bW;case 36295:return MW;case 36296:return CW;case 35678:case 36198:case 36298:case 36306:case 35682:return RW;case 35679:case 36299:case 36307:return wW;case 35680:case 36300:case 36308:case 36293:return DW;case 36289:case 36303:case 36311:case 36292:return NW}}class IW{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=fW(t.type)}}class BW{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=OW(t.type)}}class UW{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const a=this.seq;for(let r=0,s=a.length;r!==s;++r){const o=a[r];o.setValue(e,t[o.id],i)}}}const t2=/(\w+)(\])?(\[|\.)?/g;function q4(n,e){n.seq.push(e),n.map[e.id]=e}function LW(n,e,t){const i=n.name,a=i.length;for(t2.lastIndex=0;;){const r=t2.exec(i),s=t2.lastIndex;let o=r[1];const c=r[2]==="]",h=r[3];if(c&&(o=o|0),h===void 0||h==="["&&s+2===a){q4(t,h===void 0?new IW(o,n,e):new BW(o,n,e));break}else{let d=t.map[o];d===void 0&&(d=new UW(o),q4(t,d)),t=d}}}class f1{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const r=e.getActiveUniform(t,a),s=e.getUniformLocation(t,r.name);LW(r,s,this)}}setValue(e,t,i,a){const r=this.map[t];r!==void 0&&r.setValue(e,i,a)}setOptional(e,t,i){const a=t[i];a!==void 0&&this.setValue(e,i,a)}static upload(e,t,i,a){for(let r=0,s=t.length;r!==s;++r){const o=t[r],c=i[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,a)}}static seqWithValue(e,t){const i=[];for(let a=0,r=e.length;a!==r;++a){const s=e[a];s.id in t&&i.push(s)}return i}}function Z4(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const PW=37297;let FW=0;function HW(n,e){const t=n.split(`
`),i=[],a=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let s=a;s<r;s++){const o=s+1;i.push(`${o===e?">":" "} ${o}: ${t[s]}`)}return i.join(`
`)}const j4=new kt;function zW(n){gn._getMatrix(j4,gn.workingColorSpace,n);const e=`mat3( ${j4.elements.map(t=>t.toFixed(4))} )`;switch(gn.getTransfer(n)){case n0:return[e,"LinearTransferOETF"];case Un:return[e,"sRGBTransferOETF"];default:return _t("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function K4(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const o=parseInt(s[1]);return t.toUpperCase()+`
`+r+`
`+HW(n.getShaderSource(e),o)}else return r}function GW(n,e){const t=zW(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}function VW(n,e){let t;switch(e){case U5:t="Linear";break;case L5:t="Reinhard";break;case P5:t="Cineon";break;case C3:t="ACESFilmic";break;case H5:t="AgX";break;case z5:t="Neutral";break;case F5:t="Custom";break;default:_t("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Iv=new H;function kW(){gn.getLuminanceCoefficients(Iv);const n=Iv.x.toFixed(4),e=Iv.y.toFixed(4),t=Iv.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
`)}function XW(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(tm).join(`
`)}function WW(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
`)}function YW(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let a=0;a<i;a++){const r=n.getActiveAttrib(e,a),s=r.name;let o=1;r.type===n.FLOAT_MAT2&&(o=2),r.type===n.FLOAT_MAT3&&(o=3),r.type===n.FLOAT_MAT4&&(o=4),t[s]={type:r.type,location:n.getAttribLocation(e,s),locationSize:o}}return t}function tm(n){return n!==""}function J4(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 Q4(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const qW=/^[ \t]*#include +<([\w\d./]+)>/gm;function HE(n){return n.replace(qW,jW)}const ZW=new Map;function jW(n,e){let t=tn[e];if(t===void 0){const i=ZW.get(e);if(i!==void 0)t=tn[i],_t('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return HE(t)}const KW=/#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 $4(n){return n.replace(KW,JW)}function JW(n,e,t,i){let a="";for(let r=parseInt(e);r<parseInt(t);r++)a+=i.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return a}function eD(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 QW(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===fy?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===Am?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===Es&&(e="SHADOWMAP_TYPE_VSM"),e}function $W(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case no:case mc:e="ENVMAP_TYPE_CUBE";break;case Pd:e="ENVMAP_TYPE_CUBE_UV";break}return e}function eY(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case mc:e="ENVMAP_MODE_REFRACTION";break}return e}function tY(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case b0:e="ENVMAP_BLENDING_MULTIPLY";break;case I5:e="ENVMAP_BLENDING_MIX";break;case B5:e="ENVMAP_BLENDING_ADD";break}return e}function nY(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 iY(n,e,t,i){const a=n.getContext(),r=t.defines;let s=t.vertexShader,o=t.fragmentShader;const c=QW(t),h=$W(t),f=eY(t),d=tY(t),m=nY(t),g=XW(t),y=WW(r),E=a.createProgram();let S,v,_=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(S=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(tm).join(`
`),S.length>0&&(S+=`
`),v=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter(tm).join(`
`),v.length>0&&(v+=`
`)):(S=[eD(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,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 "+c:"",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(tm).join(`
`),v=[eD(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,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:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.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 "+c:"",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!==ns?"#define TONE_MAPPING":"",t.toneMapping!==ns?tn.tonemapping_pars_fragment:"",t.toneMapping!==ns?VW("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",tn.colorspace_pars_fragment,GW("linearToOutputTexel",t.outputColorSpace),kW(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(tm).join(`
`)),s=HE(s),s=J4(s,t),s=Q4(s,t),o=HE(o),o=J4(o,t),o=Q4(o,t),s=$4(s),o=$4(o),t.isRawShaderMaterial!==!0&&(_=`#version 300 es
`,S=[g,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+S,v=["#define varying in",t.glslVersion===cs?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===cs?"":"#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 A=_+S+s,b=_+v+o,O=Z4(a,a.VERTEX_SHADER,A),N=Z4(a,a.FRAGMENT_SHADER,b);a.attachShader(E,O),a.attachShader(E,N),t.index0AttributeName!==void 0?a.bindAttribLocation(E,0,t.index0AttributeName):t.morphTargets===!0&&a.bindAttribLocation(E,0,"position"),a.linkProgram(E);function L(G){if(n.debug.checkShaderErrors){const J=a.getProgramInfoLog(E)||"",$=a.getShaderInfoLog(O)||"",se=a.getShaderInfoLog(N)||"",le=J.trim(),q=$.trim(),te=se.trim();let ee=!0,de=!0;if(a.getProgramParameter(E,a.LINK_STATUS)===!1)if(ee=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(a,E,O,N);else{const ue=K4(a,O,"vertex"),Pe=K4(a,N,"fragment");qt("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(E,a.VALIDATE_STATUS)+`
Material Name: `+G.name+`
Material Type: `+G.type+`
Program Info Log: `+le+`
`+ue+`
`+Pe)}else le!==""?_t("WebGLProgram: Program Info Log:",le):(q===""||te==="")&&(de=!1);de&&(G.diagnostics={runnable:ee,programLog:le,vertexShader:{log:q,prefix:S},fragmentShader:{log:te,prefix:v}})}a.deleteShader(O),a.deleteShader(N),B=new f1(a,E),w=YW(a,E)}let B;this.getUniforms=function(){return B===void 0&&L(this),B};let w;this.getAttributes=function(){return w===void 0&&L(this),w};let D=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=a.getProgramParameter(E,PW)),D},this.destroy=function(){i.releaseStatesOfProgram(this),a.deleteProgram(E),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=FW++,this.cacheKey=e,this.usedTimes=1,this.program=E,this.vertexShader=O,this.fragmentShader=N,this}let aY=0;class rY{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,a=this._getShaderStage(t),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(e);return s.has(a)===!1&&(s.add(a),a.usedTimes++),s.has(r)===!1&&(s.add(r),r.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 sY(e),t.set(e,i)),i}}class sY{constructor(e){this.id=aY++,this.code=e,this.usedTimes=0}}function oY(n,e,t,i,a,r,s){const o=new yd,c=new rY,h=new Set,f=[],d=a.logarithmicDepthBuffer,m=a.vertexTextures;let g=a.precision;const y={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 E(w){return h.add(w),w===0?"uv":`uv${w}`}function S(w,D,G,J,$){const se=J.fog,le=$.geometry,q=w.isMeshStandardMaterial?J.environment:null,te=(w.isMeshStandardMaterial?t:e).get(w.envMap||q),ee=te&&te.mapping===Pd?te.image.height:null,de=y[w.type];w.precision!==null&&(g=a.getMaxPrecision(w.precision),g!==w.precision&&_t("WebGLProgram.getParameters:",w.precision,"not supported, using",g,"instead."));const ue=le.morphAttributes.position||le.morphAttributes.normal||le.morphAttributes.color,Pe=ue!==void 0?ue.length:0;let He=0;le.morphAttributes.position!==void 0&&(He=1),le.morphAttributes.normal!==void 0&&(He=2),le.morphAttributes.color!==void 0&&(He=3);let Ke,nt,xt,fe;if(de){const jt=Cs[de];Ke=jt.vertexShader,nt=jt.fragmentShader}else Ke=w.vertexShader,nt=w.fragmentShader,c.update(w),xt=c.getVertexShaderID(w),fe=c.getFragmentShaderID(w);const Be=n.getRenderTarget(),Je=n.state.buffers.depth.getReversed(),ve=$.isInstancedMesh===!0,at=$.isBatchedMesh===!0,ft=!!w.map,ht=!!w.matcap,et=!!te,Re=!!w.aoMap,Z=!!w.lightMap,Ue=!!w.bumpMap,ze=!!w.normalMap,Qe=!!w.displacementMap,Ye=!!w.emissiveMap,ot=!!w.metalnessMap,rt=!!w.roughnessMap,mt=w.anisotropy>0,j=w.clearcoat>0,P=w.dispersion>0,pe=w.iridescence>0,Ie=w.sheen>0,Ge=w.transmission>0,we=mt&&!!w.anisotropyMap,Tt=j&&!!w.clearcoatMap,ut=j&&!!w.clearcoatNormalMap,wt=j&&!!w.clearcoatRoughnessMap,bt=pe&&!!w.iridescenceMap,ke=pe&&!!w.iridescenceThicknessMap,Ve=Ie&&!!w.sheenColorMap,St=Ie&&!!w.sheenRoughnessMap,ne=!!w.specularMap,me=!!w.specularColorMap,Le=!!w.specularIntensityMap,K=Ge&&!!w.transmissionMap,Se=Ge&&!!w.thicknessMap,_e=!!w.gradientMap,it=!!w.alphaMap,tt=w.alphaTest>0,We=!!w.alphaHash,gt=!!w.extensions;let Nt=ns;w.toneMapped&&(Be===null||Be.isXRRenderTarget===!0)&&(Nt=n.toneMapping);const $t={shaderID:de,shaderType:w.type,shaderName:w.name,vertexShader:Ke,fragmentShader:nt,defines:w.defines,customVertexShaderID:xt,customFragmentShaderID:fe,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:g,batching:at,batchingColor:at&&$._colorsTexture!==null,instancing:ve,instancingColor:ve&&$.instanceColor!==null,instancingMorph:ve&&$.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:Be===null?n.outputColorSpace:Be.isXRRenderTarget===!0?Be.texture.colorSpace:Fi,alphaToCoverage:!!w.alphaToCoverage,map:ft,matcap:ht,envMap:et,envMapMode:et&&te.mapping,envMapCubeUVHeight:ee,aoMap:Re,lightMap:Z,bumpMap:Ue,normalMap:ze,displacementMap:m&&Qe,emissiveMap:Ye,normalMapObjectSpace:ze&&w.normalMapType===q5,normalMapTangentSpace:ze&&w.normalMapType===Ac,metalnessMap:ot,roughnessMap:rt,anisotropy:mt,anisotropyMap:we,clearcoat:j,clearcoatMap:Tt,clearcoatNormalMap:ut,clearcoatRoughnessMap:wt,dispersion:P,iridescence:pe,iridescenceMap:bt,iridescenceThicknessMap:ke,sheen:Ie,sheenColorMap:Ve,sheenRoughnessMap:St,specularMap:ne,specularColorMap:me,specularIntensityMap:Le,transmission:Ge,transmissionMap:K,thicknessMap:Se,gradientMap:_e,opaque:w.transparent===!1&&w.blending===wu&&w.alphaToCoverage===!1,alphaMap:it,alphaTest:tt,alphaHash:We,combine:w.combine,mapUv:ft&&E(w.map.channel),aoMapUv:Re&&E(w.aoMap.channel),lightMapUv:Z&&E(w.lightMap.channel),bumpMapUv:Ue&&E(w.bumpMap.channel),normalMapUv:ze&&E(w.normalMap.channel),displacementMapUv:Qe&&E(w.displacementMap.channel),emissiveMapUv:Ye&&E(w.emissiveMap.channel),metalnessMapUv:ot&&E(w.metalnessMap.channel),roughnessMapUv:rt&&E(w.roughnessMap.channel),anisotropyMapUv:we&&E(w.anisotropyMap.channel),clearcoatMapUv:Tt&&E(w.clearcoatMap.channel),clearcoatNormalMapUv:ut&&E(w.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:wt&&E(w.clearcoatRoughnessMap.channel),iridescenceMapUv:bt&&E(w.iridescenceMap.channel),iridescenceThicknessMapUv:ke&&E(w.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&E(w.sheenColorMap.channel),sheenRoughnessMapUv:St&&E(w.sheenRoughnessMap.channel),specularMapUv:ne&&E(w.specularMap.channel),specularColorMapUv:me&&E(w.specularColorMap.channel),specularIntensityMapUv:Le&&E(w.specularIntensityMap.channel),transmissionMapUv:K&&E(w.transmissionMap.channel),thicknessMapUv:Se&&E(w.thicknessMap.channel),alphaMapUv:it&&E(w.alphaMap.channel),vertexTangents:!!le.attributes.tangent&&(ze||mt),vertexColors:w.vertexColors,vertexAlphas:w.vertexColors===!0&&!!le.attributes.color&&le.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!le.attributes.uv&&(ft||it),fog:!!se,useFog:w.fog===!0,fogExp2:!!se&&se.isFogExp2,flatShading:w.flatShading===!0&&w.wireframe===!1,sizeAttenuation:w.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Je,skinning:$.isSkinnedMesh===!0,morphTargets:le.morphAttributes.position!==void 0,morphNormals:le.morphAttributes.normal!==void 0,morphColors:le.morphAttributes.color!==void 0,morphTargetsCount:Pe,morphTextureStride:He,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:w.dithering,shadowMapEnabled:n.shadowMap.enabled&&G.length>0,shadowMapType:n.shadowMap.type,toneMapping:Nt,decodeVideoTexture:ft&&w.map.isVideoTexture===!0&&gn.getTransfer(w.map.colorSpace)===Un,decodeVideoTextureEmissive:Ye&&w.emissiveMap.isVideoTexture===!0&&gn.getTransfer(w.emissiveMap.colorSpace)===Un,premultipliedAlpha:w.premultipliedAlpha,doubleSided:w.side===da,flipSided:w.side===Wi,useDepthPacking:w.depthPacking>=0,depthPacking:w.depthPacking||0,index0AttributeName:w.index0AttributeName,extensionClipCullDistance:gt&&w.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&w.extensions.multiDraw===!0||at)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:w.customProgramCacheKey()};return $t.vertexUv1s=h.has(1),$t.vertexUv2s=h.has(2),$t.vertexUv3s=h.has(3),h.clear(),$t}function v(w){const D=[];if(w.shaderID?D.push(w.shaderID):(D.push(w.customVertexShaderID),D.push(w.customFragmentShaderID)),w.defines!==void 0)for(const G in w.defines)D.push(G),D.push(w.defines[G]);return w.isRawShaderMaterial===!1&&(_(D,w),A(D,w),D.push(n.outputColorSpace)),D.push(w.customProgramCacheKey),D.join()}function _(w,D){w.push(D.precision),w.push(D.outputColorSpace),w.push(D.envMapMode),w.push(D.envMapCubeUVHeight),w.push(D.mapUv),w.push(D.alphaMapUv),w.push(D.lightMapUv),w.push(D.aoMapUv),w.push(D.bumpMapUv),w.push(D.normalMapUv),w.push(D.displacementMapUv),w.push(D.emissiveMapUv),w.push(D.metalnessMapUv),w.push(D.roughnessMapUv),w.push(D.anisotropyMapUv),w.push(D.clearcoatMapUv),w.push(D.clearcoatNormalMapUv),w.push(D.clearcoatRoughnessMapUv),w.push(D.iridescenceMapUv),w.push(D.iridescenceThicknessMapUv),w.push(D.sheenColorMapUv),w.push(D.sheenRoughnessMapUv),w.push(D.specularMapUv),w.push(D.specularColorMapUv),w.push(D.specularIntensityMapUv),w.push(D.transmissionMapUv),w.push(D.thicknessMapUv),w.push(D.combine),w.push(D.fogExp2),w.push(D.sizeAttenuation),w.push(D.morphTargetsCount),w.push(D.morphAttributeCount),w.push(D.numDirLights),w.push(D.numPointLights),w.push(D.numSpotLights),w.push(D.numSpotLightMaps),w.push(D.numHemiLights),w.push(D.numRectAreaLights),w.push(D.numDirLightShadows),w.push(D.numPointLightShadows),w.push(D.numSpotLightShadows),w.push(D.numSpotLightShadowsWithMaps),w.push(D.numLightProbes),w.push(D.shadowMapType),w.push(D.toneMapping),w.push(D.numClippingPlanes),w.push(D.numClipIntersection),w.push(D.depthPacking)}function A(w,D){o.disableAll(),D.supportsVertexTextures&&o.enable(0),D.instancing&&o.enable(1),D.instancingColor&&o.enable(2),D.instancingMorph&&o.enable(3),D.matcap&&o.enable(4),D.envMap&&o.enable(5),D.normalMapObjectSpace&&o.enable(6),D.normalMapTangentSpace&&o.enable(7),D.clearcoat&&o.enable(8),D.iridescence&&o.enable(9),D.alphaTest&&o.enable(10),D.vertexColors&&o.enable(11),D.vertexAlphas&&o.enable(12),D.vertexUv1s&&o.enable(13),D.vertexUv2s&&o.enable(14),D.vertexUv3s&&o.enable(15),D.vertexTangents&&o.enable(16),D.anisotropy&&o.enable(17),D.alphaHash&&o.enable(18),D.batching&&o.enable(19),D.dispersion&&o.enable(20),D.batchingColor&&o.enable(21),D.gradientMap&&o.enable(22),w.push(o.mask),o.disableAll(),D.fog&&o.enable(0),D.useFog&&o.enable(1),D.flatShading&&o.enable(2),D.logarithmicDepthBuffer&&o.enable(3),D.reversedDepthBuffer&&o.enable(4),D.skinning&&o.enable(5),D.morphTargets&&o.enable(6),D.morphNormals&&o.enable(7),D.morphColors&&o.enable(8),D.premultipliedAlpha&&o.enable(9),D.shadowMapEnabled&&o.enable(10),D.doubleSided&&o.enable(11),D.flipSided&&o.enable(12),D.useDepthPacking&&o.enable(13),D.dithering&&o.enable(14),D.transmission&&o.enable(15),D.sheen&&o.enable(16),D.opaque&&o.enable(17),D.pointsUvs&&o.enable(18),D.decodeVideoTexture&&o.enable(19),D.decodeVideoTextureEmissive&&o.enable(20),D.alphaToCoverage&&o.enable(21),w.push(o.mask)}function b(w){const D=y[w.type];let G;if(D){const J=Cs[D];G=oB.clone(J.uniforms)}else G=w.uniforms;return G}function O(w,D){let G;for(let J=0,$=f.length;J<$;J++){const se=f[J];if(se.cacheKey===D){G=se,++G.usedTimes;break}}return G===void 0&&(G=new iY(n,D,w,r),f.push(G)),G}function N(w){if(--w.usedTimes===0){const D=f.indexOf(w);f[D]=f[f.length-1],f.pop(),w.destroy()}}function L(w){c.remove(w)}function B(){c.dispose()}return{getParameters:S,getProgramCacheKey:v,getUniforms:b,acquireProgram:O,releaseProgram:N,releaseShaderCache:L,programs:f,dispose:B}}function lY(){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 a(s,o,c){n.get(s)[o]=c}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:a,dispose:r}}function cY(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 tD(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 nD(){const n=[];let e=0;const t=[],i=[],a=[];function r(){e=0,t.length=0,i.length=0,a.length=0}function s(d,m,g,y,E,S){let v=n[e];return v===void 0?(v={id:d.id,object:d,geometry:m,material:g,groupOrder:y,renderOrder:d.renderOrder,z:E,group:S},n[e]=v):(v.id=d.id,v.object=d,v.geometry=m,v.material=g,v.groupOrder=y,v.renderOrder=d.renderOrder,v.z=E,v.group=S),e++,v}function o(d,m,g,y,E,S){const v=s(d,m,g,y,E,S);g.transmission>0?i.push(v):g.transparent===!0?a.push(v):t.push(v)}function c(d,m,g,y,E,S){const v=s(d,m,g,y,E,S);g.transmission>0?i.unshift(v):g.transparent===!0?a.unshift(v):t.unshift(v)}function h(d,m){t.length>1&&t.sort(d||cY),i.length>1&&i.sort(m||tD),a.length>1&&a.sort(m||tD)}function f(){for(let d=e,m=n.length;d<m;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:a,init:r,push:o,unshift:c,finish:f,sort:h}}function uY(){let n=new WeakMap;function e(i,a){const r=n.get(i);let s;return r===void 0?(s=new nD,n.set(i,[s])):a>=r.length?(s=new nD,r.push(s)):s=r[a],s}function t(){n=new WeakMap}return{get:e,dispose:t}}function hY(){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 H,color:new dt};break;case"SpotLight":t={position:new H,direction:new H,color:new dt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new H,color:new dt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new H,skyColor:new dt,groundColor:new dt};break;case"RectAreaLight":t={color:new dt,position:new H,halfWidth:new H,halfHeight:new H};break}return n[e.id]=t,t}}}function fY(){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 Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let dY=0;function pY(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function mY(n){const e=new hY,t=fY(),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 H);const a=new H,r=new lt,s=new lt;function o(h){let f=0,d=0,m=0;for(let w=0;w<9;w++)i.probe[w].set(0,0,0);let g=0,y=0,E=0,S=0,v=0,_=0,A=0,b=0,O=0,N=0,L=0;h.sort(pY);for(let w=0,D=h.length;w<D;w++){const G=h[w],J=G.color,$=G.intensity,se=G.distance,le=G.shadow&&G.shadow.map?G.shadow.map.texture:null;if(G.isAmbientLight)f+=J.r*$,d+=J.g*$,m+=J.b*$;else if(G.isLightProbe){for(let q=0;q<9;q++)i.probe[q].addScaledVector(G.sh.coefficients[q],$);L++}else if(G.isDirectionalLight){const q=e.get(G);if(q.color.copy(G.color).multiplyScalar(G.intensity),G.castShadow){const te=G.shadow,ee=t.get(G);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize=te.mapSize,i.directionalShadow[g]=ee,i.directionalShadowMap[g]=le,i.directionalShadowMatrix[g]=G.shadow.matrix,_++}i.directional[g]=q,g++}else if(G.isSpotLight){const q=e.get(G);q.position.setFromMatrixPosition(G.matrixWorld),q.color.copy(J).multiplyScalar($),q.distance=se,q.coneCos=Math.cos(G.angle),q.penumbraCos=Math.cos(G.angle*(1-G.penumbra)),q.decay=G.decay,i.spot[E]=q;const te=G.shadow;if(G.map&&(i.spotLightMap[O]=G.map,O++,te.updateMatrices(G),G.castShadow&&N++),i.spotLightMatrix[E]=te.matrix,G.castShadow){const ee=t.get(G);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize=te.mapSize,i.spotShadow[E]=ee,i.spotShadowMap[E]=le,b++}E++}else if(G.isRectAreaLight){const q=e.get(G);q.color.copy(J).multiplyScalar($),q.halfWidth.set(G.width*.5,0,0),q.halfHeight.set(0,G.height*.5,0),i.rectArea[S]=q,S++}else if(G.isPointLight){const q=e.get(G);if(q.color.copy(G.color).multiplyScalar(G.intensity),q.distance=G.distance,q.decay=G.decay,G.castShadow){const te=G.shadow,ee=t.get(G);ee.shadowIntensity=te.intensity,ee.shadowBias=te.bias,ee.shadowNormalBias=te.normalBias,ee.shadowRadius=te.radius,ee.shadowMapSize=te.mapSize,ee.shadowCameraNear=te.camera.near,ee.shadowCameraFar=te.camera.far,i.pointShadow[y]=ee,i.pointShadowMap[y]=le,i.pointShadowMatrix[y]=G.shadow.matrix,A++}i.point[y]=q,y++}else if(G.isHemisphereLight){const q=e.get(G);q.skyColor.copy(G.color).multiplyScalar($),q.groundColor.copy(G.groundColor).multiplyScalar($),i.hemi[v]=q,v++}}S>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=yt.LTC_FLOAT_1,i.rectAreaLTC2=yt.LTC_FLOAT_2):(i.rectAreaLTC1=yt.LTC_HALF_1,i.rectAreaLTC2=yt.LTC_HALF_2)),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=m;const B=i.hash;(B.directionalLength!==g||B.pointLength!==y||B.spotLength!==E||B.rectAreaLength!==S||B.hemiLength!==v||B.numDirectionalShadows!==_||B.numPointShadows!==A||B.numSpotShadows!==b||B.numSpotMaps!==O||B.numLightProbes!==L)&&(i.directional.length=g,i.spot.length=E,i.rectArea.length=S,i.point.length=y,i.hemi.length=v,i.directionalShadow.length=_,i.directionalShadowMap.length=_,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=b,i.spotShadowMap.length=b,i.directionalShadowMatrix.length=_,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=b+O-N,i.spotLightMap.length=O,i.numSpotLightShadowsWithMaps=N,i.numLightProbes=L,B.directionalLength=g,B.pointLength=y,B.spotLength=E,B.rectAreaLength=S,B.hemiLength=v,B.numDirectionalShadows=_,B.numPointShadows=A,B.numSpotShadows=b,B.numSpotMaps=O,B.numLightProbes=L,i.version=dY++)}function c(h,f){let d=0,m=0,g=0,y=0,E=0;const S=f.matrixWorldInverse;for(let v=0,_=h.length;v<_;v++){const A=h[v];if(A.isDirectionalLight){const b=i.directional[d];b.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),b.direction.sub(a),b.direction.transformDirection(S),d++}else if(A.isSpotLight){const b=i.spot[g];b.position.setFromMatrixPosition(A.matrixWorld),b.position.applyMatrix4(S),b.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),b.direction.sub(a),b.direction.transformDirection(S),g++}else if(A.isRectAreaLight){const b=i.rectArea[y];b.position.setFromMatrixPosition(A.matrixWorld),b.position.applyMatrix4(S),s.identity(),r.copy(A.matrixWorld),r.premultiply(S),s.extractRotation(r),b.halfWidth.set(A.width*.5,0,0),b.halfHeight.set(0,A.height*.5,0),b.halfWidth.applyMatrix4(s),b.halfHeight.applyMatrix4(s),y++}else if(A.isPointLight){const b=i.point[m];b.position.setFromMatrixPosition(A.matrixWorld),b.position.applyMatrix4(S),m++}else if(A.isHemisphereLight){const b=i.hemi[E];b.direction.setFromMatrixPosition(A.matrixWorld),b.direction.transformDirection(S),E++}}}return{setup:o,setupView:c,state:i}}function iD(n){const e=new mY(n),t=[],i=[];function a(f){h.camera=f,t.length=0,i.length=0}function r(f){t.push(f)}function s(f){i.push(f)}function o(){e.setup(t)}function c(f){e.setupView(t,f)}const h={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:a,state:h,setupLights:o,setupLightsView:c,pushLight:r,pushShadow:s}}function gY(n){let e=new WeakMap;function t(a,r=0){const s=e.get(a);let o;return s===void 0?(o=new iD(n),e.set(a,[o])):r>=s.length?(o=new iD(n),s.push(o)):o=s[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const vY=`void main() {
gl_Position = vec4( position, 1.0 );
}`,xY=`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 yY(n,e,t){let i=new Hd;const a=new Ee,r=new Ee,s=new Yt,o=new eb({depthPacking:Y5}),c=new tb,h={},f=t.maxTextureSize,d={[os]:Wi,[Wi]:os,[da]:da},m=new Di({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:vY,fragmentShader:xY}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const y=new Xt;y.setAttribute("position",new pn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const E=new Xn(y,m),S=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=fy;let v=this.type;this.render=function(N,L,B){if(S.enabled===!1||S.autoUpdate===!1&&S.needsUpdate===!1||N.length===0)return;const w=n.getRenderTarget(),D=n.getActiveCubeFace(),G=n.getActiveMipmapLevel(),J=n.state;J.setBlending(ga),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 $=v!==Es&&this.type===Es,se=v===Es&&this.type!==Es;for(let le=0,q=N.length;le<q;le++){const te=N[le],ee=te.shadow;if(ee===void 0){_t("WebGLShadowMap:",te,"has no shadow.");continue}if(ee.autoUpdate===!1&&ee.needsUpdate===!1)continue;a.copy(ee.mapSize);const de=ee.getFrameExtents();if(a.multiply(de),r.copy(ee.mapSize),(a.x>f||a.y>f)&&(a.x>f&&(r.x=Math.floor(f/de.x),a.x=r.x*de.x,ee.mapSize.x=r.x),a.y>f&&(r.y=Math.floor(f/de.y),a.y=r.y*de.y,ee.mapSize.y=r.y)),ee.map===null||$===!0||se===!0){const Pe=this.type!==Es?{minFilter:$n,magFilter:$n}:{};ee.map!==null&&ee.map.dispose(),ee.map=new oi(a.x,a.y,Pe),ee.map.texture.name=te.name+".shadowMap",ee.camera.updateProjectionMatrix()}n.setRenderTarget(ee.map),n.clear();const ue=ee.getViewportCount();for(let Pe=0;Pe<ue;Pe++){const He=ee.getViewport(Pe);s.set(r.x*He.x,r.y*He.y,r.x*He.z,r.y*He.w),J.viewport(s),ee.updateMatrices(te,Pe),i=ee.getFrustum(),b(L,B,ee.camera,te,this.type)}ee.isPointLightShadow!==!0&&this.type===Es&&_(ee,B),ee.needsUpdate=!1}v=this.type,S.needsUpdate=!1,n.setRenderTarget(w,D,G)};function _(N,L){const B=e.update(E);m.defines.VSM_SAMPLES!==N.blurSamples&&(m.defines.VSM_SAMPLES=N.blurSamples,g.defines.VSM_SAMPLES=N.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),N.mapPass===null&&(N.mapPass=new oi(a.x,a.y)),m.uniforms.shadow_pass.value=N.map.texture,m.uniforms.resolution.value=N.mapSize,m.uniforms.radius.value=N.radius,n.setRenderTarget(N.mapPass),n.clear(),n.renderBufferDirect(L,null,B,m,E,null),g.uniforms.shadow_pass.value=N.mapPass.texture,g.uniforms.resolution.value=N.mapSize,g.uniforms.radius.value=N.radius,n.setRenderTarget(N.map),n.clear(),n.renderBufferDirect(L,null,B,g,E,null)}function A(N,L,B,w){let D=null;const G=B.isPointLight===!0?N.customDistanceMaterial:N.customDepthMaterial;if(G!==void 0)D=G;else if(D=B.isPointLight===!0?c:o,n.localClippingEnabled&&L.clipShadows===!0&&Array.isArray(L.clippingPlanes)&&L.clippingPlanes.length!==0||L.displacementMap&&L.displacementScale!==0||L.alphaMap&&L.alphaTest>0||L.map&&L.alphaTest>0||L.alphaToCoverage===!0){const J=D.uuid,$=L.uuid;let se=h[J];se===void 0&&(se={},h[J]=se);let le=se[$];le===void 0&&(le=D.clone(),se[$]=le,L.addEventListener("dispose",O)),D=le}if(D.visible=L.visible,D.wireframe=L.wireframe,w===Es?D.side=L.shadowSide!==null?L.shadowSide:L.side:D.side=L.shadowSide!==null?L.shadowSide:d[L.side],D.alphaMap=L.alphaMap,D.alphaTest=L.alphaToCoverage===!0?.5:L.alphaTest,D.map=L.map,D.clipShadows=L.clipShadows,D.clippingPlanes=L.clippingPlanes,D.clipIntersection=L.clipIntersection,D.displacementMap=L.displacementMap,D.displacementScale=L.displacementScale,D.displacementBias=L.displacementBias,D.wireframeLinewidth=L.wireframeLinewidth,D.linewidth=L.linewidth,B.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const J=n.properties.get(D);J.light=B}return D}function b(N,L,B,w,D){if(N.visible===!1)return;if(N.layers.test(L.layers)&&(N.isMesh||N.isLine||N.isPoints)&&(N.castShadow||N.receiveShadow&&D===Es)&&(!N.frustumCulled||i.intersectsObject(N))){N.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,N.matrixWorld);const $=e.update(N),se=N.material;if(Array.isArray(se)){const le=$.groups;for(let q=0,te=le.length;q<te;q++){const ee=le[q],de=se[ee.materialIndex];if(de&&de.visible){const ue=A(N,de,w,D);N.onBeforeShadow(n,N,L,B,$,ue,ee),n.renderBufferDirect(B,null,$,ue,N,ee),N.onAfterShadow(n,N,L,B,$,ue,ee)}}}else if(se.visible){const le=A(N,se,w,D);N.onBeforeShadow(n,N,L,B,$,le,null),n.renderBufferDirect(B,null,$,le,N,null),N.onAfterShadow(n,N,L,B,$,le,null)}}const J=N.children;for(let $=0,se=J.length;$<se;$++)b(J[$],L,B,w,D)}function O(N){N.target.removeEventListener("dispose",O);for(const B in h){const w=h[B],D=N.target.uuid;D in w&&(w[D].dispose(),delete w[D])}}}const _Y={[Y1]:Qm,[q1]:K1,[Z1]:J1,[zu]:j1,[Qm]:Y1,[K1]:q1,[J1]:Z1,[j1]:zu};function SY(n,e){function t(){let K=!1;const Se=new Yt;let _e=null;const it=new Yt(0,0,0,0);return{setMask:function(tt){_e!==tt&&!K&&(n.colorMask(tt,tt,tt,tt),_e=tt)},setLocked:function(tt){K=tt},setClear:function(tt,We,gt,Nt,$t){$t===!0&&(tt*=Nt,We*=Nt,gt*=Nt),Se.set(tt,We,gt,Nt),it.equals(Se)===!1&&(n.clearColor(tt,We,gt,Nt),it.copy(Se))},reset:function(){K=!1,_e=null,it.set(-1,0,0,0)}}}function i(){let K=!1,Se=!1,_e=null,it=null,tt=null;return{setReversed:function(We){if(Se!==We){const gt=e.get("EXT_clip_control");We?gt.clipControlEXT(gt.LOWER_LEFT_EXT,gt.ZERO_TO_ONE_EXT):gt.clipControlEXT(gt.LOWER_LEFT_EXT,gt.NEGATIVE_ONE_TO_ONE_EXT),Se=We;const Nt=tt;tt=null,this.setClear(Nt)}},getReversed:function(){return Se},setTest:function(We){We?Be(n.DEPTH_TEST):Je(n.DEPTH_TEST)},setMask:function(We){_e!==We&&!K&&(n.depthMask(We),_e=We)},setFunc:function(We){if(Se&&(We=_Y[We]),it!==We){switch(We){case Y1:n.depthFunc(n.NEVER);break;case Qm:n.depthFunc(n.ALWAYS);break;case q1:n.depthFunc(n.LESS);break;case zu:n.depthFunc(n.LEQUAL);break;case Z1:n.depthFunc(n.EQUAL);break;case j1:n.depthFunc(n.GEQUAL);break;case K1:n.depthFunc(n.GREATER);break;case J1:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}it=We}},setLocked:function(We){K=We},setClear:function(We){tt!==We&&(Se&&(We=1-We),n.clearDepth(We),tt=We)},reset:function(){K=!1,_e=null,it=null,tt=null,Se=!1}}}function a(){let K=!1,Se=null,_e=null,it=null,tt=null,We=null,gt=null,Nt=null,$t=null;return{setTest:function(jt){K||(jt?Be(n.STENCIL_TEST):Je(n.STENCIL_TEST))},setMask:function(jt){Se!==jt&&!K&&(n.stencilMask(jt),Se=jt)},setFunc:function(jt,hi,fi){(_e!==jt||it!==hi||tt!==fi)&&(n.stencilFunc(jt,hi,fi),_e=jt,it=hi,tt=fi)},setOp:function(jt,hi,fi){(We!==jt||gt!==hi||Nt!==fi)&&(n.stencilOp(jt,hi,fi),We=jt,gt=hi,Nt=fi)},setLocked:function(jt){K=jt},setClear:function(jt){$t!==jt&&(n.clearStencil(jt),$t=jt)},reset:function(){K=!1,Se=null,_e=null,it=null,tt=null,We=null,gt=null,Nt=null,$t=null}}}const r=new t,s=new i,o=new a,c=new WeakMap,h=new WeakMap;let f={},d={},m=new WeakMap,g=[],y=null,E=!1,S=null,v=null,_=null,A=null,b=null,O=null,N=null,L=new dt(0,0,0),B=0,w=!1,D=null,G=null,J=null,$=null,se=null;const le=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,te=0;const ee=n.getParameter(n.VERSION);ee.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(ee)[1]),q=te>=1):ee.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),q=te>=2);let de=null,ue={};const Pe=n.getParameter(n.SCISSOR_BOX),He=n.getParameter(n.VIEWPORT),Ke=new Yt().fromArray(Pe),nt=new Yt().fromArray(He);function xt(K,Se,_e,it){const tt=new Uint8Array(4),We=n.createTexture();n.bindTexture(K,We),n.texParameteri(K,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(K,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let gt=0;gt<_e;gt++)K===n.TEXTURE_3D||K===n.TEXTURE_2D_ARRAY?n.texImage3D(Se,0,n.RGBA,1,1,it,0,n.RGBA,n.UNSIGNED_BYTE,tt):n.texImage2D(Se+gt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,tt);return We}const fe={};fe[n.TEXTURE_2D]=xt(n.TEXTURE_2D,n.TEXTURE_2D,1),fe[n.TEXTURE_CUBE_MAP]=xt(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[n.TEXTURE_2D_ARRAY]=xt(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),fe[n.TEXTURE_3D]=xt(n.TEXTURE_3D,n.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),Be(n.DEPTH_TEST),s.setFunc(zu),Ue(!1),ze(bE),Be(n.CULL_FACE),Re(ga);function Be(K){f[K]!==!0&&(n.enable(K),f[K]=!0)}function Je(K){f[K]!==!1&&(n.disable(K),f[K]=!1)}function ve(K,Se){return d[K]!==Se?(n.bindFramebuffer(K,Se),d[K]=Se,K===n.DRAW_FRAMEBUFFER&&(d[n.FRAMEBUFFER]=Se),K===n.FRAMEBUFFER&&(d[n.DRAW_FRAMEBUFFER]=Se),!0):!1}function at(K,Se){let _e=g,it=!1;if(K){_e=m.get(Se),_e===void 0&&(_e=[],m.set(Se,_e));const tt=K.textures;if(_e.length!==tt.length||_e[0]!==n.COLOR_ATTACHMENT0){for(let We=0,gt=tt.length;We<gt;We++)_e[We]=n.COLOR_ATTACHMENT0+We;_e.length=tt.length,it=!0}}else _e[0]!==n.BACK&&(_e[0]=n.BACK,it=!0);it&&n.drawBuffers(_e)}function ft(K){return y!==K?(n.useProgram(K),y=K,!0):!1}const ht={[js]:n.FUNC_ADD,[v5]:n.FUNC_SUBTRACT,[x5]:n.FUNC_REVERSE_SUBTRACT};ht[y5]=n.MIN,ht[_5]=n.MAX;const et={[S5]:n.ZERO,[Uf]:n.ONE,[A5]:n.SRC_COLOR,[X1]:n.SRC_ALPHA,[R5]:n.SRC_ALPHA_SATURATE,[M5]:n.DST_COLOR,[T5]:n.DST_ALPHA,[E5]:n.ONE_MINUS_SRC_COLOR,[W1]:n.ONE_MINUS_SRC_ALPHA,[C5]:n.ONE_MINUS_DST_COLOR,[b5]:n.ONE_MINUS_DST_ALPHA,[w5]:n.CONSTANT_COLOR,[D5]:n.ONE_MINUS_CONSTANT_COLOR,[N5]:n.CONSTANT_ALPHA,[O5]:n.ONE_MINUS_CONSTANT_ALPHA};function Re(K,Se,_e,it,tt,We,gt,Nt,$t,jt){if(K===ga){E===!0&&(Je(n.BLEND),E=!1);return}if(E===!1&&(Be(n.BLEND),E=!0),K!==M3){if(K!==S||jt!==w){if((v!==js||b!==js)&&(n.blendEquation(n.FUNC_ADD),v=js,b=js),jt)switch(K){case wu:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ME:n.blendFunc(n.ONE,n.ONE);break;case CE:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case RE:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:qt("WebGLState: Invalid blending: ",K);break}else switch(K){case wu:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ME:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case CE:qt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case RE:qt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:qt("WebGLState: Invalid blending: ",K);break}_=null,A=null,O=null,N=null,L.set(0,0,0),B=0,S=K,w=jt}return}tt=tt||Se,We=We||_e,gt=gt||it,(Se!==v||tt!==b)&&(n.blendEquationSeparate(ht[Se],ht[tt]),v=Se,b=tt),(_e!==_||it!==A||We!==O||gt!==N)&&(n.blendFuncSeparate(et[_e],et[it],et[We],et[gt]),_=_e,A=it,O=We,N=gt),(Nt.equals(L)===!1||$t!==B)&&(n.blendColor(Nt.r,Nt.g,Nt.b,$t),L.copy(Nt),B=$t),S=K,w=!1}function Z(K,Se){K.side===da?Je(n.CULL_FACE):Be(n.CULL_FACE);let _e=K.side===Wi;Se&&(_e=!_e),Ue(_e),K.blending===wu&&K.transparent===!1?Re(ga):Re(K.blending,K.blendEquation,K.blendSrc,K.blendDst,K.blendEquationAlpha,K.blendSrcAlpha,K.blendDstAlpha,K.blendColor,K.blendAlpha,K.premultipliedAlpha),s.setFunc(K.depthFunc),s.setTest(K.depthTest),s.setMask(K.depthWrite),r.setMask(K.colorWrite);const it=K.stencilWrite;o.setTest(it),it&&(o.setMask(K.stencilWriteMask),o.setFunc(K.stencilFunc,K.stencilRef,K.stencilFuncMask),o.setOp(K.stencilFail,K.stencilZFail,K.stencilZPass)),Ye(K.polygonOffset,K.polygonOffsetFactor,K.polygonOffsetUnits),K.alphaToCoverage===!0?Be(n.SAMPLE_ALPHA_TO_COVERAGE):Je(n.SAMPLE_ALPHA_TO_COVERAGE)}function Ue(K){D!==K&&(K?n.frontFace(n.CW):n.frontFace(n.CCW),D=K)}function ze(K){K!==p5?(Be(n.CULL_FACE),K!==G&&(K===bE?n.cullFace(n.BACK):K===m5?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Je(n.CULL_FACE),G=K}function Qe(K){K!==J&&(q&&n.lineWidth(K),J=K)}function Ye(K,Se,_e){K?(Be(n.POLYGON_OFFSET_FILL),($!==Se||se!==_e)&&(n.polygonOffset(Se,_e),$=Se,se=_e)):Je(n.POLYGON_OFFSET_FILL)}function ot(K){K?Be(n.SCISSOR_TEST):Je(n.SCISSOR_TEST)}function rt(K){K===void 0&&(K=n.TEXTURE0+le-1),de!==K&&(n.activeTexture(K),de=K)}function mt(K,Se,_e){_e===void 0&&(de===null?_e=n.TEXTURE0+le-1:_e=de);let it=ue[_e];it===void 0&&(it={type:void 0,texture:void 0},ue[_e]=it),(it.type!==K||it.texture!==Se)&&(de!==_e&&(n.activeTexture(_e),de=_e),n.bindTexture(K,Se||fe[K]),it.type=K,it.texture=Se)}function j(){const K=ue[de];K!==void 0&&K.type!==void 0&&(n.bindTexture(K.type,null),K.type=void 0,K.texture=void 0)}function P(){try{n.compressedTexImage2D(...arguments)}catch(K){K("WebGLState:",K)}}function pe(){try{n.compressedTexImage3D(...arguments)}catch(K){K("WebGLState:",K)}}function Ie(){try{n.texSubImage2D(...arguments)}catch(K){K("WebGLState:",K)}}function Ge(){try{n.texSubImage3D(...arguments)}catch(K){K("WebGLState:",K)}}function we(){try{n.compressedTexSubImage2D(...arguments)}catch(K){K("WebGLState:",K)}}function Tt(){try{n.compressedTexSubImage3D(...arguments)}catch(K){K("WebGLState:",K)}}function ut(){try{n.texStorage2D(...arguments)}catch(K){K("WebGLState:",K)}}function wt(){try{n.texStorage3D(...arguments)}catch(K){K("WebGLState:",K)}}function bt(){try{n.texImage2D(...arguments)}catch(K){K("WebGLState:",K)}}function ke(){try{n.texImage3D(...arguments)}catch(K){K("WebGLState:",K)}}function Ve(K){Ke.equals(K)===!1&&(n.scissor(K.x,K.y,K.z,K.w),Ke.copy(K))}function St(K){nt.equals(K)===!1&&(n.viewport(K.x,K.y,K.z,K.w),nt.copy(K))}function ne(K,Se){let _e=h.get(Se);_e===void 0&&(_e=new WeakMap,h.set(Se,_e));let it=_e.get(K);it===void 0&&(it=n.getUniformBlockIndex(Se,K.name),_e.set(K,it))}function me(K,Se){const it=h.get(Se).get(K);c.get(Se)!==it&&(n.uniformBlockBinding(Se,it,K.__bindingPointIndex),c.set(Se,it))}function Le(){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={},de=null,ue={},d={},m=new WeakMap,g=[],y=null,E=!1,S=null,v=null,_=null,A=null,b=null,O=null,N=null,L=new dt(0,0,0),B=0,w=!1,D=null,G=null,J=null,$=null,se=null,Ke.set(0,0,n.canvas.width,n.canvas.height),nt.set(0,0,n.canvas.width,n.canvas.height),r.reset(),s.reset(),o.reset()}return{buffers:{color:r,depth:s,stencil:o},enable:Be,disable:Je,bindFramebuffer:ve,drawBuffers:at,useProgram:ft,setBlending:Re,setMaterial:Z,setFlipSided:Ue,setCullFace:ze,setLineWidth:Qe,setPolygonOffset:Ye,setScissorTest:ot,activeTexture:rt,bindTexture:mt,unbindTexture:j,compressedTexImage2D:P,compressedTexImage3D:pe,texImage2D:bt,texImage3D:ke,updateUBOMapping:ne,uniformBlockBinding:me,texStorage2D:ut,texStorage3D:wt,texSubImage2D:Ie,texSubImage3D:Ge,compressedTexSubImage2D:we,compressedTexSubImage3D:Tt,scissor:Ve,viewport:St,reset:Le}}function AY(n,e,t,i,a,r,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new Ee,f=new WeakMap;let d;const m=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(j,P){return g?new OffscreenCanvas(j,P):a0("canvas")}function E(j,P,pe){let Ie=1;const Ge=mt(j);if((Ge.width>pe||Ge.height>pe)&&(Ie=pe/Math.max(Ge.width,Ge.height)),Ie<1)if(typeof HTMLImageElement<"u"&&j instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&j instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&j instanceof ImageBitmap||typeof VideoFrame<"u"&&j instanceof VideoFrame){const we=Math.floor(Ie*Ge.width),Tt=Math.floor(Ie*Ge.height);d===void 0&&(d=y(we,Tt));const ut=P?y(we,Tt):d;return ut.width=we,ut.height=Tt,ut.getContext("2d").drawImage(j,0,0,we,Tt),_t("WebGLRenderer: Texture has been resized from ("+Ge.width+"x"+Ge.height+") to ("+we+"x"+Tt+")."),ut}else return"data"in j&&_t("WebGLRenderer: Image in DataTexture is too big ("+Ge.width+"x"+Ge.height+")."),j;return j}function S(j){return j.generateMipmaps}function v(j){n.generateMipmap(j)}function _(j){return j.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:j.isWebGL3DRenderTarget?n.TEXTURE_3D:j.isWebGLArrayRenderTarget||j.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function A(j,P,pe,Ie,Ge=!1){if(j!==null){if(n[j]!==void 0)return n[j];_t("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+j+"'")}let we=P;if(P===n.RED&&(pe===n.FLOAT&&(we=n.R32F),pe===n.HALF_FLOAT&&(we=n.R16F),pe===n.UNSIGNED_BYTE&&(we=n.R8)),P===n.RED_INTEGER&&(pe===n.UNSIGNED_BYTE&&(we=n.R8UI),pe===n.UNSIGNED_SHORT&&(we=n.R16UI),pe===n.UNSIGNED_INT&&(we=n.R32UI),pe===n.BYTE&&(we=n.R8I),pe===n.SHORT&&(we=n.R16I),pe===n.INT&&(we=n.R32I)),P===n.RG&&(pe===n.FLOAT&&(we=n.RG32F),pe===n.HALF_FLOAT&&(we=n.RG16F),pe===n.UNSIGNED_BYTE&&(we=n.RG8)),P===n.RG_INTEGER&&(pe===n.UNSIGNED_BYTE&&(we=n.RG8UI),pe===n.UNSIGNED_SHORT&&(we=n.RG16UI),pe===n.UNSIGNED_INT&&(we=n.RG32UI),pe===n.BYTE&&(we=n.RG8I),pe===n.SHORT&&(we=n.RG16I),pe===n.INT&&(we=n.RG32I)),P===n.RGB_INTEGER&&(pe===n.UNSIGNED_BYTE&&(we=n.RGB8UI),pe===n.UNSIGNED_SHORT&&(we=n.RGB16UI),pe===n.UNSIGNED_INT&&(we=n.RGB32UI),pe===n.BYTE&&(we=n.RGB8I),pe===n.SHORT&&(we=n.RGB16I),pe===n.INT&&(we=n.RGB32I)),P===n.RGBA_INTEGER&&(pe===n.UNSIGNED_BYTE&&(we=n.RGBA8UI),pe===n.UNSIGNED_SHORT&&(we=n.RGBA16UI),pe===n.UNSIGNED_INT&&(we=n.RGBA32UI),pe===n.BYTE&&(we=n.RGBA8I),pe===n.SHORT&&(we=n.RGBA16I),pe===n.INT&&(we=n.RGBA32I)),P===n.RGB&&(pe===n.UNSIGNED_INT_5_9_9_9_REV&&(we=n.RGB9_E5),pe===n.UNSIGNED_INT_10F_11F_11F_REV&&(we=n.R11F_G11F_B10F)),P===n.RGBA){const Tt=Ge?n0:gn.getTransfer(Ie);pe===n.FLOAT&&(we=n.RGBA32F),pe===n.HALF_FLOAT&&(we=n.RGBA16F),pe===n.UNSIGNED_BYTE&&(we=Tt===Un?n.SRGB8_ALPHA8:n.RGBA8),pe===n.UNSIGNED_SHORT_4_4_4_4&&(we=n.RGBA4),pe===n.UNSIGNED_SHORT_5_5_5_1&&(we=n.RGB5_A1)}return(we===n.R16F||we===n.R32F||we===n.RG16F||we===n.RG32F||we===n.RGBA16F||we===n.RGBA32F)&&e.get("EXT_color_buffer_float"),we}function b(j,P){let pe;return j?P===null||P===ls||P===Vu?pe=n.DEPTH24_STENCIL8:P===Sn?pe=n.DEPTH32F_STENCIL8:P===Gu&&(pe=n.DEPTH24_STENCIL8,_t("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):P===null||P===ls||P===Vu?pe=n.DEPTH_COMPONENT24:P===Sn?pe=n.DEPTH_COMPONENT32F:P===Gu&&(pe=n.DEPTH_COMPONENT16),pe}function O(j,P){return S(j)===!0||j.isFramebufferTexture&&j.minFilter!==$n&&j.minFilter!==Bt?Math.log2(Math.max(P.width,P.height))+1:j.mipmaps!==void 0&&j.mipmaps.length>0?j.mipmaps.length:j.isCompressedTexture&&Array.isArray(j.image)?P.mipmaps.length:1}function N(j){const P=j.target;P.removeEventListener("dispose",N),B(P),P.isVideoTexture&&f.delete(P)}function L(j){const P=j.target;P.removeEventListener("dispose",L),D(P)}function B(j){const P=i.get(j);if(P.__webglInit===void 0)return;const pe=j.source,Ie=m.get(pe);if(Ie){const Ge=Ie[P.__cacheKey];Ge.usedTimes--,Ge.usedTimes===0&&w(j),Object.keys(Ie).length===0&&m.delete(pe)}i.remove(j)}function w(j){const P=i.get(j);n.deleteTexture(P.__webglTexture);const pe=j.source,Ie=m.get(pe);delete Ie[P.__cacheKey],s.memory.textures--}function D(j){const P=i.get(j);if(j.depthTexture&&(j.depthTexture.dispose(),i.remove(j.depthTexture)),j.isWebGLCubeRenderTarget)for(let Ie=0;Ie<6;Ie++){if(Array.isArray(P.__webglFramebuffer[Ie]))for(let Ge=0;Ge<P.__webglFramebuffer[Ie].length;Ge++)n.deleteFramebuffer(P.__webglFramebuffer[Ie][Ge]);else n.deleteFramebuffer(P.__webglFramebuffer[Ie]);P.__webglDepthbuffer&&n.deleteRenderbuffer(P.__webglDepthbuffer[Ie])}else{if(Array.isArray(P.__webglFramebuffer))for(let Ie=0;Ie<P.__webglFramebuffer.length;Ie++)n.deleteFramebuffer(P.__webglFramebuffer[Ie]);else n.deleteFramebuffer(P.__webglFramebuffer);if(P.__webglDepthbuffer&&n.deleteRenderbuffer(P.__webglDepthbuffer),P.__webglMultisampledFramebuffer&&n.deleteFramebuffer(P.__webglMultisampledFramebuffer),P.__webglColorRenderbuffer)for(let Ie=0;Ie<P.__webglColorRenderbuffer.length;Ie++)P.__webglColorRenderbuffer[Ie]&&n.deleteRenderbuffer(P.__webglColorRenderbuffer[Ie]);P.__webglDepthRenderbuffer&&n.deleteRenderbuffer(P.__webglDepthRenderbuffer)}const pe=j.textures;for(let Ie=0,Ge=pe.length;Ie<Ge;Ie++){const we=i.get(pe[Ie]);we.__webglTexture&&(n.deleteTexture(we.__webglTexture),s.memory.textures--),i.remove(pe[Ie])}i.remove(j)}let G=0;function J(){G=0}function $(){const j=G;return j>=a.maxTextures&&_t("WebGLTextures: Trying to use "+j+" texture units while this GPU supports only "+a.maxTextures),G+=1,j}function se(j){const P=[];return P.push(j.wrapS),P.push(j.wrapT),P.push(j.wrapR||0),P.push(j.magFilter),P.push(j.minFilter),P.push(j.anisotropy),P.push(j.internalFormat),P.push(j.format),P.push(j.type),P.push(j.generateMipmaps),P.push(j.premultiplyAlpha),P.push(j.flipY),P.push(j.unpackAlignment),P.push(j.colorSpace),P.join()}function le(j,P){const pe=i.get(j);if(j.isVideoTexture&&ot(j),j.isRenderTargetTexture===!1&&j.isExternalTexture!==!0&&j.version>0&&pe.__version!==j.version){const Ie=j.image;if(Ie===null)_t("WebGLRenderer: Texture marked for update but no image data found.");else if(Ie.complete===!1)_t("WebGLRenderer: Texture marked for update but image is incomplete");else{fe(pe,j,P);return}}else j.isExternalTexture&&(pe.__webglTexture=j.sourceTexture?j.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,pe.__webglTexture,n.TEXTURE0+P)}function q(j,P){const pe=i.get(j);if(j.isRenderTargetTexture===!1&&j.version>0&&pe.__version!==j.version){fe(pe,j,P);return}else j.isExternalTexture&&(pe.__webglTexture=j.sourceTexture?j.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,pe.__webglTexture,n.TEXTURE0+P)}function te(j,P){const pe=i.get(j);if(j.isRenderTargetTexture===!1&&j.version>0&&pe.__version!==j.version){fe(pe,j,P);return}t.bindTexture(n.TEXTURE_3D,pe.__webglTexture,n.TEXTURE0+P)}function ee(j,P){const pe=i.get(j);if(j.version>0&&pe.__version!==j.version){Be(pe,j,P);return}t.bindTexture(n.TEXTURE_CUBE_MAP,pe.__webglTexture,n.TEXTURE0+P)}const de={[wi]:n.REPEAT,[Vn]:n.CLAMP_TO_EDGE,[fd]:n.MIRRORED_REPEAT},ue={[$n]:n.NEAREST,[dy]:n.NEAREST_MIPMAP_NEAREST,[gu]:n.NEAREST_MIPMAP_LINEAR,[Bt]:n.LINEAR,[Kf]:n.LINEAR_MIPMAP_NEAREST,[Sr]:n.LINEAR_MIPMAP_LINEAR},Pe={[Z5]:n.NEVER,[eB]:n.ALWAYS,[j5]:n.LESS,[B3]:n.LEQUAL,[K5]:n.EQUAL,[$5]:n.GEQUAL,[J5]:n.GREATER,[Q5]:n.NOTEQUAL};function He(j,P){if(P.type===Sn&&e.has("OES_texture_float_linear")===!1&&(P.magFilter===Bt||P.magFilter===Kf||P.magFilter===gu||P.magFilter===Sr||P.minFilter===Bt||P.minFilter===Kf||P.minFilter===gu||P.minFilter===Sr)&&_t("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(j,n.TEXTURE_WRAP_S,de[P.wrapS]),n.texParameteri(j,n.TEXTURE_WRAP_T,de[P.wrapT]),(j===n.TEXTURE_3D||j===n.TEXTURE_2D_ARRAY)&&n.texParameteri(j,n.TEXTURE_WRAP_R,de[P.wrapR]),n.texParameteri(j,n.TEXTURE_MAG_FILTER,ue[P.magFilter]),n.texParameteri(j,n.TEXTURE_MIN_FILTER,ue[P.minFilter]),P.compareFunction&&(n.texParameteri(j,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(j,n.TEXTURE_COMPARE_FUNC,Pe[P.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(P.magFilter===$n||P.minFilter!==gu&&P.minFilter!==Sr||P.type===Sn&&e.has("OES_texture_float_linear")===!1)return;if(P.anisotropy>1||i.get(P).__currentAnisotropy){const pe=e.get("EXT_texture_filter_anisotropic");n.texParameterf(j,pe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(P.anisotropy,a.getMaxAnisotropy())),i.get(P).__currentAnisotropy=P.anisotropy}}}function Ke(j,P){let pe=!1;j.__webglInit===void 0&&(j.__webglInit=!0,P.addEventListener("dispose",N));const Ie=P.source;let Ge=m.get(Ie);Ge===void 0&&(Ge={},m.set(Ie,Ge));const we=se(P);if(we!==j.__cacheKey){Ge[we]===void 0&&(Ge[we]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,pe=!0),Ge[we].usedTimes++;const Tt=Ge[j.__cacheKey];Tt!==void 0&&(Ge[j.__cacheKey].usedTimes--,Tt.usedTimes===0&&w(P)),j.__cacheKey=we,j.__webglTexture=Ge[we].texture}return pe}function nt(j,P,pe){return Math.floor(Math.floor(j/pe)/P)}function xt(j,P,pe,Ie){const we=j.updateRanges;if(we.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,P.width,P.height,pe,Ie,P.data);else{we.sort((ke,Ve)=>ke.start-Ve.start);let Tt=0;for(let ke=1;ke<we.length;ke++){const Ve=we[Tt],St=we[ke],ne=Ve.start+Ve.count,me=nt(St.start,P.width,4),Le=nt(Ve.start,P.width,4);St.start<=ne+1&&me===Le&&nt(St.start+St.count-1,P.width,4)===me?Ve.count=Math.max(Ve.count,St.start+St.count-Ve.start):(++Tt,we[Tt]=St)}we.length=Tt+1;const ut=n.getParameter(n.UNPACK_ROW_LENGTH),wt=n.getParameter(n.UNPACK_SKIP_PIXELS),bt=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,P.width);for(let ke=0,Ve=we.length;ke<Ve;ke++){const St=we[ke],ne=Math.floor(St.start/4),me=Math.ceil(St.count/4),Le=ne%P.width,K=Math.floor(ne/P.width),Se=me,_e=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,Le),n.pixelStorei(n.UNPACK_SKIP_ROWS,K),t.texSubImage2D(n.TEXTURE_2D,0,Le,K,Se,_e,pe,Ie,P.data)}j.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,ut),n.pixelStorei(n.UNPACK_SKIP_PIXELS,wt),n.pixelStorei(n.UNPACK_SKIP_ROWS,bt)}}function fe(j,P,pe){let Ie=n.TEXTURE_2D;(P.isDataArrayTexture||P.isCompressedArrayTexture)&&(Ie=n.TEXTURE_2D_ARRAY),P.isData3DTexture&&(Ie=n.TEXTURE_3D);const Ge=Ke(j,P),we=P.source;t.bindTexture(Ie,j.__webglTexture,n.TEXTURE0+pe);const Tt=i.get(we);if(we.version!==Tt.__version||Ge===!0){t.activeTexture(n.TEXTURE0+pe);const ut=gn.getPrimaries(gn.workingColorSpace),wt=P.colorSpace===pa?null:gn.getPrimaries(P.colorSpace),bt=P.colorSpace===pa||ut===wt?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,bt);let ke=E(P.image,!1,a.maxTextureSize);ke=rt(P,ke);const Ve=r.convert(P.format,P.colorSpace),St=r.convert(P.type);let ne=A(P.internalFormat,Ve,St,P.colorSpace,P.isVideoTexture);He(Ie,P);let me;const Le=P.mipmaps,K=P.isVideoTexture!==!0,Se=Tt.__version===void 0||Ge===!0,_e=we.dataReady,it=O(P,ke);if(P.isDepthTexture)ne=b(P.format===ku,P.type),Se&&(K?t.texStorage2D(n.TEXTURE_2D,1,ne,ke.width,ke.height):t.texImage2D(n.TEXTURE_2D,0,ne,ke.width,ke.height,0,Ve,St,null));else if(P.isDataTexture)if(Le.length>0){K&&Se&&t.texStorage2D(n.TEXTURE_2D,it,ne,Le[0].width,Le[0].height);for(let tt=0,We=Le.length;tt<We;tt++)me=Le[tt],K?_e&&t.texSubImage2D(n.TEXTURE_2D,tt,0,0,me.width,me.height,Ve,St,me.data):t.texImage2D(n.TEXTURE_2D,tt,ne,me.width,me.height,0,Ve,St,me.data);P.generateMipmaps=!1}else K?(Se&&t.texStorage2D(n.TEXTURE_2D,it,ne,ke.width,ke.height),_e&&xt(P,ke,Ve,St)):t.texImage2D(n.TEXTURE_2D,0,ne,ke.width,ke.height,0,Ve,St,ke.data);else if(P.isCompressedTexture)if(P.isCompressedArrayTexture){K&&Se&&t.texStorage3D(n.TEXTURE_2D_ARRAY,it,ne,Le[0].width,Le[0].height,ke.depth);for(let tt=0,We=Le.length;tt<We;tt++)if(me=Le[tt],P.format!==Rn)if(Ve!==null)if(K){if(_e)if(P.layerUpdates.size>0){const gt=PE(me.width,me.height,P.format,P.type);for(const Nt of P.layerUpdates){const $t=me.data.subarray(Nt*gt/me.data.BYTES_PER_ELEMENT,(Nt+1)*gt/me.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,tt,0,0,Nt,me.width,me.height,1,Ve,$t)}P.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,tt,0,0,0,me.width,me.height,ke.depth,Ve,me.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,tt,ne,me.width,me.height,ke.depth,0,me.data,0,0);else _t("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else K?_e&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,tt,0,0,0,me.width,me.height,ke.depth,Ve,St,me.data):t.texImage3D(n.TEXTURE_2D_ARRAY,tt,ne,me.width,me.height,ke.depth,0,Ve,St,me.data)}else{K&&Se&&t.texStorage2D(n.TEXTURE_2D,it,ne,Le[0].width,Le[0].height);for(let tt=0,We=Le.length;tt<We;tt++)me=Le[tt],P.format!==Rn?Ve!==null?K?_e&&t.compressedTexSubImage2D(n.TEXTURE_2D,tt,0,0,me.width,me.height,Ve,me.data):t.compressedTexImage2D(n.TEXTURE_2D,tt,ne,me.width,me.height,0,me.data):_t("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):K?_e&&t.texSubImage2D(n.TEXTURE_2D,tt,0,0,me.width,me.height,Ve,St,me.data):t.texImage2D(n.TEXTURE_2D,tt,ne,me.width,me.height,0,Ve,St,me.data)}else if(P.isDataArrayTexture)if(K){if(Se&&t.texStorage3D(n.TEXTURE_2D_ARRAY,it,ne,ke.width,ke.height,ke.depth),_e)if(P.layerUpdates.size>0){const tt=PE(ke.width,ke.height,P.format,P.type);for(const We of P.layerUpdates){const gt=ke.data.subarray(We*tt/ke.data.BYTES_PER_ELEMENT,(We+1)*tt/ke.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,We,ke.width,ke.height,1,Ve,St,gt)}P.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ke.width,ke.height,ke.depth,Ve,St,ke.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,ne,ke.width,ke.height,ke.depth,0,Ve,St,ke.data);else if(P.isData3DTexture)K?(Se&&t.texStorage3D(n.TEXTURE_3D,it,ne,ke.width,ke.height,ke.depth),_e&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ke.width,ke.height,ke.depth,Ve,St,ke.data)):t.texImage3D(n.TEXTURE_3D,0,ne,ke.width,ke.height,ke.depth,0,Ve,St,ke.data);else if(P.isFramebufferTexture){if(Se)if(K)t.texStorage2D(n.TEXTURE_2D,it,ne,ke.width,ke.height);else{let tt=ke.width,We=ke.height;for(let gt=0;gt<it;gt++)t.texImage2D(n.TEXTURE_2D,gt,ne,tt,We,0,Ve,St,null),tt>>=1,We>>=1}}else if(Le.length>0){if(K&&Se){const tt=mt(Le[0]);t.texStorage2D(n.TEXTURE_2D,it,ne,tt.width,tt.height)}for(let tt=0,We=Le.length;tt<We;tt++)me=Le[tt],K?_e&&t.texSubImage2D(n.TEXTURE_2D,tt,0,0,Ve,St,me):t.texImage2D(n.TEXTURE_2D,tt,ne,Ve,St,me);P.generateMipmaps=!1}else if(K){if(Se){const tt=mt(ke);t.texStorage2D(n.TEXTURE_2D,it,ne,tt.width,tt.height)}_e&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ve,St,ke)}else t.texImage2D(n.TEXTURE_2D,0,ne,Ve,St,ke);S(P)&&v(Ie),Tt.__version=we.version,P.onUpdate&&P.onUpdate(P)}j.__version=P.version}function Be(j,P,pe){if(P.image.length!==6)return;const Ie=Ke(j,P),Ge=P.source;t.bindTexture(n.TEXTURE_CUBE_MAP,j.__webglTexture,n.TEXTURE0+pe);const we=i.get(Ge);if(Ge.version!==we.__version||Ie===!0){t.activeTexture(n.TEXTURE0+pe);const Tt=gn.getPrimaries(gn.workingColorSpace),ut=P.colorSpace===pa?null:gn.getPrimaries(P.colorSpace),wt=P.colorSpace===pa||Tt===ut?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,wt);const bt=P.isCompressedTexture||P.image[0].isCompressedTexture,ke=P.image[0]&&P.image[0].isDataTexture,Ve=[];for(let We=0;We<6;We++)!bt&&!ke?Ve[We]=E(P.image[We],!0,a.maxCubemapSize):Ve[We]=ke?P.image[We].image:P.image[We],Ve[We]=rt(P,Ve[We]);const St=Ve[0],ne=r.convert(P.format,P.colorSpace),me=r.convert(P.type),Le=A(P.internalFormat,ne,me,P.colorSpace),K=P.isVideoTexture!==!0,Se=we.__version===void 0||Ie===!0,_e=Ge.dataReady;let it=O(P,St);He(n.TEXTURE_CUBE_MAP,P);let tt;if(bt){K&&Se&&t.texStorage2D(n.TEXTURE_CUBE_MAP,it,Le,St.width,St.height);for(let We=0;We<6;We++){tt=Ve[We].mipmaps;for(let gt=0;gt<tt.length;gt++){const Nt=tt[gt];P.format!==Rn?ne!==null?K?_e&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,gt,0,0,Nt.width,Nt.height,ne,Nt.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,gt,Le,Nt.width,Nt.height,0,Nt.data):_t("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):K?_e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,gt,0,0,Nt.width,Nt.height,ne,me,Nt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,gt,Le,Nt.width,Nt.height,0,ne,me,Nt.data)}}}else{if(tt=P.mipmaps,K&&Se){tt.length>0&&it++;const We=mt(Ve[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,it,Le,We.width,We.height)}for(let We=0;We<6;We++)if(ke){K?_e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,0,0,0,Ve[We].width,Ve[We].height,ne,me,Ve[We].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,0,Le,Ve[We].width,Ve[We].height,0,ne,me,Ve[We].data);for(let gt=0;gt<tt.length;gt++){const $t=tt[gt].image[We].image;K?_e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,gt+1,0,0,$t.width,$t.height,ne,me,$t.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,gt+1,Le,$t.width,$t.height,0,ne,me,$t.data)}}else{K?_e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,0,0,0,ne,me,Ve[We]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,0,Le,ne,me,Ve[We]);for(let gt=0;gt<tt.length;gt++){const Nt=tt[gt];K?_e&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,gt+1,0,0,ne,me,Nt.image[We]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,gt+1,Le,ne,me,Nt.image[We])}}}S(P)&&v(n.TEXTURE_CUBE_MAP),we.__version=Ge.version,P.onUpdate&&P.onUpdate(P)}j.__version=P.version}function Je(j,P,pe,Ie,Ge,we){const Tt=r.convert(pe.format,pe.colorSpace),ut=r.convert(pe.type),wt=A(pe.internalFormat,Tt,ut,pe.colorSpace),bt=i.get(P),ke=i.get(pe);if(ke.__renderTarget=P,!bt.__hasExternalTextures){const Ve=Math.max(1,P.width>>we),St=Math.max(1,P.height>>we);Ge===n.TEXTURE_3D||Ge===n.TEXTURE_2D_ARRAY?t.texImage3D(Ge,we,wt,Ve,St,P.depth,0,Tt,ut,null):t.texImage2D(Ge,we,wt,Ve,St,0,Tt,ut,null)}t.bindFramebuffer(n.FRAMEBUFFER,j),Ye(P)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ie,Ge,ke.__webglTexture,0,Qe(P)):(Ge===n.TEXTURE_2D||Ge>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&Ge<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Ie,Ge,ke.__webglTexture,we),t.bindFramebuffer(n.FRAMEBUFFER,null)}function ve(j,P,pe){if(n.bindRenderbuffer(n.RENDERBUFFER,j),P.depthBuffer){const Ie=P.depthTexture,Ge=Ie&&Ie.isDepthTexture?Ie.type:null,we=b(P.stencilBuffer,Ge),Tt=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ut=Qe(P);Ye(P)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ut,we,P.width,P.height):pe?n.renderbufferStorageMultisample(n.RENDERBUFFER,ut,we,P.width,P.height):n.renderbufferStorage(n.RENDERBUFFER,we,P.width,P.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Tt,n.RENDERBUFFER,j)}else{const Ie=P.textures;for(let Ge=0;Ge<Ie.length;Ge++){const we=Ie[Ge],Tt=r.convert(we.format,we.colorSpace),ut=r.convert(we.type),wt=A(we.internalFormat,Tt,ut,we.colorSpace),bt=Qe(P);pe&&Ye(P)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,bt,wt,P.width,P.height):Ye(P)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,bt,wt,P.width,P.height):n.renderbufferStorage(n.RENDERBUFFER,wt,P.width,P.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function at(j,P){if(P&&P.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,j),!(P.depthTexture&&P.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Ie=i.get(P.depthTexture);Ie.__renderTarget=P,(!Ie.__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),le(P.depthTexture,0);const Ge=Ie.__webglTexture,we=Qe(P);if(P.depthTexture.format===dd)Ye(P)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Ge,0,we):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Ge,0);else if(P.depthTexture.format===ku)Ye(P)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Ge,0,we):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Ge,0);else throw new Error("Unknown depthTexture format")}function ft(j){const P=i.get(j),pe=j.isWebGLCubeRenderTarget===!0;if(P.__boundDepthTexture!==j.depthTexture){const Ie=j.depthTexture;if(P.__depthDisposeCallback&&P.__depthDisposeCallback(),Ie){const Ge=()=>{delete P.__boundDepthTexture,delete P.__depthDisposeCallback,Ie.removeEventListener("dispose",Ge)};Ie.addEventListener("dispose",Ge),P.__depthDisposeCallback=Ge}P.__boundDepthTexture=Ie}if(j.depthTexture&&!P.__autoAllocateDepthBuffer){if(pe)throw new Error("target.depthTexture not supported in Cube render targets");const Ie=j.texture.mipmaps;Ie&&Ie.length>0?at(P.__webglFramebuffer[0],j):at(P.__webglFramebuffer,j)}else if(pe){P.__webglDepthbuffer=[];for(let Ie=0;Ie<6;Ie++)if(t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer[Ie]),P.__webglDepthbuffer[Ie]===void 0)P.__webglDepthbuffer[Ie]=n.createRenderbuffer(),ve(P.__webglDepthbuffer[Ie],j,!1);else{const Ge=j.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,we=P.__webglDepthbuffer[Ie];n.bindRenderbuffer(n.RENDERBUFFER,we),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ge,n.RENDERBUFFER,we)}}else{const Ie=j.texture.mipmaps;if(Ie&&Ie.length>0?t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,P.__webglFramebuffer),P.__webglDepthbuffer===void 0)P.__webglDepthbuffer=n.createRenderbuffer(),ve(P.__webglDepthbuffer,j,!1);else{const Ge=j.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,we=P.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,we),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ge,n.RENDERBUFFER,we)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function ht(j,P,pe){const Ie=i.get(j);P!==void 0&&Je(Ie.__webglFramebuffer,j,j.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),pe!==void 0&&ft(j)}function et(j){const P=j.texture,pe=i.get(j),Ie=i.get(P);j.addEventListener("dispose",L);const Ge=j.textures,we=j.isWebGLCubeRenderTarget===!0,Tt=Ge.length>1;if(Tt||(Ie.__webglTexture===void 0&&(Ie.__webglTexture=n.createTexture()),Ie.__version=P.version,s.memory.textures++),we){pe.__webglFramebuffer=[];for(let ut=0;ut<6;ut++)if(P.mipmaps&&P.mipmaps.length>0){pe.__webglFramebuffer[ut]=[];for(let wt=0;wt<P.mipmaps.length;wt++)pe.__webglFramebuffer[ut][wt]=n.createFramebuffer()}else pe.__webglFramebuffer[ut]=n.createFramebuffer()}else{if(P.mipmaps&&P.mipmaps.length>0){pe.__webglFramebuffer=[];for(let ut=0;ut<P.mipmaps.length;ut++)pe.__webglFramebuffer[ut]=n.createFramebuffer()}else pe.__webglFramebuffer=n.createFramebuffer();if(Tt)for(let ut=0,wt=Ge.length;ut<wt;ut++){const bt=i.get(Ge[ut]);bt.__webglTexture===void 0&&(bt.__webglTexture=n.createTexture(),s.memory.textures++)}if(j.samples>0&&Ye(j)===!1){pe.__webglMultisampledFramebuffer=n.createFramebuffer(),pe.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,pe.__webglMultisampledFramebuffer);for(let ut=0;ut<Ge.length;ut++){const wt=Ge[ut];pe.__webglColorRenderbuffer[ut]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,pe.__webglColorRenderbuffer[ut]);const bt=r.convert(wt.format,wt.colorSpace),ke=r.convert(wt.type),Ve=A(wt.internalFormat,bt,ke,wt.colorSpace,j.isXRRenderTarget===!0),St=Qe(j);n.renderbufferStorageMultisample(n.RENDERBUFFER,St,Ve,j.width,j.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+ut,n.RENDERBUFFER,pe.__webglColorRenderbuffer[ut])}n.bindRenderbuffer(n.RENDERBUFFER,null),j.depthBuffer&&(pe.__webglDepthRenderbuffer=n.createRenderbuffer(),ve(pe.__webglDepthRenderbuffer,j,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(we){t.bindTexture(n.TEXTURE_CUBE_MAP,Ie.__webglTexture),He(n.TEXTURE_CUBE_MAP,P);for(let ut=0;ut<6;ut++)if(P.mipmaps&&P.mipmaps.length>0)for(let wt=0;wt<P.mipmaps.length;wt++)Je(pe.__webglFramebuffer[ut][wt],j,P,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ut,wt);else Je(pe.__webglFramebuffer[ut],j,P,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0);S(P)&&v(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Tt){for(let ut=0,wt=Ge.length;ut<wt;ut++){const bt=Ge[ut],ke=i.get(bt);let Ve=n.TEXTURE_2D;(j.isWebGL3DRenderTarget||j.isWebGLArrayRenderTarget)&&(Ve=j.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ve,ke.__webglTexture),He(Ve,bt),Je(pe.__webglFramebuffer,j,bt,n.COLOR_ATTACHMENT0+ut,Ve,0),S(bt)&&v(Ve)}t.unbindTexture()}else{let ut=n.TEXTURE_2D;if((j.isWebGL3DRenderTarget||j.isWebGLArrayRenderTarget)&&(ut=j.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(ut,Ie.__webglTexture),He(ut,P),P.mipmaps&&P.mipmaps.length>0)for(let wt=0;wt<P.mipmaps.length;wt++)Je(pe.__webglFramebuffer[wt],j,P,n.COLOR_ATTACHMENT0,ut,wt);else Je(pe.__webglFramebuffer,j,P,n.COLOR_ATTACHMENT0,ut,0);S(P)&&v(ut),t.unbindTexture()}j.depthBuffer&&ft(j)}function Re(j){const P=j.textures;for(let pe=0,Ie=P.length;pe<Ie;pe++){const Ge=P[pe];if(S(Ge)){const we=_(j),Tt=i.get(Ge).__webglTexture;t.bindTexture(we,Tt),v(we),t.unbindTexture()}}}const Z=[],Ue=[];function ze(j){if(j.samples>0){if(Ye(j)===!1){const P=j.textures,pe=j.width,Ie=j.height;let Ge=n.COLOR_BUFFER_BIT;const we=j.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Tt=i.get(j),ut=P.length>1;if(ut)for(let bt=0;bt<P.length;bt++)t.bindFramebuffer(n.FRAMEBUFFER,Tt.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+bt,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Tt.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+bt,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Tt.__webglMultisampledFramebuffer);const wt=j.texture.mipmaps;wt&&wt.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Tt.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Tt.__webglFramebuffer);for(let bt=0;bt<P.length;bt++){if(j.resolveDepthBuffer&&(j.depthBuffer&&(Ge|=n.DEPTH_BUFFER_BIT),j.stencilBuffer&&j.resolveStencilBuffer&&(Ge|=n.STENCIL_BUFFER_BIT)),ut){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Tt.__webglColorRenderbuffer[bt]);const ke=i.get(P[bt]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,ke,0)}n.blitFramebuffer(0,0,pe,Ie,0,0,pe,Ie,Ge,n.NEAREST),c===!0&&(Z.length=0,Ue.length=0,Z.push(n.COLOR_ATTACHMENT0+bt),j.depthBuffer&&j.resolveDepthBuffer===!1&&(Z.push(we),Ue.push(we),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Ue)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Z))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),ut)for(let bt=0;bt<P.length;bt++){t.bindFramebuffer(n.FRAMEBUFFER,Tt.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+bt,n.RENDERBUFFER,Tt.__webglColorRenderbuffer[bt]);const ke=i.get(P[bt]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Tt.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+bt,n.TEXTURE_2D,ke,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Tt.__webglMultisampledFramebuffer)}else if(j.depthBuffer&&j.resolveDepthBuffer===!1&&c){const P=j.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[P])}}}function Qe(j){return Math.min(a.maxSamples,j.samples)}function Ye(j){const P=i.get(j);return j.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&P.__useRenderToTexture!==!1}function ot(j){const P=s.render.frame;f.get(j)!==P&&(f.set(j,P),j.update())}function rt(j,P){const pe=j.colorSpace,Ie=j.format,Ge=j.type;return j.isCompressedTexture===!0||j.isVideoTexture===!0||pe!==Fi&&pe!==pa&&(gn.getTransfer(pe)===Un?(Ie!==Rn||Ge!==xi)&&_t("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):qt("WebGLTextures: Unsupported texture color space:",pe)),P}function mt(j){return typeof HTMLImageElement<"u"&&j instanceof HTMLImageElement?(h.width=j.naturalWidth||j.width,h.height=j.naturalHeight||j.height):typeof VideoFrame<"u"&&j instanceof VideoFrame?(h.width=j.displayWidth,h.height=j.displayHeight):(h.width=j.width,h.height=j.height),h}this.allocateTextureUnit=$,this.resetTextureUnits=J,this.setTexture2D=le,this.setTexture2DArray=q,this.setTexture3D=te,this.setTextureCube=ee,this.rebindTextures=ht,this.setupRenderTarget=et,this.updateRenderTargetMipmap=Re,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=ft,this.setupFrameBufferTexture=Je,this.useMultisampledRTT=Ye}function n8(n,e){function t(i,a=pa){let r;const s=gn.getTransfer(a);if(i===xi)return n.UNSIGNED_BYTE;if(i===py)return n.UNSIGNED_SHORT_4_4_4_4;if(i===my)return n.UNSIGNED_SHORT_5_5_5_1;if(i===R3)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===w3)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===M0)return n.BYTE;if(i===C0)return n.SHORT;if(i===Gu)return n.UNSIGNED_SHORT;if(i===Fd)return n.INT;if(i===ls)return n.UNSIGNED_INT;if(i===Sn)return n.FLOAT;if(i===sn)return n.HALF_FLOAT;if(i===D3)return n.ALPHA;if(i===N3)return n.RGB;if(i===Rn)return n.RGBA;if(i===dd)return n.DEPTH_COMPONENT;if(i===ku)return n.DEPTH_STENCIL;if(i===Ar)return n.RED;if(i===R0)return n.RED_INTEGER;if(i===zo)return n.RG;if(i===gy)return n.RG_INTEGER;if(i===vy)return n.RGBA_INTEGER;if(i===Em||i===Tm||i===bm||i===Mm)if(s===Un)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Em)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Tm)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===bm)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Mm)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Em)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Tm)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===bm)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Mm)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Q1||i===$1||i===ex||i===tx)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===Q1)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===$1)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ex)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===tx)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===nx||i===ix||i===ax)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===nx||i===ix)return s===Un?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===ax)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===rx||i===sx||i===ox||i===lx||i===cx||i===ux||i===hx||i===fx||i===dx||i===px||i===mx||i===gx||i===vx||i===xx)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===rx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===sx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===ox)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===lx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===cx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ux)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===hx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===fx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===dx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===px)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===mx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===gx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===vx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===xx)return s===Un?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===yx||i===_x||i===Sx)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===yx)return s===Un?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===_x)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Sx)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Ax||i===Ex||i===Tx||i===bx)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===Ax)return r.COMPRESSED_RED_RGTC1_EXT;if(i===Ex)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Tx)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===bx)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Vu?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const EY=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,TY=`
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 bY{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Y3(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 Di({vertexShader:EY,fragmentShader:TY,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Xn(new Us(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class MY extends tr{constructor(e,t){super();const i=this;let a=null,r=1,s=null,o="local-floor",c=1,h=null,f=null,d=null,m=null,g=null,y=null;const E=typeof XRWebGLBinding<"u",S=new bY,v={},_=t.getContextAttributes();let A=null,b=null;const O=[],N=[],L=new Ee;let B=null;const w=new Jn;w.viewport=new Yt;const D=new Jn;D.viewport=new Yt;const G=[w,D],J=new YB;let $=null,se=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(fe){let Be=O[fe];return Be===void 0&&(Be=new h1,O[fe]=Be),Be.getTargetRaySpace()},this.getControllerGrip=function(fe){let Be=O[fe];return Be===void 0&&(Be=new h1,O[fe]=Be),Be.getGripSpace()},this.getHand=function(fe){let Be=O[fe];return Be===void 0&&(Be=new h1,O[fe]=Be),Be.getHandSpace()};function le(fe){const Be=N.indexOf(fe.inputSource);if(Be===-1)return;const Je=O[Be];Je!==void 0&&(Je.update(fe.inputSource,fe.frame,h||s),Je.dispatchEvent({type:fe.type,data:fe.inputSource}))}function q(){a.removeEventListener("select",le),a.removeEventListener("selectstart",le),a.removeEventListener("selectend",le),a.removeEventListener("squeeze",le),a.removeEventListener("squeezestart",le),a.removeEventListener("squeezeend",le),a.removeEventListener("end",q),a.removeEventListener("inputsourceschange",te);for(let fe=0;fe<O.length;fe++){const Be=N[fe];Be!==null&&(N[fe]=null,O[fe].disconnect(Be))}$=null,se=null,S.reset();for(const fe in v)delete v[fe];e.setRenderTarget(A),g=null,m=null,d=null,a=null,b=null,xt.stop(),i.isPresenting=!1,e.setPixelRatio(B),e.setSize(L.width,L.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(fe){r=fe,i.isPresenting===!0&&_t("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(fe){o=fe,i.isPresenting===!0&&_t("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||s},this.setReferenceSpace=function(fe){h=fe},this.getBaseLayer=function(){return m!==null?m:g},this.getBinding=function(){return d===null&&E&&(d=new XRWebGLBinding(a,t)),d},this.getFrame=function(){return y},this.getSession=function(){return a},this.setSession=async function(fe){if(a=fe,a!==null){if(A=e.getRenderTarget(),a.addEventListener("select",le),a.addEventListener("selectstart",le),a.addEventListener("selectend",le),a.addEventListener("squeeze",le),a.addEventListener("squeezestart",le),a.addEventListener("squeezeend",le),a.addEventListener("end",q),a.addEventListener("inputsourceschange",te),_.xrCompatible!==!0&&await t.makeXRCompatible(),B=e.getPixelRatio(),e.getSize(L),E&&"createProjectionLayer"in XRWebGLBinding.prototype){let Je=null,ve=null,at=null;_.depth&&(at=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Je=_.stencil?ku:dd,ve=_.stencil?Vu:ls);const ft={colorFormat:t.RGBA8,depthFormat:at,scaleFactor:r};d=this.getBinding(),m=d.createProjectionLayer(ft),a.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),b=new oi(m.textureWidth,m.textureHeight,{format:Rn,type:xi,depthTexture:new N0(m.textureWidth,m.textureHeight,ve,void 0,void 0,void 0,void 0,void 0,void 0,Je),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const Je={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:r};g=new XRWebGLLayer(a,t,Je),a.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),b=new oi(g.framebufferWidth,g.framebufferHeight,{format:Rn,type:xi,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(c),h=null,s=await a.requestReferenceSpace(o),xt.setContext(a),xt.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(a!==null)return a.environmentBlendMode},this.getDepthTexture=function(){return S.getDepthTexture()};function te(fe){for(let Be=0;Be<fe.removed.length;Be++){const Je=fe.removed[Be],ve=N.indexOf(Je);ve>=0&&(N[ve]=null,O[ve].disconnect(Je))}for(let Be=0;Be<fe.added.length;Be++){const Je=fe.added[Be];let ve=N.indexOf(Je);if(ve===-1){for(let ft=0;ft<O.length;ft++)if(ft>=N.length){N.push(Je),ve=ft;break}else if(N[ft]===null){N[ft]=Je,ve=ft;break}if(ve===-1)break}const at=O[ve];at&&at.connect(Je)}}const ee=new H,de=new H;function ue(fe,Be,Je){ee.setFromMatrixPosition(Be.matrixWorld),de.setFromMatrixPosition(Je.matrixWorld);const ve=ee.distanceTo(de),at=Be.projectionMatrix.elements,ft=Je.projectionMatrix.elements,ht=at[14]/(at[10]-1),et=at[14]/(at[10]+1),Re=(at[9]+1)/at[5],Z=(at[9]-1)/at[5],Ue=(at[8]-1)/at[0],ze=(ft[8]+1)/ft[0],Qe=ht*Ue,Ye=ht*ze,ot=ve/(-Ue+ze),rt=ot*-Ue;if(Be.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),fe.translateX(rt),fe.translateZ(ot),fe.matrixWorld.compose(fe.position,fe.quaternion,fe.scale),fe.matrixWorldInverse.copy(fe.matrixWorld).invert(),at[10]===-1)fe.projectionMatrix.copy(Be.projectionMatrix),fe.projectionMatrixInverse.copy(Be.projectionMatrixInverse);else{const mt=ht+ot,j=et+ot,P=Qe-rt,pe=Ye+(ve-rt),Ie=Re*et/j*mt,Ge=Z*et/j*mt;fe.projectionMatrix.makePerspective(P,pe,Ie,Ge,mt,j),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert()}}function Pe(fe,Be){Be===null?fe.matrixWorld.copy(fe.matrix):fe.matrixWorld.multiplyMatrices(Be.matrixWorld,fe.matrix),fe.matrixWorldInverse.copy(fe.matrixWorld).invert()}this.updateCamera=function(fe){if(a===null)return;let Be=fe.near,Je=fe.far;S.texture!==null&&(S.depthNear>0&&(Be=S.depthNear),S.depthFar>0&&(Je=S.depthFar)),J.near=D.near=w.near=Be,J.far=D.far=w.far=Je,($!==J.near||se!==J.far)&&(a.updateRenderState({depthNear:J.near,depthFar:J.far}),$=J.near,se=J.far),J.layers.mask=fe.layers.mask|6,w.layers.mask=J.layers.mask&3,D.layers.mask=J.layers.mask&5;const ve=fe.parent,at=J.cameras;Pe(J,ve);for(let ft=0;ft<at.length;ft++)Pe(at[ft],ve);at.length===2?ue(J,w,D):J.projectionMatrix.copy(w.projectionMatrix),He(fe,J,ve)};function He(fe,Be,Je){Je===null?fe.matrix.copy(Be.matrixWorld):(fe.matrix.copy(Je.matrixWorld),fe.matrix.invert(),fe.matrix.multiply(Be.matrixWorld)),fe.matrix.decompose(fe.position,fe.quaternion,fe.scale),fe.updateMatrixWorld(!0),fe.projectionMatrix.copy(Be.projectionMatrix),fe.projectionMatrixInverse.copy(Be.projectionMatrixInverse),fe.isPerspectiveCamera&&(fe.fov=xd*2*Math.atan(1/fe.projectionMatrix.elements[5]),fe.zoom=1)}this.getCamera=function(){return J},this.getFoveation=function(){if(!(m===null&&g===null))return c},this.setFoveation=function(fe){c=fe,m!==null&&(m.fixedFoveation=fe),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=fe)},this.hasDepthSensing=function(){return S.texture!==null},this.getDepthSensingMesh=function(){return S.getMesh(J)},this.getCameraTexture=function(fe){return v[fe]};let Ke=null;function nt(fe,Be){if(f=Be.getViewerPose(h||s),y=Be,f!==null){const Je=f.views;g!==null&&(e.setRenderTargetFramebuffer(b,g.framebuffer),e.setRenderTarget(b));let ve=!1;Je.length!==J.cameras.length&&(J.cameras.length=0,ve=!0);for(let et=0;et<Je.length;et++){const Re=Je[et];let Z=null;if(g!==null)Z=g.getViewport(Re);else{const ze=d.getViewSubImage(m,Re);Z=ze.viewport,et===0&&(e.setRenderTargetTextures(b,ze.colorTexture,ze.depthStencilTexture),e.setRenderTarget(b))}let Ue=G[et];Ue===void 0&&(Ue=new Jn,Ue.layers.enable(et),Ue.viewport=new Yt,G[et]=Ue),Ue.matrix.fromArray(Re.transform.matrix),Ue.matrix.decompose(Ue.position,Ue.quaternion,Ue.scale),Ue.projectionMatrix.fromArray(Re.projectionMatrix),Ue.projectionMatrixInverse.copy(Ue.projectionMatrix).invert(),Ue.viewport.set(Z.x,Z.y,Z.width,Z.height),et===0&&(J.matrix.copy(Ue.matrix),J.matrix.decompose(J.position,J.quaternion,J.scale)),ve===!0&&J.cameras.push(Ue)}const at=a.enabledFeatures;if(at&&at.includes("depth-sensing")&&a.depthUsage=="gpu-optimized"&&E){d=i.getBinding();const et=d.getDepthInformation(Je[0]);et&&et.isValid&&et.texture&&S.init(et,a.renderState)}if(at&&at.includes("camera-access")&&E){e.state.unbindTexture(),d=i.getBinding();for(let et=0;et<Je.length;et++){const Re=Je[et].camera;if(Re){let Z=v[Re];Z||(Z=new Y3,v[Re]=Z);const Ue=d.getCameraImage(Re);Z.sourceTexture=Ue}}}}for(let Je=0;Je<O.length;Je++){const ve=N[Je],at=O[Je];ve!==null&&at!==void 0&&at.update(ve,Be,h||s)}Ke&&Ke(fe,Be),Be.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:Be}),y=null}const xt=new JB;xt.setAnimationLoop(nt),this.setAnimationLoop=function(fe){Ke=fe},this.dispose=function(){}}}const iu=new Dr,CY=new lt;function RY(n,e){function t(S,v){S.matrixAutoUpdate===!0&&S.updateMatrix(),v.value.copy(S.matrix)}function i(S,v){v.color.getRGB(S.fogColor.value,sB(n)),v.isFog?(S.fogNear.value=v.near,S.fogFar.value=v.far):v.isFogExp2&&(S.fogDensity.value=v.density)}function a(S,v,_,A,b){v.isMeshBasicMaterial||v.isMeshLambertMaterial?r(S,v):v.isMeshToonMaterial?(r(S,v),d(S,v)):v.isMeshPhongMaterial?(r(S,v),f(S,v)):v.isMeshStandardMaterial?(r(S,v),m(S,v),v.isMeshPhysicalMaterial&&g(S,v,b)):v.isMeshMatcapMaterial?(r(S,v),y(S,v)):v.isMeshDepthMaterial?r(S,v):v.isMeshDistanceMaterial?(r(S,v),E(S,v)):v.isMeshNormalMaterial?r(S,v):v.isLineBasicMaterial?(s(S,v),v.isLineDashedMaterial&&o(S,v)):v.isPointsMaterial?c(S,v,_,A):v.isSpriteMaterial?h(S,v):v.isShadowMaterial?(S.color.value.copy(v.color),S.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function r(S,v){S.opacity.value=v.opacity,v.color&&S.diffuse.value.copy(v.color),v.emissive&&S.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(S.map.value=v.map,t(v.map,S.mapTransform)),v.alphaMap&&(S.alphaMap.value=v.alphaMap,t(v.alphaMap,S.alphaMapTransform)),v.bumpMap&&(S.bumpMap.value=v.bumpMap,t(v.bumpMap,S.bumpMapTransform),S.bumpScale.value=v.bumpScale,v.side===Wi&&(S.bumpScale.value*=-1)),v.normalMap&&(S.normalMap.value=v.normalMap,t(v.normalMap,S.normalMapTransform),S.normalScale.value.copy(v.normalScale),v.side===Wi&&S.normalScale.value.negate()),v.displacementMap&&(S.displacementMap.value=v.displacementMap,t(v.displacementMap,S.displacementMapTransform),S.displacementScale.value=v.displacementScale,S.displacementBias.value=v.displacementBias),v.emissiveMap&&(S.emissiveMap.value=v.emissiveMap,t(v.emissiveMap,S.emissiveMapTransform)),v.specularMap&&(S.specularMap.value=v.specularMap,t(v.specularMap,S.specularMapTransform)),v.alphaTest>0&&(S.alphaTest.value=v.alphaTest);const _=e.get(v),A=_.envMap,b=_.envMapRotation;A&&(S.envMap.value=A,iu.copy(b),iu.x*=-1,iu.y*=-1,iu.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(iu.y*=-1,iu.z*=-1),S.envMapRotation.value.setFromMatrix4(CY.makeRotationFromEuler(iu)),S.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,S.reflectivity.value=v.reflectivity,S.ior.value=v.ior,S.refractionRatio.value=v.refractionRatio),v.lightMap&&(S.lightMap.value=v.lightMap,S.lightMapIntensity.value=v.lightMapIntensity,t(v.lightMap,S.lightMapTransform)),v.aoMap&&(S.aoMap.value=v.aoMap,S.aoMapIntensity.value=v.aoMapIntensity,t(v.aoMap,S.aoMapTransform))}function s(S,v){S.diffuse.value.copy(v.color),S.opacity.value=v.opacity,v.map&&(S.map.value=v.map,t(v.map,S.mapTransform))}function o(S,v){S.dashSize.value=v.dashSize,S.totalSize.value=v.dashSize+v.gapSize,S.scale.value=v.scale}function c(S,v,_,A){S.diffuse.value.copy(v.color),S.opacity.value=v.opacity,S.size.value=v.size*_,S.scale.value=A*.5,v.map&&(S.map.value=v.map,t(v.map,S.uvTransform)),v.alphaMap&&(S.alphaMap.value=v.alphaMap,t(v.alphaMap,S.alphaMapTransform)),v.alphaTest>0&&(S.alphaTest.value=v.alphaTest)}function h(S,v){S.diffuse.value.copy(v.color),S.opacity.value=v.opacity,S.rotation.value=v.rotation,v.map&&(S.map.value=v.map,t(v.map,S.mapTransform)),v.alphaMap&&(S.alphaMap.value=v.alphaMap,t(v.alphaMap,S.alphaMapTransform)),v.alphaTest>0&&(S.alphaTest.value=v.alphaTest)}function f(S,v){S.specular.value.copy(v.specular),S.shininess.value=Math.max(v.shininess,1e-4)}function d(S,v){v.gradientMap&&(S.gradientMap.value=v.gradientMap)}function m(S,v){S.metalness.value=v.metalness,v.metalnessMap&&(S.metalnessMap.value=v.metalnessMap,t(v.metalnessMap,S.metalnessMapTransform)),S.roughness.value=v.roughness,v.roughnessMap&&(S.roughnessMap.value=v.roughnessMap,t(v.roughnessMap,S.roughnessMapTransform)),v.envMap&&(S.envMapIntensity.value=v.envMapIntensity)}function g(S,v,_){S.ior.value=v.ior,v.sheen>0&&(S.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),S.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(S.sheenColorMap.value=v.sheenColorMap,t(v.sheenColorMap,S.sheenColorMapTransform)),v.sheenRoughnessMap&&(S.sheenRoughnessMap.value=v.sheenRoughnessMap,t(v.sheenRoughnessMap,S.sheenRoughnessMapTransform))),v.clearcoat>0&&(S.clearcoat.value=v.clearcoat,S.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(S.clearcoatMap.value=v.clearcoatMap,t(v.clearcoatMap,S.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(S.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,t(v.clearcoatRoughnessMap,S.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(S.clearcoatNormalMap.value=v.clearcoatNormalMap,t(v.clearcoatNormalMap,S.clearcoatNormalMapTransform),S.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Wi&&S.clearcoatNormalScale.value.negate())),v.dispersion>0&&(S.dispersion.value=v.dispersion),v.iridescence>0&&(S.iridescence.value=v.iridescence,S.iridescenceIOR.value=v.iridescenceIOR,S.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],S.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(S.iridescenceMap.value=v.iridescenceMap,t(v.iridescenceMap,S.iridescenceMapTransform)),v.iridescenceThicknessMap&&(S.iridescenceThicknessMap.value=v.iridescenceThicknessMap,t(v.iridescenceThicknessMap,S.iridescenceThicknessMapTransform))),v.transmission>0&&(S.transmission.value=v.transmission,S.transmissionSamplerMap.value=_.texture,S.transmissionSamplerSize.value.set(_.width,_.height),v.transmissionMap&&(S.transmissionMap.value=v.transmissionMap,t(v.transmissionMap,S.transmissionMapTransform)),S.thickness.value=v.thickness,v.thicknessMap&&(S.thicknessMap.value=v.thicknessMap,t(v.thicknessMap,S.thicknessMapTransform)),S.attenuationDistance.value=v.attenuationDistance,S.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(S.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(S.anisotropyMap.value=v.anisotropyMap,t(v.anisotropyMap,S.anisotropyMapTransform))),S.specularIntensity.value=v.specularIntensity,S.specularColor.value.copy(v.specularColor),v.specularColorMap&&(S.specularColorMap.value=v.specularColorMap,t(v.specularColorMap,S.specularColorMapTransform)),v.specularIntensityMap&&(S.specularIntensityMap.value=v.specularIntensityMap,t(v.specularIntensityMap,S.specularIntensityMapTransform))}function y(S,v){v.matcap&&(S.matcap.value=v.matcap)}function E(S,v){const _=e.get(v).light;S.referencePosition.value.setFromMatrixPosition(_.matrixWorld),S.nearDistance.value=_.shadow.camera.near,S.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:a}}function wY(n,e,t,i){let a={},r={},s=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function c(_,A){const b=A.program;i.uniformBlockBinding(_,b)}function h(_,A){let b=a[_.id];b===void 0&&(y(_),b=f(_),a[_.id]=b,_.addEventListener("dispose",S));const O=A.program;i.updateUBOMapping(_,O);const N=e.render.frame;r[_.id]!==N&&(m(_),r[_.id]=N)}function f(_){const A=d();_.__bindingPointIndex=A;const b=n.createBuffer(),O=_.__size,N=_.usage;return n.bindBuffer(n.UNIFORM_BUFFER,b),n.bufferData(n.UNIFORM_BUFFER,O,N),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,b),b}function d(){for(let _=0;_<o;_++)if(s.indexOf(_)===-1)return s.push(_),_;return qt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(_){const A=a[_.id],b=_.uniforms,O=_.__cache;n.bindBuffer(n.UNIFORM_BUFFER,A);for(let N=0,L=b.length;N<L;N++){const B=Array.isArray(b[N])?b[N]:[b[N]];for(let w=0,D=B.length;w<D;w++){const G=B[w];if(g(G,N,w,O)===!0){const J=G.__offset,$=Array.isArray(G.value)?G.value:[G.value];let se=0;for(let le=0;le<$.length;le++){const q=$[le],te=E(q);typeof q=="number"||typeof q=="boolean"?(G.__data[0]=q,n.bufferSubData(n.UNIFORM_BUFFER,J+se,G.__data)):q.isMatrix3?(G.__data[0]=q.elements[0],G.__data[1]=q.elements[1],G.__data[2]=q.elements[2],G.__data[3]=0,G.__data[4]=q.elements[3],G.__data[5]=q.elements[4],G.__data[6]=q.elements[5],G.__data[7]=0,G.__data[8]=q.elements[6],G.__data[9]=q.elements[7],G.__data[10]=q.elements[8],G.__data[11]=0):(q.toArray(G.__data,se),se+=te.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,J,G.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function g(_,A,b,O){const N=_.value,L=A+"_"+b;if(O[L]===void 0)return typeof N=="number"||typeof N=="boolean"?O[L]=N:O[L]=N.clone(),!0;{const B=O[L];if(typeof N=="number"||typeof N=="boolean"){if(B!==N)return O[L]=N,!0}else if(B.equals(N)===!1)return B.copy(N),!0}return!1}function y(_){const A=_.uniforms;let b=0;const O=16;for(let L=0,B=A.length;L<B;L++){const w=Array.isArray(A[L])?A[L]:[A[L]];for(let D=0,G=w.length;D<G;D++){const J=w[D],$=Array.isArray(J.value)?J.value:[J.value];for(let se=0,le=$.length;se<le;se++){const q=$[se],te=E(q),ee=b%O,de=ee%te.boundary,ue=ee+de;b+=de,ue!==0&&O-ue<te.storage&&(b+=O-ue),J.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),J.__offset=b,b+=te.storage}}}const N=b%O;return N>0&&(b+=O-N),_.__size=b,_.__cache={},this}function E(_){const A={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(A.boundary=4,A.storage=4):_.isVector2?(A.boundary=8,A.storage=8):_.isVector3||_.isColor?(A.boundary=16,A.storage=12):_.isVector4?(A.boundary=16,A.storage=16):_.isMatrix3?(A.boundary=48,A.storage=48):_.isMatrix4?(A.boundary=64,A.storage=64):_.isTexture?_t("WebGLRenderer: Texture samplers can not be part of an uniforms group."):_t("WebGLRenderer: Unsupported uniform value type.",_),A}function S(_){const A=_.target;A.removeEventListener("dispose",S);const b=s.indexOf(A.__bindingPointIndex);s.splice(b,1),n.deleteBuffer(a[A.id]),delete a[A.id],delete r[A.id]}function v(){for(const _ in a)n.deleteBuffer(a[_]);s=[],a={},r={}}return{bind:c,update:h,dispose:v}}const DY=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 wo=null;function NY(){return wo===null&&(wo=new Pa(DY,32,32,zo,sn),wo.minFilter=Bt,wo.magFilter=Bt,wo.wrapS=Vn,wo.wrapT=Vn,wo.generateMipmaps=!1,wo.needsUpdate=!0),wo}class ky{constructor(e={}){const{canvas:t=nB(),context:i=null,depth:a=!0,stencil:r=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:h=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:m=!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 y=new Set([vy,gy,R0]),E=new Set([xi,ls,Gu,Vu,py,my]),S=new Uint32Array(4),v=new Int32Array(4);let _=null,A=null;const b=[],O=[];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=ns,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const N=this;let L=!1;this._outputColorSpace=Kn;let B=0,w=0,D=null,G=-1,J=null;const $=new Yt,se=new Yt;let le=null;const q=new dt(0);let te=0,ee=t.width,de=t.height,ue=1,Pe=null,He=null;const Ke=new Yt(0,0,ee,de),nt=new Yt(0,0,ee,de);let xt=!1;const fe=new Hd;let Be=!1,Je=!1;const ve=new lt,at=new H,ft=new Yt,ht={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let et=!1;function Re(){return D===null?ue:1}let Z=i;function Ue(C,F){return t.getContext(C,F)}try{const C={alpha:!0,depth:a,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:h,powerPreference:f,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${_c}`),t.addEventListener("webglcontextlost",tt,!1),t.addEventListener("webglcontextrestored",We,!1),t.addEventListener("webglcontextcreationerror",gt,!1),Z===null){const F="webgl2";if(Z=Ue(F,C),Z===null)throw Ue(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(C){throw C("WebGLRenderer: "+C.message),C}let ze,Qe,Ye,ot,rt,mt,j,P,pe,Ie,Ge,we,Tt,ut,wt,bt,ke,Ve,St,ne,me,Le,K,Se;function _e(){ze=new GX(Z),ze.init(),Le=new n8(Z,ze),Qe=new OX(Z,ze,e,Le),Ye=new SY(Z,ze),Qe.reversedDepthBuffer&&m&&Ye.buffers.depth.setReversed(!0),ot=new XX(Z),rt=new lY,mt=new AY(Z,ze,Ye,rt,Qe,Le,ot),j=new BX(N),P=new zX(N),pe=new ZG(Z),K=new DX(Z,pe),Ie=new VX(Z,pe,ot,K),Ge=new YX(Z,Ie,pe,ot),St=new WX(Z,Qe,mt),bt=new IX(rt),we=new oY(N,j,P,ze,Qe,K,bt),Tt=new RY(N,rt),ut=new uY,wt=new gY(ze),Ve=new wX(N,j,P,Ye,Ge,g,c),ke=new yY(N,Ge,Qe),Se=new wY(Z,ot,Qe,Ye),ne=new NX(Z,ze,ot),me=new kX(Z,ze,ot),ot.programs=we.programs,N.capabilities=Qe,N.extensions=ze,N.properties=rt,N.renderLists=ut,N.shadowMap=ke,N.state=Ye,N.info=ot}_e();const it=new MY(N,Z);this.xr=it,this.getContext=function(){return Z},this.getContextAttributes=function(){return Z.getContextAttributes()},this.forceContextLoss=function(){const C=ze.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=ze.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return ue},this.setPixelRatio=function(C){C!==void 0&&(ue=C,this.setSize(ee,de,!1))},this.getSize=function(C){return C.set(ee,de)},this.setSize=function(C,F,Y=!0){if(it.isPresenting){_t("WebGLRenderer: Can't change size while VR device is presenting.");return}ee=C,de=F,t.width=Math.floor(C*ue),t.height=Math.floor(F*ue),Y===!0&&(t.style.width=C+"px",t.style.height=F+"px"),this.setViewport(0,0,C,F)},this.getDrawingBufferSize=function(C){return C.set(ee*ue,de*ue).floor()},this.setDrawingBufferSize=function(C,F,Y){ee=C,de=F,ue=Y,t.width=Math.floor(C*Y),t.height=Math.floor(F*Y),this.setViewport(0,0,C,F)},this.getCurrentViewport=function(C){return C.copy($)},this.getViewport=function(C){return C.copy(Ke)},this.setViewport=function(C,F,Y,z){C.isVector4?Ke.set(C.x,C.y,C.z,C.w):Ke.set(C,F,Y,z),Ye.viewport($.copy(Ke).multiplyScalar(ue).round())},this.getScissor=function(C){return C.copy(nt)},this.setScissor=function(C,F,Y,z){C.isVector4?nt.set(C.x,C.y,C.z,C.w):nt.set(C,F,Y,z),Ye.scissor(se.copy(nt).multiplyScalar(ue).round())},this.getScissorTest=function(){return xt},this.setScissorTest=function(C){Ye.setScissorTest(xt=C)},this.setOpaqueSort=function(C){Pe=C},this.setTransparentSort=function(C){He=C},this.getClearColor=function(C){return C.copy(Ve.getClearColor())},this.setClearColor=function(){Ve.setClearColor(...arguments)},this.getClearAlpha=function(){return Ve.getClearAlpha()},this.setClearAlpha=function(){Ve.setClearAlpha(...arguments)},this.clear=function(C=!0,F=!0,Y=!0){let z=0;if(C){let k=!1;if(D!==null){const Q=D.texture.format;k=y.has(Q)}if(k){const Q=D.texture.type,ae=E.has(Q),ce=Ve.getClearColor(),xe=Ve.getClearAlpha(),Ae=ce.r,Ne=ce.g,Fe=ce.b;ae?(S[0]=Ae,S[1]=Ne,S[2]=Fe,S[3]=xe,Z.clearBufferuiv(Z.COLOR,0,S)):(v[0]=Ae,v[1]=Ne,v[2]=Fe,v[3]=xe,Z.clearBufferiv(Z.COLOR,0,v))}else z|=Z.COLOR_BUFFER_BIT}F&&(z|=Z.DEPTH_BUFFER_BIT),Y&&(z|=Z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Z.clear(z)},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",tt,!1),t.removeEventListener("webglcontextrestored",We,!1),t.removeEventListener("webglcontextcreationerror",gt,!1),Ve.dispose(),ut.dispose(),wt.dispose(),rt.dispose(),j.dispose(),P.dispose(),Ge.dispose(),K.dispose(),Se.dispose(),we.dispose(),it.dispose(),it.removeEventListener("sessionstart",Ps),it.removeEventListener("sessionend",ar),Ni.stop()};function tt(C){C.preventDefault(),r0("WebGLRenderer: Context Lost."),L=!0}function We(){r0("WebGLRenderer: Context Restored."),L=!1;const C=ot.autoReset,F=ke.enabled,Y=ke.autoUpdate,z=ke.needsUpdate,k=ke.type;_e(),ot.autoReset=C,ke.enabled=F,ke.autoUpdate=Y,ke.needsUpdate=z,ke.type=k}function gt(C){qt("WebGLRenderer: A WebGL context could not be created. Reason: ",C.statusMessage)}function Nt(C){const F=C.target;F.removeEventListener("dispose",Nt),$t(F)}function $t(C){jt(C),rt.remove(C)}function jt(C){const F=rt.get(C).programs;F!==void 0&&(F.forEach(function(Y){we.releaseProgram(Y)}),C.isShaderMaterial&&we.releaseShaderCache(C))}this.renderBufferDirect=function(C,F,Y,z,k,Q){F===null&&(F=ht);const ae=k.isMesh&&k.matrixWorld.determinant()<0,ce=Te(C,F,Y,z,k);Ye.setMaterial(z,ae);let xe=Y.index,Ae=1;if(z.wireframe===!0){if(xe=Ie.getWireframeAttribute(Y),xe===void 0)return;Ae=2}const Ne=Y.drawRange,Fe=Y.attributes.position;let Oe=Ne.start*Ae,Ze=(Ne.start+Ne.count)*Ae;Q!==null&&(Oe=Math.max(Oe,Q.start*Ae),Ze=Math.min(Ze,(Q.start+Q.count)*Ae)),xe!==null?(Oe=Math.max(Oe,0),Ze=Math.min(Ze,xe.count)):Fe!=null&&(Oe=Math.max(Oe,0),Ze=Math.min(Ze,Fe.count));const $e=Ze-Oe;if($e<0||$e===1/0)return;K.setup(k,z,ce,Y,xe);let vt,Rt=ne;if(xe!==null&&(vt=pe.get(xe),Rt=me,Rt.setIndex(vt)),k.isMesh)z.wireframe===!0?(Ye.setLineWidth(z.wireframeLinewidth*Re()),Rt.setMode(Z.LINES)):Rt.setMode(Z.TRIANGLES);else if(k.isLine){let pt=z.linewidth;pt===void 0&&(pt=1),Ye.setLineWidth(pt*Re()),k.isLineSegments?Rt.setMode(Z.LINES):k.isLineLoop?Rt.setMode(Z.LINE_LOOP):Rt.setMode(Z.LINE_STRIP)}else k.isPoints?Rt.setMode(Z.POINTS):k.isSprite&&Rt.setMode(Z.TRIANGLES);if(k.isBatchedMesh)if(k._multiDrawInstances!==null)vd("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Rt.renderMultiDrawInstances(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount,k._multiDrawInstances);else if(ze.get("WEBGL_multi_draw"))Rt.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const pt=k._multiDrawStarts,Ct=k._multiDrawCounts,je=k._multiDrawCount,Ut=xe?pe.get(xe).bytesPerElement:1,Ft=rt.get(z).currentProgram.getUniforms();for(let Et=0;Et<je;Et++)Ft.setValue(Z,"_gl_DrawID",Et),Rt.render(pt[Et]/Ut,Ct[Et])}else if(k.isInstancedMesh)Rt.renderInstances(Oe,$e,k.count);else if(Y.isInstancedBufferGeometry){const pt=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,Ct=Math.min(Y.instanceCount,pt);Rt.renderInstances(Oe,$e,Ct)}else Rt.render(Oe,$e)};function hi(C,F,Y){C.transparent===!0&&C.side===da&&C.forceSinglePass===!1?(C.side=Wi,C.needsUpdate=!0,U(C,F,Y),C.side=os,C.needsUpdate=!0,U(C,F,Y),C.side=da):U(C,F,Y)}this.compile=function(C,F,Y=null){Y===null&&(Y=C),A=wt.get(Y),A.init(F),O.push(A),Y.traverseVisible(function(k){k.isLight&&k.layers.test(F.layers)&&(A.pushLight(k),k.castShadow&&A.pushShadow(k))}),C!==Y&&C.traverseVisible(function(k){k.isLight&&k.layers.test(F.layers)&&(A.pushLight(k),k.castShadow&&A.pushShadow(k))}),A.setupLights();const z=new Set;return C.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;const Q=k.material;if(Q)if(Array.isArray(Q))for(let ae=0;ae<Q.length;ae++){const ce=Q[ae];hi(ce,Y,k),z.add(ce)}else hi(Q,Y,k),z.add(Q)}),A=O.pop(),z},this.compileAsync=function(C,F,Y=null){const z=this.compile(C,F,Y);return new Promise(k=>{function Q(){if(z.forEach(function(ae){rt.get(ae).currentProgram.isReady()&&z.delete(ae)}),z.size===0){k(C);return}setTimeout(Q,10)}ze.get("KHR_parallel_shader_compile")!==null?Q():setTimeout(Q,10)})};let fi=null;function hl(C){fi&&fi(C)}function Ps(){Ni.stop()}function ar(){Ni.start()}const Ni=new JB;Ni.setAnimationLoop(hl),typeof self<"u"&&Ni.setContext(self),this.setAnimationLoop=function(C){fi=C,it.setAnimationLoop(C),C===null?Ni.stop():Ni.start()},it.addEventListener("sessionstart",Ps),it.addEventListener("sessionend",ar),this.render=function(C,F){if(F!==void 0&&F.isCamera!==!0){qt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),it.enabled===!0&&it.isPresenting===!0&&(it.cameraAutoUpdate===!0&&it.updateCamera(F),F=it.getCamera()),C.isScene===!0&&C.onBeforeRender(N,C,F,D),A=wt.get(C,O.length),A.init(F),O.push(A),ve.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),fe.setFromProjectionMatrix(ve,Er,F.reversedDepth),Je=this.localClippingEnabled,Be=bt.init(this.clippingPlanes,Je),_=ut.get(C,b.length),_.init(),b.push(_),it.enabled===!0&&it.isPresenting===!0){const Q=N.xr.getDepthSensingMesh();Q!==null&&Va(Q,F,-1/0,N.sortObjects)}Va(C,F,0,N.sortObjects),_.finish(),N.sortObjects===!0&&_.sort(Pe,He),et=it.enabled===!1||it.isPresenting===!1||it.hasDepthSensing()===!1,et&&Ve.addToRenderList(_,C),this.info.render.frame++,Be===!0&&bt.beginShadows();const Y=A.state.shadowsArray;ke.render(Y,C,F),Be===!0&&bt.endShadows(),this.info.autoReset===!0&&this.info.reset();const z=_.opaque,k=_.transmissive;if(A.setupLights(),F.isArrayCamera){const Q=F.cameras;if(k.length>0)for(let ae=0,ce=Q.length;ae<ce;ae++){const xe=Q[ae];zt(z,k,C,xe)}et&&Ve.render(C);for(let ae=0,ce=Q.length;ae<ce;ae++){const xe=Q[ae];Oi(_,C,xe,xe.viewport)}}else k.length>0&&zt(z,k,C,F),et&&Ve.render(C),Oi(_,C,F);D!==null&&w===0&&(mt.updateMultisampleRenderTarget(D),mt.updateRenderTargetMipmap(D)),C.isScene===!0&&C.onAfterRender(N,C,F),K.resetDefaultState(),G=-1,J=null,O.pop(),O.length>0?(A=O[O.length-1],Be===!0&&bt.setGlobalState(N.clippingPlanes,A.state.camera)):A=null,b.pop(),b.length>0?_=b[b.length-1]:_=null};function Va(C,F,Y,z){if(C.visible===!1)return;if(C.layers.test(F.layers)){if(C.isGroup)Y=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(F);else if(C.isLight)A.pushLight(C),C.castShadow&&A.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||fe.intersectsSprite(C)){z&&ft.setFromMatrixPosition(C.matrixWorld).applyMatrix4(ve);const ae=Ge.update(C),ce=C.material;ce.visible&&_.push(C,ae,ce,Y,ft.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||fe.intersectsObject(C))){const ae=Ge.update(C),ce=C.material;if(z&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),ft.copy(C.boundingSphere.center)):(ae.boundingSphere===null&&ae.computeBoundingSphere(),ft.copy(ae.boundingSphere.center)),ft.applyMatrix4(C.matrixWorld).applyMatrix4(ve)),Array.isArray(ce)){const xe=ae.groups;for(let Ae=0,Ne=xe.length;Ae<Ne;Ae++){const Fe=xe[Ae],Oe=ce[Fe.materialIndex];Oe&&Oe.visible&&_.push(C,ae,Oe,Y,ft.z,Fe)}}else ce.visible&&_.push(C,ae,ce,Y,ft.z,null)}}const Q=C.children;for(let ae=0,ce=Q.length;ae<ce;ae++)Va(Q[ae],F,Y,z)}function Oi(C,F,Y,z){const{opaque:k,transmissive:Q,transparent:ae}=C;A.setupLightsView(Y),Be===!0&&bt.setGlobalState(N.clippingPlanes,Y),z&&Ye.viewport($.copy(z)),k.length>0&&ka(k,F,Y),Q.length>0&&ka(Q,F,Y),ae.length>0&&ka(ae,F,Y),Ye.buffers.depth.setTest(!0),Ye.buffers.depth.setMask(!0),Ye.buffers.color.setMask(!0),Ye.setPolygonOffset(!1)}function zt(C,F,Y,z){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;A.state.transmissionRenderTarget[z.id]===void 0&&(A.state.transmissionRenderTarget[z.id]=new oi(1,1,{generateMipmaps:!0,type:ze.has("EXT_color_buffer_half_float")||ze.has("EXT_color_buffer_float")?sn:xi,minFilter:Sr,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:gn.workingColorSpace}));const Q=A.state.transmissionRenderTarget[z.id],ae=z.viewport||$;Q.setSize(ae.z*N.transmissionResolutionScale,ae.w*N.transmissionResolutionScale);const ce=N.getRenderTarget(),xe=N.getActiveCubeFace(),Ae=N.getActiveMipmapLevel();N.setRenderTarget(Q),N.getClearColor(q),te=N.getClearAlpha(),te<1&&N.setClearColor(16777215,.5),N.clear(),et&&Ve.render(Y);const Ne=N.toneMapping;N.toneMapping=ns;const Fe=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),A.setupLightsView(z),Be===!0&&bt.setGlobalState(N.clippingPlanes,z),ka(C,Y,z),mt.updateMultisampleRenderTarget(Q),mt.updateRenderTargetMipmap(Q),ze.has("WEBGL_multisampled_render_to_texture")===!1){let Oe=!1;for(let Ze=0,$e=F.length;Ze<$e;Ze++){const vt=F[Ze],{object:Rt,geometry:pt,material:Ct,group:je}=vt;if(Ct.side===da&&Rt.layers.test(z.layers)){const Ut=Ct.side;Ct.side=Wi,Ct.needsUpdate=!0,Ln(Rt,Y,z,pt,Ct,je),Ct.side=Ut,Ct.needsUpdate=!0,Oe=!0}}Oe===!0&&(mt.updateMultisampleRenderTarget(Q),mt.updateRenderTargetMipmap(Q))}N.setRenderTarget(ce,xe,Ae),N.setClearColor(q,te),Fe!==void 0&&(z.viewport=Fe),N.toneMapping=Ne}function ka(C,F,Y){const z=F.isScene===!0?F.overrideMaterial:null;for(let k=0,Q=C.length;k<Q;k++){const ae=C[k],{object:ce,geometry:xe,group:Ae}=ae;let Ne=ae.material;Ne.allowOverride===!0&&z!==null&&(Ne=z),ce.layers.test(Y.layers)&&Ln(ce,F,Y,xe,Ne,Ae)}}function Ln(C,F,Y,z,k,Q){C.onBeforeRender(N,F,Y,z,k,Q),C.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix),k.onBeforeRender(N,F,Y,z,C,Q),k.transparent===!0&&k.side===da&&k.forceSinglePass===!1?(k.side=Wi,k.needsUpdate=!0,N.renderBufferDirect(Y,F,z,k,C,Q),k.side=os,k.needsUpdate=!0,N.renderBufferDirect(Y,F,z,k,C,Q),k.side=da):N.renderBufferDirect(Y,F,z,k,C,Q),C.onAfterRender(N,F,Y,z,k,Q)}function U(C,F,Y){F.isScene!==!0&&(F=ht);const z=rt.get(C),k=A.state.lights,Q=A.state.shadowsArray,ae=k.state.version,ce=we.getParameters(C,k.state,Q,F,Y),xe=we.getProgramCacheKey(ce);let Ae=z.programs;z.environment=C.isMeshStandardMaterial?F.environment:null,z.fog=F.fog,z.envMap=(C.isMeshStandardMaterial?P:j).get(C.envMap||z.environment),z.envMapRotation=z.environment!==null&&C.envMap===null?F.environmentRotation:C.envMapRotation,Ae===void 0&&(C.addEventListener("dispose",Nt),Ae=new Map,z.programs=Ae);let Ne=Ae.get(xe);if(Ne!==void 0){if(z.currentProgram===Ne&&z.lightsStateVersion===ae)return oe(C,ce),Ne}else ce.uniforms=we.getUniforms(C),C.onBeforeCompile(ce,N),Ne=we.acquireProgram(ce,xe),Ae.set(xe,Ne),z.uniforms=ce.uniforms;const Fe=z.uniforms;return(!C.isShaderMaterial&&!C.isRawShaderMaterial||C.clipping===!0)&&(Fe.clippingPlanes=bt.uniform),oe(C,ce),z.needsLights=Me(C),z.lightsStateVersion=ae,z.needsLights&&(Fe.ambientLightColor.value=k.state.ambient,Fe.lightProbe.value=k.state.probe,Fe.directionalLights.value=k.state.directional,Fe.directionalLightShadows.value=k.state.directionalShadow,Fe.spotLights.value=k.state.spot,Fe.spotLightShadows.value=k.state.spotShadow,Fe.rectAreaLights.value=k.state.rectArea,Fe.ltc_1.value=k.state.rectAreaLTC1,Fe.ltc_2.value=k.state.rectAreaLTC2,Fe.pointLights.value=k.state.point,Fe.pointLightShadows.value=k.state.pointShadow,Fe.hemisphereLights.value=k.state.hemi,Fe.directionalShadowMap.value=k.state.directionalShadowMap,Fe.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Fe.spotShadowMap.value=k.state.spotShadowMap,Fe.spotLightMatrix.value=k.state.spotLightMatrix,Fe.spotLightMap.value=k.state.spotLightMap,Fe.pointShadowMap.value=k.state.pointShadowMap,Fe.pointShadowMatrix.value=k.state.pointShadowMatrix),z.currentProgram=Ne,z.uniformsList=null,Ne}function W(C){if(C.uniformsList===null){const F=C.currentProgram.getUniforms();C.uniformsList=f1.seqWithValue(F.seq,C.uniforms)}return C.uniformsList}function oe(C,F){const Y=rt.get(C);Y.outputColorSpace=F.outputColorSpace,Y.batching=F.batching,Y.batchingColor=F.batchingColor,Y.instancing=F.instancing,Y.instancingColor=F.instancingColor,Y.instancingMorph=F.instancingMorph,Y.skinning=F.skinning,Y.morphTargets=F.morphTargets,Y.morphNormals=F.morphNormals,Y.morphColors=F.morphColors,Y.morphTargetsCount=F.morphTargetsCount,Y.numClippingPlanes=F.numClippingPlanes,Y.numIntersection=F.numClipIntersection,Y.vertexAlphas=F.vertexAlphas,Y.vertexTangents=F.vertexTangents,Y.toneMapping=F.toneMapping}function Te(C,F,Y,z,k){F.isScene!==!0&&(F=ht),mt.resetTextureUnits();const Q=F.fog,ae=z.isMeshStandardMaterial?F.environment:null,ce=D===null?N.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:Fi,xe=(z.isMeshStandardMaterial?P:j).get(z.envMap||ae),Ae=z.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,Ne=!!Y.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Fe=!!Y.morphAttributes.position,Oe=!!Y.morphAttributes.normal,Ze=!!Y.morphAttributes.color;let $e=ns;z.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&($e=N.toneMapping);const vt=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Rt=vt!==void 0?vt.length:0,pt=rt.get(z),Ct=A.state.lights;if(Be===!0&&(Je===!0||C!==J)){const On=C===J&&z.id===G;bt.setState(z,C,On)}let je=!1;z.version===pt.__version?(pt.needsLights&&pt.lightsStateVersion!==Ct.state.version||pt.outputColorSpace!==ce||k.isBatchedMesh&&pt.batching===!1||!k.isBatchedMesh&&pt.batching===!0||k.isBatchedMesh&&pt.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&pt.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&pt.instancing===!1||!k.isInstancedMesh&&pt.instancing===!0||k.isSkinnedMesh&&pt.skinning===!1||!k.isSkinnedMesh&&pt.skinning===!0||k.isInstancedMesh&&pt.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&pt.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&pt.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&pt.instancingMorph===!1&&k.morphTexture!==null||pt.envMap!==xe||z.fog===!0&&pt.fog!==Q||pt.numClippingPlanes!==void 0&&(pt.numClippingPlanes!==bt.numPlanes||pt.numIntersection!==bt.numIntersection)||pt.vertexAlphas!==Ae||pt.vertexTangents!==Ne||pt.morphTargets!==Fe||pt.morphNormals!==Oe||pt.morphColors!==Ze||pt.toneMapping!==$e||pt.morphTargetsCount!==Rt)&&(je=!0):(je=!0,pt.__version=z.version);let Ut=pt.currentProgram;je===!0&&(Ut=U(z,F,k));let Ft=!1,Et=!1,Lt=!1;const Ot=Ut.getUniforms(),en=pt.uniforms;if(Ye.useProgram(Ut.program)&&(Ft=!0,Et=!0,Lt=!0),z.id!==G&&(G=z.id,Et=!0),Ft||J!==C){Ye.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),Ot.setValue(Z,"projectionMatrix",C.projectionMatrix),Ot.setValue(Z,"viewMatrix",C.matrixWorldInverse);const Wn=Ot.map.cameraPosition;Wn!==void 0&&Wn.setValue(Z,at.setFromMatrixPosition(C.matrixWorld)),Qe.logarithmicDepthBuffer&&Ot.setValue(Z,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&Ot.setValue(Z,"isOrthographic",C.isOrthographicCamera===!0),J!==C&&(J=C,Et=!0,Lt=!0)}if(k.isSkinnedMesh){Ot.setOptional(Z,k,"bindMatrix"),Ot.setOptional(Z,k,"bindMatrixInverse");const On=k.skeleton;On&&(On.boneTexture===null&&On.computeBoneTexture(),Ot.setValue(Z,"boneTexture",On.boneTexture,mt))}k.isBatchedMesh&&(Ot.setOptional(Z,k,"batchingTexture"),Ot.setValue(Z,"batchingTexture",k._matricesTexture,mt),Ot.setOptional(Z,k,"batchingIdTexture"),Ot.setValue(Z,"batchingIdTexture",k._indirectTexture,mt),Ot.setOptional(Z,k,"batchingColorTexture"),k._colorsTexture!==null&&Ot.setValue(Z,"batchingColorTexture",k._colorsTexture,mt));const Nn=Y.morphAttributes;if((Nn.position!==void 0||Nn.normal!==void 0||Nn.color!==void 0)&&St.update(k,Y,Ut),(Et||pt.receiveShadow!==k.receiveShadow)&&(pt.receiveShadow=k.receiveShadow,Ot.setValue(Z,"receiveShadow",k.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(en.envMap.value=xe,en.flipEnvMap.value=xe.isCubeTexture&&xe.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&F.environment!==null&&(en.envMapIntensity.value=F.environmentIntensity),en.dfgLUT!==void 0&&(en.dfgLUT.value=NY()),Et&&(Ot.setValue(Z,"toneMappingExposure",N.toneMappingExposure),pt.needsLights&&De(en,Lt),Q&&z.fog===!0&&Tt.refreshFogUniforms(en,Q),Tt.refreshMaterialUniforms(en,z,ue,de,A.state.transmissionRenderTarget[C.id]),f1.upload(Z,W(pt),en,mt)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(f1.upload(Z,W(pt),en,mt),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&Ot.setValue(Z,"center",k.center),Ot.setValue(Z,"modelViewMatrix",k.modelViewMatrix),Ot.setValue(Z,"normalMatrix",k.normalMatrix),Ot.setValue(Z,"modelMatrix",k.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){const On=z.uniformsGroups;for(let Wn=0,mh=On.length;Wn<mh;Wn++){const Or=On[Wn];Se.update(Or,Ut),Se.bind(Or,Ut)}}return Ut}function De(C,F){C.ambientLightColor.needsUpdate=F,C.lightProbe.needsUpdate=F,C.directionalLights.needsUpdate=F,C.directionalLightShadows.needsUpdate=F,C.pointLights.needsUpdate=F,C.pointLightShadows.needsUpdate=F,C.spotLights.needsUpdate=F,C.spotLightShadows.needsUpdate=F,C.rectAreaLights.needsUpdate=F,C.hemisphereLights.needsUpdate=F}function Me(C){return C.isMeshLambertMaterial||C.isMeshToonMaterial||C.isMeshPhongMaterial||C.isMeshStandardMaterial||C.isShadowMaterial||C.isShaderMaterial&&C.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(C,F,Y){const z=rt.get(C);z.__autoAllocateDepthBuffer=C.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),rt.get(C.texture).__webglTexture=F,rt.get(C.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:Y,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(C,F){const Y=rt.get(C);Y.__webglFramebuffer=F,Y.__useDefaultFramebuffer=F===void 0};const M=Z.createFramebuffer();this.setRenderTarget=function(C,F=0,Y=0){D=C,B=F,w=Y;let z=!0,k=null,Q=!1,ae=!1;if(C){const xe=rt.get(C);if(xe.__useDefaultFramebuffer!==void 0)Ye.bindFramebuffer(Z.FRAMEBUFFER,null),z=!1;else if(xe.__webglFramebuffer===void 0)mt.setupRenderTarget(C);else if(xe.__hasExternalTextures)mt.rebindTextures(C,rt.get(C.texture).__webglTexture,rt.get(C.depthTexture).__webglTexture);else if(C.depthBuffer){const Fe=C.depthTexture;if(xe.__boundDepthTexture!==Fe){if(Fe!==null&&rt.has(Fe)&&(C.width!==Fe.image.width||C.height!==Fe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");mt.setupDepthRenderbuffer(C)}}const Ae=C.texture;(Ae.isData3DTexture||Ae.isDataArrayTexture||Ae.isCompressedArrayTexture)&&(ae=!0);const Ne=rt.get(C).__webglFramebuffer;C.isWebGLCubeRenderTarget?(Array.isArray(Ne[F])?k=Ne[F][Y]:k=Ne[F],Q=!0):C.samples>0&&mt.useMultisampledRTT(C)===!1?k=rt.get(C).__webglMultisampledFramebuffer:Array.isArray(Ne)?k=Ne[Y]:k=Ne,$.copy(C.viewport),se.copy(C.scissor),le=C.scissorTest}else $.copy(Ke).multiplyScalar(ue).floor(),se.copy(nt).multiplyScalar(ue).floor(),le=xt;if(Y!==0&&(k=M),Ye.bindFramebuffer(Z.FRAMEBUFFER,k)&&z&&Ye.drawBuffers(C,k),Ye.viewport($),Ye.scissor(se),Ye.setScissorTest(le),Q){const xe=rt.get(C.texture);Z.framebufferTexture2D(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_CUBE_MAP_POSITIVE_X+F,xe.__webglTexture,Y)}else if(ae){const xe=F;for(let Ae=0;Ae<C.textures.length;Ae++){const Ne=rt.get(C.textures[Ae]);Z.framebufferTextureLayer(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0+Ae,Ne.__webglTexture,Y,xe)}}else if(C!==null&&Y!==0){const xe=rt.get(C.texture);Z.framebufferTexture2D(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_2D,xe.__webglTexture,Y)}G=-1},this.readRenderTargetPixels=function(C,F,Y,z,k,Q,ae,ce=0){if(!(C&&C.isWebGLRenderTarget)){qt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xe=rt.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&ae!==void 0&&(xe=xe[ae]),xe){Ye.bindFramebuffer(Z.FRAMEBUFFER,xe);try{const Ae=C.textures[ce],Ne=Ae.format,Fe=Ae.type;if(!Qe.textureFormatReadable(Ne)){qt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Qe.textureTypeReadable(Fe)){qt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=C.width-z&&Y>=0&&Y<=C.height-k&&(C.textures.length>1&&Z.readBuffer(Z.COLOR_ATTACHMENT0+ce),Z.readPixels(F,Y,z,k,Le.convert(Ne),Le.convert(Fe),Q))}finally{const Ae=D!==null?rt.get(D).__webglFramebuffer:null;Ye.bindFramebuffer(Z.FRAMEBUFFER,Ae)}}},this.readRenderTargetPixelsAsync=async function(C,F,Y,z,k,Q,ae,ce=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xe=rt.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&ae!==void 0&&(xe=xe[ae]),xe)if(F>=0&&F<=C.width-z&&Y>=0&&Y<=C.height-k){Ye.bindFramebuffer(Z.FRAMEBUFFER,xe);const Ae=C.textures[ce],Ne=Ae.format,Fe=Ae.type;if(!Qe.textureFormatReadable(Ne))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Qe.textureTypeReadable(Fe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Oe=Z.createBuffer();Z.bindBuffer(Z.PIXEL_PACK_BUFFER,Oe),Z.bufferData(Z.PIXEL_PACK_BUFFER,Q.byteLength,Z.STREAM_READ),C.textures.length>1&&Z.readBuffer(Z.COLOR_ATTACHMENT0+ce),Z.readPixels(F,Y,z,k,Le.convert(Ne),Le.convert(Fe),0);const Ze=D!==null?rt.get(D).__webglFramebuffer:null;Ye.bindFramebuffer(Z.FRAMEBUFFER,Ze);const $e=Z.fenceSync(Z.SYNC_GPU_COMMANDS_COMPLETE,0);return Z.flush(),await iH(Z,$e,4),Z.bindBuffer(Z.PIXEL_PACK_BUFFER,Oe),Z.getBufferSubData(Z.PIXEL_PACK_BUFFER,0,Q),Z.deleteBuffer(Oe),Z.deleteSync($e),Q}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,F=null,Y=0){const z=Math.pow(2,-Y),k=Math.floor(C.image.width*z),Q=Math.floor(C.image.height*z),ae=F!==null?F.x:0,ce=F!==null?F.y:0;mt.setTexture2D(C,0),Z.copyTexSubImage2D(Z.TEXTURE_2D,Y,0,0,ae,ce,k,Q),Ye.unbindTexture()};const I=Z.createFramebuffer(),V=Z.createFramebuffer();this.copyTextureToTexture=function(C,F,Y=null,z=null,k=0,Q=null){Q===null&&(k!==0?(vd("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Q=k,k=0):Q=0);let ae,ce,xe,Ae,Ne,Fe,Oe,Ze,$e;const vt=C.isCompressedTexture?C.mipmaps[Q]:C.image;if(Y!==null)ae=Y.max.x-Y.min.x,ce=Y.max.y-Y.min.y,xe=Y.isBox3?Y.max.z-Y.min.z:1,Ae=Y.min.x,Ne=Y.min.y,Fe=Y.isBox3?Y.min.z:0;else{const Nn=Math.pow(2,-k);ae=Math.floor(vt.width*Nn),ce=Math.floor(vt.height*Nn),C.isDataArrayTexture?xe=vt.depth:C.isData3DTexture?xe=Math.floor(vt.depth*Nn):xe=1,Ae=0,Ne=0,Fe=0}z!==null?(Oe=z.x,Ze=z.y,$e=z.z):(Oe=0,Ze=0,$e=0);const Rt=Le.convert(F.format),pt=Le.convert(F.type);let Ct;F.isData3DTexture?(mt.setTexture3D(F,0),Ct=Z.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(mt.setTexture2DArray(F,0),Ct=Z.TEXTURE_2D_ARRAY):(mt.setTexture2D(F,0),Ct=Z.TEXTURE_2D),Z.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL,F.flipY),Z.pixelStorei(Z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),Z.pixelStorei(Z.UNPACK_ALIGNMENT,F.unpackAlignment);const je=Z.getParameter(Z.UNPACK_ROW_LENGTH),Ut=Z.getParameter(Z.UNPACK_IMAGE_HEIGHT),Ft=Z.getParameter(Z.UNPACK_SKIP_PIXELS),Et=Z.getParameter(Z.UNPACK_SKIP_ROWS),Lt=Z.getParameter(Z.UNPACK_SKIP_IMAGES);Z.pixelStorei(Z.UNPACK_ROW_LENGTH,vt.width),Z.pixelStorei(Z.UNPACK_IMAGE_HEIGHT,vt.height),Z.pixelStorei(Z.UNPACK_SKIP_PIXELS,Ae),Z.pixelStorei(Z.UNPACK_SKIP_ROWS,Ne),Z.pixelStorei(Z.UNPACK_SKIP_IMAGES,Fe);const Ot=C.isDataArrayTexture||C.isData3DTexture,en=F.isDataArrayTexture||F.isData3DTexture;if(C.isDepthTexture){const Nn=rt.get(C),On=rt.get(F),Wn=rt.get(Nn.__renderTarget),mh=rt.get(On.__renderTarget);Ye.bindFramebuffer(Z.READ_FRAMEBUFFER,Wn.__webglFramebuffer),Ye.bindFramebuffer(Z.DRAW_FRAMEBUFFER,mh.__webglFramebuffer);for(let Or=0;Or<xe;Or++)Ot&&(Z.framebufferTextureLayer(Z.READ_FRAMEBUFFER,Z.COLOR_ATTACHMENT0,rt.get(C).__webglTexture,k,Fe+Or),Z.framebufferTextureLayer(Z.DRAW_FRAMEBUFFER,Z.COLOR_ATTACHMENT0,rt.get(F).__webglTexture,Q,$e+Or)),Z.blitFramebuffer(Ae,Ne,ae,ce,Oe,Ze,ae,ce,Z.DEPTH_BUFFER_BIT,Z.NEAREST);Ye.bindFramebuffer(Z.READ_FRAMEBUFFER,null),Ye.bindFramebuffer(Z.DRAW_FRAMEBUFFER,null)}else if(k!==0||C.isRenderTargetTexture||rt.has(C)){const Nn=rt.get(C),On=rt.get(F);Ye.bindFramebuffer(Z.READ_FRAMEBUFFER,I),Ye.bindFramebuffer(Z.DRAW_FRAMEBUFFER,V);for(let Wn=0;Wn<xe;Wn++)Ot?Z.framebufferTextureLayer(Z.READ_FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Nn.__webglTexture,k,Fe+Wn):Z.framebufferTexture2D(Z.READ_FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_2D,Nn.__webglTexture,k),en?Z.framebufferTextureLayer(Z.DRAW_FRAMEBUFFER,Z.COLOR_ATTACHMENT0,On.__webglTexture,Q,$e+Wn):Z.framebufferTexture2D(Z.DRAW_FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_2D,On.__webglTexture,Q),k!==0?Z.blitFramebuffer(Ae,Ne,ae,ce,Oe,Ze,ae,ce,Z.COLOR_BUFFER_BIT,Z.NEAREST):en?Z.copyTexSubImage3D(Ct,Q,Oe,Ze,$e+Wn,Ae,Ne,ae,ce):Z.copyTexSubImage2D(Ct,Q,Oe,Ze,Ae,Ne,ae,ce);Ye.bindFramebuffer(Z.READ_FRAMEBUFFER,null),Ye.bindFramebuffer(Z.DRAW_FRAMEBUFFER,null)}else en?C.isDataTexture||C.isData3DTexture?Z.texSubImage3D(Ct,Q,Oe,Ze,$e,ae,ce,xe,Rt,pt,vt.data):F.isCompressedArrayTexture?Z.compressedTexSubImage3D(Ct,Q,Oe,Ze,$e,ae,ce,xe,Rt,vt.data):Z.texSubImage3D(Ct,Q,Oe,Ze,$e,ae,ce,xe,Rt,pt,vt):C.isDataTexture?Z.texSubImage2D(Z.TEXTURE_2D,Q,Oe,Ze,ae,ce,Rt,pt,vt.data):C.isCompressedTexture?Z.compressedTexSubImage2D(Z.TEXTURE_2D,Q,Oe,Ze,vt.width,vt.height,Rt,vt.data):Z.texSubImage2D(Z.TEXTURE_2D,Q,Oe,Ze,ae,ce,Rt,pt,vt);Z.pixelStorei(Z.UNPACK_ROW_LENGTH,je),Z.pixelStorei(Z.UNPACK_IMAGE_HEIGHT,Ut),Z.pixelStorei(Z.UNPACK_SKIP_PIXELS,Ft),Z.pixelStorei(Z.UNPACK_SKIP_ROWS,Et),Z.pixelStorei(Z.UNPACK_SKIP_IMAGES,Lt),Q===0&&F.generateMipmaps&&Z.generateMipmap(Ct),Ye.unbindTexture()},this.initRenderTarget=function(C){rt.get(C).__webglFramebuffer===void 0&&mt.setupRenderTarget(C)},this.initTexture=function(C){C.isCubeTexture?mt.setTextureCube(C,0):C.isData3DTexture?mt.setTexture3D(C,0):C.isDataArrayTexture||C.isCompressedArrayTexture?mt.setTexture2DArray(C,0):mt.setTexture2D(C,0),Ye.unbindTexture()},this.resetState=function(){B=0,w=0,D=null,Ye.reset(),K.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Er}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=gn._getDrawingBufferColorSpace(e),t.unpackColorSpace=gn._getUnpackColorSpace()}}const OY=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:C3,AddEquation:js,AddOperation:B5,AdditiveAnimationBlendMode:O3,AdditiveBlending:ME,AgXToneMapping:H5,AlphaFormat:D3,AlwaysCompare:eB,AlwaysDepth:Qm,AlwaysStencilFunc:DE,AmbientLight:HB,AnimationAction:jB,AnimationClip:Ad,AnimationLoader:kz,AnimationMixer:pG,AnimationObjectGroup:fG,AnimationUtils:Hz,ArcCurve:mB,ArrayCamera:YB,ArrowHelper:HG,AttachedBindMode:wE,Audio:qB,AudioAnalyser:nG,AudioContext:ub,AudioListener:$z,AudioLoader:Kz,AxesHelper:zG,BackSide:Wi,BasicDepthPacking:Sc,BasicShadowMap:g5,BatchedMesh:fB,Bone:Ay,BooleanKeyframeTrack:ch,Box2:EG,Box3:sa,Box3Helper:PG,BoxGeometry:lh,BoxHelper:LG,BufferAttribute:pn,BufferGeometry:Xt,BufferGeometryLoader:XB,ByteType:M0,Cache:Js,Camera:so,CameraHelper:UG,CanvasTexture:lz,CapsuleGeometry:My,CatmullRomCurve3:gB,CineonToneMapping:P5,CircleGeometry:Cy,ClampToEdgeWrapping:Vn,Clock:hb,Color:dt,ColorKeyframeTrack:ab,ColorManagement:gn,CompressedArrayTexture:sz,CompressedCubeTexture:oz,CompressedTexture:by,CompressedTextureLoader:Xz,ConeGeometry:I0,ConstantAlphaFactor:N5,ConstantColorFactor:w5,Controls:VG,CubeCamera:lB,CubeReflectionMapping:no,CubeRefractionMapping:mc,CubeTexture:w0,CubeTextureLoader:PB,CubeUVReflectionMapping:Pd,CubicBezierCurve:Z3,CubicBezierCurve3:vB,CubicInterpolant:IB,CullFaceBack:bE,CullFaceFront:m5,CullFaceFrontBack:SF,CullFaceNone:p5,Curve:Bs,CurvePath:yB,CustomBlending:M3,CustomToneMapping:F5,CylinderGeometry:O0,Cylindrical:AG,Data3DTexture:is,DataArrayTexture:yy,DataTexture:Pa,DataTextureLoader:Hy,DataUtils:Zo,DecrementStencilOp:NF,DecrementWrapStencilOp:IF,DefaultLoadingManager:LB,DepthFormat:dd,DepthStencilFormat:ku,DepthTexture:N0,DetachedBindMode:G5,DirectionalLight:cb,DirectionalLightHelper:BG,DiscreteInterpolant:BB,DodecahedronGeometry:Ry,DoubleSide:da,DstAlphaFactor:T5,DstColorFactor:M5,DynamicCopyUsage:ZF,DynamicDrawUsage:VF,DynamicReadUsage:WF,EdgesGeometry:pB,EllipseCurve:wy,EqualCompare:K5,EqualDepth:Z1,EqualStencilFunc:PF,EquirectangularReflectionMapping:hd,EquirectangularRefractionMapping:$m,Euler:Dr,EventDispatcher:tr,ExternalTexture:Y3,ExtrudeGeometry:Dy,FileLoader:oa,Float16BufferAttribute:FH,Float32BufferAttribute:Dt,FloatType:Sn,Fog:Sy,FogExp2:_y,FramebufferTexture:rz,FrontSide:os,Frustum:Hd,FrustumArray:Ey,GLBufferAttribute:yG,GLSL1:KF,GLSL3:cs,GreaterCompare:J5,GreaterDepth:K1,GreaterEqualCompare:$5,GreaterEqualDepth:j1,GreaterEqualStencilFunc:GF,GreaterStencilFunc:HF,GridHelper:OG,Group:jo,HalfFloatType:sn,HemisphereLight:FB,HemisphereLightHelper:NG,IcosahedronGeometry:B0,ImageBitmapLoader:WB,ImageLoader:c0,ImageUtils:iB,IncrementStencilOp:DF,IncrementWrapStencilOp:OF,InstancedBufferAttribute:Wu,InstancedBufferGeometry:kB,InstancedInterleavedBuffer:xG,InstancedMesh:k3,Int16BufferAttribute:LH,Int32BufferAttribute:PH,Int8BufferAttribute:IH,IntType:Fd,InterleavedBuffer:Xu,InterleavedBufferAttribute:Ns,Interpolant:zd,InterpolateDiscrete:pd,InterpolateLinear:md,InterpolateSmooth:u1,InterpolationSamplingMode:$F,InterpolationSamplingType:QF,InvertStencilOp:BF,KeepStencilOp:uu,KeyframeTrack:hs,LOD:hB,LatheGeometry:Ny,Layers:yd,LessCompare:j5,LessDepth:q1,LessEqualCompare:B3,LessEqualDepth:zu,LessEqualStencilFunc:FF,LessStencilFunc:LF,Light:Tc,LightProbe:VB,Line:rl,Line3:MG,LineBasicMaterial:Ca,LineCurve:j3,LineCurve3:xB,LineDashedMaterial:DB,LineLoop:X3,LineSegments:Is,LinearFilter:Bt,LinearInterpolant:ib,LinearMipMapLinearFilter:e0,LinearMipMapNearestFilter:TF,LinearMipmapLinearFilter:Sr,LinearMipmapNearestFilter:Kf,LinearSRGBColorSpace:Fi,LinearToneMapping:U5,LinearTransfer:n0,Loader:yi,LoaderUtils:lc,LoadingManager:Fy,LoopOnce:V5,LoopPingPong:X5,LoopRepeat:k5,MOUSE:lu,Material:ri,MaterialLoader:zy,MathUtils:Nr,Matrix2:mb,Matrix3:kt,Matrix4:lt,MaxEquation:_5,Mesh:Xn,MeshBasicMaterial:Qa,MeshDepthMaterial:eb,MeshDistanceMaterial:tb,MeshLambertMaterial:RB,MeshMatcapMaterial:wB,MeshNormalMaterial:$3,MeshPhongMaterial:MB,MeshPhysicalMaterial:us,MeshStandardMaterial:P0,MeshToonMaterial:CB,MinEquation:y5,MirroredRepeatWrapping:fd,MixOperation:I5,MultiplyBlending:RE,MultiplyOperation:b0,NearestFilter:$n,NearestMipMapLinearFilter:EF,NearestMipMapNearestFilter:AF,NearestMipmapLinearFilter:gu,NearestMipmapNearestFilter:dy,NeutralToneMapping:z5,NeverCompare:Z5,NeverDepth:Y1,NeverStencilFunc:UF,NoBlending:ga,NoColorSpace:pa,NoToneMapping:ns,NormalAnimationBlendMode:xy,NormalBlending:wu,NotEqualCompare:Q5,NotEqualDepth:J1,NotEqualStencilFunc:zF,NumberKeyframeTrack:qu,Object3D:fn,ObjectLoader:Zz,ObjectSpaceNormalMap:q5,OctahedronGeometry:U0,OneFactor:Uf,OneMinusConstantAlphaFactor:O5,OneMinusConstantColorFactor:D5,OneMinusDstAlphaFactor:b5,OneMinusDstColorFactor:C5,OneMinusSrcAlphaFactor:W1,OneMinusSrcColorFactor:E5,OrthographicCamera:Rr,PCFShadowMap:fy,PCFSoftShadowMap:Am,PMREMGenerator:FE,Path:Dx,PerspectiveCamera:Jn,Plane:Lo,PlaneGeometry:Us,PlaneHelper:FG,PointLight:lb,PointLightHelper:wG,Points:W3,PointsMaterial:Ty,PolarGridHelper:IG,PolyhedronGeometry:Ec,PositionalAudio:tG,PropertyBinding:yn,PropertyMixer:ZB,QuadraticBezierCurve:K3,QuadraticBezierCurve3:J3,Quaternion:Yi,QuaternionKeyframeTrack:Zu,QuaternionLinearInterpolant:UB,RED_GREEN_RGTC2_Format:Tx,RED_RGTC1_Format:Ax,REVISION:_c,RGBADepthPacking:Y5,RGBAFormat:Rn,RGBAIntegerFormat:vy,RGBA_ASTC_10x10_Format:gx,RGBA_ASTC_10x5_Format:dx,RGBA_ASTC_10x6_Format:px,RGBA_ASTC_10x8_Format:mx,RGBA_ASTC_12x10_Format:vx,RGBA_ASTC_12x12_Format:xx,RGBA_ASTC_4x4_Format:rx,RGBA_ASTC_5x4_Format:sx,RGBA_ASTC_5x5_Format:ox,RGBA_ASTC_6x5_Format:lx,RGBA_ASTC_6x6_Format:cx,RGBA_ASTC_8x5_Format:ux,RGBA_ASTC_8x6_Format:hx,RGBA_ASTC_8x8_Format:fx,RGBA_BPTC_Format:yx,RGBA_ETC2_EAC_Format:ax,RGBA_PVRTC_2BPPV1_Format:tx,RGBA_PVRTC_4BPPV1_Format:ex,RGBA_S3TC_DXT1_Format:Tm,RGBA_S3TC_DXT3_Format:bm,RGBA_S3TC_DXT5_Format:Mm,RGBDepthPacking:MF,RGBFormat:N3,RGBIntegerFormat:bF,RGB_BPTC_SIGNED_Format:_x,RGB_BPTC_UNSIGNED_Format:Sx,RGB_ETC1_Format:nx,RGB_ETC2_Format:ix,RGB_PVRTC_2BPPV1_Format:$1,RGB_PVRTC_4BPPV1_Format:Q1,RGB_S3TC_DXT1_Format:Em,RGDepthPacking:CF,RGFormat:zo,RGIntegerFormat:gy,RawShaderMaterial:cl,Ray:oh,Raycaster:pb,RectAreaLight:zB,RedFormat:Ar,RedIntegerFormat:R0,ReinhardToneMapping:L5,RenderTarget:L3,RenderTarget3D:mG,RepeatWrapping:wi,ReplaceStencilOp:wF,ReverseSubtractEquation:x5,RingGeometry:Oy,SIGNED_RED_GREEN_RGTC2_Format:bx,SIGNED_RED_RGTC1_Format:Ex,SRGBColorSpace:Kn,SRGBTransfer:Un,Scene:al,ShaderChunk:tn,ShaderLib:Cs,ShaderMaterial:Di,ShadowMaterial:bB,Shape:Nu,ShapeGeometry:Iy,ShapePath:GG,ShapeUtils:Rs,ShortType:C0,Skeleton:D0,SkeletonHelper:RG,SkinnedMesh:V3,Source:Kl,Sphere:zi,SphereGeometry:L0,Spherical:LE,SphericalHarmonics3:GB,SplineCurve:Q3,SpotLight:ob,SpotLightHelper:CG,Sprite:uB,SpriteMaterial:G3,SrcAlphaFactor:X1,SrcAlphaSaturateFactor:R5,SrcColorFactor:A5,StaticCopyUsage:qF,StaticDrawUsage:i0,StaticReadUsage:XF,StereoCamera:Jz,StreamCopyUsage:jF,StreamDrawUsage:kF,StreamReadUsage:YF,StringKeyframeTrack:uh,SubtractEquation:v5,SubtractiveBlending:CE,TOUCH:cu,TangentSpaceNormalMap:Ac,TetrahedronGeometry:By,Texture:vn,TextureLoader:rb,TextureUtils:qG,Timer:_G,TimestampQuery:JF,TorusGeometry:Uy,TorusKnotGeometry:Ly,Triangle:Ja,TriangleFanDrawMode:Mx,TriangleStripDrawMode:I3,TrianglesDrawMode:W5,TubeGeometry:Py,UVMapping:pc,Uint16BufferAttribute:F3,Uint32BufferAttribute:H3,Uint8BufferAttribute:BH,Uint8ClampedBufferAttribute:UH,Uniform:ie,UniformsGroup:vG,UniformsLib:yt,UniformsUtils:oB,UnsignedByteType:xi,UnsignedInt101111Type:w3,UnsignedInt248Type:Vu,UnsignedInt5999Type:R3,UnsignedIntType:ls,UnsignedShort4444Type:py,UnsignedShort5551Type:my,UnsignedShortType:Gu,VSMShadowMap:Es,Vector2:Ee,Vector3:H,Vector4:Yt,VectorKeyframeTrack:ju,VideoFrameTexture:az,VideoTexture:dB,WebGL3DRenderTarget:P3,WebGLArrayRenderTarget:aB,WebGLCoordinateSystem:Er,WebGLCubeRenderTarget:z3,WebGLRenderTarget:oi,WebGLRenderer:ky,WebGLUtils:n8,WebGPUCoordinateSystem:gd,WebXRController:h1,WireframeGeometry:TB,WrapAroundEnding:t0,ZeroCurvatureEnding:vu,ZeroFactor:S5,ZeroSlopeEnding:xu,ZeroStencilOp:RF,createCanvasElement:nB,error:qt,getConsoleFunction:nH,log:r0,setConsoleFunction:tH,warn:_t,warnOnce:vd},Symbol.toStringTag,{value:"Module"}));var i8={exports:{}},a8={},r8={exports:{}},s8={};/**
* @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 Ed=he;function IY(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var BY=typeof Object.is=="function"?Object.is:IY,UY=Ed.useState,LY=Ed.useEffect,PY=Ed.useLayoutEffect,FY=Ed.useDebugValue;function HY(n,e){var t=e(),i=UY({inst:{value:t,getSnapshot:e}}),a=i[0].inst,r=i[1];return PY(function(){a.value=t,a.getSnapshot=e,n2(a)&&r({inst:a})},[n,t,e]),LY(function(){return n2(a)&&r({inst:a}),n(function(){n2(a)&&r({inst:a})})},[n]),FY(t),t}function n2(n){var e=n.getSnapshot;n=n.value;try{var t=e();return!BY(n,t)}catch{return!0}}function zY(n,e){return e()}var GY=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?zY:HY;s8.useSyncExternalStore=Ed.useSyncExternalStore!==void 0?Ed.useSyncExternalStore:GY;r8.exports=s8;var VY=r8.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 Xy=he,kY=VY;function XY(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var WY=typeof Object.is=="function"?Object.is:XY,YY=kY.useSyncExternalStore,qY=Xy.useRef,ZY=Xy.useEffect,jY=Xy.useMemo,KY=Xy.useDebugValue;a8.useSyncExternalStoreWithSelector=function(n,e,t,i,a){var r=qY(null);if(r.current===null){var s={hasValue:!1,value:null};r.current=s}else s=r.current;r=jY(function(){function c(g){if(!h){if(h=!0,f=g,g=i(g),a!==void 0&&s.hasValue){var y=s.value;if(a(y,g))return d=y}return d=g}if(y=d,WY(f,g))return y;var E=i(g);return a!==void 0&&a(y,E)?(f=g,y):(f=g,d=E)}var h=!1,f,d,m=t===void 0?null:t;return[function(){return c(e())},m===null?void 0:function(){return c(m())}]},[e,t,i,a]);var o=YY(n,r[0],r[1]);return ZY(function(){s.hasValue=!0,s.value=o},[o]),KY(o),o};i8.exports=a8;var JY=i8.exports;const QY=Zx(JY),aD=n=>{let e;const t=new Set,i=(h,f)=>{const d=typeof h=="function"?h(e):h;if(!Object.is(d,e)){const m=e;e=f??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(g=>g(e,m))}},a=()=>e,o={setState:i,getState:a,getInitialState:()=>c,subscribe:h=>(t.add(h),()=>t.delete(h))},c=e=n(i,a,o);return o},$Y=n=>n?aD(n):aD,{useSyncExternalStoreWithSelector:eq}=QY,tq=n=>n;function nq(n,e=tq,t){const i=eq(n.subscribe,n.getState,n.getInitialState,e,t);return IT.useDebugValue(i),i}const rD=(n,e)=>{const t=$Y(n),i=(a,r=e)=>nq(t,a,r);return Object.assign(i,t),i},o8=(n,e)=>n?rD(n,e):rD,iq=n=>typeof n=="object"&&typeof n.then=="function",_u=[];function l8(n,e,t=(i,a)=>i===a){if(n===e)return!0;if(!n||!e)return!1;const i=n.length;if(e.length!==i)return!1;for(let a=0;a<i;a++)if(!t(n[a],e[a]))return!1;return!0}function c8(n,e=null,t=!1,i={}){e===null&&(e=[n]);for(const r of _u)if(l8(e,r.keys,r.equal)){if(t)return;if(Object.prototype.hasOwnProperty.call(r,"error"))throw r.error;if(Object.prototype.hasOwnProperty.call(r,"response"))return i.lifespan&&i.lifespan>0&&(r.timeout&&clearTimeout(r.timeout),r.timeout=setTimeout(r.remove,i.lifespan)),r.response;if(!t)throw r.promise}const a={keys:e,equal:i.equal,remove:()=>{const r=_u.indexOf(a);r!==-1&&_u.splice(r,1)},promise:(iq(n)?n:n(...e)).then(r=>{a.response=r,i.lifespan&&i.lifespan>0&&(a.timeout=setTimeout(a.remove,i.lifespan))}).catch(r=>a.error=r)};if(_u.push(a),!t)throw a.promise}const aq=(n,e,t)=>c8(n,e,!1,t),rq=(n,e,t)=>void c8(n,e,!0,t),sq=n=>{if(n===void 0||n.length===0)_u.splice(0,_u.length);else{const e=_u.find(t=>l8(n,t.keys,t.equal));e&&e.remove()}};var u8={exports:{}},h8={exports:{}},f8={exports:{}},d8={};/**
* @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(q,te){var ee=q.length;q.push(te);e:for(;0<ee;){var de=ee-1>>>1,ue=q[de];if(0<a(ue,te))q[de]=te,q[ee]=ue,ee=de;else break e}}function t(q){return q.length===0?null:q[0]}function i(q){if(q.length===0)return null;var te=q[0],ee=q.pop();if(ee!==te){q[0]=ee;e:for(var de=0,ue=q.length,Pe=ue>>>1;de<Pe;){var He=2*(de+1)-1,Ke=q[He],nt=He+1,xt=q[nt];if(0>a(Ke,ee))nt<ue&&0>a(xt,Ke)?(q[de]=xt,q[nt]=ee,de=nt):(q[de]=Ke,q[He]=ee,de=He);else if(nt<ue&&0>a(xt,ee))q[de]=xt,q[nt]=ee,de=nt;else break e}}return te}function a(q,te){var ee=q.sortIndex-te.sortIndex;return ee!==0?ee:q.id-te.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;n.unstable_now=function(){return r.now()}}else{var s=Date,o=s.now();n.unstable_now=function(){return s.now()-o}}var c=[],h=[],f=1,d=null,m=3,g=!1,y=!1,E=!1,S=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function A(q){for(var te=t(h);te!==null;){if(te.callback===null)i(h);else if(te.startTime<=q)i(h),te.sortIndex=te.expirationTime,e(c,te);else break;te=t(h)}}function b(q){if(E=!1,A(q),!y)if(t(c)!==null)y=!0,se();else{var te=t(h);te!==null&&le(b,te.startTime-q)}}var O=!1,N=-1,L=5,B=-1;function w(){return!(n.unstable_now()-B<L)}function D(){if(O){var q=n.unstable_now();B=q;var te=!0;try{e:{y=!1,E&&(E=!1,v(N),N=-1),g=!0;var ee=m;try{t:{for(A(q),d=t(c);d!==null&&!(d.expirationTime>q&&w());){var de=d.callback;if(typeof de=="function"){d.callback=null,m=d.priorityLevel;var ue=de(d.expirationTime<=q);if(q=n.unstable_now(),typeof ue=="function"){d.callback=ue,A(q),te=!0;break t}d===t(c)&&i(c),A(q)}else i(c);d=t(c)}if(d!==null)te=!0;else{var Pe=t(h);Pe!==null&&le(b,Pe.startTime-q),te=!1}}break e}finally{d=null,m=ee,g=!1}te=void 0}}finally{te?G():O=!1}}}var G;if(typeof _=="function")G=function(){_(D)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,$=J.port2;J.port1.onmessage=D,G=function(){$.postMessage(null)}}else G=function(){S(D,0)};function se(){O||(O=!0,G())}function le(q,te){N=S(function(){q(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(q){q.callback=null},n.unstable_continueExecution=function(){y||g||(y=!0,se())},n.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<q?Math.floor(1e3/q):5},n.unstable_getCurrentPriorityLevel=function(){return m},n.unstable_getFirstCallbackNode=function(){return t(c)},n.unstable_next=function(q){switch(m){case 1:case 2:case 3:var te=3;break;default:te=m}var ee=m;m=te;try{return q()}finally{m=ee}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(q,te){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var ee=m;m=q;try{return te()}finally{m=ee}},n.unstable_scheduleCallback=function(q,te,ee){var de=n.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?de+ee:de):ee=de,q){case 1:var ue=-1;break;case 2:ue=250;break;case 5:ue=1073741823;break;case 4:ue=1e4;break;default:ue=5e3}return ue=ee+ue,q={id:f++,callback:te,priorityLevel:q,startTime:ee,expirationTime:ue,sortIndex:-1},ee>de?(q.sortIndex=ee,e(h,q),t(c)===null&&q===t(h)&&(E?(v(N),N=-1):E=!0,le(b,ee-de))):(q.sortIndex=ue,e(c,q),y||g||(y=!0,se())),q},n.unstable_shouldYield=w,n.unstable_wrapCallback=function(q){var te=m;return function(){var ee=m;m=te;try{return q.apply(this,arguments)}finally{m=ee}}}})(d8);f8.exports=d8;var zE=f8.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(l,u,p,x){return new H9(l,u,p,x)}function i(){}function a(l){var u="https://react.dev/errors/"+l;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)u+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(l){return l===null||typeof l!="object"?null:(l=CC&&l[CC]||l["@@iterator"],typeof l=="function"?l:null)}function s(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===W9?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case Sh:return"Fragment";case _h:return"Portal";case $_:return"Profiler";case TC:return"StrictMode";case tS:return"Suspense";case nS:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case vl:return(l.displayName||"Context")+".Provider";case bC:return(l._context.displayName||"Context")+".Consumer";case eS:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case iS:return u=l.displayName||null,u!==null?u:s(l.type)||"Memo";case xl:u=l._payload,l=l._init;try{return s(l(u))}catch{}}return null}function o(l){if(aS===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);aS=u&&u[1]||"",RC=-1<p.stack.indexOf(`
at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return`
`+aS+l+RC}function c(l,u){if(!l||rS)return"";rS=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var x={DetermineComponentFrameRoot:function(){try{if(u){var At=function(){throw Error()};if(Object.defineProperty(At.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(At,[])}catch(Kt){var Mt=Kt}Reflect.construct(l,[],At)}else{try{At.call()}catch(Kt){Mt=Kt}l.call(At.prototype)}}else{try{throw Error()}catch(Kt){Mt=Kt}(At=l())&&typeof At.catch=="function"&&At.catch(function(){})}}catch(Kt){if(Kt&&Mt&&typeof Kt.stack=="string")return[Kt.stack,Mt.stack]}return[null,null]}};x.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var T=Object.getOwnPropertyDescriptor(x.DetermineComponentFrameRoot,"name");T&&T.configurable&&Object.defineProperty(x.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var R=x.DetermineComponentFrameRoot(),X=R[0],re=R[1];if(X&&re){var ye=X.split(`
`),Xe=re.split(`
`);for(T=x=0;x<ye.length&&!ye[x].includes("DetermineComponentFrameRoot");)x++;for(;T<Xe.length&&!Xe[T].includes("DetermineComponentFrameRoot");)T++;if(x===ye.length||T===Xe.length)for(x=ye.length-1,T=Xe.length-1;1<=x&&0<=T&&ye[x]!==Xe[T];)T--;for(;1<=x&&0<=T;x--,T--)if(ye[x]!==Xe[T]){if(x!==1||T!==1)do if(x--,T--,0>T||ye[x]!==Xe[T]){var ct=`
`+ye[x].replace(" at new "," at ");return l.displayName&&ct.includes("<anonymous>")&&(ct=ct.replace("<anonymous>",l.displayName)),ct}while(1<=x&&0<=T);break}}}finally{rS=!1,Error.prepareStackTrace=p}return(p=l?l.displayName||l.name:"")?o(p):""}function h(l){switch(l.tag){case 26:case 27:case 5:return o(l.type);case 16:return o("Lazy");case 13:return o("Suspense");case 19:return o("SuspenseList");case 0:case 15:return l=c(l.type,!1),l;case 11:return l=c(l.type.render,!1),l;case 1:return l=c(l.type,!0),l;default:return""}}function f(l){try{var u="";do u+=h(l),l=l.return;while(l);return u}catch(p){return`
Error generating stack: `+p.message+`
`+p.stack}}function d(l){var u=l,p=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,u.flags&4098&&(p=u.return),l=u.return;while(l)}return u.tag===3?p:null}function m(l){if(d(l)!==l)throw Error(a(188))}function g(l){var u=l.alternate;if(!u){if(u=d(l),u===null)throw Error(a(188));return u!==l?null:l}for(var p=l,x=u;;){var T=p.return;if(T===null)break;var R=T.alternate;if(R===null){if(x=T.return,x!==null){p=x;continue}break}if(T.child===R.child){for(R=T.child;R;){if(R===p)return m(T),l;if(R===x)return m(T),u;R=R.sibling}throw Error(a(188))}if(p.return!==x.return)p=T,x=R;else{for(var X=!1,re=T.child;re;){if(re===p){X=!0,p=T,x=R;break}if(re===x){X=!0,x=T,p=R;break}re=re.sibling}if(!X){for(re=R.child;re;){if(re===p){X=!0,p=R,x=T;break}if(re===x){X=!0,x=R,p=T;break}re=re.sibling}if(!X)throw Error(a(189))}}if(p.alternate!==x)throw Error(a(190))}if(p.tag!==3)throw Error(a(188));return p.stateNode.current===p?l:u}function y(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l;for(l=l.child;l!==null;){if(u=y(l),u!==null)return u;l=l.sibling}return null}function E(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l;for(l=l.child;l!==null;){if(l.tag!==4&&(u=E(l),u!==null))return u;l=l.sibling}return null}function S(l){return{current:l}}function v(l){0>Eh||(l.current=hS[Eh],hS[Eh]=null,Eh--)}function _(l,u){Eh++,hS[Eh]=l.current,l.current=u}function A(l){return l>>>=0,l===0?32:31-(sL(l)/oL|0)|0}function b(l){var u=l&42;if(u!==0)return u;switch(l&-l){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 l&4194176;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function O(l,u){var p=l.pendingLanes;if(p===0)return 0;var x=0,T=l.suspendedLanes,R=l.pingedLanes,X=l.warmLanes;l=l.finishedLanes!==0;var re=p&134217727;return re!==0?(p=re&~T,p!==0?x=b(p):(R&=re,R!==0?x=b(R):l||(X=re&~X,X!==0&&(x=b(X))))):(re=p&~T,re!==0?x=b(re):R!==0?x=b(R):l||(X=p&~X,X!==0&&(x=b(X)))),x===0?0:u!==0&&u!==x&&!(u&T)&&(T=x&-x,X=u&-u,T>=X||T===32&&(X&4194176)!==0)?u:x}function N(l,u){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&u)===0}function L(l,u){switch(l){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 B(){var l=lg;return lg<<=1,!(lg&4194176)&&(lg=128),l}function w(){var l=cg;return cg<<=1,!(cg&62914560)&&(cg=4194304),l}function D(l){for(var u=[],p=0;31>p;p++)u.push(l);return u}function G(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function J(l,u,p,x,T,R){var X=l.pendingLanes;l.pendingLanes=p,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=p,l.entangledLanes&=p,l.errorRecoveryDisabledLanes&=p,l.shellSuspendCounter=0;var re=l.entanglements,ye=l.expirationTimes,Xe=l.hiddenUpdates;for(p=X&~p;0<p;){var ct=31-ur(p),At=1<<ct;re[ct]=0,ye[ct]=-1;var Mt=Xe[ct];if(Mt!==null)for(Xe[ct]=null,ct=0;ct<Mt.length;ct++){var Kt=Mt[ct];Kt!==null&&(Kt.lane&=-536870913)}p&=~At}x!==0&&$(l,x,0),R!==0&&T===0&&l.tag!==0&&(l.suspendedLanes|=R&~(X&~u))}function $(l,u,p){l.pendingLanes|=u,l.suspendedLanes&=~u;var x=31-ur(u);l.entangledLanes|=u,l.entanglements[x]=l.entanglements[x]|1073741824|p&4194218}function se(l,u){var p=l.entangledLanes|=u;for(l=l.entanglements;p;){var x=31-ur(p),T=1<<x;T&u|l[x]&u&&(l[x]|=u),p&=~T}}function le(l){return l&=-l,2<l?8<l?l&134217727?32:268435456:8:2}function q(l){if(hr&&typeof hr.onCommitFiberRoot=="function")try{hr.onCommitFiberRoot(op,l,void 0,(l.current.flags&128)===128)}catch{}}function te(l){if(typeof fL=="function"&&dL(l),hr&&typeof hr.setStrictMode=="function")try{hr.setStrictMode(op,l)}catch{}}function ee(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}function de(l,u){if(typeof l=="object"&&l!==null){var p=eR.get(l);return p!==void 0?p:(u={value:l,source:u,stack:f(u)},eR.set(l,u),u)}return{value:l,source:u,stack:f(u)}}function ue(l,u){bh[Mh++]=fg,bh[Mh++]=hg,hg=l,fg=u}function Pe(l,u,p){Ur[Lr++]=fo,Ur[Lr++]=po,Ur[Lr++]=Ic,Ic=l;var x=fo;l=po;var T=32-ur(x)-1;x&=~(1<<T),p+=1;var R=32-ur(u)+T;if(30<R){var X=T-T%5;R=(x&(1<<X)-1).toString(32),x>>=X,T-=X,fo=1<<32-ur(u)+T|p<<T|x,po=R+l}else fo=1<<R|p<<T|x,po=l}function He(l){l.return!==null&&(ue(l,1),Pe(l,1,0))}function Ke(l){for(;l===hg;)hg=bh[--Mh],bh[Mh]=null,fg=bh[--Mh],bh[Mh]=null;for(;l===Ic;)Ic=Ur[--Lr],Ur[Lr]=null,po=Ur[--Lr],Ur[Lr]=null,fo=Ur[--Lr],Ur[Lr]=null}function nt(l,u){_(_l,u),_(lp,l),_(ua,null),l=Z9(u),v(ua),_(ua,l)}function xt(){v(ua),v(lp),v(_l)}function fe(l){l.memoizedState!==null&&_(dg,l);var u=ua.current,p=j9(u,l.type);u!==p&&(_(lp,l),_(ua,p))}function Be(l){lp.current===l&&(v(ua),v(lp)),dg.current===l&&(v(dg),ho?Oc._currentValue=Ah:Oc._currentValue2=Ah)}function Je(l){var u=Error(a(418,""));throw et(de(u,l)),pS}function ve(l,u){if(!Ir)throw Error(a(175));VU(l.stateNode,l.type,l.memoizedProps,u,l)||Je(l)}function at(l){for(wa=l.return;wa;)switch(wa.tag){case 3:case 27:Fs=!0;return;case 5:case 13:Fs=!1;return;default:wa=wa.return}}function ft(l){if(!Ir||l!==wa)return!1;if(!En)return at(l),En=!0,!1;var u=!1;if(ya?l.tag!==3&&l.tag!==27&&(l.tag!==5||kC(l.type)&&!og(l.type,l.memoizedProps))&&(u=!0):l.tag!==3&&(l.tag!==5||kC(l.type)&&!og(l.type,l.memoizedProps))&&(u=!0),u&&_a&&Je(l),at(l),l.tag===13){if(!Ir)throw Error(a(316));if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(a(317));_a=WU(l)}else _a=wa?GC(l.stateNode):null;return!0}function ht(){Ir&&(_a=wa=null,En=!1)}function et(l){ps===null?ps=[l]:ps.push(l)}function Re(){for(var l=Ch,u=mS=Ch=0;u<l;){var p=Pr[u];Pr[u++]=null;var x=Pr[u];Pr[u++]=null;var T=Pr[u];Pr[u++]=null;var R=Pr[u];if(Pr[u++]=null,x!==null&&T!==null){var X=x.pending;X===null?T.next=T:(T.next=X.next,X.next=T),x.pending=T}R!==0&&Qe(p,T,R)}}function Z(l,u,p,x){Pr[Ch++]=l,Pr[Ch++]=u,Pr[Ch++]=p,Pr[Ch++]=x,mS|=x,l.lanes|=x,l=l.alternate,l!==null&&(l.lanes|=x)}function Ue(l,u,p,x){return Z(l,u,p,x),Ye(l)}function ze(l,u){return Z(l,null,null,u),Ye(l)}function Qe(l,u,p){l.lanes|=p;var x=l.alternate;x!==null&&(x.lanes|=p);for(var T=!1,R=l.return;R!==null;)R.childLanes|=p,x=R.alternate,x!==null&&(x.childLanes|=p),R.tag===22&&(l=R.stateNode,l===null||l._visibility&1||(T=!0)),l=R,R=R.return;T&&u!==null&&l.tag===3&&(R=l.stateNode,T=31-ur(p),R=R.hiddenUpdates,l=R[T],l===null?R[T]=[u]:l.push(u),u.lane=p|536870912)}function Ye(l){if(50<vp)throw vp=0,NS=null,Error(a(185));for(var u=l.return;u!==null;)l=u,u=l.return;return l.tag===3?l.stateNode:null}function ot(l){l!==Rh&&l.next===null&&(Rh===null?pg=Rh=l:Rh=Rh.next=l),mg=!0,gS||(gS=!0,Ie(mt))}function rt(l,u){if(!vS&&mg){vS=!0;do for(var p=!1,x=pg;x!==null;){if(l!==0){var T=x.pendingLanes;if(T===0)var R=0;else{var X=x.suspendedLanes,re=x.pingedLanes;R=(1<<31-ur(42|l)+1)-1,R&=T&~(X&~re),R=R&201326677?R&201326677|1:R?R|2:0}R!==0&&(p=!0,pe(x,R))}else R=xn,R=O(x,x===Yn?R:0),!(R&3)||N(x,R)||(p=!0,pe(x,R));x=x.next}while(p);vS=!1}}function mt(){mg=gS=!1;var l=0;wh!==0&&(iU()&&(l=wh),wh=0);for(var u=ds(),p=null,x=pg;x!==null;){var T=x.next,R=j(x,u);R===0?(x.next=null,p===null?pg=T:p.next=T,T===null&&(Rh=p)):(p=x,(l!==0||R&3)&&(mg=!0)),x=T}rt(l)}function j(l,u){for(var p=l.suspendedLanes,x=l.pingedLanes,T=l.expirationTimes,R=l.pendingLanes&-62914561;0<R;){var X=31-ur(R),re=1<<X,ye=T[X];ye===-1?(!(re&p)||re&x)&&(T[X]=L(re,u)):ye<=u&&(l.expiredLanes|=re),R&=~re}if(u=Yn,p=xn,p=O(l,l===u?p:0),x=l.callbackNode,p===0||l===u&&qn===2||l.cancelPendingCommit!==null)return x!==null&&x!==null&&fS(x),l.callbackNode=null,l.callbackPriority=0;if(!(p&3)||N(l,p)){if(u=p&-p,u===l.callbackPriority)return u;switch(x!==null&&fS(x),le(p)){case 2:case 8:p=uL;break;case 32:p=dS;break;case 268435456:p=hL;break;default:p=dS}return x=P.bind(null,l),p=ug(p,x),l.callbackPriority=u,l.callbackNode=p,u}return x!==null&&x!==null&&fS(x),l.callbackPriority=2,l.callbackNode=null,2}function P(l,u){var p=l.callbackNode;if(wc()&&l.callbackNode!==p)return null;var x=xn;return x=O(l,l===Yn?x:0),x===0?null:(iC(l,x,u),j(l,ds()),l.callbackNode!=null&&l.callbackNode===p?P.bind(null,l):null)}function pe(l,u){if(wc())return null;iC(l,u,!0)}function Ie(l){cU?uU(function(){Fn&6?ug($C,l):l()}):ug($C,l)}function Ge(){return wh===0&&(wh=B()),wh}function we(l,u){if(cp===null){var p=cp=[];xS=0,Dh=Ge(),Nh={status:"pending",value:void 0,then:function(x){p.push(x)}}}return xS++,u.then(Tt,Tt),u}function Tt(){if(--xS===0&&cp!==null){Nh!==null&&(Nh.status="fulfilled");var l=cp;cp=null,Dh=0,Nh=null;for(var u=0;u<l.length;u++)(0,l[u])()}}function ut(l,u){var p=[],x={status:"pending",value:null,reason:null,then:function(T){p.push(T)}};return l.then(function(){x.status="fulfilled",x.value=u;for(var T=0;T<p.length;T++)(0,p[T])(u)},function(T){for(x.status="rejected",x.reason=T,T=0;T<p.length;T++)(0,p[T])(void 0)}),x}function wt(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bt(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function ke(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function Ve(l,u,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,Fn&2){var T=x.pending;return T===null?u.next=u:(u.next=T.next,T.next=u),x.pending=u,u=Ye(l),Qe(l,null,p),u}return Z(l,x,u,p),Ye(l)}function St(l,u,p){if(u=u.updateQueue,u!==null&&(u=u.shared,(p&4194176)!==0)){var x=u.lanes;x&=l.pendingLanes,p|=x,u.lanes=p,se(l,p)}}function ne(l,u){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var T=null,R=null;if(p=p.firstBaseUpdate,p!==null){do{var X={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};R===null?T=R=X:R=R.next=X,p=p.next}while(p!==null);R===null?T=R=u:R=R.next=u}else T=R=u;p={baseState:x.baseState,firstBaseUpdate:T,lastBaseUpdate:R,shared:x.shared,callbacks:x.callbacks},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=u}function me(){if(yS){var l=Nh;if(l!==null)throw l}}function Le(l,u,p,x){yS=!1;var T=l.updateQueue;Sl=!1;var R=T.firstBaseUpdate,X=T.lastBaseUpdate,re=T.shared.pending;if(re!==null){T.shared.pending=null;var ye=re,Xe=ye.next;ye.next=null,X===null?R=Xe:X.next=Xe,X=ye;var ct=l.alternate;ct!==null&&(ct=ct.updateQueue,re=ct.lastBaseUpdate,re!==X&&(re===null?ct.firstBaseUpdate=Xe:re.next=Xe,ct.lastBaseUpdate=ye))}if(R!==null){var At=T.baseState;X=0,ct=Xe=ye=null,re=R;do{var Mt=re.lane&-536870913,Kt=Mt!==re.lane;if(Kt?(xn&Mt)===Mt:(x&Mt)===Mt){Mt!==0&&Mt===Dh&&(yS=!0),ct!==null&&(ct=ct.next={lane:0,tag:re.tag,payload:re.payload,callback:null,next:null});e:{var zr=l,xp=re;Mt=u;var Vc=p;switch(xp.tag){case 1:if(zr=xp.payload,typeof zr=="function"){At=zr.call(Vc,At,Mt);break e}At=zr;break e;case 3:zr.flags=zr.flags&-65537|128;case 0:if(zr=xp.payload,Mt=typeof zr=="function"?zr.call(Vc,At,Mt):zr,Mt==null)break e;At=Q_({},At,Mt);break e;case 2:Sl=!0}}Mt=re.callback,Mt!==null&&(l.flags|=64,Kt&&(l.flags|=8192),Kt=T.callbacks,Kt===null?T.callbacks=[Mt]:Kt.push(Mt))}else Kt={lane:Mt,tag:re.tag,payload:re.payload,callback:re.callback,next:null},ct===null?(Xe=ct=Kt,ye=At):ct=ct.next=Kt,X|=Mt;if(re=re.next,re===null){if(re=T.shared.pending,re===null)break;Kt=re,re=Kt.next,Kt.next=null,T.lastBaseUpdate=Kt,T.shared.pending=null}}while(!0);ct===null&&(ye=At),T.baseState=ye,T.firstBaseUpdate=Xe,T.lastBaseUpdate=ct,R===null&&(T.shared.lanes=0),Tl|=X,l.lanes=X,l.memoizedState=At}}function K(l,u){if(typeof l!="function")throw Error(a(191,l));l.call(u)}function Se(l,u){var p=l.callbacks;if(p!==null)for(l.callbacks=null,l=0;l<p.length;l++)K(p[l],u)}function _e(l,u){if(fr(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var p=Object.keys(l),x=Object.keys(u);if(p.length!==x.length)return!1;for(x=0;x<p.length;x++){var T=p[x];if(!pL.call(u,T)||!fr(l[T],u[T]))return!1}return!0}function it(l){return l=l.status,l==="fulfilled"||l==="rejected"}function tt(){}function We(l,u,p){switch(p=l[p],p===void 0?l.push(u):p!==u&&(u.then(tt,tt),u=p),u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,l===up?Error(a(483)):l;default:if(typeof u.status=="string")u.then(tt,tt);else{if(l=Yn,l!==null&&100<l.shellSuspendCounter)throw Error(a(482));l=u,l.status="pending",l.then(function(x){if(u.status==="pending"){var T=u;T.status="fulfilled",T.value=x}},function(x){if(u.status==="pending"){var T=u;T.status="rejected",T.reason=x}})}switch(u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,l===up?Error(a(483)):l}throw Oh=u,up}}function gt(){if(Oh===null)throw Error(a(459));var l=Oh;return Oh=null,l}function Nt(l){var u=hp;return hp+=1,Ih===null&&(Ih=[]),We(Ih,l,u)}function $t(l,u){u=u.props.ref,l.ref=u!==void 0?u:null}function jt(l,u){throw u.$$typeof===V9?Error(a(525)):(l=Object.prototype.toString.call(u),Error(a(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l)))}function hi(l){var u=l._init;return u(l._payload)}function fi(l){function u(be,ge){if(l){var Ce=be.deletions;Ce===null?(be.deletions=[ge],be.flags|=16):Ce.push(ge)}}function p(be,ge){if(!l)return null;for(;ge!==null;)u(be,ge),ge=ge.sibling;return null}function x(be){for(var ge=new Map;be!==null;)be.key!==null?ge.set(be.key,be):ge.set(be.index,be),be=be.sibling;return ge}function T(be,ge){return be=gl(be,ge),be.index=0,be.sibling=null,be}function R(be,ge,Ce){return be.index=Ce,l?(Ce=be.alternate,Ce!==null?(Ce=Ce.index,Ce<ge?(be.flags|=33554434,ge):Ce):(be.flags|=33554434,ge)):(be.flags|=1048576,ge)}function X(be){return l&&be.alternate===null&&(be.flags|=33554434),be}function re(be,ge,Ce,st){return ge===null||ge.tag!==6?(ge=j_(Ce,be.mode,st),ge.return=be,ge):(ge=T(ge,Ce),ge.return=be,ge)}function ye(be,ge,Ce,st){var Pt=Ce.type;return Pt===Sh?ct(be,ge,Ce.props.children,st,Ce.key):ge!==null&&(ge.elementType===Pt||typeof Pt=="object"&&Pt!==null&&Pt.$$typeof===xl&&hi(Pt)===ge.type)?(ge=T(ge,Ce.props),$t(ge,Ce),ge.return=be,ge):(ge=ag(Ce.type,Ce.key,Ce.props,null,be.mode,st),$t(ge,Ce),ge.return=be,ge)}function Xe(be,ge,Ce,st){return ge===null||ge.tag!==4||ge.stateNode.containerInfo!==Ce.containerInfo||ge.stateNode.implementation!==Ce.implementation?(ge=K_(Ce,be.mode,st),ge.return=be,ge):(ge=T(ge,Ce.children||[]),ge.return=be,ge)}function ct(be,ge,Ce,st,Pt){return ge===null||ge.tag!==7?(ge=Dc(Ce,be.mode,st,Pt),ge.return=be,ge):(ge=T(ge,Ce),ge.return=be,ge)}function At(be,ge,Ce){if(typeof ge=="string"&&ge!==""||typeof ge=="number"||typeof ge=="bigint")return ge=j_(""+ge,be.mode,Ce),ge.return=be,ge;if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case rg:return Ce=ag(ge.type,ge.key,ge.props,null,be.mode,Ce),$t(Ce,ge),Ce.return=be,Ce;case _h:return ge=K_(ge,be.mode,Ce),ge.return=be,ge;case xl:var st=ge._init;return ge=st(ge._payload),At(be,ge,Ce)}if(sg(ge)||r(ge))return ge=Dc(ge,be.mode,Ce,null),ge.return=be,ge;if(typeof ge.then=="function")return At(be,Nt(ge),Ce);if(ge.$$typeof===vl)return At(be,Q0(be,ge),Ce);jt(be,ge)}return null}function Mt(be,ge,Ce,st){var Pt=ge!==null?ge.key:null;if(typeof Ce=="string"&&Ce!==""||typeof Ce=="number"||typeof Ce=="bigint")return Pt!==null?null:re(be,ge,""+Ce,st);if(typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case rg:return Ce.key===Pt?ye(be,ge,Ce,st):null;case _h:return Ce.key===Pt?Xe(be,ge,Ce,st):null;case xl:return Pt=Ce._init,Ce=Pt(Ce._payload),Mt(be,ge,Ce,st)}if(sg(Ce)||r(Ce))return Pt!==null?null:ct(be,ge,Ce,st,null);if(typeof Ce.then=="function")return Mt(be,ge,Nt(Ce),st);if(Ce.$$typeof===vl)return Mt(be,ge,Q0(be,Ce),st);jt(be,Ce)}return null}function Kt(be,ge,Ce,st,Pt){if(typeof st=="string"&&st!==""||typeof st=="number"||typeof st=="bigint")return be=be.get(Ce)||null,re(ge,be,""+st,Pt);if(typeof st=="object"&&st!==null){switch(st.$$typeof){case rg:return be=be.get(st.key===null?Ce:st.key)||null,ye(ge,be,st,Pt);case _h:return be=be.get(st.key===null?Ce:st.key)||null,Xe(ge,be,st,Pt);case xl:var ti=st._init;return st=ti(st._payload),Kt(be,ge,Ce,st,Pt)}if(sg(st)||r(st))return be=be.get(Ce)||null,ct(ge,be,st,Pt,null);if(typeof st.then=="function")return Kt(be,ge,Ce,Nt(st),Pt);if(st.$$typeof===vl)return Kt(be,ge,Ce,Q0(ge,st),Pt);jt(ge,st)}return null}function zr(be,ge,Ce,st){for(var Pt=null,ti=null,Wt=ge,Tn=ge=0,Qi=null;Wt!==null&&Tn<Ce.length;Tn++){Wt.index>Tn?(Qi=Wt,Wt=null):Qi=Wt.sibling;var bn=Mt(be,Wt,Ce[Tn],st);if(bn===null){Wt===null&&(Wt=Qi);break}l&&Wt&&bn.alternate===null&&u(be,Wt),ge=R(bn,ge,Tn),ti===null?Pt=bn:ti.sibling=bn,ti=bn,Wt=Qi}if(Tn===Ce.length)return p(be,Wt),En&&ue(be,Tn),Pt;if(Wt===null){for(;Tn<Ce.length;Tn++)Wt=At(be,Ce[Tn],st),Wt!==null&&(ge=R(Wt,ge,Tn),ti===null?Pt=Wt:ti.sibling=Wt,ti=Wt);return En&&ue(be,Tn),Pt}for(Wt=x(Wt);Tn<Ce.length;Tn++)Qi=Kt(Wt,be,Tn,Ce[Tn],st),Qi!==null&&(l&&Qi.alternate!==null&&Wt.delete(Qi.key===null?Tn:Qi.key),ge=R(Qi,ge,Tn),ti===null?Pt=Qi:ti.sibling=Qi,ti=Qi);return l&&Wt.forEach(function(Ml){return u(be,Ml)}),En&&ue(be,Tn),Pt}function xp(be,ge,Ce,st){if(Ce==null)throw Error(a(151));for(var Pt=null,ti=null,Wt=ge,Tn=ge=0,Qi=null,bn=Ce.next();Wt!==null&&!bn.done;Tn++,bn=Ce.next()){Wt.index>Tn?(Qi=Wt,Wt=null):Qi=Wt.sibling;var Ml=Mt(be,Wt,bn.value,st);if(Ml===null){Wt===null&&(Wt=Qi);break}l&&Wt&&Ml.alternate===null&&u(be,Wt),ge=R(Ml,ge,Tn),ti===null?Pt=Ml:ti.sibling=Ml,ti=Ml,Wt=Qi}if(bn.done)return p(be,Wt),En&&ue(be,Tn),Pt;if(Wt===null){for(;!bn.done;Tn++,bn=Ce.next())bn=At(be,bn.value,st),bn!==null&&(ge=R(bn,ge,Tn),ti===null?Pt=bn:ti.sibling=bn,ti=bn);return En&&ue(be,Tn),Pt}for(Wt=x(Wt);!bn.done;Tn++,bn=Ce.next())bn=Kt(Wt,be,Tn,bn.value,st),bn!==null&&(l&&bn.alternate!==null&&Wt.delete(bn.key===null?Tn:bn.key),ge=R(bn,ge,Tn),ti===null?Pt=bn:ti.sibling=bn,ti=bn);return l&&Wt.forEach(function(SL){return u(be,SL)}),En&&ue(be,Tn),Pt}function Vc(be,ge,Ce,st){if(typeof Ce=="object"&&Ce!==null&&Ce.type===Sh&&Ce.key===null&&(Ce=Ce.props.children),typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case rg:e:{for(var Pt=Ce.key;ge!==null;){if(ge.key===Pt){if(Pt=Ce.type,Pt===Sh){if(ge.tag===7){p(be,ge.sibling),st=T(ge,Ce.props.children),st.return=be,be=st;break e}}else if(ge.elementType===Pt||typeof Pt=="object"&&Pt!==null&&Pt.$$typeof===xl&&hi(Pt)===ge.type){p(be,ge.sibling),st=T(ge,Ce.props),$t(st,Ce),st.return=be,be=st;break e}p(be,ge);break}else u(be,ge);ge=ge.sibling}Ce.type===Sh?(st=Dc(Ce.props.children,be.mode,st,Ce.key),st.return=be,be=st):(st=ag(Ce.type,Ce.key,Ce.props,null,be.mode,st),$t(st,Ce),st.return=be,be=st)}return X(be);case _h:e:{for(Pt=Ce.key;ge!==null;){if(ge.key===Pt)if(ge.tag===4&&ge.stateNode.containerInfo===Ce.containerInfo&&ge.stateNode.implementation===Ce.implementation){p(be,ge.sibling),st=T(ge,Ce.children||[]),st.return=be,be=st;break e}else{p(be,ge);break}else u(be,ge);ge=ge.sibling}st=K_(Ce,be.mode,st),st.return=be,be=st}return X(be);case xl:return Pt=Ce._init,Ce=Pt(Ce._payload),Vc(be,ge,Ce,st)}if(sg(Ce))return zr(be,ge,Ce,st);if(r(Ce)){if(Pt=r(Ce),typeof Pt!="function")throw Error(a(150));return Ce=Pt.call(Ce),xp(be,ge,Ce,st)}if(typeof Ce.then=="function")return Vc(be,ge,Nt(Ce),st);if(Ce.$$typeof===vl)return Vc(be,ge,Q0(be,Ce),st);jt(be,Ce)}return typeof Ce=="string"&&Ce!==""||typeof Ce=="number"||typeof Ce=="bigint"?(Ce=""+Ce,ge!==null&&ge.tag===6?(p(be,ge.sibling),st=T(ge,Ce),st.return=be,be=st):(p(be,ge),st=j_(Ce,be.mode,st),st.return=be,be=st),X(be)):p(be,ge)}return function(be,ge,Ce,st){try{hp=0;var Pt=Vc(be,ge,Ce,st);return Ih=null,Pt}catch(Wt){if(Wt===up)throw Wt;var ti=t(29,Wt,null,be.mode);return ti.lanes=st,ti.return=be,ti}finally{}}}function hl(l,u){l=xo,_(vg,l),_(Bh,u),xo=l|u.baseLanes}function Ps(){_(vg,xo),_(Bh,Bh.current)}function ar(){xo=vg.current,v(Bh),v(vg)}function Ni(l){var u=l.alternate;_(Gi,Gi.current&1),_(Fr,l),Hs===null&&(u===null||Bh.current!==null||u.memoizedState!==null)&&(Hs=l)}function Va(l){if(l.tag===22){if(_(Gi,Gi.current),_(Fr,l),Hs===null){var u=l.alternate;u!==null&&u.memoizedState!==null&&(Hs=l)}}else Oi()}function Oi(){_(Gi,Gi.current),_(Fr,Fr.current)}function zt(l){v(Fr),Hs===l&&(Hs=null),v(Gi)}function ka(l){for(var u=l;u!==null;){if(u.tag===13){var p=u.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||lS(p)||cS(p)))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===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}function Ln(){throw Error(a(321))}function U(l,u){if(u===null)return!1;for(var p=0;p<u.length&&p<l.length;p++)if(!fr(l[p],u[p]))return!1;return!0}function W(l,u,p,x,T,R){return Al=R,rn=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,Zt.H=l===null||l.memoizedState===null?Lc:El,Uc=!1,R=p(x,T),Uc=!1,Uh&&(R=Te(u,p,x,T)),oe(l),R}function oe(l){Zt.H=zs;var u=Pn!==null&&Pn.next!==null;if(Al=0,Ii=Pn=rn=null,xg=!1,fp=0,Lh=null,u)throw Error(a(300));l===null||Ki||(l=l.dependencies,l!==null&&J0(l)&&(Ki=!0))}function Te(l,u,p,x){rn=l;var T=0;do{if(Uh&&(Lh=null),fp=0,Uh=!1,25<=T)throw Error(a(301));if(T+=1,Ii=Pn=null,l.updateQueue!=null){var R=l.updateQueue;R.lastEffect=null,R.events=null,R.stores=null,R.memoCache!=null&&(R.memoCache.index=0)}Zt.H=Pc,R=u(p,x)}while(Uh);return R}function De(){var l=Zt.H,u=l.useState()[0];return u=typeof u.then=="function"?F(u):u,l=l.useState()[0],(Pn!==null?Pn.memoizedState:null)!==l&&(rn.flags|=1024),u}function Me(){var l=yg!==0;return yg=0,l}function M(l,u,p){u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~p}function I(l){if(xg){for(l=l.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}xg=!1}Al=0,Ii=Pn=rn=null,Uh=!1,fp=yg=0,Lh=null}function V(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ii===null?rn.memoizedState=Ii=l:Ii=Ii.next=l,Ii}function C(){if(Pn===null){var l=rn.alternate;l=l!==null?l.memoizedState:null}else l=Pn.next;var u=Ii===null?rn.memoizedState:Ii.next;if(u!==null)Ii=u,Pn=l;else{if(l===null)throw rn.alternate===null?Error(a(467)):Error(a(310));Pn=l,l={memoizedState:Pn.memoizedState,baseState:Pn.baseState,baseQueue:Pn.baseQueue,queue:Pn.queue,next:null},Ii===null?rn.memoizedState=Ii=l:Ii=Ii.next=l}return Ii}function F(l){var u=fp;return fp+=1,Lh===null&&(Lh=[]),l=We(Lh,l,u),u=rn,(Ii===null?u.memoizedState:Ii.next)===null&&(u=u.alternate,Zt.H=u===null||u.memoizedState===null?Lc:El),l}function Y(l){if(l!==null&&typeof l=="object"){if(typeof l.then=="function")return F(l);if(l.$$typeof===vl)return va(l)}throw Error(a(438,String(l)))}function z(l){var u=null,p=rn.updateQueue;if(p!==null&&(u=p.memoCache),u==null){var x=rn.alternate;x!==null&&(x=x.updateQueue,x!==null&&(x=x.memoCache,x!=null&&(u={data:x.data.map(function(T){return T.slice()}),index:0})))}if(u==null&&(u={data:[],index:0}),p===null&&(p=SS(),rn.updateQueue=p),p.memoCache=u,p=u.data[u.index],p===void 0)for(p=u.data[u.index]=Array(l),x=0;x<l;x++)p[x]=X9;return u.index++,p}function k(l,u){return typeof u=="function"?u(l):u}function Q(l){var u=C();return ae(u,Pn,l)}function ae(l,u,p){var x=l.queue;if(x===null)throw Error(a(311));x.lastRenderedReducer=p;var T=l.baseQueue,R=x.pending;if(R!==null){if(T!==null){var X=T.next;T.next=R.next,R.next=X}u.baseQueue=T=R,x.pending=null}if(R=l.baseState,T===null)l.memoizedState=R;else{u=T.next;var re=X=null,ye=null,Xe=u,ct=!1;do{var At=Xe.lane&-536870913;if(At!==Xe.lane?(xn&At)===At:(Al&At)===At){var Mt=Xe.revertLane;if(Mt===0)ye!==null&&(ye=ye.next={lane:0,revertLane:0,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null}),At===Dh&&(ct=!0);else if((Al&Mt)===Mt){Xe=Xe.next,Mt===Dh&&(ct=!0);continue}else At={lane:0,revertLane:Xe.revertLane,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null},ye===null?(re=ye=At,X=R):ye=ye.next=At,rn.lanes|=Mt,Tl|=Mt;At=Xe.action,Uc&&p(R,At),R=Xe.hasEagerState?Xe.eagerState:p(R,At)}else Mt={lane:At,revertLane:Xe.revertLane,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null},ye===null?(re=ye=Mt,X=R):ye=ye.next=Mt,rn.lanes|=At,Tl|=At;Xe=Xe.next}while(Xe!==null&&Xe!==u);if(ye===null?X=R:ye.next=re,!fr(R,l.memoizedState)&&(Ki=!0,ct&&(p=Nh,p!==null)))throw p;l.memoizedState=R,l.baseState=X,l.baseQueue=ye,x.lastRenderedState=R}return T===null&&(x.lanes=0),[l.memoizedState,x.dispatch]}function ce(l){var u=C(),p=u.queue;if(p===null)throw Error(a(311));p.lastRenderedReducer=l;var x=p.dispatch,T=p.pending,R=u.memoizedState;if(T!==null){p.pending=null;var X=T=T.next;do R=l(R,X.action),X=X.next;while(X!==T);fr(R,u.memoizedState)||(Ki=!0),u.memoizedState=R,u.baseQueue===null&&(u.baseState=R),p.lastRenderedState=R}return[R,x]}function xe(l,u,p){var x=rn,T=C(),R=En;if(R){if(p===void 0)throw Error(a(407));p=p()}else p=u();var X=!fr((Pn||T).memoizedState,p);if(X&&(T.memoizedState=p,Ki=!0),T=T.queue,h_(Fe.bind(null,x,T,l),[l]),T.getSnapshot!==u||X||Ii!==null&&Ii.memoizedState.tag&1){if(x.flags|=2048,Wn(9,Ne.bind(null,x,T,p,u),{destroy:void 0},null),Yn===null)throw Error(a(349));R||Al&60||Ae(x,u,p)}return p}function Ae(l,u,p){l.flags|=16384,l={getSnapshot:u,value:p},u=rn.updateQueue,u===null?(u=SS(),rn.updateQueue=u,u.stores=[l]):(p=u.stores,p===null?u.stores=[l]:p.push(l))}function Ne(l,u,p,x){u.value=p,u.getSnapshot=x,Oe(u)&&Ze(l)}function Fe(l,u,p){return p(function(){Oe(u)&&Ze(l)})}function Oe(l){var u=l.getSnapshot;l=l.value;try{var p=u();return!fr(l,p)}catch{return!0}}function Ze(l){var u=ze(l,2);u!==null&&Ra(u,l,2)}function $e(l){var u=V();if(typeof l=="function"){var p=l;if(l=p(),Uc){te(!0);try{p()}finally{te(!1)}}}return u.memoizedState=u.baseState=l,u.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:k,lastRenderedState:l},u}function vt(l,u,p,x){return l.baseState=p,ae(l,Pn,typeof x=="function"?x:k)}function Rt(l,u,p,x,T){if(j0(l))throw Error(a(485));if(l=u.action,l!==null){var R={payload:T,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(X){R.listeners.push(X)}};Zt.T!==null?p(!0):R.isTransition=!1,x(R),p=u.pending,p===null?(R.next=u.pending=R,pt(u,R)):(R.next=p.next,u.pending=p.next=R)}}function pt(l,u){var p=u.action,x=u.payload,T=l.state;if(u.isTransition){var R=Zt.T,X={};Zt.T=X;try{var re=p(T,x),ye=Zt.S;ye!==null&&ye(X,re),Ct(l,u,re)}catch(Xe){Ut(l,u,Xe)}finally{Zt.T=R}}else try{R=p(T,x),Ct(l,u,R)}catch(Xe){Ut(l,u,Xe)}}function Ct(l,u,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(x){je(l,u,x)},function(x){return Ut(l,u,x)}):je(l,u,p)}function je(l,u,p){u.status="fulfilled",u.value=p,Ft(u),l.state=p,u=l.pending,u!==null&&(p=u.next,p===u?l.pending=null:(p=p.next,u.next=p,pt(l,p)))}function Ut(l,u,p){var x=l.pending;if(l.pending=null,x!==null){x=x.next;do u.status="rejected",u.reason=p,Ft(u),u=u.next;while(u!==x)}l.action=null}function Ft(l){l=l.listeners;for(var u=0;u<l.length;u++)(0,l[u])()}function Et(l,u){return u}function Lt(l,u){if(En){var p=Yn.formState;if(p!==null){e:{var x=rn;if(En){if(_a){var T=UU(_a,Fs);if(T){_a=GC(T),x=LU(T);break e}}Je(x)}x=!1}x&&(u=p[0])}}p=V(),p.memoizedState=p.baseState=u,x={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Et,lastRenderedState:u},p.queue=x,p=fM.bind(null,rn,x),x.dispatch=p,x=$e(!1);var R=m_.bind(null,rn,!1,x.queue);return x=V(),T={state:u,dispatch:null,action:l,pending:null},x.queue=T,p=Rt.bind(null,rn,T,R,p),T.dispatch=p,x.memoizedState=l,[u,p,!1]}function Ot(l){var u=C();return en(u,Pn,l)}function en(l,u,p){u=ae(l,u,Et)[0],l=Q(k)[0],u=typeof u=="object"&&u!==null&&typeof u.then=="function"?F(u):u;var x=C(),T=x.queue,R=T.dispatch;return p!==x.memoizedState&&(rn.flags|=2048,Wn(9,Nn.bind(null,T,p),{destroy:void 0},null)),[u,R,l]}function Nn(l,u){l.action=u}function On(l){var u=C(),p=Pn;if(p!==null)return en(u,p,l);C(),u=u.memoizedState,p=C();var x=p.queue.dispatch;return p.memoizedState=l,[u,x,!1]}function Wn(l,u,p,x){return l={tag:l,create:u,inst:p,deps:x,next:null},u=rn.updateQueue,u===null&&(u=SS(),rn.updateQueue=u),p=u.lastEffect,p===null?u.lastEffect=l.next=l:(x=p.next,p.next=l,l.next=x,u.lastEffect=l),l}function mh(){return C().memoizedState}function Or(l,u,p,x){var T=V();rn.flags|=l,T.memoizedState=Wn(1|u,p,{destroy:void 0},x===void 0?null:x)}function Z0(l,u,p,x){var T=C();x=x===void 0?null:x;var R=T.memoizedState.inst;Pn!==null&&x!==null&&U(x,Pn.memoizedState.deps)?T.memoizedState=Wn(u,p,R,x):(rn.flags|=l,T.memoizedState=Wn(1|u,p,R,x))}function eM(l,u){Or(8390656,8,l,u)}function h_(l,u){Z0(2048,8,l,u)}function tM(l,u){return Z0(4,2,l,u)}function nM(l,u){return Z0(4,4,l,u)}function iM(l,u){if(typeof u=="function"){l=l();var p=u(l);return function(){typeof p=="function"?p():u(null)}}if(u!=null)return l=l(),u.current=l,function(){u.current=null}}function aM(l,u,p){p=p!=null?p.concat([l]):null,Z0(4,4,iM.bind(null,u,l),p)}function f_(){}function rM(l,u){var p=C();u=u===void 0?null:u;var x=p.memoizedState;return u!==null&&U(u,x[1])?x[0]:(p.memoizedState=[l,u],l)}function sM(l,u){var p=C();u=u===void 0?null:u;var x=p.memoizedState;if(u!==null&&U(u,x[1]))return x[0];if(x=l(),Uc){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[x,u],x}function d_(l,u,p){return p===void 0||Al&1073741824?l.memoizedState=u:(l.memoizedState=p,l=nC(),rn.lanes|=l,Tl|=l,p)}function oM(l,u,p,x){return fr(p,u)?p:Bh.current!==null?(l=d_(l,p,x),fr(l,u)||(Ki=!0),l):Al&42?(l=nC(),rn.lanes|=l,Tl|=l,u):(Ki=!0,l.memoizedState=p)}function lM(l,u,p,x,T){var R=Nc();Wa(R!==0&&8>R?R:8);var X=Zt.T,re={};Zt.T=re,m_(l,!1,u,p);try{var ye=T(),Xe=Zt.S;if(Xe!==null&&Xe(re,ye),ye!==null&&typeof ye=="object"&&typeof ye.then=="function"){var ct=ut(ye,x);Kd(l,u,ct,lr(l))}else Kd(l,u,x,lr(l))}catch(At){Kd(l,u,{then:function(){},status:"rejected",reason:At},lr())}finally{Wa(R),Zt.T=X}}function cM(l){var u=l.memoizedState;if(u!==null)return u;u={memoizedState:Ah,baseState:Ah,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:k,lastRenderedState:Ah},next:null};var p={};return u.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:k,lastRenderedState:p},next:null},l.memoizedState=u,l=l.alternate,l!==null&&(l.memoizedState=u),u}function p_(){return va(Oc)}function uM(){return C().memoizedState}function hM(){return C().memoizedState}function A9(l){for(var u=l.return;u!==null;){switch(u.tag){case 24:case 3:var p=lr();l=ke(p);var x=Ve(u,l,p);x!==null&&(Ra(x,u,p),St(x,u,p)),u={cache:R_()},l.payload=u;return}u=u.return}}function E9(l,u,p){var x=lr();p={lane:x,revertLane:0,action:p,hasEagerState:!1,eagerState:null,next:null},j0(l)?dM(u,p):(p=Ue(l,u,p,x),p!==null&&(Ra(p,l,x),pM(p,u,x)))}function fM(l,u,p){var x=lr();Kd(l,u,p,x)}function Kd(l,u,p,x){var T={lane:x,revertLane:0,action:p,hasEagerState:!1,eagerState:null,next:null};if(j0(l))dM(u,T);else{var R=l.alternate;if(l.lanes===0&&(R===null||R.lanes===0)&&(R=u.lastRenderedReducer,R!==null))try{var X=u.lastRenderedState,re=R(X,p);if(T.hasEagerState=!0,T.eagerState=re,fr(re,X))return Z(l,u,T,0),Yn===null&&Re(),!1}catch{}finally{}if(p=Ue(l,u,T,x),p!==null)return Ra(p,l,x),pM(p,u,x),!0}return!1}function m_(l,u,p,x){if(x={lane:2,revertLane:Ge(),action:x,hasEagerState:!1,eagerState:null,next:null},j0(l)){if(u)throw Error(a(479))}else u=Ue(l,p,x,2),u!==null&&Ra(u,l,2)}function j0(l){var u=l.alternate;return l===rn||u!==null&&u===rn}function dM(l,u){Uh=xg=!0;var p=l.pending;p===null?u.next=u:(u.next=p.next,p.next=u),l.pending=u}function pM(l,u,p){if(p&4194176){var x=u.lanes;x&=l.pendingLanes,p|=x,u.lanes=p,se(l,p)}}function g_(l,u,p,x){u=l.memoizedState,p=p(x,u),p=p==null?u:Q_({},u,p),l.memoizedState=p,l.lanes===0&&(l.updateQueue.baseState=p)}function mM(l,u,p,x,T,R,X){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(x,R,X):u.prototype&&u.prototype.isPureReactComponent?!_e(p,x)||!_e(T,R):!0}function gM(l,u,p,x){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(p,x),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(p,x),u.state!==l&&AS.enqueueReplaceState(u,u.state,null)}function bc(l,u){var p=u;if("ref"in u){p={};for(var x in u)x!=="ref"&&(p[x]=u[x])}if(l=l.defaultProps){p===u&&(p=Q_({},p));for(var T in l)p[T]===void 0&&(p[T]=l[T])}return p}function K0(l,u){try{var p=l.onUncaughtError;p(u.value,{componentStack:u.stack})}catch(x){setTimeout(function(){throw x})}}function vM(l,u,p){try{var x=l.onCaughtError;x(p.value,{componentStack:p.stack,errorBoundary:u.tag===1?u.stateNode:null})}catch(T){setTimeout(function(){throw T})}}function v_(l,u,p){return p=ke(p),p.tag=3,p.payload={element:null},p.callback=function(){K0(l,u)},p}function xM(l){return l=ke(l),l.tag=3,l}function yM(l,u,p,x){var T=p.type.getDerivedStateFromError;if(typeof T=="function"){var R=x.value;l.payload=function(){return T(R)},l.callback=function(){vM(u,p,x)}}var X=p.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(l.callback=function(){vM(u,p,x),typeof T!="function"&&(bl===null?bl=new Set([this]):bl.add(this));var re=x.stack;this.componentDidCatch(x.value,{componentStack:re!==null?re:""})})}function T9(l,u,p,x,T){if(p.flags|=32768,x!==null&&typeof x=="object"&&typeof x.then=="function"){if(u=p.alternate,u!==null&&Qd(u,p,T,!0),p=Fr.current,p!==null){switch(p.tag){case 13:return Hs===null?W_():p.alternate===null&&Ai===0&&(Ai=3),p.flags&=-257,p.flags|=65536,p.lanes=T,x===gg?p.flags|=16384:(u=p.updateQueue,u===null?p.updateQueue=new Set([x]):u.add(x),q_(l,x,T)),!1;case 22:return p.flags|=65536,x===gg?p.flags|=16384:(u=p.updateQueue,u===null?(u={transitions:null,markerInstances:null,retryQueue:new Set([x])},p.updateQueue=u):(p=u.retryQueue,p===null?u.retryQueue=new Set([x]):p.add(x)),q_(l,x,T)),!1}throw Error(a(435,p.tag))}return q_(l,x,T),W_(),!1}if(En)return u=Fr.current,u!==null?(!(u.flags&65536)&&(u.flags|=256),u.flags|=65536,u.lanes=T,x!==pS&&(l=Error(a(422),{cause:x}),et(de(l,p)))):(x!==pS&&(u=Error(a(423),{cause:x}),et(de(u,p))),l=l.current.alternate,l.flags|=65536,T&=-T,l.lanes|=T,x=de(x,p),T=v_(l.stateNode,x,T),ne(l,T),Ai!==4&&(Ai=2)),!1;var R=Error(a(520),{cause:x});if(R=de(R,p),pp===null?pp=[R]:pp.push(R),Ai!==4&&(Ai=2),u===null)return!0;x=de(x,p),p=u;do{switch(p.tag){case 3:return p.flags|=65536,l=T&-T,p.lanes|=l,l=v_(p.stateNode,x,l),ne(p,l),!1;case 1:if(u=p.type,R=p.stateNode,(p.flags&128)===0&&(typeof u.getDerivedStateFromError=="function"||R!==null&&typeof R.componentDidCatch=="function"&&(bl===null||!bl.has(R))))return p.flags|=65536,T&=-T,p.lanes|=T,T=xM(T),yM(T,l,p,x),ne(p,T),!1}p=p.return}while(p!==null);return!1}function ca(l,u,p,x){u.child=l===null?tR(u,null,p,x):Bc(u,l.child,p,x)}function _M(l,u,p,x,T){p=p.render;var R=u.ref;if("ref"in x){var X={};for(var re in x)re!=="ref"&&(X[re]=x[re])}else X=x;return Mc(u),x=W(l,u,p,X,R,T),re=Me(),l!==null&&!Ki?(M(l,u,T),oo(l,u,T)):(En&&re&&He(u),u.flags|=1,ca(l,u,x,T),u.child)}function SM(l,u,p,x,T){if(l===null){var R=p.type;return typeof R=="function"&&!Z_(R)&&R.defaultProps===void 0&&p.compare===null?(u.tag=15,u.type=R,AM(l,u,R,x,T)):(l=ag(p.type,null,x,u,u.mode,T),l.ref=u.ref,l.return=u,u.child=l)}if(R=l.child,!b_(l,T)){var X=R.memoizedProps;if(p=p.compare,p=p!==null?p:_e,p(X,x)&&l.ref===u.ref)return oo(l,u,T)}return u.flags|=1,l=gl(R,x),l.ref=u.ref,l.return=u,u.child=l}function AM(l,u,p,x,T){if(l!==null){var R=l.memoizedProps;if(_e(R,x)&&l.ref===u.ref)if(Ki=!1,u.pendingProps=x=R,b_(l,T))l.flags&131072&&(Ki=!0);else return u.lanes=l.lanes,oo(l,u,T)}return x_(l,u,p,x,T)}function EM(l,u,p){var x=u.pendingProps,T=x.children,R=(u.stateNode._pendingVisibility&2)!==0,X=l!==null?l.memoizedState:null;if(Jd(l,u),x.mode==="hidden"||R){if(u.flags&128){if(x=X!==null?X.baseLanes|p:p,l!==null){for(T=u.child=l.child,R=0;T!==null;)R=R|T.lanes|T.childLanes,T=T.sibling;u.childLanes=R&~x}else u.childLanes=0,u.child=null;return TM(l,u,x,p)}if(p&536870912)u.memoizedState={baseLanes:0,cachePool:null},l!==null&&$0(u,X!==null?X.cachePool:null),X!==null?hl(u,X):Ps(),Va(u);else return u.lanes=u.childLanes=536870912,TM(l,u,X!==null?X.baseLanes|p:p,p)}else X!==null?($0(u,X.cachePool),hl(u,X),Oi(),u.memoizedState=null):(l!==null&&$0(u,null),Ps(),Oi());return ca(l,u,T,p),u.child}function TM(l,u,p,x){var T=w_();return T=T===null?null:{parent:ho?_i._currentValue:_i._currentValue2,pool:T},u.memoizedState={baseLanes:p,cachePool:T},l!==null&&$0(u,null),Ps(),Va(u),l!==null&&Qd(l,u,x,!0),null}function Jd(l,u){var p=u.ref;if(p===null)l!==null&&l.ref!==null&&(u.flags|=2097664);else{if(typeof p!="function"&&typeof p!="object")throw Error(a(284));(l===null||l.ref!==p)&&(u.flags|=2097664)}}function x_(l,u,p,x,T){return Mc(u),p=W(l,u,p,x,void 0,T),x=Me(),l!==null&&!Ki?(M(l,u,T),oo(l,u,T)):(En&&x&&He(u),u.flags|=1,ca(l,u,p,T),u.child)}function bM(l,u,p,x,T,R){return Mc(u),u.updateQueue=null,p=Te(u,x,p,T),oe(l),x=Me(),l!==null&&!Ki?(M(l,u,R),oo(l,u,R)):(En&&x&&He(u),u.flags|=1,ca(l,u,p,R),u.child)}function MM(l,u,p,x,T){if(Mc(u),u.stateNode===null){var R=Th,X=p.contextType;typeof X=="object"&&X!==null&&(R=va(X)),R=new p(x,R),u.memoizedState=R.state!==null&&R.state!==void 0?R.state:null,R.updater=AS,u.stateNode=R,R._reactInternals=u,R=u.stateNode,R.props=x,R.state=u.memoizedState,R.refs={},wt(u),X=p.contextType,R.context=typeof X=="object"&&X!==null?va(X):Th,R.state=u.memoizedState,X=p.getDerivedStateFromProps,typeof X=="function"&&(g_(u,p,X,x),R.state=u.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof R.getSnapshotBeforeUpdate=="function"||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(X=R.state,typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount(),X!==R.state&&AS.enqueueReplaceState(R,R.state,null),Le(u,x,R,T),me(),R.state=u.memoizedState),typeof R.componentDidMount=="function"&&(u.flags|=4194308),x=!0}else if(l===null){R=u.stateNode;var re=u.memoizedProps,ye=bc(p,re);R.props=ye;var Xe=R.context,ct=p.contextType;X=Th,typeof ct=="object"&&ct!==null&&(X=va(ct));var At=p.getDerivedStateFromProps;ct=typeof At=="function"||typeof R.getSnapshotBeforeUpdate=="function",re=u.pendingProps!==re,ct||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(re||Xe!==X)&&gM(u,R,x,X),Sl=!1;var Mt=u.memoizedState;R.state=Mt,Le(u,x,R,T),me(),Xe=u.memoizedState,re||Mt!==Xe||Sl?(typeof At=="function"&&(g_(u,p,At,x),Xe=u.memoizedState),(ye=Sl||mM(u,p,ye,x,Mt,Xe,X))?(ct||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount()),typeof R.componentDidMount=="function"&&(u.flags|=4194308)):(typeof R.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=x,u.memoizedState=Xe),R.props=x,R.state=Xe,R.context=X,x=ye):(typeof R.componentDidMount=="function"&&(u.flags|=4194308),x=!1)}else{R=u.stateNode,bt(l,u),X=u.memoizedProps,ct=bc(p,X),R.props=ct,At=u.pendingProps,Mt=R.context,Xe=p.contextType,ye=Th,typeof Xe=="object"&&Xe!==null&&(ye=va(Xe)),re=p.getDerivedStateFromProps,(Xe=typeof re=="function"||typeof R.getSnapshotBeforeUpdate=="function")||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(X!==At||Mt!==ye)&&gM(u,R,x,ye),Sl=!1,Mt=u.memoizedState,R.state=Mt,Le(u,x,R,T),me();var Kt=u.memoizedState;X!==At||Mt!==Kt||Sl||l!==null&&l.dependencies!==null&&J0(l.dependencies)?(typeof re=="function"&&(g_(u,p,re,x),Kt=u.memoizedState),(ct=Sl||mM(u,p,ct,x,Mt,Kt,ye)||l!==null&&l.dependencies!==null&&J0(l.dependencies))?(Xe||typeof R.UNSAFE_componentWillUpdate!="function"&&typeof R.componentWillUpdate!="function"||(typeof R.componentWillUpdate=="function"&&R.componentWillUpdate(x,Kt,ye),typeof R.UNSAFE_componentWillUpdate=="function"&&R.UNSAFE_componentWillUpdate(x,Kt,ye)),typeof R.componentDidUpdate=="function"&&(u.flags|=4),typeof R.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof R.componentDidUpdate!="function"||X===l.memoizedProps&&Mt===l.memoizedState||(u.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||X===l.memoizedProps&&Mt===l.memoizedState||(u.flags|=1024),u.memoizedProps=x,u.memoizedState=Kt),R.props=x,R.state=Kt,R.context=ye,x=ct):(typeof R.componentDidUpdate!="function"||X===l.memoizedProps&&Mt===l.memoizedState||(u.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||X===l.memoizedProps&&Mt===l.memoizedState||(u.flags|=1024),x=!1)}return R=x,Jd(l,u),x=(u.flags&128)!==0,R||x?(R=u.stateNode,p=x&&typeof p.getDerivedStateFromError!="function"?null:R.render(),u.flags|=1,l!==null&&x?(u.child=Bc(u,l.child,null,T),u.child=Bc(u,null,p,T)):ca(l,u,p,T),u.memoizedState=R.state,l=u.child):l=oo(l,u,T),l}function CM(l,u,p,x){return ht(),u.flags|=256,ca(l,u,p,x),u.child}function y_(l){return{baseLanes:l,cachePool:IM()}}function __(l,u,p){return l=l!==null?l.childLanes&~p:0,u&&(l|=Hr),l}function RM(l,u,p){var x=u.pendingProps,T=!1,R=(u.flags&128)!==0,X;if((X=R)||(X=l!==null&&l.memoizedState===null?!1:(Gi.current&2)!==0),X&&(T=!0,u.flags&=-129),X=(u.flags&32)!==0,u.flags&=-33,l===null){if(En){if(T?Ni(u):Oi(),En){var re=_a,ye;(ye=re)&&(re=GU(re,Fs),re!==null?(u.memoizedState={dehydrated:re,treeContext:Ic!==null?{id:fo,overflow:po}:null,retryLane:536870912},ye=t(18,null,null,0),ye.stateNode=re,ye.return=u,u.child=ye,wa=u,_a=null,ye=!0):ye=!1),ye||Je(u)}if(re=u.memoizedState,re!==null&&(re=re.dehydrated,re!==null))return cS(re)?u.lanes=16:u.lanes=536870912,null;zt(u)}return re=x.children,x=x.fallback,T?(Oi(),T=u.mode,re=A_({mode:"hidden",children:re},T),x=Dc(x,T,p,null),re.return=u,x.return=u,re.sibling=x,u.child=re,T=u.child,T.memoizedState=y_(p),T.childLanes=__(l,X,p),u.memoizedState=ES,x):(Ni(u),S_(u,re))}if(ye=l.memoizedState,ye!==null&&(re=ye.dehydrated,re!==null)){if(R)u.flags&256?(Ni(u),u.flags&=-257,u=E_(l,u,p)):u.memoizedState!==null?(Oi(),u.child=l.child,u.flags|=128,u=null):(Oi(),T=x.fallback,re=u.mode,x=A_({mode:"visible",children:x.children},re),T=Dc(T,re,p,null),T.flags|=2,x.return=u,T.return=u,x.sibling=T,u.child=x,Bc(u,l.child,null,p),x=u.child,x.memoizedState=y_(p),x.childLanes=__(l,X,p),u.memoizedState=ES,u=T);else if(Ni(u),cS(re))X=IU(re).digest,x=Error(a(419)),x.stack="",x.digest=X,et({value:x,source:null,stack:null}),u=E_(l,u,p);else if(Ki||Qd(l,u,p,!1),X=(p&l.childLanes)!==0,Ki||X){if(X=Yn,X!==null){if(x=p&-p,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&(X.suspendedLanes|p)?0:x,x!==0&&x!==ye.retryLane)throw ye.retryLane=x,ze(l,x),Ra(X,l,x),iR}lS(re)||W_(),u=E_(l,u,p)}else lS(re)?(u.flags|=128,u.child=l.child,u=L9.bind(null,l),BU(re,u),u=null):(l=ye.treeContext,Ir&&(_a=FU(re),wa=u,En=!0,ps=null,Fs=!1,l!==null&&(Ur[Lr++]=fo,Ur[Lr++]=po,Ur[Lr++]=Ic,fo=l.id,po=l.overflow,Ic=u)),u=S_(u,x.children),u.flags|=4096);return u}return T?(Oi(),T=x.fallback,re=u.mode,ye=l.child,R=ye.sibling,x=gl(ye,{mode:"hidden",children:x.children}),x.subtreeFlags=ye.subtreeFlags&31457280,R!==null?T=gl(R,T):(T=Dc(T,re,p,null),T.flags|=2),T.return=u,x.return=u,x.sibling=T,u.child=x,x=T,T=u.child,re=l.child.memoizedState,re===null?re=y_(p):(ye=re.cachePool,ye!==null?(R=ho?_i._currentValue:_i._currentValue2,ye=ye.parent!==R?{parent:R,pool:R}:ye):ye=IM(),re={baseLanes:re.baseLanes|p,cachePool:ye}),T.memoizedState=re,T.childLanes=__(l,X,p),u.memoizedState=ES,x):(Ni(u),p=l.child,l=p.sibling,p=gl(p,{mode:"visible",children:x.children}),p.return=u,p.sibling=null,l!==null&&(X=u.deletions,X===null?(u.deletions=[l],u.flags|=16):X.push(l)),u.child=p,u.memoizedState=null,p)}function S_(l,u){return u=A_({mode:"visible",children:u},l.mode),u.return=l,l.child=u}function A_(l,u){return xC(l,u,0,null)}function E_(l,u,p){return Bc(u,l.child,null,p),l=S_(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function wM(l,u,p){l.lanes|=u;var x=l.alternate;x!==null&&(x.lanes|=u),M_(l.return,u,p)}function T_(l,u,p,x,T){var R=l.memoizedState;R===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:x,tail:p,tailMode:T}:(R.isBackwards=u,R.rendering=null,R.renderingStartTime=0,R.last=x,R.tail=p,R.tailMode=T)}function DM(l,u,p){var x=u.pendingProps,T=x.revealOrder,R=x.tail;if(ca(l,u,x.children,p),x=Gi.current,x&2)x=x&1|2,u.flags|=128;else{if(l!==null&&l.flags&128)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&wM(l,p,u);else if(l.tag===19)wM(l,p,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}x&=1}switch(_(Gi,x),T){case"forwards":for(p=u.child,T=null;p!==null;)l=p.alternate,l!==null&&ka(l)===null&&(T=p),p=p.sibling;p=T,p===null?(T=u.child,u.child=null):(T=p.sibling,p.sibling=null),T_(u,!1,T,p,R);break;case"backwards":for(p=null,T=u.child,u.child=null;T!==null;){if(l=T.alternate,l!==null&&ka(l)===null){u.child=T;break}l=T.sibling,T.sibling=p,p=T,T=l}T_(u,!0,p,null,R);break;case"together":T_(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function oo(l,u,p){if(l!==null&&(u.dependencies=l.dependencies),Tl|=u.lanes,!(p&u.childLanes))if(l!==null){if(Qd(l,u,p,!1),(p&u.childLanes)===0)return null}else return null;if(l!==null&&u.child!==l.child)throw Error(a(153));if(u.child!==null){for(l=u.child,p=gl(l,l.pendingProps),u.child=p,p.return=u;l.sibling!==null;)l=l.sibling,p=p.sibling=gl(l,l.pendingProps),p.return=u;p.sibling=null}return u.child}function b_(l,u){return l.lanes&u?!0:(l=l.dependencies,!!(l!==null&&J0(l)))}function b9(l,u,p){switch(u.tag){case 3:nt(u,u.stateNode.containerInfo),fl(u,_i,l.memoizedState.cache),ht();break;case 27:case 5:fe(u);break;case 4:nt(u,u.stateNode.containerInfo);break;case 10:fl(u,u.type,u.memoizedProps.value);break;case 13:var x=u.memoizedState;if(x!==null)return x.dehydrated!==null?(Ni(u),u.flags|=128,null):p&u.child.childLanes?RM(l,u,p):(Ni(u),l=oo(l,u,p),l!==null?l.sibling:null);Ni(u);break;case 19:var T=(l.flags&128)!==0;if(x=(p&u.childLanes)!==0,x||(Qd(l,u,p,!1),x=(p&u.childLanes)!==0),T){if(x)return DM(l,u,p);u.flags|=128}if(T=u.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),_(Gi,Gi.current),x)break;return null;case 22:case 23:return u.lanes=0,EM(l,u,p);case 24:fl(u,_i,l.memoizedState.cache)}return oo(l,u,p)}function NM(l,u,p){if(l!==null)if(l.memoizedProps!==u.pendingProps)Ki=!0;else{if(!b_(l,p)&&!(u.flags&128))return Ki=!1,b9(l,u,p);Ki=!!(l.flags&131072)}else Ki=!1,En&&u.flags&1048576&&Pe(u,fg,u.index);switch(u.lanes=0,u.tag){case 16:e:{l=u.pendingProps;var x=u.elementType,T=x._init;if(x=T(x._payload),u.type=x,typeof x=="function")Z_(x)?(l=bc(x,l),u.tag=1,u=MM(null,u,x,l,p)):(u.tag=0,u=x_(null,u,x,l,p));else{if(x!=null){if(T=x.$$typeof,T===eS){u.tag=11,u=_M(null,u,x,l,p);break e}else if(T===iS){u.tag=14,u=SM(null,u,x,l,p);break e}}throw u=s(x)||x,Error(a(306,u,""))}}return u;case 0:return x_(l,u,u.type,u.pendingProps,p);case 1:return x=u.type,T=bc(x,u.pendingProps),MM(l,u,x,T,p);case 3:e:{if(nt(u,u.stateNode.containerInfo),l===null)throw Error(a(387));var R=u.pendingProps;T=u.memoizedState,x=T.element,bt(l,u),Le(u,R,null,p);var X=u.memoizedState;if(R=X.cache,fl(u,_i,R),R!==T.cache&&C_(u,[_i],p,!0),me(),R=X.element,Ir&&T.isDehydrated)if(T={element:R,isDehydrated:!1,cache:X.cache},u.updateQueue.baseState=T,u.memoizedState=T,u.flags&256){u=CM(l,u,R,p);break e}else if(R!==x){x=de(Error(a(424)),u),et(x),u=CM(l,u,R,p);break e}else for(Ir&&(_a=PU(u.stateNode.containerInfo),wa=u,En=!0,ps=null,Fs=!0),p=tR(u,null,R,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(ht(),R===x){u=oo(l,u,p);break e}ca(l,u,R,p)}u=u.child}return u;case 26:if(Br)return Jd(l,u),l===null?(p=WC(u.type,null,u.pendingProps,null))?u.memoizedState=p:En||(u.stateNode=$U(u.type,u.pendingProps,_l.current,u)):u.memoizedState=WC(u.type,l.memoizedProps,u.pendingProps,l.memoizedState),null;case 27:if(ya)return fe(u),l===null&&ya&&En&&(x=u.stateNode=JC(u.type,u.pendingProps,_l.current,ua.current,!1),wa=u,Fs=!0,_a=VC(x)),x=u.pendingProps.children,l!==null||En?ca(l,u,x,p):u.child=Bc(u,null,x,p),Jd(l,u),u.child;case 5:return l===null&&En&&(KU(u.type,u.pendingProps,ua.current),(T=x=_a)&&(x=HU(x,u.type,u.pendingProps,Fs),x!==null?(u.stateNode=x,wa=u,_a=VC(x),Fs=!1,T=!0):T=!1),T||Je(u)),fe(u),T=u.type,R=u.pendingProps,X=l!==null?l.memoizedProps:null,x=R.children,og(T,R)?x=null:X!==null&&og(T,X)&&(u.flags|=32),u.memoizedState!==null&&(T=W(l,u,De,null,null,p),ho?Oc._currentValue=T:Oc._currentValue2=T),Jd(l,u),ca(l,u,x,p),u.child;case 6:return l===null&&En&&(JU(u.pendingProps,ua.current),(l=p=_a)&&(p=zU(p,u.pendingProps,Fs),p!==null?(u.stateNode=p,wa=u,_a=null,l=!0):l=!1),l||Je(u)),null;case 13:return RM(l,u,p);case 4:return nt(u,u.stateNode.containerInfo),x=u.pendingProps,l===null?u.child=Bc(u,null,x,p):ca(l,u,x,p),u.child;case 11:return _M(l,u,u.type,u.pendingProps,p);case 7:return ca(l,u,u.pendingProps,p),u.child;case 8:return ca(l,u,u.pendingProps.children,p),u.child;case 12:return ca(l,u,u.pendingProps.children,p),u.child;case 10:return x=u.pendingProps,fl(u,u.type,x.value),ca(l,u,x.children,p),u.child;case 9:return T=u.type._context,x=u.pendingProps.children,Mc(u),T=va(T),x=x(T),u.flags|=1,ca(l,u,x,p),u.child;case 14:return SM(l,u,u.type,u.pendingProps,p);case 15:return AM(l,u,u.type,u.pendingProps,p);case 19:return DM(l,u,p);case 22:return EM(l,u,p);case 24:return Mc(u),x=va(_i),l===null?(T=w_(),T===null&&(T=Yn,R=R_(),T.pooledCache=R,R.refCount++,R!==null&&(T.pooledCacheLanes|=p),T=R),u.memoizedState={parent:x,cache:T},wt(u),fl(u,_i,T)):(l.lanes&p&&(bt(l,u),Le(u,null,null,p),me()),T=l.memoizedState,R=u.memoizedState,T.parent!==x?(T={parent:x,cache:x},u.memoizedState=T,u.lanes===0&&(u.memoizedState=u.updateQueue.baseState=T),fl(u,_i,x)):(x=R.cache,fl(u,_i,x),x!==T.cache&&C_(u,[_i],p,!0))),ca(l,u,u.pendingProps.children,p),u.child;case 29:throw u.pendingProps}throw Error(a(156,u.tag))}function fl(l,u,p){ho?(_(_g,u._currentValue),u._currentValue=p):(_(_g,u._currentValue2),u._currentValue2=p)}function lo(l){var u=_g.current;ho?l._currentValue=u:l._currentValue2=u,v(_g)}function M_(l,u,p){for(;l!==null;){var x=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,x!==null&&(x.childLanes|=u)):x!==null&&(x.childLanes&u)!==u&&(x.childLanes|=u),l===p)break;l=l.return}}function C_(l,u,p,x){var T=l.child;for(T!==null&&(T.return=l);T!==null;){var R=T.dependencies;if(R!==null){var X=T.child;R=R.firstContext;e:for(;R!==null;){var re=R;R=T;for(var ye=0;ye<u.length;ye++)if(re.context===u[ye]){R.lanes|=p,re=R.alternate,re!==null&&(re.lanes|=p),M_(R.return,p,l),x||(X=null);break e}R=re.next}}else if(T.tag===18){if(X=T.return,X===null)throw Error(a(341));X.lanes|=p,R=X.alternate,R!==null&&(R.lanes|=p),M_(X,p,l),X=null}else X=T.child;if(X!==null)X.return=T;else for(X=T;X!==null;){if(X===l){X=null;break}if(T=X.sibling,T!==null){T.return=X.return,X=T;break}X=X.return}T=X}}function Qd(l,u,p,x){l=null;for(var T=u,R=!1;T!==null;){if(!R){if(T.flags&524288)R=!0;else if(T.flags&262144)break}if(T.tag===10){var X=T.alternate;if(X===null)throw Error(a(387));if(X=X.memoizedProps,X!==null){var re=T.type;fr(T.pendingProps.value,X.value)||(l!==null?l.push(re):l=[re])}}else if(T===dg.current){if(X=T.alternate,X===null)throw Error(a(387));X.memoizedState.memoizedState!==T.memoizedState.memoizedState&&(l!==null?l.push(Oc):l=[Oc])}T=T.return}l!==null&&C_(u,l,p,x),u.flags|=262144}function J0(l){for(l=l.firstContext;l!==null;){var u=l.context;if(!fr(ho?u._currentValue:u._currentValue2,l.memoizedValue))return!0;l=l.next}return!1}function Mc(l){Fc=l,mo=null,l=l.dependencies,l!==null&&(l.firstContext=null)}function va(l){return OM(Fc,l)}function Q0(l,u){return Fc===null&&Mc(l),OM(l,u)}function OM(l,u){var p=ho?u._currentValue:u._currentValue2;if(u={context:u,memoizedValue:p,next:null},mo===null){if(l===null)throw Error(a(308));mo=u,l.dependencies={lanes:0,firstContext:u},l.flags|=524288}else mo=mo.next=u;return p}function R_(){return{controller:new gL,data:new Map,refCount:0}}function $d(l){l.refCount--,l.refCount===0&&vL(xL,function(){l.controller.abort()})}function w_(){var l=Hc.current;return l!==null?l:Yn.pooledCache}function $0(l,u){u===null?_(Hc,Hc.current):_(Hc,u.pool)}function IM(){var l=w_();return l===null?null:{parent:ho?_i._currentValue:_i._currentValue2,pool:l}}function rr(l){l.flags|=4}function BM(l,u){if(l!==null&&l.child===u.child)return!1;if(u.flags&16)return!0;for(l=u.child;l!==null;){if(l.flags&13878||l.subtreeFlags&13878)return!0;l=l.sibling}return!1}function D_(l,u,p,x){if(xa)for(p=u.child;p!==null;){if(p.tag===5||p.tag===6)sS(l,p.stateNode);else if(!(p.tag===4||ya&&p.tag===27)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===u)break;for(;p.sibling===null;){if(p.return===null||p.return===u)return;p=p.return}p.sibling.return=p.return,p=p.sibling}else if(yl)for(var T=u.child;T!==null;){if(T.tag===5){var R=T.stateNode;p&&x&&(R=HC(R,T.type,T.memoizedProps)),sS(l,R)}else if(T.tag===6)R=T.stateNode,p&&x&&(R=zC(R,T.memoizedProps)),sS(l,R);else if(T.tag!==4){if(T.tag===22&&T.memoizedState!==null)R=T.child,R!==null&&(R.return=T),D_(l,T,!0,!0);else if(T.child!==null){T.child.return=T,T=T.child;continue}}if(T===u)break;for(;T.sibling===null;){if(T.return===null||T.return===u)return;T=T.return}T.sibling.return=T.return,T=T.sibling}}function UM(l,u,p,x){if(yl)for(var T=u.child;T!==null;){if(T.tag===5){var R=T.stateNode;p&&x&&(R=HC(R,T.type,T.memoizedProps)),PC(l,R)}else if(T.tag===6)R=T.stateNode,p&&x&&(R=zC(R,T.memoizedProps)),PC(l,R);else if(T.tag!==4){if(T.tag===22&&T.memoizedState!==null)R=T.child,R!==null&&(R.return=T),UM(l,T,!(T.memoizedProps!==null&&T.memoizedProps.mode==="manual"),!0);else if(T.child!==null){T.child.return=T,T=T.child;continue}}if(T===u)break;for(;T.sibling===null;){if(T.return===null||T.return===u)return;T=T.return}T.sibling.return=T.return,T=T.sibling}}function LM(l,u){if(yl&&BM(l,u)){l=u.stateNode;var p=l.containerInfo,x=LC();UM(x,u,!1,!1),l.pendingChildren=x,rr(u),OU(p,x)}}function N_(l,u,p,x){if(xa)l.memoizedProps!==x&&rr(u);else if(yl){var T=l.stateNode,R=l.memoizedProps;if((l=BM(l,u))||R!==x){var X=ua.current;R=NU(T,p,R,x,!l,null),R===T?u.stateNode=T:(DC(R,p,x,X)&&rr(u),u.stateNode=R,l?D_(R,u,!1,!1):rr(u))}else u.stateNode=T}}function O_(l,u,p){if(rU(u,p)){if(l.flags|=16777216,!IC(u,p))if(oC())l.flags|=8192;else throw Oh=gg,_S}else l.flags&=-16777217}function PM(l,u){if(tL(u)){if(l.flags|=16777216,!KC(u))if(oC())l.flags|=8192;else throw Oh=gg,_S}else l.flags&=-16777217}function eg(l,u){u!==null&&(l.flags|=4),l.flags&16384&&(u=l.tag!==22?w():536870912,l.lanes|=u,Hh|=u)}function ep(l,u){if(!En)switch(l.tailMode){case"hidden":u=l.tail;for(var p=null;u!==null;)u.alternate!==null&&(p=u),u=u.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var x=null;p!==null;)p.alternate!==null&&(x=p),p=p.sibling;x===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:x.sibling=null}}function di(l){var u=l.alternate!==null&&l.alternate.child===l.child,p=0,x=0;if(u)for(var T=l.child;T!==null;)p|=T.lanes|T.childLanes,x|=T.subtreeFlags&31457280,x|=T.flags&31457280,T.return=l,T=T.sibling;else for(T=l.child;T!==null;)p|=T.lanes|T.childLanes,x|=T.subtreeFlags,x|=T.flags,T.return=l,T=T.sibling;return l.subtreeFlags|=x,l.childLanes=p,u}function M9(l,u,p){var x=u.pendingProps;switch(Ke(u),u.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return di(u),null;case 1:return di(u),null;case 3:return p=u.stateNode,x=null,l!==null&&(x=l.memoizedState.cache),u.memoizedState.cache!==x&&(u.flags|=2048),lo(_i),xt(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(l===null||l.child===null)&&(ft(u)?rr(u):l===null||l.memoizedState.isDehydrated&&!(u.flags&256)||(u.flags|=1024,ps!==null&&(k_(ps),ps=null))),LM(l,u),di(u),null;case 26:if(Br){p=u.type;var T=u.memoizedState;return l===null?(rr(u),T!==null?(di(u),PM(u,T)):(di(u),O_(u,p,x))):T?T!==l.memoizedState?(rr(u),di(u),PM(u,T)):(di(u),u.flags&=-16777217):(xa?l.memoizedProps!==x&&rr(u):N_(l,u,p,x),di(u),O_(u,p,x)),null}case 27:if(ya){if(Be(u),p=_l.current,T=u.type,l!==null&&u.stateNode!=null)xa?l.memoizedProps!==x&&rr(u):N_(l,u,T,x);else{if(!x){if(u.stateNode===null)throw Error(a(166));return di(u),null}l=ua.current,ft(u)?ve(u,l):(l=JC(T,x,p,l,!0),u.stateNode=l,rr(u))}return di(u),null}case 5:if(Be(u),p=u.type,l!==null&&u.stateNode!=null)N_(l,u,p,x);else{if(!x){if(u.stateNode===null)throw Error(a(166));return di(u),null}l=ua.current,ft(u)?ve(u,l):(T=Q9(p,x,_l.current,l,u),D_(T,u,!1,!1),u.stateNode=T,DC(T,p,x,l)&&rr(u))}return di(u),O_(u,u.type,u.pendingProps),null;case 6:if(l&&u.stateNode!=null)p=l.memoizedProps,xa?p!==x&&rr(u):yl&&(p!==x?(u.stateNode=NC(x,_l.current,ua.current,u),rr(u)):u.stateNode=l.stateNode);else{if(typeof x!="string"&&u.stateNode===null)throw Error(a(166));if(l=_l.current,p=ua.current,ft(u)){if(!Ir)throw Error(a(176));if(l=u.stateNode,p=u.memoizedProps,x=null,T=wa,T!==null)switch(T.tag){case 27:case 5:x=T.memoizedProps}kU(l,p,u,x)||Je(u)}else u.stateNode=NC(x,l,p,u)}return di(u),null;case 13:if(x=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(T=ft(u),x!==null&&x.dehydrated!==null){if(l===null){if(!T)throw Error(a(318));if(!Ir)throw Error(a(344));if(T=u.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(a(317));XU(T,u)}else ht(),!(u.flags&128)&&(u.memoizedState=null),u.flags|=4;di(u),T=!1}else ps!==null&&(k_(ps),ps=null),T=!0;if(!T)return u.flags&256?(zt(u),u):(zt(u),null)}if(zt(u),u.flags&128)return u.lanes=p,u;if(p=x!==null,l=l!==null&&l.memoizedState!==null,p){x=u.child,T=null,x.alternate!==null&&x.alternate.memoizedState!==null&&x.alternate.memoizedState.cachePool!==null&&(T=x.alternate.memoizedState.cachePool.pool);var R=null;x.memoizedState!==null&&x.memoizedState.cachePool!==null&&(R=x.memoizedState.cachePool.pool),R!==T&&(x.flags|=2048)}return p!==l&&p&&(u.child.flags|=8192),eg(u,u.updateQueue),di(u),null;case 4:return xt(),LM(l,u),l===null&&tU(u.stateNode.containerInfo),di(u),null;case 10:return lo(u.type),di(u),null;case 19:if(v(Gi),T=u.memoizedState,T===null)return di(u),null;if(x=(u.flags&128)!==0,R=T.rendering,R===null)if(x)ep(T,!1);else{if(Ai!==0||l!==null&&l.flags&128)for(l=u.child;l!==null;){if(R=ka(l),R!==null){for(u.flags|=128,ep(T,!1),l=R.updateQueue,u.updateQueue=l,eg(u,l),u.subtreeFlags=0,l=p,p=u.child;p!==null;)vC(p,l),p=p.sibling;return _(Gi,Gi.current&1|2),u.child}l=l.sibling}T.tail!==null&&ds()>mp&&(u.flags|=128,x=!0,ep(T,!1),u.lanes=4194304)}else{if(!x)if(l=ka(R),l!==null){if(u.flags|=128,x=!0,l=l.updateQueue,u.updateQueue=l,eg(u,l),ep(T,!0),T.tail===null&&T.tailMode==="hidden"&&!R.alternate&&!En)return di(u),null}else 2*ds()-T.renderingStartTime>mp&&p!==536870912&&(u.flags|=128,x=!0,ep(T,!1),u.lanes=4194304);T.isBackwards?(R.sibling=u.child,u.child=R):(l=T.last,l!==null?l.sibling=R:u.child=R,T.last=R)}return T.tail!==null?(u=T.tail,T.rendering=u,T.tail=u.sibling,T.renderingStartTime=ds(),u.sibling=null,l=Gi.current,_(Gi,x?l&1|2:l&1),u):(di(u),null);case 22:case 23:return zt(u),ar(),x=u.memoizedState!==null,l!==null?l.memoizedState!==null!==x&&(u.flags|=8192):x&&(u.flags|=8192),x?p&536870912&&!(u.flags&128)&&(di(u),u.subtreeFlags&6&&(u.flags|=8192)):di(u),p=u.updateQueue,p!==null&&eg(u,p.retryQueue),p=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),x=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(x=u.memoizedState.cachePool.pool),x!==p&&(u.flags|=2048),l!==null&&v(Hc),null;case 24:return p=null,l!==null&&(p=l.memoizedState.cache),u.memoizedState.cache!==p&&(u.flags|=2048),lo(_i),di(u),null;case 25:return null}throw Error(a(156,u.tag))}function C9(l,u){switch(Ke(u),u.tag){case 1:return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return lo(_i),xt(),l=u.flags,l&65536&&!(l&128)?(u.flags=l&-65537|128,u):null;case 26:case 27:case 5:return Be(u),null;case 13:if(zt(u),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(a(340));ht()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return v(Gi),null;case 4:return xt(),null;case 10:return lo(u.type),null;case 22:case 23:return zt(u),ar(),l!==null&&v(Hc),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 24:return lo(_i),null;case 25:return null;default:return null}}function FM(l,u){switch(Ke(u),u.tag){case 3:lo(_i),xt();break;case 26:case 27:case 5:Be(u);break;case 4:xt();break;case 13:zt(u);break;case 19:v(Gi);break;case 10:lo(u.type);break;case 22:case 23:zt(u),ar(),l!==null&&v(Hc);break;case 24:lo(_i)}}function tp(l,u){try{var p=u.updateQueue,x=p!==null?p.lastEffect:null;if(x!==null){var T=x.next;p=T;do{if((p.tag&l)===l){x=void 0;var R=p.create,X=p.inst;x=R(),X.destroy=x}p=p.next}while(p!==T)}}catch(re){In(u,u.return,re)}}function dl(l,u,p){try{var x=u.updateQueue,T=x!==null?x.lastEffect:null;if(T!==null){var R=T.next;x=R;do{if((x.tag&l)===l){var X=x.inst,re=X.destroy;if(re!==void 0){X.destroy=void 0,T=u;var ye=p;try{re()}catch(Xe){In(T,ye,Xe)}}}x=x.next}while(x!==R)}}catch(Xe){In(u,u.return,Xe)}}function HM(l){var u=l.updateQueue;if(u!==null){var p=l.stateNode;try{Se(u,p)}catch(x){In(l,l.return,x)}}}function zM(l,u,p){p.props=bc(l.type,l.memoizedProps),p.state=l.memoizedState;try{p.componentWillUnmount()}catch(x){In(l,u,x)}}function Cc(l,u){try{var p=l.ref;if(p!==null){var x=l.stateNode;switch(l.tag){case 26:case 27:case 5:var T=ap(x);break;default:T=x}typeof p=="function"?l.refCleanup=p(T):p.current=T}}catch(R){In(l,u,R)}}function sr(l,u){var p=l.ref,x=l.refCleanup;if(p!==null)if(typeof x=="function")try{x()}catch(T){In(l,u,T)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(T){In(l,u,T)}else p.current=null}function GM(l){var u=l.type,p=l.memoizedProps,x=l.stateNode;try{_U(x,u,p,l)}catch(T){In(l,l.return,T)}}function VM(l,u,p){try{SU(l.stateNode,l.type,p,u,l)}catch(x){In(l,l.return,x)}}function kM(l){return l.tag===5||l.tag===3||(Br?l.tag===26:!1)||(ya?l.tag===27:!1)||l.tag===4}function I_(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||kM(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&(!ya||l.tag!==27)&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function B_(l,u,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,u?EU(p,l,u):xU(p,l);else if(!(x===4||ya&&x===27)&&(l=l.child,l!==null))for(B_(l,u,p),l=l.sibling;l!==null;)B_(l,u,p),l=l.sibling}function tg(l,u,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,u?AU(p,l,u):vU(p,l);else if(!(x===4||ya&&x===27)&&(l=l.child,l!==null))for(tg(l,u,p),l=l.sibling;l!==null;)tg(l,u,p),l=l.sibling}function XM(l,u,p){l=l.containerInfo;try{FC(l,p)}catch(x){In(u,u.return,x)}}function R9(l,u){for(K9(l.containerInfo),Ji=u;Ji!==null;)if(l=Ji,u=l.child,(l.subtreeFlags&1028)!==0&&u!==null)u.return=l,Ji=u;else for(;Ji!==null;){l=Ji;var p=l.alternate;switch(u=l.flags,l.tag){case 0:break;case 11:case 15:break;case 1:if(u&1024&&p!==null){u=void 0;var x=l,T=p.memoizedProps;p=p.memoizedState;var R=x.stateNode;try{var X=bc(x.type,T,x.elementType===x.type);u=R.getSnapshotBeforeUpdate(X,p),R.__reactInternalSnapshotBeforeUpdate=u}catch(re){In(x,x.return,re)}}break;case 3:u&1024&&xa&&DU(l.stateNode.containerInfo);break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(u&1024)throw Error(a(163))}if(u=l.sibling,u!==null){u.return=l.return,Ji=u;break}Ji=l.return}return X=sR,sR=!1,X}function WM(l,u,p){var x=p.flags;switch(p.tag){case 0:case 11:case 15:co(l,p),x&4&&tp(5,p);break;case 1:if(co(l,p),x&4)if(l=p.stateNode,u===null)try{l.componentDidMount()}catch(re){In(p,p.return,re)}else{var T=bc(p.type,u.memoizedProps);u=u.memoizedState;try{l.componentDidUpdate(T,u,l.__reactInternalSnapshotBeforeUpdate)}catch(re){In(p,p.return,re)}}x&64&&HM(p),x&512&&Cc(p,p.return);break;case 3:if(co(l,p),x&64&&(x=p.updateQueue,x!==null)){if(l=null,p.child!==null)switch(p.child.tag){case 27:case 5:l=ap(p.child.stateNode);break;case 1:l=p.child.stateNode}try{Se(x,l)}catch(re){In(p,p.return,re)}}break;case 26:if(Br){co(l,p),x&512&&Cc(p,p.return);break}case 27:case 5:co(l,p),u===null&&x&4&&GM(p),x&512&&Cc(p,p.return);break;case 12:co(l,p);break;case 13:co(l,p),x&4&&qM(l,p);break;case 22:if(T=p.memoizedState!==null||go,!T){u=u!==null&&u.memoizedState!==null||Si;var R=go,X=Si;go=T,(Si=u)&&!X?pl(l,p,(p.subtreeFlags&8772)!==0):co(l,p),go=R,Si=X}x&512&&(p.memoizedProps.mode==="manual"?Cc(p,p.return):sr(p,p.return));break;default:co(l,p)}}function YM(l){var u=l.alternate;u!==null&&(l.alternate=null,YM(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&aU(u)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function fs(l,u,p){for(p=p.child;p!==null;)U_(l,u,p),p=p.sibling}function U_(l,u,p){if(hr&&typeof hr.onCommitFiberUnmount=="function")try{hr.onCommitFiberUnmount(op,p)}catch{}switch(p.tag){case 26:if(Br){Si||sr(p,u),fs(l,u,p),p.memoizedState?qC(p.memoizedState):p.stateNode&&jC(p.stateNode);break}case 27:if(ya){Si||sr(p,u);var x=Bi,T=dr;Bi=p.stateNode,fs(l,u,p),rL(p.stateNode),Bi=x,dr=T;break}case 5:Si||sr(p,u);case 6:if(xa){if(x=Bi,T=dr,Bi=null,fs(l,u,p),Bi=x,dr=T,Bi!==null)if(dr)try{bU(Bi,p.stateNode)}catch(R){In(p,u,R)}else try{TU(Bi,p.stateNode)}catch(R){In(p,u,R)}}else fs(l,u,p);break;case 18:xa&&Bi!==null&&(dr?jU(Bi,p.stateNode):ZU(Bi,p.stateNode));break;case 4:xa?(x=Bi,T=dr,Bi=p.stateNode.containerInfo,dr=!0,fs(l,u,p),Bi=x,dr=T):(yl&&XM(p.stateNode,p,LC()),fs(l,u,p));break;case 0:case 11:case 14:case 15:Si||dl(2,p,u),Si||dl(4,p,u),fs(l,u,p);break;case 1:Si||(sr(p,u),x=p.stateNode,typeof x.componentWillUnmount=="function"&&zM(p,u,x)),fs(l,u,p);break;case 21:fs(l,u,p);break;case 22:Si||sr(p,u),Si=(x=Si)||p.memoizedState!==null,fs(l,u,p),Si=x;break;default:fs(l,u,p)}}function qM(l,u){if(Ir&&u.memoizedState===null&&(l=u.alternate,l!==null&&(l=l.memoizedState,l!==null&&(l=l.dehydrated,l!==null))))try{qU(l)}catch(p){In(u,u.return,p)}}function w9(l){switch(l.tag){case 13:case 19:var u=l.stateNode;return u===null&&(u=l.stateNode=new rR),u;case 22:return l=l.stateNode,u=l._retryCache,u===null&&(u=l._retryCache=new rR),u;default:throw Error(a(435,l.tag))}}function L_(l,u){var p=w9(l);u.forEach(function(x){var T=P9.bind(null,l,x);p.has(x)||(p.add(x),x.then(T,T))})}function Xa(l,u){var p=u.deletions;if(p!==null)for(var x=0;x<p.length;x++){var T=p[x],R=l,X=u;if(xa){var re=X;e:for(;re!==null;){switch(re.tag){case 27:case 5:Bi=re.stateNode,dr=!1;break e;case 3:Bi=re.stateNode.containerInfo,dr=!0;break e;case 4:Bi=re.stateNode.containerInfo,dr=!0;break e}re=re.return}if(Bi===null)throw Error(a(160));U_(R,X,T),Bi=null,dr=!1}else U_(R,X,T);R=T.alternate,R!==null&&(R.return=null),T.return=null}if(u.subtreeFlags&13878)for(u=u.child;u!==null;)ZM(u,l),u=u.sibling}function ZM(l,u){var p=l.alternate,x=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:Xa(u,l),or(l),x&4&&(dl(3,l,l.return),tp(3,l),dl(5,l,l.return));break;case 1:Xa(u,l),or(l),x&512&&(Si||p===null||sr(p,p.return)),x&64&&go&&(l=l.updateQueue,l!==null&&(x=l.callbacks,x!==null&&(p=l.shared.hiddenCallbacks,l.shared.hiddenCallbacks=p===null?x:p.concat(x))));break;case 26:if(Br){var T=ms;Xa(u,l),or(l),x&512&&(Si||p===null||sr(p,p.return)),x&4&&(x=p!==null?p.memoizedState:null,u=l.memoizedState,p===null?u===null?l.stateNode===null?l.stateNode=QU(T,l.type,l.memoizedProps,l):ZC(T,l.type,l.stateNode):l.stateNode=YC(T,u,l.memoizedProps):x!==u?(x===null?p.stateNode!==null&&jC(p.stateNode):qC(x),u===null?ZC(T,l.type,l.stateNode):YC(T,u,l.memoizedProps)):u===null&&l.stateNode!==null&&VM(l,l.memoizedProps,p.memoizedProps));break}case 27:if(ya&&x&4&&l.alternate===null){T=l.stateNode;var R=l.memoizedProps;try{iL(T),aL(l.type,R,T,l)}catch(ct){In(l,l.return,ct)}}case 5:if(Xa(u,l),or(l),x&512&&(Si||p===null||sr(p,p.return)),xa){if(l.flags&32){u=l.stateNode;try{UC(u)}catch(ct){In(l,l.return,ct)}}x&4&&l.stateNode!=null&&(u=l.memoizedProps,VM(l,u,p!==null?p.memoizedProps:u)),x&1024&&(TS=!0)}break;case 6:if(Xa(u,l),or(l),x&4&&xa){if(l.stateNode===null)throw Error(a(162));x=l.memoizedProps,p=p!==null?p.memoizedProps:x,u=l.stateNode;try{yU(u,p,x)}catch(ct){In(l,l.return,ct)}}break;case 3:if(Br?(eL(),T=ms,ms=uS(u.containerInfo),Xa(u,l),ms=T):Xa(u,l),or(l),x&4){if(xa&&Ir&&p!==null&&p.memoizedState.isDehydrated)try{YU(u.containerInfo)}catch(ct){In(l,l.return,ct)}if(yl){x=u.containerInfo,p=u.pendingChildren;try{FC(x,p)}catch(ct){In(l,l.return,ct)}}}TS&&(TS=!1,jM(l));break;case 4:Br?(p=ms,ms=uS(l.stateNode.containerInfo),Xa(u,l),or(l),ms=p):(Xa(u,l),or(l)),x&4&&yl&&XM(l.stateNode,l,l.stateNode.pendingChildren);break;case 12:Xa(u,l),or(l);break;case 13:Xa(u,l),or(l),l.child.flags&8192&&l.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(RS=ds()),x&4&&(x=l.updateQueue,x!==null&&(l.updateQueue=null,L_(l,x)));break;case 22:x&512&&(Si||p===null||sr(p,p.return)),T=l.memoizedState!==null;var X=p!==null&&p.memoizedState!==null,re=go,ye=Si;if(go=re||T,Si=ye||X,Xa(u,l),Si=ye,go=re,or(l),u=l.stateNode,u._current=l,u._visibility&=-3,u._visibility|=u._pendingVisibility&2,x&8192&&(u._visibility=T?u._visibility&-2:u._visibility|1,T&&(u=go||Si,p===null||X||u||gh(l)),xa&&(l.memoizedProps===null||l.memoizedProps.mode!=="manual"))){e:if(p=null,xa)for(u=l;;){if(u.tag===5||Br&&u.tag===26||ya&&u.tag===27){if(p===null){X=p=u;try{R=X.stateNode,T?MU(R):RU(X.stateNode,X.memoizedProps)}catch(ct){In(X,X.return,ct)}}}else if(u.tag===6){if(p===null){X=u;try{var Xe=X.stateNode;T?CU(Xe):wU(Xe,X.memoizedProps)}catch(ct){In(X,X.return,ct)}}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===l)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break e;for(;u.sibling===null;){if(u.return===null||u.return===l)break e;p===u&&(p=null),u=u.return}p===u&&(p=null),u.sibling.return=u.return,u=u.sibling}}x&4&&(x=l.updateQueue,x!==null&&(p=x.retryQueue,p!==null&&(x.retryQueue=null,L_(l,p))));break;case 19:Xa(u,l),or(l),x&4&&(x=l.updateQueue,x!==null&&(l.updateQueue=null,L_(l,x)));break;case 21:break;default:Xa(u,l),or(l)}}function or(l){var u=l.flags;if(u&2){try{if(xa&&(!ya||l.tag!==27)){e:{for(var p=l.return;p!==null;){if(kM(p)){var x=p;break e}p=p.return}throw Error(a(160))}switch(x.tag){case 27:if(ya){var T=x.stateNode,R=I_(l);tg(l,R,T);break}case 5:var X=x.stateNode;x.flags&32&&(UC(X),x.flags&=-33);var re=I_(l);tg(l,re,X);break;case 3:case 4:var ye=x.stateNode.containerInfo,Xe=I_(l);B_(l,Xe,ye);break;default:throw Error(a(161))}}}catch(ct){In(l,l.return,ct)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function jM(l){if(l.subtreeFlags&1024)for(l=l.child;l!==null;){var u=l;jM(u),u.tag===5&&u.flags&1024&&lU(u.stateNode),l=l.sibling}}function co(l,u){if(u.subtreeFlags&8772)for(u=u.child;u!==null;)WM(l,u.alternate,u),u=u.sibling}function gh(l){for(l=l.child;l!==null;){var u=l;switch(u.tag){case 0:case 11:case 14:case 15:dl(4,u,u.return),gh(u);break;case 1:sr(u,u.return);var p=u.stateNode;typeof p.componentWillUnmount=="function"&&zM(u,u.return,p),gh(u);break;case 26:case 27:case 5:sr(u,u.return),gh(u);break;case 22:sr(u,u.return),u.memoizedState===null&&gh(u);break;default:gh(u)}l=l.sibling}}function pl(l,u,p){for(p=p&&(u.subtreeFlags&8772)!==0,u=u.child;u!==null;){var x=u.alternate,T=l,R=u,X=R.flags;switch(R.tag){case 0:case 11:case 15:pl(T,R,p),tp(4,R);break;case 1:if(pl(T,R,p),x=R,T=x.stateNode,typeof T.componentDidMount=="function")try{T.componentDidMount()}catch(Xe){In(x,x.return,Xe)}if(x=R,T=x.updateQueue,T!==null){var re=x.stateNode;try{var ye=T.shared.hiddenCallbacks;if(ye!==null)for(T.shared.hiddenCallbacks=null,T=0;T<ye.length;T++)K(ye[T],re)}catch(Xe){In(x,x.return,Xe)}}p&&X&64&&HM(R),Cc(R,R.return);break;case 26:case 27:case 5:pl(T,R,p),p&&x===null&&X&4&&GM(R),Cc(R,R.return);break;case 12:pl(T,R,p);break;case 13:pl(T,R,p),p&&X&4&&qM(T,R);break;case 22:R.memoizedState===null&&pl(T,R,p),Cc(R,R.return);break;default:pl(T,R,p)}u=u.sibling}}function P_(l,u){var p=null;l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),l=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(l=u.memoizedState.cachePool.pool),l!==p&&(l!=null&&l.refCount++,p!=null&&$d(p))}function F_(l,u){l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&$d(l))}function ml(l,u,p,x){if(u.subtreeFlags&10256)for(u=u.child;u!==null;)KM(l,u,p,x),u=u.sibling}function KM(l,u,p,x){var T=u.flags;switch(u.tag){case 0:case 11:case 15:ml(l,u,p,x),T&2048&&tp(9,u);break;case 3:ml(l,u,p,x),T&2048&&(l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&$d(l)));break;case 12:if(T&2048){ml(l,u,p,x),l=u.stateNode;try{var R=u.memoizedProps,X=R.id,re=R.onPostCommit;typeof re=="function"&&re(X,u.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(ye){In(u,u.return,ye)}}else ml(l,u,p,x);break;case 23:break;case 22:R=u.stateNode,u.memoizedState!==null?R._visibility&4?ml(l,u,p,x):np(l,u):R._visibility&4?ml(l,u,p,x):(R._visibility|=4,vh(l,u,p,x,(u.subtreeFlags&10256)!==0)),T&2048&&P_(u.alternate,u);break;case 24:ml(l,u,p,x),T&2048&&F_(u.alternate,u);break;default:ml(l,u,p,x)}}function vh(l,u,p,x,T){for(T=T&&(u.subtreeFlags&10256)!==0,u=u.child;u!==null;){var R=l,X=u,re=p,ye=x,Xe=X.flags;switch(X.tag){case 0:case 11:case 15:vh(R,X,re,ye,T),tp(8,X);break;case 23:break;case 22:var ct=X.stateNode;X.memoizedState!==null?ct._visibility&4?vh(R,X,re,ye,T):np(R,X):(ct._visibility|=4,vh(R,X,re,ye,T)),T&&Xe&2048&&P_(X.alternate,X);break;case 24:vh(R,X,re,ye,T),T&&Xe&2048&&F_(X.alternate,X);break;default:vh(R,X,re,ye,T)}u=u.sibling}}function np(l,u){if(u.subtreeFlags&10256)for(u=u.child;u!==null;){var p=l,x=u,T=x.flags;switch(x.tag){case 22:np(p,x),T&2048&&P_(x.alternate,x);break;case 24:np(p,x),T&2048&&F_(x.alternate,x);break;default:np(p,x)}u=u.sibling}}function Rc(l){if(l.subtreeFlags&Ph)for(l=l.child;l!==null;)JM(l),l=l.sibling}function JM(l){switch(l.tag){case 26:Rc(l),l.flags&Ph&&(l.memoizedState!==null?nL(ms,l.memoizedState,l.memoizedProps):BC(l.type,l.memoizedProps));break;case 5:Rc(l),l.flags&Ph&&BC(l.type,l.memoizedProps);break;case 3:case 4:if(Br){var u=ms;ms=uS(l.stateNode.containerInfo),Rc(l),ms=u}else Rc(l);break;case 22:l.memoizedState===null&&(u=l.alternate,u!==null&&u.memoizedState!==null?(u=Ph,Ph=16777216,Rc(l),Ph=u):Rc(l));break;default:Rc(l)}}function QM(l){var u=l.alternate;if(u!==null&&(l=u.child,l!==null)){u.child=null;do u=l.sibling,l.sibling=null,l=u;while(l!==null)}}function ip(l){var u=l.deletions;if(l.flags&16){if(u!==null)for(var p=0;p<u.length;p++){var x=u[p];Ji=x,eC(x,l)}QM(l)}if(l.subtreeFlags&10256)for(l=l.child;l!==null;)$M(l),l=l.sibling}function $M(l){switch(l.tag){case 0:case 11:case 15:ip(l),l.flags&2048&&dl(9,l,l.return);break;case 3:ip(l);break;case 12:ip(l);break;case 22:var u=l.stateNode;l.memoizedState!==null&&u._visibility&4&&(l.return===null||l.return.tag!==13)?(u._visibility&=-5,ng(l)):ip(l);break;default:ip(l)}}function ng(l){var u=l.deletions;if(l.flags&16){if(u!==null)for(var p=0;p<u.length;p++){var x=u[p];Ji=x,eC(x,l)}QM(l)}for(l=l.child;l!==null;){switch(u=l,u.tag){case 0:case 11:case 15:dl(8,u,u.return),ng(u);break;case 22:p=u.stateNode,p._visibility&4&&(p._visibility&=-5,ng(u));break;default:ng(u)}l=l.sibling}}function eC(l,u){for(;Ji!==null;){var p=Ji;switch(p.tag){case 0:case 11:case 15:dl(8,p,u);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var x=p.memoizedState.cachePool.pool;x!=null&&x.refCount++}break;case 24:$d(p.memoizedState.cache)}if(x=p.child,x!==null)x.return=p,Ji=x;else e:for(p=l;Ji!==null;){x=Ji;var T=x.sibling,R=x.return;if(YM(x),x===p){Ji=null;break e}if(T!==null){T.return=R,Ji=T;break e}Ji=R}}}function H_(l){var u=OC(l);if(u!=null){if(typeof u.memoizedProps["data-testname"]!="string")throw Error(a(364));return u}if(l=hU(l),l===null)throw Error(a(362));return l.stateNode.current}function z_(l,u){var p=l.tag;switch(u.$$typeof){case Sg:if(l.type===u.value)return!0;break;case Ag:e:{for(u=u.value,l=[l,0],p=0;p<l.length;){var x=l[p++],T=x.tag,R=l[p++],X=u[R];if(T!==5&&T!==26&&T!==27||!sp(x)){for(;X!=null&&z_(x,X);)R++,X=u[R];if(R===u.length){u=!0;break e}else for(x=x.child;x!==null;)l.push(x,R),x=x.sibling}}u=!1}return u;case Eg:if((p===5||p===26||p===27)&&pU(l.stateNode,u.value))return!0;break;case bg:if((p===5||p===6||p===26||p===27)&&(l=dU(l),l!==null&&0<=l.indexOf(u.value)))return!0;break;case Tg:if((p===5||p===26||p===27)&&(l=l.memoizedProps["data-testname"],typeof l=="string"&&l.toLowerCase()===u.value.toLowerCase()))return!0;break;default:throw Error(a(365))}return!1}function G_(l){switch(l.$$typeof){case Sg:return"<"+(s(l.value)||"Unknown")+">";case Ag:return":has("+(G_(l)||"")+")";case Eg:return'[role="'+l.value+'"]';case bg:return'"'+l.value+'"';case Tg:return'[data-testname="'+l.value+'"]';default:throw Error(a(365))}}function tC(l,u){var p=[];l=[l,0];for(var x=0;x<l.length;){var T=l[x++],R=T.tag,X=l[x++],re=u[X];if(R!==5&&R!==26&&R!==27||!sp(T)){for(;re!=null&&z_(T,re);)X++,re=u[X];if(X===u.length)p.push(T);else for(T=T.child;T!==null;)l.push(T,X),T=T.sibling}}return p}function V_(l,u){if(!rp)throw Error(a(363));l=H_(l),l=tC(l,u),u=[],l=Array.from(l);for(var p=0;p<l.length;){var x=l[p++],T=x.tag;if(T===5||T===26||T===27)sp(x)||u.push(x.stateNode);else for(x=x.child;x!==null;)l.push(x),x=x.sibling}return u}function lr(){if(Fn&2&&xn!==0)return xn&-xn;if(Zt.T!==null){var l=Dh;return l!==0?l:Ge()}return nU()}function nC(){Hr===0&&(Hr=!(xn&536870912)||En?B():536870912);var l=Fr.current;return l!==null&&(l.flags|=32),Hr}function Ra(l,u,p){(l===Yn&&qn===2||l.cancelPendingCommit!==null)&&(xh(l,0),uo(l,xn,Hr,!1)),G(l,p),(!(Fn&2)||l!==Yn)&&(l===Yn&&(!(Fn&2)&&(zc|=p),Ai===4&&uo(l,xn,Hr,!1)),ot(l))}function iC(l,u,p){if(Fn&6)throw Error(a(327));var x=!p&&(u&60)===0&&(u&l.expiredLanes)===0||N(l,u),T=x?O9(l,u):Y_(l,u,!0),R=x;do{if(T===0){Fh&&!x&&uo(l,u,0,!1);break}else if(T===6)uo(l,u,0,!vo);else{if(p=l.current.alternate,R&&!D9(p)){T=Y_(l,u,!1),R=!1;continue}if(T===2){if(R=u,l.errorRecoveryDisabledLanes&R)var X=0;else X=l.pendingLanes&-536870913,X=X!==0?X:X&536870912?536870912:0;if(X!==0){u=X;e:{var re=l;T=pp;var ye=Ir&&re.current.memoizedState.isDehydrated;if(ye&&(xh(re,X).flags|=256),X=Y_(re,X,!1),X!==2){if(bS&&!ye){re.errorRecoveryDisabledLanes|=R,zc|=R,T=4;break e}R=Gs,Gs=T,R!==null&&k_(R)}T=X}if(R=!1,T!==2)continue}}if(T===1){xh(l,0),uo(l,u,0,!0);break}e:{switch(x=l,T){case 0:case 1:throw Error(a(345));case 4:if((u&4194176)===u){uo(x,u,Hr,!vo);break e}break;case 2:Gs=null;break;case 3:case 5:break;default:throw Error(a(329))}if(x.finishedWork=p,x.finishedLanes=u,(u&62914560)===u&&(R=RS+300-ds(),10<R)){if(uo(x,u,Hr,!vo),O(x,0)!==0)break e;x.timeoutHandle=$9(aC.bind(null,x,p,Gs,Mg,CS,u,Hr,zc,Hh,vo,2,-0,0),R);break e}aC(x,p,Gs,Mg,CS,u,Hr,zc,Hh,vo,0,-0,0)}}break}while(!0);ot(l)}function k_(l){Gs===null?Gs=l:Gs.push.apply(Gs,l)}function aC(l,u,p,x,T,R,X,re,ye,Xe,ct,At,Mt){var Kt=u.subtreeFlags;if((Kt&8192||(Kt&16785408)===16785408)&&(sU(),JM(u),u=oU(),u!==null)){l.cancelPendingCommit=u(dC.bind(null,l,p,x,T,X,re,ye,1,At,Mt)),uo(l,R,X,!Xe);return}dC(l,p,x,T,X,re,ye,ct,At,Mt)}function D9(l){for(var u=l;;){var p=u.tag;if((p===0||p===11||p===15)&&u.flags&16384&&(p=u.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var x=0;x<p.length;x++){var T=p[x],R=T.getSnapshot;T=T.value;try{if(!fr(R(),T))return!1}catch{return!1}}if(p=u.child,u.subtreeFlags&16384&&p!==null)p.return=u,u=p;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function uo(l,u,p,x){u&=~MS,u&=~zc,l.suspendedLanes|=u,l.pingedLanes&=~u,x&&(l.warmLanes|=u),x=l.expirationTimes;for(var T=u;0<T;){var R=31-ur(T),X=1<<R;x[R]=-1,T&=~X}p!==0&&$(l,p,u)}function rC(){return Fn&6?!0:(rt(0),!1)}function X_(){if(cn!==null){if(qn===0)var l=cn.return;else l=cn,mo=Fc=null,I(l),Ih=null,hp=0,l=cn;for(;l!==null;)FM(l.alternate,l),l=l.return;cn=null}}function xh(l,u){l.finishedWork=null,l.finishedLanes=0;var p=l.timeoutHandle;p!==oS&&(l.timeoutHandle=oS,eU(p)),p=l.cancelPendingCommit,p!==null&&(l.cancelPendingCommit=null,p()),X_(),Yn=l,cn=p=gl(l.current,null),xn=u,qn=0,pr=null,vo=!1,Fh=N(l,u),bS=!1,Hh=Hr=MS=zc=Tl=Ai=0,Gs=pp=null,CS=!1,u&8&&(u|=u&32);var x=l.entangledLanes;if(x!==0)for(l=l.entanglements,x&=u;0<x;){var T=31-ur(x),R=1<<T;u|=l[T],x&=~R}return xo=u,Re(),p}function sC(l,u){rn=null,Zt.H=zs,u===up?(u=gt(),qn=3):u===_S?(u=gt(),qn=4):qn=u===iR?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,pr=u,cn===null&&(Ai=1,K0(l,de(u,l.current)))}function oC(){var l=Fr.current;return l===null?!0:(xn&4194176)===xn?Hs===null:(xn&62914560)===xn||xn&536870912?l===Hs:!1}function lC(){var l=Zt.H;return Zt.H=zs,l===null?zs:l}function cC(){var l=Zt.A;return Zt.A=yL,l}function W_(){Ai=4,vo||(xn&4194176)!==xn&&Fr.current!==null||(Fh=!0),!(Tl&134217727)&&!(zc&134217727)||Yn===null||uo(Yn,xn,Hr,!1)}function Y_(l,u,p){var x=Fn;Fn|=2;var T=lC(),R=cC();(Yn!==l||xn!==u)&&(Mg=null,xh(l,u)),u=!1;var X=Ai;e:do try{if(qn!==0&&cn!==null){var re=cn,ye=pr;switch(qn){case 8:X_(),X=6;break e;case 3:case 2:case 6:Fr.current===null&&(u=!0);var Xe=qn;if(qn=0,pr=null,yh(l,re,ye,Xe),p&&Fh){X=0;break e}break;default:Xe=qn,qn=0,pr=null,yh(l,re,ye,Xe)}}N9(),X=Ai;break}catch(ct){sC(l,ct)}while(!0);return u&&l.shellSuspendCounter++,mo=Fc=null,Fn=x,Zt.H=T,Zt.A=R,cn===null&&(Yn=null,xn=0,Re()),X}function N9(){for(;cn!==null;)uC(cn)}function O9(l,u){var p=Fn;Fn|=2;var x=lC(),T=cC();Yn!==l||xn!==u?(Mg=null,mp=ds()+500,xh(l,u)):Fh=N(l,u);e:do try{if(qn!==0&&cn!==null){u=cn;var R=pr;t:switch(qn){case 1:qn=0,pr=null,yh(l,u,R,1);break;case 2:if(it(R)){qn=0,pr=null,hC(u);break}u=function(){qn===2&&Yn===l&&(qn=7),ot(l)},R.then(u,u);break e;case 3:qn=7;break e;case 4:qn=5;break e;case 7:it(R)?(qn=0,pr=null,hC(u)):(qn=0,pr=null,yh(l,u,R,7));break;case 5:var X=null;switch(cn.tag){case 26:X=cn.memoizedState;case 5:case 27:var re=cn,ye=re.type,Xe=re.pendingProps;if(X?KC(X):IC(ye,Xe)){qn=0,pr=null;var ct=re.sibling;if(ct!==null)cn=ct;else{var At=re.return;At!==null?(cn=At,ig(At)):cn=null}break t}}qn=0,pr=null,yh(l,u,R,5);break;case 6:qn=0,pr=null,yh(l,u,R,6);break;case 8:X_(),Ai=6;break e;default:throw Error(a(462))}}I9();break}catch(Mt){sC(l,Mt)}while(!0);return mo=Fc=null,Zt.H=x,Zt.A=T,Fn=p,cn!==null?0:(Yn=null,xn=0,Re(),Ai)}function I9(){for(;cn!==null&&!lL();)uC(cn)}function uC(l){var u=NM(l.alternate,l,xo);l.memoizedProps=l.pendingProps,u===null?ig(l):cn=u}function hC(l){var u=l,p=u.alternate;switch(u.tag){case 15:case 0:u=bM(p,u,u.pendingProps,u.type,void 0,xn);break;case 11:u=bM(p,u,u.pendingProps,u.type.render,u.ref,xn);break;case 5:I(u);default:FM(p,u),u=cn=vC(u,xo),u=NM(p,u,xo)}l.memoizedProps=l.pendingProps,u===null?ig(l):cn=u}function yh(l,u,p,x){mo=Fc=null,I(u),Ih=null,hp=0;var T=u.return;try{if(T9(l,T,u,p,xn)){Ai=1,K0(l,de(p,l.current)),cn=null;return}}catch(R){if(T!==null)throw cn=T,R;Ai=1,K0(l,de(p,l.current)),cn=null;return}u.flags&32768?(En||x===1?l=!0:Fh||xn&536870912?l=!1:(vo=l=!0,(x===2||x===3||x===6)&&(x=Fr.current,x!==null&&x.tag===13&&(x.flags|=16384))),fC(u,l)):ig(u)}function ig(l){var u=l;do{if(u.flags&32768){fC(u,vo);return}l=u.return;var p=M9(u.alternate,u,xo);if(p!==null){cn=p;return}if(u=u.sibling,u!==null){cn=u;return}cn=u=l}while(u!==null);Ai===0&&(Ai=5)}function fC(l,u){do{var p=C9(l.alternate,l);if(p!==null){p.flags&=32767,cn=p;return}if(p=l.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!u&&(l=l.sibling,l!==null)){cn=l;return}cn=l=p}while(l!==null);Ai=6,cn=null}function dC(l,u,p,x,T,R,X,re,ye,Xe){var ct=Zt.T,At=Nc();try{Wa(2),Zt.T=null,B9(l,u,p,x,At,T,R,X,re,ye,Xe)}finally{Zt.T=ct,Wa(At)}}function B9(l,u,p,x,T,R,X,re){do wc();while(Gc!==null);if(Fn&6)throw Error(a(327));var ye=l.finishedWork;if(x=l.finishedLanes,ye===null)return null;if(l.finishedWork=null,l.finishedLanes=0,ye===l.current)throw Error(a(177));l.callbackNode=null,l.callbackPriority=0,l.cancelPendingCommit=null;var Xe=ye.lanes|ye.childLanes;if(Xe|=mS,J(l,x,Xe,R,X,re),l===Yn&&(cn=Yn=null,xn=0),!(ye.subtreeFlags&10256)&&!(ye.flags&10256)||Cg||(Cg=!0,wS=Xe,DS=p,F9(dS,function(){return wc(),null})),p=(ye.flags&15990)!==0,ye.subtreeFlags&15990||p?(p=Zt.T,Zt.T=null,R=Nc(),Wa(2),X=Fn,Fn|=4,R9(l,ye),ZM(ye,l),J9(l.containerInfo),l.current=ye,WM(l,ye.alternate,ye),cL(),Fn=X,Wa(R),Zt.T=p):l.current=ye,Cg?(Cg=!1,Gc=l,gp=x):pC(l,Xe),Xe=l.pendingLanes,Xe===0&&(bl=null),q(ye.stateNode),ot(l),u!==null)for(T=l.onRecoverableError,ye=0;ye<u.length;ye++)Xe=u[ye],T(Xe.value,{componentStack:Xe.stack});return gp&3&&wc(),Xe=l.pendingLanes,x&4194218&&Xe&42?l===NS?vp++:(vp=0,NS=l):vp=0,rt(0),null}function pC(l,u){(l.pooledCacheLanes&=u)===0&&(u=l.pooledCache,u!=null&&(l.pooledCache=null,$d(u)))}function wc(){if(Gc!==null){var l=Gc,u=wS;wS=0;var p=le(gp),x=32>p?32:p;p=Zt.T;var T=Nc();try{if(Wa(x),Zt.T=null,Gc===null)var R=!1;else{x=DS,DS=null;var X=Gc,re=gp;if(Gc=null,gp=0,Fn&6)throw Error(a(331));var ye=Fn;if(Fn|=4,$M(X.current),KM(X,X.current,re,x),Fn=ye,rt(0,!1),hr&&typeof hr.onPostCommitFiberRoot=="function")try{hr.onPostCommitFiberRoot(op,X)}catch{}R=!0}return R}finally{Wa(T),Zt.T=p,pC(l,u)}}return!1}function mC(l,u,p){u=de(p,u),u=v_(l.stateNode,u,2),l=Ve(l,u,2),l!==null&&(G(l,2),ot(l))}function In(l,u,p){if(l.tag===3)mC(l,l,p);else for(;u!==null;){if(u.tag===3){mC(u,l,p);break}else if(u.tag===1){var x=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(bl===null||!bl.has(x))){l=de(p,l),p=xM(2),x=Ve(u,p,2),x!==null&&(yM(p,x,u,l),G(x,2),ot(x));break}}u=u.return}}function q_(l,u,p){var x=l.pingCache;if(x===null){x=l.pingCache=new _L;var T=new Set;x.set(u,T)}else T=x.get(u),T===void 0&&(T=new Set,x.set(u,T));T.has(p)||(bS=!0,T.add(p),l=U9.bind(null,l,u,p),u.then(l,l))}function U9(l,u,p){var x=l.pingCache;x!==null&&x.delete(u),l.pingedLanes|=l.suspendedLanes&p,l.warmLanes&=~p,Yn===l&&(xn&p)===p&&(Ai===4||Ai===3&&(xn&62914560)===xn&&300>ds()-RS?!(Fn&2)&&xh(l,0):MS|=p,Hh===xn&&(Hh=0)),ot(l)}function gC(l,u){u===0&&(u=w()),l=ze(l,u),l!==null&&(G(l,u),ot(l))}function L9(l){var u=l.memoizedState,p=0;u!==null&&(p=u.retryLane),gC(l,p)}function P9(l,u){var p=0;switch(l.tag){case 13:var x=l.stateNode,T=l.memoizedState;T!==null&&(p=T.retryLane);break;case 19:x=l.stateNode;break;case 22:x=l.stateNode._retryCache;break;default:throw Error(a(314))}x!==null&&x.delete(u),gC(l,p)}function F9(l,u){return ug(l,u)}function H9(l,u,p,x){this.tag=l,this.key=p,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 Z_(l){return l=l.prototype,!(!l||!l.isReactComponent)}function gl(l,u){var p=l.alternate;return p===null?(p=t(l.tag,u,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=u,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&31457280,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,u=l.dependencies,p.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p.refCleanup=l.refCleanup,p}function vC(l,u){l.flags&=31457282;var p=l.alternate;return p===null?(l.childLanes=0,l.lanes=u,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=p.childLanes,l.lanes=p.lanes,l.child=p.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=p.memoizedProps,l.memoizedState=p.memoizedState,l.updateQueue=p.updateQueue,l.type=p.type,u=p.dependencies,l.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),l}function ag(l,u,p,x,T,R){var X=0;if(x=l,typeof l=="function")Z_(l)&&(X=1);else if(typeof l=="string")X=Br&&ya?XC(l,p,ua.current)?26:QC(l)?27:5:Br?XC(l,p,ua.current)?26:5:ya&&QC(l)?27:5;else e:switch(l){case Sh:return Dc(p.children,T,R,u);case TC:X=8,T|=24;break;case $_:return l=t(12,p,u,T|2),l.elementType=$_,l.lanes=R,l;case tS:return l=t(13,p,u,T),l.elementType=tS,l.lanes=R,l;case nS:return l=t(19,p,u,T),l.elementType=nS,l.lanes=R,l;case MC:return xC(p,T,R,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case k9:case vl:X=10;break e;case bC:X=9;break e;case eS:X=11;break e;case iS:X=14;break e;case xl:X=16,x=null;break e}X=29,p=Error(a(130,l===null?"null":typeof l,"")),x=null}return u=t(X,p,u,T),u.elementType=l,u.type=x,u.lanes=R,u}function Dc(l,u,p,x){return l=t(7,l,x,u),l.lanes=p,l}function xC(l,u,p,x){l=t(22,l,x,u),l.elementType=MC,l.lanes=p;var T={_visibility:1,_pendingVisibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null,_current:null,detach:function(){var R=T._current;if(R===null)throw Error(a(456));if(!(T._pendingVisibility&2)){var X=ze(R,2);X!==null&&(T._pendingVisibility|=2,Ra(X,R,2))}},attach:function(){var R=T._current;if(R===null)throw Error(a(456));if(T._pendingVisibility&2){var X=ze(R,2);X!==null&&(T._pendingVisibility&=-3,Ra(X,R,2))}}};return l.stateNode=T,l}function j_(l,u,p){return l=t(6,l,null,u),l.lanes=p,l}function K_(l,u,p){return u=t(4,l.children!==null?l.children:[],l.key,u),u.lanes=p,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function z9(l,u,p,x,T,R,X,re){this.tag=1,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=oS,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=D(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.finishedLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=D(0),this.hiddenUpdates=D(null),this.identifierPrefix=x,this.onUncaughtError=T,this.onCaughtError=R,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=re,this.incompleteTransitions=new Map}function yC(l,u,p,x,T,R,X,re,ye,Xe,ct,At){return l=new z9(l,u,p,X,re,ye,Xe,At),u=1,R===!0&&(u|=24),R=t(3,null,null,u),l.current=R,R.stateNode=l,u=R_(),u.refCount++,l.pooledCache=u,u.refCount++,R.memoizedState={element:x,isDehydrated:p,cache:u},wt(R),l}function _C(l){return l?(l=Th,l):Th}function SC(l){var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(a(188)):(l=Object.keys(l).join(","),Error(a(268,l)));return l=g(u),l=l!==null?y(l):null,l===null?null:ap(l.stateNode)}function AC(l,u,p,x,T,R){T=_C(T),x.context===null?x.context=T:x.pendingContext=T,x=ke(u),x.payload={element:p},R=R===void 0?null:R,R!==null&&(x.callback=R),p=Ve(l,x,u),p!==null&&(Ra(p,l,u),St(p,l,u))}function EC(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p<u?p:u}}function J_(l,u){EC(l,u),(l=l.alternate)&&EC(l,u)}var ln={},G9=he,cr=zE,Q_=Object.assign,V9=Symbol.for("react.element"),rg=Symbol.for("react.transitional.element"),_h=Symbol.for("react.portal"),Sh=Symbol.for("react.fragment"),TC=Symbol.for("react.strict_mode"),$_=Symbol.for("react.profiler"),k9=Symbol.for("react.provider"),bC=Symbol.for("react.consumer"),vl=Symbol.for("react.context"),eS=Symbol.for("react.forward_ref"),tS=Symbol.for("react.suspense"),nS=Symbol.for("react.suspense_list"),iS=Symbol.for("react.memo"),xl=Symbol.for("react.lazy"),MC=Symbol.for("react.offscreen"),X9=Symbol.for("react.memo_cache_sentinel"),CC=Symbol.iterator,W9=Symbol.for("react.client.reference"),Zt=G9.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,aS,RC,rS=!1,sg=Array.isArray,Y9=e.rendererVersion,q9=e.rendererPackageName,wC=e.extraDevToolsConfig,ap=e.getPublicInstance,Z9=e.getRootHostContext,j9=e.getChildHostContext,K9=e.prepareForCommit,J9=e.resetAfterCommit,Q9=e.createInstance,sS=e.appendInitialChild,DC=e.finalizeInitialChildren,og=e.shouldSetTextContent,NC=e.createTextInstance,$9=e.scheduleTimeout,eU=e.cancelTimeout,oS=e.noTimeout,ho=e.isPrimaryRenderer;e.warnsIfNotActing;var xa=e.supportsMutation,yl=e.supportsPersistence,Ir=e.supportsHydration,OC=e.getInstanceFromNode;e.beforeActiveInstanceBlur,e.afterActiveInstanceBlur;var tU=e.preparePortalMount;e.prepareScopeUpdate,e.getInstanceFromScope;var Wa=e.setCurrentUpdatePriority,Nc=e.getCurrentUpdatePriority,nU=e.resolveUpdatePriority;e.resolveEventType,e.resolveEventTimeStamp;var iU=e.shouldAttemptEagerTransition,aU=e.detachDeletedInstance;e.requestPostPaintCallback;var rU=e.maySuspendCommit,IC=e.preloadInstance,sU=e.startSuspendingCommit,BC=e.suspendInstance,oU=e.waitForCommitToBeReady,Ah=e.NotPendingTransition,Oc=e.HostTransitionContext,lU=e.resetFormInstance;e.bindToConsole;var cU=e.supportsMicrotasks,uU=e.scheduleMicrotask,rp=e.supportsTestSelectors,hU=e.findFiberRoot,fU=e.getBoundingRect,dU=e.getTextContent,sp=e.isHiddenSubtree,pU=e.matchAccessibilityRole,mU=e.setFocusIfFocusable,gU=e.setupIntersectionObserver,vU=e.appendChild,xU=e.appendChildToContainer,yU=e.commitTextUpdate,_U=e.commitMount,SU=e.commitUpdate,AU=e.insertBefore,EU=e.insertInContainerBefore,TU=e.removeChild,bU=e.removeChildFromContainer,UC=e.resetTextContent,MU=e.hideInstance,CU=e.hideTextInstance,RU=e.unhideInstance,wU=e.unhideTextInstance,DU=e.clearContainer,NU=e.cloneInstance,LC=e.createContainerChildSet,PC=e.appendChildToContainerChildSet,OU=e.finalizeContainerChildren,FC=e.replaceContainerChildren,HC=e.cloneHiddenInstance,zC=e.cloneHiddenTextInstance,lS=e.isSuspenseInstancePending,cS=e.isSuspenseInstanceFallback,IU=e.getSuspenseInstanceFallbackErrorDetails,BU=e.registerSuspenseInstanceRetry,UU=e.canHydrateFormStateMarker,LU=e.isFormStateMarkerMatching,GC=e.getNextHydratableSibling,VC=e.getFirstHydratableChild,PU=e.getFirstHydratableChildWithinContainer,FU=e.getFirstHydratableChildWithinSuspenseInstance,HU=e.canHydrateInstance,zU=e.canHydrateTextInstance,GU=e.canHydrateSuspenseInstance,VU=e.hydrateInstance,kU=e.hydrateTextInstance,XU=e.hydrateSuspenseInstance,WU=e.getNextHydratableInstanceAfterSuspenseInstance,YU=e.commitHydratedContainer,qU=e.commitHydratedSuspenseInstance,ZU=e.clearSuspenseBoundary,jU=e.clearSuspenseBoundaryFromContainer,kC=e.shouldDeleteUnhydratedTailInstances;e.diffHydratedPropsForDevWarnings,e.diffHydratedTextForDevWarnings,e.describeHydratableInstanceForDevWarnings;var KU=e.validateHydratableInstance,JU=e.validateHydratableTextInstance,Br=e.supportsResources,XC=e.isHostHoistableType,uS=e.getHoistableRoot,WC=e.getResource,YC=e.acquireResource,qC=e.releaseResource,QU=e.hydrateHoistable,ZC=e.mountHoistable,jC=e.unmountHoistable,$U=e.createHoistableInstance,eL=e.prepareToCommitHoistables,tL=e.mayResourceSuspendCommit,KC=e.preloadResource,nL=e.suspendResource,ya=e.supportsSingletons,JC=e.resolveSingletonInstance,iL=e.clearSingleton,aL=e.acquireSingletonInstance,rL=e.releaseSingletonInstance,QC=e.isHostSingletonType,hS=[],Eh=-1,Th={},ur=Math.clz32?Math.clz32:A,sL=Math.log,oL=Math.LN2,lg=128,cg=4194304,ug=cr.unstable_scheduleCallback,fS=cr.unstable_cancelCallback,lL=cr.unstable_shouldYield,cL=cr.unstable_requestPaint,ds=cr.unstable_now,$C=cr.unstable_ImmediatePriority,uL=cr.unstable_UserBlockingPriority,dS=cr.unstable_NormalPriority,hL=cr.unstable_IdlePriority,fL=cr.log,dL=cr.unstable_setDisableYieldValue,op=null,hr=null,fr=typeof Object.is=="function"?Object.is:ee,eR=new WeakMap,bh=[],Mh=0,hg=null,fg=0,Ur=[],Lr=0,Ic=null,fo=1,po="",ua=S(null),lp=S(null),_l=S(null),dg=S(null),wa=null,_a=null,En=!1,ps=null,Fs=!1,pS=Error(a(519)),Pr=[],Ch=0,mS=0,pg=null,Rh=null,gS=!1,mg=!1,vS=!1,wh=0,cp=null,xS=0,Dh=0,Nh=null,Sl=!1,yS=!1,pL=Object.prototype.hasOwnProperty,up=Error(a(460)),_S=Error(a(474)),gg={then:function(){}},Oh=null,Ih=null,hp=0,Bc=fi(!0),tR=fi(!1),Bh=S(null),vg=S(0),Fr=S(null),Hs=null,Gi=S(0),Al=0,rn=null,Pn=null,Ii=null,xg=!1,Uh=!1,Uc=!1,yg=0,fp=0,Lh=null,mL=0,SS=function(){return{lastEffect:null,events:null,stores:null,memoCache:null}},zs={readContext:va,use:Y,useCallback:Ln,useContext:Ln,useEffect:Ln,useImperativeHandle:Ln,useLayoutEffect:Ln,useInsertionEffect:Ln,useMemo:Ln,useReducer:Ln,useRef:Ln,useState:Ln,useDebugValue:Ln,useDeferredValue:Ln,useTransition:Ln,useSyncExternalStore:Ln,useId:Ln};zs.useCacheRefresh=Ln,zs.useMemoCache=Ln,zs.useHostTransitionStatus=Ln,zs.useFormState=Ln,zs.useActionState=Ln,zs.useOptimistic=Ln;var Lc={readContext:va,use:Y,useCallback:function(l,u){return V().memoizedState=[l,u===void 0?null:u],l},useContext:va,useEffect:eM,useImperativeHandle:function(l,u,p){p=p!=null?p.concat([l]):null,Or(4194308,4,iM.bind(null,u,l),p)},useLayoutEffect:function(l,u){return Or(4194308,4,l,u)},useInsertionEffect:function(l,u){Or(4,2,l,u)},useMemo:function(l,u){var p=V();u=u===void 0?null:u;var x=l();if(Uc){te(!0);try{l()}finally{te(!1)}}return p.memoizedState=[x,u],x},useReducer:function(l,u,p){var x=V();if(p!==void 0){var T=p(u);if(Uc){te(!0);try{p(u)}finally{te(!1)}}}else T=u;return x.memoizedState=x.baseState=T,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:T},x.queue=l,l=l.dispatch=E9.bind(null,rn,l),[x.memoizedState,l]},useRef:function(l){var u=V();return l={current:l},u.memoizedState=l},useState:function(l){l=$e(l);var u=l.queue,p=fM.bind(null,rn,u);return u.dispatch=p,[l.memoizedState,p]},useDebugValue:f_,useDeferredValue:function(l,u){var p=V();return d_(p,l,u)},useTransition:function(){var l=$e(!1);return l=lM.bind(null,rn,l.queue,!0,!1),V().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,p){var x=rn,T=V();if(En){if(p===void 0)throw Error(a(407));p=p()}else{if(p=u(),Yn===null)throw Error(a(349));xn&60||Ae(x,u,p)}T.memoizedState=p;var R={value:p,getSnapshot:u};return T.queue=R,eM(Fe.bind(null,x,R,l),[l]),x.flags|=2048,Wn(9,Ne.bind(null,x,R,p,u),{destroy:void 0},null),p},useId:function(){var l=V(),u=Yn.identifierPrefix;if(En){var p=po,x=fo;p=(x&~(1<<32-ur(x)-1)).toString(32)+p,u=":"+u+"R"+p,p=yg++,0<p&&(u+="H"+p.toString(32)),u+=":"}else p=mL++,u=":"+u+"r"+p.toString(32)+":";return l.memoizedState=u},useCacheRefresh:function(){return V().memoizedState=A9.bind(null,rn)}};Lc.useMemoCache=z,Lc.useHostTransitionStatus=p_,Lc.useFormState=Lt,Lc.useActionState=Lt,Lc.useOptimistic=function(l){var u=V();u.memoizedState=u.baseState=l;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return u.queue=p,u=m_.bind(null,rn,!0,p),p.dispatch=u,[l,u]};var El={readContext:va,use:Y,useCallback:rM,useContext:va,useEffect:h_,useImperativeHandle:aM,useInsertionEffect:tM,useLayoutEffect:nM,useMemo:sM,useReducer:Q,useRef:mh,useState:function(){return Q(k)},useDebugValue:f_,useDeferredValue:function(l,u){var p=C();return oM(p,Pn.memoizedState,l,u)},useTransition:function(){var l=Q(k)[0],u=C().memoizedState;return[typeof l=="boolean"?l:F(l),u]},useSyncExternalStore:xe,useId:uM};El.useCacheRefresh=hM,El.useMemoCache=z,El.useHostTransitionStatus=p_,El.useFormState=Ot,El.useActionState=Ot,El.useOptimistic=function(l,u){var p=C();return vt(p,Pn,l,u)};var Pc={readContext:va,use:Y,useCallback:rM,useContext:va,useEffect:h_,useImperativeHandle:aM,useInsertionEffect:tM,useLayoutEffect:nM,useMemo:sM,useReducer:ce,useRef:mh,useState:function(){return ce(k)},useDebugValue:f_,useDeferredValue:function(l,u){var p=C();return Pn===null?d_(p,l,u):oM(p,Pn.memoizedState,l,u)},useTransition:function(){var l=ce(k)[0],u=C().memoizedState;return[typeof l=="boolean"?l:F(l),u]},useSyncExternalStore:xe,useId:uM};Pc.useCacheRefresh=hM,Pc.useMemoCache=z,Pc.useHostTransitionStatus=p_,Pc.useFormState=On,Pc.useActionState=On,Pc.useOptimistic=function(l,u){var p=C();return Pn!==null?vt(p,Pn,l,u):(p.baseState=l,[l,p.queue.dispatch])};var AS={isMounted:function(l){return(l=l._reactInternals)?d(l)===l:!1},enqueueSetState:function(l,u,p){l=l._reactInternals;var x=lr(),T=ke(x);T.payload=u,p!=null&&(T.callback=p),u=Ve(l,T,x),u!==null&&(Ra(u,l,x),St(u,l,x))},enqueueReplaceState:function(l,u,p){l=l._reactInternals;var x=lr(),T=ke(x);T.tag=1,T.payload=u,p!=null&&(T.callback=p),u=Ve(l,T,x),u!==null&&(Ra(u,l,x),St(u,l,x))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var p=lr(),x=ke(p);x.tag=2,u!=null&&(x.callback=u),u=Ve(l,x,p),u!==null&&(Ra(u,l,p),St(u,l,p))}},nR=typeof reportError=="function"?reportError:function(l){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var u=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof l=="object"&&l!==null&&typeof l.message=="string"?String(l.message):String(l),error:l});if(!window.dispatchEvent(u))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",l);return}console.error(l)},iR=Error(a(461)),Ki=!1,ES={dehydrated:null,treeContext:null,retryLane:0},_g=S(null),Fc=null,mo=null,gL=typeof AbortController<"u"?AbortController:function(){var l=[],u=this.signal={aborted:!1,addEventListener:function(p,x){l.push(x)}};this.abort=function(){u.aborted=!0,l.forEach(function(p){return p()})}},vL=cr.unstable_scheduleCallback,xL=cr.unstable_NormalPriority,_i={$$typeof:vl,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},aR=Zt.S;Zt.S=function(l,u){typeof u=="object"&&u!==null&&typeof u.then=="function"&&we(l,u),aR!==null&&aR(l,u)};var Hc=S(null),go=!1,Si=!1,TS=!1,rR=typeof WeakSet=="function"?WeakSet:Set,Ji=null,sR=!1,Bi=null,dr=!1,ms=null,Ph=8192,yL={getCacheForType:function(l){var u=va(_i),p=u.data.get(l);return p===void 0&&(p=l(),u.data.set(l,p)),p}},Sg=0,Ag=1,Eg=2,Tg=3,bg=4;if(typeof Symbol=="function"&&Symbol.for){var dp=Symbol.for;Sg=dp("selector.component"),Ag=dp("selector.has_pseudo_class"),Eg=dp("selector.role"),Tg=dp("selector.test_id"),bg=dp("selector.text")}var _L=typeof WeakMap=="function"?WeakMap:Map,Fn=0,Yn=null,cn=null,xn=0,qn=0,pr=null,vo=!1,Fh=!1,bS=!1,xo=0,Ai=0,Tl=0,zc=0,MS=0,Hr=0,Hh=0,pp=null,Gs=null,CS=!1,RS=0,mp=1/0,Mg=null,bl=null,Cg=!1,Gc=null,gp=0,wS=0,DS=null,vp=0,NS=null;return ln.attemptContinuousHydration=function(l){if(l.tag===13){var u=ze(l,67108864);u!==null&&Ra(u,l,67108864),J_(l,67108864)}},ln.attemptHydrationAtCurrentPriority=function(l){if(l.tag===13){var u=lr(),p=ze(l,u);p!==null&&Ra(p,l,u),J_(l,u)}},ln.attemptSynchronousHydration=function(l){switch(l.tag){case 3:if(l=l.stateNode,l.current.memoizedState.isDehydrated){var u=b(l.pendingLanes);if(u!==0){for(l.pendingLanes|=2,l.entangledLanes|=2;u;){var p=1<<31-ur(u);l.entanglements[1]|=p,u&=~p}ot(l),!(Fn&6)&&(mp=ds()+500,rt(0))}}break;case 13:u=ze(l,2),u!==null&&Ra(u,l,2),rC(),J_(l,2)}},ln.batchedUpdates=function(l,u){return l(u)},ln.createComponentSelector=function(l){return{$$typeof:Sg,value:l}},ln.createContainer=function(l,u,p,x,T,R,X,re,ye,Xe){return yC(l,u,!1,null,p,x,R,X,re,ye,Xe,null)},ln.createHasPseudoClassSelector=function(l){return{$$typeof:Ag,value:l}},ln.createHydrationContainer=function(l,u,p,x,T,R,X,re,ye,Xe,ct,At,Mt){return l=yC(p,x,!0,l,T,R,re,ye,Xe,ct,At,Mt),l.context=_C(null),p=l.current,x=lr(),T=ke(x),T.callback=u??null,Ve(p,T,x),l.current.lanes=x,G(l,x),ot(l),l},ln.createPortal=function(l,u,p){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_h,key:x==null?null:""+x,children:l,containerInfo:u,implementation:p}},ln.createRoleSelector=function(l){return{$$typeof:Eg,value:l}},ln.createTestNameSelector=function(l){return{$$typeof:Tg,value:l}},ln.createTextSelector=function(l){return{$$typeof:bg,value:l}},ln.defaultOnCaughtError=function(l){console.error(l)},ln.defaultOnRecoverableError=function(l){nR(l)},ln.defaultOnUncaughtError=function(l){nR(l)},ln.deferredUpdates=function(l){var u=Zt.T,p=Nc();try{return Wa(32),Zt.T=null,l()}finally{Wa(p),Zt.T=u}},ln.discreteUpdates=function(l,u,p,x,T){var R=Zt.T,X=Nc();try{return Wa(2),Zt.T=null,l(u,p,x,T)}finally{Wa(X),Zt.T=R,Fn===0&&(mp=ds()+500)}},ln.findAllNodes=V_,ln.findBoundingRects=function(l,u){if(!rp)throw Error(a(363));u=V_(l,u),l=[];for(var p=0;p<u.length;p++)l.push(fU(u[p]));for(u=l.length-1;0<u;u--){p=l[u];for(var x=p.x,T=x+p.width,R=p.y,X=R+p.height,re=u-1;0<=re;re--)if(u!==re){var ye=l[re],Xe=ye.x,ct=Xe+ye.width,At=ye.y,Mt=At+ye.height;if(x>=Xe&&R>=At&&T<=ct&&X<=Mt){l.splice(u,1);break}else if(x!==Xe||p.width!==ye.width||Mt<R||At>X){if(!(R!==At||p.height!==ye.height||ct<x||Xe>T)){Xe>x&&(ye.width+=Xe-x,ye.x=x),ct<T&&(ye.width=T-Xe),l.splice(u,1);break}}else{At>R&&(ye.height+=At-R,ye.y=R),Mt<X&&(ye.height=X-At),l.splice(u,1);break}}}return l},ln.findHostInstance=SC,ln.findHostInstanceWithNoPortals=function(l){return l=g(l),l=l!==null?E(l):null,l===null?null:ap(l.stateNode)},ln.findHostInstanceWithWarning=function(l){return SC(l)},ln.flushPassiveEffects=wc,ln.flushSyncFromReconciler=function(l){var u=Fn;Fn|=1;var p=Zt.T,x=Nc();try{if(Wa(2),Zt.T=null,l)return l()}finally{Wa(x),Zt.T=p,Fn=u,!(Fn&6)&&rt(0)}},ln.flushSyncWork=rC,ln.focusWithin=function(l,u){if(!rp)throw Error(a(363));for(l=H_(l),u=tC(l,u),u=Array.from(u),l=0;l<u.length;){var p=u[l++],x=p.tag;if(!sp(p)){if((x===5||x===26||x===27)&&mU(p.stateNode))return!0;for(p=p.child;p!==null;)u.push(p),p=p.sibling}}return!1},ln.getFindAllNodesFailureDescription=function(l,u){if(!rp)throw Error(a(363));var p=0,x=[];l=[H_(l),0];for(var T=0;T<l.length;){var R=l[T++],X=R.tag,re=l[T++],ye=u[re];if((X!==5&&X!==26&&X!==27||!sp(R))&&(z_(R,ye)&&(x.push(G_(ye)),re++,re>p&&(p=re)),re<u.length))for(R=R.child;R!==null;)l.push(R,re),R=R.sibling}if(p<u.length){for(l=[];p<u.length;p++)l.push(G_(u[p]));return`findAllNodes was able to match part of the selector:
`+(x.join(" > ")+`
No matching component was found for:
`)+l.join(" > ")}return null},ln.getPublicRootInstance=function(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 27:case 5:return ap(l.child.stateNode);default:return l.child.stateNode}},ln.injectIntoDevTools=function(){var l={bundleType:0,version:Y9,rendererPackageName:q9,currentDispatcherRef:Zt,findFiberByHostInstance:OC,reconcilerVersion:"19.0.0"};if(wC!==null&&(l.rendererConfig=wC),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")l=!1;else{var u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(u.isDisabled||!u.supportsFiber)l=!0;else{try{op=u.inject(l),hr=u}catch{}l=!!u.checkDCE}}return l},ln.isAlreadyRendering=function(){return!1},ln.observeVisibleRects=function(l,u,p,x){if(!rp)throw Error(a(363));l=V_(l,u);var T=gU(l,p,x).disconnect;return{disconnect:function(){T()}}},ln.shouldError=function(){return null},ln.shouldSuspend=function(){return!1},ln.startHostTransition=function(l,u,p,x){if(l.tag!==5)throw Error(a(476));var T=cM(l).queue;lM(l,T,u,Ah,p===null?i:function(){var R=cM(l).next.queue;return Kd(l,R,{},lr()),p(x)})},ln.updateContainer=function(l,u,p,x){var T=u.current,R=lr();return AC(T,R,l,u,p,x),R},ln.updateContainerSync=function(l,u,p,x){return u.tag===0&&wc(),AC(u.current,2,l,u,p,x),2},ln},n.exports.default=n.exports,Object.defineProperty(n.exports,"__esModule",{value:!0})})(h8);var oq=h8.exports;u8.exports=oq;var lq=u8.exports;const cq=Zx(lq);function gb(n,e,t){if(!n)return;if(t(n)===!0)return n;let i=e?n.return:n.child;for(;i;){const a=gb(i,e,t);if(a)return a;i=e?null:i.sibling}}function p8(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const vb=p8(he.createContext(null));let m8=class extends he.Component{render(){return he.createElement(vb.Provider,{value:this._reactInternals},this.props.children)}};function g8(){const n=he.useContext(vb);if(n===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=he.useId();return he.useMemo(()=>{for(const t of[n,n==null?void 0:n.alternate]){if(!t)continue;const i=gb(t,!1,a=>{let r=a.memoizedState;for(;r;){if(r.memoizedState===e)return!0;r=r.next}});if(i)return i}},[n,e])}const uq=Symbol.for("react.context"),hq=n=>n!==null&&typeof n=="object"&&"$$typeof"in n&&n.$$typeof===uq;function fq(){const n=g8(),[e]=he.useState(()=>new Map);e.clear();let t=n;for(;t;){const i=t.type;hq(i)&&i!==vb&&!e.has(i)&&e.set(i,he.use(p8(i))),t=t.return}return e}function dq(){const n=fq();return he.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>i=>he.createElement(e,null,he.createElement(t.Provider,{...i,value:n.get(t)})),e=>he.createElement(m8,{...e})),[n])}function v8(n){let e=n.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const x8=n=>n&&n.isOrthographicCamera,pq=n=>n&&n.hasOwnProperty("current"),mq=n=>n!=null&&(typeof n=="string"||typeof n=="number"||n.isColor),F0=((n,e)=>typeof window<"u"&&(((n=window.document)==null?void 0:n.createElement)||((e=window.navigator)==null?void 0:e.product)==="ReactNative"))()?he.useLayoutEffect:he.useEffect;function xb(n){const e=he.useRef(n);return F0(()=>void(e.current=n),[n]),e}function gq(){const n=g8(),e=dq();return he.useMemo(()=>({children:t})=>{const a=!!gb(n,!0,r=>r.type===he.StrictMode)?he.StrictMode:he.Fragment;return It.jsx(a,{children:It.jsx(e,{children:t})})},[n,e])}function vq({set:n}){return F0(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}const xq=(n=>(n=class extends he.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 y8(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 uf(n){var e;return(e=n.__r3f)==null?void 0:e.root.getState()}const ci={obj:n=>n===Object(n)&&!ci.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:a=!0}={}){if(typeof n!=typeof e||!!n!=!!e)return!1;if(ci.str(n)||ci.num(n)||ci.boo(n))return n===e;const r=ci.obj(n);if(r&&i==="reference")return n===e;const s=ci.arr(n);if(s&&t==="reference")return n===e;if((s||r)&&n===e)return!0;let o;for(o in n)if(!(o in e))return!1;if(r&&t==="shallow"&&i==="shallow"){for(o in a?e:n)if(!ci.equ(n[o],e[o],{strict:a,objects:"reference"}))return!1}else for(o in a?e:n)if(n[o]!==e[o])return!1;if(ci.und(o)){if(s&&n.length===0&&e.length===0||r&&Object.keys(n).length===0&&Object.keys(e).length===0)return!0;if(n!==e)return!1}return!0}};function yq(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 _q(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 _8=["children","key","ref"];function Sq(n){const e={};for(const t in n)_8.includes(t)||(e[t]=n[t]);return e}function Nx(n,e,t,i){const a=n;let r=a==null?void 0:a.__r3f;return r||(r={root:e,type:t,parent:null,children:[],props:Sq(i),object:a,eventCount:0,handlers:{},isHidden:!1},a&&(a.__r3f=r)),r}function u0(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 a of i){if(typeof t!="object"||t===null){if(t!==void 0){const r=i.slice(i.indexOf(a)).join("-");return{root:t,key:r,target:void 0}}return{root:n,key:e,target:void 0}}e=a,n=t,t=t[e]}return{root:n,key:e,target:t}}const sD=/-\d+$/;function Ox(n,e){if(ci.str(e.props.attach)){if(sD.test(e.props.attach)){const a=e.props.attach.replace(sD,""),{root:r,key:s}=u0(n.object,a);Array.isArray(r[s])||(r[s]=[])}const{root:t,key:i}=u0(n.object,e.props.attach);e.previousAttach=t[i],t[i]=e.object}else ci.fun(e.props.attach)&&(e.previousAttach=e.props.attach(n.object,e.object))}function Ix(n,e){if(ci.str(e.props.attach)){const{root:t,key:i}=u0(n.object,e.props.attach),a=e.previousAttach;a===void 0?delete t[i]:t[i]=a}else e.previousAttach==null||e.previousAttach(n.object,e.object);delete e.previousAttach}const GE=[..._8,"args","dispose","attach","object","onUpdate","dispose"],oD=new Map;function Aq(n){let e=oD.get(n.constructor);try{e||(e=new n.constructor,oD.set(n.constructor,e))}catch{}return e}function Eq(n,e){const t={};for(const i in e)if(!GE.includes(i)&&!ci.equ(e[i],n.props[i])){t[i]=e[i];for(const a in e)a.startsWith(`${i}-`)&&(t[a]=e[a])}for(const i in n.props){if(GE.includes(i)||e.hasOwnProperty(i))continue;const{root:a,key:r}=u0(n.object,i);if(a.constructor&&a.constructor.length===0){const s=Aq(a);ci.und(s)||(t[r]=s[r])}else t[r]=0}return t}const Tq=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],bq=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function Ks(n,e){var t;const i=n.__r3f,a=i&&v8(i).getState(),r=i==null?void 0:i.eventCount;for(const o in e){let c=e[o];if(GE.includes(o))continue;if(i&&bq.test(o)){typeof c=="function"?i.handlers[o]=c:delete i.handlers[o],i.eventCount=Object.keys(i.handlers).length;continue}if(c===void 0)continue;let{root:h,key:f,target:d}=u0(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 yd&&c instanceof yd)d.mask=c.mask;else if(d instanceof dt&&mq(c))d.set(c);else if(d!==null&&typeof d=="object"&&typeof d.set=="function"&&typeof d.copy=="function"&&c!=null&&c.constructor&&d.constructor===c.constructor)d.copy(c);else if(d!==null&&typeof d=="object"&&typeof d.set=="function"&&Array.isArray(c))typeof d.fromArray=="function"?d.fromArray(c):d.set(...c);else if(d!==null&&typeof d=="object"&&typeof d.set=="function"&&typeof c=="number")typeof d.setScalar=="function"?d.setScalar(c):d.set(c);else{var s;h[f]=c,a&&!a.linear&&Tq.includes(f)&&(s=h[f])!=null&&s.isTexture&&h[f].format===Rn&&h[f].type===xi&&(h[f].colorSpace=Kn)}}if(i!=null&&i.parent&&a!=null&&a.internal&&(t=i.object)!=null&&t.isObject3D&&r!==i.eventCount){const o=i.object,c=a.internal.interaction.indexOf(o);c>-1&&a.internal.interaction.splice(c,1),i.eventCount&&o.raycast!==null&&a.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&&Vd(i),n}function Vd(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 S8(n,e){n.manual||(x8(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 Oa=n=>n==null?void 0:n.isObject3D;function Bv(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function A8(n,e,t,i){const a=t.get(e);a&&(t.delete(e),t.size===0&&(n.delete(i),a.target.releasePointerCapture(i)))}function Mq(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,a)=>{(i.eventObject===e||i.object===e)&&t.hovered.delete(a)}),t.capturedMap.forEach((i,a)=>{A8(t.capturedMap,e,i,a)})}function Cq(n){function e(c){const{internal:h}=n.getState(),f=c.offsetX-h.initialClick[0],d=c.offsetY-h.initialClick[1];return Math.round(Math.sqrt(f*f+d*d))}function t(c){return c.filter(h=>["Move","Over","Enter","Out","Leave"].some(f=>{var d;return(d=h.__r3f)==null?void 0:d.handlers["onPointer"+f]}))}function i(c,h){const f=n.getState(),d=new Set,m=[],g=h?h(f.internal.interaction):f.internal.interaction;for(let v=0;v<g.length;v++){const _=uf(g[v]);_&&(_.raycaster.camera=void 0)}f.previousRoot||f.events.compute==null||f.events.compute(c,f);function y(v){const _=uf(v);if(!_||!_.events.enabled||_.raycaster.camera===null)return[];if(_.raycaster.camera===void 0){var A;_.events.compute==null||_.events.compute(c,_,(A=_.previousRoot)==null?void 0:A.getState()),_.raycaster.camera===void 0&&(_.raycaster.camera=null)}return _.raycaster.camera?_.raycaster.intersectObject(v,!0):[]}let E=g.flatMap(y).sort((v,_)=>{const A=uf(v.object),b=uf(_.object);return!A||!b?v.distance-_.distance:b.events.priority-A.events.priority||v.distance-_.distance}).filter(v=>{const _=Bv(v);return d.has(_)?!1:(d.add(_),!0)});f.events.filter&&(E=f.events.filter(E,f));for(const v of E){let _=v.object;for(;_;){var S;(S=_.__r3f)!=null&&S.eventCount&&m.push({...v,eventObject:_}),_=_.parent}}if("pointerId"in c&&f.internal.capturedMap.has(c.pointerId))for(let v of f.internal.capturedMap.get(c.pointerId).values())d.has(Bv(v.intersection))||m.push(v.intersection);return m}function a(c,h,f,d){if(c.length){const m={stopped:!1};for(const g of c){let y=uf(g.object);if(y||g.object.traverseAncestors(E=>{const S=uf(E);if(S)return y=S,!1}),y){const{raycaster:E,pointer:S,camera:v,internal:_}=y,A=new H(S.x,S.y,0).unproject(v),b=w=>{var D,G;return(D=(G=_.capturedMap.get(w))==null?void 0:G.has(g.eventObject))!=null?D:!1},O=w=>{const D={intersection:g,target:h.target};_.capturedMap.has(w)?_.capturedMap.get(w).set(g.eventObject,D):_.capturedMap.set(w,new Map([[g.eventObject,D]])),h.target.setPointerCapture(w)},N=w=>{const D=_.capturedMap.get(w);D&&A8(_.capturedMap,g.eventObject,D,w)};let L={};for(let w in h){let D=h[w];typeof D!="function"&&(L[w]=D)}let B={...g,...L,pointer:S,intersections:c,stopped:m.stopped,delta:f,unprojectedPoint:A,ray:E.ray,camera:v,stopPropagation(){const w="pointerId"in h&&_.capturedMap.get(h.pointerId);if((!w||w.has(g.eventObject))&&(B.stopped=m.stopped=!0,_.hovered.size&&Array.from(_.hovered.values()).find(D=>D.eventObject===g.eventObject))){const D=c.slice(0,c.indexOf(g));r([...D,g])}},target:{hasPointerCapture:b,setPointerCapture:O,releasePointerCapture:N},currentTarget:{hasPointerCapture:b,setPointerCapture:O,releasePointerCapture:N},nativeEvent:h};if(d(B),m.stopped===!0)break}}}return c}function r(c){const{internal:h}=n.getState();for(const f of h.hovered.values())if(!c.length||!c.find(d=>d.object===f.object&&d.index===f.index&&d.instanceId===f.instanceId)){const m=f.eventObject.__r3f;if(h.hovered.delete(Bv(f)),m!=null&&m.eventCount){const g=m.handlers,y={...f,intersections:c};g.onPointerOut==null||g.onPointerOut(y),g.onPointerLeave==null||g.onPointerLeave(y)}}}function s(c,h){for(let f=0;f<h.length;f++){const d=h[f].__r3f;d==null||d.handlers.onPointerMissed==null||d.handlers.onPointerMissed(c)}}function o(c){switch(c){case"onPointerLeave":case"onPointerCancel":return()=>r([]);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),r([]))})}}return function(f){const{onPointerMissed:d,internal:m}=n.getState();m.lastEvent.current=f;const g=c==="onPointerMove",y=c==="onClick"||c==="onContextMenu"||c==="onDoubleClick",S=i(f,g?t:void 0),v=y?e(f):0;c==="onPointerDown"&&(m.initialClick=[f.offsetX,f.offsetY],m.initialHits=S.map(A=>A.eventObject)),y&&!S.length&&v<=2&&(s(f,m.interaction),d&&d(f)),g&&r(S);function _(A){const b=A.eventObject,O=b.__r3f;if(!(O!=null&&O.eventCount))return;const N=O.handlers;if(g){if(N.onPointerOver||N.onPointerEnter||N.onPointerOut||N.onPointerLeave){const L=Bv(A),B=m.hovered.get(L);B?B.stopped&&A.stopPropagation():(m.hovered.set(L,A),N.onPointerOver==null||N.onPointerOver(A),N.onPointerEnter==null||N.onPointerEnter(A))}N.onPointerMove==null||N.onPointerMove(A)}else{const L=N[c];L?(!y||m.initialHits.includes(b))&&(s(f,m.interaction.filter(B=>!m.initialHits.includes(B))),L(A)):y&&m.initialHits.includes(b)&&s(f,m.interaction.filter(B=>!m.initialHits.includes(B)))}}a(S,f,v,_)}}return{handlePointer:o}}const lD=n=>!!(n!=null&&n.render),yb=he.createContext(null),Rq=(n,e)=>{const t=o8((o,c)=>{const h=new H,f=new H,d=new H;function m(v=c().camera,_=f,A=c().size){const{width:b,height:O,top:N,left:L}=A,B=b/O;_.isVector3?d.copy(_):d.set(..._);const w=v.getWorldPosition(h).distanceTo(d);if(x8(v))return{width:b/v.zoom,height:O/v.zoom,top:N,left:L,factor:1,distance:w,aspect:B};{const D=v.fov*Math.PI/180,G=2*Math.tan(D/2)*w,J=G*(b/O);return{width:J,height:G,top:N,left:L,factor:b/J,distance:w,aspect:B}}}let g;const y=v=>o(_=>({performance:{..._.performance,current:v}})),E=new Ee;return{set:o,get:c,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(v=1)=>n(c(),v),advance:(v,_)=>e(v,_,c()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new hb,pointer:E,mouse:E,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const v=c();g&&clearTimeout(g),v.performance.current!==v.performance.min&&y(v.performance.min),g=setTimeout(()=>y(c().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:m},setEvents:v=>o(_=>({..._,events:{..._.events,...v}})),setSize:(v,_,A=0,b=0)=>{const O=c().camera,N={width:v,height:_,top:A,left:b};o(L=>({size:N,viewport:{...L.viewport,...m(O,f,N)}}))},setDpr:v=>o(_=>{const A=y8(v);return{viewport:{..._.viewport,dpr:A,initialDpr:_.viewport.initialDpr||A}}}),setFrameloop:(v="always")=>{const _=c().clock;_.stop(),_.elapsedTime=0,v!=="never"&&(_.start(),_.elapsedTime=0),o(()=>({frameloop:v}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:he.createRef(),active:!1,frames:0,priority:0,subscribe:(v,_,A)=>{const b=c().internal;return b.priority=b.priority+(_>0?1:0),b.subscribers.push({ref:v,priority:_,store:A}),b.subscribers=b.subscribers.sort((O,N)=>O.priority-N.priority),()=>{const O=c().internal;O!=null&&O.subscribers&&(O.priority=O.priority-(_>0?1:0),O.subscribers=O.subscribers.filter(N=>N.ref!==v))}}}}}),i=t.getState();let a=i.size,r=i.viewport.dpr,s=i.camera;return t.subscribe(()=>{const{camera:o,size:c,viewport:h,gl:f,set:d}=t.getState();if(c.width!==a.width||c.height!==a.height||h.dpr!==r){a=c,r=h.dpr,S8(o,c),h.dpr>0&&f.setPixelRatio(h.dpr);const m=typeof HTMLCanvasElement<"u"&&f.domElement instanceof HTMLCanvasElement;f.setSize(c.width,c.height,m)}o!==s&&(s=o,d(m=>({viewport:{...m.viewport,...m.viewport.getCurrentViewport(o)}})))}),t.subscribe(o=>n(o)),t};function _b(){const n=he.useContext(yb);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function jn(n=t=>t,e){return _b()(n,e)}function Ls(n,e=0){const t=_b(),i=t.getState().internal.subscribe,a=xb(n);return F0(()=>i(a,e,t),[e,i,t]),null}const cD=new WeakMap,wq=n=>{var e;return typeof n=="function"&&(n==null||(e=n.prototype)==null?void 0:e.constructor)===n};function E8(n,e){return function(t,...i){let a;return wq(t)?(a=cD.get(t),a||(a=new t,cD.set(t,a))):a=t,n&&n(a),Promise.all(i.map(r=>new Promise((s,o)=>a.load(r,c=>{Oa(c==null?void 0:c.scene)&&Object.assign(c,yq(c.scene)),s(c)},e,c=>o(new Error(`Could not load ${r}: ${c==null?void 0:c.message}`))))))}}function sl(n,e,t,i){const a=Array.isArray(e)?e:[e],r=aq(E8(t,i),[n,...a],{equal:ci.equ});return Array.isArray(e)?r:r[0]}sl.preload=function(n,e,t){const i=Array.isArray(e)?e:[e];return rq(E8(t),[n,...i])};sl.clear=function(n,e){const t=Array.isArray(e)?e:[e];return sq([n,...t])};function Dq(n){const e=cq(n);return e.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:he.version}),e}const T8=0,Td={},Nq=/^three(?=[A-Z])/,Wy=n=>`${n[0].toUpperCase()}${n.slice(1)}`;let Oq=0;const Iq=n=>typeof n=="function";function Sb(n){if(Iq(n)){const e=`${Oq++}`;return Td[e]=n,e}else Object.assign(Td,n)}function b8(n,e){const t=Wy(n),i=Td[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 Bq(n,e,t){var i;return n=Wy(n)in Td?n:n.replace(Nq,""),b8(n,e),n==="primitive"&&(i=e.object)!=null&&i.__r3f&&delete e.object.__r3f,Nx(e.object,t,n,e)}function Uq(n){if(!n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Ix(n.parent,n):Oa(n.object)&&(n.object.visible=!1),n.isHidden=!0,Vd(n)}}function M8(n){if(n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Ox(n.parent,n):Oa(n.object)&&n.props.visible!==!1&&(n.object.visible=!0),n.isHidden=!1,Vd(n)}}function Ab(n,e,t){const i=e.root.getState();if(!(!n.parent&&n.object!==i.scene)){if(!e.object){var a,r;const s=Td[Wy(e.type)];e.object=(a=e.props.object)!=null?a:new s(...(r=e.props.args)!=null?r:[]),e.object.__r3f=e}if(Ks(e.object,e.props),e.props.attach)Ox(n,e);else if(Oa(e.object)&&Oa(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 c=o<s?s-1:s;n.object.children.splice(c,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)Ab(e,s);Vd(e)}}function i2(n,e){e&&(e.parent=n,n.children.push(e),Ab(n,e))}function uD(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),Ab(n,e,t)}function C8(n){if(typeof n.dispose=="function"){const e=()=>{try{n.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<"u"?e():zE.unstable_scheduleCallback(zE.unstable_IdlePriority,e)}}function VE(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?Ix(n,e):Oa(e.object)&&Oa(n.object)&&(n.object.remove(e.object),Mq(v8(e),e.object));const a=e.props.dispose!==null&&t!==!1;for(let r=e.children.length-1;r>=0;r--){const s=e.children[r];VE(e,s,a)}e.children.length=0,delete e.object.__r3f,a&&e.type!=="primitive"&&e.object.type!=="Scene"&&C8(e.object),t===void 0&&Vd(e)}function Lq(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 d1=[];function Pq(){for(const[t]of d1){const i=t.parent;if(i){t.props.attach?Ix(i,t):Oa(t.object)&&Oa(i.object)&&i.object.remove(t.object);for(const a of t.children)a.props.attach?Ix(t,a):Oa(a.object)&&Oa(t.object)&&t.object.remove(a.object)}t.isHidden&&M8(t),t.object.__r3f&&delete t.object.__r3f,t.type!=="primitive"&&C8(t.object)}for(const[t,i,a]of d1){t.props=i;const r=t.parent;if(r){var n,e;const s=Td[Wy(t.type)];t.object=(n=t.props.object)!=null?n:new s(...(e=t.props.args)!=null?e:[]),t.object.__r3f=t,Lq(a,t.object),Ks(t.object,t.props),t.props.attach?Ox(r,t):Oa(t.object)&&Oa(r.object)&&r.object.add(t.object);for(const o of t.children)o.props.attach?Ox(t,o):Oa(o.object)&&Oa(t.object)&&t.object.add(o.object);Vd(t)}}d1.length=0}const a2=()=>{},hD={};let Uv=T8;const Fq=0,Hq=4,Bx=Dq({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:Bq,removeChild:VE,appendChild:i2,appendInitialChild:i2,insertBefore:uD,appendChildToContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||i2(t,e)},removeChildFromContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||VE(t,e)},insertInContainerBefore(n,e,t){const i=n.getState().scene.__r3f;!e||!t||!i||uD(i,e,t)},getRootHostContext:()=>hD,getChildHostContext:()=>hD,commitUpdate(n,e,t,i,a){var r,s,o;b8(e,i);let c=!1;if((n.type==="primitive"&&t.object!==i.object||((r=i.args)==null?void 0:r.length)!==((s=t.args)==null?void 0:s.length)||(o=i.args)!=null&&o.some((f,d)=>{var m;return f!==((m=t.args)==null?void 0:m[d])}))&&(c=!0),c)d1.push([n,{...i},a]);else{const f=Eq(n,i);Object.keys(f).length&&(Object.assign(n.props,f),Ks(n.object,f))}(a.sibling===null||(a.flags&Hq)===Fq)&&Pq()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:n=>n==null?void 0:n.object,prepareForCommit:()=>null,preparePortalMount:n=>Nx(n.getState().scene,n,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:Uq,unhideInstance:M8,createTextInstance:a2,hideTextInstance:a2,unhideTextInstance:a2,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:he.createContext(null),setCurrentUpdatePriority(n){Uv=n},getCurrentUpdatePriority(){return Uv},resolveUpdatePriority(){var n;if(Uv!==T8)return Uv;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 c1.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return c1.ContinuousEventPriority;default:return c1.DefaultEventPriority}},resetFormInstance(){}}),Ku=new Map,hf={objects:"shallow",strict:!1};function zq(n,e){if(!e&&typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&n.parentElement){const{width:t,height:i,top:a,left:r}=n.parentElement.getBoundingClientRect();return{width:t,height:i,top:a,left:r}}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 Gq(n){const e=Ku.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 a=typeof reportError=="function"?reportError:console.error,r=i||Rq(WE,dD),s=t||Bx.createContainer(r,c1.ConcurrentRoot,null,!1,null,"",a,a,a,null);e||Ku.set(n,{fiber:s,store:r});let o,c,h=!1,f=null;return{async configure(d={}){let m;f=new Promise(Pe=>m=Pe);let{gl:g,size:y,scene:E,events:S,onCreated:v,shadows:_=!1,linear:A=!1,flat:b=!1,legacy:O=!1,orthographic:N=!1,frameloop:L="always",dpr:B=[1,2],performance:w,raycaster:D,camera:G,onPointerMissed:J}=d,$=r.getState(),se=$.gl;if(!$.gl){const Pe={canvas:n,powerPreference:"high-performance",antialias:!0,alpha:!0},He=typeof g=="function"?await g(Pe):g;lD(He)?se=He:se=new ky({...Pe,...g}),$.set({gl:se})}let le=$.raycaster;le||$.set({raycaster:le=new pb});const{params:q,...te}=D||{};if(ci.equ(te,le,hf)||Ks(le,{...te}),ci.equ(q,le.params,hf)||Ks(le,{params:{...le.params,...q}}),!$.camera||$.camera===c&&!ci.equ(c,G,hf)){c=G;const Pe=G==null?void 0:G.isCamera,He=Pe?G:N?new Rr(0,0,0,0,.1,1e3):new Jn(75,0,.1,1e3);Pe||(He.position.z=5,G&&(Ks(He,G),He.manual||("aspect"in G||"left"in G||"right"in G||"bottom"in G||"top"in G)&&(He.manual=!0,He.updateProjectionMatrix())),!$.camera&&!(G!=null&&G.rotation)&&He.lookAt(0,0,0)),$.set({camera:He}),le.camera=He}if(!$.scene){let Pe;E!=null&&E.isScene?(Pe=E,Nx(Pe,r,"",{})):(Pe=new al,Nx(Pe,r,"",{}),E&&Ks(Pe,E)),$.set({scene:Pe})}S&&!$.events.handlers&&$.set({events:S(r)});const ee=zq(n,y);if(ci.equ(ee,$.size,hf)||$.setSize(ee.width,ee.height,ee.top,ee.left),B&&$.viewport.dpr!==y8(B)&&$.setDpr(B),$.frameloop!==L&&$.setFrameloop(L),$.onPointerMissed||$.set({onPointerMissed:J}),w&&!ci.equ(w,$.performance,hf)&&$.set(Pe=>({performance:{...Pe.performance,...w}})),!$.xr){var de;const Pe=(nt,xt)=>{const fe=r.getState();fe.frameloop!=="never"&&dD(nt,!0,fe,xt)},He=()=>{const nt=r.getState();nt.gl.xr.enabled=nt.gl.xr.isPresenting,nt.gl.xr.setAnimationLoop(nt.gl.xr.isPresenting?Pe:null),nt.gl.xr.isPresenting||WE(nt)},Ke={connect(){const nt=r.getState().gl;nt.xr.addEventListener("sessionstart",He),nt.xr.addEventListener("sessionend",He)},disconnect(){const nt=r.getState().gl;nt.xr.removeEventListener("sessionstart",He),nt.xr.removeEventListener("sessionend",He)}};typeof((de=se.xr)==null?void 0:de.addEventListener)=="function"&&Ke.connect(),$.set({xr:Ke})}if(se.shadowMap){const Pe=se.shadowMap.enabled,He=se.shadowMap.type;if(se.shadowMap.enabled=!!_,ci.boo(_))se.shadowMap.type=Am;else if(ci.str(_)){var ue;const Ke={basic:g5,percentage:fy,soft:Am,variance:Es};se.shadowMap.type=(ue=Ke[_])!=null?ue:Am}else ci.obj(_)&&Object.assign(se.shadowMap,_);(Pe!==se.shadowMap.enabled||He!==se.shadowMap.type)&&(se.shadowMap.needsUpdate=!0)}return gn.enabled=!O,h||(se.outputColorSpace=A?Fi:Kn,se.toneMapping=b?ns:C3),$.legacy!==O&&$.set(()=>({legacy:O})),$.linear!==A&&$.set(()=>({linear:A})),$.flat!==b&&$.set(()=>({flat:b})),g&&!ci.fun(g)&&!lD(g)&&!ci.equ(g,se,hf)&&Ks(se,g),o=v,h=!0,m(),this},render(d){return!h&&!f&&this.configure(),f.then(()=>{Bx.updateContainer(It.jsx(Vq,{store:r,children:d,onCreated:o,rootElement:n}),s,null,()=>{})}),r},unmount(){R8(n)}}}function Vq({store:n,children:e,onCreated:t,rootElement:i}){return F0(()=>{const a=n.getState();a.set(r=>({internal:{...r.internal,active:!0}})),t&&t(a),n.getState().events.connected||a.events.connect==null||a.events.connect(i)},[]),It.jsx(yb.Provider,{value:n,children:e})}function R8(n,e){const t=Ku.get(n),i=t==null?void 0:t.fiber;if(i){const a=t==null?void 0:t.store.getState();a&&(a.internal.active=!1),Bx.updateContainer(null,i,null,()=>{a&&setTimeout(()=>{try{var r,s,o,c;a.events.disconnect==null||a.events.disconnect(),(r=a.gl)==null||(s=r.renderLists)==null||s.dispose==null||s.dispose(),(o=a.gl)==null||o.forceContextLoss==null||o.forceContextLoss(),(c=a.gl)!=null&&c.xr&&a.xr.disconnect(),_q(a.scene),Ku.delete(n)}catch{}},500)})}}function w8(n,e,t){return It.jsx(kq,{children:n,container:e,state:t})}function kq({state:n={},children:e,container:t}){const{events:i,size:a,...r}=n,s=_b(),[o]=he.useState(()=>new pb),[c]=he.useState(()=>new Ee),h=xb((d,m)=>{let g;if(m.camera&&a){const y=m.camera;g=d.viewport.getCurrentViewport(y,new H,a),y!==d.camera&&S8(y,a)}return{...d,...m,scene:t,raycaster:o,pointer:c,mouse:c,previousRoot:s,events:{...d.events,...m.events,...i},size:{...d.size,...a},viewport:{...d.viewport,...g},setEvents:y=>m.set(E=>({...E,events:{...E.events,...y}}))}}),f=he.useMemo(()=>{const d=o8((g,y)=>({...r,set:g,get:y})),m=g=>d.setState(y=>h.current(g,y));return m(s.getState()),s.subscribe(m),d},[s,t]);return It.jsx(It.Fragment,{children:Bx.createPortal(It.jsx(yb.Provider,{value:f,children:e}),f,null)})}const Xq=new Set,Wq=new Set,Yq=new Set;function r2(n,e){if(n.size)for(const{callback:t}of n.values())t(e)}function Dm(n,e){switch(n){case"before":return r2(Xq,e);case"after":return r2(Wq,e);case"tail":return r2(Yq,e)}}let s2,o2;function kE(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),s2=e.internal.subscribers;for(let a=0;a<s2.length;a++)o2=s2[a],o2.ref.current(o2.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 Ux=!1,XE=!1,l2,fD,ff;function D8(n){fD=requestAnimationFrame(D8),Ux=!0,l2=0,Dm("before",n),XE=!0;for(const t of Ku.values()){var e;ff=t.store.getState(),ff.internal.active&&(ff.frameloop==="always"||ff.internal.frames>0)&&!((e=ff.gl.xr)!=null&&e.isPresenting)&&(l2+=kE(n,ff))}if(XE=!1,Dm("after",n),l2===0)return Dm("tail",n),Ux=!1,cancelAnimationFrame(fD)}function WE(n,e=1){var t;if(!n)return Ku.forEach(i=>WE(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):XE?n.internal.frames=2:n.internal.frames=1,Ux||(Ux=!0,requestAnimationFrame(D8)))}function dD(n,e=!0,t,i){if(e&&Dm("before",n),t)kE(n,t,i);else for(const a of Ku.values())kE(n,a.store.getState());e&&Dm("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 qq(n){const{handlePointer:e}=Cq(n);return{priority:1,enabled:!0,compute(t,i,a){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:a}=n.getState();(t=a.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(a.lastEvent.current)},connect:t=>{const{set:i,events:a}=n.getState();if(a.disconnect==null||a.disconnect(),i(r=>({events:{...r.events,connected:t}})),a.handlers)for(const r in a.handlers){const s=a.handlers[r],[o,c]=c2[r];t.addEventListener(o,s,{passive:c})}},disconnect:()=>{const{set:t,events:i}=n.getState();if(i.connected){if(i.handlers)for(const a in i.handlers){const r=i.handlers[a],[s]=c2[a];i.connected.removeEventListener(s,r)}t(a=>({events:{...a.events,connected:void 0}}))}}}}function pD(n,e){let t;return(...i)=>{window.clearTimeout(t),t=window.setTimeout(()=>n(...i),e)}}function Zq({debounce:n,scroll:e,polyfill:t,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const a=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[r,s]=he.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),o=he.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:r,orientationHandler:null}),c=n?typeof n=="number"?n:n.scroll:null,h=n?typeof n=="number"?n:n.resize:null,f=he.useRef(!1);he.useEffect(()=>(f.current=!0,()=>void(f.current=!1)));const[d,m,g]=he.useMemo(()=>{const v=()=>{if(!o.current.element)return;const{left:_,top:A,width:b,height:O,bottom:N,right:L,x:B,y:w}=o.current.element.getBoundingClientRect(),D={left:_,top:A,width:b,height:O,bottom:N,right:L,x:B,y:w};o.current.element instanceof HTMLElement&&i&&(D.height=o.current.element.offsetHeight,D.width=o.current.element.offsetWidth),Object.freeze(D),f.current&&!Qq(o.current.lastBounds,D)&&s(o.current.lastBounds=D)};return[v,h?pD(v,h):v,c?pD(v,c):v]},[s,i,c,h]);function y(){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 E(){o.current.element&&(o.current.resizeObserver=new a(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 S=v=>{!v||v===o.current.element||(y(),o.current.element=v,o.current.scrollContainers=N8(v),E())};return Kq(g,!!e),jq(m),he.useEffect(()=>{y(),E()},[e,g,m]),he.useEffect(()=>y,[]),[S,r,d]}function jq(n){he.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[n])}function Kq(n,e){he.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[n,e])}function N8(n){const e=[];if(!n||n===document.body)return e;const{overflow:t,overflowX:i,overflowY:a}=window.getComputedStyle(n);return[t,i,a].some(r=>r==="auto"||r==="scroll")&&e.push(n),[...e,...N8(n.parentElement)]}const Jq=["x","y","top","bottom","left","right","width","height"],Qq=(n,e)=>Jq.every(t=>n[t]===e[t]);function $q({ref:n,children:e,fallback:t,resize:i,style:a,gl:r,events:s=qq,eventSource:o,eventPrefix:c,shadows:h,linear:f,flat:d,legacy:m,orthographic:g,frameloop:y,dpr:E,performance:S,raycaster:v,camera:_,scene:A,onPointerMissed:b,onCreated:O,...N}){he.useMemo(()=>Sb(OY),[]);const L=gq(),[B,w]=Zq({scroll:!0,debounce:{scroll:50,resize:0},...i}),D=he.useRef(null),G=he.useRef(null);he.useImperativeHandle(n,()=>D.current);const J=xb(b),[$,se]=he.useState(!1),[le,q]=he.useState(!1);if($)throw $;if(le)throw le;const te=he.useRef(null);F0(()=>{const de=D.current;if(w.width>0&&w.height>0&&de){te.current||(te.current=Gq(de));async function ue(){await te.current.configure({gl:r,scene:A,events:s,shadows:h,linear:f,flat:d,legacy:m,orthographic:g,frameloop:y,dpr:E,performance:S,raycaster:v,camera:_,size:w,onPointerMissed:(...Pe)=>J.current==null?void 0:J.current(...Pe),onCreated:Pe=>{Pe.events.connect==null||Pe.events.connect(o?pq(o)?o.current:o:G.current),c&&Pe.setEvents({compute:(He,Ke)=>{const nt=He[c+"X"],xt=He[c+"Y"];Ke.pointer.set(nt/Ke.size.width*2-1,-(xt/Ke.size.height)*2+1),Ke.raycaster.setFromCamera(Ke.pointer,Ke.camera)}}),O==null||O(Pe)}}),te.current.render(It.jsx(L,{children:It.jsx(xq,{set:q,children:It.jsx(he.Suspense,{fallback:It.jsx(vq,{set:se}),children:e??null})})}))}ue()}}),he.useEffect(()=>{const de=D.current;if(de)return()=>R8(de)},[]);const ee=o?"none":"auto";return It.jsx("div",{ref:G,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:ee,...a},...N,children:It.jsx("div",{ref:B,style:{width:"100%",height:"100%"},children:It.jsx("canvas",{ref:D,style:{display:"block"},children:t})})})}function eZ(n){return It.jsx(m8,{children:It.jsx($q,{...n})})}/**
* postprocessing v6.38.0 build Sat Nov 08 2025
* https://github.com/pmndrs/postprocessing
* Copyright 2015-2025 Raoul van Rüschen
* @license Zlib
*/var u2=1/1e3,tZ=1e3,nZ=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*u2}get fixedDelta(){return this._fixedDelta*u2}set fixedDelta(n){this._fixedDelta=n*tZ}get elapsed(){return this._elapsed*u2}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}},iZ=(()=>{const n=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]),t=new Xt;return t.setAttribute("position",new pn(n,3)),t.setAttribute("uv",new pn(e,2)),t})(),Ha=class YE{static get fullscreenGeometry(){return iZ}constructor(e="Pass",t=new al,i=new Rr){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 Xn(YE.fullscreenGeometry,e),t.frustumCulled=!1,this.scene===null&&(this.scene=new al),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=Sc){}render(e,t,i,a,r){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 oi||t instanceof ri||t instanceof vn||t instanceof YE)&&this[e].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},aZ=class extends Ha{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(n,e,t,i,a){const r=n.state.buffers.stencil;r.setLocked(!1),r.setTest(!1)}},rZ=`#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
}`,Eb="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",sZ=class extends Di{constructor(){super({name:"CopyMaterial",defines:{DEPTH_PACKING:"0",COLOR_WRITE:"1"},uniforms:{inputBuffer:new ie(null),depthBuffer:new ie(null),channelWeights:new ie(null),opacity:new ie(1)},blending:ga,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:rZ,vertexShader:Eb}),this.depthFunc=Qm}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}},O8=class extends Ha{constructor(n,e=!0){super("CopyPass"),this.fullscreenMaterial=new sZ,this.needsSwap=!1,this.renderTarget=n,n===void 0&&(this.renderTarget=new oi(1,1,{minFilter:Bt,magFilter:Bt,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,a){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!==xi?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":n!==null&&n.outputColorSpace===Kn&&(this.renderTarget.texture.colorSpace=Kn))}},mD=new dt,I8=class extends Ha{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,a){const r=this.overrideClearColor,s=this.overrideClearAlpha,o=n.getClearAlpha(),c=r!==null,h=s>=0;c?(n.getClearColor(mD),n.setClearColor(r,h?s:o)):h&&n.setClearAlpha(s),n.setRenderTarget(this.renderToScreen?null:e),n.clear(this.color,this.depth,this.stencil),c?n.setClearColor(mD,o):h&&n.setClearAlpha(o)}},oZ=class extends Ha{constructor(n,e){super("MaskPass",n,e),this.needsSwap=!1,this.clearPass=new I8(!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,a){const r=n.getContext(),s=n.state.buffers,o=this.scene,c=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(r.REPLACE,r.REPLACE,r.REPLACE),s.stencil.setFunc(r.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,c)):(n.setRenderTarget(e),n.render(o,c),n.setRenderTarget(t),n.render(o,c)),s.color.setLocked(!1),s.depth.setLocked(!1),s.stencil.setLocked(!1),s.stencil.setFunc(r.EQUAL,1,4294967295),s.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.stencil.setLocked(!0)}},lZ=class{constructor(n=null,{depthBuffer:e=!0,stencilBuffer:t=!1,multisampling:i=0,frameBufferType:a}={}){this.renderer=null,this.inputBuffer=this.createBuffer(e,t,a,i),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new O8,this.depthTexture=null,this.passes=[],this.timer=new nZ,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 Ee),t=n.getContext().getContextAttributes().alpha,i=this.inputBuffer.texture.type;i===xi&&n.outputColorSpace===Kn&&(this.inputBuffer.texture.colorSpace=Kn,this.outputBuffer.texture.colorSpace=Kn,this.inputBuffer.dispose(),this.outputBuffer.dispose()),n.autoClear=!1,this.setSize(e.width,e.height);for(const a of this.passes)a.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 N0;return this.inputBuffer.depthTexture=n,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(n.format=ku,n.type=Vu):n.type=ls,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 a=this.renderer,r=a===null?new Ee:a.getDrawingBufferSize(new Ee),s={minFilter:Bt,magFilter:Bt,stencilBuffer:e,depthBuffer:n,type:t},o=new oi(r.width,r.height,s);return i>0&&(o.samples=i),t===xi&&a!==null&&a.outputColorSpace===Kn&&(o.texture.colorSpace=Kn),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,a=i.getDrawingBufferSize(new Ee),r=i.getContext().getContextAttributes().alpha,s=this.inputBuffer.texture.type;if(n.setRenderer(i),n.setSize(a.width,a.height),n.initialize(i,r,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 r=(o,c)=>o||c.needsDepthTexture;e.reduce(r,!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,a=this.outputBuffer,r=!1,s,o,c;n===void 0&&(this.timer.update(),n=this.timer.getDelta());for(const h of this.passes)h.enabled&&(h.render(e,i,a,n,r),h.needsSwap&&(r&&(t.renderToScreen=h.renderToScreen,s=e.getContext(),o=e.state.buffers.stencil,o.setFunc(s.NOTEQUAL,1,4294967295),t.render(e,i,a,n,r),o.setFunc(s.EQUAL,1,4294967295)),c=i,i=a,a=c),h instanceof oZ?r=!0:h instanceof aZ&&(r=!1))}setSize(n,e,t){const i=this.renderer,a=i.getSize(new Ee);(n===void 0||e===void 0)&&(n=a.width,e=a.height),(a.width!==n||a.height!==e)&&i.setSize(n,e,t);const r=i.getDrawingBufferSize(new Ee);this.inputBuffer.setSize(r.width,r.height),this.outputBuffer.setSize(r.width,r.height);for(const s of this.passes)s.setSize(r.width,r.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(),Ha.fullscreenGeometry.dispose()}},Qo={NONE:0,DEPTH:1,CONVOLUTION:2},Mn={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"},cZ=class{constructor(){this.shaderParts=new Map([[Mn.FRAGMENT_HEAD,null],[Mn.FRAGMENT_MAIN_UV,null],[Mn.FRAGMENT_MAIN_IMAGE,null],[Mn.VERTEX_HEAD,null],[Mn.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=Qo.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=Fi}},h2=!1,gD=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 da:t=this.materialsFlatShadedDoubleSide;break;case Wi:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case da:t=this.materialsDoubleSide;break;case Wi: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 Di))return n.clone();const e=n.uniforms,t=new Map;for(const a in e){const r=e[a].value;r.isRenderTargetTexture&&(e[a].value=null,t.set(a,r))}const i=n.clone();for(const a of t)e[a[0]].value=a[1],i.uniforms[a[0]].value=a[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=os;e[2].skinning=!0,this.materialsBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=Wi,i}),this.materialsDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=da,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=Wi,i}),this.materialsFlatShadedDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=da,i})}}render(n,e,t){const i=n.shadowMap.enabled;if(n.shadowMap.enabled=!1,h2){const a=this.originalMaterials;this.meshCount=0,e.traverse(this.replaceMaterial),n.render(e,t);for(const r of a)r[0].material=r[1];this.meshCount!==a.size&&a.clear()}else{const a=e.overrideMaterial;e.overrideMaterial=this.material,n.render(e,t),e.overrideMaterial=a}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 h2}static set workaroundEnabled(n){h2=n}},Ll=-1,as=class extends tr{constructor(n,e=Ll,t=Ll,i=1){super(),this.resizable=n,this.baseSize=new Ee(1,1),this.preferredSize=new Ee(e,t),this.target=this.preferredSize,this.s=i,this.effectiveSize=new Ee,this.addEventListener("change",()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){const n=this.baseSize,e=this.preferredSize,t=this.effectiveSize,i=this.scale;e.width!==Ll?t.width=e.width:e.height!==Ll?t.width=Math.round(e.height*(n.width/Math.max(n.height,1))):t.width=Math.round(n.width*i),e.height!==Ll?t.height=e.height:e.width!==Ll?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(Ll),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 Ll}},dn={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},uZ="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);}",hZ="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);}",fZ="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);}",dZ="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);}",pZ="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);}",mZ="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);}",gZ="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);}",vZ="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);}",xZ="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);}",yZ="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);}",_Z="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);}",SZ="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);}",AZ="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);}",EZ="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);}",TZ="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);}",bZ="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);}",MZ="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);}",CZ="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);}",RZ="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);}",wZ="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);}",DZ="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);}",NZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return mix(x,y,y.a*opacity);}",OZ="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);}",IZ="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);}",BZ="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);}",UZ="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);}",LZ="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);}",PZ="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);}",FZ="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y;}",HZ="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);}",zZ="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);}",GZ=new Map([[dn.ADD,uZ],[dn.AVERAGE,hZ],[dn.COLOR,fZ],[dn.COLOR_BURN,dZ],[dn.COLOR_DODGE,pZ],[dn.DARKEN,mZ],[dn.DIFFERENCE,gZ],[dn.DIVIDE,vZ],[dn.DST,null],[dn.EXCLUSION,xZ],[dn.HARD_LIGHT,yZ],[dn.HARD_MIX,_Z],[dn.HUE,SZ],[dn.INVERT,AZ],[dn.INVERT_RGB,EZ],[dn.LIGHTEN,TZ],[dn.LINEAR_BURN,bZ],[dn.LINEAR_DODGE,MZ],[dn.LINEAR_LIGHT,CZ],[dn.LUMINOSITY,RZ],[dn.MULTIPLY,wZ],[dn.NEGATION,DZ],[dn.NORMAL,NZ],[dn.OVERLAY,OZ],[dn.PIN_LIGHT,IZ],[dn.REFLECT,BZ],[dn.SATURATION,UZ],[dn.SCREEN,LZ],[dn.SOFT_LIGHT,PZ],[dn.SRC,FZ],[dn.SUBTRACT,HZ],[dn.VIVID_LIGHT,zZ]]),VZ=class extends tr{constructor(n,e=1){super(),this._blendFunction=n,this.opacity=new ie(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 GZ.get(this.blendFunction)}},h0=class extends tr{constructor(n,e,{attributes:t=Qo.NONE,blendFunction:i=dn.NORMAL,defines:a=new Map,uniforms:r=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=a,this.uniforms=r,this.extensions=s,this.blendMode=new VZ(i),this.blendMode.addEventListener("change",c=>this.setChanged()),this._inputColorSpace=Fi,this._outputColorSpace=pa}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=Sc){}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 oi||e instanceof ri||e instanceof vn||e instanceof Ha)&&this[n].dispose()}}},kZ=`#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
}`,XZ=class extends Di{constructor(n=!1,e=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:_c.replace(/\D+/g,"")},uniforms:{inputBuffer:new ie(null),threshold:new ie(0),smoothing:new ie(1),range:new ie(null)},blending:ga,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:kZ,vertexShader:Eb}),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}},WZ=class extends Ha{constructor({renderTarget:n,luminanceRange:e,colorOutput:t,resolutionScale:i=1,width:a=as.AUTO_SIZE,height:r=as.AUTO_SIZE,resolutionX:s=a,resolutionY:o=r}={}){super("LuminancePass"),this.fullscreenMaterial=new XZ(t,e),this.needsSwap=!1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new oi(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target");const c=this.resolution=new as(this,s,o,i);c.addEventListener("change",h=>this.setSize(c.baseWidth,c.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(n,e,t,i,a){const r=this.fullscreenMaterial;r.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!==xi&&(this.renderTarget.texture.type=t,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},qE=class extends Ha{constructor(n,e="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=n,this.input=e}setInput(n){this.input=n}render(n,e,t,i,a){const r=this.fullscreenMaterial.uniforms;e!==null&&r!==void 0&&r[this.input]!==void 0&&(r[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!==xi&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},Tb=class extends Ha{constructor(n,e,t=null){super("RenderPass",n,e),this.needsSwap=!1,this.clearPass=new I8,this.overrideMaterialManager=t===null?null:new gD(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 gD(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,a){const r=this.scene,s=this.camera,o=this.selection,c=s.layers.mask,h=r.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)&&(r.background=null),this.clearPass.enabled&&this.clearPass.render(n,e),n.setRenderTarget(d),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(n,r,s):n.render(r,s),s.layers.mask=c,r.background=h,n.shadowMap.autoUpdate=f}},Za={LINEAR:0,REINHARD:1,REINHARD2:2,REINHARD2_ADAPTIVE:3,OPTIMIZED_CINEON:5,CINEON:5,ACES_FILMIC:6,AGX:7,NEUTRAL:8},YZ=`#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]);}`,qZ="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);}",ZZ=class extends Di{constructor(){super({name:"DepthDownsamplingMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new ie(null),normalBuffer:new ie(null),texelSize:new ie(new Ee)},blending:ga,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:YZ,vertexShader:qZ})}set depthBuffer(n){this.uniforms.depthBuffer.value=n}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,e=Sc){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)}},jZ=class extends Ha{constructor({normalBuffer:n=null,resolutionScale:e=.5,width:t=as.AUTO_SIZE,height:i=as.AUTO_SIZE,resolutionX:a=t,resolutionY:r=i}={}){super("DepthDownsamplingPass");const s=new ZZ;s.normalBuffer=n,this.fullscreenMaterial=s,this.needsDepthTexture=!0,this.needsSwap=!1,this.renderTarget=new oi(1,1,{minFilter:$n,magFilter:$n,depthBuffer:!1,type:Sn}),this.renderTarget.texture.name="DepthDownsamplingPass.Target",this.renderTarget.texture.generateMipmaps=!1;const o=this.resolution=new as(this,a,r,e);o.addEventListener("change",c=>this.setSize(o.baseWidth,o.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(n,e=Sc){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e}render(n,e,t,i,a){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.")}},KZ=`#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);}`,JZ=class extends Di{constructor(){super({name:"AdaptiveLuminanceMaterial",defines:{MIP_LEVEL_1X1:"0.0"},uniforms:{luminanceBuffer0:new ie(null),luminanceBuffer1:new ie(null),minLuminance:new ie(.01),deltaTime:new ie(0),tau:new ie(1)},extensions:{shaderTextureLOD:!0},blending:ga,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:KZ,vertexShader:Eb})}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}},QZ=class extends Ha{constructor(n,{minLuminance:e=.01,adaptationRate:t=1}={}){super("AdaptiveLuminancePass"),this.fullscreenMaterial=new JZ,this.needsSwap=!1,this.renderTargetPrevious=new oi(1,1,{minFilter:$n,magFilter:$n,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 O8(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,a){this.fullscreenMaterial.deltaTime=i,n.setRenderTarget(this.renderToScreen?null:this.renderTargetAdapted),n.render(this.scene,this.camera),this.copyPass.render(n,this.renderTargetAdapted)}},$Z=`#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
}`,ej=class extends h0{constructor({blendFunction:n=dn.SRC,adaptive:e=!1,mode:t=e?Za.REINHARD2_ADAPTIVE:Za.AGX,resolution:i=256,maxLuminance:a=4,whitePoint:r=a,middleGrey:s=.6,minLuminance:o=.01,averageLuminance:c=1,adaptationRate:h=1}={}){super("ToneMappingEffect",$Z,{blendFunction:n,uniforms:new Map([["luminanceBuffer",new ie(null)],["maxLuminance",new ie(a)],["whitePoint",new ie(r)],["middleGrey",new ie(s)],["averageLuminance",new ie(c)]])}),this.renderTargetLuminance=new oi(1,1,{minFilter:Sr,depthBuffer:!1}),this.renderTargetLuminance.texture.generateMipmaps=!0,this.renderTargetLuminance.texture.name="Luminance",this.luminancePass=new WZ({renderTarget:this.renderTargetLuminance}),this.adaptiveLuminancePass=new QZ(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=_c.replace(/\D+/g,"")>=168?"CineonToneMapping(texel)":"OptimizedCineonToneMapping(texel)";switch(this.defines.clear(),this.defines.set("TONE_MAPPING_MODE",n.toFixed(0)),n){case Za.LINEAR:this.defines.set("toneMapping(texel)","LinearToneMapping(texel)");break;case Za.REINHARD:this.defines.set("toneMapping(texel)","ReinhardToneMapping(texel)");break;case Za.CINEON:case Za.OPTIMIZED_CINEON:this.defines.set("toneMapping(texel)",t);break;case Za.ACES_FILMIC:this.defines.set("toneMapping(texel)","ACESFilmicToneMapping(texel)");break;case Za.AGX:this.defines.set("toneMapping(texel)","AgXToneMapping(texel)");break;case Za.NEUTRAL:this.defines.set("toneMapping(texel)","NeutralToneMapping(texel)");break;default:this.defines.set("toneMapping(texel)","texel");break}this.adaptiveLuminancePass.enabled=n===Za.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===Za.REINHARD2_ADAPTIVE}set adaptive(n){this.mode=n?Za.REINHARD2_ADAPTIVE:Za.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)}},tj=`#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>
}`,nj="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);}",ij=class extends Di{constructor(n,e,t,i,a=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:_c.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new ie(null),depthBuffer:new ie(null),resolution:new ie(new Ee),texelSize:new ie(new Ee),cameraNear:new ie(.3),cameraFar:new ie(1e3),aspect:new ie(1),time:new ie(0)},blending:ga,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:a}),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=Sc){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=tj.replace(Mn.FRAGMENT_HEAD,n.get(Mn.FRAGMENT_HEAD)||"").replace(Mn.FRAGMENT_MAIN_UV,n.get(Mn.FRAGMENT_MAIN_UV)||"").replace(Mn.FRAGMENT_MAIN_IMAGE,n.get(Mn.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader=nj.replace(Mn.VERTEX_HEAD,n.get(Mn.VERTEX_HEAD)||"").replace(Mn.VERTEX_MAIN_SUPPORT,n.get(Mn.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 Jn?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 Mn}};function vD(n,e,t){for(const i of e){const a="$1"+n+i.charAt(0).toUpperCase()+i.slice(1),r=new RegExp("([^\\.])(\\b"+i+"\\b)","g");for(const s of t.entries())s[1]!==null&&t.set(s[0],s[1].replace(r,a))}}function aj(n,e,t){let i=e.getFragmentShader(),a=e.getVertexShader();const r=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&Qo.CONVOLUTION)throw new Error(`Effects that transform UVs are incompatible with convolution effects (${e.name})`);if(!r&&!s)throw new Error(`Could not find mainImage or mainUv function (${e.name})`);{const o=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,c=t.shaderParts;let h=c.get(Mn.FRAGMENT_HEAD)||"",f=c.get(Mn.FRAGMENT_MAIN_UV)||"",d=c.get(Mn.FRAGMENT_MAIN_IMAGE)||"",m=c.get(Mn.VERTEX_HEAD)||"",g=c.get(Mn.VERTEX_MAIN_SUPPORT)||"";const y=new Set,E=new Set;if(s&&(f+=` ${n}MainUv(UV);
`,t.uvTransformation=!0),a!==null&&/mainSupport/.test(a)){const _=/mainSupport *\([\w\s]*?uv\s*?\)/.test(a);g+=` ${n}MainSupport(`,g+=_?`vUv);
`:`);
`;for(const A of a.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(const b of A[1].split(/\s*,\s*/))t.varyings.add(b),y.add(b),E.add(b);for(const A of a.matchAll(o))E.add(A[1])}for(const _ of i.matchAll(o))E.add(_[1]);for(const _ of e.defines.keys())E.add(_.replace(/\([\w\s,]*\)/g,""));for(const _ of e.uniforms.keys())E.add(_);E.delete("while"),E.delete("for"),E.delete("if"),e.uniforms.forEach((_,A)=>t.uniforms.set(n+A.charAt(0).toUpperCase()+A.slice(1),_)),e.defines.forEach((_,A)=>t.defines.set(n+A.charAt(0).toUpperCase()+A.slice(1),_));const S=new Map([["fragment",i],["vertex",a]]);vD(n,E,t.defines),vD(n,E,S),i=S.get("fragment"),a=S.get("vertex");const v=e.blendMode;if(t.blendModes.set(v.blendFunction,v),r){e.inputColorSpace!==null&&e.inputColorSpace!==t.colorSpace&&(d+=e.inputColorSpace===Kn?`color0 = sRGBTransferOETF(color0);
`:`color0 = sRGBToLinear(color0);
`),e.outputColorSpace!==pa?t.colorSpace=e.outputColorSpace:e.inputColorSpace!==null&&(t.colorSpace=e.inputColorSpace);const _=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;d+=`${n}MainImage(color0, UV, `,t.attributes&Qo.DEPTH&&_.test(i)&&(d+="depth, ",t.readDepth=!0),d+=`color1);
`;const A=n+"BlendOpacity";t.uniforms.set(A,v.opacity),d+=`color0 = blend${v.blendFunction}(color0, color1, ${A});
`,h+=`uniform float ${A};
`}if(h+=i+`
`,a!==null&&(m+=a+`
`),c.set(Mn.FRAGMENT_HEAD,h),c.set(Mn.FRAGMENT_MAIN_UV,f),c.set(Mn.FRAGMENT_MAIN_IMAGE,d),c.set(Mn.VERTEX_HEAD,m),c.set(Mn.VERTEX_MAIN_SUPPORT,g),e.extensions!==null)for(const _ of e.extensions)t.extensions.add(_)}}var rj=class extends Ha{constructor(n,...e){super("EffectPass"),this.fullscreenMaterial=new ij(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 cZ;let e=0;for(const s of this.effects)if(s.blendMode.blendFunction===dn.DST)n.attributes|=s.getAttributes()&Qo.DEPTH;else{if(n.attributes&s.getAttributes()&Qo.CONVOLUTION)throw new Error(`Convolution effects cannot be merged (${s.name})`);aj("e"+e++,s,n)}let t=n.shaderParts.get(Mn.FRAGMENT_HEAD),i=n.shaderParts.get(Mn.FRAGMENT_MAIN_IMAGE),a=n.shaderParts.get(Mn.FRAGMENT_MAIN_UV);const r=/\bblend\b/g;for(const s of n.blendModes.values())t+=s.getShaderCode().replace(r,`blend${s.blendFunction}`)+`
`;n.attributes&Qo.DEPTH?(n.readDepth&&(i=`float depth = readDepth(UV);
`+i),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,n.colorSpace===Kn&&(i+=`color0 = sRGBToLinear(color0);
`),n.uvTransformation?(a=`vec2 transformedUv = vUv;
`+a,n.defines.set("UV","transformedUv")):n.defines.set("UV","vUv"),n.shaderParts.set(Mn.FRAGMENT_HEAD,t),n.shaderParts.set(Mn.FRAGMENT_MAIN_IMAGE,i),n.shaderParts.set(Mn.FRAGMENT_MAIN_UV,a);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=Sc){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e;for(const t of this.effects)t.setDepthTexture(n,e)}render(n,e,t,i,a){for(const r of this.effects)r.update(n,e,i);if(!this.skipRendering||this.renderToScreen){const r=this.fullscreenMaterial;r.inputBuffer=e.texture,r.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!==xi&&(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}}},sj=class extends Ha{constructor(n,e,{renderTarget:t,resolutionScale:i=1,width:a=as.AUTO_SIZE,height:r=as.AUTO_SIZE,resolutionX:s=a,resolutionY:o=r}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new Tb(n,e,new $3);const c=this.renderPass;c.ignoreBackground=!0,c.skipShadowMapUpdate=!0;const h=c.getClearPass();h.overrideClearColor=new dt(7829503),h.overrideClearAlpha=1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new oi(1,1,{minFilter:$n,magFilter:$n}),this.renderTarget.texture.name="NormalPass.Target");const f=this.resolution=new as(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,a){const r=this.renderToScreen?null:this.renderTarget;this.renderPass.render(n,r,r)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}};function Nm(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}new Ee;new Ee;function B8(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}var Xr=function n(e,t,i){var a=this;B8(this,n),Nm(this,"dot2",function(r,s){return a.x*r+a.y*s}),Nm(this,"dot3",function(r,s,o){return a.x*r+a.y*s+a.z*o}),this.x=e,this.y=t,this.z=i},oj=[new Xr(1,1,0),new Xr(-1,1,0),new Xr(1,-1,0),new Xr(-1,-1,0),new Xr(1,0,1),new Xr(-1,0,1),new Xr(1,0,-1),new Xr(-1,0,-1),new Xr(0,1,1),new Xr(0,-1,1),new Xr(0,1,-1),new Xr(0,-1,-1)],xD=[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],yD=new Array(512),_D=new Array(512),lj=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=xD[t]^e&255:i=xD[t]^e>>8&255,yD[t]=yD[t+256]=i,_D[t]=_D[t+256]=oj[i%12]}};lj(0);function cj(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 SD(n){var e=cj(n);return function(){var t=e*48271%2147483647;return e=t,t/2147483647}}var uj=function n(e){var t=this;B8(this,n),Nm(this,"seed",0),Nm(this,"init",function(i){t.seed=i,t.value=SD(i)}),Nm(this,"value",SD(this.seed)),this.init(e)};new uj(Math.random());const bb=he.createContext(null),AD=n=>(n.getAttributes()&2)===2,hj=he.memo(he.forwardRef(({children:n,camera:e,scene:t,resolutionScale:i,enabled:a=!0,renderPriority:r=1,autoClear:s=!0,depthBuffer:o,enableNormalPass:c,stencilBuffer:h,multisampling:f=8,frameBufferType:d=sn},m)=>{const{gl:g,scene:y,camera:E,size:S}=jn(),v=t||y,_=e||E,[A,b,O]=he.useMemo(()=>{const B=new lZ(g,{depthBuffer:o,stencilBuffer:h,multisampling:f,frameBufferType:d});B.addPass(new Tb(v,_));let w=null,D=null;return c&&(D=new sj(v,_),D.enabled=!1,B.addPass(D),i!==void 0&&(w=new jZ({normalBuffer:D.texture,resolutionScale:i}),w.enabled=!1,B.addPass(w))),[B,D,w]},[_,g,o,h,f,d,v,c,i]);he.useEffect(()=>A==null?void 0:A.setSize(S.width,S.height),[A,S]),Ls((B,w)=>{if(a){const D=g.autoClear;g.autoClear=s,h&&!s&&g.clearStencil(),A.render(w),g.autoClear=D}},a?r:0);const N=he.useRef(null);he.useLayoutEffect(()=>{var D;const B=[],w=N.current.__r3f;if(w&&A){const G=w.children;for(let J=0;J<G.length;J++){const $=G[J].object;if($ instanceof h0){const se=[$];if(!AD($)){let q=null;for(;(q=(D=G[J+1])==null?void 0:D.object)instanceof h0&&!AD(q);)se.push(q),J++}const le=new rj(_,...se);B.push(le)}else $ instanceof Ha&&B.push($)}for(const J of B)A==null||A.addPass(J);b&&(b.enabled=!0),O&&(O.enabled=!0)}return()=>{for(const G of B)A==null||A.removePass(G);b&&(b.enabled=!1),O&&(O.enabled=!1)}},[A,n,_,b,O]),he.useEffect(()=>{const B=g.toneMapping;return g.toneMapping=ns,()=>{g.toneMapping=B}},[g]);const L=he.useMemo(()=>({composer:A,normalPass:b,downSamplingPass:O,resolutionScale:i,camera:_,scene:v}),[A,b,O,i,_,v]);return he.useImperativeHandle(m,()=>A,[A]),It.jsx(bb.Provider,{value:L,children:It.jsx("group",{ref:N,children:n})})}));let fj=0;const ED=new WeakMap,dj=(n,e)=>function({blendFunction:t=e==null?void 0:e.blendFunction,opacity:i=e==null?void 0:e.opacity,...a}){let r=ED.get(n);if(!r){const c=`@react-three/postprocessing/${n.name}-${fj++}`;Sb({[c]:n}),ED.set(n,r=c)}const s=jn(c=>c.camera),o=IT.useMemo(()=>[...(e==null?void 0:e.args)??[],...a.args??[{...e,...a}]],[JSON.stringify(a)]);return It.jsx(r,{camera:s,"blendMode-blendFunction":t,"blendMode-opacity-value":i,...a,args:o})},pj=dj(ej);var mj="Invariant failed";function Lx(n,e){if(!n)throw new Error(mj)}const gj=new H;function U8(n,e,t=new H,i){const{x:a,y:r,z:s}=n,o=e.x,c=e.y,h=e.z,f=a*a*o,d=r*r*c,m=s*s*h,g=f+d+m,y=Math.sqrt(1/g);if(!Number.isFinite(y))return;const E=gj.copy(n).multiplyScalar(y);if(g<((i==null?void 0:i.centerTolerance)??.1))return t.copy(E);const S=E.multiply(e).multiplyScalar(2);let v=(1-y)*n.length()/(S.length()/2),_=0,A,b,O,N;do{v-=_,A=1/(1+v*o),b=1/(1+v*c),O=1/(1+v*h);const L=A*A,B=b*b,w=O*O,D=L*A,G=B*b,J=w*O;N=f*L+d*B+m*w-1,_=N/((f*D*o+d*G*c+m*J*h)*-2)}while(Math.abs(N)>1e-12);return t.set(a*A,r*b,s*O)}const df=new H,f2=new H,d2=new H,ZE=class{constructor(e,t,i){this.radii=new H(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 H){const{x:t,y:i,z:a}=this.radii;return e.set(1/t,1/i,1/a)}reciprocalRadiiSquared(e=new H){const{x:t,y:i,z:a}=this.radii;return e.set(1/t**2,1/i**2,1/a**2)}projectOnSurface(e,t=new H,i){return U8(e,this.reciprocalRadiiSquared(),t,i)}getSurfaceNormal(e,t=new H){return t.multiplyVectors(this.reciprocalRadiiSquared(df),e).normalize()}getEastNorthUpVectors(e,t=new H,i=new H,a=new H){this.getSurfaceNormal(e,a),t.set(-e.y,e.x,0).normalize(),i.crossVectors(a,t).normalize()}getEastNorthUpFrame(e,t=new lt){const i=df,a=f2,r=d2;return this.getEastNorthUpVectors(e,i,a,r),t.makeBasis(i,a,r).setPosition(e)}getNorthUpEastFrame(e,t=new lt){const i=df,a=f2,r=d2;return this.getEastNorthUpVectors(e,i,a,r),t.makeBasis(a,r,i).setPosition(e)}getIntersection(e,t=new H){const i=this.reciprocalRadii(df),a=f2.copy(i).multiply(e.origin),r=d2.copy(i).multiply(e.direction),s=a.lengthSq(),o=r.lengthSq(),c=a.dot(r),h=c**2-o*(s-1);if(s===1)return t.copy(e.origin);if(s>1){if(c>=0||h<0)return;const f=Math.sqrt(h),d=(-c-f)/o,m=(-c+f)/o;return e.at(Math.min(d,m),t)}if(s<1){const f=c**2-o*(s-1),d=Math.sqrt(f),m=(-c+d)/o;return e.at(m,t)}if(c<0)return e.at(-c/o,t)}getOsculatingSphereCenter(e,t,i=new H){Lx(this.radii.x===this.radii.y);const a=this.radii.x**2,r=this.radii.z**2,s=df.set(e.x/a,e.y/a,e.z/r).normalize();return i.copy(s.multiplyScalar(-t).add(e))}getNormalAtHorizon(e,t,i=new H){Lx(this.radii.x===this.radii.y);const a=this.radii.x**2,r=this.radii.z**2,s=e,o=t;let c=(s.x*o.x+s.y*o.y)/a+s.z*o.z/r;c/=(s.x**2+s.y**2)/a+s.z**2/r;const h=df.copy(o).multiplyScalar(-c).add(e);return i.set(h.x/a,h.y/a,h.z/r).normalize()}};ZE.WGS84=new ZE(6378137,6378137,6356752314245179e-9);let bd=ZE;const Lv=new H,TD=new H,nm=class jE{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 jE(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<jE.MIN_LONGITUDE&&(this.longitude+=Math.PI*2),this}setFromECEF(e,t){const i=((t==null?void 0:t.ellipsoid)??bd.WGS84).reciprocalRadiiSquared(Lv),a=U8(e,i,TD,t);if(a==null)throw new Error(`Could not project position to ellipsoid surface: ${e.toArray()}`);const r=Lv.multiplyVectors(a,i).normalize();this.longitude=Math.atan2(r.y,r.x),this.latitude=Math.asin(r.z);const s=Lv.subVectors(e,a);return this.height=Math.sign(s.dot(e))*s.length(),this}toECEF(e=new H,t){const i=(t==null?void 0:t.ellipsoid)??bd.WGS84,a=Lv.multiplyVectors(i.radii,i.radii),r=Math.cos(this.latitude),s=TD.set(r*Math.cos(this.longitude),r*Math.sin(this.longitude),Math.sin(this.latitude)).normalize();return e.multiplyVectors(a,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}};nm.MIN_LONGITUDE=-Math.PI,nm.MAX_LONGITUDE=Math.PI,nm.MIN_LATITUDE=-Math.PI/2,nm.MAX_LATITUDE=Math.PI/2;let Mb=nm;/*!
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 Qr=Uint8Array,Pf=Uint16Array,vj=Int32Array,L8=new Qr([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]),P8=new Qr([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]),xj=new Qr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),F8=function(n,e){for(var t=new Pf(31),i=0;i<31;++i)t[i]=e+=1<<n[i-1];for(var a=new vj(t[30]),i=1;i<30;++i)for(var r=t[i];r<t[i+1];++r)a[r]=r-t[i]<<5|i;return{b:t,r:a}},H8=F8(L8,2),z8=H8.b,yj=H8.r;z8[28]=258,yj[258]=28;var _j=F8(P8,0),Sj=_j.b,KE=new Pf(32768);for(var ni=0;ni<32768;++ni){var Pl=(ni&43690)>>1|(ni&21845)<<1;Pl=(Pl&52428)>>2|(Pl&13107)<<2,Pl=(Pl&61680)>>4|(Pl&3855)<<4,KE[ni]=((Pl&65280)>>8|(Pl&255)<<8)>>1}var Om=function(n,e,t){for(var i=n.length,a=0,r=new Pf(e);a<i;++a)n[a]&&++r[n[a]-1];var s=new Pf(e);for(a=1;a<e;++a)s[a]=s[a-1]+r[a-1]<<1;var o;if(t){o=new Pf(1<<e);var c=15-e;for(a=0;a<i;++a)if(n[a])for(var h=a<<4|n[a],f=e-n[a],d=s[n[a]-1]++<<f,m=d|(1<<f)-1;d<=m;++d)o[KE[d]>>c]=h}else for(o=new Pf(i),a=0;a<i;++a)n[a]&&(o[a]=KE[s[n[a]-1]++]>>15-n[a]);return o},H0=new Qr(288);for(var ni=0;ni<144;++ni)H0[ni]=8;for(var ni=144;ni<256;++ni)H0[ni]=9;for(var ni=256;ni<280;++ni)H0[ni]=7;for(var ni=280;ni<288;++ni)H0[ni]=8;var G8=new Qr(32);for(var ni=0;ni<32;++ni)G8[ni]=5;var Aj=Om(H0,9,1),Ej=Om(G8,5,1),p2=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},ys=function(n,e,t){var i=e/8|0;return(n[i]|n[i+1]<<8)>>(e&7)&t},m2=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},Tj=function(n){return(n+7)/8|0},bj=function(n,e,t){return(t==null||t>n.length)&&(t=n.length),new Qr(n.subarray(e,t))},Mj=["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"],Ts=function(n,e,t){var i=new Error(e||Mj[n]);if(i.code=n,Error.captureStackTrace&&Error.captureStackTrace(i,Ts),!t)throw i;return i},Cj=function(n,e,t,i){var a=n.length,r=0;if(!a||e.f&&!e.l)return t||new Qr(0);var s=!t,o=s||e.i!=2,c=e.i;s&&(t=new Qr(a*3));var h=function(ft){var ht=t.length;if(ft>ht){var et=new Qr(Math.max(ht*2,ft));et.set(t),t=et}},f=e.f||0,d=e.p||0,m=e.b||0,g=e.l,y=e.d,E=e.m,S=e.n,v=a*8;do{if(!g){f=ys(n,d,1);var _=ys(n,d+1,3);if(d+=3,_)if(_==1)g=Aj,y=Ej,E=9,S=5;else if(_==2){var N=ys(n,d,31)+257,L=ys(n,d+10,15)+4,B=N+ys(n,d+5,31)+1;d+=14;for(var w=new Qr(B),D=new Qr(19),G=0;G<L;++G)D[xj[G]]=ys(n,d+G*3,7);d+=L*3;for(var J=p2(D),$=(1<<J)-1,se=Om(D,J,1),G=0;G<B;){var le=se[ys(n,d,$)];d+=le&15;var A=le>>4;if(A<16)w[G++]=A;else{var q=0,te=0;for(A==16?(te=3+ys(n,d,3),d+=2,q=w[G-1]):A==17?(te=3+ys(n,d,7),d+=3):A==18&&(te=11+ys(n,d,127),d+=7);te--;)w[G++]=q}}var ee=w.subarray(0,N),de=w.subarray(N);E=p2(ee),S=p2(de),g=Om(ee,E,1),y=Om(de,S,1)}else Ts(1);else{var A=Tj(d)+4,b=n[A-4]|n[A-3]<<8,O=A+b;if(O>a){c&&Ts(0);break}o&&h(m+b),t.set(n.subarray(A,O),m),e.b=m+=b,e.p=d=O*8,e.f=f;continue}if(d>v){c&&Ts(0);break}}o&&h(m+131072);for(var ue=(1<<E)-1,Pe=(1<<S)-1,He=d;;He=d){var q=g[m2(n,d)&ue],Ke=q>>4;if(d+=q&15,d>v){c&&Ts(0);break}if(q||Ts(2),Ke<256)t[m++]=Ke;else if(Ke==256){He=d,g=null;break}else{var nt=Ke-254;if(Ke>264){var G=Ke-257,xt=L8[G];nt=ys(n,d,(1<<xt)-1)+z8[G],d+=xt}var fe=y[m2(n,d)&Pe],Be=fe>>4;fe||Ts(3),d+=fe&15;var de=Sj[Be];if(Be>3){var xt=P8[Be];de+=m2(n,d)&(1<<xt)-1,d+=xt}if(d>v){c&&Ts(0);break}o&&h(m+131072);var Je=m+nt;if(m<de){var ve=r-de,at=Math.min(de,Je);for(ve+m<0&&Ts(3);m<at;++m)t[m]=i[ve+m]}for(;m<Je;++m)t[m]=t[m-de]}}e.l=g,e.p=He,e.b=m,e.f=f,g&&(f=1,e.m=E,e.d=y,e.n=S)}while(!f);return m!=t.length&&s?bj(t,0,m):t.subarray(0,m)},Rj=new Qr(0),wj=function(n,e){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&Ts(6,"invalid zlib data"),(n[1]>>5&1)==1&&Ts(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Pv(n,e){return Cj(n.subarray(wj(n),-4),{i:2},e,e)}var Dj=typeof TextDecoder<"u"&&new TextDecoder,Nj=0;try{Dj.decode(Rj,{stream:!0}),Nj=1}catch{}let V8=class extends Hy{constructor(e){super(e),this.type=sn,this.outputFormat=Rn}parse(e){const w=Math.pow(2.7182818,2.2);function D(M,I){let V=0;for(let F=0;F<65536;++F)(F==0||M[F>>3]&1<<(F&7))&&(I[V++]=F);const C=V-1;for(;V<65536;)I[V++]=0;return C}function G(M){for(let I=0;I<16384;I++)M[I]={},M[I].len=0,M[I].lit=0,M[I].p=null}const J={l:0,c:0,lc:0};function $(M,I,V,C,F){for(;V<M;)I=I<<8|ne(C,F),V+=8;V-=M,J.l=I>>V&(1<<M)-1,J.c=I,J.lc=V}const se=new Array(59);function le(M){for(let V=0;V<=58;++V)se[V]=0;for(let V=0;V<65537;++V)se[M[V]]+=1;let I=0;for(let V=58;V>0;--V){const C=I+se[V]>>1;se[V]=I,I=C}for(let V=0;V<65537;++V){const C=M[V];C>0&&(M[V]=C|se[C]++<<6)}}function q(M,I,V,C,F,Y){const z=I;let k=0,Q=0;for(;C<=F;C++){if(z.value-I.value>V)return!1;$(6,k,Q,M,z);const ae=J.l;if(k=J.c,Q=J.lc,Y[C]=ae,ae==63){if(z.value-I.value>V)throw new Error("Something wrong with hufUnpackEncTable");$(8,k,Q,M,z);let ce=J.l+6;if(k=J.c,Q=J.lc,C+ce>F+1)throw new Error("Something wrong with hufUnpackEncTable");for(;ce--;)Y[C++]=0;C--}else if(ae>=59){let ce=ae-59+2;if(C+ce>F+1)throw new Error("Something wrong with hufUnpackEncTable");for(;ce--;)Y[C++]=0;C--}}le(Y)}function te(M){return M&63}function ee(M){return M>>6}function de(M,I,V,C){for(;I<=V;I++){const F=ee(M[I]),Y=te(M[I]);if(F>>Y)throw new Error("Invalid table entry");if(Y>14){const z=C[F>>Y-14];if(z.len)throw new Error("Invalid table entry");if(z.lit++,z.p){const k=z.p;z.p=new Array(z.lit);for(let Q=0;Q<z.lit-1;++Q)z.p[Q]=k[Q]}else z.p=new Array(1);z.p[z.lit-1]=I}else if(Y){let z=0;for(let k=1<<14-Y;k>0;k--){const Q=C[(F<<14-Y)+z];if(Q.len||Q.p)throw new Error("Invalid table entry");Q.len=Y,Q.lit=I,z++}}}return!0}const ue={c:0,lc:0};function Pe(M,I,V,C){M=M<<8|ne(V,C),I+=8,ue.c=M,ue.lc=I}const He={c:0,lc:0};function Ke(M,I,V,C,F,Y,z,k,Q){if(M==I){C<8&&(Pe(V,C,F,Y),V=ue.c,C=ue.lc),C-=8;let ae=V>>C;if(ae=new Uint8Array([ae])[0],k.value+ae>Q)return!1;const ce=z[k.value-1];for(;ae-- >0;)z[k.value++]=ce}else if(k.value<Q)z[k.value++]=M;else return!1;He.c=V,He.lc=C}function nt(M){return M&65535}function xt(M){const I=nt(M);return I>32767?I-65536:I}const fe={a:0,b:0};function Be(M,I){const V=xt(M),F=xt(I),Y=V+(F&1)+(F>>1),z=Y,k=Y-F;fe.a=z,fe.b=k}function Je(M,I){const V=nt(M),C=nt(I),F=V-(C>>1)&65535,Y=C+F-32768&65535;fe.a=Y,fe.b=F}function ve(M,I,V,C,F,Y,z){const k=z<16384,Q=V>F?F:V;let ae=1,ce,xe;for(;ae<=Q;)ae<<=1;for(ae>>=1,ce=ae,ae>>=1;ae>=1;){xe=0;const Ae=xe+Y*(F-ce),Ne=Y*ae,Fe=Y*ce,Oe=C*ae,Ze=C*ce;let $e,vt,Rt,pt;for(;xe<=Ae;xe+=Fe){let Ct=xe;const je=xe+C*(V-ce);for(;Ct<=je;Ct+=Ze){const Ut=Ct+Oe,Ft=Ct+Ne,Et=Ft+Oe;k?(Be(M[Ct+I],M[Ft+I]),$e=fe.a,Rt=fe.b,Be(M[Ut+I],M[Et+I]),vt=fe.a,pt=fe.b,Be($e,vt),M[Ct+I]=fe.a,M[Ut+I]=fe.b,Be(Rt,pt),M[Ft+I]=fe.a,M[Et+I]=fe.b):(Je(M[Ct+I],M[Ft+I]),$e=fe.a,Rt=fe.b,Je(M[Ut+I],M[Et+I]),vt=fe.a,pt=fe.b,Je($e,vt),M[Ct+I]=fe.a,M[Ut+I]=fe.b,Je(Rt,pt),M[Ft+I]=fe.a,M[Et+I]=fe.b)}if(V&ae){const Ut=Ct+Ne;k?Be(M[Ct+I],M[Ut+I]):Je(M[Ct+I],M[Ut+I]),$e=fe.a,M[Ut+I]=fe.b,M[Ct+I]=$e}}if(F&ae){let Ct=xe;const je=xe+C*(V-ce);for(;Ct<=je;Ct+=Ze){const Ut=Ct+Oe;k?Be(M[Ct+I],M[Ut+I]):Je(M[Ct+I],M[Ut+I]),$e=fe.a,M[Ut+I]=fe.b,M[Ct+I]=$e}}ce=ae,ae>>=1}return xe}function at(M,I,V,C,F,Y,z,k,Q){let ae=0,ce=0;const xe=z,Ae=Math.trunc(C.value+(F+7)/8);for(;C.value<Ae;)for(Pe(ae,ce,V,C),ae=ue.c,ce=ue.lc;ce>=14;){const Fe=ae>>ce-14&16383,Oe=I[Fe];if(Oe.len)ce-=Oe.len,Ke(Oe.lit,Y,ae,ce,V,C,k,Q,xe),ae=He.c,ce=He.lc;else{if(!Oe.p)throw new Error("hufDecode issues");let Ze;for(Ze=0;Ze<Oe.lit;Ze++){const $e=te(M[Oe.p[Ze]]);for(;ce<$e&&C.value<Ae;)Pe(ae,ce,V,C),ae=ue.c,ce=ue.lc;if(ce>=$e&&ee(M[Oe.p[Ze]])==(ae>>ce-$e&(1<<$e)-1)){ce-=$e,Ke(Oe.p[Ze],Y,ae,ce,V,C,k,Q,xe),ae=He.c,ce=He.lc;break}}if(Ze==Oe.lit)throw new Error("hufDecode issues")}}const Ne=8-F&7;for(ae>>=Ne,ce-=Ne;ce>0;){const Fe=I[ae<<14-ce&16383];if(Fe.len)ce-=Fe.len,Ke(Fe.lit,Y,ae,ce,V,C,k,Q,xe),ae=He.c,ce=He.lc;else throw new Error("hufDecode issues")}return!0}function ft(M,I,V,C,F,Y){const z={value:0},k=V.value,Q=St(I,V),ae=St(I,V);V.value+=4;const ce=St(I,V);if(V.value+=4,Q<0||Q>=65537||ae<0||ae>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const xe=new Array(65537),Ae=new Array(16384);G(Ae);const Ne=C-(V.value-k);if(q(M,V,Ne,Q,ae,xe),ce>8*(C-(V.value-k)))throw new Error("Something wrong with hufUncompress");de(xe,Q,ae,Ae),at(xe,Ae,M,V,ce,ae,Y,F,z)}function ht(M,I,V){for(let C=0;C<V;++C)I[C]=M[I[C]]}function et(M){for(let I=1;I<M.length;I++){const V=M[I-1]+M[I]-128;M[I]=V}}function Re(M,I){let V=0,C=Math.floor((M.length+1)/2),F=0;const Y=M.length-1;for(;!(F>Y||(I[F++]=M[V++],F>Y));)I[F++]=M[C++]}function Z(M){let I=M.byteLength;const V=new Array;let C=0;const F=new DataView(M);for(;I>0;){const Y=F.getInt8(C++);if(Y<0){const z=-Y;I-=z+1;for(let k=0;k<z;k++)V.push(F.getUint8(C++))}else{const z=Y;I-=2;const k=F.getUint8(C++);for(let Q=0;Q<z+1;Q++)V.push(k)}}return V}function Ue(M,I,V,C,F,Y){let z=new DataView(Y.buffer);const k=V[M.idx[0]].width,Q=V[M.idx[0]].height,ae=3,ce=Math.floor(k/8),xe=Math.ceil(k/8),Ae=Math.ceil(Q/8),Ne=k-(xe-1)*8,Fe=Q-(Ae-1)*8,Oe={value:0},Ze=new Array(ae),$e=new Array(ae),vt=new Array(ae),Rt=new Array(ae),pt=new Array(ae);for(let je=0;je<ae;++je)pt[je]=I[M.idx[je]],Ze[je]=je<1?0:Ze[je-1]+xe*Ae,$e[je]=new Float32Array(64),vt[je]=new Uint16Array(64),Rt[je]=new Uint16Array(xe*64);for(let je=0;je<Ae;++je){let Ut=8;je==Ae-1&&(Ut=Fe);let Ft=8;for(let Lt=0;Lt<xe;++Lt){Lt==xe-1&&(Ft=Ne);for(let Ot=0;Ot<ae;++Ot)vt[Ot].fill(0),vt[Ot][0]=F[Ze[Ot]++],Qe(Oe,C,vt[Ot]),Ye(vt[Ot],$e[Ot]),ot($e[Ot]);rt($e);for(let Ot=0;Ot<ae;++Ot)mt($e[Ot],Rt[Ot],Lt*64)}let Et=0;for(let Lt=0;Lt<ae;++Lt){const Ot=V[M.idx[Lt]].type;for(let en=8*je;en<8*je+Ut;++en){Et=pt[Lt][en];for(let Nn=0;Nn<ce;++Nn){const On=Nn*64+(en&7)*8;z.setUint16(Et+0*2*Ot,Rt[Lt][On+0],!0),z.setUint16(Et+1*2*Ot,Rt[Lt][On+1],!0),z.setUint16(Et+2*2*Ot,Rt[Lt][On+2],!0),z.setUint16(Et+3*2*Ot,Rt[Lt][On+3],!0),z.setUint16(Et+4*2*Ot,Rt[Lt][On+4],!0),z.setUint16(Et+5*2*Ot,Rt[Lt][On+5],!0),z.setUint16(Et+6*2*Ot,Rt[Lt][On+6],!0),z.setUint16(Et+7*2*Ot,Rt[Lt][On+7],!0),Et+=8*2*Ot}}if(ce!=xe)for(let en=8*je;en<8*je+Ut;++en){const Nn=pt[Lt][en]+8*ce*2*Ot,On=ce*64+(en&7)*8;for(let Wn=0;Wn<Ft;++Wn)z.setUint16(Nn+Wn*2*Ot,Rt[Lt][On+Wn],!0)}}}const Ct=new Uint16Array(k);z=new DataView(Y.buffer);for(let je=0;je<ae;++je){V[M.idx[je]].decoded=!0;const Ut=V[M.idx[je]].type;if(V[je].type==2)for(let Ft=0;Ft<Q;++Ft){const Et=pt[je][Ft];for(let Lt=0;Lt<k;++Lt)Ct[Lt]=z.getUint16(Et+Lt*2*Ut,!0);for(let Lt=0;Lt<k;++Lt)z.setFloat32(Et+Lt*2*Ut,_e(Ct[Lt]),!0)}}}function ze(M,I,V,C,F,Y){const z=new DataView(Y.buffer),k=V[M],Q=k.width,ae=k.height,ce=Math.ceil(Q/8),xe=Math.ceil(ae/8),Ae=Math.floor(Q/8),Ne=Q-(ce-1)*8,Fe=ae-(xe-1)*8,Oe={value:0};let Ze=0;const $e=new Float32Array(64),vt=new Uint16Array(64),Rt=new Uint16Array(ce*64);for(let pt=0;pt<xe;++pt){let Ct=8;pt==xe-1&&(Ct=Fe);for(let je=0;je<ce;++je)vt.fill(0),vt[0]=F[Ze++],Qe(Oe,C,vt),Ye(vt,$e),ot($e),mt($e,Rt,je*64);for(let je=8*pt;je<8*pt+Ct;++je){let Ut=I[M][je];for(let Ft=0;Ft<Ae;++Ft){const Et=Ft*64+(je&7)*8;for(let Lt=0;Lt<8;++Lt)z.setUint16(Ut+Lt*2*k.type,Rt[Et+Lt],!0);Ut+=8*2*k.type}if(ce!=Ae){const Ft=Ae*64+(je&7)*8;for(let Et=0;Et<Ne;++Et)z.setUint16(Ut+Et*2*k.type,Rt[Ft+Et],!0)}}}k.decoded=!0}function Qe(M,I,V){let C,F=1;for(;F<64;)C=I[M.value],C==65280?F=64:C>>8==255?F+=C&255:(V[F]=C,F++),M.value++}function Ye(M,I){I[0]=_e(M[0]),I[1]=_e(M[1]),I[2]=_e(M[5]),I[3]=_e(M[6]),I[4]=_e(M[14]),I[5]=_e(M[15]),I[6]=_e(M[27]),I[7]=_e(M[28]),I[8]=_e(M[2]),I[9]=_e(M[4]),I[10]=_e(M[7]),I[11]=_e(M[13]),I[12]=_e(M[16]),I[13]=_e(M[26]),I[14]=_e(M[29]),I[15]=_e(M[42]),I[16]=_e(M[3]),I[17]=_e(M[8]),I[18]=_e(M[12]),I[19]=_e(M[17]),I[20]=_e(M[25]),I[21]=_e(M[30]),I[22]=_e(M[41]),I[23]=_e(M[43]),I[24]=_e(M[9]),I[25]=_e(M[11]),I[26]=_e(M[18]),I[27]=_e(M[24]),I[28]=_e(M[31]),I[29]=_e(M[40]),I[30]=_e(M[44]),I[31]=_e(M[53]),I[32]=_e(M[10]),I[33]=_e(M[19]),I[34]=_e(M[23]),I[35]=_e(M[32]),I[36]=_e(M[39]),I[37]=_e(M[45]),I[38]=_e(M[52]),I[39]=_e(M[54]),I[40]=_e(M[20]),I[41]=_e(M[22]),I[42]=_e(M[33]),I[43]=_e(M[38]),I[44]=_e(M[46]),I[45]=_e(M[51]),I[46]=_e(M[55]),I[47]=_e(M[60]),I[48]=_e(M[21]),I[49]=_e(M[34]),I[50]=_e(M[37]),I[51]=_e(M[47]),I[52]=_e(M[50]),I[53]=_e(M[56]),I[54]=_e(M[59]),I[55]=_e(M[61]),I[56]=_e(M[35]),I[57]=_e(M[36]),I[58]=_e(M[48]),I[59]=_e(M[49]),I[60]=_e(M[57]),I[61]=_e(M[58]),I[62]=_e(M[62]),I[63]=_e(M[63])}function ot(M){const I=.5*Math.cos(.7853975),V=.5*Math.cos(3.14159/16),C=.5*Math.cos(3.14159/8),F=.5*Math.cos(3*3.14159/16),Y=.5*Math.cos(5*3.14159/16),z=.5*Math.cos(3*3.14159/8),k=.5*Math.cos(7*3.14159/16),Q=new Array(4),ae=new Array(4),ce=new Array(4),xe=new Array(4);for(let Ae=0;Ae<8;++Ae){const Ne=Ae*8;Q[0]=C*M[Ne+2],Q[1]=z*M[Ne+2],Q[2]=C*M[Ne+6],Q[3]=z*M[Ne+6],ae[0]=V*M[Ne+1]+F*M[Ne+3]+Y*M[Ne+5]+k*M[Ne+7],ae[1]=F*M[Ne+1]-k*M[Ne+3]-V*M[Ne+5]-Y*M[Ne+7],ae[2]=Y*M[Ne+1]-V*M[Ne+3]+k*M[Ne+5]+F*M[Ne+7],ae[3]=k*M[Ne+1]-Y*M[Ne+3]+F*M[Ne+5]-V*M[Ne+7],ce[0]=I*(M[Ne+0]+M[Ne+4]),ce[3]=I*(M[Ne+0]-M[Ne+4]),ce[1]=Q[0]+Q[3],ce[2]=Q[1]-Q[2],xe[0]=ce[0]+ce[1],xe[1]=ce[3]+ce[2],xe[2]=ce[3]-ce[2],xe[3]=ce[0]-ce[1],M[Ne+0]=xe[0]+ae[0],M[Ne+1]=xe[1]+ae[1],M[Ne+2]=xe[2]+ae[2],M[Ne+3]=xe[3]+ae[3],M[Ne+4]=xe[3]-ae[3],M[Ne+5]=xe[2]-ae[2],M[Ne+6]=xe[1]-ae[1],M[Ne+7]=xe[0]-ae[0]}for(let Ae=0;Ae<8;++Ae)Q[0]=C*M[16+Ae],Q[1]=z*M[16+Ae],Q[2]=C*M[48+Ae],Q[3]=z*M[48+Ae],ae[0]=V*M[8+Ae]+F*M[24+Ae]+Y*M[40+Ae]+k*M[56+Ae],ae[1]=F*M[8+Ae]-k*M[24+Ae]-V*M[40+Ae]-Y*M[56+Ae],ae[2]=Y*M[8+Ae]-V*M[24+Ae]+k*M[40+Ae]+F*M[56+Ae],ae[3]=k*M[8+Ae]-Y*M[24+Ae]+F*M[40+Ae]-V*M[56+Ae],ce[0]=I*(M[Ae]+M[32+Ae]),ce[3]=I*(M[Ae]-M[32+Ae]),ce[1]=Q[0]+Q[3],ce[2]=Q[1]-Q[2],xe[0]=ce[0]+ce[1],xe[1]=ce[3]+ce[2],xe[2]=ce[3]-ce[2],xe[3]=ce[0]-ce[1],M[0+Ae]=xe[0]+ae[0],M[8+Ae]=xe[1]+ae[1],M[16+Ae]=xe[2]+ae[2],M[24+Ae]=xe[3]+ae[3],M[32+Ae]=xe[3]-ae[3],M[40+Ae]=xe[2]-ae[2],M[48+Ae]=xe[1]-ae[1],M[56+Ae]=xe[0]-ae[0]}function rt(M){for(let I=0;I<64;++I){const V=M[0][I],C=M[1][I],F=M[2][I];M[0][I]=V+1.5747*F,M[1][I]=V-.1873*C-.4682*F,M[2][I]=V+1.8556*C}}function mt(M,I,V){for(let C=0;C<64;++C)I[V+C]=Zo.toHalfFloat(j(M[C]))}function j(M){return M<=1?Math.sign(M)*Math.pow(Math.abs(M),2.2):Math.sign(M)*Math.pow(w,Math.abs(M)-1)}function P(M){return new DataView(M.array.buffer,M.offset.value,M.size)}function pe(M){const I=M.viewer.buffer.slice(M.offset.value,M.offset.value+M.size),V=new Uint8Array(Z(I)),C=new Uint8Array(V.length);return et(V),Re(V,C),new DataView(C.buffer)}function Ie(M){const I=M.array.slice(M.offset.value,M.offset.value+M.size),V=Pv(I),C=new Uint8Array(V.length);return et(V),Re(V,C),new DataView(C.buffer)}function Ge(M){const I=M.viewer,V={value:M.offset.value},C=new Uint16Array(M.columns*M.lines*(M.inputChannels.length*M.type)),F=new Uint8Array(8192);let Y=0;const z=new Array(M.inputChannels.length);for(let Fe=0,Oe=M.inputChannels.length;Fe<Oe;Fe++)z[Fe]={},z[Fe].start=Y,z[Fe].end=z[Fe].start,z[Fe].nx=M.columns,z[Fe].ny=M.lines,z[Fe].size=M.type,Y+=z[Fe].nx*z[Fe].ny*z[Fe].size;const k=it(I,V),Q=it(I,V);if(Q>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(k<=Q)for(let Fe=0;Fe<Q-k+1;Fe++)F[Fe+k]=me(I,V);const ae=new Uint16Array(65536),ce=D(F,ae),xe=St(I,V);ft(M.array,I,V,xe,C,Y);for(let Fe=0;Fe<M.inputChannels.length;++Fe){const Oe=z[Fe];for(let Ze=0;Ze<z[Fe].size;++Ze)ve(C,Oe.start+Ze,Oe.nx,Oe.size,Oe.ny,Oe.nx*Oe.size,ce)}ht(ae,C,Y);let Ae=0;const Ne=new Uint8Array(C.buffer.byteLength);for(let Fe=0;Fe<M.lines;Fe++)for(let Oe=0;Oe<M.inputChannels.length;Oe++){const Ze=z[Oe],$e=Ze.nx*Ze.size,vt=new Uint8Array(C.buffer,Ze.end*2,$e*2);Ne.set(vt,Ae),Ae+=$e*2,Ze.end+=$e}return new DataView(Ne.buffer)}function we(M){const I=M.array.slice(M.offset.value,M.offset.value+M.size),V=Pv(I),C=M.inputChannels.length*M.lines*M.columns*M.totalBytes,F=new ArrayBuffer(C),Y=new DataView(F);let z=0,k=0;const Q=new Array(4);for(let ae=0;ae<M.lines;ae++)for(let ce=0;ce<M.inputChannels.length;ce++){let xe=0;switch(M.inputChannels[ce].pixelType){case 1:Q[0]=z,Q[1]=Q[0]+M.columns,z=Q[1]+M.columns;for(let Ne=0;Ne<M.columns;++Ne){const Fe=V[Q[0]++]<<8|V[Q[1]++];xe+=Fe,Y.setUint16(k,xe,!0),k+=2}break;case 2:Q[0]=z,Q[1]=Q[0]+M.columns,Q[2]=Q[1]+M.columns,z=Q[2]+M.columns;for(let Ne=0;Ne<M.columns;++Ne){const Fe=V[Q[0]++]<<24|V[Q[1]++]<<16|V[Q[2]++]<<8;xe+=Fe,Y.setUint32(k,xe,!0),k+=4}break}}return Y}function Tt(M){const I=M.viewer,V={value:M.offset.value},C=new Uint8Array(M.columns*M.lines*(M.inputChannels.length*M.type*2)),F={version:Le(I,V),unknownUncompressedSize:Le(I,V),unknownCompressedSize:Le(I,V),acCompressedSize:Le(I,V),dcCompressedSize:Le(I,V),rleCompressedSize:Le(I,V),rleUncompressedSize:Le(I,V),rleRawSize:Le(I,V),totalAcUncompressedCount:Le(I,V),totalDcUncompressedCount:Le(I,V),acCompression:Le(I,V)};if(F.version<2)throw new Error("EXRLoader.parse: "+De.compression+" version "+F.version+" is unsupported");const Y=new Array;let z=it(I,V)-2;for(;z>0;){const Oe=ut(I.buffer,V),Ze=me(I,V),$e=Ze>>2&3,vt=(Ze>>4)-1,Rt=new Int8Array([vt])[0],pt=me(I,V);Y.push({name:Oe,index:Rt,type:pt,compression:$e}),z-=Oe.length+3}const k=De.channels,Q=new Array(M.inputChannels.length);for(let Oe=0;Oe<M.inputChannels.length;++Oe){const Ze=Q[Oe]={},$e=k[Oe];Ze.name=$e.name,Ze.compression=0,Ze.decoded=!1,Ze.type=$e.pixelType,Ze.pLinear=$e.pLinear,Ze.width=M.columns,Ze.height=M.lines}const ae={idx:new Array(3)};for(let Oe=0;Oe<M.inputChannels.length;++Oe){const Ze=Q[Oe];for(let $e=0;$e<Y.length;++$e){const vt=Y[$e];Ze.name==vt.name&&(Ze.compression=vt.compression,vt.index>=0&&(ae.idx[vt.index]=Oe),Ze.offset=Oe)}}let ce,xe,Ae;if(F.acCompressedSize>0)switch(F.acCompression){case 0:ce=new Uint16Array(F.totalAcUncompressedCount),ft(M.array,I,V,F.acCompressedSize,ce,F.totalAcUncompressedCount);break;case 1:const Oe=M.array.slice(V.value,V.value+F.totalAcUncompressedCount),Ze=Pv(Oe);ce=new Uint16Array(Ze.buffer),V.value+=F.totalAcUncompressedCount;break}if(F.dcCompressedSize>0){const Oe={array:M.array,offset:V,size:F.dcCompressedSize};xe=new Uint16Array(Ie(Oe).buffer),V.value+=F.dcCompressedSize}if(F.rleRawSize>0){const Oe=M.array.slice(V.value,V.value+F.rleCompressedSize),Ze=Pv(Oe);Ae=Z(Ze.buffer),V.value+=F.rleCompressedSize}let Ne=0;const Fe=new Array(Q.length);for(let Oe=0;Oe<Fe.length;++Oe)Fe[Oe]=new Array;for(let Oe=0;Oe<M.lines;++Oe)for(let Ze=0;Ze<Q.length;++Ze)Fe[Ze].push(Ne),Ne+=Q[Ze].width*M.type*2;ae.idx[0]!==void 0&&Q[ae.idx[0]]&&Ue(ae,Fe,Q,ce,xe,C);for(let Oe=0;Oe<Q.length;++Oe){const Ze=Q[Oe];if(!Ze.decoded)switch(Ze.compression){case 2:let $e=0,vt=0;for(let Rt=0;Rt<M.lines;++Rt){let pt=Fe[Oe][$e];for(let Ct=0;Ct<Ze.width;++Ct){for(let je=0;je<2*Ze.type;++je)C[pt++]=Ae[vt+je*Ze.width*Ze.height];vt++}$e++}break;case 1:ze(Oe,Fe,Q,ce,xe,C);break;default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(C.buffer)}function ut(M,I){const V=new Uint8Array(M);let C=0;for(;V[I.value+C]!=0;)C+=1;const F=new TextDecoder().decode(V.slice(I.value,I.value+C));return I.value=I.value+C+1,F}function wt(M,I,V){const C=new TextDecoder().decode(new Uint8Array(M).slice(I.value,I.value+V));return I.value=I.value+V,C}function bt(M,I){const V=Ve(M,I),C=St(M,I);return[V,C]}function ke(M,I){const V=St(M,I),C=St(M,I);return[V,C]}function Ve(M,I){const V=M.getInt32(I.value,!0);return I.value=I.value+4,V}function St(M,I){const V=M.getUint32(I.value,!0);return I.value=I.value+4,V}function ne(M,I){const V=M[I.value];return I.value=I.value+1,V}function me(M,I){const V=M.getUint8(I.value);return I.value=I.value+1,V}const Le=function(M,I){let V;return"getBigInt64"in DataView.prototype?V=Number(M.getBigInt64(I.value,!0)):V=M.getUint32(I.value+4,!0)+Number(M.getUint32(I.value,!0)<<32),I.value+=8,V};function K(M,I){const V=M.getFloat32(I.value,!0);return I.value+=4,V}function Se(M,I){return Zo.toHalfFloat(K(M,I))}function _e(M){const I=(M&31744)>>10,V=M&1023;return(M>>15?-1:1)*(I?I===31?V?NaN:1/0:Math.pow(2,I-15)*(1+V/1024):6103515625e-14*(V/1024))}function it(M,I){const V=M.getUint16(I.value,!0);return I.value+=2,V}function tt(M,I){return _e(it(M,I))}function We(M,I,V,C){const F=V.value,Y=[];for(;V.value<F+C-1;){const z=ut(I,V),k=Ve(M,V),Q=me(M,V);V.value+=3;const ae=Ve(M,V),ce=Ve(M,V);Y.push({name:z,pixelType:k,pLinear:Q,xSampling:ae,ySampling:ce})}return V.value+=1,Y}function gt(M,I){const V=K(M,I),C=K(M,I),F=K(M,I),Y=K(M,I),z=K(M,I),k=K(M,I),Q=K(M,I),ae=K(M,I);return{redX:V,redY:C,greenX:F,greenY:Y,blueX:z,blueY:k,whiteX:Q,whiteY:ae}}function Nt(M,I){const V=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],C=me(M,I);return V[C]}function $t(M,I){const V=Ve(M,I),C=Ve(M,I),F=Ve(M,I),Y=Ve(M,I);return{xMin:V,yMin:C,xMax:F,yMax:Y}}function jt(M,I){const V=["INCREASING_Y","DECREASING_Y","RANDOM_Y"],C=me(M,I);return V[C]}function hi(M,I){const V=["ENVMAP_LATLONG","ENVMAP_CUBE"],C=me(M,I);return V[C]}function fi(M,I){const V=["ONE_LEVEL","MIPMAP_LEVELS","RIPMAP_LEVELS"],C=["ROUND_DOWN","ROUND_UP"],F=St(M,I),Y=St(M,I),z=me(M,I);return{xSize:F,ySize:Y,levelMode:V[z&15],roundingMode:C[z>>4]}}function hl(M,I){const V=K(M,I),C=K(M,I);return[V,C]}function Ps(M,I){const V=K(M,I),C=K(M,I),F=K(M,I);return[V,C,F]}function ar(M,I,V,C,F){if(C==="string"||C==="stringvector"||C==="iccProfile")return wt(I,V,F);if(C==="chlist")return We(M,I,V,F);if(C==="chromaticities")return gt(M,V);if(C==="compression")return Nt(M,V);if(C==="box2i")return $t(M,V);if(C==="envmap")return hi(M,V);if(C==="tiledesc")return fi(M,V);if(C==="lineOrder")return jt(M,V);if(C==="float")return K(M,V);if(C==="v2f")return hl(M,V);if(C==="v3f")return Ps(M,V);if(C==="int")return Ve(M,V);if(C==="rational")return bt(M,V);if(C==="timecode")return ke(M,V);if(C==="preview")return V.value+=F,"skipped";V.value+=F}function Ni(M,I){const V=Math.log2(M);return I=="ROUND_DOWN"?Math.floor(V):Math.ceil(V)}function Va(M,I,V){let C=0;switch(M.levelMode){case"ONE_LEVEL":C=1;break;case"MIPMAP_LEVELS":C=Ni(Math.max(I,V),M.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return C}function Oi(M,I,V,C){const F=new Array(M);for(let Y=0;Y<M;Y++){const z=1<<Y;let k=I/z|0;C=="ROUND_UP"&&k*z<I&&(k+=1);const Q=Math.max(k,1);F[Y]=(Q+V-1)/V|0}return F}function zt(){const M=this,I=M.offset,V={value:0};for(let C=0;C<M.tileCount;C++){const F=Ve(M.viewer,I),Y=Ve(M.viewer,I);I.value+=8,M.size=St(M.viewer,I);const z=F*M.blockWidth,k=Y*M.blockHeight;M.columns=z+M.blockWidth>M.width?M.width-z:M.blockWidth,M.lines=k+M.blockHeight>M.height?M.height-k:M.blockHeight;const Q=M.columns*M.totalBytes,ce=M.size<M.lines*Q?M.uncompress(M):P(M);I.value+=M.size;for(let xe=0;xe<M.lines;xe++){const Ae=xe*M.columns*M.totalBytes;for(let Ne=0;Ne<M.inputChannels.length;Ne++){const Fe=De.channels[Ne].name,Oe=M.channelByteOffsets[Fe]*M.columns,Ze=M.decodeChannels[Fe];if(Ze===void 0)continue;V.value=Ae+Oe;const $e=(M.height-(1+k+xe))*M.outLineWidth;for(let vt=0;vt<M.columns;vt++){const Rt=$e+(vt+z)*M.outputChannels+Ze;M.byteArray[Rt]=M.getter(ce,V)}}}}}function ka(){const M=this,I=M.offset,V={value:0};for(let C=0;C<M.height/M.blockHeight;C++){const F=Ve(M.viewer,I)-De.dataWindow.yMin;M.size=St(M.viewer,I),M.lines=F+M.blockHeight>M.height?M.height-F:M.blockHeight;const Y=M.columns*M.totalBytes,k=M.size<M.lines*Y?M.uncompress(M):P(M);I.value+=M.size;for(let Q=0;Q<M.blockHeight;Q++){const ae=C*M.blockHeight,ce=Q+M.scanOrder(ae);if(ce>=M.height)continue;const xe=Q*Y,Ae=(M.height-1-ce)*M.outLineWidth;for(let Ne=0;Ne<M.inputChannels.length;Ne++){const Fe=De.channels[Ne].name,Oe=M.channelByteOffsets[Fe]*M.columns,Ze=M.decodeChannels[Fe];if(Ze!==void 0){V.value=xe+Oe;for(let $e=0;$e<M.columns;$e++){const vt=Ae+$e*M.outputChannels+Ze;M.byteArray[vt]=M.getter(k,V)}}}}}}function Ln(M,I,V){const C={};if(M.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");C.version=M.getUint8(4);const F=M.getUint8(5);C.spec={singleTile:!!(F&2),longName:!!(F&4),deepFormat:!!(F&8),multiPart:!!(F&16)},V.value=8;let Y=!0;for(;Y;){const z=ut(I,V);if(z==="")Y=!1;else{const k=ut(I,V),Q=St(M,V),ae=ar(M,I,V,k,Q);ae===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${k}'.`):C[z]=ae}}if(F&-7)throw console.error("THREE.EXRHeader:",C),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return C}function U(M,I,V,C,F,Y){const z={size:0,viewer:I,array:V,offset:C,width:M.dataWindow.xMax-M.dataWindow.xMin+1,height:M.dataWindow.yMax-M.dataWindow.yMin+1,inputChannels:M.channels,channelByteOffsets:{},shouldExpand:!1,scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:Fi};switch(M.compression){case"NO_COMPRESSION":z.blockHeight=1,z.uncompress=P;break;case"RLE_COMPRESSION":z.blockHeight=1,z.uncompress=pe;break;case"ZIPS_COMPRESSION":z.blockHeight=1,z.uncompress=Ie;break;case"ZIP_COMPRESSION":z.blockHeight=16,z.uncompress=Ie;break;case"PIZ_COMPRESSION":z.blockHeight=32,z.uncompress=Ge;break;case"PXR24_COMPRESSION":z.blockHeight=16,z.uncompress=we;break;case"DWAA_COMPRESSION":z.blockHeight=32,z.uncompress=Tt;break;case"DWAB_COMPRESSION":z.blockHeight=256,z.uncompress=Tt;break;default:throw new Error("EXRLoader.parse: "+M.compression+" is unsupported")}const k={};for(const Ae of M.channels)switch(Ae.name){case"Y":case"R":case"G":case"B":case"A":k[Ae.name]=!0,z.type=Ae.pixelType}let Q=!1,ae=!1;if(k.R&&k.G&&k.B)z.outputChannels=4;else if(k.Y)z.outputChannels=1;else throw new Error("EXRLoader.parse: file contains unsupported data channels.");switch(z.outputChannels){case 4:Y==Rn?(Q=!k.A,z.format=Rn,z.colorSpace=Fi,z.outputChannels=4,z.decodeChannels={R:0,G:1,B:2,A:3}):Y==zo?(z.format=zo,z.colorSpace=Fi,z.outputChannels=2,z.decodeChannels={R:0,G:1}):Y==Ar?(z.format=Ar,z.colorSpace=Fi,z.outputChannels=1,z.decodeChannels={R:0}):ae=!0;break;case 1:Y==Rn?(Q=!0,z.format=Rn,z.colorSpace=Fi,z.outputChannels=4,z.shouldExpand=!0,z.decodeChannels={Y:0}):Y==zo?(z.format=zo,z.colorSpace=Fi,z.outputChannels=2,z.shouldExpand=!0,z.decodeChannels={Y:0}):Y==Ar?(z.format=Ar,z.colorSpace=Fi,z.outputChannels=1,z.decodeChannels={Y:0}):ae=!0;break;default:ae=!0}if(ae)throw new Error("EXRLoader.parse: invalid output format for specified file.");if(z.type==1)switch(F){case Sn:z.getter=tt;break;case sn:z.getter=it;break}else if(z.type==2)switch(F){case Sn:z.getter=K;break;case sn:z.getter=Se}else throw new Error("EXRLoader.parse: unsupported pixelType "+z.type+" for "+M.compression+".");z.columns=z.width;const ce=z.width*z.height*z.outputChannels;switch(F){case Sn:z.byteArray=new Float32Array(ce),Q&&z.byteArray.fill(1,0,ce);break;case sn:z.byteArray=new Uint16Array(ce),Q&&z.byteArray.fill(15360,0,ce);break;default:console.error("THREE.EXRLoader: unsupported type: ",F);break}let xe=0;for(const Ae of M.channels)z.decodeChannels[Ae.name]!==void 0&&(z.channelByteOffsets[Ae.name]=xe),xe+=Ae.pixelType*2;if(z.totalBytes=xe,z.outLineWidth=z.width*z.outputChannels,M.lineOrder==="INCREASING_Y"?z.scanOrder=Ae=>Ae:z.scanOrder=Ae=>z.height-1-Ae,M.spec.singleTile){z.blockHeight=M.tiles.ySize,z.blockWidth=M.tiles.xSize;const Ae=Va(M.tiles,z.width,z.height),Ne=Oi(Ae,z.width,M.tiles.xSize,M.tiles.roundingMode),Fe=Oi(Ae,z.height,M.tiles.ySize,M.tiles.roundingMode);z.tileCount=Ne[0]*Fe[0];for(let Oe=0;Oe<Ae;Oe++)for(let Ze=0;Ze<Fe[Oe];Ze++)for(let $e=0;$e<Ne[Oe];$e++)Le(I,C);z.decode=zt.bind(z)}else{z.blockWidth=z.width;const Ae=Math.ceil(z.height/z.blockHeight);for(let Ne=0;Ne<Ae;Ne++)Le(I,C);z.decode=ka.bind(z)}return z}const W={value:0},oe=new DataView(e),Te=new Uint8Array(e),De=Ln(oe,e,W),Me=U(De,oe,Te,W,this.type,this.outputFormat);if(Me.decode(),Me.shouldExpand){const M=Me.byteArray;if(this.outputFormat==Rn)for(let I=0;I<M.length;I+=4)M[I+2]=M[I+1]=M[I];else if(this.outputFormat==zo)for(let I=0;I<M.length;I+=2)M[I+1]=M[I]}return{header:De,width:Me.width,height:Me.height,data:Me.byteArray,format:Me.format,colorSpace:Me.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}setOutputFormat(e){return this.outputFormat=e,this}load(e,t,i,a){function r(s,o){s.colorSpace=o.colorSpace,s.minFilter=Bt,s.magFilter=Bt,s.generateMipmaps=!1,s.flipY=!1,t&&t(s,o)}return super.load(e,r,i,a)}},k8=class extends yi{load(e,t,i,a){const r=new oa(this.manager);r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setPath(this.path),r.setWithCredentials(this.withCredentials),r.load(e,s=>{Lx(s instanceof ArrayBuffer);try{t(s)}catch(o){a!=null?a(o):console.error(o),this.manager.itemError(e)}},i,a)}};function X8(n){var e,t;return n instanceof ky?n.getContext().getExtension("OES_texture_float_linear")!=null:((t=(e=n.backend).hasFeature)==null?void 0:t.call(e,"float32-filterable"))??!1}const Oj=128,Ij=128,Bj=64,Uj="9627216cc50057994c98a2118f3c4a23765d43b9",W8=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${Uj}/packages/core/assets/stbn.bin`,Lj="This is not an object",Pj="This is not a Float16Array object",bD="This constructor is not a subclass of Float16Array",Y8="The constructor property value is not an object",Fj="Species constructor didn't return TypedArray object",Hj="Derived constructor created TypedArray object which was too small length",Im="Attempting to access detached ArrayBuffer",JE="Cannot convert undefined or null to object",QE="Cannot mix BigInt and other types, use explicit conversions",MD="@@iterator property is not callable",CD="Reduce of empty array with no initial value",zj="The comparison function must be either a function or undefined",g2="Offset is out of bounds";function ei(n){return(e,...t)=>ja(n,e,t)}function kd(n,e){return ei(Md(n,e).get)}const{apply:ja,construct:im,defineProperty:Gj,get:v2,getOwnPropertyDescriptor:Md,getPrototypeOf:z0,has:$E,ownKeys:q8,set:RD,setPrototypeOf:Z8}=Reflect,Vj=Proxy,{EPSILON:kj,MAX_SAFE_INTEGER:wD,isFinite:j8,isNaN:Cd}=Number,{iterator:io,species:Xj,toStringTag:Cb,for:Wj}=Symbol,Rd=Object,{create:Yy,defineProperty:G0,freeze:Yj,is:DD}=Rd,eT=Rd.prototype,qj=eT.__lookupGetter__?ei(eT.__lookupGetter__):(n,e)=>{if(n==null)throw li(JE);let t=Rd(n);do{const i=Md(t,e);if(i!==void 0)return Vo(i,"get")?i.get:void 0}while((t=z0(t))!==null)},Vo=Rd.hasOwn||ei(eT.hasOwnProperty),K8=Array,J8=K8.isArray,qy=K8.prototype,Zj=ei(qy.join),jj=ei(qy.push),Kj=ei(qy.toLocaleString),Rb=qy[io],Jj=ei(Rb),{abs:Qj,trunc:Q8}=Math,Zy=ArrayBuffer,$j=Zy.isView,$8=Zy.prototype,eK=ei($8.slice),tK=kd($8,"byteLength"),tT=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:null,nK=tT&&kd(tT.prototype,"byteLength"),wb=z0(Uint8Array),iK=wb.from,la=wb.prototype,aK=la[io],rK=ei(la.keys),sK=ei(la.values),oK=ei(la.entries),lK=ei(la.set),ND=ei(la.reverse),cK=ei(la.fill),uK=ei(la.copyWithin),OD=ei(la.sort),zp=ei(la.slice),hK=ei(la.subarray),ea=kd(la,"buffer"),au=kd(la,"byteOffset"),Dn=kd(la,"length"),e6=kd(la,Cb),fK=Uint8Array,vr=Uint16Array,ID=(...n)=>ja(iK,vr,n),Db=Uint32Array,dK=Float32Array,Ju=z0([][io]()),jy=ei(Ju.next),pK=ei(function*(){}().next),mK=z0(Ju),gK=DataView.prototype,vK=ei(gK.getUint16),li=TypeError,x2=RangeError,t6=WeakSet,n6=t6.prototype,xK=ei(n6.add),yK=ei(n6.has),Ky=WeakMap,Nb=Ky.prototype,Px=ei(Nb.get),_K=ei(Nb.has),Ob=ei(Nb.set),i6=new Ky,SK=Yy(null,{next:{value:function(){const n=Px(i6,this);return jy(n)}},[io]:{value:function(){return this}}});function am(n){if(n[io]===Rb&&Ju.next===jy)return n;const e=Yy(SK);return Ob(i6,e,Jj(n)),e}const a6=new Ky,r6=Yy(mK,{next:{value:function(){const n=Px(a6,this);return pK(n)},writable:!0,configurable:!0}});for(const n of q8(Ju))n!=="next"&&G0(r6,n,Md(Ju,n));function BD(n){const e=Yy(r6);return Ob(a6,e,n),e}function Fx(n){return n!==null&&typeof n=="object"||typeof n=="function"}function UD(n){return n!==null&&typeof n=="object"}function Hx(n){return e6(n)!==void 0}function nT(n){const e=e6(n);return e==="BigInt64Array"||e==="BigUint64Array"}function AK(n){try{return J8(n)?!1:(tK(n),!0)}catch{return!1}}function s6(n){if(tT===null)return!1;try{return nK(n),!0}catch{return!1}}function EK(n){return AK(n)||s6(n)}function LD(n){return J8(n)?n[io]===Rb&&Ju.next===jy:!1}function TK(n){return Hx(n)?n[io]===aK&&Ju.next===jy:!1}function Fv(n){if(typeof n!="string")return!1;const e=+n;return n!==e+""||!j8(e)?!1:e===Q8(e)}const zx=Wj("__Float16Array__");function bK(n){if(!UD(n))return!1;const e=z0(n);if(!UD(e))return!1;const t=e.constructor;if(t===void 0)return!1;if(!Fx(t))throw li(Y8);return $E(t,zx)}const iT=1/kj;function MK(n){return n+iT-iT}const o6=6103515625e-14,CK=65504,l6=.0009765625,PD=l6*o6,RK=l6*iT;function wK(n){const e=+n;if(!j8(e)||e===0)return e;const t=e>0?1:-1,i=Qj(e);if(i<o6)return t*MK(i/PD)*PD;const a=(1+RK)*i,r=a-(a-i);return r>CK||Cd(r)?t*(1/0):t*r}const c6=new Zy(4),u6=new dK(c6),h6=new Db(c6),Ss=new vr(512),As=new fK(512);for(let n=0;n<256;++n){const e=n-127;e<-24?(Ss[n]=0,Ss[n|256]=32768,As[n]=24,As[n|256]=24):e<-14?(Ss[n]=1024>>-e-14,Ss[n|256]=1024>>-e-14|32768,As[n]=-e-1,As[n|256]=-e-1):e<=15?(Ss[n]=e+15<<10,Ss[n|256]=e+15<<10|32768,As[n]=13,As[n|256]=13):e<128?(Ss[n]=31744,Ss[n|256]=64512,As[n]=24,As[n|256]=24):(Ss[n]=31744,Ss[n|256]=64512,As[n]=13,As[n|256]=13)}function Xs(n){u6[0]=wK(n);const e=h6[0],t=e>>23&511;return Ss[t]+((e&8388607)>>As[t])}const Ib=new Db(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,Ib[n]=e|t}for(let n=1024;n<2048;++n)Ib[n]=939524096+(n-1024<<13);const Xd=new Db(64);for(let n=1;n<31;++n)Xd[n]=n<<23;Xd[31]=1199570944;Xd[32]=2147483648;for(let n=33;n<63;++n)Xd[n]=2147483648+(n-32<<23);Xd[63]=3347054592;const f6=new vr(64);for(let n=1;n<64;++n)n!==32&&(f6[n]=1024);function Bn(n){const e=n>>10;return h6[0]=Ib[f6[e]+(n&1023)]+Xd[e],u6[0]}function No(n){const e=+n;return Cd(e)||e===0?0:Q8(e)}function y2(n){const e=No(n);return e<0?0:e<wD?e:wD}function Hv(n,e){if(!Fx(n))throw li(Lj);const t=n.constructor;if(t===void 0)return e;if(!Fx(t))throw li(Y8);return t[Xj]??e}function Bm(n){if(s6(n))return!1;try{return eK(n,0,0),!1}catch{}return!0}function FD(n,e){const t=Cd(n),i=Cd(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 a=DD(n,0),r=DD(e,0);if(!a&&r)return-1;if(a&&!r)return 1}return 0}const Bb=2,Gx=new Ky;function Ff(n){return _K(Gx,n)||!$j(n)&&bK(n)}function wn(n){if(!Ff(n))throw li(Pj)}function zv(n,e){const t=Ff(n),i=Hx(n);if(!t&&!i)throw li(Fj);if(typeof e=="number"){let a;if(t){const r=nn(n);a=Dn(r)}else a=Dn(n);if(a<e)throw li(Hj)}if(nT(n))throw li(QE)}function nn(n){const e=Px(Gx,n);if(e!==void 0){const a=ea(e);if(Bm(a))throw li(Im);return e}const t=n.buffer;if(Bm(t))throw li(Im);const i=im(ul,[t,n.byteOffset,n.length],n.constructor);return Px(Gx,i)}function HD(n){const e=Dn(n),t=[];for(let i=0;i<e;++i)t[i]=Bn(n[i]);return t}const d6=new t6;for(const n of q8(la)){if(n===Cb)continue;const e=Md(la,n);Vo(e,"get")&&typeof e.get=="function"&&xK(d6,e.get)}const DK=Yj({get(n,e,t){return Fv(e)&&Vo(n,e)?Bn(v2(n,e)):yK(d6,qj(n,e))?v2(n,e):v2(n,e,t)},set(n,e,t,i){return Fv(e)&&Vo(n,e)?RD(n,e,Xs(t)):RD(n,e,t,i)},getOwnPropertyDescriptor(n,e){if(Fv(e)&&Vo(n,e)){const t=Md(n,e);return t.value=Bn(t.value),t}return Md(n,e)},defineProperty(n,e,t){return Fv(e)&&Vo(n,e)&&Vo(t,"value")&&(t.value=Xs(t.value)),Gj(n,e,t)}});let ul=class ta{constructor(e,t,i){let a;if(Ff(e))a=im(vr,[nn(e)],new.target);else if(Fx(e)&&!EK(e)){let s,o;if(Hx(e)){s=e,o=Dn(e);const c=ea(e);if(Bm(c))throw li(Im);if(nT(e))throw li(QE);const h=new Zy(o*Bb);a=im(vr,[h],new.target)}else{const c=e[io];if(c!=null&&typeof c!="function")throw li(MD);c!=null?LD(e)?(s=e,o=e.length):(s=[...e],o=s.length):(s=e,o=y2(s.length)),a=im(vr,[o],new.target)}for(let c=0;c<o;++c)a[c]=Xs(s[c])}else a=im(vr,arguments,new.target);const r=new Vj(a,DK);return Ob(Gx,r,a),r}static from(e,...t){const i=this;if(!$E(i,zx))throw li(bD);if(i===ta){if(Ff(e)&&t.length===0){const f=nn(e),d=new vr(ea(f),au(f),Dn(f));return new ta(ea(zp(d)))}if(t.length===0)return new ta(ea(ID(e,Xs)));const c=t[0],h=t[1];return new ta(ea(ID(e,function(f,...d){return Xs(ja(c,this,[f,...am(d)]))},h)))}let a,r;const s=e[io];if(s!=null&&typeof s!="function")throw li(MD);if(s!=null)LD(e)?(a=e,r=e.length):TK(e)?(a=e,r=Dn(e)):(a=[...e],r=a.length);else{if(e==null)throw li(JE);a=Rd(e),r=y2(a.length)}const o=new i(r);if(t.length===0)for(let c=0;c<r;++c)o[c]=a[c];else{const c=t[0],h=t[1];for(let f=0;f<r;++f)o[f]=ja(c,h,[a[f],f])}return o}static of(...e){const t=this;if(!$E(t,zx))throw li(bD);const i=e.length;if(t===ta){const r=new ta(i),s=nn(r);for(let o=0;o<i;++o)s[o]=Xs(e[o]);return r}const a=new t(i);for(let r=0;r<i;++r)a[r]=e[r];return a}keys(){wn(this);const e=nn(this);return rK(e)}values(){wn(this);const e=nn(this);return BD(function*(){for(const t of sK(e))yield Bn(t)}())}entries(){wn(this);const e=nn(this);return BD(function*(){for(const[t,i]of oK(e))yield[t,Bn(i)]}())}at(e){wn(this);const t=nn(this),i=Dn(t),a=No(e),r=a>=0?a:i+a;if(!(r<0||r>=i))return Bn(t[r])}with(e,t){wn(this);const i=nn(this),a=Dn(i),r=No(e),s=r>=0?r:a+r,o=+t;if(s<0||s>=a)throw x2(g2);const c=new vr(ea(i),au(i),Dn(i)),h=new ta(ea(zp(c))),f=nn(h);return f[s]=Xs(o),h}map(e,...t){wn(this);const i=nn(this),a=Dn(i),r=t[0],s=Hv(i,ta);if(s===ta){const c=new ta(a),h=nn(c);for(let f=0;f<a;++f){const d=Bn(i[f]);h[f]=Xs(ja(e,r,[d,f,this]))}return c}const o=new s(a);zv(o,a);for(let c=0;c<a;++c){const h=Bn(i[c]);o[c]=ja(e,r,[h,c,this])}return o}filter(e,...t){wn(this);const i=nn(this),a=Dn(i),r=t[0],s=[];for(let h=0;h<a;++h){const f=Bn(i[h]);ja(e,r,[f,h,this])&&jj(s,f)}const o=Hv(i,ta),c=new o(s);return zv(c),c}reduce(e,...t){wn(this);const i=nn(this),a=Dn(i);if(a===0&&t.length===0)throw li(CD);let r,s;t.length===0?(r=Bn(i[0]),s=1):(r=t[0],s=0);for(let o=s;o<a;++o)r=e(r,Bn(i[o]),o,this);return r}reduceRight(e,...t){wn(this);const i=nn(this),a=Dn(i);if(a===0&&t.length===0)throw li(CD);let r,s;t.length===0?(r=Bn(i[a-1]),s=a-2):(r=t[0],s=a-1);for(let o=s;o>=0;--o)r=e(r,Bn(i[o]),o,this);return r}forEach(e,...t){wn(this);const i=nn(this),a=Dn(i),r=t[0];for(let s=0;s<a;++s)ja(e,r,[Bn(i[s]),s,this])}find(e,...t){wn(this);const i=nn(this),a=Dn(i),r=t[0];for(let s=0;s<a;++s){const o=Bn(i[s]);if(ja(e,r,[o,s,this]))return o}}findIndex(e,...t){wn(this);const i=nn(this),a=Dn(i),r=t[0];for(let s=0;s<a;++s){const o=Bn(i[s]);if(ja(e,r,[o,s,this]))return s}return-1}findLast(e,...t){wn(this);const i=nn(this),a=Dn(i),r=t[0];for(let s=a-1;s>=0;--s){const o=Bn(i[s]);if(ja(e,r,[o,s,this]))return o}}findLastIndex(e,...t){wn(this);const i=nn(this),a=Dn(i),r=t[0];for(let s=a-1;s>=0;--s){const o=Bn(i[s]);if(ja(e,r,[o,s,this]))return s}return-1}every(e,...t){wn(this);const i=nn(this),a=Dn(i),r=t[0];for(let s=0;s<a;++s)if(!ja(e,r,[Bn(i[s]),s,this]))return!1;return!0}some(e,...t){wn(this);const i=nn(this),a=Dn(i),r=t[0];for(let s=0;s<a;++s)if(ja(e,r,[Bn(i[s]),s,this]))return!0;return!1}set(e,...t){wn(this);const i=nn(this),a=No(t[0]);if(a<0)throw x2(g2);if(e==null)throw li(JE);if(nT(e))throw li(QE);if(Ff(e))return lK(nn(this),nn(e),a);if(Hx(e)){const c=ea(e);if(Bm(c))throw li(Im)}const r=Dn(i),s=Rd(e),o=y2(s.length);if(a===1/0||o+a>r)throw x2(g2);for(let c=0;c<o;++c)i[c+a]=Xs(s[c])}reverse(){wn(this);const e=nn(this);return ND(e),this}toReversed(){wn(this);const e=nn(this),t=new vr(ea(e),au(e),Dn(e)),i=new ta(ea(zp(t))),a=nn(i);return ND(a),i}fill(e,...t){wn(this);const i=nn(this);return cK(i,Xs(e),...am(t)),this}copyWithin(e,t,...i){wn(this);const a=nn(this);return uK(a,e,t,...am(i)),this}sort(e){wn(this);const t=nn(this),i=e!==void 0?e:FD;return OD(t,(a,r)=>i(Bn(a),Bn(r))),this}toSorted(e){wn(this);const t=nn(this);if(e!==void 0&&typeof e!="function")throw new li(zj);const i=e!==void 0?e:FD,a=new vr(ea(t),au(t),Dn(t)),r=new ta(ea(zp(a))),s=nn(r);return OD(s,(o,c)=>i(Bn(o),Bn(c))),r}slice(e,t){wn(this);const i=nn(this),a=Hv(i,ta);if(a===ta){const y=new vr(ea(i),au(i),Dn(i));return new ta(ea(zp(y,e,t)))}const r=Dn(i),s=No(e),o=t===void 0?r:No(t);let c;s===-1/0?c=0:s<0?c=r+s>0?r+s:0:c=r<s?r:s;let h;o===-1/0?h=0:o<0?h=r+o>0?r+o:0:h=r<o?r:o;const f=h-c>0?h-c:0,d=new a(f);if(zv(d,f),f===0)return d;const m=ea(i);if(Bm(m))throw li(Im);let g=0;for(;c<h;)d[g]=Bn(i[c]),++c,++g;return d}subarray(e,t){wn(this);const i=nn(this),a=Hv(i,ta),r=new vr(ea(i),au(i),Dn(i)),s=hK(r,e,t),o=new a(ea(s),au(s),Dn(s));return zv(o),o}indexOf(e,...t){wn(this);const i=nn(this),a=Dn(i);let r=No(t[0]);if(r===1/0)return-1;r<0&&(r+=a,r<0&&(r=0));for(let s=r;s<a;++s)if(Vo(i,s)&&Bn(i[s])===e)return s;return-1}lastIndexOf(e,...t){wn(this);const i=nn(this),a=Dn(i);let r=t.length>=1?No(t[0]):a-1;if(r===-1/0)return-1;r>=0?r=r<a-1?r:a-1:r+=a;for(let s=r;s>=0;--s)if(Vo(i,s)&&Bn(i[s])===e)return s;return-1}includes(e,...t){wn(this);const i=nn(this),a=Dn(i);let r=No(t[0]);if(r===1/0)return!1;r<0&&(r+=a,r<0&&(r=0));const s=Cd(e);for(let o=r;o<a;++o){const c=Bn(i[o]);if(s&&Cd(c)||c===e)return!0}return!1}join(e){wn(this);const t=nn(this),i=HD(t);return Zj(i,e)}toLocaleString(...e){wn(this);const t=nn(this),i=HD(t);return Kj(i,...am(e))}get[Cb](){if(Ff(this))return"Float16Array"}};G0(ul,"BYTES_PER_ELEMENT",{value:Bb});G0(ul,zx,{});Z8(ul,wb);const Vx=ul.prototype;G0(Vx,"BYTES_PER_ELEMENT",{value:Bb});G0(Vx,io,{value:Vx.values,writable:!0,configurable:!0});Z8(Vx,la);function NK(n,e,...t){return Bn(vK(n,e,...am(t)))}let OK=class extends yi{constructor(e,t){super(t),this.parser=e}load(e,t,i,a){const r=new k8(this.manager);r.setRequestHeader(this.requestHeader),r.setPath(this.path),r.setWithCredentials(this.withCredentials),r.load(e,s=>{try{t(this.parser(s))}catch(o){a!=null?a(o):console.error(o),this.manager.itemError(e)}},i,a)}};function IK(n){const e=n instanceof Int8Array?M0:n instanceof Uint8Array||n instanceof Uint8ClampedArray?xi:n instanceof Int16Array?C0:n instanceof Uint16Array?Gu:n instanceof Int32Array?Fd:n instanceof Uint32Array?ls:n instanceof ul?sn:n instanceof Float32Array||n instanceof Float64Array?Sn:null;return Lx(e!=null),e}let du=class extends yi{constructor(e,t,i={},a){super(a),this.textureClass=e,this.parser=t,this.options={format:Rn,minFilter:Bt,magFilter:Bt,...i}}load(e,t,i,a){const r=new this.textureClass,s=new OK(this.parser,this.manager);return s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(this.withCredentials),s.load(e,o=>{r.image.data=o instanceof ul?new Uint16Array(o.buffer):o;const{width:c,height:h,depth:f,...d}=this.options;c!=null&&(r.image.width=c),h!=null&&(r.image.height=h),"depth"in r.image&&f!=null&&(r.image.depth=f),r.type=IK(o),Object.assign(r,d),r.needsUpdate=!0,t==null||t(r)},i,a),r}};const kx=Nr.clamp;Nr.euclideanModulo;Nr.inverseLerp;const p6=Nr.lerp,aT=Nr.degToRad;Nr.radToDeg;Nr.isPowerOfTwo;Nr.ceilPowerOfTwo;Nr.floorPowerOfTwo;Nr.normalize;function BK(n,e,t,i=0,a=1){return Nr.mapLinear(n,e,t,i,a)}function UK(n){return Math.min(Math.max(n,0),1)}function An(n){return(e,t)=>{e instanceof ri?Object.defineProperty(e,t,{enumerable:!0,get(){var i;return((i=this.defines)==null?void 0:i[n])!=null},set(i){var a;i!==this[t]&&(i?(this.defines??(this.defines={}),this.defines[n]="1"):(a=this.defines)==null||delete a[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 hh(n,{min:e=Number.MIN_SAFE_INTEGER,max:t=Number.MAX_SAFE_INTEGER}={}){return(i,a)=>{i instanceof ri?Object.defineProperty(i,a,{enumerable:!0,get(){var s;const r=(s=this.defines)==null?void 0:s[n];return r!=null?parseInt(r,10):0},set(r){const s=this[a];r!==s&&(this.defines??(this.defines={}),this.defines[n]=kx(r,e,t).toFixed(0),this.needsUpdate=!0)}}):Object.defineProperty(i,a,{enumerable:!0,get(){const r=this.defines.get(n);return r!=null?parseInt(r,10):0},set(r){const s=this[a];r!==s&&(this.defines.set(n,kx(r,e,t).toFixed(0)),this.setChanged())}})}}function Ub(n,{min:e=-1/0,max:t=1/0,precision:i=7}={}){return(a,r)=>{a instanceof ri?Object.defineProperty(a,r,{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[r];s!==o&&(this.defines??(this.defines={}),this.defines[n]=kx(s,e,t).toFixed(i),this.needsUpdate=!0)}}):Object.defineProperty(a,r,{enumerable:!0,get(){const s=this.defines.get(n);return s!=null?parseFloat(s):0},set(s){const o=this[r];s!==o&&(this.defines.set(n,kx(s,e,t).toFixed(i)),this.setChanged())}})}}function m6(n,{validate:e}={}){return(t,i)=>{t instanceof ri?Object.defineProperty(t,i,{enumerable:!0,get(){var a;return((a=this.defines)==null?void 0:a[n])??""},set(a){if(a!==this[i]){if((e==null?void 0:e(a))===!1){console.error(`Expression validation failed: ${a}`);return}this.defines??(this.defines={}),this.defines[n]=a,this.needsUpdate=!0}}}):Object.defineProperty(t,i,{enumerable:!0,get(){return this.defines.get(n)??""},set(a){if(a!==this[i]){if((e==null?void 0:e(a))===!1){console.error(`Expression validation failed: ${a}`);return}this.defines.set(n,a),this.setChanged()}}})}}function zD(n,...e){const t={};for(let i=0;i<e.length;i+=2){const a=e[i],r=e[i+1];for(const s of r)t[s]={enumerable:!0,get:()=>a[s],set:o=>{a[s]=o}}}return Object.defineProperties(n,t),n}function GD(n,e,t){const i={};for(const a of t)i[a]={enumerable:!0,get:()=>e.uniforms[a].value,set:r=>{e.uniforms[a].value=r}};return Object.defineProperties(n,i),n}class _2 extends yi{constructor(e={},t){super(t),this.options=e}load(e,t,i,a){const{width:r,height:s,depth:o}=this.options,c=new is(null,r,s,o),h=new V8(this.manager);return h.setRequestHeader(this.requestHeader),h.setPath(this.path),h.setWithCredentials(this.withCredentials),h.load(e,f=>{const{image:d}=f;c.image={data:d.data,width:r??d.width,height:s??d.height,depth:o??Math.sqrt(d.height)},c.type=f.type,c.format=f.format,c.colorSpace=f.colorSpace,c.needsUpdate=!0;try{t==null||t(c)}catch(m){a!=null?a(m):console.error(m),this.manager.itemError(e)}},i,a),c}}class VD extends yi{constructor(e={},t){super(t),this.options=e}load(e,t,i,a){const{width:r,height:s}=this.options,o=new Pa(null,r,s),c=new V8(this.manager);return c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(this.withCredentials),c.load(e,h=>{const{image:f}=h;o.image={data:f.data,width:r??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){a!=null?a(d):console.error(d),this.manager.itemError(e)}},i,a),o}}const LK=/^[ \t]*#include +"([\w\d./]+)"/gm;function ki(n,e){return n.replace(LK,(t,i)=>{const a=i.split("/").reduce((r,s)=>typeof r!="string"&&r!=null?r[s]:void 0,e);if(typeof a!="string")throw new Error(`Could not find include for ${i}.`);return ki(a,e)})}let Gv;function PK(){if(Gv!=null)return Gv;const n=new Uint32Array([268435456]);return Gv=new Uint8Array(n.buffer,n.byteOffset,n.byteLength)[0]===0,Gv}function FK(n,e,t,i=!0){if(i===PK())return new e(n);const a=Object.assign(new DataView(n),{getFloat16(s,o){return NK(this,s,o)}}),r=new e(a.byteLength/e.BYTES_PER_ELEMENT);for(let s=0,o=0;s<r.length;++s,o+=e.BYTES_PER_ELEMENT)r[s]=a[t](o,i);return r}const g6=n=>new Uint8Array(n),Gp=(n,e)=>FK(n,ul,"getFloat16",e);class v6 extends du{constructor(e){super(is,g6,{format:Ar,minFilter:$n,magFilter:$n,wrapS:wi,wrapT:wi,wrapR:wi,width:Oj,height:Ij,depth:Bj},e)}}const HK=/#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 zK(n,e,t,i){let a="";for(let r=parseInt(e,10);r<parseInt(t,10);++r)a+=i.replace(/\[\s*i\s*\]/g,"["+r+"]").replace(/UNROLLED_LOOP_INDEX/g,`${r}`);return a}function V0(n){return n.replace(HK,zK)}const GK=`// 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;
}
`,VK=`// 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));
}
`,kK=`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));
}
`,XK=`// 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)));
}
`,WK=`#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));
}
`,YK=`// 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);
}
`,qK=`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);
}
`,ZK=`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;
}
`,jK=`// 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);
}
`,KK=`// 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));
}
`,x6=GK,y6=VK,JK=kK,_6=XK,fh=WK,QK=YK,Jy=qK,$K=ZK,S6=jK,A6=KK,eJ="9c6dfd0054f077f3ad4695b802e74d4c6a814440",tJ=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${eJ}/packages/atmosphere/assets/stars.bin`,Wd=64,Yd=16,Qy=32,$y=128,e_=32,t_=8,Ou=t_*e_,Iu=$y,Bu=Qy,qd=256,Zd=64,Xx=1/1e3,E6=100,nJ=new H;function Lb(n,e,t,i){const a=t.projectOnSurface(n,nJ);return a!=null?t.getOsculatingSphereCenter(a,e,i).negate():i.setScalar(0)}var iJ="Invariant failed";function aJ(n,e){if(!n)throw new Error(iJ)}const kD=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)},Ws=`// 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));
}
`,Ys=`// 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;
};
`,n_=`// 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
`,pf=`// 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);
}
`,rJ=new H(.2126,.7152,.0722),sJ=["solarIrradiance","sunAngularRadius","bottomRadius","topRadius","rayleighDensity","rayleighScattering","mieDensity","mieScattering","mieExtinction","miePhaseFunctionG","absorptionDensity","absorptionExtinction","groundAlbedo","muSMin","skyRadianceToLuminance","sunRadianceToLuminance"];function oJ(n,e){if(e!=null)for(const t of sJ){const i=e[t];i!=null&&(n[t]instanceof H?n[t].copy(i):n[t]=i)}}class mf{constructor(e,t,i,a,r){this.width=e,this.expTerm=t,this.expScale=i,this.linearTerm=a,this.constantTerm=r}toUniform(){return new ie({width:this.width,exp_term:this.expTerm,exp_scale:this.expScale,linear_term:this.linearTerm,constant_term:this.constantTerm})}}const rT=class{constructor(e){this.solarIrradiance=new H(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 H(.005802,.013558,.0331),this.mieDensity=[new mf(0,0,0,0,0),new mf(0,1,-.833333,0,0)],this.mieScattering=new H(.003996,.003996,.003996),this.mieExtinction=new H(.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 H(65e-5,.001881,85e-6),this.groundAlbedo=new dt().setScalar(.1),this.muSMin=Math.cos(aT(120)),this.sunRadianceToLuminance=new H(98242.786222,69954.398112,66475.012354),this.skyRadianceToLuminance=new H(114974.916437,71305.954816,65310.548555),this.sunRadianceToRelativeLuminance=new H,this.skyRadianceToRelativeLuminance=new H,oJ(this,e);const t=rJ.dot(this.sunRadianceToLuminance);this.sunRadianceToRelativeLuminance.copy(this.sunRadianceToLuminance).divideScalar(t),this.skyRadianceToRelativeLuminance.copy(this.skyRadianceToLuminance).divideScalar(t)}toUniform(){return new ie({solar_irradiance:this.solarIrradiance,sun_angular_radius:this.sunAngularRadius,bottom_radius:this.bottomRadius*Xx,top_radius:this.topRadius*Xx,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})}};rT.DEFAULT=new rT;let k0=rT;const lJ=`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
}
`,cJ=`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;
}
`,T6=`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 uJ=Object.defineProperty,nr=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&uJ(e,t,a),a};const hJ=new H,fJ=new H,dJ=new Mb,b6={blendFunction:dn.NORMAL,octEncodedNormal:!1,reconstructNormal:!1,ellipsoid:bd.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 za=class extends h0{constructor(e=new so,t,i=k0.DEFAULT){const{blendFunction:a,normalBuffer:r=null,octEncodedNormal:s,reconstructNormal:o,irradianceTexture:c=null,scatteringTexture:h=null,transmittanceTexture:f=null,singleMieScatteringTexture:d=null,higherOrderScatteringTexture:m=null,ellipsoid:g,correctAltitude:y,correctGeometricError:E,sunDirection:S,sunIrradiance:v,sunLight:_,skyIrradiance:A,skyLight:b,transmittance:O,inscatter:N,irradianceScale:L,albedoScale:B,sky:w,sun:D,moon:G,moonDirection:J,moonAngularRadius:$,lunarRadianceScale:se,ground:le}={...b6,...t};super("AerialPerspectiveEffect",V0(ki(lJ,{core:{depth:y6,packing:QK,math:fh,transform:$K,raySphereIntersection:Jy,cascadedShadowMaps:x6,interleavedGradientNoise:_6,vogelDisk:A6},bruneton:{common:Ws,definitions:Ys,runtime:n_},sky:T6})),{blendFunction:a,vertexShader:cJ,attributes:Qo.DEPTH,uniforms:new Map(Object.entries({normalBuffer:new ie(r),projectionMatrix:new ie(new lt),viewMatrix:new ie(new lt),inverseProjectionMatrix:new ie(new lt),inverseViewMatrix:new ie(new lt),cameraPosition:new ie(new H),bottomRadius:new ie(i.bottomRadius),ellipsoidRadii:new ie(new H),worldToECEFMatrix:new ie(new lt),altitudeCorrection:new ie(new H),geometricErrorCorrectionAmount:new ie(0),sunDirection:new ie((S==null?void 0:S.clone())??new H),albedoScale:new ie(L??B),moonDirection:new ie((J==null?void 0:J.clone())??new H),moonAngularRadius:new ie($),lunarRadianceScale:new ie(se),overlayBuffer:new ie(null),shadowBuffer:new ie(null),shadowMapSize:new ie(new Ee),shadowIntervals:new ie([]),shadowMatrices:new ie([]),inverseShadowMatrices:new ie([]),shadowFar:new ie(0),shadowTopHeight:new ie(0),shadowRadius:new ie(3),stbnTexture:new ie(null),frame:new ie(0),shadowLengthBuffer:new ie(null),lightingMaskBuffer:new ie(null),ATMOSPHERE:i.toUniform(),SUN_SPECTRAL_RADIANCE_TO_LUMINANCE:new ie(i.sunRadianceToRelativeLuminance),SKY_SPECTRAL_RADIANCE_TO_LUMINANCE:new ie(i.skyRadianceToRelativeLuminance),irradiance_texture:new ie(c),scattering_texture:new ie(h),transmittance_texture:new ie(f),single_mie_scattering_texture:new ie(null),higher_order_scattering_texture:new ie(null)})),defines:new Map([["TRANSMITTANCE_TEXTURE_WIDTH",qd.toFixed(0)],["TRANSMITTANCE_TEXTURE_HEIGHT",Zd.toFixed(0)],["SCATTERING_TEXTURE_R_SIZE",Qy.toFixed(0)],["SCATTERING_TEXTURE_MU_SIZE",$y.toFixed(0)],["SCATTERING_TEXTURE_MU_S_SIZE",e_.toFixed(0)],["SCATTERING_TEXTURE_NU_SIZE",t_.toFixed(0)],["IRRADIANCE_TEXTURE_WIDTH",Wd.toFixed(0)],["IRRADIANCE_TEXTURE_HEIGHT",Yd.toFixed(0)],["METER_TO_LENGTH_UNIT",Xx.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=m,this.ellipsoid=g,this.correctAltitude=y,this.correctGeometricError=E,this.sunLight=v??_,this.skyLight=A??b,this.transmittance=O,this.inscatter=N,this.sky=w,this.sun=D,this.moon=G,this.ground=le}get mainCamera(){return this.camera}set mainCamera(e){this.camera=e}copyCameraSettings(e){const{projectionMatrix:t,matrixWorldInverse:i,projectionMatrixInverse:a,matrixWorld:r}=e,s=this.uniforms;s.get("projectionMatrix").value.copy(t),s.get("viewMatrix").value.copy(i),s.get("inverseProjectionMatrix").value.copy(a),s.get("inverseViewMatrix").value.copy(r);const o=e.getWorldPosition(s.get("cameraPosition").value),c=s.get("worldToECEFMatrix").value,h=hJ.copy(o).applyMatrix4(c);try{const d=dJ.setFromECEF(h).height,m=fJ.set(0,this.ellipsoid.maximumRadius,-Math.max(0,d)).applyMatrix4(t);s.get("geometricErrorCorrectionAmount").value=UK(BK(m.y,41.5,13.8,0,1))}catch{return}const f=s.get("altitudeCorrection");this.correctAltitude?Lb(h,this.atmosphere.bottomRadius,this.ellipsoid,f.value):f.value.setScalar(0)}updateOverlay(){let e=!1;const{uniforms:t,defines:i,overlay:a}=this,r=i.has("HAS_OVERLAY"),s=a!=null;return s!==r&&(s?i.set("HAS_OVERLAY","1"):(i.delete("HAS_OVERLAY"),t.get("overlayBuffer").value=null),e=!0),s&&(t.get("overlayBuffer").value=a.map),e}updateShadow(){let e=!1;const{uniforms:t,defines:i,shadow:a}=this,r=i.has("HAS_SHADOW"),s=a!=null;if(s!==r&&(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"),c=`${a.cascadeCount}`;o!==c&&(i.set("SHADOW_CASCADE_COUNT",a.cascadeCount.toFixed(0)),e=!0),t.get("shadowBuffer").value=a.map,t.get("shadowMapSize").value=a.mapSize,t.get("shadowIntervals").value=a.intervals,t.get("shadowMatrices").value=a.matrices,t.get("inverseShadowMatrices").value=a.inverseMatrices,t.get("shadowFar").value=a.far,t.get("shadowTopHeight").value=a.topHeight}return e}updateShadowLength(){let e=!1;const{uniforms:t,defines:i,shadowLength:a}=this,r=i.has("HAS_SHADOW_LENGTH"),s=a!=null;return s!==r&&(s?i.set("HAS_SHADOW_LENGTH","1"):(i.delete("HAS_SHADOW_LENGTH"),t.get("shadowLengthBuffer").value=null),e=!0),s&&(t.get("shadowLengthBuffer").value=a.map),e}updateLightingMask(){let e=!1;const{uniforms:t,defines:i,lightingMask:a}=this,r=i.has("HAS_LIGHTING_MASK"),s=a!=null;if(s!==r&&(s?i.set("HAS_LIGHTING_MASK","1"):(i.delete("HAS_LIGHTING_MASK"),t.get("lightingMaskBuffer").value=null),e=!0),s){t.get("lightingMaskBuffer").value=a.map;const o=i.get("LIGHTING_MASK_CHANNEL"),c=a.channel;c!==o&&(/^[rgba]$/.test(c)?(i.set("LIGHTING_MASK_CHANNEL",c),e=!0):console.error(`Expression validation failed: ${c}`))}return e}update(e,t,i){this.copyCameraSettings(this.camera);let a=!1;a||(a=this.updateOverlay()),a||(a=this.updateShadow()),a||(a=this.updateShadowLength()),a||(a=this.updateLightingMask()),a&&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}};nr([An("OCT_ENCODED_NORMAL")],za.prototype,"octEncodedNormal");nr([An("RECONSTRUCT_NORMAL")],za.prototype,"reconstructNormal");nr([An("COMBINED_SCATTERING_TEXTURES")],za.prototype,"combinedScatteringTextures");nr([An("HAS_HIGHER_ORDER_SCATTERING_TEXTURE")],za.prototype,"hasHigherOrderScatteringTexture");nr([An("CORRECT_GEOMETRIC_ERROR")],za.prototype,"correctGeometricError");nr([An("SUN_LIGHT")],za.prototype,"sunLight");nr([An("SKY_LIGHT")],za.prototype,"skyLight");nr([An("TRANSMITTANCE")],za.prototype,"transmittance");nr([An("INSCATTER")],za.prototype,"inscatter");nr([An("SKY")],za.prototype,"sky");nr([An("SUN")],za.prototype,"sun");nr([An("MOON")],za.prototype,"moon");nr([An("GROUND")],za.prototype,"ground");nr([hh("SHADOW_SAMPLE_COUNT",{min:1,max:16})],za.prototype,"shadowSampleCount");var pJ=Object.defineProperty,M6=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&pJ(e,t,a),a};const mJ=new H;function gJ(n,e){let t="",i="";for(let a=1;a<e;++a)t+=`layout(location = ${a}) out float renderTarget${a};
`,i+=`renderTarget${a} = 0.0;
`;return n.replace("#include <mrt_layout>",t).replace("#include <mrt_output>",i)}const Pb={ellipsoid:bd.WGS84,correctAltitude:!0,renderTargetCount:1};class X0 extends cl{constructor(e,t=k0.DEFAULT){const{irradianceTexture:i=null,scatteringTexture:a=null,transmittanceTexture:r=null,singleMieScatteringTexture:s=null,higherOrderScatteringTexture:o=null,ellipsoid:c,correctAltitude:h,sunDirection:f,sunAngularRadius:d,renderTargetCount:m,...g}={...Pb,...e};super({toneMapped:!1,depthWrite:!1,depthTest:!1,...g,uniforms:{cameraPosition:new ie(new H),worldToECEFMatrix:new ie(new lt),altitudeCorrection:new ie(new H),sunDirection:new ie((f==null?void 0:f.clone())??new H),ATMOSPHERE:t.toUniform(),SUN_SPECTRAL_RADIANCE_TO_LUMINANCE:new ie(t.sunRadianceToRelativeLuminance),SKY_SPECTRAL_RADIANCE_TO_LUMINANCE:new ie(t.skyRadianceToRelativeLuminance),irradiance_texture:new ie(i),scattering_texture:new ie(a),transmittance_texture:new ie(r),single_mie_scattering_texture:new ie(null),higher_order_scattering_texture:new ie(null),...g.uniforms},defines:{PI:`${Math.PI}`,TRANSMITTANCE_TEXTURE_WIDTH:qd.toFixed(0),TRANSMITTANCE_TEXTURE_HEIGHT:Zd.toFixed(0),SCATTERING_TEXTURE_R_SIZE:Qy.toFixed(0),SCATTERING_TEXTURE_MU_SIZE:$y.toFixed(0),SCATTERING_TEXTURE_MU_S_SIZE:e_.toFixed(0),SCATTERING_TEXTURE_NU_SIZE:t_.toFixed(0),IRRADIANCE_TEXTURE_WIDTH:Wd.toFixed(0),IRRADIANCE_TEXTURE_HEIGHT:Yd.toFixed(0),METER_TO_LENGTH_UNIT:Xx.toFixed(7),...g.defines}}),this.atmosphere=t,this.combinedScatteringTextures=!1,this.hasHigherOrderScatteringTexture=!1,this.singleMieScatteringTexture=s,this.higherOrderScatteringTexture=o,this.ellipsoid=c,this.correctAltitude=h,d!=null&&(this.sunAngularRadius=d),this.renderTargetCount=m}copyCameraSettings(e){const t=this.uniforms,i=e.getWorldPosition(t.cameraPosition.value),a=mJ.copy(i).applyMatrix4(t.worldToECEFMatrix.value),r=t.altitudeCorrection.value;this.correctAltitude?Lb(a,this.atmosphere.bottomRadius,this.ellipsoid,r):r.setScalar(0)}onBeforeCompile(e,t){e.fragmentShader=gJ(e.fragmentShader,this.renderTargetCount)}onBeforeRender(e,t,i,a,r,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)}}M6([An("COMBINED_SCATTERING_TEXTURES")],X0.prototype,"combinedScatteringTextures");M6([An("HAS_HIGHER_ORDER_SCATTERING_TEXTURE")],X0.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 vJ=173.1446326846693,xJ=14959787069098932e-8,Qu=.017453292519943295,yJ=365.24217,XD=new Date("2000-01-01T12:00:00Z"),Oo=2*Math.PI,Fl=3600*(180/Math.PI),Hf=484813681109536e-20,_J=10800*60,SJ=2*_J,AJ=6378.1366,EJ=AJ/xJ,TJ=81.30056,Fb=.0002959122082855911,sT=2825345909524226e-22,oT=8459715185680659e-23,lT=1292024916781969e-23,cT=1524358900784276e-23;function p1(n){if(!Number.isFinite(n))throw console.trace(),`Value is not a finite number: ${n}`;return n}function gf(n){return n-Math.floor(n)}var Gn;(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"})(Gn||(Gn={}));const bJ=[Gn.Star1,Gn.Star2,Gn.Star3,Gn.Star4,Gn.Star5,Gn.Star6,Gn.Star7,Gn.Star8],MJ=[{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 CJ(n){const e=bJ.indexOf(n);return e>=0?MJ[e]:null}function C6(n){const e=CJ(n);return e&&e.dist>0?e:null}var ol;(function(n){n[n.From2000=0]="From2000",n[n.Into2000=1]="Into2000"})(ol||(ol={}));const zf={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 RJ(n){var e,t,i,a,r,s,o;const c=2e3+(n-14)/yJ;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/100,t=e*e,i=e*t,a=t*t,r=t*i,s=i*i,10583.6-1014.41*e+33.78311*t-5.952053*i-.1798452*a+.022174192*r+.0090316521*s):c<1600?(e=(c-1e3)/100,t=e*e,i=e*t,a=t*t,r=t*i,s=i*i,1574.2-556.01*e+71.23472*t+.319781*i-.8503463*a-.005050998*r+.0083572073*s):c<1700?(e=c-1600,t=e*e,i=e*t,120-.9808*e-.01532*t+i/7129):c<1800?(e=c-1700,t=e*e,i=e*t,a=t*t,8.83+.1603*e-.0059285*t+13336e-8*i-a/1174e3):c<1860?(e=c-1800,t=e*e,i=e*t,a=t*t,r=t*i,s=i*i,o=i*a,13.72-.332447*e+.0068612*t+.0041116*i-37436e-8*a+121272e-10*r-1699e-10*s+875e-12*o):c<1900?(e=c-1860,t=e*e,i=e*t,a=t*t,r=t*i,7.62+.5737*e-.251754*t+.01680668*i-.0004473624*a+r/233174):c<1920?(e=c-1900,t=e*e,i=e*t,a=t*t,-2.79+1.494119*e-.0598939*t+.0061966*i-197e-6*a):c<1941?(e=c-1920,t=e*e,i=e*t,21.2+.84493*e-.0761*t+.0020936*i):c<1961?(e=c-1950,t=e*e,i=e*t,29.07+.407*e-t/233+i/2547):c<1986?(e=c-1975,t=e*e,i=e*t,45.45+1.067*e-t/260-i/718):c<2005?(e=c-2e3,t=e*e,i=e*t,a=t*t,r=t*i,63.86+.3345*e-.060374*t+.0017275*i+651814e-9*a+2373599e-11*r):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let wJ=RJ;function WD(n){return n+wJ(n)/86400}class cc{constructor(e){if(e instanceof cc){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()-XD.getTime())/t,this.tt=WD(this.ut);return}if(Number.isFinite(e)){this.date=new Date(XD.getTime()+e*t),this.ut=e,this.tt=WD(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 cc(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 cc(this.ut+e)}}function dh(n){return n instanceof cc?n:new cc(n)}function DJ(n){function e(m){return m%SJ*Hf}const t=n.tt/36525,i=e(128710479305e-5+t*1295965810481e-4),a=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),s=e(450160.398036-t*69628905431e-4);let o=Math.sin(s),c=Math.cos(s),h=(-172064161-174666*t)*o+33386*c,f=(92052331+9086*t)*c+15377*o,d=2*(a-r+s);return o=Math.sin(d),c=Math.cos(d),h+=(-13170906-1675*t)*o-13696*c,f+=(5730336-3015*t)*c-4587*o,d=2*(a+s),o=Math.sin(d),c=Math.cos(d),h+=(-2276413-234*t)*o+2796*c,f+=(978459-485*t)*c+1374*o,d=2*s,o=Math.sin(d),c=Math.cos(d),h+=(2074554+207*t)*o-698*c,f+=(-897492+470*t)*c-291*o,o=Math.sin(i),c=Math.cos(i),h+=(1475877-3633*t)*o+11817*c,f+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+h*1e-7,deps:388e-6+f*1e-7}}function R6(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 Vv;function w6(n){if(!Vv||Math.abs(Vv.tt-n.tt)>1e-6){const e=DJ(n),t=R6(n),i=t+e.deps/3600;Vv={tt:n.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*Qu)/15,mobl:t,tobl:i}}return Vv}function NJ(n,e){const t=n*Qu,i=Math.cos(t),a=Math.sin(t);return[e[0],e[1]*i-e[2]*a,e[1]*a+e[2]*i]}function OJ(n,e){return NJ(R6(n),e)}function IJ(n){const e=n.tt/36525;function t(ht,et){const Re=[];let Z;for(Z=0;Z<=et-ht;++Z)Re.push(0);return{min:ht,array:Re}}function i(ht,et,Re,Z){const Ue=[];for(let ze=0;ze<=et-ht;++ze)Ue.push(t(Re,Z));return{min:ht,array:Ue}}function a(ht,et,Re){const Z=ht.array[et-ht.min];return Z.array[Re-Z.min]}function r(ht,et,Re,Z){const Ue=ht.array[et-ht.min];Ue.array[Re-Ue.min]=Z}let s,o,c,h,f,d,m,g,y,E,S,v,_,A,b,O,N,L,B,w,D,G,J,$=i(-6,6,1,4),se=i(-6,6,1,4);function le(ht,et){return a($,ht,et)}function q(ht,et){return a(se,ht,et)}function te(ht,et,Re){return r($,ht,et,Re)}function ee(ht,et,Re){return r(se,ht,et,Re)}function de(ht,et,Re,Z,Ue){Ue(ht*Re-et*Z,et*Re+ht*Z)}function ue(ht){return Math.sin(Oo*ht)}m=e*e,y=0,J=0,S=0,v=3422.7;var Pe=ue(.19833+.05611*e),He=ue(.27869+.04508*e),Ke=ue(.16827-.36903*e),nt=ue(.34734-5.37261*e),xt=ue(.10498-5.37899*e),fe=ue(.42681-.41855*e),Be=ue(.14943-5.37511*e);for(L=.84*Pe+.31*He+14.27*Ke+7.26*nt+.28*xt+.24*fe,B=2.94*Pe+.31*He+14.27*Ke+9.34*nt+1.12*xt+.83*fe,w=-6.4*Pe-1.89*fe,D=.21*Pe+.31*He+14.27*Ke-88.7*nt-15.3*xt+.24*fe-1.86*Be,G=L-w,g=-3332e-9*ue(.59734-5.37261*e)-539e-9*ue(.35498-5.37899*e)-64e-9*ue(.39943-5.37511*e),_=Oo*gf(.60643382+1336.85522467*e-313e-8*m)+L/Fl,A=Oo*gf(.37489701+1325.55240982*e+2565e-8*m)+B/Fl,b=Oo*gf(.99312619+99.99735956*e-44e-8*m)+w/Fl,O=Oo*gf(.25909118+1342.2278298*e-892e-8*m)+D/Fl,N=Oo*gf(.82736186+1236.85308708*e-397e-8*m)+G/Fl,f=1;f<=4;++f){switch(f){case 1:c=A,o=4,h=1.000002208;break;case 2:c=b,o=3,h=.997504612-.002495388*e;break;case 3:c=O,o=4,h=1.000002708+139.978*g;break;case 4:c=N,o=6,h=1;break;default:throw`Internal error: I = ${f}`}for(te(0,f,1),te(1,f,Math.cos(c)*h),ee(0,f,0),ee(1,f,Math.sin(c)*h),d=2;d<=o;++d)de(le(d-1,f),q(d-1,f),le(1,f),q(1,f),(ht,et)=>(te(d,f,ht),ee(d,f,et)));for(d=1;d<=o;++d)te(-d,f,le(d,f)),ee(-d,f,-q(d,f))}function Je(ht,et,Re,Z){for(var Ue={x:1,y:0},ze=[0,ht,et,Re,Z],Qe=1;Qe<=4;++Qe)ze[Qe]!==0&&de(Ue.x,Ue.y,le(ze[Qe],Qe),q(ze[Qe],Qe),(Ye,ot)=>(Ue.x=Ye,Ue.y=ot));return Ue}function ve(ht,et,Re,Z,Ue,ze,Qe,Ye){var ot=Je(Ue,ze,Qe,Ye);y+=ht*ot.y,J+=et*ot.y,S+=Re*ot.x,v+=Z*ot.x}ve(13.902,14.06,-.001,.2607,0,0,0,4),ve(.403,-4.01,.394,.0023,0,0,0,3),ve(2369.912,2373.36,.601,28.2333,0,0,0,2),ve(-125.154,-112.79,-.725,-.9781,0,0,0,1),ve(1.979,6.98,-.445,.0433,1,0,0,4),ve(191.953,192.72,.029,3.0861,1,0,0,2),ve(-8.466,-13.51,.455,-.1093,1,0,0,1),ve(22639.5,22609.07,.079,186.5398,1,0,0,0),ve(18.609,3.59,-.094,.0118,1,0,0,-1),ve(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),ve(3.215,5.44,.192,-.0386,1,0,0,-3),ve(-38.428,-38.64,.001,.6008,1,0,0,-4),ve(-.393,-1.43,-.092,.0086,1,0,0,-6),ve(-.289,-1.59,.123,-.0053,0,1,0,4),ve(-24.42,-25.1,.04,-.3,0,1,0,2),ve(18.023,17.93,.007,.1494,0,1,0,1),ve(-668.146,-126.98,-1.302,-.3997,0,1,0,0),ve(.56,.32,-.001,-.0037,0,1,0,-1),ve(-165.145,-165.06,.054,1.9178,0,1,0,-2),ve(-1.877,-6.46,-.416,.0339,0,1,0,-4),ve(.213,1.02,-.074,.0054,2,0,0,4),ve(14.387,14.78,-.017,.2833,2,0,0,2),ve(-.586,-1.2,.054,-.01,2,0,0,1),ve(769.016,767.96,.107,10.1657,2,0,0,0),ve(1.75,2.01,-.018,.0155,2,0,0,-1),ve(-211.656,-152.53,5.679,-.3039,2,0,0,-2),ve(1.225,.91,-.03,-.0088,2,0,0,-3),ve(-30.773,-34.07,-.308,.3722,2,0,0,-4),ve(-.57,-1.4,-.074,.0109,2,0,0,-6),ve(-2.921,-11.75,.787,-.0484,1,1,0,2),ve(1.267,1.52,-.022,.0164,1,1,0,1),ve(-109.673,-115.18,.461,-.949,1,1,0,0),ve(-205.962,-182.36,2.056,1.4437,1,1,0,-2),ve(.233,.36,.012,-.0025,1,1,0,-3),ve(-4.391,-9.66,-.471,.0673,1,1,0,-4),ve(.283,1.53,-.111,.006,1,-1,0,4),ve(14.577,31.7,-1.54,.2302,1,-1,0,2),ve(147.687,138.76,.679,1.1528,1,-1,0,0),ve(-1.089,.55,.021,0,1,-1,0,-1),ve(28.475,23.59,-.443,-.2257,1,-1,0,-2),ve(-.276,-.38,-.006,-.0036,1,-1,0,-3),ve(.636,2.27,.146,-.0102,1,-1,0,-4),ve(-.189,-1.68,.131,-.0028,0,2,0,2),ve(-7.486,-.66,-.037,-.0086,0,2,0,0),ve(-8.096,-16.35,-.74,.0918,0,2,0,-2),ve(-5.741,-.04,0,-9e-4,0,0,2,2),ve(.255,0,0,0,0,0,2,1),ve(-411.608,-.2,0,-.0124,0,0,2,0),ve(.584,.84,0,.0071,0,0,2,-1),ve(-55.173,-52.14,0,-.1052,0,0,2,-2),ve(.254,.25,0,-.0017,0,0,2,-3),ve(.025,-1.67,0,.0031,0,0,2,-4),ve(1.06,2.96,-.166,.0243,3,0,0,2),ve(36.124,50.64,-1.3,.6215,3,0,0,0),ve(-13.193,-16.4,.258,-.1187,3,0,0,-2),ve(-1.187,-.74,.042,.0074,3,0,0,-4),ve(-.293,-.31,-.002,.0046,3,0,0,-6),ve(-.29,-1.45,.116,-.0051,2,1,0,2),ve(-7.649,-10.56,.259,-.1038,2,1,0,0),ve(-8.627,-7.59,.078,-.0192,2,1,0,-2),ve(-2.74,-2.54,.022,.0324,2,1,0,-4),ve(1.181,3.32,-.212,.0213,2,-1,0,2),ve(9.703,11.67,-.151,.1268,2,-1,0,0),ve(-.352,-.37,.001,-.0028,2,-1,0,-1),ve(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),ve(.36,.2,-.012,-.0043,2,-1,0,-4),ve(-1.167,-1.25,.008,-.0106,1,2,0,0),ve(-7.412,-6.12,.117,.0484,1,2,0,-2),ve(-.311,-.65,-.032,.0044,1,2,0,-4),ve(.757,1.82,-.105,.0112,1,-2,0,2),ve(2.58,2.32,.027,.0196,1,-2,0,0),ve(2.533,2.4,-.014,-.0212,1,-2,0,-2),ve(-.344,-.57,-.025,.0036,0,3,0,-2),ve(-.992,-.02,0,0,1,0,2,2),ve(-45.099,-.02,0,-.001,1,0,2,0),ve(-.179,-9.52,0,-.0833,1,0,2,-2),ve(-.301,-.33,0,.0014,1,0,2,-4),ve(-6.382,-3.37,0,-.0481,1,0,-2,2),ve(39.528,85.13,0,-.7136,1,0,-2,0),ve(9.366,.71,0,-.0112,1,0,-2,-2),ve(.202,.02,0,0,1,0,-2,-4),ve(.415,.1,0,.0013,0,1,2,0),ve(-2.152,-2.26,0,-.0066,0,1,2,-2),ve(-1.44,-1.3,0,.0014,0,1,-2,2),ve(.384,-.04,0,0,0,1,-2,-2),ve(1.938,3.6,-.145,.0401,4,0,0,0),ve(-.952,-1.58,.052,-.013,4,0,0,-2),ve(-.551,-.94,.032,-.0097,3,1,0,0),ve(-.482,-.57,.005,-.0045,3,1,0,-2),ve(.681,.96,-.026,.0115,3,-1,0,0),ve(-.297,-.27,.002,-9e-4,2,2,0,-2),ve(.254,.21,-.003,0,2,-2,0,-2),ve(-.25,-.22,.004,.0014,1,3,0,-2),ve(-3.996,0,0,4e-4,2,0,2,0),ve(.557,-.75,0,-.009,2,0,2,-2),ve(-.459,-.38,0,-.0053,2,0,-2,2),ve(-1.298,.74,0,4e-4,2,0,-2,0),ve(.538,1.14,0,-.0141,2,0,-2,-2),ve(.263,.02,0,0,1,1,2,0),ve(.426,.07,0,-6e-4,1,1,-2,-2),ve(-.304,.03,0,3e-4,1,-1,2,0),ve(-.372,-.19,0,-.0027,1,-1,-2,2),ve(.418,0,0,0,0,0,4,0),ve(-.33,-.04,0,0,3,0,2,0);function at(ht,et,Re,Z,Ue){return ht*Je(et,Re,Z,Ue).y}E=0,E+=at(-526.069,0,0,1,-2),E+=at(-3.352,0,0,1,-4),E+=at(44.297,1,0,1,-2),E+=at(-6,1,0,1,-4),E+=at(20.599,-1,0,1,0),E+=at(-30.598,-1,0,1,-2),E+=at(-24.649,-2,0,1,0),E+=at(-2,-2,0,1,-2),E+=at(-22.571,0,1,1,-2),E+=at(10.985,0,-1,1,-2),y+=.82*ue(.7736-62.5512*e)+.31*ue(.0466-125.1025*e)+.35*ue(.5785-25.1042*e)+.66*ue(.4591+1335.8075*e)+.64*ue(.313-91.568*e)+1.14*ue(.148+1331.2898*e)+.21*ue(.5918+1056.5859*e)+.44*ue(.5784+1322.8595*e)+.24*ue(.2275-5.7374*e)+.28*ue(.2965+2.6929*e)+.33*ue(.3132+6.3368*e),s=O+J/Fl;let ft=(1.000002708+139.978*g)*(18518.511+1.189+S)*Math.sin(s)-6.24*Math.sin(3*s)+E;return{geo_eclip_lon:Oo*gf((_+y/Fl)/Oo),geo_eclip_lat:Math.PI/(180*3600)*ft,distance_au:Fl*EJ/(.999953253*v)}}function BJ(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 UJ(n,e,t){const i=D6(e,t);return BJ(i,n)}function D6(n,e){const t=n.tt/36525;let i=84381.406,a=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,r=((((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*=Hf,a*=Hf,r*=Hf,s*=Hf;const o=Math.sin(i),c=Math.cos(i),h=Math.sin(-a),f=Math.cos(-a),d=Math.sin(-r),m=Math.cos(-r),g=Math.sin(s),y=Math.cos(s),E=y*f-h*g*m,S=y*h*c+g*m*f*c-o*g*d,v=y*h*o+g*m*f*o+c*g*d,_=-g*f-h*y*m,A=-g*h*c+y*m*f*c-o*y*d,b=-g*h*o+y*m*f*o+c*y*d,O=h*d,N=-d*f*c-o*m,L=-d*f*o+m*c;if(e===ol.Into2000)return new wd([[E,S,v],[_,A,b],[O,N,L]]);if(e===ol.From2000)return new wd([[E,_,O],[S,A,N],[v,b,L]]);throw"Invalid precess direction"}function LJ(n){const e=.779057273264+.00273781191135448*n.ut,t=n.ut%1;let i=360*((e+t)%1);return i<0&&(i+=360),i}let kv;function PJ(n){if(!kv||kv.tt!==n.tt){const e=n.tt/36525;let t=15*w6(n).ee;const i=LJ(n);let a=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+i)%360/15;a<0&&(a+=24),kv={tt:n.tt,st:a}}return kv.st}function FJ(n){const e=dh(n);return PJ(e)}function HJ(n,e){const t=w6(n),i=t.mobl*Qu,a=t.tobl*Qu,r=t.dpsi*Hf,s=Math.cos(i),o=Math.sin(i),c=Math.cos(a),h=Math.sin(a),f=Math.cos(r),d=Math.sin(r),m=f,g=-d*s,y=-d*o,E=d*c,S=f*s*c+o*h,v=f*o*c-s*h,_=d*h,A=f*s*h-o*c,b=f*o*h+s*c;if(e===ol.From2000)return new wd([[m,E,_],[g,S,A],[y,v,b]]);if(e===ol.Into2000)return new wd([[m,g,y],[E,S,v],[_,A,b]]);throw"Invalid precess direction"}class ws{constructor(e,t,i,a){this.x=e,this.y=t,this.z=i,this.t=a}Length(){return Math.hypot(this.x,this.y,this.z)}}class zJ{constructor(e,t,i,a,r,s,o){this.x=e,this.y=t,this.z=i,this.vx=a,this.vy=r,this.vz=s,this.t=o}}let GJ=class{constructor(e,t,i){this.lat=p1(e),this.lon=p1(t),this.dist=p1(i)}};class wd{constructor(e){this.rot=e}}function uT(n){const e=dh(n),t=IJ(e),i=t.distance_au*Math.cos(t.geo_eclip_lat),a=[i*Math.cos(t.geo_eclip_lon),i*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],r=OJ(e,a),s=UJ(r,e,ol.Into2000);return new ws(s[0],s[1],s[2],e)}function Qf(n,e,t){let i=1,a=0;for(let r of n){let s=0;for(let[c,h,f]of r)s+=c*Math.cos(h+e*f);let o=i*s;t&&(o%=Oo),a+=o,i*=e}return a}function S2(n,e){let t=1,i=0,a=0,r=0;for(let s of n){let o=0,c=0;for(let[h,f,d]of s){let m=f+e*d;o+=h*d*Math.sin(m),r>0&&(c+=h*Math.cos(m))}a+=r*i*c-t*o,i=t,t*=e,++r}return a}const rm=365250,hT=0,fT=1,dT=2;function pT(n){return new Ta(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 N6(n,e,t){const i=t*Math.cos(e),a=Math.cos(n),r=Math.sin(n);return[i*a,i*r,t*Math.sin(e)]}function m1(n,e){const t=e.tt/rm,i=Qf(n[hT],t,!0),a=Qf(n[fT],t,!1),r=Qf(n[dT],t,!1),s=N6(i,a,r);return pT(s).ToAstroVector(e)}function VJ(n,e){const t=e/rm,i=Qf(n[hT],t,!0),a=Qf(n[fT],t,!1),r=Qf(n[dT],t,!1),s=S2(n[hT],t),o=S2(n[fT],t),c=S2(n[dT],t),h=Math.cos(i),f=Math.sin(i),d=Math.cos(a),m=Math.sin(a),g=+(c*d*h)-r*m*h*o-r*d*f*s,y=+(c*d*f)-r*m*f*o+r*d*h*s,E=+(c*m)+r*d*o,S=N6(i,a,r),v=[g/rm,y/rm,E/rm],_=pT(S),A=pT(v);return new $u(e,_,A)}function Xv(n,e,t,i){const a=i/(i+Fb),r=m1(zf[t],e);n.x+=a*r.x,n.y+=a*r.y,n.z+=a*r.z}function kJ(n){const e=new ws(0,0,0,n);return Xv(e,n,Gn.Jupiter,sT),Xv(e,n,Gn.Saturn,oT),Xv(e,n,Gn.Uranus,lT),Xv(e,n,Gn.Neptune,cT),e}const mT=51,XJ=29200,Gf=146,Io=201,Su=[[-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 Ta{constructor(e,t,i){this.x=e,this.y=t,this.z=i}clone(){return new Ta(this.x,this.y,this.z)}ToAstroVector(e){return new ws(this.x,this.y,this.z,e)}static zero(){return new Ta(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Ta(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Ta(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 Ta(e*this.x,e*this.y,e*this.z)}div(e){return new Ta(this.x/e,this.y/e,this.z/e)}mean(e){return new Ta((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Ta(-this.x,-this.y,-this.z)}}class $u{constructor(e,t,i){this.tt=e,this.r=t,this.v=i}clone(){return new $u(this.tt,this.r,this.v)}sub(e){return new $u(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function WJ(n){let[e,[t,i,a],[r,s,o]]=n;return new $u(e,new Ta(t,i,a),new Ta(r,s,o))}function Wv(n,e,t,i){const a=i/(i+Fb),r=VJ(zf[t],e);return n.r.incr(r.r.mul(a)),n.v.incr(r.v.mul(a)),r}function Vp(n,e,t){const i=t.sub(n),a=i.quadrature();return i.mul(e/(a*Math.sqrt(a)))}class Hb{constructor(e){let t=new $u(e,new Ta(0,0,0),new Ta(0,0,0));this.Jupiter=Wv(t,e,Gn.Jupiter,sT),this.Saturn=Wv(t,e,Gn.Saturn,oT),this.Uranus=Wv(t,e,Gn.Uranus,lT),this.Neptune=Wv(t,e,Gn.Neptune,cT),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 $u(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=Vp(e,Fb,this.Sun.r);return t.incr(Vp(e,sT,this.Jupiter.r)),t.incr(Vp(e,oT,this.Saturn.r)),t.incr(Vp(e,lT,this.Uranus.r)),t.incr(Vp(e,cT,this.Neptune.r)),t}}let O6=class I6{constructor(e,t,i,a){this.tt=e,this.r=t,this.v=i,this.a=a}clone(){return new I6(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}},B6=class{constructor(e,t){this.bary=e,this.grav=t}};function Wx(n,e,t,i){return new Ta(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 YD(n,e,t){return new Ta(e.x+n*t.x,e.y+n*t.y,e.z+n*t.z)}function gT(n,e){const t=n-e.tt,i=new Hb(n),a=Wx(t,e.r,e.v,e.a),r=i.Acceleration(a).mean(e.a),s=Wx(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=i.Acceleration(s),h=new O6(n,s,o,c);return new B6(i,h)}const YJ=[];function U6(n,e){const t=Math.floor(n);return t<0?0:t>=e?e-1:t}function vT(n){const e=WJ(n),t=new Hb(e.tt),i=e.r.add(t.Sun.r),a=e.v.add(t.Sun.v),r=t.Acceleration(i),s=new O6(e.tt,i,a,r);return new B6(t,s)}function qJ(n,e){const t=Su[0][0];if(e<t||e>Su[mT-1][0])return null;const i=U6((e-t)/XJ,mT-1);if(!n[i]){const r=n[i]=[];r[0]=vT(Su[i]).grav,r[Io-1]=vT(Su[i+1]).grav;let s,o=r[0].tt;for(s=1;s<Io-1;++s)r[s]=gT(o+=Gf,r[s-1]).grav;o=r[Io-1].tt;var a=[];for(a[Io-1]=r[Io-1],s=Io-2;s>0;--s)a[s]=gT(o-=Gf,a[s+1]).grav;for(s=Io-2;s>0;--s){const c=s/(Io-1);r[s].r=r[s].r.mul(1-c).add(a[s].r.mul(c)),r[s].v=r[s].v.mul(1-c).add(a[s].v.mul(c)),r[s].a=r[s].a.mul(1-c).add(a[s].a.mul(c))}}return n[i]}function qD(n,e,t){let i=vT(n);const a=Math.ceil((e-i.grav.tt)/t);for(let r=0;r<a;++r)i=gT(r+1===a?e:i.grav.tt+t,i.grav);return i}function ZJ(n,e){let t,i,a;const r=qJ(YJ,n.tt);if(r){const s=U6((n.tt-r[0].tt)/Gf,Io-1),o=r[s],c=r[s+1],h=o.a.mean(c.a),f=Wx(n.tt-o.tt,o.r,o.v,h),d=YD(n.tt-o.tt,o.v,h),m=Wx(n.tt-c.tt,c.r,c.v,h),g=YD(n.tt-c.tt,c.v,h),y=(n.tt-o.tt)/Gf;t=f.mul(1-y).add(m.mul(y)),i=d.mul(1-y).add(g.mul(y))}else{let s;n.tt<Su[0][0]?s=qD(Su[0],n.tt,-Gf):s=qD(Su[mT-1],n.tt,+Gf),t=s.grav.r,i=s.grav.v,a=s.bary}return a||(a=new Hb(n.tt)),t=t.sub(a.Sun.r),i=i.sub(a.Sun.v),new zJ(t.x,t.y,t.z,i.x,i.y,i.z,n)}function Um(n,e){var t=dh(e);if(n in zf)return m1(zf[n],t);if(n===Gn.Pluto){const s=ZJ(t);return new ws(s.x,s.y,s.z,t)}if(n===Gn.Sun)return new ws(0,0,0,t);if(n===Gn.Moon){var i=m1(zf.Earth,t),a=uT(t);return new ws(i.x+a.x,i.y+a.y,i.z+a.z,t)}if(n===Gn.EMB){const s=m1(zf.Earth,t),o=uT(t),c=1+TJ;return new ws(s.x+o.x/c,s.y+o.y/c,s.z+o.z/c,t)}if(n===Gn.SSB)return kJ(t);const r=C6(n);if(r){const s=new GJ(r.dec,15*r.ra,r.dist);return tQ(s,t)}throw`HelioVector: Unknown body "${n}"`}function jJ(n,e){let t=e,i=0;for(let a=0;a<10;++a){const r=n(t),s=r.Length()/vJ;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 r;t=o}throw`Light-travel time solver did not converge: dt = ${i}`}class KJ{constructor(e,t,i,a){this.observerBody=e,this.targetBody=t,this.aberration=i,this.observerPos=a}Position(e){this.aberration&&(this.observerPos=Um(this.observerBody,e));const t=Um(this.targetBody,e);return new ws(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function JJ(n,e,t,i){const a=dh(n);if(C6(t)){const o=Um(t,a),c=Um(e,a);return new ws(o.x-c.x,o.y-c.y,o.z-c.z,a)}let r;r=Um(e,a);const s=new KJ(e,t,i,r);return jJ(o=>s.Position(o),a)}function QJ(n,e,t){const i=dh(e);switch(n){case Gn.Earth:return new ws(0,0,0,i);case Gn.Moon:return uT(i);default:const a=JJ(i,Gn.Earth,n,t);return a.t=i,a}}var ZD;(function(n){n[n.Pericenter=0]="Pericenter",n[n.Apocenter=1]="Apocenter"})(ZD||(ZD={}));function $J(n,e){return new wd([[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 eQ(n,e,t){const i=p1(t)*Qu,a=Math.cos(i),r=Math.sin(i),s=(e+1)%3,o=(e+2)%3,c=e;let h=[[0,0,0],[0,0,0],[0,0,0]];return h[s][s]=a*n.rot[s][s]-r*n.rot[s][o],h[s][o]=r*n.rot[s][s]+a*n.rot[s][o],h[s][c]=n.rot[s][c],h[o][s]=a*n.rot[o][s]-r*n.rot[o][o],h[o][o]=r*n.rot[o][s]+a*n.rot[o][o],h[o][c]=n.rot[o][c],h[c][s]=a*n.rot[c][s]-r*n.rot[c][o],h[c][o]=r*n.rot[c][s]+a*n.rot[c][o],h[c][c]=n.rot[c][c],new wd(h)}function tQ(n,e){e=dh(e);const t=n.lat*Qu,i=n.lon*Qu,a=n.dist*Math.cos(t);return new ws(a*Math.cos(i),a*Math.sin(i),n.dist*Math.sin(t),e)}function nQ(n){n=dh(n);const e=D6(n,ol.From2000),t=HJ(n,ol.From2000);return $J(e,t)}var jD;(function(n){n.Penumbral="penumbral",n.Partial="partial",n.Annular="annular",n.Total="total"})(jD||(jD={}));var KD;(function(n){n[n.Invalid=0]="Invalid",n[n.Ascending=1]="Ascending",n[n.Descending=-1]="Descending"})(KD||(KD={}));function zb(n){return n instanceof cc?n:new cc(n instanceof Date?n:new Date(n))}function iQ(n,e=new H){const{x:t,y:i,z:a}=n;return e.set(t,i,a)}function aQ(n,e=new lt){const[t,i,a]=n.rot;return e.set(t[0],i[0],a[0],0,t[1],i[1],a[1],0,t[2],i[2],a[2],0,0,0,0,1)}function rQ(n,e=new lt){const t=zb(n),i=eQ(nQ(t),2,-15*FJ(t));return aQ(i,e)}function L6(n,e,t,i,a){const r=QJ(n,e,!1);return iQ(r,t),i!=null,t.normalize()}function sQ(n,e=new H,t){return L6(Gn.Sun,zb(n),e,t)}function oQ(n,e=new H,t){return L6(Gn.Moon,zb(n),e,t)}const lQ=`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);
}
`,cQ=`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);
}
`,uQ=`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;
}
`,hQ=`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;
}
`,fQ=`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;
}
`,dQ=`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;
}
`,pQ=`
precision highp float;
in vec2 position;
void main() {
gl_Position = vec4(position, 1.0, 1.0);
}
`;function Yx(n,e,t){const i=new oi(e,t,{depthBuffer:!1,type:n,format:Rn}),a=i.texture;return a.minFilter=Bt,a.magFilter=Bt,a.wrapS=Vn,a.wrapT=Vn,a.colorSpace=pa,i}function $f(n,e,t,i){const a=new P3(e,t,i,{depthBuffer:!1,type:n,format:Rn}),r=a.texture;return r.minFilter=Bt,r.magFilter=Bt,r.wrapS=Vn,r.wrapT=Vn,r.wrapR=Vn,r.colorSpace=pa,a}function mQ(n){const e=n[Symbol.iterator]();return new Promise((t,i)=>{const a=()=>{try{const{value:r,done:s}=e.next();s===!0?t(r):kD(a)}catch(r){i(r instanceof Error?r:new Error)}};kD(a)})}async function JD(n,e,t){const{width:i,height:a}=e,r=t.type===sn?new Uint16Array(i*a*4):new Float32Array(i*a*4);await n.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,r),t.userData.imageData=r}class gQ{constructor(e){this.lambdas=new H,this.luminanceFromRadiance=new kt,e===sn&&(this.opticalDepth=Yx(e,qd,Zd)),this.deltaIrradiance=Yx(e,Wd,Yd),this.deltaRayleighScattering=$f(e,Ou,Iu,Bu),this.deltaMieScattering=$f(e,Ou,Iu,Bu),this.deltaScatteringDensity=$f(e,Ou,Iu,Bu),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 vf extends cl{constructor(e){super({glslVersion:cs,vertexShader:pQ,...e,defines:{TRANSMITTANCE_TEXTURE_WIDTH:qd.toFixed(0),TRANSMITTANCE_TEXTURE_HEIGHT:Zd.toFixed(0),SCATTERING_TEXTURE_R_SIZE:Qy.toFixed(0),SCATTERING_TEXTURE_MU_SIZE:$y.toFixed(0),SCATTERING_TEXTURE_MU_S_SIZE:e_.toFixed(0),SCATTERING_TEXTURE_NU_SIZE:t_.toFixed(0),IRRADIANCE_TEXTURE_WIDTH:Wd.toFixed(0),IRRADIANCE_TEXTURE_HEIGHT:Yd.toFixed(0),...e.defines}})}set additive(e){this.transparent=e,this.blending=e?M3:ga,this.blendEquation=js,this.blendEquationAlpha=js,this.blendSrc=Uf,this.blendDst=Uf,this.blendSrcAlpha=Uf,this.blendDstAlpha=Uf}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 P6{constructor(e,{type:t=X8(e)?Sn:sn,combinedScattering:i=!0,higherOrderScattering:a=!0}={}){var r,s;this.transmittanceMaterial=new vf({fragmentShader:ki(dQ,{bruneton:{common:Ws,definitions:Ys,precompute:pf}})}),this.directIrradianceMaterial=new vf({fragmentShader:ki(lQ,{bruneton:{common:Ws,definitions:Ys,precompute:pf}}),uniforms:{transmittanceTexture:new ie(null)}}),this.singleScatteringMaterial=new vf({fragmentShader:ki(fQ,{bruneton:{common:Ws,definitions:Ys,precompute:pf}}),uniforms:{luminanceFromRadiance:new ie(new kt),transmittanceTexture:new ie(null),layer:new ie(0)}}),this.scatteringDensityMaterial=new vf({fragmentShader:ki(hQ,{bruneton:{common:Ws,definitions:Ys,precompute:pf}}),uniforms:{transmittanceTexture:new ie(null),singleRayleighScatteringTexture:new ie(null),singleMieScatteringTexture:new ie(null),multipleScatteringTexture:new ie(null),irradianceTexture:new ie(null),scatteringOrder:new ie(0),layer:new ie(0)}}),this.indirectIrradianceMaterial=new vf({fragmentShader:ki(cQ,{bruneton:{common:Ws,definitions:Ys,precompute:pf}}),uniforms:{luminanceFromRadiance:new ie(new kt),singleRayleighScatteringTexture:new ie(null),singleMieScatteringTexture:new ie(null),multipleScatteringTexture:new ie(null),scatteringOrder:new ie(0)}}),this.multipleScatteringMaterial=new vf({fragmentShader:ki(uQ,{bruneton:{common:Ws,definitions:Ys,precompute:pf}}),uniforms:{luminanceFromRadiance:new ie(new kt),transmittanceTexture:new ie(null),scatteringDensityTexture:new ie(null),layer:new ie(0)}}),this.mesh=new Xn(new Us(2,2)),this.scene=new al().add(this.mesh),this.camera=new so,this.updating=!1,this.renderer=e,this.type=t,this.transmittanceRenderTarget=Yx(t,qd,Zd),this.scatteringRenderTarget=$f(t,Ou,Iu,Bu),this.irradianceRenderTarget=Yx(t,Wd,Yd),i||(this.singleMieScatteringRenderTarget=$f(t,Ou,Iu,Bu)),a&&(this.higherOrderScatteringRenderTarget=$f(t,Ou,Iu,Bu)),this.textures={transmittanceTexture:this.transmittanceRenderTarget.texture,scatteringTexture:this.scatteringRenderTarget.texture,irradianceTexture:this.irradianceRenderTarget.texture,singleMieScatteringTexture:(r=this.singleMieScatteringRenderTarget)==null?void 0:r.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 a;const t=this.directIrradianceMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,this.type===sn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((a=e.context.opticalDepth)==null?void 0:a.texture)??this.transmittanceRenderTarget.texture,this.mesh.material=t,this.renderer.setRenderTarget(e.renderTarget),this.renderer.render(this.scene,this.camera)}computeSingleScattering(e){var a;const t=this.singleScatteringMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,this.type===sn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((a=e.context.opticalDepth)==null?void 0:a.texture)??this.transmittanceRenderTarget.texture,t.setUniforms(e.context),this.mesh.material=t,this.render3DRenderTarget(e.renderTarget,t)}computeScatteringDensity(e){var a;const t=this.scatteringDensityMaterial;this.type===sn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((a=e.context.opticalDepth)==null?void 0:a.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 a;const t=this.multipleScatteringMaterial;t.defines.OUTPUT=e.output,t.additive=e.additive,this.type===sn?t.defines.TRANSMITTANCE_PRECISION_LOG="1":delete t.defines.TRANSMITTANCE_PRECISION_LOG,t.needsUpdate=!0;const i=t.uniforms;i.transmittanceTexture.value=((a=e.context.opticalDepth)==null?void 0:a.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===sn&&(aJ(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=k0.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,a=new gQ(this.type);a.lambdas.set(680,550,440),a.luminanceFromRadiance.identity();const r=i.autoClear;return i.autoClear=!1,await mQ(this.precompute(a,!1)),i.autoClear=r,a.dispose(),await JD(this.renderer,this.transmittanceRenderTarget,this.transmittanceRenderTarget.texture),await JD(this.renderer,this.irradianceRenderTarget,this.irradianceRenderTarget.texture),this.updating=!1,(s=this.disposeQueue)==null||s.call(this),this.textures}dispose(e={}){var i,a,r,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),(a=this.higherOrderScatteringRenderTarget)==null||a.textures.splice(0,1)),this.transmittanceRenderTarget.dispose(),this.scatteringRenderTarget.dispose(),this.irradianceRenderTarget.dispose(),(r=this.singleMieScatteringRenderTarget)==null||r.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 vQ(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 a=n[i];if(typeof a!="string")throw new TypeError("Url must be a string. Received "+a);a!==""&&(i>0&&(a=a.replace(/^[\/]+/,"")),i<n.length-1?a=a.replace(/[\/]+$/,""):a=a.replace(/[\/]+$/,"/"),e.push(a))}var r=e.join("/");r=r.replace(/\/(\?|&|#[^!])/g,"$1");var s=r.split("?");return r=s.shift()+(s.length>0?"?":"")+s.join("&"),r}function xQ(){var n;return typeof arguments[0]=="object"?n=arguments[0]:n=[].slice.call(arguments),vQ(n)}const QD={width:qd,height:Zd},xf={width:Ou,height:Iu,depth:Bu},$D={width:Wd,height:Yd};class F6 extends yi{constructor({format:e="exr",type:t=sn,combinedScattering:i=!0,higherOrderScattering:a=!0}={},r){super(r),this.format=e,this.type=t,this.combinedScattering=i,this.higherOrderScattering=a}setType(e){return this.type=X8(e)?Sn:sn,this}setTypeFromRenderer(e){return this.setType(e)}load(e,t,i,a){const r={},s=({key:o,loader:c,path:h})=>(c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(this.withCredentials),c.load(xQ(e,h),f=>{f.type=this.type,this.type===Sn&&(f.image.data=new Float32Array(new ul(f.image.data.buffer))),f.minFilter=Bt,f.magFilter=Bt,r[`${o}Texture`]=f,r.irradianceTexture!=null&&r.scatteringTexture!=null&&r.transmittanceTexture!=null&&(this.combinedScattering||r.singleMieScatteringTexture!=null)&&(!this.higherOrderScattering||r.higherOrderScatteringTexture!=null)&&(t==null||t(r))},i,a));return this.format==="exr"?{transmittanceTexture:s({key:"transmittance",loader:new VD(QD,this.manager),path:"transmittance.exr"}),scatteringTexture:s({key:"scattering",loader:new _2(xf,this.manager),path:"scattering.exr"}),irradianceTexture:s({key:"irradiance",loader:new VD($D,this.manager),path:"irradiance.exr"}),singleMieScatteringTexture:this.combinedScattering?void 0:s({key:"singleMieScattering",loader:new _2(xf,this.manager),path:"single_mie_scattering.exr"}),higherOrderScatteringTexture:this.higherOrderScattering?s({key:"higherOrderScattering",loader:new _2(xf,this.manager),path:"higher_order_scattering.exr"}):void 0}:{transmittanceTexture:s({key:"transmittance",loader:new du(Pa,Gp,QD,this.manager),path:"transmittance.bin"}),scatteringTexture:s({key:"scattering",loader:new du(is,Gp,xf,this.manager),path:"scattering.bin"}),irradianceTexture:s({key:"irradiance",loader:new du(Pa,Gp,$D,this.manager),path:"irradiance.bin"}),singleMieScatteringTexture:this.combinedScattering?void 0:s({key:"singleMieScattering",loader:new du(is,Gp,xf,this.manager),path:"single_mie_scattering.bin"}),higherOrderScatteringTexture:this.higherOrderScattering?s({key:"higherOrderScattering",loader:new du(is,Gp,xf,this.manager),path:"higher_order_scattering.bin"}):void 0}}}const yQ=`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>
}
`,_Q=`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 SQ=Object.defineProperty,Gb=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&SQ(e,t,a),a};const H6={...Pb,sun:!0,moon:!0,moonAngularRadius:.0045,lunarRadianceScale:1,ground:!0,groundAlbedo:new dt(0)};class i_ extends X0{constructor(e){const{sun:t,moon:i,moonDirection:a,moonAngularRadius:r,lunarRadianceScale:s,ground:o,groundAlbedo:c,...h}={...H6,...e};super({name:"SkyMaterial",glslVersion:cs,vertexShader:_Q,fragmentShader:ki(yQ,{core:{raySphereIntersection:Jy},bruneton:{common:Ws,definitions:Ys,runtime:n_},sky:T6}),...h,uniforms:{inverseProjectionMatrix:new ie(new lt),inverseViewMatrix:new ie(new lt),moonDirection:new ie((a==null?void 0:a.clone())??new H),moonAngularRadius:new ie(r),lunarRadianceScale:new ie(s),groundAlbedo:new ie(c.clone()),shadowLengthBuffer:new ie(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,a,r,s){super.onBeforeRender(e,t,i,a,r,s);const{uniforms:o,defines:c}=this;o.inverseProjectionMatrix.value.copy(i.projectionMatrixInverse),o.inverseViewMatrix.value.copy(i.matrixWorld);const h=c.PERSPECTIVE_CAMERA!=null,f=i.isPerspectiveCamera===!0;f!==h&&(f?c.PERSPECTIVE_CAMERA="1":delete c.PERSPECTIVE_CAMERA,this.needsUpdate=!0);const d=this.groundAlbedo,m=c.GROUND_ALBEDO!=null,g=d.r!==0||d.g!==0||d.b!==0;g!==m&&(g?this.defines.GROUND_ALBEDO="1":delete this.defines.GROUND_ALBEDO,this.needsUpdate=!0);const y=this.shadowLength,E=c.HAS_SHADOW_LENGTH!=null,S=y!=null;S!==E&&(S?c.HAS_SHADOW_LENGTH="1":(delete c.HAS_SHADOW_LENGTH,o.shadowLengthBuffer.value=null),this.needsUpdate=!0),S&&(o.shadowLengthBuffer.value=y.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}}Gb([An("SUN")],i_.prototype,"sun");Gb([An("MOON")],i_.prototype,"moon");Gb([An("GROUND")],i_.prototype,"ground");class AQ extends Xt{constructor(e){super();const t=new Int16Array(e),i=new Uint8Array(e),a=new Xu(t,5),r=new Xu(i,10);this.setAttribute("position",new Ns(a,3,0,!0)),this.setAttribute("magnitude",new Ns(r,1,6,!0)),this.setAttribute("color",new Ns(r,3,7,!0)),this.boundingSphere=new zi(new H,1)}}const EQ=`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>
}
`,TQ=`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 bQ=Object.defineProperty,z6=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&bQ(e,t,a),a};const G6={...Pb,pointSize:1,intensity:1,background:!0,ground:!0};let Vb=class extends X0{constructor(e){const{pointSize:t,radianceScale:i,intensity:a,background:r,ground:s,...o}={...G6,...e};super({name:"StarsMaterial",glslVersion:cs,vertexShader:TQ,fragmentShader:ki(EQ,{bruneton:{common:Ws,definitions:Ys,runtime:n_}}),...o,uniforms:{projectionMatrix:new ie(new lt),modelViewMatrix:new ie(new lt),viewMatrix:new ie(new lt),matrixWorld:new ie(new lt),cameraFar:new ie(0),pointSize:new ie(0),magnitudeRange:new ie(new Ee(-2,8)),intensity:new ie(i??a),...o.uniforms},defines:{PERSPECTIVE_CAMERA:"1"}}),this.pointSize=t,this.background=r,this.ground=s}onBeforeRender(e,t,i,a,r,s){super.onBeforeRender(e,t,i,a,r,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(r.matrixWorld),o.cameraFar.value=i.far,o.pointSize.value=this.pointSize*e.getPixelRatio();const c=i.isPerspectiveCamera===!0;this.defines.PERSPECTIVE_CAMERA!=null!==c&&(c?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}};z6([An("BACKGROUND")],Vb.prototype,"background");z6([An("GROUND")],Vb.prototype,"ground");function eh(){return eh=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},eh.apply(null,arguments)}const W0=new H,kb=new H,MQ=new H,eN=new Ee;function CQ(n,e,t){const i=W0.setFromMatrixPosition(n.matrixWorld);i.project(e);const a=t.width/2,r=t.height/2;return[i.x*a+a,-(i.y*r)+r]}function RQ(n,e){const t=W0.setFromMatrixPosition(n.matrixWorld),i=kb.setFromMatrixPosition(e.matrixWorld),a=t.sub(i),r=e.getWorldDirection(MQ);return a.angleTo(r)>Math.PI/2}function wQ(n,e,t,i){const a=W0.setFromMatrixPosition(n.matrixWorld),r=a.clone();r.project(e),eN.set(r.x,r.y),t.setFromCamera(eN,e);const s=t.intersectObjects(i,!0);if(s.length){const o=s[0].distance;return a.distanceTo(t.ray.origin)<o}return!0}function DQ(n,e){if(e instanceof Rr)return e.zoom;if(e instanceof Jn){const t=W0.setFromMatrixPosition(n.matrixWorld),i=kb.setFromMatrixPosition(e.matrixWorld),a=e.fov*Math.PI/180,r=t.distanceTo(i);return 1/(2*Math.tan(a/2)*r)}else return 1}function NQ(n,e,t){if(e instanceof Jn||e instanceof Rr){const i=W0.setFromMatrixPosition(n.matrixWorld),a=kb.setFromMatrixPosition(e.matrixWorld),r=i.distanceTo(a),s=(t[1]-t[0])/(e.far-e.near),o=t[1]-s*e.far;return Math.round(s*r+o)}}const xT=n=>Math.abs(n)<1e-10?0:n;function V6(n,e,t=""){let i="matrix3d(";for(let a=0;a!==16;a++)i+=xT(e[a]*n.elements[a])+(a!==15?",":")");return t+i}const OQ=(n=>e=>V6(e,n))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),IQ=(n=>(e,t)=>V6(e,n(t),"translate(-50%,-50%)"))(n=>[1/n,1/n,1/n,1,-1/n,-1/n,-1/n,-1,1/n,1/n,1/n,1,1,1,1,1]);function BQ(n){return n&&typeof n=="object"&&"current"in n}const UQ=he.forwardRef(({children:n,eps:e=.001,style:t,className:i,prepend:a,center:r,fullscreen:s,portal:o,distanceFactor:c,sprite:h=!1,transform:f=!1,occlude:d,onOcclude:m,castShadow:g,receiveShadow:y,material:E,geometry:S,zIndexRange:v=[16777271,0],calculatePosition:_=CQ,as:A="div",wrapperClass:b,pointerEvents:O="auto",...N},L)=>{const{gl:B,camera:w,scene:D,size:G,raycaster:J,events:$,viewport:se}=jn(),[le]=he.useState(()=>document.createElement(A)),q=he.useRef(null),te=he.useRef(null),ee=he.useRef(0),de=he.useRef([0,0]),ue=he.useRef(null),Pe=he.useRef(null),He=(o==null?void 0:o.current)||$.connected||B.domElement.parentNode,Ke=he.useRef(null),nt=he.useRef(!1),xt=he.useMemo(()=>d&&d!=="blending"||Array.isArray(d)&&d.length&&BQ(d[0]),[d]);he.useLayoutEffect(()=>{const at=B.domElement;d&&d==="blending"?(at.style.zIndex=`${Math.floor(v[0]/2)}`,at.style.position="absolute",at.style.pointerEvents="none"):(at.style.zIndex=null,at.style.position=null,at.style.pointerEvents=null)},[d]),he.useLayoutEffect(()=>{if(te.current){const at=q.current=f5.createRoot(le);if(D.updateMatrixWorld(),f)le.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const ft=_(te.current,w,G);le.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${ft[0]}px,${ft[1]}px,0);transform-origin:0 0;`}return He&&(a?He.prepend(le):He.appendChild(le)),()=>{He&&He.removeChild(le),at.unmount()}}},[He,f]),he.useLayoutEffect(()=>{b&&(le.className=b)},[b]);const fe=he.useMemo(()=>f?{position:"absolute",top:0,left:0,width:G.width,height:G.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:r?"translate3d(-50%,-50%,0)":"none",...s&&{top:-G.height/2,left:-G.width/2,width:G.width,height:G.height},...t},[t,r,s,G,f]),Be=he.useMemo(()=>({position:"absolute",pointerEvents:O}),[O]);he.useLayoutEffect(()=>{if(nt.current=!1,f){var at;(at=q.current)==null||at.render(he.createElement("div",{ref:ue,style:fe},he.createElement("div",{ref:Pe,style:Be},he.createElement("div",{ref:L,className:i,style:t,children:n}))))}else{var ft;(ft=q.current)==null||ft.render(he.createElement("div",{ref:L,style:fe,className:i,children:n}))}});const Je=he.useRef(!0);Ls(at=>{if(te.current){w.updateMatrixWorld(),te.current.updateWorldMatrix(!0,!1);const ft=f?de.current:_(te.current,w,G);if(f||Math.abs(ee.current-w.zoom)>e||Math.abs(de.current[0]-ft[0])>e||Math.abs(de.current[1]-ft[1])>e){const ht=RQ(te.current,w);let et=!1;xt&&(Array.isArray(d)?et=d.map(ze=>ze.current):d!=="blending"&&(et=[D]));const Re=Je.current;if(et){const ze=wQ(te.current,w,J,et);Je.current=ze&&!ht}else Je.current=!ht;Re!==Je.current&&(m?m(!Je.current):le.style.display=Je.current?"block":"none");const Z=Math.floor(v[0]/2),Ue=d?xt?[v[0],Z]:[Z-1,0]:v;if(le.style.zIndex=`${NQ(te.current,w,Ue)}`,f){const[ze,Qe]=[G.width/2,G.height/2],Ye=w.projectionMatrix.elements[5]*Qe,{isOrthographicCamera:ot,top:rt,left:mt,bottom:j,right:P}=w,pe=OQ(w.matrixWorldInverse),Ie=ot?`scale(${Ye})translate(${xT(-(P+mt)/2)}px,${xT((rt+j)/2)}px)`:`translateZ(${Ye}px)`;let Ge=te.current.matrixWorld;h&&(Ge=w.matrixWorldInverse.clone().transpose().copyPosition(Ge).scale(te.current.scale),Ge.elements[3]=Ge.elements[7]=Ge.elements[11]=0,Ge.elements[15]=1),le.style.width=G.width+"px",le.style.height=G.height+"px",le.style.perspective=ot?"":`${Ye}px`,ue.current&&Pe.current&&(ue.current.style.transform=`${Ie}${pe}translate(${ze}px,${Qe}px)`,Pe.current.style.transform=IQ(Ge,1/((c||10)/400)))}else{const ze=c===void 0?1:DQ(te.current,w)*c;le.style.transform=`translate3d(${ft[0]}px,${ft[1]}px,0) scale(${ze})`}de.current=ft,ee.current=w.zoom}}if(!xt&&Ke.current&&!nt.current)if(f){if(ue.current){const ft=ue.current.children[0];if(ft!=null&&ft.clientWidth&&ft!=null&&ft.clientHeight){const{isOrthographicCamera:ht}=w;if(ht||S)N.scale&&(Array.isArray(N.scale)?N.scale instanceof H?Ke.current.scale.copy(N.scale.clone().divideScalar(1)):Ke.current.scale.set(1/N.scale[0],1/N.scale[1],1/N.scale[2]):Ke.current.scale.setScalar(1/N.scale));else{const et=(c||10)/400,Re=ft.clientWidth*et,Z=ft.clientHeight*et;Ke.current.scale.set(Re,Z,1)}nt.current=!0}}}else{const ft=le.children[0];if(ft!=null&&ft.clientWidth&&ft!=null&&ft.clientHeight){const ht=1/se.factor,et=ft.clientWidth*ht,Re=ft.clientHeight*ht;Ke.current.scale.set(et,Re,1),nt.current=!0}Ke.current.lookAt(at.camera.position)}});const ve=he.useMemo(()=>({vertexShader:f?void 0:`
/*
This shader is from the THREE's SpriteMaterial.
We need to turn the backing plane into a Sprite
(make it always face the camera) if "transfrom"
is false.
*/
#include <common>
void main() {
vec2 center = vec2(0., 1.);
float rotation = 0.0;
// This is somewhat arbitrary, but it seems to work well
// Need to figure out how to derive this dynamically if it even matters
float size = 0.03;
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
vec2 scale;
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
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;
}
`,fragmentShader:`
void main() {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}
`}),[f]);return he.createElement("group",eh({},N,{ref:te}),d&&!xt&&he.createElement("mesh",{castShadow:g,receiveShadow:y,ref:Ke},S||he.createElement("planeGeometry",null),E||he.createElement("shaderMaterial",{side:da,vertexShader:ve.vertexShader,fragmentShader:ve.fragmentShader})))}),Xb=parseInt(_c.replace(/\D+/g,""));function tN(n,e){if(e===W5)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===Mx||e===I3){let t=n.getIndex();if(t===null){const s=[],o=n.getAttribute("position");if(o!==void 0){for(let c=0;c<o.count;c++)s.push(c);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,a=[];if(t)if(e===Mx)for(let s=1;s<=i;s++)a.push(t.getX(0)),a.push(t.getX(s)),a.push(t.getX(s+1));else for(let s=0;s<i;s++)s%2===0?(a.push(t.getX(s)),a.push(t.getX(s+1)),a.push(t.getX(s+2))):(a.push(t.getX(s+2)),a.push(t.getX(s+1)),a.push(t.getX(s)));a.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=n.clone();return r.setIndex(a),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}var $r=Uint8Array,Ql=Uint16Array,yT=Uint32Array,k6=new $r([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]),X6=new $r([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]),LQ=new $r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),W6=function(n,e){for(var t=new Ql(31),i=0;i<31;++i)t[i]=e+=1<<n[i-1];for(var a=new yT(t[30]),i=1;i<30;++i)for(var r=t[i];r<t[i+1];++r)a[r]=r-t[i]<<5|i;return[t,a]},Y6=W6(k6,2),q6=Y6[0],PQ=Y6[1];q6[28]=258,PQ[258]=28;var FQ=W6(X6,0),HQ=FQ[0],_T=new Ql(32768);for(var ii=0;ii<32768;++ii){var Hl=(ii&43690)>>>1|(ii&21845)<<1;Hl=(Hl&52428)>>>2|(Hl&13107)<<2,Hl=(Hl&61680)>>>4|(Hl&3855)<<4,_T[ii]=((Hl&65280)>>>8|(Hl&255)<<8)>>>1}var Lm=function(n,e,t){for(var i=n.length,a=0,r=new Ql(e);a<i;++a)++r[n[a]-1];var s=new Ql(e);for(a=0;a<e;++a)s[a]=s[a-1]+r[a-1]<<1;var o;if(t){o=new Ql(1<<e);var c=15-e;for(a=0;a<i;++a)if(n[a])for(var h=a<<4|n[a],f=e-n[a],d=s[n[a]-1]++<<f,m=d|(1<<f)-1;d<=m;++d)o[_T[d]>>>c]=h}else for(o=new Ql(i),a=0;a<i;++a)n[a]&&(o[a]=_T[s[n[a]-1]++]>>>15-n[a]);return o},Y0=new $r(288);for(var ii=0;ii<144;++ii)Y0[ii]=8;for(var ii=144;ii<256;++ii)Y0[ii]=9;for(var ii=256;ii<280;++ii)Y0[ii]=7;for(var ii=280;ii<288;++ii)Y0[ii]=8;var Z6=new $r(32);for(var ii=0;ii<32;++ii)Z6[ii]=5;var zQ=Lm(Y0,9,1),GQ=Lm(Z6,5,1),A2=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},_s=function(n,e,t){var i=e/8|0;return(n[i]|n[i+1]<<8)>>(e&7)&t},E2=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},VQ=function(n){return(n/8|0)+(n&7&&1)},kQ=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var i=new(n instanceof Ql?Ql:n instanceof yT?yT:$r)(t-e);return i.set(n.subarray(e,t)),i},XQ=function(n,e,t){var i=n.length;if(!i||t&&!t.l&&i<5)return e||new $r(0);var a=!e||t,r=!t||t.i;t||(t={}),e||(e=new $r(i*3));var s=function(fe){var Be=e.length;if(fe>Be){var Je=new $r(Math.max(Be*2,fe));Je.set(e),e=Je}},o=t.f||0,c=t.p||0,h=t.b||0,f=t.l,d=t.d,m=t.m,g=t.n,y=i*8;do{if(!f){t.f=o=_s(n,c,1);var E=_s(n,c+1,3);if(c+=3,E)if(E==1)f=zQ,d=GQ,m=9,g=5;else if(E==2){var A=_s(n,c,31)+257,b=_s(n,c+10,15)+4,O=A+_s(n,c+5,31)+1;c+=14;for(var N=new $r(O),L=new $r(19),B=0;B<b;++B)L[LQ[B]]=_s(n,c+B*3,7);c+=b*3;for(var w=A2(L),D=(1<<w)-1,G=Lm(L,w,1),B=0;B<O;){var J=G[_s(n,c,D)];c+=J&15;var S=J>>>4;if(S<16)N[B++]=S;else{var $=0,se=0;for(S==16?(se=3+_s(n,c,3),c+=2,$=N[B-1]):S==17?(se=3+_s(n,c,7),c+=3):S==18&&(se=11+_s(n,c,127),c+=7);se--;)N[B++]=$}}var le=N.subarray(0,A),q=N.subarray(A);m=A2(le),g=A2(q),f=Lm(le,m,1),d=Lm(q,g,1)}else throw"invalid block type";else{var S=VQ(c)+4,v=n[S-4]|n[S-3]<<8,_=S+v;if(_>i){if(r)throw"unexpected EOF";break}a&&s(h+v),e.set(n.subarray(S,_),h),t.b=h+=v,t.p=c=_*8;continue}if(c>y){if(r)throw"unexpected EOF";break}}a&&s(h+131072);for(var te=(1<<m)-1,ee=(1<<g)-1,de=c;;de=c){var $=f[E2(n,c)&te],ue=$>>>4;if(c+=$&15,c>y){if(r)throw"unexpected EOF";break}if(!$)throw"invalid length/literal";if(ue<256)e[h++]=ue;else if(ue==256){de=c,f=null;break}else{var Pe=ue-254;if(ue>264){var B=ue-257,He=k6[B];Pe=_s(n,c,(1<<He)-1)+q6[B],c+=He}var Ke=d[E2(n,c)&ee],nt=Ke>>>4;if(!Ke)throw"invalid distance";c+=Ke&15;var q=HQ[nt];if(nt>3){var He=X6[nt];q+=E2(n,c)&(1<<He)-1,c+=He}if(c>y){if(r)throw"unexpected EOF";break}a&&s(h+131072);for(var xt=h+Pe;h<xt;h+=4)e[h]=e[h-q],e[h+1]=e[h+1-q],e[h+2]=e[h+2-q],e[h+3]=e[h+3-q];h=xt}}t.l=f,t.p=de,t.b=h,f&&(o=1,t.m=m,t.d=d,t.n=g)}while(!o);return h==e.length?e:kQ(e,0,h)},WQ=new $r(0),YQ=function(n){if((n[0]&15)!=8||n[0]>>>4>7||(n[0]<<8|n[1])%31)throw"invalid zlib data";if(n[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Yv(n,e){return XQ((YQ(n),n.subarray(2,-4)),e)}var qQ=typeof TextDecoder<"u"&&new TextDecoder,ZQ=0;try{qQ.decode(WQ,{stream:!0}),ZQ=1}catch{}const jQ=n=>n&&n.isCubeTexture;class KQ extends Xn{constructor(e,t){var i,a;const r=jQ(e),o=((a=r?(i=e.image[0])==null?void 0:i.width:e.image.width)!=null?a:1024)/4,c=Math.floor(Math.log2(o)),h=Math.pow(2,c),f=3*Math.max(h,16*7),d=4*h,m=[r?"#define ENVMAP_TYPE_CUBE":"",`#define CUBEUV_TEXEL_WIDTH ${1/f}`,`#define CUBEUV_TEXEL_HEIGHT ${1/d}`,`#define CUBEUV_MAX_MIP ${c}.0`],g=`
varying vec3 vWorldPosition;
void main()
{
vec4 worldPosition = ( modelMatrix * vec4( position, 1.0 ) );
vWorldPosition = worldPosition.xyz;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`,y=m.join(`
`)+`
#define ENVMAP_TYPE_CUBE_UV
varying vec3 vWorldPosition;
uniform float radius;
uniform float height;
uniform float angle;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube map;
#else
uniform sampler2D map;
#endif
// From: https://www.shadertoy.com/view/4tsBD7
float diskIntersectWithBackFaceCulling( vec3 ro, vec3 rd, vec3 c, vec3 n, float r )
{
float d = dot ( rd, n );
if( d > 0.0 ) { return 1e6; }
vec3 o = ro - c;
float t = - dot( n, o ) / d;
vec3 q = o + rd * t;
return ( dot( q, q ) < r * r ) ? t : 1e6;
}
// From: https://www.iquilezles.org/www/articles/intersectors/intersectors.htm
float sphereIntersect( vec3 ro, vec3 rd, vec3 ce, float ra )
{
vec3 oc = ro - ce;
float b = dot( oc, rd );
float c = dot( oc, oc ) - ra * ra;
float h = b * b - c;
if( h < 0.0 ) { return -1.0; }
h = sqrt( h );
return - b + h;
}
vec3 project()
{
vec3 p = normalize( vWorldPosition );
vec3 camPos = cameraPosition;
camPos.y -= height;
float intersection = sphereIntersect( camPos, p, vec3( 0.0 ), radius );
if( intersection > 0.0 ) {
vec3 h = vec3( 0.0, - height, 0.0 );
float intersection2 = diskIntersectWithBackFaceCulling( camPos, p, h, vec3( 0.0, 1.0, 0.0 ), radius );
p = ( camPos + min( intersection, intersection2 ) * p ) / radius;
} else {
p = vec3( 0.0, 1.0, 0.0 );
}
return p;
}
#include <common>
#include <cube_uv_reflection_fragment>
void main()
{
vec3 projectedWorldPosition = project();
#ifdef ENVMAP_TYPE_CUBE
vec3 outcolor = textureCube( map, projectedWorldPosition ).rgb;
#else
vec3 direction = normalize( projectedWorldPosition );
vec2 uv = equirectUv( direction );
vec3 outcolor = texture2D( map, uv ).rgb;
#endif
gl_FragColor = vec4( outcolor, 1.0 );
#include <tonemapping_fragment>
#include <${Xb>=154?"colorspace_fragment":"encodings_fragment"}>
}
`,E={map:{value:e},height:{value:(t==null?void 0:t.height)||15},radius:{value:(t==null?void 0:t.radius)||100}},S=new B0(1,16),v=new Di({uniforms:E,fragmentShader:y,vertexShader:g,side:da});super(S,v)}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}var JQ=Object.defineProperty,QQ=(n,e,t)=>e in n?JQ(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,$Q=(n,e,t)=>(QQ(n,e+"",t),t);class e${constructor(){$Q(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 a=this._listeners[e];if(a!==void 0){const r=a.indexOf(t);r!==-1&&a.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const a=i.slice(0);for(let r=0,s=a.length;r<s;r++)a[r].call(this,e);e.target=null}}}var t$=Object.defineProperty,n$=(n,e,t)=>e in n?t$(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ht=(n,e,t)=>(n$(n,typeof e!="symbol"?e+"":e,t),t);const qv=new oh,nN=new Lo,i$=Math.cos(70*(Math.PI/180)),iN=(n,e)=>(n%e+e)%e;let a$=class extends e${constructor(e,t){super(),Ht(this,"object"),Ht(this,"domElement"),Ht(this,"enabled",!0),Ht(this,"target",new H),Ht(this,"minDistance",0),Ht(this,"maxDistance",1/0),Ht(this,"minZoom",0),Ht(this,"maxZoom",1/0),Ht(this,"minPolarAngle",0),Ht(this,"maxPolarAngle",Math.PI),Ht(this,"minAzimuthAngle",-1/0),Ht(this,"maxAzimuthAngle",1/0),Ht(this,"enableDamping",!1),Ht(this,"dampingFactor",.05),Ht(this,"enableZoom",!0),Ht(this,"zoomSpeed",1),Ht(this,"enableRotate",!0),Ht(this,"rotateSpeed",1),Ht(this,"enablePan",!0),Ht(this,"panSpeed",1),Ht(this,"screenSpacePanning",!0),Ht(this,"keyPanSpeed",7),Ht(this,"zoomToCursor",!1),Ht(this,"autoRotate",!1),Ht(this,"autoRotateSpeed",2),Ht(this,"reverseOrbit",!1),Ht(this,"reverseHorizontalOrbit",!1),Ht(this,"reverseVerticalOrbit",!1),Ht(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Ht(this,"mouseButtons",{LEFT:lu.ROTATE,MIDDLE:lu.DOLLY,RIGHT:lu.PAN}),Ht(this,"touches",{ONE:cu.ROTATE,TWO:cu.DOLLY_PAN}),Ht(this,"target0"),Ht(this,"position0"),Ht(this,"zoom0"),Ht(this,"_domElementKeyEvents",null),Ht(this,"getPolarAngle"),Ht(this,"getAzimuthalAngle"),Ht(this,"setPolarAngle"),Ht(this,"setAzimuthalAngle"),Ht(this,"getDistance"),Ht(this,"getZoomScale"),Ht(this,"listenToKeyEvents"),Ht(this,"stopListenToKeyEvents"),Ht(this,"saveState"),Ht(this,"reset"),Ht(this,"update"),Ht(this,"connect"),Ht(this,"dispose"),Ht(this,"dollyIn"),Ht(this,"dollyOut"),Ht(this,"getScale"),Ht(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=ne=>{let me=iN(ne,2*Math.PI),Le=f.phi;Le<0&&(Le+=2*Math.PI),me<0&&(me+=2*Math.PI);let K=Math.abs(me-Le);2*Math.PI-K<K&&(me<Le?me+=2*Math.PI:Le+=2*Math.PI),d.phi=me-Le,i.update()},this.setAzimuthalAngle=ne=>{let me=iN(ne,2*Math.PI),Le=f.theta;Le<0&&(Le+=2*Math.PI),me<0&&(me+=2*Math.PI);let K=Math.abs(me-Le);2*Math.PI-K<K&&(me<Le?me+=2*Math.PI:Le+=2*Math.PI),d.theta=me-Le,i.update()},this.getDistance=()=>i.object.position.distanceTo(i.target),this.listenToKeyEvents=ne=>{ne.addEventListener("keydown",we),this._domElementKeyEvents=ne},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",we),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(a),i.update(),c=o.NONE},this.update=(()=>{const ne=new H,me=new H(0,1,0),Le=new Yi().setFromUnitVectors(e.up,me),K=Le.clone().invert(),Se=new H,_e=new Yi,it=2*Math.PI;return function(){const We=i.object.position;Le.setFromUnitVectors(e.up,me),K.copy(Le).invert(),ne.copy(We).sub(i.target),ne.applyQuaternion(Le),f.setFromVector3(ne),i.autoRotate&&c===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 gt=i.minAzimuthAngle,Nt=i.maxAzimuthAngle;isFinite(gt)&&isFinite(Nt)&&(gt<-Math.PI?gt+=it:gt>Math.PI&&(gt-=it),Nt<-Math.PI?Nt+=it:Nt>Math.PI&&(Nt-=it),gt<=Nt?f.theta=Math.max(gt,Math.min(Nt,f.theta)):f.theta=f.theta>(gt+Nt)/2?Math.max(gt,f.theta):Math.min(Nt,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&&w||i.object.isOrthographicCamera?f.radius=Ke(f.radius):f.radius=Ke(f.radius*m),ne.setFromSpherical(f),ne.applyQuaternion(K),We.copy(i.target).add(ne),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 $t=!1;if(i.zoomToCursor&&w){let jt=null;if(i.object instanceof Jn&&i.object.isPerspectiveCamera){const hi=ne.length();jt=Ke(hi*m);const fi=hi-jt;i.object.position.addScaledVector(L,fi),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){const hi=new H(B.x,B.y,0);hi.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/m)),i.object.updateProjectionMatrix(),$t=!0;const fi=new H(B.x,B.y,0);fi.unproject(i.object),i.object.position.sub(fi).add(hi),i.object.updateMatrixWorld(),jt=ne.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;jt!==null&&(i.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(jt).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))<i$?e.lookAt(i.target):(nN.setFromNormalAndCoplanarPoint(i.object.up,i.target),qv.intersectPlane(nN,i.target))))}else i.object instanceof Rr&&i.object.isOrthographicCamera&&($t=m!==1,$t&&(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/m)),i.object.updateProjectionMatrix()));return m=1,w=!1,$t||Se.distanceToSquared(i.object.position)>h||8*(1-_e.dot(i.object.quaternion))>h?(i.dispatchEvent(a),Se.copy(i.object.position),_e.copy(i.object.quaternion),$t=!1,!0):!1}})(),this.connect=ne=>{i.domElement=ne,i.domElement.style.touchAction="none",i.domElement.addEventListener("contextmenu",wt),i.domElement.addEventListener("pointerdown",mt),i.domElement.addEventListener("pointercancel",P),i.domElement.addEventListener("wheel",Ge)},this.dispose=()=>{var ne,me,Le,K,Se,_e;i.domElement&&(i.domElement.style.touchAction="auto"),(ne=i.domElement)==null||ne.removeEventListener("contextmenu",wt),(me=i.domElement)==null||me.removeEventListener("pointerdown",mt),(Le=i.domElement)==null||Le.removeEventListener("pointercancel",P),(K=i.domElement)==null||K.removeEventListener("wheel",Ge),(Se=i.domElement)==null||Se.ownerDocument.removeEventListener("pointermove",j),(_e=i.domElement)==null||_e.ownerDocument.removeEventListener("pointerup",P),i._domElementKeyEvents!==null&&i._domElementKeyEvents.removeEventListener("keydown",we)};const i=this,a={type:"change"},r={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 c=o.NONE;const h=1e-6,f=new LE,d=new LE;let m=1;const g=new H,y=new Ee,E=new Ee,S=new Ee,v=new Ee,_=new Ee,A=new Ee,b=new Ee,O=new Ee,N=new Ee,L=new H,B=new Ee;let w=!1;const D=[],G={};function J(){return 2*Math.PI/60/60*i.autoRotateSpeed}function $(){return Math.pow(.95,i.zoomSpeed)}function se(ne){i.reverseOrbit||i.reverseHorizontalOrbit?d.theta+=ne:d.theta-=ne}function le(ne){i.reverseOrbit||i.reverseVerticalOrbit?d.phi+=ne:d.phi-=ne}const q=(()=>{const ne=new H;return function(Le,K){ne.setFromMatrixColumn(K,0),ne.multiplyScalar(-Le),g.add(ne)}})(),te=(()=>{const ne=new H;return function(Le,K){i.screenSpacePanning===!0?ne.setFromMatrixColumn(K,1):(ne.setFromMatrixColumn(K,0),ne.crossVectors(i.object.up,ne)),ne.multiplyScalar(Le),g.add(ne)}})(),ee=(()=>{const ne=new H;return function(Le,K){const Se=i.domElement;if(Se&&i.object instanceof Jn&&i.object.isPerspectiveCamera){const _e=i.object.position;ne.copy(_e).sub(i.target);let it=ne.length();it*=Math.tan(i.object.fov/2*Math.PI/180),q(2*Le*it/Se.clientHeight,i.object.matrix),te(2*K*it/Se.clientHeight,i.object.matrix)}else Se&&i.object instanceof Rr&&i.object.isOrthographicCamera?(q(Le*(i.object.right-i.object.left)/i.object.zoom/Se.clientWidth,i.object.matrix),te(K*(i.object.top-i.object.bottom)/i.object.zoom/Se.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function de(ne){i.object instanceof Jn&&i.object.isPerspectiveCamera||i.object instanceof Rr&&i.object.isOrthographicCamera?m=ne:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function ue(ne){de(m/ne)}function Pe(ne){de(m*ne)}function He(ne){if(!i.zoomToCursor||!i.domElement)return;w=!0;const me=i.domElement.getBoundingClientRect(),Le=ne.clientX-me.left,K=ne.clientY-me.top,Se=me.width,_e=me.height;B.x=Le/Se*2-1,B.y=-(K/_e)*2+1,L.set(B.x,B.y,1).unproject(i.object).sub(i.object.position).normalize()}function Ke(ne){return Math.max(i.minDistance,Math.min(i.maxDistance,ne))}function nt(ne){y.set(ne.clientX,ne.clientY)}function xt(ne){He(ne),b.set(ne.clientX,ne.clientY)}function fe(ne){v.set(ne.clientX,ne.clientY)}function Be(ne){E.set(ne.clientX,ne.clientY),S.subVectors(E,y).multiplyScalar(i.rotateSpeed);const me=i.domElement;me&&(se(2*Math.PI*S.x/me.clientHeight),le(2*Math.PI*S.y/me.clientHeight)),y.copy(E),i.update()}function Je(ne){O.set(ne.clientX,ne.clientY),N.subVectors(O,b),N.y>0?ue($()):N.y<0&&Pe($()),b.copy(O),i.update()}function ve(ne){_.set(ne.clientX,ne.clientY),A.subVectors(_,v).multiplyScalar(i.panSpeed),ee(A.x,A.y),v.copy(_),i.update()}function at(ne){He(ne),ne.deltaY<0?Pe($()):ne.deltaY>0&&ue($()),i.update()}function ft(ne){let me=!1;switch(ne.code){case i.keys.UP:ee(0,i.keyPanSpeed),me=!0;break;case i.keys.BOTTOM:ee(0,-i.keyPanSpeed),me=!0;break;case i.keys.LEFT:ee(i.keyPanSpeed,0),me=!0;break;case i.keys.RIGHT:ee(-i.keyPanSpeed,0),me=!0;break}me&&(ne.preventDefault(),i.update())}function ht(){if(D.length==1)y.set(D[0].pageX,D[0].pageY);else{const ne=.5*(D[0].pageX+D[1].pageX),me=.5*(D[0].pageY+D[1].pageY);y.set(ne,me)}}function et(){if(D.length==1)v.set(D[0].pageX,D[0].pageY);else{const ne=.5*(D[0].pageX+D[1].pageX),me=.5*(D[0].pageY+D[1].pageY);v.set(ne,me)}}function Re(){const ne=D[0].pageX-D[1].pageX,me=D[0].pageY-D[1].pageY,Le=Math.sqrt(ne*ne+me*me);b.set(0,Le)}function Z(){i.enableZoom&&Re(),i.enablePan&&et()}function Ue(){i.enableZoom&&Re(),i.enableRotate&&ht()}function ze(ne){if(D.length==1)E.set(ne.pageX,ne.pageY);else{const Le=St(ne),K=.5*(ne.pageX+Le.x),Se=.5*(ne.pageY+Le.y);E.set(K,Se)}S.subVectors(E,y).multiplyScalar(i.rotateSpeed);const me=i.domElement;me&&(se(2*Math.PI*S.x/me.clientHeight),le(2*Math.PI*S.y/me.clientHeight)),y.copy(E)}function Qe(ne){if(D.length==1)_.set(ne.pageX,ne.pageY);else{const me=St(ne),Le=.5*(ne.pageX+me.x),K=.5*(ne.pageY+me.y);_.set(Le,K)}A.subVectors(_,v).multiplyScalar(i.panSpeed),ee(A.x,A.y),v.copy(_)}function Ye(ne){const me=St(ne),Le=ne.pageX-me.x,K=ne.pageY-me.y,Se=Math.sqrt(Le*Le+K*K);O.set(0,Se),N.set(0,Math.pow(O.y/b.y,i.zoomSpeed)),ue(N.y),b.copy(O)}function ot(ne){i.enableZoom&&Ye(ne),i.enablePan&&Qe(ne)}function rt(ne){i.enableZoom&&Ye(ne),i.enableRotate&&ze(ne)}function mt(ne){var me,Le;i.enabled!==!1&&(D.length===0&&((me=i.domElement)==null||me.ownerDocument.addEventListener("pointermove",j),(Le=i.domElement)==null||Le.ownerDocument.addEventListener("pointerup",P)),bt(ne),ne.pointerType==="touch"?Tt(ne):pe(ne))}function j(ne){i.enabled!==!1&&(ne.pointerType==="touch"?ut(ne):Ie(ne))}function P(ne){var me,Le,K;ke(ne),D.length===0&&((me=i.domElement)==null||me.releasePointerCapture(ne.pointerId),(Le=i.domElement)==null||Le.ownerDocument.removeEventListener("pointermove",j),(K=i.domElement)==null||K.ownerDocument.removeEventListener("pointerup",P)),i.dispatchEvent(s),c=o.NONE}function pe(ne){let me;switch(ne.button){case 0:me=i.mouseButtons.LEFT;break;case 1:me=i.mouseButtons.MIDDLE;break;case 2:me=i.mouseButtons.RIGHT;break;default:me=-1}switch(me){case lu.DOLLY:if(i.enableZoom===!1)return;xt(ne),c=o.DOLLY;break;case lu.ROTATE:if(ne.ctrlKey||ne.metaKey||ne.shiftKey){if(i.enablePan===!1)return;fe(ne),c=o.PAN}else{if(i.enableRotate===!1)return;nt(ne),c=o.ROTATE}break;case lu.PAN:if(ne.ctrlKey||ne.metaKey||ne.shiftKey){if(i.enableRotate===!1)return;nt(ne),c=o.ROTATE}else{if(i.enablePan===!1)return;fe(ne),c=o.PAN}break;default:c=o.NONE}c!==o.NONE&&i.dispatchEvent(r)}function Ie(ne){if(i.enabled!==!1)switch(c){case o.ROTATE:if(i.enableRotate===!1)return;Be(ne);break;case o.DOLLY:if(i.enableZoom===!1)return;Je(ne);break;case o.PAN:if(i.enablePan===!1)return;ve(ne);break}}function Ge(ne){i.enabled===!1||i.enableZoom===!1||c!==o.NONE&&c!==o.ROTATE||(ne.preventDefault(),i.dispatchEvent(r),at(ne),i.dispatchEvent(s))}function we(ne){i.enabled===!1||i.enablePan===!1||ft(ne)}function Tt(ne){switch(Ve(ne),D.length){case 1:switch(i.touches.ONE){case cu.ROTATE:if(i.enableRotate===!1)return;ht(),c=o.TOUCH_ROTATE;break;case cu.PAN:if(i.enablePan===!1)return;et(),c=o.TOUCH_PAN;break;default:c=o.NONE}break;case 2:switch(i.touches.TWO){case cu.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Z(),c=o.TOUCH_DOLLY_PAN;break;case cu.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Ue(),c=o.TOUCH_DOLLY_ROTATE;break;default:c=o.NONE}break;default:c=o.NONE}c!==o.NONE&&i.dispatchEvent(r)}function ut(ne){switch(Ve(ne),c){case o.TOUCH_ROTATE:if(i.enableRotate===!1)return;ze(ne),i.update();break;case o.TOUCH_PAN:if(i.enablePan===!1)return;Qe(ne),i.update();break;case o.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;ot(ne),i.update();break;case o.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;rt(ne),i.update();break;default:c=o.NONE}}function wt(ne){i.enabled!==!1&&ne.preventDefault()}function bt(ne){D.push(ne)}function ke(ne){delete G[ne.pointerId];for(let me=0;me<D.length;me++)if(D[me].pointerId==ne.pointerId){D.splice(me,1);return}}function Ve(ne){let me=G[ne.pointerId];me===void 0&&(me=new Ee,G[ne.pointerId]=me),me.set(ne.pageX,ne.pageY)}function St(ne){const me=ne.pointerId===D[0].pointerId?D[1]:D[0];return G[me.pointerId]}this.dollyIn=(ne=$())=>{Pe(ne),i.update()},this.dollyOut=(ne=$())=>{ue(ne),i.update()},this.getScale=()=>m,this.setScale=ne=>{de(ne),i.update()},this.getZoomScale=()=>$(),t!==void 0&&this.connect(t),this.update()}};function qx(n){if(typeof TextDecoder<"u")return new TextDecoder().decode(n);let e="";for(let t=0,i=n.length;t<i;t++)e+=String.fromCharCode(n[t]);try{return decodeURIComponent(escape(e))}catch{return e}}const Au="srgb",$o="srgb-linear",aN=3001,r$=3e3;class Wb extends yi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new u$(t)}),this.register(function(t){return new h$(t)}),this.register(function(t){return new _$(t)}),this.register(function(t){return new S$(t)}),this.register(function(t){return new A$(t)}),this.register(function(t){return new d$(t)}),this.register(function(t){return new p$(t)}),this.register(function(t){return new m$(t)}),this.register(function(t){return new g$(t)}),this.register(function(t){return new c$(t)}),this.register(function(t){return new v$(t)}),this.register(function(t){return new f$(t)}),this.register(function(t){return new y$(t)}),this.register(function(t){return new x$(t)}),this.register(function(t){return new o$(t)}),this.register(function(t){return new E$(t)}),this.register(function(t){return new T$(t)})}load(e,t,i,a){const r=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const h=lc.extractUrlBase(e);s=lc.resolveURL(h,this.path)}else s=lc.extractUrlBase(e);this.manager.itemStart(e);const o=function(h){a?a(h):console.error(h),r.manager.itemError(e),r.manager.itemEnd(e)},c=new oa(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{r.parse(h,s,function(f){t(f),r.manager.itemEnd(e)},o)}catch(f){o(f)}},i,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return 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,a){let r;const s={},o={};if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(qx(new Uint8Array(e.slice(0,4)))===j6){try{s[hn.KHR_BINARY_GLTF]=new b$(e)}catch(f){a&&a(f);return}r=JSON.parse(s[hn.KHR_BINARY_GLTF].content)}else r=JSON.parse(qx(new Uint8Array(e)));else r=e;if(r.asset===void 0||r.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new F$(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const f=this.pluginCallbacks[h](c);f.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[f.name]=f,s[f.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const f=r.extensionsUsed[h],d=r.extensionsRequired||[];switch(f){case hn.KHR_MATERIALS_UNLIT:s[f]=new l$;break;case hn.KHR_DRACO_MESH_COMPRESSION:s[f]=new M$(r,this.dracoLoader);break;case hn.KHR_TEXTURE_TRANSFORM:s[f]=new C$;break;case hn.KHR_MESH_QUANTIZATION:s[f]=new R$;break;default:d.indexOf(f)>=0&&o[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(s),c.setPlugins(o),c.parse(i,a)}parseAsync(e,t){const i=this;return new Promise(function(a,r){i.parse(e,t,a,r)})}}function s$(){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 hn={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 o${constructor(e){this.parser=e,this.name=hn.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,a=t.length;i<a;i++){const r=t[i];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let a=t.cache.get(i);if(a)return a;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const f=new dt(16777215);c.color!==void 0&&f.setRGB(c.color[0],c.color[1],c.color[2],$o);const d=c.range!==void 0?c.range:0;switch(c.type){case"directional":h=new cb(f),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new lb(f),h.distance=d;break;case"spot":h=new ob(f),h.distance=d,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,h.angle=c.spot.outerConeAngle,h.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return h.position.set(0,0,0),h.decay=2,Uo(h,c),c.intensity!==void 0&&(h.intensity=c.intensity),h.name=t.createUniqueName(c.name||"light_"+e),a=Promise.resolve(h),t.cache.add(i,a),a}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,r=i.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return i._getNodeRef(t.cache,o,c)})}}class l${constructor(){this.name=hn.KHR_MATERIALS_UNLIT}getMaterialType(){return Qa}extendParams(e,t,i){const a=[];e.color=new dt(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],$o),e.opacity=s[3]}r.baseColorTexture!==void 0&&a.push(i.assignTexture(e,"map",r.baseColorTexture,Au))}return Promise.all(a)}}class c${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class u${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&r.push(i.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&r.push(i.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(r.push(i.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const o=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ee(o,o)}return Promise.all(r)}}class h${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_DISPERSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class f${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&r.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&&r.push(i.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class d${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new dt(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=a.extensions[this.name];if(s.sheenColorFactor!==void 0){const o=s.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],$o)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&r.push(i.assignTexture(t,"sheenColorMap",s.sheenColorTexture,Au)),s.sheenRoughnessTexture!==void 0&&r.push(i.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class p${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&r.push(i.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class m${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&r.push(i.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new dt().setRGB(o[0],o[1],o[2],$o),Promise.all(r)}}class g${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=a.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class v${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&r.push(i.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new dt().setRGB(o[0],o[1],o[2],$o),s.specularColorTexture!==void 0&&r.push(i.assignTexture(t,"specularColorMap",s.specularColorTexture,Au)),Promise.all(r)}}class x${constructor(e){this.parser=e,this.name=hn.EXT_MATERIALS_BUMP}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&r.push(i.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(r)}}class y${constructor(e){this.parser=e,this.name=hn.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:us}extendMaterialParams(e,t){const i=this.parser,a=i.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const r=[],s=a.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&r.push(i.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class _${constructor(e){this.parser=e,this.name=hn.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,a=i.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const r=a.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,r.source,s)}}class S${constructor(e){this.parser=e,this.name=hn.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,a=i.json,r=a.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=a.images[s.source];let c=i.textureLoader;if(o.uri){const h=i.options.manager.getHandler(o.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return i.loadTextureImage(e,s.source,c);if(a.extensionsRequired&&a.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class A${constructor(e){this.parser=e,this.name=hn.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,a=i.json,r=a.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],o=a.images[s.source];let c=i.textureLoader;if(o.uri){const h=i.options.manager.getHandler(o.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return i.loadTextureImage(e,s.source,c);if(a.extensionsRequired&&a.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class E${constructor(e){this.name=hn.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 a=i.extensions[this.name],r=this.parser.getDependency("buffer",a.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 r.then(function(o){const c=a.byteOffset||0,h=a.byteLength||0,f=a.count,d=a.byteStride,m=new Uint8Array(o,c,h);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(f,d,m,a.mode,a.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,m,a.mode,a.filter),g})})}else return null}}class T${constructor(e){this.name=hn.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 a=t.meshes[i.mesh];for(const h of a.primitives)if(h.mode!==Wr.TRIANGLES&&h.mode!==Wr.TRIANGLE_STRIP&&h.mode!==Wr.TRIANGLE_FAN&&h.mode!==void 0)return null;const s=i.extensions[this.name].attributes,o=[],c={};for(const h in s)o.push(this.parser.getDependency("accessor",s[h]).then(f=>(c[h]=f,c[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],m=h[0].count,g=[];for(const y of d){const E=new lt,S=new H,v=new Yi,_=new H(1,1,1),A=new k3(y.geometry,y.material,m);for(let b=0;b<m;b++)c.TRANSLATION&&S.fromBufferAttribute(c.TRANSLATION,b),c.ROTATION&&v.fromBufferAttribute(c.ROTATION,b),c.SCALE&&_.fromBufferAttribute(c.SCALE,b),A.setMatrixAt(b,E.compose(S,v,_));for(const b in c)if(b==="_COLOR_0"){const O=c[b];A.instanceColor=new Wu(O.array,O.itemSize,O.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&y.geometry.setAttribute(b,c[b]);fn.prototype.copy.call(A,y),this.parser.assignFinalMaterial(A),g.push(A)}return f.isGroup?(f.clear(),f.add(...g),f):g[0]}))}}const j6="glTF",kp=12,rN={JSON:1313821514,BIN:5130562};class b${constructor(e){this.name=hn.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,kp);if(this.header={magic:qx(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==j6)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-kp,a=new DataView(e,kp);let r=0;for(;r<i;){const s=a.getUint32(r,!0);r+=4;const o=a.getUint32(r,!0);if(r+=4,o===rN.JSON){const c=new Uint8Array(e,kp+r,s);this.content=qx(c)}else if(o===rN.BIN){const c=kp+r;this.body=e.slice(c,c+s)}r+=s}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class M${constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=hn.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,a=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},c={},h={};for(const f in s){const d=ST[f]||f.toLowerCase();o[d]=s[f]}for(const f in e.attributes){const d=ST[f]||f.toLowerCase();if(s[f]!==void 0){const m=i.accessors[e.attributes[f]],g=ed[m.componentType];h[d]=g.name,c[d]=m.normalized===!0}}return t.getDependency("bufferView",r).then(function(f){return new Promise(function(d,m){a.decodeDracoFile(f,function(g){for(const y in g.attributes){const E=g.attributes[y],S=c[y];S!==void 0&&(E.normalized=S)}d(g)},o,h,$o,m)})})}}class C${constructor(){this.name=hn.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 R${constructor(){this.name=hn.KHR_MESH_QUANTIZATION}}class K6 extends zd{constructor(e,t,i,a){super(e,t,i,a)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,a=this.valueSize,r=e*a*3+a;for(let s=0;s!==a;s++)t[s]=i[r+s];return t}interpolate_(e,t,i,a){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,c=o*2,h=o*3,f=a-t,d=(i-t)/f,m=d*d,g=m*d,y=e*h,E=y-h,S=-2*g+3*m,v=g-m,_=1-S,A=v-m+d;for(let b=0;b!==o;b++){const O=s[E+b+o],N=s[E+b+c]*f,L=s[y+b+o],B=s[y+b]*f;r[b]=_*O+A*N+S*L+v*B}return r}}const w$=new Yi;class D$ extends K6{interpolate_(e,t,i,a){const r=super.interpolate_(e,t,i,a);return w$.fromArray(r).normalize().toArray(r),r}}const Wr={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ed={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},sN={9728:$n,9729:Bt,9984:dy,9985:Kf,9986:gu,9987:Sr},oN={33071:Vn,33648:fd,10497:wi},T2={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ST={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Xb>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},zl={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},N$={CUBICSPLINE:void 0,LINEAR:md,STEP:pd},b2={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function O$(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new P0({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:os})),n.DefaultMaterial}function ru(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 Uo(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 I$(n,e,t){let i=!1,a=!1,r=!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&&(a=!0),d.COLOR_0!==void 0&&(r=!0),i&&a&&r)break}if(!i&&!a&&!r)return Promise.resolve(n);const s=[],o=[],c=[];for(let h=0,f=e.length;h<f;h++){const d=e[h];if(i){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):n.attributes.position;s.push(m)}if(a){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):n.attributes.normal;o.push(m)}if(r){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):n.attributes.color;c.push(m)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(c)]).then(function(h){const f=h[0],d=h[1],m=h[2];return i&&(n.morphAttributes.position=f),a&&(n.morphAttributes.normal=d),r&&(n.morphAttributes.color=m),n.morphTargetsRelative=!0,n})}function B$(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,a=t.length;i<a;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function U$(n){let e;const t=n.extensions&&n.extensions[hn.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+M2(t.attributes):e=n.indices+":"+M2(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,a=n.targets.length;i<a;i++)e+=":"+M2(n.targets[i]);return e}function M2(n){let e="";const t=Object.keys(n).sort();for(let i=0,a=t.length;i<a;i++)e+=t[i]+":"+n[t[i]]+";";return e}function AT(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 L$(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":"image/png"}const P$=new lt;class F${constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new s$,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,a=!1,r=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,a=navigator.userAgent.indexOf("Firefox")>-1,r=a?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||a&&r<98?this.textureLoader=new rb(this.options.manager):this.textureLoader=new WB(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new oa(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,a=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(s){const o={scene:s[0][a.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:a.asset,parser:i,userData:{}};return ru(r,o,a),Uo(o,a),Promise.all(i._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){for(const c of o.scenes)c.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let a=0,r=t.length;a<r;a++){const s=t[a].joints;for(let o=0,c=s.length;o<c;o++)e[s[o]].isBone=!0}for(let a=0,r=e.length;a<r;a++){const s=e[a];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 a=i.clone(),r=(s,o)=>{const c=this.associations.get(s);c!=null&&this.associations.set(o,c);for(const[h,f]of s.children.entries())r(f,o.children[h])};return r(i,a),a.name+="_instance_"+e.uses[t]++,a}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const a=e(t[i]);if(a)return a}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let a=0;a<t.length;a++){const r=e(t[a]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let a=this.cache.get(i);if(!a){switch(e){case"scene":a=this.loadScene(t);break;case"node":a=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":a=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":a=this.loadAccessor(t);break;case"bufferView":a=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":a=this.loadBuffer(t);break;case"material":a=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":a=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":a=this.loadSkin(t);break;case"animation":a=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":a=this.loadCamera(t);break;default:if(a=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(i,a)}return a}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(a.map(function(r,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[hn.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(r,s){i.load(lc.resolveURL(t.uri,a.path),r,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 a=t.byteLength||0,r=t.byteOffset||0;return i.slice(r,r+a)})}loadAccessor(e){const t=this,i=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const s=T2[a.type],o=ed[a.componentType],c=a.normalized===!0,h=new o(a.count*s);return Promise.resolve(new pn(h,s,c))}const r=[];return a.bufferView!==void 0?r.push(this.getDependency("bufferView",a.bufferView)):r.push(null),a.sparse!==void 0&&(r.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(r).then(function(s){const o=s[0],c=T2[a.type],h=ed[a.componentType],f=h.BYTES_PER_ELEMENT,d=f*c,m=a.byteOffset||0,g=a.bufferView!==void 0?i.bufferViews[a.bufferView].byteStride:void 0,y=a.normalized===!0;let E,S;if(g&&g!==d){const v=Math.floor(m/g),_="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+v+":"+a.count;let A=t.cache.get(_);A||(E=new h(o,v*g,a.count*g/f),A=new Xu(E,g/f),t.cache.add(_,A)),S=new Ns(A,c,m%g/f,y)}else o===null?E=new h(a.count*c):E=new h(o,m,a.count*c),S=new pn(E,c,y);if(a.sparse!==void 0){const v=T2.SCALAR,_=ed[a.sparse.indices.componentType],A=a.sparse.indices.byteOffset||0,b=a.sparse.values.byteOffset||0,O=new _(s[1],A,a.sparse.count*v),N=new h(s[2],b,a.sparse.count*c);o!==null&&(S=new pn(S.array.slice(),S.itemSize,S.normalized));for(let L=0,B=O.length;L<B;L++){const w=O[L];if(S.setX(w,N[L*c]),c>=2&&S.setY(w,N[L*c+1]),c>=3&&S.setZ(w,N[L*c+2]),c>=4&&S.setW(w,N[L*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return S})}loadTexture(e){const t=this.json,i=this.options,r=t.textures[e].source,s=t.images[r];let o=this.textureLoader;if(s.uri){const c=i.manager.getHandler(s.uri);c!==null&&(o=c)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,i){const a=this,r=this.json,s=r.textures[e],o=r.images[t],c=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[c])return this.textureCache[c];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 m=(r.samplers||{})[s.sampler]||{};return f.magFilter=sN[m.magFilter]||Bt,f.minFilter=sN[m.minFilter]||Sr,f.wrapS=oN[m.wrapS]||wi,f.wrapT=oN[m.wrapT]||wi,a.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,t){const i=this,a=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const s=a.images[e],o=self.URL||self.webkitURL;let c=s.uri||"",h=!1;if(s.bufferView!==void 0)c=i.getDependency("bufferView",s.bufferView).then(function(d){h=!0;const m=new Blob([d],{type:s.mimeType});return c=o.createObjectURL(m),c});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(c).then(function(d){return new Promise(function(m,g){let y=m;t.isImageBitmapLoader===!0&&(y=function(E){const S=new vn(E);S.needsUpdate=!0,m(S)}),t.load(lc.resolveURL(d,r.path),y,void 0,g)})}).then(function(d){return h===!0&&o.revokeObjectURL(c),Uo(d,s),d.userData.mimeType=s.mimeType||L$(s.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),d});return this.sourceCache[e]=f,f}assignTexture(e,t,i,a){const r=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),r.extensions[hn.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[hn.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=r.associations.get(s);s=r.extensions[hn.KHR_TEXTURE_TRANSFORM].extendTexture(s,o),r.associations.set(s,c)}}return a!==void 0&&(typeof a=="number"&&(a=a===aN?Au:$o),"colorSpace"in s?s.colorSpace=a:s.encoding=a===Au?aN:r$),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const a=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let c=this.cache.get(o);c||(c=new Ty,ri.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,c.sizeAttenuation=!1,this.cache.add(o,c)),i=c}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let c=this.cache.get(o);c||(c=new Ca,ri.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(o,c)),i=c}if(a||r||s){let o="ClonedMaterial:"+i.uuid+":";a&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),s&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=i.clone(),r&&(c.vertexColors=!0),s&&(c.flatShading=!0),a&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(i))),i=c}e.material=i}getMaterialType(){return P0}loadMaterial(e){const t=this,i=this.json,a=this.extensions,r=i.materials[e];let s;const o={},c=r.extensions||{},h=[];if(c[hn.KHR_MATERIALS_UNLIT]){const d=a[hn.KHR_MATERIALS_UNLIT];s=d.getMaterialType(),h.push(d.extendParams(o,r,t))}else{const d=r.pbrMetallicRoughness||{};if(o.color=new dt(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;o.color.setRGB(m[0],m[1],m[2],$o),o.opacity=m[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(o,"map",d.baseColorTexture,Au)),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(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=da);const f=r.alphaMode||b2.OPAQUE;if(f===b2.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,f===b2.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==Qa&&(h.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ee(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;o.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&s!==Qa&&(h.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==Qa){const d=r.emissiveFactor;o.emissive=new dt().setRGB(d[0],d[1],d[2],$o)}return r.emissiveTexture!==void 0&&s!==Qa&&h.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Au)),Promise.all(h).then(function(){const d=new s(o);return r.name&&(d.name=r.name),Uo(d,r),t.associations.set(d,{materials:e}),r.extensions&&ru(a,d,r),d})}createUniqueName(e){const t=yn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,a=this.primitiveCache;function r(o){return i[hn.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return lN(c,o,t)})}const s=[];for(let o=0,c=e.length;o<c;o++){const h=e[o],f=U$(h),d=a[f];if(d)s.push(d.promise);else{let m;h.extensions&&h.extensions[hn.KHR_DRACO_MESH_COMPRESSION]?m=r(h):m=lN(new Xt,h,t),a[f]={primitive:h,promise:m},s.push(m)}}return Promise.all(s)}loadMesh(e){const t=this,i=this.json,a=this.extensions,r=i.meshes[e],s=r.primitives,o=[];for(let c=0,h=s.length;c<h;c++){const f=s[c].material===void 0?O$(this.cache):this.getDependency("material",s[c].material);o.push(f)}return o.push(t.loadGeometries(s)),Promise.all(o).then(function(c){const h=c.slice(0,c.length-1),f=c[c.length-1],d=[];for(let g=0,y=f.length;g<y;g++){const E=f[g],S=s[g];let v;const _=h[g];if(S.mode===Wr.TRIANGLES||S.mode===Wr.TRIANGLE_STRIP||S.mode===Wr.TRIANGLE_FAN||S.mode===void 0)v=r.isSkinnedMesh===!0?new V3(E,_):new Xn(E,_),v.isSkinnedMesh===!0&&v.normalizeSkinWeights(),S.mode===Wr.TRIANGLE_STRIP?v.geometry=tN(v.geometry,I3):S.mode===Wr.TRIANGLE_FAN&&(v.geometry=tN(v.geometry,Mx));else if(S.mode===Wr.LINES)v=new Is(E,_);else if(S.mode===Wr.LINE_STRIP)v=new rl(E,_);else if(S.mode===Wr.LINE_LOOP)v=new X3(E,_);else if(S.mode===Wr.POINTS)v=new W3(E,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+S.mode);Object.keys(v.geometry.morphAttributes).length>0&&B$(v,r),v.name=t.createUniqueName(r.name||"mesh_"+e),Uo(v,r),S.extensions&&ru(a,v,S),t.assignFinalMaterial(v),d.push(v)}for(let g=0,y=d.length;g<y;g++)t.associations.set(d[g],{meshes:e,primitives:g});if(d.length===1)return r.extensions&&ru(a,d[0],r),d[0];const m=new jo;r.extensions&&ru(a,m,r),t.associations.set(m,{meshes:e});for(let g=0,y=d.length;g<y;g++)m.add(d[g]);return m})}loadCamera(e){let t;const i=this.json.cameras[e],a=i[i.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new Jn(Nr.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):i.type==="orthographic"&&(t=new Rr(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Uo(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let a=0,r=t.joints.length;a<r;a++)i.push(this._loadNodeShallow(t.joints[a]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(a){const r=a.pop(),s=a,o=[],c=[];for(let h=0,f=s.length;h<f;h++){const d=s[h];if(d){o.push(d);const m=new lt;r!==null&&m.fromArray(r.array,h*16),c.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new D0(o,c)})}loadAnimation(e){const t=this.json,i=this,a=t.animations[e],r=a.name?a.name:"animation_"+e,s=[],o=[],c=[],h=[],f=[];for(let d=0,m=a.channels.length;d<m;d++){const g=a.channels[d],y=a.samplers[g.sampler],E=g.target,S=E.node,v=a.parameters!==void 0?a.parameters[y.input]:y.input,_=a.parameters!==void 0?a.parameters[y.output]:y.output;E.node!==void 0&&(s.push(this.getDependency("node",S)),o.push(this.getDependency("accessor",v)),c.push(this.getDependency("accessor",_)),h.push(y),f.push(E))}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(c),Promise.all(h),Promise.all(f)]).then(function(d){const m=d[0],g=d[1],y=d[2],E=d[3],S=d[4],v=[];for(let _=0,A=m.length;_<A;_++){const b=m[_],O=g[_],N=y[_],L=E[_],B=S[_];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const w=i._createAnimationTracks(b,O,N,L,B);if(w)for(let D=0;D<w.length;D++)v.push(w[D])}return new Ad(r,void 0,v)})}createNodeMesh(e){const t=this.json,i=this,a=t.nodes[e];return a.mesh===void 0?null:i.getDependency("mesh",a.mesh).then(function(r){const s=i._getNodeRef(i.meshCache,a.mesh,r);return a.weights!==void 0&&s.traverse(function(o){if(o.isMesh)for(let c=0,h=a.weights.length;c<h;c++)o.morphTargetInfluences[c]=a.weights[c]}),s})}loadNode(e){const t=this.json,i=this,a=t.nodes[e],r=i._loadNodeShallow(e),s=[],o=a.children||[];for(let h=0,f=o.length;h<f;h++)s.push(i.getDependency("node",o[h]));const c=a.skin===void 0?Promise.resolve(null):i.getDependency("skin",a.skin);return Promise.all([r,Promise.all(s),c]).then(function(h){const f=h[0],d=h[1],m=h[2];m!==null&&f.traverse(function(g){g.isSkinnedMesh&&g.bind(m,P$)});for(let g=0,y=d.length;g<y;g++)f.add(d[g]);return f})}_loadNodeShallow(e){const t=this.json,i=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],s=r.name?a.createUniqueName(r.name):"",o=[],c=a._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&o.push(c),r.camera!==void 0&&o.push(a.getDependency("camera",r.camera).then(function(h){return a._getNodeRef(a.cameraCache,r.camera,h)})),a._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(r.isBone===!0?f=new Ay:h.length>1?f=new jo:h.length===1?f=h[0]:f=new fn,f!==h[0])for(let d=0,m=h.length;d<m;d++)f.add(h[d]);if(r.name&&(f.userData.name=r.name,f.name=s),Uo(f,r),r.extensions&&ru(i,f,r),r.matrix!==void 0){const d=new lt;d.fromArray(r.matrix),f.applyMatrix4(d)}else r.translation!==void 0&&f.position.fromArray(r.translation),r.rotation!==void 0&&f.quaternion.fromArray(r.rotation),r.scale!==void 0&&f.scale.fromArray(r.scale);return a.associations.has(f)||a.associations.set(f,{}),a.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],a=this,r=new jo;i.name&&(r.name=a.createUniqueName(i.name)),Uo(r,i),i.extensions&&ru(t,r,i);const s=i.nodes||[],o=[];for(let c=0,h=s.length;c<h;c++)o.push(a.getDependency("node",s[c]));return Promise.all(o).then(function(c){for(let f=0,d=c.length;f<d;f++)r.add(c[f]);const h=f=>{const d=new Map;for(const[m,g]of a.associations)(m instanceof ri||m instanceof vn)&&d.set(m,g);return f.traverse(m=>{const g=a.associations.get(m);g!=null&&d.set(m,g)}),d};return a.associations=h(r),r})}_createAnimationTracks(e,t,i,a,r){const s=[],o=e.name?e.name:e.uuid,c=[];zl[r.path]===zl.weights?e.traverse(function(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}):c.push(o);let h;switch(zl[r.path]){case zl.weights:h=qu;break;case zl.rotation:h=Zu;break;case zl.position:case zl.scale:h=ju;break;default:switch(i.itemSize){case 1:h=qu;break;case 2:case 3:default:h=ju;break}break}const f=a.interpolation!==void 0?N$[a.interpolation]:md,d=this._getArrayFromAccessor(i);for(let m=0,g=c.length;m<g;m++){const y=new h(c[m]+"."+zl[r.path],t.array,d,f);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),s.push(y)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=AT(t.constructor),a=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)a[r]=t[r]*i;t=a}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const a=this instanceof Zu?D$:K6;return new a(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function H$(n,e,t){const i=e.attributes,a=new sa;if(i.POSITION!==void 0){const o=t.json.accessors[i.POSITION],c=o.min,h=o.max;if(c!==void 0&&h!==void 0){if(a.set(new H(c[0],c[1],c[2]),new H(h[0],h[1],h[2])),o.normalized){const f=AT(ed[o.componentType]);a.min.multiplyScalar(f),a.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const o=new H,c=new H;for(let h=0,f=r.length;h<f;h++){const d=r[h];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],g=m.min,y=m.max;if(g!==void 0&&y!==void 0){if(c.setX(Math.max(Math.abs(g[0]),Math.abs(y[0]))),c.setY(Math.max(Math.abs(g[1]),Math.abs(y[1]))),c.setZ(Math.max(Math.abs(g[2]),Math.abs(y[2]))),m.normalized){const E=AT(ed[m.componentType]);c.multiplyScalar(E)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(o)}n.boundingBox=a;const s=new zi;a.getCenter(s.center),s.radius=a.min.distanceTo(a.max)/2,n.boundingSphere=s}function lN(n,e,t){const i=e.attributes,a=[];function r(s,o){return t.getDependency("accessor",s).then(function(c){n.setAttribute(o,c)})}for(const s in i){const o=ST[s]||s.toLowerCase();o in n.attributes||a.push(r(i[s],o))}if(e.indices!==void 0&&!n.index){const s=t.getDependency("accessor",e.indices).then(function(o){n.setIndex(o)});a.push(s)}return Uo(n,e),H$(n,e,t),Promise.all(a).then(function(){return e.targets!==void 0?I$(n,e.targets,t):n})}class z$ extends Hy{constructor(e){super(e),this.type=sn}parse(e){const s=function(B,w){switch(B){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(w||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(w||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(w||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(w||""))}},f=`
`,d=function(B,w,D){w=w||1024;let J=B.pos,$=-1,se=0,le="",q=String.fromCharCode.apply(null,new Uint16Array(B.subarray(J,J+128)));for(;0>($=q.indexOf(f))&&se<w&&J<B.byteLength;)le+=q,se+=q.length,J+=128,q+=String.fromCharCode.apply(null,new Uint16Array(B.subarray(J,J+128)));return-1<$?(B.pos+=se+$+1,le+q.slice(0,$)):!1},m=function(B){const w=/^#\?(\S+)/,D=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,G=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,J=/^\s*FORMAT=(\S+)\s*$/,$=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,se={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let le,q;for((B.pos>=B.byteLength||!(le=d(B)))&&s(1,"no header found"),(q=le.match(w))||s(3,"bad initial token"),se.valid|=1,se.programtype=q[1],se.string+=le+`
`;le=d(B),le!==!1;){if(se.string+=le+`
`,le.charAt(0)==="#"){se.comments+=le+`
`;continue}if((q=le.match(D))&&(se.gamma=parseFloat(q[1])),(q=le.match(G))&&(se.exposure=parseFloat(q[1])),(q=le.match(J))&&(se.valid|=2,se.format=q[1]),(q=le.match($))&&(se.valid|=4,se.height=parseInt(q[1],10),se.width=parseInt(q[2],10)),se.valid&2&&se.valid&4)break}return se.valid&2||s(3,"missing format specifier"),se.valid&4||s(3,"missing image size specifier"),se},g=function(B,w,D){const G=w;if(G<8||G>32767||B[0]!==2||B[1]!==2||B[2]&128)return new Uint8Array(B);G!==(B[2]<<8|B[3])&&s(3,"wrong scanline width");const J=new Uint8Array(4*w*D);J.length||s(4,"unable to allocate buffer space");let $=0,se=0;const le=4*G,q=new Uint8Array(4),te=new Uint8Array(le);let ee=D;for(;ee>0&&se<B.byteLength;){se+4>B.byteLength&&s(1),q[0]=B[se++],q[1]=B[se++],q[2]=B[se++],q[3]=B[se++],(q[0]!=2||q[1]!=2||(q[2]<<8|q[3])!=G)&&s(3,"bad rgbe scanline format");let de=0,ue;for(;de<le&&se<B.byteLength;){ue=B[se++];const He=ue>128;if(He&&(ue-=128),(ue===0||de+ue>le)&&s(3,"bad scanline data"),He){const Ke=B[se++];for(let nt=0;nt<ue;nt++)te[de++]=Ke}else te.set(B.subarray(se,se+ue),de),de+=ue,se+=ue}const Pe=G;for(let He=0;He<Pe;He++){let Ke=0;J[$]=te[He+Ke],Ke+=G,J[$+1]=te[He+Ke],Ke+=G,J[$+2]=te[He+Ke],Ke+=G,J[$+3]=te[He+Ke],$+=4}ee--}return J},y=function(B,w,D,G){const J=B[w+3],$=Math.pow(2,J-128)/255;D[G+0]=B[w+0]*$,D[G+1]=B[w+1]*$,D[G+2]=B[w+2]*$,D[G+3]=1},E=function(B,w,D,G){const J=B[w+3],$=Math.pow(2,J-128)/255;D[G+0]=Zo.toHalfFloat(Math.min(B[w+0]*$,65504)),D[G+1]=Zo.toHalfFloat(Math.min(B[w+1]*$,65504)),D[G+2]=Zo.toHalfFloat(Math.min(B[w+2]*$,65504)),D[G+3]=Zo.toHalfFloat(1)},S=new Uint8Array(e);S.pos=0;const v=m(S),_=v.width,A=v.height,b=g(S.subarray(S.pos),_,A);let O,N,L;switch(this.type){case Sn:L=b.length/4;const B=new Float32Array(L*4);for(let D=0;D<L;D++)y(b,D*4,B,D*4);O=B,N=Sn;break;case sn:L=b.length/4;const w=new Uint16Array(L*4);for(let D=0;D<L;D++)E(b,D*4,w,D*4);O=w,N=sn;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:_,height:A,data:O,header:v.string,gamma:v.gamma,exposure:v.exposure,type:N}}setDataType(e){return this.type=e,this}load(e,t,i,a){function r(s,o){switch(s.type){case Sn:case sn:"colorSpace"in s?s.colorSpace="srgb-linear":s.encoding=3e3,s.minFilter=Bt,s.magFilter=Bt,s.generateMipmaps=!1,s.flipY=!0;break}t&&t(s,o)}return super.load(e,r,i,a)}}const Xp=Xb>=152;class G$ extends Hy{constructor(e){super(e),this.type=sn}parse(e){const w=Math.pow(2.7182818,2.2);function D(U,W){for(var oe=0,Te=0;Te<65536;++Te)(Te==0||U[Te>>3]&1<<(Te&7))&&(W[oe++]=Te);for(var De=oe-1;oe<65536;)W[oe++]=0;return De}function G(U){for(var W=0;W<16384;W++)U[W]={},U[W].len=0,U[W].lit=0,U[W].p=null}const J={l:0,c:0,lc:0};function $(U,W,oe,Te,De){for(;oe<U;)W=W<<8|St(Te,De),oe+=8;oe-=U,J.l=W>>oe&(1<<U)-1,J.c=W,J.lc=oe}const se=new Array(59);function le(U){for(var W=0;W<=58;++W)se[W]=0;for(var W=0;W<65537;++W)se[U[W]]+=1;for(var oe=0,W=58;W>0;--W){var Te=oe+se[W]>>1;se[W]=oe,oe=Te}for(var W=0;W<65537;++W){var De=U[W];De>0&&(U[W]=De|se[De]++<<6)}}function q(U,W,oe,Te,De,Me,M){for(var I=oe,V=0,C=0;De<=Me;De++){if(I.value-oe.value>Te)return!1;$(6,V,C,U,I);var F=J.l;if(V=J.c,C=J.lc,M[De]=F,F==63){if(I.value-oe.value>Te)throw"Something wrong with hufUnpackEncTable";$(8,V,C,U,I);var Y=J.l+6;if(V=J.c,C=J.lc,De+Y>Me+1)throw"Something wrong with hufUnpackEncTable";for(;Y--;)M[De++]=0;De--}else if(F>=59){var Y=F-59+2;if(De+Y>Me+1)throw"Something wrong with hufUnpackEncTable";for(;Y--;)M[De++]=0;De--}}le(M)}function te(U){return U&63}function ee(U){return U>>6}function de(U,W,oe,Te){for(;W<=oe;W++){var De=ee(U[W]),Me=te(U[W]);if(De>>Me)throw"Invalid table entry";if(Me>14){var M=Te[De>>Me-14];if(M.len)throw"Invalid table entry";if(M.lit++,M.p){var I=M.p;M.p=new Array(M.lit);for(var V=0;V<M.lit-1;++V)M.p[V]=I[V]}else M.p=new Array(1);M.p[M.lit-1]=W}else if(Me)for(var C=0,V=1<<14-Me;V>0;V--){var M=Te[(De<<14-Me)+C];if(M.len||M.p)throw"Invalid table entry";M.len=Me,M.lit=W,C++}}return!0}const ue={c:0,lc:0};function Pe(U,W,oe,Te){U=U<<8|St(oe,Te),W+=8,ue.c=U,ue.lc=W}const He={c:0,lc:0};function Ke(U,W,oe,Te,De,Me,M,I,V,C){if(U==W){Te<8&&(Pe(oe,Te,De,M),oe=ue.c,Te=ue.lc),Te-=8;var F=oe>>Te,F=new Uint8Array([F])[0];if(V.value+F>C)return!1;for(var Y=I[V.value-1];F-- >0;)I[V.value++]=Y}else if(V.value<C)I[V.value++]=U;else return!1;He.c=oe,He.lc=Te}function nt(U){return U&65535}function xt(U){var W=nt(U);return W>32767?W-65536:W}const fe={a:0,b:0};function Be(U,W){var oe=xt(U),Te=xt(W),De=Te,Me=oe+(De&1)+(De>>1),M=Me,I=Me-De;fe.a=M,fe.b=I}function Je(U,W){var oe=nt(U),Te=nt(W),De=oe-(Te>>1)&65535,Me=Te+De-32768&65535;fe.a=Me,fe.b=De}function ve(U,W,oe,Te,De,Me,M){for(var I=M<16384,V=oe>De?De:oe,C=1,F;C<=V;)C<<=1;for(C>>=1,F=C,C>>=1;C>=1;){for(var Y=0,z=Y+Me*(De-F),k=Me*C,Q=Me*F,ae=Te*C,ce=Te*F,xe,Ae,Ne,Fe;Y<=z;Y+=Q){for(var Oe=Y,Ze=Y+Te*(oe-F);Oe<=Ze;Oe+=ce){var $e=Oe+ae,vt=Oe+k,Rt=vt+ae;I?(Be(U[Oe+W],U[vt+W]),xe=fe.a,Ne=fe.b,Be(U[$e+W],U[Rt+W]),Ae=fe.a,Fe=fe.b,Be(xe,Ae),U[Oe+W]=fe.a,U[$e+W]=fe.b,Be(Ne,Fe),U[vt+W]=fe.a,U[Rt+W]=fe.b):(Je(U[Oe+W],U[vt+W]),xe=fe.a,Ne=fe.b,Je(U[$e+W],U[Rt+W]),Ae=fe.a,Fe=fe.b,Je(xe,Ae),U[Oe+W]=fe.a,U[$e+W]=fe.b,Je(Ne,Fe),U[vt+W]=fe.a,U[Rt+W]=fe.b)}if(oe&C){var vt=Oe+k;I?Be(U[Oe+W],U[vt+W]):Je(U[Oe+W],U[vt+W]),xe=fe.a,U[vt+W]=fe.b,U[Oe+W]=xe}}if(De&C)for(var Oe=Y,Ze=Y+Te*(oe-F);Oe<=Ze;Oe+=ce){var $e=Oe+ae;I?Be(U[Oe+W],U[$e+W]):Je(U[Oe+W],U[$e+W]),xe=fe.a,U[$e+W]=fe.b,U[Oe+W]=xe}F=C,C>>=1}return Y}function at(U,W,oe,Te,De,Me,M,I,V,C){for(var F=0,Y=0,z=I,k=Math.trunc(De.value+(Me+7)/8);De.value<k;)for(Pe(F,Y,oe,De),F=ue.c,Y=ue.lc;Y>=14;){var Q=F>>Y-14&16383,ae=W[Q];if(ae.len)Y-=ae.len,Ke(ae.lit,M,F,Y,oe,Te,De,V,C,z),F=He.c,Y=He.lc;else{if(!ae.p)throw"hufDecode issues";var ce;for(ce=0;ce<ae.lit;ce++){for(var xe=te(U[ae.p[ce]]);Y<xe&&De.value<k;)Pe(F,Y,oe,De),F=ue.c,Y=ue.lc;if(Y>=xe&&ee(U[ae.p[ce]])==(F>>Y-xe&(1<<xe)-1)){Y-=xe,Ke(ae.p[ce],M,F,Y,oe,Te,De,V,C,z),F=He.c,Y=He.lc;break}}if(ce==ae.lit)throw"hufDecode issues"}}var Ae=8-Me&7;for(F>>=Ae,Y-=Ae;Y>0;){var ae=W[F<<14-Y&16383];if(ae.len)Y-=ae.len,Ke(ae.lit,M,F,Y,oe,Te,De,V,C,z),F=He.c,Y=He.lc;else throw"hufDecode issues"}return!0}function ft(U,W,oe,Te,De,Me){var M={value:0},I=oe.value,V=Ve(W,oe),C=Ve(W,oe);oe.value+=4;var F=Ve(W,oe);if(oe.value+=4,V<0||V>=65537||C<0||C>=65537)throw"Something wrong with HUF_ENCSIZE";var Y=new Array(65537),z=new Array(16384);G(z);var k=Te-(oe.value-I);if(q(U,W,oe,k,V,C,Y),F>8*(Te-(oe.value-I)))throw"Something wrong with hufUncompress";de(Y,V,C,z),at(Y,z,U,W,oe,F,C,Me,De,M)}function ht(U,W,oe){for(var Te=0;Te<oe;++Te)W[Te]=U[W[Te]]}function et(U){for(var W=1;W<U.length;W++){var oe=U[W-1]+U[W]-128;U[W]=oe}}function Re(U,W){for(var oe=0,Te=Math.floor((U.length+1)/2),De=0,Me=U.length-1;!(De>Me||(W[De++]=U[oe++],De>Me));)W[De++]=U[Te++]}function Z(U){for(var W=U.byteLength,oe=new Array,Te=0,De=new DataView(U);W>0;){var Me=De.getInt8(Te++);if(Me<0){var M=-Me;W-=M+1;for(var I=0;I<M;I++)oe.push(De.getUint8(Te++))}else{var M=Me;W-=2;for(var V=De.getUint8(Te++),I=0;I<M+1;I++)oe.push(V)}}return oe}function Ue(U,W,oe,Te,De,Me){var $e=new DataView(Me.buffer),M=oe[U.idx[0]].width,I=oe[U.idx[0]].height,V=3,C=Math.floor(M/8),F=Math.ceil(M/8),Y=Math.ceil(I/8),z=M-(F-1)*8,k=I-(Y-1)*8,Q={value:0},ae=new Array(V),ce=new Array(V),xe=new Array(V),Ae=new Array(V),Ne=new Array(V);for(let je=0;je<V;++je)Ne[je]=W[U.idx[je]],ae[je]=je<1?0:ae[je-1]+F*Y,ce[je]=new Float32Array(64),xe[je]=new Uint16Array(64),Ae[je]=new Uint16Array(F*64);for(let je=0;je<Y;++je){var Fe=8;je==Y-1&&(Fe=k);var Oe=8;for(let Ft=0;Ft<F;++Ft){Ft==F-1&&(Oe=z);for(let Et=0;Et<V;++Et)xe[Et].fill(0),xe[Et][0]=De[ae[Et]++],ze(Q,Te,xe[Et]),Qe(xe[Et],ce[Et]),Ye(ce[Et]);ot(ce);for(let Et=0;Et<V;++Et)rt(ce[Et],Ae[Et],Ft*64)}let Ut=0;for(let Ft=0;Ft<V;++Ft){const Et=oe[U.idx[Ft]].type;for(let Lt=8*je;Lt<8*je+Fe;++Lt){Ut=Ne[Ft][Lt];for(let Ot=0;Ot<C;++Ot){const en=Ot*64+(Lt&7)*8;$e.setUint16(Ut+0*2*Et,Ae[Ft][en+0],!0),$e.setUint16(Ut+1*2*Et,Ae[Ft][en+1],!0),$e.setUint16(Ut+2*2*Et,Ae[Ft][en+2],!0),$e.setUint16(Ut+3*2*Et,Ae[Ft][en+3],!0),$e.setUint16(Ut+4*2*Et,Ae[Ft][en+4],!0),$e.setUint16(Ut+5*2*Et,Ae[Ft][en+5],!0),$e.setUint16(Ut+6*2*Et,Ae[Ft][en+6],!0),$e.setUint16(Ut+7*2*Et,Ae[Ft][en+7],!0),Ut+=8*2*Et}}if(C!=F)for(let Lt=8*je;Lt<8*je+Fe;++Lt){const Ot=Ne[Ft][Lt]+8*C*2*Et,en=C*64+(Lt&7)*8;for(let Nn=0;Nn<Oe;++Nn)$e.setUint16(Ot+Nn*2*Et,Ae[Ft][en+Nn],!0)}}}for(var Ze=new Uint16Array(M),$e=new DataView(Me.buffer),vt=0;vt<V;++vt){oe[U.idx[vt]].decoded=!0;var Rt=oe[U.idx[vt]].type;if(oe[vt].type==2)for(var pt=0;pt<I;++pt){const je=Ne[vt][pt];for(var Ct=0;Ct<M;++Ct)Ze[Ct]=$e.getUint16(je+Ct*2*Rt,!0);for(var Ct=0;Ct<M;++Ct)$e.setFloat32(je+Ct*2*Rt,Se(Ze[Ct]),!0)}}}function ze(U,W,oe){for(var Te,De=1;De<64;)Te=W[U.value],Te==65280?De=64:Te>>8==255?De+=Te&255:(oe[De]=Te,De++),U.value++}function Qe(U,W){W[0]=Se(U[0]),W[1]=Se(U[1]),W[2]=Se(U[5]),W[3]=Se(U[6]),W[4]=Se(U[14]),W[5]=Se(U[15]),W[6]=Se(U[27]),W[7]=Se(U[28]),W[8]=Se(U[2]),W[9]=Se(U[4]),W[10]=Se(U[7]),W[11]=Se(U[13]),W[12]=Se(U[16]),W[13]=Se(U[26]),W[14]=Se(U[29]),W[15]=Se(U[42]),W[16]=Se(U[3]),W[17]=Se(U[8]),W[18]=Se(U[12]),W[19]=Se(U[17]),W[20]=Se(U[25]),W[21]=Se(U[30]),W[22]=Se(U[41]),W[23]=Se(U[43]),W[24]=Se(U[9]),W[25]=Se(U[11]),W[26]=Se(U[18]),W[27]=Se(U[24]),W[28]=Se(U[31]),W[29]=Se(U[40]),W[30]=Se(U[44]),W[31]=Se(U[53]),W[32]=Se(U[10]),W[33]=Se(U[19]),W[34]=Se(U[23]),W[35]=Se(U[32]),W[36]=Se(U[39]),W[37]=Se(U[45]),W[38]=Se(U[52]),W[39]=Se(U[54]),W[40]=Se(U[20]),W[41]=Se(U[22]),W[42]=Se(U[33]),W[43]=Se(U[38]),W[44]=Se(U[46]),W[45]=Se(U[51]),W[46]=Se(U[55]),W[47]=Se(U[60]),W[48]=Se(U[21]),W[49]=Se(U[34]),W[50]=Se(U[37]),W[51]=Se(U[47]),W[52]=Se(U[50]),W[53]=Se(U[56]),W[54]=Se(U[59]),W[55]=Se(U[61]),W[56]=Se(U[35]),W[57]=Se(U[36]),W[58]=Se(U[48]),W[59]=Se(U[49]),W[60]=Se(U[57]),W[61]=Se(U[58]),W[62]=Se(U[62]),W[63]=Se(U[63])}function Ye(U){const W=.5*Math.cos(.7853975),oe=.5*Math.cos(3.14159/16),Te=.5*Math.cos(3.14159/8),De=.5*Math.cos(3*3.14159/16),Me=.5*Math.cos(5*3.14159/16),M=.5*Math.cos(3*3.14159/8),I=.5*Math.cos(7*3.14159/16);for(var V=new Array(4),C=new Array(4),F=new Array(4),Y=new Array(4),z=0;z<8;++z){var k=z*8;V[0]=Te*U[k+2],V[1]=M*U[k+2],V[2]=Te*U[k+6],V[3]=M*U[k+6],C[0]=oe*U[k+1]+De*U[k+3]+Me*U[k+5]+I*U[k+7],C[1]=De*U[k+1]-I*U[k+3]-oe*U[k+5]-Me*U[k+7],C[2]=Me*U[k+1]-oe*U[k+3]+I*U[k+5]+De*U[k+7],C[3]=I*U[k+1]-Me*U[k+3]+De*U[k+5]-oe*U[k+7],F[0]=W*(U[k+0]+U[k+4]),F[3]=W*(U[k+0]-U[k+4]),F[1]=V[0]+V[3],F[2]=V[1]-V[2],Y[0]=F[0]+F[1],Y[1]=F[3]+F[2],Y[2]=F[3]-F[2],Y[3]=F[0]-F[1],U[k+0]=Y[0]+C[0],U[k+1]=Y[1]+C[1],U[k+2]=Y[2]+C[2],U[k+3]=Y[3]+C[3],U[k+4]=Y[3]-C[3],U[k+5]=Y[2]-C[2],U[k+6]=Y[1]-C[1],U[k+7]=Y[0]-C[0]}for(var Q=0;Q<8;++Q)V[0]=Te*U[16+Q],V[1]=M*U[16+Q],V[2]=Te*U[48+Q],V[3]=M*U[48+Q],C[0]=oe*U[8+Q]+De*U[24+Q]+Me*U[40+Q]+I*U[56+Q],C[1]=De*U[8+Q]-I*U[24+Q]-oe*U[40+Q]-Me*U[56+Q],C[2]=Me*U[8+Q]-oe*U[24+Q]+I*U[40+Q]+De*U[56+Q],C[3]=I*U[8+Q]-Me*U[24+Q]+De*U[40+Q]-oe*U[56+Q],F[0]=W*(U[Q]+U[32+Q]),F[3]=W*(U[Q]-U[32+Q]),F[1]=V[0]+V[3],F[2]=V[1]-V[2],Y[0]=F[0]+F[1],Y[1]=F[3]+F[2],Y[2]=F[3]-F[2],Y[3]=F[0]-F[1],U[0+Q]=Y[0]+C[0],U[8+Q]=Y[1]+C[1],U[16+Q]=Y[2]+C[2],U[24+Q]=Y[3]+C[3],U[32+Q]=Y[3]-C[3],U[40+Q]=Y[2]-C[2],U[48+Q]=Y[1]-C[1],U[56+Q]=Y[0]-C[0]}function ot(U){for(var W=0;W<64;++W){var oe=U[0][W],Te=U[1][W],De=U[2][W];U[0][W]=oe+1.5747*De,U[1][W]=oe-.1873*Te-.4682*De,U[2][W]=oe+1.8556*Te}}function rt(U,W,oe){for(var Te=0;Te<64;++Te)W[oe+Te]=Zo.toHalfFloat(mt(U[Te]))}function mt(U){return U<=1?Math.sign(U)*Math.pow(Math.abs(U),2.2):Math.sign(U)*Math.pow(w,Math.abs(U)-1)}function j(U){return new DataView(U.array.buffer,U.offset.value,U.size)}function P(U){var W=U.viewer.buffer.slice(U.offset.value,U.offset.value+U.size),oe=new Uint8Array(Z(W)),Te=new Uint8Array(oe.length);return et(oe),Re(oe,Te),new DataView(Te.buffer)}function pe(U){var W=U.array.slice(U.offset.value,U.offset.value+U.size),oe=Yv(W),Te=new Uint8Array(oe.length);return et(oe),Re(oe,Te),new DataView(Te.buffer)}function Ie(U){for(var W=U.viewer,oe={value:U.offset.value},Te=new Uint16Array(U.width*U.scanlineBlockSize*(U.channels*U.type)),De=new Uint8Array(8192),Me=0,M=new Array(U.channels),I=0;I<U.channels;I++)M[I]={},M[I].start=Me,M[I].end=M[I].start,M[I].nx=U.width,M[I].ny=U.lines,M[I].size=U.type,Me+=M[I].nx*M[I].ny*M[I].size;var V=_e(W,oe),C=_e(W,oe);if(C>=8192)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(V<=C)for(var I=0;I<C-V+1;I++)De[I+V]=ne(W,oe);var F=new Uint16Array(65536),Y=D(De,F),z=Ve(W,oe);ft(U.array,W,oe,z,Te,Me);for(var I=0;I<U.channels;++I)for(var k=M[I],Q=0;Q<M[I].size;++Q)ve(Te,k.start+Q,k.nx,k.size,k.ny,k.nx*k.size,Y);ht(F,Te,Me);for(var ae=0,ce=new Uint8Array(Te.buffer.byteLength),xe=0;xe<U.lines;xe++)for(var Ae=0;Ae<U.channels;Ae++){var k=M[Ae],Ne=k.nx*k.size,Fe=new Uint8Array(Te.buffer,k.end*2,Ne*2);ce.set(Fe,ae),ae+=Ne*2,k.end+=Ne}return new DataView(ce.buffer)}function Ge(U){var W=U.array.slice(U.offset.value,U.offset.value+U.size),oe=Yv(W);const Te=U.lines*U.channels*U.width,De=U.type==1?new Uint16Array(Te):new Uint32Array(Te);let Me=0,M=0;const I=new Array(4);for(let V=0;V<U.lines;V++)for(let C=0;C<U.channels;C++){let F=0;switch(U.type){case 1:I[0]=Me,I[1]=I[0]+U.width,Me=I[1]+U.width;for(let Y=0;Y<U.width;++Y){const z=oe[I[0]++]<<8|oe[I[1]++];F+=z,De[M]=F,M++}break;case 2:I[0]=Me,I[1]=I[0]+U.width,I[2]=I[1]+U.width,Me=I[2]+U.width;for(let Y=0;Y<U.width;++Y){const z=oe[I[0]++]<<24|oe[I[1]++]<<16|oe[I[2]++]<<8;F+=z,De[M]=F,M++}break}}return new DataView(De.buffer)}function we(U){var W=U.viewer,oe={value:U.offset.value},Te=new Uint8Array(U.width*U.lines*(U.channels*U.type*2)),De={version:me(W,oe),unknownUncompressedSize:me(W,oe),unknownCompressedSize:me(W,oe),acCompressedSize:me(W,oe),dcCompressedSize:me(W,oe),rleCompressedSize:me(W,oe),rleUncompressedSize:me(W,oe),rleRawSize:me(W,oe),totalAcUncompressedCount:me(W,oe),totalDcUncompressedCount:me(W,oe),acCompression:me(W,oe)};if(De.version<2)throw"EXRLoader.parse: "+Oi.compression+" version "+De.version+" is unsupported";for(var Me=new Array,M=_e(W,oe)-2;M>0;){var I=Tt(W.buffer,oe),V=ne(W,oe),C=V>>2&3,F=(V>>4)-1,Y=new Int8Array([F])[0],z=ne(W,oe);Me.push({name:I,index:Y,type:z,compression:C}),M-=I.length+3}for(var k=Oi.channels,Q=new Array(U.channels),ae=0;ae<U.channels;++ae){var ce=Q[ae]={},xe=k[ae];ce.name=xe.name,ce.compression=0,ce.decoded=!1,ce.type=xe.pixelType,ce.pLinear=xe.pLinear,ce.width=U.width,ce.height=U.lines}for(var Ae={idx:new Array(3)},Ne=0;Ne<U.channels;++Ne)for(var ce=Q[Ne],ae=0;ae<Me.length;++ae){var Fe=Me[ae];ce.name==Fe.name&&(ce.compression=Fe.compression,Fe.index>=0&&(Ae.idx[Fe.index]=Ne),ce.offset=Ne)}if(De.acCompressedSize>0)switch(De.acCompression){case 0:var $e=new Uint16Array(De.totalAcUncompressedCount);ft(U.array,W,oe,De.acCompressedSize,$e,De.totalAcUncompressedCount);break;case 1:var Oe=U.array.slice(oe.value,oe.value+De.totalAcUncompressedCount),Ze=Yv(Oe),$e=new Uint16Array(Ze.buffer);oe.value+=De.totalAcUncompressedCount;break}if(De.dcCompressedSize>0){var vt={array:U.array,offset:oe,size:De.dcCompressedSize},Rt=new Uint16Array(pe(vt).buffer);oe.value+=De.dcCompressedSize}if(De.rleRawSize>0){var Oe=U.array.slice(oe.value,oe.value+De.rleCompressedSize),Ze=Yv(Oe),pt=Z(Ze.buffer);oe.value+=De.rleCompressedSize}for(var Ct=0,je=new Array(Q.length),ae=0;ae<je.length;++ae)je[ae]=new Array;for(var Ut=0;Ut<U.lines;++Ut)for(var Ft=0;Ft<Q.length;++Ft)je[Ft].push(Ct),Ct+=Q[Ft].width*U.type*2;Ue(Ae,je,Q,$e,Rt,Te);for(var ae=0;ae<Q.length;++ae){var ce=Q[ae];if(!ce.decoded)switch(ce.compression){case 2:for(var Et=0,Lt=0,Ut=0;Ut<U.lines;++Ut){for(var Ot=je[ae][Et],en=0;en<ce.width;++en){for(var Nn=0;Nn<2*ce.type;++Nn)Te[Ot++]=pt[Lt+Nn*ce.width*ce.height];Lt++}Et++}break;case 1:default:throw"EXRLoader.parse: unsupported channel compression"}}return new DataView(Te.buffer)}function Tt(U,W){for(var oe=new Uint8Array(U),Te=0;oe[W.value+Te]!=0;)Te+=1;var De=new TextDecoder().decode(oe.slice(W.value,W.value+Te));return W.value=W.value+Te+1,De}function ut(U,W,oe){var Te=new TextDecoder().decode(new Uint8Array(U).slice(W.value,W.value+oe));return W.value=W.value+oe,Te}function wt(U,W){var oe=ke(U,W),Te=Ve(U,W);return[oe,Te]}function bt(U,W){var oe=Ve(U,W),Te=Ve(U,W);return[oe,Te]}function ke(U,W){var oe=U.getInt32(W.value,!0);return W.value=W.value+4,oe}function Ve(U,W){var oe=U.getUint32(W.value,!0);return W.value=W.value+4,oe}function St(U,W){var oe=U[W.value];return W.value=W.value+1,oe}function ne(U,W){var oe=U.getUint8(W.value);return W.value=W.value+1,oe}const me=function(U,W){let oe;return"getBigInt64"in DataView.prototype?oe=Number(U.getBigInt64(W.value,!0)):oe=U.getUint32(W.value+4,!0)+Number(U.getUint32(W.value,!0)<<32),W.value+=8,oe};function Le(U,W){var oe=U.getFloat32(W.value,!0);return W.value+=4,oe}function K(U,W){return Zo.toHalfFloat(Le(U,W))}function Se(U){var W=(U&31744)>>10,oe=U&1023;return(U>>15?-1:1)*(W?W===31?oe?NaN:1/0:Math.pow(2,W-15)*(1+oe/1024):6103515625e-14*(oe/1024))}function _e(U,W){var oe=U.getUint16(W.value,!0);return W.value+=2,oe}function it(U,W){return Se(_e(U,W))}function tt(U,W,oe,Te){for(var De=oe.value,Me=[];oe.value<De+Te-1;){var M=Tt(W,oe),I=ke(U,oe),V=ne(U,oe);oe.value+=3;var C=ke(U,oe),F=ke(U,oe);Me.push({name:M,pixelType:I,pLinear:V,xSampling:C,ySampling:F})}return oe.value+=1,Me}function We(U,W){var oe=Le(U,W),Te=Le(U,W),De=Le(U,W),Me=Le(U,W),M=Le(U,W),I=Le(U,W),V=Le(U,W),C=Le(U,W);return{redX:oe,redY:Te,greenX:De,greenY:Me,blueX:M,blueY:I,whiteX:V,whiteY:C}}function gt(U,W){var oe=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],Te=ne(U,W);return oe[Te]}function Nt(U,W){var oe=Ve(U,W),Te=Ve(U,W),De=Ve(U,W),Me=Ve(U,W);return{xMin:oe,yMin:Te,xMax:De,yMax:Me}}function $t(U,W){var oe=["INCREASING_Y"],Te=ne(U,W);return oe[Te]}function jt(U,W){var oe=Le(U,W),Te=Le(U,W);return[oe,Te]}function hi(U,W){var oe=Le(U,W),Te=Le(U,W),De=Le(U,W);return[oe,Te,De]}function fi(U,W,oe,Te,De){if(Te==="string"||Te==="stringvector"||Te==="iccProfile")return ut(W,oe,De);if(Te==="chlist")return tt(U,W,oe,De);if(Te==="chromaticities")return We(U,oe);if(Te==="compression")return gt(U,oe);if(Te==="box2i")return Nt(U,oe);if(Te==="lineOrder")return $t(U,oe);if(Te==="float")return Le(U,oe);if(Te==="v2f")return jt(U,oe);if(Te==="v3f")return hi(U,oe);if(Te==="int")return ke(U,oe);if(Te==="rational")return wt(U,oe);if(Te==="timecode")return bt(U,oe);if(Te==="preview")return oe.value+=De,"skipped";oe.value+=De}function hl(U,W,oe){const Te={};if(U.getUint32(0,!0)!=20000630)throw"THREE.EXRLoader: provided file doesn't appear to be in OpenEXR format.";Te.version=U.getUint8(4);const De=U.getUint8(5);Te.spec={singleTile:!!(De&2),longName:!!(De&4),deepFormat:!!(De&8),multiPart:!!(De&16)},oe.value=8;for(var Me=!0;Me;){var M=Tt(W,oe);if(M==0)Me=!1;else{var I=Tt(W,oe),V=Ve(U,oe),C=fi(U,W,oe,I,V);C===void 0?console.warn(`EXRLoader.parse: skipped unknown header attribute type '${I}'.`):Te[M]=C}}if(De&-5)throw console.error("EXRHeader:",Te),"THREE.EXRLoader: provided file is currently unsupported.";return Te}function Ps(U,W,oe,Te,De){const Me={size:0,viewer:W,array:oe,offset:Te,width:U.dataWindow.xMax-U.dataWindow.xMin+1,height:U.dataWindow.yMax-U.dataWindow.yMin+1,channels:U.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:U.channels[0].pixelType,uncompress:null,getter:null,format:null,[Xp?"colorSpace":"encoding"]:null};switch(U.compression){case"NO_COMPRESSION":Me.lines=1,Me.uncompress=j;break;case"RLE_COMPRESSION":Me.lines=1,Me.uncompress=P;break;case"ZIPS_COMPRESSION":Me.lines=1,Me.uncompress=pe;break;case"ZIP_COMPRESSION":Me.lines=16,Me.uncompress=pe;break;case"PIZ_COMPRESSION":Me.lines=32,Me.uncompress=Ie;break;case"PXR24_COMPRESSION":Me.lines=16,Me.uncompress=Ge;break;case"DWAA_COMPRESSION":Me.lines=32,Me.uncompress=we;break;case"DWAB_COMPRESSION":Me.lines=256,Me.uncompress=we;break;default:throw"EXRLoader.parse: "+U.compression+" is unsupported"}if(Me.scanlineBlockSize=Me.lines,Me.type==1)switch(De){case Sn:Me.getter=it,Me.inputSize=2;break;case sn:Me.getter=_e,Me.inputSize=2;break}else if(Me.type==2)switch(De){case Sn:Me.getter=Le,Me.inputSize=4;break;case sn:Me.getter=K,Me.inputSize=4}else throw"EXRLoader.parse: unsupported pixelType "+Me.type+" for "+U.compression+".";Me.blockCount=(U.dataWindow.yMax+1)/Me.scanlineBlockSize;for(var M=0;M<Me.blockCount;M++)me(W,Te);Me.outputChannels=Me.channels==3?4:Me.channels;const I=Me.width*Me.height*Me.outputChannels;switch(De){case Sn:Me.byteArray=new Float32Array(I),Me.channels<Me.outputChannels&&Me.byteArray.fill(1,0,I);break;case sn:Me.byteArray=new Uint16Array(I),Me.channels<Me.outputChannels&&Me.byteArray.fill(15360,0,I);break;default:console.error("THREE.EXRLoader: unsupported type: ",De);break}return Me.bytesPerLine=Me.width*Me.inputSize*Me.channels,Me.outputChannels==4?Me.format=Rn:Me.format=Ar,Xp?Me.colorSpace="srgb-linear":Me.encoding=3e3,Me}const ar=new DataView(e),Ni=new Uint8Array(e),Va={value:0},Oi=hl(ar,e,Va),zt=Ps(Oi,ar,Ni,Va,this.type),ka={value:0},Ln={R:0,G:1,B:2,A:3,Y:0};for(let U=0;U<zt.height/zt.scanlineBlockSize;U++){const W=Ve(ar,Va);zt.size=Ve(ar,Va),zt.lines=W+zt.scanlineBlockSize>zt.height?zt.height-W:zt.scanlineBlockSize;const Te=zt.size<zt.lines*zt.bytesPerLine?zt.uncompress(zt):j(zt);Va.value+=zt.size;for(let De=0;De<zt.scanlineBlockSize;De++){const Me=De+U*zt.scanlineBlockSize;if(Me>=zt.height)break;for(let M=0;M<zt.channels;M++){const I=Ln[Oi.channels[M].name];for(let V=0;V<zt.width;V++){ka.value=(De*(zt.channels*zt.width)+M*zt.width+V)*zt.inputSize;const C=(zt.height-1-Me)*(zt.width*zt.outputChannels)+V*zt.outputChannels+I;zt.byteArray[C]=zt.getter(Te,ka)}}}}return{header:Oi,width:zt.width,height:zt.height,data:zt.byteArray,format:zt.format,[Xp?"colorSpace":"encoding"]:zt[Xp?"colorSpace":"encoding"],type:this.type}}setDataType(e){return this.type=e,this}load(e,t,i,a){function r(s,o){Xp?s.colorSpace=o.colorSpace:s.encoding=o.encoding,s.minFilter=Bt,s.magFilter=Bt,s.generateMipmaps=!1,s.flipY=!1,t&&t(s,o)}return super.load(e,r,i,a)}}const C2=new WeakMap;class V$ 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,a){const r=new oa(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,s=>{const o={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(s,o).then(t).catch(a)},i,a)}decodeDracoFile(e,t,i,a){const r={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:a||this.defaultAttributeTypes,useUniqueIDs:!!i};this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){for(const c in t.attributeTypes){const h=t.attributeTypes[c];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=h.name)}const i=JSON.stringify(t);if(C2.has(e)){const c=C2.get(e);if(c.key===i)return c.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 a;const r=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(r,s).then(c=>(a=c,new Promise((h,f)=>{a._callbacks[r]={resolve:h,reject:f},a.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return o.catch(()=>!0).then(()=>{a&&r&&this._releaseTask(a,r)}),C2.set(e,{key:i,promise:o}),o}_createGeometry(e){const t=new Xt;e.index&&t.setIndex(new pn(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const a=e.attributes[i],r=a.name,s=a.array,o=a.itemSize;t.setAttribute(r,new pn(s,o))}return t}_loadLibrary(e,t){const i=new oa(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((a,r)=>{i.load(e,a,void 0,r)})}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 a=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const r=k$.toString(),s=["/* draco decoder */",a,"","/* worker */",r.substring(r.indexOf("{")+1,r.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 a=new Worker(this.workerSourceURL);a._callbacks={},a._taskCosts={},a._taskLoad=0,a.postMessage({type:"init",decoderConfig:this.decoderConfig}),a.onmessage=function(r){const s=r.data;switch(s.type){case"decode":a._callbacks[s.id].resolve(s);break;case"error":a._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(a)}else this.workerPool.sort(function(a,r){return a._taskLoad>r._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}}function k$(){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 c=o.buffer,h=o.taskConfig;e.then(f=>{const d=f.draco,m=new d.Decoder,g=new d.DecoderBuffer;g.Init(new Int8Array(c),c.byteLength);try{const y=t(d,m,g,h),E=y.attributes.map(S=>S.array.buffer);y.index&&E.push(y.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:y},E)}catch(y){console.error(y),self.postMessage({type:"error",id:o.id,error:y.message})}finally{d.destroy(g),d.destroy(m)}});break}};function t(s,o,c,h){const f=h.attributeIDs,d=h.attributeTypes;let m,g;const y=o.GetEncodedGeometryType(c);if(y===s.TRIANGULAR_MESH)m=new s.Mesh,g=o.DecodeBufferToMesh(c,m);else if(y===s.POINT_CLOUD)m=new s.PointCloud,g=o.DecodeBufferToPointCloud(c,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!g.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());const E={index:null,attributes:[]};for(const S in f){const v=self[d[S]];let _,A;if(h.useUniqueIDs)A=f[S],_=o.GetAttributeByUniqueId(m,A);else{if(A=o.GetAttributeId(m,s[f[S]]),A===-1)continue;_=o.GetAttribute(m,A)}E.attributes.push(a(s,o,m,S,v,_))}return y===s.TRIANGULAR_MESH&&(E.index=i(s,o,m)),s.destroy(m),E}function i(s,o,c){const f=c.num_faces()*3,d=f*4,m=s._malloc(d);o.GetTrianglesUInt32Array(c,d,m);const g=new Uint32Array(s.HEAPF32.buffer,m,f).slice();return s._free(m),{array:g,itemSize:1}}function a(s,o,c,h,f,d){const m=d.num_components(),y=c.num_points()*m,E=y*f.BYTES_PER_ELEMENT,S=r(s,f),v=s._malloc(E);o.GetAttributeDataArrayForAllPoints(c,d,S,E,v);const _=new f(s.HEAPF32.buffer,v,y).slice();return s._free(v),{name:h,array:_,itemSize:m}}function r(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}}}let Zv;const R2=()=>{if(Zv)return Zv;const n="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",e="B9h9z9tFBBBFiI9gBB9gLaaaaaFa9gEaaaB9gFaFaEMcBBFBFFGGGEILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBOn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBNI9z9iqlBVc+N9IcIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMk8lLbaE97F9+FaL978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAeDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAeDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBReCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBH8ZCFD9tA8ZAPD9OD9hD9RH8ZDQBTFtGmEYIPLdKeOnHpAIAQJDBIBHyCFD9tAyAPD9OD9hD9RHyAIASJDBIBH8cCFD9tA8cAPD9OD9hD9RH8cDQBTFtGmEYIPLdKeOnH8dDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAeD9uHeDyBjGBAEAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeApA8dDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNiV8ZcpMyS8cQ8df8eb8fHdAyA8cDQNiV8ZcpMyS8cQ8df8eb8fH8ZDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/dLEK97FaF97GXGXAGCI9HQBAF9FQFCBRGEXABABDBBBHECiD+rFCiD+sFD/6FHIAECND+rFCiD+sFD/6FAID/gFAECTD+rFCiD+sFD/6FHLD/gFD/kFD/lFHKCBDtD+2FHOAICUUUU94DtHND9OD9RD/kFHI9DBB/+hDYAIAID/mFAKAKD/mFALAOALAND9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHLD/mF9DBBX9LDYHOD/kFCgFDtD9OAECUUU94DtD9OD9QAIALD/mFAOD/kFCND+rFCU/+EDtD9OD9QAKALD/mFAOD/kFCTD+rFCUU/8ODtD9OD9QDMBBABCTJRBAGCIJHGAF9JQBSGMMAF9FQBCBRGEXABCTJHVAVDBBBHECBDtHOCUU98D8cFCUU98D8cEHND9OABDBBBHKAEDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAKAEDQBFGENVcMTtmYi8ZpyHECTD+sFD/6FHID/gFAECTD+rFCTD+sFD/6FHLD/gFD/kFD/lFHE9DB/+g6DYALAEAOD+2FHOALCUUUU94DtHcD9OD9RD/kFHLALD/mFAEAED/mFAIAOAIAcD9OD9RD/kFHEAED/mFD/kFD/kFD/jFD/nFHID/mF9DBBX9LDYHOD/kFCTD+rFALAID/mFAOD/kFCggEDtD9OD9QHLAEAID/mFAOD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHEDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAKAND9OALAEDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM/hEIGaF97FaL978jUUUUBCTlREGXAF9FQBCBRIEXAEABDBBBHLABCTJHKDBBBHODQILKOSQfbPden8c8d8e8fHNCTD+sFHVCID+rFDMIBAB9DBBU8/DY9D/zI818/DYAVCEDtD9QD/6FD/nFHVALAODQBFGENVcMTtmYi8ZpyHLCTD+rFCTD+sFD/6FD/mFHOAOD/mFAVALCTD+sFD/6FD/mFHcAcD/mFAVANCTD+rFCTD+sFD/6FD/mFHNAND/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHVD/mF9DBBX9LDYHLD/kFCggEDtHMD9OAcAVD/mFALD/kFCTD+rFD9QHcANAVD/mFALD/kFCTD+rFAOAVD/mFALD/kFAMD9OD9QHVDQBFTtGEmYILPdKOenHLD8dBAEDBIBDyB+t+J83EBABCNJALD8dFAEDBIBDyF+t+J83EBAKAcAVDQNVi8ZcMpySQ8c8dfb8e8fHVD8dBAEDBIBDyG+t+J83EBABCiJAVD8dFAEDBIBDyE+t+J83EBABCAJRBAICIJHIAF9JQBMMM9jFF97GXAGCGrAF9sHG9FQBCBRFEXABABDBBBHECND+rFCND+sFD/6FAECiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBABCTJRBAFCIJHFAG9JQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),i=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if(typeof WebAssembly!="object")return{supported:!1};let a=n;WebAssembly.validate(t)&&(a=e);let r;const s=WebAssembly.instantiate(o(a),{}).then(d=>{r=d.instance,r.exports.__wasm_call_ctors()});function o(d){const m=new Uint8Array(d.length);for(let y=0;y<d.length;++y){const E=d.charCodeAt(y);m[y]=E>96?E-71:E>64?E-65:E>47?E+4:E>46?63:62}let g=0;for(let y=0;y<d.length;++y)m[g++]=m[y]<60?i[m[y]]:(m[y]-60)*64+m[++y];return m.buffer.slice(0,g)}function c(d,m,g,y,E,S){const v=r.exports.sbrk,_=g+3&-4,A=v(_*y),b=v(E.length),O=new Uint8Array(r.exports.memory.buffer);O.set(E,b);const N=d(A,g,y,b,E.length);if(N===0&&S&&S(A,_,y),m.set(O.subarray(A,A+g*y)),v(A-v(0)),N!==0)throw new Error(`Malformed buffer data: ${N}`)}const h={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},f={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return Zv={ready:s,supported:!0,decodeVertexBuffer(d,m,g,y,E){c(r.exports.meshopt_decodeVertexBuffer,d,m,g,y,r.exports[h[E]])},decodeIndexBuffer(d,m,g,y){c(r.exports.meshopt_decodeIndexBuffer,d,m,g,y)},decodeIndexSequence(d,m,g,y){c(r.exports.meshopt_decodeIndexSequence,d,m,g,y)},decodeGltfBuffer(d,m,g,y,E,S){c(r.exports[f[E]],d,m,g,y,r.exports[h[S]])}},Zv};let jv=null,J6="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function Q6(n=!0,e=!0,t){return i=>{t&&t(i),n&&(jv||(jv=new V$),jv.setDecoderPath(typeof n=="string"?n:J6),i.setDRACOLoader(jv)),e&&i.setMeshoptDecoder(typeof R2=="function"?R2():R2)}}const a_=(n,e,t,i)=>sl(Wb,n,Q6(e,t,i));a_.preload=(n,e,t,i)=>sl.preload(Wb,n,Q6(e,t,i));a_.clear=n=>sl.clear(Wb,n);a_.setDecoderPath=n=>{J6=n};function X$(n,e,t){const i=jn(g=>g.size),a=jn(g=>g.viewport),r=typeof n=="number"?n:i.width*a.dpr,s=i.height*a.dpr,o=(typeof n=="number"?t:n)||{},{samples:c=0,depth:h,...f}=o,d=h??o.depthBuffer,m=he.useMemo(()=>{const g=new oi(r,s,{minFilter:Bt,magFilter:Bt,type:sn,...f});return d&&(g.depthTexture=new N0(r,s,Sn)),g.samples=c,g},[]);return he.useLayoutEffect(()=>{m.setSize(r,s),c&&(m.samples=c)},[c,m,r,s]),he.useEffect(()=>()=>m.dispose(),[]),m}const W$=n=>typeof n=="function",Y$=he.forwardRef(({envMap:n,resolution:e=256,frames:t=1/0,makeDefault:i,children:a,...r},s)=>{const o=jn(({set:S})=>S),c=jn(({camera:S})=>S),h=jn(({size:S})=>S),f=he.useRef(null);he.useImperativeHandle(s,()=>f.current,[]);const d=he.useRef(null),m=X$(e);he.useLayoutEffect(()=>{r.manual||(f.current.aspect=h.width/h.height)},[h,r]),he.useLayoutEffect(()=>{f.current.updateProjectionMatrix()});let g=0,y=null;const E=W$(a);return Ls(S=>{E&&(t===1/0||g<t)&&(d.current.visible=!1,S.gl.setRenderTarget(m),y=S.scene.background,n&&(S.scene.background=n),S.gl.render(S.scene,f.current),S.scene.background=y,S.gl.setRenderTarget(null),d.current.visible=!0,g++)}),he.useLayoutEffect(()=>{if(i){const S=c;return o(()=>({camera:f.current})),()=>o(()=>({camera:S}))}},[f,i,o]),he.createElement(he.Fragment,null,he.createElement("perspectiveCamera",eh({ref:f},r),!E&&a),he.createElement("group",{ref:d},E&&a(m.texture)))}),q$=he.forwardRef(({makeDefault:n,camera:e,regress:t,domElement:i,enableDamping:a=!0,keyEvents:r=!1,onChange:s,onStart:o,onEnd:c,...h},f)=>{const d=jn(N=>N.invalidate),m=jn(N=>N.camera),g=jn(N=>N.gl),y=jn(N=>N.events),E=jn(N=>N.setEvents),S=jn(N=>N.set),v=jn(N=>N.get),_=jn(N=>N.performance),A=e||m,b=i||y.connected||g.domElement,O=he.useMemo(()=>new a$(A),[A]);return Ls(()=>{O.enabled&&O.update()},-1),he.useEffect(()=>(r&&O.connect(r===!0?b:r),O.connect(b),()=>void O.dispose()),[r,b,t,O,d]),he.useEffect(()=>{const N=w=>{d(),t&&_.regress(),s&&s(w)},L=w=>{o&&o(w)},B=w=>{c&&c(w)};return O.addEventListener("change",N),O.addEventListener("start",L),O.addEventListener("end",B),()=>{O.removeEventListener("start",L),O.removeEventListener("end",B),O.removeEventListener("change",N)}},[s,o,c,O,d,E]),he.useEffect(()=>{if(n){const N=v().controls;return S({controls:O}),()=>S({controls:N})}},[n,O]),he.createElement("primitive",eh({ref:f,object:O,enableDamping:a},h))});function Z$(){const n=new Xt,e=new Float32Array([-1,-1,3,-1,-1,3]);return n.boundingSphere=new zi,n.boundingSphere.set(new H,1/0),n.setAttribute("position",new pn(e,2)),n}const j$=he.forwardRef(function({children:e,...t},i){const a=he.useMemo(Z$,[]);return he.createElement("mesh",eh({ref:i,geometry:a,frustumCulled:!1},t),e)}),$6=(n,e,t)=>{let i;switch(n){case xi:i=new Uint8ClampedArray(e*t*4);break;case sn:i=new Uint16Array(e*t*4);break;case ls:i=new Uint32Array(e*t*4);break;case M0:i=new Int8Array(e*t*4);break;case C0:i=new Int16Array(e*t*4);break;case Fd:i=new Int32Array(e*t*4);break;case Sn:i=new Float32Array(e*t*4);break;default:throw new Error("Unsupported data type")}return i};let Kv;const K$=(n,e,t,i)=>{if(Kv!==void 0)return Kv;const a=new oi(1,1,i);e.setRenderTarget(a);const r=new Xn(new Us,new Qa({color:16777215}));e.render(r,t),e.setRenderTarget(null);const s=$6(n,a.width,a.height);return e.readRenderTargetPixels(a,0,0,a.width,a.height,s),a.dispose(),r.geometry.dispose(),r.material.dispose(),Kv=s[0]!==0,Kv};class Yb{constructor(e){Ei(this,"_renderer");Ei(this,"_rendererIsDisposable",!1);Ei(this,"_material");Ei(this,"_scene");Ei(this,"_camera");Ei(this,"_quad");Ei(this,"_renderTarget");Ei(this,"_width");Ei(this,"_height");Ei(this,"_type");Ei(this,"_colorSpace");Ei(this,"_supportsReadPixels",!0);Ei(this,"render",()=>{this._renderer.setRenderTarget(this._renderTarget);try{this._renderer.render(this._scene,this._camera)}catch(e){throw this._renderer.setRenderTarget(null),e}this._renderer.setRenderTarget(null)});var i,a,r,s,o,c,h,f,d,m,g,y,E,S,v,_;this._width=e.width,this._height=e.height,this._type=e.type,this._colorSpace=e.colorSpace;const t={format:Rn,depthBuffer:!1,stencilBuffer:!1,type:this._type,colorSpace:this._colorSpace,anisotropy:((i=e.renderTargetOptions)==null?void 0:i.anisotropy)!==void 0?(a=e.renderTargetOptions)==null?void 0:a.anisotropy:1,generateMipmaps:((r=e.renderTargetOptions)==null?void 0:r.generateMipmaps)!==void 0?(s=e.renderTargetOptions)==null?void 0:s.generateMipmaps:!1,magFilter:((o=e.renderTargetOptions)==null?void 0:o.magFilter)!==void 0?(c=e.renderTargetOptions)==null?void 0:c.magFilter:Bt,minFilter:((h=e.renderTargetOptions)==null?void 0:h.minFilter)!==void 0?(f=e.renderTargetOptions)==null?void 0:f.minFilter:Bt,samples:((d=e.renderTargetOptions)==null?void 0:d.samples)!==void 0?(m=e.renderTargetOptions)==null?void 0:m.samples:void 0,wrapS:((g=e.renderTargetOptions)==null?void 0:g.wrapS)!==void 0?(y=e.renderTargetOptions)==null?void 0:y.wrapS:Vn,wrapT:((E=e.renderTargetOptions)==null?void 0:E.wrapT)!==void 0?(S=e.renderTargetOptions)==null?void 0:S.wrapT:Vn};if(this._material=e.material,e.renderer?this._renderer=e.renderer:(this._renderer=Yb.instantiateRenderer(),this._rendererIsDisposable=!0),this._scene=new al,this._camera=new Rr,this._camera.position.set(0,0,10),this._camera.left=-.5,this._camera.right=.5,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),!K$(this._type,this._renderer,this._camera,t)){let A;switch(this._type){case sn:A=this._renderer.extensions.has("EXT_color_buffer_float")?Sn:void 0;break}A!==void 0?(console.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to ${Sn}`),this._type=A):(this._supportsReadPixels=!1,console.warn("This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown"))}this._quad=new Xn(new Us,this._material),this._quad.geometry.computeBoundingBox(),this._scene.add(this._quad),this._renderTarget=new oi(this.width,this.height,t),this._renderTarget.texture.mapping=((v=e.renderTargetOptions)==null?void 0:v.mapping)!==void 0?(_=e.renderTargetOptions)==null?void 0:_.mapping:pc}static instantiateRenderer(){const e=new ky;return e.setSize(128,128),e}toArray(){if(!this._supportsReadPixels)throw new Error("Can't read pixels in this browser");const e=$6(this._type,this._width,this._height);return this._renderer.readRenderTargetPixels(this._renderTarget,0,0,this._width,this._height,e),e}toDataTexture(e){const t=new Pa(this.toArray(),this.width,this.height,Rn,this._type,(e==null?void 0:e.mapping)||pc,(e==null?void 0:e.wrapS)||Vn,(e==null?void 0:e.wrapT)||Vn,(e==null?void 0:e.magFilter)||Bt,(e==null?void 0:e.minFilter)||Bt,(e==null?void 0:e.anisotropy)||1,Fi);return t.generateMipmaps=(e==null?void 0:e.generateMipmaps)!==void 0?e==null?void 0:e.generateMipmaps:!1,t}disposeOnDemandRenderer(){this._renderer.setRenderTarget(null),this._rendererIsDisposable&&(this._renderer.dispose(),this._renderer.forceContextLoss())}dispose(e){this.disposeOnDemandRenderer(),e&&this.renderTarget.dispose(),this.material instanceof Di&&Object.values(this.material.uniforms).forEach(t=>{t.value instanceof vn&&t.value.dispose()}),Object.values(this.material).forEach(t=>{t instanceof vn&&t.dispose()}),this.material.dispose(),this._quad.geometry.dispose()}get width(){return this._width}set width(e){this._width=e,this._renderTarget.setSize(this._width,this._height)}get height(){return this._height}set height(e){this._height=e,this._renderTarget.setSize(this._width,this._height)}get renderer(){return this._renderer}get renderTarget(){return this._renderTarget}set renderTarget(e){this._renderTarget=e,this._width=e.width,this._height=e.height}get material(){return this._material}get type(){return this._type}get colorSpace(){return this._colorSpace}}class e9 extends Error{}class t9 extends Error{}const Wp=(n,e,t)=>{const i=new RegExp(`${e}="([^"]*)"`,"i").exec(n);if(i)return i[1];const a=new RegExp(`<${e}[^>]*>([\\s\\S]*?)</${e}>`,"i").exec(n);if(a){const r=a[1].match(/<rdf:li>([^<]*)<\/rdf:li>/g);return r&&r.length===3?r.map(s=>s.replace(/<\/?rdf:li>/g,"")):a[1].trim()}if(t!==void 0)return t;throw new Error(`Can't find ${e} in gainmap metadata`)},J$=n=>{let e;typeof TextDecoder<"u"?e=new TextDecoder().decode(n):e=n.toString();let t=e.indexOf("<x:xmpmeta");for(;t!==-1;){const i=e.indexOf("x:xmpmeta>",t),a=e.slice(t,i+10);try{const r=Wp(a,"hdrgm:GainMapMin","0"),s=Wp(a,"hdrgm:GainMapMax"),o=Wp(a,"hdrgm:Gamma","1"),c=Wp(a,"hdrgm:OffsetSDR","0.015625"),h=Wp(a,"hdrgm:OffsetHDR","0.015625"),f=/hdrgm:HDRCapacityMin="([^"]*)"/.exec(a),d=f?f[1]:"0",m=/hdrgm:HDRCapacityMax="([^"]*)"/.exec(a);if(!m)throw new Error("Incomplete gainmap metadata");const g=m[1];return{gainMapMin:Array.isArray(r)?r.map(y=>parseFloat(y)):[parseFloat(r),parseFloat(r),parseFloat(r)],gainMapMax:Array.isArray(s)?s.map(y=>parseFloat(y)):[parseFloat(s),parseFloat(s),parseFloat(s)],gamma:Array.isArray(o)?o.map(y=>parseFloat(y)):[parseFloat(o),parseFloat(o),parseFloat(o)],offsetSdr:Array.isArray(c)?c.map(y=>parseFloat(y)):[parseFloat(c),parseFloat(c),parseFloat(c)],offsetHdr:Array.isArray(h)?h.map(y=>parseFloat(y)):[parseFloat(h),parseFloat(h),parseFloat(h)],hdrCapacityMin:parseFloat(d),hdrCapacityMax:parseFloat(g)}}catch{}t=e.indexOf("<x:xmpmeta",i)}};class Q${constructor(e){Ei(this,"options");this.options={debug:e&&e.debug!==void 0?e.debug:!1,extractFII:e&&e.extractFII!==void 0?e.extractFII:!0,extractNonFII:e&&e.extractNonFII!==void 0?e.extractNonFII:!0}}extract(e){return new Promise((t,i)=>{const a=this.options.debug,r=new DataView(e.buffer);if(r.getUint16(0)!==65496){i(new Error("Not a valid jpeg"));return}const s=r.byteLength;let o=2,c=0,h;for(;o<s;){if(++c>250){i(new Error(`Found no marker after ${c} loops 😵`));return}if(r.getUint8(o)!==255){i(new Error(`Not a valid marker at offset 0x${o.toString(16)}, found: 0x${r.getUint8(o).toString(16)}`));return}if(h=r.getUint8(o+1),a&&console.log(`Marker: ${h.toString(16)}`),h===226){a&&console.log("Found APP2 marker (0xffe2)");const f=o+4;if(r.getUint32(f)===1297106432){const d=f+4;let m;if(r.getUint16(d)===18761)m=!1;else if(r.getUint16(d)===19789)m=!0;else{i(new Error("No valid endianness marker found in TIFF header"));return}if(r.getUint16(d+2,!m)!==42){i(new Error("Not valid TIFF data! (no 0x002A marker)"));return}const g=r.getUint32(d+4,!m);if(g<8){i(new Error("Not valid TIFF data! (First offset less than 8)"));return}const y=d+g,E=r.getUint16(y,!m),S=y+2;let v=0;for(let O=S;O<S+12*E;O+=12)r.getUint16(O,!m)===45057&&(v=r.getUint32(O+8,!m));const A=y+2+E*12+4,b=[];for(let O=A;O<A+v*16;O+=16){const N={MPType:r.getUint32(O,!m),size:r.getUint32(O+4,!m),dataOffset:r.getUint32(O+8,!m),dependantImages:r.getUint32(O+12,!m),start:-1,end:-1,isFII:!1};N.dataOffset?(N.start=d+N.dataOffset,N.isFII=!1):(N.start=0,N.isFII=!0),N.end=N.start+N.size,b.push(N)}if(this.options.extractNonFII&&b.length){const O=new Blob([r]),N=[];for(const L of b){if(L.isFII&&!this.options.extractFII)continue;const B=O.slice(L.start,L.end+1,"image/jpeg");N.push(B)}t(N)}}}o+=2+r.getUint16(o+2)}})}}const $$=async n=>{const e=J$(n);if(!e)throw new t9("Gain map XMP metadata not found");const i=await new Q$({extractFII:!0,extractNonFII:!0}).extract(n);if(i.length!==2)throw new e9("Gain map recovery image not found");return{sdr:new Uint8Array(await i[0].arrayBuffer()),gainMap:new Uint8Array(await i[1].arrayBuffer()),metadata:e}},cN=n=>new Promise((e,t)=>{const i=document.createElement("img");i.onload=()=>{e(i)},i.onerror=a=>{t(a)},i.src=URL.createObjectURL(n)});class eee extends yi{constructor(t,i){super(i);Ei(this,"_renderer");Ei(this,"_renderTargetOptions");Ei(this,"_internalLoadingManager");Ei(this,"_config");this._config=t,t.renderer&&(this._renderer=t.renderer),this._internalLoadingManager=new Fy}setRenderer(t){return this._renderer=t,this}setRenderTargetOptions(t){return this._renderTargetOptions=t,this}prepareQuadRenderer(){this._renderer||console.warn("WARNING: A Renderer was not passed to this Loader constructor or in setRenderer, the result of this Loader will need to be converted to a Data Texture with toDataTexture() before you can use it in your renderer.");const t=this._config.createMaterial({gainMapMax:[1,1,1],gainMapMin:[0,0,0],gamma:[1,1,1],offsetHdr:[1,1,1],offsetSdr:[1,1,1],hdrCapacityMax:1,hdrCapacityMin:0,maxDisplayBoost:1,gainMap:new vn,sdr:new vn});return this._config.createQuadRenderer({width:16,height:16,type:sn,colorSpace:Fi,material:t,renderer:this._renderer,renderTargetOptions:this._renderTargetOptions})}async processImages(t,i,a){const r=i?new Blob([i],{type:"image/jpeg"}):void 0,s=new Blob([t],{type:"image/jpeg"});let o,c,h=!1;if(typeof createImageBitmap>"u"){const f=await Promise.all([r?cN(r):Promise.resolve(void 0),cN(s)]);c=f[0],o=f[1],h=a==="flipY"}else{const f=await Promise.all([r?createImageBitmap(r,{imageOrientation:a||"flipY"}):Promise.resolve(void 0),createImageBitmap(s,{imageOrientation:a||"flipY"})]);c=f[0],o=f[1]}return{sdrImage:o,gainMapImage:c,needsFlip:h}}createTextures(t,i,a){const r=new vn(i||new ImageData(2,2),pc,Vn,Vn,Bt,e0,Rn,xi,1,Fi);r.flipY=a,r.needsUpdate=!0;const s=new vn(t,pc,Vn,Vn,Bt,e0,Rn,xi,1,Kn);return s.flipY=a,s.needsUpdate=!0,{gainMap:r,sdr:s}}updateQuadRenderer(t,i,a,r,s){t.width=i.width,t.height=i.height,t.material.gainMap=a,t.material.sdr=r,t.material.gainMapMin=s.gainMapMin,t.material.gainMapMax=s.gainMapMax,t.material.offsetHdr=s.offsetHdr,t.material.offsetSdr=s.offsetSdr,t.material.gamma=s.gamma,t.material.hdrCapacityMin=s.hdrCapacityMin,t.material.hdrCapacityMax=s.hdrCapacityMax,t.material.maxDisplayBoost=Math.pow(2,s.hdrCapacityMax),t.material.needsUpdate=!0}}const tee=`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,nee=`
// min half float value
#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 )
// max half float value
#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 )
uniform sampler2D sdr;
uniform sampler2D gainMap;
uniform vec3 gamma;
uniform vec3 offsetHdr;
uniform vec3 offsetSdr;
uniform vec3 gainMapMin;
uniform vec3 gainMapMax;
uniform float weightFactor;
varying vec2 vUv;
void main() {
vec3 rgb = texture2D( sdr, vUv ).rgb;
vec3 recovery = texture2D( gainMap, vUv ).rgb;
vec3 logRecovery = pow( recovery, gamma );
vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery;
vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr;
vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor ));
gl_FragColor = vec4( clampedHdrColor , 1.0 );
}
`;class iee extends Di{constructor({gamma:t,offsetHdr:i,offsetSdr:a,gainMapMin:r,gainMapMax:s,maxDisplayBoost:o,hdrCapacityMin:c,hdrCapacityMax:h,sdr:f,gainMap:d}){super({name:"GainMapDecoderMaterial",vertexShader:tee,fragmentShader:nee,uniforms:{sdr:{value:f},gainMap:{value:d},gamma:{value:new H(1/t[0],1/t[1],1/t[2])},offsetHdr:{value:new H().fromArray(i)},offsetSdr:{value:new H().fromArray(a)},gainMapMin:{value:new H().fromArray(r)},gainMapMax:{value:new H().fromArray(s)},weightFactor:{value:(Math.log2(o)-c)/(h-c)}},blending:ga,depthTest:!1,depthWrite:!1});Ei(this,"_maxDisplayBoost");Ei(this,"_hdrCapacityMin");Ei(this,"_hdrCapacityMax");this._maxDisplayBoost=o,this._hdrCapacityMin=c,this._hdrCapacityMax=h,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(t){this.uniforms.sdr.value=t}get gainMap(){return this.uniforms.gainMap.value}set gainMap(t){this.uniforms.gainMap.value=t}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(t){this.uniforms.offsetHdr.value.fromArray(t)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(t){this.uniforms.offsetSdr.value.fromArray(t)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(t){this.uniforms.gainMapMin.value.fromArray(t)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(t){this.uniforms.gainMapMax.value.fromArray(t)}get gamma(){const t=this.uniforms.gamma.value;return[1/t.x,1/t.y,1/t.z]}set gamma(t){const i=this.uniforms.gamma.value;i.x=1/t[0],i.y=1/t[1],i.z=1/t[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(t){this._hdrCapacityMin=t,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(t){this._hdrCapacityMax=t,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(t){this._maxDisplayBoost=Math.max(1,Math.min(65504,t)),this.calculateWeight()}calculateWeight(){const t=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,t))}}class n9 extends eee{constructor(e,t){super({renderer:e,createMaterial:i=>new iee(i),createQuadRenderer:i=>new Yb(i)},t)}async render(e,t,i,a){const{sdrImage:r,gainMapImage:s,needsFlip:o}=await this.processImages(i,a,"flipY"),{gainMap:c,sdr:h}=this.createTextures(r,s,o);this.updateQuadRenderer(e,r,c,h,t),e.render()}}class aee extends n9{load([e,t,i],a,r,s){const o=this.prepareQuadRenderer();let c,h,f;const d=async()=>{if(c&&h&&f){try{await this.render(o,f,c,h)}catch(w){this.manager.itemError(e),this.manager.itemError(t),this.manager.itemError(i),typeof s=="function"&&s(w),o.disposeOnDemandRenderer();return}typeof a=="function"&&a(o),this.manager.itemEnd(e),this.manager.itemEnd(t),this.manager.itemEnd(i),o.disposeOnDemandRenderer()}};let m=!0,g=0,y=0,E=!0,S=0,v=0,_=!0,A=0,b=0;const O=()=>{if(typeof r=="function"){const w=g+S+A,D=y+v+b,G=m&&E&&_;r(new ProgressEvent("progress",{lengthComputable:G,loaded:D,total:w}))}};this.manager.itemStart(e),this.manager.itemStart(t),this.manager.itemStart(i);const N=new oa(this._internalLoadingManager);N.setResponseType("arraybuffer"),N.setRequestHeader(this.requestHeader),N.setPath(this.path),N.setWithCredentials(this.withCredentials),N.load(e,async w=>{if(typeof w=="string")throw new Error("Invalid sdr buffer");c=w,await d()},w=>{m=w.lengthComputable,y=w.loaded,g=w.total,O()},w=>{this.manager.itemError(e),typeof s=="function"&&s(w)});const L=new oa(this._internalLoadingManager);L.setResponseType("arraybuffer"),L.setRequestHeader(this.requestHeader),L.setPath(this.path),L.setWithCredentials(this.withCredentials),L.load(t,async w=>{if(typeof w=="string")throw new Error("Invalid gainmap buffer");h=w,await d()},w=>{E=w.lengthComputable,v=w.loaded,S=w.total,O()},w=>{this.manager.itemError(t),typeof s=="function"&&s(w)});const B=new oa(this._internalLoadingManager);return B.setRequestHeader(this.requestHeader),B.setPath(this.path),B.setWithCredentials(this.withCredentials),B.load(i,async w=>{if(typeof w!="string")throw new Error("Invalid metadata string");f=JSON.parse(w),await d()},w=>{_=w.lengthComputable,b=w.loaded,A=w.total,O()},w=>{this.manager.itemError(i),typeof s=="function"&&s(w)}),o}}class ree extends n9{load(e,t,i,a){const r=this.prepareQuadRenderer(),s=new oa(this._internalLoadingManager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(this.withCredentials),this.manager.itemStart(e),s.load(e,async o=>{if(typeof o=="string")throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");const c=new Uint8Array(o);let h,f,d;try{const m=await $$(c);h=m.sdr,f=m.gainMap,d=m.metadata}catch(m){if(m instanceof t9||m instanceof e9)console.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),d={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},h=c;else throw m}try{await this.render(r,d,h.buffer,f==null?void 0:f.buffer)}catch(m){this.manager.itemError(e),typeof a=="function"&&a(m),r.disposeOnDemandRenderer();return}typeof t=="function"&&t(r),this.manager.itemEnd(e),r.disposeOnDemandRenderer()},i,o=>{this.manager.itemError(e),typeof a=="function"&&a(o)}),r}}const f0={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"},i9="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",td=n=>Array.isArray(n),qb=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"];function r_({files:n=qb,path:e="",preset:t=void 0,colorSpace:i=void 0,extensions:a}={}){t&&(Zb(t),n=f0[t],e=i9);const r=td(n),{extension:s,isCubemap:o}=jb(n),c=Kb(s);if(!c)throw new Error("useEnvironment: Unrecognized file extension: "+n);const h=jn(g=>g.gl);he.useLayoutEffect(()=>{if(s!=="webp"&&s!=="jpg"&&s!=="jpeg")return;function g(){sl.clear(c,r?[n]:n)}h.domElement.addEventListener("webglcontextlost",g,{once:!0})},[n,h.domElement]);const f=sl(c,r?[n]:n,g=>{(s==="webp"||s==="jpg"||s==="jpeg")&&g.setRenderer(h),g.setPath==null||g.setPath(e),a&&a(g)});let d=r?f[0]:f;if(s==="jpg"||s==="jpeg"||s==="webp"){var m;d=(m=d.renderTarget)==null?void 0:m.texture}return d.mapping=o?no:hd,d.colorSpace=i??(o?"srgb":"srgb-linear"),d}const see={files:qb,path:"",preset:void 0,extensions:void 0};r_.preload=n=>{const e={...see,...n};let{files:t,path:i=""}=e;const{preset:a,extensions:r}=e;a&&(Zb(a),t=f0[a],i=i9);const{extension:s}=jb(t);if(s==="webp"||s==="jpg"||s==="jpeg")throw new Error("useEnvironment: Preloading gainmaps is not supported");const o=Kb(s);if(!o)throw new Error("useEnvironment: Unrecognized file extension: "+t);sl.preload(o,td(t)?[t]:t,c=>{c.setPath==null||c.setPath(i),r&&r(c)})};const oee={files:qb,preset:void 0};r_.clear=n=>{const e={...oee,...n};let{files:t}=e;const{preset:i}=e;i&&(Zb(i),t=f0[i]);const{extension:a}=jb(t),r=Kb(a);if(!r)throw new Error("useEnvironment: Unrecognized file extension: "+t);sl.clear(r,td(t)?[t]:t)};function Zb(n){if(!(n in f0))throw new Error("Preset must be one of: "+Object.keys(f0).join(", "))}function jb(n){var e;const t=td(n)&&n.length===6,i=td(n)&&n.length===3&&n.some(s=>s.endsWith("json")),a=td(n)?n[0]:n;return{extension:t?"cube":i?"webp":a.startsWith("data:application/exr")?"exr":a.startsWith("data:application/hdr")?"hdr":a.startsWith("data:image/jpeg")?"jpg":(e=a.split(".").pop())==null||(e=e.split("?"))==null||(e=e.shift())==null?void 0:e.toLowerCase(),isCubemap:t,isGainmap:i}}function Kb(n){return n==="cube"?PB:n==="hdr"?z$:n==="exr"?G$:n==="jpg"||n==="jpeg"?ree:n==="webp"?aee:null}const lee=n=>n.current&&n.current.isScene,cee=n=>lee(n)?n.current:n;function Jb(n,e,t,i,a={}){var r,s,o,c;a={backgroundBlurriness:0,backgroundIntensity:1,backgroundRotation:[0,0,0],environmentIntensity:1,environmentRotation:[0,0,0],...a};const h=cee(e||t),f=h.background,d=h.environment,m={backgroundBlurriness:h.backgroundBlurriness,backgroundIntensity:h.backgroundIntensity,backgroundRotation:(r=(s=h.backgroundRotation)==null||s.clone==null?void 0:s.clone())!==null&&r!==void 0?r:[0,0,0],environmentIntensity:h.environmentIntensity,environmentRotation:(o=(c=h.environmentRotation)==null||c.clone==null?void 0:c.clone())!==null&&o!==void 0?o:[0,0,0]};return n!=="only"&&(h.environment=i),n&&(h.background=i),Ks(h,a),()=>{n!=="only"&&(h.environment=d),n&&(h.background=f),Ks(h,m)}}function Qb({scene:n,background:e=!1,map:t,...i}){const a=jn(r=>r.scene);return he.useLayoutEffect(()=>{if(t)return Jb(e,n,a,t,i)}),null}function a9({background:n=!1,scene:e,blur:t,backgroundBlurriness:i,backgroundIntensity:a,backgroundRotation:r,environmentIntensity:s,environmentRotation:o,...c}){const h=r_(c),f=jn(d=>d.scene);return he.useLayoutEffect(()=>Jb(n,e,f,h,{backgroundBlurriness:t??i,backgroundIntensity:a,backgroundRotation:r,environmentIntensity:s,environmentRotation:o})),he.useEffect(()=>()=>{h.dispose()},[h]),null}function uee({children:n,near:e=.1,far:t=1e3,resolution:i=256,frames:a=1,map:r,background:s=!1,blur:o,backgroundBlurriness:c,backgroundIntensity:h,backgroundRotation:f,environmentIntensity:d,environmentRotation:m,scene:g,files:y,path:E,preset:S=void 0,extensions:v}){const _=jn(B=>B.gl),A=jn(B=>B.scene),b=he.useRef(null),[O]=he.useState(()=>new al),N=he.useMemo(()=>{const B=new z3(i);return B.texture.type=sn,B},[i]);he.useEffect(()=>()=>{N.dispose()},[N]),he.useLayoutEffect(()=>{if(a===1){const B=_.autoClear;_.autoClear=!0,b.current.update(_,O),_.autoClear=B}return Jb(s,g,A,N.texture,{backgroundBlurriness:o??c,backgroundIntensity:h,backgroundRotation:f,environmentIntensity:d,environmentRotation:m})},[n,O,N.texture,g,A,s,a,_]);let L=1;return Ls(()=>{if(a===1/0||L<a){const B=_.autoClear;_.autoClear=!0,b.current.update(_,O),_.autoClear=B,L++}}),he.createElement(he.Fragment,null,w8(he.createElement(he.Fragment,null,n,he.createElement("cubeCamera",{ref:b,args:[e,t,N]}),y||S?he.createElement(a9,{background:!0,files:y,preset:S,path:E,extensions:v}):r?he.createElement(Qb,{background:!0,map:r,extensions:v}):null),O))}function hee(n){var e,t,i,a;const r=r_(n),s=n.map||r;he.useMemo(()=>Sb({GroundProjectedEnvImpl:KQ}),[]),he.useEffect(()=>()=>{r.dispose()},[r]);const o=he.useMemo(()=>[s],[s]),c=(e=n.ground)==null?void 0:e.height,h=(t=n.ground)==null?void 0:t.radius,f=(i=(a=n.ground)==null?void 0:a.scale)!==null&&i!==void 0?i:1e3;return he.createElement(he.Fragment,null,he.createElement(Qb,eh({},n,{map:s})),he.createElement("groundProjectedEnvImpl",{args:o,scale:f,height:c,radius:h}))}function fee(n){return n.ground?he.createElement(hee,n):n.map?he.createElement(Qb,n):n.children?he.createElement(uee,n):he.createElement(a9,n)}const q0=he.createContext({}),dee=({ref:n,textures:e,ellipsoid:t=bd.WGS84,correctAltitude:i=!0,ground:a=!0,date:r,children:s})=>{const o=he.useRef({sunDirection:new H,moonDirection:new H,worldToECEFMatrix:new lt,inertialToECEFMatrix:new lt,overlay:null,shadow:null,shadowLength:null,lightingMask:null}),c=jn(({gl:E})=>E),h=he.useMemo(()=>typeof e=="string"?new F6().setType(c).load(e):void 0,[e,c]);he.useEffect(()=>{if(h!=null)return()=>{for(const E of Object.values(h))E==null||E.dispose()}},[h]);const f=he.useMemo(()=>e==null?new P6(c):void 0,[e,c]);he.useEffect(()=>{if(f!=null)return f.update().catch(E=>{console.error(E)}),()=>{f.dispose()}},[f]);const d=(f==null?void 0:f.textures)??(typeof e=="string"?h:e),m=he.useMemo(()=>({textures:d,ellipsoid:t,correctAltitude:i,ground:a,transientStates:o.current}),[d,t,i,a]),g=he.useMemo(()=>{const{sunDirection:E,moonDirection:S,inertialToECEFMatrix:v}=o.current;return _=>{rQ(_,v),sQ(_,E).applyMatrix4(v),oQ(_,S).applyMatrix4(v)}},[]),y=r!=null&&!isNaN(+r)?+r:void 0;return he.useEffect(()=>{y!=null&&g(y)},[y,g]),he.useImperativeHandle(n,()=>({...o.current,textures:d,updateByDate:g}),[d,g]),It.jsx(q0.Provider,{value:m,children:s})};function s_(n){const{irradianceTexture:e,scatteringTexture:t,transmittanceTexture:i,singleMieScatteringTexture:a,higherOrderScatteringTexture:r,ellipsoid:s,correctAltitude:o,sunDirection:c,sunAngularRadius:h,ground:f,renderTargetCount:d,...m}=n;return[{irradianceTexture:e,scatteringTexture:t,transmittanceTexture:i,singleMieScatteringTexture:a,higherOrderScatteringTexture:r,ellipsoid:s,correctAltitude:o,sunDirection:c,sunAngularRadius:h,ground:f,renderTargetCount:d},m]}function pee(n){const e=he.useMemo(()=>typeof n=="string"?new v6().load(n):void 0,[n]);return he.useEffect(()=>{if(e!=null)return()=>{e.dispose()}},[e]),(typeof n=="string"?e:n)??null}const mee=({ref:n,stbnTexture:e=W8,...t})=>{const{textures:i,transientStates:a,...r}=he.useContext(q0),[s,{blendFunction:o,...c}]=s_({...b6,...r,...i,...t}),h=he.useContext(bb),{normalPass:f,camera:d}=h,m="geometryPass"in h&&h.geometryPass instanceof Tb&&"geometryTexture"in h.geometryPass&&h.geometryPass.geometryTexture instanceof vn?h.geometryPass.geometryTexture:void 0,g=he.useMemo(()=>new za(void 0,{blendFunction:o}),[o]);he.useEffect(()=>()=>{g.dispose()},[g]);const[y,E]=he.useState(!1);Ls(()=>{a!=null&&(g.sunDirection.copy(a.sunDirection),g.moonDirection.copy(a.moonDirection),g.worldToECEFMatrix.copy(a.worldToECEFMatrix),g.overlay=a.overlay,g.shadow=a.shadow,g.shadowLength=a.shadowLength,g.lightingMask=a.lightingMask,!y&&g.shadow!=null&&E(!0))});const S=pee(y?e:void 0);return It.jsx("primitive",{ref:n,object:g,mainCamera:d,normalBuffer:m??(f==null?void 0:f.texture)??null,...s,...c,stbnTexture:S,octEncodedNormal:m!=null})};function gee(n){return e=>{for(const t of n)ET(t,e)}}function vee(n){return e=>{const t=[];for(const i of n){const a=ET(i,e),r=typeof a=="function";t.push(r?a:()=>ET(i,null))}return()=>{for(const i of t)i()}}}function ET(n,e){if(typeof n=="function")return n(e);n&&(n.current=e)}var xee=parseInt(he.version.split(".")[0],10)>=19?vee:gee;const yee=({ref:n,...e})=>{const{textures:t,transientStates:i,...a}=he.useContext(q0),[r,{sun:s,moon:o,moonDirection:c,moonAngularRadius:h,lunarRadianceScale:f,groundAlbedo:d,...m}]=s_({...H6,...a,...t,...e}),g=he.useMemo(()=>new i_,[]);return he.useEffect(()=>()=>{g.dispose()},[g]),Ls(()=>{i!=null&&(g.sunDirection.copy(i.sunDirection),g.moonDirection.copy(i.moonDirection),g.worldToECEFMatrix.copy(i.worldToECEFMatrix),g.shadowLength=i.shadowLength)}),It.jsx(j$,{renderOrder:E6,...m,ref:n,children:It.jsx("primitive",{object:g,...r,sun:s,moon:o,moonDirection:c,moonAngularRadius:h,lunarRadianceScale:f,groundAlbedo:d})})},_ee=({ref:n,data:e=tJ,...t})=>{const{textures:i,transientStates:a,...r}=he.useContext(q0),[s,{pointSize:o,radianceScale:c,intensity:h,background:f,...d}]=s_({...G6,...r,...i,...t}),[m,g]=he.useState(typeof e!="string"?e:void 0);he.useEffect(()=>{if(typeof e=="string"){const _=new k8;(async()=>{g(await _.loadAsync(e))})().catch(A=>{console.error(A)})}else g(e)},[e]);const y=he.useMemo(()=>m!=null?new AQ(m):void 0,[m]);he.useEffect(()=>()=>{y==null||y.dispose()},[y]);const E=he.useMemo(()=>new Vb,[]);he.useEffect(()=>()=>{E.dispose()},[E]);const S=he.useRef(null);Ls(({camera:_})=>{var A;a!=null&&_.isPerspectiveCamera===!0&&(E.sunDirection.copy(a.sunDirection),(A=S.current)==null||A.setRotationFromMatrix(a.inertialToECEFMatrix),E.worldToECEFMatrix.copy(a.worldToECEFMatrix))});const v=jn(({camera:_})=>_);return y==null||v.isPerspectiveCamera!==!0?null:It.jsxs("points",{ref:xee([S,n]),frustumCulled:!1,renderOrder:E6+1,...d,children:[It.jsx("primitive",{object:y}),It.jsx("primitive",{object:E,...s,pointSize:o,radianceScale:c,intensity:h,background:f,depthTest:!0,depthWrite:!1})]})};new F6;const uN=n_,hN=Ws,fN=Ys;class o_{constructor(e=0,t=0,i=0,a=0){this.expTerm=e,this.exponent=t,this.linearTerm=i,this.constantTerm=a}set(e=0,t=0,i=0,a=0){return this.expTerm=e,this.exponent=t,this.linearTerm=i,this.constantTerm=a,this}clone(){return new o_(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 See=["channel","altitude","height","densityScale","shapeAmount","shapeDetailAmount","weatherExponent","shapeAlteringBias","coverageFilterWidth","shadow","densityProfile"];function Aee(n,e){if(e!=null)for(const t of See){const i=e[t];i!=null&&(n[t]instanceof o_?n[t].copy(i):n[t]=i)}}const TT=class r9{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 o_(0,0,.75,.25),this.shadow=!1,this.set(e)}set(e){return Aee(this,e),this}clone(){return new r9(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}};TT.DEFAULT=new TT;let Bo=TT;const yf=Array.from({length:8},()=>({value:0,flag:0})),Yp=Array.from({length:3},()=>({min:0,max:0}));function Eee(n,e){return n.value!==e.value?n.value-e.value:n.flag-e.flag}const bT=class s9 extends Array{constructor(e){super(new Bo(e==null?void 0:e[0]),new Bo(e==null?void 0:e[1]),new Bo(e==null?void 0:e[2]),new Bo(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(Bo.DEFAULT),this[1].copy(Bo.DEFAULT),this[2].copy(Bo.DEFAULT),this[3].copy(Bo.DEFAULT),this}clone(){return new s9(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 c=yf[s];c.value=o.altitude,c.flag=0,c=yf[s+4],c.value=o.altitude+o.height,c.flag=1}yf.sort(Eee);let i=0,a=0;for(let s=0;s<yf.length;++s){const{value:o,flag:c}=yf[s];if(a===0&&s>0){const h=Yp[i++];h.min=yf[s-1].value,h.max=o}a+=c===0?1:-1}for(;i<3;++i){const s=Yp[i];s.min=0,s.max=0}let r=Yp[0];e.x=r.min,t.x=r.max,r=Yp[1],e.y=r.min,t.y=r.max,r=Yp[2],e.z=r.min,t.z=r.max}};bT.DEFAULT=new bT([{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 o9=bT;var Tee="Invariant failed";function $l(n,e){if(!n)throw new Error(Tee)}let l9=class MT{constructor(e,t){this.near=[new H,new H,new H,new H],this.far=[new H,new H,new H,new H],e!=null&&t!=null&&this.setFromCamera(e,t)}clone(){return new MT().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,a=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 r=0;r<4;++r)this.near[r].applyMatrix4(a);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 r=0;r<4;++r){const s=this.far[r];s.applyMatrix4(a);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 a=t[i]??(t[i]=new MT);if(i===0)for(let r=0;r<4;++r)a.near[r].copy(this.near[r]);else for(let r=0;r<4;++r)a.near[r].lerpVectors(this.near[r],this.far[r],e[i-1]);if(i===e.length-1)for(let r=0;r<4;++r)a.far[r].copy(this.far[r]);else for(let r=0;r<4;++r)a.far[r].lerpVectors(this.near[r],this.far[r],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 bee={uniform:(n,e,t,i,a=[])=>{for(let r=0;r<n;++r)a[r]=(e+(t-e)*(r+1)/n)/t;return a.length=n,a},logarithmic:(n,e,t,i,a=[])=>{for(let r=0;r<n;++r)a[r]=e*(t/e)**((r+1)/n)/t;return a.length=n,a},practical:(n,e,t,i=.5,a=[])=>{for(let r=0;r<n;++r){const s=(e+(t-e)*(r+1)/n)/t,o=e*(t/e)**((r+1)/n)/t;a[r]=p6(s,o,i)}return a.length=n,a}};function Mee(n,e,t,i,a,r=[]){return bee[n](e,t,i,a,r)}const dN=new H,pN=new H,Cee=new lt,mN=new lt,Ree=new l9,wee=new sa,Dee={maxFar:null,farScale:1,splitMode:"practical",splitLambda:.5,margin:0,fade:!0};class Nee{constructor(e){this.cascades=[],this.mapSize=new Ee,this.cameraFrustum=new l9,this.frusta=[],this.splits=[],this._far=0;const{cascadeCount:t,mapSize:i,maxFar:a,farScale:r,splitMode:s,splitLambda:o,margin:c,fade:h}={...Dee,...e};this.cascadeCount=t,this.mapSize.copy(i),this.maxFar=a,this.farScale=r,this.splitMode=s,this.splitLambda=o,this.margin=c,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 Ee,matrix:new lt,inverseMatrix:new lt,projectionMatrix:new lt,inverseProjectionMatrix:new lt,viewMatrix:new lt,inverseViewMatrix:new lt});this.cascades.length=e}}get far(){return this._far}updateIntervals(e){const t=this.cascadeCount,i=this.splits,a=this.far;Mee(this.splitMode,t,e.near,a,this.splitLambda,i),this.cameraFrustum.setFromCamera(e,a),this.cameraFrustum.split(i,this.frusta);const r=this.cascades;for(let s=0;s<t;++s)r[s].interval.set(i[s-1]??0,i[s]??0)}getFrustumRadius(e,t){const i=t.near,a=t.far;let r=Math.max(a[0].distanceTo(a[2]),a[0].distanceTo(i[2]));if(this.fade){const s=e.near,o=this.far,c=a[0].z/(o-s);r+=.25*c**2*(o-s)}return r*.5}updateMatrices(e,t,i=1){const a=Cee.lookAt(dN.setScalar(0),pN.copy(t).multiplyScalar(-1),fn.DEFAULT_UP),r=mN.multiplyMatrices(mN.copy(a).invert(),e.matrixWorld),s=this.frusta,o=this.cascades;$l(s.length===o.length);const c=this.margin,h=this.mapSize;for(let f=0;f<s.length;++f){const d=s[f],m=o[f],g=this.getFrustumRadius(e,s[f]),y=-g,E=g,S=g,v=-g;m.projectionMatrix.makeOrthographic(y,E,S,v,-this.margin,g*2+this.margin);const{near:_,far:A}=Ree.copy(d).applyMatrix4(r),b=wee.makeEmpty();for(let w=0;w<4;w++)b.expandByPoint(_[w]),b.expandByPoint(A[w]);const O=b.getCenter(dN);O.z=b.max.z+c;const N=(E-y)/h.width,L=(S-v)/h.height;O.x=Math.round(O.x/N)*N,O.y=Math.round(O.y/L)*L,O.applyMatrix4(a);const B=pN.copy(t).multiplyScalar(i).add(O);m.inverseViewMatrix.lookAt(O,B,fn.DEFAULT_UP).setPosition(B)}}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 a=this.cascades,r=this.cascadeCount;for(let s=0;s<r;++s){const{matrix:o,inverseMatrix:c,projectionMatrix:h,inverseProjectionMatrix:f,viewMatrix:d,inverseViewMatrix:m}=a[s];f.copy(h).invert(),d.copy(m).invert(),o.copy(h).multiply(d),c.copy(m).multiply(f)}}}const gN=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5],c9=gN.reduce((n,e,t)=>{const i=new Ee;for(let a=0;a<16;++a)if(gN[a]===t){i.set((a%4+.5)/4,(Math.floor(a/4)+.5)/4);break}return[...n,i]},[]),Oee={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 Ee(512,512),maxIterationCount:50,minStepSize:100,maxStepSize:1e3,minDensity:1e-5,minExtinction:1e-5,minTransmittance:1e-4}},Vt=Oee,Iee={low:{...Vt,lightShafts:!1,shapeDetail:!1,turbulence:!1,clouds:{...Vt.clouds,accurateSunSkyLight:!1,maxIterationCount:200,minStepSize:100,maxRayDistance:1e5,minDensity:1e-4,minExtinction:1e-4,minTransmittance:.1,maxIterationCountToGround:0,maxIterationCountToSun:1},shadow:{...Vt.shadow,maxIterationCount:25,minDensity:1e-4,minExtinction:1e-4,minTransmittance:.01,cascadeCount:2,mapSize:new Ee(256,256)}},medium:{...Vt,lightShafts:!1,turbulence:!1,clouds:{...Vt.clouds,minDensity:1e-4,minExtinction:1e-4,accurateSunSkyLight:!1,maxIterationCountToSun:2,maxIterationCountToGround:1},shadow:{...Vt.shadow,minDensity:1e-4,minExtinction:1e-4,mapSize:new Ee(256,256)}},high:Vt,ultra:{...Vt,clouds:{...Vt.clouds,minStepSize:10},shadow:{...Vt.shadow,mapSize:new Ee(1024,1024)}}},Bee=`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
}
`,u9=`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);
}
`,Uee=`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);
}
`,h9=`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;
`,CT=`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 Lee=Object.defineProperty,ir=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&Lee(e,t,a),a};const Pee=new H,Fee=new Mb;let Ga=class extends X0{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i},a=k0.DEFAULT){super({name:"CloudsMaterial",glslVersion:cs,vertexShader:ki(Uee,{atmosphere:{bruneton:{common:hN,definitions:fN,runtime:uN}},types:CT}),fragmentShader:V0(ki(Bee,{core:{depth:y6,math:fh,turbo:S6,generators:JK,raySphereIntersection:Jy,cascadedShadowMaps:x6,interleavedGradientNoise:_6,vogelDisk:A6},atmosphere:{bruneton:{common:hN,definitions:fN,runtime:uN}},types:CT,parameters:h9,clouds:u9})),uniforms:{...e,...t,...i,depthBuffer:new ie(null),viewMatrix:new ie(new lt),inverseProjectionMatrix:new ie(new lt),inverseViewMatrix:new ie(new lt),reprojectionMatrix:new ie(new lt),viewReprojectionMatrix:new ie(new lt),resolution:new ie(new Ee),cameraNear:new ie(0),cameraFar:new ie(0),cameraHeight:new ie(0),frame:new ie(0),temporalJitter:new ie(new Ee),targetUvScale:new ie(new Ee),mipLevelScale:new ie(1),stbnTexture:new ie(null),skyLightScale:new ie(1),groundBounceScale:new ie(1),powderScale:new ie(.8),powderExponent:new ie(150),maxIterationCount:new ie(Vt.clouds.maxIterationCount),minStepSize:new ie(Vt.clouds.minStepSize),maxStepSize:new ie(Vt.clouds.maxStepSize),maxRayDistance:new ie(Vt.clouds.maxRayDistance),perspectiveStepScale:new ie(Vt.clouds.perspectiveStepScale),minDensity:new ie(Vt.clouds.minDensity),minExtinction:new ie(Vt.clouds.minExtinction),minTransmittance:new ie(Vt.clouds.minTransmittance),maxIterationCountToSun:new ie(Vt.clouds.maxIterationCountToSun),maxIterationCountToGround:new ie(Vt.clouds.maxIterationCountToGround),minSecondaryStepSize:new ie(Vt.clouds.minSecondaryStepSize),secondaryStepScale:new ie(Vt.clouds.secondaryStepScale),shadowBuffer:new ie(null),shadowTexelSize:new ie(new Ee),shadowIntervals:new ie(Array.from({length:4},()=>new Ee)),shadowMatrices:new ie(Array.from({length:4},()=>new lt)),shadowFar:new ie(0),maxShadowFilterRadius:new ie(6),shadowLayerMask:new ie(new Yt().setScalar(1)),maxShadowLengthIterationCount:new ie(Vt.clouds.maxShadowLengthIterationCount),minShadowLengthStepSize:new ie(Vt.clouds.minShadowLengthStepSize),maxShadowLengthRayDistance:new ie(Vt.clouds.maxShadowLengthRayDistance),hazeDensityScale:new ie(3e-5),hazeExponent:new ie(.001),hazeScatteringCoefficient:new ie(.9),hazeAbsorptionCoefficient:new ie(.5)}},a),this.temporalUpscale=!0,this.depthPacking=0,this.localWeatherChannels="rgba",this.shapeDetail=Vt.shapeDetail,this.turbulence=Vt.turbulence,this.shadowLength=Vt.lightShafts,this.haze=Vt.haze,this.multiScatteringOctaves=Vt.clouds.multiScatteringOctaves,this.accurateSunSkyLight=Vt.clouds.accurateSunSkyLight,this.accuratePhaseFunction=Vt.clouds.accuratePhaseFunction,this.shadowCascadeCount=Vt.shadow.cascadeCount,this.shadowSampleCount=8,this.scatterAnisotropy1=.7,this.scatterAnisotropy2=-.2,this.scatterAnisotropyMix=.5}onBeforeRender(e,t,i,a,r,s){const o=this.defines.USE_LOGARITHMIC_DEPTH_BUFFER!=null,c=e.capabilities.logarithmicDepthBuffer;c!==o&&(c?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,a=this.previousViewMatrix??e.matrixWorldInverse,r=t.inverseProjectionMatrix.value,s=t.inverseViewMatrix.value,o=t.reprojectionMatrix.value,c=t.viewReprojectionMatrix.value;if(this.temporalUpscale){const d=t.frame.value%16,m=t.resolution.value,g=c9[d],y=(g.x-.5)/m.x*4,E=(g.y-.5)/m.y*4;t.temporalJitter.value.set(y,E),t.mipLevelScale.value=.25,r.copy(e.projectionMatrix),r.elements[8]+=y*2,r.elements[9]+=E*2,r.invert(),o.copy(i),o.elements[8]+=y*2,o.elements[9]+=E*2,o.multiply(a),c.copy(o).multiply(s)}else t.temporalJitter.value.setScalar(0),t.mipLevelScale.value=1,r.copy(e.projectionMatrixInverse),o.copy(i).multiply(a),c.copy(o).multiply(s);t.cameraNear.value=e.near,t.cameraFar.value=e.far;const h=e.getWorldPosition(t.cameraPosition.value),f=Pee.copy(h).applyMatrix4(t.worldToECEFMatrix.value);try{t.cameraHeight.value=Fee.setFromECEF(f).height}catch{}}copyReprojectionMatrix(e){this.previousProjectionMatrix??(this.previousProjectionMatrix=new lt),this.previousViewMatrix??(this.previousViewMatrix=new lt),this.previousProjectionMatrix.copy(e.projectionMatrix),this.previousViewMatrix.copy(e.matrixWorldInverse)}setSize(e,t,i,a){this.uniforms.resolution.value.set(e,t),i!=null&&a!=null?this.uniforms.targetUvScale.value.set(e/i,t/a):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}};ir([hh("DEPTH_PACKING")],Ga.prototype,"depthPacking");ir([m6("LOCAL_WEATHER_CHANNELS",{validate:n=>/^[rgba]{4}$/.test(n)})],Ga.prototype,"localWeatherChannels");ir([An("SHAPE_DETAIL")],Ga.prototype,"shapeDetail");ir([An("TURBULENCE")],Ga.prototype,"turbulence");ir([An("SHADOW_LENGTH")],Ga.prototype,"shadowLength");ir([An("HAZE")],Ga.prototype,"haze");ir([hh("MULTI_SCATTERING_OCTAVES",{min:1,max:12})],Ga.prototype,"multiScatteringOctaves");ir([An("ACCURATE_SUN_SKY_LIGHT")],Ga.prototype,"accurateSunSkyLight");ir([An("ACCURATE_PHASE_FUNCTION")],Ga.prototype,"accuratePhaseFunction");ir([hh("SHADOW_CASCADE_COUNT",{min:1,max:4})],Ga.prototype,"shadowCascadeCount");ir([hh("SHADOW_SAMPLE_COUNT",{min:1,max:16})],Ga.prototype,"shadowSampleCount");ir([Ub("SCATTER_ANISOTROPY_1")],Ga.prototype,"scatterAnisotropy1");ir([Ub("SCATTER_ANISOTROPY_2")],Ga.prototype,"scatterAnisotropy2");ir([Ub("SCATTER_ANISOTROPY_MIX")],Ga.prototype,"scatterAnisotropyMix");const Hee=`// 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;
}
`,zee=`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
}
`,Gee=`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);
}
`,f9=`#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 Vee=Object.defineProperty,d9=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&Vee(e,t,a),a};class $b extends cl{constructor({colorBuffer:e=null,depthVelocityBuffer:t=null,shadowLengthBuffer:i=null,colorHistoryBuffer:a=null,shadowLengthHistoryBuffer:r=null}={}){super({name:"CloudsResolveMaterial",glslVersion:cs,vertexShader:Gee,fragmentShader:V0(ki(zee,{core:{turbo:S6},catmullRomSampling:Hee,varianceClipping:f9})),uniforms:{colorBuffer:new ie(e),depthVelocityBuffer:new ie(t),shadowLengthBuffer:new ie(i),colorHistoryBuffer:new ie(a),shadowLengthHistoryBuffer:new ie(r),texelSize:new ie(new Ee),frame:new ie(0),jitterOffset:new ie(new Ee),varianceGamma:new ie(2),temporalAlpha:new ie(.1)}}),this.temporalUpscale=!0,this.shadowLength=!0}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}onBeforeRender(e,t,i,a,r,s){const o=this.uniforms.frame.value%16,c=c9[o],h=(c.x-.5)*4,f=(c.y-.5)*4;this.uniforms.jitterOffset.value.set(h,f)}}d9([An("TEMPORAL_UPSCALE")],$b.prototype,"temporalUpscale");d9([An("SHADOW_LENGTH")],$b.prototype,"shadowLength");class p9 extends Ha{constructor(e,t){super(e),this._mainCamera=new so;const{shadow:i}=t;this.shadow=i}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e}}function w2(n,{depthVelocity:e,shadowLength:t}){const i=new oi(1,1,{depthBuffer:!1,type:sn});i.texture.minFilter=Bt,i.texture.magFilter=Bt,i.texture.name=n;let a;e&&(a=i.texture.clone(),a.isRenderTargetTexture=!0,i.depthVelocity=a,i.textures.push(a));let r;return t&&(r=i.texture.clone(),r.isRenderTargetTexture=!0,r.format=Ar,i.shadowLength=r,i.textures.push(r)),Object.assign(i,{depthVelocity:a??null,shadowLength:r??null})}class kee extends p9{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i,...a},r){super("CloudsPass",a),this.atmosphere=r,this.width=0,this.height=0,this.currentMaterial=new Ga({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i},r),this.currentPass=new qE(this.currentMaterial),this.resolveMaterial=new $b,this.resolvePass=new qE(this.resolveMaterial),this.initRenderTargets({depthVelocity:!0,shadowLength:Vt.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,c;(s=this.currentRenderTarget)==null||s.dispose(),(o=this.resolveRenderTarget)==null||o.dispose(),(c=this.historyRenderTarget)==null||c.dispose();const t=w2("Clouds",e),i=w2("Clouds.A",{...e,depthVelocity:!1}),a=w2("Clouds.B",{...e,depthVelocity:!1});this.currentRenderTarget=t,this.resolveRenderTarget=i,this.historyRenderTarget=a;const r=this.resolveMaterial.uniforms;r.colorBuffer.value=t.texture,r.depthVelocityBuffer.value=t.depthVelocity,r.shadowLengthBuffer.value=t.shadowLength,r.colorHistoryBuffer.value=a.texture,r.shadowLengthHistoryBuffer.value=a.shadowLength}copyShadow(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let i=0;i<e.cascadeCount;++i){const a=e.cascades[i];t.shadowIntervals.value[i].copy(a.interval),t.shadowMatrices.value[i].copy(a.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),a=Math.ceil(t/4);this.currentRenderTarget.setSize(i,a),this.currentMaterial.setSize(i*4,a*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 Xee(n,e){const t=n.properties.get(e.texture).__webglTexture,i=n.getContext();$l(i instanceof WebGL2RenderingContext),n.setRenderTarget(e);const a=[];if(t!=null)for(let r=0;r<e.depth;++r)i.framebufferTextureLayer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+r,t,0,r),a.push(i.COLOR_ATTACHMENT0+r);i.drawBuffers(a)}class vN extends qE{render(e,t,i,a,r){const s=this.fullscreenMaterial.uniforms;t!==null&&(s==null?void 0:s[this.input])!=null&&(s[this.input].value=t.texture),Xee(e,i),e.render(this.scene,this.camera)}}const Wee=`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
}
`,Yee=`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);
}
`,qee=`// 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 Zee=Object.defineProperty,jd=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&Zee(e,t,a),a};class ph extends cl{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i}){super({name:"ShadowMaterial",glslVersion:cs,vertexShader:Yee,fragmentShader:V0(ki(Wee,{core:{math:fh,raySphereIntersection:Jy},types:CT,parameters:h9,structuredSampling:qee,clouds:u9})),uniforms:{...e,...t,...i,inverseShadowMatrices:new ie(Array.from({length:4},()=>new lt)),reprojectionMatrices:new ie(Array.from({length:4},()=>new lt)),resolution:new ie(new Ee),frame:new ie(0),stbnTexture:new ie(null),maxIterationCount:new ie(Vt.shadow.maxIterationCount),minStepSize:new ie(Vt.shadow.minStepSize),maxStepSize:new ie(Vt.shadow.maxStepSize),minDensity:new ie(Vt.shadow.minDensity),minExtinction:new ie(Vt.shadow.minExtinction),minTransmittance:new ie(Vt.shadow.minTransmittance),opticalDepthTailScale:new ie(2)},defines:{SHADOW:"1",TEMPORAL_PASS:"1",TEMPORAL_JITTER:"1"}}),this.localWeatherChannels="rgba",this.cascadeCount=Vt.shadow.cascadeCount,this.temporalPass=!0,this.temporalJitter=!0,this.shapeDetail=Vt.shapeDetail,this.turbulence=Vt.turbulence,this.cascadeCount=Vt.shadow.cascadeCount}setSize(e,t){this.uniforms.resolution.value.set(e,t)}}jd([m6("LOCAL_WEATHER_CHANNELS",{validate:n=>/^[rgba]{4}$/.test(n)})],ph.prototype,"localWeatherChannels");jd([hh("CASCADE_COUNT",{min:1,max:4})],ph.prototype,"cascadeCount");jd([An("TEMPORAL_PASS")],ph.prototype,"temporalPass");jd([An("TEMPORAL_JITTER")],ph.prototype,"temporalJitter");jd([An("SHAPE_DETAIL")],ph.prototype,"shapeDetail");jd([An("TURBULENCE")],ph.prototype,"turbulence");const jee=`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
}
`,Kee=`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 Jee=Object.defineProperty,Qee=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&Jee(e,t,a),a};class m9 extends cl{constructor({inputBuffer:e=null,historyBuffer:t=null}={}){super({name:"ShadowResolveMaterial",glslVersion:cs,vertexShader:Kee,fragmentShader:V0(ki(jee,{varianceClipping:f9})),uniforms:{inputBuffer:new ie(e),historyBuffer:new ie(t),texelSize:new ie(new Ee),varianceGamma:new ie(1),temporalAlpha:new ie(.01)},defines:{}}),this.cascadeCount=Vt.shadow.cascadeCount}setSize(e,t){this.uniforms.texelSize.value.set(1/e,1/t)}}Qee([hh("CASCADE_COUNT",{min:1,max:4})],m9.prototype,"cascadeCount");function D2(n){const e=new aB(1,1,1,{depthBuffer:!1});return e.texture.type=sn,e.texture.minFilter=Bt,e.texture.magFilter=Bt,e.texture.name=n,e}class $ee extends p9{constructor({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i,...a}){super("ShadowPass",a),this.width=0,this.height=0,this.currentMaterial=new ph({parameterUniforms:e,layerUniforms:t,atmosphereUniforms:i}),this.currentPass=new vN(this.currentMaterial),this.resolveMaterial=new m9,this.resolvePass=new vN(this.resolveMaterial),this.initRenderTargets()}initialize(e,t,i){this.currentPass.initialize(e,t,i),this.resolvePass.initialize(e,t,i)}initRenderTargets(){var r,s,o;(r=this.currentRenderTarget)==null||r.dispose(),(s=this.resolveRenderTarget)==null||s.dispose(),(o=this.historyRenderTarget)==null||o.dispose();const e=D2("Shadow"),t=this.temporalPass?D2("Shadow.A"):null,i=this.temporalPass?D2("Shadow.B"):null;this.currentRenderTarget=e,this.resolveRenderTarget=t,this.historyRenderTarget=i;const a=this.resolveMaterial.uniforms;a.inputBuffer.value=e.texture,a.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 a=e.cascades[i];t.inverseShadowMatrices.value[i].copy(a.inverseMatrix)}}copyReprojection(){const e=this.shadow,t=this.currentMaterial.uniforms;for(let i=0;i<e.cascadeCount;++i){const a=e.cascades[i];t.reprojectionMatrices.value[i].copy(a.matrix)}}swapBuffers(){$l(this.historyRenderTarget!=null),$l(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&&($l(this.resolveRenderTarget!=null),this.resolvePass.render(e,null,this.resolveRenderTarget),this.copyReprojection(),this.swapBuffers())}setSize(e,t,i=this.shadow.cascadeCount){var a,r;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),(a=this.resolveRenderTarget)==null||a.setSize(e,t,i),(r=this.historyRenderTarget)==null||r.setSize(e,t,i)}get outputBuffer(){return this.temporalPass?($l(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 ete(n){return{scatteringCoefficient:new ie(1),absorptionCoefficient:new ie(0),coverage:new ie(.3),localWeatherTexture:new ie(n.localWeatherTexture),localWeatherRepeat:new ie(n.localWeatherRepeat),localWeatherOffset:new ie(n.localWeatherOffset),shapeTexture:new ie(n.shapeTexture),shapeRepeat:new ie(n.shapeRepeat),shapeOffset:new ie(n.shapeOffset),shapeDetailTexture:new ie(n.shapeDetailTexture),shapeDetailRepeat:new ie(n.shapeDetailRepeat),shapeDetailOffset:new ie(n.shapeDetailOffset),turbulenceTexture:new ie(n.turbulenceTexture),turbulenceRepeat:new ie(n.turbulenceRepeat),turbulenceDisplacement:new ie(350)}}function tte(){return{minLayerHeights:new ie(new Yt),maxLayerHeights:new ie(new Yt),minIntervalHeights:new ie(new H),maxIntervalHeights:new ie(new H),densityScales:new ie(new Yt),shapeAmounts:new ie(new Yt),shapeDetailAmounts:new ie(new Yt),weatherExponents:new ie(new Yt),shapeAlteringBiases:new ie(new Yt),coverageFilterWidths:new ie(new Yt),minHeight:new ie(0),maxHeight:new ie(0),shadowTopHeight:new ie(0),shadowBottomHeight:new ie(0),shadowLayerMask:new ie(new Yt),densityProfile:new ie({expTerms:new Yt,exponents:new Yt,linearTerms:new Yt,constantTerms:new Yt})}}const N2=[0,0,0,0];function nte(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,a=0,r=1/0,s=0;N2.fill(0);for(let o=0;o<e.length;++o){const{altitude:c,height:h,shadow:f}=e[o],d=c+h;h>0&&(c<i&&(i=c),f&&c<r&&(r=c),d>a&&(a=d),f&&d>s&&(s=d)),N2[o]=f?1:0}i!==1/0?(n.minHeight.value=i,n.maxHeight.value=a):($l(a===0),n.minHeight.value=0),r!==1/0?(n.shadowBottomHeight.value=r,n.shadowTopHeight.value=s):($l(s===0),n.shadowBottomHeight.value=0),n.shadowLayerMask.value.fromArray(N2)}function ite(n,e){return{bottomRadius:new ie(n.bottomRadius),topRadius:new ie(n.topRadius),worldToECEFMatrix:new ie(e.worldToECEFMatrix),ecefToWorldMatrix:new ie(e.ecefToWorldMatrix),altitudeCorrection:new ie(e.altitudeCorrection),sunDirection:new ie(e.sunDirection)}}const ate=`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 rte=Object.defineProperty,ste=(n,e,t,i)=>{for(var a=void 0,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=s(e,t,a)||a);return a&&rte(e,t,a),a};const qp=new H,ote=new Ee,lte=new kt,cte=["maxIterationCount","minStepSize","maxStepSize","maxRayDistance","perspectiveStepScale","minDensity","minExtinction","minTransmittance","maxIterationCountToSun","maxIterationCountToGround","minSecondaryStepSize","secondaryStepScale","maxShadowFilterRadius","maxShadowLengthIterationCount","minShadowLengthStepSize","maxShadowLengthRayDistance","hazeDensityScale","hazeExponent","hazeScatteringCoefficient","hazeAbsorptionCoefficient"],ute=["multiScatteringOctaves","accurateSunSkyLight","accuratePhaseFunction"],hte=["maxIterationCount","minStepSize","maxStepSize","minDensity","minExtinction","minTransmittance","opticalDepthTailScale"],fte=["temporalJitter"],dte=["temporalPass"],pte=["cascadeCount","mapSize","maxFar","farScale","splitMode","splitLambda"],Do={type:"change"},g9={resolutionScale:Vt.resolutionScale,width:as.AUTO_SIZE,height:as.AUTO_SIZE};class v9 extends h0{constructor(e=new so,t,i=k0.DEFAULT){var f,d,m,g;super("CloudsEffect",ate,{attributes:Qo.DEPTH,uniforms:new Map([["cloudsBuffer",new ie(null)]])}),this.camera=e,this.atmosphere=i,this.cloudLayers=o9.DEFAULT.clone(),this.correctAltitude=!0,this.localWeatherRepeat=new Ee().setScalar(100),this.localWeatherOffset=new Ee,this.shapeRepeat=new H().setScalar(3e-4),this.shapeOffset=new H,this.shapeDetailRepeat=new H().setScalar(.006),this.shapeDetailOffset=new H,this.turbulenceRepeat=new Ee().setScalar(20),this.worldToECEFMatrix=new lt,this.ecefToWorldMatrix=new lt,this.altitudeCorrection=new H,this.sunDirection=new H,this.localWeatherVelocity=new Ee,this.shapeVelocity=new H,this.shapeDetailVelocity=new H,this._atmosphereOverlay=null,this._atmosphereShadow=null,this._atmosphereShadowLength=null,this.events=new tr,this.frame=0,this.shadowCascadeCount=0,this.shadowMapSize=new Ee,this.onResolutionChange=()=>{this.setSize(this.resolution.baseWidth,this.resolution.baseHeight)},this.skipRendering=!0;const{resolutionScale:a,width:r,height:s,resolutionX:o=r,resolutionY:c=s}={...g9,...t};this.shadowMaps=new Nee({cascadeCount:Vt.shadow.cascadeCount,mapSize:Vt.shadow.mapSize,splitLambda:.6}),this.parameterUniforms=ete({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:((m=this.proceduralShapeDetail)==null?void 0:m.texture)??null,shapeDetailRepeat:this.shapeDetailRepeat,shapeDetailOffset:this.shapeDetailOffset,turbulenceTexture:((g=this.proceduralTurbulence)==null?void 0:g.texture)??null,turbulenceRepeat:this.turbulenceRepeat}),this.layerUniforms=tte(),this.atmosphereUniforms=ite(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 $ee(h),this.shadowPass.mainCamera=e,this.cloudsPass=new kee(h,i),this.cloudsPass.mainCamera=e,this.clouds=zD(GD({},this.cloudsPass.currentMaterial,cte),this.cloudsPass.currentMaterial,ute),this.shadow=zD(GD({},this.shadowPass.currentMaterial,hte),this.shadowPass.currentMaterial,fte,this.shadowPass,dte,this.shadowMaps,pte),this.resolution=new as(this,o,c,a),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){nte(this.layerUniforms,this.cloudLayers);const{parameterUniforms:t}=this;t.localWeatherOffset.value.add(ote.copy(this.localWeatherVelocity).multiplyScalar(e)),t.shapeOffset.value.add(qp.copy(this.shapeVelocity).multiplyScalar(e)),t.shapeDetailOffset.value.add(qp.copy(this.shapeDetailVelocity).multiplyScalar(e));const i=this.worldToECEFMatrix;this.ecefToWorldMatrix.copy(i).invert();const a=this.camera.getWorldPosition(qp).applyMatrix4(this.worldToECEFMatrix),r=this.altitudeCorrection;this.correctAltitude?Lb(a,this.atmosphere.bottomRadius,this.ellipsoid,r):r.setScalar(0);const s=this.ellipsoid.getSurfaceNormal(a,qp),o=this.sunDirection.dot(s),c=p6(1e6,1e3,o),h=lte.setFromMatrix4(i).transpose();this.shadowMaps.update(this.camera,qp.copy(this.sunDirection).applyMatrix3(h),c)}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,a=t.currentMaterial.uniforms,r=i.currentMaterial.uniforms,s=this._atmosphereOverlay,o=Object.assign(this._atmosphereOverlay??{},{map:i.outputBuffer});s!==o&&(this._atmosphereOverlay=o,Do.target=this,Do.property="atmosphereOverlay",this.events.dispatchEvent(Do));const c=this._atmosphereShadow,h=Object.assign(this._atmosphereShadow??{},{map:t.outputBuffer,mapSize:e.mapSize,cascadeCount:e.cascadeCount,intervals:r.shadowIntervals.value,matrices:r.shadowMatrices.value,inverseMatrices:a.inverseShadowMatrices.value,far:e.far,topHeight:r.shadowTopHeight.value});c!==h&&(this._atmosphereShadow=h,Do.target=this,Do.property="atmosphereShadow",this.events.dispatchEvent(Do));const f=this._atmosphereShadowLength,d=i.shadowLengthBuffer!=null?Object.assign(this._atmosphereShadowLength??{},{map:i.shadowLengthBuffer}):null;f!==d&&(this._atmosphereShadowLength=d,Do.target=this,Do.property="atmosphereShadowLength",this.events.dispatchEvent(Do))}update(e,t,i=0){var o,c,h,f;const{shadowMaps:a,shadowPass:r,cloudsPass:s}=this;if(a.cascadeCount!==this.shadowCascadeCount||!a.mapSize.equals(this.shadowMapSize)){const{width:d,height:m}=a.mapSize,g=a.cascadeCount;this.shadowMapSize.set(d,m),this.shadowCascadeCount=g,r.setSize(d,m,g),s.setShadowSize(d,m,g)}(o=this.proceduralLocalWeather)==null||o.render(e,i),(c=this.proceduralShape)==null||c.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(),r.update(e,this.frame,i),s.shadowBuffer=r.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:a,height:r}=i;this.cloudsPass.setSize(a,r)}setDepthTexture(e,t){this.shadowPass.setDepthTexture(e,t),this.cloudsPass.setDepthTexture(e,t)}set qualityPreset(e){const{clouds:t,shadow:i,...a}=Iee[e];Object.assign(this,a),Object.assign(this.clouds,t),Object.assign(this.shadow,i)}get localWeatherTexture(){return this.proceduralLocalWeather??this.parameterUniforms.localWeatherTexture.value}set localWeatherTexture(e){e instanceof vn||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 is||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 is||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 vn||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}}ste([An("SKIP_RENDERING")],v9.prototype,"skipRendering");const x9=128,y9=32,l_="45a1c6c1bb9fd38b3680fd120795ff4c32df68ff",mte=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${l_}/packages/clouds/assets/local_weather.png`,gte=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${l_}/packages/clouds/assets/shape.bin`,vte=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${l_}/packages/clouds/assets/shape_detail.bin`,xte=`https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${l_}/packages/clouds/assets/turbulence.png`,yte=he.createContext(null),_te=({layers:n,disableDefault:e=!1,children:t})=>{const[i,a]=he.useState();return he.useLayoutEffect(()=>{n.set(e?Array(4).fill(Bo.DEFAULT):o9.DEFAULT),a({layers:n,indexPool:[0,1,2,3],disableDefault:e})},[n,e]),i!=null&&It.jsx(yte.Provider,{value:i,children:t})};function xN(n,e){const t=he.useMemo(()=>typeof n=="string"?new rb().load(n,i=>{i.minFilter=e0,i.magFilter=Bt,i.wrapS=wi,i.wrapT=wi,i.colorSpace=pa,i.needsUpdate=!0}):void 0,[n]);return he.useEffect(()=>{if(t!=null)return()=>{t.dispose()}},[t]),(typeof n=="string"?t:n)??null}function yN(n,e){const t=he.useMemo(()=>typeof n=="string"?new du(is,g6,{width:e,height:e,depth:e,format:Ar,minFilter:Bt,magFilter:Bt,wrapS:wi,wrapT:wi,wrapR:wi,colorSpace:pa}).load(n):void 0,[n,e]);return he.useEffect(()=>{if(t!=null)return()=>{t.dispose()}},[t]),(typeof n=="string"?t:n)??null}function Ste(n){const e=he.useMemo(()=>typeof n=="string"?new v6().load(n):void 0,[n]);return he.useEffect(()=>{if(e!=null)return()=>{e.dispose()}},[e]),(typeof n=="string"?e:n)??null}const Ate=({ref:n,disableDefaultLayers:e=!1,localWeatherTexture:t=mte,shapeTexture:i=gte,shapeDetailTexture:a=vte,turbulenceTexture:r=xte,stbnTexture:s=W8,children:o,...c})=>{const{textures:h,transientStates:f,...d}=he.useContext(q0),[m,g]=s_({...g9,...d,...h,...c}),y=he.useMemo(()=>new v9,[]);he.useEffect(()=>()=>{y.dispose()},[y]),Ls(()=>{f!=null&&(y.sunDirection.copy(f.sunDirection),y.worldToECEFMatrix.copy(f.worldToECEFMatrix))}),he.useEffect(()=>{if(f!=null)return f.overlay=y.atmosphereOverlay,f.shadow=y.atmosphereShadow,f.shadowLength=y.atmosphereShadowLength,()=>{f.overlay=null,f.shadow=null,f.shadowLength=null}},[y,f]);const E=he.useCallback(N=>{if(f!=null)switch(N.property){case"atmosphereOverlay":f.overlay=y.atmosphereOverlay;break;case"atmosphereShadow":f.shadow=y.atmosphereShadow;break;case"atmosphereShadowLength":f.shadowLength=y.atmosphereShadowLength;break}},[y,f]);he.useEffect(()=>(y.events.addEventListener("change",E),()=>{y.events.removeEventListener("change",E)}),[y,E]),jn(({gl:N})=>N);const S=xN(t),v=yN(i,x9),_=yN(a,y9),A=xN(r),b=Ste(s),{camera:O}=he.useContext(bb);return It.jsxs(It.Fragment,{children:[It.jsx("primitive",{ref:n,object:y,mainCamera:O,...m,localWeatherTexture:S,shapeTexture:v,shapeDetailTexture:_,turbulenceTexture:A,stbnTexture:b,...g}),It.jsx(_te,{layers:y.cloudLayers,disableDefault:e,children:o})]})};class _9{constructor({size:e,fragmentShader:t}){this.needsRender=!0,this.camera=new so,this.size=e,this.material=new cl({glslVersion:cs,vertexShader:`
in vec3 position;
out vec2 vUv;
void main() {
vUv = position.xy * 0.5 + 0.5;
gl_Position = vec4(position.xy, 0.0, 1.0);
}
`,fragmentShader:t,uniforms:{layer:new ie(0)}}),this.mesh=new Xn(new Us(2,2),this.material),this.renderTarget=new P3(e,e,e,{depthBuffer:!1,format:Ar});const i=this.renderTarget.texture;i.minFilter=Bt,i.magFilter=Bt,i.wrapS=wi,i.wrapT=wi,i.wrapR=wi,i.colorSpace=pa,i.needsUpdate=!0}dispose(){this.renderTarget.dispose(),this.material.dispose()}render(e,t){if(this.needsRender){this.needsRender=!1;for(let i=0;i<this.size;++i)this.material.uniforms.layer.value=i/this.size,e.setRenderTarget(this.renderTarget,i),e.render(this.mesh,this.camera);e.setRenderTarget(null)}}get texture(){return this.renderTarget.texture}}const Ete=`// Based on the following work with slight modifications.
// https://github.com/sebh/TileableVolumeNoise
/**
* The MIT License (MIT)
*
* Copyright(c) 2017 Sébastien Hillaire
*
* 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.
*/
precision highp float;
precision highp int;
#include "core/math"
#include "perlin"
#include "tileableNoise"
uniform float layer;
in vec2 vUv;
layout(location = 0) out float outputColor;
float getPerlinWorley(const vec3 point) {
int octaveCount = 3;
float frequency = 8.0;
float perlin = getPerlinNoise(point, frequency, octaveCount);
perlin = clamp(perlin, 0.0, 1.0);
float cellCount = 4.0;
vec3 noise = vec3(
1.0 - getWorleyNoise(point, cellCount * 2.0),
1.0 - getWorleyNoise(point, cellCount * 8.0),
1.0 - getWorleyNoise(point, cellCount * 14.0)
);
float fbm = dot(noise, vec3(0.625, 0.25, 0.125));
return remap(perlin, 0.0, 1.0, fbm, 1.0);
}
float getWorleyFbm(const vec3 point) {
float cellCount = 4.0;
vec4 noise = vec4(
1.0 - getWorleyNoise(point, cellCount * 2.0),
1.0 - getWorleyNoise(point, cellCount * 4.0),
1.0 - getWorleyNoise(point, cellCount * 8.0),
1.0 - getWorleyNoise(point, cellCount * 16.0)
);
vec3 fbm = vec3(
dot(noise.xyz, vec3(0.625, 0.25, 0.125)),
dot(noise.yzw, vec3(0.625, 0.25, 0.125)),
dot(noise.zw, vec2(0.75, 0.25))
);
return dot(fbm, vec3(0.625, 0.25, 0.125));
}
void main() {
vec3 point = vec3(vUv.x, vUv.y, layer);
float perlinWorley = getPerlinWorley(point);
float worleyFbm = getWorleyFbm(point);
outputColor = remap(perlinWorley, worleyFbm - 1.0, 1.0);
}
`,c_=`// Ported from GLM: https://github.com/g-truc/glm/blob/master/glm/gtc/noise.inl
/**
* OpenGL Mathematics (GLM)
*
* GLM is licensed under The Happy Bunny License or MIT License
*
* The Happy Bunny License (Modified MIT License)
*
* Copyright (c) 2005 - G-Truc Creation
*
* 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.
*
* Restrictions:
* By making use of the Software for military purposes, you choose to make a
* Bunny unhappy.
*
* 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.
*
* The MIT License
*
* Copyright (c) 2005 - G-Truc Creation
*
* 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 mod289(const vec4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(const vec4 v) {
return mod289((v * 34.0 + 1.0) * v);
}
vec4 taylorInvSqrt(const vec4 r) {
return 1.79284291400159 - 0.85373472095314 * r;
}
vec4 fade(const vec4 v) {
return v * v * v * (v * (v * 6.0 - 15.0) + 10.0);
}
// Classic Perlin noise, periodic version
float perlin(const vec4 position, const vec4 rep) {
vec4 Pi0 = mod(floor(position), rep); // Integer part modulo rep
vec4 Pi1 = mod(Pi0 + 1.0, rep); // Integer part + 1 mod rep
vec4 Pf0 = fract(position); // Fractional part for interpolation
vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
vec4 iy = vec4(Pi0.y, Pi0.y, Pi1.y, Pi1.y);
vec4 iz0 = vec4(Pi0.z);
vec4 iz1 = vec4(Pi1.z);
vec4 iw0 = vec4(Pi0.w);
vec4 iw1 = vec4(Pi1.w);
vec4 ixy = permute(permute(ix) + iy);
vec4 ixy0 = permute(ixy + iz0);
vec4 ixy1 = permute(ixy + iz1);
vec4 ixy00 = permute(ixy0 + iw0);
vec4 ixy01 = permute(ixy0 + iw1);
vec4 ixy10 = permute(ixy1 + iw0);
vec4 ixy11 = permute(ixy1 + iw1);
vec4 gx00 = ixy00 / 7.0;
vec4 gy00 = floor(gx00) / 7.0;
vec4 gz00 = floor(gy00) / 6.0;
gx00 = fract(gx00) - 0.5;
gy00 = fract(gy00) - 0.5;
gz00 = fract(gz00) - 0.5;
vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00);
vec4 sw00 = step(gw00, vec4(0));
gx00 -= sw00 * (step(0.0, gx00) - 0.5);
gy00 -= sw00 * (step(0.0, gy00) - 0.5);
vec4 gx01 = ixy01 / 7.0;
vec4 gy01 = floor(gx01) / 7.0;
vec4 gz01 = floor(gy01) / 6.0;
gx01 = fract(gx01) - 0.5;
gy01 = fract(gy01) - 0.5;
gz01 = fract(gz01) - 0.5;
vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01);
vec4 sw01 = step(gw01, vec4(0.0));
gx01 -= sw01 * (step(0.0, gx01) - 0.5);
gy01 -= sw01 * (step(0.0, gy01) - 0.5);
vec4 gx10 = ixy10 / 7.0;
vec4 gy10 = floor(gx10) / 7.0;
vec4 gz10 = floor(gy10) / 6.0;
gx10 = fract(gx10) - 0.5;
gy10 = fract(gy10) - 0.5;
gz10 = fract(gz10) - 0.5;
vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10);
vec4 sw10 = step(gw10, vec4(0.0));
gx10 -= sw10 * (step(0.0, gx10) - 0.5);
gy10 -= sw10 * (step(0.0, gy10) - 0.5);
vec4 gx11 = ixy11 / 7.0;
vec4 gy11 = floor(gx11) / 7.0;
vec4 gz11 = floor(gy11) / 6.0;
gx11 = fract(gx11) - 0.5;
gy11 = fract(gy11) - 0.5;
gz11 = fract(gz11) - 0.5;
vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11);
vec4 sw11 = step(gw11, vec4(0.0));
gx11 -= sw11 * (step(0.0, gx11) - 0.5);
gy11 -= sw11 * (step(0.0, gy11) - 0.5);
vec4 g0000 = vec4(gx00.x, gy00.x, gz00.x, gw00.x);
vec4 g1000 = vec4(gx00.y, gy00.y, gz00.y, gw00.y);
vec4 g0100 = vec4(gx00.z, gy00.z, gz00.z, gw00.z);
vec4 g1100 = vec4(gx00.w, gy00.w, gz00.w, gw00.w);
vec4 g0010 = vec4(gx10.x, gy10.x, gz10.x, gw10.x);
vec4 g1010 = vec4(gx10.y, gy10.y, gz10.y, gw10.y);
vec4 g0110 = vec4(gx10.z, gy10.z, gz10.z, gw10.z);
vec4 g1110 = vec4(gx10.w, gy10.w, gz10.w, gw10.w);
vec4 g0001 = vec4(gx01.x, gy01.x, gz01.x, gw01.x);
vec4 g1001 = vec4(gx01.y, gy01.y, gz01.y, gw01.y);
vec4 g0101 = vec4(gx01.z, gy01.z, gz01.z, gw01.z);
vec4 g1101 = vec4(gx01.w, gy01.w, gz01.w, gw01.w);
vec4 g0011 = vec4(gx11.x, gy11.x, gz11.x, gw11.x);
vec4 g1011 = vec4(gx11.y, gy11.y, gz11.y, gw11.y);
vec4 g0111 = vec4(gx11.z, gy11.z, gz11.z, gw11.z);
vec4 g1111 = vec4(gx11.w, gy11.w, gz11.w, gw11.w);
vec4 norm00 = taylorInvSqrt(
vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))
);
g0000 *= norm00.x;
g0100 *= norm00.y;
g1000 *= norm00.z;
g1100 *= norm00.w;
vec4 norm01 = taylorInvSqrt(
vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))
);
g0001 *= norm01.x;
g0101 *= norm01.y;
g1001 *= norm01.z;
g1101 *= norm01.w;
vec4 norm10 = taylorInvSqrt(
vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))
);
g0010 *= norm10.x;
g0110 *= norm10.y;
g1010 *= norm10.z;
g1110 *= norm10.w;
vec4 norm11 = taylorInvSqrt(
vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))
);
g0011 *= norm11.x;
g0111 *= norm11.y;
g1011 *= norm11.z;
g1111 *= norm11.w;
float n0000 = dot(g0000, Pf0);
float n1000 = dot(g1000, vec4(Pf1.x, Pf0.y, Pf0.z, Pf0.w));
float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.z, Pf0.w));
float n1100 = dot(g1100, vec4(Pf1.x, Pf1.y, Pf0.z, Pf0.w));
float n0010 = dot(g0010, vec4(Pf0.x, Pf0.y, Pf1.z, Pf0.w));
float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w));
float n0110 = dot(g0110, vec4(Pf0.x, Pf1.y, Pf1.z, Pf0.w));
float n1110 = dot(g1110, vec4(Pf1.x, Pf1.y, Pf1.z, Pf0.w));
float n0001 = dot(g0001, vec4(Pf0.x, Pf0.y, Pf0.z, Pf1.w));
float n1001 = dot(g1001, vec4(Pf1.x, Pf0.y, Pf0.z, Pf1.w));
float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w));
float n1101 = dot(g1101, vec4(Pf1.x, Pf1.y, Pf0.z, Pf1.w));
float n0011 = dot(g0011, vec4(Pf0.x, Pf0.y, Pf1.z, Pf1.w));
float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.z, Pf1.w));
float n0111 = dot(g0111, vec4(Pf0.x, Pf1.y, Pf1.z, Pf1.w));
float n1111 = dot(g1111, Pf1);
vec4 fade_xyzw = fade(Pf0);
vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w);
vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w);
vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z);
vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y);
float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);
return 2.2 * n_xyzw;
}
`,u_=`// Based on the following work with slight modifications.
// https://github.com/sebh/TileableVolumeNoise
/**
* The MIT License (MIT)
*
* Copyright(c) 2017 Sébastien Hillaire
*
* 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.
*/
float hash(const float n) {
return fract(sin(n + 1.951) * 43758.5453);
}
float noise(const vec3 x) {
vec3 p = floor(x);
vec3 f = fract(x);
f = f * f * (3.0 - 2.0 * f);
float n = p.x + p.y * 57.0 + 113.0 * p.z;
return mix(
mix(mix(hash(n + 0.0), hash(n + 1.0), f.x), mix(hash(n + 57.0), hash(n + 58.0), f.x), f.y),
mix(
mix(hash(n + 113.0), hash(n + 114.0), f.x),
mix(hash(n + 170.0), hash(n + 171.0), f.x),
f.y
),
f.z
);
}
float getWorleyNoise(const vec3 p, const float cellCount) {
vec3 cell = p * cellCount;
float d = 1.0e10;
for (int x = -1; x <= 1; ++x) {
for (int y = -1; y <= 1; ++y) {
for (int z = -1; z <= 1; ++z) {
vec3 tp = floor(cell) + vec3(x, y, z);
tp = cell - tp - noise(mod(tp, cellCount / 1.0));
d = min(d, dot(tp, tp));
}
}
}
return clamp(d, 0.0, 1.0);
}
float getPerlinNoise(const vec3 point, const vec3 frequency, const int octaveCount) {
// Noise frequency factor between octave, forced to 2.
const float octaveFrequencyFactor = 2.0;
// Compute the sum for each octave.
float sum = 0.0;
float roughness = 0.5;
float weightSum = 0.0;
float weight = 1.0;
vec3 nextFrequency = frequency;
for (int i = 0; i < octaveCount; ++i) {
vec4 p = vec4(point.x, point.y, point.z, 0.0) * vec4(nextFrequency, 1.0);
float value = perlin(p, vec4(nextFrequency, 1.0));
sum += value * weight;
weightSum += weight;
weight *= roughness;
nextFrequency *= octaveFrequencyFactor;
}
return sum / weightSum; // Intentionally skip clamping.
}
float getPerlinNoise(const vec3 point, const float frequency, const int octaveCount) {
return getPerlinNoise(point, vec3(frequency), octaveCount);
}
`;class Tte extends _9{constructor(){super({size:x9,fragmentShader:ki(Ete,{core:{math:fh},perlin:c_,tileableNoise:u_})})}}const bte=`// Based on the following work with slight modifications.
// https://github.com/sebh/TileableVolumeNoise
/**
* The MIT License (MIT)
*
* Copyright(c) 2017 Sébastien Hillaire
*
* 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.
*/
precision highp float;
precision highp int;
#include "core/math"
#include "perlin"
#include "tileableNoise"
uniform float layer;
in vec2 vUv;
layout(location = 0) out float outputColor;
void main() {
vec3 point = vec3(vUv.x, vUv.y, layer);
float cellCount = 2.0;
vec4 noise = vec4(
1.0 - getWorleyNoise(point, cellCount * 1.0),
1.0 - getWorleyNoise(point, cellCount * 2.0),
1.0 - getWorleyNoise(point, cellCount * 4.0),
1.0 - getWorleyNoise(point, cellCount * 8.0)
);
vec3 fbm = vec3(
dot(noise.xyz, vec3(0.625, 0.25, 0.125)),
dot(noise.yzw, vec3(0.625, 0.25, 0.125)),
dot(noise.zw, vec2(0.75, 0.25))
);
outputColor = dot(fbm, vec3(0.625, 0.25, 0.125));
}
`;class Mte extends _9{constructor(){super({size:y9,fragmentShader:ki(bte,{core:{math:fh},perlin:c_,tileableNoise:u_})})}}class S9{constructor({size:e,fragmentShader:t}){this.needsRender=!0,this.camera=new so,this.size=e,this.material=new cl({glslVersion:cs,vertexShader:`
in vec3 position;
out vec2 vUv;
void main() {
vUv = position.xy * 0.5 + 0.5;
gl_Position = vec4(position.xy, 0.0, 1.0);
}
`,fragmentShader:t,uniforms:{layer:new ie(0)}}),this.mesh=new Xn(new Us(2,2),this.material),this.renderTarget=new oi(e,e,{depthBuffer:!1,format:Rn});const i=this.renderTarget.texture;i.generateMipmaps=!0,i.minFilter=e0,i.magFilter=Bt,i.wrapS=wi,i.wrapT=wi,i.colorSpace=pa,i.needsUpdate=!0}dispose(){this.renderTarget.dispose(),this.material.dispose()}render(e,t){this.needsRender&&(this.needsRender=!1,e.setRenderTarget(this.renderTarget),e.render(this.mesh,this.camera),e.setRenderTarget(null))}get texture(){return this.renderTarget.texture}}const Cte=`precision highp float;
precision highp int;
#include "core/math"
#include "perlin"
#include "tileableNoise"
in vec2 vUv;
layout(location = 0) out vec4 outputColor;
float getWorleyFbm(
const vec3 point,
float frequency,
float amplitude,
const float lacunarity,
const float gain,
const int octaveCount
) {
float noise = 0.0;
for (int i = 0; i < octaveCount; ++i) {
noise += amplitude * (1.0 - getWorleyNoise(point, frequency));
frequency *= lacunarity;
amplitude *= gain;
}
return noise;
}
void main() {
vec3 point = vec3(vUv.x, vUv.y, 0.0);
// Mid clouds
{
float worley = getWorleyFbm(
point + vec3(0.5),
8.0, // frequency
0.4, // amplitude
2.0, // lacunarity
0.95, // gain
4 // octaveCount
);
worley = smoothstep(1.0, 1.4, worley);
outputColor.g = worley;
}
// Low clouds
{
float worley = getWorleyFbm(
point,
16.0, // frequency
0.4, // amplitude
2.0, // lacunarity
0.95, // gain
4 // octaveCount
);
worley = smoothstep(0.8, 1.4, worley);
outputColor.r = saturate(worley - outputColor.g);
}
// High clouds
{
float perlin = getPerlinNoise(
point,
vec3(6.0, 12.0, 1.0), // frequency
8 // octaveCount
);
perlin = smoothstep(-0.5, 0.5, perlin);
outputColor.b = perlin;
}
// Extra
{
float perlin = getPerlinNoise(
point + vec3(-19.1, 33.4, 47.2),
32.0, // frequency
4 // octaveCount
);
perlin = smoothstep(-0.5, 0.5, perlin);
outputColor.a = perlin;
}
outputColor.a = 1.0;
}
`;class Rte extends S9{constructor(){super({size:512,fragmentShader:ki(Cte,{core:{math:fh},perlin:c_,tileableNoise:u_})})}}const wte=`precision highp float;
precision highp int;
#include "core/math"
#include "perlin"
#include "tileableNoise"
in vec2 vUv;
layout(location = 0) out vec4 outputColor;
const vec3 frequency = vec3(12.0);
const int octaveCount = 3;
float perlin(const vec3 point) {
return getPerlinNoise(point, frequency, octaveCount);
}
vec3 perlin3d(const vec3 point) {
float perlin1 = perlin(point);
float perlin2 = perlin(point.yzx + vec3(-19.1, 33.4, 47.2));
float perlin3 = perlin(point.zxy + vec3(74.2, -124.5, 99.4));
return vec3(perlin1, perlin2, perlin3);
}
vec3 curl(vec3 point) {
const float delta = 0.1;
vec3 dx = vec3(delta, 0.0, 0.0);
vec3 dy = vec3(0.0, delta, 0.0);
vec3 dz = vec3(0.0, 0.0, delta);
vec3 px0 = perlin3d(point - dx);
vec3 px1 = perlin3d(point + dx);
vec3 py0 = perlin3d(point - dy);
vec3 py1 = perlin3d(point + dy);
vec3 pz0 = perlin3d(point - dz);
vec3 pz1 = perlin3d(point + dz);
float x = py1.z - py0.z - pz1.y + pz0.y;
float y = pz1.x - pz0.x - px1.z + px0.z;
float z = px1.y - px0.y - py1.x + py0.x;
const float divisor = 1.0 / (2.0 * delta);
return normalize(vec3(x, y, z) * divisor);
}
void main() {
vec3 point = vec3(vUv.x, vUv.y, 0.0);
outputColor.rgb = 0.5 * curl(point) + 0.5;
outputColor.a = 1.0;
}
`;class Dte extends S9{constructor(){super({size:128,fragmentShader:ki(wte,{core:{math:fh},perlin:c_,tileableNoise:u_})})}}function Nte({url:n,position:e,scale:t}){const{scene:i}=a_(n);return he.useMemo(()=>{i.traverse(a=>{if(a.isMesh){const r=a;if(r.castShadow=!0,r.receiveShadow=!0,r.geometry&&!r.geometry.attributes.tangent&&r.geometry.attributes.position&&r.geometry.attributes.uv)try{r.geometry.computeTangents()}catch(s){console.warn("Failed to compute tangents",s)}if(r.material){const s=r.material;s.transparent=!1,s.depthWrite=!0,s.depthTest=!0,s.side=os,(s.map||s.alphaMap)&&(s.alphaTest=.5)}}})},[i]),It.jsx("primitive",{object:i,position:e,scale:t})}const Ote=()=>{const{gl:n,size:e}=jn(),t=he.useMemo(()=>new al,[]),i=he.useMemo(()=>new Jn(50,e.width/e.height,.1,1e3),[e]),a=he.useRef(null);return he.useEffect(()=>{i.position.set(0,0,5),i.lookAt(0,0,0)},[i]),Ls((r,s)=>{a.current&&(a.current.rotation.y+=s*.5);const o=n.autoClear;n.autoClear=!1,n.clearDepth(),n.render(t,i),n.autoClear=o},2),w8(It.jsxs(It.Fragment,{children:[It.jsx("ambientLight",{intensity:1}),It.jsx("directionalLight",{position:[5,5,5],intensity:2}),It.jsx(fee,{preset:"city",background:!1}),It.jsx("group",{ref:a,children:It.jsx(he.Suspense,{fallback:null,children:It.jsx(Nte,{url:"/pkg/atmosphere/assets/card.glb",position:[0,0,0],scale:.5})})})]}),t)},Ite=()=>{const{gl:n,camera:e}=jn(),[t,i]=he.useState(null);he.useEffect(()=>{n.toneMapping=ns,n.toneMappingExposure=10;const y=new P6(n);return y.update().then(E=>{i(E),y.dispose({textures:!1})}),()=>{}},[n]);const[a,r,s,o]=he.useMemo(()=>[new Rte,new Tte,new Mte,new Dte],[]),{longitude:c,latitude:h,height:f}={longitude:139.767,latitude:35.68,height:3e3},d=he.useRef(null),m=he.useRef(null);he.useEffect(()=>{if(d.current&&e){const y=new Mb,E=new H,S=new H,v=new H,_=new Yi;y.set(aT(c),aT(h),f),y.toECEF(E),bd.WGS84.getSurfaceNormal(E,S),_.setFromUnitVectors(e.up,S),v.copy(e.position).sub(d.current.target),v.applyQuaternion(_),e.up.copy(S),e.position.copy(E).add(new H(0,500,2e3).applyQuaternion(_)),d.current.target.copy(E),d.current.update()}},[e,c,h,f]);const g=he.useMemo(()=>new Date("2000-06-01T03:00:00Z"),[]);return Ls(()=>{m.current&&m.current.updateByDate(g)}),t?It.jsxs(It.Fragment,{children:[It.jsx(Y$,{makeDefault:!0,far:1e6,near:10}),It.jsx(q$,{ref:d,makeDefault:!0,minDistance:100}),It.jsxs(dee,{ref:m,textures:t,children:[It.jsx(yee,{}),It.jsx(_ee,{}),It.jsxs(hj,{enableNormalPass:!0,frameBufferType:sn,multisampling:8,children:[It.jsx(Ate,{qualityPreset:"high",coverage:.4,localWeatherTexture:a,shapeTexture:r,shapeDetailTexture:s,turbulenceTexture:o}),It.jsx(mee,{sky:!0,sunLight:!0,skyLight:!0}),It.jsx(pj,{mode:Za.AGX})]})]}),It.jsx(Ote,{})]}):It.jsx(UQ,{center:!0,children:"Generating Atmosphere..."})};function Bte(){return It.jsx("div",{style:{width:"100vw",height:"100vh"},children:It.jsx(eZ,{gl:{antialias:!1,depth:!1,logarithmicDepthBuffer:!0,stencil:!1},children:It.jsx(Ite,{})})})}_F.createRoot(document.getElementById("root")).render(It.jsx(IT.StrictMode,{children:It.jsx(Bte,{})}));