Files
2026-07-06 23:11:42 +02:00

4156 lines
836 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function n(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(l){if(l.ep)return;l.ep=!0;const c=n(l);fetch(l.href,c)}})();function zx(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var $f={exports:{}},dl={};var nv;function nM(){if(nv)return dl;nv=1;var a=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(s,l,c){var d=null;if(c!==void 0&&(d=""+c),l.key!==void 0&&(d=""+l.key),"key"in l){c={};for(var p in l)p!=="key"&&(c[p]=l[p])}else c=l;return l=c.ref,{$$typeof:a,type:s,key:d,ref:l!==void 0?l:null,props:c}}return dl.Fragment=e,dl.jsx=n,dl.jsxs=n,dl}var iv;function iM(){return iv||(iv=1,$f.exports=nM()),$f.exports}var g=iM(),Qf={exports:{}},yt={};var av;function aM(){if(av)return yt;av=1;var a=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),_=Symbol.iterator;function M(H){return H===null||typeof H!="object"?null:(H=_&&H[_]||H["@@iterator"],typeof H=="function"?H:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,y={};function x(H,te,Ee){this.props=H,this.context=te,this.refs=y,this.updater=Ee||E}x.prototype.isReactComponent={},x.prototype.setState=function(H,te){if(typeof H!="object"&&typeof H!="function"&&H!=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,H,te,"setState")},x.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function P(){}P.prototype=x.prototype;function O(H,te,Ee){this.props=H,this.context=te,this.refs=y,this.updater=Ee||E}var R=O.prototype=new P;R.constructor=O,C(R,x.prototype),R.isPureReactComponent=!0;var I=Array.isArray;function B(){}var L={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function U(H,te,Ee){var Le=Ee.ref;return{$$typeof:a,type:H,key:te,ref:Le!==void 0?Le:null,props:Ee}}function X(H,te){return U(H.type,te,H.props)}function G(H){return typeof H=="object"&&H!==null&&H.$$typeof===a}function K(H){var te={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(Ee){return te[Ee]})}var ue=/\/+/g;function pe(H,te){return typeof H=="object"&&H!==null&&H.key!=null?K(""+H.key):te.toString(36)}function Q(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(B,B):(H.status="pending",H.then(function(te){H.status==="pending"&&(H.status="fulfilled",H.value=te)},function(te){H.status==="pending"&&(H.status="rejected",H.reason=te)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function V(H,te,Ee,Le,Fe){var oe=typeof H;(oe==="undefined"||oe==="boolean")&&(H=null);var Me=!1;if(H===null)Me=!0;else switch(oe){case"bigint":case"string":case"number":Me=!0;break;case"object":switch(H.$$typeof){case a:case e:Me=!0;break;case v:return Me=H._init,V(Me(H._payload),te,Ee,Le,Fe)}}if(Me)return Fe=Fe(H),Me=Le===""?"."+pe(H,0):Le,I(Fe)?(Ee="",Me!=null&&(Ee=Me.replace(ue,"$&/")+"/"),V(Fe,te,Ee,"",function(at){return at})):Fe!=null&&(G(Fe)&&(Fe=X(Fe,Ee+(Fe.key==null||H&&H.key===Fe.key?"":(""+Fe.key).replace(ue,"$&/")+"/")+Me)),te.push(Fe)),1;Me=0;var Ae=Le===""?".":Le+":";if(I(H))for(var ze=0;ze<H.length;ze++)Le=H[ze],oe=Ae+pe(Le,ze),Me+=V(Le,te,Ee,oe,Fe);else if(ze=M(H),typeof ze=="function")for(H=ze.call(H),ze=0;!(Le=H.next()).done;)Le=Le.value,oe=Ae+pe(Le,ze++),Me+=V(Le,te,Ee,oe,Fe);else if(oe==="object"){if(typeof H.then=="function")return V(Q(H),te,Ee,Le,Fe);throw te=String(H),Error("Objects are not valid as a React child (found: "+(te==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":te)+"). If you meant to render a collection of children, use an array instead.")}return Me}function j(H,te,Ee){if(H==null)return H;var Le=[],Fe=0;return V(H,Le,"","",function(oe){return te.call(Ee,oe,Fe++)}),Le}function ae(H){if(H._status===-1){var te=H._result;te=te(),te.then(function(Ee){(H._status===0||H._status===-1)&&(H._status=1,H._result=Ee)},function(Ee){(H._status===0||H._status===-1)&&(H._status=2,H._result=Ee)}),H._status===-1&&(H._status=0,H._result=te)}if(H._status===1)return H._result.default;throw H._result}var _e=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var te=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof H=="object"&&H!==null&&typeof H.message=="string"?String(H.message):String(H),error:H});if(!window.dispatchEvent(te))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},ve={map:j,forEach:function(H,te,Ee){j(H,function(){te.apply(this,arguments)},Ee)},count:function(H){var te=0;return j(H,function(){te++}),te},toArray:function(H){return j(H,function(te){return te})||[]},only:function(H){if(!G(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return yt.Activity=S,yt.Children=ve,yt.Component=x,yt.Fragment=n,yt.Profiler=l,yt.PureComponent=O,yt.StrictMode=s,yt.Suspense=m,yt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,yt.__COMPILER_RUNTIME={__proto__:null,c:function(H){return L.H.useMemoCache(H)}},yt.cache=function(H){return function(){return H.apply(null,arguments)}},yt.cacheSignal=function(){return null},yt.cloneElement=function(H,te,Ee){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var Le=C({},H.props),Fe=H.key;if(te!=null)for(oe in te.key!==void 0&&(Fe=""+te.key),te)!T.call(te,oe)||oe==="key"||oe==="__self"||oe==="__source"||oe==="ref"&&te.ref===void 0||(Le[oe]=te[oe]);var oe=arguments.length-2;if(oe===1)Le.children=Ee;else if(1<oe){for(var Me=Array(oe),Ae=0;Ae<oe;Ae++)Me[Ae]=arguments[Ae+2];Le.children=Me}return U(H.type,Fe,Le)},yt.createContext=function(H){return H={$$typeof:d,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:c,_context:H},H},yt.createElement=function(H,te,Ee){var Le,Fe={},oe=null;if(te!=null)for(Le in te.key!==void 0&&(oe=""+te.key),te)T.call(te,Le)&&Le!=="key"&&Le!=="__self"&&Le!=="__source"&&(Fe[Le]=te[Le]);var Me=arguments.length-2;if(Me===1)Fe.children=Ee;else if(1<Me){for(var Ae=Array(Me),ze=0;ze<Me;ze++)Ae[ze]=arguments[ze+2];Fe.children=Ae}if(H&&H.defaultProps)for(Le in Me=H.defaultProps,Me)Fe[Le]===void 0&&(Fe[Le]=Me[Le]);return U(H,oe,Fe)},yt.createRef=function(){return{current:null}},yt.forwardRef=function(H){return{$$typeof:p,render:H}},yt.isValidElement=G,yt.lazy=function(H){return{$$typeof:v,_payload:{_status:-1,_result:H},_init:ae}},yt.memo=function(H,te){return{$$typeof:h,type:H,compare:te===void 0?null:te}},yt.startTransition=function(H){var te=L.T,Ee={};L.T=Ee;try{var Le=H(),Fe=L.S;Fe!==null&&Fe(Ee,Le),typeof Le=="object"&&Le!==null&&typeof Le.then=="function"&&Le.then(B,_e)}catch(oe){_e(oe)}finally{te!==null&&Ee.types!==null&&(te.types=Ee.types),L.T=te}},yt.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},yt.use=function(H){return L.H.use(H)},yt.useActionState=function(H,te,Ee){return L.H.useActionState(H,te,Ee)},yt.useCallback=function(H,te){return L.H.useCallback(H,te)},yt.useContext=function(H){return L.H.useContext(H)},yt.useDebugValue=function(){},yt.useDeferredValue=function(H,te){return L.H.useDeferredValue(H,te)},yt.useEffect=function(H,te){return L.H.useEffect(H,te)},yt.useEffectEvent=function(H){return L.H.useEffectEvent(H)},yt.useId=function(){return L.H.useId()},yt.useImperativeHandle=function(H,te,Ee){return L.H.useImperativeHandle(H,te,Ee)},yt.useInsertionEffect=function(H,te){return L.H.useInsertionEffect(H,te)},yt.useLayoutEffect=function(H,te){return L.H.useLayoutEffect(H,te)},yt.useMemo=function(H,te){return L.H.useMemo(H,te)},yt.useOptimistic=function(H,te){return L.H.useOptimistic(H,te)},yt.useReducer=function(H,te,Ee){return L.H.useReducer(H,te,Ee)},yt.useRef=function(H){return L.H.useRef(H)},yt.useState=function(H){return L.H.useState(H)},yt.useSyncExternalStore=function(H,te,Ee){return L.H.useSyncExternalStore(H,te,Ee)},yt.useTransition=function(){return L.H.useTransition()},yt.version="19.2.7",yt}var sv;function jp(){return sv||(sv=1,Qf.exports=aM()),Qf.exports}var sM=jp();const ee=zx(sM);var Jf={exports:{}},fl={},eh={exports:{}},th={};var rv;function rM(){return rv||(rv=1,(function(a){function e(V,j){var ae=V.length;V.push(j);e:for(;0<ae;){var _e=ae-1>>>1,ve=V[_e];if(0<l(ve,j))V[_e]=j,V[ae]=ve,ae=_e;else break e}}function n(V){return V.length===0?null:V[0]}function s(V){if(V.length===0)return null;var j=V[0],ae=V.pop();if(ae!==j){V[0]=ae;e:for(var _e=0,ve=V.length,H=ve>>>1;_e<H;){var te=2*(_e+1)-1,Ee=V[te],Le=te+1,Fe=V[Le];if(0>l(Ee,ae))Le<ve&&0>l(Fe,Ee)?(V[_e]=Fe,V[Le]=ae,_e=Le):(V[_e]=Ee,V[te]=ae,_e=te);else if(Le<ve&&0>l(Fe,ae))V[_e]=Fe,V[Le]=ae,_e=Le;else break e}}return j}function l(V,j){var ae=V.sortIndex-j.sortIndex;return ae!==0?ae:V.id-j.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;a.unstable_now=function(){return c.now()}}else{var d=Date,p=d.now();a.unstable_now=function(){return d.now()-p}}var m=[],h=[],v=1,S=null,_=3,M=!1,E=!1,C=!1,y=!1,x=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;function R(V){for(var j=n(h);j!==null;){if(j.callback===null)s(h);else if(j.startTime<=V)s(h),j.sortIndex=j.expirationTime,e(m,j);else break;j=n(h)}}function I(V){if(C=!1,R(V),!E)if(n(m)!==null)E=!0,B||(B=!0,K());else{var j=n(h);j!==null&&Q(I,j.startTime-V)}}var B=!1,L=-1,T=5,U=-1;function X(){return y?!0:!(a.unstable_now()-U<T)}function G(){if(y=!1,B){var V=a.unstable_now();U=V;var j=!0;try{e:{E=!1,C&&(C=!1,P(L),L=-1),M=!0;var ae=_;try{t:{for(R(V),S=n(m);S!==null&&!(S.expirationTime>V&&X());){var _e=S.callback;if(typeof _e=="function"){S.callback=null,_=S.priorityLevel;var ve=_e(S.expirationTime<=V);if(V=a.unstable_now(),typeof ve=="function"){S.callback=ve,R(V),j=!0;break t}S===n(m)&&s(m),R(V)}else s(m);S=n(m)}if(S!==null)j=!0;else{var H=n(h);H!==null&&Q(I,H.startTime-V),j=!1}}break e}finally{S=null,_=ae,M=!1}j=void 0}}finally{j?K():B=!1}}}var K;if(typeof O=="function")K=function(){O(G)};else if(typeof MessageChannel<"u"){var ue=new MessageChannel,pe=ue.port2;ue.port1.onmessage=G,K=function(){pe.postMessage(null)}}else K=function(){x(G,0)};function Q(V,j){L=x(function(){V(a.unstable_now())},j)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(V){V.callback=null},a.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<V?Math.floor(1e3/V):5},a.unstable_getCurrentPriorityLevel=function(){return _},a.unstable_next=function(V){switch(_){case 1:case 2:case 3:var j=3;break;default:j=_}var ae=_;_=j;try{return V()}finally{_=ae}},a.unstable_requestPaint=function(){y=!0},a.unstable_runWithPriority=function(V,j){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var ae=_;_=V;try{return j()}finally{_=ae}},a.unstable_scheduleCallback=function(V,j,ae){var _e=a.unstable_now();switch(typeof ae=="object"&&ae!==null?(ae=ae.delay,ae=typeof ae=="number"&&0<ae?_e+ae:_e):ae=_e,V){case 1:var ve=-1;break;case 2:ve=250;break;case 5:ve=1073741823;break;case 4:ve=1e4;break;default:ve=5e3}return ve=ae+ve,V={id:v++,callback:j,priorityLevel:V,startTime:ae,expirationTime:ve,sortIndex:-1},ae>_e?(V.sortIndex=ae,e(h,V),n(m)===null&&V===n(h)&&(C?(P(L),L=-1):C=!0,Q(I,ae-_e))):(V.sortIndex=ve,e(m,V),E||M||(E=!0,B||(B=!0,K()))),V},a.unstable_shouldYield=X,a.unstable_wrapCallback=function(V){var j=_;return function(){var ae=_;_=j;try{return V.apply(this,arguments)}finally{_=ae}}}})(th)),th}var ov;function oM(){return ov||(ov=1,eh.exports=rM()),eh.exports}var nh={exports:{}},jn={};var lv;function lM(){if(lv)return jn;lv=1;var a=jp();function e(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)h+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},l=Symbol.for("react.portal");function c(m,h,v){var S=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:S==null?null:""+S,children:m,containerInfo:h,implementation:v}}var d=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return jn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,jn.createPortal=function(m,h){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(e(299));return c(m,h,null,v)},jn.flushSync=function(m){var h=d.T,v=s.p;try{if(d.T=null,s.p=2,m)return m()}finally{d.T=h,s.p=v,s.d.f()}},jn.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,s.d.C(m,h))},jn.prefetchDNS=function(m){typeof m=="string"&&s.d.D(m)},jn.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var v=h.as,S=p(v,h.crossOrigin),_=typeof h.integrity=="string"?h.integrity:void 0,M=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;v==="style"?s.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:S,integrity:_,fetchPriority:M}):v==="script"&&s.d.X(m,{crossOrigin:S,integrity:_,fetchPriority:M,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},jn.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var v=p(h.as,h.crossOrigin);s.d.M(m,{crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&s.d.M(m)},jn.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var v=h.as,S=p(v,h.crossOrigin);s.d.L(m,v,{crossOrigin:S,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},jn.preloadModule=function(m,h){if(typeof m=="string")if(h){var v=p(h.as,h.crossOrigin);s.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else s.d.m(m)},jn.requestFormReset=function(m){s.d.r(m)},jn.unstable_batchedUpdates=function(m,h){return m(h)},jn.useFormState=function(m,h,v){return d.H.useFormState(m,h,v)},jn.useFormStatus=function(){return d.H.useHostTransitionStatus()},jn.version="19.2.7",jn}var cv;function cM(){if(cv)return nh.exports;cv=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(e){console.error(e)}}return a(),nh.exports=lM(),nh.exports}var uv;function uM(){if(uv)return fl;uv=1;var a=oM(),e=jp(),n=cM();function s(t){var i="https://react.dev/errors/"+t;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)i+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+t+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function c(t){var i=t,r=t;if(t.alternate)for(;i.return;)i=i.return;else{t=i;do i=t,(i.flags&4098)!==0&&(r=i.return),t=i.return;while(t)}return i.tag===3?r:null}function d(t){if(t.tag===13){var i=t.memoizedState;if(i===null&&(t=t.alternate,t!==null&&(i=t.memoizedState)),i!==null)return i.dehydrated}return null}function p(t){if(t.tag===31){var i=t.memoizedState;if(i===null&&(t=t.alternate,t!==null&&(i=t.memoizedState)),i!==null)return i.dehydrated}return null}function m(t){if(c(t)!==t)throw Error(s(188))}function h(t){var i=t.alternate;if(!i){if(i=c(t),i===null)throw Error(s(188));return i!==t?null:t}for(var r=t,o=i;;){var u=r.return;if(u===null)break;var f=u.alternate;if(f===null){if(o=u.return,o!==null){r=o;continue}break}if(u.child===f.child){for(f=u.child;f;){if(f===r)return m(u),t;if(f===o)return m(u),i;f=f.sibling}throw Error(s(188))}if(r.return!==o.return)r=u,o=f;else{for(var b=!1,N=u.child;N;){if(N===r){b=!0,r=u,o=f;break}if(N===o){b=!0,o=u,r=f;break}N=N.sibling}if(!b){for(N=f.child;N;){if(N===r){b=!0,r=f,o=u;break}if(N===o){b=!0,o=f,r=u;break}N=N.sibling}if(!b)throw Error(s(189))}}if(r.alternate!==o)throw Error(s(190))}if(r.tag!==3)throw Error(s(188));return r.stateNode.current===r?t:i}function v(t){var i=t.tag;if(i===5||i===26||i===27||i===6)return t;for(t=t.child;t!==null;){if(i=v(t),i!==null)return i;t=t.sibling}return null}var S=Object.assign,_=Symbol.for("react.element"),M=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),O=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),X=Symbol.for("react.memo_cache_sentinel"),G=Symbol.iterator;function K(t){return t===null||typeof t!="object"?null:(t=G&&t[G]||t["@@iterator"],typeof t=="function"?t:null)}var ue=Symbol.for("react.client.reference");function pe(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===ue?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case C:return"Fragment";case x:return"Profiler";case y:return"StrictMode";case I:return"Suspense";case B:return"SuspenseList";case U:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case E:return"Portal";case O:return t.displayName||"Context";case P:return(t._context.displayName||"Context")+".Consumer";case R:var i=t.render;return t=t.displayName,t||(t=i.displayName||i.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case L:return i=t.displayName||null,i!==null?i:pe(t.type)||"Memo";case T:i=t._payload,t=t._init;try{return pe(t(i))}catch{}}return null}var Q=Array.isArray,V=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae={pending:!1,data:null,method:null,action:null},_e=[],ve=-1;function H(t){return{current:t}}function te(t){0>ve||(t.current=_e[ve],_e[ve]=null,ve--)}function Ee(t,i){ve++,_e[ve]=t.current,t.current=i}var Le=H(null),Fe=H(null),oe=H(null),Me=H(null);function Ae(t,i){switch(Ee(oe,i),Ee(Fe,t),Ee(Le,null),i.nodeType){case 9:case 11:t=(t=i.documentElement)&&(t=t.namespaceURI)?T_(t):0;break;default:if(t=i.tagName,i=i.namespaceURI)i=T_(i),t=A_(i,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}te(Le),Ee(Le,t)}function ze(){te(Le),te(Fe),te(oe)}function at(t){t.memoizedState!==null&&Ee(Me,t);var i=Le.current,r=A_(i,t.type);i!==r&&(Ee(Fe,t),Ee(Le,r))}function Je(t){Fe.current===t&&(te(Le),te(Fe)),Me.current===t&&(te(Me),ol._currentValue=ae)}var Gt,ut;function _t(t){if(Gt===void 0)try{throw Error()}catch(r){var i=r.stack.trim().match(/\n( *(at )?)/);Gt=i&&i[1]||"",ut=-1<r.stack.indexOf(`
at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
`+Gt+t+ut}var xt=!1;function ot(t,i){if(!t||xt)return"";xt=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(i){var we=function(){throw Error()};if(Object.defineProperty(we.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(we,[])}catch(me){var he=me}Reflect.construct(t,[],we)}else{try{we.call()}catch(me){he=me}t.call(we.prototype)}}else{try{throw Error()}catch(me){he=me}(we=t())&&typeof we.catch=="function"&&we.catch(function(){})}}catch(me){if(me&&he&&typeof me.stack=="string")return[me.stack,he.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=o.DetermineComponentFrameRoot(),b=f[0],N=f[1];if(b&&N){var q=b.split(`
`),de=N.split(`
`);for(u=o=0;o<q.length&&!q[o].includes("DetermineComponentFrameRoot");)o++;for(;u<de.length&&!de[u].includes("DetermineComponentFrameRoot");)u++;if(o===q.length||u===de.length)for(o=q.length-1,u=de.length-1;1<=o&&0<=u&&q[o]!==de[u];)u--;for(;1<=o&&0<=u;o--,u--)if(q[o]!==de[u]){if(o!==1||u!==1)do if(o--,u--,0>u||q[o]!==de[u]){var Se=`
`+q[o].replace(" at new "," at ");return t.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",t.displayName)),Se}while(1<=o&&0<=u);break}}}finally{xt=!1,Error.prepareStackTrace=r}return(r=t?t.displayName||t.name:"")?_t(r):""}function Ht(t,i){switch(t.tag){case 26:case 27:case 5:return _t(t.type);case 16:return _t("Lazy");case 13:return t.child!==i&&i!==null?_t("Suspense Fallback"):_t("Suspense");case 19:return _t("SuspenseList");case 0:case 15:return ot(t.type,!1);case 11:return ot(t.type.render,!1);case 1:return ot(t.type,!0);case 31:return _t("Activity");default:return""}}function Bt(t){try{var i="",r=null;do i+=Ht(t,r),r=t,t=t.return;while(t);return i}catch(o){return`
Error generating stack: `+o.message+`
`+o.stack}}var Zt=Object.prototype.hasOwnProperty,Vt=a.unstable_scheduleCallback,dt=a.unstable_cancelCallback,J=a.unstable_shouldYield,z=a.unstable_requestPaint,Ue=a.unstable_now,ft=a.unstable_getCurrentPriorityLevel,F=a.unstable_ImmediatePriority,A=a.unstable_UserBlockingPriority,ne=a.unstable_NormalPriority,re=a.unstable_LowPriority,fe=a.unstable_IdlePriority,Ne=a.log,He=a.unstable_setDisableYieldValue,ge=null,le=null;function Ie(t){if(typeof Ne=="function"&&He(t),le&&typeof le.setStrictMode=="function")try{le.setStrictMode(ge,t)}catch{}}var We=Math.clz32?Math.clz32:nt,Xe=Math.log,ke=Math.LN2;function nt(t){return t>>>=0,t===0?32:31-(Xe(t)/ke|0)|0}var Ce=256,rt=262144,Z=4194304;function Oe(t){var i=t&42;if(i!==0)return i;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function ye(t,i,r){var o=t.pendingLanes;if(o===0)return 0;var u=0,f=t.suspendedLanes,b=t.pingedLanes;t=t.warmLanes;var N=o&134217727;return N!==0?(o=N&~f,o!==0?u=Oe(o):(b&=N,b!==0?u=Oe(b):r||(r=N&~t,r!==0&&(u=Oe(r))))):(N=o&~f,N!==0?u=Oe(N):b!==0?u=Oe(b):r||(r=o&~t,r!==0&&(u=Oe(r)))),u===0?0:i!==0&&i!==u&&(i&f)===0&&(f=u&-u,r=i&-i,f>=r||f===32&&(r&4194048)!==0)?i:u}function Pe(t,i){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&i)===0}function Ge(t,i){switch(t){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+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 De(){var t=Z;return Z<<=1,(Z&62914560)===0&&(Z=4194304),t}function Ze(t){for(var i=[],r=0;31>r;r++)i.push(t);return i}function qe(t,i){t.pendingLanes|=i,i!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function qt(t,i,r,o,u,f){var b=t.pendingLanes;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=r,t.entangledLanes&=r,t.errorRecoveryDisabledLanes&=r,t.shellSuspendCounter=0;var N=t.entanglements,q=t.expirationTimes,de=t.hiddenUpdates;for(r=b&~r;0<r;){var Se=31-We(r),we=1<<Se;N[Se]=0,q[Se]=-1;var he=de[Se];if(he!==null)for(de[Se]=null,Se=0;Se<he.length;Se++){var me=he[Se];me!==null&&(me.lane&=-536870913)}r&=~we}o!==0&&wt(t,o,0),f!==0&&u===0&&t.tag!==0&&(t.suspendedLanes|=f&~(b&~i))}function wt(t,i,r){t.pendingLanes|=i,t.suspendedLanes&=~i;var o=31-We(i);t.entangledLanes|=i,t.entanglements[o]=t.entanglements[o]|1073741824|r&261930}function Ln(t,i){var r=t.entangledLanes|=i;for(t=t.entanglements;r;){var o=31-We(r),u=1<<o;u&i|t[o]&i&&(t[o]|=i),r&=~u}}function Sn(t,i){var r=i&-i;return r=(r&42)!==0?1:Re(r),(r&(t.suspendedLanes|i))!==0?0:r}function Re(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Ke(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function gt(){var t=j.p;return t!==0?t:(t=window.event,t===void 0?32:Z_(t.type))}function Ot(t,i){var r=j.p;try{return j.p=t,i()}finally{j.p=r}}var Tt=Math.random().toString(36).slice(2),vt="__reactFiber$"+Tt,vn="__reactProps$"+Tt,Vn="__reactContainer$"+Tt,Qi="__reactEvents$"+Tt,hr="__reactListeners$"+Tt,pr="__reactHandles$"+Tt,ma="__reactResources$"+Tt,Ji="__reactMarker$"+Tt;function ea(t){delete t[vt],delete t[vn],delete t[Qi],delete t[hr],delete t[pr]}function Oi(t){var i=t[vt];if(i)return i;for(var r=t.parentNode;r;){if(i=r[Vn]||r[vt]){if(r=i.alternate,i.child!==null||r!==null&&r.child!==null)for(t=L_(t);t!==null;){if(r=t[vt])return r;t=L_(t)}return i}t=r,r=t.parentNode}return null}function Pi(t){if(t=t[vt]||t[Vn]){var i=t.tag;if(i===5||i===6||i===13||i===31||i===26||i===27||i===3)return t}return null}function Ii(t){var i=t.tag;if(i===5||i===26||i===27||i===6)return t.stateNode;throw Error(s(33))}function ta(t){var i=t[ma];return i||(i=t[ma]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function mn(t){t[Ji]=!0}var Ds=new Set,D={};function w(t,i){k(t,i),k(t+"Capture",i)}function k(t,i){for(D[t]=i,t=0;t<i.length;t++)Ds.add(i[t])}var W=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]*$"),Y={},xe={};function be(t){return Zt.call(xe,t)?!0:Zt.call(Y,t)?!1:W.test(t)?xe[t]=!0:(Y[t]=!0,!1)}function Be(t,i,r){if(be(i))if(r===null)t.removeAttribute(i);else{switch(typeof r){case"undefined":case"function":case"symbol":t.removeAttribute(i);return;case"boolean":var o=i.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){t.removeAttribute(i);return}}t.setAttribute(i,""+r)}}function Ve(t,i,r){if(r===null)t.removeAttribute(i);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(i);return}t.setAttribute(i,""+r)}}function je(t,i,r,o){if(o===null)t.removeAttribute(r);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(r);return}t.setAttributeNS(i,r,""+o)}}function Qe(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function st(t){var i=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function et(t,i,r){var o=Object.getOwnPropertyDescriptor(t.constructor.prototype,i);if(!t.hasOwnProperty(i)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,f=o.set;return Object.defineProperty(t,i,{configurable:!0,get:function(){return u.call(this)},set:function(b){r=""+b,f.call(this,b)}}),Object.defineProperty(t,i,{enumerable:o.enumerable}),{getValue:function(){return r},setValue:function(b){r=""+b},stopTracking:function(){t._valueTracker=null,delete t[i]}}}}function Mt(t){if(!t._valueTracker){var i=st(t)?"checked":"value";t._valueTracker=et(t,i,""+t[i])}}function nn(t){if(!t)return!1;var i=t._valueTracker;if(!i)return!0;var r=i.getValue(),o="";return t&&(o=st(t)?t.checked?"true":"false":t.value),t=o,t!==r?(i.setValue(t),!0):!1}function Rt(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Kt=/[\n"\\]/g;function $t(t){return t.replace(Kt,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function $e(t,i,r,o,u,f,b,N){t.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?t.type=b:t.removeAttribute("type"),i!=null?b==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+Qe(i)):t.value!==""+Qe(i)&&(t.value=""+Qe(i)):b!=="submit"&&b!=="reset"||t.removeAttribute("value"),i!=null?Dt(t,b,Qe(i)):r!=null?Dt(t,b,Qe(r)):o!=null&&t.removeAttribute("value"),u==null&&f!=null&&(t.defaultChecked=!!f),u!=null&&(t.checked=u&&typeof u!="function"&&typeof u!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?t.name=""+Qe(N):t.removeAttribute("name")}function kn(t,i,r,o,u,f,b,N){if(f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(t.type=f),i!=null||r!=null){if(!(f!=="submit"&&f!=="reset"||i!=null)){Mt(t);return}r=r!=null?""+Qe(r):"",i=i!=null?""+Qe(i):r,N||i===t.value||(t.value=i),t.defaultValue=i}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,t.checked=N?t.checked:!!o,t.defaultChecked=!!o,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(t.name=b),Mt(t)}function Dt(t,i,r){i==="number"&&Rt(t.ownerDocument)===t||t.defaultValue===""+r||(t.defaultValue=""+r)}function Cn(t,i,r,o){if(t=t.options,i){i={};for(var u=0;u<r.length;u++)i["$"+r[u]]=!0;for(r=0;r<t.length;r++)u=i.hasOwnProperty("$"+t[r].value),t[r].selected!==u&&(t[r].selected=u),u&&o&&(t[r].defaultSelected=!0)}else{for(r=""+Qe(r),i=null,u=0;u<t.length;u++){if(t[u].value===r){t[u].selected=!0,o&&(t[u].defaultSelected=!0);return}i!==null||t[u].disabled||(i=t[u])}i!==null&&(i.selected=!0)}}function oi(t,i,r){if(i!=null&&(i=""+Qe(i),i!==t.value&&(t.value=i),r==null)){t.defaultValue!==i&&(t.defaultValue=i);return}t.defaultValue=r!=null?""+Qe(r):""}function Bi(t,i,r,o){if(i==null){if(o!=null){if(r!=null)throw Error(s(92));if(Q(o)){if(1<o.length)throw Error(s(93));o=o[0]}r=o}r==null&&(r=""),i=r}r=Qe(i),t.defaultValue=r,o=t.textContent,o===r&&o!==""&&o!==null&&(t.value=o),Mt(t)}function li(t,i){if(i){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=i;return}}t.textContent=i}var Qt=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 fn(t,i,r){var o=i.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?o?t.setProperty(i,""):i==="float"?t.cssFloat="":t[i]="":o?t.setProperty(i,r):typeof r!="number"||r===0||Qt.has(i)?i==="float"?t.cssFloat=r:t[i]=(""+r).trim():t[i]=r+"px"}function Fi(t,i,r){if(i!=null&&typeof i!="object")throw Error(s(62));if(t=t.style,r!=null){for(var o in r)!r.hasOwnProperty(o)||i!=null&&i.hasOwnProperty(o)||(o.indexOf("--")===0?t.setProperty(o,""):o==="float"?t.cssFloat="":t[o]="");for(var u in i)o=i[u],i.hasOwnProperty(u)&&r[u]!==o&&fn(t,u,o)}else for(var f in i)i.hasOwnProperty(f)&&fn(t,f,i[f])}function Yt(t){if(t.indexOf("-")===-1)return!1;switch(t){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 na=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"]]),Wa=/^[\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 Ns(t){return Wa.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function ga(){}var qu=null;function Yu(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var mr=null,gr=null;function Em(t){var i=Pi(t);if(i&&(t=i.stateNode)){var r=t[vn]||null;e:switch(t=i.stateNode,i.type){case"input":if($e(t,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),i=r.name,r.type==="radio"&&i!=null){for(r=t;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+$t(""+i)+'"][type="radio"]'),i=0;i<r.length;i++){var o=r[i];if(o!==t&&o.form===t.form){var u=o[vn]||null;if(!u)throw Error(s(90));$e(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(i=0;i<r.length;i++)o=r[i],o.form===t.form&&nn(o)}break e;case"textarea":oi(t,r.value,r.defaultValue);break e;case"select":i=r.value,i!=null&&Cn(t,!!r.multiple,i,!1)}}}var Zu=!1;function Tm(t,i,r){if(Zu)return t(i,r);Zu=!0;try{var o=t(i);return o}finally{if(Zu=!1,(mr!==null||gr!==null)&&(Ec(),mr&&(i=mr,t=gr,gr=mr=null,Em(i),t)))for(i=0;i<t.length;i++)Em(t[i])}}function Eo(t,i){var r=t.stateNode;if(r===null)return null;var o=r[vn]||null;if(o===null)return null;r=o[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(t=t.type,o=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!o;break e;default:t=!1}if(t)return null;if(r&&typeof r!="function")throw Error(s(231,i,typeof r));return r}var _a=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ku=!1;if(_a)try{var To={};Object.defineProperty(To,"passive",{get:function(){Ku=!0}}),window.addEventListener("test",To,To),window.removeEventListener("test",To,To)}catch{Ku=!1}var qa=null,$u=null,Fl=null;function Am(){if(Fl)return Fl;var t,i=$u,r=i.length,o,u="value"in qa?qa.value:qa.textContent,f=u.length;for(t=0;t<r&&i[t]===u[t];t++);var b=r-t;for(o=1;o<=b&&i[r-o]===u[f-o];o++);return Fl=u.slice(t,1<o?1-o:void 0)}function zl(t){var i=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&i===13&&(t=13)):t=i,t===10&&(t=13),32<=t||t===13?t:0}function Hl(){return!0}function Cm(){return!1}function $n(t){function i(r,o,u,f,b){this._reactName=r,this._targetInst=u,this.type=o,this.nativeEvent=f,this.target=b,this.currentTarget=null;for(var N in t)t.hasOwnProperty(N)&&(r=t[N],this[N]=r?r(f):f[N]);return this.isDefaultPrevented=(f.defaultPrevented!=null?f.defaultPrevented:f.returnValue===!1)?Hl:Cm,this.isPropagationStopped=Cm,this}return S(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=Hl)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=Hl)},persist:function(){},isPersistent:Hl}),i}var Us={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gl=$n(Us),Ao=S({},Us,{view:0,detail:0}),eS=$n(Ao),Qu,Ju,Co,Vl=S({},Ao,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:td,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Co&&(Co&&t.type==="mousemove"?(Qu=t.screenX-Co.screenX,Ju=t.screenY-Co.screenY):Ju=Qu=0,Co=t),Qu)},movementY:function(t){return"movementY"in t?t.movementY:Ju}}),wm=$n(Vl),tS=S({},Vl,{dataTransfer:0}),nS=$n(tS),iS=S({},Ao,{relatedTarget:0}),ed=$n(iS),aS=S({},Us,{animationName:0,elapsedTime:0,pseudoElement:0}),sS=$n(aS),rS=S({},Us,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),oS=$n(rS),lS=S({},Us,{data:0}),Rm=$n(lS),cS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uS={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"},dS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fS(t){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(t):(t=dS[t])?!!i[t]:!1}function td(){return fS}var hS=S({},Ao,{key:function(t){if(t.key){var i=cS[t.key]||t.key;if(i!=="Unidentified")return i}return t.type==="keypress"?(t=zl(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?uS[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:td,charCode:function(t){return t.type==="keypress"?zl(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?zl(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),pS=$n(hS),mS=S({},Vl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Dm=$n(mS),gS=S({},Ao,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:td}),_S=$n(gS),vS=S({},Us,{propertyName:0,elapsedTime:0,pseudoElement:0}),xS=$n(vS),yS=S({},Vl,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),SS=$n(yS),bS=S({},Us,{newState:0,oldState:0}),MS=$n(bS),ES=[9,13,27,32],nd=_a&&"CompositionEvent"in window,wo=null;_a&&"documentMode"in document&&(wo=document.documentMode);var TS=_a&&"TextEvent"in window&&!wo,Nm=_a&&(!nd||wo&&8<wo&&11>=wo),Um=" ",Lm=!1;function Om(t,i){switch(t){case"keyup":return ES.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pm(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var _r=!1;function AS(t,i){switch(t){case"compositionend":return Pm(i);case"keypress":return i.which!==32?null:(Lm=!0,Um);case"textInput":return t=i.data,t===Um&&Lm?null:t;default:return null}}function CS(t,i){if(_r)return t==="compositionend"||!nd&&Om(t,i)?(t=Am(),Fl=$u=qa=null,_r=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return Nm&&i.locale!=="ko"?null:i.data;default:return null}}var wS={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 Im(t){var i=t&&t.nodeName&&t.nodeName.toLowerCase();return i==="input"?!!wS[t.type]:i==="textarea"}function Bm(t,i,r,o){mr?gr?gr.push(o):gr=[o]:mr=o,i=Nc(i,"onChange"),0<i.length&&(r=new Gl("onChange","change",null,r,o),t.push({event:r,listeners:i}))}var Ro=null,Do=null;function RS(t){x_(t,0)}function kl(t){var i=Ii(t);if(nn(i))return t}function Fm(t,i){if(t==="change")return i}var zm=!1;if(_a){var id;if(_a){var ad="oninput"in document;if(!ad){var Hm=document.createElement("div");Hm.setAttribute("oninput","return;"),ad=typeof Hm.oninput=="function"}id=ad}else id=!1;zm=id&&(!document.documentMode||9<document.documentMode)}function Gm(){Ro&&(Ro.detachEvent("onpropertychange",Vm),Do=Ro=null)}function Vm(t){if(t.propertyName==="value"&&kl(Do)){var i=[];Bm(i,Do,t,Yu(t)),Tm(RS,i)}}function DS(t,i,r){t==="focusin"?(Gm(),Ro=i,Do=r,Ro.attachEvent("onpropertychange",Vm)):t==="focusout"&&Gm()}function NS(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return kl(Do)}function US(t,i){if(t==="click")return kl(i)}function LS(t,i){if(t==="input"||t==="change")return kl(i)}function OS(t,i){return t===i&&(t!==0||1/t===1/i)||t!==t&&i!==i}var ci=typeof Object.is=="function"?Object.is:OS;function No(t,i){if(ci(t,i))return!0;if(typeof t!="object"||t===null||typeof i!="object"||i===null)return!1;var r=Object.keys(t),o=Object.keys(i);if(r.length!==o.length)return!1;for(o=0;o<r.length;o++){var u=r[o];if(!Zt.call(i,u)||!ci(t[u],i[u]))return!1}return!0}function km(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function jm(t,i){var r=km(t);t=0;for(var o;r;){if(r.nodeType===3){if(o=t+r.textContent.length,t<=i&&o>=i)return{node:r,offset:i-t};t=o}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=km(r)}}function Xm(t,i){return t&&i?t===i?!0:t&&t.nodeType===3?!1:i&&i.nodeType===3?Xm(t,i.parentNode):"contains"in t?t.contains(i):t.compareDocumentPosition?!!(t.compareDocumentPosition(i)&16):!1:!1}function Wm(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var i=Rt(t.document);i instanceof t.HTMLIFrameElement;){try{var r=typeof i.contentWindow.location.href=="string"}catch{r=!1}if(r)t=i.contentWindow;else break;i=Rt(t.document)}return i}function sd(t){var i=t&&t.nodeName&&t.nodeName.toLowerCase();return i&&(i==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||i==="textarea"||t.contentEditable==="true")}var PS=_a&&"documentMode"in document&&11>=document.documentMode,vr=null,rd=null,Uo=null,od=!1;function qm(t,i,r){var o=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;od||vr==null||vr!==Rt(o)||(o=vr,"selectionStart"in o&&sd(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Uo&&No(Uo,o)||(Uo=o,o=Nc(rd,"onSelect"),0<o.length&&(i=new Gl("onSelect","select",null,i,r),t.push({event:i,listeners:o}),i.target=vr)))}function Ls(t,i){var r={};return r[t.toLowerCase()]=i.toLowerCase(),r["Webkit"+t]="webkit"+i,r["Moz"+t]="moz"+i,r}var xr={animationend:Ls("Animation","AnimationEnd"),animationiteration:Ls("Animation","AnimationIteration"),animationstart:Ls("Animation","AnimationStart"),transitionrun:Ls("Transition","TransitionRun"),transitionstart:Ls("Transition","TransitionStart"),transitioncancel:Ls("Transition","TransitionCancel"),transitionend:Ls("Transition","TransitionEnd")},ld={},Ym={};_a&&(Ym=document.createElement("div").style,"AnimationEvent"in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),"TransitionEvent"in window||delete xr.transitionend.transition);function Os(t){if(ld[t])return ld[t];if(!xr[t])return t;var i=xr[t],r;for(r in i)if(i.hasOwnProperty(r)&&r in Ym)return ld[t]=i[r];return t}var Zm=Os("animationend"),Km=Os("animationiteration"),$m=Os("animationstart"),IS=Os("transitionrun"),BS=Os("transitionstart"),FS=Os("transitioncancel"),Qm=Os("transitionend"),Jm=new Map,cd="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");cd.push("scrollEnd");function zi(t,i){Jm.set(t,i),w(i,[t])}var jl=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},yi=[],yr=0,ud=0;function Xl(){for(var t=yr,i=ud=yr=0;i<t;){var r=yi[i];yi[i++]=null;var o=yi[i];yi[i++]=null;var u=yi[i];yi[i++]=null;var f=yi[i];if(yi[i++]=null,o!==null&&u!==null){var b=o.pending;b===null?u.next=u:(u.next=b.next,b.next=u),o.pending=u}f!==0&&eg(r,u,f)}}function Wl(t,i,r,o){yi[yr++]=t,yi[yr++]=i,yi[yr++]=r,yi[yr++]=o,ud|=o,t.lanes|=o,t=t.alternate,t!==null&&(t.lanes|=o)}function dd(t,i,r,o){return Wl(t,i,r,o),ql(t)}function Ps(t,i){return Wl(t,null,null,i),ql(t)}function eg(t,i,r){t.lanes|=r;var o=t.alternate;o!==null&&(o.lanes|=r);for(var u=!1,f=t.return;f!==null;)f.childLanes|=r,o=f.alternate,o!==null&&(o.childLanes|=r),f.tag===22&&(t=f.stateNode,t===null||t._visibility&1||(u=!0)),t=f,f=f.return;return t.tag===3?(f=t.stateNode,u&&i!==null&&(u=31-We(r),t=f.hiddenUpdates,o=t[u],o===null?t[u]=[i]:o.push(i),i.lane=r|536870912),f):null}function ql(t){if(50<el)throw el=0,Sf=null,Error(s(185));for(var i=t.return;i!==null;)t=i,i=t.return;return t.tag===3?t.stateNode:null}var Sr={};function zS(t,i,r,o){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ui(t,i,r,o){return new zS(t,i,r,o)}function fd(t){return t=t.prototype,!(!t||!t.isReactComponent)}function va(t,i){var r=t.alternate;return r===null?(r=ui(t.tag,i,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=i,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&65011712,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,i=t.dependencies,r.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r.refCleanup=t.refCleanup,r}function tg(t,i){t.flags&=65011714;var r=t.alternate;return r===null?(t.childLanes=0,t.lanes=i,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=r.childLanes,t.lanes=r.lanes,t.child=r.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=r.memoizedProps,t.memoizedState=r.memoizedState,t.updateQueue=r.updateQueue,t.type=r.type,i=r.dependencies,t.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),t}function Yl(t,i,r,o,u,f){var b=0;if(o=t,typeof t=="function")fd(t)&&(b=1);else if(typeof t=="string")b=jb(t,r,Le.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case U:return t=ui(31,r,i,u),t.elementType=U,t.lanes=f,t;case C:return Is(r.children,u,f,i);case y:b=8,u|=24;break;case x:return t=ui(12,r,i,u|2),t.elementType=x,t.lanes=f,t;case I:return t=ui(13,r,i,u),t.elementType=I,t.lanes=f,t;case B:return t=ui(19,r,i,u),t.elementType=B,t.lanes=f,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case O:b=10;break e;case P:b=9;break e;case R:b=11;break e;case L:b=14;break e;case T:b=16,o=null;break e}b=29,r=Error(s(130,t===null?"null":typeof t,"")),o=null}return i=ui(b,r,i,u),i.elementType=t,i.type=o,i.lanes=f,i}function Is(t,i,r,o){return t=ui(7,t,o,i),t.lanes=r,t}function hd(t,i,r){return t=ui(6,t,null,i),t.lanes=r,t}function ng(t){var i=ui(18,null,null,0);return i.stateNode=t,i}function pd(t,i,r){return i=ui(4,t.children!==null?t.children:[],t.key,i),i.lanes=r,i.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},i}var ig=new WeakMap;function Si(t,i){if(typeof t=="object"&&t!==null){var r=ig.get(t);return r!==void 0?r:(i={value:t,source:i,stack:Bt(i)},ig.set(t,i),i)}return{value:t,source:i,stack:Bt(i)}}var br=[],Mr=0,Zl=null,Lo=0,bi=[],Mi=0,Ya=null,ia=1,aa="";function xa(t,i){br[Mr++]=Lo,br[Mr++]=Zl,Zl=t,Lo=i}function ag(t,i,r){bi[Mi++]=ia,bi[Mi++]=aa,bi[Mi++]=Ya,Ya=t;var o=ia;t=aa;var u=32-We(o)-1;o&=~(1<<u),r+=1;var f=32-We(i)+u;if(30<f){var b=u-u%5;f=(o&(1<<b)-1).toString(32),o>>=b,u-=b,ia=1<<32-We(i)+u|r<<u|o,aa=f+t}else ia=1<<f|r<<u|o,aa=t}function md(t){t.return!==null&&(xa(t,1),ag(t,1,0))}function gd(t){for(;t===Zl;)Zl=br[--Mr],br[Mr]=null,Lo=br[--Mr],br[Mr]=null;for(;t===Ya;)Ya=bi[--Mi],bi[Mi]=null,aa=bi[--Mi],bi[Mi]=null,ia=bi[--Mi],bi[Mi]=null}function sg(t,i){bi[Mi++]=ia,bi[Mi++]=aa,bi[Mi++]=Ya,ia=i.id,aa=i.overflow,Ya=t}var Bn=null,un=null,Ft=!1,Za=null,Ei=!1,_d=Error(s(519));function Ka(t){var i=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Oo(Si(i,t)),_d}function rg(t){var i=t.stateNode,r=t.type,o=t.memoizedProps;switch(i[vt]=t,i[vn]=o,r){case"dialog":Ut("cancel",i),Ut("close",i);break;case"iframe":case"object":case"embed":Ut("load",i);break;case"video":case"audio":for(r=0;r<nl.length;r++)Ut(nl[r],i);break;case"source":Ut("error",i);break;case"img":case"image":case"link":Ut("error",i),Ut("load",i);break;case"details":Ut("toggle",i);break;case"input":Ut("invalid",i),kn(i,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":Ut("invalid",i);break;case"textarea":Ut("invalid",i),Bi(i,o.value,o.defaultValue,o.children)}r=o.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||i.textContent===""+r||o.suppressHydrationWarning===!0||M_(i.textContent,r)?(o.popover!=null&&(Ut("beforetoggle",i),Ut("toggle",i)),o.onScroll!=null&&Ut("scroll",i),o.onScrollEnd!=null&&Ut("scrollend",i),o.onClick!=null&&(i.onclick=ga),i=!0):i=!1,i||Ka(t,!0)}function og(t){for(Bn=t.return;Bn;)switch(Bn.tag){case 5:case 31:case 13:Ei=!1;return;case 27:case 3:Ei=!0;return;default:Bn=Bn.return}}function Er(t){if(t!==Bn)return!1;if(!Ft)return og(t),Ft=!0,!1;var i=t.tag,r;if((r=i!==3&&i!==27)&&((r=i===5)&&(r=t.type,r=!(r!=="form"&&r!=="button")||If(t.type,t.memoizedProps)),r=!r),r&&un&&Ka(t),og(t),i===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));un=U_(t)}else if(i===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));un=U_(t)}else i===27?(i=un,us(t.type)?(t=Gf,Gf=null,un=t):un=i):un=Bn?Ai(t.stateNode.nextSibling):null;return!0}function Bs(){un=Bn=null,Ft=!1}function vd(){var t=Za;return t!==null&&(ti===null?ti=t:ti.push.apply(ti,t),Za=null),t}function Oo(t){Za===null?Za=[t]:Za.push(t)}var xd=H(null),Fs=null,ya=null;function $a(t,i,r){Ee(xd,i._currentValue),i._currentValue=r}function Sa(t){t._currentValue=xd.current,te(xd)}function yd(t,i,r){for(;t!==null;){var o=t.alternate;if((t.childLanes&i)!==i?(t.childLanes|=i,o!==null&&(o.childLanes|=i)):o!==null&&(o.childLanes&i)!==i&&(o.childLanes|=i),t===r)break;t=t.return}}function Sd(t,i,r,o){var u=t.child;for(u!==null&&(u.return=t);u!==null;){var f=u.dependencies;if(f!==null){var b=u.child;f=f.firstContext;e:for(;f!==null;){var N=f;f=u;for(var q=0;q<i.length;q++)if(N.context===i[q]){f.lanes|=r,N=f.alternate,N!==null&&(N.lanes|=r),yd(f.return,r,t),o||(b=null);break e}f=N.next}}else if(u.tag===18){if(b=u.return,b===null)throw Error(s(341));b.lanes|=r,f=b.alternate,f!==null&&(f.lanes|=r),yd(b,r,t),b=null}else b=u.child;if(b!==null)b.return=u;else for(b=u;b!==null;){if(b===t){b=null;break}if(u=b.sibling,u!==null){u.return=b.return,b=u;break}b=b.return}u=b}}function Tr(t,i,r,o){t=null;for(var u=i,f=!1;u!==null;){if(!f){if((u.flags&524288)!==0)f=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var b=u.alternate;if(b===null)throw Error(s(387));if(b=b.memoizedProps,b!==null){var N=u.type;ci(u.pendingProps.value,b.value)||(t!==null?t.push(N):t=[N])}}else if(u===Me.current){if(b=u.alternate,b===null)throw Error(s(387));b.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(t!==null?t.push(ol):t=[ol])}u=u.return}t!==null&&Sd(i,t,r,o),i.flags|=262144}function Kl(t){for(t=t.firstContext;t!==null;){if(!ci(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function zs(t){Fs=t,ya=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Fn(t){return lg(Fs,t)}function $l(t,i){return Fs===null&&zs(t),lg(t,i)}function lg(t,i){var r=i._currentValue;if(i={context:i,memoizedValue:r,next:null},ya===null){if(t===null)throw Error(s(308));ya=i,t.dependencies={lanes:0,firstContext:i},t.flags|=524288}else ya=ya.next=i;return r}var HS=typeof AbortController<"u"?AbortController:function(){var t=[],i=this.signal={aborted:!1,addEventListener:function(r,o){t.push(o)}};this.abort=function(){i.aborted=!0,t.forEach(function(r){return r()})}},GS=a.unstable_scheduleCallback,VS=a.unstable_NormalPriority,bn={$$typeof:O,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function bd(){return{controller:new HS,data:new Map,refCount:0}}function Po(t){t.refCount--,t.refCount===0&&GS(VS,function(){t.controller.abort()})}var Io=null,Md=0,Ar=0,Cr=null;function kS(t,i){if(Io===null){var r=Io=[];Md=0,Ar=Cf(),Cr={status:"pending",value:void 0,then:function(o){r.push(o)}}}return Md++,i.then(cg,cg),i}function cg(){if(--Md===0&&Io!==null){Cr!==null&&(Cr.status="fulfilled");var t=Io;Io=null,Ar=0,Cr=null;for(var i=0;i<t.length;i++)(0,t[i])()}}function jS(t,i){var r=[],o={status:"pending",value:null,reason:null,then:function(u){r.push(u)}};return t.then(function(){o.status="fulfilled",o.value=i;for(var u=0;u<r.length;u++)(0,r[u])(i)},function(u){for(o.status="rejected",o.reason=u,u=0;u<r.length;u++)(0,r[u])(void 0)}),o}var ug=V.S;V.S=function(t,i){q0=Ue(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&kS(t,i),ug!==null&&ug(t,i)};var Hs=H(null);function Ed(){var t=Hs.current;return t!==null?t:ln.pooledCache}function Ql(t,i){i===null?Ee(Hs,Hs.current):Ee(Hs,i.pool)}function dg(){var t=Ed();return t===null?null:{parent:bn._currentValue,pool:t}}var wr=Error(s(460)),Td=Error(s(474)),Jl=Error(s(542)),ec={then:function(){}};function fg(t){return t=t.status,t==="fulfilled"||t==="rejected"}function hg(t,i,r){switch(r=t[r],r===void 0?t.push(i):r!==i&&(i.then(ga,ga),i=r),i.status){case"fulfilled":return i.value;case"rejected":throw t=i.reason,mg(t),t;default:if(typeof i.status=="string")i.then(ga,ga);else{if(t=ln,t!==null&&100<t.shellSuspendCounter)throw Error(s(482));t=i,t.status="pending",t.then(function(o){if(i.status==="pending"){var u=i;u.status="fulfilled",u.value=o}},function(o){if(i.status==="pending"){var u=i;u.status="rejected",u.reason=o}})}switch(i.status){case"fulfilled":return i.value;case"rejected":throw t=i.reason,mg(t),t}throw Vs=i,wr}}function Gs(t){try{var i=t._init;return i(t._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(Vs=r,wr):r}}var Vs=null;function pg(){if(Vs===null)throw Error(s(459));var t=Vs;return Vs=null,t}function mg(t){if(t===wr||t===Jl)throw Error(s(483))}var Rr=null,Bo=0;function tc(t){var i=Bo;return Bo+=1,Rr===null&&(Rr=[]),hg(Rr,t,i)}function Fo(t,i){i=i.props.ref,t.ref=i!==void 0?i:null}function nc(t,i){throw i.$$typeof===_?Error(s(525)):(t=Object.prototype.toString.call(i),Error(s(31,t==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":t)))}function gg(t){function i(ie,$){if(t){var ce=ie.deletions;ce===null?(ie.deletions=[$],ie.flags|=16):ce.push($)}}function r(ie,$){if(!t)return null;for(;$!==null;)i(ie,$),$=$.sibling;return null}function o(ie){for(var $=new Map;ie!==null;)ie.key!==null?$.set(ie.key,ie):$.set(ie.index,ie),ie=ie.sibling;return $}function u(ie,$){return ie=va(ie,$),ie.index=0,ie.sibling=null,ie}function f(ie,$,ce){return ie.index=ce,t?(ce=ie.alternate,ce!==null?(ce=ce.index,ce<$?(ie.flags|=67108866,$):ce):(ie.flags|=67108866,$)):(ie.flags|=1048576,$)}function b(ie){return t&&ie.alternate===null&&(ie.flags|=67108866),ie}function N(ie,$,ce,Te){return $===null||$.tag!==6?($=hd(ce,ie.mode,Te),$.return=ie,$):($=u($,ce),$.return=ie,$)}function q(ie,$,ce,Te){var lt=ce.type;return lt===C?Se(ie,$,ce.props.children,Te,ce.key):$!==null&&($.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===T&&Gs(lt)===$.type)?($=u($,ce.props),Fo($,ce),$.return=ie,$):($=Yl(ce.type,ce.key,ce.props,null,ie.mode,Te),Fo($,ce),$.return=ie,$)}function de(ie,$,ce,Te){return $===null||$.tag!==4||$.stateNode.containerInfo!==ce.containerInfo||$.stateNode.implementation!==ce.implementation?($=pd(ce,ie.mode,Te),$.return=ie,$):($=u($,ce.children||[]),$.return=ie,$)}function Se(ie,$,ce,Te,lt){return $===null||$.tag!==7?($=Is(ce,ie.mode,Te,lt),$.return=ie,$):($=u($,ce),$.return=ie,$)}function we(ie,$,ce){if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return $=hd(""+$,ie.mode,ce),$.return=ie,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case M:return ce=Yl($.type,$.key,$.props,null,ie.mode,ce),Fo(ce,$),ce.return=ie,ce;case E:return $=pd($,ie.mode,ce),$.return=ie,$;case T:return $=Gs($),we(ie,$,ce)}if(Q($)||K($))return $=Is($,ie.mode,ce,null),$.return=ie,$;if(typeof $.then=="function")return we(ie,tc($),ce);if($.$$typeof===O)return we(ie,$l(ie,$),ce);nc(ie,$)}return null}function he(ie,$,ce,Te){var lt=$!==null?$.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return lt!==null?null:N(ie,$,""+ce,Te);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case M:return ce.key===lt?q(ie,$,ce,Te):null;case E:return ce.key===lt?de(ie,$,ce,Te):null;case T:return ce=Gs(ce),he(ie,$,ce,Te)}if(Q(ce)||K(ce))return lt!==null?null:Se(ie,$,ce,Te,null);if(typeof ce.then=="function")return he(ie,$,tc(ce),Te);if(ce.$$typeof===O)return he(ie,$,$l(ie,ce),Te);nc(ie,ce)}return null}function me(ie,$,ce,Te,lt){if(typeof Te=="string"&&Te!==""||typeof Te=="number"||typeof Te=="bigint")return ie=ie.get(ce)||null,N($,ie,""+Te,lt);if(typeof Te=="object"&&Te!==null){switch(Te.$$typeof){case M:return ie=ie.get(Te.key===null?ce:Te.key)||null,q($,ie,Te,lt);case E:return ie=ie.get(Te.key===null?ce:Te.key)||null,de($,ie,Te,lt);case T:return Te=Gs(Te),me(ie,$,ce,Te,lt)}if(Q(Te)||K(Te))return ie=ie.get(ce)||null,Se($,ie,Te,lt,null);if(typeof Te.then=="function")return me(ie,$,ce,tc(Te),lt);if(Te.$$typeof===O)return me(ie,$,ce,$l($,Te),lt);nc($,Te)}return null}function tt(ie,$,ce,Te){for(var lt=null,jt=null,it=$,At=$=0,It=null;it!==null&&At<ce.length;At++){it.index>At?(It=it,it=null):It=it.sibling;var Xt=he(ie,it,ce[At],Te);if(Xt===null){it===null&&(it=It);break}t&&it&&Xt.alternate===null&&i(ie,it),$=f(Xt,$,At),jt===null?lt=Xt:jt.sibling=Xt,jt=Xt,it=It}if(At===ce.length)return r(ie,it),Ft&&xa(ie,At),lt;if(it===null){for(;At<ce.length;At++)it=we(ie,ce[At],Te),it!==null&&($=f(it,$,At),jt===null?lt=it:jt.sibling=it,jt=it);return Ft&&xa(ie,At),lt}for(it=o(it);At<ce.length;At++)It=me(it,ie,At,ce[At],Te),It!==null&&(t&&It.alternate!==null&&it.delete(It.key===null?At:It.key),$=f(It,$,At),jt===null?lt=It:jt.sibling=It,jt=It);return t&&it.forEach(function(ms){return i(ie,ms)}),Ft&&xa(ie,At),lt}function pt(ie,$,ce,Te){if(ce==null)throw Error(s(151));for(var lt=null,jt=null,it=$,At=$=0,It=null,Xt=ce.next();it!==null&&!Xt.done;At++,Xt=ce.next()){it.index>At?(It=it,it=null):It=it.sibling;var ms=he(ie,it,Xt.value,Te);if(ms===null){it===null&&(it=It);break}t&&it&&ms.alternate===null&&i(ie,it),$=f(ms,$,At),jt===null?lt=ms:jt.sibling=ms,jt=ms,it=It}if(Xt.done)return r(ie,it),Ft&&xa(ie,At),lt;if(it===null){for(;!Xt.done;At++,Xt=ce.next())Xt=we(ie,Xt.value,Te),Xt!==null&&($=f(Xt,$,At),jt===null?lt=Xt:jt.sibling=Xt,jt=Xt);return Ft&&xa(ie,At),lt}for(it=o(it);!Xt.done;At++,Xt=ce.next())Xt=me(it,ie,At,Xt.value,Te),Xt!==null&&(t&&Xt.alternate!==null&&it.delete(Xt.key===null?At:Xt.key),$=f(Xt,$,At),jt===null?lt=Xt:jt.sibling=Xt,jt=Xt);return t&&it.forEach(function(tM){return i(ie,tM)}),Ft&&xa(ie,At),lt}function rn(ie,$,ce,Te){if(typeof ce=="object"&&ce!==null&&ce.type===C&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case M:e:{for(var lt=ce.key;$!==null;){if($.key===lt){if(lt=ce.type,lt===C){if($.tag===7){r(ie,$.sibling),Te=u($,ce.props.children),Te.return=ie,ie=Te;break e}}else if($.elementType===lt||typeof lt=="object"&&lt!==null&&lt.$$typeof===T&&Gs(lt)===$.type){r(ie,$.sibling),Te=u($,ce.props),Fo(Te,ce),Te.return=ie,ie=Te;break e}r(ie,$);break}else i(ie,$);$=$.sibling}ce.type===C?(Te=Is(ce.props.children,ie.mode,Te,ce.key),Te.return=ie,ie=Te):(Te=Yl(ce.type,ce.key,ce.props,null,ie.mode,Te),Fo(Te,ce),Te.return=ie,ie=Te)}return b(ie);case E:e:{for(lt=ce.key;$!==null;){if($.key===lt)if($.tag===4&&$.stateNode.containerInfo===ce.containerInfo&&$.stateNode.implementation===ce.implementation){r(ie,$.sibling),Te=u($,ce.children||[]),Te.return=ie,ie=Te;break e}else{r(ie,$);break}else i(ie,$);$=$.sibling}Te=pd(ce,ie.mode,Te),Te.return=ie,ie=Te}return b(ie);case T:return ce=Gs(ce),rn(ie,$,ce,Te)}if(Q(ce))return tt(ie,$,ce,Te);if(K(ce)){if(lt=K(ce),typeof lt!="function")throw Error(s(150));return ce=lt.call(ce),pt(ie,$,ce,Te)}if(typeof ce.then=="function")return rn(ie,$,tc(ce),Te);if(ce.$$typeof===O)return rn(ie,$,$l(ie,ce),Te);nc(ie,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint"?(ce=""+ce,$!==null&&$.tag===6?(r(ie,$.sibling),Te=u($,ce),Te.return=ie,ie=Te):(r(ie,$),Te=hd(ce,ie.mode,Te),Te.return=ie,ie=Te),b(ie)):r(ie,$)}return function(ie,$,ce,Te){try{Bo=0;var lt=rn(ie,$,ce,Te);return Rr=null,lt}catch(it){if(it===wr||it===Jl)throw it;var jt=ui(29,it,null,ie.mode);return jt.lanes=Te,jt.return=ie,jt}}}var ks=gg(!0),_g=gg(!1),Qa=!1;function Ad(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Cd(t,i){t=t.updateQueue,i.updateQueue===t&&(i.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Ja(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function es(t,i,r){var o=t.updateQueue;if(o===null)return null;if(o=o.shared,(Wt&2)!==0){var u=o.pending;return u===null?i.next=i:(i.next=u.next,u.next=i),o.pending=i,i=ql(t),eg(t,null,r),i}return Wl(t,o,i,r),ql(t)}function zo(t,i,r){if(i=i.updateQueue,i!==null&&(i=i.shared,(r&4194048)!==0)){var o=i.lanes;o&=t.pendingLanes,r|=o,i.lanes=r,Ln(t,r)}}function wd(t,i){var r=t.updateQueue,o=t.alternate;if(o!==null&&(o=o.updateQueue,r===o)){var u=null,f=null;if(r=r.firstBaseUpdate,r!==null){do{var b={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};f===null?u=f=b:f=f.next=b,r=r.next}while(r!==null);f===null?u=f=i:f=f.next=i}else u=f=i;r={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:f,shared:o.shared,callbacks:o.callbacks},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=i:t.next=i,r.lastBaseUpdate=i}var Rd=!1;function Ho(){if(Rd){var t=Cr;if(t!==null)throw t}}function Go(t,i,r,o){Rd=!1;var u=t.updateQueue;Qa=!1;var f=u.firstBaseUpdate,b=u.lastBaseUpdate,N=u.shared.pending;if(N!==null){u.shared.pending=null;var q=N,de=q.next;q.next=null,b===null?f=de:b.next=de,b=q;var Se=t.alternate;Se!==null&&(Se=Se.updateQueue,N=Se.lastBaseUpdate,N!==b&&(N===null?Se.firstBaseUpdate=de:N.next=de,Se.lastBaseUpdate=q))}if(f!==null){var we=u.baseState;b=0,Se=de=q=null,N=f;do{var he=N.lane&-536870913,me=he!==N.lane;if(me?(Pt&he)===he:(o&he)===he){he!==0&&he===Ar&&(Rd=!0),Se!==null&&(Se=Se.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var tt=t,pt=N;he=i;var rn=r;switch(pt.tag){case 1:if(tt=pt.payload,typeof tt=="function"){we=tt.call(rn,we,he);break e}we=tt;break e;case 3:tt.flags=tt.flags&-65537|128;case 0:if(tt=pt.payload,he=typeof tt=="function"?tt.call(rn,we,he):tt,he==null)break e;we=S({},we,he);break e;case 2:Qa=!0}}he=N.callback,he!==null&&(t.flags|=64,me&&(t.flags|=8192),me=u.callbacks,me===null?u.callbacks=[he]:me.push(he))}else me={lane:he,tag:N.tag,payload:N.payload,callback:N.callback,next:null},Se===null?(de=Se=me,q=we):Se=Se.next=me,b|=he;if(N=N.next,N===null){if(N=u.shared.pending,N===null)break;me=N,N=me.next,me.next=null,u.lastBaseUpdate=me,u.shared.pending=null}}while(!0);Se===null&&(q=we),u.baseState=q,u.firstBaseUpdate=de,u.lastBaseUpdate=Se,f===null&&(u.shared.lanes=0),ss|=b,t.lanes=b,t.memoizedState=we}}function vg(t,i){if(typeof t!="function")throw Error(s(191,t));t.call(i)}function xg(t,i){var r=t.callbacks;if(r!==null)for(t.callbacks=null,t=0;t<r.length;t++)vg(r[t],i)}var Dr=H(null),ic=H(0);function yg(t,i){t=Da,Ee(ic,t),Ee(Dr,i),Da=t|i.baseLanes}function Dd(){Ee(ic,Da),Ee(Dr,Dr.current)}function Nd(){Da=ic.current,te(Dr),te(ic)}var di=H(null),Ti=null;function ts(t){var i=t.alternate;Ee(xn,xn.current&1),Ee(di,t),Ti===null&&(i===null||Dr.current!==null||i.memoizedState!==null)&&(Ti=t)}function Ud(t){Ee(xn,xn.current),Ee(di,t),Ti===null&&(Ti=t)}function Sg(t){t.tag===22?(Ee(xn,xn.current),Ee(di,t),Ti===null&&(Ti=t)):ns()}function ns(){Ee(xn,xn.current),Ee(di,di.current)}function fi(t){te(di),Ti===t&&(Ti=null),te(xn)}var xn=H(0);function ac(t){for(var i=t;i!==null;){if(i.tag===13){var r=i.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||zf(r)||Hf(r)))return i}else if(i.tag===19&&(i.memoizedProps.revealOrder==="forwards"||i.memoizedProps.revealOrder==="backwards"||i.memoizedProps.revealOrder==="unstable_legacy-backwards"||i.memoizedProps.revealOrder==="together")){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var ba=0,Et=null,an=null,Mn=null,sc=!1,Nr=!1,js=!1,rc=0,Vo=0,Ur=null,XS=0;function gn(){throw Error(s(321))}function Ld(t,i){if(i===null)return!1;for(var r=0;r<i.length&&r<t.length;r++)if(!ci(t[r],i[r]))return!1;return!0}function Od(t,i,r,o,u,f){return ba=f,Et=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,V.H=t===null||t.memoizedState===null?a0:Zd,js=!1,f=r(o,u),js=!1,Nr&&(f=Mg(i,r,o,u)),bg(t),f}function bg(t){V.H=Xo;var i=an!==null&&an.next!==null;if(ba=0,Mn=an=Et=null,sc=!1,Vo=0,Ur=null,i)throw Error(s(300));t===null||En||(t=t.dependencies,t!==null&&Kl(t)&&(En=!0))}function Mg(t,i,r,o){Et=t;var u=0;do{if(Nr&&(Ur=null),Vo=0,Nr=!1,25<=u)throw Error(s(301));if(u+=1,Mn=an=null,t.updateQueue!=null){var f=t.updateQueue;f.lastEffect=null,f.events=null,f.stores=null,f.memoCache!=null&&(f.memoCache.index=0)}V.H=s0,f=i(r,o)}while(Nr);return f}function WS(){var t=V.H,i=t.useState()[0];return i=typeof i.then=="function"?ko(i):i,t=t.useState()[0],(an!==null?an.memoizedState:null)!==t&&(Et.flags|=1024),i}function Pd(){var t=rc!==0;return rc=0,t}function Id(t,i,r){i.updateQueue=t.updateQueue,i.flags&=-2053,t.lanes&=~r}function Bd(t){if(sc){for(t=t.memoizedState;t!==null;){var i=t.queue;i!==null&&(i.pending=null),t=t.next}sc=!1}ba=0,Mn=an=Et=null,Nr=!1,Vo=rc=0,Ur=null}function Yn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mn===null?Et.memoizedState=Mn=t:Mn=Mn.next=t,Mn}function yn(){if(an===null){var t=Et.alternate;t=t!==null?t.memoizedState:null}else t=an.next;var i=Mn===null?Et.memoizedState:Mn.next;if(i!==null)Mn=i,an=t;else{if(t===null)throw Et.alternate===null?Error(s(467)):Error(s(310));an=t,t={memoizedState:an.memoizedState,baseState:an.baseState,baseQueue:an.baseQueue,queue:an.queue,next:null},Mn===null?Et.memoizedState=Mn=t:Mn=Mn.next=t}return Mn}function oc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ko(t){var i=Vo;return Vo+=1,Ur===null&&(Ur=[]),t=hg(Ur,t,i),i=Et,(Mn===null?i.memoizedState:Mn.next)===null&&(i=i.alternate,V.H=i===null||i.memoizedState===null?a0:Zd),t}function lc(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return ko(t);if(t.$$typeof===O)return Fn(t)}throw Error(s(438,String(t)))}function Fd(t){var i=null,r=Et.updateQueue;if(r!==null&&(i=r.memoCache),i==null){var o=Et.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(i={data:o.data.map(function(u){return u.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),r===null&&(r=oc(),Et.updateQueue=r),r.memoCache=i,r=i.data[i.index],r===void 0)for(r=i.data[i.index]=Array(t),o=0;o<t;o++)r[o]=X;return i.index++,r}function Ma(t,i){return typeof i=="function"?i(t):i}function cc(t){var i=yn();return zd(i,an,t)}function zd(t,i,r){var o=t.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=r;var u=t.baseQueue,f=o.pending;if(f!==null){if(u!==null){var b=u.next;u.next=f.next,f.next=b}i.baseQueue=u=f,o.pending=null}if(f=t.baseState,u===null)t.memoizedState=f;else{i=u.next;var N=b=null,q=null,de=i,Se=!1;do{var we=de.lane&-536870913;if(we!==de.lane?(Pt&we)===we:(ba&we)===we){var he=de.revertLane;if(he===0)q!==null&&(q=q.next={lane:0,revertLane:0,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),we===Ar&&(Se=!0);else if((ba&he)===he){de=de.next,he===Ar&&(Se=!0);continue}else we={lane:0,revertLane:de.revertLane,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},q===null?(N=q=we,b=f):q=q.next=we,Et.lanes|=he,ss|=he;we=de.action,js&&r(f,we),f=de.hasEagerState?de.eagerState:r(f,we)}else he={lane:we,revertLane:de.revertLane,gesture:de.gesture,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},q===null?(N=q=he,b=f):q=q.next=he,Et.lanes|=we,ss|=we;de=de.next}while(de!==null&&de!==i);if(q===null?b=f:q.next=N,!ci(f,t.memoizedState)&&(En=!0,Se&&(r=Cr,r!==null)))throw r;t.memoizedState=f,t.baseState=b,t.baseQueue=q,o.lastRenderedState=f}return u===null&&(o.lanes=0),[t.memoizedState,o.dispatch]}function Hd(t){var i=yn(),r=i.queue;if(r===null)throw Error(s(311));r.lastRenderedReducer=t;var o=r.dispatch,u=r.pending,f=i.memoizedState;if(u!==null){r.pending=null;var b=u=u.next;do f=t(f,b.action),b=b.next;while(b!==u);ci(f,i.memoizedState)||(En=!0),i.memoizedState=f,i.baseQueue===null&&(i.baseState=f),r.lastRenderedState=f}return[f,o]}function Eg(t,i,r){var o=Et,u=yn(),f=Ft;if(f){if(r===void 0)throw Error(s(407));r=r()}else r=i();var b=!ci((an||u).memoizedState,r);if(b&&(u.memoizedState=r,En=!0),u=u.queue,kd(Cg.bind(null,o,u,t),[t]),u.getSnapshot!==i||b||Mn!==null&&Mn.memoizedState.tag&1){if(o.flags|=2048,Lr(9,{destroy:void 0},Ag.bind(null,o,u,r,i),null),ln===null)throw Error(s(349));f||(ba&127)!==0||Tg(o,i,r)}return r}function Tg(t,i,r){t.flags|=16384,t={getSnapshot:i,value:r},i=Et.updateQueue,i===null?(i=oc(),Et.updateQueue=i,i.stores=[t]):(r=i.stores,r===null?i.stores=[t]:r.push(t))}function Ag(t,i,r,o){i.value=r,i.getSnapshot=o,wg(i)&&Rg(t)}function Cg(t,i,r){return r(function(){wg(i)&&Rg(t)})}function wg(t){var i=t.getSnapshot;t=t.value;try{var r=i();return!ci(t,r)}catch{return!0}}function Rg(t){var i=Ps(t,2);i!==null&&ni(i,t,2)}function Gd(t){var i=Yn();if(typeof t=="function"){var r=t;if(t=r(),js){Ie(!0);try{r()}finally{Ie(!1)}}}return i.memoizedState=i.baseState=t,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ma,lastRenderedState:t},i}function Dg(t,i,r,o){return t.baseState=r,zd(t,an,typeof o=="function"?o:Ma)}function qS(t,i,r,o,u){if(fc(t))throw Error(s(485));if(t=i.action,t!==null){var f={payload:u,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){f.listeners.push(b)}};V.T!==null?r(!0):f.isTransition=!1,o(f),r=i.pending,r===null?(f.next=i.pending=f,Ng(i,f)):(f.next=r.next,i.pending=r.next=f)}}function Ng(t,i){var r=i.action,o=i.payload,u=t.state;if(i.isTransition){var f=V.T,b={};V.T=b;try{var N=r(u,o),q=V.S;q!==null&&q(b,N),Ug(t,i,N)}catch(de){Vd(t,i,de)}finally{f!==null&&b.types!==null&&(f.types=b.types),V.T=f}}else try{f=r(u,o),Ug(t,i,f)}catch(de){Vd(t,i,de)}}function Ug(t,i,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(o){Lg(t,i,o)},function(o){return Vd(t,i,o)}):Lg(t,i,r)}function Lg(t,i,r){i.status="fulfilled",i.value=r,Og(i),t.state=r,i=t.pending,i!==null&&(r=i.next,r===i?t.pending=null:(r=r.next,i.next=r,Ng(t,r)))}function Vd(t,i,r){var o=t.pending;if(t.pending=null,o!==null){o=o.next;do i.status="rejected",i.reason=r,Og(i),i=i.next;while(i!==o)}t.action=null}function Og(t){t=t.listeners;for(var i=0;i<t.length;i++)(0,t[i])()}function Pg(t,i){return i}function Ig(t,i){if(Ft){var r=ln.formState;if(r!==null){e:{var o=Et;if(Ft){if(un){t:{for(var u=un,f=Ei;u.nodeType!==8;){if(!f){u=null;break t}if(u=Ai(u.nextSibling),u===null){u=null;break t}}f=u.data,u=f==="F!"||f==="F"?u:null}if(u){un=Ai(u.nextSibling),o=u.data==="F!";break e}}Ka(o)}o=!1}o&&(i=r[0])}}return r=Yn(),r.memoizedState=r.baseState=i,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Pg,lastRenderedState:i},r.queue=o,r=t0.bind(null,Et,o),o.dispatch=r,o=Gd(!1),f=Yd.bind(null,Et,!1,o.queue),o=Yn(),u={state:i,dispatch:null,action:t,pending:null},o.queue=u,r=qS.bind(null,Et,u,f,r),u.dispatch=r,o.memoizedState=t,[i,r,!1]}function Bg(t){var i=yn();return Fg(i,an,t)}function Fg(t,i,r){if(i=zd(t,i,Pg)[0],t=cc(Ma)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var o=ko(i)}catch(b){throw b===wr?Jl:b}else o=i;i=yn();var u=i.queue,f=u.dispatch;return r!==i.memoizedState&&(Et.flags|=2048,Lr(9,{destroy:void 0},YS.bind(null,u,r),null)),[o,f,t]}function YS(t,i){t.action=i}function zg(t){var i=yn(),r=an;if(r!==null)return Fg(i,r,t);yn(),i=i.memoizedState,r=yn();var o=r.queue.dispatch;return r.memoizedState=t,[i,o,!1]}function Lr(t,i,r,o){return t={tag:t,create:r,deps:o,inst:i,next:null},i=Et.updateQueue,i===null&&(i=oc(),Et.updateQueue=i),r=i.lastEffect,r===null?i.lastEffect=t.next=t:(o=r.next,r.next=t,t.next=o,i.lastEffect=t),t}function Hg(){return yn().memoizedState}function uc(t,i,r,o){var u=Yn();Et.flags|=t,u.memoizedState=Lr(1|i,{destroy:void 0},r,o===void 0?null:o)}function dc(t,i,r,o){var u=yn();o=o===void 0?null:o;var f=u.memoizedState.inst;an!==null&&o!==null&&Ld(o,an.memoizedState.deps)?u.memoizedState=Lr(i,f,r,o):(Et.flags|=t,u.memoizedState=Lr(1|i,f,r,o))}function Gg(t,i){uc(8390656,8,t,i)}function kd(t,i){dc(2048,8,t,i)}function ZS(t){Et.flags|=4;var i=Et.updateQueue;if(i===null)i=oc(),Et.updateQueue=i,i.events=[t];else{var r=i.events;r===null?i.events=[t]:r.push(t)}}function Vg(t){var i=yn().memoizedState;return ZS({ref:i,nextImpl:t}),function(){if((Wt&2)!==0)throw Error(s(440));return i.impl.apply(void 0,arguments)}}function kg(t,i){return dc(4,2,t,i)}function jg(t,i){return dc(4,4,t,i)}function Xg(t,i){if(typeof i=="function"){t=t();var r=i(t);return function(){typeof r=="function"?r():i(null)}}if(i!=null)return t=t(),i.current=t,function(){i.current=null}}function Wg(t,i,r){r=r!=null?r.concat([t]):null,dc(4,4,Xg.bind(null,i,t),r)}function jd(){}function qg(t,i){var r=yn();i=i===void 0?null:i;var o=r.memoizedState;return i!==null&&Ld(i,o[1])?o[0]:(r.memoizedState=[t,i],t)}function Yg(t,i){var r=yn();i=i===void 0?null:i;var o=r.memoizedState;if(i!==null&&Ld(i,o[1]))return o[0];if(o=t(),js){Ie(!0);try{t()}finally{Ie(!1)}}return r.memoizedState=[o,i],o}function Xd(t,i,r){return r===void 0||(ba&1073741824)!==0&&(Pt&261930)===0?t.memoizedState=i:(t.memoizedState=r,t=Z0(),Et.lanes|=t,ss|=t,r)}function Zg(t,i,r,o){return ci(r,i)?r:Dr.current!==null?(t=Xd(t,r,o),ci(t,i)||(En=!0),t):(ba&42)===0||(ba&1073741824)!==0&&(Pt&261930)===0?(En=!0,t.memoizedState=r):(t=Z0(),Et.lanes|=t,ss|=t,i)}function Kg(t,i,r,o,u){var f=j.p;j.p=f!==0&&8>f?f:8;var b=V.T,N={};V.T=N,Yd(t,!1,i,r);try{var q=u(),de=V.S;if(de!==null&&de(N,q),q!==null&&typeof q=="object"&&typeof q.then=="function"){var Se=jS(q,o);jo(t,i,Se,mi(t))}else jo(t,i,o,mi(t))}catch(we){jo(t,i,{then:function(){},status:"rejected",reason:we},mi())}finally{j.p=f,b!==null&&N.types!==null&&(b.types=N.types),V.T=b}}function KS(){}function Wd(t,i,r,o){if(t.tag!==5)throw Error(s(476));var u=$g(t).queue;Kg(t,u,i,ae,r===null?KS:function(){return Qg(t),r(o)})}function $g(t){var i=t.memoizedState;if(i!==null)return i;i={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ma,lastRenderedState:ae},next:null};var r={};return i.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ma,lastRenderedState:r},next:null},t.memoizedState=i,t=t.alternate,t!==null&&(t.memoizedState=i),i}function Qg(t){var i=$g(t);i.next===null&&(i=t.alternate.memoizedState),jo(t,i.next.queue,{},mi())}function qd(){return Fn(ol)}function Jg(){return yn().memoizedState}function e0(){return yn().memoizedState}function $S(t){for(var i=t.return;i!==null;){switch(i.tag){case 24:case 3:var r=mi();t=Ja(r);var o=es(i,t,r);o!==null&&(ni(o,i,r),zo(o,i,r)),i={cache:bd()},t.payload=i;return}i=i.return}}function QS(t,i,r){var o=mi();r={lane:o,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},fc(t)?n0(i,r):(r=dd(t,i,r,o),r!==null&&(ni(r,t,o),i0(r,i,o)))}function t0(t,i,r){var o=mi();jo(t,i,r,o)}function jo(t,i,r,o){var u={lane:o,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(fc(t))n0(i,u);else{var f=t.alternate;if(t.lanes===0&&(f===null||f.lanes===0)&&(f=i.lastRenderedReducer,f!==null))try{var b=i.lastRenderedState,N=f(b,r);if(u.hasEagerState=!0,u.eagerState=N,ci(N,b))return Wl(t,i,u,0),ln===null&&Xl(),!1}catch{}if(r=dd(t,i,u,o),r!==null)return ni(r,t,o),i0(r,i,o),!0}return!1}function Yd(t,i,r,o){if(o={lane:2,revertLane:Cf(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},fc(t)){if(i)throw Error(s(479))}else i=dd(t,r,o,2),i!==null&&ni(i,t,2)}function fc(t){var i=t.alternate;return t===Et||i!==null&&i===Et}function n0(t,i){Nr=sc=!0;var r=t.pending;r===null?i.next=i:(i.next=r.next,r.next=i),t.pending=i}function i0(t,i,r){if((r&4194048)!==0){var o=i.lanes;o&=t.pendingLanes,r|=o,i.lanes=r,Ln(t,r)}}var Xo={readContext:Fn,use:lc,useCallback:gn,useContext:gn,useEffect:gn,useImperativeHandle:gn,useLayoutEffect:gn,useInsertionEffect:gn,useMemo:gn,useReducer:gn,useRef:gn,useState:gn,useDebugValue:gn,useDeferredValue:gn,useTransition:gn,useSyncExternalStore:gn,useId:gn,useHostTransitionStatus:gn,useFormState:gn,useActionState:gn,useOptimistic:gn,useMemoCache:gn,useCacheRefresh:gn};Xo.useEffectEvent=gn;var a0={readContext:Fn,use:lc,useCallback:function(t,i){return Yn().memoizedState=[t,i===void 0?null:i],t},useContext:Fn,useEffect:Gg,useImperativeHandle:function(t,i,r){r=r!=null?r.concat([t]):null,uc(4194308,4,Xg.bind(null,i,t),r)},useLayoutEffect:function(t,i){return uc(4194308,4,t,i)},useInsertionEffect:function(t,i){uc(4,2,t,i)},useMemo:function(t,i){var r=Yn();i=i===void 0?null:i;var o=t();if(js){Ie(!0);try{t()}finally{Ie(!1)}}return r.memoizedState=[o,i],o},useReducer:function(t,i,r){var o=Yn();if(r!==void 0){var u=r(i);if(js){Ie(!0);try{r(i)}finally{Ie(!1)}}}else u=i;return o.memoizedState=o.baseState=u,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:u},o.queue=t,t=t.dispatch=QS.bind(null,Et,t),[o.memoizedState,t]},useRef:function(t){var i=Yn();return t={current:t},i.memoizedState=t},useState:function(t){t=Gd(t);var i=t.queue,r=t0.bind(null,Et,i);return i.dispatch=r,[t.memoizedState,r]},useDebugValue:jd,useDeferredValue:function(t,i){var r=Yn();return Xd(r,t,i)},useTransition:function(){var t=Gd(!1);return t=Kg.bind(null,Et,t.queue,!0,!1),Yn().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,i,r){var o=Et,u=Yn();if(Ft){if(r===void 0)throw Error(s(407));r=r()}else{if(r=i(),ln===null)throw Error(s(349));(Pt&127)!==0||Tg(o,i,r)}u.memoizedState=r;var f={value:r,getSnapshot:i};return u.queue=f,Gg(Cg.bind(null,o,f,t),[t]),o.flags|=2048,Lr(9,{destroy:void 0},Ag.bind(null,o,f,r,i),null),r},useId:function(){var t=Yn(),i=ln.identifierPrefix;if(Ft){var r=aa,o=ia;r=(o&~(1<<32-We(o)-1)).toString(32)+r,i="_"+i+"R_"+r,r=rc++,0<r&&(i+="H"+r.toString(32)),i+="_"}else r=XS++,i="_"+i+"r_"+r.toString(32)+"_";return t.memoizedState=i},useHostTransitionStatus:qd,useFormState:Ig,useActionState:Ig,useOptimistic:function(t){var i=Yn();i.memoizedState=i.baseState=t;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=r,i=Yd.bind(null,Et,!0,r),r.dispatch=i,[t,i]},useMemoCache:Fd,useCacheRefresh:function(){return Yn().memoizedState=$S.bind(null,Et)},useEffectEvent:function(t){var i=Yn(),r={impl:t};return i.memoizedState=r,function(){if((Wt&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}},Zd={readContext:Fn,use:lc,useCallback:qg,useContext:Fn,useEffect:kd,useImperativeHandle:Wg,useInsertionEffect:kg,useLayoutEffect:jg,useMemo:Yg,useReducer:cc,useRef:Hg,useState:function(){return cc(Ma)},useDebugValue:jd,useDeferredValue:function(t,i){var r=yn();return Zg(r,an.memoizedState,t,i)},useTransition:function(){var t=cc(Ma)[0],i=yn().memoizedState;return[typeof t=="boolean"?t:ko(t),i]},useSyncExternalStore:Eg,useId:Jg,useHostTransitionStatus:qd,useFormState:Bg,useActionState:Bg,useOptimistic:function(t,i){var r=yn();return Dg(r,an,t,i)},useMemoCache:Fd,useCacheRefresh:e0};Zd.useEffectEvent=Vg;var s0={readContext:Fn,use:lc,useCallback:qg,useContext:Fn,useEffect:kd,useImperativeHandle:Wg,useInsertionEffect:kg,useLayoutEffect:jg,useMemo:Yg,useReducer:Hd,useRef:Hg,useState:function(){return Hd(Ma)},useDebugValue:jd,useDeferredValue:function(t,i){var r=yn();return an===null?Xd(r,t,i):Zg(r,an.memoizedState,t,i)},useTransition:function(){var t=Hd(Ma)[0],i=yn().memoizedState;return[typeof t=="boolean"?t:ko(t),i]},useSyncExternalStore:Eg,useId:Jg,useHostTransitionStatus:qd,useFormState:zg,useActionState:zg,useOptimistic:function(t,i){var r=yn();return an!==null?Dg(r,an,t,i):(r.baseState=t,[t,r.queue.dispatch])},useMemoCache:Fd,useCacheRefresh:e0};s0.useEffectEvent=Vg;function Kd(t,i,r,o){i=t.memoizedState,r=r(o,i),r=r==null?i:S({},i,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var $d={enqueueSetState:function(t,i,r){t=t._reactInternals;var o=mi(),u=Ja(o);u.payload=i,r!=null&&(u.callback=r),i=es(t,u,o),i!==null&&(ni(i,t,o),zo(i,t,o))},enqueueReplaceState:function(t,i,r){t=t._reactInternals;var o=mi(),u=Ja(o);u.tag=1,u.payload=i,r!=null&&(u.callback=r),i=es(t,u,o),i!==null&&(ni(i,t,o),zo(i,t,o))},enqueueForceUpdate:function(t,i){t=t._reactInternals;var r=mi(),o=Ja(r);o.tag=2,i!=null&&(o.callback=i),i=es(t,o,r),i!==null&&(ni(i,t,r),zo(i,t,r))}};function r0(t,i,r,o,u,f,b){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(o,f,b):i.prototype&&i.prototype.isPureReactComponent?!No(r,o)||!No(u,f):!0}function o0(t,i,r,o){t=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(r,o),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(r,o),i.state!==t&&$d.enqueueReplaceState(i,i.state,null)}function Xs(t,i){var r=i;if("ref"in i){r={};for(var o in i)o!=="ref"&&(r[o]=i[o])}if(t=t.defaultProps){r===i&&(r=S({},r));for(var u in t)r[u]===void 0&&(r[u]=t[u])}return r}function l0(t){jl(t)}function c0(t){console.error(t)}function u0(t){jl(t)}function hc(t,i){try{var r=t.onUncaughtError;r(i.value,{componentStack:i.stack})}catch(o){setTimeout(function(){throw o})}}function d0(t,i,r){try{var o=t.onCaughtError;o(r.value,{componentStack:r.stack,errorBoundary:i.tag===1?i.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Qd(t,i,r){return r=Ja(r),r.tag=3,r.payload={element:null},r.callback=function(){hc(t,i)},r}function f0(t){return t=Ja(t),t.tag=3,t}function h0(t,i,r,o){var u=r.type.getDerivedStateFromError;if(typeof u=="function"){var f=o.value;t.payload=function(){return u(f)},t.callback=function(){d0(i,r,o)}}var b=r.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(t.callback=function(){d0(i,r,o),typeof u!="function"&&(rs===null?rs=new Set([this]):rs.add(this));var N=o.stack;this.componentDidCatch(o.value,{componentStack:N!==null?N:""})})}function JS(t,i,r,o,u){if(r.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(i=r.alternate,i!==null&&Tr(i,r,u,!0),r=di.current,r!==null){switch(r.tag){case 31:case 13:return Ti===null?Tc():r.alternate===null&&_n===0&&(_n=3),r.flags&=-257,r.flags|=65536,r.lanes=u,o===ec?r.flags|=16384:(i=r.updateQueue,i===null?r.updateQueue=new Set([o]):i.add(o),Ef(t,o,u)),!1;case 22:return r.flags|=65536,o===ec?r.flags|=16384:(i=r.updateQueue,i===null?(i={transitions:null,markerInstances:null,retryQueue:new Set([o])},r.updateQueue=i):(r=i.retryQueue,r===null?i.retryQueue=new Set([o]):r.add(o)),Ef(t,o,u)),!1}throw Error(s(435,r.tag))}return Ef(t,o,u),Tc(),!1}if(Ft)return i=di.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=u,o!==_d&&(t=Error(s(422),{cause:o}),Oo(Si(t,r)))):(o!==_d&&(i=Error(s(423),{cause:o}),Oo(Si(i,r))),t=t.current.alternate,t.flags|=65536,u&=-u,t.lanes|=u,o=Si(o,r),u=Qd(t.stateNode,o,u),wd(t,u),_n!==4&&(_n=2)),!1;var f=Error(s(520),{cause:o});if(f=Si(f,r),Jo===null?Jo=[f]:Jo.push(f),_n!==4&&(_n=2),i===null)return!0;o=Si(o,r),r=i;do{switch(r.tag){case 3:return r.flags|=65536,t=u&-u,r.lanes|=t,t=Qd(r.stateNode,o,t),wd(r,t),!1;case 1:if(i=r.type,f=r.stateNode,(r.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||f!==null&&typeof f.componentDidCatch=="function"&&(rs===null||!rs.has(f))))return r.flags|=65536,u&=-u,r.lanes|=u,u=f0(u),h0(u,t,r,o),wd(r,u),!1}r=r.return}while(r!==null);return!1}var Jd=Error(s(461)),En=!1;function zn(t,i,r,o){i.child=t===null?_g(i,null,r,o):ks(i,t.child,r,o)}function p0(t,i,r,o,u){r=r.render;var f=i.ref;if("ref"in o){var b={};for(var N in o)N!=="ref"&&(b[N]=o[N])}else b=o;return zs(i),o=Od(t,i,r,b,f,u),N=Pd(),t!==null&&!En?(Id(t,i,u),Ea(t,i,u)):(Ft&&N&&md(i),i.flags|=1,zn(t,i,o,u),i.child)}function m0(t,i,r,o,u){if(t===null){var f=r.type;return typeof f=="function"&&!fd(f)&&f.defaultProps===void 0&&r.compare===null?(i.tag=15,i.type=f,g0(t,i,f,o,u)):(t=Yl(r.type,null,o,i,i.mode,u),t.ref=i.ref,t.return=i,i.child=t)}if(f=t.child,!lf(t,u)){var b=f.memoizedProps;if(r=r.compare,r=r!==null?r:No,r(b,o)&&t.ref===i.ref)return Ea(t,i,u)}return i.flags|=1,t=va(f,o),t.ref=i.ref,t.return=i,i.child=t}function g0(t,i,r,o,u){if(t!==null){var f=t.memoizedProps;if(No(f,o)&&t.ref===i.ref)if(En=!1,i.pendingProps=o=f,lf(t,u))(t.flags&131072)!==0&&(En=!0);else return i.lanes=t.lanes,Ea(t,i,u)}return ef(t,i,r,o,u)}function _0(t,i,r,o){var u=o.children,f=t!==null?t.memoizedState:null;if(t===null&&i.stateNode===null&&(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((i.flags&128)!==0){if(f=f!==null?f.baseLanes|r:r,t!==null){for(o=i.child=t.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~f}else o=0,i.child=null;return v0(t,i,f,r,o)}if((r&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},t!==null&&Ql(i,f!==null?f.cachePool:null),f!==null?yg(i,f):Dd(),Sg(i);else return o=i.lanes=536870912,v0(t,i,f!==null?f.baseLanes|r:r,r,o)}else f!==null?(Ql(i,f.cachePool),yg(i,f),ns(),i.memoizedState=null):(t!==null&&Ql(i,null),Dd(),ns());return zn(t,i,u,r),i.child}function Wo(t,i){return t!==null&&t.tag===22||i.stateNode!==null||(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.sibling}function v0(t,i,r,o,u){var f=Ed();return f=f===null?null:{parent:bn._currentValue,pool:f},i.memoizedState={baseLanes:r,cachePool:f},t!==null&&Ql(i,null),Dd(),Sg(i),t!==null&&Tr(t,i,o,!0),i.childLanes=u,null}function pc(t,i){return i=gc({mode:i.mode,children:i.children},t.mode),i.ref=t.ref,t.child=i,i.return=t,i}function x0(t,i,r){return ks(i,t.child,null,r),t=pc(i,i.pendingProps),t.flags|=2,fi(i),i.memoizedState=null,t}function eb(t,i,r){var o=i.pendingProps,u=(i.flags&128)!==0;if(i.flags&=-129,t===null){if(Ft){if(o.mode==="hidden")return t=pc(i,o),i.lanes=536870912,Wo(null,t);if(Ud(i),(t=un)?(t=N_(t,Ei),t=t!==null&&t.data==="&"?t:null,t!==null&&(i.memoizedState={dehydrated:t,treeContext:Ya!==null?{id:ia,overflow:aa}:null,retryLane:536870912,hydrationErrors:null},r=ng(t),r.return=i,i.child=r,Bn=i,un=null)):t=null,t===null)throw Ka(i);return i.lanes=536870912,null}return pc(i,o)}var f=t.memoizedState;if(f!==null){var b=f.dehydrated;if(Ud(i),u)if(i.flags&256)i.flags&=-257,i=x0(t,i,r);else if(i.memoizedState!==null)i.child=t.child,i.flags|=128,i=null;else throw Error(s(558));else if(En||Tr(t,i,r,!1),u=(r&t.childLanes)!==0,En||u){if(o=ln,o!==null&&(b=Sn(o,r),b!==0&&b!==f.retryLane))throw f.retryLane=b,Ps(t,b),ni(o,t,b),Jd;Tc(),i=x0(t,i,r)}else t=f.treeContext,un=Ai(b.nextSibling),Bn=i,Ft=!0,Za=null,Ei=!1,t!==null&&sg(i,t),i=pc(i,o),i.flags|=4096;return i}return t=va(t.child,{mode:o.mode,children:o.children}),t.ref=i.ref,i.child=t,t.return=i,t}function mc(t,i){var r=i.ref;if(r===null)t!==null&&t.ref!==null&&(i.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(s(284));(t===null||t.ref!==r)&&(i.flags|=4194816)}}function ef(t,i,r,o,u){return zs(i),r=Od(t,i,r,o,void 0,u),o=Pd(),t!==null&&!En?(Id(t,i,u),Ea(t,i,u)):(Ft&&o&&md(i),i.flags|=1,zn(t,i,r,u),i.child)}function y0(t,i,r,o,u,f){return zs(i),i.updateQueue=null,r=Mg(i,o,r,u),bg(t),o=Pd(),t!==null&&!En?(Id(t,i,f),Ea(t,i,f)):(Ft&&o&&md(i),i.flags|=1,zn(t,i,r,f),i.child)}function S0(t,i,r,o,u){if(zs(i),i.stateNode===null){var f=Sr,b=r.contextType;typeof b=="object"&&b!==null&&(f=Fn(b)),f=new r(o,f),i.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=$d,i.stateNode=f,f._reactInternals=i,f=i.stateNode,f.props=o,f.state=i.memoizedState,f.refs={},Ad(i),b=r.contextType,f.context=typeof b=="object"&&b!==null?Fn(b):Sr,f.state=i.memoizedState,b=r.getDerivedStateFromProps,typeof b=="function"&&(Kd(i,r,b,o),f.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(b=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),b!==f.state&&$d.enqueueReplaceState(f,f.state,null),Go(i,o,f,u),Ho(),f.state=i.memoizedState),typeof f.componentDidMount=="function"&&(i.flags|=4194308),o=!0}else if(t===null){f=i.stateNode;var N=i.memoizedProps,q=Xs(r,N);f.props=q;var de=f.context,Se=r.contextType;b=Sr,typeof Se=="object"&&Se!==null&&(b=Fn(Se));var we=r.getDerivedStateFromProps;Se=typeof we=="function"||typeof f.getSnapshotBeforeUpdate=="function",N=i.pendingProps!==N,Se||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(N||de!==b)&&o0(i,f,o,b),Qa=!1;var he=i.memoizedState;f.state=he,Go(i,o,f,u),Ho(),de=i.memoizedState,N||he!==de||Qa?(typeof we=="function"&&(Kd(i,r,we,o),de=i.memoizedState),(q=Qa||r0(i,r,q,o,he,de,b))?(Se||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount()),typeof f.componentDidMount=="function"&&(i.flags|=4194308)):(typeof f.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=o,i.memoizedState=de),f.props=o,f.state=de,f.context=b,o=q):(typeof f.componentDidMount=="function"&&(i.flags|=4194308),o=!1)}else{f=i.stateNode,Cd(t,i),b=i.memoizedProps,Se=Xs(r,b),f.props=Se,we=i.pendingProps,he=f.context,de=r.contextType,q=Sr,typeof de=="object"&&de!==null&&(q=Fn(de)),N=r.getDerivedStateFromProps,(de=typeof N=="function"||typeof f.getSnapshotBeforeUpdate=="function")||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(b!==we||he!==q)&&o0(i,f,o,q),Qa=!1,he=i.memoizedState,f.state=he,Go(i,o,f,u),Ho();var me=i.memoizedState;b!==we||he!==me||Qa||t!==null&&t.dependencies!==null&&Kl(t.dependencies)?(typeof N=="function"&&(Kd(i,r,N,o),me=i.memoizedState),(Se=Qa||r0(i,r,Se,o,he,me,q)||t!==null&&t.dependencies!==null&&Kl(t.dependencies))?(de||typeof f.UNSAFE_componentWillUpdate!="function"&&typeof f.componentWillUpdate!="function"||(typeof f.componentWillUpdate=="function"&&f.componentWillUpdate(o,me,q),typeof f.UNSAFE_componentWillUpdate=="function"&&f.UNSAFE_componentWillUpdate(o,me,q)),typeof f.componentDidUpdate=="function"&&(i.flags|=4),typeof f.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof f.componentDidUpdate!="function"||b===t.memoizedProps&&he===t.memoizedState||(i.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||b===t.memoizedProps&&he===t.memoizedState||(i.flags|=1024),i.memoizedProps=o,i.memoizedState=me),f.props=o,f.state=me,f.context=q,o=Se):(typeof f.componentDidUpdate!="function"||b===t.memoizedProps&&he===t.memoizedState||(i.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||b===t.memoizedProps&&he===t.memoizedState||(i.flags|=1024),o=!1)}return f=o,mc(t,i),o=(i.flags&128)!==0,f||o?(f=i.stateNode,r=o&&typeof r.getDerivedStateFromError!="function"?null:f.render(),i.flags|=1,t!==null&&o?(i.child=ks(i,t.child,null,u),i.child=ks(i,null,r,u)):zn(t,i,r,u),i.memoizedState=f.state,t=i.child):t=Ea(t,i,u),t}function b0(t,i,r,o){return Bs(),i.flags|=256,zn(t,i,r,o),i.child}var tf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function nf(t){return{baseLanes:t,cachePool:dg()}}function af(t,i,r){return t=t!==null?t.childLanes&~r:0,i&&(t|=pi),t}function M0(t,i,r){var o=i.pendingProps,u=!1,f=(i.flags&128)!==0,b;if((b=f)||(b=t!==null&&t.memoizedState===null?!1:(xn.current&2)!==0),b&&(u=!0,i.flags&=-129),b=(i.flags&32)!==0,i.flags&=-33,t===null){if(Ft){if(u?ts(i):ns(),(t=un)?(t=N_(t,Ei),t=t!==null&&t.data!=="&"?t:null,t!==null&&(i.memoizedState={dehydrated:t,treeContext:Ya!==null?{id:ia,overflow:aa}:null,retryLane:536870912,hydrationErrors:null},r=ng(t),r.return=i,i.child=r,Bn=i,un=null)):t=null,t===null)throw Ka(i);return Hf(t)?i.lanes=32:i.lanes=536870912,null}var N=o.children;return o=o.fallback,u?(ns(),u=i.mode,N=gc({mode:"hidden",children:N},u),o=Is(o,u,r,null),N.return=i,o.return=i,N.sibling=o,i.child=N,o=i.child,o.memoizedState=nf(r),o.childLanes=af(t,b,r),i.memoizedState=tf,Wo(null,o)):(ts(i),sf(i,N))}var q=t.memoizedState;if(q!==null&&(N=q.dehydrated,N!==null)){if(f)i.flags&256?(ts(i),i.flags&=-257,i=rf(t,i,r)):i.memoizedState!==null?(ns(),i.child=t.child,i.flags|=128,i=null):(ns(),N=o.fallback,u=i.mode,o=gc({mode:"visible",children:o.children},u),N=Is(N,u,r,null),N.flags|=2,o.return=i,N.return=i,o.sibling=N,i.child=o,ks(i,t.child,null,r),o=i.child,o.memoizedState=nf(r),o.childLanes=af(t,b,r),i.memoizedState=tf,i=Wo(null,o));else if(ts(i),Hf(N)){if(b=N.nextSibling&&N.nextSibling.dataset,b)var de=b.dgst;b=de,o=Error(s(419)),o.stack="",o.digest=b,Oo({value:o,source:null,stack:null}),i=rf(t,i,r)}else if(En||Tr(t,i,r,!1),b=(r&t.childLanes)!==0,En||b){if(b=ln,b!==null&&(o=Sn(b,r),o!==0&&o!==q.retryLane))throw q.retryLane=o,Ps(t,o),ni(b,t,o),Jd;zf(N)||Tc(),i=rf(t,i,r)}else zf(N)?(i.flags|=192,i.child=t.child,i=null):(t=q.treeContext,un=Ai(N.nextSibling),Bn=i,Ft=!0,Za=null,Ei=!1,t!==null&&sg(i,t),i=sf(i,o.children),i.flags|=4096);return i}return u?(ns(),N=o.fallback,u=i.mode,q=t.child,de=q.sibling,o=va(q,{mode:"hidden",children:o.children}),o.subtreeFlags=q.subtreeFlags&65011712,de!==null?N=va(de,N):(N=Is(N,u,r,null),N.flags|=2),N.return=i,o.return=i,o.sibling=N,i.child=o,Wo(null,o),o=i.child,N=t.child.memoizedState,N===null?N=nf(r):(u=N.cachePool,u!==null?(q=bn._currentValue,u=u.parent!==q?{parent:q,pool:q}:u):u=dg(),N={baseLanes:N.baseLanes|r,cachePool:u}),o.memoizedState=N,o.childLanes=af(t,b,r),i.memoizedState=tf,Wo(t.child,o)):(ts(i),r=t.child,t=r.sibling,r=va(r,{mode:"visible",children:o.children}),r.return=i,r.sibling=null,t!==null&&(b=i.deletions,b===null?(i.deletions=[t],i.flags|=16):b.push(t)),i.child=r,i.memoizedState=null,r)}function sf(t,i){return i=gc({mode:"visible",children:i},t.mode),i.return=t,t.child=i}function gc(t,i){return t=ui(22,t,null,i),t.lanes=0,t}function rf(t,i,r){return ks(i,t.child,null,r),t=sf(i,i.pendingProps.children),t.flags|=2,i.memoizedState=null,t}function E0(t,i,r){t.lanes|=i;var o=t.alternate;o!==null&&(o.lanes|=i),yd(t.return,i,r)}function of(t,i,r,o,u,f){var b=t.memoizedState;b===null?t.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:o,tail:r,tailMode:u,treeForkCount:f}:(b.isBackwards=i,b.rendering=null,b.renderingStartTime=0,b.last=o,b.tail=r,b.tailMode=u,b.treeForkCount=f)}function T0(t,i,r){var o=i.pendingProps,u=o.revealOrder,f=o.tail;o=o.children;var b=xn.current,N=(b&2)!==0;if(N?(b=b&1|2,i.flags|=128):b&=1,Ee(xn,b),zn(t,i,o,r),o=Ft?Lo:0,!N&&t!==null&&(t.flags&128)!==0)e:for(t=i.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&E0(t,r,i);else if(t.tag===19)E0(t,r,i);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===i)break e;for(;t.sibling===null;){if(t.return===null||t.return===i)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(u){case"forwards":for(r=i.child,u=null;r!==null;)t=r.alternate,t!==null&&ac(t)===null&&(u=r),r=r.sibling;r=u,r===null?(u=i.child,i.child=null):(u=r.sibling,r.sibling=null),of(i,!1,u,r,f,o);break;case"backwards":case"unstable_legacy-backwards":for(r=null,u=i.child,i.child=null;u!==null;){if(t=u.alternate,t!==null&&ac(t)===null){i.child=u;break}t=u.sibling,u.sibling=r,r=u,u=t}of(i,!0,r,null,f,o);break;case"together":of(i,!1,null,null,void 0,o);break;default:i.memoizedState=null}return i.child}function Ea(t,i,r){if(t!==null&&(i.dependencies=t.dependencies),ss|=i.lanes,(r&i.childLanes)===0)if(t!==null){if(Tr(t,i,r,!1),(r&i.childLanes)===0)return null}else return null;if(t!==null&&i.child!==t.child)throw Error(s(153));if(i.child!==null){for(t=i.child,r=va(t,t.pendingProps),i.child=r,r.return=i;t.sibling!==null;)t=t.sibling,r=r.sibling=va(t,t.pendingProps),r.return=i;r.sibling=null}return i.child}function lf(t,i){return(t.lanes&i)!==0?!0:(t=t.dependencies,!!(t!==null&&Kl(t)))}function tb(t,i,r){switch(i.tag){case 3:Ae(i,i.stateNode.containerInfo),$a(i,bn,t.memoizedState.cache),Bs();break;case 27:case 5:at(i);break;case 4:Ae(i,i.stateNode.containerInfo);break;case 10:$a(i,i.type,i.memoizedProps.value);break;case 31:if(i.memoizedState!==null)return i.flags|=128,Ud(i),null;break;case 13:var o=i.memoizedState;if(o!==null)return o.dehydrated!==null?(ts(i),i.flags|=128,null):(r&i.child.childLanes)!==0?M0(t,i,r):(ts(i),t=Ea(t,i,r),t!==null?t.sibling:null);ts(i);break;case 19:var u=(t.flags&128)!==0;if(o=(r&i.childLanes)!==0,o||(Tr(t,i,r,!1),o=(r&i.childLanes)!==0),u){if(o)return T0(t,i,r);i.flags|=128}if(u=i.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),Ee(xn,xn.current),o)break;return null;case 22:return i.lanes=0,_0(t,i,r,i.pendingProps);case 24:$a(i,bn,t.memoizedState.cache)}return Ea(t,i,r)}function A0(t,i,r){if(t!==null)if(t.memoizedProps!==i.pendingProps)En=!0;else{if(!lf(t,r)&&(i.flags&128)===0)return En=!1,tb(t,i,r);En=(t.flags&131072)!==0}else En=!1,Ft&&(i.flags&1048576)!==0&&ag(i,Lo,i.index);switch(i.lanes=0,i.tag){case 16:e:{var o=i.pendingProps;if(t=Gs(i.elementType),i.type=t,typeof t=="function")fd(t)?(o=Xs(t,o),i.tag=1,i=S0(null,i,t,o,r)):(i.tag=0,i=ef(null,i,t,o,r));else{if(t!=null){var u=t.$$typeof;if(u===R){i.tag=11,i=p0(null,i,t,o,r);break e}else if(u===L){i.tag=14,i=m0(null,i,t,o,r);break e}}throw i=pe(t)||t,Error(s(306,i,""))}}return i;case 0:return ef(t,i,i.type,i.pendingProps,r);case 1:return o=i.type,u=Xs(o,i.pendingProps),S0(t,i,o,u,r);case 3:e:{if(Ae(i,i.stateNode.containerInfo),t===null)throw Error(s(387));o=i.pendingProps;var f=i.memoizedState;u=f.element,Cd(t,i),Go(i,o,null,r);var b=i.memoizedState;if(o=b.cache,$a(i,bn,o),o!==f.cache&&Sd(i,[bn],r,!0),Ho(),o=b.element,f.isDehydrated)if(f={element:o,isDehydrated:!1,cache:b.cache},i.updateQueue.baseState=f,i.memoizedState=f,i.flags&256){i=b0(t,i,o,r);break e}else if(o!==u){u=Si(Error(s(424)),i),Oo(u),i=b0(t,i,o,r);break e}else for(t=i.stateNode.containerInfo,t.nodeType===9?t=t.body:t=t.nodeName==="HTML"?t.ownerDocument.body:t,un=Ai(t.firstChild),Bn=i,Ft=!0,Za=null,Ei=!0,r=_g(i,null,o,r),i.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Bs(),o===u){i=Ea(t,i,r);break e}zn(t,i,o,r)}i=i.child}return i;case 26:return mc(t,i),t===null?(r=B_(i.type,null,i.pendingProps,null))?i.memoizedState=r:Ft||(r=i.type,t=i.pendingProps,o=Uc(oe.current).createElement(r),o[vt]=i,o[vn]=t,Hn(o,r,t),mn(o),i.stateNode=o):i.memoizedState=B_(i.type,t.memoizedProps,i.pendingProps,t.memoizedState),null;case 27:return at(i),t===null&&Ft&&(o=i.stateNode=O_(i.type,i.pendingProps,oe.current),Bn=i,Ei=!0,u=un,us(i.type)?(Gf=u,un=Ai(o.firstChild)):un=u),zn(t,i,i.pendingProps.children,r),mc(t,i),t===null&&(i.flags|=4194304),i.child;case 5:return t===null&&Ft&&((u=o=un)&&(o=Nb(o,i.type,i.pendingProps,Ei),o!==null?(i.stateNode=o,Bn=i,un=Ai(o.firstChild),Ei=!1,u=!0):u=!1),u||Ka(i)),at(i),u=i.type,f=i.pendingProps,b=t!==null?t.memoizedProps:null,o=f.children,If(u,f)?o=null:b!==null&&If(u,b)&&(i.flags|=32),i.memoizedState!==null&&(u=Od(t,i,WS,null,null,r),ol._currentValue=u),mc(t,i),zn(t,i,o,r),i.child;case 6:return t===null&&Ft&&((t=r=un)&&(r=Ub(r,i.pendingProps,Ei),r!==null?(i.stateNode=r,Bn=i,un=null,t=!0):t=!1),t||Ka(i)),null;case 13:return M0(t,i,r);case 4:return Ae(i,i.stateNode.containerInfo),o=i.pendingProps,t===null?i.child=ks(i,null,o,r):zn(t,i,o,r),i.child;case 11:return p0(t,i,i.type,i.pendingProps,r);case 7:return zn(t,i,i.pendingProps,r),i.child;case 8:return zn(t,i,i.pendingProps.children,r),i.child;case 12:return zn(t,i,i.pendingProps.children,r),i.child;case 10:return o=i.pendingProps,$a(i,i.type,o.value),zn(t,i,o.children,r),i.child;case 9:return u=i.type._context,o=i.pendingProps.children,zs(i),u=Fn(u),o=o(u),i.flags|=1,zn(t,i,o,r),i.child;case 14:return m0(t,i,i.type,i.pendingProps,r);case 15:return g0(t,i,i.type,i.pendingProps,r);case 19:return T0(t,i,r);case 31:return eb(t,i,r);case 22:return _0(t,i,r,i.pendingProps);case 24:return zs(i),o=Fn(bn),t===null?(u=Ed(),u===null&&(u=ln,f=bd(),u.pooledCache=f,f.refCount++,f!==null&&(u.pooledCacheLanes|=r),u=f),i.memoizedState={parent:o,cache:u},Ad(i),$a(i,bn,u)):((t.lanes&r)!==0&&(Cd(t,i),Go(i,null,null,r),Ho()),u=t.memoizedState,f=i.memoizedState,u.parent!==o?(u={parent:o,cache:o},i.memoizedState=u,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=u),$a(i,bn,o)):(o=f.cache,$a(i,bn,o),o!==u.cache&&Sd(i,[bn],r,!0))),zn(t,i,i.pendingProps.children,r),i.child;case 29:throw i.pendingProps}throw Error(s(156,i.tag))}function Ta(t){t.flags|=4}function cf(t,i,r,o,u){if((i=(t.mode&32)!==0)&&(i=!1),i){if(t.flags|=16777216,(u&335544128)===u)if(t.stateNode.complete)t.flags|=8192;else if(J0())t.flags|=8192;else throw Vs=ec,Td}else t.flags&=-16777217}function C0(t,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!V_(i))if(J0())t.flags|=8192;else throw Vs=ec,Td}function _c(t,i){i!==null&&(t.flags|=4),t.flags&16384&&(i=t.tag!==22?De():536870912,t.lanes|=i,Br|=i)}function qo(t,i){if(!Ft)switch(t.tailMode){case"hidden":i=t.tail;for(var r=null;i!==null;)i.alternate!==null&&(r=i),i=i.sibling;r===null?t.tail=null:r.sibling=null;break;case"collapsed":r=t.tail;for(var o=null;r!==null;)r.alternate!==null&&(o=r),r=r.sibling;o===null?i||t.tail===null?t.tail=null:t.tail.sibling=null:o.sibling=null}}function dn(t){var i=t.alternate!==null&&t.alternate.child===t.child,r=0,o=0;if(i)for(var u=t.child;u!==null;)r|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=t,u=u.sibling;else for(u=t.child;u!==null;)r|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=t,u=u.sibling;return t.subtreeFlags|=o,t.childLanes=r,i}function nb(t,i,r){var o=i.pendingProps;switch(gd(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dn(i),null;case 1:return dn(i),null;case 3:return r=i.stateNode,o=null,t!==null&&(o=t.memoizedState.cache),i.memoizedState.cache!==o&&(i.flags|=2048),Sa(bn),ze(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Er(i)?Ta(i):t===null||t.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,vd())),dn(i),null;case 26:var u=i.type,f=i.memoizedState;return t===null?(Ta(i),f!==null?(dn(i),C0(i,f)):(dn(i),cf(i,u,null,o,r))):f?f!==t.memoizedState?(Ta(i),dn(i),C0(i,f)):(dn(i),i.flags&=-16777217):(t=t.memoizedProps,t!==o&&Ta(i),dn(i),cf(i,u,t,o,r)),null;case 27:if(Je(i),r=oe.current,u=i.type,t!==null&&i.stateNode!=null)t.memoizedProps!==o&&Ta(i);else{if(!o){if(i.stateNode===null)throw Error(s(166));return dn(i),null}t=Le.current,Er(i)?rg(i):(t=O_(u,o,r),i.stateNode=t,Ta(i))}return dn(i),null;case 5:if(Je(i),u=i.type,t!==null&&i.stateNode!=null)t.memoizedProps!==o&&Ta(i);else{if(!o){if(i.stateNode===null)throw Error(s(166));return dn(i),null}if(f=Le.current,Er(i))rg(i);else{var b=Uc(oe.current);switch(f){case 1:f=b.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:f=b.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":f=b.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":f=b.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":f=b.createElement("div"),f.innerHTML="<script><\/script>",f=f.removeChild(f.firstChild);break;case"select":f=typeof o.is=="string"?b.createElement("select",{is:o.is}):b.createElement("select"),o.multiple?f.multiple=!0:o.size&&(f.size=o.size);break;default:f=typeof o.is=="string"?b.createElement(u,{is:o.is}):b.createElement(u)}}f[vt]=i,f[vn]=o;e:for(b=i.child;b!==null;){if(b.tag===5||b.tag===6)f.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===i)break e;for(;b.sibling===null;){if(b.return===null||b.return===i)break e;b=b.return}b.sibling.return=b.return,b=b.sibling}i.stateNode=f;e:switch(Hn(f,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Ta(i)}}return dn(i),cf(i,i.type,t===null?null:t.memoizedProps,i.pendingProps,r),null;case 6:if(t&&i.stateNode!=null)t.memoizedProps!==o&&Ta(i);else{if(typeof o!="string"&&i.stateNode===null)throw Error(s(166));if(t=oe.current,Er(i)){if(t=i.stateNode,r=i.memoizedProps,o=null,u=Bn,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}t[vt]=i,t=!!(t.nodeValue===r||o!==null&&o.suppressHydrationWarning===!0||M_(t.nodeValue,r)),t||Ka(i,!0)}else t=Uc(t).createTextNode(o),t[vt]=i,i.stateNode=t}return dn(i),null;case 31:if(r=i.memoizedState,t===null||t.memoizedState!==null){if(o=Er(i),r!==null){if(t===null){if(!o)throw Error(s(318));if(t=i.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[vt]=i}else Bs(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;dn(i),t=!1}else r=vd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=r),t=!0;if(!t)return i.flags&256?(fi(i),i):(fi(i),null);if((i.flags&128)!==0)throw Error(s(558))}return dn(i),null;case 13:if(o=i.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(u=Er(i),o!==null&&o.dehydrated!==null){if(t===null){if(!u)throw Error(s(318));if(u=i.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[vt]=i}else Bs(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;dn(i),u=!1}else u=vd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=u),u=!0;if(!u)return i.flags&256?(fi(i),i):(fi(i),null)}return fi(i),(i.flags&128)!==0?(i.lanes=r,i):(r=o!==null,t=t!==null&&t.memoizedState!==null,r&&(o=i.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),f=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(f=o.memoizedState.cachePool.pool),f!==u&&(o.flags|=2048)),r!==t&&r&&(i.child.flags|=8192),_c(i,i.updateQueue),dn(i),null);case 4:return ze(),t===null&&Nf(i.stateNode.containerInfo),dn(i),null;case 10:return Sa(i.type),dn(i),null;case 19:if(te(xn),o=i.memoizedState,o===null)return dn(i),null;if(u=(i.flags&128)!==0,f=o.rendering,f===null)if(u)qo(o,!1);else{if(_n!==0||t!==null&&(t.flags&128)!==0)for(t=i.child;t!==null;){if(f=ac(t),f!==null){for(i.flags|=128,qo(o,!1),t=f.updateQueue,i.updateQueue=t,_c(i,t),i.subtreeFlags=0,t=r,r=i.child;r!==null;)tg(r,t),r=r.sibling;return Ee(xn,xn.current&1|2),Ft&&xa(i,o.treeForkCount),i.child}t=t.sibling}o.tail!==null&&Ue()>bc&&(i.flags|=128,u=!0,qo(o,!1),i.lanes=4194304)}else{if(!u)if(t=ac(f),t!==null){if(i.flags|=128,u=!0,t=t.updateQueue,i.updateQueue=t,_c(i,t),qo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!f.alternate&&!Ft)return dn(i),null}else 2*Ue()-o.renderingStartTime>bc&&r!==536870912&&(i.flags|=128,u=!0,qo(o,!1),i.lanes=4194304);o.isBackwards?(f.sibling=i.child,i.child=f):(t=o.last,t!==null?t.sibling=f:i.child=f,o.last=f)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Ue(),t.sibling=null,r=xn.current,Ee(xn,u?r&1|2:r&1),Ft&&xa(i,o.treeForkCount),t):(dn(i),null);case 22:case 23:return fi(i),Nd(),o=i.memoizedState!==null,t!==null?t.memoizedState!==null!==o&&(i.flags|=8192):o&&(i.flags|=8192),o?(r&536870912)!==0&&(i.flags&128)===0&&(dn(i),i.subtreeFlags&6&&(i.flags|=8192)):dn(i),r=i.updateQueue,r!==null&&_c(i,r.retryQueue),r=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==r&&(i.flags|=2048),t!==null&&te(Hs),null;case 24:return r=null,t!==null&&(r=t.memoizedState.cache),i.memoizedState.cache!==r&&(i.flags|=2048),Sa(bn),dn(i),null;case 25:return null;case 30:return null}throw Error(s(156,i.tag))}function ib(t,i){switch(gd(i),i.tag){case 1:return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 3:return Sa(bn),ze(),t=i.flags,(t&65536)!==0&&(t&128)===0?(i.flags=t&-65537|128,i):null;case 26:case 27:case 5:return Je(i),null;case 31:if(i.memoizedState!==null){if(fi(i),i.alternate===null)throw Error(s(340));Bs()}return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 13:if(fi(i),t=i.memoizedState,t!==null&&t.dehydrated!==null){if(i.alternate===null)throw Error(s(340));Bs()}return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 19:return te(xn),null;case 4:return ze(),null;case 10:return Sa(i.type),null;case 22:case 23:return fi(i),Nd(),t!==null&&te(Hs),t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 24:return Sa(bn),null;case 25:return null;default:return null}}function w0(t,i){switch(gd(i),i.tag){case 3:Sa(bn),ze();break;case 26:case 27:case 5:Je(i);break;case 4:ze();break;case 31:i.memoizedState!==null&&fi(i);break;case 13:fi(i);break;case 19:te(xn);break;case 10:Sa(i.type);break;case 22:case 23:fi(i),Nd(),t!==null&&te(Hs);break;case 24:Sa(bn)}}function Yo(t,i){try{var r=i.updateQueue,o=r!==null?r.lastEffect:null;if(o!==null){var u=o.next;r=u;do{if((r.tag&t)===t){o=void 0;var f=r.create,b=r.inst;o=f(),b.destroy=o}r=r.next}while(r!==u)}}catch(N){en(i,i.return,N)}}function is(t,i,r){try{var o=i.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var f=u.next;o=f;do{if((o.tag&t)===t){var b=o.inst,N=b.destroy;if(N!==void 0){b.destroy=void 0,u=i;var q=r,de=N;try{de()}catch(Se){en(u,q,Se)}}}o=o.next}while(o!==f)}}catch(Se){en(i,i.return,Se)}}function R0(t){var i=t.updateQueue;if(i!==null){var r=t.stateNode;try{xg(i,r)}catch(o){en(t,t.return,o)}}}function D0(t,i,r){r.props=Xs(t.type,t.memoizedProps),r.state=t.memoizedState;try{r.componentWillUnmount()}catch(o){en(t,i,o)}}function Zo(t,i){try{var r=t.ref;if(r!==null){switch(t.tag){case 26:case 27:case 5:var o=t.stateNode;break;case 30:o=t.stateNode;break;default:o=t.stateNode}typeof r=="function"?t.refCleanup=r(o):r.current=o}}catch(u){en(t,i,u)}}function sa(t,i){var r=t.ref,o=t.refCleanup;if(r!==null)if(typeof o=="function")try{o()}catch(u){en(t,i,u)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(u){en(t,i,u)}else r.current=null}function N0(t){var i=t.type,r=t.memoizedProps,o=t.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":r.autoFocus&&o.focus();break e;case"img":r.src?o.src=r.src:r.srcSet&&(o.srcset=r.srcSet)}}catch(u){en(t,t.return,u)}}function uf(t,i,r){try{var o=t.stateNode;Tb(o,t.type,r,i),o[vn]=i}catch(u){en(t,t.return,u)}}function U0(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&us(t.type)||t.tag===4}function df(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||U0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&us(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function ff(t,i,r){var o=t.tag;if(o===5||o===6)t=t.stateNode,i?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(t,i):(i=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,i.appendChild(t),r=r._reactRootContainer,r!=null||i.onclick!==null||(i.onclick=ga));else if(o!==4&&(o===27&&us(t.type)&&(r=t.stateNode,i=null),t=t.child,t!==null))for(ff(t,i,r),t=t.sibling;t!==null;)ff(t,i,r),t=t.sibling}function vc(t,i,r){var o=t.tag;if(o===5||o===6)t=t.stateNode,i?r.insertBefore(t,i):r.appendChild(t);else if(o!==4&&(o===27&&us(t.type)&&(r=t.stateNode),t=t.child,t!==null))for(vc(t,i,r),t=t.sibling;t!==null;)vc(t,i,r),t=t.sibling}function L0(t){var i=t.stateNode,r=t.memoizedProps;try{for(var o=t.type,u=i.attributes;u.length;)i.removeAttributeNode(u[0]);Hn(i,o,r),i[vt]=t,i[vn]=r}catch(f){en(t,t.return,f)}}var Aa=!1,Tn=!1,hf=!1,O0=typeof WeakSet=="function"?WeakSet:Set,On=null;function ab(t,i){if(t=t.containerInfo,Of=zc,t=Wm(t),sd(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var o=r.getSelection&&r.getSelection();if(o&&o.rangeCount!==0){r=o.anchorNode;var u=o.anchorOffset,f=o.focusNode;o=o.focusOffset;try{r.nodeType,f.nodeType}catch{r=null;break e}var b=0,N=-1,q=-1,de=0,Se=0,we=t,he=null;t:for(;;){for(var me;we!==r||u!==0&&we.nodeType!==3||(N=b+u),we!==f||o!==0&&we.nodeType!==3||(q=b+o),we.nodeType===3&&(b+=we.nodeValue.length),(me=we.firstChild)!==null;)he=we,we=me;for(;;){if(we===t)break t;if(he===r&&++de===u&&(N=b),he===f&&++Se===o&&(q=b),(me=we.nextSibling)!==null)break;we=he,he=we.parentNode}we=me}r=N===-1||q===-1?null:{start:N,end:q}}else r=null}r=r||{start:0,end:0}}else r=null;for(Pf={focusedElem:t,selectionRange:r},zc=!1,On=i;On!==null;)if(i=On,t=i.child,(i.subtreeFlags&1028)!==0&&t!==null)t.return=i,On=t;else for(;On!==null;){switch(i=On,f=i.alternate,t=i.flags,i.tag){case 0:if((t&4)!==0&&(t=i.updateQueue,t=t!==null?t.events:null,t!==null))for(r=0;r<t.length;r++)u=t[r],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&f!==null){t=void 0,r=i,u=f.memoizedProps,f=f.memoizedState,o=r.stateNode;try{var tt=Xs(r.type,u);t=o.getSnapshotBeforeUpdate(tt,f),o.__reactInternalSnapshotBeforeUpdate=t}catch(pt){en(r,r.return,pt)}}break;case 3:if((t&1024)!==0){if(t=i.stateNode.containerInfo,r=t.nodeType,r===9)Ff(t);else if(r===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Ff(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(s(163))}if(t=i.sibling,t!==null){t.return=i.return,On=t;break}On=i.return}}function P0(t,i,r){var o=r.flags;switch(r.tag){case 0:case 11:case 15:wa(t,r),o&4&&Yo(5,r);break;case 1:if(wa(t,r),o&4)if(t=r.stateNode,i===null)try{t.componentDidMount()}catch(b){en(r,r.return,b)}else{var u=Xs(r.type,i.memoizedProps);i=i.memoizedState;try{t.componentDidUpdate(u,i,t.__reactInternalSnapshotBeforeUpdate)}catch(b){en(r,r.return,b)}}o&64&&R0(r),o&512&&Zo(r,r.return);break;case 3:if(wa(t,r),o&64&&(t=r.updateQueue,t!==null)){if(i=null,r.child!==null)switch(r.child.tag){case 27:case 5:i=r.child.stateNode;break;case 1:i=r.child.stateNode}try{xg(t,i)}catch(b){en(r,r.return,b)}}break;case 27:i===null&&o&4&&L0(r);case 26:case 5:wa(t,r),i===null&&o&4&&N0(r),o&512&&Zo(r,r.return);break;case 12:wa(t,r);break;case 31:wa(t,r),o&4&&F0(t,r);break;case 13:wa(t,r),o&4&&z0(t,r),o&64&&(t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(r=hb.bind(null,r),Lb(t,r))));break;case 22:if(o=r.memoizedState!==null||Aa,!o){i=i!==null&&i.memoizedState!==null||Tn,u=Aa;var f=Tn;Aa=o,(Tn=i)&&!f?Ra(t,r,(r.subtreeFlags&8772)!==0):wa(t,r),Aa=u,Tn=f}break;case 30:break;default:wa(t,r)}}function I0(t){var i=t.alternate;i!==null&&(t.alternate=null,I0(i)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(i=t.stateNode,i!==null&&ea(i)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var hn=null,Qn=!1;function Ca(t,i,r){for(r=r.child;r!==null;)B0(t,i,r),r=r.sibling}function B0(t,i,r){if(le&&typeof le.onCommitFiberUnmount=="function")try{le.onCommitFiberUnmount(ge,r)}catch{}switch(r.tag){case 26:Tn||sa(r,i),Ca(t,i,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:Tn||sa(r,i);var o=hn,u=Qn;us(r.type)&&(hn=r.stateNode,Qn=!1),Ca(t,i,r),al(r.stateNode),hn=o,Qn=u;break;case 5:Tn||sa(r,i);case 6:if(o=hn,u=Qn,hn=null,Ca(t,i,r),hn=o,Qn=u,hn!==null)if(Qn)try{(hn.nodeType===9?hn.body:hn.nodeName==="HTML"?hn.ownerDocument.body:hn).removeChild(r.stateNode)}catch(f){en(r,i,f)}else try{hn.removeChild(r.stateNode)}catch(f){en(r,i,f)}break;case 18:hn!==null&&(Qn?(t=hn,R_(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,r.stateNode),Xr(t)):R_(hn,r.stateNode));break;case 4:o=hn,u=Qn,hn=r.stateNode.containerInfo,Qn=!0,Ca(t,i,r),hn=o,Qn=u;break;case 0:case 11:case 14:case 15:is(2,r,i),Tn||is(4,r,i),Ca(t,i,r);break;case 1:Tn||(sa(r,i),o=r.stateNode,typeof o.componentWillUnmount=="function"&&D0(r,i,o)),Ca(t,i,r);break;case 21:Ca(t,i,r);break;case 22:Tn=(o=Tn)||r.memoizedState!==null,Ca(t,i,r),Tn=o;break;default:Ca(t,i,r)}}function F0(t,i){if(i.memoizedState===null&&(t=i.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{Xr(t)}catch(r){en(i,i.return,r)}}}function z0(t,i){if(i.memoizedState===null&&(t=i.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{Xr(t)}catch(r){en(i,i.return,r)}}function sb(t){switch(t.tag){case 31:case 13:case 19:var i=t.stateNode;return i===null&&(i=t.stateNode=new O0),i;case 22:return t=t.stateNode,i=t._retryCache,i===null&&(i=t._retryCache=new O0),i;default:throw Error(s(435,t.tag))}}function xc(t,i){var r=sb(t);i.forEach(function(o){if(!r.has(o)){r.add(o);var u=pb.bind(null,t,o);o.then(u,u)}})}function Jn(t,i){var r=i.deletions;if(r!==null)for(var o=0;o<r.length;o++){var u=r[o],f=t,b=i,N=b;e:for(;N!==null;){switch(N.tag){case 27:if(us(N.type)){hn=N.stateNode,Qn=!1;break e}break;case 5:hn=N.stateNode,Qn=!1;break e;case 3:case 4:hn=N.stateNode.containerInfo,Qn=!0;break e}N=N.return}if(hn===null)throw Error(s(160));B0(f,b,u),hn=null,Qn=!1,f=u.alternate,f!==null&&(f.return=null),u.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)H0(i,t),i=i.sibling}var Hi=null;function H0(t,i){var r=t.alternate,o=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:Jn(i,t),ei(t),o&4&&(is(3,t,t.return),Yo(3,t),is(5,t,t.return));break;case 1:Jn(i,t),ei(t),o&512&&(Tn||r===null||sa(r,r.return)),o&64&&Aa&&(t=t.updateQueue,t!==null&&(o=t.callbacks,o!==null&&(r=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=r===null?o:r.concat(o))));break;case 26:var u=Hi;if(Jn(i,t),ei(t),o&512&&(Tn||r===null||sa(r,r.return)),o&4){var f=r!==null?r.memoizedState:null;if(o=t.memoizedState,r===null)if(o===null)if(t.stateNode===null){e:{o=t.type,r=t.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":f=u.getElementsByTagName("title")[0],(!f||f[Ji]||f[vt]||f.namespaceURI==="http://www.w3.org/2000/svg"||f.hasAttribute("itemprop"))&&(f=u.createElement(o),u.head.insertBefore(f,u.querySelector("head > title"))),Hn(f,o,r),f[vt]=t,mn(f),o=f;break e;case"link":var b=H_("link","href",u).get(o+(r.href||""));if(b){for(var N=0;N<b.length;N++)if(f=b[N],f.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&f.getAttribute("rel")===(r.rel==null?null:r.rel)&&f.getAttribute("title")===(r.title==null?null:r.title)&&f.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){b.splice(N,1);break t}}f=u.createElement(o),Hn(f,o,r),u.head.appendChild(f);break;case"meta":if(b=H_("meta","content",u).get(o+(r.content||""))){for(N=0;N<b.length;N++)if(f=b[N],f.getAttribute("content")===(r.content==null?null:""+r.content)&&f.getAttribute("name")===(r.name==null?null:r.name)&&f.getAttribute("property")===(r.property==null?null:r.property)&&f.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&f.getAttribute("charset")===(r.charSet==null?null:r.charSet)){b.splice(N,1);break t}}f=u.createElement(o),Hn(f,o,r),u.head.appendChild(f);break;default:throw Error(s(468,o))}f[vt]=t,mn(f),o=f}t.stateNode=o}else G_(u,t.type,t.stateNode);else t.stateNode=z_(u,o,t.memoizedProps);else f!==o?(f===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):f.count--,o===null?G_(u,t.type,t.stateNode):z_(u,o,t.memoizedProps)):o===null&&t.stateNode!==null&&uf(t,t.memoizedProps,r.memoizedProps)}break;case 27:Jn(i,t),ei(t),o&512&&(Tn||r===null||sa(r,r.return)),r!==null&&o&4&&uf(t,t.memoizedProps,r.memoizedProps);break;case 5:if(Jn(i,t),ei(t),o&512&&(Tn||r===null||sa(r,r.return)),t.flags&32){u=t.stateNode;try{li(u,"")}catch(tt){en(t,t.return,tt)}}o&4&&t.stateNode!=null&&(u=t.memoizedProps,uf(t,u,r!==null?r.memoizedProps:u)),o&1024&&(hf=!0);break;case 6:if(Jn(i,t),ei(t),o&4){if(t.stateNode===null)throw Error(s(162));o=t.memoizedProps,r=t.stateNode;try{r.nodeValue=o}catch(tt){en(t,t.return,tt)}}break;case 3:if(Pc=null,u=Hi,Hi=Lc(i.containerInfo),Jn(i,t),Hi=u,ei(t),o&4&&r!==null&&r.memoizedState.isDehydrated)try{Xr(i.containerInfo)}catch(tt){en(t,t.return,tt)}hf&&(hf=!1,G0(t));break;case 4:o=Hi,Hi=Lc(t.stateNode.containerInfo),Jn(i,t),ei(t),Hi=o;break;case 12:Jn(i,t),ei(t);break;case 31:Jn(i,t),ei(t),o&4&&(o=t.updateQueue,o!==null&&(t.updateQueue=null,xc(t,o)));break;case 13:Jn(i,t),ei(t),t.child.flags&8192&&t.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(Sc=Ue()),o&4&&(o=t.updateQueue,o!==null&&(t.updateQueue=null,xc(t,o)));break;case 22:u=t.memoizedState!==null;var q=r!==null&&r.memoizedState!==null,de=Aa,Se=Tn;if(Aa=de||u,Tn=Se||q,Jn(i,t),Tn=Se,Aa=de,ei(t),o&8192)e:for(i=t.stateNode,i._visibility=u?i._visibility&-2:i._visibility|1,u&&(r===null||q||Aa||Tn||Ws(t)),r=null,i=t;;){if(i.tag===5||i.tag===26){if(r===null){q=r=i;try{if(f=q.stateNode,u)b=f.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{N=q.stateNode;var we=q.memoizedProps.style,he=we!=null&&we.hasOwnProperty("display")?we.display:null;N.style.display=he==null||typeof he=="boolean"?"":(""+he).trim()}}catch(tt){en(q,q.return,tt)}}}else if(i.tag===6){if(r===null){q=i;try{q.stateNode.nodeValue=u?"":q.memoizedProps}catch(tt){en(q,q.return,tt)}}}else if(i.tag===18){if(r===null){q=i;try{var me=q.stateNode;u?D_(me,!0):D_(q.stateNode,!1)}catch(tt){en(q,q.return,tt)}}}else if((i.tag!==22&&i.tag!==23||i.memoizedState===null||i===t)&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break e;for(;i.sibling===null;){if(i.return===null||i.return===t)break e;r===i&&(r=null),i=i.return}r===i&&(r=null),i.sibling.return=i.return,i=i.sibling}o&4&&(o=t.updateQueue,o!==null&&(r=o.retryQueue,r!==null&&(o.retryQueue=null,xc(t,r))));break;case 19:Jn(i,t),ei(t),o&4&&(o=t.updateQueue,o!==null&&(t.updateQueue=null,xc(t,o)));break;case 30:break;case 21:break;default:Jn(i,t),ei(t)}}function ei(t){var i=t.flags;if(i&2){try{for(var r,o=t.return;o!==null;){if(U0(o)){r=o;break}o=o.return}if(r==null)throw Error(s(160));switch(r.tag){case 27:var u=r.stateNode,f=df(t);vc(t,f,u);break;case 5:var b=r.stateNode;r.flags&32&&(li(b,""),r.flags&=-33);var N=df(t);vc(t,N,b);break;case 3:case 4:var q=r.stateNode.containerInfo,de=df(t);ff(t,de,q);break;default:throw Error(s(161))}}catch(Se){en(t,t.return,Se)}t.flags&=-3}i&4096&&(t.flags&=-4097)}function G0(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var i=t;G0(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),t=t.sibling}}function wa(t,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)P0(t,i.alternate,i),i=i.sibling}function Ws(t){for(t=t.child;t!==null;){var i=t;switch(i.tag){case 0:case 11:case 14:case 15:is(4,i,i.return),Ws(i);break;case 1:sa(i,i.return);var r=i.stateNode;typeof r.componentWillUnmount=="function"&&D0(i,i.return,r),Ws(i);break;case 27:al(i.stateNode);case 26:case 5:sa(i,i.return),Ws(i);break;case 22:i.memoizedState===null&&Ws(i);break;case 30:Ws(i);break;default:Ws(i)}t=t.sibling}}function Ra(t,i,r){for(r=r&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var o=i.alternate,u=t,f=i,b=f.flags;switch(f.tag){case 0:case 11:case 15:Ra(u,f,r),Yo(4,f);break;case 1:if(Ra(u,f,r),o=f,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(de){en(o,o.return,de)}if(o=f,u=o.updateQueue,u!==null){var N=o.stateNode;try{var q=u.shared.hiddenCallbacks;if(q!==null)for(u.shared.hiddenCallbacks=null,u=0;u<q.length;u++)vg(q[u],N)}catch(de){en(o,o.return,de)}}r&&b&64&&R0(f),Zo(f,f.return);break;case 27:L0(f);case 26:case 5:Ra(u,f,r),r&&o===null&&b&4&&N0(f),Zo(f,f.return);break;case 12:Ra(u,f,r);break;case 31:Ra(u,f,r),r&&b&4&&F0(u,f);break;case 13:Ra(u,f,r),r&&b&4&&z0(u,f);break;case 22:f.memoizedState===null&&Ra(u,f,r),Zo(f,f.return);break;case 30:break;default:Ra(u,f,r)}i=i.sibling}}function pf(t,i){var r=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),t=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(t=i.memoizedState.cachePool.pool),t!==r&&(t!=null&&t.refCount++,r!=null&&Po(r))}function mf(t,i){t=null,i.alternate!==null&&(t=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==t&&(i.refCount++,t!=null&&Po(t))}function Gi(t,i,r,o){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)V0(t,i,r,o),i=i.sibling}function V0(t,i,r,o){var u=i.flags;switch(i.tag){case 0:case 11:case 15:Gi(t,i,r,o),u&2048&&Yo(9,i);break;case 1:Gi(t,i,r,o);break;case 3:Gi(t,i,r,o),u&2048&&(t=null,i.alternate!==null&&(t=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==t&&(i.refCount++,t!=null&&Po(t)));break;case 12:if(u&2048){Gi(t,i,r,o),t=i.stateNode;try{var f=i.memoizedProps,b=f.id,N=f.onPostCommit;typeof N=="function"&&N(b,i.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(q){en(i,i.return,q)}}else Gi(t,i,r,o);break;case 31:Gi(t,i,r,o);break;case 13:Gi(t,i,r,o);break;case 23:break;case 22:f=i.stateNode,b=i.alternate,i.memoizedState!==null?f._visibility&2?Gi(t,i,r,o):Ko(t,i):f._visibility&2?Gi(t,i,r,o):(f._visibility|=2,Or(t,i,r,o,(i.subtreeFlags&10256)!==0||!1)),u&2048&&pf(b,i);break;case 24:Gi(t,i,r,o),u&2048&&mf(i.alternate,i);break;default:Gi(t,i,r,o)}}function Or(t,i,r,o,u){for(u=u&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var f=t,b=i,N=r,q=o,de=b.flags;switch(b.tag){case 0:case 11:case 15:Or(f,b,N,q,u),Yo(8,b);break;case 23:break;case 22:var Se=b.stateNode;b.memoizedState!==null?Se._visibility&2?Or(f,b,N,q,u):Ko(f,b):(Se._visibility|=2,Or(f,b,N,q,u)),u&&de&2048&&pf(b.alternate,b);break;case 24:Or(f,b,N,q,u),u&&de&2048&&mf(b.alternate,b);break;default:Or(f,b,N,q,u)}i=i.sibling}}function Ko(t,i){if(i.subtreeFlags&10256)for(i=i.child;i!==null;){var r=t,o=i,u=o.flags;switch(o.tag){case 22:Ko(r,o),u&2048&&pf(o.alternate,o);break;case 24:Ko(r,o),u&2048&&mf(o.alternate,o);break;default:Ko(r,o)}i=i.sibling}}var $o=8192;function Pr(t,i,r){if(t.subtreeFlags&$o)for(t=t.child;t!==null;)k0(t,i,r),t=t.sibling}function k0(t,i,r){switch(t.tag){case 26:Pr(t,i,r),t.flags&$o&&t.memoizedState!==null&&Xb(r,Hi,t.memoizedState,t.memoizedProps);break;case 5:Pr(t,i,r);break;case 3:case 4:var o=Hi;Hi=Lc(t.stateNode.containerInfo),Pr(t,i,r),Hi=o;break;case 22:t.memoizedState===null&&(o=t.alternate,o!==null&&o.memoizedState!==null?(o=$o,$o=16777216,Pr(t,i,r),$o=o):Pr(t,i,r));break;default:Pr(t,i,r)}}function j0(t){var i=t.alternate;if(i!==null&&(t=i.child,t!==null)){i.child=null;do i=t.sibling,t.sibling=null,t=i;while(t!==null)}}function Qo(t){var i=t.deletions;if((t.flags&16)!==0){if(i!==null)for(var r=0;r<i.length;r++){var o=i[r];On=o,W0(o,t)}j0(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)X0(t),t=t.sibling}function X0(t){switch(t.tag){case 0:case 11:case 15:Qo(t),t.flags&2048&&is(9,t,t.return);break;case 3:Qo(t);break;case 12:Qo(t);break;case 22:var i=t.stateNode;t.memoizedState!==null&&i._visibility&2&&(t.return===null||t.return.tag!==13)?(i._visibility&=-3,yc(t)):Qo(t);break;default:Qo(t)}}function yc(t){var i=t.deletions;if((t.flags&16)!==0){if(i!==null)for(var r=0;r<i.length;r++){var o=i[r];On=o,W0(o,t)}j0(t)}for(t=t.child;t!==null;){switch(i=t,i.tag){case 0:case 11:case 15:is(8,i,i.return),yc(i);break;case 22:r=i.stateNode,r._visibility&2&&(r._visibility&=-3,yc(i));break;default:yc(i)}t=t.sibling}}function W0(t,i){for(;On!==null;){var r=On;switch(r.tag){case 0:case 11:case 15:is(8,r,i);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var o=r.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Po(r.memoizedState.cache)}if(o=r.child,o!==null)o.return=r,On=o;else e:for(r=t;On!==null;){o=On;var u=o.sibling,f=o.return;if(I0(o),o===r){On=null;break e}if(u!==null){u.return=f,On=u;break e}On=f}}}var rb={getCacheForType:function(t){var i=Fn(bn),r=i.data.get(t);return r===void 0&&(r=t(),i.data.set(t,r)),r},cacheSignal:function(){return Fn(bn).controller.signal}},ob=typeof WeakMap=="function"?WeakMap:Map,Wt=0,ln=null,Nt=null,Pt=0,Jt=0,hi=null,as=!1,Ir=!1,gf=!1,Da=0,_n=0,ss=0,qs=0,_f=0,pi=0,Br=0,Jo=null,ti=null,vf=!1,Sc=0,q0=0,bc=1/0,Mc=null,rs=null,wn=0,os=null,Fr=null,Na=0,xf=0,yf=null,Y0=null,el=0,Sf=null;function mi(){return(Wt&2)!==0&&Pt!==0?Pt&-Pt:V.T!==null?Cf():gt()}function Z0(){if(pi===0)if((Pt&536870912)===0||Ft){var t=rt;rt<<=1,(rt&3932160)===0&&(rt=262144),pi=t}else pi=536870912;return t=di.current,t!==null&&(t.flags|=32),pi}function ni(t,i,r){(t===ln&&(Jt===2||Jt===9)||t.cancelPendingCommit!==null)&&(zr(t,0),ls(t,Pt,pi,!1)),qe(t,r),((Wt&2)===0||t!==ln)&&(t===ln&&((Wt&2)===0&&(qs|=r),_n===4&&ls(t,Pt,pi,!1)),ra(t))}function K0(t,i,r){if((Wt&6)!==0)throw Error(s(327));var o=!r&&(i&127)===0&&(i&t.expiredLanes)===0||Pe(t,i),u=o?ub(t,i):Mf(t,i,!0),f=o;do{if(u===0){Ir&&!o&&ls(t,i,0,!1);break}else{if(r=t.current.alternate,f&&!lb(r)){u=Mf(t,i,!1),f=!1;continue}if(u===2){if(f=i,t.errorRecoveryDisabledLanes&f)var b=0;else b=t.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){i=b;e:{var N=t;u=Jo;var q=N.current.memoizedState.isDehydrated;if(q&&(zr(N,b).flags|=256),b=Mf(N,b,!1),b!==2){if(gf&&!q){N.errorRecoveryDisabledLanes|=f,qs|=f,u=4;break e}f=ti,ti=u,f!==null&&(ti===null?ti=f:ti.push.apply(ti,f))}u=b}if(f=!1,u!==2)continue}}if(u===1){zr(t,0),ls(t,i,0,!0);break}e:{switch(o=t,f=u,f){case 0:case 1:throw Error(s(345));case 4:if((i&4194048)!==i)break;case 6:ls(o,i,pi,!as);break e;case 2:ti=null;break;case 3:case 5:break;default:throw Error(s(329))}if((i&62914560)===i&&(u=Sc+300-Ue(),10<u)){if(ls(o,i,pi,!as),ye(o,0,!0)!==0)break e;Na=i,o.timeoutHandle=C_($0.bind(null,o,r,ti,Mc,vf,i,pi,qs,Br,as,f,"Throttled",-0,0),u);break e}$0(o,r,ti,Mc,vf,i,pi,qs,Br,as,f,null,-0,0)}}break}while(!0);ra(t)}function $0(t,i,r,o,u,f,b,N,q,de,Se,we,he,me){if(t.timeoutHandle=-1,we=i.subtreeFlags,we&8192||(we&16785408)===16785408){we={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ga},k0(i,f,we);var tt=(f&62914560)===f?Sc-Ue():(f&4194048)===f?q0-Ue():0;if(tt=Wb(we,tt),tt!==null){Na=f,t.cancelPendingCommit=tt(s_.bind(null,t,i,f,r,o,u,b,N,q,Se,we,null,he,me)),ls(t,f,b,!de);return}}s_(t,i,f,r,o,u,b,N,q)}function lb(t){for(var i=t;;){var r=i.tag;if((r===0||r===11||r===15)&&i.flags&16384&&(r=i.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var o=0;o<r.length;o++){var u=r[o],f=u.getSnapshot;u=u.value;try{if(!ci(f(),u))return!1}catch{return!1}}if(r=i.child,i.subtreeFlags&16384&&r!==null)r.return=i,i=r;else{if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function ls(t,i,r,o){i&=~_f,i&=~qs,t.suspendedLanes|=i,t.pingedLanes&=~i,o&&(t.warmLanes|=i),o=t.expirationTimes;for(var u=i;0<u;){var f=31-We(u),b=1<<f;o[f]=-1,u&=~b}r!==0&&wt(t,r,i)}function Ec(){return(Wt&6)===0?(tl(0),!1):!0}function bf(){if(Nt!==null){if(Jt===0)var t=Nt.return;else t=Nt,ya=Fs=null,Bd(t),Rr=null,Bo=0,t=Nt;for(;t!==null;)w0(t.alternate,t),t=t.return;Nt=null}}function zr(t,i){var r=t.timeoutHandle;r!==-1&&(t.timeoutHandle=-1,wb(r)),r=t.cancelPendingCommit,r!==null&&(t.cancelPendingCommit=null,r()),Na=0,bf(),ln=t,Nt=r=va(t.current,null),Pt=i,Jt=0,hi=null,as=!1,Ir=Pe(t,i),gf=!1,Br=pi=_f=qs=ss=_n=0,ti=Jo=null,vf=!1,(i&8)!==0&&(i|=i&32);var o=t.entangledLanes;if(o!==0)for(t=t.entanglements,o&=i;0<o;){var u=31-We(o),f=1<<u;i|=t[u],o&=~f}return Da=i,Xl(),r}function Q0(t,i){Et=null,V.H=Xo,i===wr||i===Jl?(i=pg(),Jt=3):i===Td?(i=pg(),Jt=4):Jt=i===Jd?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,hi=i,Nt===null&&(_n=1,hc(t,Si(i,t.current)))}function J0(){var t=di.current;return t===null?!0:(Pt&4194048)===Pt?Ti===null:(Pt&62914560)===Pt||(Pt&536870912)!==0?t===Ti:!1}function e_(){var t=V.H;return V.H=Xo,t===null?Xo:t}function t_(){var t=V.A;return V.A=rb,t}function Tc(){_n=4,as||(Pt&4194048)!==Pt&&di.current!==null||(Ir=!0),(ss&134217727)===0&&(qs&134217727)===0||ln===null||ls(ln,Pt,pi,!1)}function Mf(t,i,r){var o=Wt;Wt|=2;var u=e_(),f=t_();(ln!==t||Pt!==i)&&(Mc=null,zr(t,i)),i=!1;var b=_n;e:do try{if(Jt!==0&&Nt!==null){var N=Nt,q=hi;switch(Jt){case 8:bf(),b=6;break e;case 3:case 2:case 9:case 6:di.current===null&&(i=!0);var de=Jt;if(Jt=0,hi=null,Hr(t,N,q,de),r&&Ir){b=0;break e}break;default:de=Jt,Jt=0,hi=null,Hr(t,N,q,de)}}cb(),b=_n;break}catch(Se){Q0(t,Se)}while(!0);return i&&t.shellSuspendCounter++,ya=Fs=null,Wt=o,V.H=u,V.A=f,Nt===null&&(ln=null,Pt=0,Xl()),b}function cb(){for(;Nt!==null;)n_(Nt)}function ub(t,i){var r=Wt;Wt|=2;var o=e_(),u=t_();ln!==t||Pt!==i?(Mc=null,bc=Ue()+500,zr(t,i)):Ir=Pe(t,i);e:do try{if(Jt!==0&&Nt!==null){i=Nt;var f=hi;t:switch(Jt){case 1:Jt=0,hi=null,Hr(t,i,f,1);break;case 2:case 9:if(fg(f)){Jt=0,hi=null,i_(i);break}i=function(){Jt!==2&&Jt!==9||ln!==t||(Jt=7),ra(t)},f.then(i,i);break e;case 3:Jt=7;break e;case 4:Jt=5;break e;case 7:fg(f)?(Jt=0,hi=null,i_(i)):(Jt=0,hi=null,Hr(t,i,f,7));break;case 5:var b=null;switch(Nt.tag){case 26:b=Nt.memoizedState;case 5:case 27:var N=Nt;if(b?V_(b):N.stateNode.complete){Jt=0,hi=null;var q=N.sibling;if(q!==null)Nt=q;else{var de=N.return;de!==null?(Nt=de,Ac(de)):Nt=null}break t}}Jt=0,hi=null,Hr(t,i,f,5);break;case 6:Jt=0,hi=null,Hr(t,i,f,6);break;case 8:bf(),_n=6;break e;default:throw Error(s(462))}}db();break}catch(Se){Q0(t,Se)}while(!0);return ya=Fs=null,V.H=o,V.A=u,Wt=r,Nt!==null?0:(ln=null,Pt=0,Xl(),_n)}function db(){for(;Nt!==null&&!J();)n_(Nt)}function n_(t){var i=A0(t.alternate,t,Da);t.memoizedProps=t.pendingProps,i===null?Ac(t):Nt=i}function i_(t){var i=t,r=i.alternate;switch(i.tag){case 15:case 0:i=y0(r,i,i.pendingProps,i.type,void 0,Pt);break;case 11:i=y0(r,i,i.pendingProps,i.type.render,i.ref,Pt);break;case 5:Bd(i);default:w0(r,i),i=Nt=tg(i,Da),i=A0(r,i,Da)}t.memoizedProps=t.pendingProps,i===null?Ac(t):Nt=i}function Hr(t,i,r,o){ya=Fs=null,Bd(i),Rr=null,Bo=0;var u=i.return;try{if(JS(t,u,i,r,Pt)){_n=1,hc(t,Si(r,t.current)),Nt=null;return}}catch(f){if(u!==null)throw Nt=u,f;_n=1,hc(t,Si(r,t.current)),Nt=null;return}i.flags&32768?(Ft||o===1?t=!0:Ir||(Pt&536870912)!==0?t=!1:(as=t=!0,(o===2||o===9||o===3||o===6)&&(o=di.current,o!==null&&o.tag===13&&(o.flags|=16384))),a_(i,t)):Ac(i)}function Ac(t){var i=t;do{if((i.flags&32768)!==0){a_(i,as);return}t=i.return;var r=nb(i.alternate,i,Da);if(r!==null){Nt=r;return}if(i=i.sibling,i!==null){Nt=i;return}Nt=i=t}while(i!==null);_n===0&&(_n=5)}function a_(t,i){do{var r=ib(t.alternate,t);if(r!==null){r.flags&=32767,Nt=r;return}if(r=t.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!i&&(t=t.sibling,t!==null)){Nt=t;return}Nt=t=r}while(t!==null);_n=6,Nt=null}function s_(t,i,r,o,u,f,b,N,q){t.cancelPendingCommit=null;do Cc();while(wn!==0);if((Wt&6)!==0)throw Error(s(327));if(i!==null){if(i===t.current)throw Error(s(177));if(f=i.lanes|i.childLanes,f|=ud,qt(t,r,f,b,N,q),t===ln&&(Nt=ln=null,Pt=0),Fr=i,os=t,Na=r,xf=f,yf=u,Y0=o,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,mb(ne,function(){return u_(),null})):(t.callbackNode=null,t.callbackPriority=0),o=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||o){o=V.T,V.T=null,u=j.p,j.p=2,b=Wt,Wt|=4;try{ab(t,i,r)}finally{Wt=b,j.p=u,V.T=o}}wn=1,r_(),o_(),l_()}}function r_(){if(wn===1){wn=0;var t=os,i=Fr,r=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||r){r=V.T,V.T=null;var o=j.p;j.p=2;var u=Wt;Wt|=4;try{H0(i,t);var f=Pf,b=Wm(t.containerInfo),N=f.focusedElem,q=f.selectionRange;if(b!==N&&N&&N.ownerDocument&&Xm(N.ownerDocument.documentElement,N)){if(q!==null&&sd(N)){var de=q.start,Se=q.end;if(Se===void 0&&(Se=de),"selectionStart"in N)N.selectionStart=de,N.selectionEnd=Math.min(Se,N.value.length);else{var we=N.ownerDocument||document,he=we&&we.defaultView||window;if(he.getSelection){var me=he.getSelection(),tt=N.textContent.length,pt=Math.min(q.start,tt),rn=q.end===void 0?pt:Math.min(q.end,tt);!me.extend&&pt>rn&&(b=rn,rn=pt,pt=b);var ie=jm(N,pt),$=jm(N,rn);if(ie&&$&&(me.rangeCount!==1||me.anchorNode!==ie.node||me.anchorOffset!==ie.offset||me.focusNode!==$.node||me.focusOffset!==$.offset)){var ce=we.createRange();ce.setStart(ie.node,ie.offset),me.removeAllRanges(),pt>rn?(me.addRange(ce),me.extend($.node,$.offset)):(ce.setEnd($.node,$.offset),me.addRange(ce))}}}}for(we=[],me=N;me=me.parentNode;)me.nodeType===1&&we.push({element:me,left:me.scrollLeft,top:me.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<we.length;N++){var Te=we[N];Te.element.scrollLeft=Te.left,Te.element.scrollTop=Te.top}}zc=!!Of,Pf=Of=null}finally{Wt=u,j.p=o,V.T=r}}t.current=i,wn=2}}function o_(){if(wn===2){wn=0;var t=os,i=Fr,r=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||r){r=V.T,V.T=null;var o=j.p;j.p=2;var u=Wt;Wt|=4;try{P0(t,i.alternate,i)}finally{Wt=u,j.p=o,V.T=r}}wn=3}}function l_(){if(wn===4||wn===3){wn=0,z();var t=os,i=Fr,r=Na,o=Y0;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?wn=5:(wn=0,Fr=os=null,c_(t,t.pendingLanes));var u=t.pendingLanes;if(u===0&&(rs=null),Ke(r),i=i.stateNode,le&&typeof le.onCommitFiberRoot=="function")try{le.onCommitFiberRoot(ge,i,void 0,(i.current.flags&128)===128)}catch{}if(o!==null){i=V.T,u=j.p,j.p=2,V.T=null;try{for(var f=t.onRecoverableError,b=0;b<o.length;b++){var N=o[b];f(N.value,{componentStack:N.stack})}}finally{V.T=i,j.p=u}}(Na&3)!==0&&Cc(),ra(t),u=t.pendingLanes,(r&261930)!==0&&(u&42)!==0?t===Sf?el++:(el=0,Sf=t):el=0,tl(0)}}function c_(t,i){(t.pooledCacheLanes&=i)===0&&(i=t.pooledCache,i!=null&&(t.pooledCache=null,Po(i)))}function Cc(){return r_(),o_(),l_(),u_()}function u_(){if(wn!==5)return!1;var t=os,i=xf;xf=0;var r=Ke(Na),o=V.T,u=j.p;try{j.p=32>r?32:r,V.T=null,r=yf,yf=null;var f=os,b=Na;if(wn=0,Fr=os=null,Na=0,(Wt&6)!==0)throw Error(s(331));var N=Wt;if(Wt|=4,X0(f.current),V0(f,f.current,b,r),Wt=N,tl(0,!1),le&&typeof le.onPostCommitFiberRoot=="function")try{le.onPostCommitFiberRoot(ge,f)}catch{}return!0}finally{j.p=u,V.T=o,c_(t,i)}}function d_(t,i,r){i=Si(r,i),i=Qd(t.stateNode,i,2),t=es(t,i,2),t!==null&&(qe(t,2),ra(t))}function en(t,i,r){if(t.tag===3)d_(t,t,r);else for(;i!==null;){if(i.tag===3){d_(i,t,r);break}else if(i.tag===1){var o=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(rs===null||!rs.has(o))){t=Si(r,t),r=f0(2),o=es(i,r,2),o!==null&&(h0(r,o,i,t),qe(o,2),ra(o));break}}i=i.return}}function Ef(t,i,r){var o=t.pingCache;if(o===null){o=t.pingCache=new ob;var u=new Set;o.set(i,u)}else u=o.get(i),u===void 0&&(u=new Set,o.set(i,u));u.has(r)||(gf=!0,u.add(r),t=fb.bind(null,t,i,r),i.then(t,t))}function fb(t,i,r){var o=t.pingCache;o!==null&&o.delete(i),t.pingedLanes|=t.suspendedLanes&r,t.warmLanes&=~r,ln===t&&(Pt&r)===r&&(_n===4||_n===3&&(Pt&62914560)===Pt&&300>Ue()-Sc?(Wt&2)===0&&zr(t,0):_f|=r,Br===Pt&&(Br=0)),ra(t)}function f_(t,i){i===0&&(i=De()),t=Ps(t,i),t!==null&&(qe(t,i),ra(t))}function hb(t){var i=t.memoizedState,r=0;i!==null&&(r=i.retryLane),f_(t,r)}function pb(t,i){var r=0;switch(t.tag){case 31:case 13:var o=t.stateNode,u=t.memoizedState;u!==null&&(r=u.retryLane);break;case 19:o=t.stateNode;break;case 22:o=t.stateNode._retryCache;break;default:throw Error(s(314))}o!==null&&o.delete(i),f_(t,r)}function mb(t,i){return Vt(t,i)}var wc=null,Gr=null,Tf=!1,Rc=!1,Af=!1,cs=0;function ra(t){t!==Gr&&t.next===null&&(Gr===null?wc=Gr=t:Gr=Gr.next=t),Rc=!0,Tf||(Tf=!0,_b())}function tl(t,i){if(!Af&&Rc){Af=!0;do for(var r=!1,o=wc;o!==null;){if(t!==0){var u=o.pendingLanes;if(u===0)var f=0;else{var b=o.suspendedLanes,N=o.pingedLanes;f=(1<<31-We(42|t)+1)-1,f&=u&~(b&~N),f=f&201326741?f&201326741|1:f?f|2:0}f!==0&&(r=!0,g_(o,f))}else f=Pt,f=ye(o,o===ln?f:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(f&3)===0||Pe(o,f)||(r=!0,g_(o,f));o=o.next}while(r);Af=!1}}function gb(){h_()}function h_(){Rc=Tf=!1;var t=0;cs!==0&&Cb()&&(t=cs);for(var i=Ue(),r=null,o=wc;o!==null;){var u=o.next,f=p_(o,i);f===0?(o.next=null,r===null?wc=u:r.next=u,u===null&&(Gr=r)):(r=o,(t!==0||(f&3)!==0)&&(Rc=!0)),o=u}wn!==0&&wn!==5||tl(t),cs!==0&&(cs=0)}function p_(t,i){for(var r=t.suspendedLanes,o=t.pingedLanes,u=t.expirationTimes,f=t.pendingLanes&-62914561;0<f;){var b=31-We(f),N=1<<b,q=u[b];q===-1?((N&r)===0||(N&o)!==0)&&(u[b]=Ge(N,i)):q<=i&&(t.expiredLanes|=N),f&=~N}if(i=ln,r=Pt,r=ye(t,t===i?r:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),o=t.callbackNode,r===0||t===i&&(Jt===2||Jt===9)||t.cancelPendingCommit!==null)return o!==null&&o!==null&&dt(o),t.callbackNode=null,t.callbackPriority=0;if((r&3)===0||Pe(t,r)){if(i=r&-r,i===t.callbackPriority)return i;switch(o!==null&&dt(o),Ke(r)){case 2:case 8:r=A;break;case 32:r=ne;break;case 268435456:r=fe;break;default:r=ne}return o=m_.bind(null,t),r=Vt(r,o),t.callbackPriority=i,t.callbackNode=r,i}return o!==null&&o!==null&&dt(o),t.callbackPriority=2,t.callbackNode=null,2}function m_(t,i){if(wn!==0&&wn!==5)return t.callbackNode=null,t.callbackPriority=0,null;var r=t.callbackNode;if(Cc()&&t.callbackNode!==r)return null;var o=Pt;return o=ye(t,t===ln?o:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),o===0?null:(K0(t,o,i),p_(t,Ue()),t.callbackNode!=null&&t.callbackNode===r?m_.bind(null,t):null)}function g_(t,i){if(Cc())return null;K0(t,i,!0)}function _b(){Rb(function(){(Wt&6)!==0?Vt(F,gb):h_()})}function Cf(){if(cs===0){var t=Ar;t===0&&(t=Ce,Ce<<=1,(Ce&261888)===0&&(Ce=256)),cs=t}return cs}function __(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Ns(""+t)}function v_(t,i){var r=i.ownerDocument.createElement("input");return r.name=i.name,r.value=i.value,t.id&&r.setAttribute("form",t.id),i.parentNode.insertBefore(r,i),t=new FormData(t),r.parentNode.removeChild(r),t}function vb(t,i,r,o,u){if(i==="submit"&&r&&r.stateNode===u){var f=__((u[vn]||null).action),b=o.submitter;b&&(i=(i=b[vn]||null)?__(i.formAction):b.getAttribute("formAction"),i!==null&&(f=i,b=null));var N=new Gl("action","action",null,o,u);t.push({event:N,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(cs!==0){var q=b?v_(u,b):new FormData(u);Wd(r,{pending:!0,data:q,method:u.method,action:f},null,q)}}else typeof f=="function"&&(N.preventDefault(),q=b?v_(u,b):new FormData(u),Wd(r,{pending:!0,data:q,method:u.method,action:f},f,q))},currentTarget:u}]})}}for(var wf=0;wf<cd.length;wf++){var Rf=cd[wf],xb=Rf.toLowerCase(),yb=Rf[0].toUpperCase()+Rf.slice(1);zi(xb,"on"+yb)}zi(Zm,"onAnimationEnd"),zi(Km,"onAnimationIteration"),zi($m,"onAnimationStart"),zi("dblclick","onDoubleClick"),zi("focusin","onFocus"),zi("focusout","onBlur"),zi(IS,"onTransitionRun"),zi(BS,"onTransitionStart"),zi(FS,"onTransitionCancel"),zi(Qm,"onTransitionEnd"),k("onMouseEnter",["mouseout","mouseover"]),k("onMouseLeave",["mouseout","mouseover"]),k("onPointerEnter",["pointerout","pointerover"]),k("onPointerLeave",["pointerout","pointerover"]),w("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),w("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),w("onBeforeInput",["compositionend","keypress","textInput","paste"]),w("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),w("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),w("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var nl="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(" "),Sb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(nl));function x_(t,i){i=(i&4)!==0;for(var r=0;r<t.length;r++){var o=t[r],u=o.event;o=o.listeners;e:{var f=void 0;if(i)for(var b=o.length-1;0<=b;b--){var N=o[b],q=N.instance,de=N.currentTarget;if(N=N.listener,q!==f&&u.isPropagationStopped())break e;f=N,u.currentTarget=de;try{f(u)}catch(Se){jl(Se)}u.currentTarget=null,f=q}else for(b=0;b<o.length;b++){if(N=o[b],q=N.instance,de=N.currentTarget,N=N.listener,q!==f&&u.isPropagationStopped())break e;f=N,u.currentTarget=de;try{f(u)}catch(Se){jl(Se)}u.currentTarget=null,f=q}}}}function Ut(t,i){var r=i[Qi];r===void 0&&(r=i[Qi]=new Set);var o=t+"__bubble";r.has(o)||(y_(i,t,2,!1),r.add(o))}function Df(t,i,r){var o=0;i&&(o|=4),y_(r,t,o,i)}var Dc="_reactListening"+Math.random().toString(36).slice(2);function Nf(t){if(!t[Dc]){t[Dc]=!0,Ds.forEach(function(r){r!=="selectionchange"&&(Sb.has(r)||Df(r,!1,t),Df(r,!0,t))});var i=t.nodeType===9?t:t.ownerDocument;i===null||i[Dc]||(i[Dc]=!0,Df("selectionchange",!1,i))}}function y_(t,i,r,o){switch(Z_(i)){case 2:var u=Zb;break;case 8:u=Kb;break;default:u=Wf}r=u.bind(null,i,r,t),u=void 0,!Ku||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(u=!0),o?u!==void 0?t.addEventListener(i,r,{capture:!0,passive:u}):t.addEventListener(i,r,!0):u!==void 0?t.addEventListener(i,r,{passive:u}):t.addEventListener(i,r,!1)}function Uf(t,i,r,o,u){var f=o;if((i&1)===0&&(i&2)===0&&o!==null)e:for(;;){if(o===null)return;var b=o.tag;if(b===3||b===4){var N=o.stateNode.containerInfo;if(N===u)break;if(b===4)for(b=o.return;b!==null;){var q=b.tag;if((q===3||q===4)&&b.stateNode.containerInfo===u)return;b=b.return}for(;N!==null;){if(b=Oi(N),b===null)return;if(q=b.tag,q===5||q===6||q===26||q===27){o=f=b;continue e}N=N.parentNode}}o=o.return}Tm(function(){var de=f,Se=Yu(r),we=[];e:{var he=Jm.get(t);if(he!==void 0){var me=Gl,tt=t;switch(t){case"keypress":if(zl(r)===0)break e;case"keydown":case"keyup":me=pS;break;case"focusin":tt="focus",me=ed;break;case"focusout":tt="blur",me=ed;break;case"beforeblur":case"afterblur":me=ed;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":me=wm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":me=nS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":me=_S;break;case Zm:case Km:case $m:me=sS;break;case Qm:me=xS;break;case"scroll":case"scrollend":me=eS;break;case"wheel":me=SS;break;case"copy":case"cut":case"paste":me=oS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":me=Dm;break;case"toggle":case"beforetoggle":me=MS}var pt=(i&4)!==0,rn=!pt&&(t==="scroll"||t==="scrollend"),ie=pt?he!==null?he+"Capture":null:he;pt=[];for(var $=de,ce;$!==null;){var Te=$;if(ce=Te.stateNode,Te=Te.tag,Te!==5&&Te!==26&&Te!==27||ce===null||ie===null||(Te=Eo($,ie),Te!=null&&pt.push(il($,Te,ce))),rn)break;$=$.return}0<pt.length&&(he=new me(he,tt,null,r,Se),we.push({event:he,listeners:pt}))}}if((i&7)===0){e:{if(he=t==="mouseover"||t==="pointerover",me=t==="mouseout"||t==="pointerout",he&&r!==qu&&(tt=r.relatedTarget||r.fromElement)&&(Oi(tt)||tt[Vn]))break e;if((me||he)&&(he=Se.window===Se?Se:(he=Se.ownerDocument)?he.defaultView||he.parentWindow:window,me?(tt=r.relatedTarget||r.toElement,me=de,tt=tt?Oi(tt):null,tt!==null&&(rn=c(tt),pt=tt.tag,tt!==rn||pt!==5&&pt!==27&&pt!==6)&&(tt=null)):(me=null,tt=de),me!==tt)){if(pt=wm,Te="onMouseLeave",ie="onMouseEnter",$="mouse",(t==="pointerout"||t==="pointerover")&&(pt=Dm,Te="onPointerLeave",ie="onPointerEnter",$="pointer"),rn=me==null?he:Ii(me),ce=tt==null?he:Ii(tt),he=new pt(Te,$+"leave",me,r,Se),he.target=rn,he.relatedTarget=ce,Te=null,Oi(Se)===de&&(pt=new pt(ie,$+"enter",tt,r,Se),pt.target=ce,pt.relatedTarget=rn,Te=pt),rn=Te,me&&tt)t:{for(pt=bb,ie=me,$=tt,ce=0,Te=ie;Te;Te=pt(Te))ce++;Te=0;for(var lt=$;lt;lt=pt(lt))Te++;for(;0<ce-Te;)ie=pt(ie),ce--;for(;0<Te-ce;)$=pt($),Te--;for(;ce--;){if(ie===$||$!==null&&ie===$.alternate){pt=ie;break t}ie=pt(ie),$=pt($)}pt=null}else pt=null;me!==null&&S_(we,he,me,pt,!1),tt!==null&&rn!==null&&S_(we,rn,tt,pt,!0)}}e:{if(he=de?Ii(de):window,me=he.nodeName&&he.nodeName.toLowerCase(),me==="select"||me==="input"&&he.type==="file")var jt=Fm;else if(Im(he))if(zm)jt=LS;else{jt=NS;var it=DS}else me=he.nodeName,!me||me.toLowerCase()!=="input"||he.type!=="checkbox"&&he.type!=="radio"?de&&Yt(de.elementType)&&(jt=Fm):jt=US;if(jt&&(jt=jt(t,de))){Bm(we,jt,r,Se);break e}it&&it(t,he,de),t==="focusout"&&de&&he.type==="number"&&de.memoizedProps.value!=null&&Dt(he,"number",he.value)}switch(it=de?Ii(de):window,t){case"focusin":(Im(it)||it.contentEditable==="true")&&(vr=it,rd=de,Uo=null);break;case"focusout":Uo=rd=vr=null;break;case"mousedown":od=!0;break;case"contextmenu":case"mouseup":case"dragend":od=!1,qm(we,r,Se);break;case"selectionchange":if(PS)break;case"keydown":case"keyup":qm(we,r,Se)}var At;if(nd)e:{switch(t){case"compositionstart":var It="onCompositionStart";break e;case"compositionend":It="onCompositionEnd";break e;case"compositionupdate":It="onCompositionUpdate";break e}It=void 0}else _r?Om(t,r)&&(It="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&(It="onCompositionStart");It&&(Nm&&r.locale!=="ko"&&(_r||It!=="onCompositionStart"?It==="onCompositionEnd"&&_r&&(At=Am()):(qa=Se,$u="value"in qa?qa.value:qa.textContent,_r=!0)),it=Nc(de,It),0<it.length&&(It=new Rm(It,t,null,r,Se),we.push({event:It,listeners:it}),At?It.data=At:(At=Pm(r),At!==null&&(It.data=At)))),(At=TS?AS(t,r):CS(t,r))&&(It=Nc(de,"onBeforeInput"),0<It.length&&(it=new Rm("onBeforeInput","beforeinput",null,r,Se),we.push({event:it,listeners:It}),it.data=At)),vb(we,t,de,r,Se)}x_(we,i)})}function il(t,i,r){return{instance:t,listener:i,currentTarget:r}}function Nc(t,i){for(var r=i+"Capture",o=[];t!==null;){var u=t,f=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||f===null||(u=Eo(t,r),u!=null&&o.unshift(il(t,u,f)),u=Eo(t,i),u!=null&&o.push(il(t,u,f))),t.tag===3)return o;t=t.return}return[]}function bb(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function S_(t,i,r,o,u){for(var f=i._reactName,b=[];r!==null&&r!==o;){var N=r,q=N.alternate,de=N.stateNode;if(N=N.tag,q!==null&&q===o)break;N!==5&&N!==26&&N!==27||de===null||(q=de,u?(de=Eo(r,f),de!=null&&b.unshift(il(r,de,q))):u||(de=Eo(r,f),de!=null&&b.push(il(r,de,q)))),r=r.return}b.length!==0&&t.push({event:i,listeners:b})}var Mb=/\r\n?/g,Eb=/\u0000|\uFFFD/g;function b_(t){return(typeof t=="string"?t:""+t).replace(Mb,`
`).replace(Eb,"")}function M_(t,i){return i=b_(i),b_(t)===i}function sn(t,i,r,o,u,f){switch(r){case"children":typeof o=="string"?i==="body"||i==="textarea"&&o===""||li(t,o):(typeof o=="number"||typeof o=="bigint")&&i!=="body"&&li(t,""+o);break;case"className":Ve(t,"class",o);break;case"tabIndex":Ve(t,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Ve(t,r,o);break;case"style":Fi(t,o,f);break;case"data":if(i!=="object"){Ve(t,"data",o);break}case"src":case"href":if(o===""&&(i!=="a"||r!=="href")){t.removeAttribute(r);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){t.removeAttribute(r);break}o=Ns(""+o),t.setAttribute(r,o);break;case"action":case"formAction":if(typeof o=="function"){t.setAttribute(r,"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 f=="function"&&(r==="formAction"?(i!=="input"&&sn(t,i,"name",u.name,u,null),sn(t,i,"formEncType",u.formEncType,u,null),sn(t,i,"formMethod",u.formMethod,u,null),sn(t,i,"formTarget",u.formTarget,u,null)):(sn(t,i,"encType",u.encType,u,null),sn(t,i,"method",u.method,u,null),sn(t,i,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){t.removeAttribute(r);break}o=Ns(""+o),t.setAttribute(r,o);break;case"onClick":o!=null&&(t.onclick=ga);break;case"onScroll":o!=null&&Ut("scroll",t);break;case"onScrollEnd":o!=null&&Ut("scrollend",t);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(r=o.__html,r!=null){if(u.children!=null)throw Error(s(60));t.innerHTML=r}}break;case"multiple":t.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":t.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){t.removeAttribute("xlink:href");break}r=Ns(""+o),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?t.setAttribute(r,""+o):t.removeAttribute(r);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":o&&typeof o!="function"&&typeof o!="symbol"?t.setAttribute(r,""):t.removeAttribute(r);break;case"capture":case"download":o===!0?t.setAttribute(r,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?t.setAttribute(r,o):t.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?t.setAttribute(r,o):t.removeAttribute(r);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?t.removeAttribute(r):t.setAttribute(r,o);break;case"popover":Ut("beforetoggle",t),Ut("toggle",t),Be(t,"popover",o);break;case"xlinkActuate":je(t,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":je(t,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":je(t,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":je(t,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":je(t,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":je(t,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":je(t,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":je(t,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":je(t,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Be(t,"is",o);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=na.get(r)||r,Be(t,r,o))}}function Lf(t,i,r,o,u,f){switch(r){case"style":Fi(t,o,f);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(r=o.__html,r!=null){if(u.children!=null)throw Error(s(60));t.innerHTML=r}}break;case"children":typeof o=="string"?li(t,o):(typeof o=="number"||typeof o=="bigint")&&li(t,""+o);break;case"onScroll":o!=null&&Ut("scroll",t);break;case"onScrollEnd":o!=null&&Ut("scrollend",t);break;case"onClick":o!=null&&(t.onclick=ga);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!D.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(u=r.endsWith("Capture"),i=r.slice(2,u?r.length-7:void 0),f=t[vn]||null,f=f!=null?f[r]:null,typeof f=="function"&&t.removeEventListener(i,f,u),typeof o=="function")){typeof f!="function"&&f!==null&&(r in t?t[r]=null:t.hasAttribute(r)&&t.removeAttribute(r)),t.addEventListener(i,o,u);break e}r in t?t[r]=o:o===!0?t.setAttribute(r,""):Be(t,r,o)}}}function Hn(t,i,r){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ut("error",t),Ut("load",t);var o=!1,u=!1,f;for(f in r)if(r.hasOwnProperty(f)){var b=r[f];if(b!=null)switch(f){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:sn(t,i,f,b,r,null)}}u&&sn(t,i,"srcSet",r.srcSet,r,null),o&&sn(t,i,"src",r.src,r,null);return;case"input":Ut("invalid",t);var N=f=b=u=null,q=null,de=null;for(o in r)if(r.hasOwnProperty(o)){var Se=r[o];if(Se!=null)switch(o){case"name":u=Se;break;case"type":b=Se;break;case"checked":q=Se;break;case"defaultChecked":de=Se;break;case"value":f=Se;break;case"defaultValue":N=Se;break;case"children":case"dangerouslySetInnerHTML":if(Se!=null)throw Error(s(137,i));break;default:sn(t,i,o,Se,r,null)}}kn(t,f,N,q,de,b,u,!1);return;case"select":Ut("invalid",t),o=b=f=null;for(u in r)if(r.hasOwnProperty(u)&&(N=r[u],N!=null))switch(u){case"value":f=N;break;case"defaultValue":b=N;break;case"multiple":o=N;default:sn(t,i,u,N,r,null)}i=f,r=b,t.multiple=!!o,i!=null?Cn(t,!!o,i,!1):r!=null&&Cn(t,!!o,r,!0);return;case"textarea":Ut("invalid",t),f=u=o=null;for(b in r)if(r.hasOwnProperty(b)&&(N=r[b],N!=null))switch(b){case"value":o=N;break;case"defaultValue":u=N;break;case"children":f=N;break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(s(91));break;default:sn(t,i,b,N,r,null)}Bi(t,o,u,f);return;case"option":for(q in r)r.hasOwnProperty(q)&&(o=r[q],o!=null)&&(q==="selected"?t.selected=o&&typeof o!="function"&&typeof o!="symbol":sn(t,i,q,o,r,null));return;case"dialog":Ut("beforetoggle",t),Ut("toggle",t),Ut("cancel",t),Ut("close",t);break;case"iframe":case"object":Ut("load",t);break;case"video":case"audio":for(o=0;o<nl.length;o++)Ut(nl[o],t);break;case"image":Ut("error",t),Ut("load",t);break;case"details":Ut("toggle",t);break;case"embed":case"source":case"link":Ut("error",t),Ut("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(de in r)if(r.hasOwnProperty(de)&&(o=r[de],o!=null))switch(de){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:sn(t,i,de,o,r,null)}return;default:if(Yt(i)){for(Se in r)r.hasOwnProperty(Se)&&(o=r[Se],o!==void 0&&Lf(t,i,Se,o,r,void 0));return}}for(N in r)r.hasOwnProperty(N)&&(o=r[N],o!=null&&sn(t,i,N,o,r,null))}function Tb(t,i,r,o){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,f=null,b=null,N=null,q=null,de=null,Se=null;for(me in r){var we=r[me];if(r.hasOwnProperty(me)&&we!=null)switch(me){case"checked":break;case"value":break;case"defaultValue":q=we;default:o.hasOwnProperty(me)||sn(t,i,me,null,o,we)}}for(var he in o){var me=o[he];if(we=r[he],o.hasOwnProperty(he)&&(me!=null||we!=null))switch(he){case"type":f=me;break;case"name":u=me;break;case"checked":de=me;break;case"defaultChecked":Se=me;break;case"value":b=me;break;case"defaultValue":N=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(s(137,i));break;default:me!==we&&sn(t,i,he,me,o,we)}}$e(t,b,N,q,de,Se,f,u);return;case"select":me=b=N=he=null;for(f in r)if(q=r[f],r.hasOwnProperty(f)&&q!=null)switch(f){case"value":break;case"multiple":me=q;default:o.hasOwnProperty(f)||sn(t,i,f,null,o,q)}for(u in o)if(f=o[u],q=r[u],o.hasOwnProperty(u)&&(f!=null||q!=null))switch(u){case"value":he=f;break;case"defaultValue":N=f;break;case"multiple":b=f;default:f!==q&&sn(t,i,u,f,o,q)}i=N,r=b,o=me,he!=null?Cn(t,!!r,he,!1):!!o!=!!r&&(i!=null?Cn(t,!!r,i,!0):Cn(t,!!r,r?[]:"",!1));return;case"textarea":me=he=null;for(N in r)if(u=r[N],r.hasOwnProperty(N)&&u!=null&&!o.hasOwnProperty(N))switch(N){case"value":break;case"children":break;default:sn(t,i,N,null,o,u)}for(b in o)if(u=o[b],f=r[b],o.hasOwnProperty(b)&&(u!=null||f!=null))switch(b){case"value":he=u;break;case"defaultValue":me=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==f&&sn(t,i,b,u,o,f)}oi(t,he,me);return;case"option":for(var tt in r)he=r[tt],r.hasOwnProperty(tt)&&he!=null&&!o.hasOwnProperty(tt)&&(tt==="selected"?t.selected=!1:sn(t,i,tt,null,o,he));for(q in o)he=o[q],me=r[q],o.hasOwnProperty(q)&&he!==me&&(he!=null||me!=null)&&(q==="selected"?t.selected=he&&typeof he!="function"&&typeof he!="symbol":sn(t,i,q,he,o,me));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 pt in r)he=r[pt],r.hasOwnProperty(pt)&&he!=null&&!o.hasOwnProperty(pt)&&sn(t,i,pt,null,o,he);for(de in o)if(he=o[de],me=r[de],o.hasOwnProperty(de)&&he!==me&&(he!=null||me!=null))switch(de){case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(s(137,i));break;default:sn(t,i,de,he,o,me)}return;default:if(Yt(i)){for(var rn in r)he=r[rn],r.hasOwnProperty(rn)&&he!==void 0&&!o.hasOwnProperty(rn)&&Lf(t,i,rn,void 0,o,he);for(Se in o)he=o[Se],me=r[Se],!o.hasOwnProperty(Se)||he===me||he===void 0&&me===void 0||Lf(t,i,Se,he,o,me);return}}for(var ie in r)he=r[ie],r.hasOwnProperty(ie)&&he!=null&&!o.hasOwnProperty(ie)&&sn(t,i,ie,null,o,he);for(we in o)he=o[we],me=r[we],!o.hasOwnProperty(we)||he===me||he==null&&me==null||sn(t,i,we,he,o,me)}function E_(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Ab(){if(typeof performance.getEntriesByType=="function"){for(var t=0,i=0,r=performance.getEntriesByType("resource"),o=0;o<r.length;o++){var u=r[o],f=u.transferSize,b=u.initiatorType,N=u.duration;if(f&&N&&E_(b)){for(b=0,N=u.responseEnd,o+=1;o<r.length;o++){var q=r[o],de=q.startTime;if(de>N)break;var Se=q.transferSize,we=q.initiatorType;Se&&E_(we)&&(q=q.responseEnd,b+=Se*(q<N?1:(N-de)/(q-de)))}if(--o,i+=8*(f+b)/(u.duration/1e3),t++,10<t)break}}if(0<t)return i/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var Of=null,Pf=null;function Uc(t){return t.nodeType===9?t:t.ownerDocument}function T_(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function A_(t,i){if(t===0)switch(i){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&i==="foreignObject"?0:t}function If(t,i){return t==="textarea"||t==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.children=="bigint"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Bf=null;function Cb(){var t=window.event;return t&&t.type==="popstate"?t===Bf?!1:(Bf=t,!0):(Bf=null,!1)}var C_=typeof setTimeout=="function"?setTimeout:void 0,wb=typeof clearTimeout=="function"?clearTimeout:void 0,w_=typeof Promise=="function"?Promise:void 0,Rb=typeof queueMicrotask=="function"?queueMicrotask:typeof w_<"u"?function(t){return w_.resolve(null).then(t).catch(Db)}:C_;function Db(t){setTimeout(function(){throw t})}function us(t){return t==="head"}function R_(t,i){var r=i,o=0;do{var u=r.nextSibling;if(t.removeChild(r),u&&u.nodeType===8)if(r=u.data,r==="/$"||r==="/&"){if(o===0){t.removeChild(u),Xr(i);return}o--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")o++;else if(r==="html")al(t.ownerDocument.documentElement);else if(r==="head"){r=t.ownerDocument.head,al(r);for(var f=r.firstChild;f;){var b=f.nextSibling,N=f.nodeName;f[Ji]||N==="SCRIPT"||N==="STYLE"||N==="LINK"&&f.rel.toLowerCase()==="stylesheet"||r.removeChild(f),f=b}}else r==="body"&&al(t.ownerDocument.body);r=u}while(r);Xr(i)}function D_(t,i){var r=t;t=0;do{var o=r.nextSibling;if(r.nodeType===1?i?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(i?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),o&&o.nodeType===8)if(r=o.data,r==="/$"){if(t===0)break;t--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||t++;r=o}while(r)}function Ff(t){var i=t.firstChild;for(i&&i.nodeType===10&&(i=i.nextSibling);i;){var r=i;switch(i=i.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":Ff(r),ea(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}t.removeChild(r)}}function Nb(t,i,r,o){for(;t.nodeType===1;){var u=r;if(t.nodeName.toLowerCase()!==i.toLowerCase()){if(!o&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(o){if(!t[Ji])switch(i){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(f=t.getAttribute("rel"),f==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(f!==u.rel||t.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||t.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||t.getAttribute("title")!==(u.title==null?null:u.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(f=t.getAttribute("src"),(f!==(u.src==null?null:u.src)||t.getAttribute("type")!==(u.type==null?null:u.type)||t.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&f&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(i==="input"&&t.type==="hidden"){var f=u.name==null?null:""+u.name;if(u.type==="hidden"&&t.getAttribute("name")===f)return t}else return t;if(t=Ai(t.nextSibling),t===null)break}return null}function Ub(t,i,r){if(i==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Ai(t.nextSibling),t===null))return null;return t}function N_(t,i){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!i||(t=Ai(t.nextSibling),t===null))return null;return t}function zf(t){return t.data==="$?"||t.data==="$~"}function Hf(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function Lb(t,i){var r=t.ownerDocument;if(t.data==="$~")t._reactRetry=i;else if(t.data!=="$?"||r.readyState!=="loading")i();else{var o=function(){i(),r.removeEventListener("DOMContentLoaded",o)};r.addEventListener("DOMContentLoaded",o),t._reactRetry=o}}function Ai(t){for(;t!=null;t=t.nextSibling){var i=t.nodeType;if(i===1||i===3)break;if(i===8){if(i=t.data,i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"||i==="F!"||i==="F")break;if(i==="/$"||i==="/&")return null}}return t}var Gf=null;function U_(t){t=t.nextSibling;for(var i=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"||r==="/&"){if(i===0)return Ai(t.nextSibling);i--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||i++}t=t.nextSibling}return null}function L_(t){t=t.previousSibling;for(var i=0;t;){if(t.nodeType===8){var r=t.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(i===0)return t;i--}else r!=="/$"&&r!=="/&"||i++}t=t.previousSibling}return null}function O_(t,i,r){switch(i=Uc(r),t){case"html":if(t=i.documentElement,!t)throw Error(s(452));return t;case"head":if(t=i.head,!t)throw Error(s(453));return t;case"body":if(t=i.body,!t)throw Error(s(454));return t;default:throw Error(s(451))}}function al(t){for(var i=t.attributes;i.length;)t.removeAttributeNode(i[0]);ea(t)}var Ci=new Map,P_=new Set;function Lc(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var Ua=j.d;j.d={f:Ob,r:Pb,D:Ib,C:Bb,L:Fb,m:zb,X:Gb,S:Hb,M:Vb};function Ob(){var t=Ua.f(),i=Ec();return t||i}function Pb(t){var i=Pi(t);i!==null&&i.tag===5&&i.type==="form"?Qg(i):Ua.r(t)}var Vr=typeof document>"u"?null:document;function I_(t,i,r){var o=Vr;if(o&&typeof i=="string"&&i){var u=$t(i);u='link[rel="'+t+'"][href="'+u+'"]',typeof r=="string"&&(u+='[crossorigin="'+r+'"]'),P_.has(u)||(P_.add(u),t={rel:t,crossOrigin:r,href:i},o.querySelector(u)===null&&(i=o.createElement("link"),Hn(i,"link",t),mn(i),o.head.appendChild(i)))}}function Ib(t){Ua.D(t),I_("dns-prefetch",t,null)}function Bb(t,i){Ua.C(t,i),I_("preconnect",t,i)}function Fb(t,i,r){Ua.L(t,i,r);var o=Vr;if(o&&t&&i){var u='link[rel="preload"][as="'+$t(i)+'"]';i==="image"&&r&&r.imageSrcSet?(u+='[imagesrcset="'+$t(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(u+='[imagesizes="'+$t(r.imageSizes)+'"]')):u+='[href="'+$t(t)+'"]';var f=u;switch(i){case"style":f=kr(t);break;case"script":f=jr(t)}Ci.has(f)||(t=S({rel:"preload",href:i==="image"&&r&&r.imageSrcSet?void 0:t,as:i},r),Ci.set(f,t),o.querySelector(u)!==null||i==="style"&&o.querySelector(sl(f))||i==="script"&&o.querySelector(rl(f))||(i=o.createElement("link"),Hn(i,"link",t),mn(i),o.head.appendChild(i)))}}function zb(t,i){Ua.m(t,i);var r=Vr;if(r&&t){var o=i&&typeof i.as=="string"?i.as:"script",u='link[rel="modulepreload"][as="'+$t(o)+'"][href="'+$t(t)+'"]',f=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":f=jr(t)}if(!Ci.has(f)&&(t=S({rel:"modulepreload",href:t},i),Ci.set(f,t),r.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(rl(f)))return}o=r.createElement("link"),Hn(o,"link",t),mn(o),r.head.appendChild(o)}}}function Hb(t,i,r){Ua.S(t,i,r);var o=Vr;if(o&&t){var u=ta(o).hoistableStyles,f=kr(t);i=i||"default";var b=u.get(f);if(!b){var N={loading:0,preload:null};if(b=o.querySelector(sl(f)))N.loading=5;else{t=S({rel:"stylesheet",href:t,"data-precedence":i},r),(r=Ci.get(f))&&Vf(t,r);var q=b=o.createElement("link");mn(q),Hn(q,"link",t),q._p=new Promise(function(de,Se){q.onload=de,q.onerror=Se}),q.addEventListener("load",function(){N.loading|=1}),q.addEventListener("error",function(){N.loading|=2}),N.loading|=4,Oc(b,i,o)}b={type:"stylesheet",instance:b,count:1,state:N},u.set(f,b)}}}function Gb(t,i){Ua.X(t,i);var r=Vr;if(r&&t){var o=ta(r).hoistableScripts,u=jr(t),f=o.get(u);f||(f=r.querySelector(rl(u)),f||(t=S({src:t,async:!0},i),(i=Ci.get(u))&&kf(t,i),f=r.createElement("script"),mn(f),Hn(f,"link",t),r.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},o.set(u,f))}}function Vb(t,i){Ua.M(t,i);var r=Vr;if(r&&t){var o=ta(r).hoistableScripts,u=jr(t),f=o.get(u);f||(f=r.querySelector(rl(u)),f||(t=S({src:t,async:!0,type:"module"},i),(i=Ci.get(u))&&kf(t,i),f=r.createElement("script"),mn(f),Hn(f,"link",t),r.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},o.set(u,f))}}function B_(t,i,r,o){var u=(u=oe.current)?Lc(u):null;if(!u)throw Error(s(446));switch(t){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(i=kr(r.href),r=ta(u).hoistableStyles,o=r.get(i),o||(o={type:"style",instance:null,count:0,state:null},r.set(i,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){t=kr(r.href);var f=ta(u).hoistableStyles,b=f.get(t);if(b||(u=u.ownerDocument||u,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},f.set(t,b),(f=u.querySelector(sl(t)))&&!f._p&&(b.instance=f,b.state.loading=5),Ci.has(t)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},Ci.set(t,r),f||kb(u,t,r,b.state))),i&&o===null)throw Error(s(528,""));return b}if(i&&o!==null)throw Error(s(529,""));return null;case"script":return i=r.async,r=r.src,typeof r=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=jr(r),r=ta(u).hoistableScripts,o=r.get(i),o||(o={type:"script",instance:null,count:0,state:null},r.set(i,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,t))}}function kr(t){return'href="'+$t(t)+'"'}function sl(t){return'link[rel="stylesheet"]['+t+"]"}function F_(t){return S({},t,{"data-precedence":t.precedence,precedence:null})}function kb(t,i,r,o){t.querySelector('link[rel="preload"][as="style"]['+i+"]")?o.loading=1:(i=t.createElement("link"),o.preload=i,i.addEventListener("load",function(){return o.loading|=1}),i.addEventListener("error",function(){return o.loading|=2}),Hn(i,"link",r),mn(i),t.head.appendChild(i))}function jr(t){return'[src="'+$t(t)+'"]'}function rl(t){return"script[async]"+t}function z_(t,i,r){if(i.count++,i.instance===null)switch(i.type){case"style":var o=t.querySelector('style[data-href~="'+$t(r.href)+'"]');if(o)return i.instance=o,mn(o),o;var u=S({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return o=(t.ownerDocument||t).createElement("style"),mn(o),Hn(o,"style",u),Oc(o,r.precedence,t),i.instance=o;case"stylesheet":u=kr(r.href);var f=t.querySelector(sl(u));if(f)return i.state.loading|=4,i.instance=f,mn(f),f;o=F_(r),(u=Ci.get(u))&&Vf(o,u),f=(t.ownerDocument||t).createElement("link"),mn(f);var b=f;return b._p=new Promise(function(N,q){b.onload=N,b.onerror=q}),Hn(f,"link",o),i.state.loading|=4,Oc(f,r.precedence,t),i.instance=f;case"script":return f=jr(r.src),(u=t.querySelector(rl(f)))?(i.instance=u,mn(u),u):(o=r,(u=Ci.get(f))&&(o=S({},r),kf(o,u)),t=t.ownerDocument||t,u=t.createElement("script"),mn(u),Hn(u,"link",o),t.head.appendChild(u),i.instance=u);case"void":return null;default:throw Error(s(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(o=i.instance,i.state.loading|=4,Oc(o,r.precedence,t));return i.instance}function Oc(t,i,r){for(var o=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,f=u,b=0;b<o.length;b++){var N=o[b];if(N.dataset.precedence===i)f=N;else if(f!==u)break}f?f.parentNode.insertBefore(t,f.nextSibling):(i=r.nodeType===9?r.head:r,i.insertBefore(t,i.firstChild))}function Vf(t,i){t.crossOrigin==null&&(t.crossOrigin=i.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=i.referrerPolicy),t.title==null&&(t.title=i.title)}function kf(t,i){t.crossOrigin==null&&(t.crossOrigin=i.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=i.referrerPolicy),t.integrity==null&&(t.integrity=i.integrity)}var Pc=null;function H_(t,i,r){if(Pc===null){var o=new Map,u=Pc=new Map;u.set(r,o)}else u=Pc,o=u.get(r),o||(o=new Map,u.set(r,o));if(o.has(t))return o;for(o.set(t,null),r=r.getElementsByTagName(t),u=0;u<r.length;u++){var f=r[u];if(!(f[Ji]||f[vt]||t==="link"&&f.getAttribute("rel")==="stylesheet")&&f.namespaceURI!=="http://www.w3.org/2000/svg"){var b=f.getAttribute(i)||"";b=t+b;var N=o.get(b);N?N.push(f):o.set(b,[f])}}return o}function G_(t,i,r){t=t.ownerDocument||t,t.head.insertBefore(r,i==="title"?t.querySelector("head > title"):null)}function jb(t,i,r){if(r===1||i.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;return i.rel==="stylesheet"?(t=i.disabled,typeof i.precedence=="string"&&t==null):!0;case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function V_(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Xb(t,i,r,o){if(r.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var u=kr(o.href),f=i.querySelector(sl(u));if(f){i=f._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(t.count++,t=Ic.bind(t),i.then(t,t)),r.state.loading|=4,r.instance=f,mn(f);return}f=i.ownerDocument||i,o=F_(o),(u=Ci.get(u))&&Vf(o,u),f=f.createElement("link"),mn(f);var b=f;b._p=new Promise(function(N,q){b.onload=N,b.onerror=q}),Hn(f,"link",o),r.instance=f}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(r,i),(i=r.state.preload)&&(r.state.loading&3)===0&&(t.count++,r=Ic.bind(t),i.addEventListener("load",r),i.addEventListener("error",r))}}var jf=0;function Wb(t,i){return t.stylesheets&&t.count===0&&Fc(t,t.stylesheets),0<t.count||0<t.imgCount?function(r){var o=setTimeout(function(){if(t.stylesheets&&Fc(t,t.stylesheets),t.unsuspend){var f=t.unsuspend;t.unsuspend=null,f()}},6e4+i);0<t.imgBytes&&jf===0&&(jf=62500*Ab());var u=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Fc(t,t.stylesheets),t.unsuspend)){var f=t.unsuspend;t.unsuspend=null,f()}},(t.imgBytes>jf?50:800)+i);return t.unsuspend=r,function(){t.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function Ic(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Fc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Bc=null;function Fc(t,i){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Bc=new Map,i.forEach(qb,t),Bc=null,Ic.call(t))}function qb(t,i){if(!(i.state.loading&4)){var r=Bc.get(t);if(r)var o=r.get(null);else{r=new Map,Bc.set(t,r);for(var u=t.querySelectorAll("link[data-precedence],style[data-precedence]"),f=0;f<u.length;f++){var b=u[f];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(r.set(b.dataset.precedence,b),o=b)}o&&r.set(null,o)}u=i.instance,b=u.getAttribute("data-precedence"),f=r.get(b)||o,f===o&&r.set(null,u),r.set(b,u),this.count++,o=Ic.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),f?f.parentNode.insertBefore(u,f.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(u,t.firstChild)),i.state.loading|=4}}var ol={$$typeof:O,Provider:null,Consumer:null,_currentValue:ae,_currentValue2:ae,_threadCount:0};function Yb(t,i,r,o,u,f,b,N,q){this.tag=1,this.containerInfo=t,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=Ze(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ze(0),this.hiddenUpdates=Ze(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=f,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=q,this.incompleteTransitions=new Map}function k_(t,i,r,o,u,f,b,N,q,de,Se,we){return t=new Yb(t,i,r,b,q,de,Se,we,N),i=1,f===!0&&(i|=24),f=ui(3,null,null,i),t.current=f,f.stateNode=t,i=bd(),i.refCount++,t.pooledCache=i,i.refCount++,f.memoizedState={element:o,isDehydrated:r,cache:i},Ad(f),t}function j_(t){return t?(t=Sr,t):Sr}function X_(t,i,r,o,u,f){u=j_(u),o.context===null?o.context=u:o.pendingContext=u,o=Ja(i),o.payload={element:r},f=f===void 0?null:f,f!==null&&(o.callback=f),r=es(t,o,i),r!==null&&(ni(r,t,i),zo(r,t,i))}function W_(t,i){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<i?r:i}}function Xf(t,i){W_(t,i),(t=t.alternate)&&W_(t,i)}function q_(t){if(t.tag===13||t.tag===31){var i=Ps(t,67108864);i!==null&&ni(i,t,67108864),Xf(t,67108864)}}function Y_(t){if(t.tag===13||t.tag===31){var i=mi();i=Re(i);var r=Ps(t,i);r!==null&&ni(r,t,i),Xf(t,i)}}var zc=!0;function Zb(t,i,r,o){var u=V.T;V.T=null;var f=j.p;try{j.p=2,Wf(t,i,r,o)}finally{j.p=f,V.T=u}}function Kb(t,i,r,o){var u=V.T;V.T=null;var f=j.p;try{j.p=8,Wf(t,i,r,o)}finally{j.p=f,V.T=u}}function Wf(t,i,r,o){if(zc){var u=qf(o);if(u===null)Uf(t,i,o,Hc,r),K_(t,o);else if(Qb(u,t,i,r,o))o.stopPropagation();else if(K_(t,o),i&4&&-1<$b.indexOf(t)){for(;u!==null;){var f=Pi(u);if(f!==null)switch(f.tag){case 3:if(f=f.stateNode,f.current.memoizedState.isDehydrated){var b=Oe(f.pendingLanes);if(b!==0){var N=f;for(N.pendingLanes|=2,N.entangledLanes|=2;b;){var q=1<<31-We(b);N.entanglements[1]|=q,b&=~q}ra(f),(Wt&6)===0&&(bc=Ue()+500,tl(0))}}break;case 31:case 13:N=Ps(f,2),N!==null&&ni(N,f,2),Ec(),Xf(f,2)}if(f=qf(o),f===null&&Uf(t,i,o,Hc,r),f===u)break;u=f}u!==null&&o.stopPropagation()}else Uf(t,i,o,null,r)}}function qf(t){return t=Yu(t),Yf(t)}var Hc=null;function Yf(t){if(Hc=null,t=Oi(t),t!==null){var i=c(t);if(i===null)t=null;else{var r=i.tag;if(r===13){if(t=d(i),t!==null)return t;t=null}else if(r===31){if(t=p(i),t!==null)return t;t=null}else if(r===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;t=null}else i!==t&&(t=null)}}return Hc=t,null}function Z_(t){switch(t){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(ft()){case F:return 2;case A:return 8;case ne:case re:return 32;case fe:return 268435456;default:return 32}default:return 32}}var Zf=!1,ds=null,fs=null,hs=null,ll=new Map,cl=new Map,ps=[],$b="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 K_(t,i){switch(t){case"focusin":case"focusout":ds=null;break;case"dragenter":case"dragleave":fs=null;break;case"mouseover":case"mouseout":hs=null;break;case"pointerover":case"pointerout":ll.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":cl.delete(i.pointerId)}}function ul(t,i,r,o,u,f){return t===null||t.nativeEvent!==f?(t={blockedOn:i,domEventName:r,eventSystemFlags:o,nativeEvent:f,targetContainers:[u]},i!==null&&(i=Pi(i),i!==null&&q_(i)),t):(t.eventSystemFlags|=o,i=t.targetContainers,u!==null&&i.indexOf(u)===-1&&i.push(u),t)}function Qb(t,i,r,o,u){switch(i){case"focusin":return ds=ul(ds,t,i,r,o,u),!0;case"dragenter":return fs=ul(fs,t,i,r,o,u),!0;case"mouseover":return hs=ul(hs,t,i,r,o,u),!0;case"pointerover":var f=u.pointerId;return ll.set(f,ul(ll.get(f)||null,t,i,r,o,u)),!0;case"gotpointercapture":return f=u.pointerId,cl.set(f,ul(cl.get(f)||null,t,i,r,o,u)),!0}return!1}function $_(t){var i=Oi(t.target);if(i!==null){var r=c(i);if(r!==null){if(i=r.tag,i===13){if(i=d(r),i!==null){t.blockedOn=i,Ot(t.priority,function(){Y_(r)});return}}else if(i===31){if(i=p(r),i!==null){t.blockedOn=i,Ot(t.priority,function(){Y_(r)});return}}else if(i===3&&r.stateNode.current.memoizedState.isDehydrated){t.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Gc(t){if(t.blockedOn!==null)return!1;for(var i=t.targetContainers;0<i.length;){var r=qf(t.nativeEvent);if(r===null){r=t.nativeEvent;var o=new r.constructor(r.type,r);qu=o,r.target.dispatchEvent(o),qu=null}else return i=Pi(r),i!==null&&q_(i),t.blockedOn=r,!1;i.shift()}return!0}function Q_(t,i,r){Gc(t)&&r.delete(i)}function Jb(){Zf=!1,ds!==null&&Gc(ds)&&(ds=null),fs!==null&&Gc(fs)&&(fs=null),hs!==null&&Gc(hs)&&(hs=null),ll.forEach(Q_),cl.forEach(Q_)}function Vc(t,i){t.blockedOn===i&&(t.blockedOn=null,Zf||(Zf=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,Jb)))}var kc=null;function J_(t){kc!==t&&(kc=t,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){kc===t&&(kc=null);for(var i=0;i<t.length;i+=3){var r=t[i],o=t[i+1],u=t[i+2];if(typeof o!="function"){if(Yf(o||r)===null)continue;break}var f=Pi(r);f!==null&&(t.splice(i,3),i-=3,Wd(f,{pending:!0,data:u,method:r.method,action:o},o,u))}}))}function Xr(t){function i(q){return Vc(q,t)}ds!==null&&Vc(ds,t),fs!==null&&Vc(fs,t),hs!==null&&Vc(hs,t),ll.forEach(i),cl.forEach(i);for(var r=0;r<ps.length;r++){var o=ps[r];o.blockedOn===t&&(o.blockedOn=null)}for(;0<ps.length&&(r=ps[0],r.blockedOn===null);)$_(r),r.blockedOn===null&&ps.shift();if(r=(t.ownerDocument||t).$$reactFormReplay,r!=null)for(o=0;o<r.length;o+=3){var u=r[o],f=r[o+1],b=u[vn]||null;if(typeof f=="function")b||J_(r);else if(b){var N=null;if(f&&f.hasAttribute("formAction")){if(u=f,b=f[vn]||null)N=b.formAction;else if(Yf(u)!==null)continue}else N=b.action;typeof N=="function"?r[o+1]=N:(r.splice(o,3),o-=3),J_(r)}}}function ev(){function t(f){f.canIntercept&&f.info==="react-transition"&&f.intercept({handler:function(){return new Promise(function(b){return u=b})},focusReset:"manual",scroll:"manual"})}function i(){u!==null&&(u(),u=null),o||setTimeout(r,20)}function r(){if(!o&&!navigation.transition){var f=navigation.currentEntry;f&&f.url!=null&&navigation.navigate(f.url,{state:f.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",i),navigation.addEventListener("navigateerror",i),setTimeout(r,100),function(){o=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",i),navigation.removeEventListener("navigateerror",i),u!==null&&(u(),u=null)}}}function Kf(t){this._internalRoot=t}jc.prototype.render=Kf.prototype.render=function(t){var i=this._internalRoot;if(i===null)throw Error(s(409));var r=i.current,o=mi();X_(r,o,t,i,null,null)},jc.prototype.unmount=Kf.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var i=t.containerInfo;X_(t.current,2,null,t,null,null),Ec(),i[Vn]=null}};function jc(t){this._internalRoot=t}jc.prototype.unstable_scheduleHydration=function(t){if(t){var i=gt();t={blockedOn:null,target:t,priority:i};for(var r=0;r<ps.length&&i!==0&&i<ps[r].priority;r++);ps.splice(r,0,t),r===0&&$_(t)}};var tv=e.version;if(tv!=="19.2.7")throw Error(s(527,tv,"19.2.7"));j.findDOMNode=function(t){var i=t._reactInternals;if(i===void 0)throw typeof t.render=="function"?Error(s(188)):(t=Object.keys(t).join(","),Error(s(268,t)));return t=h(i),t=t!==null?v(t):null,t=t===null?null:t.stateNode,t};var eM={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:V,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Xc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xc.isDisabled&&Xc.supportsFiber)try{ge=Xc.inject(eM),le=Xc}catch{}}return fl.createRoot=function(t,i){if(!l(t))throw Error(s(299));var r=!1,o="",u=l0,f=c0,b=u0;return i!=null&&(i.unstable_strictMode===!0&&(r=!0),i.identifierPrefix!==void 0&&(o=i.identifierPrefix),i.onUncaughtError!==void 0&&(u=i.onUncaughtError),i.onCaughtError!==void 0&&(f=i.onCaughtError),i.onRecoverableError!==void 0&&(b=i.onRecoverableError)),i=k_(t,1,!1,null,null,r,o,null,u,f,b,ev),t[Vn]=i.current,Nf(t),new Kf(i)},fl.hydrateRoot=function(t,i,r){if(!l(t))throw Error(s(299));var o=!1,u="",f=l0,b=c0,N=u0,q=null;return r!=null&&(r.unstable_strictMode===!0&&(o=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onUncaughtError!==void 0&&(f=r.onUncaughtError),r.onCaughtError!==void 0&&(b=r.onCaughtError),r.onRecoverableError!==void 0&&(N=r.onRecoverableError),r.formState!==void 0&&(q=r.formState)),i=k_(t,1,!0,i,r??null,o,u,q,f,b,N,ev),i.context=j_(null),r=i.current,o=mi(),o=Re(o),u=Ja(o),u.callback=null,es(r,u,o),r=o,i.current.lanes=r,qe(i,r),ra(i),t[Vn]=i.current,Nf(t),new jc(i)},fl.version="19.2.7",fl}var dv;function dM(){if(dv)return Jf.exports;dv=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(e){console.error(e)}}return a(),Jf.exports=uM(),Jf.exports}var fM=dM();const hM=zx(fM),pM="wrap",mM=24;function Hx(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function gM(a,e){return a===void 0||e===void 0?!1:Array.isArray(a)||Array.isArray(e)?!Array.isArray(a)||!Array.isArray(e)?!1:JSON.stringify([...a].sort())===JSON.stringify([...e].sort()):a===e}function Fa(a,e){return e?(a.supported_classes??a.supportedClasses??[]).some(s=>s.dimensions===e.dimensions&&gM(s.states,e.states)&&_M(s,e)):!1}function _M(a,e){return!a.neighborhoodId||!e.neighborhoodId?!0:a.neighborhoodId===e.neighborhoodId}function ir(a){const e=a?.caClass;if(!Hx(e))return;const n=typeof e.dimensions=="number"?e.dimensions:void 0,s=e.states;if(!(!n||typeof s!="number"&&!Array.isArray(s)))return{neighborhoodId:typeof e.neighborhoodId=="string"?e.neighborhoodId:void 0,dimensions:n,states:s}}function Gx(a,e,n=mM){const s=Hx(a)?a:{},l=Array.isArray(s.size)?s.size:[],c=typeof l[0]=="number"?l[0]:n,d=e>=2&&typeof l[1]=="number"?l[1]:1,p=e>=3&&typeof l[2]=="number"?l[2]:1;return[c,d,p]}function Hu(a){let e=2166136261;for(let n=0;n<a.length;n+=1)e^=a.charCodeAt(n),e=Math.imul(e,16777619);return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function Vx(a,e){return typeof a?.rng_seed=="string"&&a.rng_seed.trim()?a.rng_seed:typeof a?.seed=="string"&&a.seed.trim()?a.seed:e}function vM(a){return a==="wrap"||a==="mirror"||a==="fixed"}function Xp(a){return Pl(a?.simulation?.grid)}function Pl(a){return vM(a?.boundary)?a.boundary:a?.wrap===!1?"fixed":pM}function kx(a,e){return(a%e+e)%e}function xM(a,e){if(e<=1)return 0;const n=(e-1)*2,s=kx(a,n);return s<=e-1?s:n-s}function Ga(a,e,n){return e<=0?null:n==="wrap"?kx(a,e):n==="mirror"?xM(a,e):a>=0&&a<e?a:null}function jx(a){return a.map(e=>[...e])}function fv(a,e="cells"){const n=a[0]?.length??0;for(const s of a){if(s.length!==n)throw new Error(`${e} must be rectangular`);for(const l of s)if(typeof l!="boolean")throw new Error(`${e} must contain boolean cell states`)}}function yM(a,e,n="engine output"){if(fv(a,"input cells"),fv(e,n),e.length!==a.length||(e[0]?.length??0)!==(a[0]?.length??0))throw new Error(`${n} must preserve the input grid dimensions`)}function SM(a){const e=/(?:rule[-_\s]*)?(\d{1,3})/i.exec(a??"");return e?Math.max(0,Math.min(255,Number(e[1]))):110}function bM(a,e){const n=SM(e.simulation?.ruleId),s=jx(a),l=a[0]?.length??0;if(a.length===0||l===0)return s;const c=Pl(e.simulation?.grid),d=Math.max(0,a.findIndex(m=>m.some(Boolean))),p=a[d]??[];for(let m=0;m<l;m+=1){const h=Ga(m-1,l,c),v=Ga(m+1,l,c),S=h===null?0:p[h]?1:0,_=p[m]?1:0,M=v===null?0:p[v]?1:0,E=S<<2|_<<1|M;s[d][m]=(n>>E&1)===1}return s}class Ru{position;forward;constructor(e,n){this.position=e,this.forward=n}}function bu(a){return a===1||a===2||a===3||a===4||a===5||a===6}function MM(a,e){return[a[0]+e[0],a[1]+e[1],a[2]+e[2]]}function EM(a,e){return[a[0]-e[0],a[1]-e[1],a[2]-e[2]]}function Xx(a,e){const n=Ga(a[0],e.size[0],e.boundary),s=Ga(a[1],e.size[1],e.boundary),l=Ga(a[2],e.size[2],e.boundary);return n===null||s===null||l===null?null:[n,s,l]}function jh(a,e,n){return Xx(MM(a,e),n)}function ih(a,e,n){return Xx(EM(a,e),n)}function Wx(a){return(a+2)%6+1}function co(a){return a===1?[1,0,0]:a===2?[0,1,0]:a===3?[0,0,1]:a===4?[-1,0,0]:a===5?[0,-1,0]:a===6?[0,0,-1]:null}function Xi(a){return`${a[0]}_${a[1]}_${a[2]}`}function TM(a,e,n){const s=[];for(const l of a.values()){let c=0,d=0;if(l.forward!==null){for(let p=1;p<=6;p=p+1){const m=co(p);if(!m)continue;const h=jh(l.position,m,n);if(!h)continue;const v=a.get(Xi(h));!v||v.forward===null||(v.forward===Wx(p)&&(d+=1),p===l.forward&&(c+=1))}c<=1&&d===0&&s.push(l)}}return s}function qx(a=100){return Hu(String(a))}function AM(a,e,n,s=qx()){const l=TM(a,e,n);if(l.length===0)throw new Error("Cannot evolve, no heads");const c=l[Math.floor(s()*l.length)]??l[0];return CM(a,c,e,n)}function CM(a,e,n,s,l){let c=0,d=0,p=e,m=e,h=!0;const v=new Set;for(;h;){const x=Xi(p.position);if(v.has(x)){h=!1,m=p;break}if(v.add(x),p.forward===null)break;const P=co(p.forward);if(!P)break;const O=jh(p.position,P,s);if(!O)break;const R=a.get(Xi(O));R&&bu(R.forward)?(p=R,h=!0):(h=!1,m=p)}if(m.forward===null)return{changes:c,emits:d,comment:`T:${n} | Tail has no symbol to move.`};const S=co(m.forward);if(!S)return{changes:c,emits:d,comment:`T:${n} | Tail symbol has no direction.`};const _=ih(e.position,S,s);if(!_)return{changes:c,emits:d,comment:`T:${n} | Tail would move outside fixed boundary.`};const M=Xi(_);a.has(M)||a.set(M,new Ru(_,null));const E=a.get(M);if(!E)throw new Error(`Unable to create naga place cell at ${M}`);if(e.forward===Wx(m.forward)){let x=`T:${n} | Emission! ${E.position.join(",")} implied contradiction.`,P=!0;p=a.get(Xi(e.position))??e;const O=new Set;for(;P;){const T=Xi(p.position);if(O.has(T)||(O.add(T),p.forward===null))break;const U=co(p.forward);if(!U)break;const X=jh(p.position,U,s);if(!X)break;const G=a.get(Xi(X));if(G&&bu(G.forward)){p=G;const K=ih(p.position,S,s);if(!K){P=!1;break}const ue=a.get(Xi(K));P=!!(ue&&bu(ue.forward))}else P=!1}const R=ih(p.position,S,s);if(!R)return{changes:c,emits:d,comment:`T:${n} | Kink would move outside fixed boundary.`};const I=Xi(R);a.has(I)||a.set(I,new Ru(R,null));const B=a.get(I);if(!B)throw new Error(`Unable to create naga kink place cell at ${I}`);const L=B.forward;return B.forward=m.forward,m.forward=L,d+=1,c+=1,x+=` Kink at ${R.join(",")}, swapped ${B.forward} for ${L}.`,{changes:c,emits:d,comment:x}}const C=`T:${n} | Take tail symbol ${m.forward} from ${m.position.join(",")}, put into ${E.position.join(",")} in exchange for ${E.forward}`,y=E.forward;return E.forward=m.forward,m.forward=y,c+=1,{changes:c,emits:d,comment:C}}function wM(a,e){const n=a.simulation?.grid?.size,s=Array.isArray(n)&&typeof n[0]=="number"?n[0]:e[0]?.length??24,l=Array.isArray(n)&&typeof n[1]=="number"?n[1]:e.length||24,c=Array.isArray(n)&&typeof n[2]=="number"?n[2]:24;return[Math.max(1,s),Math.max(1,l),Math.max(1,c)]}function RM(a){const e=a[3]??1;return bu(e)?e:1}function DM(a){const e=new Map;for(const n of a??[]){const[s,l,c=0]=n;if(!Number.isInteger(s)||!Number.isInteger(l)||!Number.isInteger(c))continue;const d=[s,l,c];e.set(Xi(d),new Ru(d,RM(n)))}return e}function NM(a){const e=new Map;for(let n=0;n<a.length;n+=1)for(let s=0;s<(a[n]?.length??0);s+=1){if(!a[n][s])continue;const l=[s,n,0];e.set(Xi(l),new Ru(l,1))}return e}function UM(a,e){const n=[];for(const s of a.values()){const[l,c,d]=s.position;s.forward!==null&&(l<0||c<0||d<0||l>=e[0]||c>=e[1]||d>=e[2]||n.push([l,c,d,s.forward]))}return n}function LM(a,e){const n=e.map(s=>s.map(()=>!1));for(const s of a){const[l,c]=s;!Number.isInteger(l)||!Number.isInteger(c)||c<0||l<0||c>=n.length||l>=(n[c]?.length??0)||(n[c][l]=!0)}return n}function OM(a){return a.simulation??={},a.simulation.initialCondition??={},a.simulation}function PM(a,e){const n=OM(e),s=wM(e,a),l=n.initialCondition?.cells,c=Array.isArray(l)&&l.length>0?DM(l):NM(a),d=typeof n.nagaTick=="number"?n.nagaTick:0,p=Vx(n,"naga"),m={boundary:Pl(n.grid),size:s};try{AM(c,d,m,qx(`${p}:${d}`))}catch(v){if(!(v instanceof Error)||v.message!=="Cannot evolve, no heads")throw v}const h=UM(c,s);return n.initialCondition={...n.initialCondition,type:"cells",cells:h},n.nagaTick=d+1,LM(h,a)}function Wp(a){return jx(a)}function Yx(a){return a.map(e=>e.map(()=>!1))}function IM(a){const e=/^B([0-8]*)\/S([0-8]*)$/i.exec(a);return e?{birth:new Set(e[1].split("").map(Number)),survival:new Set(e[2].split("").map(Number))}:{birth:new Set([3]),survival:new Set([2,3])}}function Zx(a,e){const n=IM(e.simulation?.ruleId??"B3/S23"),s=Yx(a),l=a.length,c=a[0]?.length??0,d=Pl(e.simulation?.grid);for(let p=0;p<l;p+=1)for(let m=0;m<c;m+=1){let h=0;for(let v=-1;v<=1;v+=1)for(let S=-1;S<=1;S+=1){if(S===0&&v===0)continue;const _=m+S,M=p+v,E=Ga(_,c,d),C=Ga(M,l,d);E===null||C===null||a[C][E]&&(h+=1)}s[p][m]=a[p][m]?n.survival.has(h):n.birth.has(h)}return s}function BM(a,e){return typeof a=="number"&&Number.isFinite(a)?Math.max(0,Math.min(1,a)):e}function FM(a,e,n){return Hu(`${a}:${e}:${n}`)()}function zM(a,e){const n=Yx(a),s=a.length,l=a[0]?.length??0,c=Pl(e.simulation?.grid),d=BM(e.simulation?.spreadProbability,1),p=Vx(e.simulation,"wildfire");for(let m=0;m<s;m+=1)for(let h=0;h<l;h+=1){if(a[m][h]){n[m][h]=!1;continue}let v=0;const S=[[0,-1],[1,0],[0,1],[-1,0]];for(const[_,M]of S){const E=Ga(h+_,l,c),C=Ga(m+M,s,c);E===null||C===null||a[C][E]&&(v+=1)}n[m][h]=v>0&&FM(p,h,m)<d}return n}const Cl=new Map;function ur(a,e={}){if(!a.id.trim())throw new Error("CA engine runtime id is required");if(Cl.has(a.id)&&!e.replace)throw new Error(`CA engine runtime already registered: ${a.id}`);Cl.set(a.id,a)}function Rl(a,e){const n=e.simulation?.engineId??"game-of-life-2d",s=Cl.get(n)??Cl.get("outer-totalistic-2d")??Cl.get("noop"),l=structuredClone(e),c=s?s.step(a,l):Wp(a);return yM(a,c,`CA engine output (${s?.id??"fallback"})`),{cells:c,settings:l}}ur({id:"game-of-life-2d",label:"Game of Life 2D",supportedClasses:[{dimensions:2,states:2}],defaultParams:{ruleId:"B3/S23",rendererId:"2d-canvas"},step:Zx},{replace:!0});ur({id:"outer-totalistic-2d",label:"Outer-totalistic 2D",supportedClasses:[{dimensions:2,states:2}],defaultParams:{ruleId:"B3/S23",rendererId:"2d-canvas"},step:Zx},{replace:!0});ur({id:"elementary-1d",label:"Elementary 1D",supportedClasses:[{dimensions:1,states:2}],defaultParams:{ruleId:"Rule 110",rendererId:"elementary-1d"},step:bM},{replace:!0});ur({id:"wildfire-2d",label:"Wildfire 2D",supportedClasses:[{dimensions:2,states:2}],defaultParams:{ruleId:"wildfire-binary",rendererId:"wildfire-2d",spreadProbability:1},step:zM},{replace:!0});ur({id:"naga-3d",label:"Naga 3D",supportedClasses:[{dimensions:3,states:7}],defaultParams:{ruleId:"naga-3d",rendererId:"voxel-3d",rng_seed:"naga",edgeWrap:!0},step:PM},{replace:!0});ur({id:"generic-voxel-ca",label:"Generic voxel CA",step:Wp},{replace:!0});ur({id:"noop",label:"No evolution",step:Wp},{replace:!0});const Xh=new Map;function HM(a){return Math.max(0,Math.min(1,typeof a=="number"?a:.28))}function Du(a,e,n,s){return Math.max(n,Math.min(s,typeof a=="number"&&Number.isFinite(a)?Math.round(a):e))}function GM(a,e){return Math.max(0,Math.min(1,typeof a=="number"&&Number.isFinite(a)?a:e))}function Kx(a,e){return typeof a.ic_seed=="string"&&a.ic_seed.trim()?a.ic_seed:typeof a.seed=="string"&&a.seed.trim()?a.seed:e}function VM(a){const e=Math.max(Number.EPSILON,a()),n=Math.max(Number.EPSILON,a());return Math.sqrt(-2*Math.log(e))*Math.cos(2*Math.PI*n)}function kM(a,e,n,s){return e<=0?Du(a,5,1,n):Du(a+VM(s)*e,a,1,n)}function jM({settings:a,caClass:e,params:n}){const s=HM(n.density),l=Kx(n,"studio-seed"),c=Hu(l),[d,p,m]=Gx(a.simulation?.grid,e.dimensions),h=[];for(let v=0;v<m;v+=1)for(let S=0;S<p;S+=1)for(let _=0;_<d;_+=1)c()<s&&h.push([_,S,v]);return{type:"cells",cells:h,generator:{kind:"random-soup",density:s,ic_seed:l}}}function XM(a){return Math.floor(a()*6)+1}function WM(a,e,n){if(n()<e)return a;const s=[1,2,3,4,5,6].filter(l=>l!==a);return s[Math.floor(n()*s.length)]??a}function ah(a,e,n){return`${a}_${e}_${n}`}function hv(a,e,n,s,l,c){return a>=0&&e>=0&&n>=0&&a<s&&e<l&&n<c}function qM({settings:a,caClass:e,params:n}){const[s,l,c]=Gx(a.simulation?.grid,e.dimensions),d=Math.max(1,s*l*c),p=Du(n.count,3,1,Math.max(1,s*l*c)),m=Du(n.meanLength??n.length,5,1,d),h=Math.max(0,Math.min(d,typeof n.lengthStdDev=="number"&&Number.isFinite(n.lengthStdDev)?n.lengthStdDev:0)),v=GM(n.sameTypeProbability,.8),S=Kx(n,"naga-markov"),_=Hu(S),M=new Set,E=[],C=p*300;let y=0,x=0;for(;y<p&&x<C;){x+=1;let P=Math.floor(_()*s),O=Math.floor(_()*l),R=Math.floor(_()*c),I=XM(_);const B=kM(m,h,d,_),L=[],T=new Set;let U=!0;for(let G=0;G<B;G+=1){const K=ah(P,O,R);if(!hv(P,O,R,s,l,c)||M.has(K)||T.has(K)){U=!1;break}L.push([P,O,R,I]),T.add(K);const ue=co(I);if(!ue){U=!1;break}const pe=WM(I,v,_);P+=ue[0],O+=ue[1],R+=ue[2],I=pe}const X=L[L.length-1];if(X){const[G,K,ue,pe]=X,Q=co(pe);if(!Q)U=!1;else{const V=G+Q[0],j=K+Q[1],ae=ue+Q[2],_e=ah(V,j,ae);(!hv(V,j,ae,s,l,c)||M.has(_e)||T.has(_e))&&(U=!1)}}if(U){for(const G of L){const[K,ue,pe]=G;M.add(ah(K,ue,pe)),E.push(G)}y+=1}}return{type:"cells",cells:E,generator:{kind:"naga-markov",count:p,meanLength:m,lengthStdDev:h,sameTypeProbability:v,ic_seed:S,created:y}}}function $x(a,e={}){if(!a.id.trim())throw new Error("Initial condition runtime id is required");if(Xh.has(a.id)&&!e.replace)throw new Error(`Initial condition runtime already registered: ${a.id}`);Xh.set(a.id,a)}function YM(a){return Xh.get(a)??null}function ZM(a,e){const n=YM(a);if(!n)throw new Error(`Initial condition runtime unavailable: ${a}`);const s=n.generate(e);if(s.type!=="cells"||!Array.isArray(s.cells))throw new Error(`Initial condition runtime returned an invalid result: ${a}`);return s}$x({id:"random-soup",label:"Random soup",generate:jM},{replace:!0});$x({id:"naga-markov",label:"Naga Markov chains",generate:qM},{replace:!0});const qp="185",uo={ROTATE:0,DOLLY:1,PAN:2},oo={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},KM=0,pv=1,$M=2,Mu=1,Qx=2,Ml=3,As=0,si=1,za=2,Va=0,fo=1,mv=2,gv=3,_v=4,QM=5,Qs=100,JM=101,eE=102,tE=103,nE=104,iE=200,aE=201,sE=202,rE=203,Wh=204,qh=205,oE=206,lE=207,cE=208,uE=209,dE=210,fE=211,hE=212,pE=213,mE=214,Yh=0,Zh=1,Kh=2,_o=3,$h=4,Qh=5,Jh=6,ep=7,Jx=0,gE=1,_E=2,da=0,ey=1,ty=2,ny=3,Yp=4,iy=5,ay=6,sy=7,ry=300,sr=301,vo=302,sh=303,rh=304,Gu=306,tp=1e3,Ha=1001,np=1002,Gn=1003,vE=1004,Wc=1005,qn=1006,oh=1007,er=1008,xi=1009,oy=1010,ly=1011,Dl=1012,Zp=1013,pa=1014,Wi=1015,ja=1016,Kp=1017,$p=1018,Nl=1020,cy=35902,uy=35899,dy=1021,fy=1022,qi=1023,Xa=1026,tr=1027,Qp=1028,Jp=1029,rr=1030,em=1031,tm=1033,Eu=33776,Tu=33777,Au=33778,Cu=33779,ip=35840,ap=35841,sp=35842,rp=35843,op=36196,lp=37492,cp=37496,up=37488,dp=37489,Nu=37490,fp=37491,hp=37808,pp=37809,mp=37810,gp=37811,_p=37812,vp=37813,xp=37814,yp=37815,Sp=37816,bp=37817,Mp=37818,Ep=37819,Tp=37820,Ap=37821,Cp=36492,wp=36494,Rp=36495,Dp=36283,Np=36284,Uu=36285,Up=36286,xE=3200,vv=0,yE=1,Ms="",vi="srgb",Lu="srgb-linear",Ou="linear",tn="srgb",Wr=7680,xv=519,SE=512,bE=513,ME=514,nm=515,EE=516,TE=517,im=518,AE=519,yv=35044,CE=35048,Sv="300 es",ua=2e3,Ul=2001;function wE(a){for(let e=a.length-1;e>=0;--e)if(a[e]>=65535)return!0;return!1}function Pu(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function RE(){const a=Pu("canvas");return a.style.display="block",a}const bv={};function Mv(...a){const e="THREE."+a.shift();console.log(e,...a)}function hy(a){const e=a[0];if(typeof e=="string"&&e.startsWith("TSL:")){const n=a[1];n&&n.isStackTrace?a[0]+=" "+n.getLocation():a[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return a}function mt(...a){a=hy(a);const e="THREE."+a.shift();{const n=a[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...a)}}function kt(...a){a=hy(a);const e="THREE."+a.shift();{const n=a[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...a)}}function ho(...a){const e=a.join(" ");e in bv||(bv[e]=!0,mt(...a))}function DE(a,e,n){return new Promise(function(s,l){function c(){switch(a.clientWaitSync(e,a.SYNC_FLUSH_COMMANDS_BIT,0)){case a.WAIT_FAILED:l();break;case a.TIMEOUT_EXPIRED:setTimeout(c,n);break;default:s()}}setTimeout(c,n)})}const NE={[Yh]:Zh,[Kh]:Jh,[$h]:ep,[_o]:Qh,[Zh]:Yh,[Jh]:Kh,[ep]:$h,[Qh]:_o};class Rs{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(n)===-1&&s[e].push(n)}hasEventListener(e,n){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(n)!==-1}removeEventListener(e,n){const s=this._listeners;if(s===void 0)return;const l=s[e];if(l!==void 0){const c=l.indexOf(n);c!==-1&&l.splice(c,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const s=n[e.type];if(s!==void 0){e.target=this;const l=s.slice(0);for(let c=0,d=l.length;c<d;c++)l[c].call(this,e);e.target=null}}}const Xn=["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"],wl=Math.PI/180,Lp=180/Math.PI;function Il(){const a=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Xn[a&255]+Xn[a>>8&255]+Xn[a>>16&255]+Xn[a>>24&255]+"-"+Xn[e&255]+Xn[e>>8&255]+"-"+Xn[e>>16&15|64]+Xn[e>>24&255]+"-"+Xn[n&63|128]+Xn[n>>8&255]+"-"+Xn[n>>16&255]+Xn[n>>24&255]+Xn[s&255]+Xn[s>>8&255]+Xn[s>>16&255]+Xn[s>>24&255]).toLowerCase()}function Lt(a,e,n){return Math.max(e,Math.min(n,a))}function UE(a,e){return(a%e+e)%e}function lh(a,e,n){return(1-n)*a+n*e}function hl(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return a/4294967295;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int32Array:return Math.max(a/2147483647,-1);case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ii(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return Math.round(a*4294967295);case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int32Array:return Math.round(a*2147483647);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const LE={DEG2RAD:wl},xm=class xm{constructor(e=0,n=0){this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,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,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,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,n){return this.x=e.x-n.x,this.y=e.y-n.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 n=this.x,s=this.y,l=e.elements;return this.x=l[0]*n+l[3]*s+l[6],this.y=l[1]*n+l[4]*s+l[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,n){return this.x=Lt(this.x,e.x,n.x),this.y=Lt(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Lt(this.x,e,n),this.y=Lt(this.y,e,n),this}clampLength(e,n){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Lt(s,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const s=this.dot(e)/n;return Math.acos(Lt(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,s=this.y-e.y;return n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,s){return this.x=e.x+(n.x-e.x)*s,this.y=e.y+(n.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const s=Math.cos(n),l=Math.sin(n),c=this.x-e.x,d=this.y-e.y;return this.x=c*s-d*l+e.x,this.y=c*l+d*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};xm.prototype.isVector2=!0;let bt=xm;class Cs{constructor(e=0,n=0,s=0,l=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=s,this._w=l}static slerpFlat(e,n,s,l,c,d,p){let m=s[l+0],h=s[l+1],v=s[l+2],S=s[l+3],_=c[d+0],M=c[d+1],E=c[d+2],C=c[d+3];if(S!==C||m!==_||h!==M||v!==E){let y=m*_+h*M+v*E+S*C;y<0&&(_=-_,M=-M,E=-E,C=-C,y=-y);let x=1-p;if(y<.9995){const P=Math.acos(y),O=Math.sin(P);x=Math.sin(x*P)/O,p=Math.sin(p*P)/O,m=m*x+_*p,h=h*x+M*p,v=v*x+E*p,S=S*x+C*p}else{m=m*x+_*p,h=h*x+M*p,v=v*x+E*p,S=S*x+C*p;const P=1/Math.sqrt(m*m+h*h+v*v+S*S);m*=P,h*=P,v*=P,S*=P}}e[n]=m,e[n+1]=h,e[n+2]=v,e[n+3]=S}static multiplyQuaternionsFlat(e,n,s,l,c,d){const p=s[l],m=s[l+1],h=s[l+2],v=s[l+3],S=c[d],_=c[d+1],M=c[d+2],E=c[d+3];return e[n]=p*E+v*S+m*M-h*_,e[n+1]=m*E+v*_+h*S-p*M,e[n+2]=h*E+v*M+p*_-m*S,e[n+3]=v*E-p*S-m*_-h*M,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,n,s,l){return this._x=e,this._y=n,this._z=s,this._w=l,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,n=!0){const s=e._x,l=e._y,c=e._z,d=e._order,p=Math.cos,m=Math.sin,h=p(s/2),v=p(l/2),S=p(c/2),_=m(s/2),M=m(l/2),E=m(c/2);switch(d){case"XYZ":this._x=_*v*S+h*M*E,this._y=h*M*S-_*v*E,this._z=h*v*E+_*M*S,this._w=h*v*S-_*M*E;break;case"YXZ":this._x=_*v*S+h*M*E,this._y=h*M*S-_*v*E,this._z=h*v*E-_*M*S,this._w=h*v*S+_*M*E;break;case"ZXY":this._x=_*v*S-h*M*E,this._y=h*M*S+_*v*E,this._z=h*v*E+_*M*S,this._w=h*v*S-_*M*E;break;case"ZYX":this._x=_*v*S-h*M*E,this._y=h*M*S+_*v*E,this._z=h*v*E-_*M*S,this._w=h*v*S+_*M*E;break;case"YZX":this._x=_*v*S+h*M*E,this._y=h*M*S+_*v*E,this._z=h*v*E-_*M*S,this._w=h*v*S-_*M*E;break;case"XZY":this._x=_*v*S-h*M*E,this._y=h*M*S-_*v*E,this._z=h*v*E+_*M*S,this._w=h*v*S+_*M*E;break;default:mt("Quaternion: .setFromEuler() encountered an unknown order: "+d)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const s=n/2,l=Math.sin(s);return this._x=e.x*l,this._y=e.y*l,this._z=e.z*l,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,s=n[0],l=n[4],c=n[8],d=n[1],p=n[5],m=n[9],h=n[2],v=n[6],S=n[10],_=s+p+S;if(_>0){const M=.5/Math.sqrt(_+1);this._w=.25/M,this._x=(v-m)*M,this._y=(c-h)*M,this._z=(d-l)*M}else if(s>p&&s>S){const M=2*Math.sqrt(1+s-p-S);this._w=(v-m)/M,this._x=.25*M,this._y=(l+d)/M,this._z=(c+h)/M}else if(p>S){const M=2*Math.sqrt(1+p-s-S);this._w=(c-h)/M,this._x=(l+d)/M,this._y=.25*M,this._z=(m+v)/M}else{const M=2*Math.sqrt(1+S-s-p);this._w=(d-l)/M,this._x=(c+h)/M,this._y=(m+v)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let s=e.dot(n)+1;return s<1e-8?(s=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Lt(this.dot(e),-1,1)))}rotateTowards(e,n){const s=this.angleTo(e);if(s===0)return this;const l=Math.min(1,n/s);return this.slerp(e,l),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,n){const s=e._x,l=e._y,c=e._z,d=e._w,p=n._x,m=n._y,h=n._z,v=n._w;return this._x=s*v+d*p+l*h-c*m,this._y=l*v+d*m+c*p-s*h,this._z=c*v+d*h+s*m-l*p,this._w=d*v-s*p-l*m-c*h,this._onChangeCallback(),this}slerp(e,n){let s=e._x,l=e._y,c=e._z,d=e._w,p=this.dot(e);p<0&&(s=-s,l=-l,c=-c,d=-d,p=-p);let m=1-n;if(p<.9995){const h=Math.acos(p),v=Math.sin(h);m=Math.sin(m*h)/v,n=Math.sin(n*h)/v,this._x=this._x*m+s*n,this._y=this._y*m+l*n,this._z=this._z*m+c*n,this._w=this._w*m+d*n,this._onChangeCallback()}else this._x=this._x*m+s*n,this._y=this._y*m+l*n,this._z=this._z*m+c*n,this._w=this._w*m+d*n,this.normalize();return this}slerpQuaternions(e,n,s){return this.copy(e).slerp(n,s)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),s=Math.random(),l=Math.sqrt(1-s),c=Math.sqrt(s);return this.set(l*Math.sin(e),l*Math.cos(e),c*Math.sin(n),c*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),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}}const ym=class ym{constructor(e=0,n=0,s=0){this.x=e,this.y=n,this.z=s}set(e,n,s){return s===void 0&&(s=this.z),this.x=e,this.y=n,this.z=s,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,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,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,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.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,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(Ev.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(Ev.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,s=this.y,l=this.z,c=e.elements;return this.x=c[0]*n+c[3]*s+c[6]*l,this.y=c[1]*n+c[4]*s+c[7]*l,this.z=c[2]*n+c[5]*s+c[8]*l,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,s=this.y,l=this.z,c=e.elements,d=1/(c[3]*n+c[7]*s+c[11]*l+c[15]);return this.x=(c[0]*n+c[4]*s+c[8]*l+c[12])*d,this.y=(c[1]*n+c[5]*s+c[9]*l+c[13])*d,this.z=(c[2]*n+c[6]*s+c[10]*l+c[14])*d,this}applyQuaternion(e){const n=this.x,s=this.y,l=this.z,c=e.x,d=e.y,p=e.z,m=e.w,h=2*(d*l-p*s),v=2*(p*n-c*l),S=2*(c*s-d*n);return this.x=n+m*h+d*S-p*v,this.y=s+m*v+p*h-c*S,this.z=l+m*S+c*v-d*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 n=this.x,s=this.y,l=this.z,c=e.elements;return this.x=c[0]*n+c[4]*s+c[8]*l,this.y=c[1]*n+c[5]*s+c[9]*l,this.z=c[2]*n+c[6]*s+c[10]*l,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,n){return this.x=Lt(this.x,e.x,n.x),this.y=Lt(this.y,e.y,n.y),this.z=Lt(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Lt(this.x,e,n),this.y=Lt(this.y,e,n),this.z=Lt(this.z,e,n),this}clampLength(e,n){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Lt(s,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,s){return this.x=e.x+(n.x-e.x)*s,this.y=e.y+(n.y-e.y)*s,this.z=e.z+(n.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const s=e.x,l=e.y,c=e.z,d=n.x,p=n.y,m=n.z;return this.x=l*m-c*p,this.y=c*d-s*m,this.z=s*p-l*d,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const s=e.dot(this)/n;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return ch.copy(this).projectOnVector(e),this.sub(ch)}reflect(e){return this.sub(ch.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const s=this.dot(e)/n;return Math.acos(Lt(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,s=this.y-e.y,l=this.z-e.z;return n*n+s*s+l*l}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,n,s){const l=Math.sin(n)*e;return this.x=l*Math.sin(s),this.y=Math.cos(n)*e,this.z=l*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,s){return this.x=e*Math.sin(n),this.y=s,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),l=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=s,this.z=l,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*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,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,s=Math.sqrt(1-n*n);return this.x=s*Math.cos(e),this.y=n,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};ym.prototype.isVector3=!0;let se=ym;const ch=new se,Ev=new Cs,Sm=class Sm{constructor(e,n,s,l,c,d,p,m,h){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,s,l,c,d,p,m,h)}set(e,n,s,l,c,d,p,m,h){const v=this.elements;return v[0]=e,v[1]=l,v[2]=p,v[3]=n,v[4]=c,v[5]=m,v[6]=s,v[7]=d,v[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,s=e.elements;return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],this}extractBasis(e,n,s){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const s=e.elements,l=n.elements,c=this.elements,d=s[0],p=s[3],m=s[6],h=s[1],v=s[4],S=s[7],_=s[2],M=s[5],E=s[8],C=l[0],y=l[3],x=l[6],P=l[1],O=l[4],R=l[7],I=l[2],B=l[5],L=l[8];return c[0]=d*C+p*P+m*I,c[3]=d*y+p*O+m*B,c[6]=d*x+p*R+m*L,c[1]=h*C+v*P+S*I,c[4]=h*y+v*O+S*B,c[7]=h*x+v*R+S*L,c[2]=_*C+M*P+E*I,c[5]=_*y+M*O+E*B,c[8]=_*x+M*R+E*L,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],s=e[1],l=e[2],c=e[3],d=e[4],p=e[5],m=e[6],h=e[7],v=e[8];return n*d*v-n*p*h-s*c*v+s*p*m+l*c*h-l*d*m}invert(){const e=this.elements,n=e[0],s=e[1],l=e[2],c=e[3],d=e[4],p=e[5],m=e[6],h=e[7],v=e[8],S=v*d-p*h,_=p*m-v*c,M=h*c-d*m,E=n*S+s*_+l*M;if(E===0)return this.set(0,0,0,0,0,0,0,0,0);const C=1/E;return e[0]=S*C,e[1]=(l*h-v*s)*C,e[2]=(p*s-l*d)*C,e[3]=_*C,e[4]=(v*n-l*m)*C,e[5]=(l*c-p*n)*C,e[6]=M*C,e[7]=(s*m-h*n)*C,e[8]=(d*n-s*c)*C,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,s,l,c,d,p){const m=Math.cos(c),h=Math.sin(c);return this.set(s*m,s*h,-s*(m*d+h*p)+d+e,-l*h,l*m,-l*(-h*d+m*p)+p+n,0,0,1),this}scale(e,n){return ho("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(uh.makeScale(e,n)),this}rotate(e){return ho("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(uh.makeRotation(-e)),this}translate(e,n){return ho("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(uh.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),s=Math.sin(e);return this.set(n,-s,0,s,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,s=e.elements;for(let l=0;l<9;l++)if(n[l]!==s[l])return!1;return!0}fromArray(e,n=0){for(let s=0;s<9;s++)this.elements[s]=e[s+n];return this}toArray(e=[],n=0){const s=this.elements;return e[n]=s[0],e[n+1]=s[1],e[n+2]=s[2],e[n+3]=s[3],e[n+4]=s[4],e[n+5]=s[5],e[n+6]=s[6],e[n+7]=s[7],e[n+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Sm.prototype.isMatrix3=!0;let St=Sm;const uh=new St,Tv=new St().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Av=new St().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function OE(){const a={enabled:!0,workingColorSpace:Lu,spaces:{},convert:function(l,c,d){return this.enabled===!1||c===d||!c||!d||(this.spaces[c].transfer===tn&&(l.r=ka(l.r),l.g=ka(l.g),l.b=ka(l.b)),this.spaces[c].primaries!==this.spaces[d].primaries&&(l.applyMatrix3(this.spaces[c].toXYZ),l.applyMatrix3(this.spaces[d].fromXYZ)),this.spaces[d].transfer===tn&&(l.r=po(l.r),l.g=po(l.g),l.b=po(l.b))),l},workingToColorSpace:function(l,c){return this.convert(l,this.workingColorSpace,c)},colorSpaceToWorking:function(l,c){return this.convert(l,c,this.workingColorSpace)},getPrimaries:function(l){return this.spaces[l].primaries},getTransfer:function(l){return l===Ms?Ou:this.spaces[l].transfer},getToneMappingMode:function(l){return this.spaces[l].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(l,c=this.workingColorSpace){return l.fromArray(this.spaces[c].luminanceCoefficients)},define:function(l){Object.assign(this.spaces,l)},_getMatrix:function(l,c,d){return l.copy(this.spaces[c].toXYZ).multiply(this.spaces[d].fromXYZ)},_getDrawingBufferColorSpace:function(l){return this.spaces[l].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(l=this.workingColorSpace){return this.spaces[l].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(l,c){return ho("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(l,c)},toWorkingColorSpace:function(l,c){return ho("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(l,c)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],s=[.3127,.329];return a.define({[Lu]:{primaries:e,whitePoint:s,transfer:Ou,toXYZ:Tv,fromXYZ:Av,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:vi},outputColorSpaceConfig:{drawingBufferColorSpace:vi}},[vi]:{primaries:e,whitePoint:s,transfer:tn,toXYZ:Tv,fromXYZ:Av,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:vi}}}),a}const zt=OE();function ka(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function po(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}let qr;class PE{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let s;if(e instanceof HTMLCanvasElement)s=e;else{qr===void 0&&(qr=Pu("canvas")),qr.width=e.width,qr.height=e.height;const l=qr.getContext("2d");e instanceof ImageData?l.putImageData(e,0,0):l.drawImage(e,0,0,e.width,e.height),s=qr}return s.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=Pu("canvas");n.width=e.width,n.height=e.height;const s=n.getContext("2d");s.drawImage(e,0,0,e.width,e.height);const l=s.getImageData(0,0,e.width,e.height),c=l.data;for(let d=0;d<c.length;d++)c[d]=ka(c[d]/255)*255;return s.putImageData(l,0,0),n}else if(e.data){const n=e.data.slice(0);for(let s=0;s<n.length;s++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[s]=Math.floor(ka(n[s]/255)*255):n[s]=ka(n[s]);return{data:n,width:e.width,height:e.height}}else return mt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let IE=0;class am{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:IE++}),this.uuid=Il(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):typeof VideoFrame<"u"&&n instanceof VideoFrame?e.set(n.displayWidth,n.displayHeight,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const s={uuid:this.uuid,url:""},l=this.data;if(l!==null){let c;if(Array.isArray(l)){c=[];for(let d=0,p=l.length;d<p;d++)l[d].isDataTexture?c.push(dh(l[d].image)):c.push(dh(l[d]))}else c=dh(l);s.url=c}return n||(e.images[this.uuid]=s),s}}function dh(a){return typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&a instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&a instanceof ImageBitmap?PE.getDataURL(a):a.data?{data:Array.from(a.data),width:a.width,height:a.height,type:a.data.constructor.name}:(mt("Texture: Unable to serialize Texture."),{})}let BE=0;const fh=new se;class Kn extends Rs{constructor(e=Kn.DEFAULT_IMAGE,n=Kn.DEFAULT_MAPPING,s=Ha,l=Ha,c=qn,d=er,p=qi,m=xi,h=Kn.DEFAULT_ANISOTROPY,v=Ms){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:BE++}),this.uuid=Il(),this.name="",this.source=new am(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=s,this.wrapT=l,this.magFilter=c,this.minFilter=d,this.anisotropy=h,this.format=p,this.internalFormat=null,this.type=m,this.offset=new bt(0,0),this.repeat=new bt(1,1),this.center=new bt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new St,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=v,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,this.normalized=!1}get width(){return this.source.getSize(fh).x}get height(){return this.source.getSize(fh).y}get depth(){return this.source.getSize(fh).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const s=e[n];if(s===void 0){mt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const l=this[n];if(l===void 0){mt(`Texture.setValues(): property '${n}' does not exist.`);continue}l&&s&&l.isVector2&&s.isVector2||l&&s&&l.isVector3&&s.isVector3||l&&s&&l.isMatrix3&&s.isMatrix3?l.copy(s):this[n]=s}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(s.userData=this.userData),n||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ry)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case tp:e.x=e.x-Math.floor(e.x);break;case Ha:e.x=e.x<0?0:1;break;case np: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 tp:e.y=e.y-Math.floor(e.y);break;case Ha:e.y=e.y<0?0:1;break;case np: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++}}Kn.DEFAULT_IMAGE=null;Kn.DEFAULT_MAPPING=ry;Kn.DEFAULT_ANISOTROPY=1;const bm=class bm{constructor(e=0,n=0,s=0,l=1){this.x=e,this.y=n,this.z=s,this.w=l}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,s,l){return this.x=e,this.y=n,this.z=s,this.w=l,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,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?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,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,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,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.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 n=this.x,s=this.y,l=this.z,c=this.w,d=e.elements;return this.x=d[0]*n+d[4]*s+d[8]*l+d[12]*c,this.y=d[1]*n+d[5]*s+d[9]*l+d[13]*c,this.z=d[2]*n+d[6]*s+d[10]*l+d[14]*c,this.w=d[3]*n+d[7]*s+d[11]*l+d[15]*c,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 n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,s,l,c;const m=e.elements,h=m[0],v=m[4],S=m[8],_=m[1],M=m[5],E=m[9],C=m[2],y=m[6],x=m[10];if(Math.abs(v-_)<.01&&Math.abs(S-C)<.01&&Math.abs(E-y)<.01){if(Math.abs(v+_)<.1&&Math.abs(S+C)<.1&&Math.abs(E+y)<.1&&Math.abs(h+M+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const O=(h+1)/2,R=(M+1)/2,I=(x+1)/2,B=(v+_)/4,L=(S+C)/4,T=(E+y)/4;return O>R&&O>I?O<.01?(s=0,l=.707106781,c=.707106781):(s=Math.sqrt(O),l=B/s,c=L/s):R>I?R<.01?(s=.707106781,l=0,c=.707106781):(l=Math.sqrt(R),s=B/l,c=T/l):I<.01?(s=.707106781,l=.707106781,c=0):(c=Math.sqrt(I),s=L/c,l=T/c),this.set(s,l,c,n),this}let P=Math.sqrt((y-E)*(y-E)+(S-C)*(S-C)+(_-v)*(_-v));return Math.abs(P)<.001&&(P=1),this.x=(y-E)/P,this.y=(S-C)/P,this.z=(_-v)/P,this.w=Math.acos((h+M+x-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[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,n){return this.x=Lt(this.x,e.x,n.x),this.y=Lt(this.y,e.y,n.y),this.z=Lt(this.z,e.z,n.z),this.w=Lt(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Lt(this.x,e,n),this.y=Lt(this.y,e,n),this.z=Lt(this.z,e,n),this.w=Lt(this.w,e,n),this}clampLength(e,n){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Lt(s,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,s){return this.x=e.x+(n.x-e.x)*s,this.y=e.y+(n.y-e.y)*s,this.z=e.z+(n.z-e.z)*s,this.w=e.w+(n.w-e.w)*s,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),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}};bm.prototype.isVector4=!0;let pn=bm;class FE extends Rs{constructor(e=1,n=1,s={}){super(),s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},s),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=s.depth,this.scissor=new pn(0,0,e,n),this.scissorTest=!1,this.viewport=new pn(0,0,e,n),this.textures=[];const l={width:e,height:n,depth:s.depth},c=new Kn(l),d=s.count;for(let p=0;p<d;p++)this.textures[p]=c.clone(),this.textures[p].isRenderTargetTexture=!0,this.textures[p].renderTarget=this;this._setTextureOptions(s),this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=s.depthTexture,this.samples=s.samples,this.multiview=s.multiview,this.useArrayDepthTexture=s.useArrayDepthTexture}_setTextureOptions(e={}){const n={minFilter:qn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let s=0;s<this.textures.length;s++)this.textures[s].setValues(n)}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,n,s=1){if(this.width!==e||this.height!==n||this.depth!==s){this.width=e,this.height=n,this.depth=s;for(let l=0,c=this.textures.length;l<c;l++)this.textures[l].image.width=e,this.textures[l].image.height=n,this.textures[l].image.depth=s,this.textures[l].isData3DTexture!==!0&&(this.textures[l].isArrayTexture=this.textures[l].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,s=e.textures.length;n<s;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const l=Object.assign({},e.textures[n].image);this.textures[n].source=new am(l)}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.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class fa extends FE{constructor(e=1,n=1,s={}){super(e,n,s),this.isWebGLRenderTarget=!0}}class py extends Kn{constructor(e=null,n=1,s=1,l=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:s,depth:l},this.magFilter=Gn,this.minFilter=Gn,this.wrapR=Ha,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class zE extends Kn{constructor(e=null,n=1,s=1,l=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:s,depth:l},this.magFilter=Gn,this.minFilter=Gn,this.wrapR=Ha,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const zu=class zu{constructor(e,n,s,l,c,d,p,m,h,v,S,_,M,E,C,y){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,s,l,c,d,p,m,h,v,S,_,M,E,C,y)}set(e,n,s,l,c,d,p,m,h,v,S,_,M,E,C,y){const x=this.elements;return x[0]=e,x[4]=n,x[8]=s,x[12]=l,x[1]=c,x[5]=d,x[9]=p,x[13]=m,x[2]=h,x[6]=v,x[10]=S,x[14]=_,x[3]=M,x[7]=E,x[11]=C,x[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new zu().fromArray(this.elements)}copy(e){const n=this.elements,s=e.elements;return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],n[9]=s[9],n[10]=s[10],n[11]=s[11],n[12]=s[12],n[13]=s[13],n[14]=s[14],n[15]=s[15],this}copyPosition(e){const n=this.elements,s=e.elements;return n[12]=s[12],n[13]=s[13],n[14]=s[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,s){return this.determinantAffine()===0?(e.set(1,0,0),n.set(0,1,0),s.set(0,0,1),this):(e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this)}makeBasis(e,n,s){return this.set(e.x,n.x,s.x,0,e.y,n.y,s.y,0,e.z,n.z,s.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const n=this.elements,s=e.elements,l=1/Yr.setFromMatrixColumn(e,0).length(),c=1/Yr.setFromMatrixColumn(e,1).length(),d=1/Yr.setFromMatrixColumn(e,2).length();return n[0]=s[0]*l,n[1]=s[1]*l,n[2]=s[2]*l,n[3]=0,n[4]=s[4]*c,n[5]=s[5]*c,n[6]=s[6]*c,n[7]=0,n[8]=s[8]*d,n[9]=s[9]*d,n[10]=s[10]*d,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,s=e.x,l=e.y,c=e.z,d=Math.cos(s),p=Math.sin(s),m=Math.cos(l),h=Math.sin(l),v=Math.cos(c),S=Math.sin(c);if(e.order==="XYZ"){const _=d*v,M=d*S,E=p*v,C=p*S;n[0]=m*v,n[4]=-m*S,n[8]=h,n[1]=M+E*h,n[5]=_-C*h,n[9]=-p*m,n[2]=C-_*h,n[6]=E+M*h,n[10]=d*m}else if(e.order==="YXZ"){const _=m*v,M=m*S,E=h*v,C=h*S;n[0]=_+C*p,n[4]=E*p-M,n[8]=d*h,n[1]=d*S,n[5]=d*v,n[9]=-p,n[2]=M*p-E,n[6]=C+_*p,n[10]=d*m}else if(e.order==="ZXY"){const _=m*v,M=m*S,E=h*v,C=h*S;n[0]=_-C*p,n[4]=-d*S,n[8]=E+M*p,n[1]=M+E*p,n[5]=d*v,n[9]=C-_*p,n[2]=-d*h,n[6]=p,n[10]=d*m}else if(e.order==="ZYX"){const _=d*v,M=d*S,E=p*v,C=p*S;n[0]=m*v,n[4]=E*h-M,n[8]=_*h+C,n[1]=m*S,n[5]=C*h+_,n[9]=M*h-E,n[2]=-h,n[6]=p*m,n[10]=d*m}else if(e.order==="YZX"){const _=d*m,M=d*h,E=p*m,C=p*h;n[0]=m*v,n[4]=C-_*S,n[8]=E*S+M,n[1]=S,n[5]=d*v,n[9]=-p*v,n[2]=-h*v,n[6]=M*S+E,n[10]=_-C*S}else if(e.order==="XZY"){const _=d*m,M=d*h,E=p*m,C=p*h;n[0]=m*v,n[4]=-S,n[8]=h*v,n[1]=_*S+C,n[5]=d*v,n[9]=M*S-E,n[2]=E*S-M,n[6]=p*v,n[10]=C*S+_}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(HE,e,GE)}lookAt(e,n,s){const l=this.elements;return gi.subVectors(e,n),gi.lengthSq()===0&&(gi.z=1),gi.normalize(),gs.crossVectors(s,gi),gs.lengthSq()===0&&(Math.abs(s.z)===1?gi.x+=1e-4:gi.z+=1e-4,gi.normalize(),gs.crossVectors(s,gi)),gs.normalize(),qc.crossVectors(gi,gs),l[0]=gs.x,l[4]=qc.x,l[8]=gi.x,l[1]=gs.y,l[5]=qc.y,l[9]=gi.y,l[2]=gs.z,l[6]=qc.z,l[10]=gi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const s=e.elements,l=n.elements,c=this.elements,d=s[0],p=s[4],m=s[8],h=s[12],v=s[1],S=s[5],_=s[9],M=s[13],E=s[2],C=s[6],y=s[10],x=s[14],P=s[3],O=s[7],R=s[11],I=s[15],B=l[0],L=l[4],T=l[8],U=l[12],X=l[1],G=l[5],K=l[9],ue=l[13],pe=l[2],Q=l[6],V=l[10],j=l[14],ae=l[3],_e=l[7],ve=l[11],H=l[15];return c[0]=d*B+p*X+m*pe+h*ae,c[4]=d*L+p*G+m*Q+h*_e,c[8]=d*T+p*K+m*V+h*ve,c[12]=d*U+p*ue+m*j+h*H,c[1]=v*B+S*X+_*pe+M*ae,c[5]=v*L+S*G+_*Q+M*_e,c[9]=v*T+S*K+_*V+M*ve,c[13]=v*U+S*ue+_*j+M*H,c[2]=E*B+C*X+y*pe+x*ae,c[6]=E*L+C*G+y*Q+x*_e,c[10]=E*T+C*K+y*V+x*ve,c[14]=E*U+C*ue+y*j+x*H,c[3]=P*B+O*X+R*pe+I*ae,c[7]=P*L+O*G+R*Q+I*_e,c[11]=P*T+O*K+R*V+I*ve,c[15]=P*U+O*ue+R*j+I*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],s=e[4],l=e[8],c=e[12],d=e[1],p=e[5],m=e[9],h=e[13],v=e[2],S=e[6],_=e[10],M=e[14],E=e[3],C=e[7],y=e[11],x=e[15],P=m*M-h*_,O=p*M-h*S,R=p*_-m*S,I=d*M-h*v,B=d*_-m*v,L=d*S-p*v;return n*(C*P-y*O+x*R)-s*(E*P-y*I+x*B)+l*(E*O-C*I+x*L)-c*(E*R-C*B+y*L)}determinantAffine(){const e=this.elements,n=e[0],s=e[4],l=e[8],c=e[1],d=e[5],p=e[9],m=e[2],h=e[6],v=e[10];return n*(d*v-p*h)-s*(c*v-p*m)+l*(c*h-d*m)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,s){const l=this.elements;return e.isVector3?(l[12]=e.x,l[13]=e.y,l[14]=e.z):(l[12]=e,l[13]=n,l[14]=s),this}invert(){const e=this.elements,n=e[0],s=e[1],l=e[2],c=e[3],d=e[4],p=e[5],m=e[6],h=e[7],v=e[8],S=e[9],_=e[10],M=e[11],E=e[12],C=e[13],y=e[14],x=e[15],P=n*p-s*d,O=n*m-l*d,R=n*h-c*d,I=s*m-l*p,B=s*h-c*p,L=l*h-c*m,T=v*C-S*E,U=v*y-_*E,X=v*x-M*E,G=S*y-_*C,K=S*x-M*C,ue=_*x-M*y,pe=P*ue-O*K+R*G+I*X-B*U+L*T;if(pe===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const Q=1/pe;return e[0]=(p*ue-m*K+h*G)*Q,e[1]=(l*K-s*ue-c*G)*Q,e[2]=(C*L-y*B+x*I)*Q,e[3]=(_*B-S*L-M*I)*Q,e[4]=(m*X-d*ue-h*U)*Q,e[5]=(n*ue-l*X+c*U)*Q,e[6]=(y*R-E*L-x*O)*Q,e[7]=(v*L-_*R+M*O)*Q,e[8]=(d*K-p*X+h*T)*Q,e[9]=(s*X-n*K-c*T)*Q,e[10]=(E*B-C*R+x*P)*Q,e[11]=(S*R-v*B-M*P)*Q,e[12]=(p*U-d*G-m*T)*Q,e[13]=(n*G-s*U+l*T)*Q,e[14]=(C*O-E*I-y*P)*Q,e[15]=(v*I-S*O+_*P)*Q,this}scale(e){const n=this.elements,s=e.x,l=e.y,c=e.z;return n[0]*=s,n[4]*=l,n[8]*=c,n[1]*=s,n[5]*=l,n[9]*=c,n[2]*=s,n[6]*=l,n[10]*=c,n[3]*=s,n[7]*=l,n[11]*=c,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],l=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,s,l))}makeTranslation(e,n,s){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,n,0,0,1,s,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,n,-s,0,0,s,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),s=Math.sin(e);return this.set(n,0,s,0,0,1,0,0,-s,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),s=Math.sin(e);return this.set(n,-s,0,0,s,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const s=Math.cos(n),l=Math.sin(n),c=1-s,d=e.x,p=e.y,m=e.z,h=c*d,v=c*p;return this.set(h*d+s,h*p-l*m,h*m+l*p,0,h*p+l*m,v*p+s,v*m-l*d,0,h*m-l*p,v*m+l*d,c*m*m+s,0,0,0,0,1),this}makeScale(e,n,s){return this.set(e,0,0,0,0,n,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,n,s,l,c,d){return this.set(1,s,c,0,e,1,d,0,n,l,1,0,0,0,0,1),this}compose(e,n,s){const l=this.elements,c=n._x,d=n._y,p=n._z,m=n._w,h=c+c,v=d+d,S=p+p,_=c*h,M=c*v,E=c*S,C=d*v,y=d*S,x=p*S,P=m*h,O=m*v,R=m*S,I=s.x,B=s.y,L=s.z;return l[0]=(1-(C+x))*I,l[1]=(M+R)*I,l[2]=(E-O)*I,l[3]=0,l[4]=(M-R)*B,l[5]=(1-(_+x))*B,l[6]=(y+P)*B,l[7]=0,l[8]=(E+O)*L,l[9]=(y-P)*L,l[10]=(1-(_+C))*L,l[11]=0,l[12]=e.x,l[13]=e.y,l[14]=e.z,l[15]=1,this}decompose(e,n,s){const l=this.elements;e.x=l[12],e.y=l[13],e.z=l[14];const c=this.determinantAffine();if(c===0)return s.set(1,1,1),n.identity(),this;let d=Yr.set(l[0],l[1],l[2]).length();const p=Yr.set(l[4],l[5],l[6]).length(),m=Yr.set(l[8],l[9],l[10]).length();c<0&&(d=-d),Vi.copy(this);const h=1/d,v=1/p,S=1/m;return Vi.elements[0]*=h,Vi.elements[1]*=h,Vi.elements[2]*=h,Vi.elements[4]*=v,Vi.elements[5]*=v,Vi.elements[6]*=v,Vi.elements[8]*=S,Vi.elements[9]*=S,Vi.elements[10]*=S,n.setFromRotationMatrix(Vi),s.x=d,s.y=p,s.z=m,this}makePerspective(e,n,s,l,c,d,p=ua,m=!1){const h=this.elements,v=2*c/(n-e),S=2*c/(s-l),_=(n+e)/(n-e),M=(s+l)/(s-l);let E,C;if(m)E=c/(d-c),C=d*c/(d-c);else if(p===ua)E=-(d+c)/(d-c),C=-2*d*c/(d-c);else if(p===Ul)E=-d/(d-c),C=-d*c/(d-c);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+p);return h[0]=v,h[4]=0,h[8]=_,h[12]=0,h[1]=0,h[5]=S,h[9]=M,h[13]=0,h[2]=0,h[6]=0,h[10]=E,h[14]=C,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,n,s,l,c,d,p=ua,m=!1){const h=this.elements,v=2/(n-e),S=2/(s-l),_=-(n+e)/(n-e),M=-(s+l)/(s-l);let E,C;if(m)E=1/(d-c),C=d/(d-c);else if(p===ua)E=-2/(d-c),C=-(d+c)/(d-c);else if(p===Ul)E=-1/(d-c),C=-c/(d-c);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+p);return h[0]=v,h[4]=0,h[8]=0,h[12]=_,h[1]=0,h[5]=S,h[9]=0,h[13]=M,h[2]=0,h[6]=0,h[10]=E,h[14]=C,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const n=this.elements,s=e.elements;for(let l=0;l<16;l++)if(n[l]!==s[l])return!1;return!0}fromArray(e,n=0){for(let s=0;s<16;s++)this.elements[s]=e[s+n];return this}toArray(e=[],n=0){const s=this.elements;return e[n]=s[0],e[n+1]=s[1],e[n+2]=s[2],e[n+3]=s[3],e[n+4]=s[4],e[n+5]=s[5],e[n+6]=s[6],e[n+7]=s[7],e[n+8]=s[8],e[n+9]=s[9],e[n+10]=s[10],e[n+11]=s[11],e[n+12]=s[12],e[n+13]=s[13],e[n+14]=s[14],e[n+15]=s[15],e}};zu.prototype.isMatrix4=!0;let cn=zu;const Yr=new se,Vi=new cn,HE=new se(0,0,0),GE=new se(1,1,1),gs=new se,qc=new se,gi=new se,Cv=new cn,wv=new Cs;class or{constructor(e=0,n=0,s=0,l=or.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=s,this._order=l}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,n,s,l=this._order){return this._x=e,this._y=n,this._z=s,this._order=l,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,n=this._order,s=!0){const l=e.elements,c=l[0],d=l[4],p=l[8],m=l[1],h=l[5],v=l[9],S=l[2],_=l[6],M=l[10];switch(n){case"XYZ":this._y=Math.asin(Lt(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(-v,M),this._z=Math.atan2(-d,c)):(this._x=Math.atan2(_,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Lt(v,-1,1)),Math.abs(v)<.9999999?(this._y=Math.atan2(p,M),this._z=Math.atan2(m,h)):(this._y=Math.atan2(-S,c),this._z=0);break;case"ZXY":this._x=Math.asin(Lt(_,-1,1)),Math.abs(_)<.9999999?(this._y=Math.atan2(-S,M),this._z=Math.atan2(-d,h)):(this._y=0,this._z=Math.atan2(m,c));break;case"ZYX":this._y=Math.asin(-Lt(S,-1,1)),Math.abs(S)<.9999999?(this._x=Math.atan2(_,M),this._z=Math.atan2(m,c)):(this._x=0,this._z=Math.atan2(-d,h));break;case"YZX":this._z=Math.asin(Lt(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(-v,h),this._y=Math.atan2(-S,c)):(this._x=0,this._y=Math.atan2(p,M));break;case"XZY":this._z=Math.asin(-Lt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(_,h),this._y=Math.atan2(p,c)):(this._x=Math.atan2(-v,M),this._y=0);break;default:mt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,s){return Cv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Cv,n,s)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return wv.setFromEuler(this),this.setFromQuaternion(wv,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=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+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}}or.DEFAULT_ORDER="XYZ";class my{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 VE=0;const Rv=new se,Zr=new Cs,La=new cn,Yc=new se,pl=new se,kE=new se,jE=new Cs,Dv=new se(1,0,0),Nv=new se(0,1,0),Uv=new se(0,0,1),Lv={type:"added"},XE={type:"removed"},Kr={type:"childadded",child:null},hh={type:"childremoved",child:null};class Dn extends Rs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:VE++}),this.uuid=Il(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Dn.DEFAULT_UP.clone();const e=new se,n=new or,s=new Cs,l=new se(1,1,1);function c(){s.setFromEuler(n,!1)}function d(){n.setFromQuaternion(s,void 0,!1)}n._onChange(c),s._onChange(d),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:l},modelViewMatrix:{value:new cn},normalMatrix:{value:new St}}),this.matrix=new cn,this.matrixWorld=new cn,this.matrixAutoUpdate=Dn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Dn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new my,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.static=!1,this.userData={},this.pivot=null}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,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return Zr.setFromAxisAngle(e,n),this.quaternion.multiply(Zr),this}rotateOnWorldAxis(e,n){return Zr.setFromAxisAngle(e,n),this.quaternion.premultiply(Zr),this}rotateX(e){return this.rotateOnAxis(Dv,e)}rotateY(e){return this.rotateOnAxis(Nv,e)}rotateZ(e){return this.rotateOnAxis(Uv,e)}translateOnAxis(e,n){return Rv.copy(e).applyQuaternion(this.quaternion),this.position.add(Rv.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(Dv,e)}translateY(e){return this.translateOnAxis(Nv,e)}translateZ(e){return this.translateOnAxis(Uv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(La.copy(this.matrixWorld).invert())}lookAt(e,n,s){e.isVector3?Yc.copy(e):Yc.set(e,n,s);const l=this.parent;this.updateWorldMatrix(!0,!1),pl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?La.lookAt(pl,Yc,this.up):La.lookAt(Yc,pl,this.up),this.quaternion.setFromRotationMatrix(La),l&&(La.extractRotation(l.matrixWorld),Zr.setFromRotationMatrix(La),this.quaternion.premultiply(Zr.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(kt("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(Lv),Kr.child=e,this.dispatchEvent(Kr),Kr.child=null):kt("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(XE),hh.child=e,this.dispatchEvent(hh),hh.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),La.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),La.multiply(e.parent.matrixWorld)),e.applyMatrix4(La),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Lv),Kr.child=e,this.dispatchEvent(Kr),Kr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let s=0,l=this.children.length;s<l;s++){const d=this.children[s].getObjectByProperty(e,n);if(d!==void 0)return d}}getObjectsByProperty(e,n,s=[]){this[e]===n&&s.push(this);const l=this.children;for(let c=0,d=l.length;c<d;c++)l[c].getObjectsByProperty(e,n,s);return s}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(pl,e,kE),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(pl,jE,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let s=0,l=n.length;s<l;s++)n[s].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let s=0,l=n.length;s<l;s++)n[s].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const n=e.x,s=e.y,l=e.z,c=this.matrix.elements;c[12]+=n-c[0]*n-c[4]*s-c[8]*l,c[13]+=s-c[1]*n-c[5]*s-c[9]*l,c[14]+=l-c[2]*n-c[6]*s-c[10]*l}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 n=this.children;for(let s=0,l=n.length;s<l;s++)n[s].updateMatrixWorld(e)}updateWorldMatrix(e,n,s=!1){const l=this.parent;if(e===!0&&l!==null&&l.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||s)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,s=!0),n===!0){const c=this.children;for(let d=0,p=c.length;d<p;d++)c[d].updateWorldMatrix(!1,!0,s)}}toJSON(e){const n=e===void 0||typeof e=="string",s={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const l={};l.uuid=this.uuid,l.type=this.type,this.name!==""&&(l.name=this.name),this.castShadow===!0&&(l.castShadow=!0),this.receiveShadow===!0&&(l.receiveShadow=!0),this.visible===!1&&(l.visible=!1),this.frustumCulled===!1&&(l.frustumCulled=!1),this.renderOrder!==0&&(l.renderOrder=this.renderOrder),this.static!==!1&&(l.static=this.static),Object.keys(this.userData).length>0&&(l.userData=this.userData),l.layers=this.layers.mask,l.matrix=this.matrix.toArray(),l.up=this.up.toArray(),this.pivot!==null&&(l.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(l.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(l.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(l.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(l.type="InstancedMesh",l.count=this.count,l.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(l.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(l.type="BatchedMesh",l.perObjectFrustumCulled=this.perObjectFrustumCulled,l.sortObjects=this.sortObjects,l.drawRanges=this._drawRanges,l.reservedRanges=this._reservedRanges,l.geometryInfo=this._geometryInfo.map(p=>({...p,boundingBox:p.boundingBox?p.boundingBox.toJSON():void 0,boundingSphere:p.boundingSphere?p.boundingSphere.toJSON():void 0})),l.instanceInfo=this._instanceInfo.map(p=>({...p})),l.availableInstanceIds=this._availableInstanceIds.slice(),l.availableGeometryIds=this._availableGeometryIds.slice(),l.nextIndexStart=this._nextIndexStart,l.nextVertexStart=this._nextVertexStart,l.geometryCount=this._geometryCount,l.maxInstanceCount=this._maxInstanceCount,l.maxVertexCount=this._maxVertexCount,l.maxIndexCount=this._maxIndexCount,l.geometryInitialized=this._geometryInitialized,l.matricesTexture=this._matricesTexture.toJSON(e),l.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(l.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(l.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(l.boundingBox=this.boundingBox.toJSON()));function c(p,m){return p[m.uuid]===void 0&&(p[m.uuid]=m.toJSON(e)),m.uuid}if(this.isScene)this.background&&(this.background.isColor?l.background=this.background.toJSON():this.background.isTexture&&(l.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(l.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){l.geometry=c(e.geometries,this.geometry);const p=this.geometry.parameters;if(p!==void 0&&p.shapes!==void 0){const m=p.shapes;if(Array.isArray(m))for(let h=0,v=m.length;h<v;h++){const S=m[h];c(e.shapes,S)}else c(e.shapes,m)}}if(this.isSkinnedMesh&&(l.bindMode=this.bindMode,l.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(c(e.skeletons,this.skeleton),l.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const p=[];for(let m=0,h=this.material.length;m<h;m++)p.push(c(e.materials,this.material[m]));l.material=p}else l.material=c(e.materials,this.material);if(this.children.length>0){l.children=[];for(let p=0;p<this.children.length;p++)l.children.push(this.children[p].toJSON(e).object)}if(this.animations.length>0){l.animations=[];for(let p=0;p<this.animations.length;p++){const m=this.animations[p];l.animations.push(c(e.animations,m))}}if(n){const p=d(e.geometries),m=d(e.materials),h=d(e.textures),v=d(e.images),S=d(e.shapes),_=d(e.skeletons),M=d(e.animations),E=d(e.nodes);p.length>0&&(s.geometries=p),m.length>0&&(s.materials=m),h.length>0&&(s.textures=h),v.length>0&&(s.images=v),S.length>0&&(s.shapes=S),_.length>0&&(s.skeletons=_),M.length>0&&(s.animations=M),E.length>0&&(s.nodes=E)}return s.object=l,s;function d(p){const m=[];for(const h in p){const v=p[h];delete v.metadata,m.push(v)}return m}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let s=0;s<e.children.length;s++){const l=e.children[s];this.add(l.clone())}return this}}Dn.DEFAULT_UP=new se(0,1,0);Dn.DEFAULT_MATRIX_AUTO_UPDATE=!0;Dn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Zc extends Dn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const WE={type:"move"};class ph{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Zc,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 Zc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new se,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new se),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Zc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new se,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new se,this._grip.eventsEnabled=!1),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 n=this._hand;if(n)for(const s of e.hand.values())this._getHandJoint(n,s)}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,n,s){let l=null,c=null,d=null;const p=this._targetRay,m=this._grip,h=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(h&&e.hand){d=!0;for(const C of e.hand.values()){const y=n.getJointPose(C,s),x=this._getHandJoint(h,C);y!==null&&(x.matrix.fromArray(y.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=y.radius),x.visible=y!==null}const v=h.joints["index-finger-tip"],S=h.joints["thumb-tip"],_=v.position.distanceTo(S.position),M=.02,E=.005;h.inputState.pinching&&_>M+E?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&_<=M-E&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else m!==null&&e.gripSpace&&(c=n.getPose(e.gripSpace,s),c!==null&&(m.matrix.fromArray(c.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,c.linearVelocity?(m.hasLinearVelocity=!0,m.linearVelocity.copy(c.linearVelocity)):m.hasLinearVelocity=!1,c.angularVelocity?(m.hasAngularVelocity=!0,m.angularVelocity.copy(c.angularVelocity)):m.hasAngularVelocity=!1,m.eventsEnabled&&m.dispatchEvent({type:"gripUpdated",data:e,target:this})));p!==null&&(l=n.getPose(e.targetRaySpace,s),l===null&&c!==null&&(l=c),l!==null&&(p.matrix.fromArray(l.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,l.linearVelocity?(p.hasLinearVelocity=!0,p.linearVelocity.copy(l.linearVelocity)):p.hasLinearVelocity=!1,l.angularVelocity?(p.hasAngularVelocity=!0,p.angularVelocity.copy(l.angularVelocity)):p.hasAngularVelocity=!1,this.dispatchEvent(WE)))}return p!==null&&(p.visible=l!==null),m!==null&&(m.visible=c!==null),h!==null&&(h.visible=d!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const s=new Zc;s.matrixAutoUpdate=!1,s.visible=!1,e.joints[n.jointName]=s,e.add(s)}return e.joints[n.jointName]}}const gy={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},_s={h:0,s:0,l:0},Kc={h:0,s:0,l:0};function mh(a,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?a+(e-a)*6*n:n<1/2?e:n<2/3?a+(e-a)*6*(2/3-n):a}class ct{constructor(e,n,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,s)}set(e,n,s){if(n===void 0&&s===void 0){const l=e;l&&l.isColor?this.copy(l):typeof l=="number"?this.setHex(l):typeof l=="string"&&this.setStyle(l)}else this.setRGB(e,n,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=vi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,zt.colorSpaceToWorking(this,n),this}setRGB(e,n,s,l=zt.workingColorSpace){return this.r=e,this.g=n,this.b=s,zt.colorSpaceToWorking(this,l),this}setHSL(e,n,s,l=zt.workingColorSpace){if(e=UE(e,1),n=Lt(n,0,1),s=Lt(s,0,1),n===0)this.r=this.g=this.b=s;else{const c=s<=.5?s*(1+n):s+n-s*n,d=2*s-c;this.r=mh(d,c,e+1/3),this.g=mh(d,c,e),this.b=mh(d,c,e-1/3)}return zt.colorSpaceToWorking(this,l),this}setStyle(e,n=vi){function s(c){c!==void 0&&parseFloat(c)<1&&mt("Color: Alpha component of "+e+" will be ignored.")}let l;if(l=/^(\w+)\(([^\)]*)\)/.exec(e)){let c;const d=l[1],p=l[2];switch(d){case"rgb":case"rgba":if(c=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(p))return s(c[4]),this.setRGB(Math.min(255,parseInt(c[1],10))/255,Math.min(255,parseInt(c[2],10))/255,Math.min(255,parseInt(c[3],10))/255,n);if(c=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(p))return s(c[4]),this.setRGB(Math.min(100,parseInt(c[1],10))/100,Math.min(100,parseInt(c[2],10))/100,Math.min(100,parseInt(c[3],10))/100,n);break;case"hsl":case"hsla":if(c=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(p))return s(c[4]),this.setHSL(parseFloat(c[1])/360,parseFloat(c[2])/100,parseFloat(c[3])/100,n);break;default:mt("Color: Unknown color model "+e)}}else if(l=/^\#([A-Fa-f\d]+)$/.exec(e)){const c=l[1],d=c.length;if(d===3)return this.setRGB(parseInt(c.charAt(0),16)/15,parseInt(c.charAt(1),16)/15,parseInt(c.charAt(2),16)/15,n);if(d===6)return this.setHex(parseInt(c,16),n);mt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=vi){const s=gy[e.toLowerCase()];return s!==void 0?this.setHex(s,n):mt("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=ka(e.r),this.g=ka(e.g),this.b=ka(e.b),this}copyLinearToSRGB(e){return this.r=po(e.r),this.g=po(e.g),this.b=po(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=vi){return zt.workingToColorSpace(Wn.copy(this),e),Math.round(Lt(Wn.r*255,0,255))*65536+Math.round(Lt(Wn.g*255,0,255))*256+Math.round(Lt(Wn.b*255,0,255))}getHexString(e=vi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=zt.workingColorSpace){zt.workingToColorSpace(Wn.copy(this),n);const s=Wn.r,l=Wn.g,c=Wn.b,d=Math.max(s,l,c),p=Math.min(s,l,c);let m,h;const v=(p+d)/2;if(p===d)m=0,h=0;else{const S=d-p;switch(h=v<=.5?S/(d+p):S/(2-d-p),d){case s:m=(l-c)/S+(l<c?6:0);break;case l:m=(c-s)/S+2;break;case c:m=(s-l)/S+4;break}m/=6}return e.h=m,e.s=h,e.l=v,e}getRGB(e,n=zt.workingColorSpace){return zt.workingToColorSpace(Wn.copy(this),n),e.r=Wn.r,e.g=Wn.g,e.b=Wn.b,e}getStyle(e=vi){zt.workingToColorSpace(Wn.copy(this),e);const n=Wn.r,s=Wn.g,l=Wn.b;return e!==vi?`color(${e} ${n.toFixed(3)} ${s.toFixed(3)} ${l.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(s*255)},${Math.round(l*255)})`}offsetHSL(e,n,s){return this.getHSL(_s),this.setHSL(_s.h+e,_s.s+n,_s.l+s)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.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,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,s){return this.r=e.r+(n.r-e.r)*s,this.g=e.g+(n.g-e.g)*s,this.b=e.b+(n.b-e.b)*s,this}lerpHSL(e,n){this.getHSL(_s),e.getHSL(Kc);const s=lh(_s.h,Kc.h,n),l=lh(_s.s,Kc.s,n),c=lh(_s.l,Kc.l,n);return this.setHSL(s,l,c),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,s=this.g,l=this.b,c=e.elements;return this.r=c[0]*n+c[3]*s+c[6]*l,this.g=c[1]*n+c[4]*s+c[7]*l,this.b=c[2]*n+c[5]*s+c[8]*l,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Wn=new ct;ct.NAMES=gy;class qE extends Dn{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 or,this.environmentIntensity=1,this.environmentRotation=new or,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),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 n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}}const ki=new se,Oa=new se,gh=new se,Pa=new se,$r=new se,Qr=new se,Ov=new se,_h=new se,vh=new se,xh=new se,yh=new pn,Sh=new pn,bh=new pn;class Ui{constructor(e=new se,n=new se,s=new se){this.a=e,this.b=n,this.c=s}static getNormal(e,n,s,l){l.subVectors(s,n),ki.subVectors(e,n),l.cross(ki);const c=l.lengthSq();return c>0?l.multiplyScalar(1/Math.sqrt(c)):l.set(0,0,0)}static getBarycoord(e,n,s,l,c){ki.subVectors(l,n),Oa.subVectors(s,n),gh.subVectors(e,n);const d=ki.dot(ki),p=ki.dot(Oa),m=ki.dot(gh),h=Oa.dot(Oa),v=Oa.dot(gh),S=d*h-p*p;if(S===0)return c.set(0,0,0),null;const _=1/S,M=(h*m-p*v)*_,E=(d*v-p*m)*_;return c.set(1-M-E,E,M)}static containsPoint(e,n,s,l){return this.getBarycoord(e,n,s,l,Pa)===null?!1:Pa.x>=0&&Pa.y>=0&&Pa.x+Pa.y<=1}static getInterpolation(e,n,s,l,c,d,p,m){return this.getBarycoord(e,n,s,l,Pa)===null?(m.x=0,m.y=0,"z"in m&&(m.z=0),"w"in m&&(m.w=0),null):(m.setScalar(0),m.addScaledVector(c,Pa.x),m.addScaledVector(d,Pa.y),m.addScaledVector(p,Pa.z),m)}static getInterpolatedAttribute(e,n,s,l,c,d){return yh.setScalar(0),Sh.setScalar(0),bh.setScalar(0),yh.fromBufferAttribute(e,n),Sh.fromBufferAttribute(e,s),bh.fromBufferAttribute(e,l),d.setScalar(0),d.addScaledVector(yh,c.x),d.addScaledVector(Sh,c.y),d.addScaledVector(bh,c.z),d}static isFrontFacing(e,n,s,l){return ki.subVectors(s,n),Oa.subVectors(e,n),ki.cross(Oa).dot(l)<0}set(e,n,s){return this.a.copy(e),this.b.copy(n),this.c.copy(s),this}setFromPointsAndIndices(e,n,s,l){return this.a.copy(e[n]),this.b.copy(e[s]),this.c.copy(e[l]),this}setFromAttributeAndIndices(e,n,s,l){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,s),this.c.fromBufferAttribute(e,l),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 ki.subVectors(this.c,this.b),Oa.subVectors(this.a,this.b),ki.cross(Oa).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ui.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Ui.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,s,l,c){return Ui.getInterpolation(e,this.a,this.b,this.c,n,s,l,c)}containsPoint(e){return Ui.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ui.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const s=this.a,l=this.b,c=this.c;let d,p;$r.subVectors(l,s),Qr.subVectors(c,s),_h.subVectors(e,s);const m=$r.dot(_h),h=Qr.dot(_h);if(m<=0&&h<=0)return n.copy(s);vh.subVectors(e,l);const v=$r.dot(vh),S=Qr.dot(vh);if(v>=0&&S<=v)return n.copy(l);const _=m*S-v*h;if(_<=0&&m>=0&&v<=0)return d=m/(m-v),n.copy(s).addScaledVector($r,d);xh.subVectors(e,c);const M=$r.dot(xh),E=Qr.dot(xh);if(E>=0&&M<=E)return n.copy(c);const C=M*h-m*E;if(C<=0&&h>=0&&E<=0)return p=h/(h-E),n.copy(s).addScaledVector(Qr,p);const y=v*E-M*S;if(y<=0&&S-v>=0&&M-E>=0)return Ov.subVectors(c,l),p=(S-v)/(S-v+(M-E)),n.copy(l).addScaledVector(Ov,p);const x=1/(y+C+_);return d=C*x,p=_*x,n.copy(s).addScaledVector($r,d).addScaledVector(Qr,p)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class dr{constructor(e=new se(1/0,1/0,1/0),n=new se(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,s=e.length;n<s;n+=3)this.expandByPoint(ji.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,s=e.count;n<s;n++)this.expandByPoint(ji.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,s=e.length;n<s;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const s=ji.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}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,n=!1){e.updateWorldMatrix(!1,!1);const s=e.geometry;if(s!==void 0){const c=s.getAttribute("position");if(n===!0&&c!==void 0&&e.isInstancedMesh!==!0)for(let d=0,p=c.count;d<p;d++)e.isMesh===!0?e.getVertexPosition(d,ji):ji.fromBufferAttribute(c,d),ji.applyMatrix4(e.matrixWorld),this.expandByPoint(ji);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),$c.copy(e.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),$c.copy(s.boundingBox)),$c.applyMatrix4(e.matrixWorld),this.union($c)}const l=e.children;for(let c=0,d=l.length;c<d;c++)this.expandByObject(l[c],n);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,n){return n.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,ji),ji.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,s;return e.normal.x>0?(n=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),n<=-e.constant&&s>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ml),Qc.subVectors(this.max,ml),Jr.subVectors(e.a,ml),eo.subVectors(e.b,ml),to.subVectors(e.c,ml),vs.subVectors(eo,Jr),xs.subVectors(to,eo),Ys.subVectors(Jr,to);let n=[0,-vs.z,vs.y,0,-xs.z,xs.y,0,-Ys.z,Ys.y,vs.z,0,-vs.x,xs.z,0,-xs.x,Ys.z,0,-Ys.x,-vs.y,vs.x,0,-xs.y,xs.x,0,-Ys.y,Ys.x,0];return!Mh(n,Jr,eo,to,Qc)||(n=[1,0,0,0,1,0,0,0,1],!Mh(n,Jr,eo,to,Qc))?!1:(Jc.crossVectors(vs,xs),n=[Jc.x,Jc.y,Jc.z],Mh(n,Jr,eo,to,Qc))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ji).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ji).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:(Ia[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ia[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ia[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ia[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ia[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ia[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ia[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ia[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ia),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 Ia=[new se,new se,new se,new se,new se,new se,new se,new se],ji=new se,$c=new dr,Jr=new se,eo=new se,to=new se,vs=new se,xs=new se,Ys=new se,ml=new se,Qc=new se,Jc=new se,Zs=new se;function Mh(a,e,n,s,l){for(let c=0,d=a.length-3;c<=d;c+=3){Zs.fromArray(a,c);const p=l.x*Math.abs(Zs.x)+l.y*Math.abs(Zs.y)+l.z*Math.abs(Zs.z),m=e.dot(Zs),h=n.dot(Zs),v=s.dot(Zs);if(Math.max(-Math.max(m,h,v),Math.min(m,h,v))>p)return!1}return!0}const An=new se,eu=new bt;let YE=0;class Yi extends Rs{constructor(e,n,s=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:YE++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=s,this.usage=yv,this.updateRanges=[],this.gpuType=Wi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}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,n,s){e*=this.itemSize,s*=n.itemSize;for(let l=0,c=this.itemSize;l<c;l++)this.array[e+l]=n.array[s+l];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,s=this.count;n<s;n++)eu.fromBufferAttribute(this,n),eu.applyMatrix3(e),this.setXY(n,eu.x,eu.y);else if(this.itemSize===3)for(let n=0,s=this.count;n<s;n++)An.fromBufferAttribute(this,n),An.applyMatrix3(e),this.setXYZ(n,An.x,An.y,An.z);return this}applyMatrix4(e){for(let n=0,s=this.count;n<s;n++)An.fromBufferAttribute(this,n),An.applyMatrix4(e),this.setXYZ(n,An.x,An.y,An.z);return this}applyNormalMatrix(e){for(let n=0,s=this.count;n<s;n++)An.fromBufferAttribute(this,n),An.applyNormalMatrix(e),this.setXYZ(n,An.x,An.y,An.z);return this}transformDirection(e){for(let n=0,s=this.count;n<s;n++)An.fromBufferAttribute(this,n),An.transformDirection(e),this.setXYZ(n,An.x,An.y,An.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let s=this.array[e*this.itemSize+n];return this.normalized&&(s=hl(s,this.array)),s}setComponent(e,n,s){return this.normalized&&(s=ii(s,this.array)),this.array[e*this.itemSize+n]=s,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=hl(n,this.array)),n}setX(e,n){return this.normalized&&(n=ii(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=hl(n,this.array)),n}setY(e,n){return this.normalized&&(n=ii(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=hl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=ii(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=hl(n,this.array)),n}setW(e,n){return this.normalized&&(n=ii(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,s){return e*=this.itemSize,this.normalized&&(n=ii(n,this.array),s=ii(s,this.array)),this.array[e+0]=n,this.array[e+1]=s,this}setXYZ(e,n,s,l){return e*=this.itemSize,this.normalized&&(n=ii(n,this.array),s=ii(s,this.array),l=ii(l,this.array)),this.array[e+0]=n,this.array[e+1]=s,this.array[e+2]=l,this}setXYZW(e,n,s,l,c){return e*=this.itemSize,this.normalized&&(n=ii(n,this.array),s=ii(s,this.array),l=ii(l,this.array),c=ii(c,this.array)),this.array[e+0]=n,this.array[e+1]=s,this.array[e+2]=l,this.array[e+3]=c,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!==yv&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class _y extends Yi{constructor(e,n,s){super(new Uint16Array(e),n,s)}}class vy extends Yi{constructor(e,n,s){super(new Uint32Array(e),n,s)}}class ri extends Yi{constructor(e,n,s){super(new Float32Array(e),n,s)}}const ZE=new dr,gl=new se,Eh=new se;class bo{constructor(e=new se,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const s=this.center;n!==void 0?s.copy(n):ZE.setFromPoints(e).getCenter(s);let l=0;for(let c=0,d=e.length;c<d;c++)l=Math.max(l,s.distanceToSquared(e[c]));return this.radius=Math.sqrt(l),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 n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const s=this.center.distanceToSquared(e);return n.copy(e),s>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}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;gl.subVectors(e,this.center);const n=gl.lengthSq();if(n>this.radius*this.radius){const s=Math.sqrt(n),l=(s-this.radius)*.5;this.center.addScaledVector(gl,l/s),this.radius+=l}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):(Eh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(gl.copy(e.center).add(Eh)),this.expandByPoint(gl.copy(e.center).sub(Eh))),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}}let KE=0;const wi=new cn,Th=new Dn,no=new se,_i=new dr,_l=new dr,Pn=new se;class Li extends Rs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:KE++}),this.uuid=Il(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(wE(e)?vy:_y)(e,1):this.index=e,this}setIndirect(e,n=0){return this.indirect=e,this.indirectOffset=n,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,s=0){this.groups.push({start:e,count:n,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const c=new St().getNormalMatrix(e);s.applyNormalMatrix(c),s.needsUpdate=!0}const l=this.attributes.tangent;return l!==void 0&&(l.transformDirection(e),l.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return wi.makeRotationFromQuaternion(e),this.applyMatrix4(wi),this}rotateX(e){return wi.makeRotationX(e),this.applyMatrix4(wi),this}rotateY(e){return wi.makeRotationY(e),this.applyMatrix4(wi),this}rotateZ(e){return wi.makeRotationZ(e),this.applyMatrix4(wi),this}translate(e,n,s){return wi.makeTranslation(e,n,s),this.applyMatrix4(wi),this}scale(e,n,s){return wi.makeScale(e,n,s),this.applyMatrix4(wi),this}lookAt(e){return Th.lookAt(e),Th.updateMatrix(),this.applyMatrix4(Th.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(no).negate(),this.translate(no.x,no.y,no.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const s=[];for(let l=0,c=e.length;l<c;l++){const d=e[l];s.push(d.x,d.y,d.z||0)}this.setAttribute("position",new ri(s,3))}else{const s=Math.min(e.length,n.count);for(let l=0;l<s;l++){const c=e[l];n.setXYZ(l,c.x,c.y,c.z||0)}e.length>n.count&&mt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new dr);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){kt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new se(-1/0,-1/0,-1/0),new se(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let s=0,l=n.length;s<l;s++){const c=n[s];_i.setFromBufferAttribute(c),this.morphTargetsRelative?(Pn.addVectors(this.boundingBox.min,_i.min),this.boundingBox.expandByPoint(Pn),Pn.addVectors(this.boundingBox.max,_i.max),this.boundingBox.expandByPoint(Pn)):(this.boundingBox.expandByPoint(_i.min),this.boundingBox.expandByPoint(_i.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&kt('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 bo);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){kt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new se,1/0);return}if(e){const s=this.boundingSphere.center;if(_i.setFromBufferAttribute(e),n)for(let c=0,d=n.length;c<d;c++){const p=n[c];_l.setFromBufferAttribute(p),this.morphTargetsRelative?(Pn.addVectors(_i.min,_l.min),_i.expandByPoint(Pn),Pn.addVectors(_i.max,_l.max),_i.expandByPoint(Pn)):(_i.expandByPoint(_l.min),_i.expandByPoint(_l.max))}_i.getCenter(s);let l=0;for(let c=0,d=e.count;c<d;c++)Pn.fromBufferAttribute(e,c),l=Math.max(l,s.distanceToSquared(Pn));if(n)for(let c=0,d=n.length;c<d;c++){const p=n[c],m=this.morphTargetsRelative;for(let h=0,v=p.count;h<v;h++)Pn.fromBufferAttribute(p,h),m&&(no.fromBufferAttribute(e,h),Pn.add(no)),l=Math.max(l,s.distanceToSquared(Pn))}this.boundingSphere.radius=Math.sqrt(l),isNaN(this.boundingSphere.radius)&&kt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){kt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=n.position,l=n.normal,c=n.uv;let d=this.getAttribute("tangent");(d===void 0||d.count!==s.count)&&(d=new Yi(new Float32Array(4*s.count),4),this.setAttribute("tangent",d));const p=[],m=[];for(let T=0;T<s.count;T++)p[T]=new se,m[T]=new se;const h=new se,v=new se,S=new se,_=new bt,M=new bt,E=new bt,C=new se,y=new se;function x(T,U,X){h.fromBufferAttribute(s,T),v.fromBufferAttribute(s,U),S.fromBufferAttribute(s,X),_.fromBufferAttribute(c,T),M.fromBufferAttribute(c,U),E.fromBufferAttribute(c,X),v.sub(h),S.sub(h),M.sub(_),E.sub(_);const G=1/(M.x*E.y-E.x*M.y);isFinite(G)&&(C.copy(v).multiplyScalar(E.y).addScaledVector(S,-M.y).multiplyScalar(G),y.copy(S).multiplyScalar(M.x).addScaledVector(v,-E.x).multiplyScalar(G),p[T].add(C),p[U].add(C),p[X].add(C),m[T].add(y),m[U].add(y),m[X].add(y))}let P=this.groups;P.length===0&&(P=[{start:0,count:e.count}]);for(let T=0,U=P.length;T<U;++T){const X=P[T],G=X.start,K=X.count;for(let ue=G,pe=G+K;ue<pe;ue+=3)x(e.getX(ue+0),e.getX(ue+1),e.getX(ue+2))}const O=new se,R=new se,I=new se,B=new se;function L(T){I.fromBufferAttribute(l,T),B.copy(I);const U=p[T];O.copy(U),O.sub(I.multiplyScalar(I.dot(U))).normalize(),R.crossVectors(B,U);const G=R.dot(m[T])<0?-1:1;d.setXYZW(T,O.x,O.y,O.z,G)}for(let T=0,U=P.length;T<U;++T){const X=P[T],G=X.start,K=X.count;for(let ue=G,pe=G+K;ue<pe;ue+=3)L(e.getX(ue+0)),L(e.getX(ue+1)),L(e.getX(ue+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let s=this.getAttribute("normal");if(s===void 0||s.count!==n.count)s=new Yi(new Float32Array(n.count*3),3),this.setAttribute("normal",s);else for(let _=0,M=s.count;_<M;_++)s.setXYZ(_,0,0,0);const l=new se,c=new se,d=new se,p=new se,m=new se,h=new se,v=new se,S=new se;if(e)for(let _=0,M=e.count;_<M;_+=3){const E=e.getX(_+0),C=e.getX(_+1),y=e.getX(_+2);l.fromBufferAttribute(n,E),c.fromBufferAttribute(n,C),d.fromBufferAttribute(n,y),v.subVectors(d,c),S.subVectors(l,c),v.cross(S),p.fromBufferAttribute(s,E),m.fromBufferAttribute(s,C),h.fromBufferAttribute(s,y),p.add(v),m.add(v),h.add(v),s.setXYZ(E,p.x,p.y,p.z),s.setXYZ(C,m.x,m.y,m.z),s.setXYZ(y,h.x,h.y,h.z)}else for(let _=0,M=n.count;_<M;_+=3)l.fromBufferAttribute(n,_+0),c.fromBufferAttribute(n,_+1),d.fromBufferAttribute(n,_+2),v.subVectors(d,c),S.subVectors(l,c),v.cross(S),s.setXYZ(_+0,v.x,v.y,v.z),s.setXYZ(_+1,v.x,v.y,v.z),s.setXYZ(_+2,v.x,v.y,v.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,s=e.count;n<s;n++)Pn.fromBufferAttribute(e,n),Pn.normalize(),e.setXYZ(n,Pn.x,Pn.y,Pn.z)}toNonIndexed(){function e(p,m){const h=p.array,v=p.itemSize,S=p.normalized,_=new h.constructor(m.length*v);let M=0,E=0;for(let C=0,y=m.length;C<y;C++){p.isInterleavedBufferAttribute?M=m[C]*p.data.stride+p.offset:M=m[C]*v;for(let x=0;x<v;x++)_[E++]=h[M++]}return new Yi(_,v,S)}if(this.index===null)return mt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Li,s=this.index.array,l=this.attributes;for(const p in l){const m=l[p],h=e(m,s);n.setAttribute(p,h)}const c=this.morphAttributes;for(const p in c){const m=[],h=c[p];for(let v=0,S=h.length;v<S;v++){const _=h[v],M=e(_,s);m.push(M)}n.morphAttributes[p]=m}n.morphTargetsRelative=this.morphTargetsRelative;const d=this.groups;for(let p=0,m=d.length;p<m;p++){const h=d[p];n.addGroup(h.start,h.count,h.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const m=this.parameters;for(const h in m)m[h]!==void 0&&(e[h]=m[h]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const s=this.attributes;for(const m in s){const h=s[m];e.data.attributes[m]=h.toJSON(e.data)}const l={};let c=!1;for(const m in this.morphAttributes){const h=this.morphAttributes[m],v=[];for(let S=0,_=h.length;S<_;S++){const M=h[S];v.push(M.toJSON(e.data))}v.length>0&&(l[m]=v,c=!0)}c&&(e.data.morphAttributes=l,e.data.morphTargetsRelative=this.morphTargetsRelative);const d=this.groups;d.length>0&&(e.data.groups=JSON.parse(JSON.stringify(d)));const p=this.boundingSphere;return p!==null&&(e.data.boundingSphere=p.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 n={};this.name=e.name;const s=e.index;s!==null&&this.setIndex(s.clone());const l=e.attributes;for(const h in l){const v=l[h];this.setAttribute(h,v.clone(n))}const c=e.morphAttributes;for(const h in c){const v=[],S=c[h];for(let _=0,M=S.length;_<M;_++)v.push(S[_].clone(n));this.morphAttributes[h]=v}this.morphTargetsRelative=e.morphTargetsRelative;const d=e.groups;for(let h=0,v=d.length;h<v;h++){const S=d[h];this.addGroup(S.start,S.count,S.materialIndex)}const p=e.boundingBox;p!==null&&(this.boundingBox=p.clone());const m=e.boundingSphere;return m!==null&&(this.boundingSphere=m.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}let $E=0;class Bl extends Rs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:$E++}),this.uuid=Il(),this.name="",this.type="Material",this.blending=fo,this.side=As,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Wh,this.blendDst=qh,this.blendEquation=Qs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ct(0,0,0),this.blendAlpha=0,this.depthFunc=_o,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=xv,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Wr,this.stencilZFail=Wr,this.stencilZPass=Wr,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 n in e){const s=e[n];if(s===void 0){mt(`Material: parameter '${n}' has value of undefined.`);continue}const l=this[n];if(l===void 0){mt(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}l&&l.isColor?l.set(s):l&&l.isVector2&&s&&s.isVector2||l&&l.isEuler&&s&&s.isEuler||l&&l.isVector3&&s&&s.isVector3?l.copy(s):this[n]=s}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),this.roughness!==void 0&&(s.roughness=this.roughness),this.metalness!==void 0&&(s.metalness=this.metalness),this.sheen!==void 0&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(s.shininess=this.shininess),this.clearcoat!==void 0&&(s.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(s.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(s.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(s.dispersion=this.dispersion),this.iridescence!==void 0&&(s.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(s.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(s.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(e).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(e).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(e).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(e).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(e).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(s.combine=this.combine)),this.envMapRotation!==void 0&&(s.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(s.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(s.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(s.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(s.size=this.size),this.shadowSide!==null&&(s.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(s.sizeAttenuation=this.sizeAttenuation),this.blending!==fo&&(s.blending=this.blending),this.side!==As&&(s.side=this.side),this.vertexColors===!0&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),this.transparent===!0&&(s.transparent=!0),this.blendSrc!==Wh&&(s.blendSrc=this.blendSrc),this.blendDst!==qh&&(s.blendDst=this.blendDst),this.blendEquation!==Qs&&(s.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(s.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(s.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(s.blendAlpha=this.blendAlpha),this.depthFunc!==_o&&(s.depthFunc=this.depthFunc),this.depthTest===!1&&(s.depthTest=this.depthTest),this.depthWrite===!1&&(s.depthWrite=this.depthWrite),this.colorWrite===!1&&(s.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==xv&&(s.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(s.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Wr&&(s.stencilFail=this.stencilFail),this.stencilZFail!==Wr&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==Wr&&(s.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(s.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(s.rotation=this.rotation),this.polygonOffset===!0&&(s.polygonOffset=!0),this.polygonOffsetFactor!==0&&(s.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(s.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(s.linewidth=this.linewidth),this.dashSize!==void 0&&(s.dashSize=this.dashSize),this.gapSize!==void 0&&(s.gapSize=this.gapSize),this.scale!==void 0&&(s.scale=this.scale),this.dithering===!0&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),this.alphaHash===!0&&(s.alphaHash=!0),this.alphaToCoverage===!0&&(s.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(s.premultipliedAlpha=!0),this.forceSinglePass===!0&&(s.forceSinglePass=!0),this.allowOverride===!1&&(s.allowOverride=!1),this.wireframe===!0&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(s.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(s.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(s.flatShading=!0),this.visible===!1&&(s.visible=!1),this.toneMapped===!1&&(s.toneMapped=!1),this.fog===!1&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData);function l(c){const d=[];for(const p in c){const m=c[p];delete m.metadata,d.push(m)}return d}if(n){const c=l(e.textures),d=l(e.images);c.length>0&&(s.textures=c),d.length>0&&(s.images=d)}return s}fromJSON(e,n){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new ct().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=n[e.map]||null),e.matcap!==void 0&&(this.matcap=n[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=n[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=n[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=n[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),this.normalScale=new bt().fromArray(s)}return e.displacementMap!==void 0&&(this.displacementMap=n[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=n[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=n[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=n[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=n[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=n[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=n[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=n[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=n[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=n[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=n[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=n[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=n[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=n[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new bt().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=n[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=n[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=n[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=n[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=n[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=n[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=n[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let s=null;if(n!==null){const l=n.length;s=new Array(l);for(let c=0;c!==l;++c)s[c]=n[c].clone()}return this.clippingPlanes=s,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const Ba=new se,Ah=new se,tu=new se,ys=new se,Ch=new se,nu=new se,wh=new se;class sm{constructor(e=new se,n=new se(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.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,Ba)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const s=n.dot(this.direction);return s<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Ba.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Ba.copy(this.origin).addScaledVector(this.direction,n),Ba.distanceToSquared(e))}distanceSqToSegment(e,n,s,l){Ah.copy(e).add(n).multiplyScalar(.5),tu.copy(n).sub(e).normalize(),ys.copy(this.origin).sub(Ah);const c=e.distanceTo(n)*.5,d=-this.direction.dot(tu),p=ys.dot(this.direction),m=-ys.dot(tu),h=ys.lengthSq(),v=Math.abs(1-d*d);let S,_,M,E;if(v>0)if(S=d*m-p,_=d*p-m,E=c*v,S>=0)if(_>=-E)if(_<=E){const C=1/v;S*=C,_*=C,M=S*(S+d*_+2*p)+_*(d*S+_+2*m)+h}else _=c,S=Math.max(0,-(d*_+p)),M=-S*S+_*(_+2*m)+h;else _=-c,S=Math.max(0,-(d*_+p)),M=-S*S+_*(_+2*m)+h;else _<=-E?(S=Math.max(0,-(-d*c+p)),_=S>0?-c:Math.min(Math.max(-c,-m),c),M=-S*S+_*(_+2*m)+h):_<=E?(S=0,_=Math.min(Math.max(-c,-m),c),M=_*(_+2*m)+h):(S=Math.max(0,-(d*c+p)),_=S>0?c:Math.min(Math.max(-c,-m),c),M=-S*S+_*(_+2*m)+h);else _=d>0?-c:c,S=Math.max(0,-(d*_+p)),M=-S*S+_*(_+2*m)+h;return s&&s.copy(this.origin).addScaledVector(this.direction,S),l&&l.copy(Ah).addScaledVector(tu,_),M}intersectSphere(e,n){Ba.subVectors(e.center,this.origin);const s=Ba.dot(this.direction),l=Ba.dot(Ba)-s*s,c=e.radius*e.radius;if(l>c)return null;const d=Math.sqrt(c-l),p=s-d,m=s+d;return m<0?null:p<0?this.at(m,n):this.at(p,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(e.normal)+e.constant)/n;return s>=0?s:null}intersectPlane(e,n){const s=this.distanceToPlane(e);return s===null?null:this.at(s,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let s,l,c,d,p,m;const h=1/this.direction.x,v=1/this.direction.y,S=1/this.direction.z,_=this.origin;return h>=0?(s=(e.min.x-_.x)*h,l=(e.max.x-_.x)*h):(s=(e.max.x-_.x)*h,l=(e.min.x-_.x)*h),v>=0?(c=(e.min.y-_.y)*v,d=(e.max.y-_.y)*v):(c=(e.max.y-_.y)*v,d=(e.min.y-_.y)*v),s>d||c>l||((c>s||isNaN(s))&&(s=c),(d<l||isNaN(l))&&(l=d),S>=0?(p=(e.min.z-_.z)*S,m=(e.max.z-_.z)*S):(p=(e.max.z-_.z)*S,m=(e.min.z-_.z)*S),s>m||p>l)||((p>s||s!==s)&&(s=p),(m<l||l!==l)&&(l=m),l<0)?null:this.at(s>=0?s:l,n)}intersectsBox(e){return this.intersectBox(e,Ba)!==null}intersectTriangle(e,n,s,l,c){Ch.subVectors(n,e),nu.subVectors(s,e),wh.crossVectors(Ch,nu);let d=this.direction.dot(wh),p;if(d>0){if(l)return null;p=1}else if(d<0)p=-1,d=-d;else return null;ys.subVectors(this.origin,e);const m=p*this.direction.dot(nu.crossVectors(ys,nu));if(m<0)return null;const h=p*this.direction.dot(Ch.cross(ys));if(h<0||m+h>d)return null;const v=-p*ys.dot(wh);return v<0?null:this.at(v/d,c)}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 xy extends Bl{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ct(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 or,this.combine=Jx,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 Pv=new cn,Ks=new sm,iu=new bo,Iv=new se,au=new se,su=new se,ru=new se,Rh=new se,ou=new se,Bv=new se,lu=new se;class Ki extends Dn{constructor(e=new Li,n=new xy){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),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 n=this.geometry.morphAttributes,s=Object.keys(n);if(s.length>0){const l=n[s[0]];if(l!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let c=0,d=l.length;c<d;c++){const p=l[c].name||String(c);this.morphTargetInfluences.push(0),this.morphTargetDictionary[p]=c}}}}getVertexPosition(e,n){const s=this.geometry,l=s.attributes.position,c=s.morphAttributes.position,d=s.morphTargetsRelative;n.fromBufferAttribute(l,e);const p=this.morphTargetInfluences;if(c&&p){ou.set(0,0,0);for(let m=0,h=c.length;m<h;m++){const v=p[m],S=c[m];v!==0&&(Rh.fromBufferAttribute(S,e),d?ou.addScaledVector(Rh,v):ou.addScaledVector(Rh.sub(n),v))}n.add(ou)}return n}raycast(e,n){const s=this.geometry,l=this.material,c=this.matrixWorld;l!==void 0&&(s.boundingSphere===null&&s.computeBoundingSphere(),iu.copy(s.boundingSphere),iu.applyMatrix4(c),Ks.copy(e.ray).recast(e.near),!(iu.containsPoint(Ks.origin)===!1&&(Ks.intersectSphere(iu,Iv)===null||Ks.origin.distanceToSquared(Iv)>(e.far-e.near)**2))&&(Pv.copy(c).invert(),Ks.copy(e.ray).applyMatrix4(Pv),!(s.boundingBox!==null&&Ks.intersectsBox(s.boundingBox)===!1)&&this._computeIntersections(e,n,Ks)))}_computeIntersections(e,n,s){let l;const c=this.geometry,d=this.material,p=c.index,m=c.attributes.position,h=c.attributes.uv,v=c.attributes.uv1,S=c.attributes.normal,_=c.groups,M=c.drawRange;if(p!==null)if(Array.isArray(d))for(let E=0,C=_.length;E<C;E++){const y=_[E],x=d[y.materialIndex],P=Math.max(y.start,M.start),O=Math.min(p.count,Math.min(y.start+y.count,M.start+M.count));for(let R=P,I=O;R<I;R+=3){const B=p.getX(R),L=p.getX(R+1),T=p.getX(R+2);l=cu(this,x,e,s,h,v,S,B,L,T),l&&(l.faceIndex=Math.floor(R/3),l.face.materialIndex=y.materialIndex,n.push(l))}}else{const E=Math.max(0,M.start),C=Math.min(p.count,M.start+M.count);for(let y=E,x=C;y<x;y+=3){const P=p.getX(y),O=p.getX(y+1),R=p.getX(y+2);l=cu(this,d,e,s,h,v,S,P,O,R),l&&(l.faceIndex=Math.floor(y/3),n.push(l))}}else if(m!==void 0)if(Array.isArray(d))for(let E=0,C=_.length;E<C;E++){const y=_[E],x=d[y.materialIndex],P=Math.max(y.start,M.start),O=Math.min(m.count,Math.min(y.start+y.count,M.start+M.count));for(let R=P,I=O;R<I;R+=3){const B=R,L=R+1,T=R+2;l=cu(this,x,e,s,h,v,S,B,L,T),l&&(l.faceIndex=Math.floor(R/3),l.face.materialIndex=y.materialIndex,n.push(l))}}else{const E=Math.max(0,M.start),C=Math.min(m.count,M.start+M.count);for(let y=E,x=C;y<x;y+=3){const P=y,O=y+1,R=y+2;l=cu(this,d,e,s,h,v,S,P,O,R),l&&(l.faceIndex=Math.floor(y/3),n.push(l))}}}}function QE(a,e,n,s,l,c,d,p){let m;if(e.side===si?m=s.intersectTriangle(d,c,l,!0,p):m=s.intersectTriangle(l,c,d,e.side===As,p),m===null)return null;lu.copy(p),lu.applyMatrix4(a.matrixWorld);const h=n.ray.origin.distanceTo(lu);return h<n.near||h>n.far?null:{distance:h,point:lu.clone(),object:a}}function cu(a,e,n,s,l,c,d,p,m,h){a.getVertexPosition(p,au),a.getVertexPosition(m,su),a.getVertexPosition(h,ru);const v=QE(a,e,n,s,au,su,ru,Bv);if(v){const S=new se;Ui.getBarycoord(Bv,au,su,ru,S),l&&(v.uv=Ui.getInterpolatedAttribute(l,p,m,h,S,new bt)),c&&(v.uv1=Ui.getInterpolatedAttribute(c,p,m,h,S,new bt)),d&&(v.normal=Ui.getInterpolatedAttribute(d,p,m,h,S,new se),v.normal.dot(s.direction)>0&&v.normal.multiplyScalar(-1));const _={a:p,b:m,c:h,normal:new se,materialIndex:0};Ui.getNormal(au,su,ru,_.normal),v.face=_,v.barycoord=S}return v}class yy extends Kn{constructor(e=null,n=1,s=1,l,c,d,p,m,h=Gn,v=Gn,S,_){super(null,d,p,m,h,v,l,c,S,_),this.isDataTexture=!0,this.image={data:e,width:n,height:s},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Fv extends Yi{constructor(e,n,s,l=1){super(e,n,s),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=l}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 io=new cn,zv=new cn,uu=[],Hv=new dr,JE=new cn,vl=new Ki,xl=new bo;class eT extends Ki{constructor(e,n,s){super(e,n),this.isInstancedMesh=!0,this.instanceMatrix=new Fv(new Float32Array(s*16),16),this.instanceColor=null,this.morphTexture=null,this.count=s,this.boundingBox=null,this.boundingSphere=null;for(let l=0;l<s;l++)this.setMatrixAt(l,JE)}computeBoundingBox(){const e=this.geometry,n=this.count;this.boundingBox===null&&(this.boundingBox=new dr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let s=0;s<n;s++)this.getMatrixAt(s,io),Hv.copy(e.boundingBox).applyMatrix4(io),this.boundingBox.union(Hv)}computeBoundingSphere(){const e=this.geometry,n=this.count;this.boundingSphere===null&&(this.boundingSphere=new bo),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let s=0;s<n;s++)this.getMatrixAt(s,io),xl.copy(e.boundingSphere).applyMatrix4(io),this.boundingSphere.union(xl)}copy(e,n){return super.copy(e,n),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,n){return this.instanceColor===null?n.setRGB(1,1,1):n.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,n){return n.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,n){const s=n.morphTargetInfluences,l=this.morphTexture.source.data.data,c=s.length+1,d=e*c+1;for(let p=0;p<s.length;p++)s[p]=l[d+p]}raycast(e,n){const s=this.matrixWorld,l=this.count;if(vl.geometry=this.geometry,vl.material=this.material,vl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),xl.copy(this.boundingSphere),xl.applyMatrix4(s),e.ray.intersectsSphere(xl)!==!1))for(let c=0;c<l;c++){this.getMatrixAt(c,io),zv.multiplyMatrices(s,io),vl.matrixWorld=zv,vl.raycast(e,uu);for(let d=0,p=uu.length;d<p;d++){const m=uu[d];m.instanceId=c,m.object=this,n.push(m)}uu.length=0}}setColorAt(e,n){return this.instanceColor===null&&(this.instanceColor=new Fv(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),n.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,n){return n.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,n){const s=n.morphTargetInfluences,l=s.length+1;this.morphTexture===null&&(this.morphTexture=new yy(new Float32Array(l*this.count),l,this.count,Qp,Wi));const c=this.morphTexture.source.data.data;let d=0;for(let h=0;h<s.length;h++)d+=s[h];const p=this.geometry.morphTargetsRelative?1:1-d,m=l*e;return c[m]=p,c.set(s,m+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Dh=new se,tT=new se,nT=new St;class bs{constructor(e=new se(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,s,l){return this.normal.set(e,n,s),this.constant=l,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,s){const l=Dh.subVectors(s,n).cross(tT.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(l,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,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n,s=!0){const l=e.delta(Dh),c=this.normal.dot(l);if(c===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const d=-(e.start.dot(this.normal)+this.constant)/c;return s===!0&&(d<0||d>1)?null:n.copy(e.start).addScaledVector(l,d)}intersectsLine(e){const n=this.distanceToPoint(e.start),s=this.distanceToPoint(e.end);return n<0&&s>0||s<0&&n>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,n){const s=n||nT.getNormalMatrix(e),l=this.coplanarPoint(Dh).applyMatrix4(e),c=this.normal.applyMatrix3(s).normalize();return this.constant=-l.dot(c),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 $s=new bo,iT=new bt(.5,.5),du=new se;class rm{constructor(e=new bs,n=new bs,s=new bs,l=new bs,c=new bs,d=new bs){this.planes=[e,n,s,l,c,d]}set(e,n,s,l,c,d){const p=this.planes;return p[0].copy(e),p[1].copy(n),p[2].copy(s),p[3].copy(l),p[4].copy(c),p[5].copy(d),this}copy(e){const n=this.planes;for(let s=0;s<6;s++)n[s].copy(e.planes[s]);return this}setFromProjectionMatrix(e,n=ua,s=!1){const l=this.planes,c=e.elements,d=c[0],p=c[1],m=c[2],h=c[3],v=c[4],S=c[5],_=c[6],M=c[7],E=c[8],C=c[9],y=c[10],x=c[11],P=c[12],O=c[13],R=c[14],I=c[15];if(l[0].setComponents(h-d,M-v,x-E,I-P).normalize(),l[1].setComponents(h+d,M+v,x+E,I+P).normalize(),l[2].setComponents(h+p,M+S,x+C,I+O).normalize(),l[3].setComponents(h-p,M-S,x-C,I-O).normalize(),s)l[4].setComponents(m,_,y,R).normalize(),l[5].setComponents(h-m,M-_,x-y,I-R).normalize();else if(l[4].setComponents(h-m,M-_,x-y,I-R).normalize(),n===ua)l[5].setComponents(h+m,M+_,x+y,I+R).normalize();else if(n===Ul)l[5].setComponents(m,_,y,R).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),$s.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),$s.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere($s)}intersectsSprite(e){$s.center.set(0,0,0);const n=iT.distanceTo(e.center);return $s.radius=.7071067811865476+n,$s.applyMatrix4(e.matrixWorld),this.intersectsSphere($s)}intersectsSphere(e){const n=this.planes,s=e.center,l=-e.radius;for(let c=0;c<6;c++)if(n[c].distanceToPoint(s)<l)return!1;return!0}intersectsBox(e){const n=this.planes;for(let s=0;s<6;s++){const l=n[s];if(du.x=l.normal.x>0?e.max.x:e.min.x,du.y=l.normal.y>0?e.max.y:e.min.y,du.z=l.normal.z>0?e.max.z:e.min.z,l.distanceToPoint(du)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let s=0;s<6;s++)if(n[s].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class om extends Bl{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ct(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 Iu=new se,Bu=new se,Gv=new cn,yl=new sm,fu=new bo,Nh=new se,Vv=new se;class aT extends Dn{constructor(e=new Li,n=new om){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),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 n=e.attributes.position,s=[0];for(let l=1,c=n.count;l<c;l++)Iu.fromBufferAttribute(n,l-1),Bu.fromBufferAttribute(n,l),s[l]=s[l-1],s[l]+=Iu.distanceTo(Bu);e.setAttribute("lineDistance",new ri(s,1))}else mt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const s=this.geometry,l=this.matrixWorld,c=e.params.Line.threshold,d=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),fu.copy(s.boundingSphere),fu.applyMatrix4(l),fu.radius+=c,e.ray.intersectsSphere(fu)===!1)return;Gv.copy(l).invert(),yl.copy(e.ray).applyMatrix4(Gv);const p=c/((this.scale.x+this.scale.y+this.scale.z)/3),m=p*p,h=this.isLineSegments?2:1,v=s.index,_=s.attributes.position;if(v!==null){const M=Math.max(0,d.start),E=Math.min(v.count,d.start+d.count);for(let C=M,y=E-1;C<y;C+=h){const x=v.getX(C),P=v.getX(C+1),O=hu(this,e,yl,m,x,P,C);O&&n.push(O)}if(this.isLineLoop){const C=v.getX(E-1),y=v.getX(M),x=hu(this,e,yl,m,C,y,E-1);x&&n.push(x)}}else{const M=Math.max(0,d.start),E=Math.min(_.count,d.start+d.count);for(let C=M,y=E-1;C<y;C+=h){const x=hu(this,e,yl,m,C,C+1,C);x&&n.push(x)}if(this.isLineLoop){const C=hu(this,e,yl,m,E-1,M,E-1);C&&n.push(C)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,s=Object.keys(n);if(s.length>0){const l=n[s[0]];if(l!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let c=0,d=l.length;c<d;c++){const p=l[c].name||String(c);this.morphTargetInfluences.push(0),this.morphTargetDictionary[p]=c}}}}}function hu(a,e,n,s,l,c,d){const p=a.geometry.attributes.position;if(Iu.fromBufferAttribute(p,l),Bu.fromBufferAttribute(p,c),n.distanceSqToSegment(Iu,Bu,Nh,Vv)>s)return;Nh.applyMatrix4(a.matrixWorld);const h=e.ray.origin.distanceTo(Nh);if(!(h<e.near||h>e.far))return{distance:h,point:Vv.clone().applyMatrix4(a.matrixWorld),index:d,face:null,faceIndex:null,barycoord:null,object:a}}const kv=new se,jv=new se;class Sy extends aT{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,s=[];for(let l=0,c=n.count;l<c;l+=2)kv.fromBufferAttribute(n,l),jv.fromBufferAttribute(n,l+1),s[l]=l===0?0:s[l-1],s[l+1]=s[l]+kv.distanceTo(jv);e.setAttribute("lineDistance",new ri(s,1))}else mt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class by extends Kn{constructor(e=[],n=sr,s,l,c,d,p,m,h,v){super(e,n,s,l,c,d,p,m,h,v),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class xo extends Kn{constructor(e,n,s=pa,l,c,d,p=Gn,m=Gn,h,v=Xa,S=1){if(v!==Xa&&v!==tr)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const _={width:e,height:n,depth:S};super(_,l,c,d,p,m,v,s,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new am(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}class sT extends xo{constructor(e,n=pa,s=sr,l,c,d=Gn,p=Gn,m,h=Xa){const v={width:e,height:e,depth:1},S=[v,v,v,v,v,v];super(e,e,n,s,l,c,d,p,m,h),this.image=S,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class My extends Kn{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class fr extends Li{constructor(e=1,n=1,s=1,l=1,c=1,d=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:s,widthSegments:l,heightSegments:c,depthSegments:d};const p=this;l=Math.floor(l),c=Math.floor(c),d=Math.floor(d);const m=[],h=[],v=[],S=[];let _=0,M=0;E("z","y","x",-1,-1,s,n,e,d,c,0),E("z","y","x",1,-1,s,n,-e,d,c,1),E("x","z","y",1,1,e,s,n,l,d,2),E("x","z","y",1,-1,e,s,-n,l,d,3),E("x","y","z",1,-1,e,n,s,l,c,4),E("x","y","z",-1,-1,e,n,-s,l,c,5),this.setIndex(m),this.setAttribute("position",new ri(h,3)),this.setAttribute("normal",new ri(v,3)),this.setAttribute("uv",new ri(S,2));function E(C,y,x,P,O,R,I,B,L,T,U){const X=R/L,G=I/T,K=R/2,ue=I/2,pe=B/2,Q=L+1,V=T+1;let j=0,ae=0;const _e=new se;for(let ve=0;ve<V;ve++){const H=ve*G-ue;for(let te=0;te<Q;te++){const Ee=te*X-K;_e[C]=Ee*P,_e[y]=H*O,_e[x]=pe,h.push(_e.x,_e.y,_e.z),_e[C]=0,_e[y]=0,_e[x]=B>0?1:-1,v.push(_e.x,_e.y,_e.z),S.push(te/L),S.push(1-ve/T),j+=1}}for(let ve=0;ve<T;ve++)for(let H=0;H<L;H++){const te=_+H+Q*ve,Ee=_+H+Q*(ve+1),Le=_+(H+1)+Q*(ve+1),Fe=_+(H+1)+Q*ve;m.push(te,Ee,Fe),m.push(Ee,Le,Fe),ae+=6}p.addGroup(M,ae,U),M+=ae,_+=j}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}const pu=new se,mu=new se,Uh=new se,gu=new Ui;class rT extends Li{constructor(e=null,n=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:n},e!==null){const l=Math.pow(10,4),c=Math.cos(wl*n),d=e.getIndex(),p=e.getAttribute("position"),m=d?d.count:p.count,h=[0,0,0],v=["a","b","c"],S=new Array(3),_={},M=[];for(let E=0;E<m;E+=3){d?(h[0]=d.getX(E),h[1]=d.getX(E+1),h[2]=d.getX(E+2)):(h[0]=E,h[1]=E+1,h[2]=E+2);const{a:C,b:y,c:x}=gu;if(C.fromBufferAttribute(p,h[0]),y.fromBufferAttribute(p,h[1]),x.fromBufferAttribute(p,h[2]),gu.getNormal(Uh),S[0]=`${Math.round(C.x*l)},${Math.round(C.y*l)},${Math.round(C.z*l)}`,S[1]=`${Math.round(y.x*l)},${Math.round(y.y*l)},${Math.round(y.z*l)}`,S[2]=`${Math.round(x.x*l)},${Math.round(x.y*l)},${Math.round(x.z*l)}`,!(S[0]===S[1]||S[1]===S[2]||S[2]===S[0]))for(let P=0;P<3;P++){const O=(P+1)%3,R=S[P],I=S[O],B=gu[v[P]],L=gu[v[O]],T=`${R}_${I}`,U=`${I}_${R}`;U in _&&_[U]?(Uh.dot(_[U].normal)<=c&&(M.push(B.x,B.y,B.z),M.push(L.x,L.y,L.z)),_[U]=null):T in _||(_[T]={index0:h[P],index1:h[O],normal:Uh.clone()})}}for(const E in _)if(_[E]){const{index0:C,index1:y}=_[E];pu.fromBufferAttribute(p,C),mu.fromBufferAttribute(p,y),M.push(pu.x,pu.y,pu.z),M.push(mu.x,mu.y,mu.z)}this.setAttribute("position",new ri(M,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Vu extends Li{constructor(e=1,n=1,s=1,l=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:s,heightSegments:l};const c=e/2,d=n/2,p=Math.floor(s),m=Math.floor(l),h=p+1,v=m+1,S=e/p,_=n/m,M=[],E=[],C=[],y=[];for(let x=0;x<v;x++){const P=x*_-d;for(let O=0;O<h;O++){const R=O*S-c;E.push(R,-P,0),C.push(0,0,1),y.push(O/p),y.push(1-x/m)}}for(let x=0;x<m;x++)for(let P=0;P<p;P++){const O=P+h*x,R=P+h*(x+1),I=P+1+h*(x+1),B=P+1+h*x;M.push(O,R,B),M.push(R,I,B)}this.setIndex(M),this.setAttribute("position",new ri(E,3)),this.setAttribute("normal",new ri(C,3)),this.setAttribute("uv",new ri(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vu(e.width,e.height,e.widthSegments,e.heightSegments)}}function yo(a){const e={};for(const n in a){e[n]={};for(const s in a[n]){const l=a[n][s];if(Xv(l))l.isRenderTargetTexture?(mt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][s]=null):e[n][s]=l.clone();else if(Array.isArray(l))if(Xv(l[0])){const c=[];for(let d=0,p=l.length;d<p;d++)c[d]=l[d].clone();e[n][s]=c}else e[n][s]=l.slice();else e[n][s]=l}}return e}function Zn(a){const e={};for(let n=0;n<a.length;n++){const s=yo(a[n]);for(const l in s)e[l]=s[l]}return e}function Xv(a){return a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)}function oT(a){const e=[];for(let n=0;n<a.length;n++)e.push(a[n].clone());return e}function Ey(a){const e=a.getRenderTarget();return e===null?a.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:zt.workingColorSpace}const lT={clone:yo,merge:Zn};var cT=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,uT=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class $i extends Bl{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=cT,this.fragmentShader=uT,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=yo(e.uniforms),this.uniformsGroups=oT(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.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const l in this.uniforms){const d=this.uniforms[l].value;d&&d.isTexture?n.uniforms[l]={type:"t",value:d.toJSON(e).uuid}:d&&d.isColor?n.uniforms[l]={type:"c",value:d.getHex()}:d&&d.isVector2?n.uniforms[l]={type:"v2",value:d.toArray()}:d&&d.isVector3?n.uniforms[l]={type:"v3",value:d.toArray()}:d&&d.isVector4?n.uniforms[l]={type:"v4",value:d.toArray()}:d&&d.isMatrix3?n.uniforms[l]={type:"m3",value:d.toArray()}:d&&d.isMatrix4?n.uniforms[l]={type:"m4",value:d.toArray()}:n.uniforms[l]={value:d}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const s={};for(const l in this.extensions)this.extensions[l]===!0&&(s[l]=!0);return Object.keys(s).length>0&&(n.extensions=s),n}fromJSON(e,n){if(super.fromJSON(e,n),e.uniforms!==void 0)for(const s in e.uniforms){const l=e.uniforms[s];switch(this.uniforms[s]={},l.type){case"t":this.uniforms[s].value=n[l.value]||null;break;case"c":this.uniforms[s].value=new ct().setHex(l.value);break;case"v2":this.uniforms[s].value=new bt().fromArray(l.value);break;case"v3":this.uniforms[s].value=new se().fromArray(l.value);break;case"v4":this.uniforms[s].value=new pn().fromArray(l.value);break;case"m3":this.uniforms[s].value=new St().fromArray(l.value);break;case"m4":this.uniforms[s].value=new cn().fromArray(l.value);break;default:this.uniforms[s].value=l.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)this.extensions[s]=e.extensions[s];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class dT extends $i{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class fT extends Bl{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=xE,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 hT extends Bl{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 lm extends Dn{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new ct(e),this.intensity=n}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,n}}class pT extends lm{constructor(e,n,s){super(e,s),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Dn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ct(n)}copy(e,n){return super.copy(e,n),this.groundColor.copy(e.groundColor),this}toJSON(e){const n=super.toJSON(e);return n.object.groundColor=this.groundColor.getHex(),n}}const Lh=new cn,Wv=new se,qv=new se;class mT{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new bt(512,512),this.mapType=xi,this.map=null,this.mapPass=null,this.matrix=new cn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new rm,this._frameExtents=new bt(1,1),this._viewportCount=1,this._viewports=[new pn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,s=this.matrix;Wv.setFromMatrixPosition(e.matrixWorld),n.position.copy(Wv),qv.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(qv),n.updateMatrixWorld(),Lh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Lh,n.coordinateSystem,n.reversedDepth),n.coordinateSystem===Ul||n.reversedDepth?s.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):s.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),s.multiply(Lh)}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.biasNode=e.biasNode,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}}const _u=new se,vu=new Cs,oa=new se;class Ty extends Dn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new cn,this.projectionMatrix=new cn,this.projectionMatrixInverse=new cn,this.coordinateSystem=ua,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),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.matrixWorld.decompose(_u,vu,oa),oa.x===1&&oa.y===1&&oa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(_u,vu,oa.set(1,1,1)).invert()}updateWorldMatrix(e,n,s=!1){super.updateWorldMatrix(e,n,s),this.matrixWorld.decompose(_u,vu,oa),oa.x===1&&oa.y===1&&oa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(_u,vu,oa.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Ss=new se,Yv=new bt,Zv=new bt;class Ni extends Ty{constructor(e=50,n=1,s=.1,l=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=s,this.far=l,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),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 n=.5*this.getFilmHeight()/e;this.fov=Lp*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(wl*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Lp*2*Math.atan(Math.tan(wl*.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,n,s){Ss.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ss.x,Ss.y).multiplyScalar(-e/Ss.z),Ss.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(Ss.x,Ss.y).multiplyScalar(-e/Ss.z)}getViewSize(e,n){return this.getViewBounds(e,Yv,Zv),n.subVectors(Zv,Yv)}setViewOffset(e,n,s,l,c,d){this.aspect=e/n,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=n,this.view.offsetX=s,this.view.offsetY=l,this.view.width=c,this.view.height=d,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(wl*.5*this.fov)/this.zoom,s=2*n,l=this.aspect*s,c=-.5*l;const d=this.view;if(this.view!==null&&this.view.enabled){const m=d.fullWidth,h=d.fullHeight;c+=d.offsetX*l/m,n-=d.offsetY*s/h,l*=d.width/m,s*=d.height/h}const p=this.filmOffset;p!==0&&(c+=e*p/this.getFilmWidth()),this.projectionMatrix.makePerspective(c,c+l,n,n-s,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}class cm extends Ty{constructor(e=-1,n=1,s=1,l=-1,c=.1,d=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=s,this.bottom=l,this.near=c,this.far=d,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),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,n,s,l,c,d){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=n,this.view.offsetX=s,this.view.offsetY=l,this.view.width=c,this.view.height=d,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),s=(this.right+this.left)/2,l=(this.top+this.bottom)/2;let c=s-e,d=s+e,p=l+n,m=l-n;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,v=(this.top-this.bottom)/this.view.fullHeight/this.zoom;c+=h*this.view.offsetX,d=c+h*this.view.width,p-=v*this.view.offsetY,m=p-v*this.view.height}this.projectionMatrix.makeOrthographic(c,d,p,m,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}class gT extends mT{constructor(){super(new cm(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Kv extends lm{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Dn.DEFAULT_UP),this.updateMatrix(),this.target=new Dn,this.shadow=new gT}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const n=super.toJSON(e);return n.object.shadow=this.shadow.toJSON(),n.object.target=this.target.uuid,n}}class _T extends lm{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}const ao=-90,so=1;class vT extends Dn{constructor(e,n,s){super(),this.type="CubeCamera",this.renderTarget=s,this.coordinateSystem=null,this.activeMipmapLevel=0;const l=new Ni(ao,so,e,n);l.layers=this.layers,this.add(l);const c=new Ni(ao,so,e,n);c.layers=this.layers,this.add(c);const d=new Ni(ao,so,e,n);d.layers=this.layers,this.add(d);const p=new Ni(ao,so,e,n);p.layers=this.layers,this.add(p);const m=new Ni(ao,so,e,n);m.layers=this.layers,this.add(m);const h=new Ni(ao,so,e,n);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[s,l,c,d,p,m]=n;for(const h of n)this.remove(h);if(e===ua)s.up.set(0,1,0),s.lookAt(1,0,0),l.up.set(0,1,0),l.lookAt(-1,0,0),c.up.set(0,0,-1),c.lookAt(0,1,0),d.up.set(0,0,1),d.lookAt(0,-1,0),p.up.set(0,1,0),p.lookAt(0,0,1),m.up.set(0,1,0),m.lookAt(0,0,-1);else if(e===Ul)s.up.set(0,-1,0),s.lookAt(-1,0,0),l.up.set(0,-1,0),l.lookAt(1,0,0),c.up.set(0,0,1),c.lookAt(0,1,0),d.up.set(0,0,-1),d.lookAt(0,-1,0),p.up.set(0,-1,0),p.lookAt(0,0,1),m.up.set(0,-1,0),m.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of n)this.add(h),h.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:s,activeMipmapLevel:l}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[c,d,p,m,h,v]=this.children,S=e.getRenderTarget(),_=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),E=e.xr.enabled;e.xr.enabled=!1;const C=s.texture.generateMipmaps;s.texture.generateMipmaps=!1;let y=!1;e.isWebGLRenderer===!0?y=e.state.buffers.depth.getReversed():y=e.reversedDepthBuffer,e.setRenderTarget(s,0,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,c),e.setRenderTarget(s,1,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,d),e.setRenderTarget(s,2,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,p),e.setRenderTarget(s,3,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,m),e.setRenderTarget(s,4,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,h),s.texture.generateMipmaps=C,e.setRenderTarget(s,5,l),y&&e.autoClear===!1&&e.clearDepth(),e.render(n,v),e.setRenderTarget(S,_,M),e.xr.enabled=E,s.texture.needsPMREMUpdate=!0}}class xT extends Ni{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class $v{constructor(e=1,n=0,s=0){this.radius=e,this.phi=n,this.theta=s}set(e,n,s){return this.radius=e,this.phi=n,this.theta=s,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Lt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,s){return this.radius=Math.sqrt(e*e+n*n+s*s),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,s),this.phi=Math.acos(Lt(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Mm=class Mm{constructor(e,n,s,l){this.elements=[1,0,0,1],e!==void 0&&this.set(e,n,s,l)}identity(){return this.set(1,0,0,1),this}fromArray(e,n=0){for(let s=0;s<4;s++)this.elements[s]=e[s+n];return this}set(e,n,s,l){const c=this.elements;return c[0]=e,c[2]=n,c[1]=s,c[3]=l,this}};Mm.prototype.isMatrix2=!0;let Qv=Mm;class yT extends Sy{constructor(e=10,n=10,s=4473924,l=8947848){s=new ct(s),l=new ct(l);const c=n/2,d=e/n,p=e/2,m=[],h=[];for(let _=0,M=0,E=-p;_<=n;_++,E+=d){m.push(-p,0,E,p,0,E),m.push(E,0,-p,E,0,p);const C=_===c?s:l;C.toArray(h,M),M+=3,C.toArray(h,M),M+=3,C.toArray(h,M),M+=3,C.toArray(h,M),M+=3}const v=new Li;v.setAttribute("position",new ri(m,3)),v.setAttribute("color",new ri(h,3));const S=new om({vertexColors:!0,toneMapped:!1});super(v,S),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class ST extends Rs{constructor(e,n=null){super(),this.object=e,this.domElement=n,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){mt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Jv(a,e,n,s){const l=bT(s);switch(n){case dy:return a*e;case Qp:return a*e/l.components*l.byteLength;case Jp:return a*e/l.components*l.byteLength;case rr:return a*e*2/l.components*l.byteLength;case em:return a*e*2/l.components*l.byteLength;case fy:return a*e*3/l.components*l.byteLength;case qi:return a*e*4/l.components*l.byteLength;case tm:return a*e*4/l.components*l.byteLength;case Eu:case Tu:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case Au:case Cu:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case ap:case rp:return Math.max(a,16)*Math.max(e,8)/4;case ip:case sp:return Math.max(a,8)*Math.max(e,8)/2;case op:case lp:case up:case dp:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case cp:case Nu:case fp:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case hp:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case pp:return Math.floor((a+4)/5)*Math.floor((e+3)/4)*16;case mp:return Math.floor((a+4)/5)*Math.floor((e+4)/5)*16;case gp:return Math.floor((a+5)/6)*Math.floor((e+4)/5)*16;case _p:return Math.floor((a+5)/6)*Math.floor((e+5)/6)*16;case vp:return Math.floor((a+7)/8)*Math.floor((e+4)/5)*16;case xp:return Math.floor((a+7)/8)*Math.floor((e+5)/6)*16;case yp:return Math.floor((a+7)/8)*Math.floor((e+7)/8)*16;case Sp:return Math.floor((a+9)/10)*Math.floor((e+4)/5)*16;case bp:return Math.floor((a+9)/10)*Math.floor((e+5)/6)*16;case Mp:return Math.floor((a+9)/10)*Math.floor((e+7)/8)*16;case Ep:return Math.floor((a+9)/10)*Math.floor((e+9)/10)*16;case Tp:return Math.floor((a+11)/12)*Math.floor((e+9)/10)*16;case Ap:return Math.floor((a+11)/12)*Math.floor((e+11)/12)*16;case Cp:case wp:case Rp:return Math.ceil(a/4)*Math.ceil(e/4)*16;case Dp:case Np:return Math.ceil(a/4)*Math.ceil(e/4)*8;case Uu:case Up:return Math.ceil(a/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function bT(a){switch(a){case xi:case oy:return{byteLength:1,components:1};case Dl:case ly:case ja:return{byteLength:2,components:1};case Kp:case $p:return{byteLength:2,components:4};case pa:case Zp:case Wi:return{byteLength:4,components:1};case cy:case uy:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${a}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:qp}}));typeof window<"u"&&(window.__THREE__?mt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=qp);function Ay(){let a=null,e=!1,n=null,s=null;function l(c,d){n(c,d),s=a.requestAnimationFrame(l)}return{start:function(){e!==!0&&n!==null&&a!==null&&(s=a.requestAnimationFrame(l),e=!0)},stop:function(){a!==null&&a.cancelAnimationFrame(s),e=!1},setAnimationLoop:function(c){n=c},setContext:function(c){a=c}}}function MT(a){const e=new WeakMap;function n(p,m){const h=p.array,v=p.usage,S=h.byteLength,_=a.createBuffer();a.bindBuffer(m,_),a.bufferData(m,h,v),p.onUploadCallback();let M;if(h instanceof Float32Array)M=a.FLOAT;else if(typeof Float16Array<"u"&&h instanceof Float16Array)M=a.HALF_FLOAT;else if(h instanceof Uint16Array)p.isFloat16BufferAttribute?M=a.HALF_FLOAT:M=a.UNSIGNED_SHORT;else if(h instanceof Int16Array)M=a.SHORT;else if(h instanceof Uint32Array)M=a.UNSIGNED_INT;else if(h instanceof Int32Array)M=a.INT;else if(h instanceof Int8Array)M=a.BYTE;else if(h instanceof Uint8Array)M=a.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)M=a.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:_,type:M,bytesPerElement:h.BYTES_PER_ELEMENT,version:p.version,size:S}}function s(p,m,h){const v=m.array,S=m.updateRanges;if(a.bindBuffer(h,p),S.length===0)a.bufferSubData(h,0,v);else{S.sort((M,E)=>M.start-E.start);let _=0;for(let M=1;M<S.length;M++){const E=S[_],C=S[M];C.start<=E.start+E.count+1?E.count=Math.max(E.count,C.start+C.count-E.start):(++_,S[_]=C)}S.length=_+1;for(let M=0,E=S.length;M<E;M++){const C=S[M];a.bufferSubData(h,C.start*v.BYTES_PER_ELEMENT,v,C.start,C.count)}m.clearUpdateRanges()}m.onUploadCallback()}function l(p){return p.isInterleavedBufferAttribute&&(p=p.data),e.get(p)}function c(p){p.isInterleavedBufferAttribute&&(p=p.data);const m=e.get(p);m&&(a.deleteBuffer(m.buffer),e.delete(p))}function d(p,m){if(p.isInterleavedBufferAttribute&&(p=p.data),p.isGLBufferAttribute){const v=e.get(p);(!v||v.version<p.version)&&e.set(p,{buffer:p.buffer,type:p.type,bytesPerElement:p.elementSize,version:p.version});return}const h=e.get(p);if(h===void 0)e.set(p,n(p,m));else if(h.version<p.version){if(h.size!==p.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.");s(h.buffer,p,m),h.version=p.version}}return{get:l,remove:c,update:d}}var ET=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,TT=`#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`,AT=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,CT=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,wT=`#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`,RT=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,DT=`#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`,NT=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,UT=`#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;
vec4 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 );
}
#endif`,LT=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,OT=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,PT=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,IT=`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`,BT=`#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`,FT=`#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`,zT=`#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`,HT=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,GT=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,VT=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,kT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#endif`,jT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#endif`,XT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
#endif`,WT=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec4( 1.0 );
#endif
#ifdef USE_COLOR_ALPHA
vColor *= color;
#elif defined( USE_COLOR )
vColor.rgb *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.rgb *= instanceColor.rgb;
#endif
#ifdef USE_BATCHING_COLOR
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
#endif`,qT=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
float precisionSafeLength( vec3 v ) { return length( v ); }
#else
float precisionSafeLength( vec3 v ) {
float maxComponent = max3( abs( v ) );
return length( v / maxComponent ) * maxComponent;
}
#endif
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
#define inverseTransformDirection transformDirectionByInverseViewMatrix
vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {
return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );
}
vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {
return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,YT=`#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`,ZT=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
mat3 bm = mat3( batchingMatrix );
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
transformedNormal = bm * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = bm * transformedTangent;
#endif
#endif
#ifdef USE_INSTANCING
mat3 im = mat3( instanceMatrix );
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
transformedNormal = im * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = im * transformedTangent;
#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
#endif`,KT=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,$T=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,QT=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,JT=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,eA="gl_FragColor = linearToOutputTexel( gl_FragColor );",tA=`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 );
}`,nA=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
#endif
#else
vec3 reflectVec = vReflect;
#endif
#ifdef ENVMAP_TYPE_CUBE
vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );
#ifdef ENVMAP_BLENDING_MULTIPLY
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_MIX )
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif
#endif`,iA=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,aA=`#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`,sA=`#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`,rA=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif`,oA=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,lA=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,cA=`#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`,uA=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,dA=`#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
}`,fA=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,hA=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,pA=`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`,mA=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
float x = normal.x, y = normal.y, z = normal.z;
vec3 result = shCoefficients[ 0 ] * 0.886227;
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
vec3 color;
};
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
light.color = directionalLight.color;
light.direction = directionalLight.direction;
light.visible = true;
}
#endif
#if NUM_POINT_LIGHTS > 0
struct PointLight {
vec3 position;
vec3 color;
float distance;
float decay;
};
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = pointLight.position - geometryPosition;
light.direction = normalize( lVector );
float lightDistance = length( lVector );
light.color = pointLight.color;
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
}
#endif
#if NUM_SPOT_LIGHTS > 0
struct SpotLight {
vec3 position;
vec3 direction;
vec3 color;
float distance;
float decay;
float coneCos;
float penumbraCos;
};
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = spotLight.position - geometryPosition;
light.direction = normalize( lVector );
float angleCos = dot( light.direction, spotLight.direction );
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
if ( spotAttenuation > 0.0 ) {
float lightDistance = length( lVector );
light.color = spotLight.color * spotAttenuation;
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
} else {
light.color = vec3( 0.0 );
light.visible = false;
}
}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
struct RectAreaLight {
vec3 color;
vec3 position;
vec3 halfWidth;
vec3 halfHeight;
};
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
struct HemisphereLight {
vec3 direction;
vec3 skyColor;
vec3 groundColor;
};
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
#endif
#include <lightprobes_pars_fragment>`,gA=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 reflectVec = reflect( - viewDir, normal );
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
#ifdef USE_ANISOTROPY
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 bentNormal = cross( bitangent, viewDir );
bentNormal = normalize( cross( bentNormal, bitangent ) );
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
return getIBLRadiance( viewDir, bentNormal, roughness );
#else
return vec3( 0.0 );
#endif
}
#endif
#endif`,_A=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,vA=`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`,xA=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,yA=`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`,SA=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = metalnessFactor;
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
material.ior = ior;
#ifdef USE_SPECULAR
float specularIntensityFactor = specularIntensity;
vec3 specularColorFactor = specularColor;
#ifdef USE_SPECULAR_COLORMAP
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
#endif
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
#else
float specularIntensityFactor = 1.0;
vec3 specularColorFactor = vec3( 1.0 );
material.specularF90 = 1.0;
#endif
material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = vec3( 0.04 );
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
material.clearcoat = clearcoat;
material.clearcoatRoughness = clearcoatRoughness;
material.clearcoatF0 = vec3( 0.04 );
material.clearcoatF90 = 1.0;
#ifdef USE_CLEARCOATMAP
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
#endif
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
#ifdef USE_IRIDESCENCEMAP
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
#else
material.iridescenceThickness = iridescenceThicknessMaximum;
#endif
#endif
#ifdef USE_SHEEN
material.sheenColor = sheenColor;
#ifdef USE_SHEEN_COLORMAP
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
#endif
material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
#ifdef USE_SHEEN_ROUGHNESSMAP
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
#endif
#endif
#ifdef USE_ANISOTROPY
#ifdef USE_ANISOTROPYMAP
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
#else
vec2 anisotropyV = anisotropyVector;
#endif
material.anisotropy = length( anisotropyV );
if( material.anisotropy == 0.0 ) {
anisotropyV = vec2( 1.0, 0.0 );
} else {
anisotropyV /= material.anisotropy;
material.anisotropy = saturate( material.anisotropy );
}
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,bA=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
vec3 specularColor;
vec3 specularColorBlended;
float roughness;
float metalness;
float specularF90;
float dispersion;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
vec3 clearcoatF0;
float clearcoatF90;
#endif
#ifdef USE_IRIDESCENCE
float iridescence;
float iridescenceIOR;
float iridescenceThickness;
vec3 iridescenceFresnel;
vec3 iridescenceF0;
vec3 iridescenceFresnelDielectric;
vec3 iridescenceFresnelMetallic;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
float sheenRoughness;
#endif
#ifdef IOR
float ior;
#endif
#ifdef USE_TRANSMISSION
float transmission;
float transmissionAlpha;
float thickness;
float attenuationDistance;
vec3 attenuationColor;
#endif
#ifdef USE_ANISOTROPY
float anisotropy;
float alphaT;
vec3 anisotropyT;
vec3 anisotropyB;
#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
float x2 = x * x;
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
float a2 = pow2( alpha );
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
float a2 = alphaT * alphaB;
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
highp float v2 = dot( v, v );
float w2 = a2 / v2;
return RECIPROCAL_PI * a2 * pow2 ( w2 );
}
#endif
#ifdef USE_CLEARCOAT
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
vec3 f0 = material.clearcoatF0;
float f90 = material.clearcoatF90;
float roughness = material.clearcoatRoughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 f0 = material.specularColorBlended;
float f90 = material.specularF90;
float roughness = material.roughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
#ifdef USE_IRIDESCENCE
F = mix( F, material.iridescenceFresnel, material.iridescence );
#endif
#ifdef USE_ANISOTROPY
float dotTL = dot( material.anisotropyT, lightDir );
float dotTV = dot( material.anisotropyT, viewDir );
float dotTH = dot( material.anisotropyT, halfDir );
float dotBL = dot( material.anisotropyB, lightDir );
float dotBV = dot( material.anisotropyB, viewDir );
float dotBH = dot( material.anisotropyB, halfDir );
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
#else
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
#endif
return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
float dotNV = saturate( dot( N, V ) );
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
float x = dot( v1, v2 );
float y = abs( x );
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
float b = 3.4175940 + ( 4.1616724 + y ) * y;
float v = a / b;
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
vec3 lightNormal = cross( v1, v2 );
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 );
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
vec3 coords[ 4 ];
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
vec3 vectorFormFactor = vec3( 0.0 );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 );
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float D = D_Charlie( sheenRoughness, dotNH );
float V = V_Neubelt( dotNV, dotNL );
return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
float r2 = roughness * roughness;
float rInv = 1.0 / ( roughness + 0.1 );
float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
float DG = exp( a * dotNV + b );
return saturate( DG );
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
float dotNV = saturate( dot( normal, viewDir ) );
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
#ifdef USE_IRIDESCENCE
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
#else
vec3 Fr = specularColor;
#endif
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
float Ess = fab.x + fab.y;
float Ems = 1.0 - Ess;
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
float Ess_V = dfgV.x + dfgV.y;
float Ess_L = dfgL.x + dfgL.y;
float Ems_V = 1.0 - Ess_V;
float Ems_L = 1.0 - Ess_L;
vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
float compensationFactor = Ems_V * Ems_L;
vec3 multiScatter = Fms * compensationFactor;
return singleScatter + multiScatter;
}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometryNormal;
vec3 viewDir = geometryViewDir;
vec3 position = geometryPosition;
vec3 lightPos = rectAreaLight.position;
vec3 halfWidth = rectAreaLight.halfWidth;
vec3 halfHeight = rectAreaLight.halfHeight;
vec3 lightColor = rectAreaLight.color;
float roughness = material.roughness;
vec3 rectCoords[ 4 ];
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
vec2 uv = LTC_Uv( normal, viewDir, roughness );
vec4 t1 = texture2D( ltc_1, uv );
vec4 t2 = texture2D( ltc_2, uv );
mat3 mInv = mat3(
vec3( t1.x, 0, t1.y ),
vec3( 0, 1, 0 ),
vec3( t1.z, 0, t1.w )
);
vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
#ifdef USE_CLEARCOAT
vec3 Ncc = geometryClearcoatNormal;
vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );
vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );
vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );
mat3 mInvClearcoat = mat3(
vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),
vec3( 0, 1, 0 ),
vec3( t1Clearcoat.z, 0, t1Clearcoat.w )
);
vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;
clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );
#endif
}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
#ifdef USE_CLEARCOAT
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
vec3 ccIrradiance = dotNLcc * directLight.color;
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
#endif
#ifdef USE_SHEEN
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
irradiance *= sheenEnergyComp;
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
#ifdef USE_SHEEN
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
diffuse *= sheenEnergyComp;
#endif
reflectedLight.indirectDiffuse += diffuse;
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef USE_CLEARCOAT
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
#endif
vec3 singleScatteringDielectric = vec3( 0.0 );
vec3 multiScatteringDielectric = vec3( 0.0 );
vec3 singleScatteringMetallic = vec3( 0.0 );
vec3 multiScatteringMetallic = vec3( 0.0 );
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
#else
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
#endif
vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
vec3 indirectSpecular = radiance * singleScattering;
indirectSpecular += multiScattering * cosineWeightedIrradiance;
vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
#ifdef USE_SHEEN
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
indirectSpecular *= sheenEnergyComp;
indirectDiffuse *= sheenEnergyComp;
#endif
reflectedLight.indirectSpecular += indirectSpecular;
reflectedLight.indirectDiffuse += indirectDiffuse;
}
#define RE_Direct RE_Direct_Physical
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,MA=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
float dotNVi = saturate( dot( normal, geometryViewDir ) );
if ( material.iridescenceThickness == 0.0 ) {
material.iridescence = 0.0;
} else {
material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
getPointLightInfo( pointLight, geometryPosition, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
pointLightShadow = pointLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
SpotLight spotLight;
vec4 spotColor;
vec3 spotLightCoord;
bool inSpotLightMap;
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
spotLight = spotLights[ i ];
getSpotLightInfo( spotLight, geometryPosition, directLight );
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
#else
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#endif
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
#endif
#undef SPOT_LIGHT_MAP_INDEX
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
directionalLight = directionalLights[ i ];
getDirectionalLightInfo( directionalLight, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
RectAreaLight rectAreaLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
rectAreaLight = rectAreaLights[ i ];
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
#if defined( USE_LIGHT_PROBES )
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
#endif
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
}
#pragma unroll_loop_end
#endif
#ifdef USE_LIGHT_PROBES_GRID
vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;
vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );
irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,EA=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
irradiance += lightMapIrradiance;
#endif
#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )
#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )
iblIrradiance += getIBLIrradiance( geometryNormal );
#endif
#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
#ifdef USE_ANISOTROPY
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
#else
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
#endif
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
#endif`,TA=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,AA=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
uniform vec3 probesResolution;
vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
vec3 res = probesResolution;
vec3 gridRange = probesMax - probesMin;
vec3 resMinusOne = res - 1.0;
vec3 probeSpacing = gridRange / resMinusOne;
vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;
vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );
uvw = uvw * resMinusOne / res + 0.5 / res;
float nz = res.z;
float paddedSlices = nz + 2.0;
float atlasDepth = 7.0 * paddedSlices;
float uvZBase = uvw.z * nz + 1.0;
vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );
vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );
vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );
vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );
vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );
vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );
vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );
vec3 c0 = s0.xyz;
vec3 c1 = vec3( s0.w, s1.xy );
vec3 c2 = vec3( s1.zw, s2.x );
vec3 c3 = s2.yzw;
vec3 c4 = s3.xyz;
vec3 c5 = vec3( s3.w, s4.xy );
vec3 c6 = vec3( s4.zw, s5.x );
vec3 c7 = s5.yzw;
vec3 c8 = s6.xyz;
float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;
vec3 result = c0 * 0.886227;
result += c1 * 2.0 * 0.511664 * y;
result += c2 * 2.0 * 0.511664 * z;
result += c3 * 2.0 * 0.511664 * x;
result += c4 * 2.0 * 0.429043 * x * y;
result += c5 * 2.0 * 0.429043 * y * z;
result += c6 * ( 0.743125 * z * z - 0.247708 );
result += c7 * 2.0 * 0.429043 * x * z;
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
#endif`,CA=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,wA=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,RA=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,DA=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,NA=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,UA=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,LA=`#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`,OA=`#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`,PA=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,IA=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,BA=`#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`,FA=`#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`,zA=`#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`,HA=`#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`,GA=`#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`,VA=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal *= faceDirection;
#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
#ifdef USE_TANGENT
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn = getTangentFrame( - vViewPosition, normal,
#if defined( USE_NORMALMAP )
vNormalMapUv
#elif defined( USE_CLEARCOAT_NORMALMAP )
vClearcoatNormalMapUv
#else
vUv
#endif
);
#endif
#ifdef DOUBLE_SIDED
tbn[0] *= faceDirection;
tbn[1] *= faceDirection;
#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
#ifdef USE_TANGENT
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
#endif
#ifdef DOUBLE_SIDED
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
vec3 nonPerturbedNormal = normal;`,kA=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#if defined( USE_PACKED_NORMALMAP )
mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );
#endif
mapN.xy *= normalScale;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,jA=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,XA=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,WA=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#ifdef FLIP_SIDED
vBitangent = - vBitangent;
#endif
#endif
#endif`,qA=`#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`,YA=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,ZA=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,KA=`#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`,$A=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,QA=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,JA=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
if( v <= 0.0 )
return vec4( 0., 0., 0., 0. );
if( v >= 1.0 )
return vec4( 1., 1., 1., 1. );
float vuf;
float af = modf( v * PackFactors.a, vuf );
float bf = modf( vuf * ShiftRight8, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
if( v <= 0.0 )
return vec3( 0., 0., 0. );
if( v >= 1.0 )
return vec3( 1., 1., 1. );
float vuf;
float bf = modf( v * PackFactors.b, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
if( v <= 0.0 )
return vec2( 0., 0. );
if( v >= 1.0 )
return vec2( 1., 1. );
float vuf;
float gf = modf( v * 256., vuf );
return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
return depth * ( far - near ) - far;
#else
return depth * ( near - far ) - near;
#endif
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
return ( near * far ) / ( ( near - far ) * depth - near );
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
}`,e1=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,t1=`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;`,n1=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,i1=`#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`,a1=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,s1=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,r1=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
#else
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
#endif
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
#else
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
#elif defined( SHADOWMAP_TYPE_BASIC )
uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
#endif
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
#if defined( SHADOWMAP_TYPE_PCF )
float interleavedGradientNoise( vec2 position ) {
return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
}
vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
const float goldenAngle = 2.399963229728653;
float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
float theta = float( sampleIndex ) * goldenAngle + phi;
return vec2( cos( theta ), sin( theta ) ) * r;
}
#endif
#if defined( SHADOWMAP_TYPE_PCF )
float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float radius = shadowRadius * texelSize.x;
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
shadow = (
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
) * 0.2;
}
return mix( 1.0, shadow, shadowIntensity );
}
#elif defined( SHADOWMAP_TYPE_VSM )
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadowCoord.z -= shadowBias;
#else
shadowCoord.z += shadowBias;
#endif
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
float mean = distribution.x;
float variance = distribution.y * distribution.y;
#ifdef USE_REVERSED_DEPTH_BUFFER
float hard_shadow = step( mean, shadowCoord.z );
#else
float hard_shadow = step( shadowCoord.z, mean );
#endif
if ( hard_shadow == 1.0 ) {
shadow = 1.0;
} else {
variance = max( variance, 0.0000001 );
float d = shadowCoord.z - mean;
float p_max = variance / ( variance + d * d );
p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
shadow = max( hard_shadow, p_max );
}
}
return mix( 1.0, shadow, shadowIntensity );
}
#else
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadowCoord.z -= shadowBias;
#else
shadowCoord.z += shadowBias;
#endif
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
float depth = texture2D( shadowMap, shadowCoord.xy ).r;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadow = step( depth, shadowCoord.z );
#else
shadow = step( shadowCoord.z, depth );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
vec3 bd3D = normalize( lightToPosition );
vec3 absVec = abs( lightToPosition );
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp -= shadowBias;
#else
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp += shadowBias;
#endif
float texelSize = shadowRadius / shadowMapSize.x;
vec3 absDir = abs( bd3D );
vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
tangent = normalize( cross( bd3D, tangent ) );
vec3 bitangent = cross( bd3D, tangent );
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;
vec2 sample0 = vogelDiskSample( 0, 5, phi );
vec2 sample1 = vogelDiskSample( 1, 5, phi );
vec2 sample2 = vogelDiskSample( 2, 5, phi );
vec2 sample3 = vogelDiskSample( 3, 5, phi );
vec2 sample4 = vogelDiskSample( 4, 5, phi );
shadow = (
texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )
) * 0.2;
}
return mix( 1.0, shadow, shadowIntensity );
}
#elif defined( SHADOWMAP_TYPE_BASIC )
float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
vec3 absVec = abs( lightToPosition );
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
float depth = textureCube( shadowMap, bd3D ).r;
#ifdef USE_REVERSED_DEPTH_BUFFER
depth = 1.0 - depth;
#endif
shadow = step( dp, depth );
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif
#endif
#endif`,o1=`#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`,l1=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
#ifdef HAS_NORMAL
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
#else
vec3 shadowWorldNormal = vec3( 0.0 );
#endif
vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
shadowWorldPosition = worldPosition;
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
#endif
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif`,c1=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
PointLightShadow pointLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
#endif
return shadow;
}`,u1=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,d1=`#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`,f1=`#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`,h1=`#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`,p1=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,m1=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,g1=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,_1=`#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; }`,v1=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
material.attenuationDistance = attenuationDistance;
material.attenuationColor = attenuationColor;
#ifdef USE_TRANSMISSIONMAP
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
#endif
#ifdef USE_THICKNESSMAP
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,x1=`#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`,y1=`#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`,S1=`#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`,b1=`#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`,M1=`#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 E1=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,T1=`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>
}`,A1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,C1=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,w1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,R1=`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>
}`,D1=`#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;
}`,N1=`#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
}`,U1=`#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;
}`,L1=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#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 = vec4( dist, 0.0, 0.0, 1.0 );
}`,O1=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,P1=`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>
}`,I1=`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>
}`,B1=`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>
}`,F1=`#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>
}`,z1=`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>
}`,H1=`#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>
}`,G1=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#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 <emissivemap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <envmap_physical_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>
}`,V1=`#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;
}`,k1=`#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>
}`,j1=`#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
}`,X1=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#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( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,W1=`#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>
}`,q1=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#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 <emissivemap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <envmap_physical_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>
}`,Y1=`#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
}`,Z1=`#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 <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
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
#endif
#ifdef USE_CLEARCOAT
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
#endif
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,K1=`#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>
}`,$1=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#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 <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>
}`,Q1=`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>
}`,J1=`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>
}`,eC=`#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>
}`,tC=`uniform vec3 color;
uniform float opacity;
#include <common>
#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>
#include <premultiplied_alpha_fragment>
}`,nC=`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>
}`,iC=`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>
}`,Ct={alphahash_fragment:ET,alphahash_pars_fragment:TT,alphamap_fragment:AT,alphamap_pars_fragment:CT,alphatest_fragment:wT,alphatest_pars_fragment:RT,aomap_fragment:DT,aomap_pars_fragment:NT,batching_pars_vertex:UT,batching_vertex:LT,begin_vertex:OT,beginnormal_vertex:PT,bsdfs:IT,iridescence_fragment:BT,bumpmap_pars_fragment:FT,clipping_planes_fragment:zT,clipping_planes_pars_fragment:HT,clipping_planes_pars_vertex:GT,clipping_planes_vertex:VT,color_fragment:kT,color_pars_fragment:jT,color_pars_vertex:XT,color_vertex:WT,common:qT,cube_uv_reflection_fragment:YT,defaultnormal_vertex:ZT,displacementmap_pars_vertex:KT,displacementmap_vertex:$T,emissivemap_fragment:QT,emissivemap_pars_fragment:JT,colorspace_fragment:eA,colorspace_pars_fragment:tA,envmap_fragment:nA,envmap_common_pars_fragment:iA,envmap_pars_fragment:aA,envmap_pars_vertex:sA,envmap_physical_pars_fragment:gA,envmap_vertex:rA,fog_vertex:oA,fog_pars_vertex:lA,fog_fragment:cA,fog_pars_fragment:uA,gradientmap_pars_fragment:dA,lightmap_pars_fragment:fA,lights_lambert_fragment:hA,lights_lambert_pars_fragment:pA,lights_pars_begin:mA,lights_toon_fragment:_A,lights_toon_pars_fragment:vA,lights_phong_fragment:xA,lights_phong_pars_fragment:yA,lights_physical_fragment:SA,lights_physical_pars_fragment:bA,lights_fragment_begin:MA,lights_fragment_maps:EA,lights_fragment_end:TA,lightprobes_pars_fragment:AA,logdepthbuf_fragment:CA,logdepthbuf_pars_fragment:wA,logdepthbuf_pars_vertex:RA,logdepthbuf_vertex:DA,map_fragment:NA,map_pars_fragment:UA,map_particle_fragment:LA,map_particle_pars_fragment:OA,metalnessmap_fragment:PA,metalnessmap_pars_fragment:IA,morphinstance_vertex:BA,morphcolor_vertex:FA,morphnormal_vertex:zA,morphtarget_pars_vertex:HA,morphtarget_vertex:GA,normal_fragment_begin:VA,normal_fragment_maps:kA,normal_pars_fragment:jA,normal_pars_vertex:XA,normal_vertex:WA,normalmap_pars_fragment:qA,clearcoat_normal_fragment_begin:YA,clearcoat_normal_fragment_maps:ZA,clearcoat_pars_fragment:KA,iridescence_pars_fragment:$A,opaque_fragment:QA,packing:JA,premultiplied_alpha_fragment:e1,project_vertex:t1,dithering_fragment:n1,dithering_pars_fragment:i1,roughnessmap_fragment:a1,roughnessmap_pars_fragment:s1,shadowmap_pars_fragment:r1,shadowmap_pars_vertex:o1,shadowmap_vertex:l1,shadowmask_pars_fragment:c1,skinbase_vertex:u1,skinning_pars_vertex:d1,skinning_vertex:f1,skinnormal_vertex:h1,specularmap_fragment:p1,specularmap_pars_fragment:m1,tonemapping_fragment:g1,tonemapping_pars_fragment:_1,transmission_fragment:v1,transmission_pars_fragment:x1,uv_pars_fragment:y1,uv_pars_vertex:S1,uv_vertex:b1,worldpos_vertex:M1,background_vert:E1,background_frag:T1,backgroundCube_vert:A1,backgroundCube_frag:C1,cube_vert:w1,cube_frag:R1,depth_vert:D1,depth_frag:N1,distance_vert:U1,distance_frag:L1,equirect_vert:O1,equirect_frag:P1,linedashed_vert:I1,linedashed_frag:B1,meshbasic_vert:F1,meshbasic_frag:z1,meshlambert_vert:H1,meshlambert_frag:G1,meshmatcap_vert:V1,meshmatcap_frag:k1,meshnormal_vert:j1,meshnormal_frag:X1,meshphong_vert:W1,meshphong_frag:q1,meshphysical_vert:Y1,meshphysical_frag:Z1,meshtoon_vert:K1,meshtoon_frag:$1,points_vert:Q1,points_frag:J1,shadow_vert:eC,shadow_frag:tC,sprite_vert:nC,sprite_frag:iC},Ye={common:{diffuse:{value:new ct(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new St},alphaMap:{value:null},alphaMapTransform:{value:new St},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new St}},envmap:{envMap:{value:null},envMapRotation:{value:new St},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new St}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new St}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new St},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new St},normalScale:{value:new bt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new St},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new St}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new St}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new St}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ct(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new se},probesMax:{value:new se},probesResolution:{value:new se}},points:{diffuse:{value:new ct(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new St},alphaTest:{value:0},uvTransform:{value:new St}},sprite:{diffuse:{value:new ct(16777215)},opacity:{value:1},center:{value:new bt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new St},alphaMap:{value:null},alphaMapTransform:{value:new St},alphaTest:{value:0}}},ca={basic:{uniforms:Zn([Ye.common,Ye.specularmap,Ye.envmap,Ye.aomap,Ye.lightmap,Ye.fog]),vertexShader:Ct.meshbasic_vert,fragmentShader:Ct.meshbasic_frag},lambert:{uniforms:Zn([Ye.common,Ye.specularmap,Ye.envmap,Ye.aomap,Ye.lightmap,Ye.emissivemap,Ye.bumpmap,Ye.normalmap,Ye.displacementmap,Ye.fog,Ye.lights,{emissive:{value:new ct(0)},envMapIntensity:{value:1}}]),vertexShader:Ct.meshlambert_vert,fragmentShader:Ct.meshlambert_frag},phong:{uniforms:Zn([Ye.common,Ye.specularmap,Ye.envmap,Ye.aomap,Ye.lightmap,Ye.emissivemap,Ye.bumpmap,Ye.normalmap,Ye.displacementmap,Ye.fog,Ye.lights,{emissive:{value:new ct(0)},specular:{value:new ct(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ct.meshphong_vert,fragmentShader:Ct.meshphong_frag},standard:{uniforms:Zn([Ye.common,Ye.envmap,Ye.aomap,Ye.lightmap,Ye.emissivemap,Ye.bumpmap,Ye.normalmap,Ye.displacementmap,Ye.roughnessmap,Ye.metalnessmap,Ye.fog,Ye.lights,{emissive:{value:new ct(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ct.meshphysical_vert,fragmentShader:Ct.meshphysical_frag},toon:{uniforms:Zn([Ye.common,Ye.aomap,Ye.lightmap,Ye.emissivemap,Ye.bumpmap,Ye.normalmap,Ye.displacementmap,Ye.gradientmap,Ye.fog,Ye.lights,{emissive:{value:new ct(0)}}]),vertexShader:Ct.meshtoon_vert,fragmentShader:Ct.meshtoon_frag},matcap:{uniforms:Zn([Ye.common,Ye.bumpmap,Ye.normalmap,Ye.displacementmap,Ye.fog,{matcap:{value:null}}]),vertexShader:Ct.meshmatcap_vert,fragmentShader:Ct.meshmatcap_frag},points:{uniforms:Zn([Ye.points,Ye.fog]),vertexShader:Ct.points_vert,fragmentShader:Ct.points_frag},dashed:{uniforms:Zn([Ye.common,Ye.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ct.linedashed_vert,fragmentShader:Ct.linedashed_frag},depth:{uniforms:Zn([Ye.common,Ye.displacementmap]),vertexShader:Ct.depth_vert,fragmentShader:Ct.depth_frag},normal:{uniforms:Zn([Ye.common,Ye.bumpmap,Ye.normalmap,Ye.displacementmap,{opacity:{value:1}}]),vertexShader:Ct.meshnormal_vert,fragmentShader:Ct.meshnormal_frag},sprite:{uniforms:Zn([Ye.sprite,Ye.fog]),vertexShader:Ct.sprite_vert,fragmentShader:Ct.sprite_frag},background:{uniforms:{uvTransform:{value:new St},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ct.background_vert,fragmentShader:Ct.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new St}},vertexShader:Ct.backgroundCube_vert,fragmentShader:Ct.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ct.cube_vert,fragmentShader:Ct.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ct.equirect_vert,fragmentShader:Ct.equirect_frag},distance:{uniforms:Zn([Ye.common,Ye.displacementmap,{referencePosition:{value:new se},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ct.distance_vert,fragmentShader:Ct.distance_frag},shadow:{uniforms:Zn([Ye.lights,Ye.fog,{color:{value:new ct(0)},opacity:{value:1}}]),vertexShader:Ct.shadow_vert,fragmentShader:Ct.shadow_frag}};ca.physical={uniforms:Zn([ca.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new St},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new St},clearcoatNormalScale:{value:new bt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new St},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new St},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new St},sheen:{value:0},sheenColor:{value:new ct(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new St},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new St},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new St},transmissionSamplerSize:{value:new bt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new St},attenuationDistance:{value:0},attenuationColor:{value:new ct(0)},specularColor:{value:new ct(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new St},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new St},anisotropyVector:{value:new bt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new St}}]),vertexShader:Ct.meshphysical_vert,fragmentShader:Ct.meshphysical_frag};const xu={r:0,b:0,g:0},aC=new cn,Cy=new St;Cy.set(-1,0,0,0,1,0,0,0,1);function sC(a,e,n,s,l,c){const d=new ct(0);let p=l===!0?0:1,m,h,v=null,S=0,_=null;function M(P){let O=P.isScene===!0?P.background:null;if(O&&O.isTexture){const R=P.backgroundBlurriness>0;O=e.get(O,R)}return O}function E(P){let O=!1;const R=M(P);R===null?y(d,p):R&&R.isColor&&(y(R,1),O=!0);const I=a.xr.getEnvironmentBlendMode();I==="additive"?n.buffers.color.setClear(0,0,0,1,c):I==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,c),(a.autoClear||O)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil))}function C(P,O){const R=M(O);R&&(R.isCubeTexture||R.mapping===Gu)?(h===void 0&&(h=new Ki(new fr(1,1,1),new $i({name:"BackgroundCubeMaterial",uniforms:yo(ca.backgroundCube.uniforms),vertexShader:ca.backgroundCube.vertexShader,fragmentShader:ca.backgroundCube.fragmentShader,side:si,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(I,B,L){this.matrixWorld.copyPosition(L.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),h.material.uniforms.envMap.value=R,h.material.uniforms.backgroundBlurriness.value=O.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=O.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(aC.makeRotationFromEuler(O.backgroundRotation)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&h.material.uniforms.backgroundRotation.value.premultiply(Cy),h.material.toneMapped=zt.getTransfer(R.colorSpace)!==tn,(v!==R||S!==R.version||_!==a.toneMapping)&&(h.material.needsUpdate=!0,v=R,S=R.version,_=a.toneMapping),h.layers.enableAll(),P.unshift(h,h.geometry,h.material,0,0,null)):R&&R.isTexture&&(m===void 0&&(m=new Ki(new Vu(2,2),new $i({name:"BackgroundMaterial",uniforms:yo(ca.background.uniforms),vertexShader:ca.background.vertexShader,fragmentShader:ca.background.fragmentShader,side:As,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),m.geometry.deleteAttribute("normal"),Object.defineProperty(m.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(m)),m.material.uniforms.t2D.value=R,m.material.uniforms.backgroundIntensity.value=O.backgroundIntensity,m.material.toneMapped=zt.getTransfer(R.colorSpace)!==tn,R.matrixAutoUpdate===!0&&R.updateMatrix(),m.material.uniforms.uvTransform.value.copy(R.matrix),(v!==R||S!==R.version||_!==a.toneMapping)&&(m.material.needsUpdate=!0,v=R,S=R.version,_=a.toneMapping),m.layers.enableAll(),P.unshift(m,m.geometry,m.material,0,0,null))}function y(P,O){P.getRGB(xu,Ey(a)),n.buffers.color.setClear(xu.r,xu.g,xu.b,O,c)}function x(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),m!==void 0&&(m.geometry.dispose(),m.material.dispose(),m=void 0)}return{getClearColor:function(){return d},setClearColor:function(P,O=1){d.set(P),p=O,y(d,p)},getClearAlpha:function(){return p},setClearAlpha:function(P){p=P,y(d,p)},render:E,addToRenderList:C,dispose:x}}function rC(a,e){const n=a.getParameter(a.MAX_VERTEX_ATTRIBS),s={},l=_(null);let c=l,d=!1;function p(G,K,ue,pe,Q){let V=!1;const j=S(G,pe,ue,K);c!==j&&(c=j,h(c.object)),V=M(G,pe,ue,Q),V&&E(G,pe,ue,Q),Q!==null&&e.update(Q,a.ELEMENT_ARRAY_BUFFER),(V||d)&&(d=!1,R(G,K,ue,pe),Q!==null&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,e.get(Q).buffer))}function m(){return a.createVertexArray()}function h(G){return a.bindVertexArray(G)}function v(G){return a.deleteVertexArray(G)}function S(G,K,ue,pe){const Q=pe.wireframe===!0;let V=s[K.id];V===void 0&&(V={},s[K.id]=V);const j=G.isInstancedMesh===!0?G.id:0;let ae=V[j];ae===void 0&&(ae={},V[j]=ae);let _e=ae[ue.id];_e===void 0&&(_e={},ae[ue.id]=_e);let ve=_e[Q];return ve===void 0&&(ve=_(m()),_e[Q]=ve),ve}function _(G){const K=[],ue=[],pe=[];for(let Q=0;Q<n;Q++)K[Q]=0,ue[Q]=0,pe[Q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:K,enabledAttributes:ue,attributeDivisors:pe,object:G,attributes:{},index:null}}function M(G,K,ue,pe){const Q=c.attributes,V=K.attributes;let j=0;const ae=ue.getAttributes();for(const _e in ae)if(ae[_e].location>=0){const H=Q[_e];let te=V[_e];if(te===void 0&&(_e==="instanceMatrix"&&G.instanceMatrix&&(te=G.instanceMatrix),_e==="instanceColor"&&G.instanceColor&&(te=G.instanceColor)),H===void 0||H.attribute!==te||te&&H.data!==te.data)return!0;j++}return c.attributesNum!==j||c.index!==pe}function E(G,K,ue,pe){const Q={},V=K.attributes;let j=0;const ae=ue.getAttributes();for(const _e in ae)if(ae[_e].location>=0){let H=V[_e];H===void 0&&(_e==="instanceMatrix"&&G.instanceMatrix&&(H=G.instanceMatrix),_e==="instanceColor"&&G.instanceColor&&(H=G.instanceColor));const te={};te.attribute=H,H&&H.data&&(te.data=H.data),Q[_e]=te,j++}c.attributes=Q,c.attributesNum=j,c.index=pe}function C(){const G=c.newAttributes;for(let K=0,ue=G.length;K<ue;K++)G[K]=0}function y(G){x(G,0)}function x(G,K){const ue=c.newAttributes,pe=c.enabledAttributes,Q=c.attributeDivisors;ue[G]=1,pe[G]===0&&(a.enableVertexAttribArray(G),pe[G]=1),Q[G]!==K&&(a.vertexAttribDivisor(G,K),Q[G]=K)}function P(){const G=c.newAttributes,K=c.enabledAttributes;for(let ue=0,pe=K.length;ue<pe;ue++)K[ue]!==G[ue]&&(a.disableVertexAttribArray(ue),K[ue]=0)}function O(G,K,ue,pe,Q,V,j){j===!0?a.vertexAttribIPointer(G,K,ue,Q,V):a.vertexAttribPointer(G,K,ue,pe,Q,V)}function R(G,K,ue,pe){C();const Q=pe.attributes,V=ue.getAttributes(),j=K.defaultAttributeValues;for(const ae in V){const _e=V[ae];if(_e.location>=0){let ve=Q[ae];if(ve===void 0&&(ae==="instanceMatrix"&&G.instanceMatrix&&(ve=G.instanceMatrix),ae==="instanceColor"&&G.instanceColor&&(ve=G.instanceColor)),ve!==void 0){const H=ve.normalized,te=ve.itemSize,Ee=e.get(ve);if(Ee===void 0)continue;const Le=Ee.buffer,Fe=Ee.type,oe=Ee.bytesPerElement,Me=Fe===a.INT||Fe===a.UNSIGNED_INT||ve.gpuType===Zp;if(ve.isInterleavedBufferAttribute){const Ae=ve.data,ze=Ae.stride,at=ve.offset;if(Ae.isInstancedInterleavedBuffer){for(let Je=0;Je<_e.locationSize;Je++)x(_e.location+Je,Ae.meshPerAttribute);G.isInstancedMesh!==!0&&pe._maxInstanceCount===void 0&&(pe._maxInstanceCount=Ae.meshPerAttribute*Ae.count)}else for(let Je=0;Je<_e.locationSize;Je++)y(_e.location+Je);a.bindBuffer(a.ARRAY_BUFFER,Le);for(let Je=0;Je<_e.locationSize;Je++)O(_e.location+Je,te/_e.locationSize,Fe,H,ze*oe,(at+te/_e.locationSize*Je)*oe,Me)}else{if(ve.isInstancedBufferAttribute){for(let Ae=0;Ae<_e.locationSize;Ae++)x(_e.location+Ae,ve.meshPerAttribute);G.isInstancedMesh!==!0&&pe._maxInstanceCount===void 0&&(pe._maxInstanceCount=ve.meshPerAttribute*ve.count)}else for(let Ae=0;Ae<_e.locationSize;Ae++)y(_e.location+Ae);a.bindBuffer(a.ARRAY_BUFFER,Le);for(let Ae=0;Ae<_e.locationSize;Ae++)O(_e.location+Ae,te/_e.locationSize,Fe,H,te*oe,te/_e.locationSize*Ae*oe,Me)}}else if(j!==void 0){const H=j[ae];if(H!==void 0)switch(H.length){case 2:a.vertexAttrib2fv(_e.location,H);break;case 3:a.vertexAttrib3fv(_e.location,H);break;case 4:a.vertexAttrib4fv(_e.location,H);break;default:a.vertexAttrib1fv(_e.location,H)}}}}P()}function I(){U();for(const G in s){const K=s[G];for(const ue in K){const pe=K[ue];for(const Q in pe){const V=pe[Q];for(const j in V)v(V[j].object),delete V[j];delete pe[Q]}}delete s[G]}}function B(G){if(s[G.id]===void 0)return;const K=s[G.id];for(const ue in K){const pe=K[ue];for(const Q in pe){const V=pe[Q];for(const j in V)v(V[j].object),delete V[j];delete pe[Q]}}delete s[G.id]}function L(G){for(const K in s){const ue=s[K];for(const pe in ue){const Q=ue[pe];if(Q[G.id]===void 0)continue;const V=Q[G.id];for(const j in V)v(V[j].object),delete V[j];delete Q[G.id]}}}function T(G){for(const K in s){const ue=s[K],pe=G.isInstancedMesh===!0?G.id:0,Q=ue[pe];if(Q!==void 0){for(const V in Q){const j=Q[V];for(const ae in j)v(j[ae].object),delete j[ae];delete Q[V]}delete ue[pe],Object.keys(ue).length===0&&delete s[K]}}}function U(){X(),d=!0,c!==l&&(c=l,h(c.object))}function X(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:p,reset:U,resetDefaultState:X,dispose:I,releaseStatesOfGeometry:B,releaseStatesOfObject:T,releaseStatesOfProgram:L,initAttributes:C,enableAttribute:y,disableUnusedAttributes:P}}function oC(a,e,n){let s;function l(m){s=m}function c(m,h){a.drawArrays(s,m,h),n.update(h,s,1)}function d(m,h,v){v!==0&&(a.drawArraysInstanced(s,m,h,v),n.update(h,s,v))}function p(m,h,v){if(v===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(s,m,0,h,0,v);let _=0;for(let M=0;M<v;M++)_+=h[M];n.update(_,s,1)}this.setMode=l,this.render=c,this.renderInstances=d,this.renderMultiDraw=p}function lC(a,e,n,s){let l;function c(){if(l!==void 0)return l;if(e.has("EXT_texture_filter_anisotropic")===!0){const L=e.get("EXT_texture_filter_anisotropic");l=a.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else l=0;return l}function d(L){return!(L!==qi&&s.convert(L)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_FORMAT))}function p(L){const T=L===ja&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(L!==xi&&s.convert(L)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_TYPE)&&L!==Wi&&!T)}function m(L){if(L==="highp"){if(a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision>0)return"highp";L="mediump"}return L==="mediump"&&a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=n.precision!==void 0?n.precision:"highp";const v=m(h);v!==h&&(mt("WebGLRenderer:",h,"not supported, using",v,"instead."),h=v);const S=n.logarithmicDepthBuffer===!0,_=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control");n.reversedDepthBuffer===!0&&_===!1&&mt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const M=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),E=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),C=a.getParameter(a.MAX_TEXTURE_SIZE),y=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),x=a.getParameter(a.MAX_VERTEX_ATTRIBS),P=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),O=a.getParameter(a.MAX_VARYING_VECTORS),R=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),I=a.getParameter(a.MAX_SAMPLES),B=a.getParameter(a.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:c,getMaxPrecision:m,textureFormatReadable:d,textureTypeReadable:p,precision:h,logarithmicDepthBuffer:S,reversedDepthBuffer:_,maxTextures:M,maxVertexTextures:E,maxTextureSize:C,maxCubemapSize:y,maxAttributes:x,maxVertexUniforms:P,maxVaryings:O,maxFragmentUniforms:R,maxSamples:I,samples:B}}function cC(a){const e=this;let n=null,s=0,l=!1,c=!1;const d=new bs,p=new St,m={value:null,needsUpdate:!1};this.uniform=m,this.numPlanes=0,this.numIntersection=0,this.init=function(S,_){const M=S.length!==0||_||s!==0||l;return l=_,s=S.length,M},this.beginShadows=function(){c=!0,v(null)},this.endShadows=function(){c=!1},this.setGlobalState=function(S,_){n=v(S,_,0)},this.setState=function(S,_,M){const E=S.clippingPlanes,C=S.clipIntersection,y=S.clipShadows,x=a.get(S);if(!l||E===null||E.length===0||c&&!y)c?v(null):h();else{const P=c?0:s,O=P*4;let R=x.clippingState||null;m.value=R,R=v(E,_,O,M);for(let I=0;I!==O;++I)R[I]=n[I];x.clippingState=R,this.numIntersection=C?this.numPlanes:0,this.numPlanes+=P}};function h(){m.value!==n&&(m.value=n,m.needsUpdate=s>0),e.numPlanes=s,e.numIntersection=0}function v(S,_,M,E){const C=S!==null?S.length:0;let y=null;if(C!==0){if(y=m.value,E!==!0||y===null){const x=M+C*4,P=_.matrixWorldInverse;p.getNormalMatrix(P),(y===null||y.length<x)&&(y=new Float32Array(x));for(let O=0,R=M;O!==C;++O,R+=4)d.copy(S[O]).applyMatrix4(P,p),d.normal.toArray(y,R),y[R+3]=d.constant}m.value=y,m.needsUpdate=!0}return e.numPlanes=C,e.numIntersection=0,y}}const Es=4,ex=[.125,.215,.35,.446,.526,.582],Js=20,uC=256,Sl=new cm,tx=new ct;let Oh=null,Ph=0,Ih=0,Bh=!1;const dC=new se;class nx{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,n=0,s=.1,l=100,c={}){const{size:d=256,position:p=dC}=c;Oh=this._renderer.getRenderTarget(),Ph=this._renderer.getActiveCubeFace(),Ih=this._renderer.getActiveMipmapLevel(),Bh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(d);const m=this._allocateTargets();return m.depthBuffer=!0,this._sceneToCubeUV(e,s,l,m,p),n>0&&this._blur(m,0,0,n),this._applyPMREM(m),this._cleanup(m),m}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=sx(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ax(),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(Oh,Ph,Ih),this._renderer.xr.enabled=Bh,e.scissorTest=!1,ro(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===sr||e.mapping===vo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Oh=this._renderer.getRenderTarget(),Ph=this._renderer.getActiveCubeFace(),Ih=this._renderer.getActiveMipmapLevel(),Bh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const s=n||this._allocateTargets();return this._textureToCubeUV(e,s),this._applyPMREM(s),this._cleanup(s),s}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,s={magFilter:qn,minFilter:qn,generateMipmaps:!1,type:ja,format:qi,colorSpace:Lu,depthBuffer:!1},l=ix(e,n,s);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=ix(e,n,s);const{_lodMax:c}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=fC(c)),this._blurMaterial=pC(c,e,n),this._ggxMaterial=hC(c,e,n)}return l}_compileMaterial(e){const n=new Ki(new Li,e);this._renderer.compile(n,Sl)}_sceneToCubeUV(e,n,s,l,c){const m=new Ni(90,1,n,s),h=[1,-1,1,1,1,1],v=[1,1,1,-1,-1,-1],S=this._renderer,_=S.autoClear,M=S.toneMapping;S.getClearColor(tx),S.toneMapping=da,S.autoClear=!1,S.state.buffers.depth.getReversed()&&(S.setRenderTarget(l),S.clearDepth(),S.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ki(new fr,new xy({name:"PMREM.Background",side:si,depthWrite:!1,depthTest:!1})));const C=this._backgroundBox,y=C.material;let x=!1;const P=e.background;P?P.isColor&&(y.color.copy(P),e.background=null,x=!0):(y.color.copy(tx),x=!0);for(let O=0;O<6;O++){const R=O%3;R===0?(m.up.set(0,h[O],0),m.position.set(c.x,c.y,c.z),m.lookAt(c.x+v[O],c.y,c.z)):R===1?(m.up.set(0,0,h[O]),m.position.set(c.x,c.y,c.z),m.lookAt(c.x,c.y+v[O],c.z)):(m.up.set(0,h[O],0),m.position.set(c.x,c.y,c.z),m.lookAt(c.x,c.y,c.z+v[O]));const I=this._cubeSize;ro(l,R*I,O>2?I:0,I,I),S.setRenderTarget(l),x&&S.render(C,m),S.render(e,m)}S.toneMapping=M,S.autoClear=_,e.background=P}_textureToCubeUV(e,n){const s=this._renderer,l=e.mapping===sr||e.mapping===vo;l?(this._cubemapMaterial===null&&(this._cubemapMaterial=sx()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ax());const c=l?this._cubemapMaterial:this._equirectMaterial,d=this._lodMeshes[0];d.material=c;const p=c.uniforms;p.envMap.value=e;const m=this._cubeSize;ro(n,0,0,3*m,2*m),s.setRenderTarget(n),s.render(d,Sl)}_applyPMREM(e){const n=this._renderer,s=n.autoClear;n.autoClear=!1;const l=this._lodMeshes.length;for(let c=1;c<l;c++)this._applyGGXFilter(e,c-1,c);n.autoClear=s}_applyGGXFilter(e,n,s){const l=this._renderer,c=this._pingPongRenderTarget,d=this._ggxMaterial,p=this._lodMeshes[s];p.material=d;const m=d.uniforms,h=s/(this._lodMeshes.length-1),v=n/(this._lodMeshes.length-1),S=Math.sqrt(h*h-v*v),_=0+h*1.25,M=S*_,{_lodMax:E}=this,C=this._sizeLods[s],y=3*C*(s>E-Es?s-E+Es:0),x=4*(this._cubeSize-C);m.envMap.value=e.texture,m.roughness.value=M,m.mipInt.value=E-n,ro(c,y,x,3*C,2*C),l.setRenderTarget(c),l.render(p,Sl),m.envMap.value=c.texture,m.roughness.value=0,m.mipInt.value=E-s,ro(e,y,x,3*C,2*C),l.setRenderTarget(e),l.render(p,Sl)}_blur(e,n,s,l,c){const d=this._pingPongRenderTarget;this._halfBlur(e,d,n,s,l,"latitudinal",c),this._halfBlur(d,e,s,s,l,"longitudinal",c)}_halfBlur(e,n,s,l,c,d,p){const m=this._renderer,h=this._blurMaterial;d!=="latitudinal"&&d!=="longitudinal"&&kt("blur direction must be either latitudinal or longitudinal!");const v=3,S=this._lodMeshes[l];S.material=h;const _=h.uniforms,M=this._sizeLods[s]-1,E=isFinite(c)?Math.PI/(2*M):2*Math.PI/(2*Js-1),C=c/E,y=isFinite(c)?1+Math.floor(v*C):Js;y>Js&&mt(`sigmaRadians, ${c}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Js}`);const x=[];let P=0;for(let L=0;L<Js;++L){const T=L/C,U=Math.exp(-T*T/2);x.push(U),L===0?P+=U:L<y&&(P+=2*U)}for(let L=0;L<x.length;L++)x[L]=x[L]/P;_.envMap.value=e.texture,_.samples.value=y,_.weights.value=x,_.latitudinal.value=d==="latitudinal",p&&(_.poleAxis.value=p);const{_lodMax:O}=this;_.dTheta.value=E,_.mipInt.value=O-s;const R=this._sizeLods[l],I=3*R*(l>O-Es?l-O+Es:0),B=4*(this._cubeSize-R);ro(n,I,B,3*R,2*R),m.setRenderTarget(n),m.render(S,Sl)}}function fC(a){const e=[],n=[],s=[];let l=a;const c=a-Es+1+ex.length;for(let d=0;d<c;d++){const p=Math.pow(2,l);e.push(p);let m=1/p;d>a-Es?m=ex[d-a+Es-1]:d===0&&(m=0),n.push(m);const h=1/(p-2),v=-h,S=1+h,_=[v,v,S,v,S,S,v,v,S,S,v,S],M=6,E=6,C=3,y=2,x=1,P=new Float32Array(C*E*M),O=new Float32Array(y*E*M),R=new Float32Array(x*E*M);for(let B=0;B<M;B++){const L=B%3*2/3-1,T=B>2?0:-1,U=[L,T,0,L+2/3,T,0,L+2/3,T+1,0,L,T,0,L+2/3,T+1,0,L,T+1,0];P.set(U,C*E*B),O.set(_,y*E*B);const X=[B,B,B,B,B,B];R.set(X,x*E*B)}const I=new Li;I.setAttribute("position",new Yi(P,C)),I.setAttribute("uv",new Yi(O,y)),I.setAttribute("faceIndex",new Yi(R,x)),s.push(new Ki(I,null)),l>Es&&l--}return{lodMeshes:s,sizeLods:e,sigmas:n}}function ix(a,e,n){const s=new fa(a,e,n);return s.texture.mapping=Gu,s.texture.name="PMREM.cubeUv",s.scissorTest=!0,s}function ro(a,e,n,s,l){a.viewport.set(e,n,s,l),a.scissor.set(e,n,s,l)}function hC(a,e,n){return new $i({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:uC,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ku(),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 4.1: Orthonormal basis
vec3 T1 = vec3(1.0, 0.0, 0.0);
vec3 T2 = cross(V, T1);
// Section 4.2: Parameterization of projected area
float r = sqrt(Xi.x);
float phi = 2.0 * PI * Xi.y;
float t1 = r * cos(phi);
float t2 = r * sin(phi);
float s = 0.5 * (1.0 + V.z);
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
// Section 4.3: Reprojection onto hemisphere
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
// Section 3.4: Transform back to ellipsoid configuration
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
}
void main() {
vec3 N = normalize(vOutputDirection);
vec3 V = N; // Assume view direction equals normal for pre-filtering
vec3 prefilteredColor = vec3(0.0);
float totalWeight = 0.0;
// For very low roughness, just sample the environment directly
if (roughness < 0.001) {
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
return;
}
// Tangent space basis for VNDF sampling
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
vec3 tangent = normalize(cross(up, N));
vec3 bitangent = cross(N, tangent);
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
// Transform H back to world space
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
vec3 L = normalize(2.0 * dot(V, H) * H - V);
float NdotL = max(dot(N, L), 0.0);
if(NdotL > 0.0) {
// Sample environment at fixed mip level
// VNDF importance sampling handles the distribution filtering
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
// Weight by NdotL for the split-sum approximation
// VNDF PDF naturally accounts for the visible microfacet distribution
prefilteredColor += sampleColor * NdotL;
totalWeight += NdotL;
}
}
if (totalWeight > 0.0) {
prefilteredColor = prefilteredColor / totalWeight;
}
gl_FragColor = vec4(prefilteredColor, 1.0);
}
`,blending:Va,depthTest:!1,depthWrite:!1})}function pC(a,e,n){const s=new Float32Array(Js),l=new se(0,1,0);return new $i({name:"SphericalGaussianBlur",defines:{n:Js,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:s},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:l}},vertexShader:ku(),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:Va,depthTest:!1,depthWrite:!1})}function ax(){return new $i({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ku(),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:Va,depthTest:!1,depthWrite:!1})}function sx(){return new $i({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ku(),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:Va,depthTest:!1,depthWrite:!1})}function ku(){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 );
}
`}class wy extends fa{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const s={width:e,height:e,depth:1},l=[s,s,s,s,s,s];this.texture=new by(l),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const s={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 );
}
`},l=new fr(5,5,5),c=new $i({name:"CubemapFromEquirect",uniforms:yo(s.uniforms),vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,side:si,blending:Va});c.uniforms.tEquirect.value=n;const d=new Ki(l,c),p=n.minFilter;return n.minFilter===er&&(n.minFilter=qn),new vT(1,10,this).update(e,d),n.minFilter=p,d.geometry.dispose(),d.material.dispose(),this}clear(e,n=!0,s=!0,l=!0){const c=e.getRenderTarget();for(let d=0;d<6;d++)e.setRenderTarget(this,d),e.clear(n,s,l);e.setRenderTarget(c)}}function mC(a){let e=new WeakMap,n=new WeakMap,s=null;function l(_,M=!1){return _==null?null:M?d(_):c(_)}function c(_){if(_&&_.isTexture){const M=_.mapping;if(M===sh||M===rh)if(e.has(_)){const E=e.get(_).texture;return p(E,_.mapping)}else{const E=_.image;if(E&&E.height>0){const C=new wy(E.height);return C.fromEquirectangularTexture(a,_),e.set(_,C),_.addEventListener("dispose",h),p(C.texture,_.mapping)}else return null}}return _}function d(_){if(_&&_.isTexture){const M=_.mapping,E=M===sh||M===rh,C=M===sr||M===vo;if(E||C){let y=n.get(_);const x=y!==void 0?y.texture.pmremVersion:0;if(_.isRenderTargetTexture&&_.pmremVersion!==x)return s===null&&(s=new nx(a)),y=E?s.fromEquirectangular(_,y):s.fromCubemap(_,y),y.texture.pmremVersion=_.pmremVersion,n.set(_,y),y.texture;if(y!==void 0)return y.texture;{const P=_.image;return E&&P&&P.height>0||C&&P&&m(P)?(s===null&&(s=new nx(a)),y=E?s.fromEquirectangular(_):s.fromCubemap(_),y.texture.pmremVersion=_.pmremVersion,n.set(_,y),_.addEventListener("dispose",v),y.texture):null}}}return _}function p(_,M){return M===sh?_.mapping=sr:M===rh&&(_.mapping=vo),_}function m(_){let M=0;const E=6;for(let C=0;C<E;C++)_[C]!==void 0&&M++;return M===E}function h(_){const M=_.target;M.removeEventListener("dispose",h);const E=e.get(M);E!==void 0&&(e.delete(M),E.dispose())}function v(_){const M=_.target;M.removeEventListener("dispose",v);const E=n.get(M);E!==void 0&&(n.delete(M),E.dispose())}function S(){e=new WeakMap,n=new WeakMap,s!==null&&(s.dispose(),s=null)}return{get:l,dispose:S}}function gC(a){const e={};function n(s){if(e[s]!==void 0)return e[s];const l=a.getExtension(s);return e[s]=l,l}return{has:function(s){return n(s)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(s){const l=n(s);return l===null&&ho("WebGLRenderer: "+s+" extension not supported."),l}}}function _C(a,e,n,s){const l={},c=new WeakMap;function d(S){const _=S.target;_.index!==null&&e.remove(_.index);for(const E in _.attributes)e.remove(_.attributes[E]);_.removeEventListener("dispose",d),delete l[_.id];const M=c.get(_);M&&(e.remove(M),c.delete(_)),s.releaseStatesOfGeometry(_),_.isInstancedBufferGeometry===!0&&delete _._maxInstanceCount,n.memory.geometries--}function p(S,_){return l[_.id]===!0||(_.addEventListener("dispose",d),l[_.id]=!0,n.memory.geometries++),_}function m(S){const _=S.attributes;for(const M in _)e.update(_[M],a.ARRAY_BUFFER)}function h(S){const _=[],M=S.index,E=S.attributes.position;let C=0;if(E===void 0)return;if(M!==null){const P=M.array;C=M.version;for(let O=0,R=P.length;O<R;O+=3){const I=P[O+0],B=P[O+1],L=P[O+2];_.push(I,B,B,L,L,I)}}else{const P=E.array;C=E.version;for(let O=0,R=P.length/3-1;O<R;O+=3){const I=O+0,B=O+1,L=O+2;_.push(I,B,B,L,L,I)}}const y=new(E.count>=65535?vy:_y)(_,1);y.version=C;const x=c.get(S);x&&e.remove(x),c.set(S,y)}function v(S){const _=c.get(S);if(_){const M=S.index;M!==null&&_.version<M.version&&h(S)}else h(S);return c.get(S)}return{get:p,update:m,getWireframeAttribute:v}}function vC(a,e,n){let s;function l(S){s=S}let c,d;function p(S){c=S.type,d=S.bytesPerElement}function m(S,_){a.drawElements(s,_,c,S*d),n.update(_,s,1)}function h(S,_,M){M!==0&&(a.drawElementsInstanced(s,_,c,S*d,M),n.update(_,s,M))}function v(S,_,M){if(M===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(s,_,0,c,S,0,M);let C=0;for(let y=0;y<M;y++)C+=_[y];n.update(C,s,1)}this.setMode=l,this.setIndex=p,this.render=m,this.renderInstances=h,this.renderMultiDraw=v}function xC(a){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function s(c,d,p){switch(n.calls++,d){case a.TRIANGLES:n.triangles+=p*(c/3);break;case a.LINES:n.lines+=p*(c/2);break;case a.LINE_STRIP:n.lines+=p*(c-1);break;case a.LINE_LOOP:n.lines+=p*c;break;case a.POINTS:n.points+=p*c;break;default:kt("WebGLInfo: Unknown draw mode:",d);break}}function l(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:l,update:s}}function yC(a,e,n){const s=new WeakMap,l=new pn;function c(d,p,m){const h=d.morphTargetInfluences,v=p.morphAttributes.position||p.morphAttributes.normal||p.morphAttributes.color,S=v!==void 0?v.length:0;let _=s.get(p);if(_===void 0||_.count!==S){let X=function(){T.dispose(),s.delete(p),p.removeEventListener("dispose",X)};var M=X;_!==void 0&&_.texture.dispose();const E=p.morphAttributes.position!==void 0,C=p.morphAttributes.normal!==void 0,y=p.morphAttributes.color!==void 0,x=p.morphAttributes.position||[],P=p.morphAttributes.normal||[],O=p.morphAttributes.color||[];let R=0;E===!0&&(R=1),C===!0&&(R=2),y===!0&&(R=3);let I=p.attributes.position.count*R,B=1;I>e.maxTextureSize&&(B=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const L=new Float32Array(I*B*4*S),T=new py(L,I,B,S);T.type=Wi,T.needsUpdate=!0;const U=R*4;for(let G=0;G<S;G++){const K=x[G],ue=P[G],pe=O[G],Q=I*B*4*G;for(let V=0;V<K.count;V++){const j=V*U;E===!0&&(l.fromBufferAttribute(K,V),L[Q+j+0]=l.x,L[Q+j+1]=l.y,L[Q+j+2]=l.z,L[Q+j+3]=0),C===!0&&(l.fromBufferAttribute(ue,V),L[Q+j+4]=l.x,L[Q+j+5]=l.y,L[Q+j+6]=l.z,L[Q+j+7]=0),y===!0&&(l.fromBufferAttribute(pe,V),L[Q+j+8]=l.x,L[Q+j+9]=l.y,L[Q+j+10]=l.z,L[Q+j+11]=pe.itemSize===4?l.w:1)}}_={count:S,texture:T,size:new bt(I,B)},s.set(p,_),p.addEventListener("dispose",X)}if(d.isInstancedMesh===!0&&d.morphTexture!==null)m.getUniforms().setValue(a,"morphTexture",d.morphTexture,n);else{let E=0;for(let y=0;y<h.length;y++)E+=h[y];const C=p.morphTargetsRelative?1:1-E;m.getUniforms().setValue(a,"morphTargetBaseInfluence",C),m.getUniforms().setValue(a,"morphTargetInfluences",h)}m.getUniforms().setValue(a,"morphTargetsTexture",_.texture,n),m.getUniforms().setValue(a,"morphTargetsTextureSize",_.size)}return{update:c}}function SC(a,e,n,s,l){let c=new WeakMap;function d(h){const v=l.render.frame,S=h.geometry,_=e.get(h,S);if(c.get(_)!==v&&(e.update(_),c.set(_,v)),h.isInstancedMesh&&(h.hasEventListener("dispose",m)===!1&&h.addEventListener("dispose",m),c.get(h)!==v&&(n.update(h.instanceMatrix,a.ARRAY_BUFFER),h.instanceColor!==null&&n.update(h.instanceColor,a.ARRAY_BUFFER),c.set(h,v))),h.isSkinnedMesh){const M=h.skeleton;c.get(M)!==v&&(M.update(),c.set(M,v))}return _}function p(){c=new WeakMap}function m(h){const v=h.target;v.removeEventListener("dispose",m),s.releaseStatesOfObject(v),n.remove(v.instanceMatrix),v.instanceColor!==null&&n.remove(v.instanceColor)}return{update:d,dispose:p}}const bC={[ey]:"LINEAR_TONE_MAPPING",[ty]:"REINHARD_TONE_MAPPING",[ny]:"CINEON_TONE_MAPPING",[Yp]:"ACES_FILMIC_TONE_MAPPING",[ay]:"AGX_TONE_MAPPING",[sy]:"NEUTRAL_TONE_MAPPING",[iy]:"CUSTOM_TONE_MAPPING"};function MC(a,e,n,s,l,c){const d=new fa(e,n,{type:a,depthBuffer:l,stencilBuffer:c,samples:s?4:0,depthTexture:l?new xo(e,n):void 0}),p=new fa(e,n,{type:ja,depthBuffer:!1,stencilBuffer:!1}),m=new Li;m.setAttribute("position",new ri([-1,3,0,-1,-1,0,3,-1,0],3)),m.setAttribute("uv",new ri([0,2,0,0,2,0],2));const h=new dT({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute vec2 uv;
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
precision highp float;
uniform sampler2D tDiffuse;
varying vec2 vUv;
#include <tonemapping_pars_fragment>
#include <colorspace_pars_fragment>
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
#ifdef LINEAR_TONE_MAPPING
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
#elif defined( REINHARD_TONE_MAPPING )
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
#elif defined( CINEON_TONE_MAPPING )
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
#elif defined( ACES_FILMIC_TONE_MAPPING )
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
#elif defined( AGX_TONE_MAPPING )
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
#elif defined( NEUTRAL_TONE_MAPPING )
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
#elif defined( CUSTOM_TONE_MAPPING )
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
#endif
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
}`,depthTest:!1,depthWrite:!1}),v=new Ki(m,h),S=new cm(-1,1,1,-1,0,1);let _=null,M=null,E=!1,C,y=null,x=[],P=!1;this.setSize=function(O,R){d.setSize(O,R),p.setSize(O,R);for(let I=0;I<x.length;I++){const B=x[I];B.setSize&&B.setSize(O,R)}},this.setEffects=function(O){x=O,P=x.length>0&&x[0].isRenderPass===!0;const R=d.width,I=d.height;for(let B=0;B<x.length;B++){const L=x[B];L.setSize&&L.setSize(R,I)}},this.begin=function(O,R){if(E||O.toneMapping===da&&x.length===0)return!1;if(y=R,R!==null){const I=R.width,B=R.height;(d.width!==I||d.height!==B)&&this.setSize(I,B)}return P===!1&&O.setRenderTarget(d),C=O.toneMapping,O.toneMapping=da,!0},this.hasRenderPass=function(){return P},this.end=function(O,R){O.toneMapping=C,E=!0;let I=d,B=p;for(let L=0;L<x.length;L++){const T=x[L];if(T.enabled!==!1&&(T.render(O,B,I,R),T.needsSwap!==!1)){const U=I;I=B,B=U}}if(_!==O.outputColorSpace||M!==O.toneMapping){_=O.outputColorSpace,M=O.toneMapping,h.defines={},zt.getTransfer(_)===tn&&(h.defines.SRGB_TRANSFER="");const L=bC[M];L&&(h.defines[L]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=I.texture,O.setRenderTarget(y),O.render(v,S),y=null,E=!1},this.isCompositing=function(){return E},this.dispose=function(){d.depthTexture&&d.depthTexture.dispose(),d.dispose(),p.dispose(),m.dispose(),h.dispose()}}const Ry=new Kn,Op=new xo(1,1),Dy=new py,Ny=new zE,Uy=new by,rx=[],ox=[],lx=new Float32Array(16),cx=new Float32Array(9),ux=new Float32Array(4);function Mo(a,e,n){const s=a[0];if(s<=0||s>0)return a;const l=e*n;let c=rx[l];if(c===void 0&&(c=new Float32Array(l),rx[l]=c),e!==0){s.toArray(c,0);for(let d=1,p=0;d!==e;++d)p+=n,a[d].toArray(c,p)}return c}function Nn(a,e){if(a.length!==e.length)return!1;for(let n=0,s=a.length;n<s;n++)if(a[n]!==e[n])return!1;return!0}function Un(a,e){for(let n=0,s=e.length;n<s;n++)a[n]=e[n]}function ju(a,e){let n=ox[e];n===void 0&&(n=new Int32Array(e),ox[e]=n);for(let s=0;s!==e;++s)n[s]=a.allocateTextureUnit();return n}function EC(a,e){const n=this.cache;n[0]!==e&&(a.uniform1f(this.addr,e),n[0]=e)}function TC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(a.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Nn(n,e))return;a.uniform2fv(this.addr,e),Un(n,e)}}function AC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(a.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(a.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Nn(n,e))return;a.uniform3fv(this.addr,e),Un(n,e)}}function CC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(a.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Nn(n,e))return;a.uniform4fv(this.addr,e),Un(n,e)}}function wC(a,e){const n=this.cache,s=e.elements;if(s===void 0){if(Nn(n,e))return;a.uniformMatrix2fv(this.addr,!1,e),Un(n,e)}else{if(Nn(n,s))return;ux.set(s),a.uniformMatrix2fv(this.addr,!1,ux),Un(n,s)}}function RC(a,e){const n=this.cache,s=e.elements;if(s===void 0){if(Nn(n,e))return;a.uniformMatrix3fv(this.addr,!1,e),Un(n,e)}else{if(Nn(n,s))return;cx.set(s),a.uniformMatrix3fv(this.addr,!1,cx),Un(n,s)}}function DC(a,e){const n=this.cache,s=e.elements;if(s===void 0){if(Nn(n,e))return;a.uniformMatrix4fv(this.addr,!1,e),Un(n,e)}else{if(Nn(n,s))return;lx.set(s),a.uniformMatrix4fv(this.addr,!1,lx),Un(n,s)}}function NC(a,e){const n=this.cache;n[0]!==e&&(a.uniform1i(this.addr,e),n[0]=e)}function UC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(a.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Nn(n,e))return;a.uniform2iv(this.addr,e),Un(n,e)}}function LC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(a.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Nn(n,e))return;a.uniform3iv(this.addr,e),Un(n,e)}}function OC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(a.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Nn(n,e))return;a.uniform4iv(this.addr,e),Un(n,e)}}function PC(a,e){const n=this.cache;n[0]!==e&&(a.uniform1ui(this.addr,e),n[0]=e)}function IC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(a.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Nn(n,e))return;a.uniform2uiv(this.addr,e),Un(n,e)}}function BC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(a.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Nn(n,e))return;a.uniform3uiv(this.addr,e),Un(n,e)}}function FC(a,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(a.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Nn(n,e))return;a.uniform4uiv(this.addr,e),Un(n,e)}}function zC(a,e,n){const s=this.cache,l=n.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l);let c;this.type===a.SAMPLER_2D_SHADOW?(Op.compareFunction=n.isReversedDepthBuffer()?im:nm,c=Op):c=Ry,n.setTexture2D(e||c,l)}function HC(a,e,n){const s=this.cache,l=n.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l),n.setTexture3D(e||Ny,l)}function GC(a,e,n){const s=this.cache,l=n.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l),n.setTextureCube(e||Uy,l)}function VC(a,e,n){const s=this.cache,l=n.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l),n.setTexture2DArray(e||Dy,l)}function kC(a){switch(a){case 5126:return EC;case 35664:return TC;case 35665:return AC;case 35666:return CC;case 35674:return wC;case 35675:return RC;case 35676:return DC;case 5124:case 35670:return NC;case 35667:case 35671:return UC;case 35668:case 35672:return LC;case 35669:case 35673:return OC;case 5125:return PC;case 36294:return IC;case 36295:return BC;case 36296:return FC;case 35678:case 36198:case 36298:case 36306:case 35682:return zC;case 35679:case 36299:case 36307:return HC;case 35680:case 36300:case 36308:case 36293:return GC;case 36289:case 36303:case 36311:case 36292:return VC}}function jC(a,e){a.uniform1fv(this.addr,e)}function XC(a,e){const n=Mo(e,this.size,2);a.uniform2fv(this.addr,n)}function WC(a,e){const n=Mo(e,this.size,3);a.uniform3fv(this.addr,n)}function qC(a,e){const n=Mo(e,this.size,4);a.uniform4fv(this.addr,n)}function YC(a,e){const n=Mo(e,this.size,4);a.uniformMatrix2fv(this.addr,!1,n)}function ZC(a,e){const n=Mo(e,this.size,9);a.uniformMatrix3fv(this.addr,!1,n)}function KC(a,e){const n=Mo(e,this.size,16);a.uniformMatrix4fv(this.addr,!1,n)}function $C(a,e){a.uniform1iv(this.addr,e)}function QC(a,e){a.uniform2iv(this.addr,e)}function JC(a,e){a.uniform3iv(this.addr,e)}function ew(a,e){a.uniform4iv(this.addr,e)}function tw(a,e){a.uniform1uiv(this.addr,e)}function nw(a,e){a.uniform2uiv(this.addr,e)}function iw(a,e){a.uniform3uiv(this.addr,e)}function aw(a,e){a.uniform4uiv(this.addr,e)}function sw(a,e,n){const s=this.cache,l=e.length,c=ju(n,l);Nn(s,c)||(a.uniform1iv(this.addr,c),Un(s,c));let d;this.type===a.SAMPLER_2D_SHADOW?d=Op:d=Ry;for(let p=0;p!==l;++p)n.setTexture2D(e[p]||d,c[p])}function rw(a,e,n){const s=this.cache,l=e.length,c=ju(n,l);Nn(s,c)||(a.uniform1iv(this.addr,c),Un(s,c));for(let d=0;d!==l;++d)n.setTexture3D(e[d]||Ny,c[d])}function ow(a,e,n){const s=this.cache,l=e.length,c=ju(n,l);Nn(s,c)||(a.uniform1iv(this.addr,c),Un(s,c));for(let d=0;d!==l;++d)n.setTextureCube(e[d]||Uy,c[d])}function lw(a,e,n){const s=this.cache,l=e.length,c=ju(n,l);Nn(s,c)||(a.uniform1iv(this.addr,c),Un(s,c));for(let d=0;d!==l;++d)n.setTexture2DArray(e[d]||Dy,c[d])}function cw(a){switch(a){case 5126:return jC;case 35664:return XC;case 35665:return WC;case 35666:return qC;case 35674:return YC;case 35675:return ZC;case 35676:return KC;case 5124:case 35670:return $C;case 35667:case 35671:return QC;case 35668:case 35672:return JC;case 35669:case 35673:return ew;case 5125:return tw;case 36294:return nw;case 36295:return iw;case 36296:return aw;case 35678:case 36198:case 36298:case 36306:case 35682:return sw;case 35679:case 36299:case 36307:return rw;case 35680:case 36300:case 36308:case 36293:return ow;case 36289:case 36303:case 36311:case 36292:return lw}}class uw{constructor(e,n,s){this.id=e,this.addr=s,this.cache=[],this.type=n.type,this.setValue=kC(n.type)}}class dw{constructor(e,n,s){this.id=e,this.addr=s,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=cw(n.type)}}class fw{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,s){const l=this.seq;for(let c=0,d=l.length;c!==d;++c){const p=l[c];p.setValue(e,n[p.id],s)}}}const Fh=/(\w+)(\])?(\[|\.)?/g;function dx(a,e){a.seq.push(e),a.map[e.id]=e}function hw(a,e,n){const s=a.name,l=s.length;for(Fh.lastIndex=0;;){const c=Fh.exec(s),d=Fh.lastIndex;let p=c[1];const m=c[2]==="]",h=c[3];if(m&&(p=p|0),h===void 0||h==="["&&d+2===l){dx(n,h===void 0?new uw(p,a,e):new dw(p,a,e));break}else{let S=n.map[p];S===void 0&&(S=new fw(p),dx(n,S)),n=S}}}class wu{constructor(e,n){this.seq=[],this.map={};const s=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let d=0;d<s;++d){const p=e.getActiveUniform(n,d),m=e.getUniformLocation(n,p.name);hw(p,m,this)}const l=[],c=[];for(const d of this.seq)d.type===e.SAMPLER_2D_SHADOW||d.type===e.SAMPLER_CUBE_SHADOW||d.type===e.SAMPLER_2D_ARRAY_SHADOW?l.push(d):c.push(d);l.length>0&&(this.seq=l.concat(c))}setValue(e,n,s,l){const c=this.map[n];c!==void 0&&c.setValue(e,s,l)}setOptional(e,n,s){const l=n[s];l!==void 0&&this.setValue(e,s,l)}static upload(e,n,s,l){for(let c=0,d=n.length;c!==d;++c){const p=n[c],m=s[p.id];m.needsUpdate!==!1&&p.setValue(e,m.value,l)}}static seqWithValue(e,n){const s=[];for(let l=0,c=e.length;l!==c;++l){const d=e[l];d.id in n&&s.push(d)}return s}}function fx(a,e,n){const s=a.createShader(e);return a.shaderSource(s,n),a.compileShader(s),s}const pw=37297;let mw=0;function gw(a,e){const n=a.split(`
`),s=[],l=Math.max(e-6,0),c=Math.min(e+6,n.length);for(let d=l;d<c;d++){const p=d+1;s.push(`${p===e?">":" "} ${p}: ${n[d]}`)}return s.join(`
`)}const hx=new St;function _w(a){zt._getMatrix(hx,zt.workingColorSpace,a);const e=`mat3( ${hx.elements.map(n=>n.toFixed(4))} )`;switch(zt.getTransfer(a)){case Ou:return[e,"LinearTransferOETF"];case tn:return[e,"sRGBTransferOETF"];default:return mt("WebGLProgram: Unsupported color space: ",a),[e,"LinearTransferOETF"]}}function px(a,e,n){const s=a.getShaderParameter(e,a.COMPILE_STATUS),c=(a.getShaderInfoLog(e)||"").trim();if(s&&c==="")return"";const d=/ERROR: 0:(\d+)/.exec(c);if(d){const p=parseInt(d[1]);return n.toUpperCase()+`
`+c+`
`+gw(a.getShaderSource(e),p)}else return c}function vw(a,e){const n=_w(e);return[`vec4 ${a}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
`)}const xw={[ey]:"Linear",[ty]:"Reinhard",[ny]:"Cineon",[Yp]:"ACESFilmic",[ay]:"AgX",[sy]:"Neutral",[iy]:"Custom"};function yw(a,e){const n=xw[e];return n===void 0?(mt("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+a+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+a+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const yu=new se;function Sw(){zt.getLuminanceCoefficients(yu);const a=yu.x.toFixed(4),e=yu.y.toFixed(4),n=yu.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${a}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
`)}function bw(a){return[a.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",a.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(El).join(`
`)}function Mw(a){const e=[];for(const n in a){const s=a[n];s!==!1&&e.push("#define "+n+" "+s)}return e.join(`
`)}function Ew(a,e){const n={},s=a.getProgramParameter(e,a.ACTIVE_ATTRIBUTES);for(let l=0;l<s;l++){const c=a.getActiveAttrib(e,l),d=c.name;let p=1;c.type===a.FLOAT_MAT2&&(p=2),c.type===a.FLOAT_MAT3&&(p=3),c.type===a.FLOAT_MAT4&&(p=4),n[d]={type:c.type,location:a.getAttribLocation(e,d),locationSize:p}}return n}function El(a){return a!==""}function mx(a,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return a.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,n).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 gx(a,e){return a.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Tw=/^[ \t]*#include +<([\w\d./]+)>/gm;function Pp(a){return a.replace(Tw,Cw)}const Aw=new Map;function Cw(a,e){let n=Ct[e];if(n===void 0){const s=Aw.get(e);if(s!==void 0)n=Ct[s],mt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,s);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Pp(n)}const ww=/#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 _x(a){return a.replace(ww,Rw)}function Rw(a,e,n,s){let l="";for(let c=parseInt(e);c<parseInt(n);c++)l+=s.replace(/\[\s*i\s*\]/g,"[ "+c+" ]").replace(/UNROLLED_LOOP_INDEX/g,c);return l}function vx(a){let e=`precision ${a.precision} float;
precision ${a.precision} int;
precision ${a.precision} sampler2D;
precision ${a.precision} samplerCube;
precision ${a.precision} sampler3D;
precision ${a.precision} sampler2DArray;
precision ${a.precision} sampler2DShadow;
precision ${a.precision} samplerCubeShadow;
precision ${a.precision} sampler2DArrayShadow;
precision ${a.precision} isampler2D;
precision ${a.precision} isampler3D;
precision ${a.precision} isamplerCube;
precision ${a.precision} isampler2DArray;
precision ${a.precision} usampler2D;
precision ${a.precision} usampler3D;
precision ${a.precision} usamplerCube;
precision ${a.precision} usampler2DArray;
`;return a.precision==="highp"?e+=`
#define HIGH_PRECISION`:a.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:a.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}const Dw={[Mu]:"SHADOWMAP_TYPE_PCF",[Ml]:"SHADOWMAP_TYPE_VSM"};function Nw(a){return Dw[a.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const Uw={[sr]:"ENVMAP_TYPE_CUBE",[vo]:"ENVMAP_TYPE_CUBE",[Gu]:"ENVMAP_TYPE_CUBE_UV"};function Lw(a){return a.envMap===!1?"ENVMAP_TYPE_CUBE":Uw[a.envMapMode]||"ENVMAP_TYPE_CUBE"}const Ow={[vo]:"ENVMAP_MODE_REFRACTION"};function Pw(a){return a.envMap===!1?"ENVMAP_MODE_REFLECTION":Ow[a.envMapMode]||"ENVMAP_MODE_REFLECTION"}const Iw={[Jx]:"ENVMAP_BLENDING_MULTIPLY",[gE]:"ENVMAP_BLENDING_MIX",[_E]:"ENVMAP_BLENDING_ADD"};function Bw(a){return a.envMap===!1?"ENVMAP_BLENDING_NONE":Iw[a.combine]||"ENVMAP_BLENDING_NONE"}function Fw(a){const e=a.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,s=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:s,maxMip:n}}function zw(a,e,n,s){const l=a.getContext(),c=n.defines;let d=n.vertexShader,p=n.fragmentShader;const m=Nw(n),h=Lw(n),v=Pw(n),S=Bw(n),_=Fw(n),M=bw(n),E=Mw(c),C=l.createProgram();let y,x,P=n.glslVersion?"#version "+n.glslVersion+`
`:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,E].filter(El).join(`
`),y.length>0&&(y+=`
`),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,E].filter(El).join(`
`),x.length>0&&(x+=`
`)):(y=[vx(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,E,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+v:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexNormals?"#define HAS_NORMAL":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
`].filter(El).join(`
`),x=[vx(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,E,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+v:"",n.envMap?"#define "+S:"",_?"#define CUBEUV_TEXEL_WIDTH "+_.texelWidth:"",_?"#define CUBEUV_TEXEL_HEIGHT "+_.texelHeight:"",_?"#define CUBEUV_MAX_MIP "+_.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==da?"#define TONE_MAPPING":"",n.toneMapping!==da?Ct.tonemapping_pars_fragment:"",n.toneMapping!==da?yw("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ct.colorspace_pars_fragment,vw("linearToOutputTexel",n.outputColorSpace),Sw(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
`].filter(El).join(`
`)),d=Pp(d),d=mx(d,n),d=gx(d,n),p=Pp(p),p=mx(p,n),p=gx(p,n),d=_x(d),p=_x(p),n.isRawShaderMaterial!==!0&&(P=`#version 300 es
`,y=[M,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+y,x=["#define varying in",n.glslVersion===Sv?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Sv?"":"#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(`
`)+`
`+x);const O=P+y+d,R=P+x+p,I=fx(l,l.VERTEX_SHADER,O),B=fx(l,l.FRAGMENT_SHADER,R);l.attachShader(C,I),l.attachShader(C,B),n.index0AttributeName!==void 0?l.bindAttribLocation(C,0,n.index0AttributeName):n.hasPositionAttribute===!0&&l.bindAttribLocation(C,0,"position"),l.linkProgram(C);function L(G){if(a.debug.checkShaderErrors){const K=l.getProgramInfoLog(C)||"",ue=l.getShaderInfoLog(I)||"",pe=l.getShaderInfoLog(B)||"",Q=K.trim(),V=ue.trim(),j=pe.trim();let ae=!0,_e=!0;if(l.getProgramParameter(C,l.LINK_STATUS)===!1)if(ae=!1,typeof a.debug.onShaderError=="function")a.debug.onShaderError(l,C,I,B);else{const ve=px(l,I,"vertex"),H=px(l,B,"fragment");kt("WebGLProgram: Shader Error "+l.getError()+" - VALIDATE_STATUS "+l.getProgramParameter(C,l.VALIDATE_STATUS)+`
Material Name: `+G.name+`
Material Type: `+G.type+`
Program Info Log: `+Q+`
`+ve+`
`+H)}else Q!==""?mt("WebGLProgram: Program Info Log:",Q):(V===""||j==="")&&(_e=!1);_e&&(G.diagnostics={runnable:ae,programLog:Q,vertexShader:{log:V,prefix:y},fragmentShader:{log:j,prefix:x}})}l.deleteShader(I),l.deleteShader(B),T=new wu(l,C),U=Ew(l,C)}let T;this.getUniforms=function(){return T===void 0&&L(this),T};let U;this.getAttributes=function(){return U===void 0&&L(this),U};let X=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return X===!1&&(X=l.getProgramParameter(C,pw)),X},this.destroy=function(){s.releaseStatesOfProgram(this),l.deleteProgram(C),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=mw++,this.cacheKey=e,this.usedTimes=1,this.program=C,this.vertexShader=I,this.fragmentShader=B,this}let Hw=0;class Gw{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,n,s){const l=this._getShaderCacheForMaterial(e);return l.has(n)===!1&&(l.add(n),n.usedTimes++),l.has(s)===!1&&(l.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const s of n)s.usedTimes--,s.usedTimes===0&&this.shaderCache.delete(s.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let s=n.get(e);return s===void 0&&(s=new Set,n.set(e,s)),s}_getShaderStage(e){const n=this.shaderCache;let s=n.get(e);return s===void 0&&(s=new Vw(e),n.set(e,s)),s}}class Vw{constructor(e){this.id=Hw++,this.code=e,this.usedTimes=0}}function kw(a){return a===rr||a===Nu||a===Uu}function jw(a,e,n,s,l,c){const d=new my,p=new Gw,m=new Set,h=[],v=new Map,S=s.logarithmicDepthBuffer;let _=s.precision;const M={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function E(T){return m.add(T),T===0?"uv":`uv${T}`}function C(T,U,X,G,K,ue){const pe=G.fog,Q=K.geometry,V=T.isMeshStandardMaterial||T.isMeshLambertMaterial||T.isMeshPhongMaterial?G.environment:null,j=T.isMeshStandardMaterial||T.isMeshLambertMaterial&&!T.envMap||T.isMeshPhongMaterial&&!T.envMap,ae=e.get(T.envMap||V,j),_e=ae&&ae.mapping===Gu?ae.image.height:null,ve=M[T.type];T.precision!==null&&(_=s.getMaxPrecision(T.precision),_!==T.precision&&mt("WebGLProgram.getParameters:",T.precision,"not supported, using",_,"instead."));const H=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,te=H!==void 0?H.length:0;let Ee=0;Q.morphAttributes.position!==void 0&&(Ee=1),Q.morphAttributes.normal!==void 0&&(Ee=2),Q.morphAttributes.color!==void 0&&(Ee=3);let Le,Fe,oe,Me;if(ve){const qe=ca[ve];Le=qe.vertexShader,Fe=qe.fragmentShader}else{Le=T.vertexShader,Fe=T.fragmentShader;const qe=p.getVertexShaderStage(T),qt=p.getFragmentShaderStage(T);p.update(T,qe,qt),oe=qe.id,Me=qt.id}const Ae=a.getRenderTarget(),ze=a.state.buffers.depth.getReversed(),at=K.isInstancedMesh===!0,Je=K.isBatchedMesh===!0,Gt=!!T.map,ut=!!T.matcap,_t=!!ae,xt=!!T.aoMap,ot=!!T.lightMap,Ht=!!T.bumpMap&&T.wireframe===!1,Bt=!!T.normalMap,Zt=!!T.displacementMap,Vt=!!T.emissiveMap,dt=!!T.metalnessMap,J=!!T.roughnessMap,z=T.anisotropy>0,Ue=T.clearcoat>0,ft=T.dispersion>0,F=T.iridescence>0,A=T.sheen>0,ne=T.transmission>0,re=z&&!!T.anisotropyMap,fe=Ue&&!!T.clearcoatMap,Ne=Ue&&!!T.clearcoatNormalMap,He=Ue&&!!T.clearcoatRoughnessMap,ge=F&&!!T.iridescenceMap,le=F&&!!T.iridescenceThicknessMap,Ie=A&&!!T.sheenColorMap,We=A&&!!T.sheenRoughnessMap,Xe=!!T.specularMap,ke=!!T.specularColorMap,nt=!!T.specularIntensityMap,Ce=ne&&!!T.transmissionMap,rt=ne&&!!T.thicknessMap,Z=!!T.gradientMap,Oe=!!T.alphaMap,ye=T.alphaTest>0,Pe=!!T.alphaHash,Ge=!!T.extensions;let De=da;T.toneMapped&&(Ae===null||Ae.isXRRenderTarget===!0)&&(De=a.toneMapping);const Ze={shaderID:ve,shaderType:T.type,shaderName:T.name,vertexShader:Le,fragmentShader:Fe,defines:T.defines,customVertexShaderID:oe,customFragmentShaderID:Me,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:_,batching:Je,batchingColor:Je&&K._colorsTexture!==null,instancing:at,instancingColor:at&&K.instanceColor!==null,instancingMorph:at&&K.morphTexture!==null,outputColorSpace:Ae===null?a.outputColorSpace:Ae.isXRRenderTarget===!0?Ae.texture.colorSpace:zt.workingColorSpace,alphaToCoverage:!!T.alphaToCoverage,map:Gt,matcap:ut,envMap:_t,envMapMode:_t&&ae.mapping,envMapCubeUVHeight:_e,aoMap:xt,lightMap:ot,bumpMap:Ht,normalMap:Bt,displacementMap:Zt,emissiveMap:Vt,normalMapObjectSpace:Bt&&T.normalMapType===yE,normalMapTangentSpace:Bt&&T.normalMapType===vv,packedNormalMap:Bt&&T.normalMapType===vv&&kw(T.normalMap.format),metalnessMap:dt,roughnessMap:J,anisotropy:z,anisotropyMap:re,clearcoat:Ue,clearcoatMap:fe,clearcoatNormalMap:Ne,clearcoatRoughnessMap:He,dispersion:ft,iridescence:F,iridescenceMap:ge,iridescenceThicknessMap:le,sheen:A,sheenColorMap:Ie,sheenRoughnessMap:We,specularMap:Xe,specularColorMap:ke,specularIntensityMap:nt,transmission:ne,transmissionMap:Ce,thicknessMap:rt,gradientMap:Z,opaque:T.transparent===!1&&T.blending===fo&&T.alphaToCoverage===!1,alphaMap:Oe,alphaTest:ye,alphaHash:Pe,combine:T.combine,mapUv:Gt&&E(T.map.channel),aoMapUv:xt&&E(T.aoMap.channel),lightMapUv:ot&&E(T.lightMap.channel),bumpMapUv:Ht&&E(T.bumpMap.channel),normalMapUv:Bt&&E(T.normalMap.channel),displacementMapUv:Zt&&E(T.displacementMap.channel),emissiveMapUv:Vt&&E(T.emissiveMap.channel),metalnessMapUv:dt&&E(T.metalnessMap.channel),roughnessMapUv:J&&E(T.roughnessMap.channel),anisotropyMapUv:re&&E(T.anisotropyMap.channel),clearcoatMapUv:fe&&E(T.clearcoatMap.channel),clearcoatNormalMapUv:Ne&&E(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:He&&E(T.clearcoatRoughnessMap.channel),iridescenceMapUv:ge&&E(T.iridescenceMap.channel),iridescenceThicknessMapUv:le&&E(T.iridescenceThicknessMap.channel),sheenColorMapUv:Ie&&E(T.sheenColorMap.channel),sheenRoughnessMapUv:We&&E(T.sheenRoughnessMap.channel),specularMapUv:Xe&&E(T.specularMap.channel),specularColorMapUv:ke&&E(T.specularColorMap.channel),specularIntensityMapUv:nt&&E(T.specularIntensityMap.channel),transmissionMapUv:Ce&&E(T.transmissionMap.channel),thicknessMapUv:rt&&E(T.thicknessMap.channel),alphaMapUv:Oe&&E(T.alphaMap.channel),vertexTangents:!!Q.attributes.tangent&&(Bt||z),vertexNormals:!!Q.attributes.normal,vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!Q.attributes.color&&Q.attributes.color.itemSize===4,pointsUvs:K.isPoints===!0&&!!Q.attributes.uv&&(Gt||Oe),fog:!!pe,useFog:T.fog===!0,fogExp2:!!pe&&pe.isFogExp2,flatShading:T.wireframe===!1&&(T.flatShading===!0||Q.attributes.normal===void 0&&Bt===!1&&(T.isMeshLambertMaterial||T.isMeshPhongMaterial||T.isMeshStandardMaterial||T.isMeshPhysicalMaterial)),sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:S,reversedDepthBuffer:ze,skinning:K.isSkinnedMesh===!0,hasPositionAttribute:Q.attributes.position!==void 0,morphTargets:Q.morphAttributes.position!==void 0,morphNormals:Q.morphAttributes.normal!==void 0,morphColors:Q.morphAttributes.color!==void 0,morphTargetsCount:te,morphTextureStride:Ee,numDirLights:U.directional.length,numPointLights:U.point.length,numSpotLights:U.spot.length,numSpotLightMaps:U.spotLightMap.length,numRectAreaLights:U.rectArea.length,numHemiLights:U.hemi.length,numDirLightShadows:U.directionalShadowMap.length,numPointLightShadows:U.pointShadowMap.length,numSpotLightShadows:U.spotShadowMap.length,numSpotLightShadowsWithMaps:U.numSpotLightShadowsWithMaps,numLightProbes:U.numLightProbes,numLightProbeGrids:ue.length,numClippingPlanes:c.numPlanes,numClipIntersection:c.numIntersection,dithering:T.dithering,shadowMapEnabled:a.shadowMap.enabled&&X.length>0,shadowMapType:a.shadowMap.type,toneMapping:De,decodeVideoTexture:Gt&&T.map.isVideoTexture===!0&&zt.getTransfer(T.map.colorSpace)===tn,decodeVideoTextureEmissive:Vt&&T.emissiveMap.isVideoTexture===!0&&zt.getTransfer(T.emissiveMap.colorSpace)===tn,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===za,flipSided:T.side===si,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:Ge&&T.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ge&&T.extensions.multiDraw===!0||Je)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return Ze.vertexUv1s=m.has(1),Ze.vertexUv2s=m.has(2),Ze.vertexUv3s=m.has(3),m.clear(),Ze}function y(T){const U=[];if(T.shaderID?U.push(T.shaderID):(U.push(T.customVertexShaderID),U.push(T.customFragmentShaderID)),T.defines!==void 0)for(const X in T.defines)U.push(X),U.push(T.defines[X]);return T.isRawShaderMaterial===!1&&(x(U,T),P(U,T),U.push(a.outputColorSpace)),U.push(T.customProgramCacheKey),U.join()}function x(T,U){T.push(U.precision),T.push(U.outputColorSpace),T.push(U.envMapMode),T.push(U.envMapCubeUVHeight),T.push(U.mapUv),T.push(U.alphaMapUv),T.push(U.lightMapUv),T.push(U.aoMapUv),T.push(U.bumpMapUv),T.push(U.normalMapUv),T.push(U.displacementMapUv),T.push(U.emissiveMapUv),T.push(U.metalnessMapUv),T.push(U.roughnessMapUv),T.push(U.anisotropyMapUv),T.push(U.clearcoatMapUv),T.push(U.clearcoatNormalMapUv),T.push(U.clearcoatRoughnessMapUv),T.push(U.iridescenceMapUv),T.push(U.iridescenceThicknessMapUv),T.push(U.sheenColorMapUv),T.push(U.sheenRoughnessMapUv),T.push(U.specularMapUv),T.push(U.specularColorMapUv),T.push(U.specularIntensityMapUv),T.push(U.transmissionMapUv),T.push(U.thicknessMapUv),T.push(U.combine),T.push(U.fogExp2),T.push(U.sizeAttenuation),T.push(U.morphTargetsCount),T.push(U.morphAttributeCount),T.push(U.numDirLights),T.push(U.numPointLights),T.push(U.numSpotLights),T.push(U.numSpotLightMaps),T.push(U.numHemiLights),T.push(U.numRectAreaLights),T.push(U.numDirLightShadows),T.push(U.numPointLightShadows),T.push(U.numSpotLightShadows),T.push(U.numSpotLightShadowsWithMaps),T.push(U.numLightProbes),T.push(U.shadowMapType),T.push(U.toneMapping),T.push(U.numClippingPlanes),T.push(U.numClipIntersection),T.push(U.depthPacking)}function P(T,U){d.disableAll(),U.instancing&&d.enable(0),U.instancingColor&&d.enable(1),U.instancingMorph&&d.enable(2),U.matcap&&d.enable(3),U.envMap&&d.enable(4),U.normalMapObjectSpace&&d.enable(5),U.normalMapTangentSpace&&d.enable(6),U.clearcoat&&d.enable(7),U.iridescence&&d.enable(8),U.alphaTest&&d.enable(9),U.vertexColors&&d.enable(10),U.vertexAlphas&&d.enable(11),U.vertexUv1s&&d.enable(12),U.vertexUv2s&&d.enable(13),U.vertexUv3s&&d.enable(14),U.vertexTangents&&d.enable(15),U.anisotropy&&d.enable(16),U.alphaHash&&d.enable(17),U.batching&&d.enable(18),U.dispersion&&d.enable(19),U.batchingColor&&d.enable(20),U.gradientMap&&d.enable(21),U.packedNormalMap&&d.enable(22),U.vertexNormals&&d.enable(23),T.push(d.mask),d.disableAll(),U.fog&&d.enable(0),U.useFog&&d.enable(1),U.flatShading&&d.enable(2),U.logarithmicDepthBuffer&&d.enable(3),U.reversedDepthBuffer&&d.enable(4),U.skinning&&d.enable(5),U.morphTargets&&d.enable(6),U.morphNormals&&d.enable(7),U.morphColors&&d.enable(8),U.premultipliedAlpha&&d.enable(9),U.shadowMapEnabled&&d.enable(10),U.doubleSided&&d.enable(11),U.flipSided&&d.enable(12),U.useDepthPacking&&d.enable(13),U.dithering&&d.enable(14),U.transmission&&d.enable(15),U.sheen&&d.enable(16),U.opaque&&d.enable(17),U.pointsUvs&&d.enable(18),U.decodeVideoTexture&&d.enable(19),U.decodeVideoTextureEmissive&&d.enable(20),U.alphaToCoverage&&d.enable(21),U.numLightProbeGrids>0&&d.enable(22),U.hasPositionAttribute&&d.enable(23),T.push(d.mask)}function O(T){const U=M[T.type];let X;if(U){const G=ca[U];X=lT.clone(G.uniforms)}else X=T.uniforms;return X}function R(T,U){let X=v.get(U);return X!==void 0?++X.usedTimes:(X=new zw(a,U,T,l),h.push(X),v.set(U,X)),X}function I(T){if(--T.usedTimes===0){const U=h.indexOf(T);h[U]=h[h.length-1],h.pop(),v.delete(T.cacheKey),T.destroy()}}function B(T){p.remove(T)}function L(){p.dispose()}return{getParameters:C,getProgramCacheKey:y,getUniforms:O,acquireProgram:R,releaseProgram:I,releaseShaderCache:B,programs:h,dispose:L}}function Xw(){let a=new WeakMap;function e(d){return a.has(d)}function n(d){let p=a.get(d);return p===void 0&&(p={},a.set(d,p)),p}function s(d){a.delete(d)}function l(d,p,m){a.get(d)[p]=m}function c(){a=new WeakMap}return{has:e,get:n,remove:s,update:l,dispose:c}}function Ww(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.material.id!==e.material.id?a.material.id-e.material.id:a.materialVariant!==e.materialVariant?a.materialVariant-e.materialVariant:a.z!==e.z?a.z-e.z:a.id-e.id}function xx(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.z!==e.z?e.z-a.z:a.id-e.id}function yx(){const a=[];let e=0;const n=[],s=[],l=[];function c(){e=0,n.length=0,s.length=0,l.length=0}function d(_){let M=0;return _.isInstancedMesh&&(M+=2),_.isSkinnedMesh&&(M+=1),M}function p(_,M,E,C,y,x){let P=a[e];return P===void 0?(P={id:_.id,object:_,geometry:M,material:E,materialVariant:d(_),groupOrder:C,renderOrder:_.renderOrder,z:y,group:x},a[e]=P):(P.id=_.id,P.object=_,P.geometry=M,P.material=E,P.materialVariant=d(_),P.groupOrder=C,P.renderOrder=_.renderOrder,P.z=y,P.group=x),e++,P}function m(_,M,E,C,y,x){const P=p(_,M,E,C,y,x);E.transmission>0?s.push(P):E.transparent===!0?l.push(P):n.push(P)}function h(_,M,E,C,y,x){const P=p(_,M,E,C,y,x);E.transmission>0?s.unshift(P):E.transparent===!0?l.unshift(P):n.unshift(P)}function v(_,M,E){n.length>1&&n.sort(_||Ww),s.length>1&&s.sort(M||xx),l.length>1&&l.sort(M||xx),E&&(n.reverse(),s.reverse(),l.reverse())}function S(){for(let _=e,M=a.length;_<M;_++){const E=a[_];if(E.id===null)break;E.id=null,E.object=null,E.geometry=null,E.material=null,E.group=null}}return{opaque:n,transmissive:s,transparent:l,init:c,push:m,unshift:h,finish:S,sort:v}}function qw(){let a=new WeakMap;function e(s,l){const c=a.get(s);let d;return c===void 0?(d=new yx,a.set(s,[d])):l>=c.length?(d=new yx,c.push(d)):d=c[l],d}function n(){a=new WeakMap}return{get:e,dispose:n}}function Yw(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new se,color:new ct};break;case"SpotLight":n={position:new se,direction:new se,color:new ct,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new se,color:new ct,distance:0,decay:0};break;case"HemisphereLight":n={direction:new se,skyColor:new ct,groundColor:new ct};break;case"RectAreaLight":n={color:new ct,position:new se,halfWidth:new se,halfHeight:new se};break}return a[e.id]=n,n}}}function Zw(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[e.id]=n,n}}}let Kw=0;function $w(a,e){return(e.castShadow?2:0)-(a.castShadow?2:0)+(e.map?1:0)-(a.map?1:0)}function Qw(a){const e=new Yw,n=Zw(),s={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++)s.probe.push(new se);const l=new se,c=new cn,d=new cn;function p(h){let v=0,S=0,_=0;for(let U=0;U<9;U++)s.probe[U].set(0,0,0);let M=0,E=0,C=0,y=0,x=0,P=0,O=0,R=0,I=0,B=0,L=0;h.sort($w);for(let U=0,X=h.length;U<X;U++){const G=h[U],K=G.color,ue=G.intensity,pe=G.distance;let Q=null;if(G.shadow&&G.shadow.map&&(G.shadow.map.texture.format===rr?Q=G.shadow.map.texture:Q=G.shadow.map.depthTexture||G.shadow.map.texture),G.isAmbientLight)v+=K.r*ue,S+=K.g*ue,_+=K.b*ue;else if(G.isLightProbe){for(let V=0;V<9;V++)s.probe[V].addScaledVector(G.sh.coefficients[V],ue);L++}else if(G.isDirectionalLight){const V=e.get(G);if(V.color.copy(G.color).multiplyScalar(G.intensity),G.castShadow){const j=G.shadow,ae=n.get(G);ae.shadowIntensity=j.intensity,ae.shadowBias=j.bias,ae.shadowNormalBias=j.normalBias,ae.shadowRadius=j.radius,ae.shadowMapSize=j.mapSize,s.directionalShadow[M]=ae,s.directionalShadowMap[M]=Q,s.directionalShadowMatrix[M]=G.shadow.matrix,P++}s.directional[M]=V,M++}else if(G.isSpotLight){const V=e.get(G);V.position.setFromMatrixPosition(G.matrixWorld),V.color.copy(K).multiplyScalar(ue),V.distance=pe,V.coneCos=Math.cos(G.angle),V.penumbraCos=Math.cos(G.angle*(1-G.penumbra)),V.decay=G.decay,s.spot[C]=V;const j=G.shadow;if(G.map&&(s.spotLightMap[I]=G.map,I++,j.updateMatrices(G),G.castShadow&&B++),s.spotLightMatrix[C]=j.matrix,G.castShadow){const ae=n.get(G);ae.shadowIntensity=j.intensity,ae.shadowBias=j.bias,ae.shadowNormalBias=j.normalBias,ae.shadowRadius=j.radius,ae.shadowMapSize=j.mapSize,s.spotShadow[C]=ae,s.spotShadowMap[C]=Q,R++}C++}else if(G.isRectAreaLight){const V=e.get(G);V.color.copy(K).multiplyScalar(ue),V.halfWidth.set(G.width*.5,0,0),V.halfHeight.set(0,G.height*.5,0),s.rectArea[y]=V,y++}else if(G.isPointLight){const V=e.get(G);if(V.color.copy(G.color).multiplyScalar(G.intensity),V.distance=G.distance,V.decay=G.decay,G.castShadow){const j=G.shadow,ae=n.get(G);ae.shadowIntensity=j.intensity,ae.shadowBias=j.bias,ae.shadowNormalBias=j.normalBias,ae.shadowRadius=j.radius,ae.shadowMapSize=j.mapSize,ae.shadowCameraNear=j.camera.near,ae.shadowCameraFar=j.camera.far,s.pointShadow[E]=ae,s.pointShadowMap[E]=Q,s.pointShadowMatrix[E]=G.shadow.matrix,O++}s.point[E]=V,E++}else if(G.isHemisphereLight){const V=e.get(G);V.skyColor.copy(G.color).multiplyScalar(ue),V.groundColor.copy(G.groundColor).multiplyScalar(ue),s.hemi[x]=V,x++}}y>0&&(a.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=Ye.LTC_FLOAT_1,s.rectAreaLTC2=Ye.LTC_FLOAT_2):(s.rectAreaLTC1=Ye.LTC_HALF_1,s.rectAreaLTC2=Ye.LTC_HALF_2)),s.ambient[0]=v,s.ambient[1]=S,s.ambient[2]=_;const T=s.hash;(T.directionalLength!==M||T.pointLength!==E||T.spotLength!==C||T.rectAreaLength!==y||T.hemiLength!==x||T.numDirectionalShadows!==P||T.numPointShadows!==O||T.numSpotShadows!==R||T.numSpotMaps!==I||T.numLightProbes!==L)&&(s.directional.length=M,s.spot.length=C,s.rectArea.length=y,s.point.length=E,s.hemi.length=x,s.directionalShadow.length=P,s.directionalShadowMap.length=P,s.pointShadow.length=O,s.pointShadowMap.length=O,s.spotShadow.length=R,s.spotShadowMap.length=R,s.directionalShadowMatrix.length=P,s.pointShadowMatrix.length=O,s.spotLightMatrix.length=R+I-B,s.spotLightMap.length=I,s.numSpotLightShadowsWithMaps=B,s.numLightProbes=L,T.directionalLength=M,T.pointLength=E,T.spotLength=C,T.rectAreaLength=y,T.hemiLength=x,T.numDirectionalShadows=P,T.numPointShadows=O,T.numSpotShadows=R,T.numSpotMaps=I,T.numLightProbes=L,s.version=Kw++)}function m(h,v){let S=0,_=0,M=0,E=0,C=0;const y=v.matrixWorldInverse;for(let x=0,P=h.length;x<P;x++){const O=h[x];if(O.isDirectionalLight){const R=s.directional[S];R.direction.setFromMatrixPosition(O.matrixWorld),l.setFromMatrixPosition(O.target.matrixWorld),R.direction.sub(l),R.direction.transformDirection(y),S++}else if(O.isSpotLight){const R=s.spot[M];R.position.setFromMatrixPosition(O.matrixWorld),R.position.applyMatrix4(y),R.direction.setFromMatrixPosition(O.matrixWorld),l.setFromMatrixPosition(O.target.matrixWorld),R.direction.sub(l),R.direction.transformDirection(y),M++}else if(O.isRectAreaLight){const R=s.rectArea[E];R.position.setFromMatrixPosition(O.matrixWorld),R.position.applyMatrix4(y),d.identity(),c.copy(O.matrixWorld),c.premultiply(y),d.extractRotation(c),R.halfWidth.set(O.width*.5,0,0),R.halfHeight.set(0,O.height*.5,0),R.halfWidth.applyMatrix4(d),R.halfHeight.applyMatrix4(d),E++}else if(O.isPointLight){const R=s.point[_];R.position.setFromMatrixPosition(O.matrixWorld),R.position.applyMatrix4(y),_++}else if(O.isHemisphereLight){const R=s.hemi[C];R.direction.setFromMatrixPosition(O.matrixWorld),R.direction.transformDirection(y),C++}}}return{setup:p,setupView:m,state:s}}function Sx(a){const e=new Qw(a),n=[],s=[],l=[];function c(_){S.camera=_,n.length=0,s.length=0,l.length=0}function d(_){n.push(_)}function p(_){s.push(_)}function m(_){l.push(_)}function h(){e.setup(n)}function v(_){e.setupView(n,_)}const S={lightsArray:n,shadowsArray:s,lightProbeGridArray:l,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:c,state:S,setupLights:h,setupLightsView:v,pushLight:d,pushShadow:p,pushLightProbeGrid:m}}function Jw(a){let e=new WeakMap;function n(l,c=0){const d=e.get(l);let p;return d===void 0?(p=new Sx(a),e.set(l,[p])):c>=d.length?(p=new Sx(a),d.push(p)):p=d[c],p}function s(){e=new WeakMap}return{get:n,dispose:s}}const eR=`void main() {
gl_Position = vec4( position, 1.0 );
}`,tR=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
void main() {
const float samples = float( VSM_SAMPLES );
float mean = 0.0;
float squared_mean = 0.0;
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
for ( float i = 0.0; i < samples; i ++ ) {
float uvOffset = uvStart + i * uvStride;
#ifdef HORIZONTAL_PASS
vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
}`,nR=[new se(1,0,0),new se(-1,0,0),new se(0,1,0),new se(0,-1,0),new se(0,0,1),new se(0,0,-1)],iR=[new se(0,-1,0),new se(0,-1,0),new se(0,0,1),new se(0,0,-1),new se(0,-1,0),new se(0,-1,0)],bx=new cn,bl=new se,zh=new se;function aR(a,e,n){let s=new rm;const l=new bt,c=new bt,d=new pn,p=new fT,m=new hT,h={},v=n.maxTextureSize,S={[As]:si,[si]:As,[za]:za},_=new $i({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bt},radius:{value:4}},vertexShader:eR,fragmentShader:tR}),M=_.clone();M.defines.HORIZONTAL_PASS=1;const E=new Li;E.setAttribute("position",new Yi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const C=new Ki(E,_),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Mu;let x=this.type;this.render=function(B,L,T){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||B.length===0)return;this.type===Qx&&(mt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Mu);const U=a.getRenderTarget(),X=a.getActiveCubeFace(),G=a.getActiveMipmapLevel(),K=a.state;K.setBlending(Va),K.buffers.depth.getReversed()===!0?K.buffers.color.setClear(0,0,0,0):K.buffers.color.setClear(1,1,1,1),K.buffers.depth.setTest(!0),K.setScissorTest(!1);const ue=x!==this.type;ue&&L.traverse(function(pe){pe.material&&(Array.isArray(pe.material)?pe.material.forEach(Q=>Q.needsUpdate=!0):pe.material.needsUpdate=!0)});for(let pe=0,Q=B.length;pe<Q;pe++){const V=B[pe],j=V.shadow;if(j===void 0){mt("WebGLShadowMap:",V,"has no shadow.");continue}if(j.autoUpdate===!1&&j.needsUpdate===!1)continue;l.copy(j.mapSize);const ae=j.getFrameExtents();l.multiply(ae),c.copy(j.mapSize),(l.x>v||l.y>v)&&(l.x>v&&(c.x=Math.floor(v/ae.x),l.x=c.x*ae.x,j.mapSize.x=c.x),l.y>v&&(c.y=Math.floor(v/ae.y),l.y=c.y*ae.y,j.mapSize.y=c.y));const _e=a.state.buffers.depth.getReversed();if(j.camera._reversedDepth=_e,j.map===null||ue===!0){if(j.map!==null&&(j.map.depthTexture!==null&&(j.map.depthTexture.dispose(),j.map.depthTexture=null),j.map.dispose()),this.type===Ml){if(V.isPointLight){mt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}j.map=new fa(l.x,l.y,{format:rr,type:ja,minFilter:qn,magFilter:qn,generateMipmaps:!1}),j.map.texture.name=V.name+".shadowMap",j.map.depthTexture=new xo(l.x,l.y,Wi),j.map.depthTexture.name=V.name+".shadowMapDepth",j.map.depthTexture.format=Xa,j.map.depthTexture.compareFunction=null,j.map.depthTexture.minFilter=Gn,j.map.depthTexture.magFilter=Gn}else V.isPointLight?(j.map=new wy(l.x),j.map.depthTexture=new sT(l.x,pa)):(j.map=new fa(l.x,l.y),j.map.depthTexture=new xo(l.x,l.y,pa)),j.map.depthTexture.name=V.name+".shadowMap",j.map.depthTexture.format=Xa,this.type===Mu?(j.map.depthTexture.compareFunction=_e?im:nm,j.map.depthTexture.minFilter=qn,j.map.depthTexture.magFilter=qn):(j.map.depthTexture.compareFunction=null,j.map.depthTexture.minFilter=Gn,j.map.depthTexture.magFilter=Gn);j.camera.updateProjectionMatrix()}const ve=j.map.isWebGLCubeRenderTarget?6:1;for(let H=0;H<ve;H++){if(j.map.isWebGLCubeRenderTarget)a.setRenderTarget(j.map,H),a.clear();else{H===0&&(a.setRenderTarget(j.map),a.clear());const te=j.getViewport(H);d.set(c.x*te.x,c.y*te.y,c.x*te.z,c.y*te.w),K.viewport(d)}if(V.isPointLight){const te=j.camera,Ee=j.matrix,Le=V.distance||te.far;Le!==te.far&&(te.far=Le,te.updateProjectionMatrix()),bl.setFromMatrixPosition(V.matrixWorld),te.position.copy(bl),zh.copy(te.position),zh.add(nR[H]),te.up.copy(iR[H]),te.lookAt(zh),te.updateMatrixWorld(),Ee.makeTranslation(-bl.x,-bl.y,-bl.z),bx.multiplyMatrices(te.projectionMatrix,te.matrixWorldInverse),j._frustum.setFromProjectionMatrix(bx,te.coordinateSystem,te.reversedDepth)}else j.updateMatrices(V);s=j.getFrustum(),R(L,T,j.camera,V,this.type)}j.isPointLightShadow!==!0&&this.type===Ml&&P(j,T),j.needsUpdate=!1}x=this.type,y.needsUpdate=!1,a.setRenderTarget(U,X,G)};function P(B,L){const T=e.update(C);_.defines.VSM_SAMPLES!==B.blurSamples&&(_.defines.VSM_SAMPLES=B.blurSamples,M.defines.VSM_SAMPLES=B.blurSamples,_.needsUpdate=!0,M.needsUpdate=!0),B.mapPass===null&&(B.mapPass=new fa(l.x,l.y,{format:rr,type:ja})),_.uniforms.shadow_pass.value=B.map.depthTexture,_.uniforms.resolution.value=B.mapSize,_.uniforms.radius.value=B.radius,a.setRenderTarget(B.mapPass),a.clear(),a.renderBufferDirect(L,null,T,_,C,null),M.uniforms.shadow_pass.value=B.mapPass.texture,M.uniforms.resolution.value=B.mapSize,M.uniforms.radius.value=B.radius,a.setRenderTarget(B.map),a.clear(),a.renderBufferDirect(L,null,T,M,C,null)}function O(B,L,T,U){let X=null;const G=T.isPointLight===!0?B.customDistanceMaterial:B.customDepthMaterial;if(G!==void 0)X=G;else if(X=T.isPointLight===!0?m:p,a.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 K=X.uuid,ue=L.uuid;let pe=h[K];pe===void 0&&(pe={},h[K]=pe);let Q=pe[ue];Q===void 0&&(Q=X.clone(),pe[ue]=Q,L.addEventListener("dispose",I)),X=Q}if(X.visible=L.visible,X.wireframe=L.wireframe,U===Ml?X.side=L.shadowSide!==null?L.shadowSide:L.side:X.side=L.shadowSide!==null?L.shadowSide:S[L.side],X.alphaMap=L.alphaMap,X.alphaTest=L.alphaToCoverage===!0?.5:L.alphaTest,X.map=L.map,X.clipShadows=L.clipShadows,X.clippingPlanes=L.clippingPlanes,X.clipIntersection=L.clipIntersection,X.displacementMap=L.displacementMap,X.displacementScale=L.displacementScale,X.displacementBias=L.displacementBias,X.wireframeLinewidth=L.wireframeLinewidth,X.linewidth=L.linewidth,T.isPointLight===!0&&X.isMeshDistanceMaterial===!0){const K=a.properties.get(X);K.light=T}return X}function R(B,L,T,U,X){if(B.visible===!1)return;if(B.layers.test(L.layers)&&(B.isMesh||B.isLine||B.isPoints)&&(B.castShadow||B.receiveShadow&&X===Ml)&&(!B.frustumCulled||s.intersectsObject(B))){B.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,B.matrixWorld);const ue=e.update(B),pe=B.material;if(Array.isArray(pe)){const Q=ue.groups;for(let V=0,j=Q.length;V<j;V++){const ae=Q[V],_e=pe[ae.materialIndex];if(_e&&_e.visible){const ve=O(B,_e,U,X);B.onBeforeShadow(a,B,L,T,ue,ve,ae),a.renderBufferDirect(T,null,ue,ve,B,ae),B.onAfterShadow(a,B,L,T,ue,ve,ae)}}}else if(pe.visible){const Q=O(B,pe,U,X);B.onBeforeShadow(a,B,L,T,ue,Q,null),a.renderBufferDirect(T,null,ue,Q,B,null),B.onAfterShadow(a,B,L,T,ue,Q,null)}}const K=B.children;for(let ue=0,pe=K.length;ue<pe;ue++)R(K[ue],L,T,U,X)}function I(B){B.target.removeEventListener("dispose",I);for(const T in h){const U=h[T],X=B.target.uuid;X in U&&(U[X].dispose(),delete U[X])}}}function sR(a,e){function n(){let Z=!1;const Oe=new pn;let ye=null;const Pe=new pn(0,0,0,0);return{setMask:function(Ge){ye!==Ge&&!Z&&(a.colorMask(Ge,Ge,Ge,Ge),ye=Ge)},setLocked:function(Ge){Z=Ge},setClear:function(Ge,De,Ze,qe,qt){qt===!0&&(Ge*=qe,De*=qe,Ze*=qe),Oe.set(Ge,De,Ze,qe),Pe.equals(Oe)===!1&&(a.clearColor(Ge,De,Ze,qe),Pe.copy(Oe))},reset:function(){Z=!1,ye=null,Pe.set(-1,0,0,0)}}}function s(){let Z=!1,Oe=!1,ye=null,Pe=null,Ge=null;return{setReversed:function(De){if(Oe!==De){const Ze=e.get("EXT_clip_control");De?Ze.clipControlEXT(Ze.LOWER_LEFT_EXT,Ze.ZERO_TO_ONE_EXT):Ze.clipControlEXT(Ze.LOWER_LEFT_EXT,Ze.NEGATIVE_ONE_TO_ONE_EXT),Oe=De;const qe=Ge;Ge=null,this.setClear(qe)}},getReversed:function(){return Oe},setTest:function(De){De?Ae(a.DEPTH_TEST):ze(a.DEPTH_TEST)},setMask:function(De){ye!==De&&!Z&&(a.depthMask(De),ye=De)},setFunc:function(De){if(Oe&&(De=NE[De]),Pe!==De){switch(De){case Yh:a.depthFunc(a.NEVER);break;case Zh:a.depthFunc(a.ALWAYS);break;case Kh:a.depthFunc(a.LESS);break;case _o:a.depthFunc(a.LEQUAL);break;case $h:a.depthFunc(a.EQUAL);break;case Qh:a.depthFunc(a.GEQUAL);break;case Jh:a.depthFunc(a.GREATER);break;case ep:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}Pe=De}},setLocked:function(De){Z=De},setClear:function(De){Ge!==De&&(Ge=De,Oe&&(De=1-De),a.clearDepth(De))},reset:function(){Z=!1,ye=null,Pe=null,Ge=null,Oe=!1}}}function l(){let Z=!1,Oe=null,ye=null,Pe=null,Ge=null,De=null,Ze=null,qe=null,qt=null;return{setTest:function(wt){Z||(wt?Ae(a.STENCIL_TEST):ze(a.STENCIL_TEST))},setMask:function(wt){Oe!==wt&&!Z&&(a.stencilMask(wt),Oe=wt)},setFunc:function(wt,Ln,Sn){(ye!==wt||Pe!==Ln||Ge!==Sn)&&(a.stencilFunc(wt,Ln,Sn),ye=wt,Pe=Ln,Ge=Sn)},setOp:function(wt,Ln,Sn){(De!==wt||Ze!==Ln||qe!==Sn)&&(a.stencilOp(wt,Ln,Sn),De=wt,Ze=Ln,qe=Sn)},setLocked:function(wt){Z=wt},setClear:function(wt){qt!==wt&&(a.clearStencil(wt),qt=wt)},reset:function(){Z=!1,Oe=null,ye=null,Pe=null,Ge=null,De=null,Ze=null,qe=null,qt=null}}}const c=new n,d=new s,p=new l,m=new WeakMap,h=new WeakMap;let v={},S={},_={},M=new WeakMap,E=[],C=null,y=!1,x=null,P=null,O=null,R=null,I=null,B=null,L=null,T=new ct(0,0,0),U=0,X=!1,G=null,K=null,ue=null,pe=null,Q=null;const V=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let j=!1,ae=0;const _e=a.getParameter(a.VERSION);_e.indexOf("WebGL")!==-1?(ae=parseFloat(/^WebGL (\d)/.exec(_e)[1]),j=ae>=1):_e.indexOf("OpenGL ES")!==-1&&(ae=parseFloat(/^OpenGL ES (\d)/.exec(_e)[1]),j=ae>=2);let ve=null,H={};const te=a.getParameter(a.SCISSOR_BOX),Ee=a.getParameter(a.VIEWPORT),Le=new pn().fromArray(te),Fe=new pn().fromArray(Ee);function oe(Z,Oe,ye,Pe){const Ge=new Uint8Array(4),De=a.createTexture();a.bindTexture(Z,De),a.texParameteri(Z,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(Z,a.TEXTURE_MAG_FILTER,a.NEAREST);for(let Ze=0;Ze<ye;Ze++)Z===a.TEXTURE_3D||Z===a.TEXTURE_2D_ARRAY?a.texImage3D(Oe,0,a.RGBA,1,1,Pe,0,a.RGBA,a.UNSIGNED_BYTE,Ge):a.texImage2D(Oe+Ze,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,Ge);return De}const Me={};Me[a.TEXTURE_2D]=oe(a.TEXTURE_2D,a.TEXTURE_2D,1),Me[a.TEXTURE_CUBE_MAP]=oe(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6),Me[a.TEXTURE_2D_ARRAY]=oe(a.TEXTURE_2D_ARRAY,a.TEXTURE_2D_ARRAY,1,1),Me[a.TEXTURE_3D]=oe(a.TEXTURE_3D,a.TEXTURE_3D,1,1),c.setClear(0,0,0,1),d.setClear(1),p.setClear(0),Ae(a.DEPTH_TEST),d.setFunc(_o),Ht(!1),Bt(pv),Ae(a.CULL_FACE),xt(Va);function Ae(Z){v[Z]!==!0&&(a.enable(Z),v[Z]=!0)}function ze(Z){v[Z]!==!1&&(a.disable(Z),v[Z]=!1)}function at(Z,Oe){return _[Z]!==Oe?(a.bindFramebuffer(Z,Oe),_[Z]=Oe,Z===a.DRAW_FRAMEBUFFER&&(_[a.FRAMEBUFFER]=Oe),Z===a.FRAMEBUFFER&&(_[a.DRAW_FRAMEBUFFER]=Oe),!0):!1}function Je(Z,Oe){let ye=E,Pe=!1;if(Z){ye=M.get(Oe),ye===void 0&&(ye=[],M.set(Oe,ye));const Ge=Z.textures;if(ye.length!==Ge.length||ye[0]!==a.COLOR_ATTACHMENT0){for(let De=0,Ze=Ge.length;De<Ze;De++)ye[De]=a.COLOR_ATTACHMENT0+De;ye.length=Ge.length,Pe=!0}}else ye[0]!==a.BACK&&(ye[0]=a.BACK,Pe=!0);Pe&&a.drawBuffers(ye)}function Gt(Z){return C!==Z?(a.useProgram(Z),C=Z,!0):!1}const ut={[Qs]:a.FUNC_ADD,[JM]:a.FUNC_SUBTRACT,[eE]:a.FUNC_REVERSE_SUBTRACT};ut[tE]=a.MIN,ut[nE]=a.MAX;const _t={[iE]:a.ZERO,[aE]:a.ONE,[sE]:a.SRC_COLOR,[Wh]:a.SRC_ALPHA,[dE]:a.SRC_ALPHA_SATURATE,[cE]:a.DST_COLOR,[oE]:a.DST_ALPHA,[rE]:a.ONE_MINUS_SRC_COLOR,[qh]:a.ONE_MINUS_SRC_ALPHA,[uE]:a.ONE_MINUS_DST_COLOR,[lE]:a.ONE_MINUS_DST_ALPHA,[fE]:a.CONSTANT_COLOR,[hE]:a.ONE_MINUS_CONSTANT_COLOR,[pE]:a.CONSTANT_ALPHA,[mE]:a.ONE_MINUS_CONSTANT_ALPHA};function xt(Z,Oe,ye,Pe,Ge,De,Ze,qe,qt,wt){if(Z===Va){y===!0&&(ze(a.BLEND),y=!1);return}if(y===!1&&(Ae(a.BLEND),y=!0),Z!==QM){if(Z!==x||wt!==X){if((P!==Qs||I!==Qs)&&(a.blendEquation(a.FUNC_ADD),P=Qs,I=Qs),wt)switch(Z){case fo:a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case mv:a.blendFunc(a.ONE,a.ONE);break;case gv:a.blendFuncSeparate(a.ZERO,a.ONE_MINUS_SRC_COLOR,a.ZERO,a.ONE);break;case _v:a.blendFuncSeparate(a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA,a.ZERO,a.ONE);break;default:kt("WebGLState: Invalid blending: ",Z);break}else switch(Z){case fo:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case mv:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE,a.ONE,a.ONE);break;case gv:kt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case _v:kt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:kt("WebGLState: Invalid blending: ",Z);break}O=null,R=null,B=null,L=null,T.set(0,0,0),U=0,x=Z,X=wt}return}Ge=Ge||Oe,De=De||ye,Ze=Ze||Pe,(Oe!==P||Ge!==I)&&(a.blendEquationSeparate(ut[Oe],ut[Ge]),P=Oe,I=Ge),(ye!==O||Pe!==R||De!==B||Ze!==L)&&(a.blendFuncSeparate(_t[ye],_t[Pe],_t[De],_t[Ze]),O=ye,R=Pe,B=De,L=Ze),(qe.equals(T)===!1||qt!==U)&&(a.blendColor(qe.r,qe.g,qe.b,qt),T.copy(qe),U=qt),x=Z,X=!1}function ot(Z,Oe){Z.side===za?ze(a.CULL_FACE):Ae(a.CULL_FACE);let ye=Z.side===si;Oe&&(ye=!ye),Ht(ye),Z.blending===fo&&Z.transparent===!1?xt(Va):xt(Z.blending,Z.blendEquation,Z.blendSrc,Z.blendDst,Z.blendEquationAlpha,Z.blendSrcAlpha,Z.blendDstAlpha,Z.blendColor,Z.blendAlpha,Z.premultipliedAlpha),d.setFunc(Z.depthFunc),d.setTest(Z.depthTest),d.setMask(Z.depthWrite),c.setMask(Z.colorWrite);const Pe=Z.stencilWrite;p.setTest(Pe),Pe&&(p.setMask(Z.stencilWriteMask),p.setFunc(Z.stencilFunc,Z.stencilRef,Z.stencilFuncMask),p.setOp(Z.stencilFail,Z.stencilZFail,Z.stencilZPass)),Vt(Z.polygonOffset,Z.polygonOffsetFactor,Z.polygonOffsetUnits),Z.alphaToCoverage===!0?Ae(a.SAMPLE_ALPHA_TO_COVERAGE):ze(a.SAMPLE_ALPHA_TO_COVERAGE)}function Ht(Z){G!==Z&&(Z?a.frontFace(a.CW):a.frontFace(a.CCW),G=Z)}function Bt(Z){Z!==KM?(Ae(a.CULL_FACE),Z!==K&&(Z===pv?a.cullFace(a.BACK):Z===$M?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):ze(a.CULL_FACE),K=Z}function Zt(Z){Z!==ue&&(j&&a.lineWidth(Z),ue=Z)}function Vt(Z,Oe,ye){Z?(Ae(a.POLYGON_OFFSET_FILL),(pe!==Oe||Q!==ye)&&(pe=Oe,Q=ye,d.getReversed()&&(Oe=-Oe),a.polygonOffset(Oe,ye))):ze(a.POLYGON_OFFSET_FILL)}function dt(Z){Z?Ae(a.SCISSOR_TEST):ze(a.SCISSOR_TEST)}function J(Z){Z===void 0&&(Z=a.TEXTURE0+V-1),ve!==Z&&(a.activeTexture(Z),ve=Z)}function z(Z,Oe,ye){ye===void 0&&(ve===null?ye=a.TEXTURE0+V-1:ye=ve);let Pe=H[ye];Pe===void 0&&(Pe={type:void 0,texture:void 0},H[ye]=Pe),(Pe.type!==Z||Pe.texture!==Oe)&&(ve!==ye&&(a.activeTexture(ye),ve=ye),a.bindTexture(Z,Oe||Me[Z]),Pe.type=Z,Pe.texture=Oe)}function Ue(){const Z=H[ve];Z!==void 0&&Z.type!==void 0&&(a.bindTexture(Z.type,null),Z.type=void 0,Z.texture=void 0)}function ft(){try{a.compressedTexImage2D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function F(){try{a.compressedTexImage3D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function A(){try{a.texSubImage2D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function ne(){try{a.texSubImage3D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function re(){try{a.compressedTexSubImage2D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function fe(){try{a.compressedTexSubImage3D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function Ne(){try{a.texStorage2D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function He(){try{a.texStorage3D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function ge(){try{a.texImage2D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function le(){try{a.texImage3D(...arguments)}catch(Z){kt("WebGLState:",Z)}}function Ie(Z){return S[Z]!==void 0?S[Z]:a.getParameter(Z)}function We(Z,Oe){S[Z]!==Oe&&(a.pixelStorei(Z,Oe),S[Z]=Oe)}function Xe(Z){Le.equals(Z)===!1&&(a.scissor(Z.x,Z.y,Z.z,Z.w),Le.copy(Z))}function ke(Z){Fe.equals(Z)===!1&&(a.viewport(Z.x,Z.y,Z.z,Z.w),Fe.copy(Z))}function nt(Z,Oe){let ye=h.get(Oe);ye===void 0&&(ye=new WeakMap,h.set(Oe,ye));let Pe=ye.get(Z);Pe===void 0&&(Pe=a.getUniformBlockIndex(Oe,Z.name),ye.set(Z,Pe))}function Ce(Z,Oe){const Pe=h.get(Oe).get(Z);m.get(Oe)!==Pe&&(a.uniformBlockBinding(Oe,Pe,Z.__bindingPointIndex),m.set(Oe,Pe))}function rt(){a.disable(a.BLEND),a.disable(a.CULL_FACE),a.disable(a.DEPTH_TEST),a.disable(a.POLYGON_OFFSET_FILL),a.disable(a.SCISSOR_TEST),a.disable(a.STENCIL_TEST),a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ONE,a.ZERO),a.blendFuncSeparate(a.ONE,a.ZERO,a.ONE,a.ZERO),a.blendColor(0,0,0,0),a.colorMask(!0,!0,!0,!0),a.clearColor(0,0,0,0),a.depthMask(!0),a.depthFunc(a.LESS),d.setReversed(!1),a.clearDepth(1),a.stencilMask(4294967295),a.stencilFunc(a.ALWAYS,0,4294967295),a.stencilOp(a.KEEP,a.KEEP,a.KEEP),a.clearStencil(0),a.cullFace(a.BACK),a.frontFace(a.CCW),a.polygonOffset(0,0),a.activeTexture(a.TEXTURE0),a.bindFramebuffer(a.FRAMEBUFFER,null),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),a.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.useProgram(null),a.lineWidth(1),a.scissor(0,0,a.canvas.width,a.canvas.height),a.viewport(0,0,a.canvas.width,a.canvas.height),a.pixelStorei(a.PACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,a.BROWSER_DEFAULT_WEBGL),a.pixelStorei(a.PACK_ROW_LENGTH,0),a.pixelStorei(a.PACK_SKIP_PIXELS,0),a.pixelStorei(a.PACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_ROW_LENGTH,0),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,0),a.pixelStorei(a.UNPACK_SKIP_PIXELS,0),a.pixelStorei(a.UNPACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_SKIP_IMAGES,0),v={},S={},ve=null,H={},_={},M=new WeakMap,E=[],C=null,y=!1,x=null,P=null,O=null,R=null,I=null,B=null,L=null,T=new ct(0,0,0),U=0,X=!1,G=null,K=null,ue=null,pe=null,Q=null,Le.set(0,0,a.canvas.width,a.canvas.height),Fe.set(0,0,a.canvas.width,a.canvas.height),c.reset(),d.reset(),p.reset()}return{buffers:{color:c,depth:d,stencil:p},enable:Ae,disable:ze,bindFramebuffer:at,drawBuffers:Je,useProgram:Gt,setBlending:xt,setMaterial:ot,setFlipSided:Ht,setCullFace:Bt,setLineWidth:Zt,setPolygonOffset:Vt,setScissorTest:dt,activeTexture:J,bindTexture:z,unbindTexture:Ue,compressedTexImage2D:ft,compressedTexImage3D:F,texImage2D:ge,texImage3D:le,pixelStorei:We,getParameter:Ie,updateUBOMapping:nt,uniformBlockBinding:Ce,texStorage2D:Ne,texStorage3D:He,texSubImage2D:A,texSubImage3D:ne,compressedTexSubImage2D:re,compressedTexSubImage3D:fe,scissor:Xe,viewport:ke,reset:rt}}function rR(a,e,n,s,l,c,d){const p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new bt,v=new WeakMap,S=new Set;let _;const M=new WeakMap;let E=!1;try{E=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function C(F,A){return E?new OffscreenCanvas(F,A):Pu("canvas")}function y(F,A,ne){let re=1;const fe=ft(F);if((fe.width>ne||fe.height>ne)&&(re=ne/Math.max(fe.width,fe.height)),re<1)if(typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&F instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&F instanceof ImageBitmap||typeof VideoFrame<"u"&&F instanceof VideoFrame){const Ne=Math.floor(re*fe.width),He=Math.floor(re*fe.height);_===void 0&&(_=C(Ne,He));const ge=A?C(Ne,He):_;return ge.width=Ne,ge.height=He,ge.getContext("2d").drawImage(F,0,0,Ne,He),mt("WebGLRenderer: Texture has been resized from ("+fe.width+"x"+fe.height+") to ("+Ne+"x"+He+")."),ge}else return"data"in F&&mt("WebGLRenderer: Image in DataTexture is too big ("+fe.width+"x"+fe.height+")."),F;return F}function x(F){return F.generateMipmaps}function P(F){a.generateMipmap(F)}function O(F){return F.isWebGLCubeRenderTarget?a.TEXTURE_CUBE_MAP:F.isWebGL3DRenderTarget?a.TEXTURE_3D:F.isWebGLArrayRenderTarget||F.isCompressedArrayTexture?a.TEXTURE_2D_ARRAY:a.TEXTURE_2D}function R(F,A,ne,re,fe,Ne=!1){if(F!==null){if(a[F]!==void 0)return a[F];mt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+F+"'")}let He;re&&(He=e.get("EXT_texture_norm16"),He||mt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let ge=A;if(A===a.RED&&(ne===a.FLOAT&&(ge=a.R32F),ne===a.HALF_FLOAT&&(ge=a.R16F),ne===a.UNSIGNED_BYTE&&(ge=a.R8),ne===a.UNSIGNED_SHORT&&He&&(ge=He.R16_EXT),ne===a.SHORT&&He&&(ge=He.R16_SNORM_EXT)),A===a.RED_INTEGER&&(ne===a.UNSIGNED_BYTE&&(ge=a.R8UI),ne===a.UNSIGNED_SHORT&&(ge=a.R16UI),ne===a.UNSIGNED_INT&&(ge=a.R32UI),ne===a.BYTE&&(ge=a.R8I),ne===a.SHORT&&(ge=a.R16I),ne===a.INT&&(ge=a.R32I)),A===a.RG&&(ne===a.FLOAT&&(ge=a.RG32F),ne===a.HALF_FLOAT&&(ge=a.RG16F),ne===a.UNSIGNED_BYTE&&(ge=a.RG8),ne===a.UNSIGNED_SHORT&&He&&(ge=He.RG16_EXT),ne===a.SHORT&&He&&(ge=He.RG16_SNORM_EXT)),A===a.RG_INTEGER&&(ne===a.UNSIGNED_BYTE&&(ge=a.RG8UI),ne===a.UNSIGNED_SHORT&&(ge=a.RG16UI),ne===a.UNSIGNED_INT&&(ge=a.RG32UI),ne===a.BYTE&&(ge=a.RG8I),ne===a.SHORT&&(ge=a.RG16I),ne===a.INT&&(ge=a.RG32I)),A===a.RGB_INTEGER&&(ne===a.UNSIGNED_BYTE&&(ge=a.RGB8UI),ne===a.UNSIGNED_SHORT&&(ge=a.RGB16UI),ne===a.UNSIGNED_INT&&(ge=a.RGB32UI),ne===a.BYTE&&(ge=a.RGB8I),ne===a.SHORT&&(ge=a.RGB16I),ne===a.INT&&(ge=a.RGB32I)),A===a.RGBA_INTEGER&&(ne===a.UNSIGNED_BYTE&&(ge=a.RGBA8UI),ne===a.UNSIGNED_SHORT&&(ge=a.RGBA16UI),ne===a.UNSIGNED_INT&&(ge=a.RGBA32UI),ne===a.BYTE&&(ge=a.RGBA8I),ne===a.SHORT&&(ge=a.RGBA16I),ne===a.INT&&(ge=a.RGBA32I)),A===a.RGB&&(ne===a.UNSIGNED_SHORT&&He&&(ge=He.RGB16_EXT),ne===a.SHORT&&He&&(ge=He.RGB16_SNORM_EXT),ne===a.UNSIGNED_INT_5_9_9_9_REV&&(ge=a.RGB9_E5),ne===a.UNSIGNED_INT_10F_11F_11F_REV&&(ge=a.R11F_G11F_B10F)),A===a.RGBA){const le=Ne?Ou:zt.getTransfer(fe);ne===a.FLOAT&&(ge=a.RGBA32F),ne===a.HALF_FLOAT&&(ge=a.RGBA16F),ne===a.UNSIGNED_BYTE&&(ge=le===tn?a.SRGB8_ALPHA8:a.RGBA8),ne===a.UNSIGNED_SHORT&&He&&(ge=He.RGBA16_EXT),ne===a.SHORT&&He&&(ge=He.RGBA16_SNORM_EXT),ne===a.UNSIGNED_SHORT_4_4_4_4&&(ge=a.RGBA4),ne===a.UNSIGNED_SHORT_5_5_5_1&&(ge=a.RGB5_A1)}return(ge===a.R16F||ge===a.R32F||ge===a.RG16F||ge===a.RG32F||ge===a.RGBA16F||ge===a.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function I(F,A){let ne;return F?A===null||A===pa||A===Nl?ne=a.DEPTH24_STENCIL8:A===Wi?ne=a.DEPTH32F_STENCIL8:A===Dl&&(ne=a.DEPTH24_STENCIL8,mt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):A===null||A===pa||A===Nl?ne=a.DEPTH_COMPONENT24:A===Wi?ne=a.DEPTH_COMPONENT32F:A===Dl&&(ne=a.DEPTH_COMPONENT16),ne}function B(F,A){return x(F)===!0||F.isFramebufferTexture&&F.minFilter!==Gn&&F.minFilter!==qn?Math.log2(Math.max(A.width,A.height))+1:F.mipmaps!==void 0&&F.mipmaps.length>0?F.mipmaps.length:F.isCompressedTexture&&Array.isArray(F.image)?A.mipmaps.length:1}function L(F){const A=F.target;A.removeEventListener("dispose",L),U(A),A.isVideoTexture&&v.delete(A),A.isHTMLTexture&&S.delete(A)}function T(F){const A=F.target;A.removeEventListener("dispose",T),G(A)}function U(F){const A=s.get(F);if(A.__webglInit===void 0)return;const ne=F.source,re=M.get(ne);if(re){const fe=re[A.__cacheKey];fe.usedTimes--,fe.usedTimes===0&&X(F),Object.keys(re).length===0&&M.delete(ne)}s.remove(F)}function X(F){const A=s.get(F);a.deleteTexture(A.__webglTexture);const ne=F.source,re=M.get(ne);delete re[A.__cacheKey],d.memory.textures--}function G(F){const A=s.get(F);if(F.depthTexture&&(F.depthTexture.dispose(),s.remove(F.depthTexture)),F.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(A.__webglFramebuffer[re]))for(let fe=0;fe<A.__webglFramebuffer[re].length;fe++)a.deleteFramebuffer(A.__webglFramebuffer[re][fe]);else a.deleteFramebuffer(A.__webglFramebuffer[re]);A.__webglDepthbuffer&&a.deleteRenderbuffer(A.__webglDepthbuffer[re])}else{if(Array.isArray(A.__webglFramebuffer))for(let re=0;re<A.__webglFramebuffer.length;re++)a.deleteFramebuffer(A.__webglFramebuffer[re]);else a.deleteFramebuffer(A.__webglFramebuffer);if(A.__webglDepthbuffer&&a.deleteRenderbuffer(A.__webglDepthbuffer),A.__webglMultisampledFramebuffer&&a.deleteFramebuffer(A.__webglMultisampledFramebuffer),A.__webglColorRenderbuffer)for(let re=0;re<A.__webglColorRenderbuffer.length;re++)A.__webglColorRenderbuffer[re]&&a.deleteRenderbuffer(A.__webglColorRenderbuffer[re]);A.__webglDepthRenderbuffer&&a.deleteRenderbuffer(A.__webglDepthRenderbuffer)}const ne=F.textures;for(let re=0,fe=ne.length;re<fe;re++){const Ne=s.get(ne[re]);Ne.__webglTexture&&(a.deleteTexture(Ne.__webglTexture),d.memory.textures--),s.remove(ne[re])}s.remove(F)}let K=0;function ue(){K=0}function pe(){return K}function Q(F){K=F}function V(){const F=K;return F>=l.maxTextures&&mt("WebGLTextures: Trying to use "+F+" texture units while this GPU supports only "+l.maxTextures),K+=1,F}function j(F){const A=[];return A.push(F.wrapS),A.push(F.wrapT),A.push(F.wrapR||0),A.push(F.magFilter),A.push(F.minFilter),A.push(F.anisotropy),A.push(F.internalFormat),A.push(F.format),A.push(F.type),A.push(F.generateMipmaps),A.push(F.premultiplyAlpha),A.push(F.flipY),A.push(F.unpackAlignment),A.push(F.colorSpace),A.join()}function ae(F,A){const ne=s.get(F);if(F.isVideoTexture&&z(F),F.isRenderTargetTexture===!1&&F.isExternalTexture!==!0&&F.version>0&&ne.__version!==F.version){const re=F.image;if(re===null)mt("WebGLRenderer: Texture marked for update but no image data found.");else if(re.complete===!1)mt("WebGLRenderer: Texture marked for update but image is incomplete");else{ze(ne,F,A);return}}else F.isExternalTexture&&(ne.__webglTexture=F.sourceTexture?F.sourceTexture:null);n.bindTexture(a.TEXTURE_2D,ne.__webglTexture,a.TEXTURE0+A)}function _e(F,A){const ne=s.get(F);if(F.isRenderTargetTexture===!1&&F.version>0&&ne.__version!==F.version){ze(ne,F,A);return}else F.isExternalTexture&&(ne.__webglTexture=F.sourceTexture?F.sourceTexture:null);n.bindTexture(a.TEXTURE_2D_ARRAY,ne.__webglTexture,a.TEXTURE0+A)}function ve(F,A){const ne=s.get(F);if(F.isRenderTargetTexture===!1&&F.version>0&&ne.__version!==F.version){ze(ne,F,A);return}n.bindTexture(a.TEXTURE_3D,ne.__webglTexture,a.TEXTURE0+A)}function H(F,A){const ne=s.get(F);if(F.isCubeDepthTexture!==!0&&F.version>0&&ne.__version!==F.version){at(ne,F,A);return}n.bindTexture(a.TEXTURE_CUBE_MAP,ne.__webglTexture,a.TEXTURE0+A)}const te={[tp]:a.REPEAT,[Ha]:a.CLAMP_TO_EDGE,[np]:a.MIRRORED_REPEAT},Ee={[Gn]:a.NEAREST,[vE]:a.NEAREST_MIPMAP_NEAREST,[Wc]:a.NEAREST_MIPMAP_LINEAR,[qn]:a.LINEAR,[oh]:a.LINEAR_MIPMAP_NEAREST,[er]:a.LINEAR_MIPMAP_LINEAR},Le={[SE]:a.NEVER,[AE]:a.ALWAYS,[bE]:a.LESS,[nm]:a.LEQUAL,[ME]:a.EQUAL,[im]:a.GEQUAL,[EE]:a.GREATER,[TE]:a.NOTEQUAL};function Fe(F,A){if(A.type===Wi&&e.has("OES_texture_float_linear")===!1&&(A.magFilter===qn||A.magFilter===oh||A.magFilter===Wc||A.magFilter===er||A.minFilter===qn||A.minFilter===oh||A.minFilter===Wc||A.minFilter===er)&&mt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),a.texParameteri(F,a.TEXTURE_WRAP_S,te[A.wrapS]),a.texParameteri(F,a.TEXTURE_WRAP_T,te[A.wrapT]),(F===a.TEXTURE_3D||F===a.TEXTURE_2D_ARRAY)&&a.texParameteri(F,a.TEXTURE_WRAP_R,te[A.wrapR]),a.texParameteri(F,a.TEXTURE_MAG_FILTER,Ee[A.magFilter]),a.texParameteri(F,a.TEXTURE_MIN_FILTER,Ee[A.minFilter]),A.compareFunction&&(a.texParameteri(F,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(F,a.TEXTURE_COMPARE_FUNC,Le[A.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(A.magFilter===Gn||A.minFilter!==Wc&&A.minFilter!==er||A.type===Wi&&e.has("OES_texture_float_linear")===!1)return;if(A.anisotropy>1||s.get(A).__currentAnisotropy){const ne=e.get("EXT_texture_filter_anisotropic");a.texParameterf(F,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(A.anisotropy,l.getMaxAnisotropy())),s.get(A).__currentAnisotropy=A.anisotropy}}}function oe(F,A){let ne=!1;F.__webglInit===void 0&&(F.__webglInit=!0,A.addEventListener("dispose",L));const re=A.source;let fe=M.get(re);fe===void 0&&(fe={},M.set(re,fe));const Ne=j(A);if(Ne!==F.__cacheKey){fe[Ne]===void 0&&(fe[Ne]={texture:a.createTexture(),usedTimes:0},d.memory.textures++,ne=!0),fe[Ne].usedTimes++;const He=fe[F.__cacheKey];He!==void 0&&(fe[F.__cacheKey].usedTimes--,He.usedTimes===0&&X(A)),F.__cacheKey=Ne,F.__webglTexture=fe[Ne].texture}return ne}function Me(F,A,ne){return Math.floor(Math.floor(F/ne)/A)}function Ae(F,A,ne,re){const Ne=F.updateRanges;if(Ne.length===0)n.texSubImage2D(a.TEXTURE_2D,0,0,0,A.width,A.height,ne,re,A.data);else{Ne.sort((We,Xe)=>We.start-Xe.start);let He=0;for(let We=1;We<Ne.length;We++){const Xe=Ne[He],ke=Ne[We],nt=Xe.start+Xe.count,Ce=Me(ke.start,A.width,4),rt=Me(Xe.start,A.width,4);ke.start<=nt+1&&Ce===rt&&Me(ke.start+ke.count-1,A.width,4)===Ce?Xe.count=Math.max(Xe.count,ke.start+ke.count-Xe.start):(++He,Ne[He]=ke)}Ne.length=He+1;const ge=n.getParameter(a.UNPACK_ROW_LENGTH),le=n.getParameter(a.UNPACK_SKIP_PIXELS),Ie=n.getParameter(a.UNPACK_SKIP_ROWS);n.pixelStorei(a.UNPACK_ROW_LENGTH,A.width);for(let We=0,Xe=Ne.length;We<Xe;We++){const ke=Ne[We],nt=Math.floor(ke.start/4),Ce=Math.ceil(ke.count/4),rt=nt%A.width,Z=Math.floor(nt/A.width),Oe=Ce,ye=1;n.pixelStorei(a.UNPACK_SKIP_PIXELS,rt),n.pixelStorei(a.UNPACK_SKIP_ROWS,Z),n.texSubImage2D(a.TEXTURE_2D,0,rt,Z,Oe,ye,ne,re,A.data)}F.clearUpdateRanges(),n.pixelStorei(a.UNPACK_ROW_LENGTH,ge),n.pixelStorei(a.UNPACK_SKIP_PIXELS,le),n.pixelStorei(a.UNPACK_SKIP_ROWS,Ie)}}function ze(F,A,ne){let re=a.TEXTURE_2D;(A.isDataArrayTexture||A.isCompressedArrayTexture)&&(re=a.TEXTURE_2D_ARRAY),A.isData3DTexture&&(re=a.TEXTURE_3D);const fe=oe(F,A),Ne=A.source;n.bindTexture(re,F.__webglTexture,a.TEXTURE0+ne);const He=s.get(Ne);if(Ne.version!==He.__version||fe===!0){if(n.activeTexture(a.TEXTURE0+ne),(typeof ImageBitmap<"u"&&A.image instanceof ImageBitmap)===!1){const ye=zt.getPrimaries(zt.workingColorSpace),Pe=A.colorSpace===Ms?null:zt.getPrimaries(A.colorSpace),Ge=A.colorSpace===Ms||ye===Pe?a.NONE:a.BROWSER_DEFAULT_WEBGL;n.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,A.flipY),n.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,A.premultiplyAlpha),n.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge)}n.pixelStorei(a.UNPACK_ALIGNMENT,A.unpackAlignment);let le=y(A.image,!1,l.maxTextureSize);le=Ue(A,le);const Ie=c.convert(A.format,A.colorSpace),We=c.convert(A.type);let Xe=R(A.internalFormat,Ie,We,A.normalized,A.colorSpace,A.isVideoTexture);Fe(re,A);let ke;const nt=A.mipmaps,Ce=A.isVideoTexture!==!0,rt=He.__version===void 0||fe===!0,Z=Ne.dataReady,Oe=B(A,le);if(A.isDepthTexture)Xe=I(A.format===tr,A.type),rt&&(Ce?n.texStorage2D(a.TEXTURE_2D,1,Xe,le.width,le.height):n.texImage2D(a.TEXTURE_2D,0,Xe,le.width,le.height,0,Ie,We,null));else if(A.isDataTexture)if(nt.length>0){Ce&&rt&&n.texStorage2D(a.TEXTURE_2D,Oe,Xe,nt[0].width,nt[0].height);for(let ye=0,Pe=nt.length;ye<Pe;ye++)ke=nt[ye],Ce?Z&&n.texSubImage2D(a.TEXTURE_2D,ye,0,0,ke.width,ke.height,Ie,We,ke.data):n.texImage2D(a.TEXTURE_2D,ye,Xe,ke.width,ke.height,0,Ie,We,ke.data);A.generateMipmaps=!1}else Ce?(rt&&n.texStorage2D(a.TEXTURE_2D,Oe,Xe,le.width,le.height),Z&&Ae(A,le,Ie,We)):n.texImage2D(a.TEXTURE_2D,0,Xe,le.width,le.height,0,Ie,We,le.data);else if(A.isCompressedTexture)if(A.isCompressedArrayTexture){Ce&&rt&&n.texStorage3D(a.TEXTURE_2D_ARRAY,Oe,Xe,nt[0].width,nt[0].height,le.depth);for(let ye=0,Pe=nt.length;ye<Pe;ye++)if(ke=nt[ye],A.format!==qi)if(Ie!==null)if(Ce){if(Z)if(A.layerUpdates.size>0){const Ge=Jv(ke.width,ke.height,A.format,A.type);for(const De of A.layerUpdates){const Ze=ke.data.subarray(De*Ge/ke.data.BYTES_PER_ELEMENT,(De+1)*Ge/ke.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,ye,0,0,De,ke.width,ke.height,1,Ie,Ze)}A.clearLayerUpdates()}else n.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,ye,0,0,0,ke.width,ke.height,le.depth,Ie,ke.data)}else n.compressedTexImage3D(a.TEXTURE_2D_ARRAY,ye,Xe,ke.width,ke.height,le.depth,0,ke.data,0,0);else mt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ce?Z&&n.texSubImage3D(a.TEXTURE_2D_ARRAY,ye,0,0,0,ke.width,ke.height,le.depth,Ie,We,ke.data):n.texImage3D(a.TEXTURE_2D_ARRAY,ye,Xe,ke.width,ke.height,le.depth,0,Ie,We,ke.data)}else{Ce&&rt&&n.texStorage2D(a.TEXTURE_2D,Oe,Xe,nt[0].width,nt[0].height);for(let ye=0,Pe=nt.length;ye<Pe;ye++)ke=nt[ye],A.format!==qi?Ie!==null?Ce?Z&&n.compressedTexSubImage2D(a.TEXTURE_2D,ye,0,0,ke.width,ke.height,Ie,ke.data):n.compressedTexImage2D(a.TEXTURE_2D,ye,Xe,ke.width,ke.height,0,ke.data):mt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ce?Z&&n.texSubImage2D(a.TEXTURE_2D,ye,0,0,ke.width,ke.height,Ie,We,ke.data):n.texImage2D(a.TEXTURE_2D,ye,Xe,ke.width,ke.height,0,Ie,We,ke.data)}else if(A.isDataArrayTexture)if(Ce){if(rt&&n.texStorage3D(a.TEXTURE_2D_ARRAY,Oe,Xe,le.width,le.height,le.depth),Z)if(A.layerUpdates.size>0){const ye=Jv(le.width,le.height,A.format,A.type);for(const Pe of A.layerUpdates){const Ge=le.data.subarray(Pe*ye/le.data.BYTES_PER_ELEMENT,(Pe+1)*ye/le.data.BYTES_PER_ELEMENT);n.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,Pe,le.width,le.height,1,Ie,We,Ge)}A.clearLayerUpdates()}else n.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,0,le.width,le.height,le.depth,Ie,We,le.data)}else n.texImage3D(a.TEXTURE_2D_ARRAY,0,Xe,le.width,le.height,le.depth,0,Ie,We,le.data);else if(A.isData3DTexture)Ce?(rt&&n.texStorage3D(a.TEXTURE_3D,Oe,Xe,le.width,le.height,le.depth),Z&&n.texSubImage3D(a.TEXTURE_3D,0,0,0,0,le.width,le.height,le.depth,Ie,We,le.data)):n.texImage3D(a.TEXTURE_3D,0,Xe,le.width,le.height,le.depth,0,Ie,We,le.data);else if(A.isFramebufferTexture){if(rt)if(Ce)n.texStorage2D(a.TEXTURE_2D,Oe,Xe,le.width,le.height);else{let ye=le.width,Pe=le.height;for(let Ge=0;Ge<Oe;Ge++)n.texImage2D(a.TEXTURE_2D,Ge,Xe,ye,Pe,0,Ie,We,null),ye>>=1,Pe>>=1}}else if(A.isHTMLTexture){if("texElementImage2D"in a){const ye=a.canvas;if(ye.hasAttribute("layoutsubtree")||ye.setAttribute("layoutsubtree","true"),le.parentNode!==ye){ye.appendChild(le),S.add(A),ye.onpaint=Pe=>{const Ge=Pe.changedElements;for(const De of S)Ge.includes(De.image)&&(De.needsUpdate=!0)},ye.requestPaint();return}if(a.texElementImage2D.length===3)a.texElementImage2D(a.TEXTURE_2D,a.RGBA8,le);else{const Ge=a.RGBA,De=a.RGBA,Ze=a.UNSIGNED_BYTE;a.texElementImage2D(a.TEXTURE_2D,0,Ge,De,Ze,le)}a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)}}else if(nt.length>0){if(Ce&&rt){const ye=ft(nt[0]);n.texStorage2D(a.TEXTURE_2D,Oe,Xe,ye.width,ye.height)}for(let ye=0,Pe=nt.length;ye<Pe;ye++)ke=nt[ye],Ce?Z&&n.texSubImage2D(a.TEXTURE_2D,ye,0,0,Ie,We,ke):n.texImage2D(a.TEXTURE_2D,ye,Xe,Ie,We,ke);A.generateMipmaps=!1}else if(Ce){if(rt){const ye=ft(le);n.texStorage2D(a.TEXTURE_2D,Oe,Xe,ye.width,ye.height)}Z&&n.texSubImage2D(a.TEXTURE_2D,0,0,0,Ie,We,le)}else n.texImage2D(a.TEXTURE_2D,0,Xe,Ie,We,le);x(A)&&P(re),He.__version=Ne.version,A.onUpdate&&A.onUpdate(A)}F.__version=A.version}function at(F,A,ne){if(A.image.length!==6)return;const re=oe(F,A),fe=A.source;n.bindTexture(a.TEXTURE_CUBE_MAP,F.__webglTexture,a.TEXTURE0+ne);const Ne=s.get(fe);if(fe.version!==Ne.__version||re===!0){n.activeTexture(a.TEXTURE0+ne);const He=zt.getPrimaries(zt.workingColorSpace),ge=A.colorSpace===Ms?null:zt.getPrimaries(A.colorSpace),le=A.colorSpace===Ms||He===ge?a.NONE:a.BROWSER_DEFAULT_WEBGL;n.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,A.flipY),n.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,A.premultiplyAlpha),n.pixelStorei(a.UNPACK_ALIGNMENT,A.unpackAlignment),n.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,le);const Ie=A.isCompressedTexture||A.image[0].isCompressedTexture,We=A.image[0]&&A.image[0].isDataTexture,Xe=[];for(let De=0;De<6;De++)!Ie&&!We?Xe[De]=y(A.image[De],!0,l.maxCubemapSize):Xe[De]=We?A.image[De].image:A.image[De],Xe[De]=Ue(A,Xe[De]);const ke=Xe[0],nt=c.convert(A.format,A.colorSpace),Ce=c.convert(A.type),rt=R(A.internalFormat,nt,Ce,A.normalized,A.colorSpace),Z=A.isVideoTexture!==!0,Oe=Ne.__version===void 0||re===!0,ye=fe.dataReady;let Pe=B(A,ke);Fe(a.TEXTURE_CUBE_MAP,A);let Ge;if(Ie){Z&&Oe&&n.texStorage2D(a.TEXTURE_CUBE_MAP,Pe,rt,ke.width,ke.height);for(let De=0;De<6;De++){Ge=Xe[De].mipmaps;for(let Ze=0;Ze<Ge.length;Ze++){const qe=Ge[Ze];A.format!==qi?nt!==null?Z?ye&&n.compressedTexSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ze,0,0,qe.width,qe.height,nt,qe.data):n.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ze,rt,qe.width,qe.height,0,qe.data):mt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ze,0,0,qe.width,qe.height,nt,Ce,qe.data):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ze,rt,qe.width,qe.height,0,nt,Ce,qe.data)}}}else{if(Ge=A.mipmaps,Z&&Oe){Ge.length>0&&Pe++;const De=ft(Xe[0]);n.texStorage2D(a.TEXTURE_CUBE_MAP,Pe,rt,De.width,De.height)}for(let De=0;De<6;De++)if(We){Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,0,0,0,Xe[De].width,Xe[De].height,nt,Ce,Xe[De].data):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,0,rt,Xe[De].width,Xe[De].height,0,nt,Ce,Xe[De].data);for(let Ze=0;Ze<Ge.length;Ze++){const qt=Ge[Ze].image[De].image;Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ze+1,0,0,qt.width,qt.height,nt,Ce,qt.data):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ze+1,rt,qt.width,qt.height,0,nt,Ce,qt.data)}}else{Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,0,0,0,nt,Ce,Xe[De]):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,0,rt,nt,Ce,Xe[De]);for(let Ze=0;Ze<Ge.length;Ze++){const qe=Ge[Ze];Z?ye&&n.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ze+1,0,0,nt,Ce,qe.image[De]):n.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+De,Ze+1,rt,nt,Ce,qe.image[De])}}}x(A)&&P(a.TEXTURE_CUBE_MAP),Ne.__version=fe.version,A.onUpdate&&A.onUpdate(A)}F.__version=A.version}function Je(F,A,ne,re,fe,Ne){const He=c.convert(ne.format,ne.colorSpace),ge=c.convert(ne.type),le=R(ne.internalFormat,He,ge,ne.normalized,ne.colorSpace),Ie=s.get(A),We=s.get(ne);if(We.__renderTarget=A,!Ie.__hasExternalTextures){const Xe=Math.max(1,A.width>>Ne),ke=Math.max(1,A.height>>Ne);fe===a.TEXTURE_3D||fe===a.TEXTURE_2D_ARRAY?n.texImage3D(fe,Ne,le,Xe,ke,A.depth,0,He,ge,null):n.texImage2D(fe,Ne,le,Xe,ke,0,He,ge,null)}n.bindFramebuffer(a.FRAMEBUFFER,F),J(A)?p.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,re,fe,We.__webglTexture,0,dt(A)):(fe===a.TEXTURE_2D||fe>=a.TEXTURE_CUBE_MAP_POSITIVE_X&&fe<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&a.framebufferTexture2D(a.FRAMEBUFFER,re,fe,We.__webglTexture,Ne),n.bindFramebuffer(a.FRAMEBUFFER,null)}function Gt(F,A,ne){if(a.bindRenderbuffer(a.RENDERBUFFER,F),A.depthBuffer){const re=A.depthTexture,fe=re&&re.isDepthTexture?re.type:null,Ne=I(A.stencilBuffer,fe),He=A.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;J(A)?p.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,dt(A),Ne,A.width,A.height):ne?a.renderbufferStorageMultisample(a.RENDERBUFFER,dt(A),Ne,A.width,A.height):a.renderbufferStorage(a.RENDERBUFFER,Ne,A.width,A.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,He,a.RENDERBUFFER,F)}else{const re=A.textures;for(let fe=0;fe<re.length;fe++){const Ne=re[fe],He=c.convert(Ne.format,Ne.colorSpace),ge=c.convert(Ne.type),le=R(Ne.internalFormat,He,ge,Ne.normalized,Ne.colorSpace);J(A)?p.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,dt(A),le,A.width,A.height):ne?a.renderbufferStorageMultisample(a.RENDERBUFFER,dt(A),le,A.width,A.height):a.renderbufferStorage(a.RENDERBUFFER,le,A.width,A.height)}}a.bindRenderbuffer(a.RENDERBUFFER,null)}function ut(F,A,ne){const re=A.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(a.FRAMEBUFFER,F),!(A.depthTexture&&A.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const fe=s.get(A.depthTexture);if(fe.__renderTarget=A,(!fe.__webglTexture||A.depthTexture.image.width!==A.width||A.depthTexture.image.height!==A.height)&&(A.depthTexture.image.width=A.width,A.depthTexture.image.height=A.height,A.depthTexture.needsUpdate=!0),re){if(fe.__webglInit===void 0&&(fe.__webglInit=!0,A.depthTexture.addEventListener("dispose",L)),fe.__webglTexture===void 0){fe.__webglTexture=a.createTexture(),n.bindTexture(a.TEXTURE_CUBE_MAP,fe.__webglTexture),Fe(a.TEXTURE_CUBE_MAP,A.depthTexture);const Ie=c.convert(A.depthTexture.format),We=c.convert(A.depthTexture.type);let Xe;A.depthTexture.format===Xa?Xe=a.DEPTH_COMPONENT24:A.depthTexture.format===tr&&(Xe=a.DEPTH24_STENCIL8);for(let ke=0;ke<6;ke++)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+ke,0,Xe,A.width,A.height,0,Ie,We,null)}}else ae(A.depthTexture,0);const Ne=fe.__webglTexture,He=dt(A),ge=re?a.TEXTURE_CUBE_MAP_POSITIVE_X+ne:a.TEXTURE_2D,le=A.depthTexture.format===tr?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;if(A.depthTexture.format===Xa)J(A)?p.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,le,ge,Ne,0,He):a.framebufferTexture2D(a.FRAMEBUFFER,le,ge,Ne,0);else if(A.depthTexture.format===tr)J(A)?p.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,le,ge,Ne,0,He):a.framebufferTexture2D(a.FRAMEBUFFER,le,ge,Ne,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function _t(F){const A=s.get(F),ne=F.isWebGLCubeRenderTarget===!0;if(A.__boundDepthTexture!==F.depthTexture){const re=F.depthTexture;if(A.__depthDisposeCallback&&A.__depthDisposeCallback(),re){const fe=()=>{delete A.__boundDepthTexture,delete A.__depthDisposeCallback,re.removeEventListener("dispose",fe)};re.addEventListener("dispose",fe),A.__depthDisposeCallback=fe}A.__boundDepthTexture=re}if(F.depthTexture&&!A.__autoAllocateDepthBuffer)if(ne)for(let re=0;re<6;re++)ut(A.__webglFramebuffer[re],F,re);else{const re=F.texture.mipmaps;re&&re.length>0?ut(A.__webglFramebuffer[0],F,0):ut(A.__webglFramebuffer,F,0)}else if(ne){A.__webglDepthbuffer=[];for(let re=0;re<6;re++)if(n.bindFramebuffer(a.FRAMEBUFFER,A.__webglFramebuffer[re]),A.__webglDepthbuffer[re]===void 0)A.__webglDepthbuffer[re]=a.createRenderbuffer(),Gt(A.__webglDepthbuffer[re],F,!1);else{const fe=F.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,Ne=A.__webglDepthbuffer[re];a.bindRenderbuffer(a.RENDERBUFFER,Ne),a.framebufferRenderbuffer(a.FRAMEBUFFER,fe,a.RENDERBUFFER,Ne)}}else{const re=F.texture.mipmaps;if(re&&re.length>0?n.bindFramebuffer(a.FRAMEBUFFER,A.__webglFramebuffer[0]):n.bindFramebuffer(a.FRAMEBUFFER,A.__webglFramebuffer),A.__webglDepthbuffer===void 0)A.__webglDepthbuffer=a.createRenderbuffer(),Gt(A.__webglDepthbuffer,F,!1);else{const fe=F.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,Ne=A.__webglDepthbuffer;a.bindRenderbuffer(a.RENDERBUFFER,Ne),a.framebufferRenderbuffer(a.FRAMEBUFFER,fe,a.RENDERBUFFER,Ne)}}n.bindFramebuffer(a.FRAMEBUFFER,null)}function xt(F,A,ne){const re=s.get(F);A!==void 0&&Je(re.__webglFramebuffer,F,F.texture,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,0),ne!==void 0&&_t(F)}function ot(F){const A=F.texture,ne=s.get(F),re=s.get(A);F.addEventListener("dispose",T);const fe=F.textures,Ne=F.isWebGLCubeRenderTarget===!0,He=fe.length>1;if(He||(re.__webglTexture===void 0&&(re.__webglTexture=a.createTexture()),re.__version=A.version,d.memory.textures++),Ne){ne.__webglFramebuffer=[];for(let ge=0;ge<6;ge++)if(A.mipmaps&&A.mipmaps.length>0){ne.__webglFramebuffer[ge]=[];for(let le=0;le<A.mipmaps.length;le++)ne.__webglFramebuffer[ge][le]=a.createFramebuffer()}else ne.__webglFramebuffer[ge]=a.createFramebuffer()}else{if(A.mipmaps&&A.mipmaps.length>0){ne.__webglFramebuffer=[];for(let ge=0;ge<A.mipmaps.length;ge++)ne.__webglFramebuffer[ge]=a.createFramebuffer()}else ne.__webglFramebuffer=a.createFramebuffer();if(He)for(let ge=0,le=fe.length;ge<le;ge++){const Ie=s.get(fe[ge]);Ie.__webglTexture===void 0&&(Ie.__webglTexture=a.createTexture(),d.memory.textures++)}if(F.samples>0&&J(F)===!1){ne.__webglMultisampledFramebuffer=a.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(a.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let ge=0;ge<fe.length;ge++){const le=fe[ge];ne.__webglColorRenderbuffer[ge]=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,ne.__webglColorRenderbuffer[ge]);const Ie=c.convert(le.format,le.colorSpace),We=c.convert(le.type),Xe=R(le.internalFormat,Ie,We,le.normalized,le.colorSpace,F.isXRRenderTarget===!0),ke=dt(F);a.renderbufferStorageMultisample(a.RENDERBUFFER,ke,Xe,F.width,F.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+ge,a.RENDERBUFFER,ne.__webglColorRenderbuffer[ge])}a.bindRenderbuffer(a.RENDERBUFFER,null),F.depthBuffer&&(ne.__webglDepthRenderbuffer=a.createRenderbuffer(),Gt(ne.__webglDepthRenderbuffer,F,!0)),n.bindFramebuffer(a.FRAMEBUFFER,null)}}if(Ne){n.bindTexture(a.TEXTURE_CUBE_MAP,re.__webglTexture),Fe(a.TEXTURE_CUBE_MAP,A);for(let ge=0;ge<6;ge++)if(A.mipmaps&&A.mipmaps.length>0)for(let le=0;le<A.mipmaps.length;le++)Je(ne.__webglFramebuffer[ge][le],F,A,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+ge,le);else Je(ne.__webglFramebuffer[ge],F,A,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0);x(A)&&P(a.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(He){for(let ge=0,le=fe.length;ge<le;ge++){const Ie=fe[ge],We=s.get(Ie);let Xe=a.TEXTURE_2D;(F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(Xe=F.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),n.bindTexture(Xe,We.__webglTexture),Fe(Xe,Ie),Je(ne.__webglFramebuffer,F,Ie,a.COLOR_ATTACHMENT0+ge,Xe,0),x(Ie)&&P(Xe)}n.unbindTexture()}else{let ge=a.TEXTURE_2D;if((F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(ge=F.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),n.bindTexture(ge,re.__webglTexture),Fe(ge,A),A.mipmaps&&A.mipmaps.length>0)for(let le=0;le<A.mipmaps.length;le++)Je(ne.__webglFramebuffer[le],F,A,a.COLOR_ATTACHMENT0,ge,le);else Je(ne.__webglFramebuffer,F,A,a.COLOR_ATTACHMENT0,ge,0);x(A)&&P(ge),n.unbindTexture()}F.depthBuffer&&_t(F)}function Ht(F){const A=F.textures;for(let ne=0,re=A.length;ne<re;ne++){const fe=A[ne];if(x(fe)){const Ne=O(F),He=s.get(fe).__webglTexture;n.bindTexture(Ne,He),P(Ne),n.unbindTexture()}}}const Bt=[],Zt=[];function Vt(F){if(F.samples>0){if(J(F)===!1){const A=F.textures,ne=F.width,re=F.height;let fe=a.COLOR_BUFFER_BIT;const Ne=F.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,He=s.get(F),ge=A.length>1;if(ge)for(let Ie=0;Ie<A.length;Ie++)n.bindFramebuffer(a.FRAMEBUFFER,He.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Ie,a.RENDERBUFFER,null),n.bindFramebuffer(a.FRAMEBUFFER,He.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+Ie,a.TEXTURE_2D,null,0);n.bindFramebuffer(a.READ_FRAMEBUFFER,He.__webglMultisampledFramebuffer);const le=F.texture.mipmaps;le&&le.length>0?n.bindFramebuffer(a.DRAW_FRAMEBUFFER,He.__webglFramebuffer[0]):n.bindFramebuffer(a.DRAW_FRAMEBUFFER,He.__webglFramebuffer);for(let Ie=0;Ie<A.length;Ie++){if(F.resolveDepthBuffer&&(F.depthBuffer&&(fe|=a.DEPTH_BUFFER_BIT),F.stencilBuffer&&F.resolveStencilBuffer&&(fe|=a.STENCIL_BUFFER_BIT)),ge){a.framebufferRenderbuffer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.RENDERBUFFER,He.__webglColorRenderbuffer[Ie]);const We=s.get(A[Ie]).__webglTexture;a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,We,0)}a.blitFramebuffer(0,0,ne,re,0,0,ne,re,fe,a.NEAREST),m===!0&&(Bt.length=0,Zt.length=0,Bt.push(a.COLOR_ATTACHMENT0+Ie),F.depthBuffer&&F.resolveDepthBuffer===!1&&(Bt.push(Ne),Zt.push(Ne),a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,Zt)),a.invalidateFramebuffer(a.READ_FRAMEBUFFER,Bt))}if(n.bindFramebuffer(a.READ_FRAMEBUFFER,null),n.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),ge)for(let Ie=0;Ie<A.length;Ie++){n.bindFramebuffer(a.FRAMEBUFFER,He.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Ie,a.RENDERBUFFER,He.__webglColorRenderbuffer[Ie]);const We=s.get(A[Ie]).__webglTexture;n.bindFramebuffer(a.FRAMEBUFFER,He.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+Ie,a.TEXTURE_2D,We,0)}n.bindFramebuffer(a.DRAW_FRAMEBUFFER,He.__webglMultisampledFramebuffer)}else if(F.depthBuffer&&F.resolveDepthBuffer===!1&&m){const A=F.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,[A])}}}function dt(F){return Math.min(l.maxSamples,F.samples)}function J(F){const A=s.get(F);return F.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&A.__useRenderToTexture!==!1}function z(F){const A=d.render.frame;v.get(F)!==A&&(v.set(F,A),F.update())}function Ue(F,A){const ne=F.colorSpace,re=F.format,fe=F.type;return F.isCompressedTexture===!0||F.isVideoTexture===!0||ne!==Lu&&ne!==Ms&&(zt.getTransfer(ne)===tn?(re!==qi||fe!==xi)&&mt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):kt("WebGLTextures: Unsupported texture color space:",ne)),A}function ft(F){return typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement?(h.width=F.naturalWidth||F.width,h.height=F.naturalHeight||F.height):typeof VideoFrame<"u"&&F instanceof VideoFrame?(h.width=F.displayWidth,h.height=F.displayHeight):(h.width=F.width,h.height=F.height),h}this.allocateTextureUnit=V,this.resetTextureUnits=ue,this.getTextureUnits=pe,this.setTextureUnits=Q,this.setTexture2D=ae,this.setTexture2DArray=_e,this.setTexture3D=ve,this.setTextureCube=H,this.rebindTextures=xt,this.setupRenderTarget=ot,this.updateRenderTargetMipmap=Ht,this.updateMultisampleRenderTarget=Vt,this.setupDepthRenderbuffer=_t,this.setupFrameBufferTexture=Je,this.useMultisampledRTT=J,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function oR(a,e){function n(s,l=Ms){let c;const d=zt.getTransfer(l);if(s===xi)return a.UNSIGNED_BYTE;if(s===Kp)return a.UNSIGNED_SHORT_4_4_4_4;if(s===$p)return a.UNSIGNED_SHORT_5_5_5_1;if(s===cy)return a.UNSIGNED_INT_5_9_9_9_REV;if(s===uy)return a.UNSIGNED_INT_10F_11F_11F_REV;if(s===oy)return a.BYTE;if(s===ly)return a.SHORT;if(s===Dl)return a.UNSIGNED_SHORT;if(s===Zp)return a.INT;if(s===pa)return a.UNSIGNED_INT;if(s===Wi)return a.FLOAT;if(s===ja)return a.HALF_FLOAT;if(s===dy)return a.ALPHA;if(s===fy)return a.RGB;if(s===qi)return a.RGBA;if(s===Xa)return a.DEPTH_COMPONENT;if(s===tr)return a.DEPTH_STENCIL;if(s===Qp)return a.RED;if(s===Jp)return a.RED_INTEGER;if(s===rr)return a.RG;if(s===em)return a.RG_INTEGER;if(s===tm)return a.RGBA_INTEGER;if(s===Eu||s===Tu||s===Au||s===Cu)if(d===tn)if(c=e.get("WEBGL_compressed_texture_s3tc_srgb"),c!==null){if(s===Eu)return c.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Tu)return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Au)return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Cu)return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(c=e.get("WEBGL_compressed_texture_s3tc"),c!==null){if(s===Eu)return c.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Tu)return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Au)return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Cu)return c.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===ip||s===ap||s===sp||s===rp)if(c=e.get("WEBGL_compressed_texture_pvrtc"),c!==null){if(s===ip)return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===ap)return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===sp)return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===rp)return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===op||s===lp||s===cp||s===up||s===dp||s===Nu||s===fp)if(c=e.get("WEBGL_compressed_texture_etc"),c!==null){if(s===op||s===lp)return d===tn?c.COMPRESSED_SRGB8_ETC2:c.COMPRESSED_RGB8_ETC2;if(s===cp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:c.COMPRESSED_RGBA8_ETC2_EAC;if(s===up)return c.COMPRESSED_R11_EAC;if(s===dp)return c.COMPRESSED_SIGNED_R11_EAC;if(s===Nu)return c.COMPRESSED_RG11_EAC;if(s===fp)return c.COMPRESSED_SIGNED_RG11_EAC}else return null;if(s===hp||s===pp||s===mp||s===gp||s===_p||s===vp||s===xp||s===yp||s===Sp||s===bp||s===Mp||s===Ep||s===Tp||s===Ap)if(c=e.get("WEBGL_compressed_texture_astc"),c!==null){if(s===hp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:c.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===pp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:c.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===mp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:c.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===gp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:c.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===_p)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:c.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===vp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:c.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===xp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:c.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===yp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:c.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Sp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:c.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===bp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:c.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Mp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:c.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Ep)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:c.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Tp)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:c.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Ap)return d===tn?c.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:c.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Cp||s===wp||s===Rp)if(c=e.get("EXT_texture_compression_bptc"),c!==null){if(s===Cp)return d===tn?c.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:c.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===wp)return c.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===Rp)return c.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Dp||s===Np||s===Uu||s===Up)if(c=e.get("EXT_texture_compression_rgtc"),c!==null){if(s===Dp)return c.COMPRESSED_RED_RGTC1_EXT;if(s===Np)return c.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Uu)return c.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Up)return c.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Nl?a.UNSIGNED_INT_24_8:a[s]!==void 0?a[s]:null}return{convert:n}}const lR=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,cR=`
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 uR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const s=new My(e.texture);(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const n=e.cameras[0].viewport,s=new $i({vertexShader:lR,fragmentShader:cR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Ki(new Vu(20,20),s)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class dR extends Rs{constructor(e,n){super();const s=this;let l=null,c=1,d=null,p="local-floor",m=1,h=null,v=null,S=null,_=null,M=null,E=null;const C=typeof XRWebGLBinding<"u",y=new uR,x={},P=n.getContextAttributes();let O=null,R=null;const I=[],B=[],L=new bt;let T=null;const U=new Ni;U.viewport=new pn;const X=new Ni;X.viewport=new pn;const G=[U,X],K=new xT;let ue=null,pe=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(oe){let Me=I[oe];return Me===void 0&&(Me=new ph,I[oe]=Me),Me.getTargetRaySpace()},this.getControllerGrip=function(oe){let Me=I[oe];return Me===void 0&&(Me=new ph,I[oe]=Me),Me.getGripSpace()},this.getHand=function(oe){let Me=I[oe];return Me===void 0&&(Me=new ph,I[oe]=Me),Me.getHandSpace()};function Q(oe){const Me=B.indexOf(oe.inputSource);if(Me===-1)return;const Ae=I[Me];Ae!==void 0&&(Ae.update(oe.inputSource,oe.frame,h||d),Ae.dispatchEvent({type:oe.type,data:oe.inputSource}))}function V(){l.removeEventListener("select",Q),l.removeEventListener("selectstart",Q),l.removeEventListener("selectend",Q),l.removeEventListener("squeeze",Q),l.removeEventListener("squeezestart",Q),l.removeEventListener("squeezeend",Q),l.removeEventListener("end",V),l.removeEventListener("inputsourceschange",j);for(let oe=0;oe<I.length;oe++){const Me=B[oe];Me!==null&&(B[oe]=null,I[oe].disconnect(Me))}ue=null,pe=null,y.reset();for(const oe in x)delete x[oe];e.setRenderTarget(O),M=null,_=null,S=null,l=null,R=null,Fe.stop(),s.isPresenting=!1,e.setPixelRatio(T),e.setSize(L.width,L.height,!1),s.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(oe){c=oe,s.isPresenting===!0&&mt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(oe){p=oe,s.isPresenting===!0&&mt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||d},this.setReferenceSpace=function(oe){h=oe},this.getBaseLayer=function(){return _!==null?_:M},this.getBinding=function(){return S===null&&C&&(S=new XRWebGLBinding(l,n)),S},this.getFrame=function(){return E},this.getSession=function(){return l},this.setSession=async function(oe){if(l=oe,l!==null){if(O=e.getRenderTarget(),l.addEventListener("select",Q),l.addEventListener("selectstart",Q),l.addEventListener("selectend",Q),l.addEventListener("squeeze",Q),l.addEventListener("squeezestart",Q),l.addEventListener("squeezeend",Q),l.addEventListener("end",V),l.addEventListener("inputsourceschange",j),P.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(L),C&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ae=null,ze=null,at=null;P.depth&&(at=P.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ae=P.stencil?tr:Xa,ze=P.stencil?Nl:pa);const Je={colorFormat:n.RGBA8,depthFormat:at,scaleFactor:c};S=this.getBinding(),_=S.createProjectionLayer(Je),l.updateRenderState({layers:[_]}),e.setPixelRatio(1),e.setSize(_.textureWidth,_.textureHeight,!1),R=new fa(_.textureWidth,_.textureHeight,{format:qi,type:xi,depthTexture:new xo(_.textureWidth,_.textureHeight,ze,void 0,void 0,void 0,void 0,void 0,void 0,Ae),stencilBuffer:P.stencil,colorSpace:e.outputColorSpace,samples:P.antialias?4:0,resolveDepthBuffer:_.ignoreDepthValues===!1,resolveStencilBuffer:_.ignoreDepthValues===!1})}else{const Ae={antialias:P.antialias,alpha:!0,depth:P.depth,stencil:P.stencil,framebufferScaleFactor:c};M=new XRWebGLLayer(l,n,Ae),l.updateRenderState({baseLayer:M}),e.setPixelRatio(1),e.setSize(M.framebufferWidth,M.framebufferHeight,!1),R=new fa(M.framebufferWidth,M.framebufferHeight,{format:qi,type:xi,colorSpace:e.outputColorSpace,stencilBuffer:P.stencil,resolveDepthBuffer:M.ignoreDepthValues===!1,resolveStencilBuffer:M.ignoreDepthValues===!1})}R.isXRRenderTarget=!0,this.setFoveation(m),h=null,d=await l.requestReferenceSpace(p),Fe.setContext(l),Fe.start(),s.isPresenting=!0,s.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(l!==null)return l.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function j(oe){for(let Me=0;Me<oe.removed.length;Me++){const Ae=oe.removed[Me],ze=B.indexOf(Ae);ze>=0&&(B[ze]=null,I[ze].disconnect(Ae))}for(let Me=0;Me<oe.added.length;Me++){const Ae=oe.added[Me];let ze=B.indexOf(Ae);if(ze===-1){for(let Je=0;Je<I.length;Je++)if(Je>=B.length){B.push(Ae),ze=Je;break}else if(B[Je]===null){B[Je]=Ae,ze=Je;break}if(ze===-1)break}const at=I[ze];at&&at.connect(Ae)}}const ae=new se,_e=new se;function ve(oe,Me,Ae){ae.setFromMatrixPosition(Me.matrixWorld),_e.setFromMatrixPosition(Ae.matrixWorld);const ze=ae.distanceTo(_e),at=Me.projectionMatrix.elements,Je=Ae.projectionMatrix.elements,Gt=at[14]/(at[10]-1),ut=at[14]/(at[10]+1),_t=(at[9]+1)/at[5],xt=(at[9]-1)/at[5],ot=(at[8]-1)/at[0],Ht=(Je[8]+1)/Je[0],Bt=Gt*ot,Zt=Gt*Ht,Vt=ze/(-ot+Ht),dt=Vt*-ot;if(Me.matrixWorld.decompose(oe.position,oe.quaternion,oe.scale),oe.translateX(dt),oe.translateZ(Vt),oe.matrixWorld.compose(oe.position,oe.quaternion,oe.scale),oe.matrixWorldInverse.copy(oe.matrixWorld).invert(),at[10]===-1)oe.projectionMatrix.copy(Me.projectionMatrix),oe.projectionMatrixInverse.copy(Me.projectionMatrixInverse);else{const J=Gt+Vt,z=ut+Vt,Ue=Bt-dt,ft=Zt+(ze-dt),F=_t*ut/z*J,A=xt*ut/z*J;oe.projectionMatrix.makePerspective(Ue,ft,F,A,J,z),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert()}}function H(oe,Me){Me===null?oe.matrixWorld.copy(oe.matrix):oe.matrixWorld.multiplyMatrices(Me.matrixWorld,oe.matrix),oe.matrixWorldInverse.copy(oe.matrixWorld).invert()}this.updateCamera=function(oe){if(l===null)return;let Me=oe.near,Ae=oe.far;y.texture!==null&&(y.depthNear>0&&(Me=y.depthNear),y.depthFar>0&&(Ae=y.depthFar)),K.near=X.near=U.near=Me,K.far=X.far=U.far=Ae,(ue!==K.near||pe!==K.far)&&(l.updateRenderState({depthNear:K.near,depthFar:K.far}),ue=K.near,pe=K.far),K.layers.mask=oe.layers.mask|6,U.layers.mask=K.layers.mask&-5,X.layers.mask=K.layers.mask&-3;const ze=oe.parent,at=K.cameras;H(K,ze);for(let Je=0;Je<at.length;Je++)H(at[Je],ze);at.length===2?ve(K,U,X):K.projectionMatrix.copy(U.projectionMatrix),te(oe,K,ze)};function te(oe,Me,Ae){Ae===null?oe.matrix.copy(Me.matrixWorld):(oe.matrix.copy(Ae.matrixWorld),oe.matrix.invert(),oe.matrix.multiply(Me.matrixWorld)),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.updateMatrixWorld(!0),oe.projectionMatrix.copy(Me.projectionMatrix),oe.projectionMatrixInverse.copy(Me.projectionMatrixInverse),oe.isPerspectiveCamera&&(oe.fov=Lp*2*Math.atan(1/oe.projectionMatrix.elements[5]),oe.zoom=1)}this.getCamera=function(){return K},this.getFoveation=function(){if(!(_===null&&M===null))return m},this.setFoveation=function(oe){m=oe,_!==null&&(_.fixedFoveation=oe),M!==null&&M.fixedFoveation!==void 0&&(M.fixedFoveation=oe)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(K)},this.getCameraTexture=function(oe){return x[oe]};let Ee=null;function Le(oe,Me){if(v=Me.getViewerPose(h||d),E=Me,v!==null){const Ae=v.views;M!==null&&(e.setRenderTargetFramebuffer(R,M.framebuffer),e.setRenderTarget(R));let ze=!1;Ae.length!==K.cameras.length&&(K.cameras.length=0,ze=!0);for(let ut=0;ut<Ae.length;ut++){const _t=Ae[ut];let xt=null;if(M!==null)xt=M.getViewport(_t);else{const Ht=S.getViewSubImage(_,_t);xt=Ht.viewport,ut===0&&(e.setRenderTargetTextures(R,Ht.colorTexture,Ht.depthStencilTexture),e.setRenderTarget(R))}let ot=G[ut];ot===void 0&&(ot=new Ni,ot.layers.enable(ut),ot.viewport=new pn,G[ut]=ot),ot.matrix.fromArray(_t.transform.matrix),ot.matrix.decompose(ot.position,ot.quaternion,ot.scale),ot.projectionMatrix.fromArray(_t.projectionMatrix),ot.projectionMatrixInverse.copy(ot.projectionMatrix).invert(),ot.viewport.set(xt.x,xt.y,xt.width,xt.height),ut===0&&(K.matrix.copy(ot.matrix),K.matrix.decompose(K.position,K.quaternion,K.scale)),ze===!0&&K.cameras.push(ot)}const at=l.enabledFeatures;if(at&&at.includes("depth-sensing")&&l.depthUsage=="gpu-optimized"&&C){S=s.getBinding();const ut=S.getDepthInformation(Ae[0]);ut&&ut.isValid&&ut.texture&&y.init(ut,l.renderState)}if(at&&at.includes("camera-access")&&C){e.state.unbindTexture(),S=s.getBinding();for(let ut=0;ut<Ae.length;ut++){const _t=Ae[ut].camera;if(_t){let xt=x[_t];xt||(xt=new My,x[_t]=xt);const ot=S.getCameraImage(_t);xt.sourceTexture=ot}}}}for(let Ae=0;Ae<I.length;Ae++){const ze=B[Ae],at=I[Ae];ze!==null&&at!==void 0&&at.update(ze,Me,h||d)}Ee&&Ee(oe,Me),Me.detectedPlanes&&s.dispatchEvent({type:"planesdetected",data:Me}),E=null}const Fe=new Ay;Fe.setAnimationLoop(Le),this.setAnimationLoop=function(oe){Ee=oe},this.dispose=function(){}}}const fR=new cn,Ly=new St;Ly.set(-1,0,0,0,1,0,0,0,1);function hR(a,e){function n(y,x){y.matrixAutoUpdate===!0&&y.updateMatrix(),x.value.copy(y.matrix)}function s(y,x){x.color.getRGB(y.fogColor.value,Ey(a)),x.isFog?(y.fogNear.value=x.near,y.fogFar.value=x.far):x.isFogExp2&&(y.fogDensity.value=x.density)}function l(y,x,P,O,R){x.isNodeMaterial?x.uniformsNeedUpdate=!1:x.isMeshBasicMaterial?c(y,x):x.isMeshLambertMaterial?(c(y,x),x.envMap&&(y.envMapIntensity.value=x.envMapIntensity)):x.isMeshToonMaterial?(c(y,x),S(y,x)):x.isMeshPhongMaterial?(c(y,x),v(y,x),x.envMap&&(y.envMapIntensity.value=x.envMapIntensity)):x.isMeshStandardMaterial?(c(y,x),_(y,x),x.isMeshPhysicalMaterial&&M(y,x,R)):x.isMeshMatcapMaterial?(c(y,x),E(y,x)):x.isMeshDepthMaterial?c(y,x):x.isMeshDistanceMaterial?(c(y,x),C(y,x)):x.isMeshNormalMaterial?c(y,x):x.isLineBasicMaterial?(d(y,x),x.isLineDashedMaterial&&p(y,x)):x.isPointsMaterial?m(y,x,P,O):x.isSpriteMaterial?h(y,x):x.isShadowMaterial?(y.color.value.copy(x.color),y.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function c(y,x){y.opacity.value=x.opacity,x.color&&y.diffuse.value.copy(x.color),x.emissive&&y.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(y.map.value=x.map,n(x.map,y.mapTransform)),x.alphaMap&&(y.alphaMap.value=x.alphaMap,n(x.alphaMap,y.alphaMapTransform)),x.bumpMap&&(y.bumpMap.value=x.bumpMap,n(x.bumpMap,y.bumpMapTransform),y.bumpScale.value=x.bumpScale,x.side===si&&(y.bumpScale.value*=-1)),x.normalMap&&(y.normalMap.value=x.normalMap,n(x.normalMap,y.normalMapTransform),y.normalScale.value.copy(x.normalScale),x.side===si&&y.normalScale.value.negate()),x.displacementMap&&(y.displacementMap.value=x.displacementMap,n(x.displacementMap,y.displacementMapTransform),y.displacementScale.value=x.displacementScale,y.displacementBias.value=x.displacementBias),x.emissiveMap&&(y.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,y.emissiveMapTransform)),x.specularMap&&(y.specularMap.value=x.specularMap,n(x.specularMap,y.specularMapTransform)),x.alphaTest>0&&(y.alphaTest.value=x.alphaTest);const P=e.get(x),O=P.envMap,R=P.envMapRotation;O&&(y.envMap.value=O,y.envMapRotation.value.setFromMatrix4(fR.makeRotationFromEuler(R)).transpose(),O.isCubeTexture&&O.isRenderTargetTexture===!1&&y.envMapRotation.value.premultiply(Ly),y.reflectivity.value=x.reflectivity,y.ior.value=x.ior,y.refractionRatio.value=x.refractionRatio),x.lightMap&&(y.lightMap.value=x.lightMap,y.lightMapIntensity.value=x.lightMapIntensity,n(x.lightMap,y.lightMapTransform)),x.aoMap&&(y.aoMap.value=x.aoMap,y.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,y.aoMapTransform))}function d(y,x){y.diffuse.value.copy(x.color),y.opacity.value=x.opacity,x.map&&(y.map.value=x.map,n(x.map,y.mapTransform))}function p(y,x){y.dashSize.value=x.dashSize,y.totalSize.value=x.dashSize+x.gapSize,y.scale.value=x.scale}function m(y,x,P,O){y.diffuse.value.copy(x.color),y.opacity.value=x.opacity,y.size.value=x.size*P,y.scale.value=O*.5,x.map&&(y.map.value=x.map,n(x.map,y.uvTransform)),x.alphaMap&&(y.alphaMap.value=x.alphaMap,n(x.alphaMap,y.alphaMapTransform)),x.alphaTest>0&&(y.alphaTest.value=x.alphaTest)}function h(y,x){y.diffuse.value.copy(x.color),y.opacity.value=x.opacity,y.rotation.value=x.rotation,x.map&&(y.map.value=x.map,n(x.map,y.mapTransform)),x.alphaMap&&(y.alphaMap.value=x.alphaMap,n(x.alphaMap,y.alphaMapTransform)),x.alphaTest>0&&(y.alphaTest.value=x.alphaTest)}function v(y,x){y.specular.value.copy(x.specular),y.shininess.value=Math.max(x.shininess,1e-4)}function S(y,x){x.gradientMap&&(y.gradientMap.value=x.gradientMap)}function _(y,x){y.metalness.value=x.metalness,x.metalnessMap&&(y.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,y.metalnessMapTransform)),y.roughness.value=x.roughness,x.roughnessMap&&(y.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,y.roughnessMapTransform)),x.envMap&&(y.envMapIntensity.value=x.envMapIntensity)}function M(y,x,P){y.ior.value=x.ior,x.sheen>0&&(y.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),y.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(y.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,y.sheenColorMapTransform)),x.sheenRoughnessMap&&(y.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,y.sheenRoughnessMapTransform))),x.clearcoat>0&&(y.clearcoat.value=x.clearcoat,y.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(y.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,y.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(y.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===si&&y.clearcoatNormalScale.value.negate())),x.dispersion>0&&(y.dispersion.value=x.dispersion),x.iridescence>0&&(y.iridescence.value=x.iridescence,y.iridescenceIOR.value=x.iridescenceIOR,y.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(y.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,y.iridescenceMapTransform)),x.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),x.transmission>0&&(y.transmission.value=x.transmission,y.transmissionSamplerMap.value=P.texture,y.transmissionSamplerSize.value.set(P.width,P.height),x.transmissionMap&&(y.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,y.transmissionMapTransform)),y.thickness.value=x.thickness,x.thicknessMap&&(y.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=x.attenuationDistance,y.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(y.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(y.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=x.specularIntensity,y.specularColor.value.copy(x.specularColor),x.specularColorMap&&(y.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,y.specularColorMapTransform)),x.specularIntensityMap&&(y.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,y.specularIntensityMapTransform))}function E(y,x){x.matcap&&(y.matcap.value=x.matcap)}function C(y,x){const P=e.get(x).light;y.referencePosition.value.setFromMatrixPosition(P.matrixWorld),y.nearDistance.value=P.shadow.camera.near,y.farDistance.value=P.shadow.camera.far}return{refreshFogUniforms:s,refreshMaterialUniforms:l}}function pR(a,e,n,s){let l={},c={},d=[];const p=a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS);function m(R,I){const B=I.program;s.uniformBlockBinding(R,B)}function h(R,I){let B=l[R.id];B===void 0&&(y(R),B=v(R),l[R.id]=B,R.addEventListener("dispose",P));const L=I.program;s.updateUBOMapping(R,L);const T=e.render.frame;c[R.id]!==T&&(_(R),c[R.id]=T)}function v(R){const I=S();R.__bindingPointIndex=I;const B=a.createBuffer(),L=R.__size,T=R.usage;return a.bindBuffer(a.UNIFORM_BUFFER,B),a.bufferData(a.UNIFORM_BUFFER,L,T),a.bindBuffer(a.UNIFORM_BUFFER,null),a.bindBufferBase(a.UNIFORM_BUFFER,I,B),B}function S(){for(let R=0;R<p;R++)if(d.indexOf(R)===-1)return d.push(R),R;return kt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function _(R){const I=l[R.id],B=R.uniforms,L=R.__cache;a.bindBuffer(a.UNIFORM_BUFFER,I);for(let T=0,U=B.length;T<U;T++){const X=B[T];if(Array.isArray(X))for(let G=0,K=X.length;G<K;G++)M(X[G],T,G,L);else M(X,T,0,L)}a.bindBuffer(a.UNIFORM_BUFFER,null)}function M(R,I,B,L){if(C(R,I,B,L)===!0){const T=R.__offset,U=R.value;if(Array.isArray(U)){let X=0;for(let G=0;G<U.length;G++){const K=U[G],ue=x(K);E(K,R.__data,X),typeof K!="number"&&typeof K!="boolean"&&!K.isMatrix3&&!ArrayBuffer.isView(K)&&(X+=ue.storage/Float32Array.BYTES_PER_ELEMENT)}}else E(U,R.__data,0);a.bufferSubData(a.UNIFORM_BUFFER,T,R.__data)}}function E(R,I,B){typeof R=="number"||typeof R=="boolean"?I[0]=R:R.isMatrix3?(I[0]=R.elements[0],I[1]=R.elements[1],I[2]=R.elements[2],I[3]=0,I[4]=R.elements[3],I[5]=R.elements[4],I[6]=R.elements[5],I[7]=0,I[8]=R.elements[6],I[9]=R.elements[7],I[10]=R.elements[8],I[11]=0):ArrayBuffer.isView(R)?I.set(new R.constructor(R.buffer,R.byteOffset,I.length)):R.toArray(I,B)}function C(R,I,B,L){const T=R.value,U=I+"_"+B;if(L[U]===void 0)return typeof T=="number"||typeof T=="boolean"?L[U]=T:ArrayBuffer.isView(T)?L[U]=T.slice():L[U]=T.clone(),!0;{const X=L[U];if(typeof T=="number"||typeof T=="boolean"){if(X!==T)return L[U]=T,!0}else{if(ArrayBuffer.isView(T))return!0;if(X.equals(T)===!1)return X.copy(T),!0}}return!1}function y(R){const I=R.uniforms;let B=0;const L=16;for(let U=0,X=I.length;U<X;U++){const G=Array.isArray(I[U])?I[U]:[I[U]];for(let K=0,ue=G.length;K<ue;K++){const pe=G[K],Q=Array.isArray(pe.value)?pe.value:[pe.value];for(let V=0,j=Q.length;V<j;V++){const ae=Q[V],_e=x(ae),ve=B%L,H=ve%_e.boundary,te=ve+H;B+=H,te!==0&&L-te<_e.storage&&(B+=L-te),pe.__data=new Float32Array(_e.storage/Float32Array.BYTES_PER_ELEMENT),pe.__offset=B,B+=_e.storage}}}const T=B%L;return T>0&&(B+=L-T),R.__size=B,R.__cache={},this}function x(R){const I={boundary:0,storage:0};return typeof R=="number"||typeof R=="boolean"?(I.boundary=4,I.storage=4):R.isVector2?(I.boundary=8,I.storage=8):R.isVector3||R.isColor?(I.boundary=16,I.storage=12):R.isVector4?(I.boundary=16,I.storage=16):R.isMatrix3?(I.boundary=48,I.storage=48):R.isMatrix4?(I.boundary=64,I.storage=64):R.isTexture?mt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(R)?(I.boundary=16,I.storage=R.byteLength):mt("WebGLRenderer: Unsupported uniform value type.",R),I}function P(R){const I=R.target;I.removeEventListener("dispose",P);const B=d.indexOf(I.__bindingPointIndex);d.splice(B,1),a.deleteBuffer(l[I.id]),delete l[I.id],delete c[I.id]}function O(){for(const R in l)a.deleteBuffer(l[R]);d=[],l={},c={}}return{bind:m,update:h,dispose:O}}const mR=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let la=null;function gR(){return la===null&&(la=new yy(mR,16,16,rr,ja),la.name="DFG_LUT",la.minFilter=qn,la.magFilter=qn,la.wrapS=Ha,la.wrapT=Ha,la.generateMipmaps=!1,la.needsUpdate=!0),la}class _R{constructor(e={}){const{canvas:n=RE(),context:s=null,depth:l=!0,stencil:c=!1,alpha:d=!1,antialias:p=!1,premultipliedAlpha:m=!0,preserveDrawingBuffer:h=!1,powerPreference:v="default",failIfMajorPerformanceCaveat:S=!1,reversedDepthBuffer:_=!1,outputBufferType:M=xi}=e;this.isWebGLRenderer=!0;let E;if(s!==null){if(typeof WebGLRenderingContext<"u"&&s instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");E=s.getContextAttributes().alpha}else E=d;const C=M,y=new Set([tm,em,Jp]),x=new Set([xi,pa,Dl,Nl,Kp,$p]),P=new Uint32Array(4),O=new Int32Array(4),R=new se;let I=null,B=null;const L=[],T=[];let U=null;this.domElement=n,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=da,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const X=this;let G=!1,K=null,ue=null,pe=null,Q=null;this._outputColorSpace=vi;let V=0,j=0,ae=null,_e=-1,ve=null;const H=new pn,te=new pn;let Ee=null;const Le=new ct(0);let Fe=0,oe=n.width,Me=n.height,Ae=1,ze=null,at=null;const Je=new pn(0,0,oe,Me),Gt=new pn(0,0,oe,Me);let ut=!1;const _t=new rm;let xt=!1,ot=!1;const Ht=new cn,Bt=new se,Zt=new pn,Vt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let dt=!1;function J(){return ae===null?Ae:1}let z=s;function Ue(D,w){return n.getContext(D,w)}try{const D={alpha:!0,depth:l,stencil:c,antialias:p,premultipliedAlpha:m,preserveDrawingBuffer:h,powerPreference:v,failIfMajorPerformanceCaveat:S};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${qp}`),n.addEventListener("webglcontextlost",qt,!1),n.addEventListener("webglcontextrestored",wt,!1),n.addEventListener("webglcontextcreationerror",Ln,!1),z===null){const w="webgl2";if(z=Ue(w,D),z===null)throw Ue(w)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(D){throw kt("WebGLRenderer: "+D.message),D}let ft,F,A,ne,re,fe,Ne,He,ge,le,Ie,We,Xe,ke,nt,Ce,rt,Z,Oe,ye,Pe,Ge,De;function Ze(){ft=new gC(z),ft.init(),Pe=new oR(z,ft),F=new lC(z,ft,e,Pe),A=new sR(z,ft),F.reversedDepthBuffer&&_&&A.buffers.depth.setReversed(!0),ue=z.createFramebuffer(),pe=z.createFramebuffer(),Q=z.createFramebuffer(),ne=new xC(z),re=new Xw,fe=new rR(z,ft,A,re,F,Pe,ne),Ne=new mC(X),He=new MT(z),Ge=new rC(z,He),ge=new _C(z,He,ne,Ge),le=new SC(z,ge,He,Ge,ne),Z=new yC(z,F,fe),nt=new cC(re),Ie=new jw(X,Ne,ft,F,Ge,nt),We=new hR(X,re),Xe=new qw,ke=new Jw(ft),rt=new sC(X,Ne,A,le,E,m),Ce=new aR(X,le,F),De=new pR(z,ne,F,A),Oe=new oC(z,ft,ne),ye=new vC(z,ft,ne),ne.programs=Ie.programs,X.capabilities=F,X.extensions=ft,X.properties=re,X.renderLists=Xe,X.shadowMap=Ce,X.state=A,X.info=ne}Ze(),C!==xi&&(U=new MC(C,n.width,n.height,p,l,c));const qe=new dR(X,z);this.xr=qe,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const D=ft.get("WEBGL_lose_context");D&&D.loseContext()},this.forceContextRestore=function(){const D=ft.get("WEBGL_lose_context");D&&D.restoreContext()},this.getPixelRatio=function(){return Ae},this.setPixelRatio=function(D){D!==void 0&&(Ae=D,this.setSize(oe,Me,!1))},this.getSize=function(D){return D.set(oe,Me)},this.setSize=function(D,w,k=!0){if(qe.isPresenting){mt("WebGLRenderer: Can't change size while VR device is presenting.");return}oe=D,Me=w,n.width=Math.floor(D*Ae),n.height=Math.floor(w*Ae),k===!0&&(n.style.width=D+"px",n.style.height=w+"px"),U!==null&&U.setSize(n.width,n.height),this.setViewport(0,0,D,w)},this.getDrawingBufferSize=function(D){return D.set(oe*Ae,Me*Ae).floor()},this.setDrawingBufferSize=function(D,w,k){oe=D,Me=w,Ae=k,n.width=Math.floor(D*k),n.height=Math.floor(w*k),this.setViewport(0,0,D,w)},this.setEffects=function(D){if(C===xi){kt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(D){for(let w=0;w<D.length;w++)if(D[w].isOutputPass===!0){mt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}U.setEffects(D||[])},this.getCurrentViewport=function(D){return D.copy(H)},this.getViewport=function(D){return D.copy(Je)},this.setViewport=function(D,w,k,W){D.isVector4?Je.set(D.x,D.y,D.z,D.w):Je.set(D,w,k,W),A.viewport(H.copy(Je).multiplyScalar(Ae).round())},this.getScissor=function(D){return D.copy(Gt)},this.setScissor=function(D,w,k,W){D.isVector4?Gt.set(D.x,D.y,D.z,D.w):Gt.set(D,w,k,W),A.scissor(te.copy(Gt).multiplyScalar(Ae).round())},this.getScissorTest=function(){return ut},this.setScissorTest=function(D){A.setScissorTest(ut=D)},this.setOpaqueSort=function(D){ze=D},this.setTransparentSort=function(D){at=D},this.getClearColor=function(D){return D.copy(rt.getClearColor())},this.setClearColor=function(){rt.setClearColor(...arguments)},this.getClearAlpha=function(){return rt.getClearAlpha()},this.setClearAlpha=function(){rt.setClearAlpha(...arguments)},this.clear=function(D=!0,w=!0,k=!0){let W=0;if(D){let Y=!1;if(ae!==null){const xe=ae.texture.format;Y=y.has(xe)}if(Y){const xe=ae.texture.type,be=x.has(xe),Be=rt.getClearColor(),Ve=rt.getClearAlpha(),je=Be.r,Qe=Be.g,st=Be.b;be?(P[0]=je,P[1]=Qe,P[2]=st,P[3]=Ve,z.clearBufferuiv(z.COLOR,0,P)):(O[0]=je,O[1]=Qe,O[2]=st,O[3]=Ve,z.clearBufferiv(z.COLOR,0,O))}else W|=z.COLOR_BUFFER_BIT}w&&(W|=z.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),k&&(W|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),W!==0&&z.clear(W)},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.setNodesHandler=function(D){D.setRenderer(this),K=D},this.dispose=function(){n.removeEventListener("webglcontextlost",qt,!1),n.removeEventListener("webglcontextrestored",wt,!1),n.removeEventListener("webglcontextcreationerror",Ln,!1),rt.dispose(),Xe.dispose(),ke.dispose(),re.dispose(),Ne.dispose(),le.dispose(),Ge.dispose(),De.dispose(),Ie.dispose(),qe.dispose(),qe.removeEventListener("sessionstart",vt),qe.removeEventListener("sessionend",vn),Vn.stop()};function qt(D){D.preventDefault(),Mv("WebGLRenderer: Context Lost."),G=!0}function wt(){Mv("WebGLRenderer: Context Restored."),G=!1;const D=ne.autoReset,w=Ce.enabled,k=Ce.autoUpdate,W=Ce.needsUpdate,Y=Ce.type;Ze(),ne.autoReset=D,Ce.enabled=w,Ce.autoUpdate=k,Ce.needsUpdate=W,Ce.type=Y}function Ln(D){kt("WebGLRenderer: A WebGL context could not be created. Reason: ",D.statusMessage)}function Sn(D){const w=D.target;w.removeEventListener("dispose",Sn),Re(w)}function Re(D){Ke(D),re.remove(D)}function Ke(D){const w=re.get(D).programs;w!==void 0&&(w.forEach(function(k){Ie.releaseProgram(k)}),D.isShaderMaterial&&Ie.releaseShaderCache(D))}this.renderBufferDirect=function(D,w,k,W,Y,xe){w===null&&(w=Vt);const be=Y.isMesh&&Y.matrixWorld.determinantAffine()<0,Be=ta(D,w,k,W,Y);A.setMaterial(W,be);let Ve=k.index,je=1;if(W.wireframe===!0){if(Ve=ge.getWireframeAttribute(k),Ve===void 0)return;je=2}const Qe=k.drawRange,st=k.attributes.position;let et=Qe.start*je,Mt=(Qe.start+Qe.count)*je;xe!==null&&(et=Math.max(et,xe.start*je),Mt=Math.min(Mt,(xe.start+xe.count)*je)),Ve!==null?(et=Math.max(et,0),Mt=Math.min(Mt,Ve.count)):st!=null&&(et=Math.max(et,0),Mt=Math.min(Mt,st.count));const nn=Mt-et;if(nn<0||nn===1/0)return;Ge.setup(Y,W,Be,k,Ve);let Rt,Kt=Oe;if(Ve!==null&&(Rt=He.get(Ve),Kt=ye,Kt.setIndex(Rt)),Y.isMesh)W.wireframe===!0?(A.setLineWidth(W.wireframeLinewidth*J()),Kt.setMode(z.LINES)):Kt.setMode(z.TRIANGLES);else if(Y.isLine){let $t=W.linewidth;$t===void 0&&($t=1),A.setLineWidth($t*J()),Y.isLineSegments?Kt.setMode(z.LINES):Y.isLineLoop?Kt.setMode(z.LINE_LOOP):Kt.setMode(z.LINE_STRIP)}else Y.isPoints?Kt.setMode(z.POINTS):Y.isSprite&&Kt.setMode(z.TRIANGLES);if(Y.isBatchedMesh)if(ft.get("WEBGL_multi_draw"))Kt.renderMultiDraw(Y._multiDrawStarts,Y._multiDrawCounts,Y._multiDrawCount);else{const $t=Y._multiDrawStarts,$e=Y._multiDrawCounts,kn=Y._multiDrawCount,Dt=Ve?He.get(Ve).bytesPerElement:1,Cn=re.get(W).currentProgram.getUniforms();for(let oi=0;oi<kn;oi++)Cn.setValue(z,"_gl_DrawID",oi),Kt.render($t[oi]/Dt,$e[oi])}else if(Y.isInstancedMesh)Kt.renderInstances(et,nn,Y.count);else if(k.isInstancedBufferGeometry){const $t=k._maxInstanceCount!==void 0?k._maxInstanceCount:1/0,$e=Math.min(k.instanceCount,$t);Kt.renderInstances(et,nn,$e)}else Kt.render(et,nn)};function gt(D,w,k){D.transparent===!0&&D.side===za&&D.forceSinglePass===!1?(D.side=si,D.needsUpdate=!0,ea(D,w,k),D.side=As,D.needsUpdate=!0,ea(D,w,k),D.side=za):ea(D,w,k)}this.compile=function(D,w,k=null){k===null&&(k=D),B=ke.get(k),B.init(w),T.push(B),k.traverseVisible(function(Y){Y.isLight&&Y.layers.test(w.layers)&&(B.pushLight(Y),Y.castShadow&&B.pushShadow(Y))}),D!==k&&D.traverseVisible(function(Y){Y.isLight&&Y.layers.test(w.layers)&&(B.pushLight(Y),Y.castShadow&&B.pushShadow(Y))}),B.setupLights();const W=new Set;return D.traverse(function(Y){if(!(Y.isMesh||Y.isPoints||Y.isLine||Y.isSprite))return;const xe=Y.material;if(xe)if(Array.isArray(xe))for(let be=0;be<xe.length;be++){const Be=xe[be];gt(Be,k,Y),W.add(Be)}else gt(xe,k,Y),W.add(xe)}),B=T.pop(),W},this.compileAsync=function(D,w,k=null){const W=this.compile(D,w,k);return new Promise(Y=>{function xe(){if(W.forEach(function(be){re.get(be).currentProgram.isReady()&&W.delete(be)}),W.size===0){Y(D);return}setTimeout(xe,10)}ft.get("KHR_parallel_shader_compile")!==null?xe():setTimeout(xe,10)})};let Ot=null;function Tt(D){Ot&&Ot(D)}function vt(){Vn.stop()}function vn(){Vn.start()}const Vn=new Ay;Vn.setAnimationLoop(Tt),typeof self<"u"&&Vn.setContext(self),this.setAnimationLoop=function(D){Ot=D,qe.setAnimationLoop(D),D===null?Vn.stop():Vn.start()},qe.addEventListener("sessionstart",vt),qe.addEventListener("sessionend",vn),this.render=function(D,w){if(w!==void 0&&w.isCamera!==!0){kt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(G===!0)return;K!==null&&K.renderStart(D,w);const k=qe.enabled===!0&&qe.isPresenting===!0,W=U!==null&&(ae===null||k)&&U.begin(X,ae);if(D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),w.parent===null&&w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),qe.enabled===!0&&qe.isPresenting===!0&&(U===null||U.isCompositing()===!1)&&(qe.cameraAutoUpdate===!0&&qe.updateCamera(w),w=qe.getCamera()),D.isScene===!0&&D.onBeforeRender(X,D,w,ae),B=ke.get(D,T.length),B.init(w),B.state.textureUnits=fe.getTextureUnits(),T.push(B),Ht.multiplyMatrices(w.projectionMatrix,w.matrixWorldInverse),_t.setFromProjectionMatrix(Ht,ua,w.reversedDepth),ot=this.localClippingEnabled,xt=nt.init(this.clippingPlanes,ot),I=Xe.get(D,L.length),I.init(),L.push(I),qe.enabled===!0&&qe.isPresenting===!0){const be=X.xr.getDepthSensingMesh();be!==null&&Qi(be,w,-1/0,X.sortObjects)}Qi(D,w,0,X.sortObjects),I.finish(),X.sortObjects===!0&&I.sort(ze,at,w.reversedDepth),dt=qe.enabled===!1||qe.isPresenting===!1||qe.hasDepthSensing()===!1,dt&&rt.addToRenderList(I,D),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),xt===!0&&nt.beginShadows();const Y=B.state.shadowsArray;if(Ce.render(Y,D,w),xt===!0&&nt.endShadows(),(W&&U.hasRenderPass())===!1){const be=I.opaque,Be=I.transmissive;if(B.setupLights(),w.isArrayCamera){const Ve=w.cameras;if(Be.length>0)for(let je=0,Qe=Ve.length;je<Qe;je++){const st=Ve[je];pr(be,Be,D,st)}dt&&rt.render(D);for(let je=0,Qe=Ve.length;je<Qe;je++){const st=Ve[je];hr(I,D,st,st.viewport)}}else Be.length>0&&pr(be,Be,D,w),dt&&rt.render(D),hr(I,D,w)}ae!==null&&j===0&&(fe.updateMultisampleRenderTarget(ae),fe.updateRenderTargetMipmap(ae)),W&&U.end(X),D.isScene===!0&&D.onAfterRender(X,D,w),Ge.resetDefaultState(),_e=-1,ve=null,T.pop(),T.length>0?(B=T[T.length-1],fe.setTextureUnits(B.state.textureUnits),xt===!0&&nt.setGlobalState(X.clippingPlanes,B.state.camera)):B=null,L.pop(),L.length>0?I=L[L.length-1]:I=null,K!==null&&K.renderEnd()};function Qi(D,w,k,W){if(D.visible===!1)return;if(D.layers.test(w.layers)){if(D.isGroup)k=D.renderOrder;else if(D.isLOD)D.autoUpdate===!0&&D.update(w);else if(D.isLightProbeGrid)B.pushLightProbeGrid(D);else if(D.isLight)B.pushLight(D),D.castShadow&&B.pushShadow(D);else if(D.isSprite){if(!D.frustumCulled||_t.intersectsSprite(D)){W&&Zt.setFromMatrixPosition(D.matrixWorld).applyMatrix4(Ht);const be=le.update(D),Be=D.material;Be.visible&&I.push(D,be,Be,k,Zt.z,null)}}else if((D.isMesh||D.isLine||D.isPoints)&&(!D.frustumCulled||_t.intersectsObject(D))){const be=le.update(D),Be=D.material;if(W&&(D.boundingSphere!==void 0?(D.boundingSphere===null&&D.computeBoundingSphere(),Zt.copy(D.boundingSphere.center)):(be.boundingSphere===null&&be.computeBoundingSphere(),Zt.copy(be.boundingSphere.center)),Zt.applyMatrix4(D.matrixWorld).applyMatrix4(Ht)),Array.isArray(Be)){const Ve=be.groups;for(let je=0,Qe=Ve.length;je<Qe;je++){const st=Ve[je],et=Be[st.materialIndex];et&&et.visible&&I.push(D,be,et,k,Zt.z,st)}}else Be.visible&&I.push(D,be,Be,k,Zt.z,null)}}const xe=D.children;for(let be=0,Be=xe.length;be<Be;be++)Qi(xe[be],w,k,W)}function hr(D,w,k,W){const{opaque:Y,transmissive:xe,transparent:be}=D;B.setupLightsView(k),xt===!0&&nt.setGlobalState(X.clippingPlanes,k),W&&A.viewport(H.copy(W)),Y.length>0&&ma(Y,w,k),xe.length>0&&ma(xe,w,k),be.length>0&&ma(be,w,k),A.buffers.depth.setTest(!0),A.buffers.depth.setMask(!0),A.buffers.color.setMask(!0),A.setPolygonOffset(!1)}function pr(D,w,k,W){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;if(B.state.transmissionRenderTarget[W.id]===void 0){const et=ft.has("EXT_color_buffer_half_float")||ft.has("EXT_color_buffer_float");B.state.transmissionRenderTarget[W.id]=new fa(1,1,{generateMipmaps:!0,type:et?ja:xi,minFilter:er,samples:Math.max(4,F.samples),stencilBuffer:c,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:zt.workingColorSpace})}const xe=B.state.transmissionRenderTarget[W.id],be=W.viewport||H;xe.setSize(be.z*X.transmissionResolutionScale,be.w*X.transmissionResolutionScale);const Be=X.getRenderTarget(),Ve=X.getActiveCubeFace(),je=X.getActiveMipmapLevel();X.setRenderTarget(xe),X.getClearColor(Le),Fe=X.getClearAlpha(),Fe<1&&X.setClearColor(16777215,.5),X.clear(),dt&&rt.render(k);const Qe=X.toneMapping;X.toneMapping=da;const st=W.viewport;if(W.viewport!==void 0&&(W.viewport=void 0),B.setupLightsView(W),xt===!0&&nt.setGlobalState(X.clippingPlanes,W),ma(D,k,W),fe.updateMultisampleRenderTarget(xe),fe.updateRenderTargetMipmap(xe),ft.has("WEBGL_multisampled_render_to_texture")===!1){let et=!1;for(let Mt=0,nn=w.length;Mt<nn;Mt++){const Rt=w[Mt],{object:Kt,geometry:$t,material:$e,group:kn}=Rt;if($e.side===za&&Kt.layers.test(W.layers)){const Dt=$e.side;$e.side=si,$e.needsUpdate=!0,Ji(Kt,k,W,$t,$e,kn),$e.side=Dt,$e.needsUpdate=!0,et=!0}}et===!0&&(fe.updateMultisampleRenderTarget(xe),fe.updateRenderTargetMipmap(xe))}X.setRenderTarget(Be,Ve,je),X.setClearColor(Le,Fe),st!==void 0&&(W.viewport=st),X.toneMapping=Qe}function ma(D,w,k){const W=w.isScene===!0?w.overrideMaterial:null;for(let Y=0,xe=D.length;Y<xe;Y++){const be=D[Y],{object:Be,geometry:Ve,group:je}=be;let Qe=be.material;Qe.allowOverride===!0&&W!==null&&(Qe=W),Be.layers.test(k.layers)&&Ji(Be,w,k,Ve,Qe,je)}}function Ji(D,w,k,W,Y,xe){D.onBeforeRender(X,w,k,W,Y,xe),D.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,D.matrixWorld),D.normalMatrix.getNormalMatrix(D.modelViewMatrix),Y.onBeforeRender(X,w,k,W,D,xe),Y.transparent===!0&&Y.side===za&&Y.forceSinglePass===!1?(Y.side=si,Y.needsUpdate=!0,X.renderBufferDirect(k,w,W,Y,D,xe),Y.side=As,Y.needsUpdate=!0,X.renderBufferDirect(k,w,W,Y,D,xe),Y.side=za):X.renderBufferDirect(k,w,W,Y,D,xe),D.onAfterRender(X,w,k,W,Y,xe)}function ea(D,w,k){w.isScene!==!0&&(w=Vt);const W=re.get(D),Y=B.state.lights,xe=B.state.shadowsArray,be=Y.state.version,Be=Ie.getParameters(D,Y.state,xe,w,k,B.state.lightProbeGridArray),Ve=Ie.getProgramCacheKey(Be);let je=W.programs;W.environment=D.isMeshStandardMaterial||D.isMeshLambertMaterial||D.isMeshPhongMaterial?w.environment:null,W.fog=w.fog;const Qe=D.isMeshStandardMaterial||D.isMeshLambertMaterial&&!D.envMap||D.isMeshPhongMaterial&&!D.envMap;W.envMap=Ne.get(D.envMap||W.environment,Qe),W.envMapRotation=W.environment!==null&&D.envMap===null?w.environmentRotation:D.envMapRotation,je===void 0&&(D.addEventListener("dispose",Sn),je=new Map,W.programs=je);let st=je.get(Ve);if(st!==void 0){if(W.currentProgram===st&&W.lightsStateVersion===be)return Pi(D,Be),st}else Be.uniforms=Ie.getUniforms(D),K!==null&&D.isNodeMaterial&&K.build(D,k,Be),D.onBeforeCompile(Be,X),st=Ie.acquireProgram(Be,Ve),je.set(Ve,st),W.uniforms=Be.uniforms;const et=W.uniforms;return(!D.isShaderMaterial&&!D.isRawShaderMaterial||D.clipping===!0)&&(et.clippingPlanes=nt.uniform),Pi(D,Be),W.needsLights=Ds(D),W.lightsStateVersion=be,W.needsLights&&(et.ambientLightColor.value=Y.state.ambient,et.lightProbe.value=Y.state.probe,et.directionalLights.value=Y.state.directional,et.directionalLightShadows.value=Y.state.directionalShadow,et.spotLights.value=Y.state.spot,et.spotLightShadows.value=Y.state.spotShadow,et.rectAreaLights.value=Y.state.rectArea,et.ltc_1.value=Y.state.rectAreaLTC1,et.ltc_2.value=Y.state.rectAreaLTC2,et.pointLights.value=Y.state.point,et.pointLightShadows.value=Y.state.pointShadow,et.hemisphereLights.value=Y.state.hemi,et.directionalShadowMatrix.value=Y.state.directionalShadowMatrix,et.spotLightMatrix.value=Y.state.spotLightMatrix,et.spotLightMap.value=Y.state.spotLightMap,et.pointShadowMatrix.value=Y.state.pointShadowMatrix),W.lightProbeGrid=B.state.lightProbeGridArray.length>0,W.currentProgram=st,W.uniformsList=null,st}function Oi(D){if(D.uniformsList===null){const w=D.currentProgram.getUniforms();D.uniformsList=wu.seqWithValue(w.seq,D.uniforms)}return D.uniformsList}function Pi(D,w){const k=re.get(D);k.outputColorSpace=w.outputColorSpace,k.batching=w.batching,k.batchingColor=w.batchingColor,k.instancing=w.instancing,k.instancingColor=w.instancingColor,k.instancingMorph=w.instancingMorph,k.skinning=w.skinning,k.morphTargets=w.morphTargets,k.morphNormals=w.morphNormals,k.morphColors=w.morphColors,k.morphTargetsCount=w.morphTargetsCount,k.numClippingPlanes=w.numClippingPlanes,k.numIntersection=w.numClipIntersection,k.vertexAlphas=w.vertexAlphas,k.vertexTangents=w.vertexTangents,k.toneMapping=w.toneMapping}function Ii(D,w){if(D.length===0)return null;if(D.length===1)return D[0].texture!==null?D[0]:null;R.setFromMatrixPosition(w.matrixWorld);for(let k=0,W=D.length;k<W;k++){const Y=D[k];if(Y.texture!==null&&Y.boundingBox.containsPoint(R))return Y}return null}function ta(D,w,k,W,Y){w.isScene!==!0&&(w=Vt),fe.resetTextureUnits();const xe=w.fog,be=W.isMeshStandardMaterial||W.isMeshLambertMaterial||W.isMeshPhongMaterial?w.environment:null,Be=ae===null?X.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:zt.workingColorSpace,Ve=W.isMeshStandardMaterial||W.isMeshLambertMaterial&&!W.envMap||W.isMeshPhongMaterial&&!W.envMap,je=Ne.get(W.envMap||be,Ve),Qe=W.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,st=!!k.attributes.tangent&&(!!W.normalMap||W.anisotropy>0),et=!!k.morphAttributes.position,Mt=!!k.morphAttributes.normal,nn=!!k.morphAttributes.color;let Rt=da;W.toneMapped&&(ae===null||ae.isXRRenderTarget===!0)&&(Rt=X.toneMapping);const Kt=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,$t=Kt!==void 0?Kt.length:0,$e=re.get(W),kn=B.state.lights;if(xt===!0&&(ot===!0||D!==ve)){const Yt=D===ve&&W.id===_e;nt.setState(W,D,Yt)}let Dt=!1;W.version===$e.__version?($e.needsLights&&$e.lightsStateVersion!==kn.state.version||$e.outputColorSpace!==Be||Y.isBatchedMesh&&$e.batching===!1||!Y.isBatchedMesh&&$e.batching===!0||Y.isBatchedMesh&&$e.batchingColor===!0&&Y.colorTexture===null||Y.isBatchedMesh&&$e.batchingColor===!1&&Y.colorTexture!==null||Y.isInstancedMesh&&$e.instancing===!1||!Y.isInstancedMesh&&$e.instancing===!0||Y.isSkinnedMesh&&$e.skinning===!1||!Y.isSkinnedMesh&&$e.skinning===!0||Y.isInstancedMesh&&$e.instancingColor===!0&&Y.instanceColor===null||Y.isInstancedMesh&&$e.instancingColor===!1&&Y.instanceColor!==null||Y.isInstancedMesh&&$e.instancingMorph===!0&&Y.morphTexture===null||Y.isInstancedMesh&&$e.instancingMorph===!1&&Y.morphTexture!==null||$e.envMap!==je||W.fog===!0&&$e.fog!==xe||$e.numClippingPlanes!==void 0&&($e.numClippingPlanes!==nt.numPlanes||$e.numIntersection!==nt.numIntersection)||$e.vertexAlphas!==Qe||$e.vertexTangents!==st||$e.morphTargets!==et||$e.morphNormals!==Mt||$e.morphColors!==nn||$e.toneMapping!==Rt||$e.morphTargetsCount!==$t||!!$e.lightProbeGrid!=B.state.lightProbeGridArray.length>0)&&(Dt=!0):(Dt=!0,$e.__version=W.version);let Cn=$e.currentProgram;Dt===!0&&(Cn=ea(W,w,Y),K&&W.isNodeMaterial&&K.onUpdateProgram(W,Cn,$e));let oi=!1,Bi=!1,li=!1;const Qt=Cn.getUniforms(),fn=$e.uniforms;if(A.useProgram(Cn.program)&&(oi=!0,Bi=!0,li=!0),W.id!==_e&&(_e=W.id,Bi=!0),$e.needsLights){const Yt=Ii(B.state.lightProbeGridArray,Y);$e.lightProbeGrid!==Yt&&($e.lightProbeGrid=Yt,Bi=!0)}if(oi||ve!==D){A.buffers.depth.getReversed()&&D.reversedDepth!==!0&&(D._reversedDepth=!0,D.updateProjectionMatrix()),Qt.setValue(z,"projectionMatrix",D.projectionMatrix),Qt.setValue(z,"viewMatrix",D.matrixWorldInverse);const na=Qt.map.cameraPosition;na!==void 0&&na.setValue(z,Bt.setFromMatrixPosition(D.matrixWorld)),F.logarithmicDepthBuffer&&Qt.setValue(z,"logDepthBufFC",2/(Math.log(D.far+1)/Math.LN2)),(W.isMeshPhongMaterial||W.isMeshToonMaterial||W.isMeshLambertMaterial||W.isMeshBasicMaterial||W.isMeshStandardMaterial||W.isShaderMaterial)&&Qt.setValue(z,"isOrthographic",D.isOrthographicCamera===!0),ve!==D&&(ve=D,Bi=!0,li=!0)}if($e.needsLights&&(kn.state.directionalShadowMap.length>0&&Qt.setValue(z,"directionalShadowMap",kn.state.directionalShadowMap,fe),kn.state.spotShadowMap.length>0&&Qt.setValue(z,"spotShadowMap",kn.state.spotShadowMap,fe),kn.state.pointShadowMap.length>0&&Qt.setValue(z,"pointShadowMap",kn.state.pointShadowMap,fe)),Y.isSkinnedMesh){Qt.setOptional(z,Y,"bindMatrix"),Qt.setOptional(z,Y,"bindMatrixInverse");const Yt=Y.skeleton;Yt&&(Yt.boneTexture===null&&Yt.computeBoneTexture(),Qt.setValue(z,"boneTexture",Yt.boneTexture,fe))}Y.isBatchedMesh&&(Qt.setOptional(z,Y,"batchingTexture"),Qt.setValue(z,"batchingTexture",Y._matricesTexture,fe),Qt.setOptional(z,Y,"batchingIdTexture"),Qt.setValue(z,"batchingIdTexture",Y._indirectTexture,fe),Qt.setOptional(z,Y,"batchingColorTexture"),Y._colorsTexture!==null&&Qt.setValue(z,"batchingColorTexture",Y._colorsTexture,fe));const Fi=k.morphAttributes;if((Fi.position!==void 0||Fi.normal!==void 0||Fi.color!==void 0)&&Z.update(Y,k,Cn),(Bi||$e.receiveShadow!==Y.receiveShadow)&&($e.receiveShadow=Y.receiveShadow,Qt.setValue(z,"receiveShadow",Y.receiveShadow)),(W.isMeshStandardMaterial||W.isMeshLambertMaterial||W.isMeshPhongMaterial)&&W.envMap===null&&w.environment!==null&&(fn.envMapIntensity.value=w.environmentIntensity),fn.dfgLUT!==void 0&&(fn.dfgLUT.value=gR()),Bi){if(Qt.setValue(z,"toneMappingExposure",X.toneMappingExposure),$e.needsLights&&mn(fn,li),xe&&W.fog===!0&&We.refreshFogUniforms(fn,xe),We.refreshMaterialUniforms(fn,W,Ae,Me,B.state.transmissionRenderTarget[D.id]),$e.needsLights&&$e.lightProbeGrid){const Yt=$e.lightProbeGrid;fn.probesSH.value=Yt.texture,fn.probesMin.value.copy(Yt.boundingBox.min),fn.probesMax.value.copy(Yt.boundingBox.max),fn.probesResolution.value.copy(Yt.resolution)}wu.upload(z,Oi($e),fn,fe)}if(W.isShaderMaterial&&W.uniformsNeedUpdate===!0&&(wu.upload(z,Oi($e),fn,fe),W.uniformsNeedUpdate=!1),W.isSpriteMaterial&&Qt.setValue(z,"center",Y.center),Qt.setValue(z,"modelViewMatrix",Y.modelViewMatrix),Qt.setValue(z,"normalMatrix",Y.normalMatrix),Qt.setValue(z,"modelMatrix",Y.matrixWorld),W.uniformsGroups!==void 0){const Yt=W.uniformsGroups;for(let na=0,Wa=Yt.length;na<Wa;na++){const Ns=Yt[na];De.update(Ns,Cn),De.bind(Ns,Cn)}}return Cn}function mn(D,w){D.ambientLightColor.needsUpdate=w,D.lightProbe.needsUpdate=w,D.directionalLights.needsUpdate=w,D.directionalLightShadows.needsUpdate=w,D.pointLights.needsUpdate=w,D.pointLightShadows.needsUpdate=w,D.spotLights.needsUpdate=w,D.spotLightShadows.needsUpdate=w,D.rectAreaLights.needsUpdate=w,D.hemisphereLights.needsUpdate=w}function Ds(D){return D.isMeshLambertMaterial||D.isMeshToonMaterial||D.isMeshPhongMaterial||D.isMeshStandardMaterial||D.isShadowMaterial||D.isShaderMaterial&&D.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return j},this.getRenderTarget=function(){return ae},this.setRenderTargetTextures=function(D,w,k){const W=re.get(D);W.__autoAllocateDepthBuffer=D.resolveDepthBuffer===!1,W.__autoAllocateDepthBuffer===!1&&(W.__useRenderToTexture=!1),re.get(D.texture).__webglTexture=w,re.get(D.depthTexture).__webglTexture=W.__autoAllocateDepthBuffer?void 0:k,W.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(D,w){const k=re.get(D);k.__webglFramebuffer=w,k.__useDefaultFramebuffer=w===void 0},this.setRenderTarget=function(D,w=0,k=0){ae=D,V=w,j=k;let W=null,Y=!1,xe=!1;if(D){const Be=re.get(D);if(Be.__useDefaultFramebuffer!==void 0){A.bindFramebuffer(z.FRAMEBUFFER,Be.__webglFramebuffer),H.copy(D.viewport),te.copy(D.scissor),Ee=D.scissorTest,A.viewport(H),A.scissor(te),A.setScissorTest(Ee),_e=-1;return}else if(Be.__webglFramebuffer===void 0)fe.setupRenderTarget(D);else if(Be.__hasExternalTextures)fe.rebindTextures(D,re.get(D.texture).__webglTexture,re.get(D.depthTexture).__webglTexture);else if(D.depthBuffer){const Qe=D.depthTexture;if(Be.__boundDepthTexture!==Qe){if(Qe!==null&&re.has(Qe)&&(D.width!==Qe.image.width||D.height!==Qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");fe.setupDepthRenderbuffer(D)}}const Ve=D.texture;(Ve.isData3DTexture||Ve.isDataArrayTexture||Ve.isCompressedArrayTexture)&&(xe=!0);const je=re.get(D).__webglFramebuffer;D.isWebGLCubeRenderTarget?(Array.isArray(je[w])?W=je[w][k]:W=je[w],Y=!0):D.samples>0&&fe.useMultisampledRTT(D)===!1?W=re.get(D).__webglMultisampledFramebuffer:Array.isArray(je)?W=je[k]:W=je,H.copy(D.viewport),te.copy(D.scissor),Ee=D.scissorTest}else H.copy(Je).multiplyScalar(Ae).floor(),te.copy(Gt).multiplyScalar(Ae).floor(),Ee=ut;if(k!==0&&(W=ue),A.bindFramebuffer(z.FRAMEBUFFER,W)&&A.drawBuffers(D,W),A.viewport(H),A.scissor(te),A.setScissorTest(Ee),Y){const Be=re.get(D.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+w,Be.__webglTexture,k)}else if(xe){const Be=w;for(let Ve=0;Ve<D.textures.length;Ve++){const je=re.get(D.textures[Ve]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+Ve,je.__webglTexture,k,Be)}}else if(D!==null&&k!==0){const Be=re.get(D.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Be.__webglTexture,k)}_e=-1},this.readRenderTargetPixels=function(D,w,k,W,Y,xe,be,Be=0){if(!(D&&D.isWebGLRenderTarget)){kt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ve=re.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&be!==void 0&&(Ve=Ve[be]),Ve){A.bindFramebuffer(z.FRAMEBUFFER,Ve);try{const je=D.textures[Be],Qe=je.format,st=je.type;if(D.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Be),!F.textureFormatReadable(Qe)){kt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!F.textureTypeReadable(st)){kt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}w>=0&&w<=D.width-W&&k>=0&&k<=D.height-Y&&z.readPixels(w,k,W,Y,Pe.convert(Qe),Pe.convert(st),xe)}finally{const je=ae!==null?re.get(ae).__webglFramebuffer:null;A.bindFramebuffer(z.FRAMEBUFFER,je)}}},this.readRenderTargetPixelsAsync=async function(D,w,k,W,Y,xe,be,Be=0){if(!(D&&D.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ve=re.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&be!==void 0&&(Ve=Ve[be]),Ve)if(w>=0&&w<=D.width-W&&k>=0&&k<=D.height-Y){A.bindFramebuffer(z.FRAMEBUFFER,Ve);const je=D.textures[Be],Qe=je.format,st=je.type;if(D.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Be),!F.textureFormatReadable(Qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!F.textureTypeReadable(st))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const et=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,et),z.bufferData(z.PIXEL_PACK_BUFFER,xe.byteLength,z.STREAM_READ),z.readPixels(w,k,W,Y,Pe.convert(Qe),Pe.convert(st),0);const Mt=ae!==null?re.get(ae).__webglFramebuffer:null;A.bindFramebuffer(z.FRAMEBUFFER,Mt);const nn=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await DE(z,nn,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,et),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,xe),z.deleteBuffer(et),z.deleteSync(nn),xe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(D,w=null,k=0){const W=Math.pow(2,-k),Y=Math.floor(D.image.width*W),xe=Math.floor(D.image.height*W),be=w!==null?w.x:0,Be=w!==null?w.y:0;fe.setTexture2D(D,0),z.copyTexSubImage2D(z.TEXTURE_2D,k,0,0,be,Be,Y,xe),A.unbindTexture()},this.copyTextureToTexture=function(D,w,k=null,W=null,Y=0,xe=0){let be,Be,Ve,je,Qe,st,et,Mt,nn;const Rt=D.isCompressedTexture?D.mipmaps[xe]:D.image;if(k!==null)be=k.max.x-k.min.x,Be=k.max.y-k.min.y,Ve=k.isBox3?k.max.z-k.min.z:1,je=k.min.x,Qe=k.min.y,st=k.isBox3?k.min.z:0;else{const fn=Math.pow(2,-Y);be=Math.floor(Rt.width*fn),Be=Math.floor(Rt.height*fn),D.isDataArrayTexture?Ve=Rt.depth:D.isData3DTexture?Ve=Math.floor(Rt.depth*fn):Ve=1,je=0,Qe=0,st=0}W!==null?(et=W.x,Mt=W.y,nn=W.z):(et=0,Mt=0,nn=0);const Kt=Pe.convert(w.format),$t=Pe.convert(w.type);let $e;w.isData3DTexture?(fe.setTexture3D(w,0),$e=z.TEXTURE_3D):w.isDataArrayTexture||w.isCompressedArrayTexture?(fe.setTexture2DArray(w,0),$e=z.TEXTURE_2D_ARRAY):(fe.setTexture2D(w,0),$e=z.TEXTURE_2D),A.activeTexture(z.TEXTURE0),A.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,w.flipY),A.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),A.pixelStorei(z.UNPACK_ALIGNMENT,w.unpackAlignment);const kn=A.getParameter(z.UNPACK_ROW_LENGTH),Dt=A.getParameter(z.UNPACK_IMAGE_HEIGHT),Cn=A.getParameter(z.UNPACK_SKIP_PIXELS),oi=A.getParameter(z.UNPACK_SKIP_ROWS),Bi=A.getParameter(z.UNPACK_SKIP_IMAGES);A.pixelStorei(z.UNPACK_ROW_LENGTH,Rt.width),A.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Rt.height),A.pixelStorei(z.UNPACK_SKIP_PIXELS,je),A.pixelStorei(z.UNPACK_SKIP_ROWS,Qe),A.pixelStorei(z.UNPACK_SKIP_IMAGES,st);const li=D.isDataArrayTexture||D.isData3DTexture,Qt=w.isDataArrayTexture||w.isData3DTexture;if(D.isDepthTexture){const fn=re.get(D),Fi=re.get(w),Yt=re.get(fn.__renderTarget),na=re.get(Fi.__renderTarget);A.bindFramebuffer(z.READ_FRAMEBUFFER,Yt.__webglFramebuffer),A.bindFramebuffer(z.DRAW_FRAMEBUFFER,na.__webglFramebuffer);for(let Wa=0;Wa<Ve;Wa++)li&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,re.get(D).__webglTexture,Y,st+Wa),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,re.get(w).__webglTexture,xe,nn+Wa)),z.blitFramebuffer(je,Qe,be,Be,et,Mt,be,Be,z.DEPTH_BUFFER_BIT,z.NEAREST);A.bindFramebuffer(z.READ_FRAMEBUFFER,null),A.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Y!==0||D.isRenderTargetTexture||re.has(D)){const fn=re.get(D),Fi=re.get(w);A.bindFramebuffer(z.READ_FRAMEBUFFER,pe),A.bindFramebuffer(z.DRAW_FRAMEBUFFER,Q);for(let Yt=0;Yt<Ve;Yt++)li?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,fn.__webglTexture,Y,st+Yt):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,fn.__webglTexture,Y),Qt?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Fi.__webglTexture,xe,nn+Yt):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Fi.__webglTexture,xe),Y!==0?z.blitFramebuffer(je,Qe,be,Be,et,Mt,be,Be,z.COLOR_BUFFER_BIT,z.NEAREST):Qt?z.copyTexSubImage3D($e,xe,et,Mt,nn+Yt,je,Qe,be,Be):z.copyTexSubImage2D($e,xe,et,Mt,je,Qe,be,Be);A.bindFramebuffer(z.READ_FRAMEBUFFER,null),A.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else Qt?D.isDataTexture||D.isData3DTexture?z.texSubImage3D($e,xe,et,Mt,nn,be,Be,Ve,Kt,$t,Rt.data):w.isCompressedArrayTexture?z.compressedTexSubImage3D($e,xe,et,Mt,nn,be,Be,Ve,Kt,Rt.data):z.texSubImage3D($e,xe,et,Mt,nn,be,Be,Ve,Kt,$t,Rt):D.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,xe,et,Mt,be,Be,Kt,$t,Rt.data):D.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,xe,et,Mt,Rt.width,Rt.height,Kt,Rt.data):z.texSubImage2D(z.TEXTURE_2D,xe,et,Mt,be,Be,Kt,$t,Rt);A.pixelStorei(z.UNPACK_ROW_LENGTH,kn),A.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Dt),A.pixelStorei(z.UNPACK_SKIP_PIXELS,Cn),A.pixelStorei(z.UNPACK_SKIP_ROWS,oi),A.pixelStorei(z.UNPACK_SKIP_IMAGES,Bi),xe===0&&w.generateMipmaps&&z.generateMipmap($e),A.unbindTexture()},this.initRenderTarget=function(D){re.get(D).__webglFramebuffer===void 0&&fe.setupRenderTarget(D)},this.initTexture=function(D){D.isCubeTexture?fe.setTextureCube(D,0):D.isData3DTexture?fe.setTexture3D(D,0):D.isDataArrayTexture||D.isCompressedArrayTexture?fe.setTexture2DArray(D,0):fe.setTexture2D(D,0),A.unbindTexture()},this.resetState=function(){V=0,j=0,ae=null,A.reset(),Ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ua}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=zt._getDrawingBufferColorSpace(e),n.unpackColorSpace=zt._getUnpackColorSpace()}}const Mx={type:"change"},um={type:"start"},Oy={type:"end"},Su=new sm,Ex=new bs,vR=Math.cos(70*LE.DEG2RAD),Rn=new se,ai=2*Math.PI,on={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Hh=1e-6;class xR extends ST{constructor(e,n=null){super(e,n),this.state=on.NONE,this.target=new se,this.cursor=new se,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:uo.ROTATE,MIDDLE:uo.DOLLY,RIGHT:uo.PAN},this.touches={ONE:oo.ROTATE,TWO:oo.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new se,this._lastQuaternion=new Cs,this._lastTargetPosition=new se,this._quat=new Cs().setFromUnitVectors(e.up,new se(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new $v,this._sphericalDelta=new $v,this._scale=1,this._panOffset=new se,this._rotateStart=new bt,this._rotateEnd=new bt,this._rotateDelta=new bt,this._panStart=new bt,this._panEnd=new bt,this._panDelta=new bt,this._dollyStart=new bt,this._dollyEnd=new bt,this._dollyDelta=new bt,this._dollyDirection=new se,this._mouse=new bt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=SR.bind(this),this._onPointerDown=yR.bind(this),this._onPointerUp=bR.bind(this),this._onContextMenu=RR.bind(this),this._onMouseWheel=TR.bind(this),this._onKeyDown=AR.bind(this),this._onTouchStart=CR.bind(this),this._onTouchMove=wR.bind(this),this._onMouseDown=MR.bind(this),this._onMouseMove=ER.bind(this),this._interceptControlDown=DR.bind(this),this._interceptControlUp=NR.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Mx),this.update(),this.state=on.NONE}pan(e,n){this._pan(e,n),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const n=this.object.position;Rn.copy(n).sub(this.target),Rn.applyQuaternion(this._quat),this._spherical.setFromVector3(Rn),this.autoRotate&&this.state===on.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,l=this.maxAzimuthAngle;isFinite(s)&&isFinite(l)&&(s<-Math.PI?s+=ai:s>Math.PI&&(s-=ai),l<-Math.PI?l+=ai:l>Math.PI&&(l-=ai),s<=l?this._spherical.theta=Math.max(s,Math.min(l,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+l)/2?Math.max(s,this._spherical.theta):Math.min(l,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let c=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const d=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),c=d!=this._spherical.radius}if(Rn.setFromSpherical(this._spherical),Rn.applyQuaternion(this._quatInverse),n.copy(this.target).add(Rn),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let d=null;if(this.object.isPerspectiveCamera){const p=Rn.length();d=this._clampDistance(p*this._scale);const m=p-d;this.object.position.addScaledVector(this._dollyDirection,m),this.object.updateMatrixWorld(),c=!!m}else if(this.object.isOrthographicCamera){const p=new se(this._mouse.x,this._mouse.y,0);p.unproject(this.object);const m=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),c=m!==this.object.zoom;const h=new se(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(p),this.object.updateMatrixWorld(),d=Rn.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;d!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(d).add(this.object.position):(Su.origin.copy(this.object.position),Su.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Su.direction))<vR?this.object.lookAt(this.target):(Ex.setFromNormalAndCoplanarPoint(this.object.up,this.target),Su.intersectPlane(Ex,this.target))))}else if(this.object.isOrthographicCamera){const d=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),d!==this.object.zoom&&(this.object.updateProjectionMatrix(),c=!0)}return this._scale=1,this._performCursorZoom=!1,c||this._lastPosition.distanceToSquared(this.object.position)>Hh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Hh||this._lastTargetPosition.distanceToSquared(this.target)>Hh?(this.dispatchEvent(Mx),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ai/60*this.autoRotateSpeed*e:ai/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){Rn.setFromMatrixColumn(n,0),Rn.multiplyScalar(-e),this._panOffset.add(Rn)}_panUp(e,n){this.screenSpacePanning===!0?Rn.setFromMatrixColumn(n,1):(Rn.setFromMatrixColumn(n,0),Rn.crossVectors(this.object.up,Rn)),Rn.multiplyScalar(e),this._panOffset.add(Rn)}_pan(e,n){const s=this.domElement;if(this.object.isPerspectiveCamera){const l=this.object.position;Rn.copy(l).sub(this.target);let c=Rn.length();c*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*c/s.clientHeight,this.object.matrix),this._panUp(2*n*c/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),l=e-s.left,c=n-s.top,d=s.width,p=s.height;this._mouse.x=l/d*2-1,this._mouse.y=-(c/p)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(ai*this._rotateDelta.x/n.clientHeight),this._rotateUp(ai*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-ai*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),l=.5*(e.pageY+n.y);this._rotateStart.set(s,l)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),l=.5*(e.pageY+n.y);this._panStart.set(s,l)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),s=e.pageX-n.x,l=e.pageY-n.y,c=Math.sqrt(s*s+l*l);this._dollyStart.set(0,c)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const s=this._getSecondPointerPosition(e),l=.5*(e.pageX+s.x),c=.5*(e.pageY+s.y);this._rotateEnd.set(l,c)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(ai*this._rotateDelta.x/n.clientHeight),this._rotateUp(ai*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),l=.5*(e.pageY+n.y);this._panEnd.set(s,l)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),s=e.pageX-n.x,l=e.pageY-n.y,c=Math.sqrt(s*s+l*l);this._dollyEnd.set(0,c),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const d=(e.pageX+n.x)*.5,p=(e.pageY+n.y)*.5;this._updateZoomParameters(d,p)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new bt,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function yR(a){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(a.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(a)&&(this._addPointer(a),a.pointerType==="touch"?this._onTouchStart(a):this._onMouseDown(a),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function SR(a){this.enabled!==!1&&(a.pointerType==="touch"?this._onTouchMove(a):this._onMouseMove(a))}function bR(a){switch(this._removePointer(a),this._pointers.length){case 0:this.domElement.releasePointerCapture(a.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Oy),this.state=on.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function MR(a){let e;switch(a.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case uo.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(a),this.state=on.DOLLY;break;case uo.ROTATE:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=on.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=on.ROTATE}break;case uo.PAN:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=on.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=on.PAN}break;default:this.state=on.NONE}this.state!==on.NONE&&this.dispatchEvent(um)}function ER(a){switch(this.state){case on.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(a);break;case on.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(a);break;case on.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(a);break}}function TR(a){this.enabled===!1||this.enableZoom===!1||this.state!==on.NONE||(a.preventDefault(),this.dispatchEvent(um),this._handleMouseWheel(this._customWheelEvent(a)),this.dispatchEvent(Oy))}function AR(a){this.enabled!==!1&&this._handleKeyDown(a)}function CR(a){switch(this._trackPointer(a),this._pointers.length){case 1:switch(this.touches.ONE){case oo.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(a),this.state=on.TOUCH_ROTATE;break;case oo.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(a),this.state=on.TOUCH_PAN;break;default:this.state=on.NONE}break;case 2:switch(this.touches.TWO){case oo.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(a),this.state=on.TOUCH_DOLLY_PAN;break;case oo.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(a),this.state=on.TOUCH_DOLLY_ROTATE;break;default:this.state=on.NONE}break;default:this.state=on.NONE}this.state!==on.NONE&&this.dispatchEvent(um)}function wR(a){switch(this._trackPointer(a),this.state){case on.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(a),this.update();break;case on.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(a),this.update();break;case on.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(a),this.update();break;case on.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(a),this.update();break;default:this.state=on.NONE}}function RR(a){this.enabled!==!1&&a.preventDefault()}function DR(a){a.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function NR(a){a.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Ts=16,Tx=28,UR=20;function Tl(a,e,n){return Math.min(n,Math.max(e,a))}function Ip(a){const e=Array.isArray(a)?a:[a];for(const n of e)n.dispose()}function Py(a,e){e&&(a.remove(e),e.geometry.dispose(),Ip(e.material))}function LR(a){return new $i({defines:{USE_INSTANCING_COLOR:""},uniforms:{ambientStrength:{value:.56},diffuseStrength:{value:.58},glowStrength:{value:.34},lightDirection:{value:new se(.45,.82,.36).normalize()},primaryColor:{value:a}},vertexShader:`
varying vec3 vColor;
varying vec3 vNormal;
varying vec3 vWorldPosition;
void main() {
vColor = instanceColor;
vNormal = normalize(mat3(modelMatrix * instanceMatrix) * normal);
vec4 worldPosition = modelMatrix * instanceMatrix * vec4(position, 1.0);
vWorldPosition = worldPosition.xyz;
gl_Position = projectionMatrix * viewMatrix * worldPosition;
}
`,fragmentShader:`
uniform float ambientStrength;
uniform float diffuseStrength;
uniform float glowStrength;
uniform vec3 lightDirection;
uniform vec3 primaryColor;
varying vec3 vColor;
varying vec3 vNormal;
varying vec3 vWorldPosition;
void main() {
vec3 normal = normalize(vNormal);
vec3 viewDirection = normalize(cameraPosition - vWorldPosition);
float diffuse = max(dot(normal, normalize(lightDirection)), 0.0);
float reverseFill = max(dot(normal, normalize(vec3(-0.45, 0.42, -0.68))), 0.0);
float rim = pow(1.0 - max(dot(normal, viewDirection), 0.0), 2.15);
float faceLift = pow(max(abs(normal.y), 0.0), 0.7) * 0.08;
vec3 color = max(vColor, primaryColor * 0.12);
vec3 lit = color * (ambientStrength + diffuse * diffuseStrength + reverseFill * 0.16 + faceLift);
vec3 glow = color * (0.18 + rim * glowStrength);
vec3 finalColor = lit + glow;
gl_FragColor = vec4(finalColor, 1.0);
}
`,toneMapped:!0})}function OR(a){const e=new rT(new fr(Ts,Ts,Ts)),n=new om({color:new ct(a.primaryColor).lerp(new ct("#ffffff"),.1)}),s=new Sy(e,n);return s.visible=a.showBounds,s}function PR(a){const e=new yT(Ts,12,new ct(a.accentColor).lerp(new ct("#ffffff"),.05),new ct(a.primaryColor).lerp(new ct("#000000"),.4));e.position.y=-Ts/2;const n=e.material;return n.opacity=.28,n.transparent=!0,e}function IR(a,e){a.primaryColor=new ct(e.primaryColor),a.accentColor=new ct(e.accentColor),a.bounds.visible=e.showBounds,a.bounds.material.color=a.primaryColor.clone().lerp(new ct("#ffffff"),.1)}function BR(a,e){const s=Ts/a*(1-Tl(e.cellGap,.02,.45)),l=new fr(s,s,s),c=LR(new ct(e.primaryColor)),d=new eT(l,c,Math.max(1,a**3));return d.instanceMatrix.setUsage(CE),d.castShadow=!0,d.receiveShadow=!0,d}const Gh=["#70f45f","#f0c94a","#35d6ff","#ff5fb7","#ff7a3d","#b28cff","#f7f7df","#42f5b0","#ffef5f","#6aa8ff"];function FR(a,e){const n=Number(a),s=Number(e);return Number.isFinite(n)&&Number.isFinite(s)?n-s:a.localeCompare(e)}function Bp(a){return a.state??"occupied"}function zR(a,e){const n=[...new Set(a.map(Bp))].sort(FR),s=new Map,l=new Map,c=new ct(e.primaryColor),d=new ct(e.accentColor);return n.forEach((p,m)=>{if(l.set(p,m),n.length===1){s.set(p,c.clone());return}const h=Gh[m%Gh.length],v=new ct(h);m>=Gh.length&&v.setHSL(m*.61803398875%1,.72,.56),v.lerp(d,m%2===0?.08:.16),s.set(p,v)}),{colors:s,indices:l}}function HR(a,e,n,s,l,c){const d=n>1?e.y/(n-1):.5,p=n>1?e.z/(n-1):.5,m=l.indices.get(Bp(e))??0,h=Math.max(1,l.colors.size-1),v=l.colors.size>1?Tl(m/h,0,1):.5;if(c.copy(l.colors.get(Bp(e))??a.primaryColor),c.lerp(a.accentColor,Tl(d*.08,0,.16)),s==="lattice-gas-3d"||s==="snake-3d"||s==="naga-3d"){c.lerp(new ct("#ffffff"),Tl(v*.22+p*.08,0,.34)),c.multiplyScalar(1+v*.16);return}s==="generations-3d"&&c.lerp(new ct("#94a3b8"),v*.22),c.lerp(new ct("#ffffff"),Tl(p*.18,0,.24)),c.offsetHSL(0,0,.05+p*.1)}function GR(a,e,n,s,l){Py(a.scene,a.mesh),a.mesh=BR(n,l),a.scene.add(a.mesh);const c=a.mesh,d=new Dn,p=new ct,m=Ts/n,h=-Ts/2+m/2,v=zR(e,l);let S=0;for(const _ of e){if(S>=c.count)break;_.x<0||_.y<0||_.z<0||_.x>=n||_.y>=n||_.z>=n||(d.position.set(h+_.x*m,h+_.y*m,h+_.z*m),d.rotation.set(0,0,0),d.updateMatrix(),HR(a,_,n,s,v,p),c.setMatrixAt(S,d.matrix),c.setColorAt(S,p),S+=1)}c.count=S,c.instanceMatrix.needsUpdate=!0,c.instanceColor&&(c.instanceColor.needsUpdate=!0)}function VR(a,e){const n=new qE;n.background=new ct("#061006");const s=new Ni(42,1,.1,300);s.position.set(Tx,UR,Tx);const l=new _R({antialias:!0,alpha:!0});l.setPixelRatio(Math.min(window.devicePixelRatio,2)),l.shadowMap.enabled=!0,l.shadowMap.type=Qx,l.outputColorSpace=vi,l.toneMapping=Yp,l.toneMappingExposure=1.32,a.appendChild(l.domElement);const c=new xR(s,l.domElement);c.enableDamping=!0,c.dampingFactor=.06,c.minDistance=12,c.maxDistance=60,c.target.set(0,0,0),n.add(new _T("#f5efb7",.72)),n.add(new pT("#f5efb7","#10360d",1.18));const d=new Kv("#fff3a8",.82);d.position.set(18,28,14),d.target.position.set(0,0,0),n.add(d),n.add(d.target);const p=new Kv(e.accentColor,.72);p.position.set(-24,18,-12),n.add(p);const m=OR(e);n.add(m);const h=PR(e);n.add(h);const v={animationFrame:0,bounds:m,grid:h,mesh:null,primaryColor:new ct(e.primaryColor),accentColor:new ct(e.accentColor),resizeObserver:new ResizeObserver(()=>S()),scene:n};function S(){const E=Math.max(a.clientWidth,1),C=Math.max(a.clientHeight,1);s.aspect=E/C,s.updateProjectionMatrix(),l.setSize(E,C,!1)}function _(){c.update(),l.render(n,s)}function M(){_(),v.animationFrame=window.requestAnimationFrame(M)}return v.resizeObserver.observe(a),S(),M(),{dispose(){window.cancelAnimationFrame(v.animationFrame),v.resizeObserver.disconnect(),Py(v.scene,v.mesh),v.bounds.geometry.dispose(),Ip(v.bounds.material),v.grid.geometry.dispose(),Ip(v.grid.material),c.dispose(),l.dispose(),l.domElement.parentNode===a&&a.removeChild(l.domElement)},render:_,update(E){IR(v,E.options),GR(v,E.cells,E.size,E.ruleId,E.options),_()}}}function kR(a){const e=a.simulation?.grid?.size;if(!Array.isArray(e))return 16;const n=e[0];return typeof n=="number"?Math.min(30,Math.max(8,Math.round(n))):16}function jR(a){const e=a.simulation?.ruleId;return typeof e=="string"&&e.endsWith("-3d")?e:"life-3d"}function XR(a){const e=a.renderer??{};return{accentColor:typeof e.accentColor=="string"?e.accentColor:"#f0c94a",cellGap:typeof e.cellGap=="number"?e.cellGap:.14,primaryColor:typeof e.primaryColor=="string"?e.primaryColor:"#70f45f",showBounds:typeof e.showBounds=="boolean"?e.showBounds:!0}}function WR(a){const e=a.simulation?.initialCondition?.cells;return Array.isArray(e)?e.flatMap(n=>{const s=n,[l,c,d=0]=s;if(!Number.isInteger(l)||!Number.isInteger(c)||!Number.isInteger(d))return[];const p=l,m=c,h=d,v=s.length>=4?s[3]:"occupied";if(v===null||v==="none"||v==="empty")return[];const S=typeof v=="string"||typeof v=="number"?String(v):"occupied";return[{x:p,y:m,z:h,state:S}]}):[]}function qR({caption:a,settings:e}){const n=ee.useRef(null),s=ee.useRef(null),l=WR(e),c=kR(e),d=jR(e),p=ee.useMemo(()=>XR(e),[e]);return ee.useEffect(()=>{const m=n.current;if(!m)return;const h=VR(m,p);return s.current=h,h.update({cells:l,options:p,ruleId:d,size:c}),()=>{h.dispose(),s.current=null}},[]),ee.useEffect(()=>{s.current?.update({cells:l,options:p,ruleId:d,size:c})},[l,p,d,c]),g.jsxs("div",{className:"board-wrap voxel-renderer-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("div",{className:"studio-voxel-viewport",ref:n}),l.length===0?g.jsx("div",{className:"voxel-empty-hint",children:"No voxel initial condition on this node"}):null]})}const Ll=new Map;function Xu(a,e={}){if(!a.id.trim())throw new Error("CA renderer runtime id is required");if(Ll.has(a.id)&&!e.replace)throw new Error(`CA renderer runtime already registered: ${a.id}`);Ll.set(a.id,a)}function YR(){return[...Ll.values()]}function Vh(a){return YR().filter(e=>Fa(e,a))}function ZR(a){return Ll.get(a)??[...Ll.values()].find(e=>e.aliases?.includes(a))??null}function Wu({caption:a,cells:e,settings:n,onCellsChange:s}){const l=n.renderer?.id??"2d-canvas",c=ZR(l),d=ir(n);if(c&&(!d||Fa(c,d))){const p=c.Component;return g.jsx(p,{caption:a,cells:e,settings:n,onCellsChange:s})}return g.jsxs("div",{className:"board-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("div",{className:"renderer-empty",children:c?`Renderer ${l} does not support this CA space`:`Renderer unavailable: ${l}`})]})}function KR({caption:a,settings:e}){return g.jsx(qR,{caption:a,settings:e})}function $R(a,e,n,s){return typeof a=="number"&&Number.isFinite(a)?Math.max(n,Math.min(s,a)):e}function QR(a){const e=a.renderer?.elementaryRule;if(typeof e=="number")return Math.max(0,Math.min(255,Math.floor(e)));const n=a.simulation?.ruleId??"",s=/(?:rule[-_\s]*)?(\d{1,3})/i.exec(n);return s?Math.max(0,Math.min(255,Number(s[1]))):110}function JR(a,e){return a.map((n,s)=>{const l=a[(s-1+a.length)%a.length]?1:0,c=a[s]?1:0,d=a[(s+1)%a.length]?1:0,p=l<<2|c<<1|d;return(e>>p&1)===1})}function e2(a){const e=a.findIndex(n=>n.some(Boolean));return e===-1?0:e}function t2({caption:a,cells:e,onCellsChange:n}){const s=ee.useRef(null),l=ee.useRef(e),c=ee.useRef(null),[d,p]=ee.useState(0),m=e[0]?.length??0,h=e.length;ee.useEffect(()=>{l.current=e},[e]),ee.useEffect(()=>{const C=s.current;if(!C)return;const y=new ResizeObserver(()=>p(x=>x+1));return y.observe(C),()=>y.disconnect()},[]),ee.useEffect(()=>{const C=s.current;if(!C||m===0||h===0)return;const y=C.getContext("2d");if(!y)return;const x=C.getBoundingClientRect(),P=window.devicePixelRatio||1,O=Math.max(1,Math.floor(x.width*P)),R=Math.max(1,Math.floor(x.height*P));(C.width!==O||C.height!==R)&&(C.width=O,C.height=R),y.setTransform(P,0,0,P,0,0),y.clearRect(0,0,x.width,x.height),y.fillStyle="#071206",y.fillRect(0,0,x.width,x.height);const I=Math.min(x.width/m,x.height/h),B=I*m,L=I*h,T=(x.width-B)/2,U=(x.height-L)/2,X=Math.max(1,Math.min(2,I*.08));y.strokeStyle="#1e3519",y.lineWidth=1;for(let G=0;G<h;G+=1)for(let K=0;K<m;K+=1){const ue=T+K*I+X/2,pe=U+G*I+X/2,Q=Math.max(1,I-X);e[G][K]?(y.fillStyle="#70f45f",y.shadowColor="rgba(112, 244, 95, 0.42)",y.shadowBlur=Math.max(0,I*.38),y.fillRect(ue,pe,Q,Q),y.shadowBlur=0,y.strokeStyle="#b7ffab"):(y.fillStyle="#071206",y.fillRect(ue,pe,Q,Q),y.strokeStyle="#1e3519"),y.strokeRect(ue+.5,pe+.5,Math.max(0,Q-1),Math.max(0,Q-1))}},[d,e,h,m]);function v(C){const y=s.current;if(!y||m===0||h===0)return null;const x=y.getBoundingClientRect(),P=Math.min(x.width/m,x.height/h),O=P*m,R=P*h,I=(x.width-O)/2,B=(x.height-R)/2,L=Math.floor((C.clientX-x.left-I)/P),T=Math.floor((C.clientY-x.top-B)/P);return L<0||T<0||L>=m||T>=h?null:{x:L,y:T}}function S(C,y,x){const P=l.current;if(P[y]?.[C]===x)return;const O=P.map((R,I)=>I===y?R.map((B,L)=>L===C?x:B):R);l.current=O,n(O)}function _(C){const y=v(C);if(!y)return;C.currentTarget.setPointerCapture(C.pointerId);const x=!l.current[y.y][y.x];c.current=x,S(y.x,y.y,x)}function M(C){if(c.current===null)return;const y=v(C);y&&S(y.x,y.y,c.current)}function E(C){c.current=null,C.currentTarget.hasPointerCapture(C.pointerId)&&C.currentTarget.releasePointerCapture(C.pointerId)}return g.jsxs("div",{className:"board-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("canvas",{ref:s,"aria-label":"Game of Life cell editor",className:"board-canvas",role:"img",onPointerCancel:E,onPointerDown:_,onPointerLeave:E,onPointerMove:M,onPointerUp:E})]})}function n2({caption:a,cells:e,settings:n,onCellsChange:s}){const l=ee.useRef(null),c=ee.useRef(e),[d,p]=ee.useState(0),m=e[0]?.length??0,h=Math.min(e.length-1,Math.max(0,e2(e))),v=e[h]??[],S=QR(n),_=$R(n.renderer?.historyRows,96,8,512);ee.useEffect(()=>{c.current=e},[e]),ee.useEffect(()=>{const E=l.current;if(!E)return;const C=new ResizeObserver(()=>p(y=>y+1));return C.observe(E),()=>C.disconnect()},[]),ee.useEffect(()=>{const E=l.current;if(!E||m===0||v.length===0)return;const C=E.getContext("2d");if(!C)return;const y=E.getBoundingClientRect(),x=window.devicePixelRatio||1,P=Math.max(1,Math.floor(y.width*x)),O=Math.max(1,Math.floor(y.height*x));(E.width!==P||E.height!==O)&&(E.width=P,E.height=O),C.setTransform(x,0,0,x,0,0),C.clearRect(0,0,y.width,y.height),C.fillStyle="#061006",C.fillRect(0,0,y.width,y.height);const R=y.width/m,I=y.height/_;let B=[...v];for(let L=0;L<_;L+=1){const T=L/Math.max(1,_-1);for(let U=0;U<m;U+=1)if(B[U]){const X=Math.round(190+T*55),G=Math.round(112+T*80);C.fillStyle=`rgb(${G} ${X} 92)`,C.fillRect(U*R,L*I,Math.ceil(R),Math.ceil(I))}B=JR(B,S)}C.strokeStyle="rgba(240, 201, 74, 0.32)",C.lineWidth=1,C.strokeRect(.5,.5,Math.max(0,y.width-1),Math.max(0,y.height-1))},[d,_,S,v,m]);function M(E){const C=l.current;if(!C||m===0)return;const y=C.getBoundingClientRect(),x=Math.floor((E.clientX-y.left)/y.width*m);if(x<0||x>=m)return;const O=c.current.map((R,I)=>I===h?R.map((B,L)=>L===x?!B:B):R);c.current=O,s(O)}return g.jsxs("div",{className:"board-wrap elementary-renderer-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("canvas",{ref:l,"aria-label":`Elementary cellular automaton rule ${S}`,className:"elementary-canvas",role:"img",onPointerDown:M})]})}function i2({caption:a,cells:e,onCellsChange:n}){const s=ee.useRef(null),l=ee.useRef(e),c=ee.useRef(null),[d,p]=ee.useState(0),m=e[0]?.length??0,h=e.length;ee.useEffect(()=>{l.current=e},[e]),ee.useEffect(()=>{const C=s.current;if(!C)return;const y=new ResizeObserver(()=>p(x=>x+1));return y.observe(C),()=>y.disconnect()},[]),ee.useEffect(()=>{const C=s.current;if(!C||m===0||h===0)return;const y=C.getContext("2d");if(!y)return;const x=C.getBoundingClientRect(),P=window.devicePixelRatio||1,O=Math.max(1,Math.floor(x.width*P)),R=Math.max(1,Math.floor(x.height*P));(C.width!==O||C.height!==R)&&(C.width=O,C.height=R),y.setTransform(P,0,0,P,0,0),y.clearRect(0,0,x.width,x.height);const I=Math.min(x.width/m,x.height/h),B=I*m,L=I*h,T=(x.width-B)/2,U=(x.height-L)/2;y.fillStyle="#061006",y.fillRect(0,0,x.width,x.height);for(let X=0;X<h;X+=1)for(let G=0;G<m;G+=1){const K=T+G*I,ue=U+X*I;if(e[X][G]){const pe=y.createRadialGradient(K+I*.5,ue+I*.52,I*.08,K+I*.5,ue+I*.52,I*.62);pe.addColorStop(0,"#fff5b9"),pe.addColorStop(.45,"#f0c94a"),pe.addColorStop(1,"#d9481e"),y.fillStyle=pe}else y.fillStyle=(G+X)%2===0?"#143f1b":"#0d2b14";y.fillRect(K,ue,Math.ceil(I),Math.ceil(I))}},[d,e,h,m]);function v(C){const y=s.current;if(!y||m===0||h===0)return null;const x=y.getBoundingClientRect(),P=Math.min(x.width/m,x.height/h),O=P*m,R=P*h,I=(x.width-O)/2,B=(x.height-R)/2,L=Math.floor((C.clientX-x.left-I)/P),T=Math.floor((C.clientY-x.top-B)/P);return L<0||T<0||L>=m||T>=h?null:{x:L,y:T}}function S(C,y,x){const P=l.current;if(P[y]?.[C]===x)return;const O=P.map((R,I)=>I===y?R.map((B,L)=>L===C?x:B):R);l.current=O,n(O)}function _(C){const y=v(C);if(!y)return;C.currentTarget.setPointerCapture(C.pointerId);const x=!l.current[y.y][y.x];c.current=x,S(y.x,y.y,x)}function M(C){if(c.current===null)return;const y=v(C);y&&S(y.x,y.y,c.current)}function E(C){c.current=null,C.currentTarget.hasPointerCapture(C.pointerId)&&C.currentTarget.releasePointerCapture(C.pointerId)}return g.jsxs("div",{className:"board-wrap wildfire-renderer-wrap",children:[a.trim()?g.jsx("div",{className:"renderer-caption",children:a}):null,g.jsx("canvas",{ref:s,"aria-label":"Wildfire cellular automaton editor",className:"wildfire-canvas",role:"img",onPointerCancel:E,onPointerDown:_,onPointerLeave:E,onPointerMove:M,onPointerUp:E})]})}Xu({id:"2d-canvas",label:"2D Canvas",supportedClasses:[{dimensions:2,states:2}],Component:t2},{replace:!0});Xu({id:"elementary-1d",label:"Elementary 1D",aliases:["elementary-ca","1d-canvas"],supportedClasses:[{dimensions:1,states:2}],Component:n2},{replace:!0});Xu({id:"wildfire-2d",label:"Wildfire 2D",aliases:["forest-fire-2d"],supportedClasses:[{dimensions:2,states:2}],Component:i2},{replace:!0});Xu({id:"voxel-3d",label:"Voxel 3D",aliases:["three-voxel"],supportedClasses:[{dimensions:3,states:2},{dimensions:3,states:7}],Component:KR},{replace:!0});function a2(a,e){return a.sort_order-e.sort_order||a.name.localeCompare(e.name)}function s2(a){const e=new Map;for(const s of a){const l=e.get(s.parent_id)??[];l.push(s),e.set(s.parent_id,l)}function n(s){return(e.get(s)??[]).sort(a2).map(l=>({node:l,children:n(l.id)}))}return n(null)}function r2({assignedNodeId:a,nodes:e,selectedNodeId:n,onSelect:s}){const l=ee.useMemo(()=>s2(e),[e]);return l.length===0?g.jsx("p",{className:"empty",children:"This CA library has no presets."}):g.jsx("div",{className:"asset-tree",children:l.map(c=>g.jsx(Iy,{assignedNodeId:a,item:c,selectedNodeId:n,onSelect:s},c.node.id))})}function Iy({assignedNodeId:a,item:e,selectedNodeId:n,onSelect:s}){const[l,c]=ee.useState(!0),d=e.node.id===n,p=e.node.id===a;return g.jsxs("div",{className:"asset-tree-item",children:[g.jsxs("div",{className:`asset-tree-row${d?" selected":""}${p?" assigned":""}`,children:[g.jsx("button",{"aria-label":e.children.length?`${l?"Collapse":"Expand"} ${e.node.name}`:`${e.node.name} has no children`,className:"asset-tree-arrow",disabled:!e.children.length,type:"button",onClick:()=>c(m=>!m),children:e.children.length?l?"▾":"▸":"·"}),g.jsxs("button",{className:"asset-tree-select",type:"button",onClick:()=>s(e.node),children:[g.jsx("strong",{children:e.node.name}),g.jsxs("small",{children:[e.node.kind,p?" · current":""]}),e.node.description?g.jsx("span",{children:e.node.description}):null]})]}),l&&e.children.length?g.jsx("div",{className:"asset-tree-children",children:e.children.map(m=>g.jsx(Iy,{assignedNodeId:a,item:m,selectedNodeId:n,onSelect:s},m.node.id))}):null]})}function lr(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function o2(a,e){return JSON.stringify(a)===JSON.stringify(e)}function kh(a,e){let n=a;for(const s of e){if(!lr(n)||!(s in n))return;n=n[s]}return n}function l2(a,e){return a.join(".")==="simulation.initialCondition"&&lr(e)?`${Array.isArray(e.cells)?e.cells.length:0} live cells`:Array.isArray(e)?`${e.length} items`:lr(e)?"object":String(e)}function dm(a,e){const n={...a};for(const[s,l]of Object.entries(e)){const c=n[s];n[s]=lr(c)&&lr(l)?dm(c,l):l}return n}function c2(a,e){return a.sort_order-e.sort_order||a.name.localeCompare(e.name)||a.slug.localeCompare(e.slug)}function u2(a){const e=new Map;for(const s of a){const l=e.get(s.parent_id)??[];l.push(s),e.set(s.parent_id,l)}function n(s){const l=(e.get(s)??[]).sort(c2);return l.map((c,d)=>({node:c,children:n(c.id),siblingIndex:d,siblingCount:l.length}))}return n(null)}function By(a,e,n={},s=null){const l=[];for(const c of a)if(l.push({item:c,inheritedParams:n,parentId:s}),e.has(c.node.id)){const d=dm(n,c.node.params);l.push(...By(c.children,e,d,c.node.id))}return l}function d2({assignedNodeId:a,engines:e=[],nodes:n,selectedNodeId:s,usedNodeIds:l,onCreateChild:c,onCreateGroup:d,onDelete:p,onMove:m,onRename:h,onSelect:v,onSet:S,onUnset:_}){const M=ee.useMemo(()=>u2(n),[n]),[E,C]=ee.useState(()=>new Set(n.map(L=>L.id))),[y,x]=ee.useState(""),[P,O]=ee.useState(""),R=ee.useMemo(()=>By(M,E),[E,M]);ee.useEffect(()=>{C(L=>{const T=new Set([...L].filter(U=>n.some(X=>X.id===U)));for(const U of n)L.has(U.id)||T.add(U.id);return T})},[n]),ee.useEffect(()=>{if(!P)return;function L(U){const X=U.target;X instanceof Element&&(X.closest(".tree-node-action-menu")||X.closest(".node-action-trigger")||O(""))}function T(U){U.key==="Escape"&&O("")}return document.addEventListener("pointerdown",L),document.addEventListener("keydown",T),()=>{document.removeEventListener("pointerdown",L),document.removeEventListener("keydown",T)}},[P]);function I(L,T){C(U=>{const X=new Set(U);return T??!X.has(L)?X.add(L):X.delete(L),X})}function B(L){if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter"].includes(L.key))return;const T=R.findIndex(({item:G})=>G.node.id===s),U=T===-1?0:T,X=R[U];if(X){if(L.key==="ArrowDown"||L.key==="ArrowUp"){L.preventDefault();const G=L.key==="ArrowDown"?1:-1,K=R[Math.min(Math.max(U+G,0),R.length-1)];K&&v(K.item.node);return}if(L.key==="ArrowRight"){L.preventDefault(),X.item.children.length&&!E.has(X.item.node.id)?I(X.item.node.id,!0):X.item.children[0]&&v(X.item.children[0].node);return}if(L.key==="ArrowLeft"){if(L.preventDefault(),E.has(X.item.node.id)&&X.item.children.length)I(X.item.node.id,!1);else if(X.parentId){const G=n.find(K=>K.id===X.parentId);G&&v(G)}return}L.preventDefault(),x(X.item.node.id)}}return M.length===0?g.jsx("p",{className:"empty",children:"No nodes loaded."}):g.jsx("div",{className:"preset-node-tree",role:"tree",tabIndex:0,onKeyDown:B,children:M.map(L=>g.jsx(Fy,{item:L,assignedNodeId:a,engines:e,inheritedParams:{},selectedNodeId:s,usedNodeIds:l,expandedNodeIds:E,editingNodeId:y,openMenuNodeId:P,onCreateChild:c,onCreateGroup:d,onDelete:p,onEdit:x,onMenuToggle:T=>O(U=>U===T?"":T),onMove:m,onRename:h,onSelect:v,onSet:S,onToggle:I,onUnset:_},L.node.id))})}function Fy({item:a,assignedNodeId:e,engines:n,inheritedParams:s,selectedNodeId:l,usedNodeIds:c,expandedNodeIds:d,editingNodeId:p,openMenuNodeId:m,onCreateChild:h,onCreateGroup:v,onDelete:S,onEdit:_,onMenuToggle:M,onMove:E,onRename:C,onSelect:y,onSet:x,onToggle:P,onUnset:O}){const R=d.has(a.node.id),I=m===a.node.id,B=a.node.id===l,L=a.node.id===e,T=c.has(a.node.id),U=ee.useMemo(()=>{function pe(Q){return Q.reduce((V,j)=>V+(c.has(j.node.id)?1:0)+pe(j.children),0)}return pe(a.children)},[a.children,c]),X=dm(s,a.node.params),G=a.node.kind==="preset_root"?"root":a.node.kind==="chapter"?"group":a.node.kind,K=L?`${G} · assigned`:T?`${G} · used by slides`:U>0?`${G} · contains ${U} used preset${U===1?"":"s"}`:`${G} · unused`;async function ue(){M(a.node.id),window.confirm(`Delete preset "${a.node.name}"? This cannot be undone.`)&&await S(a.node)}return g.jsxs("div",{className:"tree-item",children:[g.jsxs("div",{className:`tree-node${B?" active":""}${L?" assigned":""}${T||U>0?" used":" unused"}`,children:[g.jsx("button",{"aria-label":a.children.length?`${R?"Collapse":"Expand"} ${a.node.name}`:`${a.node.name} has no children`,className:"tree-node-arrow",disabled:!a.children.length,type:"button",onClick:()=>P(a.node.id),children:a.children.length?R?"▾":"▸":"•"}),g.jsxs("button",{"aria-current":B?"true":void 0,className:"tree-node-main",role:"treeitem",type:"button",onClick:()=>y(a.node),children:[g.jsx("strong",{children:a.node.name}),g.jsx("small",{children:K})]}),g.jsxs("div",{className:"tree-node-action-shell",children:[g.jsx("button",{"aria-expanded":I,"aria-haspopup":"menu","aria-label":`Actions for ${a.node.name}`,className:"icon-button tree-node-edit node-action-trigger",title:"Preset actions",type:"button",onClick:pe=>{pe.stopPropagation(),M(a.node.id)},children:"⋯"}),I?g.jsxs("div",{className:"tree-node-action-menu",role:"menu",children:[g.jsx("button",{role:"menuitem",type:"button",onClick:()=>{M(a.node.id),_(a.node.id)},children:"Edit"}),g.jsx("button",{role:"menuitem",type:"button",onClick:()=>{M(a.node.id),h(a.node)},children:"Create child preset"}),g.jsx("button",{role:"menuitem",type:"button",onClick:()=>{M(a.node.id),v(a.node)},children:"Create child group"}),g.jsx("button",{disabled:a.siblingIndex===0,role:"menuitem",type:"button",onClick:()=>{M(a.node.id),E(a.node,-1)},children:"Move up"}),g.jsx("button",{disabled:a.siblingIndex>=a.siblingCount-1,role:"menuitem",type:"button",onClick:()=>{M(a.node.id),E(a.node,1)},children:"Move down"}),g.jsx("button",{className:"danger",role:"menuitem",type:"button",onClick:()=>{ue()},children:"Delete"})]}):null]})]}),p===a.node.id?g.jsx(_2,{engines:n,inheritedParams:s,node:a.node,resolvedParams:X,onClose:()=>_(""),onDelete:S,onRename:C,onSet:x,onUnset:O}):null,R&&a.children.length?g.jsx("div",{className:"tree-children",children:a.children.map(pe=>g.jsx(Fy,{assignedNodeId:e,engines:n,inheritedParams:X,item:pe,usedNodeIds:c,expandedNodeIds:d,editingNodeId:p,openMenuNodeId:m,onCreateChild:h,onCreateGroup:v,onDelete:S,onEdit:_,onMenuToggle:M,onMove:E,onRename:C,onSelect:y,onSet:x,onToggle:P,onUnset:O,selectedNodeId:l},pe.node.id))}):null]})}function zy(a,e=[]){if(!lr(a))return[];const n=[];for(const[s,l]of Object.entries(a)){const c=[...e,s];c.join(".")==="simulation.initialCondition"||!lr(l)?n.push({path:c,value:l}):n.push(...zy(l,c))}return n}function f2(a){const e=a.join(".");return e!=="simulation.initialCondition"&&e!=="simulation.engineId"&&e!=="simulation.neighborhoodId"&&!e.startsWith("caClass.")}function h2(a){return a==="rendererId"?["renderer","id"]:a==="ruleId"?["simulation","ruleId"]:a.startsWith("grid.")?["simulation",...a.split(".")]:a.includes(".")?a.split("."):["simulation",a]}function p2(a){return a?Object.keys(a.params_schema):[]}function m2(a,e){const n=a.join(".");return p2(e).some(s=>h2(s).join(".")===n)}function g2(a){const e=a.trim();if(e==="")return"";try{return JSON.parse(e)}catch{return a}}function Ax(a){return typeof a=="string"?a:JSON.stringify(a,null,2)}function _2({engines:a,inheritedParams:e,node:n,resolvedParams:s,onClose:l,onDelete:c,onRename:d,onSet:p,onUnset:m}){const[h,v]=ee.useState(n.name),S=kh(s,["simulation","engineId"]),_=ir(s),M=typeof S=="string"?a.find(O=>O.engine_kind===S):void 0,C=(M?Fa(M,_):!1)?M:void 0,y=zy(s).filter(O=>f2(O.path)&&!m2(O.path,C));ee.useEffect(()=>{v(n.name)},[n.name]);async function x(){const O=h.trim();if(!O){v(n.name);return}O!==n.name&&await d(n,O)}async function P(){!window.confirm(`Delete preset "${n.name}"? This cannot be undone.`)||await c(n)===!1||l()}return g.jsx("div",{className:"modal-backdrop",role:"presentation",onMouseDown:l,children:g.jsxs("section",{"aria-modal":"true",className:"property-modal",role:"dialog",onMouseDown:O=>O.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Preset Editor"}),g.jsx("h2",{children:"Edit preset"})]}),g.jsxs("span",{className:"win95-window-controls has-close",children:[g.jsx("span",{className:"window-control-decor",children:"_"}),g.jsx("span",{className:"window-control-decor",children:"□"}),g.jsx("button",{"aria-label":"Close",className:"window-control-button window-close-button",title:"Close",type:"button",onClick:l,children:"×"})]})]}),g.jsxs("div",{className:"property-modal-list",children:[g.jsxs("section",{className:"preset-modal-stage preset-modal-identity",children:[g.jsxs("div",{className:"preset-modal-stage-heading",children:[g.jsx("span",{children:"i"}),g.jsxs("div",{children:[g.jsx("h3",{children:"Preset identity"}),g.jsx("p",{children:"Edit CA space, engine, and engine settings in the inspector."})]})]}),g.jsxs("label",{children:["Preset name",g.jsx("input",{autoFocus:!0,value:h,onChange:O=>v(O.target.value),onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),x())}})]}),g.jsx("button",{disabled:!h.trim()||h.trim()===n.name,type:"button",onClick:()=>{x()},children:"Save name"})]}),y.map(O=>{const R=kh(n.params,O.path),I=kh(e,O.path),B=R!==void 0&&!o2(R,I);return g.jsx(v2,{inheritedValue:I,isLocal:B,node:n,path:O.path,value:O.value,onSet:p,onUnset:m},O.path.join("."))}),y.length===0?g.jsx("p",{className:"empty",children:"No properties are resolved for this node."}):null,g.jsxs("footer",{className:"preset-modal-danger",children:[g.jsxs("div",{children:[g.jsx("strong",{children:"Delete preset"}),g.jsx("small",{children:"Slides referencing this preset must be reassigned first."})]}),g.jsx("button",{className:"danger",type:"button",onClick:()=>{P()},children:"Delete"})]})]})]})})}function v2({inheritedValue:a,isLocal:e,node:n,path:s,value:l,onSet:c,onUnset:d}){const[p,m]=ee.useState(Ax(l));return ee.useEffect(()=>{m(Ax(l))},[l]),g.jsxs("div",{className:"property-row",children:[g.jsxs("div",{className:"property-row-meta",children:[g.jsx("strong",{children:s.join(".")}),g.jsx("span",{className:e?"local":"inherited",children:e?"local override":"inherited"}),!e&&a!==void 0?g.jsxs("small",{children:["from parent: ",l2(s,a)]}):null]}),g.jsx("textarea",{value:p,onChange:h=>m(h.target.value)}),g.jsxs("div",{className:"property-row-actions",children:[g.jsx("button",{type:"button",onClick:()=>c(n,s,g2(p)),children:"Save"}),g.jsx("button",{className:"danger",disabled:!e,type:"button",onClick:()=>d(n,s),children:"🗑"})]})]})}function x2({activeSceneId:a,canDeleteSlide:e,sceneCount:n,scenes:s,onBack:l,onDeleteSlide:c,onEditScene:d,onReorderSlides:p,onSaveNewSlide:m,onSelectScene:h}){const[v,S]=ee.useState(""),[_,M]=ee.useState(null);function E(y){return(typeof y.scene.params.caption=="string"?y.scene.params.caption:"").split(/\r?\n/,1)[0].trim()||"No caption"}function C(y,x){if(!v||v===y)return;const P=s.find(L=>L.scene.id===v);if(!P)return;const O=s.filter(L=>L.scene.id!==v),R=O.findIndex(L=>L.scene.id===y);if(R===-1)return;const I=x==="after"?R+1:R,B=[...O];B.splice(I,0,P),p(B)}return g.jsxs("aside",{className:"panel slide-panel",children:[g.jsx("div",{className:"drawer-navigation",children:g.jsx("button",{type:"button",onClick:l,children:"Back"})}),g.jsxs("div",{className:"scene-list-header",children:[g.jsx("p",{className:"eyebrow",children:"Slides"}),g.jsx("span",{children:n})]}),s.length?s.map(y=>g.jsxs("div",{className:`scene-item${y.scene.id===a?" active":""}${y.scene.id===v?" dragging":""}${_?.sceneId===y.scene.id?` drop-${_.position}`:""}`,draggable:!0,onDragEnd:()=>{S(""),M(null)},onDragOver:x=>{x.preventDefault();const P=x.currentTarget.getBoundingClientRect(),O=x.clientY>P.top+P.height/2?"after":"before";M({sceneId:y.scene.id,position:O})},onDragStart:x=>{S(y.scene.id),x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",y.scene.id)},onDrop:x=>{x.preventDefault();const P=x.currentTarget.getBoundingClientRect(),O=x.clientY>P.top+P.height/2?"after":"before";C(y.scene.id,O),S(""),M(null)},children:[g.jsxs("button",{className:"scene-item-main",type:"button",onClick:()=>h(y),children:[g.jsx("span",{children:y.scene.order_index}),g.jsx("strong",{children:y.scene.title}),g.jsx("small",{className:"scene-caption-preview",children:E(y)})]}),g.jsx("button",{"aria-label":`Edit ${y.scene.title} metadata`,className:"scene-edit-button icon-button",type:"button",onClick:()=>d(y),children:"✎"})]},y.scene.id)):g.jsx("p",{className:"empty",children:"No slides yet. Choose a CA asset to create the first one."}),g.jsx("button",{className:"primary full-width",type:"button",onClick:m,children:"New slide"}),g.jsx("button",{className:"danger full-width",disabled:!e,type:"button",onClick:c,children:"Delete selected slide"})]})}const ha=24,Cx="ca-studio-skin",Fp="ca-studio-gallery-tab",wx="ca-studio-engine-dimension",Rx="ca-studio-icg-dimension",y2="windows-95",Hy=[{id:"retro-crt",label:"Retro CRT"},{id:"clean-lab",label:"Clean Lab"},{id:"blueprint",label:"Blueprint"},{id:"paper",label:"Paper Archive"},{id:"noir",label:"Noir Terminal"},{id:"windows-95",label:"Windows 95"}],S2=["decks","cas","engines","icgs"],nr=1,ar=10,fm=5,b2=12,M2=64;function cr(){return Array.from({length:ha},()=>Array.from({length:ha},()=>!1))}function E2(){const a=cr(),e=10,n=10,s=[[1,0],[2,1],[0,2],[1,2],[2,2]];for(const[l,c]of s)a[n+c][e+l]=!0;return a}function lo(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"untitled"}async function ht(a,e={}){const n=await fetch(a,{...e,headers:{"content-type":"application/json",...e.headers??{}}});if(!n.ok){const s=await n.text();throw new Error(T2(n,s))}return n.json()}function T2(a,e){const n=e.trim();if(!n)return`Request failed: ${a.status}`;const l=(/<pre>(.*?)<\/pre>/is.exec(n)?.[1]??n).replace(/<[^>]*>/g," ").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/\s+/g," ").trim();return l.startsWith("Cannot GET /api/ca/initial-condition-generators")?"Initial condition generator API is not available on this server. Restart the backend with the latest code.":l||`Request failed: ${a.status}`}function mo(a){const e=a?.params?.studio;return!e||typeof e!="object"||Array.isArray(e)?{}:e}function A2(a,e){const n={...mo(a)};for(const[s,l]of Object.entries(e))l===void 0?delete n[s]:n[s]=l;return{...a.params,studio:n}}function hm(a){const e=[];for(let n=0;n<a.length;n+=1)for(let s=0;s<(a[n]?.length??0);s+=1)a[n][s]&&e.push([s,n,0]);return e}function Ol(a){const e=cr();for(const n of a??[]){const[s,l]=n;Number.isInteger(s)&&Number.isInteger(l)&&s>=0&&l>=0&&s<ha&&l<ha&&(e[l][s]=!0)}return e}function Gy(a){return a.reduce((e,n)=>e+n.reduce((s,l)=>s+(l?1:0),0),0)}function zp(a){return a?.dimensions===3}function Fu(a){return!zp(a)}function C2(a){return[ha,a>=2?ha:1,a>=3?ha:1]}function w2(a){return a.dimensions===1?"elementary-1d":a.dimensions===3?"voxel-3d":"2d-canvas"}function R2(a){return a>=3?"3d":"2d"}function Dx(a,e,n){const s=In(a,{caClass:e,simulation:{neighborhoodId:e.neighborhoodId,grid:{size:C2(e.dimensions),boundary:"wrap",wrap:!0}},renderer:{id:n||w2(e)},camera:{mode:R2(e.dimensions)}});return e.dimensions===3&&s.simulation?.initialCondition?.cells?.length===0&&(s.simulation.initialCondition={type:"cells",cells:[]}),s}function Vy(a){if(!(a instanceof HTMLElement))return!1;const e=a.tagName.toLowerCase();return a.isContentEditable||e==="input"||e==="select"||e==="textarea"}function ky(a){return S2.includes(a)}function D2(){const a=window.sessionStorage.getItem(Fp);return ky(a)?a:"decks"}function So(a){return`/admin?tab=${a}`}function N2(a){return a?.startsWith("/admin/edit/")||a===So("engines")?a:void 0}function Nx(){const a=/^\/view\/decks\/([^/]+)/.exec(window.location.pathname);if(a)return{view:"viewer",deckId:a[1]};const e=/^\/admin\/edit\/([^/]+)/.exec(window.location.pathname);if(e){const d=new URLSearchParams(window.location.search);return{view:"edit",deckId:e[1],sceneId:d.get("scene")??void 0}}const n=/^\/admin\/libraries\/([^/]+)/.exec(window.location.pathname);if(n){const d=new URLSearchParams(window.location.search);return{view:"library",treeId:n[1],nodeId:d.get("node")??void 0,returnTo:N2(d.get("return"))}}if(/^\/admin\/icgs\/([^/]+)/.exec(window.location.pathname))return{view:"gallery",tab:"icgs"};const l=/^\/admin\/engines\/([^/]+)/.exec(window.location.pathname);if(l)return{view:"engine",engineId:l[1]};const c=new URLSearchParams(window.location.search).get("tab");return{view:"gallery",tab:ky(c)?c:D2()}}function Di(a){window.history.pushState({},"",a),window.dispatchEvent(new PopStateEvent("popstate"))}function U2(){return{name:"Random soup",description:"Seed live cells randomly across the current voxel grid.",generatorKind:"random-soup",dimensions:2,states:2,density:.28,icSeed:"studio-seed"}}function jy(){return{name:"Conway Life",description:"Classic binary cellular automaton evolution rule.",engineKind:"game-of-life-2d",dimensions:2,states:2,ruleId:"B3/S23",rendererId:"2d-canvas",license:"internal",owner:"Glitch University",ipNotice:"Internal CA engine registry entry."}}function Xy(a){return{density:{type:"range",label:"Density",default:a.density,min:0,max:1,step:.01},ic_seed:{type:"string",label:"IC seed",default:a.icSeed}}}function Wy(a){return{density:a.density,ic_seed:a.icSeed}}function qy(a){return/^B[0-8]*\/S[0-8]*$/i.test(a)?a.toUpperCase():/^rule[-_\s]*\d{1,3}$/i.test(a)?a.replace(/^rule[-_\s]*/i,"Rule "):a==="wildfire-binary"?"Binary wildfire":a==="life-3d"?"3D Life":a==="generations-3d"?"3D Generations":a==="lattice-gas-3d"?"3D Lattice gas":a==="snake-3d"?"3D Snake":a==="naga-3d"?"3D Naga":a}function L2(a){return a===1?[{value:"elementary-1d",label:"Elementary 1D"}]:a===3?[{value:"voxel-3d",label:"Voxel 3D"}]:[{value:"2d-canvas",label:"2D Canvas"},{value:"wildfire-2d",label:"Wildfire 2D"}]}function pm(a){const e=L2(a.dimensions);return{ruleId:{type:"select",label:"Rule",default:a.ruleId,options:[{value:a.ruleId,label:qy(a.ruleId)}]},rendererId:{type:"select",label:"Renderer",default:a.rendererId,options:e}}}function mm(a){return{ruleId:a.ruleId,rendererId:a.rendererId}}function O2(a){const e=a.dimensions>=3?ha:1;return{caClass:{neighborhoodId:a.neighborhoodId,dimensions:a.dimensions,states:a.states},simulation:{engineId:a.dimensions===2&&a.states===2?"game-of-life-2d":"generic-voxel-ca",ruleId:a.ruleId,neighborhoodId:a.neighborhoodId,grid:{size:[ha,ha,e],boundary:"wrap",wrap:!0}},renderer:{id:a.rendererId},camera:{mode:a.dimensions===2?"2d":"3d"}}}function go(a,e,n,s,l,c="wrap",d=!0){return{simulation:{...l?{engineId:l}:{},ruleId:a,neighborhoodId:e,grid:{boundary:c,wrap:c==="wrap"},...d?{initialCondition:{type:"cells",cells:hm(s)}}:{}},renderer:{id:n}}}function ws(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function P2(a,e){return JSON.stringify(a)===JSON.stringify(e)}function Yy(a,e){let n=a;for(const s of e){if(!ws(n)||!(s in n))return;n=n[s]}return n}function gm(a){return a==="rendererId"?["renderer","id"]:a==="ruleId"?["simulation","ruleId"]:a==="edgeWrap"?["simulation","grid","wrap"]:a.startsWith("grid.")?["simulation",...a.split(".")]:a.includes(".")?a.split("."):["simulation",a]}function I2(a,e,n,s){if(n==="edgeWrap")return Xp(a)==="wrap";const l=gm(n);return Yy(a,l)??Hp(n,s,e)}function Ux(a,e){return typeof a=="number"&&Number.isFinite(a)?a:e}function Lx(a){return typeof a=="number"&&Number.isFinite(a)?a:void 0}function B2(a,e){return typeof e.label=="string"?e.label:a}function Hp(a,e,n){const s=n.default_params[a];return s!==void 0?s:e.default}function In(a,e){const n={...a};for(const[s,l]of Object.entries(e)){const c=n[s];n[s]=ws(c)&&ws(l)?In(c,l):l}return n}function F2(a){return typeof a?.scene.params.caption=="string"?a.scene.params.caption:""}function z2(a){return a?.scene.params.autoplayOnSlideChange===!0}function Ox(a,e){return Fu(ir(a))?In(a,{simulation:{initialCondition:{type:"cells",cells:hm(e)}}}):a}function Gp(a,e,n=[]){const s={};for(const[l,c]of Object.entries(a)){const d=[...n,l];if(ws(c)&&d.join(".")!=="simulation.initialCondition"){const p=Gp(c,e,d);Object.keys(p).length>0&&(s[l]=p);continue}P2(c,Yy(e,d))||(s[l]=c)}return s}function Al(a,e){if(!e.parent_id)return{};const n=new Map(a.map(c=>[c.id,c])),s=[];let l=n.get(e.parent_id);for(;l;)s.unshift(l),l=l.parent_id?n.get(l.parent_id):void 0;return s.reduce((c,d)=>In(c,d.params),{})}function H2(a,e){return a.sort_order-e.sort_order||a.name.localeCompare(e.name)||a.slug.localeCompare(e.slug)}function Vp(a,e){return a.filter(n=>n.parent_id===e).sort(H2)}function Px(a,e){const n=Vp(a,e);return n.length===0?0:Math.max(...n.map(s=>s.sort_order))+1}function Zy(a,e){if(e.length===0)return a;const[n,...s]=e,l={...a};if(s.length===0)return delete l[n],l;const c=l[n];if(!ws(c))return l;const d=Zy(c,s);return Object.keys(d).length===0?delete l[n]:l[n]=d,l}function Ri(a,e,n){if(e.length===0)return a;const[s,...l]=e,c={...a};if(l.length===0)return c[s]=n,c;const d=c[s];return c[s]=Ri(ws(d)?d:{},l,n),c}function G2(){const[a,e]=ee.useState(Nx),[n,s]=ee.useState(()=>{const c=window.localStorage.getItem(Cx);return Hy.some(d=>d.id===c)?c:y2});ee.useEffect(()=>{const c=()=>e(Nx());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]),ee.useEffect(()=>{document.documentElement.dataset.skin=n,window.localStorage.setItem(Cx,n)},[n]);const l=a.view==="viewer"?g.jsx(e3,{deckId:a.deckId}):a.view==="edit"?g.jsx(t3,{deckId:a.deckId,initialSceneId:a.sceneId}):a.view==="library"?g.jsx($2,{initialNodeId:a.nodeId,returnTo:a.returnTo,treeId:a.treeId}):a.view==="engine"?g.jsx(K2,{engineId:a.engineId}):g.jsx(j2,{initialTab:a.tab});return a.view==="viewer"?l:g.jsxs("div",{className:"admin-app",children:[g.jsx("div",{className:"admin-app-content",children:l}),g.jsx(V2,{skin:n,onSkinChange:s})]})}function V2({skin:a,onSkinChange:e}){const[n,s]=ee.useState(()=>Ix(new Date));return ee.useEffect(()=>{const l=window.setInterval(()=>s(Ix(new Date)),3e4);return()=>window.clearInterval(l)},[]),g.jsxs("footer",{className:"app-footer",children:[g.jsx("div",{className:"footer-start","aria-hidden":"true",children:"Start"}),g.jsx("p",{children:"CA Lab is developed by Glitch University."}),g.jsxs("label",{className:"skin-picker",children:[g.jsx("span",{children:"Skin"}),g.jsx("select",{value:a,onChange:l=>e(l.target.value),children:Hy.map(l=>g.jsx("option",{value:l.id,children:l.label},l.id))})]}),g.jsx("div",{className:"footer-clock","aria-label":`Current time ${n}`,children:n})]})}function Ix(a){return a.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function Zi({closeLabel:a="Close",disabled:e=!1,onClose:n}){return g.jsxs("span",{className:`win95-window-controls${n?" has-close":""}`,"aria-hidden":n?void 0:"true",children:[g.jsx("span",{className:"window-control-decor",children:"_"}),g.jsx("span",{className:"window-control-decor",children:"□"}),n?g.jsx("button",{"aria-label":a,className:"window-control-button window-close-button",disabled:e,title:a,type:"button",onClick:n,children:"×"}):g.jsx("span",{className:"window-control-decor window-close-button",children:"×"})]})}function Ky(a){const e=Math.max(nr,Math.min(ar,a));if(e>=ar)return 0;const n=720,s=60,l=(e-nr)/(ar-nr-1);return Math.round(n-(n-s)*l)}function $y(a){return a>=ar}function k2(a){return $y(a)?"MAX":Math.round(1e3/Ky(a)*10)/10}function _m(a,e){if(!$y(a)){const c=window.setInterval(e,Ky(a));return()=>window.clearInterval(c)}let n=!1,s=0;function l(){const c=performance.now();let d=0;for(;!n&&d<M2&&performance.now()-c<b2;)e(),d+=1;n||(s=window.requestAnimationFrame(l))}return s=window.requestAnimationFrame(l),()=>{n=!0,window.cancelAnimationFrame(s)}}function Qy({className:a="",speedLevel:e,onChange:n}){const s=Math.max(nr,Math.min(ar,e)),c=-132+(s-nr)/(ar-nr)*264,d=k2(s);return g.jsxs("label",{className:`studio-speed-knob ${a}`,style:{"--speed-knob-angle":`${c}deg`},title:d==="MAX"?"Simulation speed: maximum":`Simulation speed: ${d} steps/s`,children:[g.jsx("span",{className:"speed-knob-label",children:"Speed"}),g.jsx("span",{className:"speed-knob-face","aria-hidden":"true",children:g.jsx("span",{className:"speed-knob-marker"})}),g.jsx("input",{"aria-label":"Simulation speed",max:ar,min:nr,step:1,type:"range",value:s,onChange:p=>n(Number(p.target.value))}),g.jsx("span",{className:"speed-knob-readout",children:d==="MAX"?d:`${d}x`})]})}function j2({initialTab:a}){const[e,n]=ee.useState(a),[s,l]=ee.useState(()=>{const J=Number(window.sessionStorage.getItem(wx));return J===1||J===2||J===3?J:2}),[c,d]=ee.useState(()=>{const J=Number(window.sessionStorage.getItem(Rx));return J===1||J===2||J===3?J:2}),[p,m]=ee.useState(!1),[h,v]=ee.useState([]),[S,_]=ee.useState([]),[M,E]=ee.useState([]),[C,y]=ee.useState(null),[x,P]=ee.useState(null),[O,R]=ee.useState(()=>new Set),[I,B]=ee.useState({}),[L,T]=ee.useState(()=>new Set),[U,X]=ee.useState([]),[G,K]=ee.useState("Game of Life: Glider Deck"),[ue,pe]=ee.useState("Game of Life Presets"),[Q,V]=ee.useState(()=>U2()),[j,ae]=ee.useState(()=>jy()),[_e,ve]=ee.useState("Ready"),H=ee.useMemo(()=>({1:M.filter(J=>J.supported_classes.some(z=>z.dimensions===1)),2:M.filter(J=>J.supported_classes.some(z=>z.dimensions===2)),3:M.filter(J=>J.supported_classes.some(z=>z.dimensions===3))}),[M]),te=H[s],Ee=ee.useMemo(()=>({1:S.filter(J=>J.supported_classes.some(z=>z.dimensions===1)),2:S.filter(J=>J.supported_classes.some(z=>z.dimensions===2)),3:S.filter(J=>J.supported_classes.some(z=>z.dimensions===3))}),[S]),Le=Ee[c],Fe=ee.useCallback(async()=>{v(await ht("/api/ca/decks"))},[]),oe=ee.useCallback(async()=>{_(await ht("/api/ca/initial-condition-generators"))},[]),Me=ee.useCallback(async()=>{E(await ht("/api/ca/engines"))},[]),Ae=ee.useCallback(async()=>{X(await ht("/api/ca/preset-trees"))},[]);ee.useEffect(()=>{async function J(){try{await Promise.all([Fe(),Ae(),Me()])}catch(z){ve(z instanceof Error?z.message:"Load failed");return}try{await oe()}catch(z){_([]),ve(z instanceof Error?z.message:"ICG list unavailable")}}J()},[Fe,Me,oe,Ae]),ee.useEffect(()=>{n(a),window.sessionStorage.setItem(Fp,a)},[a]);function ze(J){n(J),m(!1),window.sessionStorage.setItem(Fp,J),window.history.replaceState({},"",So(J))}function at(J){l(J),window.sessionStorage.setItem(wx,String(J))}function Je(){const J=s===1?"elementary-1d":s===3?"voxel-3d":"2d-canvas";ae(z=>({...z,dimensions:s,rendererId:J})),m(!0)}async function Gt(J){if(O.has(J.id)){R(z=>{const Ue=new Set(z);return Ue.delete(J.id),Ue});return}if(R(z=>new Set(z).add(J.id)),!I[J.id]){T(z=>new Set(z).add(J.id));try{const z=await ht(`/api/ca/engines/${J.id}/usage`);B(Ue=>({...Ue,[J.id]:z}))}catch(z){ve(z instanceof Error?z.message:"Engine usage could not be loaded"),R(Ue=>{const ft=new Set(Ue);return ft.delete(J.id),ft})}finally{T(z=>{const Ue=new Set(z);return Ue.delete(J.id),Ue})}}}function ut(J){const z=new URLSearchParams({node:J.node_id,return:So("engines")});Di(`/admin/libraries/${J.tree_id}?${z.toString()}`)}function _t(J){d(J),window.sessionStorage.setItem(Rx,String(J))}function xt(){V(J=>({...J,dimensions:c})),m(!0)}async function ot(){try{ve("Creating deck...");const J=Date.now(),z=await ht("/api/ca/decks",{method:"POST",body:JSON.stringify({slug:`${lo(G)}-${J}`,title:G.trim()||"Untitled deck",params:{studio:{}}})});m(!1),Di(`/admin/edit/${z.id}`)}catch(J){ve(J instanceof Error?J.message:"Deck create failed")}}async function Ht(){try{ve(`Creating node tree "${ue}"...`);const J=Date.now(),z=await ht("/api/ca/preset-trees",{method:"POST",body:JSON.stringify({slug:`${lo(ue)}-${J}`,name:ue.trim()||"Untitled node tree",description:"Admin-authored CA preset tree"})});X(Ue=>[z,...Ue]),m(!1),ve(`Created node tree "${z.name}"`)}catch(J){ve(J instanceof Error?J.message:"Node tree create failed")}}async function Bt(J){const z=`${J.node_count} ${J.node_count===1?"node":"nodes"}`;if(window.confirm(`Delete "${J.name}" and its ${z}? This cannot be undone.`))try{ve(`Deleting CA library "${J.name}"...`);const Ue=await fetch(`/api/ca/preset-trees/${J.id}`,{method:"DELETE"});if(!Ue.ok){const ft=await Ue.json().catch(()=>null);throw new Error(ft?.error?`Could not delete "${J.name}": ${ft.error}`:`Could not delete "${J.name}". It may still be referenced by a slide.`)}X(ft=>ft.filter(F=>F.id!==J.id)),ve(`Deleted CA library "${J.name}"`)}catch(Ue){ve(Ue instanceof Error?Ue.message:"CA library delete failed")}}async function Zt(J){try{const Ue=mo(J).presetTreeId,ft=Ue?h.filter(fe=>fe.id!==J.id&&mo(fe).presetTreeId===Ue):[],F=!!(Ue&&ft.length===0),A=F?`Delete "${J.title}"? It is the only deck using its preset tree, so the tree can be removed as well.`:`Delete "${J.title}"?`;if(!window.confirm(A))return;if(ve(`Deleting "${J.title}"...`),!(await fetch(`/api/ca/decks/${J.id}`,{method:"DELETE"})).ok)throw new Error("Unable to delete deck");v(fe=>fe.filter(Ne=>Ne.id!==J.id));let re="";if(F&&Ue&&window.confirm("Remove the now-unused preset tree too?"))try{(await fetch(`/api/ca/preset-trees/${Ue}`,{method:"DELETE"})).ok||(re="Deck deleted, but the preset tree could not be removed.")}catch{re="Deck deleted, but the preset tree could not be removed."}await Fe(),ve(re||`Deleted "${J.title}"`)}catch(z){ve(z instanceof Error?z.message:"Deck delete failed")}}async function Vt(){try{ve(`Creating ICG "${Q.name}"...`);const J=Date.now(),z=await ht("/api/ca/initial-condition-generators",{method:"POST",body:JSON.stringify({slug:`${lo(Q.name)}-${J}`,name:Q.name,description:Q.description.trim()||null,generatorKind:Q.generatorKind,supportedClasses:[{dimensions:Q.dimensions,states:Q.states}],paramsSchema:Xy(Q),defaultParams:Wy(Q)})});_(Ue=>[z,...Ue]),m(!1),ve(`Created ICG "${z.name}"`)}catch(J){ve(J instanceof Error?J.message:"ICG create failed")}}async function dt(){try{ve(`Creating engine "${j.name}"...`);const J=Date.now(),z=await ht("/api/ca/engines",{method:"POST",body:JSON.stringify({slug:`${lo(j.name)}-${J}`,name:j.name.trim()||"Untitled CA engine",description:j.description.trim()||null,engineKind:j.engineKind,license:j.license.trim()||null,owner:j.owner.trim()||null,ipNotice:j.ipNotice.trim()||null,supportedClasses:[{dimensions:j.dimensions,states:j.states}],paramsSchema:pm(j),defaultParams:mm(j)})});E(Ue=>[z,...Ue]),m(!1),ve(`Created engine "${z.name}"`)}catch(J){ve(J instanceof Error?J.message:"Engine create failed")}}return g.jsxs("main",{className:"shell",children:[g.jsxs("header",{className:"gallery-hero panel",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Studio Admin"}),g.jsx("h1",{children:"CA Studio"}),g.jsx("p",{children:"Explore the wonderful and strange world of cellular automata."})]}),g.jsx("div",{className:"status",children:_e}),g.jsx(Zi,{})]}),g.jsxs("nav",{"aria-label":"Gallery sections",className:"gallery-tabs",children:[g.jsx("button",{className:e==="decks"?"active":"",type:"button",onClick:()=>ze("decks"),children:"Decks"}),g.jsx("button",{className:e==="cas"?"active":"",type:"button",onClick:()=>ze("cas"),children:"CAs"}),g.jsx("button",{className:e==="engines"?"active":"",type:"button",onClick:()=>ze("engines"),children:"CA Engines"}),g.jsx("button",{className:e==="icgs"?"active":"",type:"button",onClick:()=>ze("icgs"),children:"ICGs"})]}),g.jsxs("section",{className:"panel gallery-tab-panel",children:[e==="decks"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"gallery-section-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Decks"}),g.jsx("h2",{children:"Presentations"})]}),g.jsxs("div",{className:"gallery-section-actions",children:[g.jsx("span",{children:h.length}),g.jsx("button",{className:"primary",type:"button",onClick:()=>m(!0),children:"New deck"})]})]}),g.jsx("p",{className:"gallery-tab-description",children:"A deck is a narrated sequence of slides. Slides can reference CA presets from a library, then add caption, playback, and recording context."}),g.jsxs("div",{className:"gallery-list",children:[h.map(J=>g.jsxs("article",{"aria-label":`Open ${J.title}`,className:"deck-card gallery-entity-card deck-entity-card panel",role:"link",tabIndex:0,onClick:()=>Di(`/admin/edit/${J.id}`),onKeyDown:z=>{z.target===z.currentTarget&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),Di(`/admin/edit/${J.id}`))},children:[g.jsx("span",{className:"gallery-card-icon","aria-hidden":"true"}),g.jsx("span",{children:J.slug}),g.jsx("strong",{children:J.title}),g.jsx("small",{children:mo(J).presetTreeId?"tree selected":"choose a node tree in editor"}),g.jsxs("div",{className:"gallery-card-controls",children:[g.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),Di(`/view/decks/${J.id}`)},children:"View"}),g.jsx("button",{"aria-label":`Delete ${J.title}`,className:"danger deck-trash-button",type:"button",onClick:z=>{z.stopPropagation(),Zt(J)},children:"🗑"})]})]},J.id)),h.length===0?g.jsx("p",{className:"empty",children:"No decks yet."}):null]})]}):null,e==="cas"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"gallery-section-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CAs"}),g.jsx("h2",{children:"Preset libraries"})]}),g.jsxs("div",{className:"gallery-section-actions",children:[g.jsx("span",{children:U.length}),g.jsx("button",{className:"primary",type:"button",onClick:()=>m(!0),children:"New CA"})]})]}),g.jsx("p",{className:"gallery-tab-description",children:"A CA preset library is a tree of reusable simulation states. Child presets inherit renderer, rule, neighbourhood, camera, and initial-condition settings from their parents."}),g.jsxs("div",{className:"gallery-list",children:[U.map(J=>g.jsxs("article",{"aria-label":`Open ${J.name}`,className:`deck-card gallery-entity-card library-card panel${J.node_count===0?" empty-library":""}`,role:"link",tabIndex:0,onClick:()=>Di(`/admin/libraries/${J.id}`),onKeyDown:z=>{z.target===z.currentTarget&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),Di(`/admin/libraries/${J.id}`))},children:[g.jsx("span",{className:"gallery-card-icon","aria-hidden":"true"}),g.jsx("span",{children:J.slug}),g.jsx("strong",{children:J.name}),g.jsx("small",{children:J.node_count===0?"Empty library":`${J.node_count} ${J.node_count===1?"node":"nodes"}`}),g.jsx("div",{className:"gallery-card-controls gallery-card-controls-end",children:g.jsx("button",{"aria-label":`Delete ${J.name}`,className:"danger deck-trash-button",title:`Delete ${J.name}`,type:"button",onClick:z=>{z.stopPropagation(),Bt(J)},children:"🗑"})})]},J.id)),U.length===0?g.jsx("p",{className:"empty",children:"No CA libraries yet."}):null]})]}):null,e==="engines"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"gallery-section-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Engines"}),g.jsx("h2",{children:"Evolution functions"})]}),g.jsxs("div",{className:"gallery-section-actions",children:[g.jsx("span",{children:te.length}),g.jsx("button",{className:"primary",type:"button",onClick:Je,children:"New engine"})]})]}),g.jsx("p",{className:"gallery-tab-description",children:"A CA engine is an evolution function. Presets select compatible engines by dimensions and state count; licence and ownership metadata travel with the registry entry."}),g.jsx("nav",{"aria-label":"Engine dimensions",className:"dimension-tabs",children:[1,2,3].map(J=>g.jsxs("button",{"aria-selected":s===J,className:s===J?"active":"",role:"tab",type:"button",onClick:()=>at(J),children:[J,"D",g.jsx("span",{children:H[J].length})]},J))}),g.jsxs("div",{className:"gallery-list",children:[te.map(J=>g.jsxs("article",{className:"deck-card engine-gallery-card engine-entity-card panel",children:[g.jsxs("button",{"aria-label":`Edit ${J.name}`,className:"engine-card-main",type:"button",onClick:()=>P(J),children:[g.jsx("span",{className:"gallery-card-icon","aria-hidden":"true"}),g.jsx("span",{children:J.engine_kind}),g.jsx("strong",{children:J.name}),g.jsx("small",{children:Bx(J.supported_classes)}),J.license?g.jsxs("small",{children:["License: ",J.license]}):null,J.owner?g.jsxs("small",{children:["Owner: ",J.owner]}):null]}),g.jsxs("button",{"aria-expanded":O.has(J.id),className:"engine-usage-toggle",type:"button",onClick:()=>{Gt(J)},children:[g.jsx("span",{children:O.has(J.id)?"▾":"▸"}),"Preset usage",I[J.id]?g.jsx("small",{children:I[J.id].length}):null]}),O.has(J.id)?g.jsxs("div",{className:"engine-usage-list",children:[L.has(J.id)?g.jsx("p",{className:"empty",children:"Loading presets..."}):null,!L.has(J.id)&&(I[J.id]?.length??0)===0?g.jsx("p",{className:"empty",children:"No presets currently use this engine."}):null,I[J.id]?.map(z=>g.jsxs("button",{type:"button",onClick:()=>ut(z),children:[g.jsx("span",{children:z.tree_name}),g.jsx("strong",{children:z.node_name}),g.jsx("small",{children:z.node_kind==="preset_root"?"root":z.node_kind})]},`${z.tree_id}:${z.node_id}`))]}):null]},J.id)),te.length===0?g.jsxs("p",{className:"empty",children:["No ",s,"D CA engines yet."]}):null]})]}):null,e==="icgs"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"gallery-section-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"ICGs"}),g.jsx("h2",{children:"Initial condition generators"})]}),g.jsxs("div",{className:"gallery-section-actions",children:[g.jsx("span",{children:Le.length}),g.jsx("button",{className:"primary",type:"button",onClick:xt,children:"New ICG"})]})]}),g.jsx("p",{className:"gallery-tab-description",children:"An ICG is a deterministic tool that creates initial cell states for compatible CA classes. Running one writes concrete cells into a preset."}),g.jsx("nav",{"aria-label":"ICG dimensions",className:"dimension-tabs",children:[1,2,3].map(J=>g.jsxs("button",{"aria-selected":c===J,className:c===J?"active":"",role:"tab",type:"button",onClick:()=>_t(J),children:[J,"D",g.jsx("span",{children:Ee[J].length})]},J))}),g.jsxs("div",{className:"gallery-list",children:[Le.map(J=>g.jsxs("article",{"aria-label":`Edit ${J.name}`,className:"deck-card gallery-entity-card icg-entity-card panel",role:"button",tabIndex:0,onClick:()=>y(J),onKeyDown:z=>{z.target===z.currentTarget&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),y(J))},children:[g.jsx("span",{className:"gallery-card-icon","aria-hidden":"true"}),g.jsx("span",{children:J.generator_kind}),g.jsx("strong",{children:J.name}),g.jsx("small",{children:Bx(J.supported_classes)}),J.description?g.jsx("small",{children:J.description}):null]},J.id)),Le.length===0?g.jsxs("p",{className:"empty",children:["No ",c,"D generators yet."]}):null]})]}):null]}),g.jsxs("div",{className:"win95-statusbar","aria-hidden":"true",children:[g.jsxs("span",{children:["Objects: ",e==="decks"?h.length:e==="cas"?U.length:e==="engines"?te.length:Le.length]}),g.jsxs("span",{children:["Status: ",_e]}),g.jsx("span",{children:"CA Lab Studio"})]}),p?g.jsx(X2,{activeTab:e,deckName:G,engineConfig:j,icgConfig:Q,treeName:ue,onClose:()=>m(!1),onCreateDeck:()=>{ot()},onCreateEngine:()=>{dt()},onCreateIcg:()=>{Vt()},onCreateTree:()=>{Ht()},onDeckNameChange:K,onEngineConfigChange:ae,onIcgConfigChange:V,onTreeNameChange:pe}):null,x?g.jsx(W2,{engine:x,onClose:()=>P(null),onSaved:J=>{E(z=>z.map(Ue=>Ue.id===J.id?J:Ue)),P(null),ve(`Saved engine "${J.name}"`)}}):null,C?g.jsx(Z2,{generator:C,onClose:()=>y(null),onSaved:J=>{_(z=>z.map(Ue=>Ue.id===J.id?J:Ue)),y(null),ve(`Saved ICG "${J.name}"`)}}):null]})}function X2({activeTab:a,deckName:e,engineConfig:n,icgConfig:s,treeName:l,onClose:c,onCreateDeck:d,onCreateEngine:p,onCreateIcg:m,onCreateTree:h,onDeckNameChange:v,onEngineConfigChange:S,onIcgConfigChange:_,onTreeNameChange:M}){const E={decks:"deck",cas:"CA library",engines:"CA engine",icgs:"initial condition generator"},C={decks:d,cas:h,engines:p,icgs:m}[a];return ee.useEffect(()=>{function y(x){x.key==="Escape"&&c()}return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c]),g.jsx("div",{className:"modal-backdrop",role:"presentation",onMouseDown:c,children:g.jsxs("section",{"aria-modal":"true",className:"property-modal gallery-create-modal",role:"dialog",onMouseDown:y=>y.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Create"}),g.jsxs("h2",{children:["New ",E[a]]})]}),g.jsx("div",{className:"window-action-cluster",children:g.jsx(Zi,{onClose:c})})]}),g.jsxs("div",{className:"gallery-create-body",children:[a==="decks"?g.jsxs("label",{children:["Deck name",g.jsx("input",{autoFocus:!0,value:e,onChange:y=>v(y.target.value)})]}):null,a==="cas"?g.jsxs("label",{children:["Library name",g.jsx("input",{autoFocus:!0,value:l,onChange:y=>M(y.target.value)})]}):null,a==="engines"?g.jsx(vm,{config:n,onChange:S}):null,a==="icgs"?g.jsx(Jy,{config:s,onChange:_}):null,g.jsxs("div",{className:"gallery-create-actions",children:[g.jsx("button",{type:"button",onClick:c,children:"Cancel"}),g.jsxs("button",{className:"primary",type:"button",onClick:C,children:["Create ",E[a]]})]})]})]})})}function Bx(a){return a.map(e=>`${e.dimensions}D · ${e.states} states`).join(", ")}function Jy({config:a,onChange:e}){return g.jsxs("div",{className:"root-config-fields",children:[g.jsx("p",{className:"eyebrow",children:"Initial Condition Generator"}),g.jsxs("label",{children:["Generator name",g.jsx("input",{value:a.name,onChange:n=>e(s=>({...s,name:n.target.value}))})]}),g.jsxs("label",{children:["Description",g.jsx("textarea",{value:a.description,onChange:n=>e(s=>({...s,description:n.target.value}))})]}),g.jsxs("div",{className:"root-config-grid",children:[g.jsxs("label",{children:["Dimensions",g.jsxs("select",{value:a.dimensions,onChange:n=>e(s=>({...s,dimensions:Number(n.target.value)})),children:[g.jsx("option",{value:1,children:"1D"}),g.jsx("option",{value:2,children:"2D"}),g.jsx("option",{value:3,children:"3D"})]})]}),g.jsxs("label",{children:["States",g.jsx("input",{min:2,step:1,type:"number",value:a.states,onChange:n=>e(s=>({...s,states:Math.max(2,Number(n.target.value)||2)}))})]}),g.jsxs("label",{children:["Density",g.jsx("input",{max:1,min:0,step:.01,type:"number",value:a.density,onChange:n=>e(s=>({...s,density:Math.max(0,Math.min(1,Number(n.target.value)||0))}))})]})]}),g.jsxs("label",{children:["IC seed",g.jsx("input",{value:a.icSeed,onChange:n=>e(s=>({...s,icSeed:n.target.value}))})]})]})}function vm({config:a,onChange:e}){return g.jsxs("div",{className:"root-config-fields",children:[g.jsx("p",{className:"eyebrow",children:"CA Engine"}),g.jsxs("label",{children:["Engine name",g.jsx("input",{value:a.name,onChange:n=>e(s=>({...s,name:n.target.value}))})]}),g.jsxs("label",{children:["Description",g.jsx("textarea",{value:a.description,onChange:n=>e(s=>({...s,description:n.target.value}))})]}),g.jsxs("div",{className:"root-config-grid",children:[g.jsxs("label",{children:["Engine kind",g.jsx("input",{value:a.engineKind,onChange:n=>e(s=>({...s,engineKind:n.target.value}))})]}),g.jsxs("label",{children:["Rule id",g.jsx("input",{value:a.ruleId,onChange:n=>e(s=>({...s,ruleId:n.target.value}))})]}),g.jsxs("label",{children:["Renderer",g.jsxs("select",{value:a.rendererId,onChange:n=>e(s=>({...s,rendererId:n.target.value})),children:[g.jsx("option",{value:"2d-canvas",children:"2D Canvas"}),g.jsx("option",{value:"elementary-1d",children:"Elementary 1D"}),g.jsx("option",{value:"wildfire-2d",children:"Wildfire 2D"}),g.jsx("option",{value:"voxel-3d",children:"Voxel 3D"})]})]}),g.jsxs("label",{children:["Dimensions",g.jsxs("select",{value:a.dimensions,onChange:n=>e(s=>({...s,dimensions:Number(n.target.value)})),children:[g.jsx("option",{value:1,children:"1D"}),g.jsx("option",{value:2,children:"2D"}),g.jsx("option",{value:3,children:"3D"})]})]}),g.jsxs("label",{children:["States",g.jsx("input",{min:2,step:1,type:"number",value:a.states,onChange:n=>e(s=>({...s,states:Math.max(2,Number(n.target.value)||2)}))})]}),g.jsxs("label",{children:["License",g.jsx("input",{value:a.license,onChange:n=>e(s=>({...s,license:n.target.value}))})]}),g.jsxs("label",{children:["Owner",g.jsx("input",{value:a.owner,onChange:n=>e(s=>({...s,owner:n.target.value}))})]})]}),g.jsxs("label",{children:["IP notice",g.jsx("textarea",{value:a.ipNotice,onChange:n=>e(s=>({...s,ipNotice:n.target.value}))})]})]})}function W2({engine:a,onClose:e,onSaved:n}){const[s,l]=ee.useState(()=>kp(a)),[c,d]=ee.useState(!1),[p,m]=ee.useState("");ee.useEffect(()=>{function v(S){S.key==="Escape"&&!c&&e()}return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[e,c]);async function h(){try{d(!0),m("");const v=await ht(`/api/ca/engines/${a.id}`,{method:"PATCH",body:JSON.stringify({name:s.name.trim()||"Untitled CA engine",description:s.description.trim()||null,engineKind:s.engineKind,license:s.license.trim()||null,owner:s.owner.trim()||null,ipNotice:s.ipNotice.trim()||null,supportedClasses:[{dimensions:s.dimensions,states:s.states}],paramsSchema:pm(s),defaultParams:mm(s)})});n(v)}catch(v){m(v instanceof Error?v.message:"Engine save failed")}finally{d(!1)}}return g.jsx("div",{className:"modal-backdrop",role:"presentation",onMouseDown:()=>{c||e()},children:g.jsxs("section",{"aria-modal":"true",className:"property-modal gallery-create-modal",role:"dialog",onMouseDown:v=>v.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Engine"}),g.jsxs("h2",{children:["Edit ",a.name]})]}),g.jsx("div",{className:"window-action-cluster",children:g.jsx(Zi,{disabled:c,onClose:e})})]}),g.jsxs("div",{className:"gallery-create-body",children:[g.jsx(vm,{config:s,onChange:l}),p?g.jsx("p",{className:"compatibility-warning",role:"alert",children:p}):null,g.jsxs("div",{className:"gallery-create-actions",children:[g.jsx("button",{disabled:c,type:"button",onClick:e,children:"Cancel"}),g.jsx("button",{className:"primary",disabled:c,type:"button",onClick:()=>{h()},children:c?"Saving...":"Save engine"})]})]})]})})}function Fx(a){const e=a.supported_classes[0];return{name:a.name,description:a.description??"",generatorKind:a.generator_kind,dimensions:e?.dimensions??2,states:typeof e?.states=="number"?e.states:2,density:typeof a.default_params.density=="number"?a.default_params.density:.28,icSeed:typeof a.default_params.ic_seed=="string"?a.default_params.ic_seed:typeof a.default_params.seed=="string"?a.default_params.seed:"studio-seed"}}function kp(a){const e=a.supported_classes[0];return{name:a.name,description:a.description??"",engineKind:a.engine_kind,dimensions:e?.dimensions??2,states:typeof e?.states=="number"?e.states:2,ruleId:typeof a.default_params.ruleId=="string"?a.default_params.ruleId:"B3/S23",rendererId:typeof a.default_params.rendererId=="string"?a.default_params.rendererId:"2d-canvas",license:a.license??"",owner:a.owner??"",ipNotice:a.ip_notice??""}}function q2({disabled:a,engine:e,settings:n,onSet:s}){const l=e?Object.entries(e.params_schema).filter(d=>ws(d[1])):[];if(!e)return g.jsx("p",{className:"param-empty",children:"Select a compatible engine to edit engine settings."});if(l.length===0)return g.jsx("p",{className:"param-empty",children:"This engine does not expose editable settings."});const c=l.reduce((d,p)=>{const m=typeof p[1].group=="string"?p[1].group:"Engine settings",h=d.find(v=>v.name===m);return h?h.entries.push(p):d.push({name:m,entries:[p]}),d},[]);return g.jsx("div",{className:"inspector-engine-settings",children:c.map(d=>g.jsxs("fieldset",{className:"engine-setting-group",children:[g.jsx("legend",{children:d.name}),g.jsx("div",{className:"engine-settings-grid",children:d.entries.map(([p,m])=>{const h=gm(p),v=I2(n,e,p,m);return g.jsx(Y2,{disabled:a,engine:e,paramKey:p,path:h,schema:m,value:v,onSet:s},p)})})]},d.name))})}function Y2({disabled:a,engine:e,paramKey:n,path:s,schema:l,value:c,onSet:d}){const p=typeof l.type=="string"?l.type:"string",m=B2(n,l);if(p==="boolean")return g.jsxs("label",{className:"engine-setting-toggle",children:[g.jsx("input",{checked:c===!0,disabled:a,type:"checkbox",onChange:h=>d(s,h.target.checked)}),g.jsx("span",{children:m})]});if(p==="select"&&Array.isArray(l.options)){const h=l.options.filter(ws),v=new Set(h.map(E=>String(E.value))),S=String(c??""),_=String(Hp(n,l,e)??""),M=S&&!v.has(S)?S:"";return g.jsxs("label",{children:[m,g.jsxs("select",{disabled:a,value:M||S,onChange:E=>d(s,E.target.value),children:[M?g.jsxs("option",{disabled:!0,value:M,children:["Unsupported: ",M]}):null,h.map(E=>{const C=E.value;return g.jsx("option",{value:String(C),children:typeof E.label=="string"?E.label:String(C)},String(C))})]}),M?g.jsxs("small",{className:"engine-setting-warning",children:["Not supported by this engine.",g.jsxs("button",{disabled:a||!_,type:"button",onClick:()=>d(s,_),children:["Use ",qy(_)]})]}):null]})}return p==="number"||p==="range"?g.jsxs("label",{children:[m,g.jsx("input",{disabled:a,max:Lx(l.max),min:Lx(l.min),step:Ux(l.step,p==="range"?.01:1),type:p==="range"?"range":"number",value:typeof c=="number"?c:Ux(Hp(n,l,e),0),onChange:h=>d(s,Number(h.target.value))})]}):g.jsxs("label",{children:[m,g.jsx("input",{disabled:a,type:p==="color"?"color":"text",value:typeof c=="string"||typeof c=="number"?String(c):"",onChange:h=>d(s,h.target.value)})]})}function Z2({generator:a,onClose:e,onSaved:n}){const[s,l]=ee.useState(()=>Fx(a)),[c,d]=ee.useState(!1),[p,m]=ee.useState("");ee.useEffect(()=>{l(Fx(a)),m("")},[a]);async function h(){d(!0),m("");try{const v=await ht(`/api/ca/initial-condition-generators/${a.id}`,{method:"PATCH",body:JSON.stringify({name:s.name.trim()||"Untitled ICG",description:s.description.trim()||null,generatorKind:s.generatorKind,supportedClasses:[{dimensions:s.dimensions,states:s.states}],paramsSchema:Xy(s),defaultParams:Wy(s)})});n(v)}catch(v){m(v instanceof Error?v.message:"ICG save failed")}finally{d(!1)}}return g.jsx("div",{className:"modal-backdrop",role:"presentation",onMouseDown:()=>{c||e()},children:g.jsxs("section",{"aria-modal":"true",className:"property-modal gallery-create-modal",role:"dialog",onMouseDown:v=>v.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Initial Condition Generator"}),g.jsxs("h2",{children:["Edit ",a.name]})]}),g.jsx("div",{className:"window-action-cluster",children:g.jsx(Zi,{disabled:c,onClose:e})})]}),g.jsxs("div",{className:"gallery-create-body",children:[g.jsx(Jy,{config:s,onChange:l}),p?g.jsx("p",{className:"compatibility-warning",role:"alert",children:p}):null,g.jsxs("div",{className:"gallery-create-actions",children:[g.jsx("button",{disabled:c,type:"button",onClick:e,children:"Cancel"}),g.jsx("button",{className:"primary",disabled:c,type:"button",onClick:()=>{h()},children:c?"Saving...":"Save ICG"})]})]})]})})}function K2({engineId:a}){const[e,n]=ee.useState(null),[s,l]=ee.useState(()=>jy()),[c,d]=ee.useState("Loading engine...");ee.useEffect(()=>{async function m(){try{const h=await ht(`/api/ca/engines/${a}`);n(h),l(kp(h)),d("Engine ready")}catch(h){d(h instanceof Error?h.message:"Engine load failed")}}m()},[a]);async function p(){if(e)try{d(`Saving "${s.name}"...`);const m=await ht(`/api/ca/engines/${e.id}`,{method:"PATCH",body:JSON.stringify({name:s.name.trim()||"Untitled CA engine",description:s.description.trim()||null,engineKind:s.engineKind,license:s.license.trim()||null,owner:s.owner.trim()||null,ipNotice:s.ipNotice.trim()||null,supportedClasses:[{dimensions:s.dimensions,states:s.states}],paramsSchema:pm(s),defaultParams:mm(s)})});n(m),l(kp(m)),d(`Saved "${m.name}"`)}catch(m){d(m instanceof Error?m.message:"Engine save failed")}}return g.jsxs("main",{className:"shell",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Engine Editor"}),g.jsx("h1",{children:e?.name??"Evolution function"})]}),g.jsxs("div",{className:"topbar-actions",children:[g.jsx("button",{type:"button",onClick:()=>Di(So("engines")),children:"Gallery"}),g.jsx("div",{className:"status",children:c})]})]}),g.jsxs("section",{className:"panel icg-editor-panel",children:[g.jsx(vm,{config:s,onChange:l}),g.jsx("button",{className:"primary",disabled:!e,type:"button",onClick:()=>{p()},children:"Save engine"})]})]})}function $2({initialNodeId:a,returnTo:e,treeId:n}){const[s,l]=ee.useState(null),[c,d]=ee.useState([]),[p,m]=ee.useState([]),[h,v]=ee.useState([]),[S,_]=ee.useState([]),[M,E]=ee.useState(""),[C,y]=ee.useState(""),[x,P]=ee.useState(""),[O,R]=ee.useState(.28),[I,B]=ee.useState(3),[L,T]=ee.useState(5),[U,X]=ee.useState(0),[G,K]=ee.useState(.8),[ue,pe]=ee.useState("studio-seed"),[Q,V]=ee.useState("Untitled preset"),[j,ae]=ee.useState(""),[_e,ve]=ee.useState(2),[H,te]=ee.useState(2),[Ee,Le]=ee.useState("2d-canvas"),[Fe,oe]=ee.useState("moore"),[Me,Ae]=ee.useState("B3/S23"),[ze,at]=ee.useState(""),[Je,Gt]=ee.useState("wrap"),[ut,_t]=ee.useState(()=>cr()),[xt,ot]=ee.useState(null),[Ht,Bt]=ee.useState(0),[Zt,Vt]=ee.useState(!1),[dt,J]=ee.useState(fm),[z,Ue]=ee.useState(!1),[ft,F]=ee.useState(!1),[A,ne]=ee.useState(()=>!window.matchMedia("(max-width: 820px)").matches),[re,fe]=ee.useState(()=>!window.matchMedia("(max-width: 820px)").matches),[Ne,He]=ee.useState("ca"),[ge,le]=ee.useState("Loading library..."),[Ie,We]=ee.useState(""),[Xe,ke]=ee.useState(0),nt=ee.useRef(!1),Ce=c.find(w=>w.id===M)??null,rt=ee.useMemo(()=>new Set(p.map(w=>w.node_id)),[p]),Z=ee.useMemo(()=>({dimensions:_e,states:H,neighborhoodId:Fe}),[_e,Fe,H]),Oe=Ce?In(In(Al(c,Ce),Ce.params),In(go(Me,Fe,Ee,ut,ze,Je,Fu(Z)),{caClass:Z})):In(go(Me,Fe,Ee,ut,ze,Je,Fu(Z)),{caClass:Z}),ye=xt??Oe,Pe=ir(Oe),Ge=ee.useMemo(()=>h.filter(w=>Fa(w,Pe)),[h,Pe]),De=ee.useMemo(()=>Ge.find(w=>w.id===C)??null,[Ge,C]),Ze=ee.useMemo(()=>S.filter(w=>Fa(w,Pe)),[S,Pe]),qe=ee.useMemo(()=>Ze.find(w=>w.id===x)??Ze.find(w=>w.engine_kind===ze),[Ze,ze,x]),qt=ee.useMemo(()=>Vh(Pe),[Pe]),wt=ee.useCallback(async()=>{const[w,k]=await Promise.all([ht(`/api/ca/preset-trees/${n}/nodes`),ht(`/api/ca/preset-trees/${n}/node-usage`)]);return d(w),m(k),w},[n]),Ln=ee.useCallback(async()=>{const[w,k,W,Y]=await Promise.all([ht("/api/ca/preset-trees"),ht(`/api/ca/preset-trees/${n}/nodes`),ht(`/api/ca/preset-trees/${n}/node-usage`),ht("/api/ca/engines")]);l(w.find(be=>be.id===n)??null),d(k),m(W),_(Y);try{v(await ht("/api/ca/initial-condition-generators"))}catch{v([])}const xe=k.find(be=>be.id===a)??k[0];xe?await Re(xe.id):le("Library ready. Add the first top-level preset.")},[a,n]);ee.useEffect(()=>{Ln().catch(w=>le(w instanceof Error?w.message:"Library load failed"))},[Ln]),ee.useEffect(()=>{async function w(){try{const[k,W]=await Promise.all([ht("/api/ca/initial-condition-generators"),ht("/api/ca/engines")]);v(k),_(W)}catch{v([]),_([])}}return window.addEventListener("focus",w),()=>window.removeEventListener("focus",w)},[]),ee.useEffect(()=>{C&&!Ge.some(w=>w.id===C)&&y("")},[Ge,C]),ee.useEffect(()=>{if(x&&!Ze.some(w=>w.id===x)){P("");return}if(!x&&ze){const w=Ze.find(k=>k.engine_kind===ze);w&&P(w.id)}},[Ze,ze,x]),ee.useEffect(()=>{if(Zt)return _m(dt,()=>{_t(w=>{const k=Rl(w,ye);return ot(k.settings),k.cells}),Bt(w=>w+1)})},[ye,Zt,dt]),ee.useEffect(()=>{if(!Ce||Xe===0||nt.current)return;const w=window.setTimeout(async()=>{try{const k=Al(c,Ce),W=Gp(In(Ce.params,In(go(Me,Fe,Ee,ut,ze,Je,!1),{caClass:Z})),k);await ht(`/api/ca/preset-trees/${Ce.tree_id}/nodes/${Ce.id}`,{method:"PATCH",body:JSON.stringify({name:Q,description:j.trim()||null,params:W})}),d(Y=>Y.map(xe=>xe.id===Ce.id?{...xe,name:Q,description:j.trim()||null,params:W}:xe)),le("Preset saved")}catch(k){le(k instanceof Error?k.message:"Preset autosave failed")}},450);return()=>window.clearTimeout(w)},[Je,Z,Xe,ze,Fe,j,Q,c,Ee,Me,Ce]);function Sn(){nt.current||ke(w=>w+1)}async function Re(w){nt.current=!0,Vt(!1);const[k,W]=await Promise.all([ht(`/api/ca/preset-trees/${n}/nodes/${w}`),ht(`/api/ca/preset-trees/${n}/nodes/${w}/resolved`)]);E(k.id),ot(null),Ue(!1),V(k.name),ae(k.description??"");const Y=ir(W.params);ve(Y?.dimensions??2),te(typeof Y?.states=="number"?Y.states:Y?.states.length??2),Le(W.params.renderer?.id??"2d-canvas"),oe(W.params.simulation?.neighborhoodId??"moore"),Ae(W.params.simulation?.ruleId??"B3/S23"),Gt(Xp(W.params));const xe=W.params.simulation?.engineId??"";at(xe),P(S.find(be=>be.engine_kind===xe)?.id??""),y(""),We(""),_t(Ol(W.params.simulation?.initialCondition?.cells)),Bt(0),le(`Loaded preset "${k.name}"`),window.setTimeout(()=>{nt.current=!1,ke(0),Ue(!1)},0)}function Ke(w){Re(w.id),window.matchMedia("(max-width: 820px)").matches&&ne(!1)}function gt(){window.matchMedia("(max-width: 820px)").matches&&fe(!1),ne(!0)}function Ot(){window.matchMedia("(max-width: 820px)").matches&&ne(!1),fe(!0)}async function Tt(w="shot"){const k=Date.now(),W=Vp(c,null),Y=w==="chapter"?`Group ${W.length+1}`:`Preset ${W.length+1}`;try{const xe=await ht(`/api/ca/preset-trees/${n}/nodes`,{method:"POST",body:JSON.stringify({parentId:null,slug:`${lo(Y)}-${k}`,name:Y,kind:w,description:null,sortOrder:Px(c,null),params:O2({rootName:Y,rendererId:Ee,neighborhoodId:Fe,dimensions:2,states:2,ruleId:Me})})});await wt(),await Re(xe.id),le(`Created preset "${xe.name}"`)}catch(xe){le(xe instanceof Error?xe.message:"Preset create failed")}}async function vt(w,k="shot"){const W=Date.now(),Y=k==="chapter"?`${w.name} group`:`${w.name} variant`;try{const xe=await ht(`/api/ca/preset-trees/${n}/nodes`,{method:"POST",body:JSON.stringify({parentId:w.id,slug:`${lo(Y)}-${W}`,name:Y,kind:k,description:null,sortOrder:Px(c,w.id),params:{}})});await wt(),await Re(xe.id),le(`Created child preset "${xe.name}"`)}catch(xe){le(xe instanceof Error?xe.message:"Preset create failed")}}async function vn(w){const k=new Set([w.id]);let W=!0;for(;W;){W=!1;for(const be of c)be.parent_id&&k.has(be.parent_id)&&!k.has(be.id)&&(k.add(be.id),W=!0)}const xe=p.filter(be=>k.has(be.node_id)).reduce((be,Be)=>be+Be.scene_count,0);if(xe>0){const be=k.size>1?`This preset contains ${xe} slide reference${xe===1?"":"s"} in its subtree. Detach them before deleting it.`:`This preset is assigned to ${xe} slide${xe===1?"":"s"}. Detach it before deleting.`;return le(be),!1}try{const be=await fetch(`/api/ca/preset-trees/${w.tree_id}/nodes/${w.id}`,{method:"DELETE"});if(!be.ok){const je=await be.json().catch(()=>null);throw new Error(je?.error??"Preset could not be deleted.")}w.id===M&&(E(""),V("Untitled preset"),ae(""));const Be=await wt(),Ve=Be.find(je=>je.parent_id===w.parent_id)??Be[0];return Ve&&await Re(Ve.id),le(`Deleted preset "${w.name}"`),!0}catch(be){return le(be instanceof Error?be.message:"Preset delete failed"),!1}}async function Vn(w,k){const W=Vp(c,w.parent_id),Y=W.findIndex(Ve=>Ve.id===w.id),xe=Y+k;if(Y===-1||xe<0||xe>=W.length)return;const be=[...W],[Be]=be.splice(Y,1);be.splice(xe,0,Be);try{const Ve=await Promise.all(be.map((Qe,st)=>ht(`/api/ca/preset-trees/${Qe.tree_id}/nodes/${Qe.id}`,{method:"PATCH",body:JSON.stringify({sortOrder:st})}))),je=new Map(Ve.map(Qe=>[Qe.id,Qe]));d(Qe=>Qe.map(st=>je.get(st.id)??st)),le(`Moved "${w.name}"`)}catch(Ve){le(Ve instanceof Error?Ve.message:"Preset reorder failed")}}async function Qi(w,k,W){let Y=Ri(w.params,k,W);const xe=k.join(".")==="caClass.dimensions"||k.join(".")==="caClass.states"||k.join(".")==="caClass.neighborhoodId",be=[];if(xe){const Ve=In(Al(c,w),Y),je=ir(Ve),Qe=Ve.simulation?.engineId,st=S.find(Rt=>Rt.engine_kind===Qe),et=Ve.renderer?.id,Mt=Vh(je);if(st&&!Fa(st,je)&&(Y=Ri(Y,["simulation","engineId"],null),be.push(`Evolution function "${st.name}" was unset`)),typeof et=="string"&&!Mt.some(Rt=>Rt.id===et)){const Rt=Mt[0];Y=Ri(Y,["renderer","id"],Rt?.id??null),be.push(Rt?`Renderer changed to "${Rt.label}"`:"No renderer supports this dimensionality and state space")}const nn=h.find(Rt=>Rt.id===C);w.id===M&&nn&&!Fa(nn,je)&&(y(""),be.push(`Initial condition generator "${nn.name}" was unset`))}const Be=await ht(`/api/ca/preset-trees/${w.tree_id}/nodes/${w.id}`,{method:"PATCH",body:JSON.stringify({params:Y})});d(Ve=>Ve.map(je=>je.id===w.id?Be:je)),w.id===M&&await Re(w.id),be.length>0&&We(be.join(". ")),le(`Saved ${k.join(".")} on "${w.name}"`)}async function hr(w,k){const W=await ht(`/api/ca/preset-trees/${w.tree_id}/nodes/${w.id}`,{method:"PATCH",body:JSON.stringify({name:k})});d(Y=>Y.map(xe=>xe.id===w.id?W:xe)),w.id===M&&V(W.name),le(`Renamed preset to "${W.name}"`)}async function pr(w,k){const W=Zy(w.params,k),Y=await ht(`/api/ca/preset-trees/${w.tree_id}/nodes/${w.id}`,{method:"PATCH",body:JSON.stringify({params:W})});d(xe=>xe.map(be=>be.id===w.id?Y:be)),w.id===M&&await Re(w.id),le(`Unset ${k.join(".")} on "${w.name}"`)}function ma(w){typeof w?.default_params.density=="number"&&R(w.default_params.density),typeof w?.default_params.count=="number"&&B(w.default_params.count),typeof w?.default_params.meanLength=="number"?T(w.default_params.meanLength):typeof w?.default_params.length=="number"&&T(w.default_params.length),typeof w?.default_params.lengthStdDev=="number"&&X(w.default_params.lengthStdDev),typeof w?.default_params.sameTypeProbability=="number"&&K(w.default_params.sameTypeProbability),typeof w?.default_params.ic_seed=="string"?pe(w.default_params.ic_seed):typeof w?.default_params.seed=="string"&&pe(w.default_params.seed)}function Ji(w){return w.generator_kind==="naga-markov"?{count:I,meanLength:L,lengthStdDev:U,sameTypeProbability:G,ic_seed:ue}:{density:Math.max(0,Math.min(1,O)),ic_seed:ue}}function ea(){if(!Ce||!Pe)return;const w=Ge.find(k=>k.id===C);if(w)try{Vt(!1);const k=ZM(w.generator_kind,{settings:Oe,caClass:Pe,params:Ji(w)}),W=In(Ce.params,{simulation:{initialCondition:k}});d(Y=>Y.map(xe=>xe.id===Ce.id?{...xe,params:W}:xe)),ot(In(Oe,{simulation:{initialCondition:k}})),_t(Ol(k.cells)),Ue(!0),Bt(0),le(`Generated unsaved initial condition on "${Ce.name}"`)}catch(k){le(k instanceof Error?k.message:"ICG apply failed")}}async function Oi(w){const k=Ze.find(W=>W.id===w);if(P(w),!k){if(at(""),ot(null),Ce)try{const W=Ri(Ce.params,["simulation","engineId"],null),Y=await ht(`/api/ca/preset-trees/${Ce.tree_id}/nodes/${Ce.id}`,{method:"PATCH",body:JSON.stringify({params:W})});d(xe=>xe.map(be=>be.id===Y.id?Y:be)),le(`Unset evolution function on "${Ce.name}"`)}catch(W){le(W instanceof Error?W.message:"Engine update failed")}return}if(at(k.engine_kind),ot(null),typeof k.default_params.ruleId=="string"&&Ae(k.default_params.ruleId),typeof k.default_params.rendererId=="string"&&qt.some(W=>W.id===k.default_params.rendererId)&&Le(k.default_params.rendererId),Ce)try{let W=Ri(Ce.params,["simulation","engineId"],k.engine_kind);for(const[xe,be]of Object.entries(k.default_params))W=Ri(W,gm(xe),be);W=Dx(W,Z,k.default_params.rendererId);const Y=await ht(`/api/ca/preset-trees/${Ce.tree_id}/nodes/${Ce.id}`,{method:"PATCH",body:JSON.stringify({params:W})});d(xe=>xe.map(be=>be.id===Y.id?Y:be)),le(`Selected "${k.name}" for "${Ce.name}"`)}catch(W){le(W instanceof Error?W.message:"Engine update failed")}}async function Pi(w,k){if(!Ce)return;const W=w.join(".");if(W==="simulation.ruleId"&&typeof k=="string"&&Ae(k),W==="renderer.id"&&typeof k=="string"&&Le(k),W==="simulation.grid.boundary"&&(k==="wrap"||k==="mirror"||k==="fixed")&&Gt(k),W==="simulation.grid.wrap"&&typeof k=="boolean"){Gt(k?"wrap":"fixed"),ot(null);const Y=Ri(Ri(Ce.params,["simulation","grid","boundary"],k?"wrap":"fixed"),["simulation","grid","wrap"],k),xe=await ht(`/api/ca/preset-trees/${Ce.tree_id}/nodes/${Ce.id}`,{method:"PATCH",body:JSON.stringify({params:Y})});d(be=>be.map(Be=>Be.id===xe.id?xe:Be)),await Re(Ce.id),le(`Saved edge wrap on "${Ce.name}"`);return}ot(null),Qi(Ce,w,k)}function Ii(w,k,W=Fe){if(!Ce)return;const Y={dimensions:w,states:k,neighborhoodId:W},xe=[];let be=Ee,Be=!1;const Ve=S.find(st=>st.engine_kind===ze);Ve&&!Fa(Ve,Y)&&(Be=!0,at(""),P(""),xe.push(`Evolution function "${Ve.name}" was unset`));const je=h.find(st=>st.id===C);je&&!Fa(je,Y)&&(y(""),xe.push(`Initial condition generator "${je.name}" was unset`));const Qe=Vh(Y);Qe.some(st=>st.id===Ee)||(be=Qe[0]?.id??"",Le(be),xe.push(be?`Renderer changed to "${Qe[0].label}"`:"No renderer supports this dimensionality and state space")),ve(w),te(k),oe(W),ot(null),We(xe.join(". ")),d(st=>st.map(et=>{if(et.id!==Ce.id)return et;let Mt=Dx(et.params,Y,be);return Mt=Ri(Mt,["simulation","neighborhoodId"],W),Be&&(Mt=Ri(Mt,["simulation","engineId"],null)),Mt=Ri(Mt,["renderer","id"],be),{...et,params:Mt}})),Sn()}function ta(w){Vt(!1),Bt(0),ot(null),_t(w),Ue(!0)}function mn(){if(!Ce)return;Vt(!1),Bt(0),_t(cr());const w={type:"cells",cells:[]},k=In(Ce.params,{simulation:{initialCondition:w}});d(W=>W.map(Y=>Y.id===Ce.id?{...Y,params:k}:Y)),ot(In(Oe,{simulation:{initialCondition:w}})),zp(Z)?le(`Cleared unsaved voxel initial condition on "${Ce.name}"`):le(`Cleared unsaved initial condition on "${Ce.name}"`),Ue(!0)}async function Ds(){if(!(!Ce||ft))try{F(!0),Vt(!1);const w=Al(c,Ce),k=zp(Z)?ye.simulation?.initialCondition?.cells??Oe.simulation?.initialCondition?.cells??[]:hm(ut),W=Gp(In(Ce.params,{simulation:{initialCondition:{type:"cells",cells:k}}}),w),Y=await ht(`/api/ca/preset-trees/${Ce.tree_id}/nodes/${Ce.id}`,{method:"PATCH",body:JSON.stringify({params:W})});d(xe=>xe.map(be=>be.id===Y.id?Y:be)),ot(null),Ue(!1),Bt(0),le(`Saved initial condition on "${Ce.name}"`)}catch(w){le(w instanceof Error?w.message:"Initial condition save failed")}finally{F(!1)}}function D(){Vt(!1),_t(w=>{const k=Rl(w,ye);return ot(k.settings),k.cells}),Bt(w=>w+1)}return g.jsxs("main",{className:`studio-shell preset-studio-shell${re?" inspector-open":""}`,children:[g.jsxs("header",{className:"topbar preset-studio-topbar",children:[g.jsxs("div",{className:"preset-library-heading",children:[g.jsx("p",{className:"eyebrow",children:"Preset Library"}),g.jsx("h1",{children:s?.name??"Library"}),g.jsx("button",{className:"header-back-button",type:"button",onClick:()=>Di(e??So("cas")),children:"Back"})]}),g.jsx("div",{className:"topbar-speed-float","aria-label":"Simulation speed",children:g.jsx(Qy,{speedLevel:dt,onChange:J})}),g.jsxs("div",{className:"topbar-actions",children:[g.jsx("div",{className:"status",children:ge}),g.jsx(Zi,{})]})]}),g.jsxs("section",{className:`preset-studio-workspace${A?" tree-open":""}${re?" inspector-open":""}`,children:[g.jsx("button",{"aria-label":"Close preset drawer",className:"drawer-scrim tree-scrim",type:"button",onClick:()=>ne(!1)}),g.jsxs("aside",{className:"studio-drawer preset-tree-drawer",children:[g.jsxs("div",{className:"drawer-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Presets"}),g.jsx("h2",{children:"Library tree"})]}),g.jsx(Zi,{closeLabel:"Close preset drawer",onClose:()=>ne(!1)})]}),g.jsxs("div",{className:"drawer-scroll",children:[g.jsxs("div",{className:"root-selector",children:[g.jsx("button",{className:"primary",type:"button",onClick:()=>{Tt()},children:"New preset"}),g.jsx("button",{type:"button",onClick:()=>{Tt("chapter")},children:"New group"})]}),g.jsx("div",{className:"tree-list",children:g.jsx(d2,{engines:S,nodes:c,selectedNodeId:M,usedNodeIds:rt,onCreateChild:w=>{vt(w,"shot")},onCreateGroup:w=>{vt(w,"chapter")},onDelete:w=>vn(w),onMove:(w,k)=>{Vn(w,k)},onRename:(w,k)=>hr(w,k),onSelect:Ke,onSet:(w,k,W)=>{Qi(w,k,W)},onUnset:(w,k)=>{pr(w,k)}})})]})]}),g.jsxs("section",{className:"preset-stage",children:[g.jsxs("div",{className:"preset-stage-toolbar",children:[g.jsxs("div",{className:"preset-stage-title",children:[g.jsx("button",{type:"button",onClick:gt,children:"Presets"}),g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Preset Preview"}),g.jsx("h2",{children:Ce?Q:"Select a preset"})]})]}),g.jsxs("div",{className:"button-row",children:[g.jsx("button",{type:"button",onClick:D,children:"Step"}),g.jsx("button",{className:"primary playback-button",type:"button",onClick:()=>Vt(w=>!w),children:Zt?"⏸":"▶"}),g.jsx("button",{type:"button",onClick:Ot,children:"Inspector"})]})]}),g.jsxs("div",{className:`preset-renderer-stage${z?" ic-dirty":""}`,children:[z?g.jsxs("div",{className:"ic-dirty-banner",role:"status",children:[g.jsx("span",{children:"Unsaved initial condition"}),g.jsx("button",{className:"primary",disabled:!Ce||ft,type:"button",onClick:()=>{Ds()},children:ft?"Saving...":"Save"})]}):null,g.jsx(Wu,{caption:"",cells:ut,settings:ye,onCellsChange:ta})]}),g.jsxs("footer",{className:"metrics preset-stage-metrics",children:[g.jsxs("span",{children:["Generation ",g.jsx("strong",{children:Ht})]}),g.jsxs("span",{children:["Live cells ",g.jsx("strong",{children:Gy(ut)})]}),g.jsxs("span",{children:["Preset ",g.jsx("strong",{children:M?M.slice(0,8):"none"})]})]})]}),g.jsx("button",{"aria-label":"Close inspector",className:"drawer-scrim inspector-scrim",type:"button",onClick:()=>fe(!1)}),g.jsxs("aside",{className:"studio-drawer preset-inspector-drawer",children:[g.jsxs("div",{className:"drawer-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Inspector"}),g.jsx("h2",{children:Ce?Q:"No preset selected"})]}),g.jsx(Zi,{closeLabel:"Close inspector",onClose:()=>fe(!1)})]}),g.jsxs("div",{className:"inspector-tabs",role:"tablist","aria-label":"Preset inspector sections",children:[g.jsx("button",{className:Ne==="ca"?"active":"",role:"tab",type:"button",onClick:()=>He("ca"),children:"CA"}),g.jsx("button",{className:Ne==="initial"?"active":"",role:"tab",type:"button",onClick:()=>He("initial"),children:"Initial State"}),g.jsx("button",{className:Ne==="display"?"active":"",role:"tab",type:"button",onClick:()=>He("display"),children:"Display"})]}),g.jsxs("div",{className:"drawer-scroll inspector-body",children:[Ne==="ca"?g.jsxs("div",{className:"inspector-section",children:[Ie?g.jsx("div",{className:"compatibility-warning",role:"alert",children:Ie}):null,g.jsxs("section",{className:"preset-modal-stage inspector-ca-stage",children:[g.jsxs("div",{className:"preset-modal-stage-heading",children:[g.jsx("span",{children:"1"}),g.jsxs("div",{children:[g.jsx("h3",{children:"CA space"}),g.jsx("p",{children:"Choose dimensions, state count, and neighbourhood first."})]})]}),g.jsxs("label",{children:["Preset name",g.jsx("input",{disabled:!Ce,value:Q,onChange:w=>{V(w.target.value),Sn()}})]}),g.jsxs("label",{children:["Description",g.jsx("textarea",{disabled:!Ce,value:j,onChange:w=>{ae(w.target.value),Sn()}})]}),g.jsxs("div",{className:"preset-modal-class-grid inspector-ca-class-grid",children:[g.jsxs("label",{children:["Dimensions",g.jsxs("select",{disabled:!Ce,value:_e,onChange:w=>{Ii(Number(w.target.value),H,Fe)},children:[g.jsx("option",{value:1,children:"1D"}),g.jsx("option",{value:2,children:"2D"}),g.jsx("option",{value:3,children:"3D"})]})]}),g.jsxs("label",{children:["States",g.jsx("input",{disabled:!Ce,min:2,step:1,type:"number",value:H,onChange:w=>Ii(_e,Math.max(2,Number(w.target.value)||2),Fe)})]}),g.jsxs("label",{children:["Neighbourhood",g.jsxs("select",{disabled:!Ce,value:Fe,onChange:w=>{Ii(_e,H,w.target.value)},children:[g.jsx("option",{value:"moore",children:"Moore"}),g.jsx("option",{value:"von-neumann",children:"Von Neumann"})]})]})]})]}),g.jsxs("section",{className:"preset-modal-stage inspector-ca-stage",children:[g.jsxs("div",{className:"preset-modal-stage-heading",children:[g.jsx("span",{children:"2"}),g.jsxs("div",{children:[g.jsx("h3",{children:"Evolution engine"}),g.jsx("p",{children:"Only engines that support this CA space can be selected."})]})]}),g.jsxs("label",{children:["Engine",g.jsxs("select",{disabled:!Ce,value:qe?.id??"",onChange:w=>Oi(w.target.value),children:[g.jsx("option",{value:"",children:"Select evolution function"}),Ze.map(w=>g.jsx("option",{value:w.id,children:w.name},w.id))]})]}),qe?g.jsx("small",{className:"param-empty",children:qe.license?`License: ${qe.license}`:"No license metadata"}):g.jsx("p",{className:"param-empty",children:Ze.length>0?"Select an evolution function for this preset.":"No matching engine for this preset class."})]}),g.jsxs("section",{className:"preset-modal-stage inspector-ca-stage",children:[g.jsxs("div",{className:"preset-modal-stage-heading",children:[g.jsx("span",{children:"3"}),g.jsxs("div",{children:[g.jsx("h3",{children:"Engine settings"}),g.jsx("p",{children:"Controls are supplied by the selected engine schema."})]})]}),g.jsx(q2,{disabled:!Ce,engine:qe,settings:Oe,onSet:Pi})]})]}):null,Ne==="initial"?g.jsxs("div",{className:"inspector-section",children:[g.jsxs("div",{className:"button-row initial-condition-actions",children:[g.jsx("button",{type:"button",onClick:mn,children:"Clear canvas"}),g.jsx("button",{className:"primary",disabled:!Ce||!z||ft,type:"button",onClick:()=>{Ds()},children:ft?"Saving...":"Save initial condition"})]}),z?g.jsx("p",{className:"param-empty",children:"Initial condition has unsaved canvas edits."}):g.jsx("p",{className:"param-empty",children:"Canvas edits are saved explicitly so preview playback stays temporary."}),Ge.length>0?g.jsxs(g.Fragment,{children:[g.jsxs("label",{children:["Generator",g.jsxs("select",{value:C,onChange:w=>{const k=Ge.find(W=>W.id===w.target.value);y(w.target.value),ma(k)},children:[g.jsx("option",{value:"",children:"Select generator"}),Ge.map(w=>g.jsx("option",{value:w.id,children:w.name},w.id))]})]}),De?.generator_kind==="naga-markov"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"icg-controls",children:[g.jsxs("label",{children:["Naga count",g.jsx("input",{max:16,min:1,step:1,type:"range",value:I,onChange:w=>B(Math.max(1,Number(w.target.value)||1))})]}),g.jsx("strong",{children:I})]}),g.jsxs("div",{className:"icg-controls",children:[g.jsxs("label",{children:["Mean length",g.jsx("input",{max:64,min:1,step:1,type:"range",value:L,onChange:w=>T(Math.max(1,Number(w.target.value)||1))})]}),g.jsx("strong",{children:L})]}),g.jsxs("div",{className:"icg-controls",children:[g.jsxs("label",{children:["Length std. dev.",g.jsx("input",{max:32,min:0,step:1,type:"range",value:U,onChange:w=>X(Math.max(0,Number(w.target.value)||0))})]}),g.jsx("strong",{children:U})]}),g.jsxs("div",{className:"icg-controls",children:[g.jsxs("label",{children:["Same type probability",g.jsx("input",{max:1,min:0,step:.01,type:"range",value:G,onChange:w=>K(Number(w.target.value))})]}),g.jsxs("strong",{children:[Math.round(G*100),"%"]})]})]}):g.jsxs("div",{className:"icg-controls",children:[g.jsxs("label",{children:["Density",g.jsx("input",{max:1,min:0,step:.01,type:"range",value:O,onChange:w=>R(Number(w.target.value))})]}),g.jsxs("strong",{children:[Math.round(O*100),"%"]})]}),g.jsxs("label",{children:["IC seed",g.jsx("input",{value:ue,onChange:w=>pe(w.target.value)})]}),g.jsx("button",{className:"primary",disabled:!Ce||!C,type:"button",onClick:ea,children:"Generate initial condition"})]}):g.jsx("p",{className:"param-empty",children:"No matching generator for this preset class."})]}):null,Ne==="display"?g.jsxs("div",{className:"inspector-section",children:[g.jsxs("label",{children:["Renderer",g.jsx("select",{disabled:!Ce,value:Ee,onChange:w=>{Le(w.target.value),Sn()},children:qt.map(w=>g.jsx("option",{value:w.id,children:w.label},w.id))})]}),qt.length===0?g.jsx("p",{className:"param-empty",children:"No renderer supports this dimensionality and state space."}):null,g.jsx("p",{className:"param-empty",children:"Renderer-specific display controls will appear in this inspector."})]}):null]})]})]})]})}function Q2({assignedNodeId:a,assignedNodeName:e,autoplayOnSlideChange:n,caption:s,scene:l,slideTitle:c,onAutoplayChange:d,onCaptionChange:p,onClose:m,onSelectCa:h,onSlideTitleChange:v}){return g.jsx("div",{className:"modal-backdrop slide-modal-backdrop",role:"presentation",onMouseDown:m,children:g.jsxs("section",{"aria-modal":"true",className:"property-modal slide-metadata-modal",role:"dialog",onMouseDown:S=>S.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Slide Metadata"}),g.jsx("h2",{children:l.scene.title})]}),g.jsx(Zi,{onClose:m})]}),g.jsxs("div",{className:"slide-metadata-body",children:[g.jsxs("label",{children:["Slide name",g.jsx("input",{value:c,onChange:S=>v(S.target.value)})]}),g.jsxs("label",{children:["Caption",g.jsx("textarea",{value:s,onChange:S=>p(S.target.value)})]}),g.jsxs("label",{className:"toggle-field",children:[g.jsx("input",{checked:n,type:"checkbox",onChange:S=>d(S.target.checked)}),"Autoplay on slide change"]}),g.jsxs("section",{className:"slide-ca-asset",children:[g.jsxs("div",{children:[g.jsx("span",{children:"CA preset"}),g.jsx("strong",{children:e??"No CA selected"}),g.jsx("small",{children:a?a.slice(0,8):"Select a reusable preset asset"})]}),g.jsx("button",{className:"primary",type:"button",onClick:h,children:"Select CA"})]}),g.jsxs("div",{className:"slide-metadata-grid",children:[g.jsxs("span",{children:[g.jsx("strong",{children:"Order"}),g.jsx("small",{children:l.scene.order_index})]}),g.jsxs("span",{children:[g.jsx("strong",{children:"Apply mode"}),g.jsx("small",{children:l.scene.apply_mode})]}),g.jsxs("span",{children:[g.jsx("strong",{children:"Assigned node"}),g.jsx("small",{children:a?a.slice(0,8):"none"})]}),g.jsxs("span",{children:[g.jsx("strong",{children:"Tree"}),g.jsx("small",{children:l.scene.preset_tree_id?.slice(0,8)??"none"})]})]})]})]})})}function J2({assignedNodeId:a,loading:e,nodes:n,presetTrees:s,resolvedNode:l,selectedNode:c,selectedTreeId:d,onClose:p,onEditSelected:m,onSelectNode:h,onSelectTree:v,onUseSelected:S}){const _=Ol(l?.params.simulation?.initialCondition?.cells);return ee.useEffect(()=>{function M(E){E.key==="Escape"&&p()}return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[p]),g.jsx("div",{className:"modal-backdrop ca-asset-modal-backdrop",role:"presentation",onMouseDown:p,children:g.jsxs("section",{"aria-modal":"true",className:"property-modal ca-asset-modal",role:"dialog",onMouseDown:M=>M.stopPropagation(),children:[g.jsxs("header",{className:"property-modal-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"CA Assets"}),g.jsx("h2",{children:"Select a preset"})]}),g.jsx(Zi,{onClose:p})]}),g.jsxs("div",{className:"ca-asset-layout",children:[g.jsxs("aside",{className:"ca-asset-browser",children:[g.jsxs("label",{children:["CA library",g.jsx("select",{value:d,onChange:M=>v(M.target.value),children:s.map(M=>g.jsxs("option",{value:M.id,children:[M.name," (",M.node_count,")"]},M.id))})]}),e?g.jsx("p",{className:"empty",children:"Loading CA presets..."}):g.jsx(r2,{assignedNodeId:a,nodes:n,selectedNodeId:c?.id,onSelect:h})]}),g.jsxs("section",{className:"ca-asset-preview",children:[g.jsxs("div",{className:"ca-asset-preview-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Preview"}),g.jsx("h3",{children:c?.name??"Select a CA preset"}),c?.description?g.jsx("p",{children:c.description}):null]}),l?g.jsxs("small",{children:[l.params.caClass?.dimensions??"?","D · ",String(l.params.caClass?.states??"?")," states"]}):null]}),g.jsx("div",{className:"ca-asset-preview-stage",children:l?g.jsx(Wu,{caption:"",cells:_,settings:l.params,onCellsChange:()=>{}}):g.jsx("p",{className:"empty",children:"Choose a preset from the tree to inspect it."})}),g.jsxs("div",{className:"ca-asset-actions",children:[g.jsx("button",{type:"button",onClick:p,children:"Cancel"}),g.jsx("button",{disabled:!c||c.kind==="chapter",type:"button",onClick:m,children:"Edit CA"}),g.jsx("button",{className:"primary",disabled:!c||c.kind==="chapter",type:"button",onClick:S,children:"Use this CA"})]})]})]})]})})}function e3({deckId:a}){const[e,n]=ee.useState(null),[s,l]=ee.useState(0),[c,d]=ee.useState(()=>go("B3/S23","moore","2d-canvas",cr())),[p,m]=ee.useState(()=>cr()),[h,v]=ee.useState(0),[S,_]=ee.useState(!1),[M,E]=ee.useState(fm),[C,y]=ee.useState("Loading viewer..."),x=ee.useRef(c),P=ee.useRef(s),O=e?.scenes[s]??null,R=ee.useMemo(()=>Ox(c,p),[p,c]);ee.useEffect(()=>{x.current=c},[c]),ee.useEffect(()=>{P.current=s},[s]);function I(T,U,X={}){const G=X.forceReinitialize===!0||T.scene.apply_mode!=="patch_existing"&&T.scene.requires_previous_scene!==!0;l(U),d(T.params),G&&(m(Ol(T.params.simulation?.initialCondition?.cells)),v(0)),_(z2(T)),y(T.scene.title)}const B=ee.useCallback((T,U={})=>{const X=e?.scenes??[];if(X.length===0)return;const G=Math.min(Math.max(T,0),X.length-1);I(X[G],G,U)},[e]),L=ee.useCallback(()=>{m(T=>{const U=Rl(T,Ox(x.current,T));return d(U.settings),x.current=U.settings,U.cells}),v(T=>T+1)},[]);return ee.useEffect(()=>{let T=!1;async function U(){try{const X=await ht(`/api/ca/decks/${a}/resolved`);if(T)return;n(X),X.scenes[0]?I(X.scenes[0],0,{forceReinitialize:!0}):y("Deck has no slides")}catch(X){T||y(X instanceof Error?X.message:"Viewer load failed")}}return U(),()=>{T=!0}},[a]),ee.useEffect(()=>{if(S)return _m(M,L)},[S,M,L]),ee.useEffect(()=>{function T(U){if(!Vy(U.target)){if(U.key==="ArrowRight"||U.key==="ArrowDown"){U.preventDefault(),B(P.current+1);return}if(U.key==="ArrowLeft"||U.key==="ArrowUp"){U.preventDefault(),B(P.current-1);return}if(U.key===" "){U.preventDefault(),_(X=>!X);return}if(U.key==="."||U.key.toLowerCase()==="s"){U.preventDefault(),_(!1),L();return}U.key.toLowerCase()==="r"&&(U.preventDefault(),B(P.current,{forceReinitialize:!0}))}}return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[B,L]),g.jsx("main",{className:"viewer-shell",children:g.jsxs("section",{className:"viewer-stage","aria-label":O?.scene.title??C,children:[g.jsx(Wu,{caption:F2(O),cells:p,settings:R,onCellsChange:()=>{}}),g.jsx("div",{className:"viewer-speed-float","aria-label":"Simulation speed",children:g.jsx(Qy,{speedLevel:M,onChange:E})}),g.jsxs("div",{className:"viewer-rec-status","aria-hidden":"true",children:[g.jsx("span",{children:e?.deck.title??"CA Deck"}),g.jsx("span",{children:O?`${s+1}/${e?.scenes.length??0}`:C}),g.jsx("span",{children:S?"REC PLAY":"REC HOLD"}),g.jsxs("span",{children:["G",h]})]})]})})}function t3({deckId:a,initialSceneId:e}){const[n,s]=ee.useState(null),[l,c]=ee.useState("Deck editor"),[d,p]=ee.useState(null),[m,h]=ee.useState([]),[v,S]=ee.useState([]),[_,M]=ee.useState(""),[E,C]=ee.useState(!1),[y,x]=ee.useState(!1),[P,O]=ee.useState(""),[R,I]=ee.useState([]),[B,L]=ee.useState(""),[T,U]=ee.useState(null),[X,G]=ee.useState(!1),[K,ue]=ee.useState(""),[pe,Q]=ee.useState("Untitled slide"),[V,j]=ee.useState("Glider"),[ae,_e]=ee.useState(""),[ve,H]=ee.useState(!1),[te,Ee]=ee.useState("2d-canvas"),[Le,Fe]=ee.useState("moore"),[oe,Me]=ee.useState("B3/S23"),[Ae,ze]=ee.useState("wrap"),[at,Je]=ee.useState(()=>E2()),[Gt,ut]=ee.useState(null),[_t,xt]=ee.useState(0),[ot,Ht]=ee.useState(!1),[Bt,Zt]=ee.useState(fm),[Vt,dt]=ee.useState("Loading deck..."),J=ee.useRef(!1),z=ee.useRef(!1),Ue=d?.scenes.find(Re=>Re.scene.id===_)??null,ft=d?.scenes.findIndex(Re=>Re.scene.id===_)??-1;mo(n);const F=d?.scenes.length??0,A=ft>0,ne=ft>=0&&ft<F-1,re=v.find(Re=>Re.id===K)??null,fe=Ue?.scene.preset_node_id,Ne=R.find(Re=>Re.id===B)??null,He=re?In(Al(v,re),re.params):null,ge=ir(He??void 0),le=re?In(He??{},go(oe,Le,te,at,void 0,Ae,Fu(ge))):go(oe,Le,te,at,void 0,Ae),Ie=Gt??le,We=ee.useCallback(async()=>{const Re=await ht(`/api/ca/decks/${a}`),Ke=await ht(`/api/ca/decks/${a}/resolved`);return z.current=!0,s(Re),c(Re.title),p(Ke),window.setTimeout(()=>{z.current=!1},0),{deck:Re,resolvedDeck:Ke}},[a]);async function Xe(Re){const Ke=await ht(`/api/ca/preset-trees/${Re}/nodes`);S(Ke)}async function ke(){const Re=await ht("/api/ca/preset-trees");return h(Re),Re}async function nt(Re,Ke){const gt=mo(Re);if(gt.presetTreeId)return await Xe(gt.presetTreeId),gt;const Ot=Ke.scenes[0];if(Ot?.scene.preset_tree_id){const Tt={presetTreeId:Ot.scene.preset_tree_id,rootNodeId:void 0,rendererId:Ot.params.renderer?.id??"2d-canvas",neighborhoodId:Ot.params.simulation?.neighborhoodId??"moore",ruleId:Ot.params.simulation?.ruleId??"B3/S23"},vt=await ht(`/api/ca/decks/${Re.id}`,{method:"PATCH",body:JSON.stringify({params:A2(Re,Tt)})});return s(vt),await Xe(Tt.presetTreeId),dt("Repaired deck metadata from existing slides"),Tt}return S([]),gt}ee.useEffect(()=>{async function Re(){try{const Ke=await We();await ke();const gt=await nt(Ke.deck,Ke.resolvedDeck),Ot=Ke.resolvedDeck.scenes.find(Tt=>Tt.scene.id===e)??Ke.resolvedDeck.scenes[0];Ot?rt(Ot):(Ee(gt.rendererId??"2d-canvas"),Fe(gt.neighborhoodId??"moore"),Me(gt.ruleId??"B3/S23"),ze("wrap"),dt(gt.presetTreeId?"Deck ready. Add the first slide.":"Deck ready. Add the first slide and select a CA asset."))}catch(Ke){dt(Ke instanceof Error?Ke.message:"Deck load failed")}}Re()},[a,e,We]),ee.useEffect(()=>{if(ot)return _m(Bt,()=>{Je(Re=>{const Ke=Rl(Re,Ie);return ut(Ke.settings),Ke.cells}),xt(Re=>Re+1)})},[Ie,ot,Bt]),ee.useEffect(()=>{if(!n||z.current||l===n.title)return;const Re=window.setTimeout(async()=>{const Ke=l.trim()||"Untitled deck";try{const gt=await ht(`/api/ca/decks/${n.id}`,{method:"PATCH",body:JSON.stringify({title:Ke})});s(gt),c(gt.title),dt("Deck name saved")}catch(gt){dt(gt instanceof Error?gt.message:"Deck name save failed")}},450);return()=>window.clearTimeout(Re)},[n,l]),ee.useEffect(()=>{if(!Ue||J.current)return;const Re=pe.trim()||"Untitled slide",Ke=typeof Ue.scene.params.caption=="string"?Ue.scene.params.caption:"",gt=Ue.scene.params.autoplayOnSlideChange===!0;if(Ue.scene.title===Re&&Ke===ae&&gt===ve)return;const Ot=window.setTimeout(async()=>{try{await ht(`/api/ca/scenes/${Ue.scene.id}`,{method:"PATCH",body:JSON.stringify({title:Re,params:{...Ue.scene.params,caption:ae,autoplayOnSlideChange:ve}})}),p(Tt=>Tt&&{...Tt,scenes:Tt.scenes.map(vt=>vt.scene.id===Ue.scene.id?{...vt,scene:{...vt.scene,title:Re,params:{...vt.scene.params,caption:ae,autoplayOnSlideChange:ve}}}:vt)}),dt("Slide settings saved")}catch(Tt){dt(Tt instanceof Error?Tt.message:"Slide settings autosave failed")}},450);return()=>window.clearTimeout(Ot)},[Ue,ve,ae,pe]);async function Ce(Re,Ke,gt,Ot={}){J.current=!0,Ht(!1);const[Tt,vt,vn]=await Promise.all([ht(`/api/ca/preset-trees/${Re}/nodes/${Ke}`),ht(`/api/ca/preset-trees/${Re}/nodes/${Ke}/resolved`),ht(`/api/ca/preset-trees/${Re}/nodes`)]);S(vn),ue(Ke),ut(null),j(Tt.name||gt||"Untitled node"),Ee(vt.params.renderer?.id??"2d-canvas"),Fe(vt.params.simulation?.neighborhoodId??"moore"),Me(vt.params.simulation?.ruleId??"B3/S23"),ze(Xp(vt.params)),Je(Ol(vt.params.simulation?.initialCondition?.cells)),xt(0),dt(`Loaded node "${Tt.name}"`),window.setTimeout(()=>{J.current=!1,Ht(Ot.runAfterLoad===!0)},0)}function rt(Re){J.current=!0;const Ke=Re.scene.params.autoplayOnSlideChange===!0;if(Ht(!1),M(Re.scene.id),Q(Re.scene.title),_e(typeof Re.scene.params.caption=="string"?Re.scene.params.caption:""),H(Ke),Re.scene.preset_tree_id&&Re.scene.preset_node_id){ut(null),Ce(Re.scene.preset_tree_id,Re.scene.preset_node_id,Re.scene.title,{runAfterLoad:Ke});return}ue(""),ut(null),j("No CA preset"),Je(cr()),xt(0),dt(`Loaded empty slide "${Re.scene.title}"`),window.setTimeout(()=>{J.current=!1},0)}function Z(Re){rt(Re),C(!0)}async function Oe(Re){L(Re.id),G(!0);try{const Ke=await ht(`/api/ca/preset-trees/${Re.tree_id}/nodes/${Re.id}/resolved`);U(Ke)}catch(Ke){U(null),dt(Ke instanceof Error?Ke.message:"CA preview failed")}finally{G(!1)}}async function ye(Re,Ke){if(!Re){O(""),I([]),L(""),U(null);return}O(Re),G(!0);try{const gt=await ht(`/api/ca/preset-trees/${Re}/nodes`);I(gt);const Tt=gt.find(vt=>vt.id===Ke)??gt.find(vt=>vt.kind!=="chapter")??null;Tt?(L(Tt.id),U(await ht(`/api/ca/preset-trees/${Re}/nodes/${Tt.id}/resolved`))):(L(""),U(null))}catch(gt){I([]),L(""),U(null),dt(gt instanceof Error?gt.message:"CA library load failed")}finally{G(!1)}}function Pe(){const Re=Ue?.scene.preset_tree_id??m[0]?.id??"";C(!1),x(!0),ye(Re,Ue?.scene.preset_node_id??void 0)}async function Ge(){if(!Ne||Ne.kind==="chapter"||!Ue)return;await ht(`/api/ca/scenes/${Ue.scene.id}`,{method:"PATCH",body:JSON.stringify({presetTreeId:Ne.tree_id,presetNodeId:Ne.id,params:{...Ue.scene.params,caption:ae,autoplayOnSlideChange:ve}})});const Ke=(await We()).resolvedDeck.scenes.find(gt=>gt.scene.id===Ue.scene.id);Ke&&rt(Ke),x(!1),dt(`Assigned "${Ne.name}" to selected slide`)}async function De(){if(Ue)try{Ht(!1),dt(`Deleting slide "${Ue.scene.title}"...`);const Re=Ue.scene.id,Ke=Ue.scene.title,gt=d?.scenes.findIndex(vt=>vt.scene.id===Re)??0;await fetch(`/api/ca/scenes/${Re}`,{method:"DELETE"}).then(vt=>{if(!vt.ok)throw new Error("Unable to delete slide")});const Ot=await We(),Tt=Ot.resolvedDeck.scenes[Math.min(Math.max(gt,0),Ot.resolvedDeck.scenes.length-1)];Tt?rt(Tt):(M(""),Q("Untitled slide"),_e(""),H(!1)),dt(`Deleted slide "${Ke}". Preset node kept.`)}catch(Re){dt(Re instanceof Error?Re.message:"Slide delete failed")}}async function Ze(Re){if(!(!n||Re.length===0))try{dt("Reordering slides...");const Ke=1e5;await Promise.all(Re.map((gt,Ot)=>ht(`/api/ca/scenes/${gt.scene.id}`,{method:"PATCH",body:JSON.stringify({orderIndex:Ke+Ot})}))),await Promise.all(Re.map((gt,Ot)=>ht(`/api/ca/scenes/${gt.scene.id}`,{method:"PATCH",body:JSON.stringify({orderIndex:Ot+1})}))),await We(),dt("Slides reordered")}catch(Ke){dt(Ke instanceof Error?Ke.message:"Slide reorder failed")}}async function qe(){if(!n)return;dt("Creating slide...");const Re=F+1,Ke=await ht(`/api/ca/decks/${n.id}/scenes`,{method:"POST",body:JSON.stringify({orderIndex:Re,title:`Slide ${Re}`,presetTreeId:null,presetNodeId:null,applyMode:"reinitialize",params:{caption:"",autoplayOnSlideChange:!1}})}),Ot=(await We()).resolvedDeck.scenes.find(Tt=>Tt.scene.id===Ke.id);Ot&&rt(Ot),dt(`Created slide ${Re}. Select a CA preset.`)}function qt(){Ht(!1),Je(Re=>{const Ke=Rl(Re,Ie);return ut(Ke.settings),Ke.cells}),xt(Re=>Re+1)}function wt(Re){if(!d?.scenes.length)return;const Ke=d.scenes.findIndex(Tt=>Tt.scene.id===_),gt=Math.min(Math.max(Ke===-1?0:Ke+Re,0),d.scenes.length-1),Ot=d.scenes[gt];Ot&&Ot.scene.id!==_&&rt(Ot)}function Ln(){if(!Ue?.scene.preset_tree_id||!Ue.scene.preset_node_id)return;const Re=new URLSearchParams({node:Ue.scene.preset_node_id,return:`/admin/edit/${a}?scene=${Ue.scene.id}`});Di(`/admin/libraries/${Ue.scene.preset_tree_id}?${Re.toString()}`)}function Sn(){if(!Ne||Ne.kind==="chapter")return;const Re=Ue?`/admin/edit/${a}?scene=${Ue.scene.id}`:`/admin/edit/${a}`,Ke=new URLSearchParams({node:Ne.id,return:Re});Di(`/admin/libraries/${Ne.tree_id}?${Ke.toString()}`)}return ee.useEffect(()=>{function Re(Ke){if(!Vy(Ke.target)){if(Ke.key==="ArrowDown"||Ke.key==="ArrowRight"){Ke.preventDefault(),wt(1);return}if(Ke.key==="ArrowUp"||Ke.key==="ArrowLeft"){Ke.preventDefault(),wt(-1);return}Ke.key===" "&&(Ke.preventDefault(),Ht(gt=>!gt))}}return window.addEventListener("keydown",Re),()=>window.removeEventListener("keydown",Re)},[_,d]),g.jsxs("main",{className:"studio-shell",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"deck-title-editor",children:[g.jsx("p",{className:"eyebrow",children:"CA Studio Admin"}),g.jsx("input",{"aria-label":"Deck name",className:"deck-title-input",value:l,onChange:Re=>c(Re.target.value)})]}),g.jsxs("div",{className:"topbar-actions",children:[g.jsx("div",{className:"status",children:Vt}),g.jsx(Zi,{})]})]}),g.jsxs("section",{className:"editor-layout",children:[g.jsx(x2,{activeSceneId:_,canDeleteSlide:!!Ue,sceneCount:F,scenes:d?.scenes??[],onBack:()=>Di(So("decks")),onDeleteSlide:()=>{De()},onEditScene:Z,onReorderSlides:Re=>{Ze(Re)},onSaveNewSlide:()=>{qe()},onSelectScene:rt}),E&&Ue?g.jsx(Q2,{assignedNodeId:fe??void 0,assignedNodeName:V,autoplayOnSlideChange:ve,caption:ae,scene:Ue,slideTitle:pe,onAutoplayChange:H,onCaptionChange:_e,onClose:()=>C(!1),onSelectCa:Pe,onSlideTitleChange:Q}):null,y?g.jsx(J2,{assignedNodeId:fe??void 0,loading:X,nodes:R,presetTrees:m,resolvedNode:T,selectedNode:Ne,selectedTreeId:P,onClose:()=>x(!1),onEditSelected:Sn,onSelectNode:Re=>{Oe(Re)},onSelectTree:Re=>{ye(Re)},onUseSelected:()=>{Ge()}}):null,g.jsxs("section",{className:"panel editor-panel deck-editor-panel",children:[g.jsxs("div",{className:"editor-header",children:[g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Visualization"}),g.jsx("h2",{children:Ue?pe:V})]}),g.jsxs("div",{className:"button-row",children:[g.jsx(Zi,{}),g.jsx("button",{"aria-label":"Previous slide",className:"deck-nav-button",disabled:!A,title:"Previous slide",type:"button",onClick:()=>wt(-1),children:"←"}),g.jsxs("span",{className:"deck-position",children:[ft>=0?ft+1:0,"/",F]}),g.jsx("button",{"aria-label":"Next slide",className:"deck-nav-button",disabled:!ne,title:"Next slide",type:"button",onClick:()=>wt(1),children:"→"}),g.jsx("button",{disabled:!fe,type:"button",onClick:Ln,children:"Edit CA"}),g.jsx("button",{disabled:!fe,type:"button",onClick:qt,children:"Step"}),g.jsx("button",{className:"primary playback-button",disabled:!fe,type:"button",onClick:()=>Ht(Re=>!Re),children:ot?"⏸":"▶"})]})]}),fe?g.jsx(Wu,{caption:Ue?ae:"",cells:at,settings:Ie,onCellsChange:()=>{}}):g.jsx("section",{className:"empty-slide-stage",children:g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Empty slide"}),g.jsx("h3",{children:"Select a CA preset"}),g.jsx("p",{children:"This slide has no simulation asset assigned yet."}),g.jsx("button",{className:"primary",type:"button",onClick:Pe,children:"Select CA preset"})]})}),g.jsxs("footer",{className:"metrics",children:[g.jsxs("span",{children:["Generation ",g.jsx("strong",{children:_t})]}),g.jsxs("span",{children:["Live cells ",g.jsx("strong",{children:Gy(at)})]}),g.jsxs("span",{children:["Selected node ",g.jsx("strong",{children:K?K.slice(0,8):"none"})]}),g.jsxs("span",{children:["Assigned node ",g.jsx("strong",{children:fe?fe.slice(0,8):"none"})]})]})]})]})]})}hM.createRoot(document.getElementById("root")).render(g.jsx(ee.StrictMode,{children:g.jsx(G2,{})}));