4117 lines
821 KiB
JavaScript
4117 lines
821 KiB
JavaScript
(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 f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&s(f)}).observe(document,{childList:!0,subtree:!0});function i(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=i(l);fetch(l.href,c)}})();function gx(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Vd={exports:{}},rl={};var B_;function AM(){if(B_)return rl;B_=1;var a=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function i(s,l,c){var f=null;if(c!==void 0&&(f=""+c),l.key!==void 0&&(f=""+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:f,ref:l!==void 0?l:null,props:c}}return rl.Fragment=e,rl.jsx=i,rl.jsxs=i,rl}var F_;function CM(){return F_||(F_=1,Vd.exports=AM()),Vd.exports}var g=CM(),kd={exports:{}},Tt={};var z_;function wM(){if(z_)return Tt;z_=1;var a=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),_=Symbol.iterator;function b(F){return F===null||typeof F!="object"?null:(F=_&&F[_]||F["@@iterator"],typeof F=="function"?F:null)}var T={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,v={};function x(F,J,Ce){this.props=F,this.context=J,this.refs=v,this.updater=Ce||T}x.prototype.isReactComponent={},x.prototype.setState=function(F,J){if(typeof F!="object"&&typeof F!="function"&&F!=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,F,J,"setState")},x.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function B(){}B.prototype=x.prototype;function P(F,J,Ce){this.props=F,this.context=J,this.refs=v,this.updater=Ce||T}var D=P.prototype=new B;D.constructor=P,C(D,x.prototype),D.isPureReactComponent=!0;var O=Array.isArray;function U(){}var N={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function L(F,J,Ce){var Ue=Ce.ref;return{$$typeof:a,type:F,key:J,ref:Ue!==void 0?Ue:null,props:Ce}}function j(F,J){return L(F.type,J,F.props)}function V(F){return typeof F=="object"&&F!==null&&F.$$typeof===a}function $(F){var J={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(Ce){return J[Ce]})}var pe=/\/+/g;function ge(F,J){return typeof F=="object"&&F!==null&&F.key!=null?$(""+F.key):J.toString(36)}function K(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(U,U):(F.status="pending",F.then(function(J){F.status==="pending"&&(F.status="fulfilled",F.value=J)},function(J){F.status==="pending"&&(F.status="rejected",F.reason=J)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function H(F,J,Ce,Ue,Ie){var ae=typeof F;(ae==="undefined"||ae==="boolean")&&(F=null);var Ae=!1;if(F===null)Ae=!0;else switch(ae){case"bigint":case"string":case"number":Ae=!0;break;case"object":switch(F.$$typeof){case a:case e:Ae=!0;break;case y:return Ae=F._init,H(Ae(F._payload),J,Ce,Ue,Ie)}}if(Ae)return Ie=Ie(F),Ae=Ue===""?"."+ge(F,0):Ue,O(Ie)?(Ce="",Ae!=null&&(Ce=Ae.replace(pe,"$&/")+"/"),H(Ie,J,Ce,"",function(nt){return nt})):Ie!=null&&(V(Ie)&&(Ie=j(Ie,Ce+(Ie.key==null||F&&F.key===Ie.key?"":(""+Ie.key).replace(pe,"$&/")+"/")+Ae)),J.push(Ie)),1;Ae=0;var Ee=Ue===""?".":Ue+":";if(O(F))for(var He=0;He<F.length;He++)Ue=F[He],ae=Ee+ge(Ue,He),Ae+=H(Ue,J,Ce,ae,Ie);else if(He=b(F),typeof He=="function")for(F=He.call(F),He=0;!(Ue=F.next()).done;)Ue=Ue.value,ae=Ee+ge(Ue,He++),Ae+=H(Ue,J,Ce,ae,Ie);else if(ae==="object"){if(typeof F.then=="function")return H(K(F),J,Ce,Ue,Ie);throw J=String(F),Error("Objects are not valid as a React child (found: "+(J==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":J)+"). If you meant to render a collection of children, use an array instead.")}return Ae}function G(F,J,Ce){if(F==null)return F;var Ue=[],Ie=0;return H(F,Ue,"","",function(ae){return J.call(Ce,ae,Ie++)}),Ue}function ne(F){if(F._status===-1){var J=F._result;J=J(),J.then(function(Ce){(F._status===0||F._status===-1)&&(F._status=1,F._result=Ce)},function(Ce){(F._status===0||F._status===-1)&&(F._status=2,F._result=Ce)}),F._status===-1&&(F._status=0,F._result=J)}if(F._status===1)return F._result.default;throw F._result}var ye=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var J=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(J))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},xe={map:G,forEach:function(F,J,Ce){G(F,function(){J.apply(this,arguments)},Ce)},count:function(F){var J=0;return G(F,function(){J++}),J},toArray:function(F){return G(F,function(J){return J})||[]},only:function(F){if(!V(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return Tt.Activity=S,Tt.Children=xe,Tt.Component=x,Tt.Fragment=i,Tt.Profiler=l,Tt.PureComponent=P,Tt.StrictMode=s,Tt.Suspense=m,Tt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,Tt.__COMPILER_RUNTIME={__proto__:null,c:function(F){return N.H.useMemoCache(F)}},Tt.cache=function(F){return function(){return F.apply(null,arguments)}},Tt.cacheSignal=function(){return null},Tt.cloneElement=function(F,J,Ce){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var Ue=C({},F.props),Ie=F.key;if(J!=null)for(ae in J.key!==void 0&&(Ie=""+J.key),J)!A.call(J,ae)||ae==="key"||ae==="__self"||ae==="__source"||ae==="ref"&&J.ref===void 0||(Ue[ae]=J[ae]);var ae=arguments.length-2;if(ae===1)Ue.children=Ce;else if(1<ae){for(var Ae=Array(ae),Ee=0;Ee<ae;Ee++)Ae[Ee]=arguments[Ee+2];Ue.children=Ae}return L(F.type,Ie,Ue)},Tt.createContext=function(F){return F={$$typeof:f,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:c,_context:F},F},Tt.createElement=function(F,J,Ce){var Ue,Ie={},ae=null;if(J!=null)for(Ue in J.key!==void 0&&(ae=""+J.key),J)A.call(J,Ue)&&Ue!=="key"&&Ue!=="__self"&&Ue!=="__source"&&(Ie[Ue]=J[Ue]);var Ae=arguments.length-2;if(Ae===1)Ie.children=Ce;else if(1<Ae){for(var Ee=Array(Ae),He=0;He<Ae;He++)Ee[He]=arguments[He+2];Ie.children=Ee}if(F&&F.defaultProps)for(Ue in Ae=F.defaultProps,Ae)Ie[Ue]===void 0&&(Ie[Ue]=Ae[Ue]);return L(F,ae,Ie)},Tt.createRef=function(){return{current:null}},Tt.forwardRef=function(F){return{$$typeof:p,render:F}},Tt.isValidElement=V,Tt.lazy=function(F){return{$$typeof:y,_payload:{_status:-1,_result:F},_init:ne}},Tt.memo=function(F,J){return{$$typeof:h,type:F,compare:J===void 0?null:J}},Tt.startTransition=function(F){var J=N.T,Ce={};N.T=Ce;try{var Ue=F(),Ie=N.S;Ie!==null&&Ie(Ce,Ue),typeof Ue=="object"&&Ue!==null&&typeof Ue.then=="function"&&Ue.then(U,ye)}catch(ae){ye(ae)}finally{J!==null&&Ce.types!==null&&(J.types=Ce.types),N.T=J}},Tt.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},Tt.use=function(F){return N.H.use(F)},Tt.useActionState=function(F,J,Ce){return N.H.useActionState(F,J,Ce)},Tt.useCallback=function(F,J){return N.H.useCallback(F,J)},Tt.useContext=function(F){return N.H.useContext(F)},Tt.useDebugValue=function(){},Tt.useDeferredValue=function(F,J){return N.H.useDeferredValue(F,J)},Tt.useEffect=function(F,J){return N.H.useEffect(F,J)},Tt.useEffectEvent=function(F){return N.H.useEffectEvent(F)},Tt.useId=function(){return N.H.useId()},Tt.useImperativeHandle=function(F,J,Ce){return N.H.useImperativeHandle(F,J,Ce)},Tt.useInsertionEffect=function(F,J){return N.H.useInsertionEffect(F,J)},Tt.useLayoutEffect=function(F,J){return N.H.useLayoutEffect(F,J)},Tt.useMemo=function(F,J){return N.H.useMemo(F,J)},Tt.useOptimistic=function(F,J){return N.H.useOptimistic(F,J)},Tt.useReducer=function(F,J,Ce){return N.H.useReducer(F,J,Ce)},Tt.useRef=function(F){return N.H.useRef(F)},Tt.useState=function(F){return N.H.useState(F)},Tt.useSyncExternalStore=function(F,J,Ce){return N.H.useSyncExternalStore(F,J,Ce)},Tt.useTransition=function(){return N.H.useTransition()},Tt.version="19.2.7",Tt}var H_;function Rp(){return H_||(H_=1,kd.exports=wM()),kd.exports}var RM=Rp();const ee=gx(RM);var jd={exports:{}},ol={},Xd={exports:{}},Wd={};var G_;function DM(){return G_||(G_=1,(function(a){function e(H,G){var ne=H.length;H.push(G);e:for(;0<ne;){var ye=ne-1>>>1,xe=H[ye];if(0<l(xe,G))H[ye]=G,H[ne]=xe,ne=ye;else break e}}function i(H){return H.length===0?null:H[0]}function s(H){if(H.length===0)return null;var G=H[0],ne=H.pop();if(ne!==G){H[0]=ne;e:for(var ye=0,xe=H.length,F=xe>>>1;ye<F;){var J=2*(ye+1)-1,Ce=H[J],Ue=J+1,Ie=H[Ue];if(0>l(Ce,ne))Ue<xe&&0>l(Ie,Ce)?(H[ye]=Ie,H[Ue]=ne,ye=Ue):(H[ye]=Ce,H[J]=ne,ye=J);else if(Ue<xe&&0>l(Ie,ne))H[ye]=Ie,H[Ue]=ne,ye=Ue;else break e}}return G}function l(H,G){var ne=H.sortIndex-G.sortIndex;return ne!==0?ne:H.id-G.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 f=Date,p=f.now();a.unstable_now=function(){return f.now()-p}}var m=[],h=[],y=1,S=null,_=3,b=!1,T=!1,C=!1,v=!1,x=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;function D(H){for(var G=i(h);G!==null;){if(G.callback===null)s(h);else if(G.startTime<=H)s(h),G.sortIndex=G.expirationTime,e(m,G);else break;G=i(h)}}function O(H){if(C=!1,D(H),!T)if(i(m)!==null)T=!0,U||(U=!0,$());else{var G=i(h);G!==null&&K(O,G.startTime-H)}}var U=!1,N=-1,A=5,L=-1;function j(){return v?!0:!(a.unstable_now()-L<A)}function V(){if(v=!1,U){var H=a.unstable_now();L=H;var G=!0;try{e:{T=!1,C&&(C=!1,B(N),N=-1),b=!0;var ne=_;try{t:{for(D(H),S=i(m);S!==null&&!(S.expirationTime>H&&j());){var ye=S.callback;if(typeof ye=="function"){S.callback=null,_=S.priorityLevel;var xe=ye(S.expirationTime<=H);if(H=a.unstable_now(),typeof xe=="function"){S.callback=xe,D(H),G=!0;break t}S===i(m)&&s(m),D(H)}else s(m);S=i(m)}if(S!==null)G=!0;else{var F=i(h);F!==null&&K(O,F.startTime-H),G=!1}}break e}finally{S=null,_=ne,b=!1}G=void 0}}finally{G?$():U=!1}}}var $;if(typeof P=="function")$=function(){P(V)};else if(typeof MessageChannel<"u"){var pe=new MessageChannel,ge=pe.port2;pe.port1.onmessage=V,$=function(){ge.postMessage(null)}}else $=function(){x(V,0)};function K(H,G){N=x(function(){H(a.unstable_now())},G)}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(H){H.callback=null},a.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<H?Math.floor(1e3/H):5},a.unstable_getCurrentPriorityLevel=function(){return _},a.unstable_next=function(H){switch(_){case 1:case 2:case 3:var G=3;break;default:G=_}var ne=_;_=G;try{return H()}finally{_=ne}},a.unstable_requestPaint=function(){v=!0},a.unstable_runWithPriority=function(H,G){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var ne=_;_=H;try{return G()}finally{_=ne}},a.unstable_scheduleCallback=function(H,G,ne){var ye=a.unstable_now();switch(typeof ne=="object"&&ne!==null?(ne=ne.delay,ne=typeof ne=="number"&&0<ne?ye+ne:ye):ne=ye,H){case 1:var xe=-1;break;case 2:xe=250;break;case 5:xe=1073741823;break;case 4:xe=1e4;break;default:xe=5e3}return xe=ne+xe,H={id:y++,callback:G,priorityLevel:H,startTime:ne,expirationTime:xe,sortIndex:-1},ne>ye?(H.sortIndex=ne,e(h,H),i(m)===null&&H===i(h)&&(C?(B(N),N=-1):C=!0,K(O,ne-ye))):(H.sortIndex=xe,e(m,H),T||b||(T=!0,U||(U=!0,$()))),H},a.unstable_shouldYield=j,a.unstable_wrapCallback=function(H){var G=_;return function(){var ne=_;_=G;try{return H.apply(this,arguments)}finally{_=ne}}}})(Wd)),Wd}var V_;function NM(){return V_||(V_=1,Xd.exports=DM()),Xd.exports}var qd={exports:{}},Yn={};var k_;function UM(){if(k_)return Yn;k_=1;var a=Rp();function e(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)h+="&args[]="+encodeURIComponent(arguments[y])}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 i(){}var s={d:{f:i,r:function(){throw Error(e(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},l=Symbol.for("react.portal");function c(m,h,y){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:y}}var f=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 Yn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,Yn.createPortal=function(m,h){var y=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,y)},Yn.flushSync=function(m){var h=f.T,y=s.p;try{if(f.T=null,s.p=2,m)return m()}finally{f.T=h,s.p=y,s.d.f()}},Yn.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))},Yn.prefetchDNS=function(m){typeof m=="string"&&s.d.D(m)},Yn.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var y=h.as,S=p(y,h.crossOrigin),_=typeof h.integrity=="string"?h.integrity:void 0,b=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;y==="style"?s.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:S,integrity:_,fetchPriority:b}):y==="script"&&s.d.X(m,{crossOrigin:S,integrity:_,fetchPriority:b,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Yn.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var y=p(h.as,h.crossOrigin);s.d.M(m,{crossOrigin:y,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)},Yn.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var y=h.as,S=p(y,h.crossOrigin);s.d.L(m,y,{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})}},Yn.preloadModule=function(m,h){if(typeof m=="string")if(h){var y=p(h.as,h.crossOrigin);s.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:y,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else s.d.m(m)},Yn.requestFormReset=function(m){s.d.r(m)},Yn.unstable_batchedUpdates=function(m,h){return m(h)},Yn.useFormState=function(m,h,y){return f.H.useFormState(m,h,y)},Yn.useFormStatus=function(){return f.H.useHostTransitionStatus()},Yn.version="19.2.7",Yn}var j_;function LM(){if(j_)return qd.exports;j_=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(),qd.exports=UM(),qd.exports}var X_;function OM(){if(X_)return ol;X_=1;var a=NM(),e=Rp(),i=LM();function s(t){var n="https://react.dev/errors/"+t;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)n+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+t+"; visit "+n+" 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 n=t,r=t;if(t.alternate)for(;n.return;)n=n.return;else{t=n;do n=t,(n.flags&4098)!==0&&(r=n.return),t=n.return;while(t)}return n.tag===3?r:null}function f(t){if(t.tag===13){var n=t.memoizedState;if(n===null&&(t=t.alternate,t!==null&&(n=t.memoizedState)),n!==null)return n.dehydrated}return null}function p(t){if(t.tag===31){var n=t.memoizedState;if(n===null&&(t=t.alternate,t!==null&&(n=t.memoizedState)),n!==null)return n.dehydrated}return null}function m(t){if(c(t)!==t)throw Error(s(188))}function h(t){var n=t.alternate;if(!n){if(n=c(t),n===null)throw Error(s(188));return n!==t?null:t}for(var r=t,o=n;;){var u=r.return;if(u===null)break;var d=u.alternate;if(d===null){if(o=u.return,o!==null){r=o;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===r)return m(u),t;if(d===o)return m(u),n;d=d.sibling}throw Error(s(188))}if(r.return!==o.return)r=u,o=d;else{for(var M=!1,R=u.child;R;){if(R===r){M=!0,r=u,o=d;break}if(R===o){M=!0,o=u,r=d;break}R=R.sibling}if(!M){for(R=d.child;R;){if(R===r){M=!0,r=d,o=u;break}if(R===o){M=!0,o=d,r=u;break}R=R.sibling}if(!M)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:n}function y(t){var n=t.tag;if(n===5||n===26||n===27||n===6)return t;for(t=t.child;t!==null;){if(n=y(t),n!==null)return n;t=t.sibling}return null}var S=Object.assign,_=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),P=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),j=Symbol.for("react.memo_cache_sentinel"),V=Symbol.iterator;function $(t){return t===null||typeof t!="object"?null:(t=V&&t[V]||t["@@iterator"],typeof t=="function"?t:null)}var pe=Symbol.for("react.client.reference");function ge(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===pe?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case C:return"Fragment";case x:return"Profiler";case v:return"StrictMode";case O:return"Suspense";case U:return"SuspenseList";case L:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case T:return"Portal";case P:return t.displayName||"Context";case B:return(t._context.displayName||"Context")+".Consumer";case D:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case N:return n=t.displayName||null,n!==null?n:ge(t.type)||"Memo";case A:n=t._payload,t=t._init;try{return ge(t(n))}catch{}}return null}var K=Array.isArray,H=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},ye=[],xe=-1;function F(t){return{current:t}}function J(t){0>xe||(t.current=ye[xe],ye[xe]=null,xe--)}function Ce(t,n){xe++,ye[xe]=t.current,t.current=n}var Ue=F(null),Ie=F(null),ae=F(null),Ae=F(null);function Ee(t,n){switch(Ce(ae,n),Ce(Ie,t),Ce(Ue,null),n.nodeType){case 9:case 11:t=(t=n.documentElement)&&(t=t.namespaceURI)?r_(t):0;break;default:if(t=n.tagName,n=n.namespaceURI)n=r_(n),t=o_(n,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}J(Ue),Ce(Ue,t)}function He(){J(Ue),J(Ie),J(ae)}function nt(t){t.memoizedState!==null&&Ce(Ae,t);var n=Ue.current,r=o_(n,t.type);n!==r&&(Ce(Ie,t),Ce(Ue,r))}function Ke(t){Ie.current===t&&(J(Ue),J(Ie)),Ae.current===t&&(J(Ae),nl._currentValue=ne)}var zt,ht;function Et(t){if(zt===void 0)try{throw Error()}catch(r){var n=r.stack.trim().match(/\n( *(at )?)/);zt=n&&n[1]||"",ht=-1<r.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+zt+t+ht}var yt=!1;function St(t,n){if(!t||yt)return"";yt=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(n){var Re=function(){throw Error()};if(Object.defineProperty(Re.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Re,[])}catch(ve){var de=ve}Reflect.construct(t,[],Re)}else{try{Re.call()}catch(ve){de=ve}t.call(Re.prototype)}}else{try{throw Error()}catch(ve){de=ve}(Re=t())&&typeof Re.catch=="function"&&Re.catch(function(){})}}catch(ve){if(ve&&de&&typeof ve.stack=="string")return[ve.stack,de.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 d=o.DetermineComponentFrameRoot(),M=d[0],R=d[1];if(M&&R){var k=M.split(`
|
||
`),le=R.split(`
|
||
`);for(u=o=0;o<k.length&&!k[o].includes("DetermineComponentFrameRoot");)o++;for(;u<le.length&&!le[u].includes("DetermineComponentFrameRoot");)u++;if(o===k.length||u===le.length)for(o=k.length-1,u=le.length-1;1<=o&&0<=u&&k[o]!==le[u];)u--;for(;1<=o&&0<=u;o--,u--)if(k[o]!==le[u]){if(o!==1||u!==1)do if(o--,u--,0>u||k[o]!==le[u]){var be=`
|
||
`+k[o].replace(" at new "," at ");return t.displayName&&be.includes("<anonymous>")&&(be=be.replace("<anonymous>",t.displayName)),be}while(1<=o&&0<=u);break}}}finally{yt=!1,Error.prepareStackTrace=r}return(r=t?t.displayName||t.name:"")?Et(r):""}function Mt(t,n){switch(t.tag){case 26:case 27:case 5:return Et(t.type);case 16:return Et("Lazy");case 13:return t.child!==n&&n!==null?Et("Suspense Fallback"):Et("Suspense");case 19:return Et("SuspenseList");case 0:case 15:return St(t.type,!1);case 11:return St(t.type.render,!1);case 1:return St(t.type,!0);case 31:return Et("Activity");default:return""}}function Ht(t){try{var n="",r=null;do n+=Mt(t,r),r=t,t=t.return;while(t);return n}catch(o){return`
|
||
Error generating stack: `+o.message+`
|
||
`+o.stack}}var Gt=Object.prototype.hasOwnProperty,st=a.unstable_scheduleCallback,It=a.unstable_cancelCallback,W=a.unstable_shouldYield,z=a.unstable_requestPaint,Ye=a.unstable_now,xt=a.unstable_getCurrentPriorityLevel,I=a.unstable_ImmediatePriority,E=a.unstable_UserBlockingPriority,X=a.unstable_NormalPriority,se=a.unstable_LowPriority,me=a.unstable_IdlePriority,Ne=a.log,Oe=a.unstable_setDisableYieldValue,_e=null,he=null;function Le(t){if(typeof Ne=="function"&&Oe(t),he&&typeof he.setStrictMode=="function")try{he.setStrictMode(_e,t)}catch{}}var je=Math.clz32?Math.clz32:Qe,ze=Math.log,Fe=Math.LN2;function Qe(t){return t>>>=0,t===0?32:31-(ze(t)/Fe|0)|0}var Je=256,pt=262144,Z=4194304;function Pe(t){var n=t&42;if(n!==0)return n;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 Se(t,n,r){var o=t.pendingLanes;if(o===0)return 0;var u=0,d=t.suspendedLanes,M=t.pingedLanes;t=t.warmLanes;var R=o&134217727;return R!==0?(o=R&~d,o!==0?u=Pe(o):(M&=R,M!==0?u=Pe(M):r||(r=R&~t,r!==0&&(u=Pe(r))))):(R=o&~d,R!==0?u=Pe(R):M!==0?u=Pe(M):r||(r=o&~t,r!==0&&(u=Pe(r)))),u===0?0:n!==0&&n!==u&&(n&d)===0&&(d=u&-u,r=n&-n,d>=r||d===32&&(r&4194048)!==0)?n:u}function Be(t,n){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&n)===0}function ke(t,n){switch(t){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 q(){var t=Z;return Z<<=1,(Z&62914560)===0&&(Z=4194304),t}function Me(t){for(var n=[],r=0;31>r;r++)n.push(t);return n}function De(t,n){t.pendingLanes|=n,n!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function ft(t,n,r,o,u,d){var M=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 R=t.entanglements,k=t.expirationTimes,le=t.hiddenUpdates;for(r=M&~r;0<r;){var be=31-je(r),Re=1<<be;R[be]=0,k[be]=-1;var de=le[be];if(de!==null)for(le[be]=null,be=0;be<de.length;be++){var ve=de[be];ve!==null&&(ve.lane&=-536870913)}r&=~Re}o!==0&&rt(t,o,0),d!==0&&u===0&&t.tag!==0&&(t.suspendedLanes|=d&~(M&~n))}function rt(t,n,r){t.pendingLanes|=n,t.suspendedLanes&=~n;var o=31-je(n);t.entangledLanes|=n,t.entanglements[o]=t.entanglements[o]|1073741824|r&261930}function Nt(t,n){var r=t.entangledLanes|=n;for(t=t.entanglements;r;){var o=31-je(r),u=1<<o;u&n|t[o]&n&&(t[o]|=n),r&=~u}}function Hn(t,n){var r=n&-n;return r=(r&42)!==0?1:ua(r),(r&(t.suspendedLanes|n))!==0?0:r}function ua(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 Ga(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function Va(){var t=G.p;return t!==0?t:(t=window.event,t===void 0?32:D_(t.type))}function ka(t,n){var r=G.p;try{return G.p=t,n()}finally{G.p=r}}var re=Math.random().toString(36).slice(2),we="__reactFiber$"+re,Ge="__reactProps$"+re,it="__reactContainer$"+re,lt="__reactEvents$"+re,vt="__reactListeners$"+re,In="__reactHandles$"+re,Zt="__reactResources$"+re,hn="__reactMarker$"+re;function yn(t){delete t[we],delete t[Ge],delete t[lt],delete t[vt],delete t[In]}function fn(t){var n=t[we];if(n)return n;for(var r=t.parentNode;r;){if(n=r[it]||r[we]){if(r=n.alternate,n.child!==null||r!==null&&r.child!==null)for(t=p_(t);t!==null;){if(r=t[we])return r;t=p_(t)}return n}t=r,r=t.parentNode}return null}function Gn(t){if(t=t[we]||t[it]){var n=t.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return t}return null}function Bn(t){var n=t.tag;if(n===5||n===26||n===27||n===6)return t.stateNode;throw Error(s(33))}function Ti(t){var n=t[Zt];return n||(n=t[Zt]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Kt(t){t[hn]=!0}var Nl=new Set,w={};function Q(t,n){fe(t,n),fe(t+"Capture",n)}function fe(t,n){for(w[t]=n,t=0;t<n.length;t++)Nl.add(n[t])}var ce=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]*$"),ue={},Xe={};function Ze(t){return Gt.call(Xe,t)?!0:Gt.call(ue,t)?!1:ce.test(t)?Xe[t]=!0:(ue[t]=!0,!1)}function Ve(t,n,r){if(Ze(n))if(r===null)t.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":t.removeAttribute(n);return;case"boolean":var o=n.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){t.removeAttribute(n);return}}t.setAttribute(n,""+r)}}function et(t,n,r){if(r===null)t.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(n);return}t.setAttribute(n,""+r)}}function $e(t,n,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(n,r,""+o)}}function ct(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Ct(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function ot(t,n,r){var o=Object.getOwnPropertyDescriptor(t.constructor.prototype,n);if(!t.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,d=o.set;return Object.defineProperty(t,n,{configurable:!0,get:function(){return u.call(this)},set:function(M){r=""+M,d.call(this,M)}}),Object.defineProperty(t,n,{enumerable:o.enumerable}),{getValue:function(){return r},setValue:function(M){r=""+M},stopTracking:function(){t._valueTracker=null,delete t[n]}}}}function Xt(t){if(!t._valueTracker){var n=Ct(t)?"checked":"value";t._valueTracker=ot(t,n,""+t[n])}}function gn(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var r=n.getValue(),o="";return t&&(o=Ct(t)?t.checked?"true":"false":t.value),t=o,t!==r?(n.setValue(t),!0):!1}function cn(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 Qt=/[\n"\\]/g;function Jt(t){return t.replace(Qt,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function qe(t,n,r,o,u,d,M,R){t.name="",M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?t.type=M:t.removeAttribute("type"),n!=null?M==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+ct(n)):t.value!==""+ct(n)&&(t.value=""+ct(n)):M!=="submit"&&M!=="reset"||t.removeAttribute("value"),n!=null?Ut(t,M,ct(n)):r!=null?Ut(t,M,ct(r)):o!=null&&t.removeAttribute("value"),u==null&&d!=null&&(t.defaultChecked=!!d),u!=null&&(t.checked=u&&typeof u!="function"&&typeof u!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?t.name=""+ct(R):t.removeAttribute("name")}function qn(t,n,r,o,u,d,M,R){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(t.type=d),n!=null||r!=null){if(!(d!=="submit"&&d!=="reset"||n!=null)){Xt(t);return}r=r!=null?""+ct(r):"",n=n!=null?""+ct(n):r,R||n===t.value||(t.value=n),t.defaultValue=n}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,t.checked=R?t.checked:!!o,t.defaultChecked=!!o,M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(t.name=M),Xt(t)}function Ut(t,n,r){n==="number"&&cn(t.ownerDocument)===t||t.defaultValue===""+r||(t.defaultValue=""+r)}function Dn(t,n,r,o){if(t=t.options,n){n={};for(var u=0;u<r.length;u++)n["$"+r[u]]=!0;for(r=0;r<t.length;r++)u=n.hasOwnProperty("$"+t[r].value),t[r].selected!==u&&(t[r].selected=u),u&&o&&(t[r].defaultSelected=!0)}else{for(r=""+ct(r),n=null,u=0;u<t.length;u++){if(t[u].value===r){t[u].selected=!0,o&&(t[u].defaultSelected=!0);return}n!==null||t[u].disabled||(n=t[u])}n!==null&&(n.selected=!0)}}function di(t,n,r){if(n!=null&&(n=""+ct(n),n!==t.value&&(t.value=n),r==null)){t.defaultValue!==n&&(t.defaultValue=n);return}t.defaultValue=r!=null?""+ct(r):""}function zi(t,n,r,o){if(n==null){if(o!=null){if(r!=null)throw Error(s(92));if(K(o)){if(1<o.length)throw Error(s(93));o=o[0]}r=o}r==null&&(r=""),n=r}r=ct(n),t.defaultValue=r,o=t.textContent,o===r&&o!==""&&o!==null&&(t.value=o),Xt(t)}function hi(t,n){if(n){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=n;return}}t.textContent=n}var en=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 _n(t,n,r){var o=n.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?o?t.setProperty(n,""):n==="float"?t.cssFloat="":t[n]="":o?t.setProperty(n,r):typeof r!="number"||r===0||en.has(n)?n==="float"?t.cssFloat=r:t[n]=(""+r).trim():t[n]=r+"px"}function Hi(t,n,r){if(n!=null&&typeof n!="object")throw Error(s(62));if(t=t.style,r!=null){for(var o in r)!r.hasOwnProperty(o)||n!=null&&n.hasOwnProperty(o)||(o.indexOf("--")===0?t.setProperty(o,""):o==="float"?t.cssFloat="":t[o]="");for(var u in n)o=n[u],n.hasOwnProperty(u)&&r[u]!==o&&_n(t,u,o)}else for(var d in n)n.hasOwnProperty(d)&&_n(t,d,n[d])}function $t(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 $i=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"]]),ja=/^[\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 Rs(t){return ja.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function fa(){}var Fu=null;function zu(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var or=null,lr=null;function sm(t){var n=Gn(t);if(n&&(t=n.stateNode)){var r=t[Ge]||null;e:switch(t=n.stateNode,n.type){case"input":if(qe(t,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),n=r.name,r.type==="radio"&&n!=null){for(r=t;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+Jt(""+n)+'"][type="radio"]'),n=0;n<r.length;n++){var o=r[n];if(o!==t&&o.form===t.form){var u=o[Ge]||null;if(!u)throw Error(s(90));qe(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(n=0;n<r.length;n++)o=r[n],o.form===t.form&&gn(o)}break e;case"textarea":di(t,r.value,r.defaultValue);break e;case"select":n=r.value,n!=null&&Dn(t,!!r.multiple,n,!1)}}}var Hu=!1;function rm(t,n,r){if(Hu)return t(n,r);Hu=!0;try{var o=t(n);return o}finally{if(Hu=!1,(or!==null||lr!==null)&&(vc(),or&&(n=or,t=lr,lr=or=null,sm(n),t)))for(n=0;n<t.length;n++)sm(t[n])}}function xo(t,n){var r=t.stateNode;if(r===null)return null;var o=r[Ge]||null;if(o===null)return null;r=o[n];e:switch(n){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,n,typeof r));return r}var da=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gu=!1;if(da)try{var yo={};Object.defineProperty(yo,"passive",{get:function(){Gu=!0}}),window.addEventListener("test",yo,yo),window.removeEventListener("test",yo,yo)}catch{Gu=!1}var Xa=null,Vu=null,Ul=null;function om(){if(Ul)return Ul;var t,n=Vu,r=n.length,o,u="value"in Xa?Xa.value:Xa.textContent,d=u.length;for(t=0;t<r&&n[t]===u[t];t++);var M=r-t;for(o=1;o<=M&&n[r-o]===u[d-o];o++);return Ul=u.slice(t,1<o?1-o:void 0)}function Ll(t){var n=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&n===13&&(t=13)):t=n,t===10&&(t=13),32<=t||t===13?t:0}function Ol(){return!0}function lm(){return!1}function ti(t){function n(r,o,u,d,M){this._reactName=r,this._targetInst=u,this.type=o,this.nativeEvent=d,this.target=M,this.currentTarget=null;for(var R in t)t.hasOwnProperty(R)&&(r=t[R],this[R]=r?r(d):d[R]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?Ol:lm,this.isPropagationStopped=lm,this}return S(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=Ol)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=Ol)},persist:function(){},isPersistent:Ol}),n}var Ds={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Pl=ti(Ds),So=S({},Ds,{view:0,detail:0}),Ey=ti(So),ku,ju,Mo,Il=S({},So,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Wu,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!==Mo&&(Mo&&t.type==="mousemove"?(ku=t.screenX-Mo.screenX,ju=t.screenY-Mo.screenY):ju=ku=0,Mo=t),ku)},movementY:function(t){return"movementY"in t?t.movementY:ju}}),cm=ti(Il),Ty=S({},Il,{dataTransfer:0}),Ay=ti(Ty),Cy=S({},So,{relatedTarget:0}),Xu=ti(Cy),wy=S({},Ds,{animationName:0,elapsedTime:0,pseudoElement:0}),Ry=ti(wy),Dy=S({},Ds,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Ny=ti(Dy),Uy=S({},Ds,{data:0}),um=ti(Uy),Ly={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Oy={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"},Py={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Iy(t){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(t):(t=Py[t])?!!n[t]:!1}function Wu(){return Iy}var By=S({},So,{key:function(t){if(t.key){var n=Ly[t.key]||t.key;if(n!=="Unidentified")return n}return t.type==="keypress"?(t=Ll(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Oy[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Wu,charCode:function(t){return t.type==="keypress"?Ll(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ll(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Fy=ti(By),zy=S({},Il,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),fm=ti(zy),Hy=S({},So,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Wu}),Gy=ti(Hy),Vy=S({},Ds,{propertyName:0,elapsedTime:0,pseudoElement:0}),ky=ti(Vy),jy=S({},Il,{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}),Xy=ti(jy),Wy=S({},Ds,{newState:0,oldState:0}),qy=ti(Wy),Yy=[9,13,27,32],qu=da&&"CompositionEvent"in window,bo=null;da&&"documentMode"in document&&(bo=document.documentMode);var Zy=da&&"TextEvent"in window&&!bo,dm=da&&(!qu||bo&&8<bo&&11>=bo),hm=" ",pm=!1;function mm(t,n){switch(t){case"keyup":return Yy.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gm(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var cr=!1;function Ky(t,n){switch(t){case"compositionend":return gm(n);case"keypress":return n.which!==32?null:(pm=!0,hm);case"textInput":return t=n.data,t===hm&&pm?null:t;default:return null}}function $y(t,n){if(cr)return t==="compositionend"||!qu&&mm(t,n)?(t=om(),Ul=Vu=Xa=null,cr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return dm&&n.locale!=="ko"?null:n.data;default:return null}}var Qy={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 _m(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n==="input"?!!Qy[t.type]:n==="textarea"}function vm(t,n,r,o){or?lr?lr.push(o):lr=[o]:or=o,n=Tc(n,"onChange"),0<n.length&&(r=new Pl("onChange","change",null,r,o),t.push({event:r,listeners:n}))}var Eo=null,To=null;function Jy(t){e_(t,0)}function Bl(t){var n=Bn(t);if(gn(n))return t}function xm(t,n){if(t==="change")return n}var ym=!1;if(da){var Yu;if(da){var Zu="oninput"in document;if(!Zu){var Sm=document.createElement("div");Sm.setAttribute("oninput","return;"),Zu=typeof Sm.oninput=="function"}Yu=Zu}else Yu=!1;ym=Yu&&(!document.documentMode||9<document.documentMode)}function Mm(){Eo&&(Eo.detachEvent("onpropertychange",bm),To=Eo=null)}function bm(t){if(t.propertyName==="value"&&Bl(To)){var n=[];vm(n,To,t,zu(t)),rm(Jy,n)}}function eS(t,n,r){t==="focusin"?(Mm(),Eo=n,To=r,Eo.attachEvent("onpropertychange",bm)):t==="focusout"&&Mm()}function tS(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Bl(To)}function nS(t,n){if(t==="click")return Bl(n)}function iS(t,n){if(t==="input"||t==="change")return Bl(n)}function aS(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}var pi=typeof Object.is=="function"?Object.is:aS;function Ao(t,n){if(pi(t,n))return!0;if(typeof t!="object"||t===null||typeof n!="object"||n===null)return!1;var r=Object.keys(t),o=Object.keys(n);if(r.length!==o.length)return!1;for(o=0;o<r.length;o++){var u=r[o];if(!Gt.call(n,u)||!pi(t[u],n[u]))return!1}return!0}function Em(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Tm(t,n){var r=Em(t);t=0;for(var o;r;){if(r.nodeType===3){if(o=t+r.textContent.length,t<=n&&o>=n)return{node:r,offset:n-t};t=o}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Em(r)}}function Am(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?Am(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function Cm(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var n=cn(t.document);n instanceof t.HTMLIFrameElement;){try{var r=typeof n.contentWindow.location.href=="string"}catch{r=!1}if(r)t=n.contentWindow;else break;n=cn(t.document)}return n}function Ku(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}var sS=da&&"documentMode"in document&&11>=document.documentMode,ur=null,$u=null,Co=null,Qu=!1;function wm(t,n,r){var o=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Qu||ur==null||ur!==cn(o)||(o=ur,"selectionStart"in o&&Ku(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}),Co&&Ao(Co,o)||(Co=o,o=Tc($u,"onSelect"),0<o.length&&(n=new Pl("onSelect","select",null,n,r),t.push({event:n,listeners:o}),n.target=ur)))}function Ns(t,n){var r={};return r[t.toLowerCase()]=n.toLowerCase(),r["Webkit"+t]="webkit"+n,r["Moz"+t]="moz"+n,r}var fr={animationend:Ns("Animation","AnimationEnd"),animationiteration:Ns("Animation","AnimationIteration"),animationstart:Ns("Animation","AnimationStart"),transitionrun:Ns("Transition","TransitionRun"),transitionstart:Ns("Transition","TransitionStart"),transitioncancel:Ns("Transition","TransitionCancel"),transitionend:Ns("Transition","TransitionEnd")},Ju={},Rm={};da&&(Rm=document.createElement("div").style,"AnimationEvent"in window||(delete fr.animationend.animation,delete fr.animationiteration.animation,delete fr.animationstart.animation),"TransitionEvent"in window||delete fr.transitionend.transition);function Us(t){if(Ju[t])return Ju[t];if(!fr[t])return t;var n=fr[t],r;for(r in n)if(n.hasOwnProperty(r)&&r in Rm)return Ju[t]=n[r];return t}var Dm=Us("animationend"),Nm=Us("animationiteration"),Um=Us("animationstart"),rS=Us("transitionrun"),oS=Us("transitionstart"),lS=Us("transitioncancel"),Lm=Us("transitionend"),Om=new Map,ef="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(" ");ef.push("scrollEnd");function Gi(t,n){Om.set(t,n),Q(n,[t])}var Fl=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=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(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},Ai=[],dr=0,tf=0;function zl(){for(var t=dr,n=tf=dr=0;n<t;){var r=Ai[n];Ai[n++]=null;var o=Ai[n];Ai[n++]=null;var u=Ai[n];Ai[n++]=null;var d=Ai[n];if(Ai[n++]=null,o!==null&&u!==null){var M=o.pending;M===null?u.next=u:(u.next=M.next,M.next=u),o.pending=u}d!==0&&Pm(r,u,d)}}function Hl(t,n,r,o){Ai[dr++]=t,Ai[dr++]=n,Ai[dr++]=r,Ai[dr++]=o,tf|=o,t.lanes|=o,t=t.alternate,t!==null&&(t.lanes|=o)}function nf(t,n,r,o){return Hl(t,n,r,o),Gl(t)}function Ls(t,n){return Hl(t,null,null,n),Gl(t)}function Pm(t,n,r){t.lanes|=r;var o=t.alternate;o!==null&&(o.lanes|=r);for(var u=!1,d=t.return;d!==null;)d.childLanes|=r,o=d.alternate,o!==null&&(o.childLanes|=r),d.tag===22&&(t=d.stateNode,t===null||t._visibility&1||(u=!0)),t=d,d=d.return;return t.tag===3?(d=t.stateNode,u&&n!==null&&(u=31-je(r),t=d.hiddenUpdates,o=t[u],o===null?t[u]=[n]:o.push(n),n.lane=r|536870912),d):null}function Gl(t){if(50<Zo)throw Zo=0,dd=null,Error(s(185));for(var n=t.return;n!==null;)t=n,n=t.return;return t.tag===3?t.stateNode:null}var hr={};function cS(t,n,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=n,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 mi(t,n,r,o){return new cS(t,n,r,o)}function af(t){return t=t.prototype,!(!t||!t.isReactComponent)}function ha(t,n){var r=t.alternate;return r===null?(r=mi(t.tag,n,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=n,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,n=t.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r.refCleanup=t.refCleanup,r}function Im(t,n){t.flags&=65011714;var r=t.alternate;return r===null?(t.childLanes=0,t.lanes=n,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,n=r.dependencies,t.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),t}function Vl(t,n,r,o,u,d){var M=0;if(o=t,typeof t=="function")af(t)&&(M=1);else if(typeof t=="string")M=pM(t,r,Ue.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case L:return t=mi(31,r,n,u),t.elementType=L,t.lanes=d,t;case C:return Os(r.children,u,d,n);case v:M=8,u|=24;break;case x:return t=mi(12,r,n,u|2),t.elementType=x,t.lanes=d,t;case O:return t=mi(13,r,n,u),t.elementType=O,t.lanes=d,t;case U:return t=mi(19,r,n,u),t.elementType=U,t.lanes=d,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case P:M=10;break e;case B:M=9;break e;case D:M=11;break e;case N:M=14;break e;case A:M=16,o=null;break e}M=29,r=Error(s(130,t===null?"null":typeof t,"")),o=null}return n=mi(M,r,n,u),n.elementType=t,n.type=o,n.lanes=d,n}function Os(t,n,r,o){return t=mi(7,t,o,n),t.lanes=r,t}function sf(t,n,r){return t=mi(6,t,null,n),t.lanes=r,t}function Bm(t){var n=mi(18,null,null,0);return n.stateNode=t,n}function rf(t,n,r){return n=mi(4,t.children!==null?t.children:[],t.key,n),n.lanes=r,n.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},n}var Fm=new WeakMap;function Ci(t,n){if(typeof t=="object"&&t!==null){var r=Fm.get(t);return r!==void 0?r:(n={value:t,source:n,stack:Ht(n)},Fm.set(t,n),n)}return{value:t,source:n,stack:Ht(n)}}var pr=[],mr=0,kl=null,wo=0,wi=[],Ri=0,Wa=null,Qi=1,Ji="";function pa(t,n){pr[mr++]=wo,pr[mr++]=kl,kl=t,wo=n}function zm(t,n,r){wi[Ri++]=Qi,wi[Ri++]=Ji,wi[Ri++]=Wa,Wa=t;var o=Qi;t=Ji;var u=32-je(o)-1;o&=~(1<<u),r+=1;var d=32-je(n)+u;if(30<d){var M=u-u%5;d=(o&(1<<M)-1).toString(32),o>>=M,u-=M,Qi=1<<32-je(n)+u|r<<u|o,Ji=d+t}else Qi=1<<d|r<<u|o,Ji=t}function of(t){t.return!==null&&(pa(t,1),zm(t,1,0))}function lf(t){for(;t===kl;)kl=pr[--mr],pr[mr]=null,wo=pr[--mr],pr[mr]=null;for(;t===Wa;)Wa=wi[--Ri],wi[Ri]=null,Ji=wi[--Ri],wi[Ri]=null,Qi=wi[--Ri],wi[Ri]=null}function Hm(t,n){wi[Ri++]=Qi,wi[Ri++]=Ji,wi[Ri++]=Wa,Qi=n.id,Ji=n.overflow,Wa=t}var Vn=null,pn=null,Vt=!1,qa=null,Di=!1,cf=Error(s(519));function Ya(t){var n=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ro(Ci(n,t)),cf}function Gm(t){var n=t.stateNode,r=t.type,o=t.memoizedProps;switch(n[we]=t,n[Ge]=o,r){case"dialog":Ot("cancel",n),Ot("close",n);break;case"iframe":case"object":case"embed":Ot("load",n);break;case"video":case"audio":for(r=0;r<$o.length;r++)Ot($o[r],n);break;case"source":Ot("error",n);break;case"img":case"image":case"link":Ot("error",n),Ot("load",n);break;case"details":Ot("toggle",n);break;case"input":Ot("invalid",n),qn(n,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":Ot("invalid",n);break;case"textarea":Ot("invalid",n),zi(n,o.value,o.defaultValue,o.children)}r=o.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||n.textContent===""+r||o.suppressHydrationWarning===!0||a_(n.textContent,r)?(o.popover!=null&&(Ot("beforetoggle",n),Ot("toggle",n)),o.onScroll!=null&&Ot("scroll",n),o.onScrollEnd!=null&&Ot("scrollend",n),o.onClick!=null&&(n.onclick=fa),n=!0):n=!1,n||Ya(t,!0)}function Vm(t){for(Vn=t.return;Vn;)switch(Vn.tag){case 5:case 31:case 13:Di=!1;return;case 27:case 3:Di=!0;return;default:Vn=Vn.return}}function gr(t){if(t!==Vn)return!1;if(!Vt)return Vm(t),Vt=!0,!1;var n=t.tag,r;if((r=n!==3&&n!==27)&&((r=n===5)&&(r=t.type,r=!(r!=="form"&&r!=="button")||Cd(t.type,t.memoizedProps)),r=!r),r&&pn&&Ya(t),Vm(t),n===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));pn=h_(t)}else if(n===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));pn=h_(t)}else n===27?(n=pn,ls(t.type)?(t=Ud,Ud=null,pn=t):pn=n):pn=Vn?Ui(t.stateNode.nextSibling):null;return!0}function Ps(){pn=Vn=null,Vt=!1}function uf(){var t=qa;return t!==null&&(si===null?si=t:si.push.apply(si,t),qa=null),t}function Ro(t){qa===null?qa=[t]:qa.push(t)}var ff=F(null),Is=null,ma=null;function Za(t,n,r){Ce(ff,n._currentValue),n._currentValue=r}function ga(t){t._currentValue=ff.current,J(ff)}function df(t,n,r){for(;t!==null;){var o=t.alternate;if((t.childLanes&n)!==n?(t.childLanes|=n,o!==null&&(o.childLanes|=n)):o!==null&&(o.childLanes&n)!==n&&(o.childLanes|=n),t===r)break;t=t.return}}function hf(t,n,r,o){var u=t.child;for(u!==null&&(u.return=t);u!==null;){var d=u.dependencies;if(d!==null){var M=u.child;d=d.firstContext;e:for(;d!==null;){var R=d;d=u;for(var k=0;k<n.length;k++)if(R.context===n[k]){d.lanes|=r,R=d.alternate,R!==null&&(R.lanes|=r),df(d.return,r,t),o||(M=null);break e}d=R.next}}else if(u.tag===18){if(M=u.return,M===null)throw Error(s(341));M.lanes|=r,d=M.alternate,d!==null&&(d.lanes|=r),df(M,r,t),M=null}else M=u.child;if(M!==null)M.return=u;else for(M=u;M!==null;){if(M===t){M=null;break}if(u=M.sibling,u!==null){u.return=M.return,M=u;break}M=M.return}u=M}}function _r(t,n,r,o){t=null;for(var u=n,d=!1;u!==null;){if(!d){if((u.flags&524288)!==0)d=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var M=u.alternate;if(M===null)throw Error(s(387));if(M=M.memoizedProps,M!==null){var R=u.type;pi(u.pendingProps.value,M.value)||(t!==null?t.push(R):t=[R])}}else if(u===Ae.current){if(M=u.alternate,M===null)throw Error(s(387));M.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(t!==null?t.push(nl):t=[nl])}u=u.return}t!==null&&hf(n,t,r,o),n.flags|=262144}function jl(t){for(t=t.firstContext;t!==null;){if(!pi(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function Bs(t){Is=t,ma=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function kn(t){return km(Is,t)}function Xl(t,n){return Is===null&&Bs(t),km(t,n)}function km(t,n){var r=n._currentValue;if(n={context:n,memoizedValue:r,next:null},ma===null){if(t===null)throw Error(s(308));ma=n,t.dependencies={lanes:0,firstContext:n},t.flags|=524288}else ma=ma.next=n;return r}var uS=typeof AbortController<"u"?AbortController:function(){var t=[],n=this.signal={aborted:!1,addEventListener:function(r,o){t.push(o)}};this.abort=function(){n.aborted=!0,t.forEach(function(r){return r()})}},fS=a.unstable_scheduleCallback,dS=a.unstable_NormalPriority,Tn={$$typeof:P,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function pf(){return{controller:new uS,data:new Map,refCount:0}}function Do(t){t.refCount--,t.refCount===0&&fS(dS,function(){t.controller.abort()})}var No=null,mf=0,vr=0,xr=null;function hS(t,n){if(No===null){var r=No=[];mf=0,vr=vd(),xr={status:"pending",value:void 0,then:function(o){r.push(o)}}}return mf++,n.then(jm,jm),n}function jm(){if(--mf===0&&No!==null){xr!==null&&(xr.status="fulfilled");var t=No;No=null,vr=0,xr=null;for(var n=0;n<t.length;n++)(0,t[n])()}}function pS(t,n){var r=[],o={status:"pending",value:null,reason:null,then:function(u){r.push(u)}};return t.then(function(){o.status="fulfilled",o.value=n;for(var u=0;u<r.length;u++)(0,r[u])(n)},function(u){for(o.status="rejected",o.reason=u,u=0;u<r.length;u++)(0,r[u])(void 0)}),o}var Xm=H.S;H.S=function(t,n){w0=Ye(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&hS(t,n),Xm!==null&&Xm(t,n)};var Fs=F(null);function gf(){var t=Fs.current;return t!==null?t:un.pooledCache}function Wl(t,n){n===null?Ce(Fs,Fs.current):Ce(Fs,n.pool)}function Wm(){var t=gf();return t===null?null:{parent:Tn._currentValue,pool:t}}var yr=Error(s(460)),_f=Error(s(474)),ql=Error(s(542)),Yl={then:function(){}};function qm(t){return t=t.status,t==="fulfilled"||t==="rejected"}function Ym(t,n,r){switch(r=t[r],r===void 0?t.push(n):r!==n&&(n.then(fa,fa),n=r),n.status){case"fulfilled":return n.value;case"rejected":throw t=n.reason,Km(t),t;default:if(typeof n.status=="string")n.then(fa,fa);else{if(t=un,t!==null&&100<t.shellSuspendCounter)throw Error(s(482));t=n,t.status="pending",t.then(function(o){if(n.status==="pending"){var u=n;u.status="fulfilled",u.value=o}},function(o){if(n.status==="pending"){var u=n;u.status="rejected",u.reason=o}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw t=n.reason,Km(t),t}throw Hs=n,yr}}function zs(t){try{var n=t._init;return n(t._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(Hs=r,yr):r}}var Hs=null;function Zm(){if(Hs===null)throw Error(s(459));var t=Hs;return Hs=null,t}function Km(t){if(t===yr||t===ql)throw Error(s(483))}var Sr=null,Uo=0;function Zl(t){var n=Uo;return Uo+=1,Sr===null&&(Sr=[]),Ym(Sr,t,n)}function Lo(t,n){n=n.props.ref,t.ref=n!==void 0?n:null}function Kl(t,n){throw n.$$typeof===_?Error(s(525)):(t=Object.prototype.toString.call(n),Error(s(31,t==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":t)))}function $m(t){function n(te,Y){if(t){var oe=te.deletions;oe===null?(te.deletions=[Y],te.flags|=16):oe.push(Y)}}function r(te,Y){if(!t)return null;for(;Y!==null;)n(te,Y),Y=Y.sibling;return null}function o(te){for(var Y=new Map;te!==null;)te.key!==null?Y.set(te.key,te):Y.set(te.index,te),te=te.sibling;return Y}function u(te,Y){return te=ha(te,Y),te.index=0,te.sibling=null,te}function d(te,Y,oe){return te.index=oe,t?(oe=te.alternate,oe!==null?(oe=oe.index,oe<Y?(te.flags|=67108866,Y):oe):(te.flags|=67108866,Y)):(te.flags|=1048576,Y)}function M(te){return t&&te.alternate===null&&(te.flags|=67108866),te}function R(te,Y,oe,Te){return Y===null||Y.tag!==6?(Y=sf(oe,te.mode,Te),Y.return=te,Y):(Y=u(Y,oe),Y.return=te,Y)}function k(te,Y,oe,Te){var ut=oe.type;return ut===C?be(te,Y,oe.props.children,Te,oe.key):Y!==null&&(Y.elementType===ut||typeof ut=="object"&&ut!==null&&ut.$$typeof===A&&zs(ut)===Y.type)?(Y=u(Y,oe.props),Lo(Y,oe),Y.return=te,Y):(Y=Vl(oe.type,oe.key,oe.props,null,te.mode,Te),Lo(Y,oe),Y.return=te,Y)}function le(te,Y,oe,Te){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==oe.containerInfo||Y.stateNode.implementation!==oe.implementation?(Y=rf(oe,te.mode,Te),Y.return=te,Y):(Y=u(Y,oe.children||[]),Y.return=te,Y)}function be(te,Y,oe,Te,ut){return Y===null||Y.tag!==7?(Y=Os(oe,te.mode,Te,ut),Y.return=te,Y):(Y=u(Y,oe),Y.return=te,Y)}function Re(te,Y,oe){if(typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint")return Y=sf(""+Y,te.mode,oe),Y.return=te,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case b:return oe=Vl(Y.type,Y.key,Y.props,null,te.mode,oe),Lo(oe,Y),oe.return=te,oe;case T:return Y=rf(Y,te.mode,oe),Y.return=te,Y;case A:return Y=zs(Y),Re(te,Y,oe)}if(K(Y)||$(Y))return Y=Os(Y,te.mode,oe,null),Y.return=te,Y;if(typeof Y.then=="function")return Re(te,Zl(Y),oe);if(Y.$$typeof===P)return Re(te,Xl(te,Y),oe);Kl(te,Y)}return null}function de(te,Y,oe,Te){var ut=Y!==null?Y.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return ut!==null?null:R(te,Y,""+oe,Te);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case b:return oe.key===ut?k(te,Y,oe,Te):null;case T:return oe.key===ut?le(te,Y,oe,Te):null;case A:return oe=zs(oe),de(te,Y,oe,Te)}if(K(oe)||$(oe))return ut!==null?null:be(te,Y,oe,Te,null);if(typeof oe.then=="function")return de(te,Y,Zl(oe),Te);if(oe.$$typeof===P)return de(te,Y,Xl(te,oe),Te);Kl(te,oe)}return null}function ve(te,Y,oe,Te,ut){if(typeof Te=="string"&&Te!==""||typeof Te=="number"||typeof Te=="bigint")return te=te.get(oe)||null,R(Y,te,""+Te,ut);if(typeof Te=="object"&&Te!==null){switch(Te.$$typeof){case b:return te=te.get(Te.key===null?oe:Te.key)||null,k(Y,te,Te,ut);case T:return te=te.get(Te.key===null?oe:Te.key)||null,le(Y,te,Te,ut);case A:return Te=zs(Te),ve(te,Y,oe,Te,ut)}if(K(Te)||$(Te))return te=te.get(oe)||null,be(Y,te,Te,ut,null);if(typeof Te.then=="function")return ve(te,Y,oe,Zl(Te),ut);if(Te.$$typeof===P)return ve(te,Y,oe,Xl(Y,Te),ut);Kl(Y,Te)}return null}function tt(te,Y,oe,Te){for(var ut=null,Wt=null,at=Y,Rt=Y=0,Ft=null;at!==null&&Rt<oe.length;Rt++){at.index>Rt?(Ft=at,at=null):Ft=at.sibling;var qt=de(te,at,oe[Rt],Te);if(qt===null){at===null&&(at=Ft);break}t&&at&&qt.alternate===null&&n(te,at),Y=d(qt,Y,Rt),Wt===null?ut=qt:Wt.sibling=qt,Wt=qt,at=Ft}if(Rt===oe.length)return r(te,at),Vt&&pa(te,Rt),ut;if(at===null){for(;Rt<oe.length;Rt++)at=Re(te,oe[Rt],Te),at!==null&&(Y=d(at,Y,Rt),Wt===null?ut=at:Wt.sibling=at,Wt=at);return Vt&&pa(te,Rt),ut}for(at=o(at);Rt<oe.length;Rt++)Ft=ve(at,te,Rt,oe[Rt],Te),Ft!==null&&(t&&Ft.alternate!==null&&at.delete(Ft.key===null?Rt:Ft.key),Y=d(Ft,Y,Rt),Wt===null?ut=Ft:Wt.sibling=Ft,Wt=Ft);return t&&at.forEach(function(hs){return n(te,hs)}),Vt&&pa(te,Rt),ut}function mt(te,Y,oe,Te){if(oe==null)throw Error(s(151));for(var ut=null,Wt=null,at=Y,Rt=Y=0,Ft=null,qt=oe.next();at!==null&&!qt.done;Rt++,qt=oe.next()){at.index>Rt?(Ft=at,at=null):Ft=at.sibling;var hs=de(te,at,qt.value,Te);if(hs===null){at===null&&(at=Ft);break}t&&at&&hs.alternate===null&&n(te,at),Y=d(hs,Y,Rt),Wt===null?ut=hs:Wt.sibling=hs,Wt=hs,at=Ft}if(qt.done)return r(te,at),Vt&&pa(te,Rt),ut;if(at===null){for(;!qt.done;Rt++,qt=oe.next())qt=Re(te,qt.value,Te),qt!==null&&(Y=d(qt,Y,Rt),Wt===null?ut=qt:Wt.sibling=qt,Wt=qt);return Vt&&pa(te,Rt),ut}for(at=o(at);!qt.done;Rt++,qt=oe.next())qt=ve(at,te,Rt,qt.value,Te),qt!==null&&(t&&qt.alternate!==null&&at.delete(qt.key===null?Rt:qt.key),Y=d(qt,Y,Rt),Wt===null?ut=qt:Wt.sibling=qt,Wt=qt);return t&&at.forEach(function(TM){return n(te,TM)}),Vt&&pa(te,Rt),ut}function on(te,Y,oe,Te){if(typeof oe=="object"&&oe!==null&&oe.type===C&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case b:e:{for(var ut=oe.key;Y!==null;){if(Y.key===ut){if(ut=oe.type,ut===C){if(Y.tag===7){r(te,Y.sibling),Te=u(Y,oe.props.children),Te.return=te,te=Te;break e}}else if(Y.elementType===ut||typeof ut=="object"&&ut!==null&&ut.$$typeof===A&&zs(ut)===Y.type){r(te,Y.sibling),Te=u(Y,oe.props),Lo(Te,oe),Te.return=te,te=Te;break e}r(te,Y);break}else n(te,Y);Y=Y.sibling}oe.type===C?(Te=Os(oe.props.children,te.mode,Te,oe.key),Te.return=te,te=Te):(Te=Vl(oe.type,oe.key,oe.props,null,te.mode,Te),Lo(Te,oe),Te.return=te,te=Te)}return M(te);case T:e:{for(ut=oe.key;Y!==null;){if(Y.key===ut)if(Y.tag===4&&Y.stateNode.containerInfo===oe.containerInfo&&Y.stateNode.implementation===oe.implementation){r(te,Y.sibling),Te=u(Y,oe.children||[]),Te.return=te,te=Te;break e}else{r(te,Y);break}else n(te,Y);Y=Y.sibling}Te=rf(oe,te.mode,Te),Te.return=te,te=Te}return M(te);case A:return oe=zs(oe),on(te,Y,oe,Te)}if(K(oe))return tt(te,Y,oe,Te);if($(oe)){if(ut=$(oe),typeof ut!="function")throw Error(s(150));return oe=ut.call(oe),mt(te,Y,oe,Te)}if(typeof oe.then=="function")return on(te,Y,Zl(oe),Te);if(oe.$$typeof===P)return on(te,Y,Xl(te,oe),Te);Kl(te,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint"?(oe=""+oe,Y!==null&&Y.tag===6?(r(te,Y.sibling),Te=u(Y,oe),Te.return=te,te=Te):(r(te,Y),Te=sf(oe,te.mode,Te),Te.return=te,te=Te),M(te)):r(te,Y)}return function(te,Y,oe,Te){try{Uo=0;var ut=on(te,Y,oe,Te);return Sr=null,ut}catch(at){if(at===yr||at===ql)throw at;var Wt=mi(29,at,null,te.mode);return Wt.lanes=Te,Wt.return=te,Wt}}}var Gs=$m(!0),Qm=$m(!1),Ka=!1;function vf(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xf(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function $a(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Qa(t,n,r){var o=t.updateQueue;if(o===null)return null;if(o=o.shared,(Yt&2)!==0){var u=o.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),o.pending=n,n=Gl(t),Pm(t,null,r),n}return Hl(t,o,n,r),Gl(t)}function Oo(t,n,r){if(n=n.updateQueue,n!==null&&(n=n.shared,(r&4194048)!==0)){var o=n.lanes;o&=t.pendingLanes,r|=o,n.lanes=r,Nt(t,r)}}function yf(t,n){var r=t.updateQueue,o=t.alternate;if(o!==null&&(o=o.updateQueue,r===o)){var u=null,d=null;if(r=r.firstBaseUpdate,r!==null){do{var M={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};d===null?u=d=M:d=d.next=M,r=r.next}while(r!==null);d===null?u=d=n:d=d.next=n}else u=d=n;r={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:o.shared,callbacks:o.callbacks},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=n:t.next=n,r.lastBaseUpdate=n}var Sf=!1;function Po(){if(Sf){var t=xr;if(t!==null)throw t}}function Io(t,n,r,o){Sf=!1;var u=t.updateQueue;Ka=!1;var d=u.firstBaseUpdate,M=u.lastBaseUpdate,R=u.shared.pending;if(R!==null){u.shared.pending=null;var k=R,le=k.next;k.next=null,M===null?d=le:M.next=le,M=k;var be=t.alternate;be!==null&&(be=be.updateQueue,R=be.lastBaseUpdate,R!==M&&(R===null?be.firstBaseUpdate=le:R.next=le,be.lastBaseUpdate=k))}if(d!==null){var Re=u.baseState;M=0,be=le=k=null,R=d;do{var de=R.lane&-536870913,ve=de!==R.lane;if(ve?(Bt&de)===de:(o&de)===de){de!==0&&de===vr&&(Sf=!0),be!==null&&(be=be.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var tt=t,mt=R;de=n;var on=r;switch(mt.tag){case 1:if(tt=mt.payload,typeof tt=="function"){Re=tt.call(on,Re,de);break e}Re=tt;break e;case 3:tt.flags=tt.flags&-65537|128;case 0:if(tt=mt.payload,de=typeof tt=="function"?tt.call(on,Re,de):tt,de==null)break e;Re=S({},Re,de);break e;case 2:Ka=!0}}de=R.callback,de!==null&&(t.flags|=64,ve&&(t.flags|=8192),ve=u.callbacks,ve===null?u.callbacks=[de]:ve.push(de))}else ve={lane:de,tag:R.tag,payload:R.payload,callback:R.callback,next:null},be===null?(le=be=ve,k=Re):be=be.next=ve,M|=de;if(R=R.next,R===null){if(R=u.shared.pending,R===null)break;ve=R,R=ve.next,ve.next=null,u.lastBaseUpdate=ve,u.shared.pending=null}}while(!0);be===null&&(k=Re),u.baseState=k,u.firstBaseUpdate=le,u.lastBaseUpdate=be,d===null&&(u.shared.lanes=0),is|=M,t.lanes=M,t.memoizedState=Re}}function Jm(t,n){if(typeof t!="function")throw Error(s(191,t));t.call(n)}function eg(t,n){var r=t.callbacks;if(r!==null)for(t.callbacks=null,t=0;t<r.length;t++)Jm(r[t],n)}var Mr=F(null),$l=F(0);function tg(t,n){t=Ta,Ce($l,t),Ce(Mr,n),Ta=t|n.baseLanes}function Mf(){Ce($l,Ta),Ce(Mr,Mr.current)}function bf(){Ta=$l.current,J(Mr),J($l)}var gi=F(null),Ni=null;function Ja(t){var n=t.alternate;Ce(bn,bn.current&1),Ce(gi,t),Ni===null&&(n===null||Mr.current!==null||n.memoizedState!==null)&&(Ni=t)}function Ef(t){Ce(bn,bn.current),Ce(gi,t),Ni===null&&(Ni=t)}function ng(t){t.tag===22?(Ce(bn,bn.current),Ce(gi,t),Ni===null&&(Ni=t)):es()}function es(){Ce(bn,bn.current),Ce(gi,gi.current)}function _i(t){J(gi),Ni===t&&(Ni=null),J(bn)}var bn=F(0);function Ql(t){for(var n=t;n!==null;){if(n.tag===13){var r=n.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||Dd(r)||Nd(r)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var _a=0,wt=null,sn=null,An=null,Jl=!1,br=!1,Vs=!1,ec=0,Bo=0,Er=null,mS=0;function Sn(){throw Error(s(321))}function Tf(t,n){if(n===null)return!1;for(var r=0;r<n.length&&r<t.length;r++)if(!pi(t[r],n[r]))return!1;return!0}function Af(t,n,r,o,u,d){return _a=d,wt=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,H.H=t===null||t.memoizedState===null?zg:Gf,Vs=!1,d=r(o,u),Vs=!1,br&&(d=ag(n,r,o,u)),ig(t),d}function ig(t){H.H=Ho;var n=sn!==null&&sn.next!==null;if(_a=0,An=sn=wt=null,Jl=!1,Bo=0,Er=null,n)throw Error(s(300));t===null||Cn||(t=t.dependencies,t!==null&&jl(t)&&(Cn=!0))}function ag(t,n,r,o){wt=t;var u=0;do{if(br&&(Er=null),Bo=0,br=!1,25<=u)throw Error(s(301));if(u+=1,An=sn=null,t.updateQueue!=null){var d=t.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}H.H=Hg,d=n(r,o)}while(br);return d}function gS(){var t=H.H,n=t.useState()[0];return n=typeof n.then=="function"?Fo(n):n,t=t.useState()[0],(sn!==null?sn.memoizedState:null)!==t&&(wt.flags|=1024),n}function Cf(){var t=ec!==0;return ec=0,t}function wf(t,n,r){n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~r}function Rf(t){if(Jl){for(t=t.memoizedState;t!==null;){var n=t.queue;n!==null&&(n.pending=null),t=t.next}Jl=!1}_a=0,An=sn=wt=null,br=!1,Bo=ec=0,Er=null}function Qn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return An===null?wt.memoizedState=An=t:An=An.next=t,An}function En(){if(sn===null){var t=wt.alternate;t=t!==null?t.memoizedState:null}else t=sn.next;var n=An===null?wt.memoizedState:An.next;if(n!==null)An=n,sn=t;else{if(t===null)throw wt.alternate===null?Error(s(467)):Error(s(310));sn=t,t={memoizedState:sn.memoizedState,baseState:sn.baseState,baseQueue:sn.baseQueue,queue:sn.queue,next:null},An===null?wt.memoizedState=An=t:An=An.next=t}return An}function tc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Fo(t){var n=Bo;return Bo+=1,Er===null&&(Er=[]),t=Ym(Er,t,n),n=wt,(An===null?n.memoizedState:An.next)===null&&(n=n.alternate,H.H=n===null||n.memoizedState===null?zg:Gf),t}function nc(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Fo(t);if(t.$$typeof===P)return kn(t)}throw Error(s(438,String(t)))}function Df(t){var n=null,r=wt.updateQueue;if(r!==null&&(n=r.memoCache),n==null){var o=wt.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(n={data:o.data.map(function(u){return u.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),r===null&&(r=tc(),wt.updateQueue=r),r.memoCache=n,r=n.data[n.index],r===void 0)for(r=n.data[n.index]=Array(t),o=0;o<t;o++)r[o]=j;return n.index++,r}function va(t,n){return typeof n=="function"?n(t):n}function ic(t){var n=En();return Nf(n,sn,t)}function Nf(t,n,r){var o=t.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=r;var u=t.baseQueue,d=o.pending;if(d!==null){if(u!==null){var M=u.next;u.next=d.next,d.next=M}n.baseQueue=u=d,o.pending=null}if(d=t.baseState,u===null)t.memoizedState=d;else{n=u.next;var R=M=null,k=null,le=n,be=!1;do{var Re=le.lane&-536870913;if(Re!==le.lane?(Bt&Re)===Re:(_a&Re)===Re){var de=le.revertLane;if(de===0)k!==null&&(k=k.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),Re===vr&&(be=!0);else if((_a&de)===de){le=le.next,de===vr&&(be=!0);continue}else Re={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},k===null?(R=k=Re,M=d):k=k.next=Re,wt.lanes|=de,is|=de;Re=le.action,Vs&&r(d,Re),d=le.hasEagerState?le.eagerState:r(d,Re)}else de={lane:Re,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},k===null?(R=k=de,M=d):k=k.next=de,wt.lanes|=Re,is|=Re;le=le.next}while(le!==null&&le!==n);if(k===null?M=d:k.next=R,!pi(d,t.memoizedState)&&(Cn=!0,be&&(r=xr,r!==null)))throw r;t.memoizedState=d,t.baseState=M,t.baseQueue=k,o.lastRenderedState=d}return u===null&&(o.lanes=0),[t.memoizedState,o.dispatch]}function Uf(t){var n=En(),r=n.queue;if(r===null)throw Error(s(311));r.lastRenderedReducer=t;var o=r.dispatch,u=r.pending,d=n.memoizedState;if(u!==null){r.pending=null;var M=u=u.next;do d=t(d,M.action),M=M.next;while(M!==u);pi(d,n.memoizedState)||(Cn=!0),n.memoizedState=d,n.baseQueue===null&&(n.baseState=d),r.lastRenderedState=d}return[d,o]}function sg(t,n,r){var o=wt,u=En(),d=Vt;if(d){if(r===void 0)throw Error(s(407));r=r()}else r=n();var M=!pi((sn||u).memoizedState,r);if(M&&(u.memoizedState=r,Cn=!0),u=u.queue,Pf(lg.bind(null,o,u,t),[t]),u.getSnapshot!==n||M||An!==null&&An.memoizedState.tag&1){if(o.flags|=2048,Tr(9,{destroy:void 0},og.bind(null,o,u,r,n),null),un===null)throw Error(s(349));d||(_a&127)!==0||rg(o,n,r)}return r}function rg(t,n,r){t.flags|=16384,t={getSnapshot:n,value:r},n=wt.updateQueue,n===null?(n=tc(),wt.updateQueue=n,n.stores=[t]):(r=n.stores,r===null?n.stores=[t]:r.push(t))}function og(t,n,r,o){n.value=r,n.getSnapshot=o,cg(n)&&ug(t)}function lg(t,n,r){return r(function(){cg(n)&&ug(t)})}function cg(t){var n=t.getSnapshot;t=t.value;try{var r=n();return!pi(t,r)}catch{return!0}}function ug(t){var n=Ls(t,2);n!==null&&ri(n,t,2)}function Lf(t){var n=Qn();if(typeof t=="function"){var r=t;if(t=r(),Vs){Le(!0);try{r()}finally{Le(!1)}}}return n.memoizedState=n.baseState=t,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:va,lastRenderedState:t},n}function fg(t,n,r,o){return t.baseState=r,Nf(t,sn,typeof o=="function"?o:va)}function _S(t,n,r,o,u){if(rc(t))throw Error(s(485));if(t=n.action,t!==null){var d={payload:u,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(M){d.listeners.push(M)}};H.T!==null?r(!0):d.isTransition=!1,o(d),r=n.pending,r===null?(d.next=n.pending=d,dg(n,d)):(d.next=r.next,n.pending=r.next=d)}}function dg(t,n){var r=n.action,o=n.payload,u=t.state;if(n.isTransition){var d=H.T,M={};H.T=M;try{var R=r(u,o),k=H.S;k!==null&&k(M,R),hg(t,n,R)}catch(le){Of(t,n,le)}finally{d!==null&&M.types!==null&&(d.types=M.types),H.T=d}}else try{d=r(u,o),hg(t,n,d)}catch(le){Of(t,n,le)}}function hg(t,n,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(o){pg(t,n,o)},function(o){return Of(t,n,o)}):pg(t,n,r)}function pg(t,n,r){n.status="fulfilled",n.value=r,mg(n),t.state=r,n=t.pending,n!==null&&(r=n.next,r===n?t.pending=null:(r=r.next,n.next=r,dg(t,r)))}function Of(t,n,r){var o=t.pending;if(t.pending=null,o!==null){o=o.next;do n.status="rejected",n.reason=r,mg(n),n=n.next;while(n!==o)}t.action=null}function mg(t){t=t.listeners;for(var n=0;n<t.length;n++)(0,t[n])()}function gg(t,n){return n}function _g(t,n){if(Vt){var r=un.formState;if(r!==null){e:{var o=wt;if(Vt){if(pn){t:{for(var u=pn,d=Di;u.nodeType!==8;){if(!d){u=null;break t}if(u=Ui(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){pn=Ui(u.nextSibling),o=u.data==="F!";break e}}Ya(o)}o=!1}o&&(n=r[0])}}return r=Qn(),r.memoizedState=r.baseState=n,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gg,lastRenderedState:n},r.queue=o,r=Ig.bind(null,wt,o),o.dispatch=r,o=Lf(!1),d=Hf.bind(null,wt,!1,o.queue),o=Qn(),u={state:n,dispatch:null,action:t,pending:null},o.queue=u,r=_S.bind(null,wt,u,d,r),u.dispatch=r,o.memoizedState=t,[n,r,!1]}function vg(t){var n=En();return xg(n,sn,t)}function xg(t,n,r){if(n=Nf(t,n,gg)[0],t=ic(va)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var o=Fo(n)}catch(M){throw M===yr?ql:M}else o=n;n=En();var u=n.queue,d=u.dispatch;return r!==n.memoizedState&&(wt.flags|=2048,Tr(9,{destroy:void 0},vS.bind(null,u,r),null)),[o,d,t]}function vS(t,n){t.action=n}function yg(t){var n=En(),r=sn;if(r!==null)return xg(n,r,t);En(),n=n.memoizedState,r=En();var o=r.queue.dispatch;return r.memoizedState=t,[n,o,!1]}function Tr(t,n,r,o){return t={tag:t,create:r,deps:o,inst:n,next:null},n=wt.updateQueue,n===null&&(n=tc(),wt.updateQueue=n),r=n.lastEffect,r===null?n.lastEffect=t.next=t:(o=r.next,r.next=t,t.next=o,n.lastEffect=t),t}function Sg(){return En().memoizedState}function ac(t,n,r,o){var u=Qn();wt.flags|=t,u.memoizedState=Tr(1|n,{destroy:void 0},r,o===void 0?null:o)}function sc(t,n,r,o){var u=En();o=o===void 0?null:o;var d=u.memoizedState.inst;sn!==null&&o!==null&&Tf(o,sn.memoizedState.deps)?u.memoizedState=Tr(n,d,r,o):(wt.flags|=t,u.memoizedState=Tr(1|n,d,r,o))}function Mg(t,n){ac(8390656,8,t,n)}function Pf(t,n){sc(2048,8,t,n)}function xS(t){wt.flags|=4;var n=wt.updateQueue;if(n===null)n=tc(),wt.updateQueue=n,n.events=[t];else{var r=n.events;r===null?n.events=[t]:r.push(t)}}function bg(t){var n=En().memoizedState;return xS({ref:n,nextImpl:t}),function(){if((Yt&2)!==0)throw Error(s(440));return n.impl.apply(void 0,arguments)}}function Eg(t,n){return sc(4,2,t,n)}function Tg(t,n){return sc(4,4,t,n)}function Ag(t,n){if(typeof n=="function"){t=t();var r=n(t);return function(){typeof r=="function"?r():n(null)}}if(n!=null)return t=t(),n.current=t,function(){n.current=null}}function Cg(t,n,r){r=r!=null?r.concat([t]):null,sc(4,4,Ag.bind(null,n,t),r)}function If(){}function wg(t,n){var r=En();n=n===void 0?null:n;var o=r.memoizedState;return n!==null&&Tf(n,o[1])?o[0]:(r.memoizedState=[t,n],t)}function Rg(t,n){var r=En();n=n===void 0?null:n;var o=r.memoizedState;if(n!==null&&Tf(n,o[1]))return o[0];if(o=t(),Vs){Le(!0);try{t()}finally{Le(!1)}}return r.memoizedState=[o,n],o}function Bf(t,n,r){return r===void 0||(_a&1073741824)!==0&&(Bt&261930)===0?t.memoizedState=n:(t.memoizedState=r,t=D0(),wt.lanes|=t,is|=t,r)}function Dg(t,n,r,o){return pi(r,n)?r:Mr.current!==null?(t=Bf(t,r,o),pi(t,n)||(Cn=!0),t):(_a&42)===0||(_a&1073741824)!==0&&(Bt&261930)===0?(Cn=!0,t.memoizedState=r):(t=D0(),wt.lanes|=t,is|=t,n)}function Ng(t,n,r,o,u){var d=G.p;G.p=d!==0&&8>d?d:8;var M=H.T,R={};H.T=R,Hf(t,!1,n,r);try{var k=u(),le=H.S;if(le!==null&&le(R,k),k!==null&&typeof k=="object"&&typeof k.then=="function"){var be=pS(k,o);zo(t,n,be,yi(t))}else zo(t,n,o,yi(t))}catch(Re){zo(t,n,{then:function(){},status:"rejected",reason:Re},yi())}finally{G.p=d,M!==null&&R.types!==null&&(M.types=R.types),H.T=M}}function yS(){}function Ff(t,n,r,o){if(t.tag!==5)throw Error(s(476));var u=Ug(t).queue;Ng(t,u,n,ne,r===null?yS:function(){return Lg(t),r(o)})}function Ug(t){var n=t.memoizedState;if(n!==null)return n;n={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:va,lastRenderedState:ne},next:null};var r={};return n.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:va,lastRenderedState:r},next:null},t.memoizedState=n,t=t.alternate,t!==null&&(t.memoizedState=n),n}function Lg(t){var n=Ug(t);n.next===null&&(n=t.alternate.memoizedState),zo(t,n.next.queue,{},yi())}function zf(){return kn(nl)}function Og(){return En().memoizedState}function Pg(){return En().memoizedState}function SS(t){for(var n=t.return;n!==null;){switch(n.tag){case 24:case 3:var r=yi();t=$a(r);var o=Qa(n,t,r);o!==null&&(ri(o,n,r),Oo(o,n,r)),n={cache:pf()},t.payload=n;return}n=n.return}}function MS(t,n,r){var o=yi();r={lane:o,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},rc(t)?Bg(n,r):(r=nf(t,n,r,o),r!==null&&(ri(r,t,o),Fg(r,n,o)))}function Ig(t,n,r){var o=yi();zo(t,n,r,o)}function zo(t,n,r,o){var u={lane:o,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(rc(t))Bg(n,u);else{var d=t.alternate;if(t.lanes===0&&(d===null||d.lanes===0)&&(d=n.lastRenderedReducer,d!==null))try{var M=n.lastRenderedState,R=d(M,r);if(u.hasEagerState=!0,u.eagerState=R,pi(R,M))return Hl(t,n,u,0),un===null&&zl(),!1}catch{}if(r=nf(t,n,u,o),r!==null)return ri(r,t,o),Fg(r,n,o),!0}return!1}function Hf(t,n,r,o){if(o={lane:2,revertLane:vd(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},rc(t)){if(n)throw Error(s(479))}else n=nf(t,r,o,2),n!==null&&ri(n,t,2)}function rc(t){var n=t.alternate;return t===wt||n!==null&&n===wt}function Bg(t,n){br=Jl=!0;var r=t.pending;r===null?n.next=n:(n.next=r.next,r.next=n),t.pending=n}function Fg(t,n,r){if((r&4194048)!==0){var o=n.lanes;o&=t.pendingLanes,r|=o,n.lanes=r,Nt(t,r)}}var Ho={readContext:kn,use:nc,useCallback:Sn,useContext:Sn,useEffect:Sn,useImperativeHandle:Sn,useLayoutEffect:Sn,useInsertionEffect:Sn,useMemo:Sn,useReducer:Sn,useRef:Sn,useState:Sn,useDebugValue:Sn,useDeferredValue:Sn,useTransition:Sn,useSyncExternalStore:Sn,useId:Sn,useHostTransitionStatus:Sn,useFormState:Sn,useActionState:Sn,useOptimistic:Sn,useMemoCache:Sn,useCacheRefresh:Sn};Ho.useEffectEvent=Sn;var zg={readContext:kn,use:nc,useCallback:function(t,n){return Qn().memoizedState=[t,n===void 0?null:n],t},useContext:kn,useEffect:Mg,useImperativeHandle:function(t,n,r){r=r!=null?r.concat([t]):null,ac(4194308,4,Ag.bind(null,n,t),r)},useLayoutEffect:function(t,n){return ac(4194308,4,t,n)},useInsertionEffect:function(t,n){ac(4,2,t,n)},useMemo:function(t,n){var r=Qn();n=n===void 0?null:n;var o=t();if(Vs){Le(!0);try{t()}finally{Le(!1)}}return r.memoizedState=[o,n],o},useReducer:function(t,n,r){var o=Qn();if(r!==void 0){var u=r(n);if(Vs){Le(!0);try{r(n)}finally{Le(!1)}}}else u=n;return o.memoizedState=o.baseState=u,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:u},o.queue=t,t=t.dispatch=MS.bind(null,wt,t),[o.memoizedState,t]},useRef:function(t){var n=Qn();return t={current:t},n.memoizedState=t},useState:function(t){t=Lf(t);var n=t.queue,r=Ig.bind(null,wt,n);return n.dispatch=r,[t.memoizedState,r]},useDebugValue:If,useDeferredValue:function(t,n){var r=Qn();return Bf(r,t,n)},useTransition:function(){var t=Lf(!1);return t=Ng.bind(null,wt,t.queue,!0,!1),Qn().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,n,r){var o=wt,u=Qn();if(Vt){if(r===void 0)throw Error(s(407));r=r()}else{if(r=n(),un===null)throw Error(s(349));(Bt&127)!==0||rg(o,n,r)}u.memoizedState=r;var d={value:r,getSnapshot:n};return u.queue=d,Mg(lg.bind(null,o,d,t),[t]),o.flags|=2048,Tr(9,{destroy:void 0},og.bind(null,o,d,r,n),null),r},useId:function(){var t=Qn(),n=un.identifierPrefix;if(Vt){var r=Ji,o=Qi;r=(o&~(1<<32-je(o)-1)).toString(32)+r,n="_"+n+"R_"+r,r=ec++,0<r&&(n+="H"+r.toString(32)),n+="_"}else r=mS++,n="_"+n+"r_"+r.toString(32)+"_";return t.memoizedState=n},useHostTransitionStatus:zf,useFormState:_g,useActionState:_g,useOptimistic:function(t){var n=Qn();n.memoizedState=n.baseState=t;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=r,n=Hf.bind(null,wt,!0,r),r.dispatch=n,[t,n]},useMemoCache:Df,useCacheRefresh:function(){return Qn().memoizedState=SS.bind(null,wt)},useEffectEvent:function(t){var n=Qn(),r={impl:t};return n.memoizedState=r,function(){if((Yt&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}},Gf={readContext:kn,use:nc,useCallback:wg,useContext:kn,useEffect:Pf,useImperativeHandle:Cg,useInsertionEffect:Eg,useLayoutEffect:Tg,useMemo:Rg,useReducer:ic,useRef:Sg,useState:function(){return ic(va)},useDebugValue:If,useDeferredValue:function(t,n){var r=En();return Dg(r,sn.memoizedState,t,n)},useTransition:function(){var t=ic(va)[0],n=En().memoizedState;return[typeof t=="boolean"?t:Fo(t),n]},useSyncExternalStore:sg,useId:Og,useHostTransitionStatus:zf,useFormState:vg,useActionState:vg,useOptimistic:function(t,n){var r=En();return fg(r,sn,t,n)},useMemoCache:Df,useCacheRefresh:Pg};Gf.useEffectEvent=bg;var Hg={readContext:kn,use:nc,useCallback:wg,useContext:kn,useEffect:Pf,useImperativeHandle:Cg,useInsertionEffect:Eg,useLayoutEffect:Tg,useMemo:Rg,useReducer:Uf,useRef:Sg,useState:function(){return Uf(va)},useDebugValue:If,useDeferredValue:function(t,n){var r=En();return sn===null?Bf(r,t,n):Dg(r,sn.memoizedState,t,n)},useTransition:function(){var t=Uf(va)[0],n=En().memoizedState;return[typeof t=="boolean"?t:Fo(t),n]},useSyncExternalStore:sg,useId:Og,useHostTransitionStatus:zf,useFormState:yg,useActionState:yg,useOptimistic:function(t,n){var r=En();return sn!==null?fg(r,sn,t,n):(r.baseState=t,[t,r.queue.dispatch])},useMemoCache:Df,useCacheRefresh:Pg};Hg.useEffectEvent=bg;function Vf(t,n,r,o){n=t.memoizedState,r=r(o,n),r=r==null?n:S({},n,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var kf={enqueueSetState:function(t,n,r){t=t._reactInternals;var o=yi(),u=$a(o);u.payload=n,r!=null&&(u.callback=r),n=Qa(t,u,o),n!==null&&(ri(n,t,o),Oo(n,t,o))},enqueueReplaceState:function(t,n,r){t=t._reactInternals;var o=yi(),u=$a(o);u.tag=1,u.payload=n,r!=null&&(u.callback=r),n=Qa(t,u,o),n!==null&&(ri(n,t,o),Oo(n,t,o))},enqueueForceUpdate:function(t,n){t=t._reactInternals;var r=yi(),o=$a(r);o.tag=2,n!=null&&(o.callback=n),n=Qa(t,o,r),n!==null&&(ri(n,t,r),Oo(n,t,r))}};function Gg(t,n,r,o,u,d,M){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(o,d,M):n.prototype&&n.prototype.isPureReactComponent?!Ao(r,o)||!Ao(u,d):!0}function Vg(t,n,r,o){t=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(r,o),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(r,o),n.state!==t&&kf.enqueueReplaceState(n,n.state,null)}function ks(t,n){var r=n;if("ref"in n){r={};for(var o in n)o!=="ref"&&(r[o]=n[o])}if(t=t.defaultProps){r===n&&(r=S({},r));for(var u in t)r[u]===void 0&&(r[u]=t[u])}return r}function kg(t){Fl(t)}function jg(t){console.error(t)}function Xg(t){Fl(t)}function oc(t,n){try{var r=t.onUncaughtError;r(n.value,{componentStack:n.stack})}catch(o){setTimeout(function(){throw o})}}function Wg(t,n,r){try{var o=t.onCaughtError;o(r.value,{componentStack:r.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function jf(t,n,r){return r=$a(r),r.tag=3,r.payload={element:null},r.callback=function(){oc(t,n)},r}function qg(t){return t=$a(t),t.tag=3,t}function Yg(t,n,r,o){var u=r.type.getDerivedStateFromError;if(typeof u=="function"){var d=o.value;t.payload=function(){return u(d)},t.callback=function(){Wg(n,r,o)}}var M=r.stateNode;M!==null&&typeof M.componentDidCatch=="function"&&(t.callback=function(){Wg(n,r,o),typeof u!="function"&&(as===null?as=new Set([this]):as.add(this));var R=o.stack;this.componentDidCatch(o.value,{componentStack:R!==null?R:""})})}function bS(t,n,r,o,u){if(r.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(n=r.alternate,n!==null&&_r(n,r,u,!0),r=gi.current,r!==null){switch(r.tag){case 31:case 13:return Ni===null?xc():r.alternate===null&&Mn===0&&(Mn=3),r.flags&=-257,r.flags|=65536,r.lanes=u,o===Yl?r.flags|=16384:(n=r.updateQueue,n===null?r.updateQueue=new Set([o]):n.add(o),md(t,o,u)),!1;case 22:return r.flags|=65536,o===Yl?r.flags|=16384:(n=r.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([o])},r.updateQueue=n):(r=n.retryQueue,r===null?n.retryQueue=new Set([o]):r.add(o)),md(t,o,u)),!1}throw Error(s(435,r.tag))}return md(t,o,u),xc(),!1}if(Vt)return n=gi.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=u,o!==cf&&(t=Error(s(422),{cause:o}),Ro(Ci(t,r)))):(o!==cf&&(n=Error(s(423),{cause:o}),Ro(Ci(n,r))),t=t.current.alternate,t.flags|=65536,u&=-u,t.lanes|=u,o=Ci(o,r),u=jf(t.stateNode,o,u),yf(t,u),Mn!==4&&(Mn=2)),!1;var d=Error(s(520),{cause:o});if(d=Ci(d,r),Yo===null?Yo=[d]:Yo.push(d),Mn!==4&&(Mn=2),n===null)return!0;o=Ci(o,r),r=n;do{switch(r.tag){case 3:return r.flags|=65536,t=u&-u,r.lanes|=t,t=jf(r.stateNode,o,t),yf(r,t),!1;case 1:if(n=r.type,d=r.stateNode,(r.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(as===null||!as.has(d))))return r.flags|=65536,u&=-u,r.lanes|=u,u=qg(u),Yg(u,t,r,o),yf(r,u),!1}r=r.return}while(r!==null);return!1}var Xf=Error(s(461)),Cn=!1;function jn(t,n,r,o){n.child=t===null?Qm(n,null,r,o):Gs(n,t.child,r,o)}function Zg(t,n,r,o,u){r=r.render;var d=n.ref;if("ref"in o){var M={};for(var R in o)R!=="ref"&&(M[R]=o[R])}else M=o;return Bs(n),o=Af(t,n,r,M,d,u),R=Cf(),t!==null&&!Cn?(wf(t,n,u),xa(t,n,u)):(Vt&&R&&of(n),n.flags|=1,jn(t,n,o,u),n.child)}function Kg(t,n,r,o,u){if(t===null){var d=r.type;return typeof d=="function"&&!af(d)&&d.defaultProps===void 0&&r.compare===null?(n.tag=15,n.type=d,$g(t,n,d,o,u)):(t=Vl(r.type,null,o,n,n.mode,u),t.ref=n.ref,t.return=n,n.child=t)}if(d=t.child,!Jf(t,u)){var M=d.memoizedProps;if(r=r.compare,r=r!==null?r:Ao,r(M,o)&&t.ref===n.ref)return xa(t,n,u)}return n.flags|=1,t=ha(d,o),t.ref=n.ref,t.return=n,n.child=t}function $g(t,n,r,o,u){if(t!==null){var d=t.memoizedProps;if(Ao(d,o)&&t.ref===n.ref)if(Cn=!1,n.pendingProps=o=d,Jf(t,u))(t.flags&131072)!==0&&(Cn=!0);else return n.lanes=t.lanes,xa(t,n,u)}return Wf(t,n,r,o,u)}function Qg(t,n,r,o){var u=o.children,d=t!==null?t.memoizedState:null;if(t===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((n.flags&128)!==0){if(d=d!==null?d.baseLanes|r:r,t!==null){for(o=n.child=t.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~d}else o=0,n.child=null;return Jg(t,n,d,r,o)}if((r&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},t!==null&&Wl(n,d!==null?d.cachePool:null),d!==null?tg(n,d):Mf(),ng(n);else return o=n.lanes=536870912,Jg(t,n,d!==null?d.baseLanes|r:r,r,o)}else d!==null?(Wl(n,d.cachePool),tg(n,d),es(),n.memoizedState=null):(t!==null&&Wl(n,null),Mf(),es());return jn(t,n,u,r),n.child}function Go(t,n){return t!==null&&t.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Jg(t,n,r,o,u){var d=gf();return d=d===null?null:{parent:Tn._currentValue,pool:d},n.memoizedState={baseLanes:r,cachePool:d},t!==null&&Wl(n,null),Mf(),ng(n),t!==null&&_r(t,n,o,!0),n.childLanes=u,null}function lc(t,n){return n=uc({mode:n.mode,children:n.children},t.mode),n.ref=t.ref,t.child=n,n.return=t,n}function e0(t,n,r){return Gs(n,t.child,null,r),t=lc(n,n.pendingProps),t.flags|=2,_i(n),n.memoizedState=null,t}function ES(t,n,r){var o=n.pendingProps,u=(n.flags&128)!==0;if(n.flags&=-129,t===null){if(Vt){if(o.mode==="hidden")return t=lc(n,o),n.lanes=536870912,Go(null,t);if(Ef(n),(t=pn)?(t=d_(t,Di),t=t!==null&&t.data==="&"?t:null,t!==null&&(n.memoizedState={dehydrated:t,treeContext:Wa!==null?{id:Qi,overflow:Ji}:null,retryLane:536870912,hydrationErrors:null},r=Bm(t),r.return=n,n.child=r,Vn=n,pn=null)):t=null,t===null)throw Ya(n);return n.lanes=536870912,null}return lc(n,o)}var d=t.memoizedState;if(d!==null){var M=d.dehydrated;if(Ef(n),u)if(n.flags&256)n.flags&=-257,n=e0(t,n,r);else if(n.memoizedState!==null)n.child=t.child,n.flags|=128,n=null;else throw Error(s(558));else if(Cn||_r(t,n,r,!1),u=(r&t.childLanes)!==0,Cn||u){if(o=un,o!==null&&(M=Hn(o,r),M!==0&&M!==d.retryLane))throw d.retryLane=M,Ls(t,M),ri(o,t,M),Xf;xc(),n=e0(t,n,r)}else t=d.treeContext,pn=Ui(M.nextSibling),Vn=n,Vt=!0,qa=null,Di=!1,t!==null&&Hm(n,t),n=lc(n,o),n.flags|=4096;return n}return t=ha(t.child,{mode:o.mode,children:o.children}),t.ref=n.ref,n.child=t,t.return=n,t}function cc(t,n){var r=n.ref;if(r===null)t!==null&&t.ref!==null&&(n.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(s(284));(t===null||t.ref!==r)&&(n.flags|=4194816)}}function Wf(t,n,r,o,u){return Bs(n),r=Af(t,n,r,o,void 0,u),o=Cf(),t!==null&&!Cn?(wf(t,n,u),xa(t,n,u)):(Vt&&o&&of(n),n.flags|=1,jn(t,n,r,u),n.child)}function t0(t,n,r,o,u,d){return Bs(n),n.updateQueue=null,r=ag(n,o,r,u),ig(t),o=Cf(),t!==null&&!Cn?(wf(t,n,d),xa(t,n,d)):(Vt&&o&&of(n),n.flags|=1,jn(t,n,r,d),n.child)}function n0(t,n,r,o,u){if(Bs(n),n.stateNode===null){var d=hr,M=r.contextType;typeof M=="object"&&M!==null&&(d=kn(M)),d=new r(o,d),n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=kf,n.stateNode=d,d._reactInternals=n,d=n.stateNode,d.props=o,d.state=n.memoizedState,d.refs={},vf(n),M=r.contextType,d.context=typeof M=="object"&&M!==null?kn(M):hr,d.state=n.memoizedState,M=r.getDerivedStateFromProps,typeof M=="function"&&(Vf(n,r,M,o),d.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(M=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),M!==d.state&&kf.enqueueReplaceState(d,d.state,null),Io(n,o,d,u),Po(),d.state=n.memoizedState),typeof d.componentDidMount=="function"&&(n.flags|=4194308),o=!0}else if(t===null){d=n.stateNode;var R=n.memoizedProps,k=ks(r,R);d.props=k;var le=d.context,be=r.contextType;M=hr,typeof be=="object"&&be!==null&&(M=kn(be));var Re=r.getDerivedStateFromProps;be=typeof Re=="function"||typeof d.getSnapshotBeforeUpdate=="function",R=n.pendingProps!==R,be||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(R||le!==M)&&Vg(n,d,o,M),Ka=!1;var de=n.memoizedState;d.state=de,Io(n,o,d,u),Po(),le=n.memoizedState,R||de!==le||Ka?(typeof Re=="function"&&(Vf(n,r,Re,o),le=n.memoizedState),(k=Ka||Gg(n,r,k,o,de,le,M))?(be||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(n.flags|=4194308)):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=o,n.memoizedState=le),d.props=o,d.state=le,d.context=M,o=k):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{d=n.stateNode,xf(t,n),M=n.memoizedProps,be=ks(r,M),d.props=be,Re=n.pendingProps,de=d.context,le=r.contextType,k=hr,typeof le=="object"&&le!==null&&(k=kn(le)),R=r.getDerivedStateFromProps,(le=typeof R=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(M!==Re||de!==k)&&Vg(n,d,o,k),Ka=!1,de=n.memoizedState,d.state=de,Io(n,o,d,u),Po();var ve=n.memoizedState;M!==Re||de!==ve||Ka||t!==null&&t.dependencies!==null&&jl(t.dependencies)?(typeof R=="function"&&(Vf(n,r,R,o),ve=n.memoizedState),(be=Ka||Gg(n,r,be,o,de,ve,k)||t!==null&&t.dependencies!==null&&jl(t.dependencies))?(le||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(o,ve,k),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(o,ve,k)),typeof d.componentDidUpdate=="function"&&(n.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof d.componentDidUpdate!="function"||M===t.memoizedProps&&de===t.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&de===t.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=ve),d.props=o,d.state=ve,d.context=k,o=be):(typeof d.componentDidUpdate!="function"||M===t.memoizedProps&&de===t.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&de===t.memoizedState||(n.flags|=1024),o=!1)}return d=o,cc(t,n),o=(n.flags&128)!==0,d||o?(d=n.stateNode,r=o&&typeof r.getDerivedStateFromError!="function"?null:d.render(),n.flags|=1,t!==null&&o?(n.child=Gs(n,t.child,null,u),n.child=Gs(n,null,r,u)):jn(t,n,r,u),n.memoizedState=d.state,t=n.child):t=xa(t,n,u),t}function i0(t,n,r,o){return Ps(),n.flags|=256,jn(t,n,r,o),n.child}var qf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Yf(t){return{baseLanes:t,cachePool:Wm()}}function Zf(t,n,r){return t=t!==null?t.childLanes&~r:0,n&&(t|=xi),t}function a0(t,n,r){var o=n.pendingProps,u=!1,d=(n.flags&128)!==0,M;if((M=d)||(M=t!==null&&t.memoizedState===null?!1:(bn.current&2)!==0),M&&(u=!0,n.flags&=-129),M=(n.flags&32)!==0,n.flags&=-33,t===null){if(Vt){if(u?Ja(n):es(),(t=pn)?(t=d_(t,Di),t=t!==null&&t.data!=="&"?t:null,t!==null&&(n.memoizedState={dehydrated:t,treeContext:Wa!==null?{id:Qi,overflow:Ji}:null,retryLane:536870912,hydrationErrors:null},r=Bm(t),r.return=n,n.child=r,Vn=n,pn=null)):t=null,t===null)throw Ya(n);return Nd(t)?n.lanes=32:n.lanes=536870912,null}var R=o.children;return o=o.fallback,u?(es(),u=n.mode,R=uc({mode:"hidden",children:R},u),o=Os(o,u,r,null),R.return=n,o.return=n,R.sibling=o,n.child=R,o=n.child,o.memoizedState=Yf(r),o.childLanes=Zf(t,M,r),n.memoizedState=qf,Go(null,o)):(Ja(n),Kf(n,R))}var k=t.memoizedState;if(k!==null&&(R=k.dehydrated,R!==null)){if(d)n.flags&256?(Ja(n),n.flags&=-257,n=$f(t,n,r)):n.memoizedState!==null?(es(),n.child=t.child,n.flags|=128,n=null):(es(),R=o.fallback,u=n.mode,o=uc({mode:"visible",children:o.children},u),R=Os(R,u,r,null),R.flags|=2,o.return=n,R.return=n,o.sibling=R,n.child=o,Gs(n,t.child,null,r),o=n.child,o.memoizedState=Yf(r),o.childLanes=Zf(t,M,r),n.memoizedState=qf,n=Go(null,o));else if(Ja(n),Nd(R)){if(M=R.nextSibling&&R.nextSibling.dataset,M)var le=M.dgst;M=le,o=Error(s(419)),o.stack="",o.digest=M,Ro({value:o,source:null,stack:null}),n=$f(t,n,r)}else if(Cn||_r(t,n,r,!1),M=(r&t.childLanes)!==0,Cn||M){if(M=un,M!==null&&(o=Hn(M,r),o!==0&&o!==k.retryLane))throw k.retryLane=o,Ls(t,o),ri(M,t,o),Xf;Dd(R)||xc(),n=$f(t,n,r)}else Dd(R)?(n.flags|=192,n.child=t.child,n=null):(t=k.treeContext,pn=Ui(R.nextSibling),Vn=n,Vt=!0,qa=null,Di=!1,t!==null&&Hm(n,t),n=Kf(n,o.children),n.flags|=4096);return n}return u?(es(),R=o.fallback,u=n.mode,k=t.child,le=k.sibling,o=ha(k,{mode:"hidden",children:o.children}),o.subtreeFlags=k.subtreeFlags&65011712,le!==null?R=ha(le,R):(R=Os(R,u,r,null),R.flags|=2),R.return=n,o.return=n,o.sibling=R,n.child=o,Go(null,o),o=n.child,R=t.child.memoizedState,R===null?R=Yf(r):(u=R.cachePool,u!==null?(k=Tn._currentValue,u=u.parent!==k?{parent:k,pool:k}:u):u=Wm(),R={baseLanes:R.baseLanes|r,cachePool:u}),o.memoizedState=R,o.childLanes=Zf(t,M,r),n.memoizedState=qf,Go(t.child,o)):(Ja(n),r=t.child,t=r.sibling,r=ha(r,{mode:"visible",children:o.children}),r.return=n,r.sibling=null,t!==null&&(M=n.deletions,M===null?(n.deletions=[t],n.flags|=16):M.push(t)),n.child=r,n.memoizedState=null,r)}function Kf(t,n){return n=uc({mode:"visible",children:n},t.mode),n.return=t,t.child=n}function uc(t,n){return t=mi(22,t,null,n),t.lanes=0,t}function $f(t,n,r){return Gs(n,t.child,null,r),t=Kf(n,n.pendingProps.children),t.flags|=2,n.memoizedState=null,t}function s0(t,n,r){t.lanes|=n;var o=t.alternate;o!==null&&(o.lanes|=n),df(t.return,n,r)}function Qf(t,n,r,o,u,d){var M=t.memoizedState;M===null?t.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:r,tailMode:u,treeForkCount:d}:(M.isBackwards=n,M.rendering=null,M.renderingStartTime=0,M.last=o,M.tail=r,M.tailMode=u,M.treeForkCount=d)}function r0(t,n,r){var o=n.pendingProps,u=o.revealOrder,d=o.tail;o=o.children;var M=bn.current,R=(M&2)!==0;if(R?(M=M&1|2,n.flags|=128):M&=1,Ce(bn,M),jn(t,n,o,r),o=Vt?wo:0,!R&&t!==null&&(t.flags&128)!==0)e:for(t=n.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&s0(t,r,n);else if(t.tag===19)s0(t,r,n);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===n)break e;for(;t.sibling===null;){if(t.return===null||t.return===n)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(u){case"forwards":for(r=n.child,u=null;r!==null;)t=r.alternate,t!==null&&Ql(t)===null&&(u=r),r=r.sibling;r=u,r===null?(u=n.child,n.child=null):(u=r.sibling,r.sibling=null),Qf(n,!1,u,r,d,o);break;case"backwards":case"unstable_legacy-backwards":for(r=null,u=n.child,n.child=null;u!==null;){if(t=u.alternate,t!==null&&Ql(t)===null){n.child=u;break}t=u.sibling,u.sibling=r,r=u,u=t}Qf(n,!0,r,null,d,o);break;case"together":Qf(n,!1,null,null,void 0,o);break;default:n.memoizedState=null}return n.child}function xa(t,n,r){if(t!==null&&(n.dependencies=t.dependencies),is|=n.lanes,(r&n.childLanes)===0)if(t!==null){if(_r(t,n,r,!1),(r&n.childLanes)===0)return null}else return null;if(t!==null&&n.child!==t.child)throw Error(s(153));if(n.child!==null){for(t=n.child,r=ha(t,t.pendingProps),n.child=r,r.return=n;t.sibling!==null;)t=t.sibling,r=r.sibling=ha(t,t.pendingProps),r.return=n;r.sibling=null}return n.child}function Jf(t,n){return(t.lanes&n)!==0?!0:(t=t.dependencies,!!(t!==null&&jl(t)))}function TS(t,n,r){switch(n.tag){case 3:Ee(n,n.stateNode.containerInfo),Za(n,Tn,t.memoizedState.cache),Ps();break;case 27:case 5:nt(n);break;case 4:Ee(n,n.stateNode.containerInfo);break;case 10:Za(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Ef(n),null;break;case 13:var o=n.memoizedState;if(o!==null)return o.dehydrated!==null?(Ja(n),n.flags|=128,null):(r&n.child.childLanes)!==0?a0(t,n,r):(Ja(n),t=xa(t,n,r),t!==null?t.sibling:null);Ja(n);break;case 19:var u=(t.flags&128)!==0;if(o=(r&n.childLanes)!==0,o||(_r(t,n,r,!1),o=(r&n.childLanes)!==0),u){if(o)return r0(t,n,r);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),Ce(bn,bn.current),o)break;return null;case 22:return n.lanes=0,Qg(t,n,r,n.pendingProps);case 24:Za(n,Tn,t.memoizedState.cache)}return xa(t,n,r)}function o0(t,n,r){if(t!==null)if(t.memoizedProps!==n.pendingProps)Cn=!0;else{if(!Jf(t,r)&&(n.flags&128)===0)return Cn=!1,TS(t,n,r);Cn=(t.flags&131072)!==0}else Cn=!1,Vt&&(n.flags&1048576)!==0&&zm(n,wo,n.index);switch(n.lanes=0,n.tag){case 16:e:{var o=n.pendingProps;if(t=zs(n.elementType),n.type=t,typeof t=="function")af(t)?(o=ks(t,o),n.tag=1,n=n0(null,n,t,o,r)):(n.tag=0,n=Wf(null,n,t,o,r));else{if(t!=null){var u=t.$$typeof;if(u===D){n.tag=11,n=Zg(null,n,t,o,r);break e}else if(u===N){n.tag=14,n=Kg(null,n,t,o,r);break e}}throw n=ge(t)||t,Error(s(306,n,""))}}return n;case 0:return Wf(t,n,n.type,n.pendingProps,r);case 1:return o=n.type,u=ks(o,n.pendingProps),n0(t,n,o,u,r);case 3:e:{if(Ee(n,n.stateNode.containerInfo),t===null)throw Error(s(387));o=n.pendingProps;var d=n.memoizedState;u=d.element,xf(t,n),Io(n,o,null,r);var M=n.memoizedState;if(o=M.cache,Za(n,Tn,o),o!==d.cache&&hf(n,[Tn],r,!0),Po(),o=M.element,d.isDehydrated)if(d={element:o,isDehydrated:!1,cache:M.cache},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){n=i0(t,n,o,r);break e}else if(o!==u){u=Ci(Error(s(424)),n),Ro(u),n=i0(t,n,o,r);break e}else for(t=n.stateNode.containerInfo,t.nodeType===9?t=t.body:t=t.nodeName==="HTML"?t.ownerDocument.body:t,pn=Ui(t.firstChild),Vn=n,Vt=!0,qa=null,Di=!0,r=Qm(n,null,o,r),n.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Ps(),o===u){n=xa(t,n,r);break e}jn(t,n,o,r)}n=n.child}return n;case 26:return cc(t,n),t===null?(r=v_(n.type,null,n.pendingProps,null))?n.memoizedState=r:Vt||(r=n.type,t=n.pendingProps,o=Ac(ae.current).createElement(r),o[we]=n,o[Ge]=t,Xn(o,r,t),Kt(o),n.stateNode=o):n.memoizedState=v_(n.type,t.memoizedProps,n.pendingProps,t.memoizedState),null;case 27:return nt(n),t===null&&Vt&&(o=n.stateNode=m_(n.type,n.pendingProps,ae.current),Vn=n,Di=!0,u=pn,ls(n.type)?(Ud=u,pn=Ui(o.firstChild)):pn=u),jn(t,n,n.pendingProps.children,r),cc(t,n),t===null&&(n.flags|=4194304),n.child;case 5:return t===null&&Vt&&((u=o=pn)&&(o=tM(o,n.type,n.pendingProps,Di),o!==null?(n.stateNode=o,Vn=n,pn=Ui(o.firstChild),Di=!1,u=!0):u=!1),u||Ya(n)),nt(n),u=n.type,d=n.pendingProps,M=t!==null?t.memoizedProps:null,o=d.children,Cd(u,d)?o=null:M!==null&&Cd(u,M)&&(n.flags|=32),n.memoizedState!==null&&(u=Af(t,n,gS,null,null,r),nl._currentValue=u),cc(t,n),jn(t,n,o,r),n.child;case 6:return t===null&&Vt&&((t=r=pn)&&(r=nM(r,n.pendingProps,Di),r!==null?(n.stateNode=r,Vn=n,pn=null,t=!0):t=!1),t||Ya(n)),null;case 13:return a0(t,n,r);case 4:return Ee(n,n.stateNode.containerInfo),o=n.pendingProps,t===null?n.child=Gs(n,null,o,r):jn(t,n,o,r),n.child;case 11:return Zg(t,n,n.type,n.pendingProps,r);case 7:return jn(t,n,n.pendingProps,r),n.child;case 8:return jn(t,n,n.pendingProps.children,r),n.child;case 12:return jn(t,n,n.pendingProps.children,r),n.child;case 10:return o=n.pendingProps,Za(n,n.type,o.value),jn(t,n,o.children,r),n.child;case 9:return u=n.type._context,o=n.pendingProps.children,Bs(n),u=kn(u),o=o(u),n.flags|=1,jn(t,n,o,r),n.child;case 14:return Kg(t,n,n.type,n.pendingProps,r);case 15:return $g(t,n,n.type,n.pendingProps,r);case 19:return r0(t,n,r);case 31:return ES(t,n,r);case 22:return Qg(t,n,r,n.pendingProps);case 24:return Bs(n),o=kn(Tn),t===null?(u=gf(),u===null&&(u=un,d=pf(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=r),u=d),n.memoizedState={parent:o,cache:u},vf(n),Za(n,Tn,u)):((t.lanes&r)!==0&&(xf(t,n),Io(n,null,null,r),Po()),u=t.memoizedState,d=n.memoizedState,u.parent!==o?(u={parent:o,cache:o},n.memoizedState=u,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=u),Za(n,Tn,o)):(o=d.cache,Za(n,Tn,o),o!==u.cache&&hf(n,[Tn],r,!0))),jn(t,n,n.pendingProps.children,r),n.child;case 29:throw n.pendingProps}throw Error(s(156,n.tag))}function ya(t){t.flags|=4}function ed(t,n,r,o,u){if((n=(t.mode&32)!==0)&&(n=!1),n){if(t.flags|=16777216,(u&335544128)===u)if(t.stateNode.complete)t.flags|=8192;else if(O0())t.flags|=8192;else throw Hs=Yl,_f}else t.flags&=-16777217}function l0(t,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!b_(n))if(O0())t.flags|=8192;else throw Hs=Yl,_f}function fc(t,n){n!==null&&(t.flags|=4),t.flags&16384&&(n=t.tag!==22?q():536870912,t.lanes|=n,Rr|=n)}function Vo(t,n){if(!Vt)switch(t.tailMode){case"hidden":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.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?n||t.tail===null?t.tail=null:t.tail.sibling=null:o.sibling=null}}function mn(t){var n=t.alternate!==null&&t.alternate.child===t.child,r=0,o=0;if(n)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,n}function AS(t,n,r){var o=n.pendingProps;switch(lf(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mn(n),null;case 1:return mn(n),null;case 3:return r=n.stateNode,o=null,t!==null&&(o=t.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),ga(Tn),He(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(gr(n)?ya(n):t===null||t.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,uf())),mn(n),null;case 26:var u=n.type,d=n.memoizedState;return t===null?(ya(n),d!==null?(mn(n),l0(n,d)):(mn(n),ed(n,u,null,o,r))):d?d!==t.memoizedState?(ya(n),mn(n),l0(n,d)):(mn(n),n.flags&=-16777217):(t=t.memoizedProps,t!==o&&ya(n),mn(n),ed(n,u,t,o,r)),null;case 27:if(Ke(n),r=ae.current,u=n.type,t!==null&&n.stateNode!=null)t.memoizedProps!==o&&ya(n);else{if(!o){if(n.stateNode===null)throw Error(s(166));return mn(n),null}t=Ue.current,gr(n)?Gm(n):(t=m_(u,o,r),n.stateNode=t,ya(n))}return mn(n),null;case 5:if(Ke(n),u=n.type,t!==null&&n.stateNode!=null)t.memoizedProps!==o&&ya(n);else{if(!o){if(n.stateNode===null)throw Error(s(166));return mn(n),null}if(d=Ue.current,gr(n))Gm(n);else{var M=Ac(ae.current);switch(d){case 1:d=M.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:d=M.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":d=M.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":d=M.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":d=M.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof o.is=="string"?M.createElement("select",{is:o.is}):M.createElement("select"),o.multiple?d.multiple=!0:o.size&&(d.size=o.size);break;default:d=typeof o.is=="string"?M.createElement(u,{is:o.is}):M.createElement(u)}}d[we]=n,d[Ge]=o;e:for(M=n.child;M!==null;){if(M.tag===5||M.tag===6)d.appendChild(M.stateNode);else if(M.tag!==4&&M.tag!==27&&M.child!==null){M.child.return=M,M=M.child;continue}if(M===n)break e;for(;M.sibling===null;){if(M.return===null||M.return===n)break e;M=M.return}M.sibling.return=M.return,M=M.sibling}n.stateNode=d;e:switch(Xn(d,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&&ya(n)}}return mn(n),ed(n,n.type,t===null?null:t.memoizedProps,n.pendingProps,r),null;case 6:if(t&&n.stateNode!=null)t.memoizedProps!==o&&ya(n);else{if(typeof o!="string"&&n.stateNode===null)throw Error(s(166));if(t=ae.current,gr(n)){if(t=n.stateNode,r=n.memoizedProps,o=null,u=Vn,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}t[we]=n,t=!!(t.nodeValue===r||o!==null&&o.suppressHydrationWarning===!0||a_(t.nodeValue,r)),t||Ya(n,!0)}else t=Ac(t).createTextNode(o),t[we]=n,n.stateNode=t}return mn(n),null;case 31:if(r=n.memoizedState,t===null||t.memoizedState!==null){if(o=gr(n),r!==null){if(t===null){if(!o)throw Error(s(318));if(t=n.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[we]=n}else Ps(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;mn(n),t=!1}else r=uf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=r),t=!0;if(!t)return n.flags&256?(_i(n),n):(_i(n),null);if((n.flags&128)!==0)throw Error(s(558))}return mn(n),null;case 13:if(o=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(u=gr(n),o!==null&&o.dehydrated!==null){if(t===null){if(!u)throw Error(s(318));if(u=n.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[we]=n}else Ps(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;mn(n),u=!1}else u=uf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(_i(n),n):(_i(n),null)}return _i(n),(n.flags&128)!==0?(n.lanes=r,n):(r=o!==null,t=t!==null&&t.memoizedState!==null,r&&(o=n.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),d=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(d=o.memoizedState.cachePool.pool),d!==u&&(o.flags|=2048)),r!==t&&r&&(n.child.flags|=8192),fc(n,n.updateQueue),mn(n),null);case 4:return He(),t===null&&Md(n.stateNode.containerInfo),mn(n),null;case 10:return ga(n.type),mn(n),null;case 19:if(J(bn),o=n.memoizedState,o===null)return mn(n),null;if(u=(n.flags&128)!==0,d=o.rendering,d===null)if(u)Vo(o,!1);else{if(Mn!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(d=Ql(t),d!==null){for(n.flags|=128,Vo(o,!1),t=d.updateQueue,n.updateQueue=t,fc(n,t),n.subtreeFlags=0,t=r,r=n.child;r!==null;)Im(r,t),r=r.sibling;return Ce(bn,bn.current&1|2),Vt&&pa(n,o.treeForkCount),n.child}t=t.sibling}o.tail!==null&&Ye()>gc&&(n.flags|=128,u=!0,Vo(o,!1),n.lanes=4194304)}else{if(!u)if(t=Ql(d),t!==null){if(n.flags|=128,u=!0,t=t.updateQueue,n.updateQueue=t,fc(n,t),Vo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!d.alternate&&!Vt)return mn(n),null}else 2*Ye()-o.renderingStartTime>gc&&r!==536870912&&(n.flags|=128,u=!0,Vo(o,!1),n.lanes=4194304);o.isBackwards?(d.sibling=n.child,n.child=d):(t=o.last,t!==null?t.sibling=d:n.child=d,o.last=d)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Ye(),t.sibling=null,r=bn.current,Ce(bn,u?r&1|2:r&1),Vt&&pa(n,o.treeForkCount),t):(mn(n),null);case 22:case 23:return _i(n),bf(),o=n.memoizedState!==null,t!==null?t.memoizedState!==null!==o&&(n.flags|=8192):o&&(n.flags|=8192),o?(r&536870912)!==0&&(n.flags&128)===0&&(mn(n),n.subtreeFlags&6&&(n.flags|=8192)):mn(n),r=n.updateQueue,r!==null&&fc(n,r.retryQueue),r=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==r&&(n.flags|=2048),t!==null&&J(Fs),null;case 24:return r=null,t!==null&&(r=t.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),ga(Tn),mn(n),null;case 25:return null;case 30:return null}throw Error(s(156,n.tag))}function CS(t,n){switch(lf(n),n.tag){case 1:return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return ga(Tn),He(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 26:case 27:case 5:return Ke(n),null;case 31:if(n.memoizedState!==null){if(_i(n),n.alternate===null)throw Error(s(340));Ps()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 13:if(_i(n),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(s(340));Ps()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return J(bn),null;case 4:return He(),null;case 10:return ga(n.type),null;case 22:case 23:return _i(n),bf(),t!==null&&J(Fs),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 24:return ga(Tn),null;case 25:return null;default:return null}}function c0(t,n){switch(lf(n),n.tag){case 3:ga(Tn),He();break;case 26:case 27:case 5:Ke(n);break;case 4:He();break;case 31:n.memoizedState!==null&&_i(n);break;case 13:_i(n);break;case 19:J(bn);break;case 10:ga(n.type);break;case 22:case 23:_i(n),bf(),t!==null&&J(Fs);break;case 24:ga(Tn)}}function ko(t,n){try{var r=n.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 d=r.create,M=r.inst;o=d(),M.destroy=o}r=r.next}while(r!==u)}}catch(R){nn(n,n.return,R)}}function ts(t,n,r){try{var o=n.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var d=u.next;o=d;do{if((o.tag&t)===t){var M=o.inst,R=M.destroy;if(R!==void 0){M.destroy=void 0,u=n;var k=r,le=R;try{le()}catch(be){nn(u,k,be)}}}o=o.next}while(o!==d)}}catch(be){nn(n,n.return,be)}}function u0(t){var n=t.updateQueue;if(n!==null){var r=t.stateNode;try{eg(n,r)}catch(o){nn(t,t.return,o)}}}function f0(t,n,r){r.props=ks(t.type,t.memoizedProps),r.state=t.memoizedState;try{r.componentWillUnmount()}catch(o){nn(t,n,o)}}function jo(t,n){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){nn(t,n,u)}}function ea(t,n){var r=t.ref,o=t.refCleanup;if(r!==null)if(typeof o=="function")try{o()}catch(u){nn(t,n,u)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(u){nn(t,n,u)}else r.current=null}function d0(t){var n=t.type,r=t.memoizedProps,o=t.stateNode;try{e:switch(n){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){nn(t,t.return,u)}}function td(t,n,r){try{var o=t.stateNode;ZS(o,t.type,r,n),o[Ge]=n}catch(u){nn(t,t.return,u)}}function h0(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&ls(t.type)||t.tag===4}function nd(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||h0(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&&ls(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 id(t,n,r){var o=t.tag;if(o===5||o===6)t=t.stateNode,n?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(t,n):(n=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,n.appendChild(t),r=r._reactRootContainer,r!=null||n.onclick!==null||(n.onclick=fa));else if(o!==4&&(o===27&&ls(t.type)&&(r=t.stateNode,n=null),t=t.child,t!==null))for(id(t,n,r),t=t.sibling;t!==null;)id(t,n,r),t=t.sibling}function dc(t,n,r){var o=t.tag;if(o===5||o===6)t=t.stateNode,n?r.insertBefore(t,n):r.appendChild(t);else if(o!==4&&(o===27&&ls(t.type)&&(r=t.stateNode),t=t.child,t!==null))for(dc(t,n,r),t=t.sibling;t!==null;)dc(t,n,r),t=t.sibling}function p0(t){var n=t.stateNode,r=t.memoizedProps;try{for(var o=t.type,u=n.attributes;u.length;)n.removeAttributeNode(u[0]);Xn(n,o,r),n[we]=t,n[Ge]=r}catch(d){nn(t,t.return,d)}}var Sa=!1,wn=!1,ad=!1,m0=typeof WeakSet=="function"?WeakSet:Set,Fn=null;function wS(t,n){if(t=t.containerInfo,Td=Lc,t=Cm(t),Ku(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,d=o.focusNode;o=o.focusOffset;try{r.nodeType,d.nodeType}catch{r=null;break e}var M=0,R=-1,k=-1,le=0,be=0,Re=t,de=null;t:for(;;){for(var ve;Re!==r||u!==0&&Re.nodeType!==3||(R=M+u),Re!==d||o!==0&&Re.nodeType!==3||(k=M+o),Re.nodeType===3&&(M+=Re.nodeValue.length),(ve=Re.firstChild)!==null;)de=Re,Re=ve;for(;;){if(Re===t)break t;if(de===r&&++le===u&&(R=M),de===d&&++be===o&&(k=M),(ve=Re.nextSibling)!==null)break;Re=de,de=Re.parentNode}Re=ve}r=R===-1||k===-1?null:{start:R,end:k}}else r=null}r=r||{start:0,end:0}}else r=null;for(Ad={focusedElem:t,selectionRange:r},Lc=!1,Fn=n;Fn!==null;)if(n=Fn,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,Fn=t;else for(;Fn!==null;){switch(n=Fn,d=n.alternate,t=n.flags,n.tag){case 0:if((t&4)!==0&&(t=n.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&&d!==null){t=void 0,r=n,u=d.memoizedProps,d=d.memoizedState,o=r.stateNode;try{var tt=ks(r.type,u);t=o.getSnapshotBeforeUpdate(tt,d),o.__reactInternalSnapshotBeforeUpdate=t}catch(mt){nn(r,r.return,mt)}}break;case 3:if((t&1024)!==0){if(t=n.stateNode.containerInfo,r=t.nodeType,r===9)Rd(t);else if(r===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":Rd(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=n.sibling,t!==null){t.return=n.return,Fn=t;break}Fn=n.return}}function g0(t,n,r){var o=r.flags;switch(r.tag){case 0:case 11:case 15:ba(t,r),o&4&&ko(5,r);break;case 1:if(ba(t,r),o&4)if(t=r.stateNode,n===null)try{t.componentDidMount()}catch(M){nn(r,r.return,M)}else{var u=ks(r.type,n.memoizedProps);n=n.memoizedState;try{t.componentDidUpdate(u,n,t.__reactInternalSnapshotBeforeUpdate)}catch(M){nn(r,r.return,M)}}o&64&&u0(r),o&512&&jo(r,r.return);break;case 3:if(ba(t,r),o&64&&(t=r.updateQueue,t!==null)){if(n=null,r.child!==null)switch(r.child.tag){case 27:case 5:n=r.child.stateNode;break;case 1:n=r.child.stateNode}try{eg(t,n)}catch(M){nn(r,r.return,M)}}break;case 27:n===null&&o&4&&p0(r);case 26:case 5:ba(t,r),n===null&&o&4&&d0(r),o&512&&jo(r,r.return);break;case 12:ba(t,r);break;case 31:ba(t,r),o&4&&x0(t,r);break;case 13:ba(t,r),o&4&&y0(t,r),o&64&&(t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(r=BS.bind(null,r),iM(t,r))));break;case 22:if(o=r.memoizedState!==null||Sa,!o){n=n!==null&&n.memoizedState!==null||wn,u=Sa;var d=wn;Sa=o,(wn=n)&&!d?Ea(t,r,(r.subtreeFlags&8772)!==0):ba(t,r),Sa=u,wn=d}break;case 30:break;default:ba(t,r)}}function _0(t){var n=t.alternate;n!==null&&(t.alternate=null,_0(n)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(n=t.stateNode,n!==null&&yn(n)),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 vn=null,ni=!1;function Ma(t,n,r){for(r=r.child;r!==null;)v0(t,n,r),r=r.sibling}function v0(t,n,r){if(he&&typeof he.onCommitFiberUnmount=="function")try{he.onCommitFiberUnmount(_e,r)}catch{}switch(r.tag){case 26:wn||ea(r,n),Ma(t,n,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:wn||ea(r,n);var o=vn,u=ni;ls(r.type)&&(vn=r.stateNode,ni=!1),Ma(t,n,r),Jo(r.stateNode),vn=o,ni=u;break;case 5:wn||ea(r,n);case 6:if(o=vn,u=ni,vn=null,Ma(t,n,r),vn=o,ni=u,vn!==null)if(ni)try{(vn.nodeType===9?vn.body:vn.nodeName==="HTML"?vn.ownerDocument.body:vn).removeChild(r.stateNode)}catch(d){nn(r,n,d)}else try{vn.removeChild(r.stateNode)}catch(d){nn(r,n,d)}break;case 18:vn!==null&&(ni?(t=vn,u_(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,r.stateNode),Br(t)):u_(vn,r.stateNode));break;case 4:o=vn,u=ni,vn=r.stateNode.containerInfo,ni=!0,Ma(t,n,r),vn=o,ni=u;break;case 0:case 11:case 14:case 15:ts(2,r,n),wn||ts(4,r,n),Ma(t,n,r);break;case 1:wn||(ea(r,n),o=r.stateNode,typeof o.componentWillUnmount=="function"&&f0(r,n,o)),Ma(t,n,r);break;case 21:Ma(t,n,r);break;case 22:wn=(o=wn)||r.memoizedState!==null,Ma(t,n,r),wn=o;break;default:Ma(t,n,r)}}function x0(t,n){if(n.memoizedState===null&&(t=n.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{Br(t)}catch(r){nn(n,n.return,r)}}}function y0(t,n){if(n.memoizedState===null&&(t=n.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{Br(t)}catch(r){nn(n,n.return,r)}}function RS(t){switch(t.tag){case 31:case 13:case 19:var n=t.stateNode;return n===null&&(n=t.stateNode=new m0),n;case 22:return t=t.stateNode,n=t._retryCache,n===null&&(n=t._retryCache=new m0),n;default:throw Error(s(435,t.tag))}}function hc(t,n){var r=RS(t);n.forEach(function(o){if(!r.has(o)){r.add(o);var u=FS.bind(null,t,o);o.then(u,u)}})}function ii(t,n){var r=n.deletions;if(r!==null)for(var o=0;o<r.length;o++){var u=r[o],d=t,M=n,R=M;e:for(;R!==null;){switch(R.tag){case 27:if(ls(R.type)){vn=R.stateNode,ni=!1;break e}break;case 5:vn=R.stateNode,ni=!1;break e;case 3:case 4:vn=R.stateNode.containerInfo,ni=!0;break e}R=R.return}if(vn===null)throw Error(s(160));v0(d,M,u),vn=null,ni=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)S0(n,t),n=n.sibling}var Vi=null;function S0(t,n){var r=t.alternate,o=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:ii(n,t),ai(t),o&4&&(ts(3,t,t.return),ko(3,t),ts(5,t,t.return));break;case 1:ii(n,t),ai(t),o&512&&(wn||r===null||ea(r,r.return)),o&64&&Sa&&(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=Vi;if(ii(n,t),ai(t),o&512&&(wn||r===null||ea(r,r.return)),o&4){var d=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":d=u.getElementsByTagName("title")[0],(!d||d[hn]||d[we]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(o),u.head.insertBefore(d,u.querySelector("head > title"))),Xn(d,o,r),d[we]=t,Kt(d),o=d;break e;case"link":var M=S_("link","href",u).get(o+(r.href||""));if(M){for(var R=0;R<M.length;R++)if(d=M[R],d.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&d.getAttribute("rel")===(r.rel==null?null:r.rel)&&d.getAttribute("title")===(r.title==null?null:r.title)&&d.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){M.splice(R,1);break t}}d=u.createElement(o),Xn(d,o,r),u.head.appendChild(d);break;case"meta":if(M=S_("meta","content",u).get(o+(r.content||""))){for(R=0;R<M.length;R++)if(d=M[R],d.getAttribute("content")===(r.content==null?null:""+r.content)&&d.getAttribute("name")===(r.name==null?null:r.name)&&d.getAttribute("property")===(r.property==null?null:r.property)&&d.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&d.getAttribute("charset")===(r.charSet==null?null:r.charSet)){M.splice(R,1);break t}}d=u.createElement(o),Xn(d,o,r),u.head.appendChild(d);break;default:throw Error(s(468,o))}d[we]=t,Kt(d),o=d}t.stateNode=o}else M_(u,t.type,t.stateNode);else t.stateNode=y_(u,o,t.memoizedProps);else d!==o?(d===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):d.count--,o===null?M_(u,t.type,t.stateNode):y_(u,o,t.memoizedProps)):o===null&&t.stateNode!==null&&td(t,t.memoizedProps,r.memoizedProps)}break;case 27:ii(n,t),ai(t),o&512&&(wn||r===null||ea(r,r.return)),r!==null&&o&4&&td(t,t.memoizedProps,r.memoizedProps);break;case 5:if(ii(n,t),ai(t),o&512&&(wn||r===null||ea(r,r.return)),t.flags&32){u=t.stateNode;try{hi(u,"")}catch(tt){nn(t,t.return,tt)}}o&4&&t.stateNode!=null&&(u=t.memoizedProps,td(t,u,r!==null?r.memoizedProps:u)),o&1024&&(ad=!0);break;case 6:if(ii(n,t),ai(t),o&4){if(t.stateNode===null)throw Error(s(162));o=t.memoizedProps,r=t.stateNode;try{r.nodeValue=o}catch(tt){nn(t,t.return,tt)}}break;case 3:if(Rc=null,u=Vi,Vi=Cc(n.containerInfo),ii(n,t),Vi=u,ai(t),o&4&&r!==null&&r.memoizedState.isDehydrated)try{Br(n.containerInfo)}catch(tt){nn(t,t.return,tt)}ad&&(ad=!1,M0(t));break;case 4:o=Vi,Vi=Cc(t.stateNode.containerInfo),ii(n,t),ai(t),Vi=o;break;case 12:ii(n,t),ai(t);break;case 31:ii(n,t),ai(t),o&4&&(o=t.updateQueue,o!==null&&(t.updateQueue=null,hc(t,o)));break;case 13:ii(n,t),ai(t),t.child.flags&8192&&t.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(mc=Ye()),o&4&&(o=t.updateQueue,o!==null&&(t.updateQueue=null,hc(t,o)));break;case 22:u=t.memoizedState!==null;var k=r!==null&&r.memoizedState!==null,le=Sa,be=wn;if(Sa=le||u,wn=be||k,ii(n,t),wn=be,Sa=le,ai(t),o&8192)e:for(n=t.stateNode,n._visibility=u?n._visibility&-2:n._visibility|1,u&&(r===null||k||Sa||wn||js(t)),r=null,n=t;;){if(n.tag===5||n.tag===26){if(r===null){k=r=n;try{if(d=k.stateNode,u)M=d.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none";else{R=k.stateNode;var Re=k.memoizedProps.style,de=Re!=null&&Re.hasOwnProperty("display")?Re.display:null;R.style.display=de==null||typeof de=="boolean"?"":(""+de).trim()}}catch(tt){nn(k,k.return,tt)}}}else if(n.tag===6){if(r===null){k=n;try{k.stateNode.nodeValue=u?"":k.memoizedProps}catch(tt){nn(k,k.return,tt)}}}else if(n.tag===18){if(r===null){k=n;try{var ve=k.stateNode;u?f_(ve,!0):f_(k.stateNode,!1)}catch(tt){nn(k,k.return,tt)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===t)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break e;for(;n.sibling===null;){if(n.return===null||n.return===t)break e;r===n&&(r=null),n=n.return}r===n&&(r=null),n.sibling.return=n.return,n=n.sibling}o&4&&(o=t.updateQueue,o!==null&&(r=o.retryQueue,r!==null&&(o.retryQueue=null,hc(t,r))));break;case 19:ii(n,t),ai(t),o&4&&(o=t.updateQueue,o!==null&&(t.updateQueue=null,hc(t,o)));break;case 30:break;case 21:break;default:ii(n,t),ai(t)}}function ai(t){var n=t.flags;if(n&2){try{for(var r,o=t.return;o!==null;){if(h0(o)){r=o;break}o=o.return}if(r==null)throw Error(s(160));switch(r.tag){case 27:var u=r.stateNode,d=nd(t);dc(t,d,u);break;case 5:var M=r.stateNode;r.flags&32&&(hi(M,""),r.flags&=-33);var R=nd(t);dc(t,R,M);break;case 3:case 4:var k=r.stateNode.containerInfo,le=nd(t);id(t,le,k);break;default:throw Error(s(161))}}catch(be){nn(t,t.return,be)}t.flags&=-3}n&4096&&(t.flags&=-4097)}function M0(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var n=t;M0(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),t=t.sibling}}function ba(t,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)g0(t,n.alternate,n),n=n.sibling}function js(t){for(t=t.child;t!==null;){var n=t;switch(n.tag){case 0:case 11:case 14:case 15:ts(4,n,n.return),js(n);break;case 1:ea(n,n.return);var r=n.stateNode;typeof r.componentWillUnmount=="function"&&f0(n,n.return,r),js(n);break;case 27:Jo(n.stateNode);case 26:case 5:ea(n,n.return),js(n);break;case 22:n.memoizedState===null&&js(n);break;case 30:js(n);break;default:js(n)}t=t.sibling}}function Ea(t,n,r){for(r=r&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var o=n.alternate,u=t,d=n,M=d.flags;switch(d.tag){case 0:case 11:case 15:Ea(u,d,r),ko(4,d);break;case 1:if(Ea(u,d,r),o=d,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(le){nn(o,o.return,le)}if(o=d,u=o.updateQueue,u!==null){var R=o.stateNode;try{var k=u.shared.hiddenCallbacks;if(k!==null)for(u.shared.hiddenCallbacks=null,u=0;u<k.length;u++)Jm(k[u],R)}catch(le){nn(o,o.return,le)}}r&&M&64&&u0(d),jo(d,d.return);break;case 27:p0(d);case 26:case 5:Ea(u,d,r),r&&o===null&&M&4&&d0(d),jo(d,d.return);break;case 12:Ea(u,d,r);break;case 31:Ea(u,d,r),r&&M&4&&x0(u,d);break;case 13:Ea(u,d,r),r&&M&4&&y0(u,d);break;case 22:d.memoizedState===null&&Ea(u,d,r),jo(d,d.return);break;case 30:break;default:Ea(u,d,r)}n=n.sibling}}function sd(t,n){var r=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),t=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(t=n.memoizedState.cachePool.pool),t!==r&&(t!=null&&t.refCount++,r!=null&&Do(r))}function rd(t,n){t=null,n.alternate!==null&&(t=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==t&&(n.refCount++,t!=null&&Do(t))}function ki(t,n,r,o){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)b0(t,n,r,o),n=n.sibling}function b0(t,n,r,o){var u=n.flags;switch(n.tag){case 0:case 11:case 15:ki(t,n,r,o),u&2048&&ko(9,n);break;case 1:ki(t,n,r,o);break;case 3:ki(t,n,r,o),u&2048&&(t=null,n.alternate!==null&&(t=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==t&&(n.refCount++,t!=null&&Do(t)));break;case 12:if(u&2048){ki(t,n,r,o),t=n.stateNode;try{var d=n.memoizedProps,M=d.id,R=d.onPostCommit;typeof R=="function"&&R(M,n.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(k){nn(n,n.return,k)}}else ki(t,n,r,o);break;case 31:ki(t,n,r,o);break;case 13:ki(t,n,r,o);break;case 23:break;case 22:d=n.stateNode,M=n.alternate,n.memoizedState!==null?d._visibility&2?ki(t,n,r,o):Xo(t,n):d._visibility&2?ki(t,n,r,o):(d._visibility|=2,Ar(t,n,r,o,(n.subtreeFlags&10256)!==0||!1)),u&2048&&sd(M,n);break;case 24:ki(t,n,r,o),u&2048&&rd(n.alternate,n);break;default:ki(t,n,r,o)}}function Ar(t,n,r,o,u){for(u=u&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var d=t,M=n,R=r,k=o,le=M.flags;switch(M.tag){case 0:case 11:case 15:Ar(d,M,R,k,u),ko(8,M);break;case 23:break;case 22:var be=M.stateNode;M.memoizedState!==null?be._visibility&2?Ar(d,M,R,k,u):Xo(d,M):(be._visibility|=2,Ar(d,M,R,k,u)),u&&le&2048&&sd(M.alternate,M);break;case 24:Ar(d,M,R,k,u),u&&le&2048&&rd(M.alternate,M);break;default:Ar(d,M,R,k,u)}n=n.sibling}}function Xo(t,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var r=t,o=n,u=o.flags;switch(o.tag){case 22:Xo(r,o),u&2048&&sd(o.alternate,o);break;case 24:Xo(r,o),u&2048&&rd(o.alternate,o);break;default:Xo(r,o)}n=n.sibling}}var Wo=8192;function Cr(t,n,r){if(t.subtreeFlags&Wo)for(t=t.child;t!==null;)E0(t,n,r),t=t.sibling}function E0(t,n,r){switch(t.tag){case 26:Cr(t,n,r),t.flags&Wo&&t.memoizedState!==null&&mM(r,Vi,t.memoizedState,t.memoizedProps);break;case 5:Cr(t,n,r);break;case 3:case 4:var o=Vi;Vi=Cc(t.stateNode.containerInfo),Cr(t,n,r),Vi=o;break;case 22:t.memoizedState===null&&(o=t.alternate,o!==null&&o.memoizedState!==null?(o=Wo,Wo=16777216,Cr(t,n,r),Wo=o):Cr(t,n,r));break;default:Cr(t,n,r)}}function T0(t){var n=t.alternate;if(n!==null&&(t=n.child,t!==null)){n.child=null;do n=t.sibling,t.sibling=null,t=n;while(t!==null)}}function qo(t){var n=t.deletions;if((t.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var o=n[r];Fn=o,C0(o,t)}T0(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)A0(t),t=t.sibling}function A0(t){switch(t.tag){case 0:case 11:case 15:qo(t),t.flags&2048&&ts(9,t,t.return);break;case 3:qo(t);break;case 12:qo(t);break;case 22:var n=t.stateNode;t.memoizedState!==null&&n._visibility&2&&(t.return===null||t.return.tag!==13)?(n._visibility&=-3,pc(t)):qo(t);break;default:qo(t)}}function pc(t){var n=t.deletions;if((t.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var o=n[r];Fn=o,C0(o,t)}T0(t)}for(t=t.child;t!==null;){switch(n=t,n.tag){case 0:case 11:case 15:ts(8,n,n.return),pc(n);break;case 22:r=n.stateNode,r._visibility&2&&(r._visibility&=-3,pc(n));break;default:pc(n)}t=t.sibling}}function C0(t,n){for(;Fn!==null;){var r=Fn;switch(r.tag){case 0:case 11:case 15:ts(8,r,n);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:Do(r.memoizedState.cache)}if(o=r.child,o!==null)o.return=r,Fn=o;else e:for(r=t;Fn!==null;){o=Fn;var u=o.sibling,d=o.return;if(_0(o),o===r){Fn=null;break e}if(u!==null){u.return=d,Fn=u;break e}Fn=d}}}var DS={getCacheForType:function(t){var n=kn(Tn),r=n.data.get(t);return r===void 0&&(r=t(),n.data.set(t,r)),r},cacheSignal:function(){return kn(Tn).controller.signal}},NS=typeof WeakMap=="function"?WeakMap:Map,Yt=0,un=null,Lt=null,Bt=0,tn=0,vi=null,ns=!1,wr=!1,od=!1,Ta=0,Mn=0,is=0,Xs=0,ld=0,xi=0,Rr=0,Yo=null,si=null,cd=!1,mc=0,w0=0,gc=1/0,_c=null,as=null,Nn=0,ss=null,Dr=null,Aa=0,ud=0,fd=null,R0=null,Zo=0,dd=null;function yi(){return(Yt&2)!==0&&Bt!==0?Bt&-Bt:H.T!==null?vd():Va()}function D0(){if(xi===0)if((Bt&536870912)===0||Vt){var t=pt;pt<<=1,(pt&3932160)===0&&(pt=262144),xi=t}else xi=536870912;return t=gi.current,t!==null&&(t.flags|=32),xi}function ri(t,n,r){(t===un&&(tn===2||tn===9)||t.cancelPendingCommit!==null)&&(Nr(t,0),rs(t,Bt,xi,!1)),De(t,r),((Yt&2)===0||t!==un)&&(t===un&&((Yt&2)===0&&(Xs|=r),Mn===4&&rs(t,Bt,xi,!1)),ta(t))}function N0(t,n,r){if((Yt&6)!==0)throw Error(s(327));var o=!r&&(n&127)===0&&(n&t.expiredLanes)===0||Be(t,n),u=o?OS(t,n):pd(t,n,!0),d=o;do{if(u===0){wr&&!o&&rs(t,n,0,!1);break}else{if(r=t.current.alternate,d&&!US(r)){u=pd(t,n,!1),d=!1;continue}if(u===2){if(d=n,t.errorRecoveryDisabledLanes&d)var M=0;else M=t.pendingLanes&-536870913,M=M!==0?M:M&536870912?536870912:0;if(M!==0){n=M;e:{var R=t;u=Yo;var k=R.current.memoizedState.isDehydrated;if(k&&(Nr(R,M).flags|=256),M=pd(R,M,!1),M!==2){if(od&&!k){R.errorRecoveryDisabledLanes|=d,Xs|=d,u=4;break e}d=si,si=u,d!==null&&(si===null?si=d:si.push.apply(si,d))}u=M}if(d=!1,u!==2)continue}}if(u===1){Nr(t,0),rs(t,n,0,!0);break}e:{switch(o=t,d=u,d){case 0:case 1:throw Error(s(345));case 4:if((n&4194048)!==n)break;case 6:rs(o,n,xi,!ns);break e;case 2:si=null;break;case 3:case 5:break;default:throw Error(s(329))}if((n&62914560)===n&&(u=mc+300-Ye(),10<u)){if(rs(o,n,xi,!ns),Se(o,0,!0)!==0)break e;Aa=n,o.timeoutHandle=l_(U0.bind(null,o,r,si,_c,cd,n,xi,Xs,Rr,ns,d,"Throttled",-0,0),u);break e}U0(o,r,si,_c,cd,n,xi,Xs,Rr,ns,d,null,-0,0)}}break}while(!0);ta(t)}function U0(t,n,r,o,u,d,M,R,k,le,be,Re,de,ve){if(t.timeoutHandle=-1,Re=n.subtreeFlags,Re&8192||(Re&16785408)===16785408){Re={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:fa},E0(n,d,Re);var tt=(d&62914560)===d?mc-Ye():(d&4194048)===d?w0-Ye():0;if(tt=gM(Re,tt),tt!==null){Aa=d,t.cancelPendingCommit=tt(H0.bind(null,t,n,d,r,o,u,M,R,k,be,Re,null,de,ve)),rs(t,d,M,!le);return}}H0(t,n,d,r,o,u,M,R,k)}function US(t){for(var n=t;;){var r=n.tag;if((r===0||r===11||r===15)&&n.flags&16384&&(r=n.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var o=0;o<r.length;o++){var u=r[o],d=u.getSnapshot;u=u.value;try{if(!pi(d(),u))return!1}catch{return!1}}if(r=n.child,n.subtreeFlags&16384&&r!==null)r.return=n,n=r;else{if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function rs(t,n,r,o){n&=~ld,n&=~Xs,t.suspendedLanes|=n,t.pingedLanes&=~n,o&&(t.warmLanes|=n),o=t.expirationTimes;for(var u=n;0<u;){var d=31-je(u),M=1<<d;o[d]=-1,u&=~M}r!==0&&rt(t,r,n)}function vc(){return(Yt&6)===0?(Ko(0),!1):!0}function hd(){if(Lt!==null){if(tn===0)var t=Lt.return;else t=Lt,ma=Is=null,Rf(t),Sr=null,Uo=0,t=Lt;for(;t!==null;)c0(t.alternate,t),t=t.return;Lt=null}}function Nr(t,n){var r=t.timeoutHandle;r!==-1&&(t.timeoutHandle=-1,QS(r)),r=t.cancelPendingCommit,r!==null&&(t.cancelPendingCommit=null,r()),Aa=0,hd(),un=t,Lt=r=ha(t.current,null),Bt=n,tn=0,vi=null,ns=!1,wr=Be(t,n),od=!1,Rr=xi=ld=Xs=is=Mn=0,si=Yo=null,cd=!1,(n&8)!==0&&(n|=n&32);var o=t.entangledLanes;if(o!==0)for(t=t.entanglements,o&=n;0<o;){var u=31-je(o),d=1<<u;n|=t[u],o&=~d}return Ta=n,zl(),r}function L0(t,n){wt=null,H.H=Ho,n===yr||n===ql?(n=Zm(),tn=3):n===_f?(n=Zm(),tn=4):tn=n===Xf?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,vi=n,Lt===null&&(Mn=1,oc(t,Ci(n,t.current)))}function O0(){var t=gi.current;return t===null?!0:(Bt&4194048)===Bt?Ni===null:(Bt&62914560)===Bt||(Bt&536870912)!==0?t===Ni:!1}function P0(){var t=H.H;return H.H=Ho,t===null?Ho:t}function I0(){var t=H.A;return H.A=DS,t}function xc(){Mn=4,ns||(Bt&4194048)!==Bt&&gi.current!==null||(wr=!0),(is&134217727)===0&&(Xs&134217727)===0||un===null||rs(un,Bt,xi,!1)}function pd(t,n,r){var o=Yt;Yt|=2;var u=P0(),d=I0();(un!==t||Bt!==n)&&(_c=null,Nr(t,n)),n=!1;var M=Mn;e:do try{if(tn!==0&&Lt!==null){var R=Lt,k=vi;switch(tn){case 8:hd(),M=6;break e;case 3:case 2:case 9:case 6:gi.current===null&&(n=!0);var le=tn;if(tn=0,vi=null,Ur(t,R,k,le),r&&wr){M=0;break e}break;default:le=tn,tn=0,vi=null,Ur(t,R,k,le)}}LS(),M=Mn;break}catch(be){L0(t,be)}while(!0);return n&&t.shellSuspendCounter++,ma=Is=null,Yt=o,H.H=u,H.A=d,Lt===null&&(un=null,Bt=0,zl()),M}function LS(){for(;Lt!==null;)B0(Lt)}function OS(t,n){var r=Yt;Yt|=2;var o=P0(),u=I0();un!==t||Bt!==n?(_c=null,gc=Ye()+500,Nr(t,n)):wr=Be(t,n);e:do try{if(tn!==0&&Lt!==null){n=Lt;var d=vi;t:switch(tn){case 1:tn=0,vi=null,Ur(t,n,d,1);break;case 2:case 9:if(qm(d)){tn=0,vi=null,F0(n);break}n=function(){tn!==2&&tn!==9||un!==t||(tn=7),ta(t)},d.then(n,n);break e;case 3:tn=7;break e;case 4:tn=5;break e;case 7:qm(d)?(tn=0,vi=null,F0(n)):(tn=0,vi=null,Ur(t,n,d,7));break;case 5:var M=null;switch(Lt.tag){case 26:M=Lt.memoizedState;case 5:case 27:var R=Lt;if(M?b_(M):R.stateNode.complete){tn=0,vi=null;var k=R.sibling;if(k!==null)Lt=k;else{var le=R.return;le!==null?(Lt=le,yc(le)):Lt=null}break t}}tn=0,vi=null,Ur(t,n,d,5);break;case 6:tn=0,vi=null,Ur(t,n,d,6);break;case 8:hd(),Mn=6;break e;default:throw Error(s(462))}}PS();break}catch(be){L0(t,be)}while(!0);return ma=Is=null,H.H=o,H.A=u,Yt=r,Lt!==null?0:(un=null,Bt=0,zl(),Mn)}function PS(){for(;Lt!==null&&!W();)B0(Lt)}function B0(t){var n=o0(t.alternate,t,Ta);t.memoizedProps=t.pendingProps,n===null?yc(t):Lt=n}function F0(t){var n=t,r=n.alternate;switch(n.tag){case 15:case 0:n=t0(r,n,n.pendingProps,n.type,void 0,Bt);break;case 11:n=t0(r,n,n.pendingProps,n.type.render,n.ref,Bt);break;case 5:Rf(n);default:c0(r,n),n=Lt=Im(n,Ta),n=o0(r,n,Ta)}t.memoizedProps=t.pendingProps,n===null?yc(t):Lt=n}function Ur(t,n,r,o){ma=Is=null,Rf(n),Sr=null,Uo=0;var u=n.return;try{if(bS(t,u,n,r,Bt)){Mn=1,oc(t,Ci(r,t.current)),Lt=null;return}}catch(d){if(u!==null)throw Lt=u,d;Mn=1,oc(t,Ci(r,t.current)),Lt=null;return}n.flags&32768?(Vt||o===1?t=!0:wr||(Bt&536870912)!==0?t=!1:(ns=t=!0,(o===2||o===9||o===3||o===6)&&(o=gi.current,o!==null&&o.tag===13&&(o.flags|=16384))),z0(n,t)):yc(n)}function yc(t){var n=t;do{if((n.flags&32768)!==0){z0(n,ns);return}t=n.return;var r=AS(n.alternate,n,Ta);if(r!==null){Lt=r;return}if(n=n.sibling,n!==null){Lt=n;return}Lt=n=t}while(n!==null);Mn===0&&(Mn=5)}function z0(t,n){do{var r=CS(t.alternate,t);if(r!==null){r.flags&=32767,Lt=r;return}if(r=t.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!n&&(t=t.sibling,t!==null)){Lt=t;return}Lt=t=r}while(t!==null);Mn=6,Lt=null}function H0(t,n,r,o,u,d,M,R,k){t.cancelPendingCommit=null;do Sc();while(Nn!==0);if((Yt&6)!==0)throw Error(s(327));if(n!==null){if(n===t.current)throw Error(s(177));if(d=n.lanes|n.childLanes,d|=tf,ft(t,r,d,M,R,k),t===un&&(Lt=un=null,Bt=0),Dr=n,ss=t,Aa=r,ud=d,fd=u,R0=o,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,zS(X,function(){return X0(),null})):(t.callbackNode=null,t.callbackPriority=0),o=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||o){o=H.T,H.T=null,u=G.p,G.p=2,M=Yt,Yt|=4;try{wS(t,n,r)}finally{Yt=M,G.p=u,H.T=o}}Nn=1,G0(),V0(),k0()}}function G0(){if(Nn===1){Nn=0;var t=ss,n=Dr,r=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||r){r=H.T,H.T=null;var o=G.p;G.p=2;var u=Yt;Yt|=4;try{S0(n,t);var d=Ad,M=Cm(t.containerInfo),R=d.focusedElem,k=d.selectionRange;if(M!==R&&R&&R.ownerDocument&&Am(R.ownerDocument.documentElement,R)){if(k!==null&&Ku(R)){var le=k.start,be=k.end;if(be===void 0&&(be=le),"selectionStart"in R)R.selectionStart=le,R.selectionEnd=Math.min(be,R.value.length);else{var Re=R.ownerDocument||document,de=Re&&Re.defaultView||window;if(de.getSelection){var ve=de.getSelection(),tt=R.textContent.length,mt=Math.min(k.start,tt),on=k.end===void 0?mt:Math.min(k.end,tt);!ve.extend&&mt>on&&(M=on,on=mt,mt=M);var te=Tm(R,mt),Y=Tm(R,on);if(te&&Y&&(ve.rangeCount!==1||ve.anchorNode!==te.node||ve.anchorOffset!==te.offset||ve.focusNode!==Y.node||ve.focusOffset!==Y.offset)){var oe=Re.createRange();oe.setStart(te.node,te.offset),ve.removeAllRanges(),mt>on?(ve.addRange(oe),ve.extend(Y.node,Y.offset)):(oe.setEnd(Y.node,Y.offset),ve.addRange(oe))}}}}for(Re=[],ve=R;ve=ve.parentNode;)ve.nodeType===1&&Re.push({element:ve,left:ve.scrollLeft,top:ve.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<Re.length;R++){var Te=Re[R];Te.element.scrollLeft=Te.left,Te.element.scrollTop=Te.top}}Lc=!!Td,Ad=Td=null}finally{Yt=u,G.p=o,H.T=r}}t.current=n,Nn=2}}function V0(){if(Nn===2){Nn=0;var t=ss,n=Dr,r=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||r){r=H.T,H.T=null;var o=G.p;G.p=2;var u=Yt;Yt|=4;try{g0(t,n.alternate,n)}finally{Yt=u,G.p=o,H.T=r}}Nn=3}}function k0(){if(Nn===4||Nn===3){Nn=0,z();var t=ss,n=Dr,r=Aa,o=R0;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Nn=5:(Nn=0,Dr=ss=null,j0(t,t.pendingLanes));var u=t.pendingLanes;if(u===0&&(as=null),Ga(r),n=n.stateNode,he&&typeof he.onCommitFiberRoot=="function")try{he.onCommitFiberRoot(_e,n,void 0,(n.current.flags&128)===128)}catch{}if(o!==null){n=H.T,u=G.p,G.p=2,H.T=null;try{for(var d=t.onRecoverableError,M=0;M<o.length;M++){var R=o[M];d(R.value,{componentStack:R.stack})}}finally{H.T=n,G.p=u}}(Aa&3)!==0&&Sc(),ta(t),u=t.pendingLanes,(r&261930)!==0&&(u&42)!==0?t===dd?Zo++:(Zo=0,dd=t):Zo=0,Ko(0)}}function j0(t,n){(t.pooledCacheLanes&=n)===0&&(n=t.pooledCache,n!=null&&(t.pooledCache=null,Do(n)))}function Sc(){return G0(),V0(),k0(),X0()}function X0(){if(Nn!==5)return!1;var t=ss,n=ud;ud=0;var r=Ga(Aa),o=H.T,u=G.p;try{G.p=32>r?32:r,H.T=null,r=fd,fd=null;var d=ss,M=Aa;if(Nn=0,Dr=ss=null,Aa=0,(Yt&6)!==0)throw Error(s(331));var R=Yt;if(Yt|=4,A0(d.current),b0(d,d.current,M,r),Yt=R,Ko(0,!1),he&&typeof he.onPostCommitFiberRoot=="function")try{he.onPostCommitFiberRoot(_e,d)}catch{}return!0}finally{G.p=u,H.T=o,j0(t,n)}}function W0(t,n,r){n=Ci(r,n),n=jf(t.stateNode,n,2),t=Qa(t,n,2),t!==null&&(De(t,2),ta(t))}function nn(t,n,r){if(t.tag===3)W0(t,t,r);else for(;n!==null;){if(n.tag===3){W0(n,t,r);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(as===null||!as.has(o))){t=Ci(r,t),r=qg(2),o=Qa(n,r,2),o!==null&&(Yg(r,o,n,t),De(o,2),ta(o));break}}n=n.return}}function md(t,n,r){var o=t.pingCache;if(o===null){o=t.pingCache=new NS;var u=new Set;o.set(n,u)}else u=o.get(n),u===void 0&&(u=new Set,o.set(n,u));u.has(r)||(od=!0,u.add(r),t=IS.bind(null,t,n,r),n.then(t,t))}function IS(t,n,r){var o=t.pingCache;o!==null&&o.delete(n),t.pingedLanes|=t.suspendedLanes&r,t.warmLanes&=~r,un===t&&(Bt&r)===r&&(Mn===4||Mn===3&&(Bt&62914560)===Bt&&300>Ye()-mc?(Yt&2)===0&&Nr(t,0):ld|=r,Rr===Bt&&(Rr=0)),ta(t)}function q0(t,n){n===0&&(n=q()),t=Ls(t,n),t!==null&&(De(t,n),ta(t))}function BS(t){var n=t.memoizedState,r=0;n!==null&&(r=n.retryLane),q0(t,r)}function FS(t,n){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(n),q0(t,r)}function zS(t,n){return st(t,n)}var Mc=null,Lr=null,gd=!1,bc=!1,_d=!1,os=0;function ta(t){t!==Lr&&t.next===null&&(Lr===null?Mc=Lr=t:Lr=Lr.next=t),bc=!0,gd||(gd=!0,GS())}function Ko(t,n){if(!_d&&bc){_d=!0;do for(var r=!1,o=Mc;o!==null;){if(t!==0){var u=o.pendingLanes;if(u===0)var d=0;else{var M=o.suspendedLanes,R=o.pingedLanes;d=(1<<31-je(42|t)+1)-1,d&=u&~(M&~R),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(r=!0,$0(o,d))}else d=Bt,d=Se(o,o===un?d:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(d&3)===0||Be(o,d)||(r=!0,$0(o,d));o=o.next}while(r);_d=!1}}function HS(){Y0()}function Y0(){bc=gd=!1;var t=0;os!==0&&$S()&&(t=os);for(var n=Ye(),r=null,o=Mc;o!==null;){var u=o.next,d=Z0(o,n);d===0?(o.next=null,r===null?Mc=u:r.next=u,u===null&&(Lr=r)):(r=o,(t!==0||(d&3)!==0)&&(bc=!0)),o=u}Nn!==0&&Nn!==5||Ko(t),os!==0&&(os=0)}function Z0(t,n){for(var r=t.suspendedLanes,o=t.pingedLanes,u=t.expirationTimes,d=t.pendingLanes&-62914561;0<d;){var M=31-je(d),R=1<<M,k=u[M];k===-1?((R&r)===0||(R&o)!==0)&&(u[M]=ke(R,n)):k<=n&&(t.expiredLanes|=R),d&=~R}if(n=un,r=Bt,r=Se(t,t===n?r:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),o=t.callbackNode,r===0||t===n&&(tn===2||tn===9)||t.cancelPendingCommit!==null)return o!==null&&o!==null&&It(o),t.callbackNode=null,t.callbackPriority=0;if((r&3)===0||Be(t,r)){if(n=r&-r,n===t.callbackPriority)return n;switch(o!==null&&It(o),Ga(r)){case 2:case 8:r=E;break;case 32:r=X;break;case 268435456:r=me;break;default:r=X}return o=K0.bind(null,t),r=st(r,o),t.callbackPriority=n,t.callbackNode=r,n}return o!==null&&o!==null&&It(o),t.callbackPriority=2,t.callbackNode=null,2}function K0(t,n){if(Nn!==0&&Nn!==5)return t.callbackNode=null,t.callbackPriority=0,null;var r=t.callbackNode;if(Sc()&&t.callbackNode!==r)return null;var o=Bt;return o=Se(t,t===un?o:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),o===0?null:(N0(t,o,n),Z0(t,Ye()),t.callbackNode!=null&&t.callbackNode===r?K0.bind(null,t):null)}function $0(t,n){if(Sc())return null;N0(t,n,!0)}function GS(){JS(function(){(Yt&6)!==0?st(I,HS):Y0()})}function vd(){if(os===0){var t=vr;t===0&&(t=Je,Je<<=1,(Je&261888)===0&&(Je=256)),os=t}return os}function Q0(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Rs(""+t)}function J0(t,n){var r=n.ownerDocument.createElement("input");return r.name=n.name,r.value=n.value,t.id&&r.setAttribute("form",t.id),n.parentNode.insertBefore(r,n),t=new FormData(t),r.parentNode.removeChild(r),t}function VS(t,n,r,o,u){if(n==="submit"&&r&&r.stateNode===u){var d=Q0((u[Ge]||null).action),M=o.submitter;M&&(n=(n=M[Ge]||null)?Q0(n.formAction):M.getAttribute("formAction"),n!==null&&(d=n,M=null));var R=new Pl("action","action",null,o,u);t.push({event:R,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(os!==0){var k=M?J0(u,M):new FormData(u);Ff(r,{pending:!0,data:k,method:u.method,action:d},null,k)}}else typeof d=="function"&&(R.preventDefault(),k=M?J0(u,M):new FormData(u),Ff(r,{pending:!0,data:k,method:u.method,action:d},d,k))},currentTarget:u}]})}}for(var xd=0;xd<ef.length;xd++){var yd=ef[xd],kS=yd.toLowerCase(),jS=yd[0].toUpperCase()+yd.slice(1);Gi(kS,"on"+jS)}Gi(Dm,"onAnimationEnd"),Gi(Nm,"onAnimationIteration"),Gi(Um,"onAnimationStart"),Gi("dblclick","onDoubleClick"),Gi("focusin","onFocus"),Gi("focusout","onBlur"),Gi(rS,"onTransitionRun"),Gi(oS,"onTransitionStart"),Gi(lS,"onTransitionCancel"),Gi(Lm,"onTransitionEnd"),fe("onMouseEnter",["mouseout","mouseover"]),fe("onMouseLeave",["mouseout","mouseover"]),fe("onPointerEnter",["pointerout","pointerover"]),fe("onPointerLeave",["pointerout","pointerover"]),Q("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Q("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Q("onBeforeInput",["compositionend","keypress","textInput","paste"]),Q("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Q("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Q("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var $o="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(" "),XS=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat($o));function e_(t,n){n=(n&4)!==0;for(var r=0;r<t.length;r++){var o=t[r],u=o.event;o=o.listeners;e:{var d=void 0;if(n)for(var M=o.length-1;0<=M;M--){var R=o[M],k=R.instance,le=R.currentTarget;if(R=R.listener,k!==d&&u.isPropagationStopped())break e;d=R,u.currentTarget=le;try{d(u)}catch(be){Fl(be)}u.currentTarget=null,d=k}else for(M=0;M<o.length;M++){if(R=o[M],k=R.instance,le=R.currentTarget,R=R.listener,k!==d&&u.isPropagationStopped())break e;d=R,u.currentTarget=le;try{d(u)}catch(be){Fl(be)}u.currentTarget=null,d=k}}}}function Ot(t,n){var r=n[lt];r===void 0&&(r=n[lt]=new Set);var o=t+"__bubble";r.has(o)||(t_(n,t,2,!1),r.add(o))}function Sd(t,n,r){var o=0;n&&(o|=4),t_(r,t,o,n)}var Ec="_reactListening"+Math.random().toString(36).slice(2);function Md(t){if(!t[Ec]){t[Ec]=!0,Nl.forEach(function(r){r!=="selectionchange"&&(XS.has(r)||Sd(r,!1,t),Sd(r,!0,t))});var n=t.nodeType===9?t:t.ownerDocument;n===null||n[Ec]||(n[Ec]=!0,Sd("selectionchange",!1,n))}}function t_(t,n,r,o){switch(D_(n)){case 2:var u=xM;break;case 8:u=yM;break;default:u=Bd}r=u.bind(null,n,r,t),u=void 0,!Gu||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(u=!0),o?u!==void 0?t.addEventListener(n,r,{capture:!0,passive:u}):t.addEventListener(n,r,!0):u!==void 0?t.addEventListener(n,r,{passive:u}):t.addEventListener(n,r,!1)}function bd(t,n,r,o,u){var d=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var M=o.tag;if(M===3||M===4){var R=o.stateNode.containerInfo;if(R===u)break;if(M===4)for(M=o.return;M!==null;){var k=M.tag;if((k===3||k===4)&&M.stateNode.containerInfo===u)return;M=M.return}for(;R!==null;){if(M=fn(R),M===null)return;if(k=M.tag,k===5||k===6||k===26||k===27){o=d=M;continue e}R=R.parentNode}}o=o.return}rm(function(){var le=d,be=zu(r),Re=[];e:{var de=Om.get(t);if(de!==void 0){var ve=Pl,tt=t;switch(t){case"keypress":if(Ll(r)===0)break e;case"keydown":case"keyup":ve=Fy;break;case"focusin":tt="focus",ve=Xu;break;case"focusout":tt="blur",ve=Xu;break;case"beforeblur":case"afterblur":ve=Xu;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":ve=cm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ve=Ay;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ve=Gy;break;case Dm:case Nm:case Um:ve=Ry;break;case Lm:ve=ky;break;case"scroll":case"scrollend":ve=Ey;break;case"wheel":ve=Xy;break;case"copy":case"cut":case"paste":ve=Ny;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ve=fm;break;case"toggle":case"beforetoggle":ve=qy}var mt=(n&4)!==0,on=!mt&&(t==="scroll"||t==="scrollend"),te=mt?de!==null?de+"Capture":null:de;mt=[];for(var Y=le,oe;Y!==null;){var Te=Y;if(oe=Te.stateNode,Te=Te.tag,Te!==5&&Te!==26&&Te!==27||oe===null||te===null||(Te=xo(Y,te),Te!=null&&mt.push(Qo(Y,Te,oe))),on)break;Y=Y.return}0<mt.length&&(de=new ve(de,tt,null,r,be),Re.push({event:de,listeners:mt}))}}if((n&7)===0){e:{if(de=t==="mouseover"||t==="pointerover",ve=t==="mouseout"||t==="pointerout",de&&r!==Fu&&(tt=r.relatedTarget||r.fromElement)&&(fn(tt)||tt[it]))break e;if((ve||de)&&(de=be.window===be?be:(de=be.ownerDocument)?de.defaultView||de.parentWindow:window,ve?(tt=r.relatedTarget||r.toElement,ve=le,tt=tt?fn(tt):null,tt!==null&&(on=c(tt),mt=tt.tag,tt!==on||mt!==5&&mt!==27&&mt!==6)&&(tt=null)):(ve=null,tt=le),ve!==tt)){if(mt=cm,Te="onMouseLeave",te="onMouseEnter",Y="mouse",(t==="pointerout"||t==="pointerover")&&(mt=fm,Te="onPointerLeave",te="onPointerEnter",Y="pointer"),on=ve==null?de:Bn(ve),oe=tt==null?de:Bn(tt),de=new mt(Te,Y+"leave",ve,r,be),de.target=on,de.relatedTarget=oe,Te=null,fn(be)===le&&(mt=new mt(te,Y+"enter",tt,r,be),mt.target=oe,mt.relatedTarget=on,Te=mt),on=Te,ve&&tt)t:{for(mt=WS,te=ve,Y=tt,oe=0,Te=te;Te;Te=mt(Te))oe++;Te=0;for(var ut=Y;ut;ut=mt(ut))Te++;for(;0<oe-Te;)te=mt(te),oe--;for(;0<Te-oe;)Y=mt(Y),Te--;for(;oe--;){if(te===Y||Y!==null&&te===Y.alternate){mt=te;break t}te=mt(te),Y=mt(Y)}mt=null}else mt=null;ve!==null&&n_(Re,de,ve,mt,!1),tt!==null&&on!==null&&n_(Re,on,tt,mt,!0)}}e:{if(de=le?Bn(le):window,ve=de.nodeName&&de.nodeName.toLowerCase(),ve==="select"||ve==="input"&&de.type==="file")var Wt=xm;else if(_m(de))if(ym)Wt=iS;else{Wt=tS;var at=eS}else ve=de.nodeName,!ve||ve.toLowerCase()!=="input"||de.type!=="checkbox"&&de.type!=="radio"?le&&$t(le.elementType)&&(Wt=xm):Wt=nS;if(Wt&&(Wt=Wt(t,le))){vm(Re,Wt,r,be);break e}at&&at(t,de,le),t==="focusout"&&le&&de.type==="number"&&le.memoizedProps.value!=null&&Ut(de,"number",de.value)}switch(at=le?Bn(le):window,t){case"focusin":(_m(at)||at.contentEditable==="true")&&(ur=at,$u=le,Co=null);break;case"focusout":Co=$u=ur=null;break;case"mousedown":Qu=!0;break;case"contextmenu":case"mouseup":case"dragend":Qu=!1,wm(Re,r,be);break;case"selectionchange":if(sS)break;case"keydown":case"keyup":wm(Re,r,be)}var Rt;if(qu)e:{switch(t){case"compositionstart":var Ft="onCompositionStart";break e;case"compositionend":Ft="onCompositionEnd";break e;case"compositionupdate":Ft="onCompositionUpdate";break e}Ft=void 0}else cr?mm(t,r)&&(Ft="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&(Ft="onCompositionStart");Ft&&(dm&&r.locale!=="ko"&&(cr||Ft!=="onCompositionStart"?Ft==="onCompositionEnd"&&cr&&(Rt=om()):(Xa=be,Vu="value"in Xa?Xa.value:Xa.textContent,cr=!0)),at=Tc(le,Ft),0<at.length&&(Ft=new um(Ft,t,null,r,be),Re.push({event:Ft,listeners:at}),Rt?Ft.data=Rt:(Rt=gm(r),Rt!==null&&(Ft.data=Rt)))),(Rt=Zy?Ky(t,r):$y(t,r))&&(Ft=Tc(le,"onBeforeInput"),0<Ft.length&&(at=new um("onBeforeInput","beforeinput",null,r,be),Re.push({event:at,listeners:Ft}),at.data=Rt)),VS(Re,t,le,r,be)}e_(Re,n)})}function Qo(t,n,r){return{instance:t,listener:n,currentTarget:r}}function Tc(t,n){for(var r=n+"Capture",o=[];t!==null;){var u=t,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=xo(t,r),u!=null&&o.unshift(Qo(t,u,d)),u=xo(t,n),u!=null&&o.push(Qo(t,u,d))),t.tag===3)return o;t=t.return}return[]}function WS(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function n_(t,n,r,o,u){for(var d=n._reactName,M=[];r!==null&&r!==o;){var R=r,k=R.alternate,le=R.stateNode;if(R=R.tag,k!==null&&k===o)break;R!==5&&R!==26&&R!==27||le===null||(k=le,u?(le=xo(r,d),le!=null&&M.unshift(Qo(r,le,k))):u||(le=xo(r,d),le!=null&&M.push(Qo(r,le,k)))),r=r.return}M.length!==0&&t.push({event:n,listeners:M})}var qS=/\r\n?/g,YS=/\u0000|\uFFFD/g;function i_(t){return(typeof t=="string"?t:""+t).replace(qS,`
|
||
`).replace(YS,"")}function a_(t,n){return n=i_(n),i_(t)===n}function rn(t,n,r,o,u,d){switch(r){case"children":typeof o=="string"?n==="body"||n==="textarea"&&o===""||hi(t,o):(typeof o=="number"||typeof o=="bigint")&&n!=="body"&&hi(t,""+o);break;case"className":et(t,"class",o);break;case"tabIndex":et(t,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":et(t,r,o);break;case"style":Hi(t,o,d);break;case"data":if(n!=="object"){et(t,"data",o);break}case"src":case"href":if(o===""&&(n!=="a"||r!=="href")){t.removeAttribute(r);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){t.removeAttribute(r);break}o=Rs(""+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 d=="function"&&(r==="formAction"?(n!=="input"&&rn(t,n,"name",u.name,u,null),rn(t,n,"formEncType",u.formEncType,u,null),rn(t,n,"formMethod",u.formMethod,u,null),rn(t,n,"formTarget",u.formTarget,u,null)):(rn(t,n,"encType",u.encType,u,null),rn(t,n,"method",u.method,u,null),rn(t,n,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){t.removeAttribute(r);break}o=Rs(""+o),t.setAttribute(r,o);break;case"onClick":o!=null&&(t.onclick=fa);break;case"onScroll":o!=null&&Ot("scroll",t);break;case"onScrollEnd":o!=null&&Ot("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=Rs(""+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":Ot("beforetoggle",t),Ot("toggle",t),Ve(t,"popover",o);break;case"xlinkActuate":$e(t,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":$e(t,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":$e(t,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":$e(t,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":$e(t,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":$e(t,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":$e(t,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":$e(t,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":$e(t,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Ve(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=$i.get(r)||r,Ve(t,r,o))}}function Ed(t,n,r,o,u,d){switch(r){case"style":Hi(t,o,d);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"?hi(t,o):(typeof o=="number"||typeof o=="bigint")&&hi(t,""+o);break;case"onScroll":o!=null&&Ot("scroll",t);break;case"onScrollEnd":o!=null&&Ot("scrollend",t);break;case"onClick":o!=null&&(t.onclick=fa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!w.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(u=r.endsWith("Capture"),n=r.slice(2,u?r.length-7:void 0),d=t[Ge]||null,d=d!=null?d[r]:null,typeof d=="function"&&t.removeEventListener(n,d,u),typeof o=="function")){typeof d!="function"&&d!==null&&(r in t?t[r]=null:t.hasAttribute(r)&&t.removeAttribute(r)),t.addEventListener(n,o,u);break e}r in t?t[r]=o:o===!0?t.setAttribute(r,""):Ve(t,r,o)}}}function Xn(t,n,r){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ot("error",t),Ot("load",t);var o=!1,u=!1,d;for(d in r)if(r.hasOwnProperty(d)){var M=r[d];if(M!=null)switch(d){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:rn(t,n,d,M,r,null)}}u&&rn(t,n,"srcSet",r.srcSet,r,null),o&&rn(t,n,"src",r.src,r,null);return;case"input":Ot("invalid",t);var R=d=M=u=null,k=null,le=null;for(o in r)if(r.hasOwnProperty(o)){var be=r[o];if(be!=null)switch(o){case"name":u=be;break;case"type":M=be;break;case"checked":k=be;break;case"defaultChecked":le=be;break;case"value":d=be;break;case"defaultValue":R=be;break;case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(s(137,n));break;default:rn(t,n,o,be,r,null)}}qn(t,d,R,k,le,M,u,!1);return;case"select":Ot("invalid",t),o=M=d=null;for(u in r)if(r.hasOwnProperty(u)&&(R=r[u],R!=null))switch(u){case"value":d=R;break;case"defaultValue":M=R;break;case"multiple":o=R;default:rn(t,n,u,R,r,null)}n=d,r=M,t.multiple=!!o,n!=null?Dn(t,!!o,n,!1):r!=null&&Dn(t,!!o,r,!0);return;case"textarea":Ot("invalid",t),d=u=o=null;for(M in r)if(r.hasOwnProperty(M)&&(R=r[M],R!=null))switch(M){case"value":o=R;break;case"defaultValue":u=R;break;case"children":d=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(s(91));break;default:rn(t,n,M,R,r,null)}zi(t,o,u,d);return;case"option":for(k in r)r.hasOwnProperty(k)&&(o=r[k],o!=null)&&(k==="selected"?t.selected=o&&typeof o!="function"&&typeof o!="symbol":rn(t,n,k,o,r,null));return;case"dialog":Ot("beforetoggle",t),Ot("toggle",t),Ot("cancel",t),Ot("close",t);break;case"iframe":case"object":Ot("load",t);break;case"video":case"audio":for(o=0;o<$o.length;o++)Ot($o[o],t);break;case"image":Ot("error",t),Ot("load",t);break;case"details":Ot("toggle",t);break;case"embed":case"source":case"link":Ot("error",t),Ot("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(le in r)if(r.hasOwnProperty(le)&&(o=r[le],o!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:rn(t,n,le,o,r,null)}return;default:if($t(n)){for(be in r)r.hasOwnProperty(be)&&(o=r[be],o!==void 0&&Ed(t,n,be,o,r,void 0));return}}for(R in r)r.hasOwnProperty(R)&&(o=r[R],o!=null&&rn(t,n,R,o,r,null))}function ZS(t,n,r,o){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,d=null,M=null,R=null,k=null,le=null,be=null;for(ve in r){var Re=r[ve];if(r.hasOwnProperty(ve)&&Re!=null)switch(ve){case"checked":break;case"value":break;case"defaultValue":k=Re;default:o.hasOwnProperty(ve)||rn(t,n,ve,null,o,Re)}}for(var de in o){var ve=o[de];if(Re=r[de],o.hasOwnProperty(de)&&(ve!=null||Re!=null))switch(de){case"type":d=ve;break;case"name":u=ve;break;case"checked":le=ve;break;case"defaultChecked":be=ve;break;case"value":M=ve;break;case"defaultValue":R=ve;break;case"children":case"dangerouslySetInnerHTML":if(ve!=null)throw Error(s(137,n));break;default:ve!==Re&&rn(t,n,de,ve,o,Re)}}qe(t,M,R,k,le,be,d,u);return;case"select":ve=M=R=de=null;for(d in r)if(k=r[d],r.hasOwnProperty(d)&&k!=null)switch(d){case"value":break;case"multiple":ve=k;default:o.hasOwnProperty(d)||rn(t,n,d,null,o,k)}for(u in o)if(d=o[u],k=r[u],o.hasOwnProperty(u)&&(d!=null||k!=null))switch(u){case"value":de=d;break;case"defaultValue":R=d;break;case"multiple":M=d;default:d!==k&&rn(t,n,u,d,o,k)}n=R,r=M,o=ve,de!=null?Dn(t,!!r,de,!1):!!o!=!!r&&(n!=null?Dn(t,!!r,n,!0):Dn(t,!!r,r?[]:"",!1));return;case"textarea":ve=de=null;for(R in r)if(u=r[R],r.hasOwnProperty(R)&&u!=null&&!o.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:rn(t,n,R,null,o,u)}for(M in o)if(u=o[M],d=r[M],o.hasOwnProperty(M)&&(u!=null||d!=null))switch(M){case"value":de=u;break;case"defaultValue":ve=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==d&&rn(t,n,M,u,o,d)}di(t,de,ve);return;case"option":for(var tt in r)de=r[tt],r.hasOwnProperty(tt)&&de!=null&&!o.hasOwnProperty(tt)&&(tt==="selected"?t.selected=!1:rn(t,n,tt,null,o,de));for(k in o)de=o[k],ve=r[k],o.hasOwnProperty(k)&&de!==ve&&(de!=null||ve!=null)&&(k==="selected"?t.selected=de&&typeof de!="function"&&typeof de!="symbol":rn(t,n,k,de,o,ve));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 mt in r)de=r[mt],r.hasOwnProperty(mt)&&de!=null&&!o.hasOwnProperty(mt)&&rn(t,n,mt,null,o,de);for(le in o)if(de=o[le],ve=r[le],o.hasOwnProperty(le)&&de!==ve&&(de!=null||ve!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(s(137,n));break;default:rn(t,n,le,de,o,ve)}return;default:if($t(n)){for(var on in r)de=r[on],r.hasOwnProperty(on)&&de!==void 0&&!o.hasOwnProperty(on)&&Ed(t,n,on,void 0,o,de);for(be in o)de=o[be],ve=r[be],!o.hasOwnProperty(be)||de===ve||de===void 0&&ve===void 0||Ed(t,n,be,de,o,ve);return}}for(var te in r)de=r[te],r.hasOwnProperty(te)&&de!=null&&!o.hasOwnProperty(te)&&rn(t,n,te,null,o,de);for(Re in o)de=o[Re],ve=r[Re],!o.hasOwnProperty(Re)||de===ve||de==null&&ve==null||rn(t,n,Re,de,o,ve)}function s_(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function KS(){if(typeof performance.getEntriesByType=="function"){for(var t=0,n=0,r=performance.getEntriesByType("resource"),o=0;o<r.length;o++){var u=r[o],d=u.transferSize,M=u.initiatorType,R=u.duration;if(d&&R&&s_(M)){for(M=0,R=u.responseEnd,o+=1;o<r.length;o++){var k=r[o],le=k.startTime;if(le>R)break;var be=k.transferSize,Re=k.initiatorType;be&&s_(Re)&&(k=k.responseEnd,M+=be*(k<R?1:(R-le)/(k-le)))}if(--o,n+=8*(d+M)/(u.duration/1e3),t++,10<t)break}}if(0<t)return n/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var Td=null,Ad=null;function Ac(t){return t.nodeType===9?t:t.ownerDocument}function r_(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 o_(t,n){if(t===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&n==="foreignObject"?0:t}function Cd(t,n){return t==="textarea"||t==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var wd=null;function $S(){var t=window.event;return t&&t.type==="popstate"?t===wd?!1:(wd=t,!0):(wd=null,!1)}var l_=typeof setTimeout=="function"?setTimeout:void 0,QS=typeof clearTimeout=="function"?clearTimeout:void 0,c_=typeof Promise=="function"?Promise:void 0,JS=typeof queueMicrotask=="function"?queueMicrotask:typeof c_<"u"?function(t){return c_.resolve(null).then(t).catch(eM)}:l_;function eM(t){setTimeout(function(){throw t})}function ls(t){return t==="head"}function u_(t,n){var r=n,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),Br(n);return}o--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")o++;else if(r==="html")Jo(t.ownerDocument.documentElement);else if(r==="head"){r=t.ownerDocument.head,Jo(r);for(var d=r.firstChild;d;){var M=d.nextSibling,R=d.nodeName;d[hn]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&d.rel.toLowerCase()==="stylesheet"||r.removeChild(d),d=M}}else r==="body"&&Jo(t.ownerDocument.body);r=u}while(r);Br(n)}function f_(t,n){var r=t;t=0;do{var o=r.nextSibling;if(r.nodeType===1?n?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(n?(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 Rd(t){var n=t.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var r=n;switch(n=n.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":Rd(r),yn(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}t.removeChild(r)}}function tM(t,n,r,o){for(;t.nodeType===1;){var u=r;if(t.nodeName.toLowerCase()!==n.toLowerCase()){if(!o&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(o){if(!t[hn])switch(n){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(d=t.getAttribute("rel"),d==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(d!==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(d=t.getAttribute("src"),(d!==(u.src==null?null:u.src)||t.getAttribute("type")!==(u.type==null?null:u.type)||t.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&d&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(n==="input"&&t.type==="hidden"){var d=u.name==null?null:""+u.name;if(u.type==="hidden"&&t.getAttribute("name")===d)return t}else return t;if(t=Ui(t.nextSibling),t===null)break}return null}function nM(t,n,r){if(n==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=Ui(t.nextSibling),t===null))return null;return t}function d_(t,n){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!n||(t=Ui(t.nextSibling),t===null))return null;return t}function Dd(t){return t.data==="$?"||t.data==="$~"}function Nd(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function iM(t,n){var r=t.ownerDocument;if(t.data==="$~")t._reactRetry=n;else if(t.data!=="$?"||r.readyState!=="loading")n();else{var o=function(){n(),r.removeEventListener("DOMContentLoaded",o)};r.addEventListener("DOMContentLoaded",o),t._reactRetry=o}}function Ui(t){for(;t!=null;t=t.nextSibling){var n=t.nodeType;if(n===1||n===3)break;if(n===8){if(n=t.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return t}var Ud=null;function h_(t){t=t.nextSibling;for(var n=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"||r==="/&"){if(n===0)return Ui(t.nextSibling);n--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||n++}t=t.nextSibling}return null}function p_(t){t=t.previousSibling;for(var n=0;t;){if(t.nodeType===8){var r=t.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(n===0)return t;n--}else r!=="/$"&&r!=="/&"||n++}t=t.previousSibling}return null}function m_(t,n,r){switch(n=Ac(r),t){case"html":if(t=n.documentElement,!t)throw Error(s(452));return t;case"head":if(t=n.head,!t)throw Error(s(453));return t;case"body":if(t=n.body,!t)throw Error(s(454));return t;default:throw Error(s(451))}}function Jo(t){for(var n=t.attributes;n.length;)t.removeAttributeNode(n[0]);yn(t)}var Li=new Map,g_=new Set;function Cc(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var Ca=G.d;G.d={f:aM,r:sM,D:rM,C:oM,L:lM,m:cM,X:fM,S:uM,M:dM};function aM(){var t=Ca.f(),n=vc();return t||n}function sM(t){var n=Gn(t);n!==null&&n.tag===5&&n.type==="form"?Lg(n):Ca.r(t)}var Or=typeof document>"u"?null:document;function __(t,n,r){var o=Or;if(o&&typeof n=="string"&&n){var u=Jt(n);u='link[rel="'+t+'"][href="'+u+'"]',typeof r=="string"&&(u+='[crossorigin="'+r+'"]'),g_.has(u)||(g_.add(u),t={rel:t,crossOrigin:r,href:n},o.querySelector(u)===null&&(n=o.createElement("link"),Xn(n,"link",t),Kt(n),o.head.appendChild(n)))}}function rM(t){Ca.D(t),__("dns-prefetch",t,null)}function oM(t,n){Ca.C(t,n),__("preconnect",t,n)}function lM(t,n,r){Ca.L(t,n,r);var o=Or;if(o&&t&&n){var u='link[rel="preload"][as="'+Jt(n)+'"]';n==="image"&&r&&r.imageSrcSet?(u+='[imagesrcset="'+Jt(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(u+='[imagesizes="'+Jt(r.imageSizes)+'"]')):u+='[href="'+Jt(t)+'"]';var d=u;switch(n){case"style":d=Pr(t);break;case"script":d=Ir(t)}Li.has(d)||(t=S({rel:"preload",href:n==="image"&&r&&r.imageSrcSet?void 0:t,as:n},r),Li.set(d,t),o.querySelector(u)!==null||n==="style"&&o.querySelector(el(d))||n==="script"&&o.querySelector(tl(d))||(n=o.createElement("link"),Xn(n,"link",t),Kt(n),o.head.appendChild(n)))}}function cM(t,n){Ca.m(t,n);var r=Or;if(r&&t){var o=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+Jt(o)+'"][href="'+Jt(t)+'"]',d=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=Ir(t)}if(!Li.has(d)&&(t=S({rel:"modulepreload",href:t},n),Li.set(d,t),r.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(tl(d)))return}o=r.createElement("link"),Xn(o,"link",t),Kt(o),r.head.appendChild(o)}}}function uM(t,n,r){Ca.S(t,n,r);var o=Or;if(o&&t){var u=Ti(o).hoistableStyles,d=Pr(t);n=n||"default";var M=u.get(d);if(!M){var R={loading:0,preload:null};if(M=o.querySelector(el(d)))R.loading=5;else{t=S({rel:"stylesheet",href:t,"data-precedence":n},r),(r=Li.get(d))&&Ld(t,r);var k=M=o.createElement("link");Kt(k),Xn(k,"link",t),k._p=new Promise(function(le,be){k.onload=le,k.onerror=be}),k.addEventListener("load",function(){R.loading|=1}),k.addEventListener("error",function(){R.loading|=2}),R.loading|=4,wc(M,n,o)}M={type:"stylesheet",instance:M,count:1,state:R},u.set(d,M)}}}function fM(t,n){Ca.X(t,n);var r=Or;if(r&&t){var o=Ti(r).hoistableScripts,u=Ir(t),d=o.get(u);d||(d=r.querySelector(tl(u)),d||(t=S({src:t,async:!0},n),(n=Li.get(u))&&Od(t,n),d=r.createElement("script"),Kt(d),Xn(d,"link",t),r.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function dM(t,n){Ca.M(t,n);var r=Or;if(r&&t){var o=Ti(r).hoistableScripts,u=Ir(t),d=o.get(u);d||(d=r.querySelector(tl(u)),d||(t=S({src:t,async:!0,type:"module"},n),(n=Li.get(u))&&Od(t,n),d=r.createElement("script"),Kt(d),Xn(d,"link",t),r.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function v_(t,n,r,o){var u=(u=ae.current)?Cc(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"?(n=Pr(r.href),r=Ti(u).hoistableStyles,o=r.get(n),o||(o={type:"style",instance:null,count:0,state:null},r.set(n,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=Pr(r.href);var d=Ti(u).hoistableStyles,M=d.get(t);if(M||(u=u.ownerDocument||u,M={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(t,M),(d=u.querySelector(el(t)))&&!d._p&&(M.instance=d,M.state.loading=5),Li.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},Li.set(t,r),d||hM(u,t,r,M.state))),n&&o===null)throw Error(s(528,""));return M}if(n&&o!==null)throw Error(s(529,""));return null;case"script":return n=r.async,r=r.src,typeof r=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Ir(r),r=Ti(u).hoistableScripts,o=r.get(n),o||(o={type:"script",instance:null,count:0,state:null},r.set(n,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,t))}}function Pr(t){return'href="'+Jt(t)+'"'}function el(t){return'link[rel="stylesheet"]['+t+"]"}function x_(t){return S({},t,{"data-precedence":t.precedence,precedence:null})}function hM(t,n,r,o){t.querySelector('link[rel="preload"][as="style"]['+n+"]")?o.loading=1:(n=t.createElement("link"),o.preload=n,n.addEventListener("load",function(){return o.loading|=1}),n.addEventListener("error",function(){return o.loading|=2}),Xn(n,"link",r),Kt(n),t.head.appendChild(n))}function Ir(t){return'[src="'+Jt(t)+'"]'}function tl(t){return"script[async]"+t}function y_(t,n,r){if(n.count++,n.instance===null)switch(n.type){case"style":var o=t.querySelector('style[data-href~="'+Jt(r.href)+'"]');if(o)return n.instance=o,Kt(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"),Kt(o),Xn(o,"style",u),wc(o,r.precedence,t),n.instance=o;case"stylesheet":u=Pr(r.href);var d=t.querySelector(el(u));if(d)return n.state.loading|=4,n.instance=d,Kt(d),d;o=x_(r),(u=Li.get(u))&&Ld(o,u),d=(t.ownerDocument||t).createElement("link"),Kt(d);var M=d;return M._p=new Promise(function(R,k){M.onload=R,M.onerror=k}),Xn(d,"link",o),n.state.loading|=4,wc(d,r.precedence,t),n.instance=d;case"script":return d=Ir(r.src),(u=t.querySelector(tl(d)))?(n.instance=u,Kt(u),u):(o=r,(u=Li.get(d))&&(o=S({},r),Od(o,u)),t=t.ownerDocument||t,u=t.createElement("script"),Kt(u),Xn(u,"link",o),t.head.appendChild(u),n.instance=u);case"void":return null;default:throw Error(s(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(o=n.instance,n.state.loading|=4,wc(o,r.precedence,t));return n.instance}function wc(t,n,r){for(var o=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,d=u,M=0;M<o.length;M++){var R=o[M];if(R.dataset.precedence===n)d=R;else if(d!==u)break}d?d.parentNode.insertBefore(t,d.nextSibling):(n=r.nodeType===9?r.head:r,n.insertBefore(t,n.firstChild))}function Ld(t,n){t.crossOrigin==null&&(t.crossOrigin=n.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=n.referrerPolicy),t.title==null&&(t.title=n.title)}function Od(t,n){t.crossOrigin==null&&(t.crossOrigin=n.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=n.referrerPolicy),t.integrity==null&&(t.integrity=n.integrity)}var Rc=null;function S_(t,n,r){if(Rc===null){var o=new Map,u=Rc=new Map;u.set(r,o)}else u=Rc,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 d=r[u];if(!(d[hn]||d[we]||t==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var M=d.getAttribute(n)||"";M=t+M;var R=o.get(M);R?R.push(d):o.set(M,[d])}}return o}function M_(t,n,r){t=t.ownerDocument||t,t.head.insertBefore(r,n==="title"?t.querySelector("head > title"):null)}function pM(t,n,r){if(r===1||n.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(t=n.disabled,typeof n.precedence=="string"&&t==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function b_(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function mM(t,n,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=Pr(o.href),d=n.querySelector(el(u));if(d){n=d._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(t.count++,t=Dc.bind(t),n.then(t,t)),r.state.loading|=4,r.instance=d,Kt(d);return}d=n.ownerDocument||n,o=x_(o),(u=Li.get(u))&&Ld(o,u),d=d.createElement("link"),Kt(d);var M=d;M._p=new Promise(function(R,k){M.onload=R,M.onerror=k}),Xn(d,"link",o),r.instance=d}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(r,n),(n=r.state.preload)&&(r.state.loading&3)===0&&(t.count++,r=Dc.bind(t),n.addEventListener("load",r),n.addEventListener("error",r))}}var Pd=0;function gM(t,n){return t.stylesheets&&t.count===0&&Uc(t,t.stylesheets),0<t.count||0<t.imgCount?function(r){var o=setTimeout(function(){if(t.stylesheets&&Uc(t,t.stylesheets),t.unsuspend){var d=t.unsuspend;t.unsuspend=null,d()}},6e4+n);0<t.imgBytes&&Pd===0&&(Pd=62500*KS());var u=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Uc(t,t.stylesheets),t.unsuspend)){var d=t.unsuspend;t.unsuspend=null,d()}},(t.imgBytes>Pd?50:800)+n);return t.unsuspend=r,function(){t.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function Dc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Uc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Nc=null;function Uc(t,n){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Nc=new Map,n.forEach(_M,t),Nc=null,Dc.call(t))}function _M(t,n){if(!(n.state.loading&4)){var r=Nc.get(t);if(r)var o=r.get(null);else{r=new Map,Nc.set(t,r);for(var u=t.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<u.length;d++){var M=u[d];(M.nodeName==="LINK"||M.getAttribute("media")!=="not all")&&(r.set(M.dataset.precedence,M),o=M)}o&&r.set(null,o)}u=n.instance,M=u.getAttribute("data-precedence"),d=r.get(M)||o,d===o&&r.set(null,u),r.set(M,u),this.count++,o=Dc.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),d?d.parentNode.insertBefore(u,d.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(u,t.firstChild)),n.state.loading|=4}}var nl={$$typeof:P,Provider:null,Consumer:null,_currentValue:ne,_currentValue2:ne,_threadCount:0};function vM(t,n,r,o,u,d,M,R,k){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=Me(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Me(0),this.hiddenUpdates=Me(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=M,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=k,this.incompleteTransitions=new Map}function E_(t,n,r,o,u,d,M,R,k,le,be,Re){return t=new vM(t,n,r,M,k,le,be,Re,R),n=1,d===!0&&(n|=24),d=mi(3,null,null,n),t.current=d,d.stateNode=t,n=pf(),n.refCount++,t.pooledCache=n,n.refCount++,d.memoizedState={element:o,isDehydrated:r,cache:n},vf(d),t}function T_(t){return t?(t=hr,t):hr}function A_(t,n,r,o,u,d){u=T_(u),o.context===null?o.context=u:o.pendingContext=u,o=$a(n),o.payload={element:r},d=d===void 0?null:d,d!==null&&(o.callback=d),r=Qa(t,o,n),r!==null&&(ri(r,t,n),Oo(r,t,n))}function C_(t,n){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<n?r:n}}function Id(t,n){C_(t,n),(t=t.alternate)&&C_(t,n)}function w_(t){if(t.tag===13||t.tag===31){var n=Ls(t,67108864);n!==null&&ri(n,t,67108864),Id(t,67108864)}}function R_(t){if(t.tag===13||t.tag===31){var n=yi();n=ua(n);var r=Ls(t,n);r!==null&&ri(r,t,n),Id(t,n)}}var Lc=!0;function xM(t,n,r,o){var u=H.T;H.T=null;var d=G.p;try{G.p=2,Bd(t,n,r,o)}finally{G.p=d,H.T=u}}function yM(t,n,r,o){var u=H.T;H.T=null;var d=G.p;try{G.p=8,Bd(t,n,r,o)}finally{G.p=d,H.T=u}}function Bd(t,n,r,o){if(Lc){var u=Fd(o);if(u===null)bd(t,n,o,Oc,r),N_(t,o);else if(MM(u,t,n,r,o))o.stopPropagation();else if(N_(t,o),n&4&&-1<SM.indexOf(t)){for(;u!==null;){var d=Gn(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var M=Pe(d.pendingLanes);if(M!==0){var R=d;for(R.pendingLanes|=2,R.entangledLanes|=2;M;){var k=1<<31-je(M);R.entanglements[1]|=k,M&=~k}ta(d),(Yt&6)===0&&(gc=Ye()+500,Ko(0))}}break;case 31:case 13:R=Ls(d,2),R!==null&&ri(R,d,2),vc(),Id(d,2)}if(d=Fd(o),d===null&&bd(t,n,o,Oc,r),d===u)break;u=d}u!==null&&o.stopPropagation()}else bd(t,n,o,null,r)}}function Fd(t){return t=zu(t),zd(t)}var Oc=null;function zd(t){if(Oc=null,t=fn(t),t!==null){var n=c(t);if(n===null)t=null;else{var r=n.tag;if(r===13){if(t=f(n),t!==null)return t;t=null}else if(r===31){if(t=p(n),t!==null)return t;t=null}else if(r===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;t=null}else n!==t&&(t=null)}}return Oc=t,null}function D_(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(xt()){case I:return 2;case E:return 8;case X:case se:return 32;case me:return 268435456;default:return 32}default:return 32}}var Hd=!1,cs=null,us=null,fs=null,il=new Map,al=new Map,ds=[],SM="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 N_(t,n){switch(t){case"focusin":case"focusout":cs=null;break;case"dragenter":case"dragleave":us=null;break;case"mouseover":case"mouseout":fs=null;break;case"pointerover":case"pointerout":il.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":al.delete(n.pointerId)}}function sl(t,n,r,o,u,d){return t===null||t.nativeEvent!==d?(t={blockedOn:n,domEventName:r,eventSystemFlags:o,nativeEvent:d,targetContainers:[u]},n!==null&&(n=Gn(n),n!==null&&w_(n)),t):(t.eventSystemFlags|=o,n=t.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),t)}function MM(t,n,r,o,u){switch(n){case"focusin":return cs=sl(cs,t,n,r,o,u),!0;case"dragenter":return us=sl(us,t,n,r,o,u),!0;case"mouseover":return fs=sl(fs,t,n,r,o,u),!0;case"pointerover":var d=u.pointerId;return il.set(d,sl(il.get(d)||null,t,n,r,o,u)),!0;case"gotpointercapture":return d=u.pointerId,al.set(d,sl(al.get(d)||null,t,n,r,o,u)),!0}return!1}function U_(t){var n=fn(t.target);if(n!==null){var r=c(n);if(r!==null){if(n=r.tag,n===13){if(n=f(r),n!==null){t.blockedOn=n,ka(t.priority,function(){R_(r)});return}}else if(n===31){if(n=p(r),n!==null){t.blockedOn=n,ka(t.priority,function(){R_(r)});return}}else if(n===3&&r.stateNode.current.memoizedState.isDehydrated){t.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Pc(t){if(t.blockedOn!==null)return!1;for(var n=t.targetContainers;0<n.length;){var r=Fd(t.nativeEvent);if(r===null){r=t.nativeEvent;var o=new r.constructor(r.type,r);Fu=o,r.target.dispatchEvent(o),Fu=null}else return n=Gn(r),n!==null&&w_(n),t.blockedOn=r,!1;n.shift()}return!0}function L_(t,n,r){Pc(t)&&r.delete(n)}function bM(){Hd=!1,cs!==null&&Pc(cs)&&(cs=null),us!==null&&Pc(us)&&(us=null),fs!==null&&Pc(fs)&&(fs=null),il.forEach(L_),al.forEach(L_)}function Ic(t,n){t.blockedOn===n&&(t.blockedOn=null,Hd||(Hd=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,bM)))}var Bc=null;function O_(t){Bc!==t&&(Bc=t,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){Bc===t&&(Bc=null);for(var n=0;n<t.length;n+=3){var r=t[n],o=t[n+1],u=t[n+2];if(typeof o!="function"){if(zd(o||r)===null)continue;break}var d=Gn(r);d!==null&&(t.splice(n,3),n-=3,Ff(d,{pending:!0,data:u,method:r.method,action:o},o,u))}}))}function Br(t){function n(k){return Ic(k,t)}cs!==null&&Ic(cs,t),us!==null&&Ic(us,t),fs!==null&&Ic(fs,t),il.forEach(n),al.forEach(n);for(var r=0;r<ds.length;r++){var o=ds[r];o.blockedOn===t&&(o.blockedOn=null)}for(;0<ds.length&&(r=ds[0],r.blockedOn===null);)U_(r),r.blockedOn===null&&ds.shift();if(r=(t.ownerDocument||t).$$reactFormReplay,r!=null)for(o=0;o<r.length;o+=3){var u=r[o],d=r[o+1],M=u[Ge]||null;if(typeof d=="function")M||O_(r);else if(M){var R=null;if(d&&d.hasAttribute("formAction")){if(u=d,M=d[Ge]||null)R=M.formAction;else if(zd(u)!==null)continue}else R=M.action;typeof R=="function"?r[o+1]=R:(r.splice(o,3),o-=3),O_(r)}}}function P_(){function t(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(M){return u=M})},focusReset:"manual",scroll:"manual"})}function n(){u!==null&&(u(),u=null),o||setTimeout(r,20)}function r(){if(!o&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(r,100),function(){o=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),u!==null&&(u(),u=null)}}}function Gd(t){this._internalRoot=t}Fc.prototype.render=Gd.prototype.render=function(t){var n=this._internalRoot;if(n===null)throw Error(s(409));var r=n.current,o=yi();A_(r,o,t,n,null,null)},Fc.prototype.unmount=Gd.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var n=t.containerInfo;A_(t.current,2,null,t,null,null),vc(),n[it]=null}};function Fc(t){this._internalRoot=t}Fc.prototype.unstable_scheduleHydration=function(t){if(t){var n=Va();t={blockedOn:null,target:t,priority:n};for(var r=0;r<ds.length&&n!==0&&n<ds[r].priority;r++);ds.splice(r,0,t),r===0&&U_(t)}};var I_=e.version;if(I_!=="19.2.7")throw Error(s(527,I_,"19.2.7"));G.findDOMNode=function(t){var n=t._reactInternals;if(n===void 0)throw typeof t.render=="function"?Error(s(188)):(t=Object.keys(t).join(","),Error(s(268,t)));return t=h(n),t=t!==null?y(t):null,t=t===null?null:t.stateNode,t};var EM={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:H,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zc.isDisabled&&zc.supportsFiber)try{_e=zc.inject(EM),he=zc}catch{}}return ol.createRoot=function(t,n){if(!l(t))throw Error(s(299));var r=!1,o="",u=kg,d=jg,M=Xg;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(d=n.onCaughtError),n.onRecoverableError!==void 0&&(M=n.onRecoverableError)),n=E_(t,1,!1,null,null,r,o,null,u,d,M,P_),t[it]=n.current,Md(t),new Gd(n)},ol.hydrateRoot=function(t,n,r){if(!l(t))throw Error(s(299));var o=!1,u="",d=kg,M=jg,R=Xg,k=null;return r!=null&&(r.unstable_strictMode===!0&&(o=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onUncaughtError!==void 0&&(d=r.onUncaughtError),r.onCaughtError!==void 0&&(M=r.onCaughtError),r.onRecoverableError!==void 0&&(R=r.onRecoverableError),r.formState!==void 0&&(k=r.formState)),n=E_(t,1,!0,n,r??null,o,u,k,d,M,R,P_),n.context=T_(null),r=n.current,o=yi(),o=ua(o),u=$a(o),u.callback=null,Qa(r,u,o),r=o,n.current.lanes=r,De(n,r),ta(n),t[it]=n.current,Md(t),new Fc(n)},ol.version="19.2.7",ol}var W_;function PM(){if(W_)return jd.exports;W_=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(),jd.exports=OM(),jd.exports}var IM=PM();const BM=gx(IM),FM="wrap",zM=24;function _x(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function HM(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 Oa(a,e){return e?(a.supported_classes??a.supportedClasses??[]).some(s=>s.dimensions===e.dimensions&&HM(s.states,e.states)&&GM(s,e)):!1}function GM(a,e){return!a.neighborhoodId||!e.neighborhoodId?!0:a.neighborhoodId===e.neighborhoodId}function Sl(a){const e=a?.caClass;if(!_x(e))return;const i=typeof e.dimensions=="number"?e.dimensions:void 0,s=e.states;if(!(!i||typeof s!="number"&&!Array.isArray(s)))return{neighborhoodId:typeof e.neighborhoodId=="string"?e.neighborhoodId:void 0,dimensions:i,states:s}}function VM(a,e,i=zM){const s=_x(a)?a:{},l=Array.isArray(s.size)?s.size:[],c=typeof l[0]=="number"?l[0]:i,f=e>=2&&typeof l[1]=="number"?l[1]:1,p=e>=3&&typeof l[2]=="number"?l[2]:1;return[c,f,p]}function vx(a){let e=2166136261;for(let i=0;i<a.length;i+=1)e^=a.charCodeAt(i),e=Math.imul(e,16777619);return()=>{e+=1831565813;let i=e;return i=Math.imul(i^i>>>15,i|1),i^=i+Math.imul(i^i>>>7,i|61),((i^i>>>14)>>>0)/4294967296}}function kM(a){return a==="wrap"||a==="mirror"||a==="fixed"}function xx(a){return Nu(a?.simulation?.grid)}function Nu(a){return kM(a?.boundary)?a.boundary:a?.wrap===!1?"fixed":FM}function yx(a,e){return(a%e+e)%e}function jM(a,e){if(e<=1)return 0;const i=(e-1)*2,s=yx(a,i);return s<=e-1?s:i-s}function lo(a,e,i){return e<=0?null:i==="wrap"?yx(a,e):i==="mirror"?jM(a,e):a>=0&&a<e?a:null}function Sx(a){return a.map(e=>[...e])}function q_(a,e="cells"){const i=a[0]?.length??0;for(const s of a){if(s.length!==i)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 XM(a,e,i="engine output"){if(q_(a,"input cells"),q_(e,i),e.length!==a.length||(e[0]?.length??0)!==(a[0]?.length??0))throw new Error(`${i} must preserve the input grid dimensions`)}const Ml=new Map;function Mx(a){return a.map(e=>e.map(()=>!1))}function WM(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 qM(a){const e=/(?:rule[-_\s]*)?(\d{1,3})/i.exec(a??"");return e?Math.max(0,Math.min(255,Number(e[1]))):110}function YM(a,e){return typeof a=="number"&&Number.isFinite(a)?Math.max(0,Math.min(1,a)):e}function bx(a,e){const i=WM(e.simulation?.ruleId??"B3/S23"),s=Mx(a),l=a.length,c=a[0]?.length??0,f=Nu(e.simulation?.grid);for(let p=0;p<l;p+=1)for(let m=0;m<c;m+=1){let h=0;for(let y=-1;y<=1;y+=1)for(let S=-1;S<=1;S+=1){if(S===0&&y===0)continue;const _=m+S,b=p+y,T=lo(_,c,f),C=lo(b,l,f);T===null||C===null||a[C][T]&&(h+=1)}s[p][m]=a[p][m]?i.survival.has(h):i.birth.has(h)}return s}function ZM(a,e){const i=qM(e.simulation?.ruleId),s=Sx(a),l=a[0]?.length??0;if(a.length===0||l===0)return s;const c=Nu(e.simulation?.grid),f=Math.max(0,a.findIndex(m=>m.some(Boolean))),p=a[f]??[];for(let m=0;m<l;m+=1){const h=lo(m-1,l,c),y=lo(m+1,l,c),S=h===null?0:p[h]?1:0,_=p[m]?1:0,b=y===null?0:p[y]?1:0,T=S<<2|_<<1|b;s[f][m]=(i>>T&1)===1}return s}function KM(a,e,i){return vx(`${a}:${e}:${i}`)()}function $M(a,e){const i=Mx(a),s=a.length,l=a[0]?.length??0,c=Nu(e.simulation?.grid),f=YM(e.simulation?.spreadProbability,1),p=typeof e.simulation?.seed=="string"?e.simulation.seed:"wildfire";for(let m=0;m<s;m+=1)for(let h=0;h<l;h+=1){if(a[m][h]){i[m][h]=!1;continue}let y=0;const S=[[0,-1],[1,0],[0,1],[-1,0]];for(const[_,b]of S){const T=lo(h+_,l,c),C=lo(m+b,s,c);T===null||C===null||a[C][T]&&(y+=1)}i[m][h]=y>0&&KM(p,h,m)<f}return i}function Dp(a){return Sx(a)}function mo(a,e={}){if(!a.id.trim())throw new Error("CA engine runtime id is required");if(Ml.has(a.id)&&!e.replace)throw new Error(`CA engine runtime already registered: ${a.id}`);Ml.set(a.id,a)}function El(a,e){const i=e.simulation?.engineId??"game-of-life-2d",s=Ml.get(i)??Ml.get("outer-totalistic-2d")??Ml.get("noop"),l=s?s.step(a,e):Dp(a);return XM(a,l,`CA engine output (${s?.id??"fallback"})`),l}mo({id:"game-of-life-2d",label:"Game of Life 2D",supportedClasses:[{dimensions:2,states:2}],defaultParams:{ruleId:"B3/S23",rendererId:"2d-canvas"},step:bx},{replace:!0});mo({id:"outer-totalistic-2d",label:"Outer-totalistic 2D",supportedClasses:[{dimensions:2,states:2}],defaultParams:{ruleId:"B3/S23",rendererId:"2d-canvas"},step:bx},{replace:!0});mo({id:"elementary-1d",label:"Elementary 1D",supportedClasses:[{dimensions:1,states:2}],defaultParams:{ruleId:"Rule 110",rendererId:"elementary-1d"},step:ZM},{replace:!0});mo({id:"wildfire-2d",label:"Wildfire 2D",supportedClasses:[{dimensions:2,states:2}],defaultParams:{ruleId:"wildfire-binary",rendererId:"wildfire-2d",spreadProbability:1},step:$M},{replace:!0});mo({id:"generic-voxel-ca",label:"Generic voxel CA",step:Dp},{replace:!0});mo({id:"noop",label:"No evolution",step:Dp},{replace:!0});const Uh=new Map;function QM(a){return Math.max(0,Math.min(1,typeof a=="number"?a:.28))}function JM({settings:a,caClass:e,params:i}){const s=QM(i.density),l=typeof i.seed=="string"?i.seed:"studio-seed",c=vx(l),[f,p,m]=VM(a.simulation?.grid,e.dimensions),h=[];for(let y=0;y<m;y+=1)for(let S=0;S<p;S+=1)for(let _=0;_<f;_+=1)c()<s&&h.push([_,S,y]);return{type:"cells",cells:h,generator:{kind:"random-soup",density:s,seed:l}}}function eb(a,e={}){if(!a.id.trim())throw new Error("Initial condition runtime id is required");if(Uh.has(a.id)&&!e.replace)throw new Error(`Initial condition runtime already registered: ${a.id}`);Uh.set(a.id,a)}function tb(a){return Uh.get(a)??null}function nb(a,e){const i=tb(a);if(!i)throw new Error(`Initial condition runtime unavailable: ${a}`);const s=i.generate(e);if(s.type!=="cells"||!Array.isArray(s.cells))throw new Error(`Initial condition runtime returned an invalid result: ${a}`);return s}eb({id:"random-soup",label:"Random soup",generate:JM},{replace:!0});const Np="185",no={ROTATE:0,DOLLY:1,PAN:2},eo={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ib=0,Y_=1,ab=2,gu=1,Ex=2,vl=3,Es=0,ui=1,Pa=2,Ba=0,io=1,Z_=2,K_=3,$_=4,sb=5,Ks=100,rb=101,ob=102,lb=103,cb=104,ub=200,fb=201,db=202,hb=203,Lh=204,Oh=205,pb=206,mb=207,gb=208,_b=209,vb=210,xb=211,yb=212,Sb=213,Mb=214,Ph=0,Ih=1,Bh=2,co=3,Fh=4,zh=5,Hh=6,Gh=7,Tx=0,bb=1,Eb=2,ra=0,Ax=1,Cx=2,wx=3,Up=4,Rx=5,Dx=6,Nx=7,Ux=300,tr=301,uo=302,Yd=303,Zd=304,Uu=306,Vh=1e3,Ia=1001,kh=1002,Wn=1003,Tb=1004,Hc=1005,$n=1006,Kd=1007,Qs=1008,Ei=1009,Lx=1010,Ox=1011,Tl=1012,Lp=1013,la=1014,qi=1015,za=1016,Op=1017,Pp=1018,Al=1020,Px=35902,Ix=35899,Bx=1021,Fx=1022,Yi=1023,Ha=1026,Js=1027,Ip=1028,Bp=1029,nr=1030,Fp=1031,zp=1033,_u=33776,vu=33777,xu=33778,yu=33779,jh=35840,Xh=35841,Wh=35842,qh=35843,Yh=36196,Zh=37492,Kh=37496,$h=37488,Qh=37489,bu=37490,Jh=37491,ep=37808,tp=37809,np=37810,ip=37811,ap=37812,sp=37813,rp=37814,op=37815,lp=37816,cp=37817,up=37818,fp=37819,dp=37820,hp=37821,pp=36492,mp=36494,gp=36495,_p=36283,vp=36284,Eu=36285,xp=36286,Ab=3200,yp=0,Cb=1,Ss="",bi="srgb",Tu="srgb-linear",Au="linear",an="srgb",Fr=7680,Q_=519,wb=512,Rb=513,Db=514,Hp=515,Nb=516,Ub=517,Gp=518,Lb=519,J_=35044,Ob=35048,ev="300 es",sa=2e3,Cl=2001;function Pb(a){for(let e=a.length-1;e>=0;--e)if(a[e]>=65535)return!0;return!1}function Cu(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function Ib(){const a=Cu("canvas");return a.style.display="block",a}const tv={};function nv(...a){const e="THREE."+a.shift();console.log(e,...a)}function zx(a){const e=a[0];if(typeof e=="string"&&e.startsWith("TSL:")){const i=a[1];i&&i.isStackTrace?a[0]+=" "+i.getLocation():a[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return a}function _t(...a){a=zx(a);const e="THREE."+a.shift();{const i=a[0];i&&i.isStackTrace?console.warn(i.getError(e)):console.warn(e,...a)}}function jt(...a){a=zx(a);const e="THREE."+a.shift();{const i=a[0];i&&i.isStackTrace?console.error(i.getError(e)):console.error(e,...a)}}function ao(...a){const e=a.join(" ");e in tv||(tv[e]=!0,_t(...a))}function Bb(a,e,i){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,i);break;default:s()}}setTimeout(c,i)})}const Fb={[Ph]:Ih,[Bh]:Hh,[Fh]:Gh,[co]:zh,[Ih]:Ph,[Hh]:Bh,[Gh]:Fh,[zh]:co};class ws{addEventListener(e,i){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(i)===-1&&s[e].push(i)}hasEventListener(e,i){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(i)!==-1}removeEventListener(e,i){const s=this._listeners;if(s===void 0)return;const l=s[e];if(l!==void 0){const c=l.indexOf(i);c!==-1&&l.splice(c,1)}}dispatchEvent(e){const i=this._listeners;if(i===void 0)return;const s=i[e.type];if(s!==void 0){e.target=this;const l=s.slice(0);for(let c=0,f=l.length;c<f;c++)l[c].call(this,e);e.target=null}}}const Zn=["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"],bl=Math.PI/180,Sp=180/Math.PI;function Dl(){const a=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Zn[a&255]+Zn[a>>8&255]+Zn[a>>16&255]+Zn[a>>24&255]+"-"+Zn[e&255]+Zn[e>>8&255]+"-"+Zn[e>>16&15|64]+Zn[e>>24&255]+"-"+Zn[i&63|128]+Zn[i>>8&255]+"-"+Zn[i>>16&255]+Zn[i>>24&255]+Zn[s&255]+Zn[s>>8&255]+Zn[s>>16&255]+Zn[s>>24&255]).toLowerCase()}function Pt(a,e,i){return Math.max(e,Math.min(i,a))}function zb(a,e){return(a%e+e)%e}function $d(a,e,i){return(1-i)*a+i*e}function ll(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 oi(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 Hb={DEG2RAD:bl},em=class em{constructor(e=0,i=0){this.x=e,this.y=i}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,i){return this.x=e,this.y=i,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,i){switch(e){case 0:this.x=i;break;case 1:this.y=i;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,i){return this.x=e.x+i.x,this.y=e.y+i.y,this}addScaledVector(e,i){return this.x+=e.x*i,this.y+=e.y*i,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,i){return this.x=e.x-i.x,this.y=e.y-i.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 i=this.x,s=this.y,l=e.elements;return this.x=l[0]*i+l[3]*s+l[6],this.y=l[1]*i+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,i){return this.x=Pt(this.x,e.x,i.x),this.y=Pt(this.y,e.y,i.y),this}clampScalar(e,i){return this.x=Pt(this.x,e,i),this.y=Pt(this.y,e,i),this}clampLength(e,i){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Pt(s,e,i))}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 i=Math.sqrt(this.lengthSq()*e.lengthSq());if(i===0)return Math.PI/2;const s=this.dot(e)/i;return Math.acos(Pt(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const i=this.x-e.x,s=this.y-e.y;return i*i+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,i){return this.x+=(e.x-this.x)*i,this.y+=(e.y-this.y)*i,this}lerpVectors(e,i,s){return this.x=e.x+(i.x-e.x)*s,this.y=e.y+(i.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,i=0){return this.x=e[i],this.y=e[i+1],this}toArray(e=[],i=0){return e[i]=this.x,e[i+1]=this.y,e}fromBufferAttribute(e,i){return this.x=e.getX(i),this.y=e.getY(i),this}rotateAround(e,i){const s=Math.cos(i),l=Math.sin(i),c=this.x-e.x,f=this.y-e.y;return this.x=c*s-f*l+e.x,this.y=c*l+f*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};em.prototype.isVector2=!0;let bt=em;class Ts{constructor(e=0,i=0,s=0,l=1){this.isQuaternion=!0,this._x=e,this._y=i,this._z=s,this._w=l}static slerpFlat(e,i,s,l,c,f,p){let m=s[l+0],h=s[l+1],y=s[l+2],S=s[l+3],_=c[f+0],b=c[f+1],T=c[f+2],C=c[f+3];if(S!==C||m!==_||h!==b||y!==T){let v=m*_+h*b+y*T+S*C;v<0&&(_=-_,b=-b,T=-T,C=-C,v=-v);let x=1-p;if(v<.9995){const B=Math.acos(v),P=Math.sin(B);x=Math.sin(x*B)/P,p=Math.sin(p*B)/P,m=m*x+_*p,h=h*x+b*p,y=y*x+T*p,S=S*x+C*p}else{m=m*x+_*p,h=h*x+b*p,y=y*x+T*p,S=S*x+C*p;const B=1/Math.sqrt(m*m+h*h+y*y+S*S);m*=B,h*=B,y*=B,S*=B}}e[i]=m,e[i+1]=h,e[i+2]=y,e[i+3]=S}static multiplyQuaternionsFlat(e,i,s,l,c,f){const p=s[l],m=s[l+1],h=s[l+2],y=s[l+3],S=c[f],_=c[f+1],b=c[f+2],T=c[f+3];return e[i]=p*T+y*S+m*b-h*_,e[i+1]=m*T+y*_+h*S-p*b,e[i+2]=h*T+y*b+p*_-m*S,e[i+3]=y*T-p*S-m*_-h*b,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,i,s,l){return this._x=e,this._y=i,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,i=!0){const s=e._x,l=e._y,c=e._z,f=e._order,p=Math.cos,m=Math.sin,h=p(s/2),y=p(l/2),S=p(c/2),_=m(s/2),b=m(l/2),T=m(c/2);switch(f){case"XYZ":this._x=_*y*S+h*b*T,this._y=h*b*S-_*y*T,this._z=h*y*T+_*b*S,this._w=h*y*S-_*b*T;break;case"YXZ":this._x=_*y*S+h*b*T,this._y=h*b*S-_*y*T,this._z=h*y*T-_*b*S,this._w=h*y*S+_*b*T;break;case"ZXY":this._x=_*y*S-h*b*T,this._y=h*b*S+_*y*T,this._z=h*y*T+_*b*S,this._w=h*y*S-_*b*T;break;case"ZYX":this._x=_*y*S-h*b*T,this._y=h*b*S+_*y*T,this._z=h*y*T-_*b*S,this._w=h*y*S+_*b*T;break;case"YZX":this._x=_*y*S+h*b*T,this._y=h*b*S+_*y*T,this._z=h*y*T-_*b*S,this._w=h*y*S-_*b*T;break;case"XZY":this._x=_*y*S-h*b*T,this._y=h*b*S-_*y*T,this._z=h*y*T+_*b*S,this._w=h*y*S+_*b*T;break;default:_t("Quaternion: .setFromEuler() encountered an unknown order: "+f)}return i===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,i){const s=i/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 i=e.elements,s=i[0],l=i[4],c=i[8],f=i[1],p=i[5],m=i[9],h=i[2],y=i[6],S=i[10],_=s+p+S;if(_>0){const b=.5/Math.sqrt(_+1);this._w=.25/b,this._x=(y-m)*b,this._y=(c-h)*b,this._z=(f-l)*b}else if(s>p&&s>S){const b=2*Math.sqrt(1+s-p-S);this._w=(y-m)/b,this._x=.25*b,this._y=(l+f)/b,this._z=(c+h)/b}else if(p>S){const b=2*Math.sqrt(1+p-s-S);this._w=(c-h)/b,this._x=(l+f)/b,this._y=.25*b,this._z=(m+y)/b}else{const b=2*Math.sqrt(1+S-s-p);this._w=(f-l)/b,this._x=(c+h)/b,this._y=(m+y)/b,this._z=.25*b}return this._onChangeCallback(),this}setFromUnitVectors(e,i){let s=e.dot(i)+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*i.z-e.z*i.y,this._y=e.z*i.x-e.x*i.z,this._z=e.x*i.y-e.y*i.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Pt(this.dot(e),-1,1)))}rotateTowards(e,i){const s=this.angleTo(e);if(s===0)return this;const l=Math.min(1,i/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,i){const s=e._x,l=e._y,c=e._z,f=e._w,p=i._x,m=i._y,h=i._z,y=i._w;return this._x=s*y+f*p+l*h-c*m,this._y=l*y+f*m+c*p-s*h,this._z=c*y+f*h+s*m-l*p,this._w=f*y-s*p-l*m-c*h,this._onChangeCallback(),this}slerp(e,i){let s=e._x,l=e._y,c=e._z,f=e._w,p=this.dot(e);p<0&&(s=-s,l=-l,c=-c,f=-f,p=-p);let m=1-i;if(p<.9995){const h=Math.acos(p),y=Math.sin(h);m=Math.sin(m*h)/y,i=Math.sin(i*h)/y,this._x=this._x*m+s*i,this._y=this._y*m+l*i,this._z=this._z*m+c*i,this._w=this._w*m+f*i,this._onChangeCallback()}else this._x=this._x*m+s*i,this._y=this._y*m+l*i,this._z=this._z*m+c*i,this._w=this._w*m+f*i,this.normalize();return this}slerpQuaternions(e,i,s){return this.copy(e).slerp(i,s)}random(){const e=2*Math.PI*Math.random(),i=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(i),c*Math.cos(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,i=0){return this._x=e[i],this._y=e[i+1],this._z=e[i+2],this._w=e[i+3],this._onChangeCallback(),this}toArray(e=[],i=0){return e[i]=this._x,e[i+1]=this._y,e[i+2]=this._z,e[i+3]=this._w,e}fromBufferAttribute(e,i){return this._x=e.getX(i),this._y=e.getY(i),this._z=e.getZ(i),this._w=e.getW(i),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 tm=class tm{constructor(e=0,i=0,s=0){this.x=e,this.y=i,this.z=s}set(e,i,s){return s===void 0&&(s=this.z),this.x=e,this.y=i,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,i){switch(e){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;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,i){return this.x=e.x+i.x,this.y=e.y+i.y,this.z=e.z+i.z,this}addScaledVector(e,i){return this.x+=e.x*i,this.y+=e.y*i,this.z+=e.z*i,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,i){return this.x=e.x-i.x,this.y=e.y-i.y,this.z=e.z-i.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,i){return this.x=e.x*i.x,this.y=e.y*i.y,this.z=e.z*i.z,this}applyEuler(e){return this.applyQuaternion(iv.setFromEuler(e))}applyAxisAngle(e,i){return this.applyQuaternion(iv.setFromAxisAngle(e,i))}applyMatrix3(e){const i=this.x,s=this.y,l=this.z,c=e.elements;return this.x=c[0]*i+c[3]*s+c[6]*l,this.y=c[1]*i+c[4]*s+c[7]*l,this.z=c[2]*i+c[5]*s+c[8]*l,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const i=this.x,s=this.y,l=this.z,c=e.elements,f=1/(c[3]*i+c[7]*s+c[11]*l+c[15]);return this.x=(c[0]*i+c[4]*s+c[8]*l+c[12])*f,this.y=(c[1]*i+c[5]*s+c[9]*l+c[13])*f,this.z=(c[2]*i+c[6]*s+c[10]*l+c[14])*f,this}applyQuaternion(e){const i=this.x,s=this.y,l=this.z,c=e.x,f=e.y,p=e.z,m=e.w,h=2*(f*l-p*s),y=2*(p*i-c*l),S=2*(c*s-f*i);return this.x=i+m*h+f*S-p*y,this.y=s+m*y+p*h-c*S,this.z=l+m*S+c*y-f*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 i=this.x,s=this.y,l=this.z,c=e.elements;return this.x=c[0]*i+c[4]*s+c[8]*l,this.y=c[1]*i+c[5]*s+c[9]*l,this.z=c[2]*i+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,i){return this.x=Pt(this.x,e.x,i.x),this.y=Pt(this.y,e.y,i.y),this.z=Pt(this.z,e.z,i.z),this}clampScalar(e,i){return this.x=Pt(this.x,e,i),this.y=Pt(this.y,e,i),this.z=Pt(this.z,e,i),this}clampLength(e,i){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Pt(s,e,i))}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,i){return this.x+=(e.x-this.x)*i,this.y+=(e.y-this.y)*i,this.z+=(e.z-this.z)*i,this}lerpVectors(e,i,s){return this.x=e.x+(i.x-e.x)*s,this.y=e.y+(i.y-e.y)*s,this.z=e.z+(i.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,i){const s=e.x,l=e.y,c=e.z,f=i.x,p=i.y,m=i.z;return this.x=l*m-c*p,this.y=c*f-s*m,this.z=s*p-l*f,this}projectOnVector(e){const i=e.lengthSq();if(i===0)return this.set(0,0,0);const s=e.dot(this)/i;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return Qd.copy(this).projectOnVector(e),this.sub(Qd)}reflect(e){return this.sub(Qd.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const i=Math.sqrt(this.lengthSq()*e.lengthSq());if(i===0)return Math.PI/2;const s=this.dot(e)/i;return Math.acos(Pt(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const i=this.x-e.x,s=this.y-e.y,l=this.z-e.z;return i*i+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,i,s){const l=Math.sin(i)*e;return this.x=l*Math.sin(s),this.y=Math.cos(i)*e,this.z=l*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,i,s){return this.x=e*Math.sin(i),this.y=s,this.z=e*Math.cos(i),this}setFromMatrixPosition(e){const i=e.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(e){const i=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),l=this.setFromMatrixColumn(e,2).length();return this.x=i,this.y=s,this.z=l,this}setFromMatrixColumn(e,i){return this.fromArray(e.elements,i*4)}setFromMatrix3Column(e,i){return this.fromArray(e.elements,i*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,i=0){return this.x=e[i],this.y=e[i+1],this.z=e[i+2],this}toArray(e=[],i=0){return e[i]=this.x,e[i+1]=this.y,e[i+2]=this.z,e}fromBufferAttribute(e,i){return this.x=e.getX(i),this.y=e.getY(i),this.z=e.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,i=Math.random()*2-1,s=Math.sqrt(1-i*i);return this.x=s*Math.cos(e),this.y=i,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};tm.prototype.isVector3=!0;let ie=tm;const Qd=new ie,iv=new Ts,nm=class nm{constructor(e,i,s,l,c,f,p,m,h){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,i,s,l,c,f,p,m,h)}set(e,i,s,l,c,f,p,m,h){const y=this.elements;return y[0]=e,y[1]=l,y[2]=p,y[3]=i,y[4]=c,y[5]=m,y[6]=s,y[7]=f,y[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const i=this.elements,s=e.elements;return i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=s[3],i[4]=s[4],i[5]=s[5],i[6]=s[6],i[7]=s[7],i[8]=s[8],this}extractBasis(e,i,s){return e.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const i=e.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,i){const s=e.elements,l=i.elements,c=this.elements,f=s[0],p=s[3],m=s[6],h=s[1],y=s[4],S=s[7],_=s[2],b=s[5],T=s[8],C=l[0],v=l[3],x=l[6],B=l[1],P=l[4],D=l[7],O=l[2],U=l[5],N=l[8];return c[0]=f*C+p*B+m*O,c[3]=f*v+p*P+m*U,c[6]=f*x+p*D+m*N,c[1]=h*C+y*B+S*O,c[4]=h*v+y*P+S*U,c[7]=h*x+y*D+S*N,c[2]=_*C+b*B+T*O,c[5]=_*v+b*P+T*U,c[8]=_*x+b*D+T*N,this}multiplyScalar(e){const i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=e,i[4]*=e,i[7]*=e,i[2]*=e,i[5]*=e,i[8]*=e,this}determinant(){const e=this.elements,i=e[0],s=e[1],l=e[2],c=e[3],f=e[4],p=e[5],m=e[6],h=e[7],y=e[8];return i*f*y-i*p*h-s*c*y+s*p*m+l*c*h-l*f*m}invert(){const e=this.elements,i=e[0],s=e[1],l=e[2],c=e[3],f=e[4],p=e[5],m=e[6],h=e[7],y=e[8],S=y*f-p*h,_=p*m-y*c,b=h*c-f*m,T=i*S+s*_+l*b;if(T===0)return this.set(0,0,0,0,0,0,0,0,0);const C=1/T;return e[0]=S*C,e[1]=(l*h-y*s)*C,e[2]=(p*s-l*f)*C,e[3]=_*C,e[4]=(y*i-l*m)*C,e[5]=(l*c-p*i)*C,e[6]=b*C,e[7]=(s*m-h*i)*C,e[8]=(f*i-s*c)*C,this}transpose(){let e;const i=this.elements;return e=i[1],i[1]=i[3],i[3]=e,e=i[2],i[2]=i[6],i[6]=e,e=i[5],i[5]=i[7],i[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const i=this.elements;return e[0]=i[0],e[1]=i[3],e[2]=i[6],e[3]=i[1],e[4]=i[4],e[5]=i[7],e[6]=i[2],e[7]=i[5],e[8]=i[8],this}setUvTransform(e,i,s,l,c,f,p){const m=Math.cos(c),h=Math.sin(c);return this.set(s*m,s*h,-s*(m*f+h*p)+f+e,-l*h,l*m,-l*(-h*f+m*p)+p+i,0,0,1),this}scale(e,i){return ao("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Jd.makeScale(e,i)),this}rotate(e){return ao("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Jd.makeRotation(-e)),this}translate(e,i){return ao("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Jd.makeTranslation(e,i)),this}makeTranslation(e,i){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,i,0,0,1),this}makeRotation(e){const i=Math.cos(e),s=Math.sin(e);return this.set(i,-s,0,s,i,0,0,0,1),this}makeScale(e,i){return this.set(e,0,0,0,i,0,0,0,1),this}equals(e){const i=this.elements,s=e.elements;for(let l=0;l<9;l++)if(i[l]!==s[l])return!1;return!0}fromArray(e,i=0){for(let s=0;s<9;s++)this.elements[s]=e[s+i];return this}toArray(e=[],i=0){const s=this.elements;return e[i]=s[0],e[i+1]=s[1],e[i+2]=s[2],e[i+3]=s[3],e[i+4]=s[4],e[i+5]=s[5],e[i+6]=s[6],e[i+7]=s[7],e[i+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}};nm.prototype.isMatrix3=!0;let At=nm;const Jd=new At,av=new At().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),sv=new At().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Gb(){const a={enabled:!0,workingColorSpace:Tu,spaces:{},convert:function(l,c,f){return this.enabled===!1||c===f||!c||!f||(this.spaces[c].transfer===an&&(l.r=Fa(l.r),l.g=Fa(l.g),l.b=Fa(l.b)),this.spaces[c].primaries!==this.spaces[f].primaries&&(l.applyMatrix3(this.spaces[c].toXYZ),l.applyMatrix3(this.spaces[f].fromXYZ)),this.spaces[f].transfer===an&&(l.r=so(l.r),l.g=so(l.g),l.b=so(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===Ss?Au: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,f){return l.copy(this.spaces[c].toXYZ).multiply(this.spaces[f].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 ao("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(l,c)},toWorkingColorSpace:function(l,c){return ao("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(l,c)}},e=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],s=[.3127,.329];return a.define({[Tu]:{primaries:e,whitePoint:s,transfer:Au,toXYZ:av,fromXYZ:sv,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:bi},outputColorSpaceConfig:{drawingBufferColorSpace:bi}},[bi]:{primaries:e,whitePoint:s,transfer:an,toXYZ:av,fromXYZ:sv,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:bi}}}),a}const kt=Gb();function Fa(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function so(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}let zr;class Vb{static getDataURL(e,i="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let s;if(e instanceof HTMLCanvasElement)s=e;else{zr===void 0&&(zr=Cu("canvas")),zr.width=e.width,zr.height=e.height;const l=zr.getContext("2d");e instanceof ImageData?l.putImageData(e,0,0):l.drawImage(e,0,0,e.width,e.height),s=zr}return s.toDataURL(i)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const i=Cu("canvas");i.width=e.width,i.height=e.height;const s=i.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 f=0;f<c.length;f++)c[f]=Fa(c[f]/255)*255;return s.putImageData(l,0,0),i}else if(e.data){const i=e.data.slice(0);for(let s=0;s<i.length;s++)i instanceof Uint8Array||i instanceof Uint8ClampedArray?i[s]=Math.floor(Fa(i[s]/255)*255):i[s]=Fa(i[s]);return{data:i,width:e.width,height:e.height}}else return _t("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let kb=0;class Vp{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:kb++}),this.uuid=Dl(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const i=this.data;return typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement?e.set(i.videoWidth,i.videoHeight,0):typeof VideoFrame<"u"&&i instanceof VideoFrame?e.set(i.displayWidth,i.displayHeight,0):i!==null?e.set(i.width,i.height,i.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const i=e===void 0||typeof e=="string";if(!i&&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 f=0,p=l.length;f<p;f++)l[f].isDataTexture?c.push(eh(l[f].image)):c.push(eh(l[f]))}else c=eh(l);s.url=c}return i||(e.images[this.uuid]=s),s}}function eh(a){return typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&a instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&a instanceof ImageBitmap?Vb.getDataURL(a):a.data?{data:Array.from(a.data),width:a.width,height:a.height,type:a.data.constructor.name}:(_t("Texture: Unable to serialize Texture."),{})}let jb=0;const th=new ie;class ei extends ws{constructor(e=ei.DEFAULT_IMAGE,i=ei.DEFAULT_MAPPING,s=Ia,l=Ia,c=$n,f=Qs,p=Yi,m=Ei,h=ei.DEFAULT_ANISOTROPY,y=Ss){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:jb++}),this.uuid=Dl(),this.name="",this.source=new Vp(e),this.mipmaps=[],this.mapping=i,this.channel=0,this.wrapS=s,this.wrapT=l,this.magFilter=c,this.minFilter=f,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 At,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=y,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(th).x}get height(){return this.source.getSize(th).y}get depth(){return this.source.getSize(th).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,i){this.updateRanges.push({start:e,count:i})}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 i in e){const s=e[i];if(s===void 0){_t(`Texture.setValues(): parameter '${i}' has value of undefined.`);continue}const l=this[i];if(l===void 0){_t(`Texture.setValues(): property '${i}' 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[i]=s}}toJSON(e){const i=e===void 0||typeof e=="string";if(!i&&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),i||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ux)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Vh:e.x=e.x-Math.floor(e.x);break;case Ia:e.x=e.x<0?0:1;break;case kh: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 Vh:e.y=e.y-Math.floor(e.y);break;case Ia:e.y=e.y<0?0:1;break;case kh: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++}}ei.DEFAULT_IMAGE=null;ei.DEFAULT_MAPPING=Ux;ei.DEFAULT_ANISOTROPY=1;const im=class im{constructor(e=0,i=0,s=0,l=1){this.x=e,this.y=i,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,i,s,l){return this.x=e,this.y=i,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,i){switch(e){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;case 3:this.w=i;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,i){return this.x=e.x+i.x,this.y=e.y+i.y,this.z=e.z+i.z,this.w=e.w+i.w,this}addScaledVector(e,i){return this.x+=e.x*i,this.y+=e.y*i,this.z+=e.z*i,this.w+=e.w*i,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,i){return this.x=e.x-i.x,this.y=e.y-i.y,this.z=e.z-i.z,this.w=e.w-i.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 i=this.x,s=this.y,l=this.z,c=this.w,f=e.elements;return this.x=f[0]*i+f[4]*s+f[8]*l+f[12]*c,this.y=f[1]*i+f[5]*s+f[9]*l+f[13]*c,this.z=f[2]*i+f[6]*s+f[10]*l+f[14]*c,this.w=f[3]*i+f[7]*s+f[11]*l+f[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 i=Math.sqrt(1-e.w*e.w);return i<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/i,this.y=e.y/i,this.z=e.z/i),this}setAxisAngleFromRotationMatrix(e){let i,s,l,c;const m=e.elements,h=m[0],y=m[4],S=m[8],_=m[1],b=m[5],T=m[9],C=m[2],v=m[6],x=m[10];if(Math.abs(y-_)<.01&&Math.abs(S-C)<.01&&Math.abs(T-v)<.01){if(Math.abs(y+_)<.1&&Math.abs(S+C)<.1&&Math.abs(T+v)<.1&&Math.abs(h+b+x-3)<.1)return this.set(1,0,0,0),this;i=Math.PI;const P=(h+1)/2,D=(b+1)/2,O=(x+1)/2,U=(y+_)/4,N=(S+C)/4,A=(T+v)/4;return P>D&&P>O?P<.01?(s=0,l=.707106781,c=.707106781):(s=Math.sqrt(P),l=U/s,c=N/s):D>O?D<.01?(s=.707106781,l=0,c=.707106781):(l=Math.sqrt(D),s=U/l,c=A/l):O<.01?(s=.707106781,l=.707106781,c=0):(c=Math.sqrt(O),s=N/c,l=A/c),this.set(s,l,c,i),this}let B=Math.sqrt((v-T)*(v-T)+(S-C)*(S-C)+(_-y)*(_-y));return Math.abs(B)<.001&&(B=1),this.x=(v-T)/B,this.y=(S-C)/B,this.z=(_-y)/B,this.w=Math.acos((h+b+x-1)/2),this}setFromMatrixPosition(e){const i=e.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this.w=i[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,i){return this.x=Pt(this.x,e.x,i.x),this.y=Pt(this.y,e.y,i.y),this.z=Pt(this.z,e.z,i.z),this.w=Pt(this.w,e.w,i.w),this}clampScalar(e,i){return this.x=Pt(this.x,e,i),this.y=Pt(this.y,e,i),this.z=Pt(this.z,e,i),this.w=Pt(this.w,e,i),this}clampLength(e,i){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Pt(s,e,i))}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,i){return this.x+=(e.x-this.x)*i,this.y+=(e.y-this.y)*i,this.z+=(e.z-this.z)*i,this.w+=(e.w-this.w)*i,this}lerpVectors(e,i,s){return this.x=e.x+(i.x-e.x)*s,this.y=e.y+(i.y-e.y)*s,this.z=e.z+(i.z-e.z)*s,this.w=e.w+(i.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,i=0){return this.x=e[i],this.y=e[i+1],this.z=e[i+2],this.w=e[i+3],this}toArray(e=[],i=0){return e[i]=this.x,e[i+1]=this.y,e[i+2]=this.z,e[i+3]=this.w,e}fromBufferAttribute(e,i){return this.x=e.getX(i),this.y=e.getY(i),this.z=e.getZ(i),this.w=e.getW(i),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}};im.prototype.isVector4=!0;let xn=im;class Xb extends ws{constructor(e=1,i=1,s={}){super(),s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:$n,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=i,this.depth=s.depth,this.scissor=new xn(0,0,e,i),this.scissorTest=!1,this.viewport=new xn(0,0,e,i),this.textures=[];const l={width:e,height:i,depth:s.depth},c=new ei(l),f=s.count;for(let p=0;p<f;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 i={minFilter:$n,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(i.mapping=e.mapping),e.wrapS!==void 0&&(i.wrapS=e.wrapS),e.wrapT!==void 0&&(i.wrapT=e.wrapT),e.wrapR!==void 0&&(i.wrapR=e.wrapR),e.magFilter!==void 0&&(i.magFilter=e.magFilter),e.minFilter!==void 0&&(i.minFilter=e.minFilter),e.format!==void 0&&(i.format=e.format),e.type!==void 0&&(i.type=e.type),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(i.colorSpace=e.colorSpace),e.flipY!==void 0&&(i.flipY=e.flipY),e.generateMipmaps!==void 0&&(i.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(i.internalFormat=e.internalFormat);for(let s=0;s<this.textures.length;s++)this.textures[s].setValues(i)}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,i,s=1){if(this.width!==e||this.height!==i||this.depth!==s){this.width=e,this.height=i,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=i,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,i),this.scissor.set(0,0,e,i)}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 i=0,s=e.textures.length;i<s;i++){this.textures[i]=e.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0,this.textures[i].renderTarget=this;const l=Object.assign({},e.textures[i].image);this.textures[i].source=new Vp(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 oa extends Xb{constructor(e=1,i=1,s={}){super(e,i,s),this.isWebGLRenderTarget=!0}}class Hx extends ei{constructor(e=null,i=1,s=1,l=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:i,height:s,depth:l},this.magFilter=Wn,this.minFilter=Wn,this.wrapR=Ia,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Wb extends ei{constructor(e=null,i=1,s=1,l=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:i,height:s,depth:l},this.magFilter=Wn,this.minFilter=Wn,this.wrapR=Ia,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Du=class Du{constructor(e,i,s,l,c,f,p,m,h,y,S,_,b,T,C,v){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,i,s,l,c,f,p,m,h,y,S,_,b,T,C,v)}set(e,i,s,l,c,f,p,m,h,y,S,_,b,T,C,v){const x=this.elements;return x[0]=e,x[4]=i,x[8]=s,x[12]=l,x[1]=c,x[5]=f,x[9]=p,x[13]=m,x[2]=h,x[6]=y,x[10]=S,x[14]=_,x[3]=b,x[7]=T,x[11]=C,x[15]=v,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 Du().fromArray(this.elements)}copy(e){const i=this.elements,s=e.elements;return i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=s[3],i[4]=s[4],i[5]=s[5],i[6]=s[6],i[7]=s[7],i[8]=s[8],i[9]=s[9],i[10]=s[10],i[11]=s[11],i[12]=s[12],i[13]=s[13],i[14]=s[14],i[15]=s[15],this}copyPosition(e){const i=this.elements,s=e.elements;return i[12]=s[12],i[13]=s[13],i[14]=s[14],this}setFromMatrix3(e){const i=e.elements;return this.set(i[0],i[3],i[6],0,i[1],i[4],i[7],0,i[2],i[5],i[8],0,0,0,0,1),this}extractBasis(e,i,s){return this.determinantAffine()===0?(e.set(1,0,0),i.set(0,1,0),s.set(0,0,1),this):(e.setFromMatrixColumn(this,0),i.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this)}makeBasis(e,i,s){return this.set(e.x,i.x,s.x,0,e.y,i.y,s.y,0,e.z,i.z,s.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const i=this.elements,s=e.elements,l=1/Hr.setFromMatrixColumn(e,0).length(),c=1/Hr.setFromMatrixColumn(e,1).length(),f=1/Hr.setFromMatrixColumn(e,2).length();return i[0]=s[0]*l,i[1]=s[1]*l,i[2]=s[2]*l,i[3]=0,i[4]=s[4]*c,i[5]=s[5]*c,i[6]=s[6]*c,i[7]=0,i[8]=s[8]*f,i[9]=s[9]*f,i[10]=s[10]*f,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromEuler(e){const i=this.elements,s=e.x,l=e.y,c=e.z,f=Math.cos(s),p=Math.sin(s),m=Math.cos(l),h=Math.sin(l),y=Math.cos(c),S=Math.sin(c);if(e.order==="XYZ"){const _=f*y,b=f*S,T=p*y,C=p*S;i[0]=m*y,i[4]=-m*S,i[8]=h,i[1]=b+T*h,i[5]=_-C*h,i[9]=-p*m,i[2]=C-_*h,i[6]=T+b*h,i[10]=f*m}else if(e.order==="YXZ"){const _=m*y,b=m*S,T=h*y,C=h*S;i[0]=_+C*p,i[4]=T*p-b,i[8]=f*h,i[1]=f*S,i[5]=f*y,i[9]=-p,i[2]=b*p-T,i[6]=C+_*p,i[10]=f*m}else if(e.order==="ZXY"){const _=m*y,b=m*S,T=h*y,C=h*S;i[0]=_-C*p,i[4]=-f*S,i[8]=T+b*p,i[1]=b+T*p,i[5]=f*y,i[9]=C-_*p,i[2]=-f*h,i[6]=p,i[10]=f*m}else if(e.order==="ZYX"){const _=f*y,b=f*S,T=p*y,C=p*S;i[0]=m*y,i[4]=T*h-b,i[8]=_*h+C,i[1]=m*S,i[5]=C*h+_,i[9]=b*h-T,i[2]=-h,i[6]=p*m,i[10]=f*m}else if(e.order==="YZX"){const _=f*m,b=f*h,T=p*m,C=p*h;i[0]=m*y,i[4]=C-_*S,i[8]=T*S+b,i[1]=S,i[5]=f*y,i[9]=-p*y,i[2]=-h*y,i[6]=b*S+T,i[10]=_-C*S}else if(e.order==="XZY"){const _=f*m,b=f*h,T=p*m,C=p*h;i[0]=m*y,i[4]=-S,i[8]=h*y,i[1]=_*S+C,i[5]=f*y,i[9]=b*S-T,i[2]=T*S-b,i[6]=p*y,i[10]=C*S+_}return i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}makeRotationFromQuaternion(e){return this.compose(qb,e,Yb)}lookAt(e,i,s){const l=this.elements;return Si.subVectors(e,i),Si.lengthSq()===0&&(Si.z=1),Si.normalize(),ps.crossVectors(s,Si),ps.lengthSq()===0&&(Math.abs(s.z)===1?Si.x+=1e-4:Si.z+=1e-4,Si.normalize(),ps.crossVectors(s,Si)),ps.normalize(),Gc.crossVectors(Si,ps),l[0]=ps.x,l[4]=Gc.x,l[8]=Si.x,l[1]=ps.y,l[5]=Gc.y,l[9]=Si.y,l[2]=ps.z,l[6]=Gc.z,l[10]=Si.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,i){const s=e.elements,l=i.elements,c=this.elements,f=s[0],p=s[4],m=s[8],h=s[12],y=s[1],S=s[5],_=s[9],b=s[13],T=s[2],C=s[6],v=s[10],x=s[14],B=s[3],P=s[7],D=s[11],O=s[15],U=l[0],N=l[4],A=l[8],L=l[12],j=l[1],V=l[5],$=l[9],pe=l[13],ge=l[2],K=l[6],H=l[10],G=l[14],ne=l[3],ye=l[7],xe=l[11],F=l[15];return c[0]=f*U+p*j+m*ge+h*ne,c[4]=f*N+p*V+m*K+h*ye,c[8]=f*A+p*$+m*H+h*xe,c[12]=f*L+p*pe+m*G+h*F,c[1]=y*U+S*j+_*ge+b*ne,c[5]=y*N+S*V+_*K+b*ye,c[9]=y*A+S*$+_*H+b*xe,c[13]=y*L+S*pe+_*G+b*F,c[2]=T*U+C*j+v*ge+x*ne,c[6]=T*N+C*V+v*K+x*ye,c[10]=T*A+C*$+v*H+x*xe,c[14]=T*L+C*pe+v*G+x*F,c[3]=B*U+P*j+D*ge+O*ne,c[7]=B*N+P*V+D*K+O*ye,c[11]=B*A+P*$+D*H+O*xe,c[15]=B*L+P*pe+D*G+O*F,this}multiplyScalar(e){const i=this.elements;return i[0]*=e,i[4]*=e,i[8]*=e,i[12]*=e,i[1]*=e,i[5]*=e,i[9]*=e,i[13]*=e,i[2]*=e,i[6]*=e,i[10]*=e,i[14]*=e,i[3]*=e,i[7]*=e,i[11]*=e,i[15]*=e,this}determinant(){const e=this.elements,i=e[0],s=e[4],l=e[8],c=e[12],f=e[1],p=e[5],m=e[9],h=e[13],y=e[2],S=e[6],_=e[10],b=e[14],T=e[3],C=e[7],v=e[11],x=e[15],B=m*b-h*_,P=p*b-h*S,D=p*_-m*S,O=f*b-h*y,U=f*_-m*y,N=f*S-p*y;return i*(C*B-v*P+x*D)-s*(T*B-v*O+x*U)+l*(T*P-C*O+x*N)-c*(T*D-C*U+v*N)}determinantAffine(){const e=this.elements,i=e[0],s=e[4],l=e[8],c=e[1],f=e[5],p=e[9],m=e[2],h=e[6],y=e[10];return i*(f*y-p*h)-s*(c*y-p*m)+l*(c*h-f*m)}transpose(){const e=this.elements;let i;return i=e[1],e[1]=e[4],e[4]=i,i=e[2],e[2]=e[8],e[8]=i,i=e[6],e[6]=e[9],e[9]=i,i=e[3],e[3]=e[12],e[12]=i,i=e[7],e[7]=e[13],e[13]=i,i=e[11],e[11]=e[14],e[14]=i,this}setPosition(e,i,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]=i,l[14]=s),this}invert(){const e=this.elements,i=e[0],s=e[1],l=e[2],c=e[3],f=e[4],p=e[5],m=e[6],h=e[7],y=e[8],S=e[9],_=e[10],b=e[11],T=e[12],C=e[13],v=e[14],x=e[15],B=i*p-s*f,P=i*m-l*f,D=i*h-c*f,O=s*m-l*p,U=s*h-c*p,N=l*h-c*m,A=y*C-S*T,L=y*v-_*T,j=y*x-b*T,V=S*v-_*C,$=S*x-b*C,pe=_*x-b*v,ge=B*pe-P*$+D*V+O*j-U*L+N*A;if(ge===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const K=1/ge;return e[0]=(p*pe-m*$+h*V)*K,e[1]=(l*$-s*pe-c*V)*K,e[2]=(C*N-v*U+x*O)*K,e[3]=(_*U-S*N-b*O)*K,e[4]=(m*j-f*pe-h*L)*K,e[5]=(i*pe-l*j+c*L)*K,e[6]=(v*D-T*N-x*P)*K,e[7]=(y*N-_*D+b*P)*K,e[8]=(f*$-p*j+h*A)*K,e[9]=(s*j-i*$-c*A)*K,e[10]=(T*U-C*D+x*B)*K,e[11]=(S*D-y*U-b*B)*K,e[12]=(p*L-f*V-m*A)*K,e[13]=(i*V-s*L+l*A)*K,e[14]=(C*P-T*O-v*B)*K,e[15]=(y*O-S*P+_*B)*K,this}scale(e){const i=this.elements,s=e.x,l=e.y,c=e.z;return i[0]*=s,i[4]*=l,i[8]*=c,i[1]*=s,i[5]*=l,i[9]*=c,i[2]*=s,i[6]*=l,i[10]*=c,i[3]*=s,i[7]*=l,i[11]*=c,this}getMaxScaleOnAxis(){const e=this.elements,i=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(i,s,l))}makeTranslation(e,i,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,i,0,0,1,s,0,0,0,1),this}makeRotationX(e){const i=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,i,-s,0,0,s,i,0,0,0,0,1),this}makeRotationY(e){const i=Math.cos(e),s=Math.sin(e);return this.set(i,0,s,0,0,1,0,0,-s,0,i,0,0,0,0,1),this}makeRotationZ(e){const i=Math.cos(e),s=Math.sin(e);return this.set(i,-s,0,0,s,i,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,i){const s=Math.cos(i),l=Math.sin(i),c=1-s,f=e.x,p=e.y,m=e.z,h=c*f,y=c*p;return this.set(h*f+s,h*p-l*m,h*m+l*p,0,h*p+l*m,y*p+s,y*m-l*f,0,h*m-l*p,y*m+l*f,c*m*m+s,0,0,0,0,1),this}makeScale(e,i,s){return this.set(e,0,0,0,0,i,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,i,s,l,c,f){return this.set(1,s,c,0,e,1,f,0,i,l,1,0,0,0,0,1),this}compose(e,i,s){const l=this.elements,c=i._x,f=i._y,p=i._z,m=i._w,h=c+c,y=f+f,S=p+p,_=c*h,b=c*y,T=c*S,C=f*y,v=f*S,x=p*S,B=m*h,P=m*y,D=m*S,O=s.x,U=s.y,N=s.z;return l[0]=(1-(C+x))*O,l[1]=(b+D)*O,l[2]=(T-P)*O,l[3]=0,l[4]=(b-D)*U,l[5]=(1-(_+x))*U,l[6]=(v+B)*U,l[7]=0,l[8]=(T+P)*N,l[9]=(v-B)*N,l[10]=(1-(_+C))*N,l[11]=0,l[12]=e.x,l[13]=e.y,l[14]=e.z,l[15]=1,this}decompose(e,i,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),i.identity(),this;let f=Hr.set(l[0],l[1],l[2]).length();const p=Hr.set(l[4],l[5],l[6]).length(),m=Hr.set(l[8],l[9],l[10]).length();c<0&&(f=-f),ji.copy(this);const h=1/f,y=1/p,S=1/m;return ji.elements[0]*=h,ji.elements[1]*=h,ji.elements[2]*=h,ji.elements[4]*=y,ji.elements[5]*=y,ji.elements[6]*=y,ji.elements[8]*=S,ji.elements[9]*=S,ji.elements[10]*=S,i.setFromRotationMatrix(ji),s.x=f,s.y=p,s.z=m,this}makePerspective(e,i,s,l,c,f,p=sa,m=!1){const h=this.elements,y=2*c/(i-e),S=2*c/(s-l),_=(i+e)/(i-e),b=(s+l)/(s-l);let T,C;if(m)T=c/(f-c),C=f*c/(f-c);else if(p===sa)T=-(f+c)/(f-c),C=-2*f*c/(f-c);else if(p===Cl)T=-f/(f-c),C=-f*c/(f-c);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+p);return h[0]=y,h[4]=0,h[8]=_,h[12]=0,h[1]=0,h[5]=S,h[9]=b,h[13]=0,h[2]=0,h[6]=0,h[10]=T,h[14]=C,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,i,s,l,c,f,p=sa,m=!1){const h=this.elements,y=2/(i-e),S=2/(s-l),_=-(i+e)/(i-e),b=-(s+l)/(s-l);let T,C;if(m)T=1/(f-c),C=f/(f-c);else if(p===sa)T=-2/(f-c),C=-(f+c)/(f-c);else if(p===Cl)T=-1/(f-c),C=-c/(f-c);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+p);return h[0]=y,h[4]=0,h[8]=0,h[12]=_,h[1]=0,h[5]=S,h[9]=0,h[13]=b,h[2]=0,h[6]=0,h[10]=T,h[14]=C,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const i=this.elements,s=e.elements;for(let l=0;l<16;l++)if(i[l]!==s[l])return!1;return!0}fromArray(e,i=0){for(let s=0;s<16;s++)this.elements[s]=e[s+i];return this}toArray(e=[],i=0){const s=this.elements;return e[i]=s[0],e[i+1]=s[1],e[i+2]=s[2],e[i+3]=s[3],e[i+4]=s[4],e[i+5]=s[5],e[i+6]=s[6],e[i+7]=s[7],e[i+8]=s[8],e[i+9]=s[9],e[i+10]=s[10],e[i+11]=s[11],e[i+12]=s[12],e[i+13]=s[13],e[i+14]=s[14],e[i+15]=s[15],e}};Du.prototype.isMatrix4=!0;let dn=Du;const Hr=new ie,ji=new dn,qb=new ie(0,0,0),Yb=new ie(1,1,1),ps=new ie,Gc=new ie,Si=new ie,rv=new dn,ov=new Ts;class As{constructor(e=0,i=0,s=0,l=As.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=i,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,i,s,l=this._order){return this._x=e,this._y=i,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,i=this._order,s=!0){const l=e.elements,c=l[0],f=l[4],p=l[8],m=l[1],h=l[5],y=l[9],S=l[2],_=l[6],b=l[10];switch(i){case"XYZ":this._y=Math.asin(Pt(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(-y,b),this._z=Math.atan2(-f,c)):(this._x=Math.atan2(_,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Pt(y,-1,1)),Math.abs(y)<.9999999?(this._y=Math.atan2(p,b),this._z=Math.atan2(m,h)):(this._y=Math.atan2(-S,c),this._z=0);break;case"ZXY":this._x=Math.asin(Pt(_,-1,1)),Math.abs(_)<.9999999?(this._y=Math.atan2(-S,b),this._z=Math.atan2(-f,h)):(this._y=0,this._z=Math.atan2(m,c));break;case"ZYX":this._y=Math.asin(-Pt(S,-1,1)),Math.abs(S)<.9999999?(this._x=Math.atan2(_,b),this._z=Math.atan2(m,c)):(this._x=0,this._z=Math.atan2(-f,h));break;case"YZX":this._z=Math.asin(Pt(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(-y,h),this._y=Math.atan2(-S,c)):(this._x=0,this._y=Math.atan2(p,b));break;case"XZY":this._z=Math.asin(-Pt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(_,h),this._y=Math.atan2(p,c)):(this._x=Math.atan2(-y,b),this._y=0);break;default:_t("Euler: .setFromRotationMatrix() encountered an unknown order: "+i)}return this._order=i,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,i,s){return rv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(rv,i,s)}setFromVector3(e,i=this._order){return this.set(e.x,e.y,e.z,i)}reorder(e){return ov.setFromEuler(this),this.setFromQuaternion(ov,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=[],i=0){return e[i]=this._x,e[i+1]=this._y,e[i+2]=this._z,e[i+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}}As.DEFAULT_ORDER="XYZ";class Gx{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 Zb=0;const lv=new ie,Gr=new Ts,wa=new dn,Vc=new ie,cl=new ie,Kb=new ie,$b=new Ts,cv=new ie(1,0,0),uv=new ie(0,1,0),fv=new ie(0,0,1),dv={type:"added"},Qb={type:"removed"},Vr={type:"childadded",child:null},nh={type:"childremoved",child:null};class Ln extends ws{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Zb++}),this.uuid=Dl(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ln.DEFAULT_UP.clone();const e=new ie,i=new As,s=new Ts,l=new ie(1,1,1);function c(){s.setFromEuler(i,!1)}function f(){i.setFromQuaternion(s,void 0,!1)}i._onChange(c),s._onChange(f),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:i},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:l},modelViewMatrix:{value:new dn},normalMatrix:{value:new At}}),this.matrix=new dn,this.matrixWorld=new dn,this.matrixAutoUpdate=Ln.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ln.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Gx,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,i){this.quaternion.setFromAxisAngle(e,i)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,i){return Gr.setFromAxisAngle(e,i),this.quaternion.multiply(Gr),this}rotateOnWorldAxis(e,i){return Gr.setFromAxisAngle(e,i),this.quaternion.premultiply(Gr),this}rotateX(e){return this.rotateOnAxis(cv,e)}rotateY(e){return this.rotateOnAxis(uv,e)}rotateZ(e){return this.rotateOnAxis(fv,e)}translateOnAxis(e,i){return lv.copy(e).applyQuaternion(this.quaternion),this.position.add(lv.multiplyScalar(i)),this}translateX(e){return this.translateOnAxis(cv,e)}translateY(e){return this.translateOnAxis(uv,e)}translateZ(e){return this.translateOnAxis(fv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(wa.copy(this.matrixWorld).invert())}lookAt(e,i,s){e.isVector3?Vc.copy(e):Vc.set(e,i,s);const l=this.parent;this.updateWorldMatrix(!0,!1),cl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?wa.lookAt(cl,Vc,this.up):wa.lookAt(Vc,cl,this.up),this.quaternion.setFromRotationMatrix(wa),l&&(wa.extractRotation(l.matrixWorld),Gr.setFromRotationMatrix(wa),this.quaternion.premultiply(Gr.invert()))}add(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.add(arguments[i]);return this}return e===this?(jt("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(dv),Vr.child=e,this.dispatchEvent(Vr),Vr.child=null):jt("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 i=this.children.indexOf(e);return i!==-1&&(e.parent=null,this.children.splice(i,1),e.dispatchEvent(Qb),nh.child=e,this.dispatchEvent(nh),nh.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),wa.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),wa.multiply(e.parent.matrixWorld)),e.applyMatrix4(wa),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(dv),Vr.child=e,this.dispatchEvent(Vr),Vr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,i){if(this[e]===i)return this;for(let s=0,l=this.children.length;s<l;s++){const f=this.children[s].getObjectByProperty(e,i);if(f!==void 0)return f}}getObjectsByProperty(e,i,s=[]){this[e]===i&&s.push(this);const l=this.children;for(let c=0,f=l.length;c<f;c++)l[c].getObjectsByProperty(e,i,s);return s}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(cl,e,Kb),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(cl,$b,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const i=this.matrixWorld.elements;return e.set(i[8],i[9],i[10]).normalize()}raycast(){}traverse(e){e(this);const i=this.children;for(let s=0,l=i.length;s<l;s++)i[s].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const i=this.children;for(let s=0,l=i.length;s<l;s++)i[s].traverseVisible(e)}traverseAncestors(e){const i=this.parent;i!==null&&(e(i),i.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const i=e.x,s=e.y,l=e.z,c=this.matrix.elements;c[12]+=i-c[0]*i-c[4]*s-c[8]*l,c[13]+=s-c[1]*i-c[5]*s-c[9]*l,c[14]+=l-c[2]*i-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 i=this.children;for(let s=0,l=i.length;s<l;s++)i[s].updateMatrixWorld(e)}updateWorldMatrix(e,i,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),i===!0){const c=this.children;for(let f=0,p=c.length;f<p;f++)c[f].updateWorldMatrix(!1,!0,s)}}toJSON(e){const i=e===void 0||typeof e=="string",s={};i&&(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,y=m.length;h<y;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(i){const p=f(e.geometries),m=f(e.materials),h=f(e.textures),y=f(e.images),S=f(e.shapes),_=f(e.skeletons),b=f(e.animations),T=f(e.nodes);p.length>0&&(s.geometries=p),m.length>0&&(s.materials=m),h.length>0&&(s.textures=h),y.length>0&&(s.images=y),S.length>0&&(s.shapes=S),_.length>0&&(s.skeletons=_),b.length>0&&(s.animations=b),T.length>0&&(s.nodes=T)}return s.object=l,s;function f(p){const m=[];for(const h in p){const y=p[h];delete y.metadata,m.push(y)}return m}}clone(e){return new this.constructor().copy(this,e)}copy(e,i=!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)),i===!0)for(let s=0;s<e.children.length;s++){const l=e.children[s];this.add(l.clone())}return this}}Ln.DEFAULT_UP=new ie(0,1,0);Ln.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ln.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class kc extends Ln{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Jb={type:"move"};class ih{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new kc,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 kc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ie,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ie),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new kc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ie,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ie,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 i=this._hand;if(i)for(const s of e.hand.values())this._getHandJoint(i,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,i,s){let l=null,c=null,f=null;const p=this._targetRay,m=this._grip,h=this._hand;if(e&&i.session.visibilityState!=="visible-blurred"){if(h&&e.hand){f=!0;for(const C of e.hand.values()){const v=i.getJointPose(C,s),x=this._getHandJoint(h,C);v!==null&&(x.matrix.fromArray(v.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=v.radius),x.visible=v!==null}const y=h.joints["index-finger-tip"],S=h.joints["thumb-tip"],_=y.position.distanceTo(S.position),b=.02,T=.005;h.inputState.pinching&&_>b+T?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&_<=b-T&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else m!==null&&e.gripSpace&&(c=i.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=i.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(Jb)))}return p!==null&&(p.visible=l!==null),m!==null&&(m.visible=c!==null),h!==null&&(h.visible=f!==null),this}_getHandJoint(e,i){if(e.joints[i.jointName]===void 0){const s=new kc;s.matrixAutoUpdate=!1,s.visible=!1,e.joints[i.jointName]=s,e.add(s)}return e.joints[i.jointName]}}const Vx={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},ms={h:0,s:0,l:0},jc={h:0,s:0,l:0};function ah(a,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?a+(e-a)*6*i:i<1/2?e:i<2/3?a+(e-a)*6*(2/3-i):a}class dt{constructor(e,i,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,i,s)}set(e,i,s){if(i===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,i,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,i=bi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,kt.colorSpaceToWorking(this,i),this}setRGB(e,i,s,l=kt.workingColorSpace){return this.r=e,this.g=i,this.b=s,kt.colorSpaceToWorking(this,l),this}setHSL(e,i,s,l=kt.workingColorSpace){if(e=zb(e,1),i=Pt(i,0,1),s=Pt(s,0,1),i===0)this.r=this.g=this.b=s;else{const c=s<=.5?s*(1+i):s+i-s*i,f=2*s-c;this.r=ah(f,c,e+1/3),this.g=ah(f,c,e),this.b=ah(f,c,e-1/3)}return kt.colorSpaceToWorking(this,l),this}setStyle(e,i=bi){function s(c){c!==void 0&&parseFloat(c)<1&&_t("Color: Alpha component of "+e+" will be ignored.")}let l;if(l=/^(\w+)\(([^\)]*)\)/.exec(e)){let c;const f=l[1],p=l[2];switch(f){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,i);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,i);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,i);break;default:_t("Color: Unknown color model "+e)}}else if(l=/^\#([A-Fa-f\d]+)$/.exec(e)){const c=l[1],f=c.length;if(f===3)return this.setRGB(parseInt(c.charAt(0),16)/15,parseInt(c.charAt(1),16)/15,parseInt(c.charAt(2),16)/15,i);if(f===6)return this.setHex(parseInt(c,16),i);_t("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,i);return this}setColorName(e,i=bi){const s=Vx[e.toLowerCase()];return s!==void 0?this.setHex(s,i):_t("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Fa(e.r),this.g=Fa(e.g),this.b=Fa(e.b),this}copyLinearToSRGB(e){return this.r=so(e.r),this.g=so(e.g),this.b=so(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=bi){return kt.workingToColorSpace(Kn.copy(this),e),Math.round(Pt(Kn.r*255,0,255))*65536+Math.round(Pt(Kn.g*255,0,255))*256+Math.round(Pt(Kn.b*255,0,255))}getHexString(e=bi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,i=kt.workingColorSpace){kt.workingToColorSpace(Kn.copy(this),i);const s=Kn.r,l=Kn.g,c=Kn.b,f=Math.max(s,l,c),p=Math.min(s,l,c);let m,h;const y=(p+f)/2;if(p===f)m=0,h=0;else{const S=f-p;switch(h=y<=.5?S/(f+p):S/(2-f-p),f){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=y,e}getRGB(e,i=kt.workingColorSpace){return kt.workingToColorSpace(Kn.copy(this),i),e.r=Kn.r,e.g=Kn.g,e.b=Kn.b,e}getStyle(e=bi){kt.workingToColorSpace(Kn.copy(this),e);const i=Kn.r,s=Kn.g,l=Kn.b;return e!==bi?`color(${e} ${i.toFixed(3)} ${s.toFixed(3)} ${l.toFixed(3)})`:`rgb(${Math.round(i*255)},${Math.round(s*255)},${Math.round(l*255)})`}offsetHSL(e,i,s){return this.getHSL(ms),this.setHSL(ms.h+e,ms.s+i,ms.l+s)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,i){return this.r=e.r+i.r,this.g=e.g+i.g,this.b=e.b+i.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,i){return this.r+=(e.r-this.r)*i,this.g+=(e.g-this.g)*i,this.b+=(e.b-this.b)*i,this}lerpColors(e,i,s){return this.r=e.r+(i.r-e.r)*s,this.g=e.g+(i.g-e.g)*s,this.b=e.b+(i.b-e.b)*s,this}lerpHSL(e,i){this.getHSL(ms),e.getHSL(jc);const s=$d(ms.h,jc.h,i),l=$d(ms.s,jc.s,i),c=$d(ms.l,jc.l,i);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 i=this.r,s=this.g,l=this.b,c=e.elements;return this.r=c[0]*i+c[3]*s+c[6]*l,this.g=c[1]*i+c[4]*s+c[7]*l,this.b=c[2]*i+c[5]*s+c[8]*l,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,i=0){return this.r=e[i],this.g=e[i+1],this.b=e[i+2],this}toArray(e=[],i=0){return e[i]=this.r,e[i+1]=this.g,e[i+2]=this.b,e}fromBufferAttribute(e,i){return this.r=e.getX(i),this.g=e.getY(i),this.b=e.getZ(i),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Kn=new dt;dt.NAMES=Vx;class eE extends Ln{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 As,this.environmentIntensity=1,this.environmentRotation=new As,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,i){return super.copy(e,i),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 i=super.toJSON(e);return this.fog!==null&&(i.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(i.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(i.object.backgroundIntensity=this.backgroundIntensity),i.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(i.object.environmentIntensity=this.environmentIntensity),i.object.environmentRotation=this.environmentRotation.toArray(),i}}const Xi=new ie,Ra=new ie,sh=new ie,Da=new ie,kr=new ie,jr=new ie,hv=new ie,rh=new ie,oh=new ie,lh=new ie,ch=new xn,uh=new xn,fh=new xn;class Bi{constructor(e=new ie,i=new ie,s=new ie){this.a=e,this.b=i,this.c=s}static getNormal(e,i,s,l){l.subVectors(s,i),Xi.subVectors(e,i),l.cross(Xi);const c=l.lengthSq();return c>0?l.multiplyScalar(1/Math.sqrt(c)):l.set(0,0,0)}static getBarycoord(e,i,s,l,c){Xi.subVectors(l,i),Ra.subVectors(s,i),sh.subVectors(e,i);const f=Xi.dot(Xi),p=Xi.dot(Ra),m=Xi.dot(sh),h=Ra.dot(Ra),y=Ra.dot(sh),S=f*h-p*p;if(S===0)return c.set(0,0,0),null;const _=1/S,b=(h*m-p*y)*_,T=(f*y-p*m)*_;return c.set(1-b-T,T,b)}static containsPoint(e,i,s,l){return this.getBarycoord(e,i,s,l,Da)===null?!1:Da.x>=0&&Da.y>=0&&Da.x+Da.y<=1}static getInterpolation(e,i,s,l,c,f,p,m){return this.getBarycoord(e,i,s,l,Da)===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,Da.x),m.addScaledVector(f,Da.y),m.addScaledVector(p,Da.z),m)}static getInterpolatedAttribute(e,i,s,l,c,f){return ch.setScalar(0),uh.setScalar(0),fh.setScalar(0),ch.fromBufferAttribute(e,i),uh.fromBufferAttribute(e,s),fh.fromBufferAttribute(e,l),f.setScalar(0),f.addScaledVector(ch,c.x),f.addScaledVector(uh,c.y),f.addScaledVector(fh,c.z),f}static isFrontFacing(e,i,s,l){return Xi.subVectors(s,i),Ra.subVectors(e,i),Xi.cross(Ra).dot(l)<0}set(e,i,s){return this.a.copy(e),this.b.copy(i),this.c.copy(s),this}setFromPointsAndIndices(e,i,s,l){return this.a.copy(e[i]),this.b.copy(e[s]),this.c.copy(e[l]),this}setFromAttributeAndIndices(e,i,s,l){return this.a.fromBufferAttribute(e,i),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 Xi.subVectors(this.c,this.b),Ra.subVectors(this.a,this.b),Xi.cross(Ra).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Bi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,i){return Bi.getBarycoord(e,this.a,this.b,this.c,i)}getInterpolation(e,i,s,l,c){return Bi.getInterpolation(e,this.a,this.b,this.c,i,s,l,c)}containsPoint(e){return Bi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Bi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,i){const s=this.a,l=this.b,c=this.c;let f,p;kr.subVectors(l,s),jr.subVectors(c,s),rh.subVectors(e,s);const m=kr.dot(rh),h=jr.dot(rh);if(m<=0&&h<=0)return i.copy(s);oh.subVectors(e,l);const y=kr.dot(oh),S=jr.dot(oh);if(y>=0&&S<=y)return i.copy(l);const _=m*S-y*h;if(_<=0&&m>=0&&y<=0)return f=m/(m-y),i.copy(s).addScaledVector(kr,f);lh.subVectors(e,c);const b=kr.dot(lh),T=jr.dot(lh);if(T>=0&&b<=T)return i.copy(c);const C=b*h-m*T;if(C<=0&&h>=0&&T<=0)return p=h/(h-T),i.copy(s).addScaledVector(jr,p);const v=y*T-b*S;if(v<=0&&S-y>=0&&b-T>=0)return hv.subVectors(c,l),p=(S-y)/(S-y+(b-T)),i.copy(l).addScaledVector(hv,p);const x=1/(v+C+_);return f=C*x,p=_*x,i.copy(s).addScaledVector(kr,f).addScaledVector(jr,p)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class sr{constructor(e=new ie(1/0,1/0,1/0),i=new ie(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=i}set(e,i){return this.min.copy(e),this.max.copy(i),this}setFromArray(e){this.makeEmpty();for(let i=0,s=e.length;i<s;i+=3)this.expandByPoint(Wi.fromArray(e,i));return this}setFromBufferAttribute(e){this.makeEmpty();for(let i=0,s=e.count;i<s;i++)this.expandByPoint(Wi.fromBufferAttribute(e,i));return this}setFromPoints(e){this.makeEmpty();for(let i=0,s=e.length;i<s;i++)this.expandByPoint(e[i]);return this}setFromCenterAndSize(e,i){const s=Wi.copy(i).multiplyScalar(.5);return this.min.copy(e).sub(s),this.max.copy(e).add(s),this}setFromObject(e,i=!1){return this.makeEmpty(),this.expandByObject(e,i)}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,i=!1){e.updateWorldMatrix(!1,!1);const s=e.geometry;if(s!==void 0){const c=s.getAttribute("position");if(i===!0&&c!==void 0&&e.isInstancedMesh!==!0)for(let f=0,p=c.count;f<p;f++)e.isMesh===!0?e.getVertexPosition(f,Wi):Wi.fromBufferAttribute(c,f),Wi.applyMatrix4(e.matrixWorld),this.expandByPoint(Wi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Xc.copy(e.boundingBox)):(s.boundingBox===null&&s.computeBoundingBox(),Xc.copy(s.boundingBox)),Xc.applyMatrix4(e.matrixWorld),this.union(Xc)}const l=e.children;for(let c=0,f=l.length;c<f;c++)this.expandByObject(l[c],i);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,i){return i.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,Wi),Wi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let i,s;return e.normal.x>0?(i=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(i=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(i+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(i+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(i+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(i+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),i<=-e.constant&&s>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ul),Wc.subVectors(this.max,ul),Xr.subVectors(e.a,ul),Wr.subVectors(e.b,ul),qr.subVectors(e.c,ul),gs.subVectors(Wr,Xr),_s.subVectors(qr,Wr),Ws.subVectors(Xr,qr);let i=[0,-gs.z,gs.y,0,-_s.z,_s.y,0,-Ws.z,Ws.y,gs.z,0,-gs.x,_s.z,0,-_s.x,Ws.z,0,-Ws.x,-gs.y,gs.x,0,-_s.y,_s.x,0,-Ws.y,Ws.x,0];return!dh(i,Xr,Wr,qr,Wc)||(i=[1,0,0,0,1,0,0,0,1],!dh(i,Xr,Wr,qr,Wc))?!1:(qc.crossVectors(gs,_s),i=[qc.x,qc.y,qc.z],dh(i,Xr,Wr,qr,Wc))}clampPoint(e,i){return i.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Wi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Wi).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:(Na[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Na[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Na[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Na[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Na[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Na[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Na[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Na[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Na),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 Na=[new ie,new ie,new ie,new ie,new ie,new ie,new ie,new ie],Wi=new ie,Xc=new sr,Xr=new ie,Wr=new ie,qr=new ie,gs=new ie,_s=new ie,Ws=new ie,ul=new ie,Wc=new ie,qc=new ie,qs=new ie;function dh(a,e,i,s,l){for(let c=0,f=a.length-3;c<=f;c+=3){qs.fromArray(a,c);const p=l.x*Math.abs(qs.x)+l.y*Math.abs(qs.y)+l.z*Math.abs(qs.z),m=e.dot(qs),h=i.dot(qs),y=s.dot(qs);if(Math.max(-Math.max(m,h,y),Math.min(m,h,y))>p)return!1}return!0}const Rn=new ie,Yc=new bt;let tE=0;class Zi extends ws{constructor(e,i,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:tE++}),this.name="",this.array=e,this.itemSize=i,this.count=e!==void 0?e.length/i:0,this.normalized=s,this.usage=J_,this.updateRanges=[],this.gpuType=qi,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,i){this.updateRanges.push({start:e,count:i})}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,i,s){e*=this.itemSize,s*=i.itemSize;for(let l=0,c=this.itemSize;l<c;l++)this.array[e+l]=i.array[s+l];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let i=0,s=this.count;i<s;i++)Yc.fromBufferAttribute(this,i),Yc.applyMatrix3(e),this.setXY(i,Yc.x,Yc.y);else if(this.itemSize===3)for(let i=0,s=this.count;i<s;i++)Rn.fromBufferAttribute(this,i),Rn.applyMatrix3(e),this.setXYZ(i,Rn.x,Rn.y,Rn.z);return this}applyMatrix4(e){for(let i=0,s=this.count;i<s;i++)Rn.fromBufferAttribute(this,i),Rn.applyMatrix4(e),this.setXYZ(i,Rn.x,Rn.y,Rn.z);return this}applyNormalMatrix(e){for(let i=0,s=this.count;i<s;i++)Rn.fromBufferAttribute(this,i),Rn.applyNormalMatrix(e),this.setXYZ(i,Rn.x,Rn.y,Rn.z);return this}transformDirection(e){for(let i=0,s=this.count;i<s;i++)Rn.fromBufferAttribute(this,i),Rn.transformDirection(e),this.setXYZ(i,Rn.x,Rn.y,Rn.z);return this}set(e,i=0){return this.array.set(e,i),this}getComponent(e,i){let s=this.array[e*this.itemSize+i];return this.normalized&&(s=ll(s,this.array)),s}setComponent(e,i,s){return this.normalized&&(s=oi(s,this.array)),this.array[e*this.itemSize+i]=s,this}getX(e){let i=this.array[e*this.itemSize];return this.normalized&&(i=ll(i,this.array)),i}setX(e,i){return this.normalized&&(i=oi(i,this.array)),this.array[e*this.itemSize]=i,this}getY(e){let i=this.array[e*this.itemSize+1];return this.normalized&&(i=ll(i,this.array)),i}setY(e,i){return this.normalized&&(i=oi(i,this.array)),this.array[e*this.itemSize+1]=i,this}getZ(e){let i=this.array[e*this.itemSize+2];return this.normalized&&(i=ll(i,this.array)),i}setZ(e,i){return this.normalized&&(i=oi(i,this.array)),this.array[e*this.itemSize+2]=i,this}getW(e){let i=this.array[e*this.itemSize+3];return this.normalized&&(i=ll(i,this.array)),i}setW(e,i){return this.normalized&&(i=oi(i,this.array)),this.array[e*this.itemSize+3]=i,this}setXY(e,i,s){return e*=this.itemSize,this.normalized&&(i=oi(i,this.array),s=oi(s,this.array)),this.array[e+0]=i,this.array[e+1]=s,this}setXYZ(e,i,s,l){return e*=this.itemSize,this.normalized&&(i=oi(i,this.array),s=oi(s,this.array),l=oi(l,this.array)),this.array[e+0]=i,this.array[e+1]=s,this.array[e+2]=l,this}setXYZW(e,i,s,l,c){return e*=this.itemSize,this.normalized&&(i=oi(i,this.array),s=oi(s,this.array),l=oi(l,this.array),c=oi(c,this.array)),this.array[e+0]=i,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!==J_&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class kx extends Zi{constructor(e,i,s){super(new Uint16Array(e),i,s)}}class jx extends Zi{constructor(e,i,s){super(new Uint32Array(e),i,s)}}class fi extends Zi{constructor(e,i,s){super(new Float32Array(e),i,s)}}const nE=new sr,fl=new ie,hh=new ie;class go{constructor(e=new ie,i=-1){this.isSphere=!0,this.center=e,this.radius=i}set(e,i){return this.center.copy(e),this.radius=i,this}setFromPoints(e,i){const s=this.center;i!==void 0?s.copy(i):nE.setFromPoints(e).getCenter(s);let l=0;for(let c=0,f=e.length;c<f;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 i=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=i*i}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,i){const s=this.center.distanceToSquared(e);return i.copy(e),s>this.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i}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;fl.subVectors(e,this.center);const i=fl.lengthSq();if(i>this.radius*this.radius){const s=Math.sqrt(i),l=(s-this.radius)*.5;this.center.addScaledVector(fl,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):(hh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(fl.copy(e.center).add(hh)),this.expandByPoint(fl.copy(e.center).sub(hh))),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 iE=0;const Oi=new dn,ph=new Ln,Yr=new ie,Mi=new sr,dl=new sr,zn=new ie;class Fi extends ws{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:iE++}),this.uuid=Dl(),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(Pb(e)?jx:kx)(e,1):this.index=e,this}setIndirect(e,i=0){return this.indirect=e,this.indirectOffset=i,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,i){return this.attributes[e]=i,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,i,s=0){this.groups.push({start:e,count:i,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(e,i){this.drawRange.start=e,this.drawRange.count=i}applyMatrix4(e){const i=this.attributes.position;i!==void 0&&(i.applyMatrix4(e),i.needsUpdate=!0);const s=this.attributes.normal;if(s!==void 0){const c=new At().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 Oi.makeRotationFromQuaternion(e),this.applyMatrix4(Oi),this}rotateX(e){return Oi.makeRotationX(e),this.applyMatrix4(Oi),this}rotateY(e){return Oi.makeRotationY(e),this.applyMatrix4(Oi),this}rotateZ(e){return Oi.makeRotationZ(e),this.applyMatrix4(Oi),this}translate(e,i,s){return Oi.makeTranslation(e,i,s),this.applyMatrix4(Oi),this}scale(e,i,s){return Oi.makeScale(e,i,s),this.applyMatrix4(Oi),this}lookAt(e){return ph.lookAt(e),ph.updateMatrix(),this.applyMatrix4(ph.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Yr).negate(),this.translate(Yr.x,Yr.y,Yr.z),this}setFromPoints(e){const i=this.getAttribute("position");if(i===void 0){const s=[];for(let l=0,c=e.length;l<c;l++){const f=e[l];s.push(f.x,f.y,f.z||0)}this.setAttribute("position",new fi(s,3))}else{const s=Math.min(e.length,i.count);for(let l=0;l<s;l++){const c=e[l];i.setXYZ(l,c.x,c.y,c.z||0)}e.length>i.count&&_t("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),i.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new sr);const e=this.attributes.position,i=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){jt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ie(-1/0,-1/0,-1/0),new ie(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),i)for(let s=0,l=i.length;s<l;s++){const c=i[s];Mi.setFromBufferAttribute(c),this.morphTargetsRelative?(zn.addVectors(this.boundingBox.min,Mi.min),this.boundingBox.expandByPoint(zn),zn.addVectors(this.boundingBox.max,Mi.max),this.boundingBox.expandByPoint(zn)):(this.boundingBox.expandByPoint(Mi.min),this.boundingBox.expandByPoint(Mi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&jt('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 go);const e=this.attributes.position,i=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){jt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ie,1/0);return}if(e){const s=this.boundingSphere.center;if(Mi.setFromBufferAttribute(e),i)for(let c=0,f=i.length;c<f;c++){const p=i[c];dl.setFromBufferAttribute(p),this.morphTargetsRelative?(zn.addVectors(Mi.min,dl.min),Mi.expandByPoint(zn),zn.addVectors(Mi.max,dl.max),Mi.expandByPoint(zn)):(Mi.expandByPoint(dl.min),Mi.expandByPoint(dl.max))}Mi.getCenter(s);let l=0;for(let c=0,f=e.count;c<f;c++)zn.fromBufferAttribute(e,c),l=Math.max(l,s.distanceToSquared(zn));if(i)for(let c=0,f=i.length;c<f;c++){const p=i[c],m=this.morphTargetsRelative;for(let h=0,y=p.count;h<y;h++)zn.fromBufferAttribute(p,h),m&&(Yr.fromBufferAttribute(e,h),zn.add(Yr)),l=Math.max(l,s.distanceToSquared(zn))}this.boundingSphere.radius=Math.sqrt(l),isNaN(this.boundingSphere.radius)&&jt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,i=this.attributes;if(e===null||i.position===void 0||i.normal===void 0||i.uv===void 0){jt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const s=i.position,l=i.normal,c=i.uv;let f=this.getAttribute("tangent");(f===void 0||f.count!==s.count)&&(f=new Zi(new Float32Array(4*s.count),4),this.setAttribute("tangent",f));const p=[],m=[];for(let A=0;A<s.count;A++)p[A]=new ie,m[A]=new ie;const h=new ie,y=new ie,S=new ie,_=new bt,b=new bt,T=new bt,C=new ie,v=new ie;function x(A,L,j){h.fromBufferAttribute(s,A),y.fromBufferAttribute(s,L),S.fromBufferAttribute(s,j),_.fromBufferAttribute(c,A),b.fromBufferAttribute(c,L),T.fromBufferAttribute(c,j),y.sub(h),S.sub(h),b.sub(_),T.sub(_);const V=1/(b.x*T.y-T.x*b.y);isFinite(V)&&(C.copy(y).multiplyScalar(T.y).addScaledVector(S,-b.y).multiplyScalar(V),v.copy(S).multiplyScalar(b.x).addScaledVector(y,-T.x).multiplyScalar(V),p[A].add(C),p[L].add(C),p[j].add(C),m[A].add(v),m[L].add(v),m[j].add(v))}let B=this.groups;B.length===0&&(B=[{start:0,count:e.count}]);for(let A=0,L=B.length;A<L;++A){const j=B[A],V=j.start,$=j.count;for(let pe=V,ge=V+$;pe<ge;pe+=3)x(e.getX(pe+0),e.getX(pe+1),e.getX(pe+2))}const P=new ie,D=new ie,O=new ie,U=new ie;function N(A){O.fromBufferAttribute(l,A),U.copy(O);const L=p[A];P.copy(L),P.sub(O.multiplyScalar(O.dot(L))).normalize(),D.crossVectors(U,L);const V=D.dot(m[A])<0?-1:1;f.setXYZW(A,P.x,P.y,P.z,V)}for(let A=0,L=B.length;A<L;++A){const j=B[A],V=j.start,$=j.count;for(let pe=V,ge=V+$;pe<ge;pe+=3)N(e.getX(pe+0)),N(e.getX(pe+1)),N(e.getX(pe+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,i=this.getAttribute("position");if(i!==void 0){let s=this.getAttribute("normal");if(s===void 0||s.count!==i.count)s=new Zi(new Float32Array(i.count*3),3),this.setAttribute("normal",s);else for(let _=0,b=s.count;_<b;_++)s.setXYZ(_,0,0,0);const l=new ie,c=new ie,f=new ie,p=new ie,m=new ie,h=new ie,y=new ie,S=new ie;if(e)for(let _=0,b=e.count;_<b;_+=3){const T=e.getX(_+0),C=e.getX(_+1),v=e.getX(_+2);l.fromBufferAttribute(i,T),c.fromBufferAttribute(i,C),f.fromBufferAttribute(i,v),y.subVectors(f,c),S.subVectors(l,c),y.cross(S),p.fromBufferAttribute(s,T),m.fromBufferAttribute(s,C),h.fromBufferAttribute(s,v),p.add(y),m.add(y),h.add(y),s.setXYZ(T,p.x,p.y,p.z),s.setXYZ(C,m.x,m.y,m.z),s.setXYZ(v,h.x,h.y,h.z)}else for(let _=0,b=i.count;_<b;_+=3)l.fromBufferAttribute(i,_+0),c.fromBufferAttribute(i,_+1),f.fromBufferAttribute(i,_+2),y.subVectors(f,c),S.subVectors(l,c),y.cross(S),s.setXYZ(_+0,y.x,y.y,y.z),s.setXYZ(_+1,y.x,y.y,y.z),s.setXYZ(_+2,y.x,y.y,y.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let i=0,s=e.count;i<s;i++)zn.fromBufferAttribute(e,i),zn.normalize(),e.setXYZ(i,zn.x,zn.y,zn.z)}toNonIndexed(){function e(p,m){const h=p.array,y=p.itemSize,S=p.normalized,_=new h.constructor(m.length*y);let b=0,T=0;for(let C=0,v=m.length;C<v;C++){p.isInterleavedBufferAttribute?b=m[C]*p.data.stride+p.offset:b=m[C]*y;for(let x=0;x<y;x++)_[T++]=h[b++]}return new Zi(_,y,S)}if(this.index===null)return _t("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const i=new Fi,s=this.index.array,l=this.attributes;for(const p in l){const m=l[p],h=e(m,s);i.setAttribute(p,h)}const c=this.morphAttributes;for(const p in c){const m=[],h=c[p];for(let y=0,S=h.length;y<S;y++){const _=h[y],b=e(_,s);m.push(b)}i.morphAttributes[p]=m}i.morphTargetsRelative=this.morphTargetsRelative;const f=this.groups;for(let p=0,m=f.length;p<m;p++){const h=f[p];i.addGroup(h.start,h.count,h.materialIndex)}return i}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 i=this.index;i!==null&&(e.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.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],y=[];for(let S=0,_=h.length;S<_;S++){const b=h[S];y.push(b.toJSON(e.data))}y.length>0&&(l[m]=y,c=!0)}c&&(e.data.morphAttributes=l,e.data.morphTargetsRelative=this.morphTargetsRelative);const f=this.groups;f.length>0&&(e.data.groups=JSON.parse(JSON.stringify(f)));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 i={};this.name=e.name;const s=e.index;s!==null&&this.setIndex(s.clone());const l=e.attributes;for(const h in l){const y=l[h];this.setAttribute(h,y.clone(i))}const c=e.morphAttributes;for(const h in c){const y=[],S=c[h];for(let _=0,b=S.length;_<b;_++)y.push(S[_].clone(i));this.morphAttributes[h]=y}this.morphTargetsRelative=e.morphTargetsRelative;const f=e.groups;for(let h=0,y=f.length;h<y;h++){const S=f[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 aE=0;class _o extends ws{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:aE++}),this.uuid=Dl(),this.name="",this.type="Material",this.blending=io,this.side=Es,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Lh,this.blendDst=Oh,this.blendEquation=Ks,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new dt(0,0,0),this.blendAlpha=0,this.depthFunc=co,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Q_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Fr,this.stencilZFail=Fr,this.stencilZPass=Fr,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 i in e){const s=e[i];if(s===void 0){_t(`Material: parameter '${i}' has value of undefined.`);continue}const l=this[i];if(l===void 0){_t(`Material: '${i}' 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[i]=s}}toJSON(e){const i=e===void 0||typeof e=="string";i&&(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!==io&&(s.blending=this.blending),this.side!==Es&&(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!==Lh&&(s.blendSrc=this.blendSrc),this.blendDst!==Oh&&(s.blendDst=this.blendDst),this.blendEquation!==Ks&&(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!==co&&(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!==Q_&&(s.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(s.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Fr&&(s.stencilFail=this.stencilFail),this.stencilZFail!==Fr&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==Fr&&(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 f=[];for(const p in c){const m=c[p];delete m.metadata,f.push(m)}return f}if(i){const c=l(e.textures),f=l(e.images);c.length>0&&(s.textures=c),f.length>0&&(s.images=f)}return s}fromJSON(e,i){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 dt().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=i[e.map]||null),e.matcap!==void 0&&(this.matcap=i[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=i[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=i[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=i[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=i[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=i[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=i[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=i[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=i[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=i[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=i[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=i[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=i[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=i[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=i[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=i[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=i[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=i[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new bt().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=i[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=i[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=i[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=i[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=i[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=i[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=i[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 i=e.clippingPlanes;let s=null;if(i!==null){const l=i.length;s=new Array(l);for(let c=0;c!==l;++c)s[c]=i[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 Ua=new ie,mh=new ie,Zc=new ie,vs=new ie,gh=new ie,Kc=new ie,_h=new ie;class kp{constructor(e=new ie,i=new ie(0,0,-1)){this.origin=e,this.direction=i}set(e,i){return this.origin.copy(e),this.direction.copy(i),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,i){return i.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,Ua)),this}closestPointToPoint(e,i){i.subVectors(e,this.origin);const s=i.dot(this.direction);return s<0?i.copy(this.origin):i.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const i=Ua.subVectors(e,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(e):(Ua.copy(this.origin).addScaledVector(this.direction,i),Ua.distanceToSquared(e))}distanceSqToSegment(e,i,s,l){mh.copy(e).add(i).multiplyScalar(.5),Zc.copy(i).sub(e).normalize(),vs.copy(this.origin).sub(mh);const c=e.distanceTo(i)*.5,f=-this.direction.dot(Zc),p=vs.dot(this.direction),m=-vs.dot(Zc),h=vs.lengthSq(),y=Math.abs(1-f*f);let S,_,b,T;if(y>0)if(S=f*m-p,_=f*p-m,T=c*y,S>=0)if(_>=-T)if(_<=T){const C=1/y;S*=C,_*=C,b=S*(S+f*_+2*p)+_*(f*S+_+2*m)+h}else _=c,S=Math.max(0,-(f*_+p)),b=-S*S+_*(_+2*m)+h;else _=-c,S=Math.max(0,-(f*_+p)),b=-S*S+_*(_+2*m)+h;else _<=-T?(S=Math.max(0,-(-f*c+p)),_=S>0?-c:Math.min(Math.max(-c,-m),c),b=-S*S+_*(_+2*m)+h):_<=T?(S=0,_=Math.min(Math.max(-c,-m),c),b=_*(_+2*m)+h):(S=Math.max(0,-(f*c+p)),_=S>0?c:Math.min(Math.max(-c,-m),c),b=-S*S+_*(_+2*m)+h);else _=f>0?-c:c,S=Math.max(0,-(f*_+p)),b=-S*S+_*(_+2*m)+h;return s&&s.copy(this.origin).addScaledVector(this.direction,S),l&&l.copy(mh).addScaledVector(Zc,_),b}intersectSphere(e,i){Ua.subVectors(e.center,this.origin);const s=Ua.dot(this.direction),l=Ua.dot(Ua)-s*s,c=e.radius*e.radius;if(l>c)return null;const f=Math.sqrt(c-l),p=s-f,m=s+f;return m<0?null:p<0?this.at(m,i):this.at(p,i)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const i=e.normal.dot(this.direction);if(i===0)return e.distanceToPoint(this.origin)===0?0:null;const s=-(this.origin.dot(e.normal)+e.constant)/i;return s>=0?s:null}intersectPlane(e,i){const s=this.distanceToPlane(e);return s===null?null:this.at(s,i)}intersectsPlane(e){const i=e.distanceToPoint(this.origin);return i===0||e.normal.dot(this.direction)*i<0}intersectBox(e,i){let s,l,c,f,p,m;const h=1/this.direction.x,y=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),y>=0?(c=(e.min.y-_.y)*y,f=(e.max.y-_.y)*y):(c=(e.max.y-_.y)*y,f=(e.min.y-_.y)*y),s>f||c>l||((c>s||isNaN(s))&&(s=c),(f<l||isNaN(l))&&(l=f),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,i)}intersectsBox(e){return this.intersectBox(e,Ua)!==null}intersectTriangle(e,i,s,l,c){gh.subVectors(i,e),Kc.subVectors(s,e),_h.crossVectors(gh,Kc);let f=this.direction.dot(_h),p;if(f>0){if(l)return null;p=1}else if(f<0)p=-1,f=-f;else return null;vs.subVectors(this.origin,e);const m=p*this.direction.dot(Kc.crossVectors(vs,Kc));if(m<0)return null;const h=p*this.direction.dot(gh.cross(vs));if(h<0||m+h>f)return null;const y=-p*vs.dot(_h);return y<0?null:this.at(y/f,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 Xx extends _o{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new dt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new As,this.combine=Tx,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 dn,Ys=new kp,$c=new go,mv=new ie,Qc=new ie,Jc=new ie,eu=new ie,vh=new ie,tu=new ie,gv=new ie,nu=new ie;class Ki extends Ln{constructor(e=new Fi,i=new Xx){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=i,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,i){return super.copy(e,i),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 i=this.geometry.morphAttributes,s=Object.keys(i);if(s.length>0){const l=i[s[0]];if(l!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let c=0,f=l.length;c<f;c++){const p=l[c].name||String(c);this.morphTargetInfluences.push(0),this.morphTargetDictionary[p]=c}}}}getVertexPosition(e,i){const s=this.geometry,l=s.attributes.position,c=s.morphAttributes.position,f=s.morphTargetsRelative;i.fromBufferAttribute(l,e);const p=this.morphTargetInfluences;if(c&&p){tu.set(0,0,0);for(let m=0,h=c.length;m<h;m++){const y=p[m],S=c[m];y!==0&&(vh.fromBufferAttribute(S,e),f?tu.addScaledVector(vh,y):tu.addScaledVector(vh.sub(i),y))}i.add(tu)}return i}raycast(e,i){const s=this.geometry,l=this.material,c=this.matrixWorld;l!==void 0&&(s.boundingSphere===null&&s.computeBoundingSphere(),$c.copy(s.boundingSphere),$c.applyMatrix4(c),Ys.copy(e.ray).recast(e.near),!($c.containsPoint(Ys.origin)===!1&&(Ys.intersectSphere($c,mv)===null||Ys.origin.distanceToSquared(mv)>(e.far-e.near)**2))&&(pv.copy(c).invert(),Ys.copy(e.ray).applyMatrix4(pv),!(s.boundingBox!==null&&Ys.intersectsBox(s.boundingBox)===!1)&&this._computeIntersections(e,i,Ys)))}_computeIntersections(e,i,s){let l;const c=this.geometry,f=this.material,p=c.index,m=c.attributes.position,h=c.attributes.uv,y=c.attributes.uv1,S=c.attributes.normal,_=c.groups,b=c.drawRange;if(p!==null)if(Array.isArray(f))for(let T=0,C=_.length;T<C;T++){const v=_[T],x=f[v.materialIndex],B=Math.max(v.start,b.start),P=Math.min(p.count,Math.min(v.start+v.count,b.start+b.count));for(let D=B,O=P;D<O;D+=3){const U=p.getX(D),N=p.getX(D+1),A=p.getX(D+2);l=iu(this,x,e,s,h,y,S,U,N,A),l&&(l.faceIndex=Math.floor(D/3),l.face.materialIndex=v.materialIndex,i.push(l))}}else{const T=Math.max(0,b.start),C=Math.min(p.count,b.start+b.count);for(let v=T,x=C;v<x;v+=3){const B=p.getX(v),P=p.getX(v+1),D=p.getX(v+2);l=iu(this,f,e,s,h,y,S,B,P,D),l&&(l.faceIndex=Math.floor(v/3),i.push(l))}}else if(m!==void 0)if(Array.isArray(f))for(let T=0,C=_.length;T<C;T++){const v=_[T],x=f[v.materialIndex],B=Math.max(v.start,b.start),P=Math.min(m.count,Math.min(v.start+v.count,b.start+b.count));for(let D=B,O=P;D<O;D+=3){const U=D,N=D+1,A=D+2;l=iu(this,x,e,s,h,y,S,U,N,A),l&&(l.faceIndex=Math.floor(D/3),l.face.materialIndex=v.materialIndex,i.push(l))}}else{const T=Math.max(0,b.start),C=Math.min(m.count,b.start+b.count);for(let v=T,x=C;v<x;v+=3){const B=v,P=v+1,D=v+2;l=iu(this,f,e,s,h,y,S,B,P,D),l&&(l.faceIndex=Math.floor(v/3),i.push(l))}}}}function sE(a,e,i,s,l,c,f,p){let m;if(e.side===ui?m=s.intersectTriangle(f,c,l,!0,p):m=s.intersectTriangle(l,c,f,e.side===Es,p),m===null)return null;nu.copy(p),nu.applyMatrix4(a.matrixWorld);const h=i.ray.origin.distanceTo(nu);return h<i.near||h>i.far?null:{distance:h,point:nu.clone(),object:a}}function iu(a,e,i,s,l,c,f,p,m,h){a.getVertexPosition(p,Qc),a.getVertexPosition(m,Jc),a.getVertexPosition(h,eu);const y=sE(a,e,i,s,Qc,Jc,eu,gv);if(y){const S=new ie;Bi.getBarycoord(gv,Qc,Jc,eu,S),l&&(y.uv=Bi.getInterpolatedAttribute(l,p,m,h,S,new bt)),c&&(y.uv1=Bi.getInterpolatedAttribute(c,p,m,h,S,new bt)),f&&(y.normal=Bi.getInterpolatedAttribute(f,p,m,h,S,new ie),y.normal.dot(s.direction)>0&&y.normal.multiplyScalar(-1));const _={a:p,b:m,c:h,normal:new ie,materialIndex:0};Bi.getNormal(Qc,Jc,eu,_.normal),y.face=_,y.barycoord=S}return y}class Wx extends ei{constructor(e=null,i=1,s=1,l,c,f,p,m,h=Wn,y=Wn,S,_){super(null,f,p,m,h,y,l,c,S,_),this.isDataTexture=!0,this.image={data:e,width:i,height:s},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class _v extends Zi{constructor(e,i,s,l=1){super(e,i,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 Zr=new dn,vv=new dn,au=[],xv=new sr,rE=new dn,hl=new Ki,pl=new go;class oE extends Ki{constructor(e,i,s){super(e,i),this.isInstancedMesh=!0,this.instanceMatrix=new _v(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,rE)}computeBoundingBox(){const e=this.geometry,i=this.count;this.boundingBox===null&&(this.boundingBox=new sr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let s=0;s<i;s++)this.getMatrixAt(s,Zr),xv.copy(e.boundingBox).applyMatrix4(Zr),this.boundingBox.union(xv)}computeBoundingSphere(){const e=this.geometry,i=this.count;this.boundingSphere===null&&(this.boundingSphere=new go),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let s=0;s<i;s++)this.getMatrixAt(s,Zr),pl.copy(e.boundingSphere).applyMatrix4(Zr),this.boundingSphere.union(pl)}copy(e,i){return super.copy(e,i),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,i){return this.instanceColor===null?i.setRGB(1,1,1):i.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,i){return i.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,i){const s=i.morphTargetInfluences,l=this.morphTexture.source.data.data,c=s.length+1,f=e*c+1;for(let p=0;p<s.length;p++)s[p]=l[f+p]}raycast(e,i){const s=this.matrixWorld,l=this.count;if(hl.geometry=this.geometry,hl.material=this.material,hl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),pl.copy(this.boundingSphere),pl.applyMatrix4(s),e.ray.intersectsSphere(pl)!==!1))for(let c=0;c<l;c++){this.getMatrixAt(c,Zr),vv.multiplyMatrices(s,Zr),hl.matrixWorld=vv,hl.raycast(e,au);for(let f=0,p=au.length;f<p;f++){const m=au[f];m.instanceId=c,m.object=this,i.push(m)}au.length=0}}setColorAt(e,i){return this.instanceColor===null&&(this.instanceColor=new _v(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),i.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,i){return i.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,i){const s=i.morphTargetInfluences,l=s.length+1;this.morphTexture===null&&(this.morphTexture=new Wx(new Float32Array(l*this.count),l,this.count,Ip,qi));const c=this.morphTexture.source.data.data;let f=0;for(let h=0;h<s.length;h++)f+=s[h];const p=this.geometry.morphTargetsRelative?1:1-f,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 xh=new ie,lE=new ie,cE=new At;class ys{constructor(e=new ie(1,0,0),i=0){this.isPlane=!0,this.normal=e,this.constant=i}set(e,i){return this.normal.copy(e),this.constant=i,this}setComponents(e,i,s,l){return this.normal.set(e,i,s),this.constant=l,this}setFromNormalAndCoplanarPoint(e,i){return this.normal.copy(e),this.constant=-i.dot(this.normal),this}setFromCoplanarPoints(e,i,s){const l=xh.subVectors(s,i).cross(lE.subVectors(e,i)).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,i){return i.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,i,s=!0){const l=e.delta(xh),c=this.normal.dot(l);if(c===0)return this.distanceToPoint(e.start)===0?i.copy(e.start):null;const f=-(e.start.dot(this.normal)+this.constant)/c;return s===!0&&(f<0||f>1)?null:i.copy(e.start).addScaledVector(l,f)}intersectsLine(e){const i=this.distanceToPoint(e.start),s=this.distanceToPoint(e.end);return i<0&&s>0||s<0&&i>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,i){const s=i||cE.getNormalMatrix(e),l=this.coplanarPoint(xh).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 Zs=new go,uE=new bt(.5,.5),su=new ie;class jp{constructor(e=new ys,i=new ys,s=new ys,l=new ys,c=new ys,f=new ys){this.planes=[e,i,s,l,c,f]}set(e,i,s,l,c,f){const p=this.planes;return p[0].copy(e),p[1].copy(i),p[2].copy(s),p[3].copy(l),p[4].copy(c),p[5].copy(f),this}copy(e){const i=this.planes;for(let s=0;s<6;s++)i[s].copy(e.planes[s]);return this}setFromProjectionMatrix(e,i=sa,s=!1){const l=this.planes,c=e.elements,f=c[0],p=c[1],m=c[2],h=c[3],y=c[4],S=c[5],_=c[6],b=c[7],T=c[8],C=c[9],v=c[10],x=c[11],B=c[12],P=c[13],D=c[14],O=c[15];if(l[0].setComponents(h-f,b-y,x-T,O-B).normalize(),l[1].setComponents(h+f,b+y,x+T,O+B).normalize(),l[2].setComponents(h+p,b+S,x+C,O+P).normalize(),l[3].setComponents(h-p,b-S,x-C,O-P).normalize(),s)l[4].setComponents(m,_,v,D).normalize(),l[5].setComponents(h-m,b-_,x-v,O-D).normalize();else if(l[4].setComponents(h-m,b-_,x-v,O-D).normalize(),i===sa)l[5].setComponents(h+m,b+_,x+v,O+D).normalize();else if(i===Cl)l[5].setComponents(m,_,v,D).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+i);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Zs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const i=e.geometry;i.boundingSphere===null&&i.computeBoundingSphere(),Zs.copy(i.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Zs)}intersectsSprite(e){Zs.center.set(0,0,0);const i=uE.distanceTo(e.center);return Zs.radius=.7071067811865476+i,Zs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zs)}intersectsSphere(e){const i=this.planes,s=e.center,l=-e.radius;for(let c=0;c<6;c++)if(i[c].distanceToPoint(s)<l)return!1;return!0}intersectsBox(e){const i=this.planes;for(let s=0;s<6;s++){const l=i[s];if(su.x=l.normal.x>0?e.max.x:e.min.x,su.y=l.normal.y>0?e.max.y:e.min.y,su.z=l.normal.z>0?e.max.z:e.min.z,l.distanceToPoint(su)<0)return!1}return!0}containsPoint(e){const i=this.planes;for(let s=0;s<6;s++)if(i[s].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Xp extends _o{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new dt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const wu=new ie,Ru=new ie,yv=new dn,ml=new kp,ru=new go,yh=new ie,Sv=new ie;class fE extends Ln{constructor(e=new Fi,i=new Xp){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=i,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,i){return super.copy(e,i),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 i=e.attributes.position,s=[0];for(let l=1,c=i.count;l<c;l++)wu.fromBufferAttribute(i,l-1),Ru.fromBufferAttribute(i,l),s[l]=s[l-1],s[l]+=wu.distanceTo(Ru);e.setAttribute("lineDistance",new fi(s,1))}else _t("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,i){const s=this.geometry,l=this.matrixWorld,c=e.params.Line.threshold,f=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),ru.copy(s.boundingSphere),ru.applyMatrix4(l),ru.radius+=c,e.ray.intersectsSphere(ru)===!1)return;yv.copy(l).invert(),ml.copy(e.ray).applyMatrix4(yv);const p=c/((this.scale.x+this.scale.y+this.scale.z)/3),m=p*p,h=this.isLineSegments?2:1,y=s.index,_=s.attributes.position;if(y!==null){const b=Math.max(0,f.start),T=Math.min(y.count,f.start+f.count);for(let C=b,v=T-1;C<v;C+=h){const x=y.getX(C),B=y.getX(C+1),P=ou(this,e,ml,m,x,B,C);P&&i.push(P)}if(this.isLineLoop){const C=y.getX(T-1),v=y.getX(b),x=ou(this,e,ml,m,C,v,T-1);x&&i.push(x)}}else{const b=Math.max(0,f.start),T=Math.min(_.count,f.start+f.count);for(let C=b,v=T-1;C<v;C+=h){const x=ou(this,e,ml,m,C,C+1,C);x&&i.push(x)}if(this.isLineLoop){const C=ou(this,e,ml,m,T-1,b,T-1);C&&i.push(C)}}}updateMorphTargets(){const i=this.geometry.morphAttributes,s=Object.keys(i);if(s.length>0){const l=i[s[0]];if(l!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let c=0,f=l.length;c<f;c++){const p=l[c].name||String(c);this.morphTargetInfluences.push(0),this.morphTargetDictionary[p]=c}}}}}function ou(a,e,i,s,l,c,f){const p=a.geometry.attributes.position;if(wu.fromBufferAttribute(p,l),Ru.fromBufferAttribute(p,c),i.distanceSqToSegment(wu,Ru,yh,Sv)>s)return;yh.applyMatrix4(a.matrixWorld);const h=e.ray.origin.distanceTo(yh);if(!(h<e.near||h>e.far))return{distance:h,point:Sv.clone().applyMatrix4(a.matrixWorld),index:f,face:null,faceIndex:null,barycoord:null,object:a}}const Mv=new ie,bv=new ie;class qx extends fE{constructor(e,i){super(e,i),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const i=e.attributes.position,s=[];for(let l=0,c=i.count;l<c;l+=2)Mv.fromBufferAttribute(i,l),bv.fromBufferAttribute(i,l+1),s[l]=l===0?0:s[l-1],s[l+1]=s[l]+Mv.distanceTo(bv);e.setAttribute("lineDistance",new fi(s,1))}else _t("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Yx extends ei{constructor(e=[],i=tr,s,l,c,f,p,m,h,y){super(e,i,s,l,c,f,p,m,h,y),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class fo extends ei{constructor(e,i,s=la,l,c,f,p=Wn,m=Wn,h,y=Ha,S=1){if(y!==Ha&&y!==Js)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const _={width:e,height:i,depth:S};super(_,l,c,f,p,m,y,s,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Vp(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const i=super.toJSON(e);return this.compareFunction!==null&&(i.compareFunction=this.compareFunction),i}}class dE extends fo{constructor(e,i=la,s=tr,l,c,f=Wn,p=Wn,m,h=Ha){const y={width:e,height:e,depth:1},S=[y,y,y,y,y,y];super(e,e,i,s,l,c,f,p,m,h),this.image=S,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Zx extends ei{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class rr extends Fi{constructor(e=1,i=1,s=1,l=1,c=1,f=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:i,depth:s,widthSegments:l,heightSegments:c,depthSegments:f};const p=this;l=Math.floor(l),c=Math.floor(c),f=Math.floor(f);const m=[],h=[],y=[],S=[];let _=0,b=0;T("z","y","x",-1,-1,s,i,e,f,c,0),T("z","y","x",1,-1,s,i,-e,f,c,1),T("x","z","y",1,1,e,s,i,l,f,2),T("x","z","y",1,-1,e,s,-i,l,f,3),T("x","y","z",1,-1,e,i,s,l,c,4),T("x","y","z",-1,-1,e,i,-s,l,c,5),this.setIndex(m),this.setAttribute("position",new fi(h,3)),this.setAttribute("normal",new fi(y,3)),this.setAttribute("uv",new fi(S,2));function T(C,v,x,B,P,D,O,U,N,A,L){const j=D/N,V=O/A,$=D/2,pe=O/2,ge=U/2,K=N+1,H=A+1;let G=0,ne=0;const ye=new ie;for(let xe=0;xe<H;xe++){const F=xe*V-pe;for(let J=0;J<K;J++){const Ce=J*j-$;ye[C]=Ce*B,ye[v]=F*P,ye[x]=ge,h.push(ye.x,ye.y,ye.z),ye[C]=0,ye[v]=0,ye[x]=U>0?1:-1,y.push(ye.x,ye.y,ye.z),S.push(J/N),S.push(1-xe/A),G+=1}}for(let xe=0;xe<A;xe++)for(let F=0;F<N;F++){const J=_+F+K*xe,Ce=_+F+K*(xe+1),Ue=_+(F+1)+K*(xe+1),Ie=_+(F+1)+K*xe;m.push(J,Ce,Ie),m.push(Ce,Ue,Ie),ne+=6}p.addGroup(b,ne,L),b+=ne,_+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}const lu=new ie,cu=new ie,Sh=new ie,uu=new Bi;class hE extends Fi{constructor(e=null,i=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:i},e!==null){const l=Math.pow(10,4),c=Math.cos(bl*i),f=e.getIndex(),p=e.getAttribute("position"),m=f?f.count:p.count,h=[0,0,0],y=["a","b","c"],S=new Array(3),_={},b=[];for(let T=0;T<m;T+=3){f?(h[0]=f.getX(T),h[1]=f.getX(T+1),h[2]=f.getX(T+2)):(h[0]=T,h[1]=T+1,h[2]=T+2);const{a:C,b:v,c:x}=uu;if(C.fromBufferAttribute(p,h[0]),v.fromBufferAttribute(p,h[1]),x.fromBufferAttribute(p,h[2]),uu.getNormal(Sh),S[0]=`${Math.round(C.x*l)},${Math.round(C.y*l)},${Math.round(C.z*l)}`,S[1]=`${Math.round(v.x*l)},${Math.round(v.y*l)},${Math.round(v.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 B=0;B<3;B++){const P=(B+1)%3,D=S[B],O=S[P],U=uu[y[B]],N=uu[y[P]],A=`${D}_${O}`,L=`${O}_${D}`;L in _&&_[L]?(Sh.dot(_[L].normal)<=c&&(b.push(U.x,U.y,U.z),b.push(N.x,N.y,N.z)),_[L]=null):A in _||(_[A]={index0:h[B],index1:h[P],normal:Sh.clone()})}}for(const T in _)if(_[T]){const{index0:C,index1:v}=_[T];lu.fromBufferAttribute(p,C),cu.fromBufferAttribute(p,v),b.push(lu.x,lu.y,lu.z),b.push(cu.x,cu.y,cu.z)}this.setAttribute("position",new fi(b,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Lu extends Fi{constructor(e=1,i=1,s=1,l=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:i,widthSegments:s,heightSegments:l};const c=e/2,f=i/2,p=Math.floor(s),m=Math.floor(l),h=p+1,y=m+1,S=e/p,_=i/m,b=[],T=[],C=[],v=[];for(let x=0;x<y;x++){const B=x*_-f;for(let P=0;P<h;P++){const D=P*S-c;T.push(D,-B,0),C.push(0,0,1),v.push(P/p),v.push(1-x/m)}}for(let x=0;x<m;x++)for(let B=0;B<p;B++){const P=B+h*x,D=B+h*(x+1),O=B+1+h*(x+1),U=B+1+h*x;b.push(P,D,U),b.push(D,O,U)}this.setIndex(b),this.setAttribute("position",new fi(T,3)),this.setAttribute("normal",new fi(C,3)),this.setAttribute("uv",new fi(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Lu(e.width,e.height,e.widthSegments,e.heightSegments)}}function ho(a){const e={};for(const i in a){e[i]={};for(const s in a[i]){const l=a[i][s];if(Ev(l))l.isRenderTargetTexture?(_t("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[i][s]=null):e[i][s]=l.clone();else if(Array.isArray(l))if(Ev(l[0])){const c=[];for(let f=0,p=l.length;f<p;f++)c[f]=l[f].clone();e[i][s]=c}else e[i][s]=l.slice();else e[i][s]=l}}return e}function Jn(a){const e={};for(let i=0;i<a.length;i++){const s=ho(a[i]);for(const l in s)e[l]=s[l]}return e}function Ev(a){return a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)}function pE(a){const e=[];for(let i=0;i<a.length;i++)e.push(a[i].clone());return e}function Kx(a){const e=a.getRenderTarget();return e===null?a.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:kt.workingColorSpace}const mE={clone:ho,merge:Jn};var gE=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,_E=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`;class ca extends _o{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=gE,this.fragmentShader=_E,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=ho(e.uniforms),this.uniformsGroups=pE(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 i=super.toJSON(e);i.glslVersion=this.glslVersion,i.uniforms={};for(const l in this.uniforms){const f=this.uniforms[l].value;f&&f.isTexture?i.uniforms[l]={type:"t",value:f.toJSON(e).uuid}:f&&f.isColor?i.uniforms[l]={type:"c",value:f.getHex()}:f&&f.isVector2?i.uniforms[l]={type:"v2",value:f.toArray()}:f&&f.isVector3?i.uniforms[l]={type:"v3",value:f.toArray()}:f&&f.isVector4?i.uniforms[l]={type:"v4",value:f.toArray()}:f&&f.isMatrix3?i.uniforms[l]={type:"m3",value:f.toArray()}:f&&f.isMatrix4?i.uniforms[l]={type:"m4",value:f.toArray()}:i.uniforms[l]={value:f}}Object.keys(this.defines).length>0&&(i.defines=this.defines),i.vertexShader=this.vertexShader,i.fragmentShader=this.fragmentShader,i.lights=this.lights,i.clipping=this.clipping;const s={};for(const l in this.extensions)this.extensions[l]===!0&&(s[l]=!0);return Object.keys(s).length>0&&(i.extensions=s),i}fromJSON(e,i){if(super.fromJSON(e,i),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=i[l.value]||null;break;case"c":this.uniforms[s].value=new dt().setHex(l.value);break;case"v2":this.uniforms[s].value=new bt().fromArray(l.value);break;case"v3":this.uniforms[s].value=new ie().fromArray(l.value);break;case"v4":this.uniforms[s].value=new xn().fromArray(l.value);break;case"m3":this.uniforms[s].value=new At().fromArray(l.value);break;case"m4":this.uniforms[s].value=new dn().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 vE extends ca{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class xE extends _o{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new dt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new dt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yp,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new As,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yE extends _o{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ab,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 SE extends _o{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 Wp extends Ln{constructor(e,i=1){super(),this.isLight=!0,this.type="Light",this.color=new dt(e),this.intensity=i}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,i){return super.copy(e,i),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const i=super.toJSON(e);return i.object.color=this.color.getHex(),i.object.intensity=this.intensity,i}}class ME extends Wp{constructor(e,i,s){super(e,s),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ln.DEFAULT_UP),this.updateMatrix(),this.groundColor=new dt(i)}copy(e,i){return super.copy(e,i),this.groundColor.copy(e.groundColor),this}toJSON(e){const i=super.toJSON(e);return i.object.groundColor=this.groundColor.getHex(),i}}const Mh=new dn,Tv=new ie,Av=new ie;class bE{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=Ei,this.map=null,this.mapPass=null,this.matrix=new dn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new jp,this._frameExtents=new bt(1,1),this._viewportCount=1,this._viewports=[new xn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const i=this.camera,s=this.matrix;Tv.setFromMatrixPosition(e.matrixWorld),i.position.copy(Tv),Av.setFromMatrixPosition(e.target.matrixWorld),i.lookAt(Av),i.updateMatrixWorld(),Mh.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Mh,i.coordinateSystem,i.reversedDepth),i.coordinateSystem===Cl||i.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(Mh)}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 fu=new ie,du=new Ts,na=new ie;class $x extends Ln{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new dn,this.projectionMatrix=new dn,this.projectionMatrixInverse=new dn,this.coordinateSystem=sa,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,i){return super.copy(e,i),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(fu,du,na),na.x===1&&na.y===1&&na.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(fu,du,na.set(1,1,1)).invert()}updateWorldMatrix(e,i,s=!1){super.updateWorldMatrix(e,i,s),this.matrixWorld.decompose(fu,du,na),na.x===1&&na.y===1&&na.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(fu,du,na.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const xs=new ie,Cv=new bt,wv=new bt;class Ii extends $x{constructor(e=50,i=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=i,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,i){return super.copy(e,i),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 i=.5*this.getFilmHeight()/e;this.fov=Sp*2*Math.atan(i),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(bl*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Sp*2*Math.atan(Math.tan(bl*.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,i,s){xs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(xs.x,xs.y).multiplyScalar(-e/xs.z),xs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(xs.x,xs.y).multiplyScalar(-e/xs.z)}getViewSize(e,i){return this.getViewBounds(e,Cv,wv),i.subVectors(wv,Cv)}setViewOffset(e,i,s,l,c,f){this.aspect=e/i,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=i,this.view.offsetX=s,this.view.offsetY=l,this.view.width=c,this.view.height=f,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let i=e*Math.tan(bl*.5*this.fov)/this.zoom,s=2*i,l=this.aspect*s,c=-.5*l;const f=this.view;if(this.view!==null&&this.view.enabled){const m=f.fullWidth,h=f.fullHeight;c+=f.offsetX*l/m,i-=f.offsetY*s/h,l*=f.width/m,s*=f.height/h}const p=this.filmOffset;p!==0&&(c+=e*p/this.getFilmWidth()),this.projectionMatrix.makePerspective(c,c+l,i,i-s,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const i=super.toJSON(e);return i.object.fov=this.fov,i.object.zoom=this.zoom,i.object.near=this.near,i.object.far=this.far,i.object.focus=this.focus,i.object.aspect=this.aspect,this.view!==null&&(i.object.view=Object.assign({},this.view)),i.object.filmGauge=this.filmGauge,i.object.filmOffset=this.filmOffset,i}}class qp extends $x{constructor(e=-1,i=1,s=1,l=-1,c=.1,f=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=i,this.top=s,this.bottom=l,this.near=c,this.far=f,this.updateProjectionMatrix()}copy(e,i){return super.copy(e,i),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,i,s,l,c,f){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=i,this.view.offsetX=s,this.view.offsetY=l,this.view.width=c,this.view.height=f,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),i=(this.top-this.bottom)/(2*this.zoom),s=(this.right+this.left)/2,l=(this.top+this.bottom)/2;let c=s-e,f=s+e,p=l+i,m=l-i;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,y=(this.top-this.bottom)/this.view.fullHeight/this.zoom;c+=h*this.view.offsetX,f=c+h*this.view.width,p-=y*this.view.offsetY,m=p-y*this.view.height}this.projectionMatrix.makeOrthographic(c,f,p,m,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const i=super.toJSON(e);return i.object.zoom=this.zoom,i.object.left=this.left,i.object.right=this.right,i.object.top=this.top,i.object.bottom=this.bottom,i.object.near=this.near,i.object.far=this.far,this.view!==null&&(i.object.view=Object.assign({},this.view)),i}}class EE extends bE{constructor(){super(new qp(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Rv extends Wp{constructor(e,i){super(e,i),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ln.DEFAULT_UP),this.updateMatrix(),this.target=new Ln,this.shadow=new EE}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 i=super.toJSON(e);return i.object.shadow=this.shadow.toJSON(),i.object.target=this.target.uuid,i}}class TE extends Wp{constructor(e,i){super(e,i),this.isAmbientLight=!0,this.type="AmbientLight"}}const Kr=-90,$r=1;class AE extends Ln{constructor(e,i,s){super(),this.type="CubeCamera",this.renderTarget=s,this.coordinateSystem=null,this.activeMipmapLevel=0;const l=new Ii(Kr,$r,e,i);l.layers=this.layers,this.add(l);const c=new Ii(Kr,$r,e,i);c.layers=this.layers,this.add(c);const f=new Ii(Kr,$r,e,i);f.layers=this.layers,this.add(f);const p=new Ii(Kr,$r,e,i);p.layers=this.layers,this.add(p);const m=new Ii(Kr,$r,e,i);m.layers=this.layers,this.add(m);const h=new Ii(Kr,$r,e,i);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,i=this.children.concat(),[s,l,c,f,p,m]=i;for(const h of i)this.remove(h);if(e===sa)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),f.up.set(0,0,1),f.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===Cl)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),f.up.set(0,0,-1),f.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 i)this.add(h),h.updateMatrixWorld()}update(e,i){this.parent===null&&this.updateMatrixWorld();const{renderTarget:s,activeMipmapLevel:l}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[c,f,p,m,h,y]=this.children,S=e.getRenderTarget(),_=e.getActiveCubeFace(),b=e.getActiveMipmapLevel(),T=e.xr.enabled;e.xr.enabled=!1;const C=s.texture.generateMipmaps;s.texture.generateMipmaps=!1;let v=!1;e.isWebGLRenderer===!0?v=e.state.buffers.depth.getReversed():v=e.reversedDepthBuffer,e.setRenderTarget(s,0,l),v&&e.autoClear===!1&&e.clearDepth(),e.render(i,c),e.setRenderTarget(s,1,l),v&&e.autoClear===!1&&e.clearDepth(),e.render(i,f),e.setRenderTarget(s,2,l),v&&e.autoClear===!1&&e.clearDepth(),e.render(i,p),e.setRenderTarget(s,3,l),v&&e.autoClear===!1&&e.clearDepth(),e.render(i,m),e.setRenderTarget(s,4,l),v&&e.autoClear===!1&&e.clearDepth(),e.render(i,h),s.texture.generateMipmaps=C,e.setRenderTarget(s,5,l),v&&e.autoClear===!1&&e.clearDepth(),e.render(i,y),e.setRenderTarget(S,_,b),e.xr.enabled=T,s.texture.needsPMREMUpdate=!0}}class CE extends Ii{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Dv{constructor(e=1,i=0,s=0){this.radius=e,this.phi=i,this.theta=s}set(e,i,s){return this.radius=e,this.phi=i,this.theta=s,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Pt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,i,s){return this.radius=Math.sqrt(e*e+i*i+s*s),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,s),this.phi=Math.acos(Pt(i/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const am=class am{constructor(e,i,s,l){this.elements=[1,0,0,1],e!==void 0&&this.set(e,i,s,l)}identity(){return this.set(1,0,0,1),this}fromArray(e,i=0){for(let s=0;s<4;s++)this.elements[s]=e[s+i];return this}set(e,i,s,l){const c=this.elements;return c[0]=e,c[2]=i,c[1]=s,c[3]=l,this}};am.prototype.isMatrix2=!0;let Nv=am;class wE extends qx{constructor(e=10,i=10,s=4473924,l=8947848){s=new dt(s),l=new dt(l);const c=i/2,f=e/i,p=e/2,m=[],h=[];for(let _=0,b=0,T=-p;_<=i;_++,T+=f){m.push(-p,0,T,p,0,T),m.push(T,0,-p,T,0,p);const C=_===c?s:l;C.toArray(h,b),b+=3,C.toArray(h,b),b+=3,C.toArray(h,b),b+=3,C.toArray(h,b),b+=3}const y=new Fi;y.setAttribute("position",new fi(m,3)),y.setAttribute("color",new fi(h,3));const S=new Xp({vertexColors:!0,toneMapped:!1});super(y,S),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class RE extends ws{constructor(e,i=null){super(),this.object=e,this.domElement=i,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){_t("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Uv(a,e,i,s){const l=DE(s);switch(i){case Bx:return a*e;case Ip:return a*e/l.components*l.byteLength;case Bp:return a*e/l.components*l.byteLength;case nr:return a*e*2/l.components*l.byteLength;case Fp:return a*e*2/l.components*l.byteLength;case Fx:return a*e*3/l.components*l.byteLength;case Yi:return a*e*4/l.components*l.byteLength;case zp:return a*e*4/l.components*l.byteLength;case _u:case vu:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case xu:case yu:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case Xh:case qh:return Math.max(a,16)*Math.max(e,8)/4;case jh:case Wh:return Math.max(a,8)*Math.max(e,8)/2;case Yh:case Zh:case $h:case Qh:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case Kh:case bu:case Jh:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case ep:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case tp:return Math.floor((a+4)/5)*Math.floor((e+3)/4)*16;case np:return Math.floor((a+4)/5)*Math.floor((e+4)/5)*16;case ip:return Math.floor((a+5)/6)*Math.floor((e+4)/5)*16;case ap:return Math.floor((a+5)/6)*Math.floor((e+5)/6)*16;case sp:return Math.floor((a+7)/8)*Math.floor((e+4)/5)*16;case rp:return Math.floor((a+7)/8)*Math.floor((e+5)/6)*16;case op:return Math.floor((a+7)/8)*Math.floor((e+7)/8)*16;case lp:return Math.floor((a+9)/10)*Math.floor((e+4)/5)*16;case cp:return Math.floor((a+9)/10)*Math.floor((e+5)/6)*16;case up:return Math.floor((a+9)/10)*Math.floor((e+7)/8)*16;case fp:return Math.floor((a+9)/10)*Math.floor((e+9)/10)*16;case dp:return Math.floor((a+11)/12)*Math.floor((e+9)/10)*16;case hp:return Math.floor((a+11)/12)*Math.floor((e+11)/12)*16;case pp:case mp:case gp:return Math.ceil(a/4)*Math.ceil(e/4)*16;case _p:case vp:return Math.ceil(a/4)*Math.ceil(e/4)*8;case Eu:case xp:return Math.ceil(a/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${i} format.`)}function DE(a){switch(a){case Ei:case Lx:return{byteLength:1,components:1};case Tl:case Ox:case za:return{byteLength:2,components:1};case Op:case Pp:return{byteLength:2,components:4};case la:case Lp:case qi:return{byteLength:4,components:1};case Px:case Ix: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:Np}}));typeof window<"u"&&(window.__THREE__?_t("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Np);function Qx(){let a=null,e=!1,i=null,s=null;function l(c,f){i(c,f),s=a.requestAnimationFrame(l)}return{start:function(){e!==!0&&i!==null&&a!==null&&(s=a.requestAnimationFrame(l),e=!0)},stop:function(){a!==null&&a.cancelAnimationFrame(s),e=!1},setAnimationLoop:function(c){i=c},setContext:function(c){a=c}}}function NE(a){const e=new WeakMap;function i(p,m){const h=p.array,y=p.usage,S=h.byteLength,_=a.createBuffer();a.bindBuffer(m,_),a.bufferData(m,h,y),p.onUploadCallback();let b;if(h instanceof Float32Array)b=a.FLOAT;else if(typeof Float16Array<"u"&&h instanceof Float16Array)b=a.HALF_FLOAT;else if(h instanceof Uint16Array)p.isFloat16BufferAttribute?b=a.HALF_FLOAT:b=a.UNSIGNED_SHORT;else if(h instanceof Int16Array)b=a.SHORT;else if(h instanceof Uint32Array)b=a.UNSIGNED_INT;else if(h instanceof Int32Array)b=a.INT;else if(h instanceof Int8Array)b=a.BYTE;else if(h instanceof Uint8Array)b=a.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)b=a.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:_,type:b,bytesPerElement:h.BYTES_PER_ELEMENT,version:p.version,size:S}}function s(p,m,h){const y=m.array,S=m.updateRanges;if(a.bindBuffer(h,p),S.length===0)a.bufferSubData(h,0,y);else{S.sort((b,T)=>b.start-T.start);let _=0;for(let b=1;b<S.length;b++){const T=S[_],C=S[b];C.start<=T.start+T.count+1?T.count=Math.max(T.count,C.start+C.count-T.start):(++_,S[_]=C)}S.length=_+1;for(let b=0,T=S.length;b<T;b++){const C=S[b];a.bufferSubData(h,C.start*y.BYTES_PER_ELEMENT,y,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 f(p,m){if(p.isInterleavedBufferAttribute&&(p=p.data),p.isGLBufferAttribute){const y=e.get(p);(!y||y.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,i(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:f}}var UE=`#ifdef USE_ALPHAHASH
|
||
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
||
#endif`,LE=`#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`,OE=`#ifdef USE_ALPHAMAP
|
||
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
||
#endif`,PE=`#ifdef USE_ALPHAMAP
|
||
uniform sampler2D alphaMap;
|
||
#endif`,IE=`#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`,BE=`#ifdef USE_ALPHATEST
|
||
uniform float alphaTest;
|
||
#endif`,FE=`#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`,zE=`#ifdef USE_AOMAP
|
||
uniform sampler2D aoMap;
|
||
uniform float aoMapIntensity;
|
||
#endif`,HE=`#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`,GE=`#ifdef USE_BATCHING
|
||
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
||
#endif`,VE=`vec3 transformed = vec3( position );
|
||
#ifdef USE_ALPHAHASH
|
||
vPosition = vec3( position );
|
||
#endif`,kE=`vec3 objectNormal = vec3( normal );
|
||
#ifdef USE_TANGENT
|
||
vec3 objectTangent = vec3( tangent.xyz );
|
||
#endif`,jE=`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`,XE=`#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`,WE=`#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`,qE=`#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`,YE=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
||
#endif`,ZE=`#if NUM_CLIPPING_PLANES > 0
|
||
varying vec3 vClipPosition;
|
||
#endif`,KE=`#if NUM_CLIPPING_PLANES > 0
|
||
vClipPosition = - mvPosition.xyz;
|
||
#endif`,$E=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
||
diffuseColor *= vColor;
|
||
#endif`,QE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
||
varying vec4 vColor;
|
||
#endif`,JE=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
||
varying vec4 vColor;
|
||
#endif`,eT=`#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`,tT=`#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`,nT=`#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`,iT=`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`,aT=`#ifdef USE_DISPLACEMENTMAP
|
||
uniform sampler2D displacementMap;
|
||
uniform float displacementScale;
|
||
uniform float displacementBias;
|
||
#endif`,sT=`#ifdef USE_DISPLACEMENTMAP
|
||
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
||
#endif`,rT=`#ifdef USE_EMISSIVEMAP
|
||
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
||
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
||
#endif
|
||
totalEmissiveRadiance *= emissiveColor.rgb;
|
||
#endif`,oT=`#ifdef USE_EMISSIVEMAP
|
||
uniform sampler2D emissiveMap;
|
||
#endif`,lT="gl_FragColor = linearToOutputTexel( gl_FragColor );",cT=`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 );
|
||
}`,uT=`#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`,fT=`#ifdef USE_ENVMAP
|
||
uniform float envMapIntensity;
|
||
uniform mat3 envMapRotation;
|
||
#ifdef ENVMAP_TYPE_CUBE
|
||
uniform samplerCube envMap;
|
||
#else
|
||
uniform sampler2D envMap;
|
||
#endif
|
||
#endif`,dT=`#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`,hT=`#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`,pT=`#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`,mT=`#ifdef USE_FOG
|
||
vFogDepth = - mvPosition.z;
|
||
#endif`,gT=`#ifdef USE_FOG
|
||
varying float vFogDepth;
|
||
#endif`,_T=`#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`,vT=`#ifdef USE_FOG
|
||
uniform vec3 fogColor;
|
||
varying float vFogDepth;
|
||
#ifdef FOG_EXP2
|
||
uniform float fogDensity;
|
||
#else
|
||
uniform float fogNear;
|
||
uniform float fogFar;
|
||
#endif
|
||
#endif`,xT=`#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
|
||
}`,yT=`#ifdef USE_LIGHTMAP
|
||
uniform sampler2D lightMap;
|
||
uniform float lightMapIntensity;
|
||
#endif`,ST=`LambertMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularStrength = specularStrength;`,MT=`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`,bT=`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>`,ET=`#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`,TT=`ToonMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;`,AT=`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`,CT=`BlinnPhongMaterial material;
|
||
material.diffuseColor = diffuseColor.rgb;
|
||
material.specularColor = specular;
|
||
material.specularShininess = shininess;
|
||
material.specularStrength = specularStrength;`,wT=`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`,RT=`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`,DT=`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 );
|
||
}`,NT=`
|
||
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`,UT=`#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`,LT=`#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`,OT=`#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`,PT=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
||
#endif`,IT=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
||
uniform float logDepthBufFC;
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,BT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
varying float vFragDepth;
|
||
varying float vIsPerspective;
|
||
#endif`,FT=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
||
vFragDepth = 1.0 + gl_Position.w;
|
||
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
||
#endif`,zT=`#ifdef USE_MAP
|
||
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
||
#ifdef DECODE_VIDEO_TEXTURE
|
||
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
||
#endif
|
||
diffuseColor *= sampledDiffuseColor;
|
||
#endif`,HT=`#ifdef USE_MAP
|
||
uniform sampler2D map;
|
||
#endif`,GT=`#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`,VT=`#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`,kT=`float metalnessFactor = metalness;
|
||
#ifdef USE_METALNESSMAP
|
||
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
||
metalnessFactor *= texelMetalness.b;
|
||
#endif`,jT=`#ifdef USE_METALNESSMAP
|
||
uniform sampler2D metalnessMap;
|
||
#endif`,XT=`#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`,WT=`#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`,qT=`#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`,YT=`#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`,ZT=`#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`,KT=`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;`,$T=`#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`,QT=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,JT=`#ifndef FLAT_SHADED
|
||
varying vec3 vNormal;
|
||
#ifdef USE_TANGENT
|
||
varying vec3 vTangent;
|
||
varying vec3 vBitangent;
|
||
#endif
|
||
#endif`,eA=`#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`,tA=`#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`,nA=`#ifdef USE_CLEARCOAT
|
||
vec3 clearcoatNormal = nonPerturbedNormal;
|
||
#endif`,iA=`#ifdef USE_CLEARCOAT_NORMALMAP
|
||
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
||
clearcoatMapN.xy *= clearcoatNormalScale;
|
||
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
||
#endif`,aA=`#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`,sA=`#ifdef USE_IRIDESCENCEMAP
|
||
uniform sampler2D iridescenceMap;
|
||
#endif
|
||
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
||
uniform sampler2D iridescenceThicknessMap;
|
||
#endif`,rA=`#ifdef OPAQUE
|
||
diffuseColor.a = 1.0;
|
||
#endif
|
||
#ifdef USE_TRANSMISSION
|
||
diffuseColor.a *= material.transmissionAlpha;
|
||
#endif
|
||
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,oA=`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
|
||
}`,lA=`#ifdef PREMULTIPLIED_ALPHA
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
#endif`,cA=`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;`,uA=`#ifdef DITHERING
|
||
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
||
#endif`,fA=`#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`,dA=`float roughnessFactor = roughness;
|
||
#ifdef USE_ROUGHNESSMAP
|
||
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
||
roughnessFactor *= texelRoughness.g;
|
||
#endif`,hA=`#ifdef USE_ROUGHNESSMAP
|
||
uniform sampler2D roughnessMap;
|
||
#endif`,pA=`#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`,mA=`#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`,gA=`#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`,_A=`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;
|
||
}`,vA=`#ifdef USE_SKINNING
|
||
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
||
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
||
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
||
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
||
#endif`,xA=`#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`,yA=`#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`,SA=`#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`,MA=`float specularStrength;
|
||
#ifdef USE_SPECULARMAP
|
||
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
||
specularStrength = texelSpecular.r;
|
||
#else
|
||
specularStrength = 1.0;
|
||
#endif`,bA=`#ifdef USE_SPECULARMAP
|
||
uniform sampler2D specularMap;
|
||
#endif`,EA=`#if defined( TONE_MAPPING )
|
||
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
||
#endif`,TA=`#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; }`,AA=`#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`,CA=`#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`,wA=`#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`,RA=`#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`,DA=`#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`,NA=`#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 UA=`varying vec2 vUv;
|
||
uniform mat3 uvTransform;
|
||
void main() {
|
||
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
||
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
||
}`,LA=`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>
|
||
}`,OA=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,PA=`#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>
|
||
}`,IA=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
gl_Position.z = gl_Position.w;
|
||
}`,BA=`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>
|
||
}`,FA=`#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;
|
||
}`,zA=`#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
|
||
}`,HA=`#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;
|
||
}`,GA=`#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 );
|
||
}`,VA=`varying vec3 vWorldDirection;
|
||
#include <common>
|
||
void main() {
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
}`,kA=`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>
|
||
}`,jA=`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>
|
||
}`,XA=`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>
|
||
}`,WA=`#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>
|
||
}`,qA=`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>
|
||
}`,YA=`#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>
|
||
}`,ZA=`#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>
|
||
}`,KA=`#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;
|
||
}`,$A=`#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>
|
||
}`,QA=`#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
|
||
}`,JA=`#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
|
||
}`,e1=`#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>
|
||
}`,t1=`#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>
|
||
}`,n1=`#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
|
||
}`,i1=`#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>
|
||
}`,a1=`#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>
|
||
}`,s1=`#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>
|
||
}`,r1=`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>
|
||
}`,o1=`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>
|
||
}`,l1=`#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>
|
||
}`,c1=`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>
|
||
}`,u1=`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>
|
||
}`,f1=`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>
|
||
}`,Dt={alphahash_fragment:UE,alphahash_pars_fragment:LE,alphamap_fragment:OE,alphamap_pars_fragment:PE,alphatest_fragment:IE,alphatest_pars_fragment:BE,aomap_fragment:FE,aomap_pars_fragment:zE,batching_pars_vertex:HE,batching_vertex:GE,begin_vertex:VE,beginnormal_vertex:kE,bsdfs:jE,iridescence_fragment:XE,bumpmap_pars_fragment:WE,clipping_planes_fragment:qE,clipping_planes_pars_fragment:YE,clipping_planes_pars_vertex:ZE,clipping_planes_vertex:KE,color_fragment:$E,color_pars_fragment:QE,color_pars_vertex:JE,color_vertex:eT,common:tT,cube_uv_reflection_fragment:nT,defaultnormal_vertex:iT,displacementmap_pars_vertex:aT,displacementmap_vertex:sT,emissivemap_fragment:rT,emissivemap_pars_fragment:oT,colorspace_fragment:lT,colorspace_pars_fragment:cT,envmap_fragment:uT,envmap_common_pars_fragment:fT,envmap_pars_fragment:dT,envmap_pars_vertex:hT,envmap_physical_pars_fragment:ET,envmap_vertex:pT,fog_vertex:mT,fog_pars_vertex:gT,fog_fragment:_T,fog_pars_fragment:vT,gradientmap_pars_fragment:xT,lightmap_pars_fragment:yT,lights_lambert_fragment:ST,lights_lambert_pars_fragment:MT,lights_pars_begin:bT,lights_toon_fragment:TT,lights_toon_pars_fragment:AT,lights_phong_fragment:CT,lights_phong_pars_fragment:wT,lights_physical_fragment:RT,lights_physical_pars_fragment:DT,lights_fragment_begin:NT,lights_fragment_maps:UT,lights_fragment_end:LT,lightprobes_pars_fragment:OT,logdepthbuf_fragment:PT,logdepthbuf_pars_fragment:IT,logdepthbuf_pars_vertex:BT,logdepthbuf_vertex:FT,map_fragment:zT,map_pars_fragment:HT,map_particle_fragment:GT,map_particle_pars_fragment:VT,metalnessmap_fragment:kT,metalnessmap_pars_fragment:jT,morphinstance_vertex:XT,morphcolor_vertex:WT,morphnormal_vertex:qT,morphtarget_pars_vertex:YT,morphtarget_vertex:ZT,normal_fragment_begin:KT,normal_fragment_maps:$T,normal_pars_fragment:QT,normal_pars_vertex:JT,normal_vertex:eA,normalmap_pars_fragment:tA,clearcoat_normal_fragment_begin:nA,clearcoat_normal_fragment_maps:iA,clearcoat_pars_fragment:aA,iridescence_pars_fragment:sA,opaque_fragment:rA,packing:oA,premultiplied_alpha_fragment:lA,project_vertex:cA,dithering_fragment:uA,dithering_pars_fragment:fA,roughnessmap_fragment:dA,roughnessmap_pars_fragment:hA,shadowmap_pars_fragment:pA,shadowmap_pars_vertex:mA,shadowmap_vertex:gA,shadowmask_pars_fragment:_A,skinbase_vertex:vA,skinning_pars_vertex:xA,skinning_vertex:yA,skinnormal_vertex:SA,specularmap_fragment:MA,specularmap_pars_fragment:bA,tonemapping_fragment:EA,tonemapping_pars_fragment:TA,transmission_fragment:AA,transmission_pars_fragment:CA,uv_pars_fragment:wA,uv_pars_vertex:RA,uv_vertex:DA,worldpos_vertex:NA,background_vert:UA,background_frag:LA,backgroundCube_vert:OA,backgroundCube_frag:PA,cube_vert:IA,cube_frag:BA,depth_vert:FA,depth_frag:zA,distance_vert:HA,distance_frag:GA,equirect_vert:VA,equirect_frag:kA,linedashed_vert:jA,linedashed_frag:XA,meshbasic_vert:WA,meshbasic_frag:qA,meshlambert_vert:YA,meshlambert_frag:ZA,meshmatcap_vert:KA,meshmatcap_frag:$A,meshnormal_vert:QA,meshnormal_frag:JA,meshphong_vert:e1,meshphong_frag:t1,meshphysical_vert:n1,meshphysical_frag:i1,meshtoon_vert:a1,meshtoon_frag:s1,points_vert:r1,points_frag:o1,shadow_vert:l1,shadow_frag:c1,sprite_vert:u1,sprite_frag:f1},We={common:{diffuse:{value:new dt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new At},alphaMap:{value:null},alphaMapTransform:{value:new At},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new At}},envmap:{envMap:{value:null},envMapRotation:{value:new At},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new At}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new At}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new At},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new At},normalScale:{value:new bt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new At},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new At}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new At}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new At}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new dt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},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 ie},probesMax:{value:new ie},probesResolution:{value:new ie}},points:{diffuse:{value:new dt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new At},alphaTest:{value:0},uvTransform:{value:new At}},sprite:{diffuse:{value:new dt(16777215)},opacity:{value:1},center:{value:new bt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new At},alphaMap:{value:null},alphaMapTransform:{value:new At},alphaTest:{value:0}}},aa={basic:{uniforms:Jn([We.common,We.specularmap,We.envmap,We.aomap,We.lightmap,We.fog]),vertexShader:Dt.meshbasic_vert,fragmentShader:Dt.meshbasic_frag},lambert:{uniforms:Jn([We.common,We.specularmap,We.envmap,We.aomap,We.lightmap,We.emissivemap,We.bumpmap,We.normalmap,We.displacementmap,We.fog,We.lights,{emissive:{value:new dt(0)},envMapIntensity:{value:1}}]),vertexShader:Dt.meshlambert_vert,fragmentShader:Dt.meshlambert_frag},phong:{uniforms:Jn([We.common,We.specularmap,We.envmap,We.aomap,We.lightmap,We.emissivemap,We.bumpmap,We.normalmap,We.displacementmap,We.fog,We.lights,{emissive:{value:new dt(0)},specular:{value:new dt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Dt.meshphong_vert,fragmentShader:Dt.meshphong_frag},standard:{uniforms:Jn([We.common,We.envmap,We.aomap,We.lightmap,We.emissivemap,We.bumpmap,We.normalmap,We.displacementmap,We.roughnessmap,We.metalnessmap,We.fog,We.lights,{emissive:{value:new dt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Dt.meshphysical_vert,fragmentShader:Dt.meshphysical_frag},toon:{uniforms:Jn([We.common,We.aomap,We.lightmap,We.emissivemap,We.bumpmap,We.normalmap,We.displacementmap,We.gradientmap,We.fog,We.lights,{emissive:{value:new dt(0)}}]),vertexShader:Dt.meshtoon_vert,fragmentShader:Dt.meshtoon_frag},matcap:{uniforms:Jn([We.common,We.bumpmap,We.normalmap,We.displacementmap,We.fog,{matcap:{value:null}}]),vertexShader:Dt.meshmatcap_vert,fragmentShader:Dt.meshmatcap_frag},points:{uniforms:Jn([We.points,We.fog]),vertexShader:Dt.points_vert,fragmentShader:Dt.points_frag},dashed:{uniforms:Jn([We.common,We.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Dt.linedashed_vert,fragmentShader:Dt.linedashed_frag},depth:{uniforms:Jn([We.common,We.displacementmap]),vertexShader:Dt.depth_vert,fragmentShader:Dt.depth_frag},normal:{uniforms:Jn([We.common,We.bumpmap,We.normalmap,We.displacementmap,{opacity:{value:1}}]),vertexShader:Dt.meshnormal_vert,fragmentShader:Dt.meshnormal_frag},sprite:{uniforms:Jn([We.sprite,We.fog]),vertexShader:Dt.sprite_vert,fragmentShader:Dt.sprite_frag},background:{uniforms:{uvTransform:{value:new At},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Dt.background_vert,fragmentShader:Dt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new At}},vertexShader:Dt.backgroundCube_vert,fragmentShader:Dt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Dt.cube_vert,fragmentShader:Dt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Dt.equirect_vert,fragmentShader:Dt.equirect_frag},distance:{uniforms:Jn([We.common,We.displacementmap,{referencePosition:{value:new ie},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Dt.distance_vert,fragmentShader:Dt.distance_frag},shadow:{uniforms:Jn([We.lights,We.fog,{color:{value:new dt(0)},opacity:{value:1}}]),vertexShader:Dt.shadow_vert,fragmentShader:Dt.shadow_frag}};aa.physical={uniforms:Jn([aa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new At},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new At},clearcoatNormalScale:{value:new bt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new At},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new At},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new At},sheen:{value:0},sheenColor:{value:new dt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new At},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new At},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new At},transmissionSamplerSize:{value:new bt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new At},attenuationDistance:{value:0},attenuationColor:{value:new dt(0)},specularColor:{value:new dt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new At},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new At},anisotropyVector:{value:new bt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new At}}]),vertexShader:Dt.meshphysical_vert,fragmentShader:Dt.meshphysical_frag};const hu={r:0,b:0,g:0},d1=new dn,Jx=new At;Jx.set(-1,0,0,0,1,0,0,0,1);function h1(a,e,i,s,l,c){const f=new dt(0);let p=l===!0?0:1,m,h,y=null,S=0,_=null;function b(B){let P=B.isScene===!0?B.background:null;if(P&&P.isTexture){const D=B.backgroundBlurriness>0;P=e.get(P,D)}return P}function T(B){let P=!1;const D=b(B);D===null?v(f,p):D&&D.isColor&&(v(D,1),P=!0);const O=a.xr.getEnvironmentBlendMode();O==="additive"?i.buffers.color.setClear(0,0,0,1,c):O==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,c),(a.autoClear||P)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil))}function C(B,P){const D=b(P);D&&(D.isCubeTexture||D.mapping===Uu)?(h===void 0&&(h=new Ki(new rr(1,1,1),new ca({name:"BackgroundCubeMaterial",uniforms:ho(aa.backgroundCube.uniforms),vertexShader:aa.backgroundCube.vertexShader,fragmentShader:aa.backgroundCube.fragmentShader,side:ui,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(O,U,N){this.matrixWorld.copyPosition(N.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),h.material.uniforms.envMap.value=D,h.material.uniforms.backgroundBlurriness.value=P.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=P.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(d1.makeRotationFromEuler(P.backgroundRotation)).transpose(),D.isCubeTexture&&D.isRenderTargetTexture===!1&&h.material.uniforms.backgroundRotation.value.premultiply(Jx),h.material.toneMapped=kt.getTransfer(D.colorSpace)!==an,(y!==D||S!==D.version||_!==a.toneMapping)&&(h.material.needsUpdate=!0,y=D,S=D.version,_=a.toneMapping),h.layers.enableAll(),B.unshift(h,h.geometry,h.material,0,0,null)):D&&D.isTexture&&(m===void 0&&(m=new Ki(new Lu(2,2),new ca({name:"BackgroundMaterial",uniforms:ho(aa.background.uniforms),vertexShader:aa.background.vertexShader,fragmentShader:aa.background.fragmentShader,side:Es,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=D,m.material.uniforms.backgroundIntensity.value=P.backgroundIntensity,m.material.toneMapped=kt.getTransfer(D.colorSpace)!==an,D.matrixAutoUpdate===!0&&D.updateMatrix(),m.material.uniforms.uvTransform.value.copy(D.matrix),(y!==D||S!==D.version||_!==a.toneMapping)&&(m.material.needsUpdate=!0,y=D,S=D.version,_=a.toneMapping),m.layers.enableAll(),B.unshift(m,m.geometry,m.material,0,0,null))}function v(B,P){B.getRGB(hu,Kx(a)),i.buffers.color.setClear(hu.r,hu.g,hu.b,P,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 f},setClearColor:function(B,P=1){f.set(B),p=P,v(f,p)},getClearAlpha:function(){return p},setClearAlpha:function(B){p=B,v(f,p)},render:T,addToRenderList:C,dispose:x}}function p1(a,e){const i=a.getParameter(a.MAX_VERTEX_ATTRIBS),s={},l=_(null);let c=l,f=!1;function p(V,$,pe,ge,K){let H=!1;const G=S(V,ge,pe,$);c!==G&&(c=G,h(c.object)),H=b(V,ge,pe,K),H&&T(V,ge,pe,K),K!==null&&e.update(K,a.ELEMENT_ARRAY_BUFFER),(H||f)&&(f=!1,D(V,$,pe,ge),K!==null&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,e.get(K).buffer))}function m(){return a.createVertexArray()}function h(V){return a.bindVertexArray(V)}function y(V){return a.deleteVertexArray(V)}function S(V,$,pe,ge){const K=ge.wireframe===!0;let H=s[$.id];H===void 0&&(H={},s[$.id]=H);const G=V.isInstancedMesh===!0?V.id:0;let ne=H[G];ne===void 0&&(ne={},H[G]=ne);let ye=ne[pe.id];ye===void 0&&(ye={},ne[pe.id]=ye);let xe=ye[K];return xe===void 0&&(xe=_(m()),ye[K]=xe),xe}function _(V){const $=[],pe=[],ge=[];for(let K=0;K<i;K++)$[K]=0,pe[K]=0,ge[K]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:pe,attributeDivisors:ge,object:V,attributes:{},index:null}}function b(V,$,pe,ge){const K=c.attributes,H=$.attributes;let G=0;const ne=pe.getAttributes();for(const ye in ne)if(ne[ye].location>=0){const F=K[ye];let J=H[ye];if(J===void 0&&(ye==="instanceMatrix"&&V.instanceMatrix&&(J=V.instanceMatrix),ye==="instanceColor"&&V.instanceColor&&(J=V.instanceColor)),F===void 0||F.attribute!==J||J&&F.data!==J.data)return!0;G++}return c.attributesNum!==G||c.index!==ge}function T(V,$,pe,ge){const K={},H=$.attributes;let G=0;const ne=pe.getAttributes();for(const ye in ne)if(ne[ye].location>=0){let F=H[ye];F===void 0&&(ye==="instanceMatrix"&&V.instanceMatrix&&(F=V.instanceMatrix),ye==="instanceColor"&&V.instanceColor&&(F=V.instanceColor));const J={};J.attribute=F,F&&F.data&&(J.data=F.data),K[ye]=J,G++}c.attributes=K,c.attributesNum=G,c.index=ge}function C(){const V=c.newAttributes;for(let $=0,pe=V.length;$<pe;$++)V[$]=0}function v(V){x(V,0)}function x(V,$){const pe=c.newAttributes,ge=c.enabledAttributes,K=c.attributeDivisors;pe[V]=1,ge[V]===0&&(a.enableVertexAttribArray(V),ge[V]=1),K[V]!==$&&(a.vertexAttribDivisor(V,$),K[V]=$)}function B(){const V=c.newAttributes,$=c.enabledAttributes;for(let pe=0,ge=$.length;pe<ge;pe++)$[pe]!==V[pe]&&(a.disableVertexAttribArray(pe),$[pe]=0)}function P(V,$,pe,ge,K,H,G){G===!0?a.vertexAttribIPointer(V,$,pe,K,H):a.vertexAttribPointer(V,$,pe,ge,K,H)}function D(V,$,pe,ge){C();const K=ge.attributes,H=pe.getAttributes(),G=$.defaultAttributeValues;for(const ne in H){const ye=H[ne];if(ye.location>=0){let xe=K[ne];if(xe===void 0&&(ne==="instanceMatrix"&&V.instanceMatrix&&(xe=V.instanceMatrix),ne==="instanceColor"&&V.instanceColor&&(xe=V.instanceColor)),xe!==void 0){const F=xe.normalized,J=xe.itemSize,Ce=e.get(xe);if(Ce===void 0)continue;const Ue=Ce.buffer,Ie=Ce.type,ae=Ce.bytesPerElement,Ae=Ie===a.INT||Ie===a.UNSIGNED_INT||xe.gpuType===Lp;if(xe.isInterleavedBufferAttribute){const Ee=xe.data,He=Ee.stride,nt=xe.offset;if(Ee.isInstancedInterleavedBuffer){for(let Ke=0;Ke<ye.locationSize;Ke++)x(ye.location+Ke,Ee.meshPerAttribute);V.isInstancedMesh!==!0&&ge._maxInstanceCount===void 0&&(ge._maxInstanceCount=Ee.meshPerAttribute*Ee.count)}else for(let Ke=0;Ke<ye.locationSize;Ke++)v(ye.location+Ke);a.bindBuffer(a.ARRAY_BUFFER,Ue);for(let Ke=0;Ke<ye.locationSize;Ke++)P(ye.location+Ke,J/ye.locationSize,Ie,F,He*ae,(nt+J/ye.locationSize*Ke)*ae,Ae)}else{if(xe.isInstancedBufferAttribute){for(let Ee=0;Ee<ye.locationSize;Ee++)x(ye.location+Ee,xe.meshPerAttribute);V.isInstancedMesh!==!0&&ge._maxInstanceCount===void 0&&(ge._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let Ee=0;Ee<ye.locationSize;Ee++)v(ye.location+Ee);a.bindBuffer(a.ARRAY_BUFFER,Ue);for(let Ee=0;Ee<ye.locationSize;Ee++)P(ye.location+Ee,J/ye.locationSize,Ie,F,J*ae,J/ye.locationSize*Ee*ae,Ae)}}else if(G!==void 0){const F=G[ne];if(F!==void 0)switch(F.length){case 2:a.vertexAttrib2fv(ye.location,F);break;case 3:a.vertexAttrib3fv(ye.location,F);break;case 4:a.vertexAttrib4fv(ye.location,F);break;default:a.vertexAttrib1fv(ye.location,F)}}}}B()}function O(){L();for(const V in s){const $=s[V];for(const pe in $){const ge=$[pe];for(const K in ge){const H=ge[K];for(const G in H)y(H[G].object),delete H[G];delete ge[K]}}delete s[V]}}function U(V){if(s[V.id]===void 0)return;const $=s[V.id];for(const pe in $){const ge=$[pe];for(const K in ge){const H=ge[K];for(const G in H)y(H[G].object),delete H[G];delete ge[K]}}delete s[V.id]}function N(V){for(const $ in s){const pe=s[$];for(const ge in pe){const K=pe[ge];if(K[V.id]===void 0)continue;const H=K[V.id];for(const G in H)y(H[G].object),delete H[G];delete K[V.id]}}}function A(V){for(const $ in s){const pe=s[$],ge=V.isInstancedMesh===!0?V.id:0,K=pe[ge];if(K!==void 0){for(const H in K){const G=K[H];for(const ne in G)y(G[ne].object),delete G[ne];delete K[H]}delete pe[ge],Object.keys(pe).length===0&&delete s[$]}}}function L(){j(),f=!0,c!==l&&(c=l,h(c.object))}function j(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:p,reset:L,resetDefaultState:j,dispose:O,releaseStatesOfGeometry:U,releaseStatesOfObject:A,releaseStatesOfProgram:N,initAttributes:C,enableAttribute:v,disableUnusedAttributes:B}}function m1(a,e,i){let s;function l(m){s=m}function c(m,h){a.drawArrays(s,m,h),i.update(h,s,1)}function f(m,h,y){y!==0&&(a.drawArraysInstanced(s,m,h,y),i.update(h,s,y))}function p(m,h,y){if(y===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(s,m,0,h,0,y);let _=0;for(let b=0;b<y;b++)_+=h[b];i.update(_,s,1)}this.setMode=l,this.render=c,this.renderInstances=f,this.renderMultiDraw=p}function g1(a,e,i,s){let l;function c(){if(l!==void 0)return l;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");l=a.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else l=0;return l}function f(N){return!(N!==Yi&&s.convert(N)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_FORMAT))}function p(N){const A=N===za&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==Ei&&s.convert(N)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==qi&&!A)}function m(N){if(N==="highp"){if(a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="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=i.precision!==void 0?i.precision:"highp";const y=m(h);y!==h&&(_t("WebGLRenderer:",h,"not supported, using",y,"instead."),h=y);const S=i.logarithmicDepthBuffer===!0,_=i.reversedDepthBuffer===!0&&e.has("EXT_clip_control");i.reversedDepthBuffer===!0&&_===!1&&_t("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const b=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),T=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),C=a.getParameter(a.MAX_TEXTURE_SIZE),v=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),x=a.getParameter(a.MAX_VERTEX_ATTRIBS),B=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),P=a.getParameter(a.MAX_VARYING_VECTORS),D=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),O=a.getParameter(a.MAX_SAMPLES),U=a.getParameter(a.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:c,getMaxPrecision:m,textureFormatReadable:f,textureTypeReadable:p,precision:h,logarithmicDepthBuffer:S,reversedDepthBuffer:_,maxTextures:b,maxVertexTextures:T,maxTextureSize:C,maxCubemapSize:v,maxAttributes:x,maxVertexUniforms:B,maxVaryings:P,maxFragmentUniforms:D,maxSamples:O,samples:U}}function _1(a){const e=this;let i=null,s=0,l=!1,c=!1;const f=new ys,p=new At,m={value:null,needsUpdate:!1};this.uniform=m,this.numPlanes=0,this.numIntersection=0,this.init=function(S,_){const b=S.length!==0||_||s!==0||l;return l=_,s=S.length,b},this.beginShadows=function(){c=!0,y(null)},this.endShadows=function(){c=!1},this.setGlobalState=function(S,_){i=y(S,_,0)},this.setState=function(S,_,b){const T=S.clippingPlanes,C=S.clipIntersection,v=S.clipShadows,x=a.get(S);if(!l||T===null||T.length===0||c&&!v)c?y(null):h();else{const B=c?0:s,P=B*4;let D=x.clippingState||null;m.value=D,D=y(T,_,P,b);for(let O=0;O!==P;++O)D[O]=i[O];x.clippingState=D,this.numIntersection=C?this.numPlanes:0,this.numPlanes+=B}};function h(){m.value!==i&&(m.value=i,m.needsUpdate=s>0),e.numPlanes=s,e.numIntersection=0}function y(S,_,b,T){const C=S!==null?S.length:0;let v=null;if(C!==0){if(v=m.value,T!==!0||v===null){const x=b+C*4,B=_.matrixWorldInverse;p.getNormalMatrix(B),(v===null||v.length<x)&&(v=new Float32Array(x));for(let P=0,D=b;P!==C;++P,D+=4)f.copy(S[P]).applyMatrix4(B,p),f.normal.toArray(v,D),v[D+3]=f.constant}m.value=v,m.needsUpdate=!0}return e.numPlanes=C,e.numIntersection=0,v}}const Ms=4,Lv=[.125,.215,.35,.446,.526,.582],$s=20,v1=256,gl=new qp,Ov=new dt;let bh=null,Eh=0,Th=0,Ah=!1;const x1=new ie;class Pv{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,i=0,s=.1,l=100,c={}){const{size:f=256,position:p=x1}=c;bh=this._renderer.getRenderTarget(),Eh=this._renderer.getActiveCubeFace(),Th=this._renderer.getActiveMipmapLevel(),Ah=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(f);const m=this._allocateTargets();return m.depthBuffer=!0,this._sceneToCubeUV(e,s,l,m,p),i>0&&this._blur(m,0,0,i),this._applyPMREM(m),this._cleanup(m),m}fromEquirectangular(e,i=null){return this._fromTexture(e,i)}fromCubemap(e,i=null){return this._fromTexture(e,i)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Fv(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Bv(),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(bh,Eh,Th),this._renderer.xr.enabled=Ah,e.scissorTest=!1,Qr(e,0,0,e.width,e.height)}_fromTexture(e,i){e.mapping===tr||e.mapping===uo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),bh=this._renderer.getRenderTarget(),Eh=this._renderer.getActiveCubeFace(),Th=this._renderer.getActiveMipmapLevel(),Ah=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const s=i||this._allocateTargets();return this._textureToCubeUV(e,s),this._applyPMREM(s),this._cleanup(s),s}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),i=4*this._cubeSize,s={magFilter:$n,minFilter:$n,generateMipmaps:!1,type:za,format:Yi,colorSpace:Tu,depthBuffer:!1},l=Iv(e,i,s);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==i){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Iv(e,i,s);const{_lodMax:c}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=y1(c)),this._blurMaterial=M1(c,e,i),this._ggxMaterial=S1(c,e,i)}return l}_compileMaterial(e){const i=new Ki(new Fi,e);this._renderer.compile(i,gl)}_sceneToCubeUV(e,i,s,l,c){const m=new Ii(90,1,i,s),h=[1,-1,1,1,1,1],y=[1,1,1,-1,-1,-1],S=this._renderer,_=S.autoClear,b=S.toneMapping;S.getClearColor(Ov),S.toneMapping=ra,S.autoClear=!1,S.state.buffers.depth.getReversed()&&(S.setRenderTarget(l),S.clearDepth(),S.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ki(new rr,new Xx({name:"PMREM.Background",side:ui,depthWrite:!1,depthTest:!1})));const C=this._backgroundBox,v=C.material;let x=!1;const B=e.background;B?B.isColor&&(v.color.copy(B),e.background=null,x=!0):(v.color.copy(Ov),x=!0);for(let P=0;P<6;P++){const D=P%3;D===0?(m.up.set(0,h[P],0),m.position.set(c.x,c.y,c.z),m.lookAt(c.x+y[P],c.y,c.z)):D===1?(m.up.set(0,0,h[P]),m.position.set(c.x,c.y,c.z),m.lookAt(c.x,c.y+y[P],c.z)):(m.up.set(0,h[P],0),m.position.set(c.x,c.y,c.z),m.lookAt(c.x,c.y,c.z+y[P]));const O=this._cubeSize;Qr(l,D*O,P>2?O:0,O,O),S.setRenderTarget(l),x&&S.render(C,m),S.render(e,m)}S.toneMapping=b,S.autoClear=_,e.background=B}_textureToCubeUV(e,i){const s=this._renderer,l=e.mapping===tr||e.mapping===uo;l?(this._cubemapMaterial===null&&(this._cubemapMaterial=Fv()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Bv());const c=l?this._cubemapMaterial:this._equirectMaterial,f=this._lodMeshes[0];f.material=c;const p=c.uniforms;p.envMap.value=e;const m=this._cubeSize;Qr(i,0,0,3*m,2*m),s.setRenderTarget(i),s.render(f,gl)}_applyPMREM(e){const i=this._renderer,s=i.autoClear;i.autoClear=!1;const l=this._lodMeshes.length;for(let c=1;c<l;c++)this._applyGGXFilter(e,c-1,c);i.autoClear=s}_applyGGXFilter(e,i,s){const l=this._renderer,c=this._pingPongRenderTarget,f=this._ggxMaterial,p=this._lodMeshes[s];p.material=f;const m=f.uniforms,h=s/(this._lodMeshes.length-1),y=i/(this._lodMeshes.length-1),S=Math.sqrt(h*h-y*y),_=0+h*1.25,b=S*_,{_lodMax:T}=this,C=this._sizeLods[s],v=3*C*(s>T-Ms?s-T+Ms:0),x=4*(this._cubeSize-C);m.envMap.value=e.texture,m.roughness.value=b,m.mipInt.value=T-i,Qr(c,v,x,3*C,2*C),l.setRenderTarget(c),l.render(p,gl),m.envMap.value=c.texture,m.roughness.value=0,m.mipInt.value=T-s,Qr(e,v,x,3*C,2*C),l.setRenderTarget(e),l.render(p,gl)}_blur(e,i,s,l,c){const f=this._pingPongRenderTarget;this._halfBlur(e,f,i,s,l,"latitudinal",c),this._halfBlur(f,e,s,s,l,"longitudinal",c)}_halfBlur(e,i,s,l,c,f,p){const m=this._renderer,h=this._blurMaterial;f!=="latitudinal"&&f!=="longitudinal"&&jt("blur direction must be either latitudinal or longitudinal!");const y=3,S=this._lodMeshes[l];S.material=h;const _=h.uniforms,b=this._sizeLods[s]-1,T=isFinite(c)?Math.PI/(2*b):2*Math.PI/(2*$s-1),C=c/T,v=isFinite(c)?1+Math.floor(y*C):$s;v>$s&&_t(`sigmaRadians, ${c}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${$s}`);const x=[];let B=0;for(let N=0;N<$s;++N){const A=N/C,L=Math.exp(-A*A/2);x.push(L),N===0?B+=L:N<v&&(B+=2*L)}for(let N=0;N<x.length;N++)x[N]=x[N]/B;_.envMap.value=e.texture,_.samples.value=v,_.weights.value=x,_.latitudinal.value=f==="latitudinal",p&&(_.poleAxis.value=p);const{_lodMax:P}=this;_.dTheta.value=T,_.mipInt.value=P-s;const D=this._sizeLods[l],O=3*D*(l>P-Ms?l-P+Ms:0),U=4*(this._cubeSize-D);Qr(i,O,U,3*D,2*D),m.setRenderTarget(i),m.render(S,gl)}}function y1(a){const e=[],i=[],s=[];let l=a;const c=a-Ms+1+Lv.length;for(let f=0;f<c;f++){const p=Math.pow(2,l);e.push(p);let m=1/p;f>a-Ms?m=Lv[f-a+Ms-1]:f===0&&(m=0),i.push(m);const h=1/(p-2),y=-h,S=1+h,_=[y,y,S,y,S,S,y,y,S,S,y,S],b=6,T=6,C=3,v=2,x=1,B=new Float32Array(C*T*b),P=new Float32Array(v*T*b),D=new Float32Array(x*T*b);for(let U=0;U<b;U++){const N=U%3*2/3-1,A=U>2?0:-1,L=[N,A,0,N+2/3,A,0,N+2/3,A+1,0,N,A,0,N+2/3,A+1,0,N,A+1,0];B.set(L,C*T*U),P.set(_,v*T*U);const j=[U,U,U,U,U,U];D.set(j,x*T*U)}const O=new Fi;O.setAttribute("position",new Zi(B,C)),O.setAttribute("uv",new Zi(P,v)),O.setAttribute("faceIndex",new Zi(D,x)),s.push(new Ki(O,null)),l>Ms&&l--}return{lodMeshes:s,sizeLods:e,sigmas:i}}function Iv(a,e,i){const s=new oa(a,e,i);return s.texture.mapping=Uu,s.texture.name="PMREM.cubeUv",s.scissorTest=!0,s}function Qr(a,e,i,s,l){a.viewport.set(e,i,s,l),a.scissor.set(e,i,s,l)}function S1(a,e,i){return new ca({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:v1,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ou(),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:Ba,depthTest:!1,depthWrite:!1})}function M1(a,e,i){const s=new Float32Array($s),l=new ie(0,1,0);return new ca({name:"SphericalGaussianBlur",defines:{n:$s,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,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:Ou(),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:Ba,depthTest:!1,depthWrite:!1})}function Bv(){return new ca({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ou(),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:Ba,depthTest:!1,depthWrite:!1})}function Fv(){return new ca({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ou(),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:Ba,depthTest:!1,depthWrite:!1})}function Ou(){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 ey extends oa{constructor(e=1,i={}){super(e,e,i),this.isWebGLCubeRenderTarget=!0;const s={width:e,height:e,depth:1},l=[s,s,s,s,s,s];this.texture=new Yx(l),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,i){this.texture.type=i.type,this.texture.colorSpace=i.colorSpace,this.texture.generateMipmaps=i.generateMipmaps,this.texture.minFilter=i.minFilter,this.texture.magFilter=i.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 rr(5,5,5),c=new ca({name:"CubemapFromEquirect",uniforms:ho(s.uniforms),vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,side:ui,blending:Ba});c.uniforms.tEquirect.value=i;const f=new Ki(l,c),p=i.minFilter;return i.minFilter===Qs&&(i.minFilter=$n),new AE(1,10,this).update(e,f),i.minFilter=p,f.geometry.dispose(),f.material.dispose(),this}clear(e,i=!0,s=!0,l=!0){const c=e.getRenderTarget();for(let f=0;f<6;f++)e.setRenderTarget(this,f),e.clear(i,s,l);e.setRenderTarget(c)}}function b1(a){let e=new WeakMap,i=new WeakMap,s=null;function l(_,b=!1){return _==null?null:b?f(_):c(_)}function c(_){if(_&&_.isTexture){const b=_.mapping;if(b===Yd||b===Zd)if(e.has(_)){const T=e.get(_).texture;return p(T,_.mapping)}else{const T=_.image;if(T&&T.height>0){const C=new ey(T.height);return C.fromEquirectangularTexture(a,_),e.set(_,C),_.addEventListener("dispose",h),p(C.texture,_.mapping)}else return null}}return _}function f(_){if(_&&_.isTexture){const b=_.mapping,T=b===Yd||b===Zd,C=b===tr||b===uo;if(T||C){let v=i.get(_);const x=v!==void 0?v.texture.pmremVersion:0;if(_.isRenderTargetTexture&&_.pmremVersion!==x)return s===null&&(s=new Pv(a)),v=T?s.fromEquirectangular(_,v):s.fromCubemap(_,v),v.texture.pmremVersion=_.pmremVersion,i.set(_,v),v.texture;if(v!==void 0)return v.texture;{const B=_.image;return T&&B&&B.height>0||C&&B&&m(B)?(s===null&&(s=new Pv(a)),v=T?s.fromEquirectangular(_):s.fromCubemap(_),v.texture.pmremVersion=_.pmremVersion,i.set(_,v),_.addEventListener("dispose",y),v.texture):null}}}return _}function p(_,b){return b===Yd?_.mapping=tr:b===Zd&&(_.mapping=uo),_}function m(_){let b=0;const T=6;for(let C=0;C<T;C++)_[C]!==void 0&&b++;return b===T}function h(_){const b=_.target;b.removeEventListener("dispose",h);const T=e.get(b);T!==void 0&&(e.delete(b),T.dispose())}function y(_){const b=_.target;b.removeEventListener("dispose",y);const T=i.get(b);T!==void 0&&(i.delete(b),T.dispose())}function S(){e=new WeakMap,i=new WeakMap,s!==null&&(s.dispose(),s=null)}return{get:l,dispose:S}}function E1(a){const e={};function i(s){if(e[s]!==void 0)return e[s];const l=a.getExtension(s);return e[s]=l,l}return{has:function(s){return i(s)!==null},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(s){const l=i(s);return l===null&&ao("WebGLRenderer: "+s+" extension not supported."),l}}}function T1(a,e,i,s){const l={},c=new WeakMap;function f(S){const _=S.target;_.index!==null&&e.remove(_.index);for(const T in _.attributes)e.remove(_.attributes[T]);_.removeEventListener("dispose",f),delete l[_.id];const b=c.get(_);b&&(e.remove(b),c.delete(_)),s.releaseStatesOfGeometry(_),_.isInstancedBufferGeometry===!0&&delete _._maxInstanceCount,i.memory.geometries--}function p(S,_){return l[_.id]===!0||(_.addEventListener("dispose",f),l[_.id]=!0,i.memory.geometries++),_}function m(S){const _=S.attributes;for(const b in _)e.update(_[b],a.ARRAY_BUFFER)}function h(S){const _=[],b=S.index,T=S.attributes.position;let C=0;if(T===void 0)return;if(b!==null){const B=b.array;C=b.version;for(let P=0,D=B.length;P<D;P+=3){const O=B[P+0],U=B[P+1],N=B[P+2];_.push(O,U,U,N,N,O)}}else{const B=T.array;C=T.version;for(let P=0,D=B.length/3-1;P<D;P+=3){const O=P+0,U=P+1,N=P+2;_.push(O,U,U,N,N,O)}}const v=new(T.count>=65535?jx:kx)(_,1);v.version=C;const x=c.get(S);x&&e.remove(x),c.set(S,v)}function y(S){const _=c.get(S);if(_){const b=S.index;b!==null&&_.version<b.version&&h(S)}else h(S);return c.get(S)}return{get:p,update:m,getWireframeAttribute:y}}function A1(a,e,i){let s;function l(S){s=S}let c,f;function p(S){c=S.type,f=S.bytesPerElement}function m(S,_){a.drawElements(s,_,c,S*f),i.update(_,s,1)}function h(S,_,b){b!==0&&(a.drawElementsInstanced(s,_,c,S*f,b),i.update(_,s,b))}function y(S,_,b){if(b===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(s,_,0,c,S,0,b);let C=0;for(let v=0;v<b;v++)C+=_[v];i.update(C,s,1)}this.setMode=l,this.setIndex=p,this.render=m,this.renderInstances=h,this.renderMultiDraw=y}function C1(a){const e={geometries:0,textures:0},i={frame:0,calls:0,triangles:0,points:0,lines:0};function s(c,f,p){switch(i.calls++,f){case a.TRIANGLES:i.triangles+=p*(c/3);break;case a.LINES:i.lines+=p*(c/2);break;case a.LINE_STRIP:i.lines+=p*(c-1);break;case a.LINE_LOOP:i.lines+=p*c;break;case a.POINTS:i.points+=p*c;break;default:jt("WebGLInfo: Unknown draw mode:",f);break}}function l(){i.calls=0,i.triangles=0,i.points=0,i.lines=0}return{memory:e,render:i,programs:null,autoReset:!0,reset:l,update:s}}function w1(a,e,i){const s=new WeakMap,l=new xn;function c(f,p,m){const h=f.morphTargetInfluences,y=p.morphAttributes.position||p.morphAttributes.normal||p.morphAttributes.color,S=y!==void 0?y.length:0;let _=s.get(p);if(_===void 0||_.count!==S){let j=function(){A.dispose(),s.delete(p),p.removeEventListener("dispose",j)};var b=j;_!==void 0&&_.texture.dispose();const T=p.morphAttributes.position!==void 0,C=p.morphAttributes.normal!==void 0,v=p.morphAttributes.color!==void 0,x=p.morphAttributes.position||[],B=p.morphAttributes.normal||[],P=p.morphAttributes.color||[];let D=0;T===!0&&(D=1),C===!0&&(D=2),v===!0&&(D=3);let O=p.attributes.position.count*D,U=1;O>e.maxTextureSize&&(U=Math.ceil(O/e.maxTextureSize),O=e.maxTextureSize);const N=new Float32Array(O*U*4*S),A=new Hx(N,O,U,S);A.type=qi,A.needsUpdate=!0;const L=D*4;for(let V=0;V<S;V++){const $=x[V],pe=B[V],ge=P[V],K=O*U*4*V;for(let H=0;H<$.count;H++){const G=H*L;T===!0&&(l.fromBufferAttribute($,H),N[K+G+0]=l.x,N[K+G+1]=l.y,N[K+G+2]=l.z,N[K+G+3]=0),C===!0&&(l.fromBufferAttribute(pe,H),N[K+G+4]=l.x,N[K+G+5]=l.y,N[K+G+6]=l.z,N[K+G+7]=0),v===!0&&(l.fromBufferAttribute(ge,H),N[K+G+8]=l.x,N[K+G+9]=l.y,N[K+G+10]=l.z,N[K+G+11]=ge.itemSize===4?l.w:1)}}_={count:S,texture:A,size:new bt(O,U)},s.set(p,_),p.addEventListener("dispose",j)}if(f.isInstancedMesh===!0&&f.morphTexture!==null)m.getUniforms().setValue(a,"morphTexture",f.morphTexture,i);else{let T=0;for(let v=0;v<h.length;v++)T+=h[v];const C=p.morphTargetsRelative?1:1-T;m.getUniforms().setValue(a,"morphTargetBaseInfluence",C),m.getUniforms().setValue(a,"morphTargetInfluences",h)}m.getUniforms().setValue(a,"morphTargetsTexture",_.texture,i),m.getUniforms().setValue(a,"morphTargetsTextureSize",_.size)}return{update:c}}function R1(a,e,i,s,l){let c=new WeakMap;function f(h){const y=l.render.frame,S=h.geometry,_=e.get(h,S);if(c.get(_)!==y&&(e.update(_),c.set(_,y)),h.isInstancedMesh&&(h.hasEventListener("dispose",m)===!1&&h.addEventListener("dispose",m),c.get(h)!==y&&(i.update(h.instanceMatrix,a.ARRAY_BUFFER),h.instanceColor!==null&&i.update(h.instanceColor,a.ARRAY_BUFFER),c.set(h,y))),h.isSkinnedMesh){const b=h.skeleton;c.get(b)!==y&&(b.update(),c.set(b,y))}return _}function p(){c=new WeakMap}function m(h){const y=h.target;y.removeEventListener("dispose",m),s.releaseStatesOfObject(y),i.remove(y.instanceMatrix),y.instanceColor!==null&&i.remove(y.instanceColor)}return{update:f,dispose:p}}const D1={[Ax]:"LINEAR_TONE_MAPPING",[Cx]:"REINHARD_TONE_MAPPING",[wx]:"CINEON_TONE_MAPPING",[Up]:"ACES_FILMIC_TONE_MAPPING",[Dx]:"AGX_TONE_MAPPING",[Nx]:"NEUTRAL_TONE_MAPPING",[Rx]:"CUSTOM_TONE_MAPPING"};function N1(a,e,i,s,l,c){const f=new oa(e,i,{type:a,depthBuffer:l,stencilBuffer:c,samples:s?4:0,depthTexture:l?new fo(e,i):void 0}),p=new oa(e,i,{type:za,depthBuffer:!1,stencilBuffer:!1}),m=new Fi;m.setAttribute("position",new fi([-1,3,0,-1,-1,0,3,-1,0],3)),m.setAttribute("uv",new fi([0,2,0,0,2,0],2));const h=new vE({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}),y=new Ki(m,h),S=new qp(-1,1,1,-1,0,1);let _=null,b=null,T=!1,C,v=null,x=[],B=!1;this.setSize=function(P,D){f.setSize(P,D),p.setSize(P,D);for(let O=0;O<x.length;O++){const U=x[O];U.setSize&&U.setSize(P,D)}},this.setEffects=function(P){x=P,B=x.length>0&&x[0].isRenderPass===!0;const D=f.width,O=f.height;for(let U=0;U<x.length;U++){const N=x[U];N.setSize&&N.setSize(D,O)}},this.begin=function(P,D){if(T||P.toneMapping===ra&&x.length===0)return!1;if(v=D,D!==null){const O=D.width,U=D.height;(f.width!==O||f.height!==U)&&this.setSize(O,U)}return B===!1&&P.setRenderTarget(f),C=P.toneMapping,P.toneMapping=ra,!0},this.hasRenderPass=function(){return B},this.end=function(P,D){P.toneMapping=C,T=!0;let O=f,U=p;for(let N=0;N<x.length;N++){const A=x[N];if(A.enabled!==!1&&(A.render(P,U,O,D),A.needsSwap!==!1)){const L=O;O=U,U=L}}if(_!==P.outputColorSpace||b!==P.toneMapping){_=P.outputColorSpace,b=P.toneMapping,h.defines={},kt.getTransfer(_)===an&&(h.defines.SRGB_TRANSFER="");const N=D1[b];N&&(h.defines[N]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=O.texture,P.setRenderTarget(v),P.render(y,S),v=null,T=!1},this.isCompositing=function(){return T},this.dispose=function(){f.depthTexture&&f.depthTexture.dispose(),f.dispose(),p.dispose(),m.dispose(),h.dispose()}}const ty=new ei,Mp=new fo(1,1),ny=new Hx,iy=new Wb,ay=new Yx,zv=[],Hv=[],Gv=new Float32Array(16),Vv=new Float32Array(9),kv=new Float32Array(4);function vo(a,e,i){const s=a[0];if(s<=0||s>0)return a;const l=e*i;let c=zv[l];if(c===void 0&&(c=new Float32Array(l),zv[l]=c),e!==0){s.toArray(c,0);for(let f=1,p=0;f!==e;++f)p+=i,a[f].toArray(c,p)}return c}function On(a,e){if(a.length!==e.length)return!1;for(let i=0,s=a.length;i<s;i++)if(a[i]!==e[i])return!1;return!0}function Pn(a,e){for(let i=0,s=e.length;i<s;i++)a[i]=e[i]}function Pu(a,e){let i=Hv[e];i===void 0&&(i=new Int32Array(e),Hv[e]=i);for(let s=0;s!==e;++s)i[s]=a.allocateTextureUnit();return i}function U1(a,e){const i=this.cache;i[0]!==e&&(a.uniform1f(this.addr,e),i[0]=e)}function L1(a,e){const i=this.cache;if(e.x!==void 0)(i[0]!==e.x||i[1]!==e.y)&&(a.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(On(i,e))return;a.uniform2fv(this.addr,e),Pn(i,e)}}function O1(a,e){const i=this.cache;if(e.x!==void 0)(i[0]!==e.x||i[1]!==e.y||i[2]!==e.z)&&(a.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(e.r!==void 0)(i[0]!==e.r||i[1]!==e.g||i[2]!==e.b)&&(a.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(On(i,e))return;a.uniform3fv(this.addr,e),Pn(i,e)}}function P1(a,e){const i=this.cache;if(e.x!==void 0)(i[0]!==e.x||i[1]!==e.y||i[2]!==e.z||i[3]!==e.w)&&(a.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(On(i,e))return;a.uniform4fv(this.addr,e),Pn(i,e)}}function I1(a,e){const i=this.cache,s=e.elements;if(s===void 0){if(On(i,e))return;a.uniformMatrix2fv(this.addr,!1,e),Pn(i,e)}else{if(On(i,s))return;kv.set(s),a.uniformMatrix2fv(this.addr,!1,kv),Pn(i,s)}}function B1(a,e){const i=this.cache,s=e.elements;if(s===void 0){if(On(i,e))return;a.uniformMatrix3fv(this.addr,!1,e),Pn(i,e)}else{if(On(i,s))return;Vv.set(s),a.uniformMatrix3fv(this.addr,!1,Vv),Pn(i,s)}}function F1(a,e){const i=this.cache,s=e.elements;if(s===void 0){if(On(i,e))return;a.uniformMatrix4fv(this.addr,!1,e),Pn(i,e)}else{if(On(i,s))return;Gv.set(s),a.uniformMatrix4fv(this.addr,!1,Gv),Pn(i,s)}}function z1(a,e){const i=this.cache;i[0]!==e&&(a.uniform1i(this.addr,e),i[0]=e)}function H1(a,e){const i=this.cache;if(e.x!==void 0)(i[0]!==e.x||i[1]!==e.y)&&(a.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(On(i,e))return;a.uniform2iv(this.addr,e),Pn(i,e)}}function G1(a,e){const i=this.cache;if(e.x!==void 0)(i[0]!==e.x||i[1]!==e.y||i[2]!==e.z)&&(a.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(On(i,e))return;a.uniform3iv(this.addr,e),Pn(i,e)}}function V1(a,e){const i=this.cache;if(e.x!==void 0)(i[0]!==e.x||i[1]!==e.y||i[2]!==e.z||i[3]!==e.w)&&(a.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(On(i,e))return;a.uniform4iv(this.addr,e),Pn(i,e)}}function k1(a,e){const i=this.cache;i[0]!==e&&(a.uniform1ui(this.addr,e),i[0]=e)}function j1(a,e){const i=this.cache;if(e.x!==void 0)(i[0]!==e.x||i[1]!==e.y)&&(a.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(On(i,e))return;a.uniform2uiv(this.addr,e),Pn(i,e)}}function X1(a,e){const i=this.cache;if(e.x!==void 0)(i[0]!==e.x||i[1]!==e.y||i[2]!==e.z)&&(a.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(On(i,e))return;a.uniform3uiv(this.addr,e),Pn(i,e)}}function W1(a,e){const i=this.cache;if(e.x!==void 0)(i[0]!==e.x||i[1]!==e.y||i[2]!==e.z||i[3]!==e.w)&&(a.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(On(i,e))return;a.uniform4uiv(this.addr,e),Pn(i,e)}}function q1(a,e,i){const s=this.cache,l=i.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l);let c;this.type===a.SAMPLER_2D_SHADOW?(Mp.compareFunction=i.isReversedDepthBuffer()?Gp:Hp,c=Mp):c=ty,i.setTexture2D(e||c,l)}function Y1(a,e,i){const s=this.cache,l=i.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l),i.setTexture3D(e||iy,l)}function Z1(a,e,i){const s=this.cache,l=i.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l),i.setTextureCube(e||ay,l)}function K1(a,e,i){const s=this.cache,l=i.allocateTextureUnit();s[0]!==l&&(a.uniform1i(this.addr,l),s[0]=l),i.setTexture2DArray(e||ny,l)}function $1(a){switch(a){case 5126:return U1;case 35664:return L1;case 35665:return O1;case 35666:return P1;case 35674:return I1;case 35675:return B1;case 35676:return F1;case 5124:case 35670:return z1;case 35667:case 35671:return H1;case 35668:case 35672:return G1;case 35669:case 35673:return V1;case 5125:return k1;case 36294:return j1;case 36295:return X1;case 36296:return W1;case 35678:case 36198:case 36298:case 36306:case 35682:return q1;case 35679:case 36299:case 36307:return Y1;case 35680:case 36300:case 36308:case 36293:return Z1;case 36289:case 36303:case 36311:case 36292:return K1}}function Q1(a,e){a.uniform1fv(this.addr,e)}function J1(a,e){const i=vo(e,this.size,2);a.uniform2fv(this.addr,i)}function eC(a,e){const i=vo(e,this.size,3);a.uniform3fv(this.addr,i)}function tC(a,e){const i=vo(e,this.size,4);a.uniform4fv(this.addr,i)}function nC(a,e){const i=vo(e,this.size,4);a.uniformMatrix2fv(this.addr,!1,i)}function iC(a,e){const i=vo(e,this.size,9);a.uniformMatrix3fv(this.addr,!1,i)}function aC(a,e){const i=vo(e,this.size,16);a.uniformMatrix4fv(this.addr,!1,i)}function sC(a,e){a.uniform1iv(this.addr,e)}function rC(a,e){a.uniform2iv(this.addr,e)}function oC(a,e){a.uniform3iv(this.addr,e)}function lC(a,e){a.uniform4iv(this.addr,e)}function cC(a,e){a.uniform1uiv(this.addr,e)}function uC(a,e){a.uniform2uiv(this.addr,e)}function fC(a,e){a.uniform3uiv(this.addr,e)}function dC(a,e){a.uniform4uiv(this.addr,e)}function hC(a,e,i){const s=this.cache,l=e.length,c=Pu(i,l);On(s,c)||(a.uniform1iv(this.addr,c),Pn(s,c));let f;this.type===a.SAMPLER_2D_SHADOW?f=Mp:f=ty;for(let p=0;p!==l;++p)i.setTexture2D(e[p]||f,c[p])}function pC(a,e,i){const s=this.cache,l=e.length,c=Pu(i,l);On(s,c)||(a.uniform1iv(this.addr,c),Pn(s,c));for(let f=0;f!==l;++f)i.setTexture3D(e[f]||iy,c[f])}function mC(a,e,i){const s=this.cache,l=e.length,c=Pu(i,l);On(s,c)||(a.uniform1iv(this.addr,c),Pn(s,c));for(let f=0;f!==l;++f)i.setTextureCube(e[f]||ay,c[f])}function gC(a,e,i){const s=this.cache,l=e.length,c=Pu(i,l);On(s,c)||(a.uniform1iv(this.addr,c),Pn(s,c));for(let f=0;f!==l;++f)i.setTexture2DArray(e[f]||ny,c[f])}function _C(a){switch(a){case 5126:return Q1;case 35664:return J1;case 35665:return eC;case 35666:return tC;case 35674:return nC;case 35675:return iC;case 35676:return aC;case 5124:case 35670:return sC;case 35667:case 35671:return rC;case 35668:case 35672:return oC;case 35669:case 35673:return lC;case 5125:return cC;case 36294:return uC;case 36295:return fC;case 36296:return dC;case 35678:case 36198:case 36298:case 36306:case 35682:return hC;case 35679:case 36299:case 36307:return pC;case 35680:case 36300:case 36308:case 36293:return mC;case 36289:case 36303:case 36311:case 36292:return gC}}class vC{constructor(e,i,s){this.id=e,this.addr=s,this.cache=[],this.type=i.type,this.setValue=$1(i.type)}}class xC{constructor(e,i,s){this.id=e,this.addr=s,this.cache=[],this.type=i.type,this.size=i.size,this.setValue=_C(i.type)}}class yC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,i,s){const l=this.seq;for(let c=0,f=l.length;c!==f;++c){const p=l[c];p.setValue(e,i[p.id],s)}}}const Ch=/(\w+)(\])?(\[|\.)?/g;function jv(a,e){a.seq.push(e),a.map[e.id]=e}function SC(a,e,i){const s=a.name,l=s.length;for(Ch.lastIndex=0;;){const c=Ch.exec(s),f=Ch.lastIndex;let p=c[1];const m=c[2]==="]",h=c[3];if(m&&(p=p|0),h===void 0||h==="["&&f+2===l){jv(i,h===void 0?new vC(p,a,e):new xC(p,a,e));break}else{let S=i.map[p];S===void 0&&(S=new yC(p),jv(i,S)),i=S}}}class Su{constructor(e,i){this.seq=[],this.map={};const s=e.getProgramParameter(i,e.ACTIVE_UNIFORMS);for(let f=0;f<s;++f){const p=e.getActiveUniform(i,f),m=e.getUniformLocation(i,p.name);SC(p,m,this)}const l=[],c=[];for(const f of this.seq)f.type===e.SAMPLER_2D_SHADOW||f.type===e.SAMPLER_CUBE_SHADOW||f.type===e.SAMPLER_2D_ARRAY_SHADOW?l.push(f):c.push(f);l.length>0&&(this.seq=l.concat(c))}setValue(e,i,s,l){const c=this.map[i];c!==void 0&&c.setValue(e,s,l)}setOptional(e,i,s){const l=i[s];l!==void 0&&this.setValue(e,s,l)}static upload(e,i,s,l){for(let c=0,f=i.length;c!==f;++c){const p=i[c],m=s[p.id];m.needsUpdate!==!1&&p.setValue(e,m.value,l)}}static seqWithValue(e,i){const s=[];for(let l=0,c=e.length;l!==c;++l){const f=e[l];f.id in i&&s.push(f)}return s}}function Xv(a,e,i){const s=a.createShader(e);return a.shaderSource(s,i),a.compileShader(s),s}const MC=37297;let bC=0;function EC(a,e){const i=a.split(`
|
||
`),s=[],l=Math.max(e-6,0),c=Math.min(e+6,i.length);for(let f=l;f<c;f++){const p=f+1;s.push(`${p===e?">":" "} ${p}: ${i[f]}`)}return s.join(`
|
||
`)}const Wv=new At;function TC(a){kt._getMatrix(Wv,kt.workingColorSpace,a);const e=`mat3( ${Wv.elements.map(i=>i.toFixed(4))} )`;switch(kt.getTransfer(a)){case Au:return[e,"LinearTransferOETF"];case an:return[e,"sRGBTransferOETF"];default:return _t("WebGLProgram: Unsupported color space: ",a),[e,"LinearTransferOETF"]}}function qv(a,e,i){const s=a.getShaderParameter(e,a.COMPILE_STATUS),c=(a.getShaderInfoLog(e)||"").trim();if(s&&c==="")return"";const f=/ERROR: 0:(\d+)/.exec(c);if(f){const p=parseInt(f[1]);return i.toUpperCase()+`
|
||
|
||
`+c+`
|
||
|
||
`+EC(a.getShaderSource(e),p)}else return c}function AC(a,e){const i=TC(e);return[`vec4 ${a}( vec4 value ) {`,` return ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join(`
|
||
`)}const CC={[Ax]:"Linear",[Cx]:"Reinhard",[wx]:"Cineon",[Up]:"ACESFilmic",[Dx]:"AgX",[Nx]:"Neutral",[Rx]:"Custom"};function wC(a,e){const i=CC[e];return i===void 0?(_t("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+a+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+a+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const pu=new ie;function RC(){kt.getLuminanceCoefficients(pu);const a=pu.x.toFixed(4),e=pu.y.toFixed(4),i=pu.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${a}, ${e}, ${i} );`," return dot( weights, rgb );","}"].join(`
|
||
`)}function DC(a){return[a.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",a.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(xl).join(`
|
||
`)}function NC(a){const e=[];for(const i in a){const s=a[i];s!==!1&&e.push("#define "+i+" "+s)}return e.join(`
|
||
`)}function UC(a,e){const i={},s=a.getProgramParameter(e,a.ACTIVE_ATTRIBUTES);for(let l=0;l<s;l++){const c=a.getActiveAttrib(e,l),f=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),i[f]={type:c.type,location:a.getAttribLocation(e,f),locationSize:p}}return i}function xl(a){return a!==""}function Yv(a,e){const i=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,i).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 Zv(a,e){return a.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const LC=/^[ \t]*#include +<([\w\d./]+)>/gm;function bp(a){return a.replace(LC,PC)}const OC=new Map;function PC(a,e){let i=Dt[e];if(i===void 0){const s=OC.get(e);if(s!==void 0)i=Dt[s],_t('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,s);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return bp(i)}const IC=/#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 Kv(a){return a.replace(IC,BC)}function BC(a,e,i,s){let l="";for(let c=parseInt(e);c<parseInt(i);c++)l+=s.replace(/\[\s*i\s*\]/g,"[ "+c+" ]").replace(/UNROLLED_LOOP_INDEX/g,c);return l}function $v(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 FC={[gu]:"SHADOWMAP_TYPE_PCF",[vl]:"SHADOWMAP_TYPE_VSM"};function zC(a){return FC[a.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const HC={[tr]:"ENVMAP_TYPE_CUBE",[uo]:"ENVMAP_TYPE_CUBE",[Uu]:"ENVMAP_TYPE_CUBE_UV"};function GC(a){return a.envMap===!1?"ENVMAP_TYPE_CUBE":HC[a.envMapMode]||"ENVMAP_TYPE_CUBE"}const VC={[uo]:"ENVMAP_MODE_REFRACTION"};function kC(a){return a.envMap===!1?"ENVMAP_MODE_REFLECTION":VC[a.envMapMode]||"ENVMAP_MODE_REFLECTION"}const jC={[Tx]:"ENVMAP_BLENDING_MULTIPLY",[bb]:"ENVMAP_BLENDING_MIX",[Eb]:"ENVMAP_BLENDING_ADD"};function XC(a){return a.envMap===!1?"ENVMAP_BLENDING_NONE":jC[a.combine]||"ENVMAP_BLENDING_NONE"}function WC(a){const e=a.envMapCubeUVHeight;if(e===null)return null;const i=Math.log2(e)-2,s=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:s,maxMip:i}}function qC(a,e,i,s){const l=a.getContext(),c=i.defines;let f=i.vertexShader,p=i.fragmentShader;const m=zC(i),h=GC(i),y=kC(i),S=XC(i),_=WC(i),b=DC(i),T=NC(c),C=l.createProgram();let v,x,B=i.glslVersion?"#version "+i.glslVersion+`
|
||
`:"";i.isRawShaderMaterial?(v=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,T].filter(xl).join(`
|
||
`),v.length>0&&(v+=`
|
||
`),x=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,T].filter(xl).join(`
|
||
`),x.length>0&&(x+=`
|
||
`)):(v=[$v(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,T,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+y:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&i.flatShading===!1?"#define USE_TANGENT":"",i.vertexNormals?"#define HAS_NORMAL":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&i.flatShading===!1?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+m:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.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(xl).join(`
|
||
`),x=[$v(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,T,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+y:"",i.envMap?"#define "+S:"",_?"#define CUBEUV_TEXEL_WIDTH "+_.texelWidth:"",_?"#define CUBEUV_TEXEL_HEIGHT "+_.texelHeight:"",_?"#define CUBEUV_MAX_MIP "+_.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&i.flatShading===!1?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas||i.batchingColor?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+m:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==ra?"#define TONE_MAPPING":"",i.toneMapping!==ra?Dt.tonemapping_pars_fragment:"",i.toneMapping!==ra?wC("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Dt.colorspace_pars_fragment,AC("linearToOutputTexel",i.outputColorSpace),RC(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"",`
|
||
`].filter(xl).join(`
|
||
`)),f=bp(f),f=Yv(f,i),f=Zv(f,i),p=bp(p),p=Yv(p,i),p=Zv(p,i),f=Kv(f),p=Kv(p),i.isRawShaderMaterial!==!0&&(B=`#version 300 es
|
||
`,v=[b,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
||
`)+`
|
||
`+v,x=["#define varying in",i.glslVersion===ev?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===ev?"":"#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 P=B+v+f,D=B+x+p,O=Xv(l,l.VERTEX_SHADER,P),U=Xv(l,l.FRAGMENT_SHADER,D);l.attachShader(C,O),l.attachShader(C,U),i.index0AttributeName!==void 0?l.bindAttribLocation(C,0,i.index0AttributeName):i.hasPositionAttribute===!0&&l.bindAttribLocation(C,0,"position"),l.linkProgram(C);function N(V){if(a.debug.checkShaderErrors){const $=l.getProgramInfoLog(C)||"",pe=l.getShaderInfoLog(O)||"",ge=l.getShaderInfoLog(U)||"",K=$.trim(),H=pe.trim(),G=ge.trim();let ne=!0,ye=!0;if(l.getProgramParameter(C,l.LINK_STATUS)===!1)if(ne=!1,typeof a.debug.onShaderError=="function")a.debug.onShaderError(l,C,O,U);else{const xe=qv(l,O,"vertex"),F=qv(l,U,"fragment");jt("WebGLProgram: Shader Error "+l.getError()+" - VALIDATE_STATUS "+l.getProgramParameter(C,l.VALIDATE_STATUS)+`
|
||
|
||
Material Name: `+V.name+`
|
||
Material Type: `+V.type+`
|
||
|
||
Program Info Log: `+K+`
|
||
`+xe+`
|
||
`+F)}else K!==""?_t("WebGLProgram: Program Info Log:",K):(H===""||G==="")&&(ye=!1);ye&&(V.diagnostics={runnable:ne,programLog:K,vertexShader:{log:H,prefix:v},fragmentShader:{log:G,prefix:x}})}l.deleteShader(O),l.deleteShader(U),A=new Su(l,C),L=UC(l,C)}let A;this.getUniforms=function(){return A===void 0&&N(this),A};let L;this.getAttributes=function(){return L===void 0&&N(this),L};let j=i.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return j===!1&&(j=l.getProgramParameter(C,MC)),j},this.destroy=function(){s.releaseStatesOfProgram(this),l.deleteProgram(C),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=bC++,this.cacheKey=e,this.usedTimes=1,this.program=C,this.vertexShader=O,this.fragmentShader=U,this}let YC=0;class ZC{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,i,s){const l=this._getShaderCacheForMaterial(e);return l.has(i)===!1&&(l.add(i),i.usedTimes++),l.has(s)===!1&&(l.add(s),s.usedTimes++),this}remove(e){const i=this.materialCache.get(e);for(const s of i)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 i=this.materialCache;let s=i.get(e);return s===void 0&&(s=new Set,i.set(e,s)),s}_getShaderStage(e){const i=this.shaderCache;let s=i.get(e);return s===void 0&&(s=new KC(e),i.set(e,s)),s}}class KC{constructor(e){this.id=YC++,this.code=e,this.usedTimes=0}}function $C(a){return a===nr||a===bu||a===Eu}function QC(a,e,i,s,l,c){const f=new Gx,p=new ZC,m=new Set,h=[],y=new Map,S=s.logarithmicDepthBuffer;let _=s.precision;const b={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 T(A){return m.add(A),A===0?"uv":`uv${A}`}function C(A,L,j,V,$,pe){const ge=V.fog,K=$.geometry,H=A.isMeshStandardMaterial||A.isMeshLambertMaterial||A.isMeshPhongMaterial?V.environment:null,G=A.isMeshStandardMaterial||A.isMeshLambertMaterial&&!A.envMap||A.isMeshPhongMaterial&&!A.envMap,ne=e.get(A.envMap||H,G),ye=ne&&ne.mapping===Uu?ne.image.height:null,xe=b[A.type];A.precision!==null&&(_=s.getMaxPrecision(A.precision),_!==A.precision&&_t("WebGLProgram.getParameters:",A.precision,"not supported, using",_,"instead."));const F=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,J=F!==void 0?F.length:0;let Ce=0;K.morphAttributes.position!==void 0&&(Ce=1),K.morphAttributes.normal!==void 0&&(Ce=2),K.morphAttributes.color!==void 0&&(Ce=3);let Ue,Ie,ae,Ae;if(xe){const De=aa[xe];Ue=De.vertexShader,Ie=De.fragmentShader}else{Ue=A.vertexShader,Ie=A.fragmentShader;const De=p.getVertexShaderStage(A),ft=p.getFragmentShaderStage(A);p.update(A,De,ft),ae=De.id,Ae=ft.id}const Ee=a.getRenderTarget(),He=a.state.buffers.depth.getReversed(),nt=$.isInstancedMesh===!0,Ke=$.isBatchedMesh===!0,zt=!!A.map,ht=!!A.matcap,Et=!!ne,yt=!!A.aoMap,St=!!A.lightMap,Mt=!!A.bumpMap&&A.wireframe===!1,Ht=!!A.normalMap,Gt=!!A.displacementMap,st=!!A.emissiveMap,It=!!A.metalnessMap,W=!!A.roughnessMap,z=A.anisotropy>0,Ye=A.clearcoat>0,xt=A.dispersion>0,I=A.iridescence>0,E=A.sheen>0,X=A.transmission>0,se=z&&!!A.anisotropyMap,me=Ye&&!!A.clearcoatMap,Ne=Ye&&!!A.clearcoatNormalMap,Oe=Ye&&!!A.clearcoatRoughnessMap,_e=I&&!!A.iridescenceMap,he=I&&!!A.iridescenceThicknessMap,Le=E&&!!A.sheenColorMap,je=E&&!!A.sheenRoughnessMap,ze=!!A.specularMap,Fe=!!A.specularColorMap,Qe=!!A.specularIntensityMap,Je=X&&!!A.transmissionMap,pt=X&&!!A.thicknessMap,Z=!!A.gradientMap,Pe=!!A.alphaMap,Se=A.alphaTest>0,Be=!!A.alphaHash,ke=!!A.extensions;let q=ra;A.toneMapped&&(Ee===null||Ee.isXRRenderTarget===!0)&&(q=a.toneMapping);const Me={shaderID:xe,shaderType:A.type,shaderName:A.name,vertexShader:Ue,fragmentShader:Ie,defines:A.defines,customVertexShaderID:ae,customFragmentShaderID:Ae,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:_,batching:Ke,batchingColor:Ke&&$._colorsTexture!==null,instancing:nt,instancingColor:nt&&$.instanceColor!==null,instancingMorph:nt&&$.morphTexture!==null,outputColorSpace:Ee===null?a.outputColorSpace:Ee.isXRRenderTarget===!0?Ee.texture.colorSpace:kt.workingColorSpace,alphaToCoverage:!!A.alphaToCoverage,map:zt,matcap:ht,envMap:Et,envMapMode:Et&&ne.mapping,envMapCubeUVHeight:ye,aoMap:yt,lightMap:St,bumpMap:Mt,normalMap:Ht,displacementMap:Gt,emissiveMap:st,normalMapObjectSpace:Ht&&A.normalMapType===Cb,normalMapTangentSpace:Ht&&A.normalMapType===yp,packedNormalMap:Ht&&A.normalMapType===yp&&$C(A.normalMap.format),metalnessMap:It,roughnessMap:W,anisotropy:z,anisotropyMap:se,clearcoat:Ye,clearcoatMap:me,clearcoatNormalMap:Ne,clearcoatRoughnessMap:Oe,dispersion:xt,iridescence:I,iridescenceMap:_e,iridescenceThicknessMap:he,sheen:E,sheenColorMap:Le,sheenRoughnessMap:je,specularMap:ze,specularColorMap:Fe,specularIntensityMap:Qe,transmission:X,transmissionMap:Je,thicknessMap:pt,gradientMap:Z,opaque:A.transparent===!1&&A.blending===io&&A.alphaToCoverage===!1,alphaMap:Pe,alphaTest:Se,alphaHash:Be,combine:A.combine,mapUv:zt&&T(A.map.channel),aoMapUv:yt&&T(A.aoMap.channel),lightMapUv:St&&T(A.lightMap.channel),bumpMapUv:Mt&&T(A.bumpMap.channel),normalMapUv:Ht&&T(A.normalMap.channel),displacementMapUv:Gt&&T(A.displacementMap.channel),emissiveMapUv:st&&T(A.emissiveMap.channel),metalnessMapUv:It&&T(A.metalnessMap.channel),roughnessMapUv:W&&T(A.roughnessMap.channel),anisotropyMapUv:se&&T(A.anisotropyMap.channel),clearcoatMapUv:me&&T(A.clearcoatMap.channel),clearcoatNormalMapUv:Ne&&T(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Oe&&T(A.clearcoatRoughnessMap.channel),iridescenceMapUv:_e&&T(A.iridescenceMap.channel),iridescenceThicknessMapUv:he&&T(A.iridescenceThicknessMap.channel),sheenColorMapUv:Le&&T(A.sheenColorMap.channel),sheenRoughnessMapUv:je&&T(A.sheenRoughnessMap.channel),specularMapUv:ze&&T(A.specularMap.channel),specularColorMapUv:Fe&&T(A.specularColorMap.channel),specularIntensityMapUv:Qe&&T(A.specularIntensityMap.channel),transmissionMapUv:Je&&T(A.transmissionMap.channel),thicknessMapUv:pt&&T(A.thicknessMap.channel),alphaMapUv:Pe&&T(A.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(Ht||z),vertexNormals:!!K.attributes.normal,vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!K.attributes.uv&&(zt||Pe),fog:!!ge,useFog:A.fog===!0,fogExp2:!!ge&&ge.isFogExp2,flatShading:A.wireframe===!1&&(A.flatShading===!0||K.attributes.normal===void 0&&Ht===!1&&(A.isMeshLambertMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isMeshPhysicalMaterial)),sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:S,reversedDepthBuffer:He,skinning:$.isSkinnedMesh===!0,hasPositionAttribute:K.attributes.position!==void 0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:J,morphTextureStride:Ce,numDirLights:L.directional.length,numPointLights:L.point.length,numSpotLights:L.spot.length,numSpotLightMaps:L.spotLightMap.length,numRectAreaLights:L.rectArea.length,numHemiLights:L.hemi.length,numDirLightShadows:L.directionalShadowMap.length,numPointLightShadows:L.pointShadowMap.length,numSpotLightShadows:L.spotShadowMap.length,numSpotLightShadowsWithMaps:L.numSpotLightShadowsWithMaps,numLightProbes:L.numLightProbes,numLightProbeGrids:pe.length,numClippingPlanes:c.numPlanes,numClipIntersection:c.numIntersection,dithering:A.dithering,shadowMapEnabled:a.shadowMap.enabled&&j.length>0,shadowMapType:a.shadowMap.type,toneMapping:q,decodeVideoTexture:zt&&A.map.isVideoTexture===!0&&kt.getTransfer(A.map.colorSpace)===an,decodeVideoTextureEmissive:st&&A.emissiveMap.isVideoTexture===!0&&kt.getTransfer(A.emissiveMap.colorSpace)===an,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===Pa,flipSided:A.side===ui,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:ke&&A.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ke&&A.extensions.multiDraw===!0||Ke)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return Me.vertexUv1s=m.has(1),Me.vertexUv2s=m.has(2),Me.vertexUv3s=m.has(3),m.clear(),Me}function v(A){const L=[];if(A.shaderID?L.push(A.shaderID):(L.push(A.customVertexShaderID),L.push(A.customFragmentShaderID)),A.defines!==void 0)for(const j in A.defines)L.push(j),L.push(A.defines[j]);return A.isRawShaderMaterial===!1&&(x(L,A),B(L,A),L.push(a.outputColorSpace)),L.push(A.customProgramCacheKey),L.join()}function x(A,L){A.push(L.precision),A.push(L.outputColorSpace),A.push(L.envMapMode),A.push(L.envMapCubeUVHeight),A.push(L.mapUv),A.push(L.alphaMapUv),A.push(L.lightMapUv),A.push(L.aoMapUv),A.push(L.bumpMapUv),A.push(L.normalMapUv),A.push(L.displacementMapUv),A.push(L.emissiveMapUv),A.push(L.metalnessMapUv),A.push(L.roughnessMapUv),A.push(L.anisotropyMapUv),A.push(L.clearcoatMapUv),A.push(L.clearcoatNormalMapUv),A.push(L.clearcoatRoughnessMapUv),A.push(L.iridescenceMapUv),A.push(L.iridescenceThicknessMapUv),A.push(L.sheenColorMapUv),A.push(L.sheenRoughnessMapUv),A.push(L.specularMapUv),A.push(L.specularColorMapUv),A.push(L.specularIntensityMapUv),A.push(L.transmissionMapUv),A.push(L.thicknessMapUv),A.push(L.combine),A.push(L.fogExp2),A.push(L.sizeAttenuation),A.push(L.morphTargetsCount),A.push(L.morphAttributeCount),A.push(L.numDirLights),A.push(L.numPointLights),A.push(L.numSpotLights),A.push(L.numSpotLightMaps),A.push(L.numHemiLights),A.push(L.numRectAreaLights),A.push(L.numDirLightShadows),A.push(L.numPointLightShadows),A.push(L.numSpotLightShadows),A.push(L.numSpotLightShadowsWithMaps),A.push(L.numLightProbes),A.push(L.shadowMapType),A.push(L.toneMapping),A.push(L.numClippingPlanes),A.push(L.numClipIntersection),A.push(L.depthPacking)}function B(A,L){f.disableAll(),L.instancing&&f.enable(0),L.instancingColor&&f.enable(1),L.instancingMorph&&f.enable(2),L.matcap&&f.enable(3),L.envMap&&f.enable(4),L.normalMapObjectSpace&&f.enable(5),L.normalMapTangentSpace&&f.enable(6),L.clearcoat&&f.enable(7),L.iridescence&&f.enable(8),L.alphaTest&&f.enable(9),L.vertexColors&&f.enable(10),L.vertexAlphas&&f.enable(11),L.vertexUv1s&&f.enable(12),L.vertexUv2s&&f.enable(13),L.vertexUv3s&&f.enable(14),L.vertexTangents&&f.enable(15),L.anisotropy&&f.enable(16),L.alphaHash&&f.enable(17),L.batching&&f.enable(18),L.dispersion&&f.enable(19),L.batchingColor&&f.enable(20),L.gradientMap&&f.enable(21),L.packedNormalMap&&f.enable(22),L.vertexNormals&&f.enable(23),A.push(f.mask),f.disableAll(),L.fog&&f.enable(0),L.useFog&&f.enable(1),L.flatShading&&f.enable(2),L.logarithmicDepthBuffer&&f.enable(3),L.reversedDepthBuffer&&f.enable(4),L.skinning&&f.enable(5),L.morphTargets&&f.enable(6),L.morphNormals&&f.enable(7),L.morphColors&&f.enable(8),L.premultipliedAlpha&&f.enable(9),L.shadowMapEnabled&&f.enable(10),L.doubleSided&&f.enable(11),L.flipSided&&f.enable(12),L.useDepthPacking&&f.enable(13),L.dithering&&f.enable(14),L.transmission&&f.enable(15),L.sheen&&f.enable(16),L.opaque&&f.enable(17),L.pointsUvs&&f.enable(18),L.decodeVideoTexture&&f.enable(19),L.decodeVideoTextureEmissive&&f.enable(20),L.alphaToCoverage&&f.enable(21),L.numLightProbeGrids>0&&f.enable(22),L.hasPositionAttribute&&f.enable(23),A.push(f.mask)}function P(A){const L=b[A.type];let j;if(L){const V=aa[L];j=mE.clone(V.uniforms)}else j=A.uniforms;return j}function D(A,L){let j=y.get(L);return j!==void 0?++j.usedTimes:(j=new qC(a,L,A,l),h.push(j),y.set(L,j)),j}function O(A){if(--A.usedTimes===0){const L=h.indexOf(A);h[L]=h[h.length-1],h.pop(),y.delete(A.cacheKey),A.destroy()}}function U(A){p.remove(A)}function N(){p.dispose()}return{getParameters:C,getProgramCacheKey:v,getUniforms:P,acquireProgram:D,releaseProgram:O,releaseShaderCache:U,programs:h,dispose:N}}function JC(){let a=new WeakMap;function e(f){return a.has(f)}function i(f){let p=a.get(f);return p===void 0&&(p={},a.set(f,p)),p}function s(f){a.delete(f)}function l(f,p,m){a.get(f)[p]=m}function c(){a=new WeakMap}return{has:e,get:i,remove:s,update:l,dispose:c}}function ew(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 Qv(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 Jv(){const a=[];let e=0;const i=[],s=[],l=[];function c(){e=0,i.length=0,s.length=0,l.length=0}function f(_){let b=0;return _.isInstancedMesh&&(b+=2),_.isSkinnedMesh&&(b+=1),b}function p(_,b,T,C,v,x){let B=a[e];return B===void 0?(B={id:_.id,object:_,geometry:b,material:T,materialVariant:f(_),groupOrder:C,renderOrder:_.renderOrder,z:v,group:x},a[e]=B):(B.id=_.id,B.object=_,B.geometry=b,B.material=T,B.materialVariant=f(_),B.groupOrder=C,B.renderOrder=_.renderOrder,B.z=v,B.group=x),e++,B}function m(_,b,T,C,v,x){const B=p(_,b,T,C,v,x);T.transmission>0?s.push(B):T.transparent===!0?l.push(B):i.push(B)}function h(_,b,T,C,v,x){const B=p(_,b,T,C,v,x);T.transmission>0?s.unshift(B):T.transparent===!0?l.unshift(B):i.unshift(B)}function y(_,b,T){i.length>1&&i.sort(_||ew),s.length>1&&s.sort(b||Qv),l.length>1&&l.sort(b||Qv),T&&(i.reverse(),s.reverse(),l.reverse())}function S(){for(let _=e,b=a.length;_<b;_++){const T=a[_];if(T.id===null)break;T.id=null,T.object=null,T.geometry=null,T.material=null,T.group=null}}return{opaque:i,transmissive:s,transparent:l,init:c,push:m,unshift:h,finish:S,sort:y}}function tw(){let a=new WeakMap;function e(s,l){const c=a.get(s);let f;return c===void 0?(f=new Jv,a.set(s,[f])):l>=c.length?(f=new Jv,c.push(f)):f=c[l],f}function i(){a=new WeakMap}return{get:e,dispose:i}}function nw(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new ie,color:new dt};break;case"SpotLight":i={position:new ie,direction:new ie,color:new dt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new ie,color:new dt,distance:0,decay:0};break;case"HemisphereLight":i={direction:new ie,skyColor:new dt,groundColor:new dt};break;case"RectAreaLight":i={color:new dt,position:new ie,halfWidth:new ie,halfHeight:new ie};break}return a[e.id]=i,i}}}function iw(){const a={};return{get:function(e){if(a[e.id]!==void 0)return a[e.id];let i;switch(e.type){case"DirectionalLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[e.id]=i,i}}}let aw=0;function sw(a,e){return(e.castShadow?2:0)-(a.castShadow?2:0)+(e.map?1:0)-(a.map?1:0)}function rw(a){const e=new nw,i=iw(),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 ie);const l=new ie,c=new dn,f=new dn;function p(h){let y=0,S=0,_=0;for(let L=0;L<9;L++)s.probe[L].set(0,0,0);let b=0,T=0,C=0,v=0,x=0,B=0,P=0,D=0,O=0,U=0,N=0;h.sort(sw);for(let L=0,j=h.length;L<j;L++){const V=h[L],$=V.color,pe=V.intensity,ge=V.distance;let K=null;if(V.shadow&&V.shadow.map&&(V.shadow.map.texture.format===nr?K=V.shadow.map.texture:K=V.shadow.map.depthTexture||V.shadow.map.texture),V.isAmbientLight)y+=$.r*pe,S+=$.g*pe,_+=$.b*pe;else if(V.isLightProbe){for(let H=0;H<9;H++)s.probe[H].addScaledVector(V.sh.coefficients[H],pe);N++}else if(V.isDirectionalLight){const H=e.get(V);if(H.color.copy(V.color).multiplyScalar(V.intensity),V.castShadow){const G=V.shadow,ne=i.get(V);ne.shadowIntensity=G.intensity,ne.shadowBias=G.bias,ne.shadowNormalBias=G.normalBias,ne.shadowRadius=G.radius,ne.shadowMapSize=G.mapSize,s.directionalShadow[b]=ne,s.directionalShadowMap[b]=K,s.directionalShadowMatrix[b]=V.shadow.matrix,B++}s.directional[b]=H,b++}else if(V.isSpotLight){const H=e.get(V);H.position.setFromMatrixPosition(V.matrixWorld),H.color.copy($).multiplyScalar(pe),H.distance=ge,H.coneCos=Math.cos(V.angle),H.penumbraCos=Math.cos(V.angle*(1-V.penumbra)),H.decay=V.decay,s.spot[C]=H;const G=V.shadow;if(V.map&&(s.spotLightMap[O]=V.map,O++,G.updateMatrices(V),V.castShadow&&U++),s.spotLightMatrix[C]=G.matrix,V.castShadow){const ne=i.get(V);ne.shadowIntensity=G.intensity,ne.shadowBias=G.bias,ne.shadowNormalBias=G.normalBias,ne.shadowRadius=G.radius,ne.shadowMapSize=G.mapSize,s.spotShadow[C]=ne,s.spotShadowMap[C]=K,D++}C++}else if(V.isRectAreaLight){const H=e.get(V);H.color.copy($).multiplyScalar(pe),H.halfWidth.set(V.width*.5,0,0),H.halfHeight.set(0,V.height*.5,0),s.rectArea[v]=H,v++}else if(V.isPointLight){const H=e.get(V);if(H.color.copy(V.color).multiplyScalar(V.intensity),H.distance=V.distance,H.decay=V.decay,V.castShadow){const G=V.shadow,ne=i.get(V);ne.shadowIntensity=G.intensity,ne.shadowBias=G.bias,ne.shadowNormalBias=G.normalBias,ne.shadowRadius=G.radius,ne.shadowMapSize=G.mapSize,ne.shadowCameraNear=G.camera.near,ne.shadowCameraFar=G.camera.far,s.pointShadow[T]=ne,s.pointShadowMap[T]=K,s.pointShadowMatrix[T]=V.shadow.matrix,P++}s.point[T]=H,T++}else if(V.isHemisphereLight){const H=e.get(V);H.skyColor.copy(V.color).multiplyScalar(pe),H.groundColor.copy(V.groundColor).multiplyScalar(pe),s.hemi[x]=H,x++}}v>0&&(a.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=We.LTC_FLOAT_1,s.rectAreaLTC2=We.LTC_FLOAT_2):(s.rectAreaLTC1=We.LTC_HALF_1,s.rectAreaLTC2=We.LTC_HALF_2)),s.ambient[0]=y,s.ambient[1]=S,s.ambient[2]=_;const A=s.hash;(A.directionalLength!==b||A.pointLength!==T||A.spotLength!==C||A.rectAreaLength!==v||A.hemiLength!==x||A.numDirectionalShadows!==B||A.numPointShadows!==P||A.numSpotShadows!==D||A.numSpotMaps!==O||A.numLightProbes!==N)&&(s.directional.length=b,s.spot.length=C,s.rectArea.length=v,s.point.length=T,s.hemi.length=x,s.directionalShadow.length=B,s.directionalShadowMap.length=B,s.pointShadow.length=P,s.pointShadowMap.length=P,s.spotShadow.length=D,s.spotShadowMap.length=D,s.directionalShadowMatrix.length=B,s.pointShadowMatrix.length=P,s.spotLightMatrix.length=D+O-U,s.spotLightMap.length=O,s.numSpotLightShadowsWithMaps=U,s.numLightProbes=N,A.directionalLength=b,A.pointLength=T,A.spotLength=C,A.rectAreaLength=v,A.hemiLength=x,A.numDirectionalShadows=B,A.numPointShadows=P,A.numSpotShadows=D,A.numSpotMaps=O,A.numLightProbes=N,s.version=aw++)}function m(h,y){let S=0,_=0,b=0,T=0,C=0;const v=y.matrixWorldInverse;for(let x=0,B=h.length;x<B;x++){const P=h[x];if(P.isDirectionalLight){const D=s.directional[S];D.direction.setFromMatrixPosition(P.matrixWorld),l.setFromMatrixPosition(P.target.matrixWorld),D.direction.sub(l),D.direction.transformDirection(v),S++}else if(P.isSpotLight){const D=s.spot[b];D.position.setFromMatrixPosition(P.matrixWorld),D.position.applyMatrix4(v),D.direction.setFromMatrixPosition(P.matrixWorld),l.setFromMatrixPosition(P.target.matrixWorld),D.direction.sub(l),D.direction.transformDirection(v),b++}else if(P.isRectAreaLight){const D=s.rectArea[T];D.position.setFromMatrixPosition(P.matrixWorld),D.position.applyMatrix4(v),f.identity(),c.copy(P.matrixWorld),c.premultiply(v),f.extractRotation(c),D.halfWidth.set(P.width*.5,0,0),D.halfHeight.set(0,P.height*.5,0),D.halfWidth.applyMatrix4(f),D.halfHeight.applyMatrix4(f),T++}else if(P.isPointLight){const D=s.point[_];D.position.setFromMatrixPosition(P.matrixWorld),D.position.applyMatrix4(v),_++}else if(P.isHemisphereLight){const D=s.hemi[C];D.direction.setFromMatrixPosition(P.matrixWorld),D.direction.transformDirection(v),C++}}}return{setup:p,setupView:m,state:s}}function ex(a){const e=new rw(a),i=[],s=[],l=[];function c(_){S.camera=_,i.length=0,s.length=0,l.length=0}function f(_){i.push(_)}function p(_){s.push(_)}function m(_){l.push(_)}function h(){e.setup(i)}function y(_){e.setupView(i,_)}const S={lightsArray:i,shadowsArray:s,lightProbeGridArray:l,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:c,state:S,setupLights:h,setupLightsView:y,pushLight:f,pushShadow:p,pushLightProbeGrid:m}}function ow(a){let e=new WeakMap;function i(l,c=0){const f=e.get(l);let p;return f===void 0?(p=new ex(a),e.set(l,[p])):c>=f.length?(p=new ex(a),f.push(p)):p=f[c],p}function s(){e=new WeakMap}return{get:i,dispose:s}}const lw=`void main() {
|
||
gl_Position = vec4( position, 1.0 );
|
||
}`,cw=`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 );
|
||
}`,uw=[new ie(1,0,0),new ie(-1,0,0),new ie(0,1,0),new ie(0,-1,0),new ie(0,0,1),new ie(0,0,-1)],fw=[new ie(0,-1,0),new ie(0,-1,0),new ie(0,0,1),new ie(0,0,-1),new ie(0,-1,0),new ie(0,-1,0)],tx=new dn,_l=new ie,wh=new ie;function dw(a,e,i){let s=new jp;const l=new bt,c=new bt,f=new xn,p=new yE,m=new SE,h={},y=i.maxTextureSize,S={[Es]:ui,[ui]:Es,[Pa]:Pa},_=new ca({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bt},radius:{value:4}},vertexShader:lw,fragmentShader:cw}),b=_.clone();b.defines.HORIZONTAL_PASS=1;const T=new Fi;T.setAttribute("position",new Zi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const C=new Ki(T,_),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=gu;let x=this.type;this.render=function(U,N,A){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||U.length===0)return;this.type===Ex&&(_t("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=gu);const L=a.getRenderTarget(),j=a.getActiveCubeFace(),V=a.getActiveMipmapLevel(),$=a.state;$.setBlending(Ba),$.buffers.depth.getReversed()===!0?$.buffers.color.setClear(0,0,0,0):$.buffers.color.setClear(1,1,1,1),$.buffers.depth.setTest(!0),$.setScissorTest(!1);const pe=x!==this.type;pe&&N.traverse(function(ge){ge.material&&(Array.isArray(ge.material)?ge.material.forEach(K=>K.needsUpdate=!0):ge.material.needsUpdate=!0)});for(let ge=0,K=U.length;ge<K;ge++){const H=U[ge],G=H.shadow;if(G===void 0){_t("WebGLShadowMap:",H,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;l.copy(G.mapSize);const ne=G.getFrameExtents();l.multiply(ne),c.copy(G.mapSize),(l.x>y||l.y>y)&&(l.x>y&&(c.x=Math.floor(y/ne.x),l.x=c.x*ne.x,G.mapSize.x=c.x),l.y>y&&(c.y=Math.floor(y/ne.y),l.y=c.y*ne.y,G.mapSize.y=c.y));const ye=a.state.buffers.depth.getReversed();if(G.camera._reversedDepth=ye,G.map===null||pe===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===vl){if(H.isPointLight){_t("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new oa(l.x,l.y,{format:nr,type:za,minFilter:$n,magFilter:$n,generateMipmaps:!1}),G.map.texture.name=H.name+".shadowMap",G.map.depthTexture=new fo(l.x,l.y,qi),G.map.depthTexture.name=H.name+".shadowMapDepth",G.map.depthTexture.format=Ha,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Wn,G.map.depthTexture.magFilter=Wn}else H.isPointLight?(G.map=new ey(l.x),G.map.depthTexture=new dE(l.x,la)):(G.map=new oa(l.x,l.y),G.map.depthTexture=new fo(l.x,l.y,la)),G.map.depthTexture.name=H.name+".shadowMap",G.map.depthTexture.format=Ha,this.type===gu?(G.map.depthTexture.compareFunction=ye?Gp:Hp,G.map.depthTexture.minFilter=$n,G.map.depthTexture.magFilter=$n):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Wn,G.map.depthTexture.magFilter=Wn);G.camera.updateProjectionMatrix()}const xe=G.map.isWebGLCubeRenderTarget?6:1;for(let F=0;F<xe;F++){if(G.map.isWebGLCubeRenderTarget)a.setRenderTarget(G.map,F),a.clear();else{F===0&&(a.setRenderTarget(G.map),a.clear());const J=G.getViewport(F);f.set(c.x*J.x,c.y*J.y,c.x*J.z,c.y*J.w),$.viewport(f)}if(H.isPointLight){const J=G.camera,Ce=G.matrix,Ue=H.distance||J.far;Ue!==J.far&&(J.far=Ue,J.updateProjectionMatrix()),_l.setFromMatrixPosition(H.matrixWorld),J.position.copy(_l),wh.copy(J.position),wh.add(uw[F]),J.up.copy(fw[F]),J.lookAt(wh),J.updateMatrixWorld(),Ce.makeTranslation(-_l.x,-_l.y,-_l.z),tx.multiplyMatrices(J.projectionMatrix,J.matrixWorldInverse),G._frustum.setFromProjectionMatrix(tx,J.coordinateSystem,J.reversedDepth)}else G.updateMatrices(H);s=G.getFrustum(),D(N,A,G.camera,H,this.type)}G.isPointLightShadow!==!0&&this.type===vl&&B(G,A),G.needsUpdate=!1}x=this.type,v.needsUpdate=!1,a.setRenderTarget(L,j,V)};function B(U,N){const A=e.update(C);_.defines.VSM_SAMPLES!==U.blurSamples&&(_.defines.VSM_SAMPLES=U.blurSamples,b.defines.VSM_SAMPLES=U.blurSamples,_.needsUpdate=!0,b.needsUpdate=!0),U.mapPass===null&&(U.mapPass=new oa(l.x,l.y,{format:nr,type:za})),_.uniforms.shadow_pass.value=U.map.depthTexture,_.uniforms.resolution.value=U.mapSize,_.uniforms.radius.value=U.radius,a.setRenderTarget(U.mapPass),a.clear(),a.renderBufferDirect(N,null,A,_,C,null),b.uniforms.shadow_pass.value=U.mapPass.texture,b.uniforms.resolution.value=U.mapSize,b.uniforms.radius.value=U.radius,a.setRenderTarget(U.map),a.clear(),a.renderBufferDirect(N,null,A,b,C,null)}function P(U,N,A,L){let j=null;const V=A.isPointLight===!0?U.customDistanceMaterial:U.customDepthMaterial;if(V!==void 0)j=V;else if(j=A.isPointLight===!0?m:p,a.localClippingEnabled&&N.clipShadows===!0&&Array.isArray(N.clippingPlanes)&&N.clippingPlanes.length!==0||N.displacementMap&&N.displacementScale!==0||N.alphaMap&&N.alphaTest>0||N.map&&N.alphaTest>0||N.alphaToCoverage===!0){const $=j.uuid,pe=N.uuid;let ge=h[$];ge===void 0&&(ge={},h[$]=ge);let K=ge[pe];K===void 0&&(K=j.clone(),ge[pe]=K,N.addEventListener("dispose",O)),j=K}if(j.visible=N.visible,j.wireframe=N.wireframe,L===vl?j.side=N.shadowSide!==null?N.shadowSide:N.side:j.side=N.shadowSide!==null?N.shadowSide:S[N.side],j.alphaMap=N.alphaMap,j.alphaTest=N.alphaToCoverage===!0?.5:N.alphaTest,j.map=N.map,j.clipShadows=N.clipShadows,j.clippingPlanes=N.clippingPlanes,j.clipIntersection=N.clipIntersection,j.displacementMap=N.displacementMap,j.displacementScale=N.displacementScale,j.displacementBias=N.displacementBias,j.wireframeLinewidth=N.wireframeLinewidth,j.linewidth=N.linewidth,A.isPointLight===!0&&j.isMeshDistanceMaterial===!0){const $=a.properties.get(j);$.light=A}return j}function D(U,N,A,L,j){if(U.visible===!1)return;if(U.layers.test(N.layers)&&(U.isMesh||U.isLine||U.isPoints)&&(U.castShadow||U.receiveShadow&&j===vl)&&(!U.frustumCulled||s.intersectsObject(U))){U.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,U.matrixWorld);const pe=e.update(U),ge=U.material;if(Array.isArray(ge)){const K=pe.groups;for(let H=0,G=K.length;H<G;H++){const ne=K[H],ye=ge[ne.materialIndex];if(ye&&ye.visible){const xe=P(U,ye,L,j);U.onBeforeShadow(a,U,N,A,pe,xe,ne),a.renderBufferDirect(A,null,pe,xe,U,ne),U.onAfterShadow(a,U,N,A,pe,xe,ne)}}}else if(ge.visible){const K=P(U,ge,L,j);U.onBeforeShadow(a,U,N,A,pe,K,null),a.renderBufferDirect(A,null,pe,K,U,null),U.onAfterShadow(a,U,N,A,pe,K,null)}}const $=U.children;for(let pe=0,ge=$.length;pe<ge;pe++)D($[pe],N,A,L,j)}function O(U){U.target.removeEventListener("dispose",O);for(const A in h){const L=h[A],j=U.target.uuid;j in L&&(L[j].dispose(),delete L[j])}}}function hw(a,e){function i(){let Z=!1;const Pe=new xn;let Se=null;const Be=new xn(0,0,0,0);return{setMask:function(ke){Se!==ke&&!Z&&(a.colorMask(ke,ke,ke,ke),Se=ke)},setLocked:function(ke){Z=ke},setClear:function(ke,q,Me,De,ft){ft===!0&&(ke*=De,q*=De,Me*=De),Pe.set(ke,q,Me,De),Be.equals(Pe)===!1&&(a.clearColor(ke,q,Me,De),Be.copy(Pe))},reset:function(){Z=!1,Se=null,Be.set(-1,0,0,0)}}}function s(){let Z=!1,Pe=!1,Se=null,Be=null,ke=null;return{setReversed:function(q){if(Pe!==q){const Me=e.get("EXT_clip_control");q?Me.clipControlEXT(Me.LOWER_LEFT_EXT,Me.ZERO_TO_ONE_EXT):Me.clipControlEXT(Me.LOWER_LEFT_EXT,Me.NEGATIVE_ONE_TO_ONE_EXT),Pe=q;const De=ke;ke=null,this.setClear(De)}},getReversed:function(){return Pe},setTest:function(q){q?Ee(a.DEPTH_TEST):He(a.DEPTH_TEST)},setMask:function(q){Se!==q&&!Z&&(a.depthMask(q),Se=q)},setFunc:function(q){if(Pe&&(q=Fb[q]),Be!==q){switch(q){case Ph:a.depthFunc(a.NEVER);break;case Ih:a.depthFunc(a.ALWAYS);break;case Bh:a.depthFunc(a.LESS);break;case co:a.depthFunc(a.LEQUAL);break;case Fh:a.depthFunc(a.EQUAL);break;case zh:a.depthFunc(a.GEQUAL);break;case Hh:a.depthFunc(a.GREATER);break;case Gh:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}Be=q}},setLocked:function(q){Z=q},setClear:function(q){ke!==q&&(ke=q,Pe&&(q=1-q),a.clearDepth(q))},reset:function(){Z=!1,Se=null,Be=null,ke=null,Pe=!1}}}function l(){let Z=!1,Pe=null,Se=null,Be=null,ke=null,q=null,Me=null,De=null,ft=null;return{setTest:function(rt){Z||(rt?Ee(a.STENCIL_TEST):He(a.STENCIL_TEST))},setMask:function(rt){Pe!==rt&&!Z&&(a.stencilMask(rt),Pe=rt)},setFunc:function(rt,Nt,Hn){(Se!==rt||Be!==Nt||ke!==Hn)&&(a.stencilFunc(rt,Nt,Hn),Se=rt,Be=Nt,ke=Hn)},setOp:function(rt,Nt,Hn){(q!==rt||Me!==Nt||De!==Hn)&&(a.stencilOp(rt,Nt,Hn),q=rt,Me=Nt,De=Hn)},setLocked:function(rt){Z=rt},setClear:function(rt){ft!==rt&&(a.clearStencil(rt),ft=rt)},reset:function(){Z=!1,Pe=null,Se=null,Be=null,ke=null,q=null,Me=null,De=null,ft=null}}}const c=new i,f=new s,p=new l,m=new WeakMap,h=new WeakMap;let y={},S={},_={},b=new WeakMap,T=[],C=null,v=!1,x=null,B=null,P=null,D=null,O=null,U=null,N=null,A=new dt(0,0,0),L=0,j=!1,V=null,$=null,pe=null,ge=null,K=null;const H=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,ne=0;const ye=a.getParameter(a.VERSION);ye.indexOf("WebGL")!==-1?(ne=parseFloat(/^WebGL (\d)/.exec(ye)[1]),G=ne>=1):ye.indexOf("OpenGL ES")!==-1&&(ne=parseFloat(/^OpenGL ES (\d)/.exec(ye)[1]),G=ne>=2);let xe=null,F={};const J=a.getParameter(a.SCISSOR_BOX),Ce=a.getParameter(a.VIEWPORT),Ue=new xn().fromArray(J),Ie=new xn().fromArray(Ce);function ae(Z,Pe,Se,Be){const ke=new Uint8Array(4),q=a.createTexture();a.bindTexture(Z,q),a.texParameteri(Z,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(Z,a.TEXTURE_MAG_FILTER,a.NEAREST);for(let Me=0;Me<Se;Me++)Z===a.TEXTURE_3D||Z===a.TEXTURE_2D_ARRAY?a.texImage3D(Pe,0,a.RGBA,1,1,Be,0,a.RGBA,a.UNSIGNED_BYTE,ke):a.texImage2D(Pe+Me,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,ke);return q}const Ae={};Ae[a.TEXTURE_2D]=ae(a.TEXTURE_2D,a.TEXTURE_2D,1),Ae[a.TEXTURE_CUBE_MAP]=ae(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6),Ae[a.TEXTURE_2D_ARRAY]=ae(a.TEXTURE_2D_ARRAY,a.TEXTURE_2D_ARRAY,1,1),Ae[a.TEXTURE_3D]=ae(a.TEXTURE_3D,a.TEXTURE_3D,1,1),c.setClear(0,0,0,1),f.setClear(1),p.setClear(0),Ee(a.DEPTH_TEST),f.setFunc(co),Mt(!1),Ht(Y_),Ee(a.CULL_FACE),yt(Ba);function Ee(Z){y[Z]!==!0&&(a.enable(Z),y[Z]=!0)}function He(Z){y[Z]!==!1&&(a.disable(Z),y[Z]=!1)}function nt(Z,Pe){return _[Z]!==Pe?(a.bindFramebuffer(Z,Pe),_[Z]=Pe,Z===a.DRAW_FRAMEBUFFER&&(_[a.FRAMEBUFFER]=Pe),Z===a.FRAMEBUFFER&&(_[a.DRAW_FRAMEBUFFER]=Pe),!0):!1}function Ke(Z,Pe){let Se=T,Be=!1;if(Z){Se=b.get(Pe),Se===void 0&&(Se=[],b.set(Pe,Se));const ke=Z.textures;if(Se.length!==ke.length||Se[0]!==a.COLOR_ATTACHMENT0){for(let q=0,Me=ke.length;q<Me;q++)Se[q]=a.COLOR_ATTACHMENT0+q;Se.length=ke.length,Be=!0}}else Se[0]!==a.BACK&&(Se[0]=a.BACK,Be=!0);Be&&a.drawBuffers(Se)}function zt(Z){return C!==Z?(a.useProgram(Z),C=Z,!0):!1}const ht={[Ks]:a.FUNC_ADD,[rb]:a.FUNC_SUBTRACT,[ob]:a.FUNC_REVERSE_SUBTRACT};ht[lb]=a.MIN,ht[cb]=a.MAX;const Et={[ub]:a.ZERO,[fb]:a.ONE,[db]:a.SRC_COLOR,[Lh]:a.SRC_ALPHA,[vb]:a.SRC_ALPHA_SATURATE,[gb]:a.DST_COLOR,[pb]:a.DST_ALPHA,[hb]:a.ONE_MINUS_SRC_COLOR,[Oh]:a.ONE_MINUS_SRC_ALPHA,[_b]:a.ONE_MINUS_DST_COLOR,[mb]:a.ONE_MINUS_DST_ALPHA,[xb]:a.CONSTANT_COLOR,[yb]:a.ONE_MINUS_CONSTANT_COLOR,[Sb]:a.CONSTANT_ALPHA,[Mb]:a.ONE_MINUS_CONSTANT_ALPHA};function yt(Z,Pe,Se,Be,ke,q,Me,De,ft,rt){if(Z===Ba){v===!0&&(He(a.BLEND),v=!1);return}if(v===!1&&(Ee(a.BLEND),v=!0),Z!==sb){if(Z!==x||rt!==j){if((B!==Ks||O!==Ks)&&(a.blendEquation(a.FUNC_ADD),B=Ks,O=Ks),rt)switch(Z){case io:a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Z_:a.blendFunc(a.ONE,a.ONE);break;case K_:a.blendFuncSeparate(a.ZERO,a.ONE_MINUS_SRC_COLOR,a.ZERO,a.ONE);break;case $_:a.blendFuncSeparate(a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA,a.ZERO,a.ONE);break;default:jt("WebGLState: Invalid blending: ",Z);break}else switch(Z){case io:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Z_:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE,a.ONE,a.ONE);break;case K_:jt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $_:jt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:jt("WebGLState: Invalid blending: ",Z);break}P=null,D=null,U=null,N=null,A.set(0,0,0),L=0,x=Z,j=rt}return}ke=ke||Pe,q=q||Se,Me=Me||Be,(Pe!==B||ke!==O)&&(a.blendEquationSeparate(ht[Pe],ht[ke]),B=Pe,O=ke),(Se!==P||Be!==D||q!==U||Me!==N)&&(a.blendFuncSeparate(Et[Se],Et[Be],Et[q],Et[Me]),P=Se,D=Be,U=q,N=Me),(De.equals(A)===!1||ft!==L)&&(a.blendColor(De.r,De.g,De.b,ft),A.copy(De),L=ft),x=Z,j=!1}function St(Z,Pe){Z.side===Pa?He(a.CULL_FACE):Ee(a.CULL_FACE);let Se=Z.side===ui;Pe&&(Se=!Se),Mt(Se),Z.blending===io&&Z.transparent===!1?yt(Ba):yt(Z.blending,Z.blendEquation,Z.blendSrc,Z.blendDst,Z.blendEquationAlpha,Z.blendSrcAlpha,Z.blendDstAlpha,Z.blendColor,Z.blendAlpha,Z.premultipliedAlpha),f.setFunc(Z.depthFunc),f.setTest(Z.depthTest),f.setMask(Z.depthWrite),c.setMask(Z.colorWrite);const Be=Z.stencilWrite;p.setTest(Be),Be&&(p.setMask(Z.stencilWriteMask),p.setFunc(Z.stencilFunc,Z.stencilRef,Z.stencilFuncMask),p.setOp(Z.stencilFail,Z.stencilZFail,Z.stencilZPass)),st(Z.polygonOffset,Z.polygonOffsetFactor,Z.polygonOffsetUnits),Z.alphaToCoverage===!0?Ee(a.SAMPLE_ALPHA_TO_COVERAGE):He(a.SAMPLE_ALPHA_TO_COVERAGE)}function Mt(Z){V!==Z&&(Z?a.frontFace(a.CW):a.frontFace(a.CCW),V=Z)}function Ht(Z){Z!==ib?(Ee(a.CULL_FACE),Z!==$&&(Z===Y_?a.cullFace(a.BACK):Z===ab?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):He(a.CULL_FACE),$=Z}function Gt(Z){Z!==pe&&(G&&a.lineWidth(Z),pe=Z)}function st(Z,Pe,Se){Z?(Ee(a.POLYGON_OFFSET_FILL),(ge!==Pe||K!==Se)&&(ge=Pe,K=Se,f.getReversed()&&(Pe=-Pe),a.polygonOffset(Pe,Se))):He(a.POLYGON_OFFSET_FILL)}function It(Z){Z?Ee(a.SCISSOR_TEST):He(a.SCISSOR_TEST)}function W(Z){Z===void 0&&(Z=a.TEXTURE0+H-1),xe!==Z&&(a.activeTexture(Z),xe=Z)}function z(Z,Pe,Se){Se===void 0&&(xe===null?Se=a.TEXTURE0+H-1:Se=xe);let Be=F[Se];Be===void 0&&(Be={type:void 0,texture:void 0},F[Se]=Be),(Be.type!==Z||Be.texture!==Pe)&&(xe!==Se&&(a.activeTexture(Se),xe=Se),a.bindTexture(Z,Pe||Ae[Z]),Be.type=Z,Be.texture=Pe)}function Ye(){const Z=F[xe];Z!==void 0&&Z.type!==void 0&&(a.bindTexture(Z.type,null),Z.type=void 0,Z.texture=void 0)}function xt(){try{a.compressedTexImage2D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function I(){try{a.compressedTexImage3D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function E(){try{a.texSubImage2D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function X(){try{a.texSubImage3D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function se(){try{a.compressedTexSubImage2D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function me(){try{a.compressedTexSubImage3D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function Ne(){try{a.texStorage2D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function Oe(){try{a.texStorage3D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function _e(){try{a.texImage2D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function he(){try{a.texImage3D(...arguments)}catch(Z){jt("WebGLState:",Z)}}function Le(Z){return S[Z]!==void 0?S[Z]:a.getParameter(Z)}function je(Z,Pe){S[Z]!==Pe&&(a.pixelStorei(Z,Pe),S[Z]=Pe)}function ze(Z){Ue.equals(Z)===!1&&(a.scissor(Z.x,Z.y,Z.z,Z.w),Ue.copy(Z))}function Fe(Z){Ie.equals(Z)===!1&&(a.viewport(Z.x,Z.y,Z.z,Z.w),Ie.copy(Z))}function Qe(Z,Pe){let Se=h.get(Pe);Se===void 0&&(Se=new WeakMap,h.set(Pe,Se));let Be=Se.get(Z);Be===void 0&&(Be=a.getUniformBlockIndex(Pe,Z.name),Se.set(Z,Be))}function Je(Z,Pe){const Be=h.get(Pe).get(Z);m.get(Pe)!==Be&&(a.uniformBlockBinding(Pe,Be,Z.__bindingPointIndex),m.set(Pe,Be))}function pt(){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),f.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),y={},S={},xe=null,F={},_={},b=new WeakMap,T=[],C=null,v=!1,x=null,B=null,P=null,D=null,O=null,U=null,N=null,A=new dt(0,0,0),L=0,j=!1,V=null,$=null,pe=null,ge=null,K=null,Ue.set(0,0,a.canvas.width,a.canvas.height),Ie.set(0,0,a.canvas.width,a.canvas.height),c.reset(),f.reset(),p.reset()}return{buffers:{color:c,depth:f,stencil:p},enable:Ee,disable:He,bindFramebuffer:nt,drawBuffers:Ke,useProgram:zt,setBlending:yt,setMaterial:St,setFlipSided:Mt,setCullFace:Ht,setLineWidth:Gt,setPolygonOffset:st,setScissorTest:It,activeTexture:W,bindTexture:z,unbindTexture:Ye,compressedTexImage2D:xt,compressedTexImage3D:I,texImage2D:_e,texImage3D:he,pixelStorei:je,getParameter:Le,updateUBOMapping:Qe,uniformBlockBinding:Je,texStorage2D:Ne,texStorage3D:Oe,texSubImage2D:E,texSubImage3D:X,compressedTexSubImage2D:se,compressedTexSubImage3D:me,scissor:ze,viewport:Fe,reset:pt}}function pw(a,e,i,s,l,c,f){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,y=new WeakMap,S=new Set;let _;const b=new WeakMap;let T=!1;try{T=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function C(I,E){return T?new OffscreenCanvas(I,E):Cu("canvas")}function v(I,E,X){let se=1;const me=xt(I);if((me.width>X||me.height>X)&&(se=X/Math.max(me.width,me.height)),se<1)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap||typeof VideoFrame<"u"&&I instanceof VideoFrame){const Ne=Math.floor(se*me.width),Oe=Math.floor(se*me.height);_===void 0&&(_=C(Ne,Oe));const _e=E?C(Ne,Oe):_;return _e.width=Ne,_e.height=Oe,_e.getContext("2d").drawImage(I,0,0,Ne,Oe),_t("WebGLRenderer: Texture has been resized from ("+me.width+"x"+me.height+") to ("+Ne+"x"+Oe+")."),_e}else return"data"in I&&_t("WebGLRenderer: Image in DataTexture is too big ("+me.width+"x"+me.height+")."),I;return I}function x(I){return I.generateMipmaps}function B(I){a.generateMipmap(I)}function P(I){return I.isWebGLCubeRenderTarget?a.TEXTURE_CUBE_MAP:I.isWebGL3DRenderTarget?a.TEXTURE_3D:I.isWebGLArrayRenderTarget||I.isCompressedArrayTexture?a.TEXTURE_2D_ARRAY:a.TEXTURE_2D}function D(I,E,X,se,me,Ne=!1){if(I!==null){if(a[I]!==void 0)return a[I];_t("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let Oe;se&&(Oe=e.get("EXT_texture_norm16"),Oe||_t("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let _e=E;if(E===a.RED&&(X===a.FLOAT&&(_e=a.R32F),X===a.HALF_FLOAT&&(_e=a.R16F),X===a.UNSIGNED_BYTE&&(_e=a.R8),X===a.UNSIGNED_SHORT&&Oe&&(_e=Oe.R16_EXT),X===a.SHORT&&Oe&&(_e=Oe.R16_SNORM_EXT)),E===a.RED_INTEGER&&(X===a.UNSIGNED_BYTE&&(_e=a.R8UI),X===a.UNSIGNED_SHORT&&(_e=a.R16UI),X===a.UNSIGNED_INT&&(_e=a.R32UI),X===a.BYTE&&(_e=a.R8I),X===a.SHORT&&(_e=a.R16I),X===a.INT&&(_e=a.R32I)),E===a.RG&&(X===a.FLOAT&&(_e=a.RG32F),X===a.HALF_FLOAT&&(_e=a.RG16F),X===a.UNSIGNED_BYTE&&(_e=a.RG8),X===a.UNSIGNED_SHORT&&Oe&&(_e=Oe.RG16_EXT),X===a.SHORT&&Oe&&(_e=Oe.RG16_SNORM_EXT)),E===a.RG_INTEGER&&(X===a.UNSIGNED_BYTE&&(_e=a.RG8UI),X===a.UNSIGNED_SHORT&&(_e=a.RG16UI),X===a.UNSIGNED_INT&&(_e=a.RG32UI),X===a.BYTE&&(_e=a.RG8I),X===a.SHORT&&(_e=a.RG16I),X===a.INT&&(_e=a.RG32I)),E===a.RGB_INTEGER&&(X===a.UNSIGNED_BYTE&&(_e=a.RGB8UI),X===a.UNSIGNED_SHORT&&(_e=a.RGB16UI),X===a.UNSIGNED_INT&&(_e=a.RGB32UI),X===a.BYTE&&(_e=a.RGB8I),X===a.SHORT&&(_e=a.RGB16I),X===a.INT&&(_e=a.RGB32I)),E===a.RGBA_INTEGER&&(X===a.UNSIGNED_BYTE&&(_e=a.RGBA8UI),X===a.UNSIGNED_SHORT&&(_e=a.RGBA16UI),X===a.UNSIGNED_INT&&(_e=a.RGBA32UI),X===a.BYTE&&(_e=a.RGBA8I),X===a.SHORT&&(_e=a.RGBA16I),X===a.INT&&(_e=a.RGBA32I)),E===a.RGB&&(X===a.UNSIGNED_SHORT&&Oe&&(_e=Oe.RGB16_EXT),X===a.SHORT&&Oe&&(_e=Oe.RGB16_SNORM_EXT),X===a.UNSIGNED_INT_5_9_9_9_REV&&(_e=a.RGB9_E5),X===a.UNSIGNED_INT_10F_11F_11F_REV&&(_e=a.R11F_G11F_B10F)),E===a.RGBA){const he=Ne?Au:kt.getTransfer(me);X===a.FLOAT&&(_e=a.RGBA32F),X===a.HALF_FLOAT&&(_e=a.RGBA16F),X===a.UNSIGNED_BYTE&&(_e=he===an?a.SRGB8_ALPHA8:a.RGBA8),X===a.UNSIGNED_SHORT&&Oe&&(_e=Oe.RGBA16_EXT),X===a.SHORT&&Oe&&(_e=Oe.RGBA16_SNORM_EXT),X===a.UNSIGNED_SHORT_4_4_4_4&&(_e=a.RGBA4),X===a.UNSIGNED_SHORT_5_5_5_1&&(_e=a.RGB5_A1)}return(_e===a.R16F||_e===a.R32F||_e===a.RG16F||_e===a.RG32F||_e===a.RGBA16F||_e===a.RGBA32F)&&e.get("EXT_color_buffer_float"),_e}function O(I,E){let X;return I?E===null||E===la||E===Al?X=a.DEPTH24_STENCIL8:E===qi?X=a.DEPTH32F_STENCIL8:E===Tl&&(X=a.DEPTH24_STENCIL8,_t("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):E===null||E===la||E===Al?X=a.DEPTH_COMPONENT24:E===qi?X=a.DEPTH_COMPONENT32F:E===Tl&&(X=a.DEPTH_COMPONENT16),X}function U(I,E){return x(I)===!0||I.isFramebufferTexture&&I.minFilter!==Wn&&I.minFilter!==$n?Math.log2(Math.max(E.width,E.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?E.mipmaps.length:1}function N(I){const E=I.target;E.removeEventListener("dispose",N),L(E),E.isVideoTexture&&y.delete(E),E.isHTMLTexture&&S.delete(E)}function A(I){const E=I.target;E.removeEventListener("dispose",A),V(E)}function L(I){const E=s.get(I);if(E.__webglInit===void 0)return;const X=I.source,se=b.get(X);if(se){const me=se[E.__cacheKey];me.usedTimes--,me.usedTimes===0&&j(I),Object.keys(se).length===0&&b.delete(X)}s.remove(I)}function j(I){const E=s.get(I);a.deleteTexture(E.__webglTexture);const X=I.source,se=b.get(X);delete se[E.__cacheKey],f.memory.textures--}function V(I){const E=s.get(I);if(I.depthTexture&&(I.depthTexture.dispose(),s.remove(I.depthTexture)),I.isWebGLCubeRenderTarget)for(let se=0;se<6;se++){if(Array.isArray(E.__webglFramebuffer[se]))for(let me=0;me<E.__webglFramebuffer[se].length;me++)a.deleteFramebuffer(E.__webglFramebuffer[se][me]);else a.deleteFramebuffer(E.__webglFramebuffer[se]);E.__webglDepthbuffer&&a.deleteRenderbuffer(E.__webglDepthbuffer[se])}else{if(Array.isArray(E.__webglFramebuffer))for(let se=0;se<E.__webglFramebuffer.length;se++)a.deleteFramebuffer(E.__webglFramebuffer[se]);else a.deleteFramebuffer(E.__webglFramebuffer);if(E.__webglDepthbuffer&&a.deleteRenderbuffer(E.__webglDepthbuffer),E.__webglMultisampledFramebuffer&&a.deleteFramebuffer(E.__webglMultisampledFramebuffer),E.__webglColorRenderbuffer)for(let se=0;se<E.__webglColorRenderbuffer.length;se++)E.__webglColorRenderbuffer[se]&&a.deleteRenderbuffer(E.__webglColorRenderbuffer[se]);E.__webglDepthRenderbuffer&&a.deleteRenderbuffer(E.__webglDepthRenderbuffer)}const X=I.textures;for(let se=0,me=X.length;se<me;se++){const Ne=s.get(X[se]);Ne.__webglTexture&&(a.deleteTexture(Ne.__webglTexture),f.memory.textures--),s.remove(X[se])}s.remove(I)}let $=0;function pe(){$=0}function ge(){return $}function K(I){$=I}function H(){const I=$;return I>=l.maxTextures&&_t("WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+l.maxTextures),$+=1,I}function G(I){const E=[];return E.push(I.wrapS),E.push(I.wrapT),E.push(I.wrapR||0),E.push(I.magFilter),E.push(I.minFilter),E.push(I.anisotropy),E.push(I.internalFormat),E.push(I.format),E.push(I.type),E.push(I.generateMipmaps),E.push(I.premultiplyAlpha),E.push(I.flipY),E.push(I.unpackAlignment),E.push(I.colorSpace),E.join()}function ne(I,E){const X=s.get(I);if(I.isVideoTexture&&z(I),I.isRenderTargetTexture===!1&&I.isExternalTexture!==!0&&I.version>0&&X.__version!==I.version){const se=I.image;if(se===null)_t("WebGLRenderer: Texture marked for update but no image data found.");else if(se.complete===!1)_t("WebGLRenderer: Texture marked for update but image is incomplete");else{He(X,I,E);return}}else I.isExternalTexture&&(X.__webglTexture=I.sourceTexture?I.sourceTexture:null);i.bindTexture(a.TEXTURE_2D,X.__webglTexture,a.TEXTURE0+E)}function ye(I,E){const X=s.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&X.__version!==I.version){He(X,I,E);return}else I.isExternalTexture&&(X.__webglTexture=I.sourceTexture?I.sourceTexture:null);i.bindTexture(a.TEXTURE_2D_ARRAY,X.__webglTexture,a.TEXTURE0+E)}function xe(I,E){const X=s.get(I);if(I.isRenderTargetTexture===!1&&I.version>0&&X.__version!==I.version){He(X,I,E);return}i.bindTexture(a.TEXTURE_3D,X.__webglTexture,a.TEXTURE0+E)}function F(I,E){const X=s.get(I);if(I.isCubeDepthTexture!==!0&&I.version>0&&X.__version!==I.version){nt(X,I,E);return}i.bindTexture(a.TEXTURE_CUBE_MAP,X.__webglTexture,a.TEXTURE0+E)}const J={[Vh]:a.REPEAT,[Ia]:a.CLAMP_TO_EDGE,[kh]:a.MIRRORED_REPEAT},Ce={[Wn]:a.NEAREST,[Tb]:a.NEAREST_MIPMAP_NEAREST,[Hc]:a.NEAREST_MIPMAP_LINEAR,[$n]:a.LINEAR,[Kd]:a.LINEAR_MIPMAP_NEAREST,[Qs]:a.LINEAR_MIPMAP_LINEAR},Ue={[wb]:a.NEVER,[Lb]:a.ALWAYS,[Rb]:a.LESS,[Hp]:a.LEQUAL,[Db]:a.EQUAL,[Gp]:a.GEQUAL,[Nb]:a.GREATER,[Ub]:a.NOTEQUAL};function Ie(I,E){if(E.type===qi&&e.has("OES_texture_float_linear")===!1&&(E.magFilter===$n||E.magFilter===Kd||E.magFilter===Hc||E.magFilter===Qs||E.minFilter===$n||E.minFilter===Kd||E.minFilter===Hc||E.minFilter===Qs)&&_t("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),a.texParameteri(I,a.TEXTURE_WRAP_S,J[E.wrapS]),a.texParameteri(I,a.TEXTURE_WRAP_T,J[E.wrapT]),(I===a.TEXTURE_3D||I===a.TEXTURE_2D_ARRAY)&&a.texParameteri(I,a.TEXTURE_WRAP_R,J[E.wrapR]),a.texParameteri(I,a.TEXTURE_MAG_FILTER,Ce[E.magFilter]),a.texParameteri(I,a.TEXTURE_MIN_FILTER,Ce[E.minFilter]),E.compareFunction&&(a.texParameteri(I,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(I,a.TEXTURE_COMPARE_FUNC,Ue[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(E.magFilter===Wn||E.minFilter!==Hc&&E.minFilter!==Qs||E.type===qi&&e.has("OES_texture_float_linear")===!1)return;if(E.anisotropy>1||s.get(E).__currentAnisotropy){const X=e.get("EXT_texture_filter_anisotropic");a.texParameterf(I,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,l.getMaxAnisotropy())),s.get(E).__currentAnisotropy=E.anisotropy}}}function ae(I,E){let X=!1;I.__webglInit===void 0&&(I.__webglInit=!0,E.addEventListener("dispose",N));const se=E.source;let me=b.get(se);me===void 0&&(me={},b.set(se,me));const Ne=G(E);if(Ne!==I.__cacheKey){me[Ne]===void 0&&(me[Ne]={texture:a.createTexture(),usedTimes:0},f.memory.textures++,X=!0),me[Ne].usedTimes++;const Oe=me[I.__cacheKey];Oe!==void 0&&(me[I.__cacheKey].usedTimes--,Oe.usedTimes===0&&j(E)),I.__cacheKey=Ne,I.__webglTexture=me[Ne].texture}return X}function Ae(I,E,X){return Math.floor(Math.floor(I/X)/E)}function Ee(I,E,X,se){const Ne=I.updateRanges;if(Ne.length===0)i.texSubImage2D(a.TEXTURE_2D,0,0,0,E.width,E.height,X,se,E.data);else{Ne.sort((je,ze)=>je.start-ze.start);let Oe=0;for(let je=1;je<Ne.length;je++){const ze=Ne[Oe],Fe=Ne[je],Qe=ze.start+ze.count,Je=Ae(Fe.start,E.width,4),pt=Ae(ze.start,E.width,4);Fe.start<=Qe+1&&Je===pt&&Ae(Fe.start+Fe.count-1,E.width,4)===Je?ze.count=Math.max(ze.count,Fe.start+Fe.count-ze.start):(++Oe,Ne[Oe]=Fe)}Ne.length=Oe+1;const _e=i.getParameter(a.UNPACK_ROW_LENGTH),he=i.getParameter(a.UNPACK_SKIP_PIXELS),Le=i.getParameter(a.UNPACK_SKIP_ROWS);i.pixelStorei(a.UNPACK_ROW_LENGTH,E.width);for(let je=0,ze=Ne.length;je<ze;je++){const Fe=Ne[je],Qe=Math.floor(Fe.start/4),Je=Math.ceil(Fe.count/4),pt=Qe%E.width,Z=Math.floor(Qe/E.width),Pe=Je,Se=1;i.pixelStorei(a.UNPACK_SKIP_PIXELS,pt),i.pixelStorei(a.UNPACK_SKIP_ROWS,Z),i.texSubImage2D(a.TEXTURE_2D,0,pt,Z,Pe,Se,X,se,E.data)}I.clearUpdateRanges(),i.pixelStorei(a.UNPACK_ROW_LENGTH,_e),i.pixelStorei(a.UNPACK_SKIP_PIXELS,he),i.pixelStorei(a.UNPACK_SKIP_ROWS,Le)}}function He(I,E,X){let se=a.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(se=a.TEXTURE_2D_ARRAY),E.isData3DTexture&&(se=a.TEXTURE_3D);const me=ae(I,E),Ne=E.source;i.bindTexture(se,I.__webglTexture,a.TEXTURE0+X);const Oe=s.get(Ne);if(Ne.version!==Oe.__version||me===!0){if(i.activeTexture(a.TEXTURE0+X),(typeof ImageBitmap<"u"&&E.image instanceof ImageBitmap)===!1){const Se=kt.getPrimaries(kt.workingColorSpace),Be=E.colorSpace===Ss?null:kt.getPrimaries(E.colorSpace),ke=E.colorSpace===Ss||Se===Be?a.NONE:a.BROWSER_DEFAULT_WEBGL;i.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,E.flipY),i.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),i.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,ke)}i.pixelStorei(a.UNPACK_ALIGNMENT,E.unpackAlignment);let he=v(E.image,!1,l.maxTextureSize);he=Ye(E,he);const Le=c.convert(E.format,E.colorSpace),je=c.convert(E.type);let ze=D(E.internalFormat,Le,je,E.normalized,E.colorSpace,E.isVideoTexture);Ie(se,E);let Fe;const Qe=E.mipmaps,Je=E.isVideoTexture!==!0,pt=Oe.__version===void 0||me===!0,Z=Ne.dataReady,Pe=U(E,he);if(E.isDepthTexture)ze=O(E.format===Js,E.type),pt&&(Je?i.texStorage2D(a.TEXTURE_2D,1,ze,he.width,he.height):i.texImage2D(a.TEXTURE_2D,0,ze,he.width,he.height,0,Le,je,null));else if(E.isDataTexture)if(Qe.length>0){Je&&pt&&i.texStorage2D(a.TEXTURE_2D,Pe,ze,Qe[0].width,Qe[0].height);for(let Se=0,Be=Qe.length;Se<Be;Se++)Fe=Qe[Se],Je?Z&&i.texSubImage2D(a.TEXTURE_2D,Se,0,0,Fe.width,Fe.height,Le,je,Fe.data):i.texImage2D(a.TEXTURE_2D,Se,ze,Fe.width,Fe.height,0,Le,je,Fe.data);E.generateMipmaps=!1}else Je?(pt&&i.texStorage2D(a.TEXTURE_2D,Pe,ze,he.width,he.height),Z&&Ee(E,he,Le,je)):i.texImage2D(a.TEXTURE_2D,0,ze,he.width,he.height,0,Le,je,he.data);else if(E.isCompressedTexture)if(E.isCompressedArrayTexture){Je&&pt&&i.texStorage3D(a.TEXTURE_2D_ARRAY,Pe,ze,Qe[0].width,Qe[0].height,he.depth);for(let Se=0,Be=Qe.length;Se<Be;Se++)if(Fe=Qe[Se],E.format!==Yi)if(Le!==null)if(Je){if(Z)if(E.layerUpdates.size>0){const ke=Uv(Fe.width,Fe.height,E.format,E.type);for(const q of E.layerUpdates){const Me=Fe.data.subarray(q*ke/Fe.data.BYTES_PER_ELEMENT,(q+1)*ke/Fe.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,Se,0,0,q,Fe.width,Fe.height,1,Le,Me)}E.clearLayerUpdates()}else i.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,Se,0,0,0,Fe.width,Fe.height,he.depth,Le,Fe.data)}else i.compressedTexImage3D(a.TEXTURE_2D_ARRAY,Se,ze,Fe.width,Fe.height,he.depth,0,Fe.data,0,0);else _t("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Je?Z&&i.texSubImage3D(a.TEXTURE_2D_ARRAY,Se,0,0,0,Fe.width,Fe.height,he.depth,Le,je,Fe.data):i.texImage3D(a.TEXTURE_2D_ARRAY,Se,ze,Fe.width,Fe.height,he.depth,0,Le,je,Fe.data)}else{Je&&pt&&i.texStorage2D(a.TEXTURE_2D,Pe,ze,Qe[0].width,Qe[0].height);for(let Se=0,Be=Qe.length;Se<Be;Se++)Fe=Qe[Se],E.format!==Yi?Le!==null?Je?Z&&i.compressedTexSubImage2D(a.TEXTURE_2D,Se,0,0,Fe.width,Fe.height,Le,Fe.data):i.compressedTexImage2D(a.TEXTURE_2D,Se,ze,Fe.width,Fe.height,0,Fe.data):_t("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Je?Z&&i.texSubImage2D(a.TEXTURE_2D,Se,0,0,Fe.width,Fe.height,Le,je,Fe.data):i.texImage2D(a.TEXTURE_2D,Se,ze,Fe.width,Fe.height,0,Le,je,Fe.data)}else if(E.isDataArrayTexture)if(Je){if(pt&&i.texStorage3D(a.TEXTURE_2D_ARRAY,Pe,ze,he.width,he.height,he.depth),Z)if(E.layerUpdates.size>0){const Se=Uv(he.width,he.height,E.format,E.type);for(const Be of E.layerUpdates){const ke=he.data.subarray(Be*Se/he.data.BYTES_PER_ELEMENT,(Be+1)*Se/he.data.BYTES_PER_ELEMENT);i.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,Be,he.width,he.height,1,Le,je,ke)}E.clearLayerUpdates()}else i.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,0,he.width,he.height,he.depth,Le,je,he.data)}else i.texImage3D(a.TEXTURE_2D_ARRAY,0,ze,he.width,he.height,he.depth,0,Le,je,he.data);else if(E.isData3DTexture)Je?(pt&&i.texStorage3D(a.TEXTURE_3D,Pe,ze,he.width,he.height,he.depth),Z&&i.texSubImage3D(a.TEXTURE_3D,0,0,0,0,he.width,he.height,he.depth,Le,je,he.data)):i.texImage3D(a.TEXTURE_3D,0,ze,he.width,he.height,he.depth,0,Le,je,he.data);else if(E.isFramebufferTexture){if(pt)if(Je)i.texStorage2D(a.TEXTURE_2D,Pe,ze,he.width,he.height);else{let Se=he.width,Be=he.height;for(let ke=0;ke<Pe;ke++)i.texImage2D(a.TEXTURE_2D,ke,ze,Se,Be,0,Le,je,null),Se>>=1,Be>>=1}}else if(E.isHTMLTexture){if("texElementImage2D"in a){const Se=a.canvas;if(Se.hasAttribute("layoutsubtree")||Se.setAttribute("layoutsubtree","true"),he.parentNode!==Se){Se.appendChild(he),S.add(E),Se.onpaint=Be=>{const ke=Be.changedElements;for(const q of S)ke.includes(q.image)&&(q.needsUpdate=!0)},Se.requestPaint();return}if(a.texElementImage2D.length===3)a.texElementImage2D(a.TEXTURE_2D,a.RGBA8,he);else{const ke=a.RGBA,q=a.RGBA,Me=a.UNSIGNED_BYTE;a.texElementImage2D(a.TEXTURE_2D,0,ke,q,Me,he)}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(Qe.length>0){if(Je&&pt){const Se=xt(Qe[0]);i.texStorage2D(a.TEXTURE_2D,Pe,ze,Se.width,Se.height)}for(let Se=0,Be=Qe.length;Se<Be;Se++)Fe=Qe[Se],Je?Z&&i.texSubImage2D(a.TEXTURE_2D,Se,0,0,Le,je,Fe):i.texImage2D(a.TEXTURE_2D,Se,ze,Le,je,Fe);E.generateMipmaps=!1}else if(Je){if(pt){const Se=xt(he);i.texStorage2D(a.TEXTURE_2D,Pe,ze,Se.width,Se.height)}Z&&i.texSubImage2D(a.TEXTURE_2D,0,0,0,Le,je,he)}else i.texImage2D(a.TEXTURE_2D,0,ze,Le,je,he);x(E)&&B(se),Oe.__version=Ne.version,E.onUpdate&&E.onUpdate(E)}I.__version=E.version}function nt(I,E,X){if(E.image.length!==6)return;const se=ae(I,E),me=E.source;i.bindTexture(a.TEXTURE_CUBE_MAP,I.__webglTexture,a.TEXTURE0+X);const Ne=s.get(me);if(me.version!==Ne.__version||se===!0){i.activeTexture(a.TEXTURE0+X);const Oe=kt.getPrimaries(kt.workingColorSpace),_e=E.colorSpace===Ss?null:kt.getPrimaries(E.colorSpace),he=E.colorSpace===Ss||Oe===_e?a.NONE:a.BROWSER_DEFAULT_WEBGL;i.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,E.flipY),i.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),i.pixelStorei(a.UNPACK_ALIGNMENT,E.unpackAlignment),i.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,he);const Le=E.isCompressedTexture||E.image[0].isCompressedTexture,je=E.image[0]&&E.image[0].isDataTexture,ze=[];for(let q=0;q<6;q++)!Le&&!je?ze[q]=v(E.image[q],!0,l.maxCubemapSize):ze[q]=je?E.image[q].image:E.image[q],ze[q]=Ye(E,ze[q]);const Fe=ze[0],Qe=c.convert(E.format,E.colorSpace),Je=c.convert(E.type),pt=D(E.internalFormat,Qe,Je,E.normalized,E.colorSpace),Z=E.isVideoTexture!==!0,Pe=Ne.__version===void 0||se===!0,Se=me.dataReady;let Be=U(E,Fe);Ie(a.TEXTURE_CUBE_MAP,E);let ke;if(Le){Z&&Pe&&i.texStorage2D(a.TEXTURE_CUBE_MAP,Be,pt,Fe.width,Fe.height);for(let q=0;q<6;q++){ke=ze[q].mipmaps;for(let Me=0;Me<ke.length;Me++){const De=ke[Me];E.format!==Yi?Qe!==null?Z?Se&&i.compressedTexSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,Me,0,0,De.width,De.height,Qe,De.data):i.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,Me,pt,De.width,De.height,0,De.data):_t("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Z?Se&&i.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,Me,0,0,De.width,De.height,Qe,Je,De.data):i.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,Me,pt,De.width,De.height,0,Qe,Je,De.data)}}}else{if(ke=E.mipmaps,Z&&Pe){ke.length>0&&Be++;const q=xt(ze[0]);i.texStorage2D(a.TEXTURE_CUBE_MAP,Be,pt,q.width,q.height)}for(let q=0;q<6;q++)if(je){Z?Se&&i.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,ze[q].width,ze[q].height,Qe,Je,ze[q].data):i.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,pt,ze[q].width,ze[q].height,0,Qe,Je,ze[q].data);for(let Me=0;Me<ke.length;Me++){const ft=ke[Me].image[q].image;Z?Se&&i.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,Me+1,0,0,ft.width,ft.height,Qe,Je,ft.data):i.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,Me+1,pt,ft.width,ft.height,0,Qe,Je,ft.data)}}else{Z?Se&&i.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,Qe,Je,ze[q]):i.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,pt,Qe,Je,ze[q]);for(let Me=0;Me<ke.length;Me++){const De=ke[Me];Z?Se&&i.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,Me+1,0,0,Qe,Je,De.image[q]):i.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+q,Me+1,pt,Qe,Je,De.image[q])}}}x(E)&&B(a.TEXTURE_CUBE_MAP),Ne.__version=me.version,E.onUpdate&&E.onUpdate(E)}I.__version=E.version}function Ke(I,E,X,se,me,Ne){const Oe=c.convert(X.format,X.colorSpace),_e=c.convert(X.type),he=D(X.internalFormat,Oe,_e,X.normalized,X.colorSpace),Le=s.get(E),je=s.get(X);if(je.__renderTarget=E,!Le.__hasExternalTextures){const ze=Math.max(1,E.width>>Ne),Fe=Math.max(1,E.height>>Ne);me===a.TEXTURE_3D||me===a.TEXTURE_2D_ARRAY?i.texImage3D(me,Ne,he,ze,Fe,E.depth,0,Oe,_e,null):i.texImage2D(me,Ne,he,ze,Fe,0,Oe,_e,null)}i.bindFramebuffer(a.FRAMEBUFFER,I),W(E)?p.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,se,me,je.__webglTexture,0,It(E)):(me===a.TEXTURE_2D||me>=a.TEXTURE_CUBE_MAP_POSITIVE_X&&me<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&a.framebufferTexture2D(a.FRAMEBUFFER,se,me,je.__webglTexture,Ne),i.bindFramebuffer(a.FRAMEBUFFER,null)}function zt(I,E,X){if(a.bindRenderbuffer(a.RENDERBUFFER,I),E.depthBuffer){const se=E.depthTexture,me=se&&se.isDepthTexture?se.type:null,Ne=O(E.stencilBuffer,me),Oe=E.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;W(E)?p.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,It(E),Ne,E.width,E.height):X?a.renderbufferStorageMultisample(a.RENDERBUFFER,It(E),Ne,E.width,E.height):a.renderbufferStorage(a.RENDERBUFFER,Ne,E.width,E.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,Oe,a.RENDERBUFFER,I)}else{const se=E.textures;for(let me=0;me<se.length;me++){const Ne=se[me],Oe=c.convert(Ne.format,Ne.colorSpace),_e=c.convert(Ne.type),he=D(Ne.internalFormat,Oe,_e,Ne.normalized,Ne.colorSpace);W(E)?p.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,It(E),he,E.width,E.height):X?a.renderbufferStorageMultisample(a.RENDERBUFFER,It(E),he,E.width,E.height):a.renderbufferStorage(a.RENDERBUFFER,he,E.width,E.height)}}a.bindRenderbuffer(a.RENDERBUFFER,null)}function ht(I,E,X){const se=E.isWebGLCubeRenderTarget===!0;if(i.bindFramebuffer(a.FRAMEBUFFER,I),!(E.depthTexture&&E.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const me=s.get(E.depthTexture);if(me.__renderTarget=E,(!me.__webglTexture||E.depthTexture.image.width!==E.width||E.depthTexture.image.height!==E.height)&&(E.depthTexture.image.width=E.width,E.depthTexture.image.height=E.height,E.depthTexture.needsUpdate=!0),se){if(me.__webglInit===void 0&&(me.__webglInit=!0,E.depthTexture.addEventListener("dispose",N)),me.__webglTexture===void 0){me.__webglTexture=a.createTexture(),i.bindTexture(a.TEXTURE_CUBE_MAP,me.__webglTexture),Ie(a.TEXTURE_CUBE_MAP,E.depthTexture);const Le=c.convert(E.depthTexture.format),je=c.convert(E.depthTexture.type);let ze;E.depthTexture.format===Ha?ze=a.DEPTH_COMPONENT24:E.depthTexture.format===Js&&(ze=a.DEPTH24_STENCIL8);for(let Fe=0;Fe<6;Fe++)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,0,ze,E.width,E.height,0,Le,je,null)}}else ne(E.depthTexture,0);const Ne=me.__webglTexture,Oe=It(E),_e=se?a.TEXTURE_CUBE_MAP_POSITIVE_X+X:a.TEXTURE_2D,he=E.depthTexture.format===Js?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;if(E.depthTexture.format===Ha)W(E)?p.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,he,_e,Ne,0,Oe):a.framebufferTexture2D(a.FRAMEBUFFER,he,_e,Ne,0);else if(E.depthTexture.format===Js)W(E)?p.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,he,_e,Ne,0,Oe):a.framebufferTexture2D(a.FRAMEBUFFER,he,_e,Ne,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Et(I){const E=s.get(I),X=I.isWebGLCubeRenderTarget===!0;if(E.__boundDepthTexture!==I.depthTexture){const se=I.depthTexture;if(E.__depthDisposeCallback&&E.__depthDisposeCallback(),se){const me=()=>{delete E.__boundDepthTexture,delete E.__depthDisposeCallback,se.removeEventListener("dispose",me)};se.addEventListener("dispose",me),E.__depthDisposeCallback=me}E.__boundDepthTexture=se}if(I.depthTexture&&!E.__autoAllocateDepthBuffer)if(X)for(let se=0;se<6;se++)ht(E.__webglFramebuffer[se],I,se);else{const se=I.texture.mipmaps;se&&se.length>0?ht(E.__webglFramebuffer[0],I,0):ht(E.__webglFramebuffer,I,0)}else if(X){E.__webglDepthbuffer=[];for(let se=0;se<6;se++)if(i.bindFramebuffer(a.FRAMEBUFFER,E.__webglFramebuffer[se]),E.__webglDepthbuffer[se]===void 0)E.__webglDepthbuffer[se]=a.createRenderbuffer(),zt(E.__webglDepthbuffer[se],I,!1);else{const me=I.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,Ne=E.__webglDepthbuffer[se];a.bindRenderbuffer(a.RENDERBUFFER,Ne),a.framebufferRenderbuffer(a.FRAMEBUFFER,me,a.RENDERBUFFER,Ne)}}else{const se=I.texture.mipmaps;if(se&&se.length>0?i.bindFramebuffer(a.FRAMEBUFFER,E.__webglFramebuffer[0]):i.bindFramebuffer(a.FRAMEBUFFER,E.__webglFramebuffer),E.__webglDepthbuffer===void 0)E.__webglDepthbuffer=a.createRenderbuffer(),zt(E.__webglDepthbuffer,I,!1);else{const me=I.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,Ne=E.__webglDepthbuffer;a.bindRenderbuffer(a.RENDERBUFFER,Ne),a.framebufferRenderbuffer(a.FRAMEBUFFER,me,a.RENDERBUFFER,Ne)}}i.bindFramebuffer(a.FRAMEBUFFER,null)}function yt(I,E,X){const se=s.get(I);E!==void 0&&Ke(se.__webglFramebuffer,I,I.texture,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,0),X!==void 0&&Et(I)}function St(I){const E=I.texture,X=s.get(I),se=s.get(E);I.addEventListener("dispose",A);const me=I.textures,Ne=I.isWebGLCubeRenderTarget===!0,Oe=me.length>1;if(Oe||(se.__webglTexture===void 0&&(se.__webglTexture=a.createTexture()),se.__version=E.version,f.memory.textures++),Ne){X.__webglFramebuffer=[];for(let _e=0;_e<6;_e++)if(E.mipmaps&&E.mipmaps.length>0){X.__webglFramebuffer[_e]=[];for(let he=0;he<E.mipmaps.length;he++)X.__webglFramebuffer[_e][he]=a.createFramebuffer()}else X.__webglFramebuffer[_e]=a.createFramebuffer()}else{if(E.mipmaps&&E.mipmaps.length>0){X.__webglFramebuffer=[];for(let _e=0;_e<E.mipmaps.length;_e++)X.__webglFramebuffer[_e]=a.createFramebuffer()}else X.__webglFramebuffer=a.createFramebuffer();if(Oe)for(let _e=0,he=me.length;_e<he;_e++){const Le=s.get(me[_e]);Le.__webglTexture===void 0&&(Le.__webglTexture=a.createTexture(),f.memory.textures++)}if(I.samples>0&&W(I)===!1){X.__webglMultisampledFramebuffer=a.createFramebuffer(),X.__webglColorRenderbuffer=[],i.bindFramebuffer(a.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let _e=0;_e<me.length;_e++){const he=me[_e];X.__webglColorRenderbuffer[_e]=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,X.__webglColorRenderbuffer[_e]);const Le=c.convert(he.format,he.colorSpace),je=c.convert(he.type),ze=D(he.internalFormat,Le,je,he.normalized,he.colorSpace,I.isXRRenderTarget===!0),Fe=It(I);a.renderbufferStorageMultisample(a.RENDERBUFFER,Fe,ze,I.width,I.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+_e,a.RENDERBUFFER,X.__webglColorRenderbuffer[_e])}a.bindRenderbuffer(a.RENDERBUFFER,null),I.depthBuffer&&(X.__webglDepthRenderbuffer=a.createRenderbuffer(),zt(X.__webglDepthRenderbuffer,I,!0)),i.bindFramebuffer(a.FRAMEBUFFER,null)}}if(Ne){i.bindTexture(a.TEXTURE_CUBE_MAP,se.__webglTexture),Ie(a.TEXTURE_CUBE_MAP,E);for(let _e=0;_e<6;_e++)if(E.mipmaps&&E.mipmaps.length>0)for(let he=0;he<E.mipmaps.length;he++)Ke(X.__webglFramebuffer[_e][he],I,E,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+_e,he);else Ke(X.__webglFramebuffer[_e],I,E,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0);x(E)&&B(a.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(Oe){for(let _e=0,he=me.length;_e<he;_e++){const Le=me[_e],je=s.get(Le);let ze=a.TEXTURE_2D;(I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(ze=I.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),i.bindTexture(ze,je.__webglTexture),Ie(ze,Le),Ke(X.__webglFramebuffer,I,Le,a.COLOR_ATTACHMENT0+_e,ze,0),x(Le)&&B(ze)}i.unbindTexture()}else{let _e=a.TEXTURE_2D;if((I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(_e=I.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),i.bindTexture(_e,se.__webglTexture),Ie(_e,E),E.mipmaps&&E.mipmaps.length>0)for(let he=0;he<E.mipmaps.length;he++)Ke(X.__webglFramebuffer[he],I,E,a.COLOR_ATTACHMENT0,_e,he);else Ke(X.__webglFramebuffer,I,E,a.COLOR_ATTACHMENT0,_e,0);x(E)&&B(_e),i.unbindTexture()}I.depthBuffer&&Et(I)}function Mt(I){const E=I.textures;for(let X=0,se=E.length;X<se;X++){const me=E[X];if(x(me)){const Ne=P(I),Oe=s.get(me).__webglTexture;i.bindTexture(Ne,Oe),B(Ne),i.unbindTexture()}}}const Ht=[],Gt=[];function st(I){if(I.samples>0){if(W(I)===!1){const E=I.textures,X=I.width,se=I.height;let me=a.COLOR_BUFFER_BIT;const Ne=I.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,Oe=s.get(I),_e=E.length>1;if(_e)for(let Le=0;Le<E.length;Le++)i.bindFramebuffer(a.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Le,a.RENDERBUFFER,null),i.bindFramebuffer(a.FRAMEBUFFER,Oe.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+Le,a.TEXTURE_2D,null,0);i.bindFramebuffer(a.READ_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer);const he=I.texture.mipmaps;he&&he.length>0?i.bindFramebuffer(a.DRAW_FRAMEBUFFER,Oe.__webglFramebuffer[0]):i.bindFramebuffer(a.DRAW_FRAMEBUFFER,Oe.__webglFramebuffer);for(let Le=0;Le<E.length;Le++){if(I.resolveDepthBuffer&&(I.depthBuffer&&(me|=a.DEPTH_BUFFER_BIT),I.stencilBuffer&&I.resolveStencilBuffer&&(me|=a.STENCIL_BUFFER_BIT)),_e){a.framebufferRenderbuffer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.RENDERBUFFER,Oe.__webglColorRenderbuffer[Le]);const je=s.get(E[Le]).__webglTexture;a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,je,0)}a.blitFramebuffer(0,0,X,se,0,0,X,se,me,a.NEAREST),m===!0&&(Ht.length=0,Gt.length=0,Ht.push(a.COLOR_ATTACHMENT0+Le),I.depthBuffer&&I.resolveDepthBuffer===!1&&(Ht.push(Ne),Gt.push(Ne),a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,Gt)),a.invalidateFramebuffer(a.READ_FRAMEBUFFER,Ht))}if(i.bindFramebuffer(a.READ_FRAMEBUFFER,null),i.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),_e)for(let Le=0;Le<E.length;Le++){i.bindFramebuffer(a.FRAMEBUFFER,Oe.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Le,a.RENDERBUFFER,Oe.__webglColorRenderbuffer[Le]);const je=s.get(E[Le]).__webglTexture;i.bindFramebuffer(a.FRAMEBUFFER,Oe.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+Le,a.TEXTURE_2D,je,0)}i.bindFramebuffer(a.DRAW_FRAMEBUFFER,Oe.__webglMultisampledFramebuffer)}else if(I.depthBuffer&&I.resolveDepthBuffer===!1&&m){const E=I.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,[E])}}}function It(I){return Math.min(l.maxSamples,I.samples)}function W(I){const E=s.get(I);return I.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function z(I){const E=f.render.frame;y.get(I)!==E&&(y.set(I,E),I.update())}function Ye(I,E){const X=I.colorSpace,se=I.format,me=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||X!==Tu&&X!==Ss&&(kt.getTransfer(X)===an?(se!==Yi||me!==Ei)&&_t("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):jt("WebGLTextures: Unsupported texture color space:",X)),E}function xt(I){return typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement?(h.width=I.naturalWidth||I.width,h.height=I.naturalHeight||I.height):typeof VideoFrame<"u"&&I instanceof VideoFrame?(h.width=I.displayWidth,h.height=I.displayHeight):(h.width=I.width,h.height=I.height),h}this.allocateTextureUnit=H,this.resetTextureUnits=pe,this.getTextureUnits=ge,this.setTextureUnits=K,this.setTexture2D=ne,this.setTexture2DArray=ye,this.setTexture3D=xe,this.setTextureCube=F,this.rebindTextures=yt,this.setupRenderTarget=St,this.updateRenderTargetMipmap=Mt,this.updateMultisampleRenderTarget=st,this.setupDepthRenderbuffer=Et,this.setupFrameBufferTexture=Ke,this.useMultisampledRTT=W,this.isReversedDepthBuffer=function(){return i.buffers.depth.getReversed()}}function mw(a,e){function i(s,l=Ss){let c;const f=kt.getTransfer(l);if(s===Ei)return a.UNSIGNED_BYTE;if(s===Op)return a.UNSIGNED_SHORT_4_4_4_4;if(s===Pp)return a.UNSIGNED_SHORT_5_5_5_1;if(s===Px)return a.UNSIGNED_INT_5_9_9_9_REV;if(s===Ix)return a.UNSIGNED_INT_10F_11F_11F_REV;if(s===Lx)return a.BYTE;if(s===Ox)return a.SHORT;if(s===Tl)return a.UNSIGNED_SHORT;if(s===Lp)return a.INT;if(s===la)return a.UNSIGNED_INT;if(s===qi)return a.FLOAT;if(s===za)return a.HALF_FLOAT;if(s===Bx)return a.ALPHA;if(s===Fx)return a.RGB;if(s===Yi)return a.RGBA;if(s===Ha)return a.DEPTH_COMPONENT;if(s===Js)return a.DEPTH_STENCIL;if(s===Ip)return a.RED;if(s===Bp)return a.RED_INTEGER;if(s===nr)return a.RG;if(s===Fp)return a.RG_INTEGER;if(s===zp)return a.RGBA_INTEGER;if(s===_u||s===vu||s===xu||s===yu)if(f===an)if(c=e.get("WEBGL_compressed_texture_s3tc_srgb"),c!==null){if(s===_u)return c.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===vu)return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===xu)return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===yu)return c.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(c=e.get("WEBGL_compressed_texture_s3tc"),c!==null){if(s===_u)return c.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===vu)return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===xu)return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===yu)return c.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===jh||s===Xh||s===Wh||s===qh)if(c=e.get("WEBGL_compressed_texture_pvrtc"),c!==null){if(s===jh)return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Xh)return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Wh)return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===qh)return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Yh||s===Zh||s===Kh||s===$h||s===Qh||s===bu||s===Jh)if(c=e.get("WEBGL_compressed_texture_etc"),c!==null){if(s===Yh||s===Zh)return f===an?c.COMPRESSED_SRGB8_ETC2:c.COMPRESSED_RGB8_ETC2;if(s===Kh)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:c.COMPRESSED_RGBA8_ETC2_EAC;if(s===$h)return c.COMPRESSED_R11_EAC;if(s===Qh)return c.COMPRESSED_SIGNED_R11_EAC;if(s===bu)return c.COMPRESSED_RG11_EAC;if(s===Jh)return c.COMPRESSED_SIGNED_RG11_EAC}else return null;if(s===ep||s===tp||s===np||s===ip||s===ap||s===sp||s===rp||s===op||s===lp||s===cp||s===up||s===fp||s===dp||s===hp)if(c=e.get("WEBGL_compressed_texture_astc"),c!==null){if(s===ep)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:c.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===tp)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:c.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===np)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:c.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===ip)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:c.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===ap)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:c.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===sp)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:c.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===rp)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:c.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===op)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:c.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===lp)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:c.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===cp)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:c.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===up)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:c.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===fp)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:c.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===dp)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:c.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===hp)return f===an?c.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:c.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===pp||s===mp||s===gp)if(c=e.get("EXT_texture_compression_bptc"),c!==null){if(s===pp)return f===an?c.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:c.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===mp)return c.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===gp)return c.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===_p||s===vp||s===Eu||s===xp)if(c=e.get("EXT_texture_compression_rgtc"),c!==null){if(s===_p)return c.COMPRESSED_RED_RGTC1_EXT;if(s===vp)return c.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Eu)return c.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===xp)return c.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Al?a.UNSIGNED_INT_24_8:a[s]!==void 0?a[s]:null}return{convert:i}}const gw=`
|
||
void main() {
|
||
|
||
gl_Position = vec4( position, 1.0 );
|
||
|
||
}`,_w=`
|
||
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 vw{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,i){if(this.texture===null){const s=new Zx(e.texture);(e.depthNear!==i.depthNear||e.depthFar!==i.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const i=e.cameras[0].viewport,s=new ca({vertexShader:gw,fragmentShader:_w,uniforms:{depthColor:{value:this.texture},depthWidth:{value:i.z},depthHeight:{value:i.w}}});this.mesh=new Ki(new Lu(20,20),s)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class xw extends ws{constructor(e,i){super();const s=this;let l=null,c=1,f=null,p="local-floor",m=1,h=null,y=null,S=null,_=null,b=null,T=null;const C=typeof XRWebGLBinding<"u",v=new vw,x={},B=i.getContextAttributes();let P=null,D=null;const O=[],U=[],N=new bt;let A=null;const L=new Ii;L.viewport=new xn;const j=new Ii;j.viewport=new xn;const V=[L,j],$=new CE;let pe=null,ge=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ae){let Ae=O[ae];return Ae===void 0&&(Ae=new ih,O[ae]=Ae),Ae.getTargetRaySpace()},this.getControllerGrip=function(ae){let Ae=O[ae];return Ae===void 0&&(Ae=new ih,O[ae]=Ae),Ae.getGripSpace()},this.getHand=function(ae){let Ae=O[ae];return Ae===void 0&&(Ae=new ih,O[ae]=Ae),Ae.getHandSpace()};function K(ae){const Ae=U.indexOf(ae.inputSource);if(Ae===-1)return;const Ee=O[Ae];Ee!==void 0&&(Ee.update(ae.inputSource,ae.frame,h||f),Ee.dispatchEvent({type:ae.type,data:ae.inputSource}))}function H(){l.removeEventListener("select",K),l.removeEventListener("selectstart",K),l.removeEventListener("selectend",K),l.removeEventListener("squeeze",K),l.removeEventListener("squeezestart",K),l.removeEventListener("squeezeend",K),l.removeEventListener("end",H),l.removeEventListener("inputsourceschange",G);for(let ae=0;ae<O.length;ae++){const Ae=U[ae];Ae!==null&&(U[ae]=null,O[ae].disconnect(Ae))}pe=null,ge=null,v.reset();for(const ae in x)delete x[ae];e.setRenderTarget(P),b=null,_=null,S=null,l=null,D=null,Ie.stop(),s.isPresenting=!1,e.setPixelRatio(A),e.setSize(N.width,N.height,!1),s.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ae){c=ae,s.isPresenting===!0&&_t("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ae){p=ae,s.isPresenting===!0&&_t("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||f},this.setReferenceSpace=function(ae){h=ae},this.getBaseLayer=function(){return _!==null?_:b},this.getBinding=function(){return S===null&&C&&(S=new XRWebGLBinding(l,i)),S},this.getFrame=function(){return T},this.getSession=function(){return l},this.setSession=async function(ae){if(l=ae,l!==null){if(P=e.getRenderTarget(),l.addEventListener("select",K),l.addEventListener("selectstart",K),l.addEventListener("selectend",K),l.addEventListener("squeeze",K),l.addEventListener("squeezestart",K),l.addEventListener("squeezeend",K),l.addEventListener("end",H),l.addEventListener("inputsourceschange",G),B.xrCompatible!==!0&&await i.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(N),C&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ee=null,He=null,nt=null;B.depth&&(nt=B.stencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24,Ee=B.stencil?Js:Ha,He=B.stencil?Al:la);const Ke={colorFormat:i.RGBA8,depthFormat:nt,scaleFactor:c};S=this.getBinding(),_=S.createProjectionLayer(Ke),l.updateRenderState({layers:[_]}),e.setPixelRatio(1),e.setSize(_.textureWidth,_.textureHeight,!1),D=new oa(_.textureWidth,_.textureHeight,{format:Yi,type:Ei,depthTexture:new fo(_.textureWidth,_.textureHeight,He,void 0,void 0,void 0,void 0,void 0,void 0,Ee),stencilBuffer:B.stencil,colorSpace:e.outputColorSpace,samples:B.antialias?4:0,resolveDepthBuffer:_.ignoreDepthValues===!1,resolveStencilBuffer:_.ignoreDepthValues===!1})}else{const Ee={antialias:B.antialias,alpha:!0,depth:B.depth,stencil:B.stencil,framebufferScaleFactor:c};b=new XRWebGLLayer(l,i,Ee),l.updateRenderState({baseLayer:b}),e.setPixelRatio(1),e.setSize(b.framebufferWidth,b.framebufferHeight,!1),D=new oa(b.framebufferWidth,b.framebufferHeight,{format:Yi,type:Ei,colorSpace:e.outputColorSpace,stencilBuffer:B.stencil,resolveDepthBuffer:b.ignoreDepthValues===!1,resolveStencilBuffer:b.ignoreDepthValues===!1})}D.isXRRenderTarget=!0,this.setFoveation(m),h=null,f=await l.requestReferenceSpace(p),Ie.setContext(l),Ie.start(),s.isPresenting=!0,s.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(l!==null)return l.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function G(ae){for(let Ae=0;Ae<ae.removed.length;Ae++){const Ee=ae.removed[Ae],He=U.indexOf(Ee);He>=0&&(U[He]=null,O[He].disconnect(Ee))}for(let Ae=0;Ae<ae.added.length;Ae++){const Ee=ae.added[Ae];let He=U.indexOf(Ee);if(He===-1){for(let Ke=0;Ke<O.length;Ke++)if(Ke>=U.length){U.push(Ee),He=Ke;break}else if(U[Ke]===null){U[Ke]=Ee,He=Ke;break}if(He===-1)break}const nt=O[He];nt&&nt.connect(Ee)}}const ne=new ie,ye=new ie;function xe(ae,Ae,Ee){ne.setFromMatrixPosition(Ae.matrixWorld),ye.setFromMatrixPosition(Ee.matrixWorld);const He=ne.distanceTo(ye),nt=Ae.projectionMatrix.elements,Ke=Ee.projectionMatrix.elements,zt=nt[14]/(nt[10]-1),ht=nt[14]/(nt[10]+1),Et=(nt[9]+1)/nt[5],yt=(nt[9]-1)/nt[5],St=(nt[8]-1)/nt[0],Mt=(Ke[8]+1)/Ke[0],Ht=zt*St,Gt=zt*Mt,st=He/(-St+Mt),It=st*-St;if(Ae.matrixWorld.decompose(ae.position,ae.quaternion,ae.scale),ae.translateX(It),ae.translateZ(st),ae.matrixWorld.compose(ae.position,ae.quaternion,ae.scale),ae.matrixWorldInverse.copy(ae.matrixWorld).invert(),nt[10]===-1)ae.projectionMatrix.copy(Ae.projectionMatrix),ae.projectionMatrixInverse.copy(Ae.projectionMatrixInverse);else{const W=zt+st,z=ht+st,Ye=Ht-It,xt=Gt+(He-It),I=Et*ht/z*W,E=yt*ht/z*W;ae.projectionMatrix.makePerspective(Ye,xt,I,E,W,z),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert()}}function F(ae,Ae){Ae===null?ae.matrixWorld.copy(ae.matrix):ae.matrixWorld.multiplyMatrices(Ae.matrixWorld,ae.matrix),ae.matrixWorldInverse.copy(ae.matrixWorld).invert()}this.updateCamera=function(ae){if(l===null)return;let Ae=ae.near,Ee=ae.far;v.texture!==null&&(v.depthNear>0&&(Ae=v.depthNear),v.depthFar>0&&(Ee=v.depthFar)),$.near=j.near=L.near=Ae,$.far=j.far=L.far=Ee,(pe!==$.near||ge!==$.far)&&(l.updateRenderState({depthNear:$.near,depthFar:$.far}),pe=$.near,ge=$.far),$.layers.mask=ae.layers.mask|6,L.layers.mask=$.layers.mask&-5,j.layers.mask=$.layers.mask&-3;const He=ae.parent,nt=$.cameras;F($,He);for(let Ke=0;Ke<nt.length;Ke++)F(nt[Ke],He);nt.length===2?xe($,L,j):$.projectionMatrix.copy(L.projectionMatrix),J(ae,$,He)};function J(ae,Ae,Ee){Ee===null?ae.matrix.copy(Ae.matrixWorld):(ae.matrix.copy(Ee.matrixWorld),ae.matrix.invert(),ae.matrix.multiply(Ae.matrixWorld)),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.updateMatrixWorld(!0),ae.projectionMatrix.copy(Ae.projectionMatrix),ae.projectionMatrixInverse.copy(Ae.projectionMatrixInverse),ae.isPerspectiveCamera&&(ae.fov=Sp*2*Math.atan(1/ae.projectionMatrix.elements[5]),ae.zoom=1)}this.getCamera=function(){return $},this.getFoveation=function(){if(!(_===null&&b===null))return m},this.setFoveation=function(ae){m=ae,_!==null&&(_.fixedFoveation=ae),b!==null&&b.fixedFoveation!==void 0&&(b.fixedFoveation=ae)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh($)},this.getCameraTexture=function(ae){return x[ae]};let Ce=null;function Ue(ae,Ae){if(y=Ae.getViewerPose(h||f),T=Ae,y!==null){const Ee=y.views;b!==null&&(e.setRenderTargetFramebuffer(D,b.framebuffer),e.setRenderTarget(D));let He=!1;Ee.length!==$.cameras.length&&($.cameras.length=0,He=!0);for(let ht=0;ht<Ee.length;ht++){const Et=Ee[ht];let yt=null;if(b!==null)yt=b.getViewport(Et);else{const Mt=S.getViewSubImage(_,Et);yt=Mt.viewport,ht===0&&(e.setRenderTargetTextures(D,Mt.colorTexture,Mt.depthStencilTexture),e.setRenderTarget(D))}let St=V[ht];St===void 0&&(St=new Ii,St.layers.enable(ht),St.viewport=new xn,V[ht]=St),St.matrix.fromArray(Et.transform.matrix),St.matrix.decompose(St.position,St.quaternion,St.scale),St.projectionMatrix.fromArray(Et.projectionMatrix),St.projectionMatrixInverse.copy(St.projectionMatrix).invert(),St.viewport.set(yt.x,yt.y,yt.width,yt.height),ht===0&&($.matrix.copy(St.matrix),$.matrix.decompose($.position,$.quaternion,$.scale)),He===!0&&$.cameras.push(St)}const nt=l.enabledFeatures;if(nt&&nt.includes("depth-sensing")&&l.depthUsage=="gpu-optimized"&&C){S=s.getBinding();const ht=S.getDepthInformation(Ee[0]);ht&&ht.isValid&&ht.texture&&v.init(ht,l.renderState)}if(nt&&nt.includes("camera-access")&&C){e.state.unbindTexture(),S=s.getBinding();for(let ht=0;ht<Ee.length;ht++){const Et=Ee[ht].camera;if(Et){let yt=x[Et];yt||(yt=new Zx,x[Et]=yt);const St=S.getCameraImage(Et);yt.sourceTexture=St}}}}for(let Ee=0;Ee<O.length;Ee++){const He=U[Ee],nt=O[Ee];He!==null&&nt!==void 0&&nt.update(He,Ae,h||f)}Ce&&Ce(ae,Ae),Ae.detectedPlanes&&s.dispatchEvent({type:"planesdetected",data:Ae}),T=null}const Ie=new Qx;Ie.setAnimationLoop(Ue),this.setAnimationLoop=function(ae){Ce=ae},this.dispose=function(){}}}const yw=new dn,sy=new At;sy.set(-1,0,0,0,1,0,0,0,1);function Sw(a,e){function i(v,x){v.matrixAutoUpdate===!0&&v.updateMatrix(),x.value.copy(v.matrix)}function s(v,x){x.color.getRGB(v.fogColor.value,Kx(a)),x.isFog?(v.fogNear.value=x.near,v.fogFar.value=x.far):x.isFogExp2&&(v.fogDensity.value=x.density)}function l(v,x,B,P,D){x.isNodeMaterial?x.uniformsNeedUpdate=!1:x.isMeshBasicMaterial?c(v,x):x.isMeshLambertMaterial?(c(v,x),x.envMap&&(v.envMapIntensity.value=x.envMapIntensity)):x.isMeshToonMaterial?(c(v,x),S(v,x)):x.isMeshPhongMaterial?(c(v,x),y(v,x),x.envMap&&(v.envMapIntensity.value=x.envMapIntensity)):x.isMeshStandardMaterial?(c(v,x),_(v,x),x.isMeshPhysicalMaterial&&b(v,x,D)):x.isMeshMatcapMaterial?(c(v,x),T(v,x)):x.isMeshDepthMaterial?c(v,x):x.isMeshDistanceMaterial?(c(v,x),C(v,x)):x.isMeshNormalMaterial?c(v,x):x.isLineBasicMaterial?(f(v,x),x.isLineDashedMaterial&&p(v,x)):x.isPointsMaterial?m(v,x,B,P):x.isSpriteMaterial?h(v,x):x.isShadowMaterial?(v.color.value.copy(x.color),v.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function c(v,x){v.opacity.value=x.opacity,x.color&&v.diffuse.value.copy(x.color),x.emissive&&v.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(v.map.value=x.map,i(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,i(x.alphaMap,v.alphaMapTransform)),x.bumpMap&&(v.bumpMap.value=x.bumpMap,i(x.bumpMap,v.bumpMapTransform),v.bumpScale.value=x.bumpScale,x.side===ui&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,i(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===ui&&v.normalScale.value.negate()),x.displacementMap&&(v.displacementMap.value=x.displacementMap,i(x.displacementMap,v.displacementMapTransform),v.displacementScale.value=x.displacementScale,v.displacementBias.value=x.displacementBias),x.emissiveMap&&(v.emissiveMap.value=x.emissiveMap,i(x.emissiveMap,v.emissiveMapTransform)),x.specularMap&&(v.specularMap.value=x.specularMap,i(x.specularMap,v.specularMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest);const B=e.get(x),P=B.envMap,D=B.envMapRotation;P&&(v.envMap.value=P,v.envMapRotation.value.setFromMatrix4(yw.makeRotationFromEuler(D)).transpose(),P.isCubeTexture&&P.isRenderTargetTexture===!1&&v.envMapRotation.value.premultiply(sy),v.reflectivity.value=x.reflectivity,v.ior.value=x.ior,v.refractionRatio.value=x.refractionRatio),x.lightMap&&(v.lightMap.value=x.lightMap,v.lightMapIntensity.value=x.lightMapIntensity,i(x.lightMap,v.lightMapTransform)),x.aoMap&&(v.aoMap.value=x.aoMap,v.aoMapIntensity.value=x.aoMapIntensity,i(x.aoMap,v.aoMapTransform))}function f(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,x.map&&(v.map.value=x.map,i(x.map,v.mapTransform))}function p(v,x){v.dashSize.value=x.dashSize,v.totalSize.value=x.dashSize+x.gapSize,v.scale.value=x.scale}function m(v,x,B,P){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.size.value=x.size*B,v.scale.value=P*.5,x.map&&(v.map.value=x.map,i(x.map,v.uvTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,i(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function h(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.rotation.value=x.rotation,x.map&&(v.map.value=x.map,i(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,i(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function y(v,x){v.specular.value.copy(x.specular),v.shininess.value=Math.max(x.shininess,1e-4)}function S(v,x){x.gradientMap&&(v.gradientMap.value=x.gradientMap)}function _(v,x){v.metalness.value=x.metalness,x.metalnessMap&&(v.metalnessMap.value=x.metalnessMap,i(x.metalnessMap,v.metalnessMapTransform)),v.roughness.value=x.roughness,x.roughnessMap&&(v.roughnessMap.value=x.roughnessMap,i(x.roughnessMap,v.roughnessMapTransform)),x.envMap&&(v.envMapIntensity.value=x.envMapIntensity)}function b(v,x,B){v.ior.value=x.ior,x.sheen>0&&(v.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),v.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(v.sheenColorMap.value=x.sheenColorMap,i(x.sheenColorMap,v.sheenColorMapTransform)),x.sheenRoughnessMap&&(v.sheenRoughnessMap.value=x.sheenRoughnessMap,i(x.sheenRoughnessMap,v.sheenRoughnessMapTransform))),x.clearcoat>0&&(v.clearcoat.value=x.clearcoat,v.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(v.clearcoatMap.value=x.clearcoatMap,i(x.clearcoatMap,v.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,i(x.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(v.clearcoatNormalMap.value=x.clearcoatNormalMap,i(x.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===ui&&v.clearcoatNormalScale.value.negate())),x.dispersion>0&&(v.dispersion.value=x.dispersion),x.iridescence>0&&(v.iridescence.value=x.iridescence,v.iridescenceIOR.value=x.iridescenceIOR,v.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(v.iridescenceMap.value=x.iridescenceMap,i(x.iridescenceMap,v.iridescenceMapTransform)),x.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=x.iridescenceThicknessMap,i(x.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),x.transmission>0&&(v.transmission.value=x.transmission,v.transmissionSamplerMap.value=B.texture,v.transmissionSamplerSize.value.set(B.width,B.height),x.transmissionMap&&(v.transmissionMap.value=x.transmissionMap,i(x.transmissionMap,v.transmissionMapTransform)),v.thickness.value=x.thickness,x.thicknessMap&&(v.thicknessMap.value=x.thicknessMap,i(x.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=x.attenuationDistance,v.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(v.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(v.anisotropyMap.value=x.anisotropyMap,i(x.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=x.specularIntensity,v.specularColor.value.copy(x.specularColor),x.specularColorMap&&(v.specularColorMap.value=x.specularColorMap,i(x.specularColorMap,v.specularColorMapTransform)),x.specularIntensityMap&&(v.specularIntensityMap.value=x.specularIntensityMap,i(x.specularIntensityMap,v.specularIntensityMapTransform))}function T(v,x){x.matcap&&(v.matcap.value=x.matcap)}function C(v,x){const B=e.get(x).light;v.referencePosition.value.setFromMatrixPosition(B.matrixWorld),v.nearDistance.value=B.shadow.camera.near,v.farDistance.value=B.shadow.camera.far}return{refreshFogUniforms:s,refreshMaterialUniforms:l}}function Mw(a,e,i,s){let l={},c={},f=[];const p=a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS);function m(D,O){const U=O.program;s.uniformBlockBinding(D,U)}function h(D,O){let U=l[D.id];U===void 0&&(v(D),U=y(D),l[D.id]=U,D.addEventListener("dispose",B));const N=O.program;s.updateUBOMapping(D,N);const A=e.render.frame;c[D.id]!==A&&(_(D),c[D.id]=A)}function y(D){const O=S();D.__bindingPointIndex=O;const U=a.createBuffer(),N=D.__size,A=D.usage;return a.bindBuffer(a.UNIFORM_BUFFER,U),a.bufferData(a.UNIFORM_BUFFER,N,A),a.bindBuffer(a.UNIFORM_BUFFER,null),a.bindBufferBase(a.UNIFORM_BUFFER,O,U),U}function S(){for(let D=0;D<p;D++)if(f.indexOf(D)===-1)return f.push(D),D;return jt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function _(D){const O=l[D.id],U=D.uniforms,N=D.__cache;a.bindBuffer(a.UNIFORM_BUFFER,O);for(let A=0,L=U.length;A<L;A++){const j=U[A];if(Array.isArray(j))for(let V=0,$=j.length;V<$;V++)b(j[V],A,V,N);else b(j,A,0,N)}a.bindBuffer(a.UNIFORM_BUFFER,null)}function b(D,O,U,N){if(C(D,O,U,N)===!0){const A=D.__offset,L=D.value;if(Array.isArray(L)){let j=0;for(let V=0;V<L.length;V++){const $=L[V],pe=x($);T($,D.__data,j),typeof $!="number"&&typeof $!="boolean"&&!$.isMatrix3&&!ArrayBuffer.isView($)&&(j+=pe.storage/Float32Array.BYTES_PER_ELEMENT)}}else T(L,D.__data,0);a.bufferSubData(a.UNIFORM_BUFFER,A,D.__data)}}function T(D,O,U){typeof D=="number"||typeof D=="boolean"?O[0]=D:D.isMatrix3?(O[0]=D.elements[0],O[1]=D.elements[1],O[2]=D.elements[2],O[3]=0,O[4]=D.elements[3],O[5]=D.elements[4],O[6]=D.elements[5],O[7]=0,O[8]=D.elements[6],O[9]=D.elements[7],O[10]=D.elements[8],O[11]=0):ArrayBuffer.isView(D)?O.set(new D.constructor(D.buffer,D.byteOffset,O.length)):D.toArray(O,U)}function C(D,O,U,N){const A=D.value,L=O+"_"+U;if(N[L]===void 0)return typeof A=="number"||typeof A=="boolean"?N[L]=A:ArrayBuffer.isView(A)?N[L]=A.slice():N[L]=A.clone(),!0;{const j=N[L];if(typeof A=="number"||typeof A=="boolean"){if(j!==A)return N[L]=A,!0}else{if(ArrayBuffer.isView(A))return!0;if(j.equals(A)===!1)return j.copy(A),!0}}return!1}function v(D){const O=D.uniforms;let U=0;const N=16;for(let L=0,j=O.length;L<j;L++){const V=Array.isArray(O[L])?O[L]:[O[L]];for(let $=0,pe=V.length;$<pe;$++){const ge=V[$],K=Array.isArray(ge.value)?ge.value:[ge.value];for(let H=0,G=K.length;H<G;H++){const ne=K[H],ye=x(ne),xe=U%N,F=xe%ye.boundary,J=xe+F;U+=F,J!==0&&N-J<ye.storage&&(U+=N-J),ge.__data=new Float32Array(ye.storage/Float32Array.BYTES_PER_ELEMENT),ge.__offset=U,U+=ye.storage}}}const A=U%N;return A>0&&(U+=N-A),D.__size=U,D.__cache={},this}function x(D){const O={boundary:0,storage:0};return typeof D=="number"||typeof D=="boolean"?(O.boundary=4,O.storage=4):D.isVector2?(O.boundary=8,O.storage=8):D.isVector3||D.isColor?(O.boundary=16,O.storage=12):D.isVector4?(O.boundary=16,O.storage=16):D.isMatrix3?(O.boundary=48,O.storage=48):D.isMatrix4?(O.boundary=64,O.storage=64):D.isTexture?_t("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(D)?(O.boundary=16,O.storage=D.byteLength):_t("WebGLRenderer: Unsupported uniform value type.",D),O}function B(D){const O=D.target;O.removeEventListener("dispose",B);const U=f.indexOf(O.__bindingPointIndex);f.splice(U,1),a.deleteBuffer(l[O.id]),delete l[O.id],delete c[O.id]}function P(){for(const D in l)a.deleteBuffer(l[D]);f=[],l={},c={}}return{bind:m,update:h,dispose:P}}const bw=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 ia=null;function Ew(){return ia===null&&(ia=new Wx(bw,16,16,nr,za),ia.name="DFG_LUT",ia.minFilter=$n,ia.magFilter=$n,ia.wrapS=Ia,ia.wrapT=Ia,ia.generateMipmaps=!1,ia.needsUpdate=!0),ia}class Tw{constructor(e={}){const{canvas:i=Ib(),context:s=null,depth:l=!0,stencil:c=!1,alpha:f=!1,antialias:p=!1,premultipliedAlpha:m=!0,preserveDrawingBuffer:h=!1,powerPreference:y="default",failIfMajorPerformanceCaveat:S=!1,reversedDepthBuffer:_=!1,outputBufferType:b=Ei}=e;this.isWebGLRenderer=!0;let T;if(s!==null){if(typeof WebGLRenderingContext<"u"&&s instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");T=s.getContextAttributes().alpha}else T=f;const C=b,v=new Set([zp,Fp,Bp]),x=new Set([Ei,la,Tl,Al,Op,Pp]),B=new Uint32Array(4),P=new Int32Array(4),D=new ie;let O=null,U=null;const N=[],A=[];let L=null;this.domElement=i,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=ra,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const j=this;let V=!1,$=null,pe=null,ge=null,K=null;this._outputColorSpace=bi;let H=0,G=0,ne=null,ye=-1,xe=null;const F=new xn,J=new xn;let Ce=null;const Ue=new dt(0);let Ie=0,ae=i.width,Ae=i.height,Ee=1,He=null,nt=null;const Ke=new xn(0,0,ae,Ae),zt=new xn(0,0,ae,Ae);let ht=!1;const Et=new jp;let yt=!1,St=!1;const Mt=new dn,Ht=new ie,Gt=new xn,st={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let It=!1;function W(){return ne===null?Ee:1}let z=s;function Ye(w,Q){return i.getContext(w,Q)}try{const w={alpha:!0,depth:l,stencil:c,antialias:p,premultipliedAlpha:m,preserveDrawingBuffer:h,powerPreference:y,failIfMajorPerformanceCaveat:S};if("setAttribute"in i&&i.setAttribute("data-engine",`three.js r${Np}`),i.addEventListener("webglcontextlost",ft,!1),i.addEventListener("webglcontextrestored",rt,!1),i.addEventListener("webglcontextcreationerror",Nt,!1),z===null){const Q="webgl2";if(z=Ye(Q,w),z===null)throw Ye(Q)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(w){throw jt("WebGLRenderer: "+w.message),w}let xt,I,E,X,se,me,Ne,Oe,_e,he,Le,je,ze,Fe,Qe,Je,pt,Z,Pe,Se,Be,ke,q;function Me(){xt=new E1(z),xt.init(),Be=new mw(z,xt),I=new g1(z,xt,e,Be),E=new hw(z,xt),I.reversedDepthBuffer&&_&&E.buffers.depth.setReversed(!0),pe=z.createFramebuffer(),ge=z.createFramebuffer(),K=z.createFramebuffer(),X=new C1(z),se=new JC,me=new pw(z,xt,E,se,I,Be,X),Ne=new b1(j),Oe=new NE(z),ke=new p1(z,Oe),_e=new T1(z,Oe,X,ke),he=new R1(z,_e,Oe,ke,X),Z=new w1(z,I,me),Qe=new _1(se),Le=new QC(j,Ne,xt,I,ke,Qe),je=new Sw(j,se),ze=new tw,Fe=new ow(xt),pt=new h1(j,Ne,E,he,T,m),Je=new dw(j,he,I),q=new Mw(z,X,I,E),Pe=new m1(z,xt,X),Se=new A1(z,xt,X),X.programs=Le.programs,j.capabilities=I,j.extensions=xt,j.properties=se,j.renderLists=ze,j.shadowMap=Je,j.state=E,j.info=X}Me(),C!==Ei&&(L=new N1(C,i.width,i.height,p,l,c));const De=new xw(j,z);this.xr=De,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const w=xt.get("WEBGL_lose_context");w&&w.loseContext()},this.forceContextRestore=function(){const w=xt.get("WEBGL_lose_context");w&&w.restoreContext()},this.getPixelRatio=function(){return Ee},this.setPixelRatio=function(w){w!==void 0&&(Ee=w,this.setSize(ae,Ae,!1))},this.getSize=function(w){return w.set(ae,Ae)},this.setSize=function(w,Q,fe=!0){if(De.isPresenting){_t("WebGLRenderer: Can't change size while VR device is presenting.");return}ae=w,Ae=Q,i.width=Math.floor(w*Ee),i.height=Math.floor(Q*Ee),fe===!0&&(i.style.width=w+"px",i.style.height=Q+"px"),L!==null&&L.setSize(i.width,i.height),this.setViewport(0,0,w,Q)},this.getDrawingBufferSize=function(w){return w.set(ae*Ee,Ae*Ee).floor()},this.setDrawingBufferSize=function(w,Q,fe){ae=w,Ae=Q,Ee=fe,i.width=Math.floor(w*fe),i.height=Math.floor(Q*fe),this.setViewport(0,0,w,Q)},this.setEffects=function(w){if(C===Ei){jt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(w){for(let Q=0;Q<w.length;Q++)if(w[Q].isOutputPass===!0){_t("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}L.setEffects(w||[])},this.getCurrentViewport=function(w){return w.copy(F)},this.getViewport=function(w){return w.copy(Ke)},this.setViewport=function(w,Q,fe,ce){w.isVector4?Ke.set(w.x,w.y,w.z,w.w):Ke.set(w,Q,fe,ce),E.viewport(F.copy(Ke).multiplyScalar(Ee).round())},this.getScissor=function(w){return w.copy(zt)},this.setScissor=function(w,Q,fe,ce){w.isVector4?zt.set(w.x,w.y,w.z,w.w):zt.set(w,Q,fe,ce),E.scissor(J.copy(zt).multiplyScalar(Ee).round())},this.getScissorTest=function(){return ht},this.setScissorTest=function(w){E.setScissorTest(ht=w)},this.setOpaqueSort=function(w){He=w},this.setTransparentSort=function(w){nt=w},this.getClearColor=function(w){return w.copy(pt.getClearColor())},this.setClearColor=function(){pt.setClearColor(...arguments)},this.getClearAlpha=function(){return pt.getClearAlpha()},this.setClearAlpha=function(){pt.setClearAlpha(...arguments)},this.clear=function(w=!0,Q=!0,fe=!0){let ce=0;if(w){let ue=!1;if(ne!==null){const Xe=ne.texture.format;ue=v.has(Xe)}if(ue){const Xe=ne.texture.type,Ze=x.has(Xe),Ve=pt.getClearColor(),et=pt.getClearAlpha(),$e=Ve.r,ct=Ve.g,Ct=Ve.b;Ze?(B[0]=$e,B[1]=ct,B[2]=Ct,B[3]=et,z.clearBufferuiv(z.COLOR,0,B)):(P[0]=$e,P[1]=ct,P[2]=Ct,P[3]=et,z.clearBufferiv(z.COLOR,0,P))}else ce|=z.COLOR_BUFFER_BIT}Q&&(ce|=z.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),fe&&(ce|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ce!==0&&z.clear(ce)},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(w){w.setRenderer(this),$=w},this.dispose=function(){i.removeEventListener("webglcontextlost",ft,!1),i.removeEventListener("webglcontextrestored",rt,!1),i.removeEventListener("webglcontextcreationerror",Nt,!1),pt.dispose(),ze.dispose(),Fe.dispose(),se.dispose(),Ne.dispose(),he.dispose(),ke.dispose(),q.dispose(),Le.dispose(),De.dispose(),De.removeEventListener("sessionstart",we),De.removeEventListener("sessionend",Ge),it.stop()};function ft(w){w.preventDefault(),nv("WebGLRenderer: Context Lost."),V=!0}function rt(){nv("WebGLRenderer: Context Restored."),V=!1;const w=X.autoReset,Q=Je.enabled,fe=Je.autoUpdate,ce=Je.needsUpdate,ue=Je.type;Me(),X.autoReset=w,Je.enabled=Q,Je.autoUpdate=fe,Je.needsUpdate=ce,Je.type=ue}function Nt(w){jt("WebGLRenderer: A WebGL context could not be created. Reason: ",w.statusMessage)}function Hn(w){const Q=w.target;Q.removeEventListener("dispose",Hn),ua(Q)}function ua(w){Ga(w),se.remove(w)}function Ga(w){const Q=se.get(w).programs;Q!==void 0&&(Q.forEach(function(fe){Le.releaseProgram(fe)}),w.isShaderMaterial&&Le.releaseShaderCache(w))}this.renderBufferDirect=function(w,Q,fe,ce,ue,Xe){Q===null&&(Q=st);const Ze=ue.isMesh&&ue.matrixWorld.determinantAffine()<0,Ve=Ti(w,Q,fe,ce,ue);E.setMaterial(ce,Ze);let et=fe.index,$e=1;if(ce.wireframe===!0){if(et=_e.getWireframeAttribute(fe),et===void 0)return;$e=2}const ct=fe.drawRange,Ct=fe.attributes.position;let ot=ct.start*$e,Xt=(ct.start+ct.count)*$e;Xe!==null&&(ot=Math.max(ot,Xe.start*$e),Xt=Math.min(Xt,(Xe.start+Xe.count)*$e)),et!==null?(ot=Math.max(ot,0),Xt=Math.min(Xt,et.count)):Ct!=null&&(ot=Math.max(ot,0),Xt=Math.min(Xt,Ct.count));const gn=Xt-ot;if(gn<0||gn===1/0)return;ke.setup(ue,ce,Ve,fe,et);let cn,Qt=Pe;if(et!==null&&(cn=Oe.get(et),Qt=Se,Qt.setIndex(cn)),ue.isMesh)ce.wireframe===!0?(E.setLineWidth(ce.wireframeLinewidth*W()),Qt.setMode(z.LINES)):Qt.setMode(z.TRIANGLES);else if(ue.isLine){let Jt=ce.linewidth;Jt===void 0&&(Jt=1),E.setLineWidth(Jt*W()),ue.isLineSegments?Qt.setMode(z.LINES):ue.isLineLoop?Qt.setMode(z.LINE_LOOP):Qt.setMode(z.LINE_STRIP)}else ue.isPoints?Qt.setMode(z.POINTS):ue.isSprite&&Qt.setMode(z.TRIANGLES);if(ue.isBatchedMesh)if(xt.get("WEBGL_multi_draw"))Qt.renderMultiDraw(ue._multiDrawStarts,ue._multiDrawCounts,ue._multiDrawCount);else{const Jt=ue._multiDrawStarts,qe=ue._multiDrawCounts,qn=ue._multiDrawCount,Ut=et?Oe.get(et).bytesPerElement:1,Dn=se.get(ce).currentProgram.getUniforms();for(let di=0;di<qn;di++)Dn.setValue(z,"_gl_DrawID",di),Qt.render(Jt[di]/Ut,qe[di])}else if(ue.isInstancedMesh)Qt.renderInstances(ot,gn,ue.count);else if(fe.isInstancedBufferGeometry){const Jt=fe._maxInstanceCount!==void 0?fe._maxInstanceCount:1/0,qe=Math.min(fe.instanceCount,Jt);Qt.renderInstances(ot,gn,qe)}else Qt.render(ot,gn)};function Va(w,Q,fe){w.transparent===!0&&w.side===Pa&&w.forceSinglePass===!1?(w.side=ui,w.needsUpdate=!0,yn(w,Q,fe),w.side=Es,w.needsUpdate=!0,yn(w,Q,fe),w.side=Pa):yn(w,Q,fe)}this.compile=function(w,Q,fe=null){fe===null&&(fe=w),U=Fe.get(fe),U.init(Q),A.push(U),fe.traverseVisible(function(ue){ue.isLight&&ue.layers.test(Q.layers)&&(U.pushLight(ue),ue.castShadow&&U.pushShadow(ue))}),w!==fe&&w.traverseVisible(function(ue){ue.isLight&&ue.layers.test(Q.layers)&&(U.pushLight(ue),ue.castShadow&&U.pushShadow(ue))}),U.setupLights();const ce=new Set;return w.traverse(function(ue){if(!(ue.isMesh||ue.isPoints||ue.isLine||ue.isSprite))return;const Xe=ue.material;if(Xe)if(Array.isArray(Xe))for(let Ze=0;Ze<Xe.length;Ze++){const Ve=Xe[Ze];Va(Ve,fe,ue),ce.add(Ve)}else Va(Xe,fe,ue),ce.add(Xe)}),U=A.pop(),ce},this.compileAsync=function(w,Q,fe=null){const ce=this.compile(w,Q,fe);return new Promise(ue=>{function Xe(){if(ce.forEach(function(Ze){se.get(Ze).currentProgram.isReady()&&ce.delete(Ze)}),ce.size===0){ue(w);return}setTimeout(Xe,10)}xt.get("KHR_parallel_shader_compile")!==null?Xe():setTimeout(Xe,10)})};let ka=null;function re(w){ka&&ka(w)}function we(){it.stop()}function Ge(){it.start()}const it=new Qx;it.setAnimationLoop(re),typeof self<"u"&&it.setContext(self),this.setAnimationLoop=function(w){ka=w,De.setAnimationLoop(w),w===null?it.stop():it.start()},De.addEventListener("sessionstart",we),De.addEventListener("sessionend",Ge),this.render=function(w,Q){if(Q!==void 0&&Q.isCamera!==!0){jt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(V===!0)return;$!==null&&$.renderStart(w,Q);const fe=De.enabled===!0&&De.isPresenting===!0,ce=L!==null&&(ne===null||fe)&&L.begin(j,ne);if(w.matrixWorldAutoUpdate===!0&&w.updateMatrixWorld(),Q.parent===null&&Q.matrixWorldAutoUpdate===!0&&Q.updateMatrixWorld(),De.enabled===!0&&De.isPresenting===!0&&(L===null||L.isCompositing()===!1)&&(De.cameraAutoUpdate===!0&&De.updateCamera(Q),Q=De.getCamera()),w.isScene===!0&&w.onBeforeRender(j,w,Q,ne),U=Fe.get(w,A.length),U.init(Q),U.state.textureUnits=me.getTextureUnits(),A.push(U),Mt.multiplyMatrices(Q.projectionMatrix,Q.matrixWorldInverse),Et.setFromProjectionMatrix(Mt,sa,Q.reversedDepth),St=this.localClippingEnabled,yt=Qe.init(this.clippingPlanes,St),O=ze.get(w,N.length),O.init(),N.push(O),De.enabled===!0&&De.isPresenting===!0){const Ze=j.xr.getDepthSensingMesh();Ze!==null&<(Ze,Q,-1/0,j.sortObjects)}lt(w,Q,0,j.sortObjects),O.finish(),j.sortObjects===!0&&O.sort(He,nt,Q.reversedDepth),It=De.enabled===!1||De.isPresenting===!1||De.hasDepthSensing()===!1,It&&pt.addToRenderList(O,w),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),yt===!0&&Qe.beginShadows();const ue=U.state.shadowsArray;if(Je.render(ue,w,Q),yt===!0&&Qe.endShadows(),(ce&&L.hasRenderPass())===!1){const Ze=O.opaque,Ve=O.transmissive;if(U.setupLights(),Q.isArrayCamera){const et=Q.cameras;if(Ve.length>0)for(let $e=0,ct=et.length;$e<ct;$e++){const Ct=et[$e];In(Ze,Ve,w,Ct)}It&&pt.render(w);for(let $e=0,ct=et.length;$e<ct;$e++){const Ct=et[$e];vt(O,w,Ct,Ct.viewport)}}else Ve.length>0&&In(Ze,Ve,w,Q),It&&pt.render(w),vt(O,w,Q)}ne!==null&&G===0&&(me.updateMultisampleRenderTarget(ne),me.updateRenderTargetMipmap(ne)),ce&&L.end(j),w.isScene===!0&&w.onAfterRender(j,w,Q),ke.resetDefaultState(),ye=-1,xe=null,A.pop(),A.length>0?(U=A[A.length-1],me.setTextureUnits(U.state.textureUnits),yt===!0&&Qe.setGlobalState(j.clippingPlanes,U.state.camera)):U=null,N.pop(),N.length>0?O=N[N.length-1]:O=null,$!==null&&$.renderEnd()};function lt(w,Q,fe,ce){if(w.visible===!1)return;if(w.layers.test(Q.layers)){if(w.isGroup)fe=w.renderOrder;else if(w.isLOD)w.autoUpdate===!0&&w.update(Q);else if(w.isLightProbeGrid)U.pushLightProbeGrid(w);else if(w.isLight)U.pushLight(w),w.castShadow&&U.pushShadow(w);else if(w.isSprite){if(!w.frustumCulled||Et.intersectsSprite(w)){ce&&Gt.setFromMatrixPosition(w.matrixWorld).applyMatrix4(Mt);const Ze=he.update(w),Ve=w.material;Ve.visible&&O.push(w,Ze,Ve,fe,Gt.z,null)}}else if((w.isMesh||w.isLine||w.isPoints)&&(!w.frustumCulled||Et.intersectsObject(w))){const Ze=he.update(w),Ve=w.material;if(ce&&(w.boundingSphere!==void 0?(w.boundingSphere===null&&w.computeBoundingSphere(),Gt.copy(w.boundingSphere.center)):(Ze.boundingSphere===null&&Ze.computeBoundingSphere(),Gt.copy(Ze.boundingSphere.center)),Gt.applyMatrix4(w.matrixWorld).applyMatrix4(Mt)),Array.isArray(Ve)){const et=Ze.groups;for(let $e=0,ct=et.length;$e<ct;$e++){const Ct=et[$e],ot=Ve[Ct.materialIndex];ot&&ot.visible&&O.push(w,Ze,ot,fe,Gt.z,Ct)}}else Ve.visible&&O.push(w,Ze,Ve,fe,Gt.z,null)}}const Xe=w.children;for(let Ze=0,Ve=Xe.length;Ze<Ve;Ze++)lt(Xe[Ze],Q,fe,ce)}function vt(w,Q,fe,ce){const{opaque:ue,transmissive:Xe,transparent:Ze}=w;U.setupLightsView(fe),yt===!0&&Qe.setGlobalState(j.clippingPlanes,fe),ce&&E.viewport(F.copy(ce)),ue.length>0&&Zt(ue,Q,fe),Xe.length>0&&Zt(Xe,Q,fe),Ze.length>0&&Zt(Ze,Q,fe),E.buffers.depth.setTest(!0),E.buffers.depth.setMask(!0),E.buffers.color.setMask(!0),E.setPolygonOffset(!1)}function In(w,Q,fe,ce){if((fe.isScene===!0?fe.overrideMaterial:null)!==null)return;if(U.state.transmissionRenderTarget[ce.id]===void 0){const ot=xt.has("EXT_color_buffer_half_float")||xt.has("EXT_color_buffer_float");U.state.transmissionRenderTarget[ce.id]=new oa(1,1,{generateMipmaps:!0,type:ot?za:Ei,minFilter:Qs,samples:Math.max(4,I.samples),stencilBuffer:c,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:kt.workingColorSpace})}const Xe=U.state.transmissionRenderTarget[ce.id],Ze=ce.viewport||F;Xe.setSize(Ze.z*j.transmissionResolutionScale,Ze.w*j.transmissionResolutionScale);const Ve=j.getRenderTarget(),et=j.getActiveCubeFace(),$e=j.getActiveMipmapLevel();j.setRenderTarget(Xe),j.getClearColor(Ue),Ie=j.getClearAlpha(),Ie<1&&j.setClearColor(16777215,.5),j.clear(),It&&pt.render(fe);const ct=j.toneMapping;j.toneMapping=ra;const Ct=ce.viewport;if(ce.viewport!==void 0&&(ce.viewport=void 0),U.setupLightsView(ce),yt===!0&&Qe.setGlobalState(j.clippingPlanes,ce),Zt(w,fe,ce),me.updateMultisampleRenderTarget(Xe),me.updateRenderTargetMipmap(Xe),xt.has("WEBGL_multisampled_render_to_texture")===!1){let ot=!1;for(let Xt=0,gn=Q.length;Xt<gn;Xt++){const cn=Q[Xt],{object:Qt,geometry:Jt,material:qe,group:qn}=cn;if(qe.side===Pa&&Qt.layers.test(ce.layers)){const Ut=qe.side;qe.side=ui,qe.needsUpdate=!0,hn(Qt,fe,ce,Jt,qe,qn),qe.side=Ut,qe.needsUpdate=!0,ot=!0}}ot===!0&&(me.updateMultisampleRenderTarget(Xe),me.updateRenderTargetMipmap(Xe))}j.setRenderTarget(Ve,et,$e),j.setClearColor(Ue,Ie),Ct!==void 0&&(ce.viewport=Ct),j.toneMapping=ct}function Zt(w,Q,fe){const ce=Q.isScene===!0?Q.overrideMaterial:null;for(let ue=0,Xe=w.length;ue<Xe;ue++){const Ze=w[ue],{object:Ve,geometry:et,group:$e}=Ze;let ct=Ze.material;ct.allowOverride===!0&&ce!==null&&(ct=ce),Ve.layers.test(fe.layers)&&hn(Ve,Q,fe,et,ct,$e)}}function hn(w,Q,fe,ce,ue,Xe){w.onBeforeRender(j,Q,fe,ce,ue,Xe),w.modelViewMatrix.multiplyMatrices(fe.matrixWorldInverse,w.matrixWorld),w.normalMatrix.getNormalMatrix(w.modelViewMatrix),ue.onBeforeRender(j,Q,fe,ce,w,Xe),ue.transparent===!0&&ue.side===Pa&&ue.forceSinglePass===!1?(ue.side=ui,ue.needsUpdate=!0,j.renderBufferDirect(fe,Q,ce,ue,w,Xe),ue.side=Es,ue.needsUpdate=!0,j.renderBufferDirect(fe,Q,ce,ue,w,Xe),ue.side=Pa):j.renderBufferDirect(fe,Q,ce,ue,w,Xe),w.onAfterRender(j,Q,fe,ce,ue,Xe)}function yn(w,Q,fe){Q.isScene!==!0&&(Q=st);const ce=se.get(w),ue=U.state.lights,Xe=U.state.shadowsArray,Ze=ue.state.version,Ve=Le.getParameters(w,ue.state,Xe,Q,fe,U.state.lightProbeGridArray),et=Le.getProgramCacheKey(Ve);let $e=ce.programs;ce.environment=w.isMeshStandardMaterial||w.isMeshLambertMaterial||w.isMeshPhongMaterial?Q.environment:null,ce.fog=Q.fog;const ct=w.isMeshStandardMaterial||w.isMeshLambertMaterial&&!w.envMap||w.isMeshPhongMaterial&&!w.envMap;ce.envMap=Ne.get(w.envMap||ce.environment,ct),ce.envMapRotation=ce.environment!==null&&w.envMap===null?Q.environmentRotation:w.envMapRotation,$e===void 0&&(w.addEventListener("dispose",Hn),$e=new Map,ce.programs=$e);let Ct=$e.get(et);if(Ct!==void 0){if(ce.currentProgram===Ct&&ce.lightsStateVersion===Ze)return Gn(w,Ve),Ct}else Ve.uniforms=Le.getUniforms(w),$!==null&&w.isNodeMaterial&&$.build(w,fe,Ve),w.onBeforeCompile(Ve,j),Ct=Le.acquireProgram(Ve,et),$e.set(et,Ct),ce.uniforms=Ve.uniforms;const ot=ce.uniforms;return(!w.isShaderMaterial&&!w.isRawShaderMaterial||w.clipping===!0)&&(ot.clippingPlanes=Qe.uniform),Gn(w,Ve),ce.needsLights=Nl(w),ce.lightsStateVersion=Ze,ce.needsLights&&(ot.ambientLightColor.value=ue.state.ambient,ot.lightProbe.value=ue.state.probe,ot.directionalLights.value=ue.state.directional,ot.directionalLightShadows.value=ue.state.directionalShadow,ot.spotLights.value=ue.state.spot,ot.spotLightShadows.value=ue.state.spotShadow,ot.rectAreaLights.value=ue.state.rectArea,ot.ltc_1.value=ue.state.rectAreaLTC1,ot.ltc_2.value=ue.state.rectAreaLTC2,ot.pointLights.value=ue.state.point,ot.pointLightShadows.value=ue.state.pointShadow,ot.hemisphereLights.value=ue.state.hemi,ot.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,ot.spotLightMatrix.value=ue.state.spotLightMatrix,ot.spotLightMap.value=ue.state.spotLightMap,ot.pointShadowMatrix.value=ue.state.pointShadowMatrix),ce.lightProbeGrid=U.state.lightProbeGridArray.length>0,ce.currentProgram=Ct,ce.uniformsList=null,Ct}function fn(w){if(w.uniformsList===null){const Q=w.currentProgram.getUniforms();w.uniformsList=Su.seqWithValue(Q.seq,w.uniforms)}return w.uniformsList}function Gn(w,Q){const fe=se.get(w);fe.outputColorSpace=Q.outputColorSpace,fe.batching=Q.batching,fe.batchingColor=Q.batchingColor,fe.instancing=Q.instancing,fe.instancingColor=Q.instancingColor,fe.instancingMorph=Q.instancingMorph,fe.skinning=Q.skinning,fe.morphTargets=Q.morphTargets,fe.morphNormals=Q.morphNormals,fe.morphColors=Q.morphColors,fe.morphTargetsCount=Q.morphTargetsCount,fe.numClippingPlanes=Q.numClippingPlanes,fe.numIntersection=Q.numClipIntersection,fe.vertexAlphas=Q.vertexAlphas,fe.vertexTangents=Q.vertexTangents,fe.toneMapping=Q.toneMapping}function Bn(w,Q){if(w.length===0)return null;if(w.length===1)return w[0].texture!==null?w[0]:null;D.setFromMatrixPosition(Q.matrixWorld);for(let fe=0,ce=w.length;fe<ce;fe++){const ue=w[fe];if(ue.texture!==null&&ue.boundingBox.containsPoint(D))return ue}return null}function Ti(w,Q,fe,ce,ue){Q.isScene!==!0&&(Q=st),me.resetTextureUnits();const Xe=Q.fog,Ze=ce.isMeshStandardMaterial||ce.isMeshLambertMaterial||ce.isMeshPhongMaterial?Q.environment:null,Ve=ne===null?j.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:kt.workingColorSpace,et=ce.isMeshStandardMaterial||ce.isMeshLambertMaterial&&!ce.envMap||ce.isMeshPhongMaterial&&!ce.envMap,$e=Ne.get(ce.envMap||Ze,et),ct=ce.vertexColors===!0&&!!fe.attributes.color&&fe.attributes.color.itemSize===4,Ct=!!fe.attributes.tangent&&(!!ce.normalMap||ce.anisotropy>0),ot=!!fe.morphAttributes.position,Xt=!!fe.morphAttributes.normal,gn=!!fe.morphAttributes.color;let cn=ra;ce.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(cn=j.toneMapping);const Qt=fe.morphAttributes.position||fe.morphAttributes.normal||fe.morphAttributes.color,Jt=Qt!==void 0?Qt.length:0,qe=se.get(ce),qn=U.state.lights;if(yt===!0&&(St===!0||w!==xe)){const $t=w===xe&&ce.id===ye;Qe.setState(ce,w,$t)}let Ut=!1;ce.version===qe.__version?(qe.needsLights&&qe.lightsStateVersion!==qn.state.version||qe.outputColorSpace!==Ve||ue.isBatchedMesh&&qe.batching===!1||!ue.isBatchedMesh&&qe.batching===!0||ue.isBatchedMesh&&qe.batchingColor===!0&&ue.colorTexture===null||ue.isBatchedMesh&&qe.batchingColor===!1&&ue.colorTexture!==null||ue.isInstancedMesh&&qe.instancing===!1||!ue.isInstancedMesh&&qe.instancing===!0||ue.isSkinnedMesh&&qe.skinning===!1||!ue.isSkinnedMesh&&qe.skinning===!0||ue.isInstancedMesh&&qe.instancingColor===!0&&ue.instanceColor===null||ue.isInstancedMesh&&qe.instancingColor===!1&&ue.instanceColor!==null||ue.isInstancedMesh&&qe.instancingMorph===!0&&ue.morphTexture===null||ue.isInstancedMesh&&qe.instancingMorph===!1&&ue.morphTexture!==null||qe.envMap!==$e||ce.fog===!0&&qe.fog!==Xe||qe.numClippingPlanes!==void 0&&(qe.numClippingPlanes!==Qe.numPlanes||qe.numIntersection!==Qe.numIntersection)||qe.vertexAlphas!==ct||qe.vertexTangents!==Ct||qe.morphTargets!==ot||qe.morphNormals!==Xt||qe.morphColors!==gn||qe.toneMapping!==cn||qe.morphTargetsCount!==Jt||!!qe.lightProbeGrid!=U.state.lightProbeGridArray.length>0)&&(Ut=!0):(Ut=!0,qe.__version=ce.version);let Dn=qe.currentProgram;Ut===!0&&(Dn=yn(ce,Q,ue),$&&ce.isNodeMaterial&&$.onUpdateProgram(ce,Dn,qe));let di=!1,zi=!1,hi=!1;const en=Dn.getUniforms(),_n=qe.uniforms;if(E.useProgram(Dn.program)&&(di=!0,zi=!0,hi=!0),ce.id!==ye&&(ye=ce.id,zi=!0),qe.needsLights){const $t=Bn(U.state.lightProbeGridArray,ue);qe.lightProbeGrid!==$t&&(qe.lightProbeGrid=$t,zi=!0)}if(di||xe!==w){E.buffers.depth.getReversed()&&w.reversedDepth!==!0&&(w._reversedDepth=!0,w.updateProjectionMatrix()),en.setValue(z,"projectionMatrix",w.projectionMatrix),en.setValue(z,"viewMatrix",w.matrixWorldInverse);const $i=en.map.cameraPosition;$i!==void 0&&$i.setValue(z,Ht.setFromMatrixPosition(w.matrixWorld)),I.logarithmicDepthBuffer&&en.setValue(z,"logDepthBufFC",2/(Math.log(w.far+1)/Math.LN2)),(ce.isMeshPhongMaterial||ce.isMeshToonMaterial||ce.isMeshLambertMaterial||ce.isMeshBasicMaterial||ce.isMeshStandardMaterial||ce.isShaderMaterial)&&en.setValue(z,"isOrthographic",w.isOrthographicCamera===!0),xe!==w&&(xe=w,zi=!0,hi=!0)}if(qe.needsLights&&(qn.state.directionalShadowMap.length>0&&en.setValue(z,"directionalShadowMap",qn.state.directionalShadowMap,me),qn.state.spotShadowMap.length>0&&en.setValue(z,"spotShadowMap",qn.state.spotShadowMap,me),qn.state.pointShadowMap.length>0&&en.setValue(z,"pointShadowMap",qn.state.pointShadowMap,me)),ue.isSkinnedMesh){en.setOptional(z,ue,"bindMatrix"),en.setOptional(z,ue,"bindMatrixInverse");const $t=ue.skeleton;$t&&($t.boneTexture===null&&$t.computeBoneTexture(),en.setValue(z,"boneTexture",$t.boneTexture,me))}ue.isBatchedMesh&&(en.setOptional(z,ue,"batchingTexture"),en.setValue(z,"batchingTexture",ue._matricesTexture,me),en.setOptional(z,ue,"batchingIdTexture"),en.setValue(z,"batchingIdTexture",ue._indirectTexture,me),en.setOptional(z,ue,"batchingColorTexture"),ue._colorsTexture!==null&&en.setValue(z,"batchingColorTexture",ue._colorsTexture,me));const Hi=fe.morphAttributes;if((Hi.position!==void 0||Hi.normal!==void 0||Hi.color!==void 0)&&Z.update(ue,fe,Dn),(zi||qe.receiveShadow!==ue.receiveShadow)&&(qe.receiveShadow=ue.receiveShadow,en.setValue(z,"receiveShadow",ue.receiveShadow)),(ce.isMeshStandardMaterial||ce.isMeshLambertMaterial||ce.isMeshPhongMaterial)&&ce.envMap===null&&Q.environment!==null&&(_n.envMapIntensity.value=Q.environmentIntensity),_n.dfgLUT!==void 0&&(_n.dfgLUT.value=Ew()),zi){if(en.setValue(z,"toneMappingExposure",j.toneMappingExposure),qe.needsLights&&Kt(_n,hi),Xe&&ce.fog===!0&&je.refreshFogUniforms(_n,Xe),je.refreshMaterialUniforms(_n,ce,Ee,Ae,U.state.transmissionRenderTarget[w.id]),qe.needsLights&&qe.lightProbeGrid){const $t=qe.lightProbeGrid;_n.probesSH.value=$t.texture,_n.probesMin.value.copy($t.boundingBox.min),_n.probesMax.value.copy($t.boundingBox.max),_n.probesResolution.value.copy($t.resolution)}Su.upload(z,fn(qe),_n,me)}if(ce.isShaderMaterial&&ce.uniformsNeedUpdate===!0&&(Su.upload(z,fn(qe),_n,me),ce.uniformsNeedUpdate=!1),ce.isSpriteMaterial&&en.setValue(z,"center",ue.center),en.setValue(z,"modelViewMatrix",ue.modelViewMatrix),en.setValue(z,"normalMatrix",ue.normalMatrix),en.setValue(z,"modelMatrix",ue.matrixWorld),ce.uniformsGroups!==void 0){const $t=ce.uniformsGroups;for(let $i=0,ja=$t.length;$i<ja;$i++){const Rs=$t[$i];q.update(Rs,Dn),q.bind(Rs,Dn)}}return Dn}function Kt(w,Q){w.ambientLightColor.needsUpdate=Q,w.lightProbe.needsUpdate=Q,w.directionalLights.needsUpdate=Q,w.directionalLightShadows.needsUpdate=Q,w.pointLights.needsUpdate=Q,w.pointLightShadows.needsUpdate=Q,w.spotLights.needsUpdate=Q,w.spotLightShadows.needsUpdate=Q,w.rectAreaLights.needsUpdate=Q,w.hemisphereLights.needsUpdate=Q}function Nl(w){return w.isMeshLambertMaterial||w.isMeshToonMaterial||w.isMeshPhongMaterial||w.isMeshStandardMaterial||w.isShadowMaterial||w.isShaderMaterial&&w.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return ne},this.setRenderTargetTextures=function(w,Q,fe){const ce=se.get(w);ce.__autoAllocateDepthBuffer=w.resolveDepthBuffer===!1,ce.__autoAllocateDepthBuffer===!1&&(ce.__useRenderToTexture=!1),se.get(w.texture).__webglTexture=Q,se.get(w.depthTexture).__webglTexture=ce.__autoAllocateDepthBuffer?void 0:fe,ce.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(w,Q){const fe=se.get(w);fe.__webglFramebuffer=Q,fe.__useDefaultFramebuffer=Q===void 0},this.setRenderTarget=function(w,Q=0,fe=0){ne=w,H=Q,G=fe;let ce=null,ue=!1,Xe=!1;if(w){const Ve=se.get(w);if(Ve.__useDefaultFramebuffer!==void 0){E.bindFramebuffer(z.FRAMEBUFFER,Ve.__webglFramebuffer),F.copy(w.viewport),J.copy(w.scissor),Ce=w.scissorTest,E.viewport(F),E.scissor(J),E.setScissorTest(Ce),ye=-1;return}else if(Ve.__webglFramebuffer===void 0)me.setupRenderTarget(w);else if(Ve.__hasExternalTextures)me.rebindTextures(w,se.get(w.texture).__webglTexture,se.get(w.depthTexture).__webglTexture);else if(w.depthBuffer){const ct=w.depthTexture;if(Ve.__boundDepthTexture!==ct){if(ct!==null&&se.has(ct)&&(w.width!==ct.image.width||w.height!==ct.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");me.setupDepthRenderbuffer(w)}}const et=w.texture;(et.isData3DTexture||et.isDataArrayTexture||et.isCompressedArrayTexture)&&(Xe=!0);const $e=se.get(w).__webglFramebuffer;w.isWebGLCubeRenderTarget?(Array.isArray($e[Q])?ce=$e[Q][fe]:ce=$e[Q],ue=!0):w.samples>0&&me.useMultisampledRTT(w)===!1?ce=se.get(w).__webglMultisampledFramebuffer:Array.isArray($e)?ce=$e[fe]:ce=$e,F.copy(w.viewport),J.copy(w.scissor),Ce=w.scissorTest}else F.copy(Ke).multiplyScalar(Ee).floor(),J.copy(zt).multiplyScalar(Ee).floor(),Ce=ht;if(fe!==0&&(ce=pe),E.bindFramebuffer(z.FRAMEBUFFER,ce)&&E.drawBuffers(w,ce),E.viewport(F),E.scissor(J),E.setScissorTest(Ce),ue){const Ve=se.get(w.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+Q,Ve.__webglTexture,fe)}else if(Xe){const Ve=Q;for(let et=0;et<w.textures.length;et++){const $e=se.get(w.textures[et]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+et,$e.__webglTexture,fe,Ve)}}else if(w!==null&&fe!==0){const Ve=se.get(w.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Ve.__webglTexture,fe)}ye=-1},this.readRenderTargetPixels=function(w,Q,fe,ce,ue,Xe,Ze,Ve=0){if(!(w&&w.isWebGLRenderTarget)){jt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let et=se.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&Ze!==void 0&&(et=et[Ze]),et){E.bindFramebuffer(z.FRAMEBUFFER,et);try{const $e=w.textures[Ve],ct=$e.format,Ct=$e.type;if(w.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Ve),!I.textureFormatReadable(ct)){jt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!I.textureTypeReadable(Ct)){jt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Q>=0&&Q<=w.width-ce&&fe>=0&&fe<=w.height-ue&&z.readPixels(Q,fe,ce,ue,Be.convert(ct),Be.convert(Ct),Xe)}finally{const $e=ne!==null?se.get(ne).__webglFramebuffer:null;E.bindFramebuffer(z.FRAMEBUFFER,$e)}}},this.readRenderTargetPixelsAsync=async function(w,Q,fe,ce,ue,Xe,Ze,Ve=0){if(!(w&&w.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let et=se.get(w).__webglFramebuffer;if(w.isWebGLCubeRenderTarget&&Ze!==void 0&&(et=et[Ze]),et)if(Q>=0&&Q<=w.width-ce&&fe>=0&&fe<=w.height-ue){E.bindFramebuffer(z.FRAMEBUFFER,et);const $e=w.textures[Ve],ct=$e.format,Ct=$e.type;if(w.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+Ve),!I.textureFormatReadable(ct))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!I.textureTypeReadable(Ct))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const ot=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,ot),z.bufferData(z.PIXEL_PACK_BUFFER,Xe.byteLength,z.STREAM_READ),z.readPixels(Q,fe,ce,ue,Be.convert(ct),Be.convert(Ct),0);const Xt=ne!==null?se.get(ne).__webglFramebuffer:null;E.bindFramebuffer(z.FRAMEBUFFER,Xt);const gn=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await Bb(z,gn,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,ot),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,Xe),z.deleteBuffer(ot),z.deleteSync(gn),Xe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(w,Q=null,fe=0){const ce=Math.pow(2,-fe),ue=Math.floor(w.image.width*ce),Xe=Math.floor(w.image.height*ce),Ze=Q!==null?Q.x:0,Ve=Q!==null?Q.y:0;me.setTexture2D(w,0),z.copyTexSubImage2D(z.TEXTURE_2D,fe,0,0,Ze,Ve,ue,Xe),E.unbindTexture()},this.copyTextureToTexture=function(w,Q,fe=null,ce=null,ue=0,Xe=0){let Ze,Ve,et,$e,ct,Ct,ot,Xt,gn;const cn=w.isCompressedTexture?w.mipmaps[Xe]:w.image;if(fe!==null)Ze=fe.max.x-fe.min.x,Ve=fe.max.y-fe.min.y,et=fe.isBox3?fe.max.z-fe.min.z:1,$e=fe.min.x,ct=fe.min.y,Ct=fe.isBox3?fe.min.z:0;else{const _n=Math.pow(2,-ue);Ze=Math.floor(cn.width*_n),Ve=Math.floor(cn.height*_n),w.isDataArrayTexture?et=cn.depth:w.isData3DTexture?et=Math.floor(cn.depth*_n):et=1,$e=0,ct=0,Ct=0}ce!==null?(ot=ce.x,Xt=ce.y,gn=ce.z):(ot=0,Xt=0,gn=0);const Qt=Be.convert(Q.format),Jt=Be.convert(Q.type);let qe;Q.isData3DTexture?(me.setTexture3D(Q,0),qe=z.TEXTURE_3D):Q.isDataArrayTexture||Q.isCompressedArrayTexture?(me.setTexture2DArray(Q,0),qe=z.TEXTURE_2D_ARRAY):(me.setTexture2D(Q,0),qe=z.TEXTURE_2D),E.activeTexture(z.TEXTURE0),E.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,Q.flipY),E.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Q.premultiplyAlpha),E.pixelStorei(z.UNPACK_ALIGNMENT,Q.unpackAlignment);const qn=E.getParameter(z.UNPACK_ROW_LENGTH),Ut=E.getParameter(z.UNPACK_IMAGE_HEIGHT),Dn=E.getParameter(z.UNPACK_SKIP_PIXELS),di=E.getParameter(z.UNPACK_SKIP_ROWS),zi=E.getParameter(z.UNPACK_SKIP_IMAGES);E.pixelStorei(z.UNPACK_ROW_LENGTH,cn.width),E.pixelStorei(z.UNPACK_IMAGE_HEIGHT,cn.height),E.pixelStorei(z.UNPACK_SKIP_PIXELS,$e),E.pixelStorei(z.UNPACK_SKIP_ROWS,ct),E.pixelStorei(z.UNPACK_SKIP_IMAGES,Ct);const hi=w.isDataArrayTexture||w.isData3DTexture,en=Q.isDataArrayTexture||Q.isData3DTexture;if(w.isDepthTexture){const _n=se.get(w),Hi=se.get(Q),$t=se.get(_n.__renderTarget),$i=se.get(Hi.__renderTarget);E.bindFramebuffer(z.READ_FRAMEBUFFER,$t.__webglFramebuffer),E.bindFramebuffer(z.DRAW_FRAMEBUFFER,$i.__webglFramebuffer);for(let ja=0;ja<et;ja++)hi&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,se.get(w).__webglTexture,ue,Ct+ja),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,se.get(Q).__webglTexture,Xe,gn+ja)),z.blitFramebuffer($e,ct,Ze,Ve,ot,Xt,Ze,Ve,z.DEPTH_BUFFER_BIT,z.NEAREST);E.bindFramebuffer(z.READ_FRAMEBUFFER,null),E.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(ue!==0||w.isRenderTargetTexture||se.has(w)){const _n=se.get(w),Hi=se.get(Q);E.bindFramebuffer(z.READ_FRAMEBUFFER,ge),E.bindFramebuffer(z.DRAW_FRAMEBUFFER,K);for(let $t=0;$t<et;$t++)hi?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,_n.__webglTexture,ue,Ct+$t):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,_n.__webglTexture,ue),en?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Hi.__webglTexture,Xe,gn+$t):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,Hi.__webglTexture,Xe),ue!==0?z.blitFramebuffer($e,ct,Ze,Ve,ot,Xt,Ze,Ve,z.COLOR_BUFFER_BIT,z.NEAREST):en?z.copyTexSubImage3D(qe,Xe,ot,Xt,gn+$t,$e,ct,Ze,Ve):z.copyTexSubImage2D(qe,Xe,ot,Xt,$e,ct,Ze,Ve);E.bindFramebuffer(z.READ_FRAMEBUFFER,null),E.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else en?w.isDataTexture||w.isData3DTexture?z.texSubImage3D(qe,Xe,ot,Xt,gn,Ze,Ve,et,Qt,Jt,cn.data):Q.isCompressedArrayTexture?z.compressedTexSubImage3D(qe,Xe,ot,Xt,gn,Ze,Ve,et,Qt,cn.data):z.texSubImage3D(qe,Xe,ot,Xt,gn,Ze,Ve,et,Qt,Jt,cn):w.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,Xe,ot,Xt,Ze,Ve,Qt,Jt,cn.data):w.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,Xe,ot,Xt,cn.width,cn.height,Qt,cn.data):z.texSubImage2D(z.TEXTURE_2D,Xe,ot,Xt,Ze,Ve,Qt,Jt,cn);E.pixelStorei(z.UNPACK_ROW_LENGTH,qn),E.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Ut),E.pixelStorei(z.UNPACK_SKIP_PIXELS,Dn),E.pixelStorei(z.UNPACK_SKIP_ROWS,di),E.pixelStorei(z.UNPACK_SKIP_IMAGES,zi),Xe===0&&Q.generateMipmaps&&z.generateMipmap(qe),E.unbindTexture()},this.initRenderTarget=function(w){se.get(w).__webglFramebuffer===void 0&&me.setupRenderTarget(w)},this.initTexture=function(w){w.isCubeTexture?me.setTextureCube(w,0):w.isData3DTexture?me.setTexture3D(w,0):w.isDataArrayTexture||w.isCompressedArrayTexture?me.setTexture2DArray(w,0):me.setTexture2D(w,0),E.unbindTexture()},this.resetState=function(){H=0,G=0,ne=null,E.reset(),ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return sa}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const i=this.getContext();i.drawingBufferColorSpace=kt._getDrawingBufferColorSpace(e),i.unpackColorSpace=kt._getUnpackColorSpace()}}const nx={type:"change"},Yp={type:"start"},ry={type:"end"},mu=new kp,ix=new ys,Aw=Math.cos(70*Hb.DEG2RAD),Un=new ie,li=2*Math.PI,ln={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Rh=1e-6;class Cw extends RE{constructor(e,i=null){super(e,i),this.state=ln.NONE,this.target=new ie,this.cursor=new ie,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:no.ROTATE,MIDDLE:no.DOLLY,RIGHT:no.PAN},this.touches={ONE:eo.ROTATE,TWO:eo.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 ie,this._lastQuaternion=new Ts,this._lastTargetPosition=new ie,this._quat=new Ts().setFromUnitVectors(e.up,new ie(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Dv,this._sphericalDelta=new Dv,this._scale=1,this._panOffset=new ie,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 ie,this._mouse=new bt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Rw.bind(this),this._onPointerDown=ww.bind(this),this._onPointerUp=Dw.bind(this),this._onContextMenu=Bw.bind(this),this._onMouseWheel=Lw.bind(this),this._onKeyDown=Ow.bind(this),this._onTouchStart=Pw.bind(this),this._onTouchMove=Iw.bind(this),this._onMouseDown=Nw.bind(this),this._onMouseMove=Uw.bind(this),this._interceptControlDown=Fw.bind(this),this._interceptControlUp=zw.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(nx),this.update(),this.state=ln.NONE}pan(e,i){this._pan(e,i),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 i=this.object.position;Un.copy(i).sub(this.target),Un.applyQuaternion(this._quat),this._spherical.setFromVector3(Un),this.autoRotate&&this.state===ln.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+=li:s>Math.PI&&(s-=li),l<-Math.PI?l+=li:l>Math.PI&&(l-=li),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 f=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),c=f!=this._spherical.radius}if(Un.setFromSpherical(this._spherical),Un.applyQuaternion(this._quatInverse),i.copy(this.target).add(Un),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 f=null;if(this.object.isPerspectiveCamera){const p=Un.length();f=this._clampDistance(p*this._scale);const m=p-f;this.object.position.addScaledVector(this._dollyDirection,m),this.object.updateMatrixWorld(),c=!!m}else if(this.object.isOrthographicCamera){const p=new ie(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 ie(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(p),this.object.updateMatrixWorld(),f=Un.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;f!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(f).add(this.object.position):(mu.origin.copy(this.object.position),mu.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(mu.direction))<Aw?this.object.lookAt(this.target):(ix.setFromNormalAndCoplanarPoint(this.object.up,this.target),mu.intersectPlane(ix,this.target))))}else if(this.object.isOrthographicCamera){const f=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),f!==this.object.zoom&&(this.object.updateProjectionMatrix(),c=!0)}return this._scale=1,this._performCursorZoom=!1,c||this._lastPosition.distanceToSquared(this.object.position)>Rh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Rh||this._lastTargetPosition.distanceToSquared(this.target)>Rh?(this.dispatchEvent(nx),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?li/60*this.autoRotateSpeed*e:li/60/60*this.autoRotateSpeed}_getZoomScale(e){const i=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*i)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,i){Un.setFromMatrixColumn(i,0),Un.multiplyScalar(-e),this._panOffset.add(Un)}_panUp(e,i){this.screenSpacePanning===!0?Un.setFromMatrixColumn(i,1):(Un.setFromMatrixColumn(i,0),Un.crossVectors(this.object.up,Un)),Un.multiplyScalar(e),this._panOffset.add(Un)}_pan(e,i){const s=this.domElement;if(this.object.isPerspectiveCamera){const l=this.object.position;Un.copy(l).sub(this.target);let c=Un.length();c*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*c/s.clientHeight,this.object.matrix),this._panUp(2*i*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(i*(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,i){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),l=e-s.left,c=i-s.top,f=s.width,p=s.height;this._mouse.x=l/f*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 i=this.domElement;this._rotateLeft(li*this._rotateDelta.x/i.clientHeight),this._rotateUp(li*this._rotateDelta.y/i.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 i=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(li*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),i=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-li*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),i=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(li*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),i=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-li*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),i=!0;break}i&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),l=.5*(e.pageY+i.y);this._rotateStart.set(s,l)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),l=.5*(e.pageY+i.y);this._panStart.set(s,l)}}_handleTouchStartDolly(e){const i=this._getSecondPointerPosition(e),s=e.pageX-i.x,l=e.pageY-i.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 i=this.domElement;this._rotateLeft(li*this._rotateDelta.x/i.clientHeight),this._rotateUp(li*this._rotateDelta.y/i.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),l=.5*(e.pageY+i.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 i=this._getSecondPointerPosition(e),s=e.pageX-i.x,l=e.pageY-i.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 f=(e.pageX+i.x)*.5,p=(e.pageY+i.y)*.5;this._updateZoomParameters(f,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 i=0;i<this._pointers.length;i++)if(this._pointers[i]==e.pointerId){this._pointers.splice(i,1);return}}_isTrackingPointer(e){for(let i=0;i<this._pointers.length;i++)if(this._pointers[i]==e.pointerId)return!0;return!1}_trackPointer(e){let i=this._pointerPositions[e.pointerId];i===void 0&&(i=new bt,this._pointerPositions[e.pointerId]=i),i.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const i=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[i]}_customWheelEvent(e){const i=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(i){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function ww(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 Rw(a){this.enabled!==!1&&(a.pointerType==="touch"?this._onTouchMove(a):this._onMouseMove(a))}function Dw(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(ry),this.state=ln.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],i=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:i.x,pageY:i.y});break}}function Nw(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 no.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(a),this.state=ln.DOLLY;break;case no.ROTATE:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=ln.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=ln.ROTATE}break;case no.PAN:if(a.ctrlKey||a.metaKey||a.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(a),this.state=ln.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(a),this.state=ln.PAN}break;default:this.state=ln.NONE}this.state!==ln.NONE&&this.dispatchEvent(Yp)}function Uw(a){switch(this.state){case ln.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(a);break;case ln.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(a);break;case ln.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(a);break}}function Lw(a){this.enabled===!1||this.enableZoom===!1||this.state!==ln.NONE||(a.preventDefault(),this.dispatchEvent(Yp),this._handleMouseWheel(this._customWheelEvent(a)),this.dispatchEvent(ry))}function Ow(a){this.enabled!==!1&&this._handleKeyDown(a)}function Pw(a){switch(this._trackPointer(a),this._pointers.length){case 1:switch(this.touches.ONE){case eo.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(a),this.state=ln.TOUCH_ROTATE;break;case eo.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(a),this.state=ln.TOUCH_PAN;break;default:this.state=ln.NONE}break;case 2:switch(this.touches.TWO){case eo.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(a),this.state=ln.TOUCH_DOLLY_PAN;break;case eo.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(a),this.state=ln.TOUCH_DOLLY_ROTATE;break;default:this.state=ln.NONE}break;default:this.state=ln.NONE}this.state!==ln.NONE&&this.dispatchEvent(Yp)}function Iw(a){switch(this._trackPointer(a),this.state){case ln.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(a),this.update();break;case ln.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(a),this.update();break;case ln.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(a),this.update();break;case ln.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(a),this.update();break;default:this.state=ln.NONE}}function Bw(a){this.enabled!==!1&&a.preventDefault()}function Fw(a){a.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function zw(a){a.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const bs=16,ax=28,Hw=20;function yl(a,e,i){return Math.min(i,Math.max(e,a))}function Ep(a){const e=Array.isArray(a)?a:[a];for(const i of e)i.dispose()}function oy(a){a&&(a.geometry.dispose(),Ep(a.material))}function Gw(a){return new xE({color:a,emissive:a.clone().multiplyScalar(.36),emissiveIntensity:.26,metalness:.04,roughness:.28,vertexColors:!0})}function Vw(a){const e=new hE(new rr(bs,bs,bs)),i=new Xp({color:new dt(a.primaryColor).lerp(new dt("#ffffff"),.1)}),s=new qx(e,i);return s.visible=a.showBounds,s}function kw(a){const e=new wE(bs,12,new dt(a.accentColor).lerp(new dt("#ffffff"),.05),new dt(a.primaryColor).lerp(new dt("#000000"),.4));e.position.y=-bs/2;const i=e.material;return i.opacity=.28,i.transparent=!0,e}function jw(a,e){a.primaryColor=new dt(e.primaryColor),a.accentColor=new dt(e.accentColor),a.bounds.visible=e.showBounds,a.bounds.material.color=a.primaryColor.clone().lerp(new dt("#ffffff"),.1)}function Xw(a,e){const s=bs/a*(1-yl(e.cellGap,.02,.45)),l=new rr(s,s,s),c=Gw(new dt(e.primaryColor)),f=new oE(l,c,Math.max(1,a**3));return f.instanceMatrix.setUsage(Ob),f.castShadow=!0,f.receiveShadow=!0,f}function Ww(a,e,i,s,l){const c=i>1?e.y/(i-1):.5,f=i>1?e.z/(i-1):.5,p=yl((e.state??1)/6,0,1);if(l.copy(a.primaryColor).lerp(a.accentColor,yl(c*.42+p*.5,0,1)),s==="lattice-gas-3d"||s==="snake-3d"){l.lerp(new dt("#ffffff"),yl(p*.22+f*.08,0,.34)),l.multiplyScalar(1+p*.16);return}s==="generations-3d"&&l.lerp(new dt("#94a3b8"),p*.22),l.lerp(new dt("#ffffff"),yl(f*.18,0,.24)),l.offsetHSL(0,0,.05+f*.1)}function qw(a,e,i,s,l){oy(a.mesh),a.mesh=Xw(i,l),a.scene.add(a.mesh);const c=a.mesh,f=new Ln,p=new dt,m=bs/i,h=-bs/2+m/2;let y=0;for(const S of e){if(y>=c.count)break;S.x<0||S.y<0||S.z<0||S.x>=i||S.y>=i||S.z>=i||(f.position.set(h+S.x*m,h+S.y*m,h+S.z*m),f.rotation.set(0,0,0),f.updateMatrix(),Ww(a,S,i,s,p),c.setMatrixAt(y,f.matrix),c.setColorAt(y,p),y+=1)}c.count=y,c.instanceMatrix.needsUpdate=!0,c.instanceColor&&(c.instanceColor.needsUpdate=!0)}function Yw(a,e){const i=new eE;i.background=new dt("#061006");const s=new Ii(42,1,.1,300);s.position.set(ax,Hw,ax);const l=new Tw({antialias:!0,alpha:!0});l.setPixelRatio(Math.min(window.devicePixelRatio,2)),l.shadowMap.enabled=!0,l.shadowMap.type=Ex,l.outputColorSpace=bi,l.toneMapping=Up,l.toneMappingExposure=1.12,a.appendChild(l.domElement);const c=new Cw(s,l.domElement);c.enableDamping=!0,c.dampingFactor=.06,c.minDistance=12,c.maxDistance=60,c.target.set(0,0,0),i.add(new TE("#f5efb7",.42)),i.add(new ME("#f5efb7","#061006",.96));const f=new Rv("#fff3a8",1.25);f.position.set(18,28,14),f.target.position.set(0,0,0),i.add(f),i.add(f.target);const p=new Rv(e.accentColor,.46);p.position.set(-24,18,-12),i.add(p);const m=Vw(e);i.add(m);const h=kw(e);i.add(h);const y={animationFrame:0,bounds:m,grid:h,mesh:null,primaryColor:new dt(e.primaryColor),accentColor:new dt(e.accentColor),resizeObserver:new ResizeObserver(()=>S()),scene:i};function S(){const T=Math.max(a.clientWidth,1),C=Math.max(a.clientHeight,1);s.aspect=T/C,s.updateProjectionMatrix(),l.setSize(T,C,!1)}function _(){c.update(),l.render(i,s)}function b(){_(),y.animationFrame=window.requestAnimationFrame(b)}return y.resizeObserver.observe(a),S(),b(),{dispose(){window.cancelAnimationFrame(y.animationFrame),y.resizeObserver.disconnect(),oy(y.mesh),y.bounds.geometry.dispose(),Ep(y.bounds.material),y.grid.geometry.dispose(),Ep(y.grid.material),c.dispose(),l.dispose(),l.domElement.parentNode===a&&a.removeChild(l.domElement)},render:_,update(T){jw(y,T.options),qw(y,T.cells,T.size,T.ruleId,T.options),_()}}}function Zw(a){const e=a.simulation?.grid?.size;if(!Array.isArray(e))return 16;const i=e[0];return typeof i=="number"?Math.min(30,Math.max(8,Math.round(i))):16}function Kw(a){const e=a.simulation?.ruleId;return typeof e=="string"&&e.endsWith("-3d")?e:"life-3d"}function $w(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 Qw(a){const e=a.simulation?.initialCondition?.cells;return Array.isArray(e)?e.flatMap(i=>{const[s,l,c=0,f=1]=i;return!Number.isInteger(s)||!Number.isInteger(l)||!Number.isInteger(c)?[]:[{x:s,y:l,z:c,state:typeof f=="number"?f:1}]}):[]}function Jw({caption:a,settings:e}){const i=ee.useRef(null),s=ee.useRef(null),l=ee.useMemo(()=>Qw(e),[e]),c=Zw(e),f=Kw(e),p=ee.useMemo(()=>$w(e),[e]);return ee.useEffect(()=>{const m=i.current;if(!m)return;const h=Yw(m,p);return s.current=h,h.update({cells:l,options:p,ruleId:f,size:c}),()=>{h.dispose(),s.current=null}},[]),ee.useEffect(()=>{s.current?.update({cells:l,options:p,ruleId:f,size:c})},[l,p,f,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:i}),l.length===0?g.jsx("div",{className:"voxel-empty-hint",children:"No voxel initial condition on this node"}):null]})}const wl=new Map;function Iu(a,e={}){if(!a.id.trim())throw new Error("CA renderer runtime id is required");if(wl.has(a.id)&&!e.replace)throw new Error(`CA renderer runtime already registered: ${a.id}`);wl.set(a.id,a)}function eR(){return[...wl.values()]}function Dh(a){return eR().filter(e=>Oa(e,a))}function tR(a){return wl.get(a)??[...wl.values()].find(e=>e.aliases?.includes(a))??null}function Bu({caption:a,cells:e,settings:i,onCellsChange:s}){const l=i.renderer?.id??"2d-canvas",c=tR(l),f=Sl(i);if(c&&(!f||Oa(c,f))){const p=c.Component;return g.jsx(p,{caption:a,cells:e,settings:i,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 nR({caption:a,settings:e}){return g.jsx(Jw,{caption:a,settings:e})}function iR(a,e,i,s){return typeof a=="number"&&Number.isFinite(a)?Math.max(i,Math.min(s,a)):e}function aR(a){const e=a.renderer?.elementaryRule;if(typeof e=="number")return Math.max(0,Math.min(255,Math.floor(e)));const i=a.simulation?.ruleId??"",s=/(?:rule[-_\s]*)?(\d{1,3})/i.exec(i);return s?Math.max(0,Math.min(255,Number(s[1]))):110}function sR(a,e){return a.map((i,s)=>{const l=a[(s-1+a.length)%a.length]?1:0,c=a[s]?1:0,f=a[(s+1)%a.length]?1:0,p=l<<2|c<<1|f;return(e>>p&1)===1})}function rR(a){const e=a.findIndex(i=>i.some(Boolean));return e===-1?0:e}function oR({caption:a,cells:e,onCellsChange:i}){const s=ee.useRef(null),l=ee.useRef(e),c=ee.useRef(null),[f,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 v=new ResizeObserver(()=>p(x=>x+1));return v.observe(C),()=>v.disconnect()},[]),ee.useEffect(()=>{const C=s.current;if(!C||m===0||h===0)return;const v=C.getContext("2d");if(!v)return;const x=C.getBoundingClientRect(),B=window.devicePixelRatio||1,P=Math.max(1,Math.floor(x.width*B)),D=Math.max(1,Math.floor(x.height*B));(C.width!==P||C.height!==D)&&(C.width=P,C.height=D),v.setTransform(B,0,0,B,0,0),v.clearRect(0,0,x.width,x.height),v.fillStyle="#071206",v.fillRect(0,0,x.width,x.height);const O=Math.min(x.width/m,x.height/h),U=O*m,N=O*h,A=(x.width-U)/2,L=(x.height-N)/2,j=Math.max(1,Math.min(2,O*.08));v.strokeStyle="#1e3519",v.lineWidth=1;for(let V=0;V<h;V+=1)for(let $=0;$<m;$+=1){const pe=A+$*O+j/2,ge=L+V*O+j/2,K=Math.max(1,O-j);e[V][$]?(v.fillStyle="#70f45f",v.shadowColor="rgba(112, 244, 95, 0.42)",v.shadowBlur=Math.max(0,O*.38),v.fillRect(pe,ge,K,K),v.shadowBlur=0,v.strokeStyle="#b7ffab"):(v.fillStyle="#071206",v.fillRect(pe,ge,K,K),v.strokeStyle="#1e3519"),v.strokeRect(pe+.5,ge+.5,Math.max(0,K-1),Math.max(0,K-1))}},[f,e,h,m]);function y(C){const v=s.current;if(!v||m===0||h===0)return null;const x=v.getBoundingClientRect(),B=Math.min(x.width/m,x.height/h),P=B*m,D=B*h,O=(x.width-P)/2,U=(x.height-D)/2,N=Math.floor((C.clientX-x.left-O)/B),A=Math.floor((C.clientY-x.top-U)/B);return N<0||A<0||N>=m||A>=h?null:{x:N,y:A}}function S(C,v,x){const B=l.current;if(B[v]?.[C]===x)return;const P=B.map((D,O)=>O===v?D.map((U,N)=>N===C?x:U):D);l.current=P,i(P)}function _(C){const v=y(C);if(!v)return;C.currentTarget.setPointerCapture(C.pointerId);const x=!l.current[v.y][v.x];c.current=x,S(v.x,v.y,x)}function b(C){if(c.current===null)return;const v=y(C);v&&S(v.x,v.y,c.current)}function T(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:T,onPointerDown:_,onPointerLeave:T,onPointerMove:b,onPointerUp:T})]})}function lR({caption:a,cells:e,settings:i,onCellsChange:s}){const l=ee.useRef(null),c=ee.useRef(e),[f,p]=ee.useState(0),m=e[0]?.length??0,h=Math.min(e.length-1,Math.max(0,rR(e))),y=e[h]??[],S=aR(i),_=iR(i.renderer?.historyRows,96,8,512);ee.useEffect(()=>{c.current=e},[e]),ee.useEffect(()=>{const T=l.current;if(!T)return;const C=new ResizeObserver(()=>p(v=>v+1));return C.observe(T),()=>C.disconnect()},[]),ee.useEffect(()=>{const T=l.current;if(!T||m===0||y.length===0)return;const C=T.getContext("2d");if(!C)return;const v=T.getBoundingClientRect(),x=window.devicePixelRatio||1,B=Math.max(1,Math.floor(v.width*x)),P=Math.max(1,Math.floor(v.height*x));(T.width!==B||T.height!==P)&&(T.width=B,T.height=P),C.setTransform(x,0,0,x,0,0),C.clearRect(0,0,v.width,v.height),C.fillStyle="#061006",C.fillRect(0,0,v.width,v.height);const D=v.width/m,O=v.height/_;let U=[...y];for(let N=0;N<_;N+=1){const A=N/Math.max(1,_-1);for(let L=0;L<m;L+=1)if(U[L]){const j=Math.round(190+A*55),V=Math.round(112+A*80);C.fillStyle=`rgb(${V} ${j} 92)`,C.fillRect(L*D,N*O,Math.ceil(D),Math.ceil(O))}U=sR(U,S)}C.strokeStyle="rgba(240, 201, 74, 0.32)",C.lineWidth=1,C.strokeRect(.5,.5,Math.max(0,v.width-1),Math.max(0,v.height-1))},[f,_,S,y,m]);function b(T){const C=l.current;if(!C||m===0)return;const v=C.getBoundingClientRect(),x=Math.floor((T.clientX-v.left)/v.width*m);if(x<0||x>=m)return;const P=c.current.map((D,O)=>O===h?D.map((U,N)=>N===x?!U:U):D);c.current=P,s(P)}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:b})]})}function cR({caption:a,cells:e,onCellsChange:i}){const s=ee.useRef(null),l=ee.useRef(e),c=ee.useRef(null),[f,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 v=new ResizeObserver(()=>p(x=>x+1));return v.observe(C),()=>v.disconnect()},[]),ee.useEffect(()=>{const C=s.current;if(!C||m===0||h===0)return;const v=C.getContext("2d");if(!v)return;const x=C.getBoundingClientRect(),B=window.devicePixelRatio||1,P=Math.max(1,Math.floor(x.width*B)),D=Math.max(1,Math.floor(x.height*B));(C.width!==P||C.height!==D)&&(C.width=P,C.height=D),v.setTransform(B,0,0,B,0,0),v.clearRect(0,0,x.width,x.height);const O=Math.min(x.width/m,x.height/h),U=O*m,N=O*h,A=(x.width-U)/2,L=(x.height-N)/2;v.fillStyle="#061006",v.fillRect(0,0,x.width,x.height);for(let j=0;j<h;j+=1)for(let V=0;V<m;V+=1){const $=A+V*O,pe=L+j*O;if(e[j][V]){const ge=v.createRadialGradient($+O*.5,pe+O*.52,O*.08,$+O*.5,pe+O*.52,O*.62);ge.addColorStop(0,"#fff5b9"),ge.addColorStop(.45,"#f0c94a"),ge.addColorStop(1,"#d9481e"),v.fillStyle=ge}else v.fillStyle=(V+j)%2===0?"#143f1b":"#0d2b14";v.fillRect($,pe,Math.ceil(O),Math.ceil(O))}},[f,e,h,m]);function y(C){const v=s.current;if(!v||m===0||h===0)return null;const x=v.getBoundingClientRect(),B=Math.min(x.width/m,x.height/h),P=B*m,D=B*h,O=(x.width-P)/2,U=(x.height-D)/2,N=Math.floor((C.clientX-x.left-O)/B),A=Math.floor((C.clientY-x.top-U)/B);return N<0||A<0||N>=m||A>=h?null:{x:N,y:A}}function S(C,v,x){const B=l.current;if(B[v]?.[C]===x)return;const P=B.map((D,O)=>O===v?D.map((U,N)=>N===C?x:U):D);l.current=P,i(P)}function _(C){const v=y(C);if(!v)return;C.currentTarget.setPointerCapture(C.pointerId);const x=!l.current[v.y][v.x];c.current=x,S(v.x,v.y,x)}function b(C){if(c.current===null)return;const v=y(C);v&&S(v.x,v.y,c.current)}function T(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:T,onPointerDown:_,onPointerLeave:T,onPointerMove:b,onPointerUp:T})]})}Iu({id:"2d-canvas",label:"2D Canvas",supportedClasses:[{dimensions:2,states:2}],Component:oR},{replace:!0});Iu({id:"elementary-1d",label:"Elementary 1D",aliases:["elementary-ca","1d-canvas"],supportedClasses:[{dimensions:1,states:2}],Component:lR},{replace:!0});Iu({id:"wildfire-2d",label:"Wildfire 2D",aliases:["forest-fire-2d"],supportedClasses:[{dimensions:2,states:2}],Component:cR},{replace:!0});Iu({id:"voxel-3d",label:"Voxel 3D",aliases:["three-voxel"],supportedClasses:[{dimensions:3,states:2}],Component:nR},{replace:!0});function uR(a,e){return a.sort_order-e.sort_order||a.name.localeCompare(e.name)}function fR(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 i(s){return(e.get(s)??[]).sort(uR).map(l=>({node:l,children:i(l.id)}))}return i(null)}function dR({assignedNodeId:a,nodes:e,selectedNodeId:i,onSelect:s}){const l=ee.useMemo(()=>fR(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(ly,{assignedNodeId:a,item:c,selectedNodeId:i,onSelect:s},c.node.id))})}function ly({assignedNodeId:a,item:e,selectedNodeId:i,onSelect:s}){const[l,c]=ee.useState(!0),f=e.node.id===i,p=e.node.id===a;return g.jsxs("div",{className:"asset-tree-item",children:[g.jsxs("div",{className:`asset-tree-row${f?" 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(ly,{assignedNodeId:a,item:m,selectedNodeId:i,onSelect:s},m.node.id))}):null]})}function ir(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function hR(a,e){return JSON.stringify(a)===JSON.stringify(e)}function Nh(a,e){let i=a;for(const s of e){if(!ir(i)||!(s in i))return;i=i[s]}return i}function pR(a,e){return a.join(".")==="simulation.initialCondition"&&ir(e)?`${Array.isArray(e.cells)?e.cells.length:0} live cells`:Array.isArray(e)?`${e.length} items`:ir(e)?"object":String(e)}function Zp(a,e){const i={...a};for(const[s,l]of Object.entries(e)){const c=i[s];i[s]=ir(c)&&ir(l)?Zp(c,l):l}return i}function mR(a,e){return a.sort_order-e.sort_order||a.name.localeCompare(e.name)||a.slug.localeCompare(e.slug)}function gR(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 i(s){const l=(e.get(s)??[]).sort(mR);return l.map((c,f)=>({node:c,children:i(c.id),siblingIndex:f,siblingCount:l.length}))}return i(null)}function cy(a,e,i={},s=null){const l=[];for(const c of a)if(l.push({item:c,inheritedParams:i,parentId:s}),e.has(c.node.id)){const f=Zp(i,c.node.params);l.push(...cy(c.children,e,f,c.node.id))}return l}function _R({assignedNodeId:a,engines:e=[],nodes:i,selectedNodeId:s,usedNodeIds:l,onCreateChild:c,onCreateGroup:f,onDelete:p,onMove:m,onRename:h,onSelect:y,onSet:S,onUnset:_}){const b=ee.useMemo(()=>gR(i),[i]),[T,C]=ee.useState(()=>new Set(i.map(N=>N.id))),[v,x]=ee.useState(""),[B,P]=ee.useState(""),D=ee.useMemo(()=>cy(b,T),[T,b]);ee.useEffect(()=>{C(N=>{const A=new Set([...N].filter(L=>i.some(j=>j.id===L)));for(const L of i)N.has(L.id)||A.add(L.id);return A})},[i]),ee.useEffect(()=>{if(!B)return;function N(L){const j=L.target;j instanceof Element&&(j.closest(".tree-node-action-menu")||j.closest(".node-action-trigger")||P(""))}function A(L){L.key==="Escape"&&P("")}return document.addEventListener("pointerdown",N),document.addEventListener("keydown",A),()=>{document.removeEventListener("pointerdown",N),document.removeEventListener("keydown",A)}},[B]);function O(N,A){C(L=>{const j=new Set(L);return A??!j.has(N)?j.add(N):j.delete(N),j})}function U(N){if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter"].includes(N.key))return;const A=D.findIndex(({item:V})=>V.node.id===s),L=A===-1?0:A,j=D[L];if(j){if(N.key==="ArrowDown"||N.key==="ArrowUp"){N.preventDefault();const V=N.key==="ArrowDown"?1:-1,$=D[Math.min(Math.max(L+V,0),D.length-1)];$&&y($.item.node);return}if(N.key==="ArrowRight"){N.preventDefault(),j.item.children.length&&!T.has(j.item.node.id)?O(j.item.node.id,!0):j.item.children[0]&&y(j.item.children[0].node);return}if(N.key==="ArrowLeft"){if(N.preventDefault(),T.has(j.item.node.id)&&j.item.children.length)O(j.item.node.id,!1);else if(j.parentId){const V=i.find($=>$.id===j.parentId);V&&y(V)}return}N.preventDefault(),x(j.item.node.id)}}return b.length===0?g.jsx("p",{className:"empty",children:"No nodes loaded."}):g.jsx("div",{className:"preset-node-tree",role:"tree",tabIndex:0,onKeyDown:U,children:b.map(N=>g.jsx(uy,{item:N,assignedNodeId:a,engines:e,inheritedParams:{},selectedNodeId:s,usedNodeIds:l,expandedNodeIds:T,editingNodeId:v,openMenuNodeId:B,onCreateChild:c,onCreateGroup:f,onDelete:p,onEdit:x,onMenuToggle:A=>P(L=>L===A?"":A),onMove:m,onRename:h,onSelect:y,onSet:S,onToggle:O,onUnset:_},N.node.id))})}function uy({item:a,assignedNodeId:e,engines:i,inheritedParams:s,selectedNodeId:l,usedNodeIds:c,expandedNodeIds:f,editingNodeId:p,openMenuNodeId:m,onCreateChild:h,onCreateGroup:y,onDelete:S,onEdit:_,onMenuToggle:b,onMove:T,onRename:C,onSelect:v,onSet:x,onToggle:B,onUnset:P}){const D=f.has(a.node.id),O=m===a.node.id,U=a.node.id===l,N=a.node.id===e,A=c.has(a.node.id),L=ee.useMemo(()=>{function ge(K){return K.reduce((H,G)=>H+(c.has(G.node.id)?1:0)+ge(G.children),0)}return ge(a.children)},[a.children,c]),j=Zp(s,a.node.params),V=a.node.kind==="preset_root"?"root":a.node.kind==="chapter"?"group":a.node.kind,$=N?`${V} · assigned`:A?`${V} · used by slides`:L>0?`${V} · contains ${L} used preset${L===1?"":"s"}`:`${V} · unused`;async function pe(){b(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${U?" active":""}${N?" assigned":""}${A||L>0?" used":" unused"}`,children:[g.jsx("button",{"aria-label":a.children.length?`${D?"Collapse":"Expand"} ${a.node.name}`:`${a.node.name} has no children`,className:"tree-node-arrow",disabled:!a.children.length,type:"button",onClick:()=>B(a.node.id),children:a.children.length?D?"▾":"▸":"•"}),g.jsxs("button",{"aria-current":U?"true":void 0,className:"tree-node-main",role:"treeitem",type:"button",onClick:()=>v(a.node),children:[g.jsx("strong",{children:a.node.name}),g.jsx("small",{children:$})]}),g.jsxs("div",{className:"tree-node-action-shell",children:[g.jsx("button",{"aria-expanded":O,"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:ge=>{ge.stopPropagation(),b(a.node.id)},children:"⋯"}),O?g.jsxs("div",{className:"tree-node-action-menu",role:"menu",children:[g.jsx("button",{role:"menuitem",type:"button",onClick:()=>{b(a.node.id),_(a.node.id)},children:"Edit"}),g.jsx("button",{role:"menuitem",type:"button",onClick:()=>{b(a.node.id),h(a.node)},children:"Create child preset"}),g.jsx("button",{role:"menuitem",type:"button",onClick:()=>{b(a.node.id),y(a.node)},children:"Create child group"}),g.jsx("button",{disabled:a.siblingIndex===0,role:"menuitem",type:"button",onClick:()=>{b(a.node.id),T(a.node,-1)},children:"Move up"}),g.jsx("button",{disabled:a.siblingIndex>=a.siblingCount-1,role:"menuitem",type:"button",onClick:()=>{b(a.node.id),T(a.node,1)},children:"Move down"}),g.jsx("button",{className:"danger",role:"menuitem",type:"button",onClick:()=>{pe()},children:"Delete"})]}):null]})]}),p===a.node.id?g.jsx(bR,{engines:i,inheritedParams:s,node:a.node,resolvedParams:j,onClose:()=>_(""),onDelete:S,onRename:C,onSet:x,onUnset:P}):null,D&&a.children.length?g.jsx("div",{className:"tree-children",children:a.children.map(ge=>g.jsx(uy,{assignedNodeId:e,engines:i,inheritedParams:j,item:ge,usedNodeIds:c,expandedNodeIds:f,editingNodeId:p,openMenuNodeId:m,onCreateChild:h,onCreateGroup:y,onDelete:S,onEdit:_,onMenuToggle:b,onMove:T,onRename:C,onSelect:v,onSet:x,onToggle:B,onUnset:P,selectedNodeId:l},ge.node.id))}):null]})}function fy(a,e=[]){if(!ir(a))return[];const i=[];for(const[s,l]of Object.entries(a)){const c=[...e,s];c.join(".")==="simulation.initialCondition"||!ir(l)?i.push({path:c,value:l}):i.push(...fy(l,c))}return i}function vR(a){const e=a.join(".");return e!=="simulation.initialCondition"&&e!=="simulation.engineId"&&e!=="simulation.neighborhoodId"&&!e.startsWith("caClass.")}function xR(a){return a==="rendererId"?["renderer","id"]:a==="ruleId"?["simulation","ruleId"]:a.startsWith("grid.")?["simulation",...a.split(".")]:a.includes(".")?a.split("."):["simulation",a]}function yR(a){return a?Object.keys(a.params_schema):[]}function SR(a,e){const i=a.join(".");return yR(e).some(s=>xR(s).join(".")===i)}function MR(a){const e=a.trim();if(e==="")return"";try{return JSON.parse(e)}catch{return a}}function sx(a){return typeof a=="string"?a:JSON.stringify(a,null,2)}function bR({engines:a,inheritedParams:e,node:i,resolvedParams:s,onClose:l,onDelete:c,onRename:f,onSet:p,onUnset:m}){const[h,y]=ee.useState(i.name),S=Nh(s,["simulation","engineId"]),_=Sl(s),b=typeof S=="string"?a.find(P=>P.engine_kind===S):void 0,C=(b?Oa(b,_):!1)?b:void 0,v=fy(s).filter(P=>vR(P.path)&&!SR(P.path,C));ee.useEffect(()=>{y(i.name)},[i.name]);async function x(){const P=h.trim();if(!P){y(i.name);return}P!==i.name&&await f(i,P)}async function B(){!window.confirm(`Delete preset "${i.name}"? This cannot be undone.`)||await c(i)===!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:P=>P.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.jsx("button",{type:"button",onClick:l,children:"Close"})]}),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:P=>y(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),x())}})]}),g.jsx("button",{disabled:!h.trim()||h.trim()===i.name,type:"button",onClick:()=>{x()},children:"Save name"})]}),v.map(P=>{const D=Nh(i.params,P.path),O=Nh(e,P.path),U=D!==void 0&&!hR(D,O);return g.jsx(ER,{inheritedValue:O,isLocal:U,node:i,path:P.path,value:P.value,onSet:p,onUnset:m},P.path.join("."))}),v.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:()=>{B()},children:"Delete"})]})]})]})})}function ER({inheritedValue:a,isLocal:e,node:i,path:s,value:l,onSet:c,onUnset:f}){const[p,m]=ee.useState(sx(l));return ee.useEffect(()=>{m(sx(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: ",pR(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(i,s,MR(p)),children:"Save"}),g.jsx("button",{className:"danger",disabled:!e,type:"button",onClick:()=>f(i,s),children:"🗑"})]})]})}function TR({activeSceneId:a,canDeleteSlide:e,sceneCount:i,scenes:s,onBack:l,onDeleteSlide:c,onEditScene:f,onReorderSlides:p,onSaveNewSlide:m,onSelectScene:h}){const[y,S]=ee.useState(""),[_,b]=ee.useState(null);function T(v){return(typeof v.scene.params.caption=="string"?v.scene.params.caption:"").split(/\r?\n/,1)[0].trim()||"No caption"}function C(v,x){if(!y||y===v)return;const B=s.find(N=>N.scene.id===y);if(!B)return;const P=s.filter(N=>N.scene.id!==y),D=P.findIndex(N=>N.scene.id===v);if(D===-1)return;const O=x==="after"?D+1:D,U=[...P];U.splice(O,0,B),p(U)}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:i})]}),s.length?s.map(v=>g.jsxs("div",{className:`scene-item${v.scene.id===a?" active":""}${v.scene.id===y?" dragging":""}${_?.sceneId===v.scene.id?` drop-${_.position}`:""}`,draggable:!0,onDragEnd:()=>{S(""),b(null)},onDragOver:x=>{x.preventDefault();const B=x.currentTarget.getBoundingClientRect(),P=x.clientY>B.top+B.height/2?"after":"before";b({sceneId:v.scene.id,position:P})},onDragStart:x=>{S(v.scene.id),x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",v.scene.id)},onDrop:x=>{x.preventDefault();const B=x.currentTarget.getBoundingClientRect(),P=x.clientY>B.top+B.height/2?"after":"before";C(v.scene.id,P),S(""),b(null)},children:[g.jsxs("button",{className:"scene-item-main",type:"button",onClick:()=>h(v),children:[g.jsx("span",{children:v.scene.order_index}),g.jsx("strong",{children:v.scene.title}),g.jsx("small",{className:"scene-caption-preview",children:T(v)})]}),g.jsx("button",{"aria-label":`Edit ${v.scene.title} metadata`,className:"scene-edit-button icon-button",type:"button",onClick:()=>f(v),children:"✎"})]},v.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 er=24,rx="ca-studio-skin",Tp="ca-studio-gallery-tab",ox="ca-studio-engine-dimension",lx="ca-studio-icg-dimension",dy=[{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"}],AR=["decks","cas","engines","icgs"];function ar(){return Array.from({length:er},()=>Array.from({length:er},()=>!1))}function CR(){const a=ar(),e=10,i=10,s=[[1,0],[2,1],[0,2],[1,2],[2,2]];for(const[l,c]of s)a[i+c][e+l]=!0;return a}function to(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"untitled"}async function gt(a,e={}){const i=await fetch(a,{...e,headers:{"content-type":"application/json",...e.headers??{}}});if(!i.ok){const s=await i.text();throw new Error(wR(i,s))}return i.json()}function wR(a,e){const i=e.trim();if(!i)return`Request failed: ${a.status}`;const l=(/<pre>(.*?)<\/pre>/is.exec(i)?.[1]??i).replace(/<[^>]*>/g," ").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/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 ro(a){const e=a?.params?.studio;return!e||typeof e!="object"||Array.isArray(e)?{}:e}function RR(a,e){const i={...ro(a)};for(const[s,l]of Object.entries(e))l===void 0?delete i[s]:i[s]=l;return{...a.params,studio:i}}function Kp(a){const e=[];for(let i=0;i<a.length;i+=1)for(let s=0;s<(a[i]?.length??0);s+=1)a[i][s]&&e.push([s,i,0]);return e}function Rl(a){const e=ar();for(const i of a??[]){const[s,l]=i;Number.isInteger(s)&&Number.isInteger(l)&&s>=0&&l>=0&&s<er&&l<er&&(e[l][s]=!0)}return e}function hy(a){return a.reduce((e,i)=>e+i.reduce((s,l)=>s+(l?1:0),0),0)}function py(a){if(!(a instanceof HTMLElement))return!1;const e=a.tagName.toLowerCase();return a.isContentEditable||e==="input"||e==="select"||e==="textarea"}function my(a){return AR.includes(a)}function DR(){const a=window.sessionStorage.getItem(Tp);return my(a)?a:"decks"}function po(a){return`/admin?tab=${a}`}function NR(a){return a?.startsWith("/admin/edit/")||a===po("engines")?a:void 0}function cx(){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 f=new URLSearchParams(window.location.search);return{view:"edit",deckId:e[1],sceneId:f.get("scene")??void 0}}const i=/^\/admin\/libraries\/([^/]+)/.exec(window.location.pathname);if(i){const f=new URLSearchParams(window.location.search);return{view:"library",treeId:i[1],nodeId:f.get("node")??void 0,returnTo:NR(f.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:my(c)?c:DR()}}function Pi(a){window.history.pushState({},"",a),window.dispatchEvent(new PopStateEvent("popstate"))}function UR(){return{name:"Random soup",description:"Seed live cells randomly across the current voxel grid.",generatorKind:"random-soup",dimensions:2,states:2,density:.28,seed:"studio-seed"}}function gy(){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 _y(a){return{density:{type:"range",label:"Density",default:a.density,min:0,max:1,step:.01},seed:{type:"string",label:"Seed",default:a.seed}}}function vy(a){return{density:a.density,seed:a.seed}}function xy(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}function LR(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 $p(a){const e=LR(a.dimensions);return{ruleId:{type:"select",label:"Rule",default:a.ruleId,options:[{value:a.ruleId,label:xy(a.ruleId)}]},rendererId:{type:"select",label:"Renderer",default:a.rendererId,options:e}}}function Qp(a){return{ruleId:a.ruleId,rendererId:a.rendererId}}function OR(a){const e=a.dimensions>=3?er: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:[er,er,e],boundary:"wrap",wrap:!0}},renderer:{id:a.rendererId},camera:{mode:a.dimensions===2?"2d":"3d"}}}function oo(a,e,i,s,l,c="wrap",f=!0){return{simulation:{...l?{engineId:l}:{},ruleId:a,neighborhoodId:e,grid:{boundary:c,wrap:c==="wrap"},...f?{initialCondition:{type:"cells",cells:Kp(s)}}:{}},renderer:{id:i}}}function Cs(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function PR(a,e){return JSON.stringify(a)===JSON.stringify(e)}function yy(a,e){let i=a;for(const s of e){if(!Cs(i)||!(s in i))return;i=i[s]}return i}function Sy(a){return a==="rendererId"?["renderer","id"]:a==="ruleId"?["simulation","ruleId"]:a.startsWith("grid.")?["simulation",...a.split(".")]:a.includes(".")?a.split("."):["simulation",a]}function ux(a,e){return typeof a=="number"&&Number.isFinite(a)?a:e}function fx(a){return typeof a=="number"&&Number.isFinite(a)?a:void 0}function IR(a,e){return typeof e.label=="string"?e.label:a}function Ap(a,e,i){const s=i.default_params[a];return s!==void 0?s:e.default}function ci(a,e){const i={...a};for(const[s,l]of Object.entries(e)){const c=i[s];i[s]=Cs(c)&&Cs(l)?ci(c,l):l}return i}function BR(a){return typeof a?.scene.params.caption=="string"?a.scene.params.caption:""}function FR(a){return a?.scene.params.autoplayOnSlideChange===!0}function dx(a,e){return ci(a,{simulation:{initialCondition:{type:"cells",cells:Kp(e)}}})}function Mu(a,e,i=[]){const s={};for(const[l,c]of Object.entries(a)){const f=[...i,l];if(Cs(c)&&f.join(".")!=="simulation.initialCondition"){const p=Mu(c,e,f);Object.keys(p).length>0&&(s[l]=p);continue}PR(c,yy(e,f))||(s[l]=c)}return s}function Jr(a,e){if(!e.parent_id)return{};const i=new Map(a.map(c=>[c.id,c])),s=[];let l=i.get(e.parent_id);for(;l;)s.unshift(l),l=l.parent_id?i.get(l.parent_id):void 0;return s.reduce((c,f)=>ci(c,f.params),{})}function zR(a,e){return a.sort_order-e.sort_order||a.name.localeCompare(e.name)||a.slug.localeCompare(e.slug)}function Cp(a,e){return a.filter(i=>i.parent_id===e).sort(zR)}function hx(a,e){const i=Cp(a,e);return i.length===0?0:Math.max(...i.map(s=>s.sort_order))+1}function My(a,e){if(e.length===0)return a;const[i,...s]=e,l={...a};if(s.length===0)return delete l[i],l;const c=l[i];if(!Cs(c))return l;const f=My(c,s);return Object.keys(f).length===0?delete l[i]:l[i]=f,l}function La(a,e,i){if(e.length===0)return a;const[s,...l]=e,c={...a};if(l.length===0)return c[s]=i,c;const f=c[s];return c[s]=La(Cs(f)?f:{},l,i),c}function HR(){const[a,e]=ee.useState(cx),[i,s]=ee.useState(()=>{const c=window.localStorage.getItem(rx);return dy.some(f=>f.id===c)?c:"retro-crt"});ee.useEffect(()=>{const c=()=>e(cx());return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]),ee.useEffect(()=>{document.documentElement.dataset.skin=i,window.localStorage.setItem(rx,i)},[i]);const l=a.view==="viewer"?g.jsx(QR,{deckId:a.deckId}):a.view==="edit"?g.jsx(JR,{deckId:a.deckId,initialSceneId:a.sceneId}):a.view==="library"?g.jsx(ZR,{initialNodeId:a.nodeId,returnTo:a.returnTo,treeId:a.treeId}):a.view==="engine"?g.jsx(YR,{engineId:a.engineId}):g.jsx(VR,{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(GR,{skin:i,onSkinChange:s})]})}function GR({skin:a,onSkinChange:e}){return g.jsxs("footer",{className:"app-footer",children:[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:i=>e(i.target.value),children:dy.map(i=>g.jsx("option",{value:i.id,children:i.label},i.id))})]})]})}function VR({initialTab:a}){const[e,i]=ee.useState(a),[s,l]=ee.useState(()=>{const W=Number(window.sessionStorage.getItem(ox));return W===1||W===2||W===3?W:2}),[c,f]=ee.useState(()=>{const W=Number(window.sessionStorage.getItem(lx));return W===1||W===2||W===3?W:2}),[p,m]=ee.useState(!1),[h,y]=ee.useState([]),[S,_]=ee.useState([]),[b,T]=ee.useState([]),[C,v]=ee.useState(null),[x,B]=ee.useState(null),[P,D]=ee.useState(()=>new Set),[O,U]=ee.useState({}),[N,A]=ee.useState(()=>new Set),[L,j]=ee.useState([]),[V,$]=ee.useState("Game of Life: Glider Deck"),[pe,ge]=ee.useState("Game of Life Presets"),[K,H]=ee.useState(()=>UR()),[G,ne]=ee.useState(()=>gy()),[ye,xe]=ee.useState("Ready"),F=ee.useMemo(()=>({1:b.filter(W=>W.supported_classes.some(z=>z.dimensions===1)),2:b.filter(W=>W.supported_classes.some(z=>z.dimensions===2)),3:b.filter(W=>W.supported_classes.some(z=>z.dimensions===3))}),[b]),J=F[s],Ce=ee.useMemo(()=>({1:S.filter(W=>W.supported_classes.some(z=>z.dimensions===1)),2:S.filter(W=>W.supported_classes.some(z=>z.dimensions===2)),3:S.filter(W=>W.supported_classes.some(z=>z.dimensions===3))}),[S]),Ue=Ce[c],Ie=ee.useCallback(async()=>{y(await gt("/api/ca/decks"))},[]),ae=ee.useCallback(async()=>{_(await gt("/api/ca/initial-condition-generators"))},[]),Ae=ee.useCallback(async()=>{T(await gt("/api/ca/engines"))},[]),Ee=ee.useCallback(async()=>{j(await gt("/api/ca/preset-trees"))},[]);ee.useEffect(()=>{async function W(){try{await Promise.all([Ie(),Ee(),Ae()])}catch(z){xe(z instanceof Error?z.message:"Load failed");return}try{await ae()}catch(z){_([]),xe(z instanceof Error?z.message:"ICG list unavailable")}}W()},[Ie,Ae,ae,Ee]),ee.useEffect(()=>{i(a),window.sessionStorage.setItem(Tp,a)},[a]);function He(W){i(W),m(!1),window.sessionStorage.setItem(Tp,W),window.history.replaceState({},"",po(W))}function nt(W){l(W),window.sessionStorage.setItem(ox,String(W))}function Ke(){const W=s===1?"elementary-1d":s===3?"voxel-3d":"2d-canvas";ne(z=>({...z,dimensions:s,rendererId:W})),m(!0)}async function zt(W){if(P.has(W.id)){D(z=>{const Ye=new Set(z);return Ye.delete(W.id),Ye});return}if(D(z=>new Set(z).add(W.id)),!O[W.id]){A(z=>new Set(z).add(W.id));try{const z=await gt(`/api/ca/engines/${W.id}/usage`);U(Ye=>({...Ye,[W.id]:z}))}catch(z){xe(z instanceof Error?z.message:"Engine usage could not be loaded"),D(Ye=>{const xt=new Set(Ye);return xt.delete(W.id),xt})}finally{A(z=>{const Ye=new Set(z);return Ye.delete(W.id),Ye})}}}function ht(W){const z=new URLSearchParams({node:W.node_id,return:po("engines")});Pi(`/admin/libraries/${W.tree_id}?${z.toString()}`)}function Et(W){f(W),window.sessionStorage.setItem(lx,String(W))}function yt(){H(W=>({...W,dimensions:c})),m(!0)}async function St(){try{xe("Creating deck...");const W=Date.now(),z=await gt("/api/ca/decks",{method:"POST",body:JSON.stringify({slug:`${to(V)}-${W}`,title:V.trim()||"Untitled deck",params:{studio:{}}})});m(!1),Pi(`/admin/edit/${z.id}`)}catch(W){xe(W instanceof Error?W.message:"Deck create failed")}}async function Mt(){try{xe(`Creating node tree "${pe}"...`);const W=Date.now(),z=await gt("/api/ca/preset-trees",{method:"POST",body:JSON.stringify({slug:`${to(pe)}-${W}`,name:pe.trim()||"Untitled node tree",description:"Admin-authored CA preset tree"})});j(Ye=>[z,...Ye]),m(!1),xe(`Created node tree "${z.name}"`)}catch(W){xe(W instanceof Error?W.message:"Node tree create failed")}}async function Ht(W){const z=`${W.node_count} ${W.node_count===1?"node":"nodes"}`;if(window.confirm(`Delete "${W.name}" and its ${z}? This cannot be undone.`))try{xe(`Deleting CA library "${W.name}"...`);const Ye=await fetch(`/api/ca/preset-trees/${W.id}`,{method:"DELETE"});if(!Ye.ok){const xt=await Ye.json().catch(()=>null);throw new Error(xt?.error?`Could not delete "${W.name}": ${xt.error}`:`Could not delete "${W.name}". It may still be referenced by a slide.`)}j(xt=>xt.filter(I=>I.id!==W.id)),xe(`Deleted CA library "${W.name}"`)}catch(Ye){xe(Ye instanceof Error?Ye.message:"CA library delete failed")}}async function Gt(W){try{const Ye=ro(W).presetTreeId,xt=Ye?h.filter(me=>me.id!==W.id&&ro(me).presetTreeId===Ye):[],I=!!(Ye&&xt.length===0),E=I?`Delete "${W.title}"? It is the only deck using its preset tree, so the tree can be removed as well.`:`Delete "${W.title}"?`;if(!window.confirm(E))return;if(xe(`Deleting "${W.title}"...`),!(await fetch(`/api/ca/decks/${W.id}`,{method:"DELETE"})).ok)throw new Error("Unable to delete deck");y(me=>me.filter(Ne=>Ne.id!==W.id));let se="";if(I&&Ye&&window.confirm("Remove the now-unused preset tree too?"))try{(await fetch(`/api/ca/preset-trees/${Ye}`,{method:"DELETE"})).ok||(se="Deck deleted, but the preset tree could not be removed.")}catch{se="Deck deleted, but the preset tree could not be removed."}await Ie(),xe(se||`Deleted "${W.title}"`)}catch(z){xe(z instanceof Error?z.message:"Deck delete failed")}}async function st(){try{xe(`Creating ICG "${K.name}"...`);const W=Date.now(),z=await gt("/api/ca/initial-condition-generators",{method:"POST",body:JSON.stringify({slug:`${to(K.name)}-${W}`,name:K.name,description:K.description.trim()||null,generatorKind:K.generatorKind,supportedClasses:[{dimensions:K.dimensions,states:K.states}],paramsSchema:_y(K),defaultParams:vy(K)})});_(Ye=>[z,...Ye]),m(!1),xe(`Created ICG "${z.name}"`)}catch(W){xe(W instanceof Error?W.message:"ICG create failed")}}async function It(){try{xe(`Creating engine "${G.name}"...`);const W=Date.now(),z=await gt("/api/ca/engines",{method:"POST",body:JSON.stringify({slug:`${to(G.name)}-${W}`,name:G.name.trim()||"Untitled CA engine",description:G.description.trim()||null,engineKind:G.engineKind,license:G.license.trim()||null,owner:G.owner.trim()||null,ipNotice:G.ipNotice.trim()||null,supportedClasses:[{dimensions:G.dimensions,states:G.states}],paramsSchema:$p(G),defaultParams:Qp(G)})});T(Ye=>[z,...Ye]),m(!1),xe(`Created engine "${z.name}"`)}catch(W){xe(W instanceof Error?W.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:ye})]}),g.jsxs("nav",{"aria-label":"Gallery sections",className:"gallery-tabs",children:[g.jsx("button",{className:e==="decks"?"active":"",type:"button",onClick:()=>He("decks"),children:"Decks"}),g.jsx("button",{className:e==="cas"?"active":"",type:"button",onClick:()=>He("cas"),children:"CAs"}),g.jsx("button",{className:e==="engines"?"active":"",type:"button",onClick:()=>He("engines"),children:"CA Engines"}),g.jsx("button",{className:e==="icgs"?"active":"",type:"button",onClick:()=>He("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(W=>g.jsxs("article",{"aria-label":`Open ${W.title}`,className:"deck-card gallery-entity-card panel",role:"link",tabIndex:0,onClick:()=>Pi(`/admin/edit/${W.id}`),onKeyDown:z=>{z.target===z.currentTarget&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),Pi(`/admin/edit/${W.id}`))},children:[g.jsx("span",{children:W.slug}),g.jsx("strong",{children:W.title}),g.jsx("small",{children:ro(W).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(),Pi(`/view/decks/${W.id}`)},children:"View"}),g.jsx("button",{"aria-label":`Delete ${W.title}`,className:"danger deck-trash-button",type:"button",onClick:z=>{z.stopPropagation(),Gt(W)},children:"🗑"})]})]},W.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:L.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:[L.map(W=>g.jsxs("article",{"aria-label":`Open ${W.name}`,className:`deck-card gallery-entity-card library-card panel${W.node_count===0?" empty-library":""}`,role:"link",tabIndex:0,onClick:()=>Pi(`/admin/libraries/${W.id}`),onKeyDown:z=>{z.target===z.currentTarget&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),Pi(`/admin/libraries/${W.id}`))},children:[g.jsx("span",{children:W.slug}),g.jsx("strong",{children:W.name}),g.jsx("small",{children:W.node_count===0?"Empty library":`${W.node_count} ${W.node_count===1?"node":"nodes"}`}),g.jsx("div",{className:"gallery-card-controls gallery-card-controls-end",children:g.jsx("button",{"aria-label":`Delete ${W.name}`,className:"danger deck-trash-button",title:`Delete ${W.name}`,type:"button",onClick:z=>{z.stopPropagation(),Ht(W)},children:"🗑"})})]},W.id)),L.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:J.length}),g.jsx("button",{className:"primary",type:"button",onClick:Ke,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(W=>g.jsxs("button",{"aria-selected":s===W,className:s===W?"active":"",role:"tab",type:"button",onClick:()=>nt(W),children:[W,"D",g.jsx("span",{children:F[W].length})]},W))}),g.jsxs("div",{className:"gallery-list",children:[J.map(W=>g.jsxs("article",{className:"deck-card engine-gallery-card panel",children:[g.jsxs("button",{"aria-label":`Edit ${W.name}`,className:"engine-card-main",type:"button",onClick:()=>B(W),children:[g.jsx("span",{children:W.engine_kind}),g.jsx("strong",{children:W.name}),g.jsx("small",{children:px(W.supported_classes)}),W.license?g.jsxs("small",{children:["License: ",W.license]}):null,W.owner?g.jsxs("small",{children:["Owner: ",W.owner]}):null]}),g.jsxs("button",{"aria-expanded":P.has(W.id),className:"engine-usage-toggle",type:"button",onClick:()=>{zt(W)},children:[g.jsx("span",{children:P.has(W.id)?"▾":"▸"}),"Preset usage",O[W.id]?g.jsx("small",{children:O[W.id].length}):null]}),P.has(W.id)?g.jsxs("div",{className:"engine-usage-list",children:[N.has(W.id)?g.jsx("p",{className:"empty",children:"Loading presets..."}):null,!N.has(W.id)&&(O[W.id]?.length??0)===0?g.jsx("p",{className:"empty",children:"No presets currently use this engine."}):null,O[W.id]?.map(z=>g.jsxs("button",{type:"button",onClick:()=>ht(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]},W.id)),J.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:Ue.length}),g.jsx("button",{className:"primary",type:"button",onClick:yt,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(W=>g.jsxs("button",{"aria-selected":c===W,className:c===W?"active":"",role:"tab",type:"button",onClick:()=>Et(W),children:[W,"D",g.jsx("span",{children:Ce[W].length})]},W))}),g.jsxs("div",{className:"gallery-list",children:[Ue.map(W=>g.jsxs("article",{"aria-label":`Edit ${W.name}`,className:"deck-card gallery-entity-card panel",role:"button",tabIndex:0,onClick:()=>v(W),onKeyDown:z=>{z.target===z.currentTarget&&(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),v(W))},children:[g.jsx("span",{children:W.generator_kind}),g.jsx("strong",{children:W.name}),g.jsx("small",{children:px(W.supported_classes)}),W.description?g.jsx("small",{children:W.description}):null]},W.id)),Ue.length===0?g.jsxs("p",{className:"empty",children:["No ",c,"D generators yet."]}):null]})]}):null]}),p?g.jsx(kR,{activeTab:e,deckName:V,engineConfig:G,icgConfig:K,treeName:pe,onClose:()=>m(!1),onCreateDeck:()=>{St()},onCreateEngine:()=>{It()},onCreateIcg:()=>{st()},onCreateTree:()=>{Mt()},onDeckNameChange:$,onEngineConfigChange:ne,onIcgConfigChange:H,onTreeNameChange:ge}):null,x?g.jsx(jR,{engine:x,onClose:()=>B(null),onSaved:W=>{T(z=>z.map(Ye=>Ye.id===W.id?W:Ye)),B(null),xe(`Saved engine "${W.name}"`)}}):null,C?g.jsx(qR,{generator:C,onClose:()=>v(null),onSaved:W=>{_(z=>z.map(Ye=>Ye.id===W.id?W:Ye)),v(null),xe(`Saved ICG "${W.name}"`)}}):null]})}function kR({activeTab:a,deckName:e,engineConfig:i,icgConfig:s,treeName:l,onClose:c,onCreateDeck:f,onCreateEngine:p,onCreateIcg:m,onCreateTree:h,onDeckNameChange:y,onEngineConfigChange:S,onIcgConfigChange:_,onTreeNameChange:b}){const T={decks:"deck",cas:"CA library",engines:"CA engine",icgs:"initial condition generator"},C={decks:f,cas:h,engines:p,icgs:m}[a];return ee.useEffect(()=>{function v(x){x.key==="Escape"&&c()}return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[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:v=>v.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 ",T[a]]})]}),g.jsx("button",{type:"button",onClick:c,children:"Close"})]}),g.jsxs("div",{className:"gallery-create-body",children:[a==="decks"?g.jsxs("label",{children:["Deck name",g.jsx("input",{autoFocus:!0,value:e,onChange:v=>y(v.target.value)})]}):null,a==="cas"?g.jsxs("label",{children:["Library name",g.jsx("input",{autoFocus:!0,value:l,onChange:v=>b(v.target.value)})]}):null,a==="engines"?g.jsx(Jp,{config:i,onChange:S}):null,a==="icgs"?g.jsx(by,{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 ",T[a]]})]})]})]})})}function px(a){return a.map(e=>`${e.dimensions}D · ${e.states} states`).join(", ")}function by({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:i=>e(s=>({...s,name:i.target.value}))})]}),g.jsxs("label",{children:["Description",g.jsx("textarea",{value:a.description,onChange:i=>e(s=>({...s,description:i.target.value}))})]}),g.jsxs("div",{className:"root-config-grid",children:[g.jsxs("label",{children:["Dimensions",g.jsxs("select",{value:a.dimensions,onChange:i=>e(s=>({...s,dimensions:Number(i.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:i=>e(s=>({...s,states:Math.max(2,Number(i.target.value)||2)}))})]}),g.jsxs("label",{children:["Density",g.jsx("input",{max:1,min:0,step:.01,type:"number",value:a.density,onChange:i=>e(s=>({...s,density:Math.max(0,Math.min(1,Number(i.target.value)||0))}))})]})]}),g.jsxs("label",{children:["Seed",g.jsx("input",{value:a.seed,onChange:i=>e(s=>({...s,seed:i.target.value}))})]})]})}function Jp({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:i=>e(s=>({...s,name:i.target.value}))})]}),g.jsxs("label",{children:["Description",g.jsx("textarea",{value:a.description,onChange:i=>e(s=>({...s,description:i.target.value}))})]}),g.jsxs("div",{className:"root-config-grid",children:[g.jsxs("label",{children:["Engine kind",g.jsx("input",{value:a.engineKind,onChange:i=>e(s=>({...s,engineKind:i.target.value}))})]}),g.jsxs("label",{children:["Rule id",g.jsx("input",{value:a.ruleId,onChange:i=>e(s=>({...s,ruleId:i.target.value}))})]}),g.jsxs("label",{children:["Renderer",g.jsxs("select",{value:a.rendererId,onChange:i=>e(s=>({...s,rendererId:i.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:i=>e(s=>({...s,dimensions:Number(i.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:i=>e(s=>({...s,states:Math.max(2,Number(i.target.value)||2)}))})]}),g.jsxs("label",{children:["License",g.jsx("input",{value:a.license,onChange:i=>e(s=>({...s,license:i.target.value}))})]}),g.jsxs("label",{children:["Owner",g.jsx("input",{value:a.owner,onChange:i=>e(s=>({...s,owner:i.target.value}))})]})]}),g.jsxs("label",{children:["IP notice",g.jsx("textarea",{value:a.ipNotice,onChange:i=>e(s=>({...s,ipNotice:i.target.value}))})]})]})}function jR({engine:a,onClose:e,onSaved:i}){const[s,l]=ee.useState(()=>wp(a)),[c,f]=ee.useState(!1),[p,m]=ee.useState("");ee.useEffect(()=>{function y(S){S.key==="Escape"&&!c&&e()}return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[e,c]);async function h(){try{f(!0),m("");const y=await gt(`/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:$p(s),defaultParams:Qp(s)})});i(y)}catch(y){m(y instanceof Error?y.message:"Engine save failed")}finally{f(!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:y=>y.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("button",{disabled:c,type:"button",onClick:e,children:"Close"})]}),g.jsxs("div",{className:"gallery-create-body",children:[g.jsx(Jp,{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 mx(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,seed:typeof a.default_params.seed=="string"?a.default_params.seed:"studio-seed"}}function wp(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 XR({disabled:a,engine:e,settings:i,onSet:s}){const l=e?Object.entries(e.params_schema).filter(c=>Cs(c[1])):[];return e?l.length===0?g.jsx("p",{className:"param-empty",children:"This engine does not expose editable settings."}):g.jsx("div",{className:"engine-settings-grid inspector-engine-settings",children:l.map(([c,f])=>{const p=Sy(c),m=yy(i,p)??Ap(c,f,e);return g.jsx(WR,{disabled:a,engine:e,paramKey:c,path:p,schema:f,value:m,onSet:s},c)})}):g.jsx("p",{className:"param-empty",children:"Select a compatible engine to edit engine settings."})}function WR({disabled:a,engine:e,paramKey:i,path:s,schema:l,value:c,onSet:f}){const p=typeof l.type=="string"?l.type:"string",m=IR(i,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=>f(s,h.target.checked)}),g.jsx("span",{children:m})]});if(p==="select"&&Array.isArray(l.options)){const h=l.options.filter(Cs),y=new Set(h.map(T=>String(T.value))),S=String(c??""),_=String(Ap(i,l,e)??""),b=S&&!y.has(S)?S:"";return g.jsxs("label",{children:[m,g.jsxs("select",{disabled:a,value:b||S,onChange:T=>f(s,T.target.value),children:[b?g.jsxs("option",{disabled:!0,value:b,children:["Unsupported: ",b]}):null,h.map(T=>{const C=T.value;return g.jsx("option",{value:String(C),children:typeof T.label=="string"?T.label:String(C)},String(C))})]}),b?g.jsxs("small",{className:"engine-setting-warning",children:["Not supported by this engine.",g.jsxs("button",{disabled:a||!_,type:"button",onClick:()=>f(s,_),children:["Use ",xy(_)]})]}):null]})}return p==="number"||p==="range"?g.jsxs("label",{children:[m,g.jsx("input",{disabled:a,max:fx(l.max),min:fx(l.min),step:ux(l.step,p==="range"?.01:1),type:p==="range"?"range":"number",value:typeof c=="number"?c:ux(Ap(i,l,e),0),onChange:h=>f(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=>f(s,h.target.value)})]})}function qR({generator:a,onClose:e,onSaved:i}){const[s,l]=ee.useState(()=>mx(a)),[c,f]=ee.useState(!1),[p,m]=ee.useState("");ee.useEffect(()=>{l(mx(a)),m("")},[a]);async function h(){f(!0),m("");try{const y=await gt(`/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:_y(s),defaultParams:vy(s)})});i(y)}catch(y){m(y instanceof Error?y.message:"ICG save failed")}finally{f(!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:y=>y.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("button",{disabled:c,type:"button",onClick:e,children:"Close"})]}),g.jsxs("div",{className:"gallery-create-body",children:[g.jsx(by,{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 YR({engineId:a}){const[e,i]=ee.useState(null),[s,l]=ee.useState(()=>gy()),[c,f]=ee.useState("Loading engine...");ee.useEffect(()=>{async function m(){try{const h=await gt(`/api/ca/engines/${a}`);i(h),l(wp(h)),f("Engine ready")}catch(h){f(h instanceof Error?h.message:"Engine load failed")}}m()},[a]);async function p(){if(e)try{f(`Saving "${s.name}"...`);const m=await gt(`/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:$p(s),defaultParams:Qp(s)})});i(m),l(wp(m)),f(`Saved "${m.name}"`)}catch(m){f(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:()=>Pi(po("engines")),children:"Gallery"}),g.jsx("div",{className:"status",children:c})]})]}),g.jsxs("section",{className:"panel icg-editor-panel",children:[g.jsx(Jp,{config:s,onChange:l}),g.jsx("button",{className:"primary",disabled:!e,type:"button",onClick:()=>{p()},children:"Save engine"})]})]})}function ZR({initialNodeId:a,returnTo:e,treeId:i}){const[s,l]=ee.useState(null),[c,f]=ee.useState([]),[p,m]=ee.useState([]),[h,y]=ee.useState([]),[S,_]=ee.useState([]),[b,T]=ee.useState(""),[C,v]=ee.useState(""),[x,B]=ee.useState(""),[P,D]=ee.useState(.28),[O,U]=ee.useState("studio-seed"),[N,A]=ee.useState("Untitled preset"),[L,j]=ee.useState(""),[V,$]=ee.useState(2),[pe,ge]=ee.useState(2),[K,H]=ee.useState("2d-canvas"),[G,ne]=ee.useState("moore"),[ye,xe]=ee.useState("B3/S23"),[F,J]=ee.useState(""),[Ce,Ue]=ee.useState("wrap"),[Ie,ae]=ee.useState(()=>ar()),[Ae,Ee]=ee.useState(0),[He,nt]=ee.useState(!1),[Ke,zt]=ee.useState(!1),[ht,Et]=ee.useState(!1),[yt,St]=ee.useState(()=>!window.matchMedia("(max-width: 820px)").matches),[Mt,Ht]=ee.useState(()=>!window.matchMedia("(max-width: 820px)").matches),[Gt,st]=ee.useState("ca"),[It,W]=ee.useState("Loading library..."),[z,Ye]=ee.useState(""),[xt,I]=ee.useState(0),E=ee.useRef(!1),X=c.find(re=>re.id===b)??null,se=ee.useMemo(()=>new Set(p.map(re=>re.node_id)),[p]),me=ee.useMemo(()=>({dimensions:V,states:pe,neighborhoodId:G}),[V,G,pe]),Ne=X?ci(ci(Jr(c,X),X.params),ci(oo(ye,G,K,Ie,F,Ce),{caClass:me})):ci(oo(ye,G,K,Ie,F,Ce),{caClass:me}),Oe=Sl(Ne),_e=ee.useMemo(()=>h.filter(re=>Oa(re,Oe)),[h,Oe]),he=ee.useMemo(()=>S.filter(re=>Oa(re,Oe)),[S,Oe]),Le=ee.useMemo(()=>he.find(re=>re.id===x)??he.find(re=>re.engine_kind===F),[he,F,x]),je=ee.useMemo(()=>Dh(Oe),[Oe]),ze=ee.useCallback(async()=>{const[re,we]=await Promise.all([gt(`/api/ca/preset-trees/${i}/nodes`),gt(`/api/ca/preset-trees/${i}/node-usage`)]);return f(re),m(we),re},[i]),Fe=ee.useCallback(async()=>{const[re,we,Ge,it]=await Promise.all([gt("/api/ca/preset-trees"),gt(`/api/ca/preset-trees/${i}/nodes`),gt(`/api/ca/preset-trees/${i}/node-usage`),gt("/api/ca/engines")]);l(re.find(vt=>vt.id===i)??null),f(we),m(Ge),_(it);try{y(await gt("/api/ca/initial-condition-generators"))}catch{y([])}const lt=we.find(vt=>vt.id===a)??we[0];lt?await Je(lt.id):W("Library ready. Add the first top-level preset.")},[a,i]);ee.useEffect(()=>{Fe().catch(re=>W(re instanceof Error?re.message:"Library load failed"))},[Fe]),ee.useEffect(()=>{async function re(){try{const[we,Ge]=await Promise.all([gt("/api/ca/initial-condition-generators"),gt("/api/ca/engines")]);y(we),_(Ge)}catch{y([]),_([])}}return window.addEventListener("focus",re),()=>window.removeEventListener("focus",re)},[]),ee.useEffect(()=>{C&&!_e.some(re=>re.id===C)&&v("")},[_e,C]),ee.useEffect(()=>{if(x&&!he.some(re=>re.id===x)){B("");return}if(!x&&F){const re=he.find(we=>we.engine_kind===F);re&&B(re.id)}},[he,F,x]),ee.useEffect(()=>{if(!He)return;const re=window.setInterval(()=>{ae(we=>El(we,Ne)),Ee(we=>we+1)},220);return()=>window.clearInterval(re)},[ye,He]),ee.useEffect(()=>{if(!X||xt===0||E.current)return;const re=window.setTimeout(async()=>{try{const we=Jr(c,X),Ge=Mu(ci(X.params,ci(oo(ye,G,K,Ie,F,Ce,!1),{caClass:me})),we);await gt(`/api/ca/preset-trees/${X.tree_id}/nodes/${X.id}`,{method:"PATCH",body:JSON.stringify({name:N,description:L.trim()||null,params:Ge})}),f(it=>it.map(lt=>lt.id===X.id?{...lt,name:N,description:L.trim()||null,params:Ge}:lt)),W("Preset saved")}catch(we){W(we instanceof Error?we.message:"Preset autosave failed")}},450);return()=>window.clearTimeout(re)},[Ce,me,xt,F,G,L,N,c,K,ye,X]);function Qe(){E.current||I(re=>re+1)}async function Je(re){E.current=!0,nt(!1);const[we,Ge]=await Promise.all([gt(`/api/ca/preset-trees/${i}/nodes/${re}`),gt(`/api/ca/preset-trees/${i}/nodes/${re}/resolved`)]);T(we.id),zt(!1),A(we.name),j(we.description??"");const it=Sl(Ge.params);$(it?.dimensions??2),ge(typeof it?.states=="number"?it.states:it?.states.length??2),H(Ge.params.renderer?.id??"2d-canvas"),ne(Ge.params.simulation?.neighborhoodId??"moore"),xe(Ge.params.simulation?.ruleId??"B3/S23"),Ue(xx(Ge.params));const lt=Ge.params.simulation?.engineId??"";J(lt),B(S.find(vt=>vt.engine_kind===lt)?.id??""),v(""),Ye(""),ae(Rl(Ge.params.simulation?.initialCondition?.cells)),Ee(0),W(`Loaded preset "${we.name}"`),window.setTimeout(()=>{E.current=!1,I(0),zt(!1)},0)}function pt(re){Je(re.id),window.matchMedia("(max-width: 820px)").matches&&St(!1)}function Z(){window.matchMedia("(max-width: 820px)").matches&&Ht(!1),St(!0)}function Pe(){window.matchMedia("(max-width: 820px)").matches&&St(!1),Ht(!0)}async function Se(re="shot"){const we=Date.now(),Ge=Cp(c,null),it=re==="chapter"?`Group ${Ge.length+1}`:`Preset ${Ge.length+1}`;try{const lt=await gt(`/api/ca/preset-trees/${i}/nodes`,{method:"POST",body:JSON.stringify({parentId:null,slug:`${to(it)}-${we}`,name:it,kind:re,description:null,sortOrder:hx(c,null),params:OR({rootName:it,rendererId:K,neighborhoodId:G,dimensions:2,states:2,ruleId:ye})})});await ze(),await Je(lt.id),W(`Created preset "${lt.name}"`)}catch(lt){W(lt instanceof Error?lt.message:"Preset create failed")}}async function Be(re,we="shot"){const Ge=Date.now(),it=we==="chapter"?`${re.name} group`:`${re.name} variant`;try{const lt=await gt(`/api/ca/preset-trees/${i}/nodes`,{method:"POST",body:JSON.stringify({parentId:re.id,slug:`${to(it)}-${Ge}`,name:it,kind:we,description:null,sortOrder:hx(c,re.id),params:{}})});await ze(),await Je(lt.id),W(`Created child preset "${lt.name}"`)}catch(lt){W(lt instanceof Error?lt.message:"Preset create failed")}}async function ke(re){const we=new Set([re.id]);let Ge=!0;for(;Ge;){Ge=!1;for(const vt of c)vt.parent_id&&we.has(vt.parent_id)&&!we.has(vt.id)&&(we.add(vt.id),Ge=!0)}const lt=p.filter(vt=>we.has(vt.node_id)).reduce((vt,In)=>vt+In.scene_count,0);if(lt>0){const vt=we.size>1?`This preset contains ${lt} slide reference${lt===1?"":"s"} in its subtree. Detach them before deleting it.`:`This preset is assigned to ${lt} slide${lt===1?"":"s"}. Detach it before deleting.`;return W(vt),!1}try{const vt=await fetch(`/api/ca/preset-trees/${re.tree_id}/nodes/${re.id}`,{method:"DELETE"});if(!vt.ok){const hn=await vt.json().catch(()=>null);throw new Error(hn?.error??"Preset could not be deleted.")}re.id===b&&(T(""),A("Untitled preset"),j(""));const In=await ze(),Zt=In.find(hn=>hn.parent_id===re.parent_id)??In[0];return Zt&&await Je(Zt.id),W(`Deleted preset "${re.name}"`),!0}catch(vt){return W(vt instanceof Error?vt.message:"Preset delete failed"),!1}}async function q(re,we){const Ge=Cp(c,re.parent_id),it=Ge.findIndex(Zt=>Zt.id===re.id),lt=it+we;if(it===-1||lt<0||lt>=Ge.length)return;const vt=[...Ge],[In]=vt.splice(it,1);vt.splice(lt,0,In);try{const Zt=await Promise.all(vt.map((yn,fn)=>gt(`/api/ca/preset-trees/${yn.tree_id}/nodes/${yn.id}`,{method:"PATCH",body:JSON.stringify({sortOrder:fn})}))),hn=new Map(Zt.map(yn=>[yn.id,yn]));f(yn=>yn.map(fn=>hn.get(fn.id)??fn)),W(`Moved "${re.name}"`)}catch(Zt){W(Zt instanceof Error?Zt.message:"Preset reorder failed")}}async function Me(re,we,Ge){let it=La(re.params,we,Ge);const lt=we.join(".")==="caClass.dimensions"||we.join(".")==="caClass.states"||we.join(".")==="caClass.neighborhoodId",vt=[];if(lt){const Zt=ci(Jr(c,re),it),hn=Sl(Zt),yn=Zt.simulation?.engineId,fn=S.find(Kt=>Kt.engine_kind===yn),Gn=Zt.renderer?.id,Bn=Dh(hn);if(fn&&!Oa(fn,hn)&&(it=La(it,["simulation","engineId"],null),vt.push(`Evolution function "${fn.name}" was unset`)),typeof Gn=="string"&&!Bn.some(Kt=>Kt.id===Gn)){const Kt=Bn[0];it=La(it,["renderer","id"],Kt?.id??null),vt.push(Kt?`Renderer changed to "${Kt.label}"`:"No renderer supports this dimensionality and state space")}const Ti=h.find(Kt=>Kt.id===C);re.id===b&&Ti&&!Oa(Ti,hn)&&(v(""),vt.push(`Initial condition generator "${Ti.name}" was unset`))}const In=await gt(`/api/ca/preset-trees/${re.tree_id}/nodes/${re.id}`,{method:"PATCH",body:JSON.stringify({params:it})});f(Zt=>Zt.map(hn=>hn.id===re.id?In:hn)),re.id===b&&await Je(re.id),vt.length>0&&Ye(vt.join(". ")),W(`Saved ${we.join(".")} on "${re.name}"`)}async function De(re,we){const Ge=await gt(`/api/ca/preset-trees/${re.tree_id}/nodes/${re.id}`,{method:"PATCH",body:JSON.stringify({name:we})});f(it=>it.map(lt=>lt.id===re.id?Ge:lt)),re.id===b&&A(Ge.name),W(`Renamed preset to "${Ge.name}"`)}async function ft(re,we){const Ge=My(re.params,we),it=await gt(`/api/ca/preset-trees/${re.tree_id}/nodes/${re.id}`,{method:"PATCH",body:JSON.stringify({params:Ge})});f(lt=>lt.map(vt=>vt.id===re.id?it:vt)),re.id===b&&await Je(re.id),W(`Unset ${we.join(".")} on "${re.name}"`)}async function rt(){if(!X||!Oe)return;const re=_e.find(we=>we.id===C);if(re)try{nt(!1);const we=Math.max(0,Math.min(1,P)),Ge=nb(re.generator_kind,{settings:Ne,caClass:Oe,params:{density:we,seed:O}}),it=Jr(c,X),lt=Mu(ci(X.params,{simulation:{initialCondition:Ge}}),it),vt=await gt(`/api/ca/preset-trees/${X.tree_id}/nodes/${X.id}`,{method:"PATCH",body:JSON.stringify({params:lt})});f(In=>In.map(Zt=>Zt.id===vt.id?vt:Zt)),ae(Rl(Ge.cells)),zt(!1),Ee(0),W(`Generated initial condition on "${X.name}"`)}catch(we){W(we instanceof Error?we.message:"ICG apply failed")}}function Nt(re){const we=he.find(Ge=>Ge.id===re);if(B(re),!we){J(""),X&&(f(Ge=>Ge.map(it=>it.id===X.id?{...it,params:La(it.params,["simulation","engineId"],null)}:it)),Qe());return}if(J(we.engine_kind),typeof we.default_params.ruleId=="string"&&xe(we.default_params.ruleId),typeof we.default_params.rendererId=="string"&&je.some(Ge=>Ge.id===we.default_params.rendererId)&&H(we.default_params.rendererId),X){Me(X,["simulation","engineId"],we.engine_kind);for(const[Ge,it]of Object.entries(we.default_params))Me(X,Sy(Ge),it)}Qe()}function Hn(re,we){if(!X)return;const Ge=re.join(".");Ge==="simulation.ruleId"&&typeof we=="string"&&xe(we),Ge==="renderer.id"&&typeof we=="string"&&H(we),Ge==="simulation.grid.boundary"&&(we==="wrap"||we==="mirror"||we==="fixed")&&Ue(we),Ge==="simulation.grid.wrap"&&typeof we=="boolean"&&Ue(we?"wrap":"fixed"),Me(X,re,we)}function ua(re,we,Ge=G){if(!X)return;const it={dimensions:re,states:we,neighborhoodId:Ge},lt=[];let vt=K,In=!1;const Zt=S.find(fn=>fn.engine_kind===F);Zt&&!Oa(Zt,it)&&(In=!0,J(""),B(""),lt.push(`Evolution function "${Zt.name}" was unset`));const hn=h.find(fn=>fn.id===C);hn&&!Oa(hn,it)&&(v(""),lt.push(`Initial condition generator "${hn.name}" was unset`));const yn=Dh(it);yn.some(fn=>fn.id===K)||(vt=yn[0]?.id??"",H(vt),lt.push(vt?`Renderer changed to "${yn[0].label}"`:"No renderer supports this dimensionality and state space")),$(re),ge(we),ne(Ge),Ye(lt.join(". ")),f(fn=>fn.map(Gn=>{if(Gn.id!==X.id)return Gn;let Bn=La(Gn.params,["caClass"],it);return Bn=La(Bn,["simulation","neighborhoodId"],Ge),In&&(Bn=La(Bn,["simulation","engineId"],null)),vt!==K&&(Bn=La(Bn,["renderer","id"],vt)),{...Gn,params:Bn}})),Qe()}function Ga(re){nt(!1),Ee(0),ae(re),zt(!0)}async function Va(){if(!(!X||ht))try{Et(!0),nt(!1);const re=Jr(c,X),we=Mu(ci(X.params,{simulation:{initialCondition:{type:"cells",cells:Kp(Ie)}}}),re),Ge=await gt(`/api/ca/preset-trees/${X.tree_id}/nodes/${X.id}`,{method:"PATCH",body:JSON.stringify({params:we})});f(it=>it.map(lt=>lt.id===Ge.id?Ge:lt)),zt(!1),Ee(0),W(`Saved initial condition on "${X.name}"`)}catch(re){W(re instanceof Error?re.message:"Initial condition save failed")}finally{Et(!1)}}function ka(){nt(!1),ae(re=>El(re,Ne)),Ee(re=>re+1)}return g.jsxs("main",{className:"studio-shell preset-studio-shell",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:()=>Pi(e??po("cas")),children:"Back"})]}),g.jsx("div",{className:"topbar-actions",children:g.jsx("div",{className:"status",children:It})})]}),g.jsxs("section",{className:`preset-studio-workspace${yt?" tree-open":""}${Mt?" inspector-open":""}`,children:[g.jsx("button",{"aria-label":"Close preset drawer",className:"drawer-scrim tree-scrim",type:"button",onClick:()=>St(!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("button",{"aria-label":"Close preset drawer",className:"icon-button drawer-close",type:"button",onClick:()=>St(!1),children:"×"})]}),g.jsxs("div",{className:"drawer-scroll",children:[g.jsxs("div",{className:"root-selector",children:[g.jsx("button",{className:"primary",type:"button",onClick:()=>{Se()},children:"New preset"}),g.jsx("button",{type:"button",onClick:()=>{Se("chapter")},children:"New group"})]}),g.jsx("div",{className:"tree-list",children:g.jsx(_R,{engines:S,nodes:c,selectedNodeId:b,usedNodeIds:se,onCreateChild:re=>{Be(re,"shot")},onCreateGroup:re=>{Be(re,"chapter")},onDelete:re=>ke(re),onMove:(re,we)=>{q(re,we)},onRename:(re,we)=>De(re,we),onSelect:pt,onSet:(re,we,Ge)=>{Me(re,we,Ge)},onUnset:(re,we)=>{ft(re,we)}})})]})]}),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:Z,children:"Presets"}),g.jsxs("div",{children:[g.jsx("p",{className:"eyebrow",children:"Preset Preview"}),g.jsx("h2",{children:X?N:"Select a preset"})]})]}),g.jsxs("div",{className:"button-row",children:[g.jsx("button",{type:"button",onClick:ka,children:"Step"}),g.jsx("button",{className:"primary playback-button",type:"button",onClick:()=>nt(re=>!re),children:He?"⏸":"▶"}),g.jsx("button",{type:"button",onClick:Pe,children:"Inspector"})]})]}),g.jsxs("div",{className:`preset-renderer-stage${Ke?" ic-dirty":""}`,children:[Ke?g.jsxs("div",{className:"ic-dirty-banner",role:"status",children:[g.jsx("span",{children:"Unsaved initial condition"}),g.jsx("button",{className:"primary",disabled:!X||ht,type:"button",onClick:()=>{Va()},children:ht?"Saving...":"Save"})]}):null,g.jsx(Bu,{caption:"",cells:Ie,settings:Ne,onCellsChange:Ga})]}),g.jsxs("footer",{className:"metrics preset-stage-metrics",children:[g.jsxs("span",{children:["Generation ",g.jsx("strong",{children:Ae})]}),g.jsxs("span",{children:["Live cells ",g.jsx("strong",{children:hy(Ie)})]}),g.jsxs("span",{children:["Preset ",g.jsx("strong",{children:b?b.slice(0,8):"none"})]})]})]}),g.jsx("button",{"aria-label":"Close inspector",className:"drawer-scrim inspector-scrim",type:"button",onClick:()=>Ht(!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:X?N:"No preset selected"})]}),g.jsx("button",{"aria-label":"Close inspector",className:"icon-button drawer-close",type:"button",onClick:()=>Ht(!1),children:"×"})]}),g.jsxs("div",{className:"inspector-tabs",role:"tablist","aria-label":"Preset inspector sections",children:[g.jsx("button",{className:Gt==="ca"?"active":"",role:"tab",type:"button",onClick:()=>st("ca"),children:"CA"}),g.jsx("button",{className:Gt==="initial"?"active":"",role:"tab",type:"button",onClick:()=>st("initial"),children:"Initial State"}),g.jsx("button",{className:Gt==="display"?"active":"",role:"tab",type:"button",onClick:()=>st("display"),children:"Display"})]}),g.jsxs("div",{className:"drawer-scroll inspector-body",children:[Gt==="ca"?g.jsxs("div",{className:"inspector-section",children:[z?g.jsx("div",{className:"compatibility-warning",role:"alert",children:z}):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:!X,value:N,onChange:re=>{A(re.target.value),Qe()}})]}),g.jsxs("label",{children:["Description",g.jsx("textarea",{disabled:!X,value:L,onChange:re=>{j(re.target.value),Qe()}})]}),g.jsxs("div",{className:"preset-modal-class-grid inspector-ca-class-grid",children:[g.jsxs("label",{children:["Dimensions",g.jsxs("select",{disabled:!X,value:V,onChange:re=>{ua(Number(re.target.value),pe,G)},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:!X,min:2,step:1,type:"number",value:pe,onChange:re=>ua(V,Math.max(2,Number(re.target.value)||2),G)})]}),g.jsxs("label",{children:["Neighbourhood",g.jsxs("select",{disabled:!X,value:G,onChange:re=>{ua(V,pe,re.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:!X,value:Le?.id??"",onChange:re=>Nt(re.target.value),children:[g.jsx("option",{value:"",children:"Select evolution function"}),he.map(re=>g.jsx("option",{value:re.id,children:re.name},re.id))]})]}),Le?g.jsx("small",{className:"param-empty",children:Le.license?`License: ${Le.license}`:"No license metadata"}):g.jsx("p",{className:"param-empty",children:he.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(XR,{disabled:!X,engine:Le,settings:Ne,onSet:Hn})]})]}):null,Gt==="initial"?g.jsxs("div",{className:"inspector-section",children:[g.jsxs("div",{className:"button-row initial-condition-actions",children:[g.jsx("button",{type:"button",onClick:()=>Ga(ar()),children:"Clear canvas"}),g.jsx("button",{className:"primary",disabled:!X||!Ke||ht,type:"button",onClick:()=>{Va()},children:ht?"Saving...":"Save initial condition"})]}),Ke?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."}),_e.length>0?g.jsxs(g.Fragment,{children:[g.jsxs("label",{children:["Generator",g.jsxs("select",{value:C,onChange:re=>{const we=_e.find(Ge=>Ge.id===re.target.value);v(re.target.value),typeof we?.default_params.density=="number"&&D(we.default_params.density),typeof we?.default_params.seed=="string"&&U(we.default_params.seed)},children:[g.jsx("option",{value:"",children:"Select generator"}),_e.map(re=>g.jsx("option",{value:re.id,children:re.name},re.id))]})]}),g.jsxs("div",{className:"icg-controls",children:[g.jsxs("label",{children:["Density",g.jsx("input",{max:1,min:0,step:.01,type:"range",value:P,onChange:re=>D(Number(re.target.value))})]}),g.jsxs("strong",{children:[Math.round(P*100),"%"]})]}),g.jsxs("label",{children:["Seed",g.jsx("input",{value:O,onChange:re=>U(re.target.value)})]}),g.jsx("button",{className:"primary",disabled:!X||!C,type:"button",onClick:()=>{rt()},children:"Generate initial condition"})]}):g.jsx("p",{className:"param-empty",children:"No matching generator for this preset class."})]}):null,Gt==="display"?g.jsxs("div",{className:"inspector-section",children:[g.jsxs("label",{children:["Renderer",g.jsx("select",{disabled:!X,value:K,onChange:re=>{H(re.target.value),Qe()},children:je.map(re=>g.jsx("option",{value:re.id,children:re.label},re.id))})]}),je.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 KR({assignedNodeId:a,assignedNodeName:e,autoplayOnSlideChange:i,caption:s,scene:l,slideTitle:c,onAutoplayChange:f,onCaptionChange:p,onClose:m,onSelectCa:h,onSlideTitleChange:y}){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("button",{type:"button",onClick:m,children:"Close"})]}),g.jsxs("div",{className:"slide-metadata-body",children:[g.jsxs("label",{children:["Slide name",g.jsx("input",{value:c,onChange:S=>y(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:i,type:"checkbox",onChange:S=>f(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 $R({assignedNodeId:a,loading:e,nodes:i,presetTrees:s,resolvedNode:l,selectedNode:c,selectedTreeId:f,onClose:p,onEditSelected:m,onSelectNode:h,onSelectTree:y,onUseSelected:S}){const _=Rl(l?.params.simulation?.initialCondition?.cells);return ee.useEffect(()=>{function b(T){T.key==="Escape"&&p()}return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[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:b=>b.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("button",{type:"button",onClick:p,children:"Close"})]}),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:f,onChange:b=>y(b.target.value),children:s.map(b=>g.jsxs("option",{value:b.id,children:[b.name," (",b.node_count,")"]},b.id))})]}),e?g.jsx("p",{className:"empty",children:"Loading CA presets..."}):g.jsx(dR,{assignedNodeId:a,nodes:i,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(Bu,{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 QR({deckId:a}){const[e,i]=ee.useState(null),[s,l]=ee.useState(0),[c,f]=ee.useState(()=>oo("B3/S23","moore","2d-canvas",ar())),[p,m]=ee.useState(()=>ar()),[h,y]=ee.useState(0),[S,_]=ee.useState(!1),[b,T]=ee.useState("Loading viewer..."),C=ee.useRef(c),v=ee.useRef(s),x=e?.scenes[s]??null,B=ee.useMemo(()=>dx(c,p),[p,c]);ee.useEffect(()=>{C.current=c},[c]),ee.useEffect(()=>{v.current=s},[s]);function P(U,N,A={}){const L=A.forceReinitialize===!0||U.scene.apply_mode!=="patch_existing"&&U.scene.requires_previous_scene!==!0;l(N),f(U.params),L&&(m(Rl(U.params.simulation?.initialCondition?.cells)),y(0)),_(FR(U)),T(U.scene.title)}const D=ee.useCallback((U,N={})=>{const A=e?.scenes??[];if(A.length===0)return;const L=Math.min(Math.max(U,0),A.length-1);P(A[L],L,N)},[e]),O=ee.useCallback(()=>{m(U=>El(U,dx(C.current,U))),y(U=>U+1)},[]);return ee.useEffect(()=>{let U=!1;async function N(){try{const A=await gt(`/api/ca/decks/${a}/resolved`);if(U)return;i(A),A.scenes[0]?P(A.scenes[0],0,{forceReinitialize:!0}):T("Deck has no slides")}catch(A){U||T(A instanceof Error?A.message:"Viewer load failed")}}return N(),()=>{U=!0}},[a]),ee.useEffect(()=>{if(!S)return;const U=window.setInterval(O,220);return()=>window.clearInterval(U)},[S,O]),ee.useEffect(()=>{function U(N){if(!py(N.target)){if(N.key==="ArrowRight"||N.key==="ArrowDown"){N.preventDefault(),D(v.current+1);return}if(N.key==="ArrowLeft"||N.key==="ArrowUp"){N.preventDefault(),D(v.current-1);return}if(N.key===" "){N.preventDefault(),_(A=>!A);return}if(N.key==="."||N.key.toLowerCase()==="s"){N.preventDefault(),_(!1),O();return}N.key.toLowerCase()==="r"&&(N.preventDefault(),D(v.current,{forceReinitialize:!0}))}}return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[D,O]),g.jsx("main",{className:"viewer-shell",children:g.jsxs("section",{className:"viewer-stage","aria-label":x?.scene.title??b,children:[g.jsx(Bu,{caption:BR(x),cells:p,settings:B,onCellsChange:()=>{}}),g.jsxs("div",{className:"viewer-rec-status","aria-hidden":"true",children:[g.jsx("span",{children:e?.deck.title??"CA Deck"}),g.jsx("span",{children:x?`${s+1}/${e?.scenes.length??0}`:b}),g.jsx("span",{children:S?"REC PLAY":"REC HOLD"}),g.jsxs("span",{children:["G",h]})]})]})})}function JR({deckId:a,initialSceneId:e}){const[i,s]=ee.useState(null),[l,c]=ee.useState("Deck editor"),[f,p]=ee.useState(null),[m,h]=ee.useState([]),[y,S]=ee.useState([]),[_,b]=ee.useState(""),[T,C]=ee.useState(!1),[v,x]=ee.useState(!1),[B,P]=ee.useState(""),[D,O]=ee.useState([]),[U,N]=ee.useState(""),[A,L]=ee.useState(null),[j,V]=ee.useState(!1),[$,pe]=ee.useState(""),[ge,K]=ee.useState("Untitled slide"),[H,G]=ee.useState("Glider"),[ne,ye]=ee.useState(""),[xe,F]=ee.useState(!1),[J,Ce]=ee.useState("2d-canvas"),[Ue,Ie]=ee.useState("moore"),[ae,Ae]=ee.useState("B3/S23"),[Ee,He]=ee.useState("wrap"),[nt,Ke]=ee.useState(()=>CR()),[zt,ht]=ee.useState(0),[Et,yt]=ee.useState(!1),[St,Mt]=ee.useState("Loading deck..."),Ht=ee.useRef(!1),Gt=ee.useRef(!1),st=f?.scenes.find(q=>q.scene.id===_)??null,It=f?.scenes.findIndex(q=>q.scene.id===_)??-1;ro(i);const W=f?.scenes.length??0,z=It>0,Ye=It>=0&&It<W-1,xt=y.find(q=>q.id===$)??null,I=st?.scene.preset_node_id,E=D.find(q=>q.id===U)??null,X=xt?ci(ci(Jr(y,xt),xt.params),oo(ae,Ue,J,nt,void 0,Ee)):oo(ae,Ue,J,nt,void 0,Ee),se=ee.useCallback(async()=>{const q=await gt(`/api/ca/decks/${a}`),Me=await gt(`/api/ca/decks/${a}/resolved`);return Gt.current=!0,s(q),c(q.title),p(Me),window.setTimeout(()=>{Gt.current=!1},0),{deck:q,resolvedDeck:Me}},[a]);async function me(q){const Me=await gt(`/api/ca/preset-trees/${q}/nodes`);S(Me)}async function Ne(){const q=await gt("/api/ca/preset-trees");return h(q),q}async function Oe(q,Me){const De=ro(q);if(De.presetTreeId)return await me(De.presetTreeId),De;const ft=Me.scenes[0];if(ft?.scene.preset_tree_id){const rt={presetTreeId:ft.scene.preset_tree_id,rootNodeId:void 0,rendererId:ft.params.renderer?.id??"2d-canvas",neighborhoodId:ft.params.simulation?.neighborhoodId??"moore",ruleId:ft.params.simulation?.ruleId??"B3/S23"},Nt=await gt(`/api/ca/decks/${q.id}`,{method:"PATCH",body:JSON.stringify({params:RR(q,rt)})});return s(Nt),await me(rt.presetTreeId),Mt("Repaired deck metadata from existing slides"),rt}return S([]),De}ee.useEffect(()=>{async function q(){try{const Me=await se();await Ne();const De=await Oe(Me.deck,Me.resolvedDeck),ft=Me.resolvedDeck.scenes.find(rt=>rt.scene.id===e)??Me.resolvedDeck.scenes[0];ft?he(ft):(Ce(De.rendererId??"2d-canvas"),Ie(De.neighborhoodId??"moore"),Ae(De.ruleId??"B3/S23"),He("wrap"),Mt(De.presetTreeId?"Deck ready. Add the first slide.":"Deck ready. Add the first slide and select a CA asset."))}catch(Me){Mt(Me instanceof Error?Me.message:"Deck load failed")}}q()},[a,e,se]),ee.useEffect(()=>{if(!Et)return;const q=window.setInterval(()=>{Ke(Me=>El(Me,X)),ht(Me=>Me+1)},220);return()=>window.clearInterval(q)},[ae,Et]),ee.useEffect(()=>{if(!i||Gt.current||l===i.title)return;const q=window.setTimeout(async()=>{const Me=l.trim()||"Untitled deck";try{const De=await gt(`/api/ca/decks/${i.id}`,{method:"PATCH",body:JSON.stringify({title:Me})});s(De),c(De.title),Mt("Deck name saved")}catch(De){Mt(De instanceof Error?De.message:"Deck name save failed")}},450);return()=>window.clearTimeout(q)},[i,l]),ee.useEffect(()=>{if(!st||Ht.current)return;const q=ge.trim()||"Untitled slide",Me=typeof st.scene.params.caption=="string"?st.scene.params.caption:"",De=st.scene.params.autoplayOnSlideChange===!0;if(st.scene.title===q&&Me===ne&&De===xe)return;const ft=window.setTimeout(async()=>{try{await gt(`/api/ca/scenes/${st.scene.id}`,{method:"PATCH",body:JSON.stringify({title:q,params:{...st.scene.params,caption:ne,autoplayOnSlideChange:xe}})}),p(rt=>rt&&{...rt,scenes:rt.scenes.map(Nt=>Nt.scene.id===st.scene.id?{...Nt,scene:{...Nt.scene,title:q,params:{...Nt.scene.params,caption:ne,autoplayOnSlideChange:xe}}}:Nt)}),Mt("Slide settings saved")}catch(rt){Mt(rt instanceof Error?rt.message:"Slide settings autosave failed")}},450);return()=>window.clearTimeout(ft)},[st,xe,ne,ge]);async function _e(q,Me,De,ft={}){Ht.current=!0,yt(!1);const[rt,Nt,Hn]=await Promise.all([gt(`/api/ca/preset-trees/${q}/nodes/${Me}`),gt(`/api/ca/preset-trees/${q}/nodes/${Me}/resolved`),gt(`/api/ca/preset-trees/${q}/nodes`)]);S(Hn),pe(Me),G(rt.name||De||"Untitled node"),Ce(Nt.params.renderer?.id??"2d-canvas"),Ie(Nt.params.simulation?.neighborhoodId??"moore"),Ae(Nt.params.simulation?.ruleId??"B3/S23"),He(xx(Nt.params)),Ke(Rl(Nt.params.simulation?.initialCondition?.cells)),ht(0),Mt(`Loaded node "${rt.name}"`),window.setTimeout(()=>{Ht.current=!1,yt(ft.runAfterLoad===!0)},0)}function he(q){Ht.current=!0;const Me=q.scene.params.autoplayOnSlideChange===!0;if(yt(!1),b(q.scene.id),K(q.scene.title),ye(typeof q.scene.params.caption=="string"?q.scene.params.caption:""),F(Me),q.scene.preset_tree_id&&q.scene.preset_node_id){_e(q.scene.preset_tree_id,q.scene.preset_node_id,q.scene.title,{runAfterLoad:Me});return}pe(""),G("No CA preset"),Ke(ar()),ht(0),Mt(`Loaded empty slide "${q.scene.title}"`),window.setTimeout(()=>{Ht.current=!1},0)}function Le(q){he(q),C(!0)}async function je(q){N(q.id),V(!0);try{const Me=await gt(`/api/ca/preset-trees/${q.tree_id}/nodes/${q.id}/resolved`);L(Me)}catch(Me){L(null),Mt(Me instanceof Error?Me.message:"CA preview failed")}finally{V(!1)}}async function ze(q,Me){if(!q){P(""),O([]),N(""),L(null);return}P(q),V(!0);try{const De=await gt(`/api/ca/preset-trees/${q}/nodes`);O(De);const rt=De.find(Nt=>Nt.id===Me)??De.find(Nt=>Nt.kind!=="chapter")??null;rt?(N(rt.id),L(await gt(`/api/ca/preset-trees/${q}/nodes/${rt.id}/resolved`))):(N(""),L(null))}catch(De){O([]),N(""),L(null),Mt(De instanceof Error?De.message:"CA library load failed")}finally{V(!1)}}function Fe(){const q=st?.scene.preset_tree_id??m[0]?.id??"";C(!1),x(!0),ze(q,st?.scene.preset_node_id??void 0)}async function Qe(){if(!E||E.kind==="chapter"||!st)return;await gt(`/api/ca/scenes/${st.scene.id}`,{method:"PATCH",body:JSON.stringify({presetTreeId:E.tree_id,presetNodeId:E.id,params:{...st.scene.params,caption:ne,autoplayOnSlideChange:xe}})});const Me=(await se()).resolvedDeck.scenes.find(De=>De.scene.id===st.scene.id);Me&&he(Me),x(!1),Mt(`Assigned "${E.name}" to selected slide`)}async function Je(){if(st)try{yt(!1),Mt(`Deleting slide "${st.scene.title}"...`);const q=st.scene.id,Me=st.scene.title,De=f?.scenes.findIndex(Nt=>Nt.scene.id===q)??0;await fetch(`/api/ca/scenes/${q}`,{method:"DELETE"}).then(Nt=>{if(!Nt.ok)throw new Error("Unable to delete slide")});const ft=await se(),rt=ft.resolvedDeck.scenes[Math.min(Math.max(De,0),ft.resolvedDeck.scenes.length-1)];rt?he(rt):(b(""),K("Untitled slide"),ye(""),F(!1)),Mt(`Deleted slide "${Me}". Preset node kept.`)}catch(q){Mt(q instanceof Error?q.message:"Slide delete failed")}}async function pt(q){if(!(!i||q.length===0))try{Mt("Reordering slides...");const Me=1e5;await Promise.all(q.map((De,ft)=>gt(`/api/ca/scenes/${De.scene.id}`,{method:"PATCH",body:JSON.stringify({orderIndex:Me+ft})}))),await Promise.all(q.map((De,ft)=>gt(`/api/ca/scenes/${De.scene.id}`,{method:"PATCH",body:JSON.stringify({orderIndex:ft+1})}))),await se(),Mt("Slides reordered")}catch(Me){Mt(Me instanceof Error?Me.message:"Slide reorder failed")}}async function Z(){if(!i)return;Mt("Creating slide...");const q=W+1,Me=await gt(`/api/ca/decks/${i.id}/scenes`,{method:"POST",body:JSON.stringify({orderIndex:q,title:`Slide ${q}`,presetTreeId:null,presetNodeId:null,applyMode:"reinitialize",params:{caption:"",autoplayOnSlideChange:!1}})}),ft=(await se()).resolvedDeck.scenes.find(rt=>rt.scene.id===Me.id);ft&&he(ft),Mt(`Created slide ${q}. Select a CA preset.`)}function Pe(){yt(!1),Ke(q=>El(q,X)),ht(q=>q+1)}function Se(q){if(!f?.scenes.length)return;const Me=f.scenes.findIndex(rt=>rt.scene.id===_),De=Math.min(Math.max(Me===-1?0:Me+q,0),f.scenes.length-1),ft=f.scenes[De];ft&&ft.scene.id!==_&&he(ft)}function Be(){if(!st?.scene.preset_tree_id||!st.scene.preset_node_id)return;const q=new URLSearchParams({node:st.scene.preset_node_id,return:`/admin/edit/${a}?scene=${st.scene.id}`});Pi(`/admin/libraries/${st.scene.preset_tree_id}?${q.toString()}`)}function ke(){if(!E||E.kind==="chapter")return;const q=st?`/admin/edit/${a}?scene=${st.scene.id}`:`/admin/edit/${a}`,Me=new URLSearchParams({node:E.id,return:q});Pi(`/admin/libraries/${E.tree_id}?${Me.toString()}`)}return ee.useEffect(()=>{function q(Me){if(!py(Me.target)){if(Me.key==="ArrowDown"||Me.key==="ArrowRight"){Me.preventDefault(),Se(1);return}if(Me.key==="ArrowUp"||Me.key==="ArrowLeft"){Me.preventDefault(),Se(-1);return}Me.key===" "&&(Me.preventDefault(),yt(De=>!De))}}return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[_,f]),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:q=>c(q.target.value)})]}),g.jsx("div",{className:"topbar-actions",children:g.jsx("div",{className:"status",children:St})})]}),g.jsxs("section",{className:"editor-layout",children:[g.jsx(TR,{activeSceneId:_,canDeleteSlide:!!st,sceneCount:W,scenes:f?.scenes??[],onBack:()=>Pi(po("decks")),onDeleteSlide:()=>{Je()},onEditScene:Le,onReorderSlides:q=>{pt(q)},onSaveNewSlide:()=>{Z()},onSelectScene:he}),T&&st?g.jsx(KR,{assignedNodeId:I??void 0,assignedNodeName:H,autoplayOnSlideChange:xe,caption:ne,scene:st,slideTitle:ge,onAutoplayChange:F,onCaptionChange:ye,onClose:()=>C(!1),onSelectCa:Fe,onSlideTitleChange:K}):null,v?g.jsx($R,{assignedNodeId:I??void 0,loading:j,nodes:D,presetTrees:m,resolvedNode:A,selectedNode:E,selectedTreeId:B,onClose:()=>x(!1),onEditSelected:ke,onSelectNode:q=>{je(q)},onSelectTree:q=>{ze(q)},onUseSelected:()=>{Qe()}}):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:st?ge:H})]}),g.jsxs("div",{className:"button-row",children:[g.jsx("button",{"aria-label":"Previous slide",className:"deck-nav-button",disabled:!z,title:"Previous slide",type:"button",onClick:()=>Se(-1),children:"←"}),g.jsxs("span",{className:"deck-position",children:[It>=0?It+1:0,"/",W]}),g.jsx("button",{"aria-label":"Next slide",className:"deck-nav-button",disabled:!Ye,title:"Next slide",type:"button",onClick:()=>Se(1),children:"→"}),g.jsx("button",{disabled:!I,type:"button",onClick:Be,children:"Edit CA"}),g.jsx("button",{disabled:!I,type:"button",onClick:Pe,children:"Step"}),g.jsx("button",{className:"primary playback-button",disabled:!I,type:"button",onClick:()=>yt(q=>!q),children:Et?"⏸":"▶"})]})]}),I?g.jsx(Bu,{caption:st?ne:"",cells:nt,settings:X,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:Fe,children:"Select CA preset"})]})}),g.jsxs("footer",{className:"metrics",children:[g.jsxs("span",{children:["Generation ",g.jsx("strong",{children:zt})]}),g.jsxs("span",{children:["Live cells ",g.jsx("strong",{children:hy(nt)})]}),g.jsxs("span",{children:["Selected node ",g.jsx("strong",{children:$?$.slice(0,8):"none"})]}),g.jsxs("span",{children:["Assigned node ",g.jsx("strong",{children:I?I.slice(0,8):"none"})]})]})]})]})]})}BM.createRoot(document.getElementById("root")).render(g.jsx(ee.StrictMode,{children:g.jsx(HR,{})}));
|