(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();function k_(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ty={exports:{}},ed={};/**
 * @license React
 * react-jsx-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var w1;function HU(){if(w1)return ed;w1=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,r,s){var o=null;if(s!==void 0&&(o=""+s),r.key!==void 0&&(o=""+r.key),"key"in r){s={};for(var u in r)u!=="key"&&(s[u]=r[u])}else s=r;return r=s.ref,{$$typeof:i,type:n,key:o,ref:r!==void 0?r:null,props:s}}return ed.Fragment=e,ed.jsx=t,ed.jsxs=t,ed}var R1;function jU(){return R1||(R1=1,Ty.exports=HU()),Ty.exports}var k=jU(),My={exports:{}},Bt={};/**
 * @license React
 * react.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var C1;function WU(){if(C1)return Bt;C1=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),g=Symbol.iterator;function _(O){return O===null||typeof O!="object"?null:(O=g&&O[g]||O["@@iterator"],typeof O=="function"?O:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,b={};function x(O,W,ce){this.props=O,this.context=W,this.refs=b,this.updater=ce||v}x.prototype.isReactComponent={},x.prototype.setState=function(O,W){if(typeof O!="object"&&typeof O!="function"&&O!=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,O,W,"setState")},x.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function M(){}M.prototype=x.prototype;function E(O,W,ce){this.props=O,this.context=W,this.refs=b,this.updater=ce||v}var w=E.prototype=new M;w.constructor=E,S(w,x.prototype),w.isPureReactComponent=!0;var D=Array.isArray;function C(){}var N={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function L(O,W,ce){var Le=ce.ref;return{$$typeof:i,type:O,key:W,ref:Le!==void 0?Le:null,props:ce}}function j(O,W){return L(O.type,W,O.props)}function z(O){return typeof O=="object"&&O!==null&&O.$$typeof===i}function H(O){var W={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(ce){return W[ce]})}var K=/\/+/g;function te(O,W){return typeof O=="object"&&O!==null&&O.key!=null?H(""+O.key):W.toString(36)}function Z(O){switch(O.status){case"fulfilled":return O.value;case"rejected":throw O.reason;default:switch(typeof O.status=="string"?O.then(C,C):(O.status="pending",O.then(function(W){O.status==="pending"&&(O.status="fulfilled",O.value=W)},function(W){O.status==="pending"&&(O.status="rejected",O.reason=W)})),O.status){case"fulfilled":return O.value;case"rejected":throw O.reason}}throw O}function I(O,W,ce,Le,ee){var $=typeof O;($==="undefined"||$==="boolean")&&(O=null);var ue=!1;if(O===null)ue=!0;else switch($){case"bigint":case"string":case"number":ue=!0;break;case"object":switch(O.$$typeof){case i:case e:ue=!0;break;case d:return ue=O._init,I(ue(O._payload),W,ce,Le,ee)}}if(ue)return ee=ee(O),ue=Le===""?"."+te(O,0):Le,D(ee)?(ce="",ue!=null&&(ce=ue.replace(K,"$&/")+"/"),I(ee,W,ce,"",function(We){return We})):ee!=null&&(z(ee)&&(ee=j(ee,ce+(ee.key==null||O&&O.key===ee.key?"":(""+ee.key).replace(K,"$&/")+"/")+ue)),W.push(ee)),1;ue=0;var Ee=Le===""?".":Le+":";if(D(O))for(var ke=0;ke<O.length;ke++)Le=O[ke],$=Ee+te(Le,ke),ue+=I(Le,W,ce,$,ee);else if(ke=_(O),typeof ke=="function")for(O=ke.call(O),ke=0;!(Le=O.next()).done;)Le=Le.value,$=Ee+te(Le,ke++),ue+=I(Le,W,ce,$,ee);else if($==="object"){if(typeof O.then=="function")return I(Z(O),W,ce,Le,ee);throw W=String(O),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return ue}function F(O,W,ce){if(O==null)return O;var Le=[],ee=0;return I(O,Le,"","",function($){return W.call(ce,$,ee++)}),Le}function Y(O){if(O._status===-1){var W=O._result;W=W(),W.then(function(ce){(O._status===0||O._status===-1)&&(O._status=1,O._result=ce)},function(ce){(O._status===0||O._status===-1)&&(O._status=2,O._result=ce)}),O._status===-1&&(O._status=0,O._result=W)}if(O._status===1)return O._result.default;throw O._result}var se=typeof reportError=="function"?reportError:function(O){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof O=="object"&&O!==null&&typeof O.message=="string"?String(O.message):String(O),error:O});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",O);return}console.error(O)},Te={map:F,forEach:function(O,W,ce){F(O,function(){W.apply(this,arguments)},ce)},count:function(O){var W=0;return F(O,function(){W++}),W},toArray:function(O){return F(O,function(W){return W})||[]},only:function(O){if(!z(O))throw Error("React.Children.only expected to receive a single React element child.");return O}};return Bt.Activity=p,Bt.Children=Te,Bt.Component=x,Bt.Fragment=t,Bt.Profiler=r,Bt.PureComponent=E,Bt.StrictMode=n,Bt.Suspense=c,Bt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,Bt.__COMPILER_RUNTIME={__proto__:null,c:function(O){return N.H.useMemoCache(O)}},Bt.cache=function(O){return function(){return O.apply(null,arguments)}},Bt.cacheSignal=function(){return null},Bt.cloneElement=function(O,W,ce){if(O==null)throw Error("The argument must be a React element, but you passed "+O+".");var Le=S({},O.props),ee=O.key;if(W!=null)for($ in W.key!==void 0&&(ee=""+W.key),W)!A.call(W,$)||$==="key"||$==="__self"||$==="__source"||$==="ref"&&W.ref===void 0||(Le[$]=W[$]);var $=arguments.length-2;if($===1)Le.children=ce;else if(1<$){for(var ue=Array($),Ee=0;Ee<$;Ee++)ue[Ee]=arguments[Ee+2];Le.children=ue}return L(O.type,ee,Le)},Bt.createContext=function(O){return O={$$typeof:o,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null},O.Provider=O,O.Consumer={$$typeof:s,_context:O},O},Bt.createElement=function(O,W,ce){var Le,ee={},$=null;if(W!=null)for(Le in W.key!==void 0&&($=""+W.key),W)A.call(W,Le)&&Le!=="key"&&Le!=="__self"&&Le!=="__source"&&(ee[Le]=W[Le]);var ue=arguments.length-2;if(ue===1)ee.children=ce;else if(1<ue){for(var Ee=Array(ue),ke=0;ke<ue;ke++)Ee[ke]=arguments[ke+2];ee.children=Ee}if(O&&O.defaultProps)for(Le in ue=O.defaultProps,ue)ee[Le]===void 0&&(ee[Le]=ue[Le]);return L(O,$,ee)},Bt.createRef=function(){return{current:null}},Bt.forwardRef=function(O){return{$$typeof:u,render:O}},Bt.isValidElement=z,Bt.lazy=function(O){return{$$typeof:d,_payload:{_status:-1,_result:O},_init:Y}},Bt.memo=function(O,W){return{$$typeof:h,type:O,compare:W===void 0?null:W}},Bt.startTransition=function(O){var W=N.T,ce={};N.T=ce;try{var Le=O(),ee=N.S;ee!==null&&ee(ce,Le),typeof Le=="object"&&Le!==null&&typeof Le.then=="function"&&Le.then(C,se)}catch($){se($)}finally{W!==null&&ce.types!==null&&(W.types=ce.types),N.T=W}},Bt.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},Bt.use=function(O){return N.H.use(O)},Bt.useActionState=function(O,W,ce){return N.H.useActionState(O,W,ce)},Bt.useCallback=function(O,W){return N.H.useCallback(O,W)},Bt.useContext=function(O){return N.H.useContext(O)},Bt.useDebugValue=function(){},Bt.useDeferredValue=function(O,W){return N.H.useDeferredValue(O,W)},Bt.useEffect=function(O,W){return N.H.useEffect(O,W)},Bt.useEffectEvent=function(O){return N.H.useEffectEvent(O)},Bt.useId=function(){return N.H.useId()},Bt.useImperativeHandle=function(O,W,ce){return N.H.useImperativeHandle(O,W,ce)},Bt.useInsertionEffect=function(O,W){return N.H.useInsertionEffect(O,W)},Bt.useLayoutEffect=function(O,W){return N.H.useLayoutEffect(O,W)},Bt.useMemo=function(O,W){return N.H.useMemo(O,W)},Bt.useOptimistic=function(O,W){return N.H.useOptimistic(O,W)},Bt.useReducer=function(O,W,ce){return N.H.useReducer(O,W,ce)},Bt.useRef=function(O){return N.H.useRef(O)},Bt.useState=function(O){return N.H.useState(O)},Bt.useSyncExternalStore=function(O,W,ce){return N.H.useSyncExternalStore(O,W,ce)},Bt.useTransition=function(){return N.H.useTransition()},Bt.version="19.2.4",Bt}var N1;function yS(){return N1||(N1=1,My.exports=WU()),My.exports}var Et=yS();const DN=k_(Et);var Ey={exports:{}},td={},Ay={exports:{}},wy={};/**
 * @license React
 * scheduler.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var D1;function $U(){return D1||(D1=1,(function(i){function e(I,F){var Y=I.length;I.push(F);e:for(;0<Y;){var se=Y-1>>>1,Te=I[se];if(0<r(Te,F))I[se]=F,I[Y]=Te,Y=se;else break e}}function t(I){return I.length===0?null:I[0]}function n(I){if(I.length===0)return null;var F=I[0],Y=I.pop();if(Y!==F){I[0]=Y;e:for(var se=0,Te=I.length,O=Te>>>1;se<O;){var W=2*(se+1)-1,ce=I[W],Le=W+1,ee=I[Le];if(0>r(ce,Y))Le<Te&&0>r(ee,ce)?(I[se]=ee,I[Le]=Y,se=Le):(I[se]=ce,I[W]=Y,se=W);else if(Le<Te&&0>r(ee,Y))I[se]=ee,I[Le]=Y,se=Le;else break e}}return F}function r(I,F){var Y=I.sortIndex-F.sortIndex;return Y!==0?Y:I.id-F.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;i.unstable_now=function(){return s.now()}}else{var o=Date,u=o.now();i.unstable_now=function(){return o.now()-u}}var c=[],h=[],d=1,p=null,g=3,_=!1,v=!1,S=!1,b=!1,x=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function w(I){for(var F=t(h);F!==null;){if(F.callback===null)n(h);else if(F.startTime<=I)n(h),F.sortIndex=F.expirationTime,e(c,F);else break;F=t(h)}}function D(I){if(S=!1,w(I),!v)if(t(c)!==null)v=!0,C||(C=!0,H());else{var F=t(h);F!==null&&Z(D,F.startTime-I)}}var C=!1,N=-1,A=5,L=-1;function j(){return b?!0:!(i.unstable_now()-L<A)}function z(){if(b=!1,C){var I=i.unstable_now();L=I;var F=!0;try{e:{v=!1,S&&(S=!1,M(N),N=-1),_=!0;var Y=g;try{t:{for(w(I),p=t(c);p!==null&&!(p.expirationTime>I&&j());){var se=p.callback;if(typeof se=="function"){p.callback=null,g=p.priorityLevel;var Te=se(p.expirationTime<=I);if(I=i.unstable_now(),typeof Te=="function"){p.callback=Te,w(I),F=!0;break t}p===t(c)&&n(c),w(I)}else n(c);p=t(c)}if(p!==null)F=!0;else{var O=t(h);O!==null&&Z(D,O.startTime-I),F=!1}}break e}finally{p=null,g=Y,_=!1}F=void 0}}finally{F?H():C=!1}}}var H;if(typeof E=="function")H=function(){E(z)};else if(typeof MessageChannel<"u"){var K=new MessageChannel,te=K.port2;K.port1.onmessage=z,H=function(){te.postMessage(null)}}else H=function(){x(z,0)};function Z(I,F){N=x(function(){I(i.unstable_now())},F)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(I){I.callback=null},i.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<I?Math.floor(1e3/I):5},i.unstable_getCurrentPriorityLevel=function(){return g},i.unstable_next=function(I){switch(g){case 1:case 2:case 3:var F=3;break;default:F=g}var Y=g;g=F;try{return I()}finally{g=Y}},i.unstable_requestPaint=function(){b=!0},i.unstable_runWithPriority=function(I,F){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var Y=g;g=I;try{return F()}finally{g=Y}},i.unstable_scheduleCallback=function(I,F,Y){var se=i.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?se+Y:se):Y=se,I){case 1:var Te=-1;break;case 2:Te=250;break;case 5:Te=1073741823;break;case 4:Te=1e4;break;default:Te=5e3}return Te=Y+Te,I={id:d++,callback:F,priorityLevel:I,startTime:Y,expirationTime:Te,sortIndex:-1},Y>se?(I.sortIndex=Y,e(h,I),t(c)===null&&I===t(h)&&(S?(M(N),N=-1):S=!0,Z(D,Y-se))):(I.sortIndex=Te,e(c,I),v||_||(v=!0,C||(C=!0,H()))),I},i.unstable_shouldYield=j,i.unstable_wrapCallback=function(I){var F=g;return function(){var Y=g;g=F;try{return I.apply(this,arguments)}finally{g=Y}}}})(wy)),wy}var L1;function qU(){return L1||(L1=1,Ay.exports=$U()),Ay.exports}var Ry={exports:{}},Ki={};/**
 * @license React
 * react-dom.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var P1;function XU(){if(P1)return Ki;P1=1;var i=yS();function e(c){var h="https://react.dev/errors/"+c;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)h+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(){}var n={d:{f:t,r:function(){throw Error(e(522))},D:t,C:t,L:t,m:t,X:t,S:t,M:t},p:0,findDOMNode:null},r=Symbol.for("react.portal");function s(c,h,d){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:p==null?null:""+p,children:c,containerInfo:h,implementation:d}}var o=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(c,h){if(c==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Ki.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,Ki.createPortal=function(c,h){var d=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 s(c,h,null,d)},Ki.flushSync=function(c){var h=o.T,d=n.p;try{if(o.T=null,n.p=2,c)return c()}finally{o.T=h,n.p=d,n.d.f()}},Ki.preconnect=function(c,h){typeof c=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,n.d.C(c,h))},Ki.prefetchDNS=function(c){typeof c=="string"&&n.d.D(c)},Ki.preinit=function(c,h){if(typeof c=="string"&&h&&typeof h.as=="string"){var d=h.as,p=u(d,h.crossOrigin),g=typeof h.integrity=="string"?h.integrity:void 0,_=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;d==="style"?n.d.S(c,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:p,integrity:g,fetchPriority:_}):d==="script"&&n.d.X(c,{crossOrigin:p,integrity:g,fetchPriority:_,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Ki.preinitModule=function(c,h){if(typeof c=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var d=u(h.as,h.crossOrigin);n.d.M(c,{crossOrigin:d,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&n.d.M(c)},Ki.preload=function(c,h){if(typeof c=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var d=h.as,p=u(d,h.crossOrigin);n.d.L(c,d,{crossOrigin:p,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})}},Ki.preloadModule=function(c,h){if(typeof c=="string")if(h){var d=u(h.as,h.crossOrigin);n.d.m(c,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:d,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else n.d.m(c)},Ki.requestFormReset=function(c){n.d.r(c)},Ki.unstable_batchedUpdates=function(c,h){return c(h)},Ki.useFormState=function(c,h,d){return o.H.useFormState(c,h,d)},Ki.useFormStatus=function(){return o.H.useHostTransitionStatus()},Ki.version="19.2.4",Ki}var U1;function YU(){if(U1)return Ry.exports;U1=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Ry.exports=XU(),Ry.exports}/**
 * @license React
 * react-dom-client.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var O1;function KU(){if(O1)return td;O1=1;var i=qU(),e=yS(),t=YU();function n(a){var l="https://react.dev/errors/"+a;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)l+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function s(a){var l=a,f=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(f=l.return),a=l.return;while(a)}return l.tag===3?f:null}function o(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function u(a){if(a.tag===31){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function c(a){if(s(a)!==a)throw Error(n(188))}function h(a){var l=a.alternate;if(!l){if(l=s(a),l===null)throw Error(n(188));return l!==a?null:a}for(var f=a,m=l;;){var y=f.return;if(y===null)break;var T=y.alternate;if(T===null){if(m=y.return,m!==null){f=m;continue}break}if(y.child===T.child){for(T=y.child;T;){if(T===f)return c(y),a;if(T===m)return c(y),l;T=T.sibling}throw Error(n(188))}if(f.return!==m.return)f=y,m=T;else{for(var R=!1,U=y.child;U;){if(U===f){R=!0,f=y,m=T;break}if(U===m){R=!0,m=y,f=T;break}U=U.sibling}if(!R){for(U=T.child;U;){if(U===f){R=!0,f=T,m=y;break}if(U===m){R=!0,m=T,f=y;break}U=U.sibling}if(!R)throw Error(n(189))}}if(f.alternate!==m)throw Error(n(190))}if(f.tag!==3)throw Error(n(188));return f.stateNode.current===f?a:l}function d(a){var l=a.tag;if(l===5||l===26||l===27||l===6)return a;for(a=a.child;a!==null;){if(l=d(a),l!==null)return l;a=a.sibling}return null}var p=Object.assign,g=Symbol.for("react.element"),_=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),E=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),C=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"),z=Symbol.iterator;function H(a){return a===null||typeof a!="object"?null:(a=z&&a[z]||a["@@iterator"],typeof a=="function"?a:null)}var K=Symbol.for("react.client.reference");function te(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===K?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case S:return"Fragment";case x:return"Profiler";case b:return"StrictMode";case D:return"Suspense";case C:return"SuspenseList";case L:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case v:return"Portal";case E:return a.displayName||"Context";case M:return(a._context.displayName||"Context")+".Consumer";case w:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case N:return l=a.displayName||null,l!==null?l:te(a.type)||"Memo";case A:l=a._payload,a=a._init;try{return te(a(l))}catch{}}return null}var Z=Array.isArray,I=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y={pending:!1,data:null,method:null,action:null},se=[],Te=-1;function O(a){return{current:a}}function W(a){0>Te||(a.current=se[Te],se[Te]=null,Te--)}function ce(a,l){Te++,se[Te]=a.current,a.current=l}var Le=O(null),ee=O(null),$=O(null),ue=O(null);function Ee(a,l){switch(ce($,l),ce(ee,a),ce(Le,null),l.nodeType){case 9:case 11:a=(a=l.documentElement)&&(a=a.namespaceURI)?KA(a):0;break;default:if(a=l.tagName,l=l.namespaceURI)l=KA(l),a=ZA(l,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}W(Le),ce(Le,a)}function ke(){W(Le),W(ee),W($)}function We(a){a.memoizedState!==null&&ce(ue,a);var l=Le.current,f=ZA(l,a.type);l!==f&&(ce(ee,a),ce(Le,f))}function Ke(a){ee.current===a&&(W(Le),W(ee)),ue.current===a&&(W(ue),Kf._currentValue=Y)}var sn,Ut;function Rt(a){if(sn===void 0)try{throw Error()}catch(f){var l=f.stack.trim().match(/\n( *(at )?)/);sn=l&&l[1]||"",Ut=-1<f.stack.indexOf(`
    at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
`+sn+a+Ut}var qt=!1;function St(a,l){if(!a||qt)return"";qt=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var m={DetermineComponentFrameRoot:function(){try{if(l){var De=function(){throw Error()};if(Object.defineProperty(De.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(De,[])}catch(_e){var me=_e}Reflect.construct(a,[],De)}else{try{De.call()}catch(_e){me=_e}a.call(De.prototype)}}else{try{throw Error()}catch(_e){me=_e}(De=a())&&typeof De.catch=="function"&&De.catch(function(){})}}catch(_e){if(_e&&me&&typeof _e.stack=="string")return[_e.stack,me.stack]}return[null,null]}};m.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var y=Object.getOwnPropertyDescriptor(m.DetermineComponentFrameRoot,"name");y&&y.configurable&&Object.defineProperty(m.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var T=m.DetermineComponentFrameRoot(),R=T[0],U=T[1];if(R&&U){var q=R.split(`
`),de=U.split(`
`);for(y=m=0;m<q.length&&!q[m].includes("DetermineComponentFrameRoot");)m++;for(;y<de.length&&!de[y].includes("DetermineComponentFrameRoot");)y++;if(m===q.length||y===de.length)for(m=q.length-1,y=de.length-1;1<=m&&0<=y&&q[m]!==de[y];)y--;for(;1<=m&&0<=y;m--,y--)if(q[m]!==de[y]){if(m!==1||y!==1)do if(m--,y--,0>y||q[m]!==de[y]){var we=`
`+q[m].replace(" at new "," at ");return a.displayName&&we.includes("<anonymous>")&&(we=we.replace("<anonymous>",a.displayName)),we}while(1<=m&&0<=y);break}}}finally{qt=!1,Error.prepareStackTrace=f}return(f=a?a.displayName||a.name:"")?Rt(f):""}function on(a,l){switch(a.tag){case 26:case 27:case 5:return Rt(a.type);case 16:return Rt("Lazy");case 13:return a.child!==l&&l!==null?Rt("Suspense Fallback"):Rt("Suspense");case 19:return Rt("SuspenseList");case 0:case 15:return St(a.type,!1);case 11:return St(a.type.render,!1);case 1:return St(a.type,!0);case 31:return Rt("Activity");default:return""}}function Q(a){try{var l="",f=null;do l+=on(a,f),f=a,a=a.return;while(a);return l}catch(m){return`
Error generating stack: `+m.message+`
`+m.stack}}var $n=Object.prototype.hasOwnProperty,nn=i.unstable_scheduleCallback,_n=i.unstable_cancelCallback,ht=i.unstable_shouldYield,V=i.unstable_requestPaint,P=i.unstable_now,ae=i.unstable_getCurrentPriorityLevel,Re=i.unstable_ImmediatePriority,Ue=i.unstable_UserBlockingPriority,Ae=i.unstable_NormalPriority,lt=i.unstable_LowPriority,He=i.unstable_IdlePriority,gt=i.log,Tt=i.unstable_setDisableYieldValue,Fe=null,Oe=null;function Ze(a){if(typeof gt=="function"&&Tt(a),Oe&&typeof Oe.setStrictMode=="function")try{Oe.setStrictMode(Fe,a)}catch{}}var Xe=Math.clz32?Math.clz32:re,Qe=Math.log,Gt=Math.LN2;function re(a){return a>>>=0,a===0?32:31-(Qe(a)/Gt|0)|0}var Ge=256,ze=262144,Je=4194304;function Be(a){var l=a&42;if(l!==0)return l;switch(a&-a){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 a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function Me(a,l,f){var m=a.pendingLanes;if(m===0)return 0;var y=0,T=a.suspendedLanes,R=a.pingedLanes;a=a.warmLanes;var U=m&134217727;return U!==0?(m=U&~T,m!==0?y=Be(m):(R&=U,R!==0?y=Be(R):f||(f=U&~a,f!==0&&(y=Be(f))))):(U=m&~T,U!==0?y=Be(U):R!==0?y=Be(R):f||(f=m&~a,f!==0&&(y=Be(f)))),y===0?0:l!==0&&l!==y&&(l&T)===0&&(T=y&-y,f=l&-l,T>=f||T===32&&(f&4194048)!==0)?l:y}function nt(a,l){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&l)===0}function Ct(a,l){switch(a){case 1:case 2:case 4:case 8:case 64:return l+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 l+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 Mn(){var a=Je;return Je<<=1,(Je&62914560)===0&&(Je=4194304),a}function an(a){for(var l=[],f=0;31>f;f++)l.push(a);return l}function sr(a,l){a.pendingLanes|=l,l!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function As(a,l,f,m,y,T){var R=a.pendingLanes;a.pendingLanes=f,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=f,a.entangledLanes&=f,a.errorRecoveryDisabledLanes&=f,a.shellSuspendCounter=0;var U=a.entanglements,q=a.expirationTimes,de=a.hiddenUpdates;for(f=R&~f;0<f;){var we=31-Xe(f),De=1<<we;U[we]=0,q[we]=-1;var me=de[we];if(me!==null)for(de[we]=null,we=0;we<me.length;we++){var _e=me[we];_e!==null&&(_e.lane&=-536870913)}f&=~De}m!==0&&hf(a,m,0),T!==0&&y===0&&a.tag!==0&&(a.suspendedLanes|=T&~(R&~l))}function hf(a,l,f){a.pendingLanes|=l,a.suspendedLanes&=~l;var m=31-Xe(l);a.entangledLanes|=l,a.entanglements[m]=a.entanglements[m]|1073741824|f&261930}function ju(a,l){var f=a.entangledLanes|=l;for(a=a.entanglements;f;){var m=31-Xe(f),y=1<<m;y&l|a[m]&l&&(a[m]|=l),f&=~y}}function Pp(a,l){var f=l&-l;return f=(f&42)!==0?1:Wu(f),(f&(a.suspendedLanes|l))!==0?0:f}function Wu(a){switch(a){case 2:a=1;break;case 8:a=4;break;case 32:a=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:a=128;break;case 268435456:a=134217728;break;default:a=0}return a}function $u(a){return a&=-a,2<a?8<a?(a&134217727)!==0?32:268435456:8:2}function Ws(){var a=F.p;return a!==0?a:(a=window.event,a===void 0?32:x1(a.type))}function qu(a,l){var f=F.p;try{return F.p=a,l()}finally{F.p=f}}var ws=Math.random().toString(36).slice(2),ci="__reactFiber$"+ws,Ti="__reactProps$"+ws,Ca="__reactContainer$"+ws,Eo="__reactEvents$"+ws,Up="__reactListeners$"+ws,Op="__reactHandles$"+ws,Bp="__reactResources$"+ws,Pl="__reactMarker$"+ws;function ff(a){delete a[ci],delete a[Ti],delete a[Eo],delete a[Up],delete a[Op]}function Ao(a){var l=a[ci];if(l)return l;for(var f=a.parentNode;f;){if(l=f[Ca]||f[ci]){if(f=l.alternate,l.child!==null||f!==null&&f.child!==null)for(a=r1(a);a!==null;){if(f=a[ci])return f;a=r1(a)}return l}a=f,f=a.parentNode}return null}function wo(a){if(a=a[ci]||a[Ca]){var l=a.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return a}return null}function Ul(a){var l=a.tag;if(l===5||l===26||l===27||l===6)return a.stateNode;throw Error(n(33))}function B(a){var l=a[Bp];return l||(l=a[Bp]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function ne(a){a[Pl]=!0}var ge=new Set,pe={};function he(a,l){je(a,l),je(a+"Capture",l)}function je(a,l){for(pe[a]=l,a=0;a<l.length;a++)ge.add(l[a])}var tt=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]*$"),$e={},ut={};function dt(a){return $n.call(ut,a)?!0:$n.call($e,a)?!1:tt.test(a)?ut[a]=!0:($e[a]=!0,!1)}function At(a,l,f){if(dt(l))if(f===null)a.removeAttribute(l);else{switch(typeof f){case"undefined":case"function":case"symbol":a.removeAttribute(l);return;case"boolean":var m=l.toLowerCase().slice(0,5);if(m!=="data-"&&m!=="aria-"){a.removeAttribute(l);return}}a.setAttribute(l,""+f)}}function Ot(a,l,f){if(f===null)a.removeAttribute(l);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(l);return}a.setAttribute(l,""+f)}}function it(a,l,f,m){if(m===null)a.removeAttribute(f);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(f);return}a.setAttributeNS(l,f,""+m)}}function Vt(a){switch(typeof a){case"bigint":case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function qn(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Xn(a,l,f){var m=Object.getOwnPropertyDescriptor(a.constructor.prototype,l);if(!a.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var y=m.get,T=m.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return y.call(this)},set:function(R){f=""+R,T.call(this,R)}}),Object.defineProperty(a,l,{enumerable:m.enumerable}),{getValue:function(){return f},setValue:function(R){f=""+R},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function ln(a){if(!a._valueTracker){var l=qn(a)?"checked":"value";a._valueTracker=Xn(a,l,""+a[l])}}function Mi(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var f=l.getValue(),m="";return a&&(m=qn(a)?a.checked?"true":"false":a.value),a=m,a!==f?(l.setValue(a),!0):!1}function at(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var ar=/[\n"\\]/g;function Lt(a){return a.replace(ar,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function or(a,l,f,m,y,T,R,U){a.name="",R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?a.type=R:a.removeAttribute("type"),l!=null?R==="number"?(l===0&&a.value===""||a.value!=l)&&(a.value=""+Vt(l)):a.value!==""+Vt(l)&&(a.value=""+Vt(l)):R!=="submit"&&R!=="reset"||a.removeAttribute("value"),l!=null?Rs(a,R,Vt(l)):f!=null?Rs(a,R,Vt(f)):m!=null&&a.removeAttribute("value"),y==null&&T!=null&&(a.defaultChecked=!!T),y!=null&&(a.checked=y&&typeof y!="function"&&typeof y!="symbol"),U!=null&&typeof U!="function"&&typeof U!="symbol"&&typeof U!="boolean"?a.name=""+Vt(U):a.removeAttribute("name")}function kr(a,l,f,m,y,T,R,U){if(T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(a.type=T),l!=null||f!=null){if(!(T!=="submit"&&T!=="reset"||l!=null)){ln(a);return}f=f!=null?""+Vt(f):"",l=l!=null?""+Vt(l):f,U||l===a.value||(a.value=l),a.defaultValue=l}m=m??y,m=typeof m!="function"&&typeof m!="symbol"&&!!m,a.checked=U?a.checked:!!m,a.defaultChecked=!!m,R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"&&(a.name=R),ln(a)}function Rs(a,l,f){l==="number"&&at(a.ownerDocument)===a||a.defaultValue===""+f||(a.defaultValue=""+f)}function Gr(a,l,f,m){if(a=a.options,l){l={};for(var y=0;y<f.length;y++)l["$"+f[y]]=!0;for(f=0;f<a.length;f++)y=l.hasOwnProperty("$"+a[f].value),a[f].selected!==y&&(a[f].selected=y),y&&m&&(a[f].defaultSelected=!0)}else{for(f=""+Vt(f),l=null,y=0;y<a.length;y++){if(a[y].value===f){a[y].selected=!0,m&&(a[y].defaultSelected=!0);return}l!==null||a[y].disabled||(l=a[y])}l!==null&&(l.selected=!0)}}function vn(a,l,f){if(l!=null&&(l=""+Vt(l),l!==a.value&&(a.value=l),f==null)){a.defaultValue!==l&&(a.defaultValue=l);return}a.defaultValue=f!=null?""+Vt(f):""}function hi(a,l,f,m){if(l==null){if(m!=null){if(f!=null)throw Error(n(92));if(Z(m)){if(1<m.length)throw Error(n(93));m=m[0]}f=m}f==null&&(f=""),l=f}f=Vt(l),a.defaultValue=f,m=a.textContent,m===f&&m!==""&&m!==null&&(a.value=m),ln(a)}function lr(a,l){if(l){var f=a.firstChild;if(f&&f===a.lastChild&&f.nodeType===3){f.nodeValue=l;return}}a.textContent=l}var fi=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 Cs(a,l,f){var m=l.indexOf("--")===0;f==null||typeof f=="boolean"||f===""?m?a.setProperty(l,""):l==="float"?a.cssFloat="":a[l]="":m?a.setProperty(l,f):typeof f!="number"||f===0||fi.has(l)?l==="float"?a.cssFloat=f:a[l]=(""+f).trim():a[l]=f+"px"}function Na(a,l,f){if(l!=null&&typeof l!="object")throw Error(n(62));if(a=a.style,f!=null){for(var m in f)!f.hasOwnProperty(m)||l!=null&&l.hasOwnProperty(m)||(m.indexOf("--")===0?a.setProperty(m,""):m==="float"?a.cssFloat="":a[m]="");for(var y in l)m=l[y],l.hasOwnProperty(y)&&f[y]!==m&&Cs(a,y,m)}else for(var T in l)l.hasOwnProperty(T)&&Cs(a,T,l[T])}function Xu(a){if(a.indexOf("-")===-1)return!1;switch(a){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 zL=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"]]),kL=/^[\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 Fp(a){return kL.test(""+a)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":a}function Da(){}var x0=null;function b0(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var Yu=null,Ku=null;function YT(a){var l=wo(a);if(l&&(a=l.stateNode)){var f=a[Ti]||null;e:switch(a=l.stateNode,l.type){case"input":if(or(a,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name),l=f.name,f.type==="radio"&&l!=null){for(f=a;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll('input[name="'+Lt(""+l)+'"][type="radio"]'),l=0;l<f.length;l++){var m=f[l];if(m!==a&&m.form===a.form){var y=m[Ti]||null;if(!y)throw Error(n(90));or(m,y.value,y.defaultValue,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name)}}for(l=0;l<f.length;l++)m=f[l],m.form===a.form&&Mi(m)}break e;case"textarea":vn(a,f.value,f.defaultValue);break e;case"select":l=f.value,l!=null&&Gr(a,!!f.multiple,l,!1)}}}var S0=!1;function KT(a,l,f){if(S0)return a(l,f);S0=!0;try{var m=a(l);return m}finally{if(S0=!1,(Yu!==null||Ku!==null)&&(Mm(),Yu&&(l=Yu,a=Ku,Ku=Yu=null,YT(l),a)))for(l=0;l<a.length;l++)YT(a[l])}}function df(a,l){var f=a.stateNode;if(f===null)return null;var m=f[Ti]||null;if(m===null)return null;f=m[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(a=a.type,m=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!m;break e;default:a=!1}if(a)return null;if(f&&typeof f!="function")throw Error(n(231,l,typeof f));return f}var La=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),T0=!1;if(La)try{var pf={};Object.defineProperty(pf,"passive",{get:function(){T0=!0}}),window.addEventListener("test",pf,pf),window.removeEventListener("test",pf,pf)}catch{T0=!1}var Ro=null,M0=null,Ip=null;function ZT(){if(Ip)return Ip;var a,l=M0,f=l.length,m,y="value"in Ro?Ro.value:Ro.textContent,T=y.length;for(a=0;a<f&&l[a]===y[a];a++);var R=f-a;for(m=1;m<=R&&l[f-m]===y[T-m];m++);return Ip=y.slice(a,1<m?1-m:void 0)}function zp(a){var l=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&l===13&&(a=13)):a=l,a===10&&(a=13),32<=a||a===13?a:0}function kp(){return!0}function QT(){return!1}function Tr(a){function l(f,m,y,T,R){this._reactName=f,this._targetInst=y,this.type=m,this.nativeEvent=T,this.target=R,this.currentTarget=null;for(var U in a)a.hasOwnProperty(U)&&(f=a[U],this[U]=f?f(T):T[U]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?kp:QT,this.isPropagationStopped=QT,this}return p(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=kp)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=kp)},persist:function(){},isPersistent:kp}),l}var Ol={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gp=Tr(Ol),mf=p({},Ol,{view:0,detail:0}),GL=Tr(mf),E0,A0,gf,Vp=p({},mf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:R0,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==gf&&(gf&&a.type==="mousemove"?(E0=a.screenX-gf.screenX,A0=a.screenY-gf.screenY):A0=E0=0,gf=a),E0)},movementY:function(a){return"movementY"in a?a.movementY:A0}}),JT=Tr(Vp),VL=p({},Vp,{dataTransfer:0}),HL=Tr(VL),jL=p({},mf,{relatedTarget:0}),w0=Tr(jL),WL=p({},Ol,{animationName:0,elapsedTime:0,pseudoElement:0}),$L=Tr(WL),qL=p({},Ol,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),XL=Tr(qL),YL=p({},Ol,{data:0}),eM=Tr(YL),KL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ZL={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"},QL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function JL(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=QL[a])?!!l[a]:!1}function R0(){return JL}var eP=p({},mf,{key:function(a){if(a.key){var l=KL[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=zp(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?ZL[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:R0,charCode:function(a){return a.type==="keypress"?zp(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?zp(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),tP=Tr(eP),nP=p({},Vp,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),tM=Tr(nP),iP=p({},mf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:R0}),rP=Tr(iP),sP=p({},Ol,{propertyName:0,elapsedTime:0,pseudoElement:0}),aP=Tr(sP),oP=p({},Vp,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),lP=Tr(oP),uP=p({},Ol,{newState:0,oldState:0}),cP=Tr(uP),hP=[9,13,27,32],C0=La&&"CompositionEvent"in window,_f=null;La&&"documentMode"in document&&(_f=document.documentMode);var fP=La&&"TextEvent"in window&&!_f,nM=La&&(!C0||_f&&8<_f&&11>=_f),iM=" ",rM=!1;function sM(a,l){switch(a){case"keyup":return hP.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function aM(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Zu=!1;function dP(a,l){switch(a){case"compositionend":return aM(l);case"keypress":return l.which!==32?null:(rM=!0,iM);case"textInput":return a=l.data,a===iM&&rM?null:a;default:return null}}function pP(a,l){if(Zu)return a==="compositionend"||!C0&&sM(a,l)?(a=ZT(),Ip=M0=Ro=null,Zu=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return nM&&l.locale!=="ko"?null:l.data;default:return null}}var mP={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 oM(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!mP[a.type]:l==="textarea"}function lM(a,l,f,m){Yu?Ku?Ku.push(m):Ku=[m]:Yu=m,l=Dm(l,"onChange"),0<l.length&&(f=new Gp("onChange","change",null,f,m),a.push({event:f,listeners:l}))}var vf=null,yf=null;function gP(a){jA(a,0)}function Hp(a){var l=Ul(a);if(Mi(l))return a}function uM(a,l){if(a==="change")return l}var cM=!1;if(La){var N0;if(La){var D0="oninput"in document;if(!D0){var hM=document.createElement("div");hM.setAttribute("oninput","return;"),D0=typeof hM.oninput=="function"}N0=D0}else N0=!1;cM=N0&&(!document.documentMode||9<document.documentMode)}function fM(){vf&&(vf.detachEvent("onpropertychange",dM),yf=vf=null)}function dM(a){if(a.propertyName==="value"&&Hp(yf)){var l=[];lM(l,yf,a,b0(a)),KT(gP,l)}}function _P(a,l,f){a==="focusin"?(fM(),vf=l,yf=f,vf.attachEvent("onpropertychange",dM)):a==="focusout"&&fM()}function vP(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Hp(yf)}function yP(a,l){if(a==="click")return Hp(l)}function xP(a,l){if(a==="input"||a==="change")return Hp(l)}function bP(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var Vr=typeof Object.is=="function"?Object.is:bP;function xf(a,l){if(Vr(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var f=Object.keys(a),m=Object.keys(l);if(f.length!==m.length)return!1;for(m=0;m<f.length;m++){var y=f[m];if(!$n.call(l,y)||!Vr(a[y],l[y]))return!1}return!0}function pM(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function mM(a,l){var f=pM(a);a=0;for(var m;f;){if(f.nodeType===3){if(m=a+f.textContent.length,a<=l&&m>=l)return{node:f,offset:l-a};a=m}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=pM(f)}}function gM(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?gM(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function _M(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var l=at(a.document);l instanceof a.HTMLIFrameElement;){try{var f=typeof l.contentWindow.location.href=="string"}catch{f=!1}if(f)a=l.contentWindow;else break;l=at(a.document)}return l}function L0(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}var SP=La&&"documentMode"in document&&11>=document.documentMode,Qu=null,P0=null,bf=null,U0=!1;function vM(a,l,f){var m=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;U0||Qu==null||Qu!==at(m)||(m=Qu,"selectionStart"in m&&L0(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),bf&&xf(bf,m)||(bf=m,m=Dm(P0,"onSelect"),0<m.length&&(l=new Gp("onSelect","select",null,l,f),a.push({event:l,listeners:m}),l.target=Qu)))}function Bl(a,l){var f={};return f[a.toLowerCase()]=l.toLowerCase(),f["Webkit"+a]="webkit"+l,f["Moz"+a]="moz"+l,f}var Ju={animationend:Bl("Animation","AnimationEnd"),animationiteration:Bl("Animation","AnimationIteration"),animationstart:Bl("Animation","AnimationStart"),transitionrun:Bl("Transition","TransitionRun"),transitionstart:Bl("Transition","TransitionStart"),transitioncancel:Bl("Transition","TransitionCancel"),transitionend:Bl("Transition","TransitionEnd")},O0={},yM={};La&&(yM=document.createElement("div").style,"AnimationEvent"in window||(delete Ju.animationend.animation,delete Ju.animationiteration.animation,delete Ju.animationstart.animation),"TransitionEvent"in window||delete Ju.transitionend.transition);function Fl(a){if(O0[a])return O0[a];if(!Ju[a])return a;var l=Ju[a],f;for(f in l)if(l.hasOwnProperty(f)&&f in yM)return O0[a]=l[f];return a}var xM=Fl("animationend"),bM=Fl("animationiteration"),SM=Fl("animationstart"),TP=Fl("transitionrun"),MP=Fl("transitionstart"),EP=Fl("transitioncancel"),TM=Fl("transitionend"),MM=new Map,B0="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(" ");B0.push("scrollEnd");function Ns(a,l){MM.set(a,l),he(l,[a])}var jp=typeof reportError=="function"?reportError:function(a){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof a=="object"&&a!==null&&typeof a.message=="string"?String(a.message):String(a),error:a});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",a);return}console.error(a)},ss=[],ec=0,F0=0;function Wp(){for(var a=ec,l=F0=ec=0;l<a;){var f=ss[l];ss[l++]=null;var m=ss[l];ss[l++]=null;var y=ss[l];ss[l++]=null;var T=ss[l];if(ss[l++]=null,m!==null&&y!==null){var R=m.pending;R===null?y.next=y:(y.next=R.next,R.next=y),m.pending=y}T!==0&&EM(f,y,T)}}function $p(a,l,f,m){ss[ec++]=a,ss[ec++]=l,ss[ec++]=f,ss[ec++]=m,F0|=m,a.lanes|=m,a=a.alternate,a!==null&&(a.lanes|=m)}function I0(a,l,f,m){return $p(a,l,f,m),qp(a)}function Il(a,l){return $p(a,null,null,l),qp(a)}function EM(a,l,f){a.lanes|=f;var m=a.alternate;m!==null&&(m.lanes|=f);for(var y=!1,T=a.return;T!==null;)T.childLanes|=f,m=T.alternate,m!==null&&(m.childLanes|=f),T.tag===22&&(a=T.stateNode,a===null||a._visibility&1||(y=!0)),a=T,T=T.return;return a.tag===3?(T=a.stateNode,y&&l!==null&&(y=31-Xe(f),a=T.hiddenUpdates,m=a[y],m===null?a[y]=[l]:m.push(l),l.lane=f|536870912),T):null}function qp(a){if(50<Hf)throw Hf=0,qv=null,Error(n(185));for(var l=a.return;l!==null;)a=l,l=a.return;return a.tag===3?a.stateNode:null}var tc={};function AP(a,l,f,m){this.tag=a,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Hr(a,l,f,m){return new AP(a,l,f,m)}function z0(a){return a=a.prototype,!(!a||!a.isReactComponent)}function Pa(a,l){var f=a.alternate;return f===null?(f=Hr(a.tag,l,a.key,a.mode),f.elementType=a.elementType,f.type=a.type,f.stateNode=a.stateNode,f.alternate=a,a.alternate=f):(f.pendingProps=l,f.type=a.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=a.flags&65011712,f.childLanes=a.childLanes,f.lanes=a.lanes,f.child=a.child,f.memoizedProps=a.memoizedProps,f.memoizedState=a.memoizedState,f.updateQueue=a.updateQueue,l=a.dependencies,f.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},f.sibling=a.sibling,f.index=a.index,f.ref=a.ref,f.refCleanup=a.refCleanup,f}function AM(a,l){a.flags&=65011714;var f=a.alternate;return f===null?(a.childLanes=0,a.lanes=l,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=f.childLanes,a.lanes=f.lanes,a.child=f.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=f.memoizedProps,a.memoizedState=f.memoizedState,a.updateQueue=f.updateQueue,a.type=f.type,l=f.dependencies,a.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),a}function Xp(a,l,f,m,y,T){var R=0;if(m=a,typeof a=="function")z0(a)&&(R=1);else if(typeof a=="string")R=DU(a,f,Le.current)?26:a==="html"||a==="head"||a==="body"?27:5;else e:switch(a){case L:return a=Hr(31,f,l,y),a.elementType=L,a.lanes=T,a;case S:return zl(f.children,y,T,l);case b:R=8,y|=24;break;case x:return a=Hr(12,f,l,y|2),a.elementType=x,a.lanes=T,a;case D:return a=Hr(13,f,l,y),a.elementType=D,a.lanes=T,a;case C:return a=Hr(19,f,l,y),a.elementType=C,a.lanes=T,a;default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case E:R=10;break e;case M:R=9;break e;case w:R=11;break e;case N:R=14;break e;case A:R=16,m=null;break e}R=29,f=Error(n(130,a===null?"null":typeof a,"")),m=null}return l=Hr(R,f,l,y),l.elementType=a,l.type=m,l.lanes=T,l}function zl(a,l,f,m){return a=Hr(7,a,m,l),a.lanes=f,a}function k0(a,l,f){return a=Hr(6,a,null,l),a.lanes=f,a}function wM(a){var l=Hr(18,null,null,0);return l.stateNode=a,l}function G0(a,l,f){return l=Hr(4,a.children!==null?a.children:[],a.key,l),l.lanes=f,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}var RM=new WeakMap;function as(a,l){if(typeof a=="object"&&a!==null){var f=RM.get(a);return f!==void 0?f:(l={value:a,source:l,stack:Q(l)},RM.set(a,l),l)}return{value:a,source:l,stack:Q(l)}}var nc=[],ic=0,Yp=null,Sf=0,os=[],ls=0,Co=null,$s=1,qs="";function Ua(a,l){nc[ic++]=Sf,nc[ic++]=Yp,Yp=a,Sf=l}function CM(a,l,f){os[ls++]=$s,os[ls++]=qs,os[ls++]=Co,Co=a;var m=$s;a=qs;var y=32-Xe(m)-1;m&=~(1<<y),f+=1;var T=32-Xe(l)+y;if(30<T){var R=y-y%5;T=(m&(1<<R)-1).toString(32),m>>=R,y-=R,$s=1<<32-Xe(l)+y|f<<y|m,qs=T+a}else $s=1<<T|f<<y|m,qs=a}function V0(a){a.return!==null&&(Ua(a,1),CM(a,1,0))}function H0(a){for(;a===Yp;)Yp=nc[--ic],nc[ic]=null,Sf=nc[--ic],nc[ic]=null;for(;a===Co;)Co=os[--ls],os[ls]=null,qs=os[--ls],os[ls]=null,$s=os[--ls],os[ls]=null}function NM(a,l){os[ls++]=$s,os[ls++]=qs,os[ls++]=Co,$s=l.id,qs=l.overflow,Co=a}var Ii=null,Vn=null,en=!1,No=null,us=!1,j0=Error(n(519));function Do(a){var l=Error(n(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Tf(as(l,a)),j0}function DM(a){var l=a.stateNode,f=a.type,m=a.memoizedProps;switch(l[ci]=a,l[Ti]=m,f){case"dialog":Yt("cancel",l),Yt("close",l);break;case"iframe":case"object":case"embed":Yt("load",l);break;case"video":case"audio":for(f=0;f<Wf.length;f++)Yt(Wf[f],l);break;case"source":Yt("error",l);break;case"img":case"image":case"link":Yt("error",l),Yt("load",l);break;case"details":Yt("toggle",l);break;case"input":Yt("invalid",l),kr(l,m.value,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name,!0);break;case"select":Yt("invalid",l);break;case"textarea":Yt("invalid",l),hi(l,m.value,m.defaultValue,m.children)}f=m.children,typeof f!="string"&&typeof f!="number"&&typeof f!="bigint"||l.textContent===""+f||m.suppressHydrationWarning===!0||XA(l.textContent,f)?(m.popover!=null&&(Yt("beforetoggle",l),Yt("toggle",l)),m.onScroll!=null&&Yt("scroll",l),m.onScrollEnd!=null&&Yt("scrollend",l),m.onClick!=null&&(l.onclick=Da),l=!0):l=!1,l||Do(a,!0)}function LM(a){for(Ii=a.return;Ii;)switch(Ii.tag){case 5:case 31:case 13:us=!1;return;case 27:case 3:us=!0;return;default:Ii=Ii.return}}function rc(a){if(a!==Ii)return!1;if(!en)return LM(a),en=!0,!1;var l=a.tag,f;if((f=l!==3&&l!==27)&&((f=l===5)&&(f=a.type,f=!(f!=="form"&&f!=="button")||ly(a.type,a.memoizedProps)),f=!f),f&&Vn&&Do(a),LM(a),l===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));Vn=i1(a)}else if(l===31){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));Vn=i1(a)}else l===27?(l=Vn,Wo(a.type)?(a=dy,dy=null,Vn=a):Vn=l):Vn=Ii?hs(a.stateNode.nextSibling):null;return!0}function kl(){Vn=Ii=null,en=!1}function W0(){var a=No;return a!==null&&(wr===null?wr=a:wr.push.apply(wr,a),No=null),a}function Tf(a){No===null?No=[a]:No.push(a)}var $0=O(null),Gl=null,Oa=null;function Lo(a,l,f){ce($0,l._currentValue),l._currentValue=f}function Ba(a){a._currentValue=$0.current,W($0)}function q0(a,l,f){for(;a!==null;){var m=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,m!==null&&(m.childLanes|=l)):m!==null&&(m.childLanes&l)!==l&&(m.childLanes|=l),a===f)break;a=a.return}}function X0(a,l,f,m){var y=a.child;for(y!==null&&(y.return=a);y!==null;){var T=y.dependencies;if(T!==null){var R=y.child;T=T.firstContext;e:for(;T!==null;){var U=T;T=y;for(var q=0;q<l.length;q++)if(U.context===l[q]){T.lanes|=f,U=T.alternate,U!==null&&(U.lanes|=f),q0(T.return,f,a),m||(R=null);break e}T=U.next}}else if(y.tag===18){if(R=y.return,R===null)throw Error(n(341));R.lanes|=f,T=R.alternate,T!==null&&(T.lanes|=f),q0(R,f,a),R=null}else R=y.child;if(R!==null)R.return=y;else for(R=y;R!==null;){if(R===a){R=null;break}if(y=R.sibling,y!==null){y.return=R.return,R=y;break}R=R.return}y=R}}function sc(a,l,f,m){a=null;for(var y=l,T=!1;y!==null;){if(!T){if((y.flags&524288)!==0)T=!0;else if((y.flags&262144)!==0)break}if(y.tag===10){var R=y.alternate;if(R===null)throw Error(n(387));if(R=R.memoizedProps,R!==null){var U=y.type;Vr(y.pendingProps.value,R.value)||(a!==null?a.push(U):a=[U])}}else if(y===ue.current){if(R=y.alternate,R===null)throw Error(n(387));R.memoizedState.memoizedState!==y.memoizedState.memoizedState&&(a!==null?a.push(Kf):a=[Kf])}y=y.return}a!==null&&X0(l,a,f,m),l.flags|=262144}function Kp(a){for(a=a.firstContext;a!==null;){if(!Vr(a.context._currentValue,a.memoizedValue))return!0;a=a.next}return!1}function Vl(a){Gl=a,Oa=null,a=a.dependencies,a!==null&&(a.firstContext=null)}function zi(a){return PM(Gl,a)}function Zp(a,l){return Gl===null&&Vl(a),PM(a,l)}function PM(a,l){var f=l._currentValue;if(l={context:l,memoizedValue:f,next:null},Oa===null){if(a===null)throw Error(n(308));Oa=l,a.dependencies={lanes:0,firstContext:l},a.flags|=524288}else Oa=Oa.next=l;return f}var wP=typeof AbortController<"u"?AbortController:function(){var a=[],l=this.signal={aborted:!1,addEventListener:function(f,m){a.push(m)}};this.abort=function(){l.aborted=!0,a.forEach(function(f){return f()})}},RP=i.unstable_scheduleCallback,CP=i.unstable_NormalPriority,di={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Y0(){return{controller:new wP,data:new Map,refCount:0}}function Mf(a){a.refCount--,a.refCount===0&&RP(CP,function(){a.controller.abort()})}var Ef=null,K0=0,ac=0,oc=null;function NP(a,l){if(Ef===null){var f=Ef=[];K0=0,ac=Jv(),oc={status:"pending",value:void 0,then:function(m){f.push(m)}}}return K0++,l.then(UM,UM),l}function UM(){if(--K0===0&&Ef!==null){oc!==null&&(oc.status="fulfilled");var a=Ef;Ef=null,ac=0,oc=null;for(var l=0;l<a.length;l++)(0,a[l])()}}function DP(a,l){var f=[],m={status:"pending",value:null,reason:null,then:function(y){f.push(y)}};return a.then(function(){m.status="fulfilled",m.value=l;for(var y=0;y<f.length;y++)(0,f[y])(l)},function(y){for(m.status="rejected",m.reason=y,y=0;y<f.length;y++)(0,f[y])(void 0)}),m}var OM=I.S;I.S=function(a,l){vA=P(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&NP(a,l),OM!==null&&OM(a,l)};var Hl=O(null);function Z0(){var a=Hl.current;return a!==null?a:Pn.pooledCache}function Qp(a,l){l===null?ce(Hl,Hl.current):ce(Hl,l.pool)}function BM(){var a=Z0();return a===null?null:{parent:di._currentValue,pool:a}}var lc=Error(n(460)),Q0=Error(n(474)),Jp=Error(n(542)),em={then:function(){}};function FM(a){return a=a.status,a==="fulfilled"||a==="rejected"}function IM(a,l,f){switch(f=a[f],f===void 0?a.push(l):f!==l&&(l.then(Da,Da),l=f),l.status){case"fulfilled":return l.value;case"rejected":throw a=l.reason,kM(a),a;default:if(typeof l.status=="string")l.then(Da,Da);else{if(a=Pn,a!==null&&100<a.shellSuspendCounter)throw Error(n(482));a=l,a.status="pending",a.then(function(m){if(l.status==="pending"){var y=l;y.status="fulfilled",y.value=m}},function(m){if(l.status==="pending"){var y=l;y.status="rejected",y.reason=m}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw a=l.reason,kM(a),a}throw Wl=l,lc}}function jl(a){try{var l=a._init;return l(a._payload)}catch(f){throw f!==null&&typeof f=="object"&&typeof f.then=="function"?(Wl=f,lc):f}}var Wl=null;function zM(){if(Wl===null)throw Error(n(459));var a=Wl;return Wl=null,a}function kM(a){if(a===lc||a===Jp)throw Error(n(483))}var uc=null,Af=0;function tm(a){var l=Af;return Af+=1,uc===null&&(uc=[]),IM(uc,a,l)}function wf(a,l){l=l.props.ref,a.ref=l!==void 0?l:null}function nm(a,l){throw l.$$typeof===g?Error(n(525)):(a=Object.prototype.toString.call(l),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a)))}function GM(a){function l(oe,J){if(a){var fe=oe.deletions;fe===null?(oe.deletions=[J],oe.flags|=16):fe.push(J)}}function f(oe,J){if(!a)return null;for(;J!==null;)l(oe,J),J=J.sibling;return null}function m(oe){for(var J=new Map;oe!==null;)oe.key!==null?J.set(oe.key,oe):J.set(oe.index,oe),oe=oe.sibling;return J}function y(oe,J){return oe=Pa(oe,J),oe.index=0,oe.sibling=null,oe}function T(oe,J,fe){return oe.index=fe,a?(fe=oe.alternate,fe!==null?(fe=fe.index,fe<J?(oe.flags|=67108866,J):fe):(oe.flags|=67108866,J)):(oe.flags|=1048576,J)}function R(oe){return a&&oe.alternate===null&&(oe.flags|=67108866),oe}function U(oe,J,fe,Ce){return J===null||J.tag!==6?(J=k0(fe,oe.mode,Ce),J.return=oe,J):(J=y(J,fe),J.return=oe,J)}function q(oe,J,fe,Ce){var vt=fe.type;return vt===S?we(oe,J,fe.props.children,Ce,fe.key):J!==null&&(J.elementType===vt||typeof vt=="object"&&vt!==null&&vt.$$typeof===A&&jl(vt)===J.type)?(J=y(J,fe.props),wf(J,fe),J.return=oe,J):(J=Xp(fe.type,fe.key,fe.props,null,oe.mode,Ce),wf(J,fe),J.return=oe,J)}function de(oe,J,fe,Ce){return J===null||J.tag!==4||J.stateNode.containerInfo!==fe.containerInfo||J.stateNode.implementation!==fe.implementation?(J=G0(fe,oe.mode,Ce),J.return=oe,J):(J=y(J,fe.children||[]),J.return=oe,J)}function we(oe,J,fe,Ce,vt){return J===null||J.tag!==7?(J=zl(fe,oe.mode,Ce,vt),J.return=oe,J):(J=y(J,fe),J.return=oe,J)}function De(oe,J,fe){if(typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint")return J=k0(""+J,oe.mode,fe),J.return=oe,J;if(typeof J=="object"&&J!==null){switch(J.$$typeof){case _:return fe=Xp(J.type,J.key,J.props,null,oe.mode,fe),wf(fe,J),fe.return=oe,fe;case v:return J=G0(J,oe.mode,fe),J.return=oe,J;case A:return J=jl(J),De(oe,J,fe)}if(Z(J)||H(J))return J=zl(J,oe.mode,fe,null),J.return=oe,J;if(typeof J.then=="function")return De(oe,tm(J),fe);if(J.$$typeof===E)return De(oe,Zp(oe,J),fe);nm(oe,J)}return null}function me(oe,J,fe,Ce){var vt=J!==null?J.key:null;if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return vt!==null?null:U(oe,J,""+fe,Ce);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case _:return fe.key===vt?q(oe,J,fe,Ce):null;case v:return fe.key===vt?de(oe,J,fe,Ce):null;case A:return fe=jl(fe),me(oe,J,fe,Ce)}if(Z(fe)||H(fe))return vt!==null?null:we(oe,J,fe,Ce,null);if(typeof fe.then=="function")return me(oe,J,tm(fe),Ce);if(fe.$$typeof===E)return me(oe,J,Zp(oe,fe),Ce);nm(oe,fe)}return null}function _e(oe,J,fe,Ce,vt){if(typeof Ce=="string"&&Ce!==""||typeof Ce=="number"||typeof Ce=="bigint")return oe=oe.get(fe)||null,U(J,oe,""+Ce,vt);if(typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case _:return oe=oe.get(Ce.key===null?fe:Ce.key)||null,q(J,oe,Ce,vt);case v:return oe=oe.get(Ce.key===null?fe:Ce.key)||null,de(J,oe,Ce,vt);case A:return Ce=jl(Ce),_e(oe,J,fe,Ce,vt)}if(Z(Ce)||H(Ce))return oe=oe.get(fe)||null,we(J,oe,Ce,vt,null);if(typeof Ce.then=="function")return _e(oe,J,fe,tm(Ce),vt);if(Ce.$$typeof===E)return _e(oe,J,fe,Zp(J,Ce),vt);nm(J,Ce)}return null}function st(oe,J,fe,Ce){for(var vt=null,un=null,ft=J,Ht=J=0,Jt=null;ft!==null&&Ht<fe.length;Ht++){ft.index>Ht?(Jt=ft,ft=null):Jt=ft.sibling;var cn=me(oe,ft,fe[Ht],Ce);if(cn===null){ft===null&&(ft=Jt);break}a&&ft&&cn.alternate===null&&l(oe,ft),J=T(cn,J,Ht),un===null?vt=cn:un.sibling=cn,un=cn,ft=Jt}if(Ht===fe.length)return f(oe,ft),en&&Ua(oe,Ht),vt;if(ft===null){for(;Ht<fe.length;Ht++)ft=De(oe,fe[Ht],Ce),ft!==null&&(J=T(ft,J,Ht),un===null?vt=ft:un.sibling=ft,un=ft);return en&&Ua(oe,Ht),vt}for(ft=m(ft);Ht<fe.length;Ht++)Jt=_e(ft,oe,Ht,fe[Ht],Ce),Jt!==null&&(a&&Jt.alternate!==null&&ft.delete(Jt.key===null?Ht:Jt.key),J=T(Jt,J,Ht),un===null?vt=Jt:un.sibling=Jt,un=Jt);return a&&ft.forEach(function(Ko){return l(oe,Ko)}),en&&Ua(oe,Ht),vt}function bt(oe,J,fe,Ce){if(fe==null)throw Error(n(151));for(var vt=null,un=null,ft=J,Ht=J=0,Jt=null,cn=fe.next();ft!==null&&!cn.done;Ht++,cn=fe.next()){ft.index>Ht?(Jt=ft,ft=null):Jt=ft.sibling;var Ko=me(oe,ft,cn.value,Ce);if(Ko===null){ft===null&&(ft=Jt);break}a&&ft&&Ko.alternate===null&&l(oe,ft),J=T(Ko,J,Ht),un===null?vt=Ko:un.sibling=Ko,un=Ko,ft=Jt}if(cn.done)return f(oe,ft),en&&Ua(oe,Ht),vt;if(ft===null){for(;!cn.done;Ht++,cn=fe.next())cn=De(oe,cn.value,Ce),cn!==null&&(J=T(cn,J,Ht),un===null?vt=cn:un.sibling=cn,un=cn);return en&&Ua(oe,Ht),vt}for(ft=m(ft);!cn.done;Ht++,cn=fe.next())cn=_e(ft,oe,Ht,cn.value,Ce),cn!==null&&(a&&cn.alternate!==null&&ft.delete(cn.key===null?Ht:cn.key),J=T(cn,J,Ht),un===null?vt=cn:un.sibling=cn,un=cn);return a&&ft.forEach(function(VU){return l(oe,VU)}),en&&Ua(oe,Ht),vt}function Dn(oe,J,fe,Ce){if(typeof fe=="object"&&fe!==null&&fe.type===S&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case _:e:{for(var vt=fe.key;J!==null;){if(J.key===vt){if(vt=fe.type,vt===S){if(J.tag===7){f(oe,J.sibling),Ce=y(J,fe.props.children),Ce.return=oe,oe=Ce;break e}}else if(J.elementType===vt||typeof vt=="object"&&vt!==null&&vt.$$typeof===A&&jl(vt)===J.type){f(oe,J.sibling),Ce=y(J,fe.props),wf(Ce,fe),Ce.return=oe,oe=Ce;break e}f(oe,J);break}else l(oe,J);J=J.sibling}fe.type===S?(Ce=zl(fe.props.children,oe.mode,Ce,fe.key),Ce.return=oe,oe=Ce):(Ce=Xp(fe.type,fe.key,fe.props,null,oe.mode,Ce),wf(Ce,fe),Ce.return=oe,oe=Ce)}return R(oe);case v:e:{for(vt=fe.key;J!==null;){if(J.key===vt)if(J.tag===4&&J.stateNode.containerInfo===fe.containerInfo&&J.stateNode.implementation===fe.implementation){f(oe,J.sibling),Ce=y(J,fe.children||[]),Ce.return=oe,oe=Ce;break e}else{f(oe,J);break}else l(oe,J);J=J.sibling}Ce=G0(fe,oe.mode,Ce),Ce.return=oe,oe=Ce}return R(oe);case A:return fe=jl(fe),Dn(oe,J,fe,Ce)}if(Z(fe))return st(oe,J,fe,Ce);if(H(fe)){if(vt=H(fe),typeof vt!="function")throw Error(n(150));return fe=vt.call(fe),bt(oe,J,fe,Ce)}if(typeof fe.then=="function")return Dn(oe,J,tm(fe),Ce);if(fe.$$typeof===E)return Dn(oe,J,Zp(oe,fe),Ce);nm(oe,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint"?(fe=""+fe,J!==null&&J.tag===6?(f(oe,J.sibling),Ce=y(J,fe),Ce.return=oe,oe=Ce):(f(oe,J),Ce=k0(fe,oe.mode,Ce),Ce.return=oe,oe=Ce),R(oe)):f(oe,J)}return function(oe,J,fe,Ce){try{Af=0;var vt=Dn(oe,J,fe,Ce);return uc=null,vt}catch(ft){if(ft===lc||ft===Jp)throw ft;var un=Hr(29,ft,null,oe.mode);return un.lanes=Ce,un.return=oe,un}finally{}}}var $l=GM(!0),VM=GM(!1),Po=!1;function J0(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ev(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function Uo(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function Oo(a,l,f){var m=a.updateQueue;if(m===null)return null;if(m=m.shared,(pn&2)!==0){var y=m.pending;return y===null?l.next=l:(l.next=y.next,y.next=l),m.pending=l,l=qp(a),EM(a,null,f),l}return $p(a,m,l,f),qp(a)}function Rf(a,l,f){if(l=l.updateQueue,l!==null&&(l=l.shared,(f&4194048)!==0)){var m=l.lanes;m&=a.pendingLanes,f|=m,l.lanes=f,ju(a,f)}}function tv(a,l){var f=a.updateQueue,m=a.alternate;if(m!==null&&(m=m.updateQueue,f===m)){var y=null,T=null;if(f=f.firstBaseUpdate,f!==null){do{var R={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};T===null?y=T=R:T=T.next=R,f=f.next}while(f!==null);T===null?y=T=l:T=T.next=l}else y=T=l;f={baseState:m.baseState,firstBaseUpdate:y,lastBaseUpdate:T,shared:m.shared,callbacks:m.callbacks},a.updateQueue=f;return}a=f.lastBaseUpdate,a===null?f.firstBaseUpdate=l:a.next=l,f.lastBaseUpdate=l}var nv=!1;function Cf(){if(nv){var a=oc;if(a!==null)throw a}}function Nf(a,l,f,m){nv=!1;var y=a.updateQueue;Po=!1;var T=y.firstBaseUpdate,R=y.lastBaseUpdate,U=y.shared.pending;if(U!==null){y.shared.pending=null;var q=U,de=q.next;q.next=null,R===null?T=de:R.next=de,R=q;var we=a.alternate;we!==null&&(we=we.updateQueue,U=we.lastBaseUpdate,U!==R&&(U===null?we.firstBaseUpdate=de:U.next=de,we.lastBaseUpdate=q))}if(T!==null){var De=y.baseState;R=0,we=de=q=null,U=T;do{var me=U.lane&-536870913,_e=me!==U.lane;if(_e?(Qt&me)===me:(m&me)===me){me!==0&&me===ac&&(nv=!0),we!==null&&(we=we.next={lane:0,tag:U.tag,payload:U.payload,callback:null,next:null});e:{var st=a,bt=U;me=l;var Dn=f;switch(bt.tag){case 1:if(st=bt.payload,typeof st=="function"){De=st.call(Dn,De,me);break e}De=st;break e;case 3:st.flags=st.flags&-65537|128;case 0:if(st=bt.payload,me=typeof st=="function"?st.call(Dn,De,me):st,me==null)break e;De=p({},De,me);break e;case 2:Po=!0}}me=U.callback,me!==null&&(a.flags|=64,_e&&(a.flags|=8192),_e=y.callbacks,_e===null?y.callbacks=[me]:_e.push(me))}else _e={lane:me,tag:U.tag,payload:U.payload,callback:U.callback,next:null},we===null?(de=we=_e,q=De):we=we.next=_e,R|=me;if(U=U.next,U===null){if(U=y.shared.pending,U===null)break;_e=U,U=_e.next,_e.next=null,y.lastBaseUpdate=_e,y.shared.pending=null}}while(!0);we===null&&(q=De),y.baseState=q,y.firstBaseUpdate=de,y.lastBaseUpdate=we,T===null&&(y.shared.lanes=0),ko|=R,a.lanes=R,a.memoizedState=De}}function HM(a,l){if(typeof a!="function")throw Error(n(191,a));a.call(l)}function jM(a,l){var f=a.callbacks;if(f!==null)for(a.callbacks=null,a=0;a<f.length;a++)HM(f[a],l)}var cc=O(null),im=O(0);function WM(a,l){a=Wa,ce(im,a),ce(cc,l),Wa=a|l.baseLanes}function iv(){ce(im,Wa),ce(cc,cc.current)}function rv(){Wa=im.current,W(cc),W(im)}var jr=O(null),cs=null;function Bo(a){var l=a.alternate;ce(ai,ai.current&1),ce(jr,a),cs===null&&(l===null||cc.current!==null||l.memoizedState!==null)&&(cs=a)}function sv(a){ce(ai,ai.current),ce(jr,a),cs===null&&(cs=a)}function $M(a){a.tag===22?(ce(ai,ai.current),ce(jr,a),cs===null&&(cs=a)):Fo()}function Fo(){ce(ai,ai.current),ce(jr,jr.current)}function Wr(a){W(jr),cs===a&&(cs=null),W(ai)}var ai=O(0);function rm(a){for(var l=a;l!==null;){if(l.tag===13){var f=l.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||hy(f)||fy(f)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Fa=0,It=null,Cn=null,pi=null,sm=!1,hc=!1,ql=!1,am=0,Df=0,fc=null,LP=0;function ni(){throw Error(n(321))}function av(a,l){if(l===null)return!1;for(var f=0;f<l.length&&f<a.length;f++)if(!Vr(a[f],l[f]))return!1;return!0}function ov(a,l,f,m,y,T){return Fa=T,It=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,I.H=a===null||a.memoizedState===null?CE:Sv,ql=!1,T=f(m,y),ql=!1,hc&&(T=XM(l,f,m,y)),qM(a),T}function qM(a){I.H=Uf;var l=Cn!==null&&Cn.next!==null;if(Fa=0,pi=Cn=It=null,sm=!1,Df=0,fc=null,l)throw Error(n(300));a===null||mi||(a=a.dependencies,a!==null&&Kp(a)&&(mi=!0))}function XM(a,l,f,m){It=a;var y=0;do{if(hc&&(fc=null),Df=0,hc=!1,25<=y)throw Error(n(301));if(y+=1,pi=Cn=null,a.updateQueue!=null){var T=a.updateQueue;T.lastEffect=null,T.events=null,T.stores=null,T.memoCache!=null&&(T.memoCache.index=0)}I.H=NE,T=l(f,m)}while(hc);return T}function PP(){var a=I.H,l=a.useState()[0];return l=typeof l.then=="function"?Lf(l):l,a=a.useState()[0],(Cn!==null?Cn.memoizedState:null)!==a&&(It.flags|=1024),l}function lv(){var a=am!==0;return am=0,a}function uv(a,l,f){l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~f}function cv(a){if(sm){for(a=a.memoizedState;a!==null;){var l=a.queue;l!==null&&(l.pending=null),a=a.next}sm=!1}Fa=0,pi=Cn=It=null,hc=!1,Df=am=0,fc=null}function ur(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return pi===null?It.memoizedState=pi=a:pi=pi.next=a,pi}function oi(){if(Cn===null){var a=It.alternate;a=a!==null?a.memoizedState:null}else a=Cn.next;var l=pi===null?It.memoizedState:pi.next;if(l!==null)pi=l,Cn=a;else{if(a===null)throw It.alternate===null?Error(n(467)):Error(n(310));Cn=a,a={memoizedState:Cn.memoizedState,baseState:Cn.baseState,baseQueue:Cn.baseQueue,queue:Cn.queue,next:null},pi===null?It.memoizedState=pi=a:pi=pi.next=a}return pi}function om(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Lf(a){var l=Df;return Df+=1,fc===null&&(fc=[]),a=IM(fc,a,l),l=It,(pi===null?l.memoizedState:pi.next)===null&&(l=l.alternate,I.H=l===null||l.memoizedState===null?CE:Sv),a}function lm(a){if(a!==null&&typeof a=="object"){if(typeof a.then=="function")return Lf(a);if(a.$$typeof===E)return zi(a)}throw Error(n(438,String(a)))}function hv(a){var l=null,f=It.updateQueue;if(f!==null&&(l=f.memoCache),l==null){var m=It.alternate;m!==null&&(m=m.updateQueue,m!==null&&(m=m.memoCache,m!=null&&(l={data:m.data.map(function(y){return y.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),f===null&&(f=om(),It.updateQueue=f),f.memoCache=l,f=l.data[l.index],f===void 0)for(f=l.data[l.index]=Array(a),m=0;m<a;m++)f[m]=j;return l.index++,f}function Ia(a,l){return typeof l=="function"?l(a):l}function um(a){var l=oi();return fv(l,Cn,a)}function fv(a,l,f){var m=a.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=f;var y=a.baseQueue,T=m.pending;if(T!==null){if(y!==null){var R=y.next;y.next=T.next,T.next=R}l.baseQueue=y=T,m.pending=null}if(T=a.baseState,y===null)a.memoizedState=T;else{l=y.next;var U=R=null,q=null,de=l,we=!1;do{var De=de.lane&-536870913;if(De!==de.lane?(Qt&De)===De:(Fa&De)===De){var me=de.revertLane;if(me===0)q!==null&&(q=q.next={lane:0,revertLane:0,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),De===ac&&(we=!0);else if((Fa&me)===me){de=de.next,me===ac&&(we=!0);continue}else De={lane:0,revertLane:de.revertLane,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},q===null?(U=q=De,R=T):q=q.next=De,It.lanes|=me,ko|=me;De=de.action,ql&&f(T,De),T=de.hasEagerState?de.eagerState:f(T,De)}else me={lane:De,revertLane:de.revertLane,gesture:de.gesture,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},q===null?(U=q=me,R=T):q=q.next=me,It.lanes|=De,ko|=De;de=de.next}while(de!==null&&de!==l);if(q===null?R=T:q.next=U,!Vr(T,a.memoizedState)&&(mi=!0,we&&(f=oc,f!==null)))throw f;a.memoizedState=T,a.baseState=R,a.baseQueue=q,m.lastRenderedState=T}return y===null&&(m.lanes=0),[a.memoizedState,m.dispatch]}function dv(a){var l=oi(),f=l.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=a;var m=f.dispatch,y=f.pending,T=l.memoizedState;if(y!==null){f.pending=null;var R=y=y.next;do T=a(T,R.action),R=R.next;while(R!==y);Vr(T,l.memoizedState)||(mi=!0),l.memoizedState=T,l.baseQueue===null&&(l.baseState=T),f.lastRenderedState=T}return[T,m]}function YM(a,l,f){var m=It,y=oi(),T=en;if(T){if(f===void 0)throw Error(n(407));f=f()}else f=l();var R=!Vr((Cn||y).memoizedState,f);if(R&&(y.memoizedState=f,mi=!0),y=y.queue,gv(QM.bind(null,m,y,a),[a]),y.getSnapshot!==l||R||pi!==null&&pi.memoizedState.tag&1){if(m.flags|=2048,dc(9,{destroy:void 0},ZM.bind(null,m,y,f,l),null),Pn===null)throw Error(n(349));T||(Fa&127)!==0||KM(m,l,f)}return f}function KM(a,l,f){a.flags|=16384,a={getSnapshot:l,value:f},l=It.updateQueue,l===null?(l=om(),It.updateQueue=l,l.stores=[a]):(f=l.stores,f===null?l.stores=[a]:f.push(a))}function ZM(a,l,f,m){l.value=f,l.getSnapshot=m,JM(l)&&eE(a)}function QM(a,l,f){return f(function(){JM(l)&&eE(a)})}function JM(a){var l=a.getSnapshot;a=a.value;try{var f=l();return!Vr(a,f)}catch{return!0}}function eE(a){var l=Il(a,2);l!==null&&Rr(l,a,2)}function pv(a){var l=ur();if(typeof a=="function"){var f=a;if(a=f(),ql){Ze(!0);try{f()}finally{Ze(!1)}}}return l.memoizedState=l.baseState=a,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:a},l}function tE(a,l,f,m){return a.baseState=f,fv(a,Cn,typeof m=="function"?m:Ia)}function UP(a,l,f,m,y){if(fm(a))throw Error(n(485));if(a=l.action,a!==null){var T={payload:y,action:a,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(R){T.listeners.push(R)}};I.T!==null?f(!0):T.isTransition=!1,m(T),f=l.pending,f===null?(T.next=l.pending=T,nE(l,T)):(T.next=f.next,l.pending=f.next=T)}}function nE(a,l){var f=l.action,m=l.payload,y=a.state;if(l.isTransition){var T=I.T,R={};I.T=R;try{var U=f(y,m),q=I.S;q!==null&&q(R,U),iE(a,l,U)}catch(de){mv(a,l,de)}finally{T!==null&&R.types!==null&&(T.types=R.types),I.T=T}}else try{T=f(y,m),iE(a,l,T)}catch(de){mv(a,l,de)}}function iE(a,l,f){f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(function(m){rE(a,l,m)},function(m){return mv(a,l,m)}):rE(a,l,f)}function rE(a,l,f){l.status="fulfilled",l.value=f,sE(l),a.state=f,l=a.pending,l!==null&&(f=l.next,f===l?a.pending=null:(f=f.next,l.next=f,nE(a,f)))}function mv(a,l,f){var m=a.pending;if(a.pending=null,m!==null){m=m.next;do l.status="rejected",l.reason=f,sE(l),l=l.next;while(l!==m)}a.action=null}function sE(a){a=a.listeners;for(var l=0;l<a.length;l++)(0,a[l])()}function aE(a,l){return l}function oE(a,l){if(en){var f=Pn.formState;if(f!==null){e:{var m=It;if(en){if(Vn){t:{for(var y=Vn,T=us;y.nodeType!==8;){if(!T){y=null;break t}if(y=hs(y.nextSibling),y===null){y=null;break t}}T=y.data,y=T==="F!"||T==="F"?y:null}if(y){Vn=hs(y.nextSibling),m=y.data==="F!";break e}}Do(m)}m=!1}m&&(l=f[0])}}return f=ur(),f.memoizedState=f.baseState=l,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:aE,lastRenderedState:l},f.queue=m,f=AE.bind(null,It,m),m.dispatch=f,m=pv(!1),T=bv.bind(null,It,!1,m.queue),m=ur(),y={state:l,dispatch:null,action:a,pending:null},m.queue=y,f=UP.bind(null,It,y,T,f),y.dispatch=f,m.memoizedState=a,[l,f,!1]}function lE(a){var l=oi();return uE(l,Cn,a)}function uE(a,l,f){if(l=fv(a,l,aE)[0],a=um(Ia)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var m=Lf(l)}catch(R){throw R===lc?Jp:R}else m=l;l=oi();var y=l.queue,T=y.dispatch;return f!==l.memoizedState&&(It.flags|=2048,dc(9,{destroy:void 0},OP.bind(null,y,f),null)),[m,T,a]}function OP(a,l){a.action=l}function cE(a){var l=oi(),f=Cn;if(f!==null)return uE(l,f,a);oi(),l=l.memoizedState,f=oi();var m=f.queue.dispatch;return f.memoizedState=a,[l,m,!1]}function dc(a,l,f,m){return a={tag:a,create:f,deps:m,inst:l,next:null},l=It.updateQueue,l===null&&(l=om(),It.updateQueue=l),f=l.lastEffect,f===null?l.lastEffect=a.next=a:(m=f.next,f.next=a,a.next=m,l.lastEffect=a),a}function hE(){return oi().memoizedState}function cm(a,l,f,m){var y=ur();It.flags|=a,y.memoizedState=dc(1|l,{destroy:void 0},f,m===void 0?null:m)}function hm(a,l,f,m){var y=oi();m=m===void 0?null:m;var T=y.memoizedState.inst;Cn!==null&&m!==null&&av(m,Cn.memoizedState.deps)?y.memoizedState=dc(l,T,f,m):(It.flags|=a,y.memoizedState=dc(1|l,T,f,m))}function fE(a,l){cm(8390656,8,a,l)}function gv(a,l){hm(2048,8,a,l)}function BP(a){It.flags|=4;var l=It.updateQueue;if(l===null)l=om(),It.updateQueue=l,l.events=[a];else{var f=l.events;f===null?l.events=[a]:f.push(a)}}function dE(a){var l=oi().memoizedState;return BP({ref:l,nextImpl:a}),function(){if((pn&2)!==0)throw Error(n(440));return l.impl.apply(void 0,arguments)}}function pE(a,l){return hm(4,2,a,l)}function mE(a,l){return hm(4,4,a,l)}function gE(a,l){if(typeof l=="function"){a=a();var f=l(a);return function(){typeof f=="function"?f():l(null)}}if(l!=null)return a=a(),l.current=a,function(){l.current=null}}function _E(a,l,f){f=f!=null?f.concat([a]):null,hm(4,4,gE.bind(null,l,a),f)}function _v(){}function vE(a,l){var f=oi();l=l===void 0?null:l;var m=f.memoizedState;return l!==null&&av(l,m[1])?m[0]:(f.memoizedState=[a,l],a)}function yE(a,l){var f=oi();l=l===void 0?null:l;var m=f.memoizedState;if(l!==null&&av(l,m[1]))return m[0];if(m=a(),ql){Ze(!0);try{a()}finally{Ze(!1)}}return f.memoizedState=[m,l],m}function vv(a,l,f){return f===void 0||(Fa&1073741824)!==0&&(Qt&261930)===0?a.memoizedState=l:(a.memoizedState=f,a=xA(),It.lanes|=a,ko|=a,f)}function xE(a,l,f,m){return Vr(f,l)?f:cc.current!==null?(a=vv(a,f,m),Vr(a,l)||(mi=!0),a):(Fa&42)===0||(Fa&1073741824)!==0&&(Qt&261930)===0?(mi=!0,a.memoizedState=f):(a=xA(),It.lanes|=a,ko|=a,l)}function bE(a,l,f,m,y){var T=F.p;F.p=T!==0&&8>T?T:8;var R=I.T,U={};I.T=U,bv(a,!1,l,f);try{var q=y(),de=I.S;if(de!==null&&de(U,q),q!==null&&typeof q=="object"&&typeof q.then=="function"){var we=DP(q,m);Pf(a,l,we,Xr(a))}else Pf(a,l,m,Xr(a))}catch(De){Pf(a,l,{then:function(){},status:"rejected",reason:De},Xr())}finally{F.p=T,R!==null&&U.types!==null&&(R.types=U.types),I.T=R}}function FP(){}function yv(a,l,f,m){if(a.tag!==5)throw Error(n(476));var y=SE(a).queue;bE(a,y,l,Y,f===null?FP:function(){return TE(a),f(m)})}function SE(a){var l=a.memoizedState;if(l!==null)return l;l={memoizedState:Y,baseState:Y,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:Y},next:null};var f={};return l.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:f},next:null},a.memoizedState=l,a=a.alternate,a!==null&&(a.memoizedState=l),l}function TE(a){var l=SE(a);l.next===null&&(l=a.alternate.memoizedState),Pf(a,l.next.queue,{},Xr())}function xv(){return zi(Kf)}function ME(){return oi().memoizedState}function EE(){return oi().memoizedState}function IP(a){for(var l=a.return;l!==null;){switch(l.tag){case 24:case 3:var f=Xr();a=Uo(f);var m=Oo(l,a,f);m!==null&&(Rr(m,l,f),Rf(m,l,f)),l={cache:Y0()},a.payload=l;return}l=l.return}}function zP(a,l,f){var m=Xr();f={lane:m,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},fm(a)?wE(l,f):(f=I0(a,l,f,m),f!==null&&(Rr(f,a,m),RE(f,l,m)))}function AE(a,l,f){var m=Xr();Pf(a,l,f,m)}function Pf(a,l,f,m){var y={lane:m,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if(fm(a))wE(l,y);else{var T=a.alternate;if(a.lanes===0&&(T===null||T.lanes===0)&&(T=l.lastRenderedReducer,T!==null))try{var R=l.lastRenderedState,U=T(R,f);if(y.hasEagerState=!0,y.eagerState=U,Vr(U,R))return $p(a,l,y,0),Pn===null&&Wp(),!1}catch{}finally{}if(f=I0(a,l,y,m),f!==null)return Rr(f,a,m),RE(f,l,m),!0}return!1}function bv(a,l,f,m){if(m={lane:2,revertLane:Jv(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},fm(a)){if(l)throw Error(n(479))}else l=I0(a,f,m,2),l!==null&&Rr(l,a,2)}function fm(a){var l=a.alternate;return a===It||l!==null&&l===It}function wE(a,l){hc=sm=!0;var f=a.pending;f===null?l.next=l:(l.next=f.next,f.next=l),a.pending=l}function RE(a,l,f){if((f&4194048)!==0){var m=l.lanes;m&=a.pendingLanes,f|=m,l.lanes=f,ju(a,f)}}var Uf={readContext:zi,use:lm,useCallback:ni,useContext:ni,useEffect:ni,useImperativeHandle:ni,useLayoutEffect:ni,useInsertionEffect:ni,useMemo:ni,useReducer:ni,useRef:ni,useState:ni,useDebugValue:ni,useDeferredValue:ni,useTransition:ni,useSyncExternalStore:ni,useId:ni,useHostTransitionStatus:ni,useFormState:ni,useActionState:ni,useOptimistic:ni,useMemoCache:ni,useCacheRefresh:ni};Uf.useEffectEvent=ni;var CE={readContext:zi,use:lm,useCallback:function(a,l){return ur().memoizedState=[a,l===void 0?null:l],a},useContext:zi,useEffect:fE,useImperativeHandle:function(a,l,f){f=f!=null?f.concat([a]):null,cm(4194308,4,gE.bind(null,l,a),f)},useLayoutEffect:function(a,l){return cm(4194308,4,a,l)},useInsertionEffect:function(a,l){cm(4,2,a,l)},useMemo:function(a,l){var f=ur();l=l===void 0?null:l;var m=a();if(ql){Ze(!0);try{a()}finally{Ze(!1)}}return f.memoizedState=[m,l],m},useReducer:function(a,l,f){var m=ur();if(f!==void 0){var y=f(l);if(ql){Ze(!0);try{f(l)}finally{Ze(!1)}}}else y=l;return m.memoizedState=m.baseState=y,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:y},m.queue=a,a=a.dispatch=zP.bind(null,It,a),[m.memoizedState,a]},useRef:function(a){var l=ur();return a={current:a},l.memoizedState=a},useState:function(a){a=pv(a);var l=a.queue,f=AE.bind(null,It,l);return l.dispatch=f,[a.memoizedState,f]},useDebugValue:_v,useDeferredValue:function(a,l){var f=ur();return vv(f,a,l)},useTransition:function(){var a=pv(!1);return a=bE.bind(null,It,a.queue,!0,!1),ur().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,l,f){var m=It,y=ur();if(en){if(f===void 0)throw Error(n(407));f=f()}else{if(f=l(),Pn===null)throw Error(n(349));(Qt&127)!==0||KM(m,l,f)}y.memoizedState=f;var T={value:f,getSnapshot:l};return y.queue=T,fE(QM.bind(null,m,T,a),[a]),m.flags|=2048,dc(9,{destroy:void 0},ZM.bind(null,m,T,f,l),null),f},useId:function(){var a=ur(),l=Pn.identifierPrefix;if(en){var f=qs,m=$s;f=(m&~(1<<32-Xe(m)-1)).toString(32)+f,l="_"+l+"R_"+f,f=am++,0<f&&(l+="H"+f.toString(32)),l+="_"}else f=LP++,l="_"+l+"r_"+f.toString(32)+"_";return a.memoizedState=l},useHostTransitionStatus:xv,useFormState:oE,useActionState:oE,useOptimistic:function(a){var l=ur();l.memoizedState=l.baseState=a;var f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=f,l=bv.bind(null,It,!0,f),f.dispatch=l,[a,l]},useMemoCache:hv,useCacheRefresh:function(){return ur().memoizedState=IP.bind(null,It)},useEffectEvent:function(a){var l=ur(),f={impl:a};return l.memoizedState=f,function(){if((pn&2)!==0)throw Error(n(440));return f.impl.apply(void 0,arguments)}}},Sv={readContext:zi,use:lm,useCallback:vE,useContext:zi,useEffect:gv,useImperativeHandle:_E,useInsertionEffect:pE,useLayoutEffect:mE,useMemo:yE,useReducer:um,useRef:hE,useState:function(){return um(Ia)},useDebugValue:_v,useDeferredValue:function(a,l){var f=oi();return xE(f,Cn.memoizedState,a,l)},useTransition:function(){var a=um(Ia)[0],l=oi().memoizedState;return[typeof a=="boolean"?a:Lf(a),l]},useSyncExternalStore:YM,useId:ME,useHostTransitionStatus:xv,useFormState:lE,useActionState:lE,useOptimistic:function(a,l){var f=oi();return tE(f,Cn,a,l)},useMemoCache:hv,useCacheRefresh:EE};Sv.useEffectEvent=dE;var NE={readContext:zi,use:lm,useCallback:vE,useContext:zi,useEffect:gv,useImperativeHandle:_E,useInsertionEffect:pE,useLayoutEffect:mE,useMemo:yE,useReducer:dv,useRef:hE,useState:function(){return dv(Ia)},useDebugValue:_v,useDeferredValue:function(a,l){var f=oi();return Cn===null?vv(f,a,l):xE(f,Cn.memoizedState,a,l)},useTransition:function(){var a=dv(Ia)[0],l=oi().memoizedState;return[typeof a=="boolean"?a:Lf(a),l]},useSyncExternalStore:YM,useId:ME,useHostTransitionStatus:xv,useFormState:cE,useActionState:cE,useOptimistic:function(a,l){var f=oi();return Cn!==null?tE(f,Cn,a,l):(f.baseState=a,[a,f.queue.dispatch])},useMemoCache:hv,useCacheRefresh:EE};NE.useEffectEvent=dE;function Tv(a,l,f,m){l=a.memoizedState,f=f(m,l),f=f==null?l:p({},l,f),a.memoizedState=f,a.lanes===0&&(a.updateQueue.baseState=f)}var Mv={enqueueSetState:function(a,l,f){a=a._reactInternals;var m=Xr(),y=Uo(m);y.payload=l,f!=null&&(y.callback=f),l=Oo(a,y,m),l!==null&&(Rr(l,a,m),Rf(l,a,m))},enqueueReplaceState:function(a,l,f){a=a._reactInternals;var m=Xr(),y=Uo(m);y.tag=1,y.payload=l,f!=null&&(y.callback=f),l=Oo(a,y,m),l!==null&&(Rr(l,a,m),Rf(l,a,m))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var f=Xr(),m=Uo(f);m.tag=2,l!=null&&(m.callback=l),l=Oo(a,m,f),l!==null&&(Rr(l,a,f),Rf(l,a,f))}};function DE(a,l,f,m,y,T,R){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(m,T,R):l.prototype&&l.prototype.isPureReactComponent?!xf(f,m)||!xf(y,T):!0}function LE(a,l,f,m){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(f,m),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(f,m),l.state!==a&&Mv.enqueueReplaceState(l,l.state,null)}function Xl(a,l){var f=l;if("ref"in l){f={};for(var m in l)m!=="ref"&&(f[m]=l[m])}if(a=a.defaultProps){f===l&&(f=p({},f));for(var y in a)f[y]===void 0&&(f[y]=a[y])}return f}function PE(a){jp(a)}function UE(a){console.error(a)}function OE(a){jp(a)}function dm(a,l){try{var f=a.onUncaughtError;f(l.value,{componentStack:l.stack})}catch(m){setTimeout(function(){throw m})}}function BE(a,l,f){try{var m=a.onCaughtError;m(f.value,{componentStack:f.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(y){setTimeout(function(){throw y})}}function Ev(a,l,f){return f=Uo(f),f.tag=3,f.payload={element:null},f.callback=function(){dm(a,l)},f}function FE(a){return a=Uo(a),a.tag=3,a}function IE(a,l,f,m){var y=f.type.getDerivedStateFromError;if(typeof y=="function"){var T=m.value;a.payload=function(){return y(T)},a.callback=function(){BE(l,f,m)}}var R=f.stateNode;R!==null&&typeof R.componentDidCatch=="function"&&(a.callback=function(){BE(l,f,m),typeof y!="function"&&(Go===null?Go=new Set([this]):Go.add(this));var U=m.stack;this.componentDidCatch(m.value,{componentStack:U!==null?U:""})})}function kP(a,l,f,m,y){if(f.flags|=32768,m!==null&&typeof m=="object"&&typeof m.then=="function"){if(l=f.alternate,l!==null&&sc(l,f,y,!0),f=jr.current,f!==null){switch(f.tag){case 31:case 13:return cs===null?Em():f.alternate===null&&ii===0&&(ii=3),f.flags&=-257,f.flags|=65536,f.lanes=y,m===em?f.flags|=16384:(l=f.updateQueue,l===null?f.updateQueue=new Set([m]):l.add(m),Kv(a,m,y)),!1;case 22:return f.flags|=65536,m===em?f.flags|=16384:(l=f.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([m])},f.updateQueue=l):(f=l.retryQueue,f===null?l.retryQueue=new Set([m]):f.add(m)),Kv(a,m,y)),!1}throw Error(n(435,f.tag))}return Kv(a,m,y),Em(),!1}if(en)return l=jr.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=y,m!==j0&&(a=Error(n(422),{cause:m}),Tf(as(a,f)))):(m!==j0&&(l=Error(n(423),{cause:m}),Tf(as(l,f))),a=a.current.alternate,a.flags|=65536,y&=-y,a.lanes|=y,m=as(m,f),y=Ev(a.stateNode,m,y),tv(a,y),ii!==4&&(ii=2)),!1;var T=Error(n(520),{cause:m});if(T=as(T,f),Vf===null?Vf=[T]:Vf.push(T),ii!==4&&(ii=2),l===null)return!0;m=as(m,f),f=l;do{switch(f.tag){case 3:return f.flags|=65536,a=y&-y,f.lanes|=a,a=Ev(f.stateNode,m,a),tv(f,a),!1;case 1:if(l=f.type,T=f.stateNode,(f.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||T!==null&&typeof T.componentDidCatch=="function"&&(Go===null||!Go.has(T))))return f.flags|=65536,y&=-y,f.lanes|=y,y=FE(y),IE(y,a,f,m),tv(f,y),!1}f=f.return}while(f!==null);return!1}var Av=Error(n(461)),mi=!1;function ki(a,l,f,m){l.child=a===null?VM(l,null,f,m):$l(l,a.child,f,m)}function zE(a,l,f,m,y){f=f.render;var T=l.ref;if("ref"in m){var R={};for(var U in m)U!=="ref"&&(R[U]=m[U])}else R=m;return Vl(l),m=ov(a,l,f,R,T,y),U=lv(),a!==null&&!mi?(uv(a,l,y),za(a,l,y)):(en&&U&&V0(l),l.flags|=1,ki(a,l,m,y),l.child)}function kE(a,l,f,m,y){if(a===null){var T=f.type;return typeof T=="function"&&!z0(T)&&T.defaultProps===void 0&&f.compare===null?(l.tag=15,l.type=T,GE(a,l,T,m,y)):(a=Xp(f.type,null,m,l,l.mode,y),a.ref=l.ref,a.return=l,l.child=a)}if(T=a.child,!Uv(a,y)){var R=T.memoizedProps;if(f=f.compare,f=f!==null?f:xf,f(R,m)&&a.ref===l.ref)return za(a,l,y)}return l.flags|=1,a=Pa(T,m),a.ref=l.ref,a.return=l,l.child=a}function GE(a,l,f,m,y){if(a!==null){var T=a.memoizedProps;if(xf(T,m)&&a.ref===l.ref)if(mi=!1,l.pendingProps=m=T,Uv(a,y))(a.flags&131072)!==0&&(mi=!0);else return l.lanes=a.lanes,za(a,l,y)}return wv(a,l,f,m,y)}function VE(a,l,f,m){var y=m.children,T=a!==null?a.memoizedState:null;if(a===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.mode==="hidden"){if((l.flags&128)!==0){if(T=T!==null?T.baseLanes|f:f,a!==null){for(m=l.child=a.child,y=0;m!==null;)y=y|m.lanes|m.childLanes,m=m.sibling;m=y&~T}else m=0,l.child=null;return HE(a,l,T,f,m)}if((f&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},a!==null&&Qp(l,T!==null?T.cachePool:null),T!==null?WM(l,T):iv(),$M(l);else return m=l.lanes=536870912,HE(a,l,T!==null?T.baseLanes|f:f,f,m)}else T!==null?(Qp(l,T.cachePool),WM(l,T),Fo(),l.memoizedState=null):(a!==null&&Qp(l,null),iv(),Fo());return ki(a,l,y,f),l.child}function Of(a,l){return a!==null&&a.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function HE(a,l,f,m,y){var T=Z0();return T=T===null?null:{parent:di._currentValue,pool:T},l.memoizedState={baseLanes:f,cachePool:T},a!==null&&Qp(l,null),iv(),$M(l),a!==null&&sc(a,l,m,!0),l.childLanes=y,null}function pm(a,l){return l=gm({mode:l.mode,children:l.children},a.mode),l.ref=a.ref,a.child=l,l.return=a,l}function jE(a,l,f){return $l(l,a.child,null,f),a=pm(l,l.pendingProps),a.flags|=2,Wr(l),l.memoizedState=null,a}function GP(a,l,f){var m=l.pendingProps,y=(l.flags&128)!==0;if(l.flags&=-129,a===null){if(en){if(m.mode==="hidden")return a=pm(l,m),l.lanes=536870912,Of(null,a);if(sv(l),(a=Vn)?(a=n1(a,us),a=a!==null&&a.data==="&"?a:null,a!==null&&(l.memoizedState={dehydrated:a,treeContext:Co!==null?{id:$s,overflow:qs}:null,retryLane:536870912,hydrationErrors:null},f=wM(a),f.return=l,l.child=f,Ii=l,Vn=null)):a=null,a===null)throw Do(l);return l.lanes=536870912,null}return pm(l,m)}var T=a.memoizedState;if(T!==null){var R=T.dehydrated;if(sv(l),y)if(l.flags&256)l.flags&=-257,l=jE(a,l,f);else if(l.memoizedState!==null)l.child=a.child,l.flags|=128,l=null;else throw Error(n(558));else if(mi||sc(a,l,f,!1),y=(f&a.childLanes)!==0,mi||y){if(m=Pn,m!==null&&(R=Pp(m,f),R!==0&&R!==T.retryLane))throw T.retryLane=R,Il(a,R),Rr(m,a,R),Av;Em(),l=jE(a,l,f)}else a=T.treeContext,Vn=hs(R.nextSibling),Ii=l,en=!0,No=null,us=!1,a!==null&&NM(l,a),l=pm(l,m),l.flags|=4096;return l}return a=Pa(a.child,{mode:m.mode,children:m.children}),a.ref=l.ref,l.child=a,a.return=l,a}function mm(a,l){var f=l.ref;if(f===null)a!==null&&a.ref!==null&&(l.flags|=4194816);else{if(typeof f!="function"&&typeof f!="object")throw Error(n(284));(a===null||a.ref!==f)&&(l.flags|=4194816)}}function wv(a,l,f,m,y){return Vl(l),f=ov(a,l,f,m,void 0,y),m=lv(),a!==null&&!mi?(uv(a,l,y),za(a,l,y)):(en&&m&&V0(l),l.flags|=1,ki(a,l,f,y),l.child)}function WE(a,l,f,m,y,T){return Vl(l),l.updateQueue=null,f=XM(l,m,f,y),qM(a),m=lv(),a!==null&&!mi?(uv(a,l,T),za(a,l,T)):(en&&m&&V0(l),l.flags|=1,ki(a,l,f,T),l.child)}function $E(a,l,f,m,y){if(Vl(l),l.stateNode===null){var T=tc,R=f.contextType;typeof R=="object"&&R!==null&&(T=zi(R)),T=new f(m,T),l.memoizedState=T.state!==null&&T.state!==void 0?T.state:null,T.updater=Mv,l.stateNode=T,T._reactInternals=l,T=l.stateNode,T.props=m,T.state=l.memoizedState,T.refs={},J0(l),R=f.contextType,T.context=typeof R=="object"&&R!==null?zi(R):tc,T.state=l.memoizedState,R=f.getDerivedStateFromProps,typeof R=="function"&&(Tv(l,f,R,m),T.state=l.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof T.getSnapshotBeforeUpdate=="function"||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(R=T.state,typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount(),R!==T.state&&Mv.enqueueReplaceState(T,T.state,null),Nf(l,m,T,y),Cf(),T.state=l.memoizedState),typeof T.componentDidMount=="function"&&(l.flags|=4194308),m=!0}else if(a===null){T=l.stateNode;var U=l.memoizedProps,q=Xl(f,U);T.props=q;var de=T.context,we=f.contextType;R=tc,typeof we=="object"&&we!==null&&(R=zi(we));var De=f.getDerivedStateFromProps;we=typeof De=="function"||typeof T.getSnapshotBeforeUpdate=="function",U=l.pendingProps!==U,we||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(U||de!==R)&&LE(l,T,m,R),Po=!1;var me=l.memoizedState;T.state=me,Nf(l,m,T,y),Cf(),de=l.memoizedState,U||me!==de||Po?(typeof De=="function"&&(Tv(l,f,De,m),de=l.memoizedState),(q=Po||DE(l,f,q,m,me,de,R))?(we||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount()),typeof T.componentDidMount=="function"&&(l.flags|=4194308)):(typeof T.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=m,l.memoizedState=de),T.props=m,T.state=de,T.context=R,m=q):(typeof T.componentDidMount=="function"&&(l.flags|=4194308),m=!1)}else{T=l.stateNode,ev(a,l),R=l.memoizedProps,we=Xl(f,R),T.props=we,De=l.pendingProps,me=T.context,de=f.contextType,q=tc,typeof de=="object"&&de!==null&&(q=zi(de)),U=f.getDerivedStateFromProps,(de=typeof U=="function"||typeof T.getSnapshotBeforeUpdate=="function")||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(R!==De||me!==q)&&LE(l,T,m,q),Po=!1,me=l.memoizedState,T.state=me,Nf(l,m,T,y),Cf();var _e=l.memoizedState;R!==De||me!==_e||Po||a!==null&&a.dependencies!==null&&Kp(a.dependencies)?(typeof U=="function"&&(Tv(l,f,U,m),_e=l.memoizedState),(we=Po||DE(l,f,we,m,me,_e,q)||a!==null&&a.dependencies!==null&&Kp(a.dependencies))?(de||typeof T.UNSAFE_componentWillUpdate!="function"&&typeof T.componentWillUpdate!="function"||(typeof T.componentWillUpdate=="function"&&T.componentWillUpdate(m,_e,q),typeof T.UNSAFE_componentWillUpdate=="function"&&T.UNSAFE_componentWillUpdate(m,_e,q)),typeof T.componentDidUpdate=="function"&&(l.flags|=4),typeof T.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof T.componentDidUpdate!="function"||R===a.memoizedProps&&me===a.memoizedState||(l.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||R===a.memoizedProps&&me===a.memoizedState||(l.flags|=1024),l.memoizedProps=m,l.memoizedState=_e),T.props=m,T.state=_e,T.context=q,m=we):(typeof T.componentDidUpdate!="function"||R===a.memoizedProps&&me===a.memoizedState||(l.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||R===a.memoizedProps&&me===a.memoizedState||(l.flags|=1024),m=!1)}return T=m,mm(a,l),m=(l.flags&128)!==0,T||m?(T=l.stateNode,f=m&&typeof f.getDerivedStateFromError!="function"?null:T.render(),l.flags|=1,a!==null&&m?(l.child=$l(l,a.child,null,y),l.child=$l(l,null,f,y)):ki(a,l,f,y),l.memoizedState=T.state,a=l.child):a=za(a,l,y),a}function qE(a,l,f,m){return kl(),l.flags|=256,ki(a,l,f,m),l.child}var Rv={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Cv(a){return{baseLanes:a,cachePool:BM()}}function Nv(a,l,f){return a=a!==null?a.childLanes&~f:0,l&&(a|=qr),a}function XE(a,l,f){var m=l.pendingProps,y=!1,T=(l.flags&128)!==0,R;if((R=T)||(R=a!==null&&a.memoizedState===null?!1:(ai.current&2)!==0),R&&(y=!0,l.flags&=-129),R=(l.flags&32)!==0,l.flags&=-33,a===null){if(en){if(y?Bo(l):Fo(),(a=Vn)?(a=n1(a,us),a=a!==null&&a.data!=="&"?a:null,a!==null&&(l.memoizedState={dehydrated:a,treeContext:Co!==null?{id:$s,overflow:qs}:null,retryLane:536870912,hydrationErrors:null},f=wM(a),f.return=l,l.child=f,Ii=l,Vn=null)):a=null,a===null)throw Do(l);return fy(a)?l.lanes=32:l.lanes=536870912,null}var U=m.children;return m=m.fallback,y?(Fo(),y=l.mode,U=gm({mode:"hidden",children:U},y),m=zl(m,y,f,null),U.return=l,m.return=l,U.sibling=m,l.child=U,m=l.child,m.memoizedState=Cv(f),m.childLanes=Nv(a,R,f),l.memoizedState=Rv,Of(null,m)):(Bo(l),Dv(l,U))}var q=a.memoizedState;if(q!==null&&(U=q.dehydrated,U!==null)){if(T)l.flags&256?(Bo(l),l.flags&=-257,l=Lv(a,l,f)):l.memoizedState!==null?(Fo(),l.child=a.child,l.flags|=128,l=null):(Fo(),U=m.fallback,y=l.mode,m=gm({mode:"visible",children:m.children},y),U=zl(U,y,f,null),U.flags|=2,m.return=l,U.return=l,m.sibling=U,l.child=m,$l(l,a.child,null,f),m=l.child,m.memoizedState=Cv(f),m.childLanes=Nv(a,R,f),l.memoizedState=Rv,l=Of(null,m));else if(Bo(l),fy(U)){if(R=U.nextSibling&&U.nextSibling.dataset,R)var de=R.dgst;R=de,m=Error(n(419)),m.stack="",m.digest=R,Tf({value:m,source:null,stack:null}),l=Lv(a,l,f)}else if(mi||sc(a,l,f,!1),R=(f&a.childLanes)!==0,mi||R){if(R=Pn,R!==null&&(m=Pp(R,f),m!==0&&m!==q.retryLane))throw q.retryLane=m,Il(a,m),Rr(R,a,m),Av;hy(U)||Em(),l=Lv(a,l,f)}else hy(U)?(l.flags|=192,l.child=a.child,l=null):(a=q.treeContext,Vn=hs(U.nextSibling),Ii=l,en=!0,No=null,us=!1,a!==null&&NM(l,a),l=Dv(l,m.children),l.flags|=4096);return l}return y?(Fo(),U=m.fallback,y=l.mode,q=a.child,de=q.sibling,m=Pa(q,{mode:"hidden",children:m.children}),m.subtreeFlags=q.subtreeFlags&65011712,de!==null?U=Pa(de,U):(U=zl(U,y,f,null),U.flags|=2),U.return=l,m.return=l,m.sibling=U,l.child=m,Of(null,m),m=l.child,U=a.child.memoizedState,U===null?U=Cv(f):(y=U.cachePool,y!==null?(q=di._currentValue,y=y.parent!==q?{parent:q,pool:q}:y):y=BM(),U={baseLanes:U.baseLanes|f,cachePool:y}),m.memoizedState=U,m.childLanes=Nv(a,R,f),l.memoizedState=Rv,Of(a.child,m)):(Bo(l),f=a.child,a=f.sibling,f=Pa(f,{mode:"visible",children:m.children}),f.return=l,f.sibling=null,a!==null&&(R=l.deletions,R===null?(l.deletions=[a],l.flags|=16):R.push(a)),l.child=f,l.memoizedState=null,f)}function Dv(a,l){return l=gm({mode:"visible",children:l},a.mode),l.return=a,a.child=l}function gm(a,l){return a=Hr(22,a,null,l),a.lanes=0,a}function Lv(a,l,f){return $l(l,a.child,null,f),a=Dv(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function YE(a,l,f){a.lanes|=l;var m=a.alternate;m!==null&&(m.lanes|=l),q0(a.return,l,f)}function Pv(a,l,f,m,y,T){var R=a.memoizedState;R===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:m,tail:f,tailMode:y,treeForkCount:T}:(R.isBackwards=l,R.rendering=null,R.renderingStartTime=0,R.last=m,R.tail=f,R.tailMode=y,R.treeForkCount=T)}function KE(a,l,f){var m=l.pendingProps,y=m.revealOrder,T=m.tail;m=m.children;var R=ai.current,U=(R&2)!==0;if(U?(R=R&1|2,l.flags|=128):R&=1,ce(ai,R),ki(a,l,m,f),m=en?Sf:0,!U&&a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&YE(a,f,l);else if(a.tag===19)YE(a,f,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}switch(y){case"forwards":for(f=l.child,y=null;f!==null;)a=f.alternate,a!==null&&rm(a)===null&&(y=f),f=f.sibling;f=y,f===null?(y=l.child,l.child=null):(y=f.sibling,f.sibling=null),Pv(l,!1,y,f,T,m);break;case"backwards":case"unstable_legacy-backwards":for(f=null,y=l.child,l.child=null;y!==null;){if(a=y.alternate,a!==null&&rm(a)===null){l.child=y;break}a=y.sibling,y.sibling=f,f=y,y=a}Pv(l,!0,f,null,T,m);break;case"together":Pv(l,!1,null,null,void 0,m);break;default:l.memoizedState=null}return l.child}function za(a,l,f){if(a!==null&&(l.dependencies=a.dependencies),ko|=l.lanes,(f&l.childLanes)===0)if(a!==null){if(sc(a,l,f,!1),(f&l.childLanes)===0)return null}else return null;if(a!==null&&l.child!==a.child)throw Error(n(153));if(l.child!==null){for(a=l.child,f=Pa(a,a.pendingProps),l.child=f,f.return=l;a.sibling!==null;)a=a.sibling,f=f.sibling=Pa(a,a.pendingProps),f.return=l;f.sibling=null}return l.child}function Uv(a,l){return(a.lanes&l)!==0?!0:(a=a.dependencies,!!(a!==null&&Kp(a)))}function VP(a,l,f){switch(l.tag){case 3:Ee(l,l.stateNode.containerInfo),Lo(l,di,a.memoizedState.cache),kl();break;case 27:case 5:We(l);break;case 4:Ee(l,l.stateNode.containerInfo);break;case 10:Lo(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,sv(l),null;break;case 13:var m=l.memoizedState;if(m!==null)return m.dehydrated!==null?(Bo(l),l.flags|=128,null):(f&l.child.childLanes)!==0?XE(a,l,f):(Bo(l),a=za(a,l,f),a!==null?a.sibling:null);Bo(l);break;case 19:var y=(a.flags&128)!==0;if(m=(f&l.childLanes)!==0,m||(sc(a,l,f,!1),m=(f&l.childLanes)!==0),y){if(m)return KE(a,l,f);l.flags|=128}if(y=l.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),ce(ai,ai.current),m)break;return null;case 22:return l.lanes=0,VE(a,l,f,l.pendingProps);case 24:Lo(l,di,a.memoizedState.cache)}return za(a,l,f)}function ZE(a,l,f){if(a!==null)if(a.memoizedProps!==l.pendingProps)mi=!0;else{if(!Uv(a,f)&&(l.flags&128)===0)return mi=!1,VP(a,l,f);mi=(a.flags&131072)!==0}else mi=!1,en&&(l.flags&1048576)!==0&&CM(l,Sf,l.index);switch(l.lanes=0,l.tag){case 16:e:{var m=l.pendingProps;if(a=jl(l.elementType),l.type=a,typeof a=="function")z0(a)?(m=Xl(a,m),l.tag=1,l=$E(null,l,a,m,f)):(l.tag=0,l=wv(null,l,a,m,f));else{if(a!=null){var y=a.$$typeof;if(y===w){l.tag=11,l=zE(null,l,a,m,f);break e}else if(y===N){l.tag=14,l=kE(null,l,a,m,f);break e}}throw l=te(a)||a,Error(n(306,l,""))}}return l;case 0:return wv(a,l,l.type,l.pendingProps,f);case 1:return m=l.type,y=Xl(m,l.pendingProps),$E(a,l,m,y,f);case 3:e:{if(Ee(l,l.stateNode.containerInfo),a===null)throw Error(n(387));m=l.pendingProps;var T=l.memoizedState;y=T.element,ev(a,l),Nf(l,m,null,f);var R=l.memoizedState;if(m=R.cache,Lo(l,di,m),m!==T.cache&&X0(l,[di],f,!0),Cf(),m=R.element,T.isDehydrated)if(T={element:m,isDehydrated:!1,cache:R.cache},l.updateQueue.baseState=T,l.memoizedState=T,l.flags&256){l=qE(a,l,m,f);break e}else if(m!==y){y=as(Error(n(424)),l),Tf(y),l=qE(a,l,m,f);break e}else{switch(a=l.stateNode.containerInfo,a.nodeType){case 9:a=a.body;break;default:a=a.nodeName==="HTML"?a.ownerDocument.body:a}for(Vn=hs(a.firstChild),Ii=l,en=!0,No=null,us=!0,f=VM(l,null,m,f),l.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling}else{if(kl(),m===y){l=za(a,l,f);break e}ki(a,l,m,f)}l=l.child}return l;case 26:return mm(a,l),a===null?(f=l1(l.type,null,l.pendingProps,null))?l.memoizedState=f:en||(f=l.type,a=l.pendingProps,m=Lm($.current).createElement(f),m[ci]=l,m[Ti]=a,Gi(m,f,a),ne(m),l.stateNode=m):l.memoizedState=l1(l.type,a.memoizedProps,l.pendingProps,a.memoizedState),null;case 27:return We(l),a===null&&en&&(m=l.stateNode=s1(l.type,l.pendingProps,$.current),Ii=l,us=!0,y=Vn,Wo(l.type)?(dy=y,Vn=hs(m.firstChild)):Vn=y),ki(a,l,l.pendingProps.children,f),mm(a,l),a===null&&(l.flags|=4194304),l.child;case 5:return a===null&&en&&((y=m=Vn)&&(m=vU(m,l.type,l.pendingProps,us),m!==null?(l.stateNode=m,Ii=l,Vn=hs(m.firstChild),us=!1,y=!0):y=!1),y||Do(l)),We(l),y=l.type,T=l.pendingProps,R=a!==null?a.memoizedProps:null,m=T.children,ly(y,T)?m=null:R!==null&&ly(y,R)&&(l.flags|=32),l.memoizedState!==null&&(y=ov(a,l,PP,null,null,f),Kf._currentValue=y),mm(a,l),ki(a,l,m,f),l.child;case 6:return a===null&&en&&((a=f=Vn)&&(f=yU(f,l.pendingProps,us),f!==null?(l.stateNode=f,Ii=l,Vn=null,a=!0):a=!1),a||Do(l)),null;case 13:return XE(a,l,f);case 4:return Ee(l,l.stateNode.containerInfo),m=l.pendingProps,a===null?l.child=$l(l,null,m,f):ki(a,l,m,f),l.child;case 11:return zE(a,l,l.type,l.pendingProps,f);case 7:return ki(a,l,l.pendingProps,f),l.child;case 8:return ki(a,l,l.pendingProps.children,f),l.child;case 12:return ki(a,l,l.pendingProps.children,f),l.child;case 10:return m=l.pendingProps,Lo(l,l.type,m.value),ki(a,l,m.children,f),l.child;case 9:return y=l.type._context,m=l.pendingProps.children,Vl(l),y=zi(y),m=m(y),l.flags|=1,ki(a,l,m,f),l.child;case 14:return kE(a,l,l.type,l.pendingProps,f);case 15:return GE(a,l,l.type,l.pendingProps,f);case 19:return KE(a,l,f);case 31:return GP(a,l,f);case 22:return VE(a,l,f,l.pendingProps);case 24:return Vl(l),m=zi(di),a===null?(y=Z0(),y===null&&(y=Pn,T=Y0(),y.pooledCache=T,T.refCount++,T!==null&&(y.pooledCacheLanes|=f),y=T),l.memoizedState={parent:m,cache:y},J0(l),Lo(l,di,y)):((a.lanes&f)!==0&&(ev(a,l),Nf(l,null,null,f),Cf()),y=a.memoizedState,T=l.memoizedState,y.parent!==m?(y={parent:m,cache:m},l.memoizedState=y,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=y),Lo(l,di,m)):(m=T.cache,Lo(l,di,m),m!==y.cache&&X0(l,[di],f,!0))),ki(a,l,l.pendingProps.children,f),l.child;case 29:throw l.pendingProps}throw Error(n(156,l.tag))}function ka(a){a.flags|=4}function Ov(a,l,f,m,y){if((l=(a.mode&32)!==0)&&(l=!1),l){if(a.flags|=16777216,(y&335544128)===y)if(a.stateNode.complete)a.flags|=8192;else if(MA())a.flags|=8192;else throw Wl=em,Q0}else a.flags&=-16777217}function QE(a,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)a.flags&=-16777217;else if(a.flags|=16777216,!d1(l))if(MA())a.flags|=8192;else throw Wl=em,Q0}function _m(a,l){l!==null&&(a.flags|=4),a.flags&16384&&(l=a.tag!==22?Mn():536870912,a.lanes|=l,_c|=l)}function Bf(a,l){if(!en)switch(a.tailMode){case"hidden":l=a.tail;for(var f=null;l!==null;)l.alternate!==null&&(f=l),l=l.sibling;f===null?a.tail=null:f.sibling=null;break;case"collapsed":f=a.tail;for(var m=null;f!==null;)f.alternate!==null&&(m=f),f=f.sibling;m===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:m.sibling=null}}function Hn(a){var l=a.alternate!==null&&a.alternate.child===a.child,f=0,m=0;if(l)for(var y=a.child;y!==null;)f|=y.lanes|y.childLanes,m|=y.subtreeFlags&65011712,m|=y.flags&65011712,y.return=a,y=y.sibling;else for(y=a.child;y!==null;)f|=y.lanes|y.childLanes,m|=y.subtreeFlags,m|=y.flags,y.return=a,y=y.sibling;return a.subtreeFlags|=m,a.childLanes=f,l}function HP(a,l,f){var m=l.pendingProps;switch(H0(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Hn(l),null;case 1:return Hn(l),null;case 3:return f=l.stateNode,m=null,a!==null&&(m=a.memoizedState.cache),l.memoizedState.cache!==m&&(l.flags|=2048),Ba(di),ke(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(a===null||a.child===null)&&(rc(l)?ka(l):a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,W0())),Hn(l),null;case 26:var y=l.type,T=l.memoizedState;return a===null?(ka(l),T!==null?(Hn(l),QE(l,T)):(Hn(l),Ov(l,y,null,m,f))):T?T!==a.memoizedState?(ka(l),Hn(l),QE(l,T)):(Hn(l),l.flags&=-16777217):(a=a.memoizedProps,a!==m&&ka(l),Hn(l),Ov(l,y,a,m,f)),null;case 27:if(Ke(l),f=$.current,y=l.type,a!==null&&l.stateNode!=null)a.memoizedProps!==m&&ka(l);else{if(!m){if(l.stateNode===null)throw Error(n(166));return Hn(l),null}a=Le.current,rc(l)?DM(l):(a=s1(y,m,f),l.stateNode=a,ka(l))}return Hn(l),null;case 5:if(Ke(l),y=l.type,a!==null&&l.stateNode!=null)a.memoizedProps!==m&&ka(l);else{if(!m){if(l.stateNode===null)throw Error(n(166));return Hn(l),null}if(T=Le.current,rc(l))DM(l);else{var R=Lm($.current);switch(T){case 1:T=R.createElementNS("http://www.w3.org/2000/svg",y);break;case 2:T=R.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;default:switch(y){case"svg":T=R.createElementNS("http://www.w3.org/2000/svg",y);break;case"math":T=R.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;case"script":T=R.createElement("div"),T.innerHTML="<script><\/script>",T=T.removeChild(T.firstChild);break;case"select":T=typeof m.is=="string"?R.createElement("select",{is:m.is}):R.createElement("select"),m.multiple?T.multiple=!0:m.size&&(T.size=m.size);break;default:T=typeof m.is=="string"?R.createElement(y,{is:m.is}):R.createElement(y)}}T[ci]=l,T[Ti]=m;e:for(R=l.child;R!==null;){if(R.tag===5||R.tag===6)T.appendChild(R.stateNode);else if(R.tag!==4&&R.tag!==27&&R.child!==null){R.child.return=R,R=R.child;continue}if(R===l)break e;for(;R.sibling===null;){if(R.return===null||R.return===l)break e;R=R.return}R.sibling.return=R.return,R=R.sibling}l.stateNode=T;e:switch(Gi(T,y,m),y){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&ka(l)}}return Hn(l),Ov(l,l.type,a===null?null:a.memoizedProps,l.pendingProps,f),null;case 6:if(a&&l.stateNode!=null)a.memoizedProps!==m&&ka(l);else{if(typeof m!="string"&&l.stateNode===null)throw Error(n(166));if(a=$.current,rc(l)){if(a=l.stateNode,f=l.memoizedProps,m=null,y=Ii,y!==null)switch(y.tag){case 27:case 5:m=y.memoizedProps}a[ci]=l,a=!!(a.nodeValue===f||m!==null&&m.suppressHydrationWarning===!0||XA(a.nodeValue,f)),a||Do(l,!0)}else a=Lm(a).createTextNode(m),a[ci]=l,l.stateNode=a}return Hn(l),null;case 31:if(f=l.memoizedState,a===null||a.memoizedState!==null){if(m=rc(l),f!==null){if(a===null){if(!m)throw Error(n(318));if(a=l.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(557));a[ci]=l}else kl(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Hn(l),a=!1}else f=W0(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=f),a=!0;if(!a)return l.flags&256?(Wr(l),l):(Wr(l),null);if((l.flags&128)!==0)throw Error(n(558))}return Hn(l),null;case 13:if(m=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(y=rc(l),m!==null&&m.dehydrated!==null){if(a===null){if(!y)throw Error(n(318));if(y=l.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(n(317));y[ci]=l}else kl(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Hn(l),y=!1}else y=W0(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=y),y=!0;if(!y)return l.flags&256?(Wr(l),l):(Wr(l),null)}return Wr(l),(l.flags&128)!==0?(l.lanes=f,l):(f=m!==null,a=a!==null&&a.memoizedState!==null,f&&(m=l.child,y=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(y=m.alternate.memoizedState.cachePool.pool),T=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(T=m.memoizedState.cachePool.pool),T!==y&&(m.flags|=2048)),f!==a&&f&&(l.child.flags|=8192),_m(l,l.updateQueue),Hn(l),null);case 4:return ke(),a===null&&iy(l.stateNode.containerInfo),Hn(l),null;case 10:return Ba(l.type),Hn(l),null;case 19:if(W(ai),m=l.memoizedState,m===null)return Hn(l),null;if(y=(l.flags&128)!==0,T=m.rendering,T===null)if(y)Bf(m,!1);else{if(ii!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(T=rm(a),T!==null){for(l.flags|=128,Bf(m,!1),a=T.updateQueue,l.updateQueue=a,_m(l,a),l.subtreeFlags=0,a=f,f=l.child;f!==null;)AM(f,a),f=f.sibling;return ce(ai,ai.current&1|2),en&&Ua(l,m.treeForkCount),l.child}a=a.sibling}m.tail!==null&&P()>Sm&&(l.flags|=128,y=!0,Bf(m,!1),l.lanes=4194304)}else{if(!y)if(a=rm(T),a!==null){if(l.flags|=128,y=!0,a=a.updateQueue,l.updateQueue=a,_m(l,a),Bf(m,!0),m.tail===null&&m.tailMode==="hidden"&&!T.alternate&&!en)return Hn(l),null}else 2*P()-m.renderingStartTime>Sm&&f!==536870912&&(l.flags|=128,y=!0,Bf(m,!1),l.lanes=4194304);m.isBackwards?(T.sibling=l.child,l.child=T):(a=m.last,a!==null?a.sibling=T:l.child=T,m.last=T)}return m.tail!==null?(a=m.tail,m.rendering=a,m.tail=a.sibling,m.renderingStartTime=P(),a.sibling=null,f=ai.current,ce(ai,y?f&1|2:f&1),en&&Ua(l,m.treeForkCount),a):(Hn(l),null);case 22:case 23:return Wr(l),rv(),m=l.memoizedState!==null,a!==null?a.memoizedState!==null!==m&&(l.flags|=8192):m&&(l.flags|=8192),m?(f&536870912)!==0&&(l.flags&128)===0&&(Hn(l),l.subtreeFlags&6&&(l.flags|=8192)):Hn(l),f=l.updateQueue,f!==null&&_m(l,f.retryQueue),f=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(f=a.memoizedState.cachePool.pool),m=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),m!==f&&(l.flags|=2048),a!==null&&W(Hl),null;case 24:return f=null,a!==null&&(f=a.memoizedState.cache),l.memoizedState.cache!==f&&(l.flags|=2048),Ba(di),Hn(l),null;case 25:return null;case 30:return null}throw Error(n(156,l.tag))}function jP(a,l){switch(H0(l),l.tag){case 1:return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return Ba(di),ke(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 26:case 27:case 5:return Ke(l),null;case 31:if(l.memoizedState!==null){if(Wr(l),l.alternate===null)throw Error(n(340));kl()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 13:if(Wr(l),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(n(340));kl()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return W(ai),null;case 4:return ke(),null;case 10:return Ba(l.type),null;case 22:case 23:return Wr(l),rv(),a!==null&&W(Hl),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 24:return Ba(di),null;case 25:return null;default:return null}}function JE(a,l){switch(H0(l),l.tag){case 3:Ba(di),ke();break;case 26:case 27:case 5:Ke(l);break;case 4:ke();break;case 31:l.memoizedState!==null&&Wr(l);break;case 13:Wr(l);break;case 19:W(ai);break;case 10:Ba(l.type);break;case 22:case 23:Wr(l),rv(),a!==null&&W(Hl);break;case 24:Ba(di)}}function Ff(a,l){try{var f=l.updateQueue,m=f!==null?f.lastEffect:null;if(m!==null){var y=m.next;f=y;do{if((f.tag&a)===a){m=void 0;var T=f.create,R=f.inst;m=T(),R.destroy=m}f=f.next}while(f!==y)}}catch(U){An(l,l.return,U)}}function Io(a,l,f){try{var m=l.updateQueue,y=m!==null?m.lastEffect:null;if(y!==null){var T=y.next;m=T;do{if((m.tag&a)===a){var R=m.inst,U=R.destroy;if(U!==void 0){R.destroy=void 0,y=l;var q=f,de=U;try{de()}catch(we){An(y,q,we)}}}m=m.next}while(m!==T)}}catch(we){An(l,l.return,we)}}function eA(a){var l=a.updateQueue;if(l!==null){var f=a.stateNode;try{jM(l,f)}catch(m){An(a,a.return,m)}}}function tA(a,l,f){f.props=Xl(a.type,a.memoizedProps),f.state=a.memoizedState;try{f.componentWillUnmount()}catch(m){An(a,l,m)}}function If(a,l){try{var f=a.ref;if(f!==null){switch(a.tag){case 26:case 27:case 5:var m=a.stateNode;break;case 30:m=a.stateNode;break;default:m=a.stateNode}typeof f=="function"?a.refCleanup=f(m):f.current=m}}catch(y){An(a,l,y)}}function Xs(a,l){var f=a.ref,m=a.refCleanup;if(f!==null)if(typeof m=="function")try{m()}catch(y){An(a,l,y)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(y){An(a,l,y)}else f.current=null}function nA(a){var l=a.type,f=a.memoizedProps,m=a.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":f.autoFocus&&m.focus();break e;case"img":f.src?m.src=f.src:f.srcSet&&(m.srcset=f.srcSet)}}catch(y){An(a,a.return,y)}}function Bv(a,l,f){try{var m=a.stateNode;fU(m,a.type,f,l),m[Ti]=l}catch(y){An(a,a.return,y)}}function iA(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&Wo(a.type)||a.tag===4}function Fv(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||iA(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&Wo(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Iv(a,l,f){var m=a.tag;if(m===5||m===6)a=a.stateNode,l?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(a,l):(l=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,l.appendChild(a),f=f._reactRootContainer,f!=null||l.onclick!==null||(l.onclick=Da));else if(m!==4&&(m===27&&Wo(a.type)&&(f=a.stateNode,l=null),a=a.child,a!==null))for(Iv(a,l,f),a=a.sibling;a!==null;)Iv(a,l,f),a=a.sibling}function vm(a,l,f){var m=a.tag;if(m===5||m===6)a=a.stateNode,l?f.insertBefore(a,l):f.appendChild(a);else if(m!==4&&(m===27&&Wo(a.type)&&(f=a.stateNode),a=a.child,a!==null))for(vm(a,l,f),a=a.sibling;a!==null;)vm(a,l,f),a=a.sibling}function rA(a){var l=a.stateNode,f=a.memoizedProps;try{for(var m=a.type,y=l.attributes;y.length;)l.removeAttributeNode(y[0]);Gi(l,m,f),l[ci]=a,l[Ti]=f}catch(T){An(a,a.return,T)}}var Ga=!1,gi=!1,zv=!1,sA=typeof WeakSet=="function"?WeakSet:Set,Ci=null;function WP(a,l){if(a=a.containerInfo,ay=zm,a=_M(a),L0(a)){if("selectionStart"in a)var f={start:a.selectionStart,end:a.selectionEnd};else e:{f=(f=a.ownerDocument)&&f.defaultView||window;var m=f.getSelection&&f.getSelection();if(m&&m.rangeCount!==0){f=m.anchorNode;var y=m.anchorOffset,T=m.focusNode;m=m.focusOffset;try{f.nodeType,T.nodeType}catch{f=null;break e}var R=0,U=-1,q=-1,de=0,we=0,De=a,me=null;t:for(;;){for(var _e;De!==f||y!==0&&De.nodeType!==3||(U=R+y),De!==T||m!==0&&De.nodeType!==3||(q=R+m),De.nodeType===3&&(R+=De.nodeValue.length),(_e=De.firstChild)!==null;)me=De,De=_e;for(;;){if(De===a)break t;if(me===f&&++de===y&&(U=R),me===T&&++we===m&&(q=R),(_e=De.nextSibling)!==null)break;De=me,me=De.parentNode}De=_e}f=U===-1||q===-1?null:{start:U,end:q}}else f=null}f=f||{start:0,end:0}}else f=null;for(oy={focusedElem:a,selectionRange:f},zm=!1,Ci=l;Ci!==null;)if(l=Ci,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,Ci=a;else for(;Ci!==null;){switch(l=Ci,T=l.alternate,a=l.flags,l.tag){case 0:if((a&4)!==0&&(a=l.updateQueue,a=a!==null?a.events:null,a!==null))for(f=0;f<a.length;f++)y=a[f],y.ref.impl=y.nextImpl;break;case 11:case 15:break;case 1:if((a&1024)!==0&&T!==null){a=void 0,f=l,y=T.memoizedProps,T=T.memoizedState,m=f.stateNode;try{var st=Xl(f.type,y);a=m.getSnapshotBeforeUpdate(st,T),m.__reactInternalSnapshotBeforeUpdate=a}catch(bt){An(f,f.return,bt)}}break;case 3:if((a&1024)!==0){if(a=l.stateNode.containerInfo,f=a.nodeType,f===9)cy(a);else if(f===1)switch(a.nodeName){case"HEAD":case"HTML":case"BODY":cy(a);break;default:a.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((a&1024)!==0)throw Error(n(163))}if(a=l.sibling,a!==null){a.return=l.return,Ci=a;break}Ci=l.return}}function aA(a,l,f){var m=f.flags;switch(f.tag){case 0:case 11:case 15:Ha(a,f),m&4&&Ff(5,f);break;case 1:if(Ha(a,f),m&4)if(a=f.stateNode,l===null)try{a.componentDidMount()}catch(R){An(f,f.return,R)}else{var y=Xl(f.type,l.memoizedProps);l=l.memoizedState;try{a.componentDidUpdate(y,l,a.__reactInternalSnapshotBeforeUpdate)}catch(R){An(f,f.return,R)}}m&64&&eA(f),m&512&&If(f,f.return);break;case 3:if(Ha(a,f),m&64&&(a=f.updateQueue,a!==null)){if(l=null,f.child!==null)switch(f.child.tag){case 27:case 5:l=f.child.stateNode;break;case 1:l=f.child.stateNode}try{jM(a,l)}catch(R){An(f,f.return,R)}}break;case 27:l===null&&m&4&&rA(f);case 26:case 5:Ha(a,f),l===null&&m&4&&nA(f),m&512&&If(f,f.return);break;case 12:Ha(a,f);break;case 31:Ha(a,f),m&4&&uA(a,f);break;case 13:Ha(a,f),m&4&&cA(a,f),m&64&&(a=f.memoizedState,a!==null&&(a=a.dehydrated,a!==null&&(f=eU.bind(null,f),xU(a,f))));break;case 22:if(m=f.memoizedState!==null||Ga,!m){l=l!==null&&l.memoizedState!==null||gi,y=Ga;var T=gi;Ga=m,(gi=l)&&!T?ja(a,f,(f.subtreeFlags&8772)!==0):Ha(a,f),Ga=y,gi=T}break;case 30:break;default:Ha(a,f)}}function oA(a){var l=a.alternate;l!==null&&(a.alternate=null,oA(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&ff(l)),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}var Yn=null,Mr=!1;function Va(a,l,f){for(f=f.child;f!==null;)lA(a,l,f),f=f.sibling}function lA(a,l,f){if(Oe&&typeof Oe.onCommitFiberUnmount=="function")try{Oe.onCommitFiberUnmount(Fe,f)}catch{}switch(f.tag){case 26:gi||Xs(f,l),Va(a,l,f),f.memoizedState?f.memoizedState.count--:f.stateNode&&(f=f.stateNode,f.parentNode.removeChild(f));break;case 27:gi||Xs(f,l);var m=Yn,y=Mr;Wo(f.type)&&(Yn=f.stateNode,Mr=!1),Va(a,l,f),qf(f.stateNode),Yn=m,Mr=y;break;case 5:gi||Xs(f,l);case 6:if(m=Yn,y=Mr,Yn=null,Va(a,l,f),Yn=m,Mr=y,Yn!==null)if(Mr)try{(Yn.nodeType===9?Yn.body:Yn.nodeName==="HTML"?Yn.ownerDocument.body:Yn).removeChild(f.stateNode)}catch(T){An(f,l,T)}else try{Yn.removeChild(f.stateNode)}catch(T){An(f,l,T)}break;case 18:Yn!==null&&(Mr?(a=Yn,e1(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,f.stateNode),Ec(a)):e1(Yn,f.stateNode));break;case 4:m=Yn,y=Mr,Yn=f.stateNode.containerInfo,Mr=!0,Va(a,l,f),Yn=m,Mr=y;break;case 0:case 11:case 14:case 15:Io(2,f,l),gi||Io(4,f,l),Va(a,l,f);break;case 1:gi||(Xs(f,l),m=f.stateNode,typeof m.componentWillUnmount=="function"&&tA(f,l,m)),Va(a,l,f);break;case 21:Va(a,l,f);break;case 22:gi=(m=gi)||f.memoizedState!==null,Va(a,l,f),gi=m;break;default:Va(a,l,f)}}function uA(a,l){if(l.memoizedState===null&&(a=l.alternate,a!==null&&(a=a.memoizedState,a!==null))){a=a.dehydrated;try{Ec(a)}catch(f){An(l,l.return,f)}}}function cA(a,l){if(l.memoizedState===null&&(a=l.alternate,a!==null&&(a=a.memoizedState,a!==null&&(a=a.dehydrated,a!==null))))try{Ec(a)}catch(f){An(l,l.return,f)}}function $P(a){switch(a.tag){case 31:case 13:case 19:var l=a.stateNode;return l===null&&(l=a.stateNode=new sA),l;case 22:return a=a.stateNode,l=a._retryCache,l===null&&(l=a._retryCache=new sA),l;default:throw Error(n(435,a.tag))}}function ym(a,l){var f=$P(a);l.forEach(function(m){if(!f.has(m)){f.add(m);var y=tU.bind(null,a,m);m.then(y,y)}})}function Er(a,l){var f=l.deletions;if(f!==null)for(var m=0;m<f.length;m++){var y=f[m],T=a,R=l,U=R;e:for(;U!==null;){switch(U.tag){case 27:if(Wo(U.type)){Yn=U.stateNode,Mr=!1;break e}break;case 5:Yn=U.stateNode,Mr=!1;break e;case 3:case 4:Yn=U.stateNode.containerInfo,Mr=!0;break e}U=U.return}if(Yn===null)throw Error(n(160));lA(T,R,y),Yn=null,Mr=!1,T=y.alternate,T!==null&&(T.return=null),y.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)hA(l,a),l=l.sibling}var Ds=null;function hA(a,l){var f=a.alternate,m=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:Er(l,a),Ar(a),m&4&&(Io(3,a,a.return),Ff(3,a),Io(5,a,a.return));break;case 1:Er(l,a),Ar(a),m&512&&(gi||f===null||Xs(f,f.return)),m&64&&Ga&&(a=a.updateQueue,a!==null&&(m=a.callbacks,m!==null&&(f=a.shared.hiddenCallbacks,a.shared.hiddenCallbacks=f===null?m:f.concat(m))));break;case 26:var y=Ds;if(Er(l,a),Ar(a),m&512&&(gi||f===null||Xs(f,f.return)),m&4){var T=f!==null?f.memoizedState:null;if(m=a.memoizedState,f===null)if(m===null)if(a.stateNode===null){e:{m=a.type,f=a.memoizedProps,y=y.ownerDocument||y;t:switch(m){case"title":T=y.getElementsByTagName("title")[0],(!T||T[Pl]||T[ci]||T.namespaceURI==="http://www.w3.org/2000/svg"||T.hasAttribute("itemprop"))&&(T=y.createElement(m),y.head.insertBefore(T,y.querySelector("head > title"))),Gi(T,m,f),T[ci]=a,ne(T),m=T;break e;case"link":var R=h1("link","href",y).get(m+(f.href||""));if(R){for(var U=0;U<R.length;U++)if(T=R[U],T.getAttribute("href")===(f.href==null||f.href===""?null:f.href)&&T.getAttribute("rel")===(f.rel==null?null:f.rel)&&T.getAttribute("title")===(f.title==null?null:f.title)&&T.getAttribute("crossorigin")===(f.crossOrigin==null?null:f.crossOrigin)){R.splice(U,1);break t}}T=y.createElement(m),Gi(T,m,f),y.head.appendChild(T);break;case"meta":if(R=h1("meta","content",y).get(m+(f.content||""))){for(U=0;U<R.length;U++)if(T=R[U],T.getAttribute("content")===(f.content==null?null:""+f.content)&&T.getAttribute("name")===(f.name==null?null:f.name)&&T.getAttribute("property")===(f.property==null?null:f.property)&&T.getAttribute("http-equiv")===(f.httpEquiv==null?null:f.httpEquiv)&&T.getAttribute("charset")===(f.charSet==null?null:f.charSet)){R.splice(U,1);break t}}T=y.createElement(m),Gi(T,m,f),y.head.appendChild(T);break;default:throw Error(n(468,m))}T[ci]=a,ne(T),m=T}a.stateNode=m}else f1(y,a.type,a.stateNode);else a.stateNode=c1(y,m,a.memoizedProps);else T!==m?(T===null?f.stateNode!==null&&(f=f.stateNode,f.parentNode.removeChild(f)):T.count--,m===null?f1(y,a.type,a.stateNode):c1(y,m,a.memoizedProps)):m===null&&a.stateNode!==null&&Bv(a,a.memoizedProps,f.memoizedProps)}break;case 27:Er(l,a),Ar(a),m&512&&(gi||f===null||Xs(f,f.return)),f!==null&&m&4&&Bv(a,a.memoizedProps,f.memoizedProps);break;case 5:if(Er(l,a),Ar(a),m&512&&(gi||f===null||Xs(f,f.return)),a.flags&32){y=a.stateNode;try{lr(y,"")}catch(st){An(a,a.return,st)}}m&4&&a.stateNode!=null&&(y=a.memoizedProps,Bv(a,y,f!==null?f.memoizedProps:y)),m&1024&&(zv=!0);break;case 6:if(Er(l,a),Ar(a),m&4){if(a.stateNode===null)throw Error(n(162));m=a.memoizedProps,f=a.stateNode;try{f.nodeValue=m}catch(st){An(a,a.return,st)}}break;case 3:if(Om=null,y=Ds,Ds=Pm(l.containerInfo),Er(l,a),Ds=y,Ar(a),m&4&&f!==null&&f.memoizedState.isDehydrated)try{Ec(l.containerInfo)}catch(st){An(a,a.return,st)}zv&&(zv=!1,fA(a));break;case 4:m=Ds,Ds=Pm(a.stateNode.containerInfo),Er(l,a),Ar(a),Ds=m;break;case 12:Er(l,a),Ar(a);break;case 31:Er(l,a),Ar(a),m&4&&(m=a.updateQueue,m!==null&&(a.updateQueue=null,ym(a,m)));break;case 13:Er(l,a),Ar(a),a.child.flags&8192&&a.memoizedState!==null!=(f!==null&&f.memoizedState!==null)&&(bm=P()),m&4&&(m=a.updateQueue,m!==null&&(a.updateQueue=null,ym(a,m)));break;case 22:y=a.memoizedState!==null;var q=f!==null&&f.memoizedState!==null,de=Ga,we=gi;if(Ga=de||y,gi=we||q,Er(l,a),gi=we,Ga=de,Ar(a),m&8192)e:for(l=a.stateNode,l._visibility=y?l._visibility&-2:l._visibility|1,y&&(f===null||q||Ga||gi||Yl(a)),f=null,l=a;;){if(l.tag===5||l.tag===26){if(f===null){q=f=l;try{if(T=q.stateNode,y)R=T.style,typeof R.setProperty=="function"?R.setProperty("display","none","important"):R.display="none";else{U=q.stateNode;var De=q.memoizedProps.style,me=De!=null&&De.hasOwnProperty("display")?De.display:null;U.style.display=me==null||typeof me=="boolean"?"":(""+me).trim()}}catch(st){An(q,q.return,st)}}}else if(l.tag===6){if(f===null){q=l;try{q.stateNode.nodeValue=y?"":q.memoizedProps}catch(st){An(q,q.return,st)}}}else if(l.tag===18){if(f===null){q=l;try{var _e=q.stateNode;y?t1(_e,!0):t1(q.stateNode,!1)}catch(st){An(q,q.return,st)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===a)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break e;for(;l.sibling===null;){if(l.return===null||l.return===a)break e;f===l&&(f=null),l=l.return}f===l&&(f=null),l.sibling.return=l.return,l=l.sibling}m&4&&(m=a.updateQueue,m!==null&&(f=m.retryQueue,f!==null&&(m.retryQueue=null,ym(a,f))));break;case 19:Er(l,a),Ar(a),m&4&&(m=a.updateQueue,m!==null&&(a.updateQueue=null,ym(a,m)));break;case 30:break;case 21:break;default:Er(l,a),Ar(a)}}function Ar(a){var l=a.flags;if(l&2){try{for(var f,m=a.return;m!==null;){if(iA(m)){f=m;break}m=m.return}if(f==null)throw Error(n(160));switch(f.tag){case 27:var y=f.stateNode,T=Fv(a);vm(a,T,y);break;case 5:var R=f.stateNode;f.flags&32&&(lr(R,""),f.flags&=-33);var U=Fv(a);vm(a,U,R);break;case 3:case 4:var q=f.stateNode.containerInfo,de=Fv(a);Iv(a,de,q);break;default:throw Error(n(161))}}catch(we){An(a,a.return,we)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function fA(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var l=a;fA(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),a=a.sibling}}function Ha(a,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)aA(a,l.alternate,l),l=l.sibling}function Yl(a){for(a=a.child;a!==null;){var l=a;switch(l.tag){case 0:case 11:case 14:case 15:Io(4,l,l.return),Yl(l);break;case 1:Xs(l,l.return);var f=l.stateNode;typeof f.componentWillUnmount=="function"&&tA(l,l.return,f),Yl(l);break;case 27:qf(l.stateNode);case 26:case 5:Xs(l,l.return),Yl(l);break;case 22:l.memoizedState===null&&Yl(l);break;case 30:Yl(l);break;default:Yl(l)}a=a.sibling}}function ja(a,l,f){for(f=f&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var m=l.alternate,y=a,T=l,R=T.flags;switch(T.tag){case 0:case 11:case 15:ja(y,T,f),Ff(4,T);break;case 1:if(ja(y,T,f),m=T,y=m.stateNode,typeof y.componentDidMount=="function")try{y.componentDidMount()}catch(de){An(m,m.return,de)}if(m=T,y=m.updateQueue,y!==null){var U=m.stateNode;try{var q=y.shared.hiddenCallbacks;if(q!==null)for(y.shared.hiddenCallbacks=null,y=0;y<q.length;y++)HM(q[y],U)}catch(de){An(m,m.return,de)}}f&&R&64&&eA(T),If(T,T.return);break;case 27:rA(T);case 26:case 5:ja(y,T,f),f&&m===null&&R&4&&nA(T),If(T,T.return);break;case 12:ja(y,T,f);break;case 31:ja(y,T,f),f&&R&4&&uA(y,T);break;case 13:ja(y,T,f),f&&R&4&&cA(y,T);break;case 22:T.memoizedState===null&&ja(y,T,f),If(T,T.return);break;case 30:break;default:ja(y,T,f)}l=l.sibling}}function kv(a,l){var f=null;a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(f=a.memoizedState.cachePool.pool),a=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(a=l.memoizedState.cachePool.pool),a!==f&&(a!=null&&a.refCount++,f!=null&&Mf(f))}function Gv(a,l){a=null,l.alternate!==null&&(a=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==a&&(l.refCount++,a!=null&&Mf(a))}function Ls(a,l,f,m){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)dA(a,l,f,m),l=l.sibling}function dA(a,l,f,m){var y=l.flags;switch(l.tag){case 0:case 11:case 15:Ls(a,l,f,m),y&2048&&Ff(9,l);break;case 1:Ls(a,l,f,m);break;case 3:Ls(a,l,f,m),y&2048&&(a=null,l.alternate!==null&&(a=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==a&&(l.refCount++,a!=null&&Mf(a)));break;case 12:if(y&2048){Ls(a,l,f,m),a=l.stateNode;try{var T=l.memoizedProps,R=T.id,U=T.onPostCommit;typeof U=="function"&&U(R,l.alternate===null?"mount":"update",a.passiveEffectDuration,-0)}catch(q){An(l,l.return,q)}}else Ls(a,l,f,m);break;case 31:Ls(a,l,f,m);break;case 13:Ls(a,l,f,m);break;case 23:break;case 22:T=l.stateNode,R=l.alternate,l.memoizedState!==null?T._visibility&2?Ls(a,l,f,m):zf(a,l):T._visibility&2?Ls(a,l,f,m):(T._visibility|=2,pc(a,l,f,m,(l.subtreeFlags&10256)!==0||!1)),y&2048&&kv(R,l);break;case 24:Ls(a,l,f,m),y&2048&&Gv(l.alternate,l);break;default:Ls(a,l,f,m)}}function pc(a,l,f,m,y){for(y=y&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var T=a,R=l,U=f,q=m,de=R.flags;switch(R.tag){case 0:case 11:case 15:pc(T,R,U,q,y),Ff(8,R);break;case 23:break;case 22:var we=R.stateNode;R.memoizedState!==null?we._visibility&2?pc(T,R,U,q,y):zf(T,R):(we._visibility|=2,pc(T,R,U,q,y)),y&&de&2048&&kv(R.alternate,R);break;case 24:pc(T,R,U,q,y),y&&de&2048&&Gv(R.alternate,R);break;default:pc(T,R,U,q,y)}l=l.sibling}}function zf(a,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var f=a,m=l,y=m.flags;switch(m.tag){case 22:zf(f,m),y&2048&&kv(m.alternate,m);break;case 24:zf(f,m),y&2048&&Gv(m.alternate,m);break;default:zf(f,m)}l=l.sibling}}var kf=8192;function mc(a,l,f){if(a.subtreeFlags&kf)for(a=a.child;a!==null;)pA(a,l,f),a=a.sibling}function pA(a,l,f){switch(a.tag){case 26:mc(a,l,f),a.flags&kf&&a.memoizedState!==null&&LU(f,Ds,a.memoizedState,a.memoizedProps);break;case 5:mc(a,l,f);break;case 3:case 4:var m=Ds;Ds=Pm(a.stateNode.containerInfo),mc(a,l,f),Ds=m;break;case 22:a.memoizedState===null&&(m=a.alternate,m!==null&&m.memoizedState!==null?(m=kf,kf=16777216,mc(a,l,f),kf=m):mc(a,l,f));break;default:mc(a,l,f)}}function mA(a){var l=a.alternate;if(l!==null&&(a=l.child,a!==null)){l.child=null;do l=a.sibling,a.sibling=null,a=l;while(a!==null)}}function Gf(a){var l=a.deletions;if((a.flags&16)!==0){if(l!==null)for(var f=0;f<l.length;f++){var m=l[f];Ci=m,_A(m,a)}mA(a)}if(a.subtreeFlags&10256)for(a=a.child;a!==null;)gA(a),a=a.sibling}function gA(a){switch(a.tag){case 0:case 11:case 15:Gf(a),a.flags&2048&&Io(9,a,a.return);break;case 3:Gf(a);break;case 12:Gf(a);break;case 22:var l=a.stateNode;a.memoizedState!==null&&l._visibility&2&&(a.return===null||a.return.tag!==13)?(l._visibility&=-3,xm(a)):Gf(a);break;default:Gf(a)}}function xm(a){var l=a.deletions;if((a.flags&16)!==0){if(l!==null)for(var f=0;f<l.length;f++){var m=l[f];Ci=m,_A(m,a)}mA(a)}for(a=a.child;a!==null;){switch(l=a,l.tag){case 0:case 11:case 15:Io(8,l,l.return),xm(l);break;case 22:f=l.stateNode,f._visibility&2&&(f._visibility&=-3,xm(l));break;default:xm(l)}a=a.sibling}}function _A(a,l){for(;Ci!==null;){var f=Ci;switch(f.tag){case 0:case 11:case 15:Io(8,f,l);break;case 23:case 22:if(f.memoizedState!==null&&f.memoizedState.cachePool!==null){var m=f.memoizedState.cachePool.pool;m!=null&&m.refCount++}break;case 24:Mf(f.memoizedState.cache)}if(m=f.child,m!==null)m.return=f,Ci=m;else e:for(f=a;Ci!==null;){m=Ci;var y=m.sibling,T=m.return;if(oA(m),m===f){Ci=null;break e}if(y!==null){y.return=T,Ci=y;break e}Ci=T}}}var qP={getCacheForType:function(a){var l=zi(di),f=l.data.get(a);return f===void 0&&(f=a(),l.data.set(a,f)),f},cacheSignal:function(){return zi(di).controller.signal}},XP=typeof WeakMap=="function"?WeakMap:Map,pn=0,Pn=null,Xt=null,Qt=0,En=0,$r=null,zo=!1,gc=!1,Vv=!1,Wa=0,ii=0,ko=0,Kl=0,Hv=0,qr=0,_c=0,Vf=null,wr=null,jv=!1,bm=0,vA=0,Sm=1/0,Tm=null,Go=null,Ei=0,Vo=null,vc=null,$a=0,Wv=0,$v=null,yA=null,Hf=0,qv=null;function Xr(){return(pn&2)!==0&&Qt!==0?Qt&-Qt:I.T!==null?Jv():Ws()}function xA(){if(qr===0)if((Qt&536870912)===0||en){var a=ze;ze<<=1,(ze&3932160)===0&&(ze=262144),qr=a}else qr=536870912;return a=jr.current,a!==null&&(a.flags|=32),qr}function Rr(a,l,f){(a===Pn&&(En===2||En===9)||a.cancelPendingCommit!==null)&&(yc(a,0),Ho(a,Qt,qr,!1)),sr(a,f),((pn&2)===0||a!==Pn)&&(a===Pn&&((pn&2)===0&&(Kl|=f),ii===4&&Ho(a,Qt,qr,!1)),Ys(a))}function bA(a,l,f){if((pn&6)!==0)throw Error(n(327));var m=!f&&(l&127)===0&&(l&a.expiredLanes)===0||nt(a,l),y=m?ZP(a,l):Yv(a,l,!0),T=m;do{if(y===0){gc&&!m&&Ho(a,l,0,!1);break}else{if(f=a.current.alternate,T&&!YP(f)){y=Yv(a,l,!1),T=!1;continue}if(y===2){if(T=l,a.errorRecoveryDisabledLanes&T)var R=0;else R=a.pendingLanes&-536870913,R=R!==0?R:R&536870912?536870912:0;if(R!==0){l=R;e:{var U=a;y=Vf;var q=U.current.memoizedState.isDehydrated;if(q&&(yc(U,R).flags|=256),R=Yv(U,R,!1),R!==2){if(Vv&&!q){U.errorRecoveryDisabledLanes|=T,Kl|=T,y=4;break e}T=wr,wr=y,T!==null&&(wr===null?wr=T:wr.push.apply(wr,T))}y=R}if(T=!1,y!==2)continue}}if(y===1){yc(a,0),Ho(a,l,0,!0);break}e:{switch(m=a,T=y,T){case 0:case 1:throw Error(n(345));case 4:if((l&4194048)!==l)break;case 6:Ho(m,l,qr,!zo);break e;case 2:wr=null;break;case 3:case 5:break;default:throw Error(n(329))}if((l&62914560)===l&&(y=bm+300-P(),10<y)){if(Ho(m,l,qr,!zo),Me(m,0,!0)!==0)break e;$a=l,m.timeoutHandle=QA(SA.bind(null,m,f,wr,Tm,jv,l,qr,Kl,_c,zo,T,"Throttled",-0,0),y);break e}SA(m,f,wr,Tm,jv,l,qr,Kl,_c,zo,T,null,-0,0)}}break}while(!0);Ys(a)}function SA(a,l,f,m,y,T,R,U,q,de,we,De,me,_e){if(a.timeoutHandle=-1,De=l.subtreeFlags,De&8192||(De&16785408)===16785408){De={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Da},pA(l,T,De);var st=(T&62914560)===T?bm-P():(T&4194048)===T?vA-P():0;if(st=PU(De,st),st!==null){$a=T,a.cancelPendingCommit=st(NA.bind(null,a,l,T,f,m,y,R,U,q,we,De,null,me,_e)),Ho(a,T,R,!de);return}}NA(a,l,T,f,m,y,R,U,q)}function YP(a){for(var l=a;;){var f=l.tag;if((f===0||f===11||f===15)&&l.flags&16384&&(f=l.updateQueue,f!==null&&(f=f.stores,f!==null)))for(var m=0;m<f.length;m++){var y=f[m],T=y.getSnapshot;y=y.value;try{if(!Vr(T(),y))return!1}catch{return!1}}if(f=l.child,l.subtreeFlags&16384&&f!==null)f.return=l,l=f;else{if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Ho(a,l,f,m){l&=~Hv,l&=~Kl,a.suspendedLanes|=l,a.pingedLanes&=~l,m&&(a.warmLanes|=l),m=a.expirationTimes;for(var y=l;0<y;){var T=31-Xe(y),R=1<<T;m[T]=-1,y&=~R}f!==0&&hf(a,f,l)}function Mm(){return(pn&6)===0?(jf(0),!1):!0}function Xv(){if(Xt!==null){if(En===0)var a=Xt.return;else a=Xt,Oa=Gl=null,cv(a),uc=null,Af=0,a=Xt;for(;a!==null;)JE(a.alternate,a),a=a.return;Xt=null}}function yc(a,l){var f=a.timeoutHandle;f!==-1&&(a.timeoutHandle=-1,mU(f)),f=a.cancelPendingCommit,f!==null&&(a.cancelPendingCommit=null,f()),$a=0,Xv(),Pn=a,Xt=f=Pa(a.current,null),Qt=l,En=0,$r=null,zo=!1,gc=nt(a,l),Vv=!1,_c=qr=Hv=Kl=ko=ii=0,wr=Vf=null,jv=!1,(l&8)!==0&&(l|=l&32);var m=a.entangledLanes;if(m!==0)for(a=a.entanglements,m&=l;0<m;){var y=31-Xe(m),T=1<<y;l|=a[y],m&=~T}return Wa=l,Wp(),f}function TA(a,l){It=null,I.H=Uf,l===lc||l===Jp?(l=zM(),En=3):l===Q0?(l=zM(),En=4):En=l===Av?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,$r=l,Xt===null&&(ii=1,dm(a,as(l,a.current)))}function MA(){var a=jr.current;return a===null?!0:(Qt&4194048)===Qt?cs===null:(Qt&62914560)===Qt||(Qt&536870912)!==0?a===cs:!1}function EA(){var a=I.H;return I.H=Uf,a===null?Uf:a}function AA(){var a=I.A;return I.A=qP,a}function Em(){ii=4,zo||(Qt&4194048)!==Qt&&jr.current!==null||(gc=!0),(ko&134217727)===0&&(Kl&134217727)===0||Pn===null||Ho(Pn,Qt,qr,!1)}function Yv(a,l,f){var m=pn;pn|=2;var y=EA(),T=AA();(Pn!==a||Qt!==l)&&(Tm=null,yc(a,l)),l=!1;var R=ii;e:do try{if(En!==0&&Xt!==null){var U=Xt,q=$r;switch(En){case 8:Xv(),R=6;break e;case 3:case 2:case 9:case 6:jr.current===null&&(l=!0);var de=En;if(En=0,$r=null,xc(a,U,q,de),f&&gc){R=0;break e}break;default:de=En,En=0,$r=null,xc(a,U,q,de)}}KP(),R=ii;break}catch(we){TA(a,we)}while(!0);return l&&a.shellSuspendCounter++,Oa=Gl=null,pn=m,I.H=y,I.A=T,Xt===null&&(Pn=null,Qt=0,Wp()),R}function KP(){for(;Xt!==null;)wA(Xt)}function ZP(a,l){var f=pn;pn|=2;var m=EA(),y=AA();Pn!==a||Qt!==l?(Tm=null,Sm=P()+500,yc(a,l)):gc=nt(a,l);e:do try{if(En!==0&&Xt!==null){l=Xt;var T=$r;t:switch(En){case 1:En=0,$r=null,xc(a,l,T,1);break;case 2:case 9:if(FM(T)){En=0,$r=null,RA(l);break}l=function(){En!==2&&En!==9||Pn!==a||(En=7),Ys(a)},T.then(l,l);break e;case 3:En=7;break e;case 4:En=5;break e;case 7:FM(T)?(En=0,$r=null,RA(l)):(En=0,$r=null,xc(a,l,T,7));break;case 5:var R=null;switch(Xt.tag){case 26:R=Xt.memoizedState;case 5:case 27:var U=Xt;if(R?d1(R):U.stateNode.complete){En=0,$r=null;var q=U.sibling;if(q!==null)Xt=q;else{var de=U.return;de!==null?(Xt=de,Am(de)):Xt=null}break t}}En=0,$r=null,xc(a,l,T,5);break;case 6:En=0,$r=null,xc(a,l,T,6);break;case 8:Xv(),ii=6;break e;default:throw Error(n(462))}}QP();break}catch(we){TA(a,we)}while(!0);return Oa=Gl=null,I.H=m,I.A=y,pn=f,Xt!==null?0:(Pn=null,Qt=0,Wp(),ii)}function QP(){for(;Xt!==null&&!ht();)wA(Xt)}function wA(a){var l=ZE(a.alternate,a,Wa);a.memoizedProps=a.pendingProps,l===null?Am(a):Xt=l}function RA(a){var l=a,f=l.alternate;switch(l.tag){case 15:case 0:l=WE(f,l,l.pendingProps,l.type,void 0,Qt);break;case 11:l=WE(f,l,l.pendingProps,l.type.render,l.ref,Qt);break;case 5:cv(l);default:JE(f,l),l=Xt=AM(l,Wa),l=ZE(f,l,Wa)}a.memoizedProps=a.pendingProps,l===null?Am(a):Xt=l}function xc(a,l,f,m){Oa=Gl=null,cv(l),uc=null,Af=0;var y=l.return;try{if(kP(a,y,l,f,Qt)){ii=1,dm(a,as(f,a.current)),Xt=null;return}}catch(T){if(y!==null)throw Xt=y,T;ii=1,dm(a,as(f,a.current)),Xt=null;return}l.flags&32768?(en||m===1?a=!0:gc||(Qt&536870912)!==0?a=!1:(zo=a=!0,(m===2||m===9||m===3||m===6)&&(m=jr.current,m!==null&&m.tag===13&&(m.flags|=16384))),CA(l,a)):Am(l)}function Am(a){var l=a;do{if((l.flags&32768)!==0){CA(l,zo);return}a=l.return;var f=HP(l.alternate,l,Wa);if(f!==null){Xt=f;return}if(l=l.sibling,l!==null){Xt=l;return}Xt=l=a}while(l!==null);ii===0&&(ii=5)}function CA(a,l){do{var f=jP(a.alternate,a);if(f!==null){f.flags&=32767,Xt=f;return}if(f=a.return,f!==null&&(f.flags|=32768,f.subtreeFlags=0,f.deletions=null),!l&&(a=a.sibling,a!==null)){Xt=a;return}Xt=a=f}while(a!==null);ii=6,Xt=null}function NA(a,l,f,m,y,T,R,U,q){a.cancelPendingCommit=null;do wm();while(Ei!==0);if((pn&6)!==0)throw Error(n(327));if(l!==null){if(l===a.current)throw Error(n(177));if(T=l.lanes|l.childLanes,T|=F0,As(a,f,T,R,U,q),a===Pn&&(Xt=Pn=null,Qt=0),vc=l,Vo=a,$a=f,Wv=T,$v=y,yA=m,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(a.callbackNode=null,a.callbackPriority=0,nU(Ae,function(){return OA(),null})):(a.callbackNode=null,a.callbackPriority=0),m=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||m){m=I.T,I.T=null,y=F.p,F.p=2,R=pn,pn|=4;try{WP(a,l,f)}finally{pn=R,F.p=y,I.T=m}}Ei=1,DA(),LA(),PA()}}function DA(){if(Ei===1){Ei=0;var a=Vo,l=vc,f=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||f){f=I.T,I.T=null;var m=F.p;F.p=2;var y=pn;pn|=4;try{hA(l,a);var T=oy,R=_M(a.containerInfo),U=T.focusedElem,q=T.selectionRange;if(R!==U&&U&&U.ownerDocument&&gM(U.ownerDocument.documentElement,U)){if(q!==null&&L0(U)){var de=q.start,we=q.end;if(we===void 0&&(we=de),"selectionStart"in U)U.selectionStart=de,U.selectionEnd=Math.min(we,U.value.length);else{var De=U.ownerDocument||document,me=De&&De.defaultView||window;if(me.getSelection){var _e=me.getSelection(),st=U.textContent.length,bt=Math.min(q.start,st),Dn=q.end===void 0?bt:Math.min(q.end,st);!_e.extend&&bt>Dn&&(R=Dn,Dn=bt,bt=R);var oe=mM(U,bt),J=mM(U,Dn);if(oe&&J&&(_e.rangeCount!==1||_e.anchorNode!==oe.node||_e.anchorOffset!==oe.offset||_e.focusNode!==J.node||_e.focusOffset!==J.offset)){var fe=De.createRange();fe.setStart(oe.node,oe.offset),_e.removeAllRanges(),bt>Dn?(_e.addRange(fe),_e.extend(J.node,J.offset)):(fe.setEnd(J.node,J.offset),_e.addRange(fe))}}}}for(De=[],_e=U;_e=_e.parentNode;)_e.nodeType===1&&De.push({element:_e,left:_e.scrollLeft,top:_e.scrollTop});for(typeof U.focus=="function"&&U.focus(),U=0;U<De.length;U++){var Ce=De[U];Ce.element.scrollLeft=Ce.left,Ce.element.scrollTop=Ce.top}}zm=!!ay,oy=ay=null}finally{pn=y,F.p=m,I.T=f}}a.current=l,Ei=2}}function LA(){if(Ei===2){Ei=0;var a=Vo,l=vc,f=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||f){f=I.T,I.T=null;var m=F.p;F.p=2;var y=pn;pn|=4;try{aA(a,l.alternate,l)}finally{pn=y,F.p=m,I.T=f}}Ei=3}}function PA(){if(Ei===4||Ei===3){Ei=0,V();var a=Vo,l=vc,f=$a,m=yA;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?Ei=5:(Ei=0,vc=Vo=null,UA(a,a.pendingLanes));var y=a.pendingLanes;if(y===0&&(Go=null),$u(f),l=l.stateNode,Oe&&typeof Oe.onCommitFiberRoot=="function")try{Oe.onCommitFiberRoot(Fe,l,void 0,(l.current.flags&128)===128)}catch{}if(m!==null){l=I.T,y=F.p,F.p=2,I.T=null;try{for(var T=a.onRecoverableError,R=0;R<m.length;R++){var U=m[R];T(U.value,{componentStack:U.stack})}}finally{I.T=l,F.p=y}}($a&3)!==0&&wm(),Ys(a),y=a.pendingLanes,(f&261930)!==0&&(y&42)!==0?a===qv?Hf++:(Hf=0,qv=a):Hf=0,jf(0)}}function UA(a,l){(a.pooledCacheLanes&=l)===0&&(l=a.pooledCache,l!=null&&(a.pooledCache=null,Mf(l)))}function wm(){return DA(),LA(),PA(),OA()}function OA(){if(Ei!==5)return!1;var a=Vo,l=Wv;Wv=0;var f=$u($a),m=I.T,y=F.p;try{F.p=32>f?32:f,I.T=null,f=$v,$v=null;var T=Vo,R=$a;if(Ei=0,vc=Vo=null,$a=0,(pn&6)!==0)throw Error(n(331));var U=pn;if(pn|=4,gA(T.current),dA(T,T.current,R,f),pn=U,jf(0,!1),Oe&&typeof Oe.onPostCommitFiberRoot=="function")try{Oe.onPostCommitFiberRoot(Fe,T)}catch{}return!0}finally{F.p=y,I.T=m,UA(a,l)}}function BA(a,l,f){l=as(f,l),l=Ev(a.stateNode,l,2),a=Oo(a,l,2),a!==null&&(sr(a,2),Ys(a))}function An(a,l,f){if(a.tag===3)BA(a,a,f);else for(;l!==null;){if(l.tag===3){BA(l,a,f);break}else if(l.tag===1){var m=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Go===null||!Go.has(m))){a=as(f,a),f=FE(2),m=Oo(l,f,2),m!==null&&(IE(f,m,l,a),sr(m,2),Ys(m));break}}l=l.return}}function Kv(a,l,f){var m=a.pingCache;if(m===null){m=a.pingCache=new XP;var y=new Set;m.set(l,y)}else y=m.get(l),y===void 0&&(y=new Set,m.set(l,y));y.has(f)||(Vv=!0,y.add(f),a=JP.bind(null,a,l,f),l.then(a,a))}function JP(a,l,f){var m=a.pingCache;m!==null&&m.delete(l),a.pingedLanes|=a.suspendedLanes&f,a.warmLanes&=~f,Pn===a&&(Qt&f)===f&&(ii===4||ii===3&&(Qt&62914560)===Qt&&300>P()-bm?(pn&2)===0&&yc(a,0):Hv|=f,_c===Qt&&(_c=0)),Ys(a)}function FA(a,l){l===0&&(l=Mn()),a=Il(a,l),a!==null&&(sr(a,l),Ys(a))}function eU(a){var l=a.memoizedState,f=0;l!==null&&(f=l.retryLane),FA(a,f)}function tU(a,l){var f=0;switch(a.tag){case 31:case 13:var m=a.stateNode,y=a.memoizedState;y!==null&&(f=y.retryLane);break;case 19:m=a.stateNode;break;case 22:m=a.stateNode._retryCache;break;default:throw Error(n(314))}m!==null&&m.delete(l),FA(a,f)}function nU(a,l){return nn(a,l)}var Rm=null,bc=null,Zv=!1,Cm=!1,Qv=!1,jo=0;function Ys(a){a!==bc&&a.next===null&&(bc===null?Rm=bc=a:bc=bc.next=a),Cm=!0,Zv||(Zv=!0,rU())}function jf(a,l){if(!Qv&&Cm){Qv=!0;do for(var f=!1,m=Rm;m!==null;){if(a!==0){var y=m.pendingLanes;if(y===0)var T=0;else{var R=m.suspendedLanes,U=m.pingedLanes;T=(1<<31-Xe(42|a)+1)-1,T&=y&~(R&~U),T=T&201326741?T&201326741|1:T?T|2:0}T!==0&&(f=!0,GA(m,T))}else T=Qt,T=Me(m,m===Pn?T:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(T&3)===0||nt(m,T)||(f=!0,GA(m,T));m=m.next}while(f);Qv=!1}}function iU(){IA()}function IA(){Cm=Zv=!1;var a=0;jo!==0&&pU()&&(a=jo);for(var l=P(),f=null,m=Rm;m!==null;){var y=m.next,T=zA(m,l);T===0?(m.next=null,f===null?Rm=y:f.next=y,y===null&&(bc=f)):(f=m,(a!==0||(T&3)!==0)&&(Cm=!0)),m=y}Ei!==0&&Ei!==5||jf(a),jo!==0&&(jo=0)}function zA(a,l){for(var f=a.suspendedLanes,m=a.pingedLanes,y=a.expirationTimes,T=a.pendingLanes&-62914561;0<T;){var R=31-Xe(T),U=1<<R,q=y[R];q===-1?((U&f)===0||(U&m)!==0)&&(y[R]=Ct(U,l)):q<=l&&(a.expiredLanes|=U),T&=~U}if(l=Pn,f=Qt,f=Me(a,a===l?f:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),m=a.callbackNode,f===0||a===l&&(En===2||En===9)||a.cancelPendingCommit!==null)return m!==null&&m!==null&&_n(m),a.callbackNode=null,a.callbackPriority=0;if((f&3)===0||nt(a,f)){if(l=f&-f,l===a.callbackPriority)return l;switch(m!==null&&_n(m),$u(f)){case 2:case 8:f=Ue;break;case 32:f=Ae;break;case 268435456:f=He;break;default:f=Ae}return m=kA.bind(null,a),f=nn(f,m),a.callbackPriority=l,a.callbackNode=f,l}return m!==null&&m!==null&&_n(m),a.callbackPriority=2,a.callbackNode=null,2}function kA(a,l){if(Ei!==0&&Ei!==5)return a.callbackNode=null,a.callbackPriority=0,null;var f=a.callbackNode;if(wm()&&a.callbackNode!==f)return null;var m=Qt;return m=Me(a,a===Pn?m:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),m===0?null:(bA(a,m,l),zA(a,P()),a.callbackNode!=null&&a.callbackNode===f?kA.bind(null,a):null)}function GA(a,l){if(wm())return null;bA(a,l,!0)}function rU(){gU(function(){(pn&6)!==0?nn(Re,iU):IA()})}function Jv(){if(jo===0){var a=ac;a===0&&(a=Ge,Ge<<=1,(Ge&261888)===0&&(Ge=256)),jo=a}return jo}function VA(a){return a==null||typeof a=="symbol"||typeof a=="boolean"?null:typeof a=="function"?a:Fp(""+a)}function HA(a,l){var f=l.ownerDocument.createElement("input");return f.name=l.name,f.value=l.value,a.id&&f.setAttribute("form",a.id),l.parentNode.insertBefore(f,l),a=new FormData(a),f.parentNode.removeChild(f),a}function sU(a,l,f,m,y){if(l==="submit"&&f&&f.stateNode===y){var T=VA((y[Ti]||null).action),R=m.submitter;R&&(l=(l=R[Ti]||null)?VA(l.formAction):R.getAttribute("formAction"),l!==null&&(T=l,R=null));var U=new Gp("action","action",null,m,y);a.push({event:U,listeners:[{instance:null,listener:function(){if(m.defaultPrevented){if(jo!==0){var q=R?HA(y,R):new FormData(y);yv(f,{pending:!0,data:q,method:y.method,action:T},null,q)}}else typeof T=="function"&&(U.preventDefault(),q=R?HA(y,R):new FormData(y),yv(f,{pending:!0,data:q,method:y.method,action:T},T,q))},currentTarget:y}]})}}for(var ey=0;ey<B0.length;ey++){var ty=B0[ey],aU=ty.toLowerCase(),oU=ty[0].toUpperCase()+ty.slice(1);Ns(aU,"on"+oU)}Ns(xM,"onAnimationEnd"),Ns(bM,"onAnimationIteration"),Ns(SM,"onAnimationStart"),Ns("dblclick","onDoubleClick"),Ns("focusin","onFocus"),Ns("focusout","onBlur"),Ns(TP,"onTransitionRun"),Ns(MP,"onTransitionStart"),Ns(EP,"onTransitionCancel"),Ns(TM,"onTransitionEnd"),je("onMouseEnter",["mouseout","mouseover"]),je("onMouseLeave",["mouseout","mouseover"]),je("onPointerEnter",["pointerout","pointerover"]),je("onPointerLeave",["pointerout","pointerover"]),he("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),he("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),he("onBeforeInput",["compositionend","keypress","textInput","paste"]),he("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),he("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),he("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Wf="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(" "),lU=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Wf));function jA(a,l){l=(l&4)!==0;for(var f=0;f<a.length;f++){var m=a[f],y=m.event;m=m.listeners;e:{var T=void 0;if(l)for(var R=m.length-1;0<=R;R--){var U=m[R],q=U.instance,de=U.currentTarget;if(U=U.listener,q!==T&&y.isPropagationStopped())break e;T=U,y.currentTarget=de;try{T(y)}catch(we){jp(we)}y.currentTarget=null,T=q}else for(R=0;R<m.length;R++){if(U=m[R],q=U.instance,de=U.currentTarget,U=U.listener,q!==T&&y.isPropagationStopped())break e;T=U,y.currentTarget=de;try{T(y)}catch(we){jp(we)}y.currentTarget=null,T=q}}}}function Yt(a,l){var f=l[Eo];f===void 0&&(f=l[Eo]=new Set);var m=a+"__bubble";f.has(m)||(WA(l,a,2,!1),f.add(m))}function ny(a,l,f){var m=0;l&&(m|=4),WA(f,a,m,l)}var Nm="_reactListening"+Math.random().toString(36).slice(2);function iy(a){if(!a[Nm]){a[Nm]=!0,ge.forEach(function(f){f!=="selectionchange"&&(lU.has(f)||ny(f,!1,a),ny(f,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[Nm]||(l[Nm]=!0,ny("selectionchange",!1,l))}}function WA(a,l,f,m){switch(x1(l)){case 2:var y=BU;break;case 8:y=FU;break;default:y=vy}f=y.bind(null,l,f,a),y=void 0,!T0||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(y=!0),m?y!==void 0?a.addEventListener(l,f,{capture:!0,passive:y}):a.addEventListener(l,f,!0):y!==void 0?a.addEventListener(l,f,{passive:y}):a.addEventListener(l,f,!1)}function ry(a,l,f,m,y){var T=m;if((l&1)===0&&(l&2)===0&&m!==null)e:for(;;){if(m===null)return;var R=m.tag;if(R===3||R===4){var U=m.stateNode.containerInfo;if(U===y)break;if(R===4)for(R=m.return;R!==null;){var q=R.tag;if((q===3||q===4)&&R.stateNode.containerInfo===y)return;R=R.return}for(;U!==null;){if(R=Ao(U),R===null)return;if(q=R.tag,q===5||q===6||q===26||q===27){m=T=R;continue e}U=U.parentNode}}m=m.return}KT(function(){var de=T,we=b0(f),De=[];e:{var me=MM.get(a);if(me!==void 0){var _e=Gp,st=a;switch(a){case"keypress":if(zp(f)===0)break e;case"keydown":case"keyup":_e=tP;break;case"focusin":st="focus",_e=w0;break;case"focusout":st="blur",_e=w0;break;case"beforeblur":case"afterblur":_e=w0;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":_e=JT;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":_e=HL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":_e=rP;break;case xM:case bM:case SM:_e=$L;break;case TM:_e=aP;break;case"scroll":case"scrollend":_e=GL;break;case"wheel":_e=lP;break;case"copy":case"cut":case"paste":_e=XL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":_e=tM;break;case"toggle":case"beforetoggle":_e=cP}var bt=(l&4)!==0,Dn=!bt&&(a==="scroll"||a==="scrollend"),oe=bt?me!==null?me+"Capture":null:me;bt=[];for(var J=de,fe;J!==null;){var Ce=J;if(fe=Ce.stateNode,Ce=Ce.tag,Ce!==5&&Ce!==26&&Ce!==27||fe===null||oe===null||(Ce=df(J,oe),Ce!=null&&bt.push($f(J,Ce,fe))),Dn)break;J=J.return}0<bt.length&&(me=new _e(me,st,null,f,we),De.push({event:me,listeners:bt}))}}if((l&7)===0){e:{if(me=a==="mouseover"||a==="pointerover",_e=a==="mouseout"||a==="pointerout",me&&f!==x0&&(st=f.relatedTarget||f.fromElement)&&(Ao(st)||st[Ca]))break e;if((_e||me)&&(me=we.window===we?we:(me=we.ownerDocument)?me.defaultView||me.parentWindow:window,_e?(st=f.relatedTarget||f.toElement,_e=de,st=st?Ao(st):null,st!==null&&(Dn=s(st),bt=st.tag,st!==Dn||bt!==5&&bt!==27&&bt!==6)&&(st=null)):(_e=null,st=de),_e!==st)){if(bt=JT,Ce="onMouseLeave",oe="onMouseEnter",J="mouse",(a==="pointerout"||a==="pointerover")&&(bt=tM,Ce="onPointerLeave",oe="onPointerEnter",J="pointer"),Dn=_e==null?me:Ul(_e),fe=st==null?me:Ul(st),me=new bt(Ce,J+"leave",_e,f,we),me.target=Dn,me.relatedTarget=fe,Ce=null,Ao(we)===de&&(bt=new bt(oe,J+"enter",st,f,we),bt.target=fe,bt.relatedTarget=Dn,Ce=bt),Dn=Ce,_e&&st)t:{for(bt=uU,oe=_e,J=st,fe=0,Ce=oe;Ce;Ce=bt(Ce))fe++;Ce=0;for(var vt=J;vt;vt=bt(vt))Ce++;for(;0<fe-Ce;)oe=bt(oe),fe--;for(;0<Ce-fe;)J=bt(J),Ce--;for(;fe--;){if(oe===J||J!==null&&oe===J.alternate){bt=oe;break t}oe=bt(oe),J=bt(J)}bt=null}else bt=null;_e!==null&&$A(De,me,_e,bt,!1),st!==null&&Dn!==null&&$A(De,Dn,st,bt,!0)}}e:{if(me=de?Ul(de):window,_e=me.nodeName&&me.nodeName.toLowerCase(),_e==="select"||_e==="input"&&me.type==="file")var un=uM;else if(oM(me))if(cM)un=xP;else{un=vP;var ft=_P}else _e=me.nodeName,!_e||_e.toLowerCase()!=="input"||me.type!=="checkbox"&&me.type!=="radio"?de&&Xu(de.elementType)&&(un=uM):un=yP;if(un&&(un=un(a,de))){lM(De,un,f,we);break e}ft&&ft(a,me,de),a==="focusout"&&de&&me.type==="number"&&de.memoizedProps.value!=null&&Rs(me,"number",me.value)}switch(ft=de?Ul(de):window,a){case"focusin":(oM(ft)||ft.contentEditable==="true")&&(Qu=ft,P0=de,bf=null);break;case"focusout":bf=P0=Qu=null;break;case"mousedown":U0=!0;break;case"contextmenu":case"mouseup":case"dragend":U0=!1,vM(De,f,we);break;case"selectionchange":if(SP)break;case"keydown":case"keyup":vM(De,f,we)}var Ht;if(C0)e:{switch(a){case"compositionstart":var Jt="onCompositionStart";break e;case"compositionend":Jt="onCompositionEnd";break e;case"compositionupdate":Jt="onCompositionUpdate";break e}Jt=void 0}else Zu?sM(a,f)&&(Jt="onCompositionEnd"):a==="keydown"&&f.keyCode===229&&(Jt="onCompositionStart");Jt&&(nM&&f.locale!=="ko"&&(Zu||Jt!=="onCompositionStart"?Jt==="onCompositionEnd"&&Zu&&(Ht=ZT()):(Ro=we,M0="value"in Ro?Ro.value:Ro.textContent,Zu=!0)),ft=Dm(de,Jt),0<ft.length&&(Jt=new eM(Jt,a,null,f,we),De.push({event:Jt,listeners:ft}),Ht?Jt.data=Ht:(Ht=aM(f),Ht!==null&&(Jt.data=Ht)))),(Ht=fP?dP(a,f):pP(a,f))&&(Jt=Dm(de,"onBeforeInput"),0<Jt.length&&(ft=new eM("onBeforeInput","beforeinput",null,f,we),De.push({event:ft,listeners:Jt}),ft.data=Ht)),sU(De,a,de,f,we)}jA(De,l)})}function $f(a,l,f){return{instance:a,listener:l,currentTarget:f}}function Dm(a,l){for(var f=l+"Capture",m=[];a!==null;){var y=a,T=y.stateNode;if(y=y.tag,y!==5&&y!==26&&y!==27||T===null||(y=df(a,f),y!=null&&m.unshift($f(a,y,T)),y=df(a,l),y!=null&&m.push($f(a,y,T))),a.tag===3)return m;a=a.return}return[]}function uU(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5&&a.tag!==27);return a||null}function $A(a,l,f,m,y){for(var T=l._reactName,R=[];f!==null&&f!==m;){var U=f,q=U.alternate,de=U.stateNode;if(U=U.tag,q!==null&&q===m)break;U!==5&&U!==26&&U!==27||de===null||(q=de,y?(de=df(f,T),de!=null&&R.unshift($f(f,de,q))):y||(de=df(f,T),de!=null&&R.push($f(f,de,q)))),f=f.return}R.length!==0&&a.push({event:l,listeners:R})}var cU=/\r\n?/g,hU=/\u0000|\uFFFD/g;function qA(a){return(typeof a=="string"?a:""+a).replace(cU,`
`).replace(hU,"")}function XA(a,l){return l=qA(l),qA(a)===l}function Nn(a,l,f,m,y,T){switch(f){case"children":typeof m=="string"?l==="body"||l==="textarea"&&m===""||lr(a,m):(typeof m=="number"||typeof m=="bigint")&&l!=="body"&&lr(a,""+m);break;case"className":Ot(a,"class",m);break;case"tabIndex":Ot(a,"tabindex",m);break;case"dir":case"role":case"viewBox":case"width":case"height":Ot(a,f,m);break;case"style":Na(a,m,T);break;case"data":if(l!=="object"){Ot(a,"data",m);break}case"src":case"href":if(m===""&&(l!=="a"||f!=="href")){a.removeAttribute(f);break}if(m==null||typeof m=="function"||typeof m=="symbol"||typeof m=="boolean"){a.removeAttribute(f);break}m=Fp(""+m),a.setAttribute(f,m);break;case"action":case"formAction":if(typeof m=="function"){a.setAttribute(f,"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 T=="function"&&(f==="formAction"?(l!=="input"&&Nn(a,l,"name",y.name,y,null),Nn(a,l,"formEncType",y.formEncType,y,null),Nn(a,l,"formMethod",y.formMethod,y,null),Nn(a,l,"formTarget",y.formTarget,y,null)):(Nn(a,l,"encType",y.encType,y,null),Nn(a,l,"method",y.method,y,null),Nn(a,l,"target",y.target,y,null)));if(m==null||typeof m=="symbol"||typeof m=="boolean"){a.removeAttribute(f);break}m=Fp(""+m),a.setAttribute(f,m);break;case"onClick":m!=null&&(a.onclick=Da);break;case"onScroll":m!=null&&Yt("scroll",a);break;case"onScrollEnd":m!=null&&Yt("scrollend",a);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(n(61));if(f=m.__html,f!=null){if(y.children!=null)throw Error(n(60));a.innerHTML=f}}break;case"multiple":a.multiple=m&&typeof m!="function"&&typeof m!="symbol";break;case"muted":a.muted=m&&typeof m!="function"&&typeof m!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(m==null||typeof m=="function"||typeof m=="boolean"||typeof m=="symbol"){a.removeAttribute("xlink:href");break}f=Fp(""+m),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":m!=null&&typeof m!="function"&&typeof m!="symbol"?a.setAttribute(f,""+m):a.removeAttribute(f);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":m&&typeof m!="function"&&typeof m!="symbol"?a.setAttribute(f,""):a.removeAttribute(f);break;case"capture":case"download":m===!0?a.setAttribute(f,""):m!==!1&&m!=null&&typeof m!="function"&&typeof m!="symbol"?a.setAttribute(f,m):a.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":m!=null&&typeof m!="function"&&typeof m!="symbol"&&!isNaN(m)&&1<=m?a.setAttribute(f,m):a.removeAttribute(f);break;case"rowSpan":case"start":m==null||typeof m=="function"||typeof m=="symbol"||isNaN(m)?a.removeAttribute(f):a.setAttribute(f,m);break;case"popover":Yt("beforetoggle",a),Yt("toggle",a),At(a,"popover",m);break;case"xlinkActuate":it(a,"http://www.w3.org/1999/xlink","xlink:actuate",m);break;case"xlinkArcrole":it(a,"http://www.w3.org/1999/xlink","xlink:arcrole",m);break;case"xlinkRole":it(a,"http://www.w3.org/1999/xlink","xlink:role",m);break;case"xlinkShow":it(a,"http://www.w3.org/1999/xlink","xlink:show",m);break;case"xlinkTitle":it(a,"http://www.w3.org/1999/xlink","xlink:title",m);break;case"xlinkType":it(a,"http://www.w3.org/1999/xlink","xlink:type",m);break;case"xmlBase":it(a,"http://www.w3.org/XML/1998/namespace","xml:base",m);break;case"xmlLang":it(a,"http://www.w3.org/XML/1998/namespace","xml:lang",m);break;case"xmlSpace":it(a,"http://www.w3.org/XML/1998/namespace","xml:space",m);break;case"is":At(a,"is",m);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=zL.get(f)||f,At(a,f,m))}}function sy(a,l,f,m,y,T){switch(f){case"style":Na(a,m,T);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(n(61));if(f=m.__html,f!=null){if(y.children!=null)throw Error(n(60));a.innerHTML=f}}break;case"children":typeof m=="string"?lr(a,m):(typeof m=="number"||typeof m=="bigint")&&lr(a,""+m);break;case"onScroll":m!=null&&Yt("scroll",a);break;case"onScrollEnd":m!=null&&Yt("scrollend",a);break;case"onClick":m!=null&&(a.onclick=Da);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!pe.hasOwnProperty(f))e:{if(f[0]==="o"&&f[1]==="n"&&(y=f.endsWith("Capture"),l=f.slice(2,y?f.length-7:void 0),T=a[Ti]||null,T=T!=null?T[f]:null,typeof T=="function"&&a.removeEventListener(l,T,y),typeof m=="function")){typeof T!="function"&&T!==null&&(f in a?a[f]=null:a.hasAttribute(f)&&a.removeAttribute(f)),a.addEventListener(l,m,y);break e}f in a?a[f]=m:m===!0?a.setAttribute(f,""):At(a,f,m)}}}function Gi(a,l,f){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Yt("error",a),Yt("load",a);var m=!1,y=!1,T;for(T in f)if(f.hasOwnProperty(T)){var R=f[T];if(R!=null)switch(T){case"src":m=!0;break;case"srcSet":y=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(n(137,l));default:Nn(a,l,T,R,f,null)}}y&&Nn(a,l,"srcSet",f.srcSet,f,null),m&&Nn(a,l,"src",f.src,f,null);return;case"input":Yt("invalid",a);var U=T=R=y=null,q=null,de=null;for(m in f)if(f.hasOwnProperty(m)){var we=f[m];if(we!=null)switch(m){case"name":y=we;break;case"type":R=we;break;case"checked":q=we;break;case"defaultChecked":de=we;break;case"value":T=we;break;case"defaultValue":U=we;break;case"children":case"dangerouslySetInnerHTML":if(we!=null)throw Error(n(137,l));break;default:Nn(a,l,m,we,f,null)}}kr(a,T,U,q,de,R,y,!1);return;case"select":Yt("invalid",a),m=R=T=null;for(y in f)if(f.hasOwnProperty(y)&&(U=f[y],U!=null))switch(y){case"value":T=U;break;case"defaultValue":R=U;break;case"multiple":m=U;default:Nn(a,l,y,U,f,null)}l=T,f=R,a.multiple=!!m,l!=null?Gr(a,!!m,l,!1):f!=null&&Gr(a,!!m,f,!0);return;case"textarea":Yt("invalid",a),T=y=m=null;for(R in f)if(f.hasOwnProperty(R)&&(U=f[R],U!=null))switch(R){case"value":m=U;break;case"defaultValue":y=U;break;case"children":T=U;break;case"dangerouslySetInnerHTML":if(U!=null)throw Error(n(91));break;default:Nn(a,l,R,U,f,null)}hi(a,m,y,T);return;case"option":for(q in f)if(f.hasOwnProperty(q)&&(m=f[q],m!=null))switch(q){case"selected":a.selected=m&&typeof m!="function"&&typeof m!="symbol";break;default:Nn(a,l,q,m,f,null)}return;case"dialog":Yt("beforetoggle",a),Yt("toggle",a),Yt("cancel",a),Yt("close",a);break;case"iframe":case"object":Yt("load",a);break;case"video":case"audio":for(m=0;m<Wf.length;m++)Yt(Wf[m],a);break;case"image":Yt("error",a),Yt("load",a);break;case"details":Yt("toggle",a);break;case"embed":case"source":case"link":Yt("error",a),Yt("load",a);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(de in f)if(f.hasOwnProperty(de)&&(m=f[de],m!=null))switch(de){case"children":case"dangerouslySetInnerHTML":throw Error(n(137,l));default:Nn(a,l,de,m,f,null)}return;default:if(Xu(l)){for(we in f)f.hasOwnProperty(we)&&(m=f[we],m!==void 0&&sy(a,l,we,m,f,void 0));return}}for(U in f)f.hasOwnProperty(U)&&(m=f[U],m!=null&&Nn(a,l,U,m,f,null))}function fU(a,l,f,m){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var y=null,T=null,R=null,U=null,q=null,de=null,we=null;for(_e in f){var De=f[_e];if(f.hasOwnProperty(_e)&&De!=null)switch(_e){case"checked":break;case"value":break;case"defaultValue":q=De;default:m.hasOwnProperty(_e)||Nn(a,l,_e,null,m,De)}}for(var me in m){var _e=m[me];if(De=f[me],m.hasOwnProperty(me)&&(_e!=null||De!=null))switch(me){case"type":T=_e;break;case"name":y=_e;break;case"checked":de=_e;break;case"defaultChecked":we=_e;break;case"value":R=_e;break;case"defaultValue":U=_e;break;case"children":case"dangerouslySetInnerHTML":if(_e!=null)throw Error(n(137,l));break;default:_e!==De&&Nn(a,l,me,_e,m,De)}}or(a,R,U,q,de,we,T,y);return;case"select":_e=R=U=me=null;for(T in f)if(q=f[T],f.hasOwnProperty(T)&&q!=null)switch(T){case"value":break;case"multiple":_e=q;default:m.hasOwnProperty(T)||Nn(a,l,T,null,m,q)}for(y in m)if(T=m[y],q=f[y],m.hasOwnProperty(y)&&(T!=null||q!=null))switch(y){case"value":me=T;break;case"defaultValue":U=T;break;case"multiple":R=T;default:T!==q&&Nn(a,l,y,T,m,q)}l=U,f=R,m=_e,me!=null?Gr(a,!!f,me,!1):!!m!=!!f&&(l!=null?Gr(a,!!f,l,!0):Gr(a,!!f,f?[]:"",!1));return;case"textarea":_e=me=null;for(U in f)if(y=f[U],f.hasOwnProperty(U)&&y!=null&&!m.hasOwnProperty(U))switch(U){case"value":break;case"children":break;default:Nn(a,l,U,null,m,y)}for(R in m)if(y=m[R],T=f[R],m.hasOwnProperty(R)&&(y!=null||T!=null))switch(R){case"value":me=y;break;case"defaultValue":_e=y;break;case"children":break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(n(91));break;default:y!==T&&Nn(a,l,R,y,m,T)}vn(a,me,_e);return;case"option":for(var st in f)if(me=f[st],f.hasOwnProperty(st)&&me!=null&&!m.hasOwnProperty(st))switch(st){case"selected":a.selected=!1;break;default:Nn(a,l,st,null,m,me)}for(q in m)if(me=m[q],_e=f[q],m.hasOwnProperty(q)&&me!==_e&&(me!=null||_e!=null))switch(q){case"selected":a.selected=me&&typeof me!="function"&&typeof me!="symbol";break;default:Nn(a,l,q,me,m,_e)}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 bt in f)me=f[bt],f.hasOwnProperty(bt)&&me!=null&&!m.hasOwnProperty(bt)&&Nn(a,l,bt,null,m,me);for(de in m)if(me=m[de],_e=f[de],m.hasOwnProperty(de)&&me!==_e&&(me!=null||_e!=null))switch(de){case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(n(137,l));break;default:Nn(a,l,de,me,m,_e)}return;default:if(Xu(l)){for(var Dn in f)me=f[Dn],f.hasOwnProperty(Dn)&&me!==void 0&&!m.hasOwnProperty(Dn)&&sy(a,l,Dn,void 0,m,me);for(we in m)me=m[we],_e=f[we],!m.hasOwnProperty(we)||me===_e||me===void 0&&_e===void 0||sy(a,l,we,me,m,_e);return}}for(var oe in f)me=f[oe],f.hasOwnProperty(oe)&&me!=null&&!m.hasOwnProperty(oe)&&Nn(a,l,oe,null,m,me);for(De in m)me=m[De],_e=f[De],!m.hasOwnProperty(De)||me===_e||me==null&&_e==null||Nn(a,l,De,me,m,_e)}function YA(a){switch(a){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function dU(){if(typeof performance.getEntriesByType=="function"){for(var a=0,l=0,f=performance.getEntriesByType("resource"),m=0;m<f.length;m++){var y=f[m],T=y.transferSize,R=y.initiatorType,U=y.duration;if(T&&U&&YA(R)){for(R=0,U=y.responseEnd,m+=1;m<f.length;m++){var q=f[m],de=q.startTime;if(de>U)break;var we=q.transferSize,De=q.initiatorType;we&&YA(De)&&(q=q.responseEnd,R+=we*(q<U?1:(U-de)/(q-de)))}if(--m,l+=8*(T+R)/(y.duration/1e3),a++,10<a)break}}if(0<a)return l/a/1e6}return navigator.connection&&(a=navigator.connection.downlink,typeof a=="number")?a:5}var ay=null,oy=null;function Lm(a){return a.nodeType===9?a:a.ownerDocument}function KA(a){switch(a){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function ZA(a,l){if(a===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return a===1&&l==="foreignObject"?0:a}function ly(a,l){return a==="textarea"||a==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var uy=null;function pU(){var a=window.event;return a&&a.type==="popstate"?a===uy?!1:(uy=a,!0):(uy=null,!1)}var QA=typeof setTimeout=="function"?setTimeout:void 0,mU=typeof clearTimeout=="function"?clearTimeout:void 0,JA=typeof Promise=="function"?Promise:void 0,gU=typeof queueMicrotask=="function"?queueMicrotask:typeof JA<"u"?function(a){return JA.resolve(null).then(a).catch(_U)}:QA;function _U(a){setTimeout(function(){throw a})}function Wo(a){return a==="head"}function e1(a,l){var f=l,m=0;do{var y=f.nextSibling;if(a.removeChild(f),y&&y.nodeType===8)if(f=y.data,f==="/$"||f==="/&"){if(m===0){a.removeChild(y),Ec(l);return}m--}else if(f==="$"||f==="$?"||f==="$~"||f==="$!"||f==="&")m++;else if(f==="html")qf(a.ownerDocument.documentElement);else if(f==="head"){f=a.ownerDocument.head,qf(f);for(var T=f.firstChild;T;){var R=T.nextSibling,U=T.nodeName;T[Pl]||U==="SCRIPT"||U==="STYLE"||U==="LINK"&&T.rel.toLowerCase()==="stylesheet"||f.removeChild(T),T=R}}else f==="body"&&qf(a.ownerDocument.body);f=y}while(f);Ec(l)}function t1(a,l){var f=a;a=0;do{var m=f.nextSibling;if(f.nodeType===1?l?(f._stashedDisplay=f.style.display,f.style.display="none"):(f.style.display=f._stashedDisplay||"",f.getAttribute("style")===""&&f.removeAttribute("style")):f.nodeType===3&&(l?(f._stashedText=f.nodeValue,f.nodeValue=""):f.nodeValue=f._stashedText||""),m&&m.nodeType===8)if(f=m.data,f==="/$"){if(a===0)break;a--}else f!=="$"&&f!=="$?"&&f!=="$~"&&f!=="$!"||a++;f=m}while(f)}function cy(a){var l=a.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var f=l;switch(l=l.nextSibling,f.nodeName){case"HTML":case"HEAD":case"BODY":cy(f),ff(f);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(f.rel.toLowerCase()==="stylesheet")continue}a.removeChild(f)}}function vU(a,l,f,m){for(;a.nodeType===1;){var y=f;if(a.nodeName.toLowerCase()!==l.toLowerCase()){if(!m&&(a.nodeName!=="INPUT"||a.type!=="hidden"))break}else if(m){if(!a[Pl])switch(l){case"meta":if(!a.hasAttribute("itemprop"))break;return a;case"link":if(T=a.getAttribute("rel"),T==="stylesheet"&&a.hasAttribute("data-precedence"))break;if(T!==y.rel||a.getAttribute("href")!==(y.href==null||y.href===""?null:y.href)||a.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin)||a.getAttribute("title")!==(y.title==null?null:y.title))break;return a;case"style":if(a.hasAttribute("data-precedence"))break;return a;case"script":if(T=a.getAttribute("src"),(T!==(y.src==null?null:y.src)||a.getAttribute("type")!==(y.type==null?null:y.type)||a.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin))&&T&&a.hasAttribute("async")&&!a.hasAttribute("itemprop"))break;return a;default:return a}}else if(l==="input"&&a.type==="hidden"){var T=y.name==null?null:""+y.name;if(y.type==="hidden"&&a.getAttribute("name")===T)return a}else return a;if(a=hs(a.nextSibling),a===null)break}return null}function yU(a,l,f){if(l==="")return null;for(;a.nodeType!==3;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!f||(a=hs(a.nextSibling),a===null))return null;return a}function n1(a,l){for(;a.nodeType!==8;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!l||(a=hs(a.nextSibling),a===null))return null;return a}function hy(a){return a.data==="$?"||a.data==="$~"}function fy(a){return a.data==="$!"||a.data==="$?"&&a.ownerDocument.readyState!=="loading"}function xU(a,l){var f=a.ownerDocument;if(a.data==="$~")a._reactRetry=l;else if(a.data!=="$?"||f.readyState!=="loading")l();else{var m=function(){l(),f.removeEventListener("DOMContentLoaded",m)};f.addEventListener("DOMContentLoaded",m),a._reactRetry=m}}function hs(a){for(;a!=null;a=a.nextSibling){var l=a.nodeType;if(l===1||l===3)break;if(l===8){if(l=a.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return a}var dy=null;function i1(a){a=a.nextSibling;for(var l=0;a;){if(a.nodeType===8){var f=a.data;if(f==="/$"||f==="/&"){if(l===0)return hs(a.nextSibling);l--}else f!=="$"&&f!=="$!"&&f!=="$?"&&f!=="$~"&&f!=="&"||l++}a=a.nextSibling}return null}function r1(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var f=a.data;if(f==="$"||f==="$!"||f==="$?"||f==="$~"||f==="&"){if(l===0)return a;l--}else f!=="/$"&&f!=="/&"||l++}a=a.previousSibling}return null}function s1(a,l,f){switch(l=Lm(f),a){case"html":if(a=l.documentElement,!a)throw Error(n(452));return a;case"head":if(a=l.head,!a)throw Error(n(453));return a;case"body":if(a=l.body,!a)throw Error(n(454));return a;default:throw Error(n(451))}}function qf(a){for(var l=a.attributes;l.length;)a.removeAttributeNode(l[0]);ff(a)}var fs=new Map,a1=new Set;function Pm(a){return typeof a.getRootNode=="function"?a.getRootNode():a.nodeType===9?a:a.ownerDocument}var qa=F.d;F.d={f:bU,r:SU,D:TU,C:MU,L:EU,m:AU,X:RU,S:wU,M:CU};function bU(){var a=qa.f(),l=Mm();return a||l}function SU(a){var l=wo(a);l!==null&&l.tag===5&&l.type==="form"?TE(l):qa.r(a)}var Sc=typeof document>"u"?null:document;function o1(a,l,f){var m=Sc;if(m&&typeof l=="string"&&l){var y=Lt(l);y='link[rel="'+a+'"][href="'+y+'"]',typeof f=="string"&&(y+='[crossorigin="'+f+'"]'),a1.has(y)||(a1.add(y),a={rel:a,crossOrigin:f,href:l},m.querySelector(y)===null&&(l=m.createElement("link"),Gi(l,"link",a),ne(l),m.head.appendChild(l)))}}function TU(a){qa.D(a),o1("dns-prefetch",a,null)}function MU(a,l){qa.C(a,l),o1("preconnect",a,l)}function EU(a,l,f){qa.L(a,l,f);var m=Sc;if(m&&a&&l){var y='link[rel="preload"][as="'+Lt(l)+'"]';l==="image"&&f&&f.imageSrcSet?(y+='[imagesrcset="'+Lt(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(y+='[imagesizes="'+Lt(f.imageSizes)+'"]')):y+='[href="'+Lt(a)+'"]';var T=y;switch(l){case"style":T=Tc(a);break;case"script":T=Mc(a)}fs.has(T)||(a=p({rel:"preload",href:l==="image"&&f&&f.imageSrcSet?void 0:a,as:l},f),fs.set(T,a),m.querySelector(y)!==null||l==="style"&&m.querySelector(Xf(T))||l==="script"&&m.querySelector(Yf(T))||(l=m.createElement("link"),Gi(l,"link",a),ne(l),m.head.appendChild(l)))}}function AU(a,l){qa.m(a,l);var f=Sc;if(f&&a){var m=l&&typeof l.as=="string"?l.as:"script",y='link[rel="modulepreload"][as="'+Lt(m)+'"][href="'+Lt(a)+'"]',T=y;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":T=Mc(a)}if(!fs.has(T)&&(a=p({rel:"modulepreload",href:a},l),fs.set(T,a),f.querySelector(y)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(Yf(T)))return}m=f.createElement("link"),Gi(m,"link",a),ne(m),f.head.appendChild(m)}}}function wU(a,l,f){qa.S(a,l,f);var m=Sc;if(m&&a){var y=B(m).hoistableStyles,T=Tc(a);l=l||"default";var R=y.get(T);if(!R){var U={loading:0,preload:null};if(R=m.querySelector(Xf(T)))U.loading=5;else{a=p({rel:"stylesheet",href:a,"data-precedence":l},f),(f=fs.get(T))&&py(a,f);var q=R=m.createElement("link");ne(q),Gi(q,"link",a),q._p=new Promise(function(de,we){q.onload=de,q.onerror=we}),q.addEventListener("load",function(){U.loading|=1}),q.addEventListener("error",function(){U.loading|=2}),U.loading|=4,Um(R,l,m)}R={type:"stylesheet",instance:R,count:1,state:U},y.set(T,R)}}}function RU(a,l){qa.X(a,l);var f=Sc;if(f&&a){var m=B(f).hoistableScripts,y=Mc(a),T=m.get(y);T||(T=f.querySelector(Yf(y)),T||(a=p({src:a,async:!0},l),(l=fs.get(y))&&my(a,l),T=f.createElement("script"),ne(T),Gi(T,"link",a),f.head.appendChild(T)),T={type:"script",instance:T,count:1,state:null},m.set(y,T))}}function CU(a,l){qa.M(a,l);var f=Sc;if(f&&a){var m=B(f).hoistableScripts,y=Mc(a),T=m.get(y);T||(T=f.querySelector(Yf(y)),T||(a=p({src:a,async:!0,type:"module"},l),(l=fs.get(y))&&my(a,l),T=f.createElement("script"),ne(T),Gi(T,"link",a),f.head.appendChild(T)),T={type:"script",instance:T,count:1,state:null},m.set(y,T))}}function l1(a,l,f,m){var y=(y=$.current)?Pm(y):null;if(!y)throw Error(n(446));switch(a){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(l=Tc(f.href),f=B(y).hoistableStyles,m=f.get(l),m||(m={type:"style",instance:null,count:0,state:null},f.set(l,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){a=Tc(f.href);var T=B(y).hoistableStyles,R=T.get(a);if(R||(y=y.ownerDocument||y,R={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},T.set(a,R),(T=y.querySelector(Xf(a)))&&!T._p&&(R.instance=T,R.state.loading=5),fs.has(a)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},fs.set(a,f),T||NU(y,a,f,R.state))),l&&m===null)throw Error(n(528,""));return R}if(l&&m!==null)throw Error(n(529,""));return null;case"script":return l=f.async,f=f.src,typeof f=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=Mc(f),f=B(y).hoistableScripts,m=f.get(l),m||(m={type:"script",instance:null,count:0,state:null},f.set(l,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,a))}}function Tc(a){return'href="'+Lt(a)+'"'}function Xf(a){return'link[rel="stylesheet"]['+a+"]"}function u1(a){return p({},a,{"data-precedence":a.precedence,precedence:null})}function NU(a,l,f,m){a.querySelector('link[rel="preload"][as="style"]['+l+"]")?m.loading=1:(l=a.createElement("link"),m.preload=l,l.addEventListener("load",function(){return m.loading|=1}),l.addEventListener("error",function(){return m.loading|=2}),Gi(l,"link",f),ne(l),a.head.appendChild(l))}function Mc(a){return'[src="'+Lt(a)+'"]'}function Yf(a){return"script[async]"+a}function c1(a,l,f){if(l.count++,l.instance===null)switch(l.type){case"style":var m=a.querySelector('style[data-href~="'+Lt(f.href)+'"]');if(m)return l.instance=m,ne(m),m;var y=p({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return m=(a.ownerDocument||a).createElement("style"),ne(m),Gi(m,"style",y),Um(m,f.precedence,a),l.instance=m;case"stylesheet":y=Tc(f.href);var T=a.querySelector(Xf(y));if(T)return l.state.loading|=4,l.instance=T,ne(T),T;m=u1(f),(y=fs.get(y))&&py(m,y),T=(a.ownerDocument||a).createElement("link"),ne(T);var R=T;return R._p=new Promise(function(U,q){R.onload=U,R.onerror=q}),Gi(T,"link",m),l.state.loading|=4,Um(T,f.precedence,a),l.instance=T;case"script":return T=Mc(f.src),(y=a.querySelector(Yf(T)))?(l.instance=y,ne(y),y):(m=f,(y=fs.get(T))&&(m=p({},f),my(m,y)),a=a.ownerDocument||a,y=a.createElement("script"),ne(y),Gi(y,"link",m),a.head.appendChild(y),l.instance=y);case"void":return null;default:throw Error(n(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(m=l.instance,l.state.loading|=4,Um(m,f.precedence,a));return l.instance}function Um(a,l,f){for(var m=f.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),y=m.length?m[m.length-1]:null,T=y,R=0;R<m.length;R++){var U=m[R];if(U.dataset.precedence===l)T=U;else if(T!==y)break}T?T.parentNode.insertBefore(a,T.nextSibling):(l=f.nodeType===9?f.head:f,l.insertBefore(a,l.firstChild))}function py(a,l){a.crossOrigin==null&&(a.crossOrigin=l.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=l.referrerPolicy),a.title==null&&(a.title=l.title)}function my(a,l){a.crossOrigin==null&&(a.crossOrigin=l.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=l.referrerPolicy),a.integrity==null&&(a.integrity=l.integrity)}var Om=null;function h1(a,l,f){if(Om===null){var m=new Map,y=Om=new Map;y.set(f,m)}else y=Om,m=y.get(f),m||(m=new Map,y.set(f,m));if(m.has(a))return m;for(m.set(a,null),f=f.getElementsByTagName(a),y=0;y<f.length;y++){var T=f[y];if(!(T[Pl]||T[ci]||a==="link"&&T.getAttribute("rel")==="stylesheet")&&T.namespaceURI!=="http://www.w3.org/2000/svg"){var R=T.getAttribute(l)||"";R=a+R;var U=m.get(R);U?U.push(T):m.set(R,[T])}}return m}function f1(a,l,f){a=a.ownerDocument||a,a.head.insertBefore(f,l==="title"?a.querySelector("head > title"):null)}function DU(a,l,f){if(f===1||l.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;switch(l.rel){case"stylesheet":return a=l.disabled,typeof l.precedence=="string"&&a==null;default:return!0}case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function d1(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function LU(a,l,f,m){if(f.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var y=Tc(m.href),T=l.querySelector(Xf(y));if(T){l=T._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(a.count++,a=Bm.bind(a),l.then(a,a)),f.state.loading|=4,f.instance=T,ne(T);return}T=l.ownerDocument||l,m=u1(m),(y=fs.get(y))&&py(m,y),T=T.createElement("link"),ne(T);var R=T;R._p=new Promise(function(U,q){R.onload=U,R.onerror=q}),Gi(T,"link",m),f.instance=T}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(f,l),(l=f.state.preload)&&(f.state.loading&3)===0&&(a.count++,f=Bm.bind(a),l.addEventListener("load",f),l.addEventListener("error",f))}}var gy=0;function PU(a,l){return a.stylesheets&&a.count===0&&Im(a,a.stylesheets),0<a.count||0<a.imgCount?function(f){var m=setTimeout(function(){if(a.stylesheets&&Im(a,a.stylesheets),a.unsuspend){var T=a.unsuspend;a.unsuspend=null,T()}},6e4+l);0<a.imgBytes&&gy===0&&(gy=62500*dU());var y=setTimeout(function(){if(a.waitingForImages=!1,a.count===0&&(a.stylesheets&&Im(a,a.stylesheets),a.unsuspend)){var T=a.unsuspend;a.unsuspend=null,T()}},(a.imgBytes>gy?50:800)+l);return a.unsuspend=f,function(){a.unsuspend=null,clearTimeout(m),clearTimeout(y)}}:null}function Bm(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Im(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var Fm=null;function Im(a,l){a.stylesheets=null,a.unsuspend!==null&&(a.count++,Fm=new Map,l.forEach(UU,a),Fm=null,Bm.call(a))}function UU(a,l){if(!(l.state.loading&4)){var f=Fm.get(a);if(f)var m=f.get(null);else{f=new Map,Fm.set(a,f);for(var y=a.querySelectorAll("link[data-precedence],style[data-precedence]"),T=0;T<y.length;T++){var R=y[T];(R.nodeName==="LINK"||R.getAttribute("media")!=="not all")&&(f.set(R.dataset.precedence,R),m=R)}m&&f.set(null,m)}y=l.instance,R=y.getAttribute("data-precedence"),T=f.get(R)||m,T===m&&f.set(null,y),f.set(R,y),this.count++,m=Bm.bind(this),y.addEventListener("load",m),y.addEventListener("error",m),T?T.parentNode.insertBefore(y,T.nextSibling):(a=a.nodeType===9?a.head:a,a.insertBefore(y,a.firstChild)),l.state.loading|=4}}var Kf={$$typeof:E,Provider:null,Consumer:null,_currentValue:Y,_currentValue2:Y,_threadCount:0};function OU(a,l,f,m,y,T,R,U,q){this.tag=1,this.containerInfo=a,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=an(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=an(0),this.hiddenUpdates=an(null),this.identifierPrefix=m,this.onUncaughtError=y,this.onCaughtError=T,this.onRecoverableError=R,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=q,this.incompleteTransitions=new Map}function p1(a,l,f,m,y,T,R,U,q,de,we,De){return a=new OU(a,l,f,R,q,de,we,De,U),l=1,T===!0&&(l|=24),T=Hr(3,null,null,l),a.current=T,T.stateNode=a,l=Y0(),l.refCount++,a.pooledCache=l,l.refCount++,T.memoizedState={element:m,isDehydrated:f,cache:l},J0(T),a}function m1(a){return a?(a=tc,a):tc}function g1(a,l,f,m,y,T){y=m1(y),m.context===null?m.context=y:m.pendingContext=y,m=Uo(l),m.payload={element:f},T=T===void 0?null:T,T!==null&&(m.callback=T),f=Oo(a,m,l),f!==null&&(Rr(f,a,l),Rf(f,a,l))}function _1(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var f=a.retryLane;a.retryLane=f!==0&&f<l?f:l}}function _y(a,l){_1(a,l),(a=a.alternate)&&_1(a,l)}function v1(a){if(a.tag===13||a.tag===31){var l=Il(a,67108864);l!==null&&Rr(l,a,67108864),_y(a,67108864)}}function y1(a){if(a.tag===13||a.tag===31){var l=Xr();l=Wu(l);var f=Il(a,l);f!==null&&Rr(f,a,l),_y(a,l)}}var zm=!0;function BU(a,l,f,m){var y=I.T;I.T=null;var T=F.p;try{F.p=2,vy(a,l,f,m)}finally{F.p=T,I.T=y}}function FU(a,l,f,m){var y=I.T;I.T=null;var T=F.p;try{F.p=8,vy(a,l,f,m)}finally{F.p=T,I.T=y}}function vy(a,l,f,m){if(zm){var y=yy(m);if(y===null)ry(a,l,m,km,f),b1(a,m);else if(zU(y,a,l,f,m))m.stopPropagation();else if(b1(a,m),l&4&&-1<IU.indexOf(a)){for(;y!==null;){var T=wo(y);if(T!==null)switch(T.tag){case 3:if(T=T.stateNode,T.current.memoizedState.isDehydrated){var R=Be(T.pendingLanes);if(R!==0){var U=T;for(U.pendingLanes|=2,U.entangledLanes|=2;R;){var q=1<<31-Xe(R);U.entanglements[1]|=q,R&=~q}Ys(T),(pn&6)===0&&(Sm=P()+500,jf(0))}}break;case 31:case 13:U=Il(T,2),U!==null&&Rr(U,T,2),Mm(),_y(T,2)}if(T=yy(m),T===null&&ry(a,l,m,km,f),T===y)break;y=T}y!==null&&m.stopPropagation()}else ry(a,l,m,null,f)}}function yy(a){return a=b0(a),xy(a)}var km=null;function xy(a){if(km=null,a=Ao(a),a!==null){var l=s(a);if(l===null)a=null;else{var f=l.tag;if(f===13){if(a=o(l),a!==null)return a;a=null}else if(f===31){if(a=u(l),a!==null)return a;a=null}else if(f===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null)}}return km=a,null}function x1(a){switch(a){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(ae()){case Re:return 2;case Ue:return 8;case Ae:case lt:return 32;case He:return 268435456;default:return 32}default:return 32}}var by=!1,$o=null,qo=null,Xo=null,Zf=new Map,Qf=new Map,Yo=[],IU="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 b1(a,l){switch(a){case"focusin":case"focusout":$o=null;break;case"dragenter":case"dragleave":qo=null;break;case"mouseover":case"mouseout":Xo=null;break;case"pointerover":case"pointerout":Zf.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Qf.delete(l.pointerId)}}function Jf(a,l,f,m,y,T){return a===null||a.nativeEvent!==T?(a={blockedOn:l,domEventName:f,eventSystemFlags:m,nativeEvent:T,targetContainers:[y]},l!==null&&(l=wo(l),l!==null&&v1(l)),a):(a.eventSystemFlags|=m,l=a.targetContainers,y!==null&&l.indexOf(y)===-1&&l.push(y),a)}function zU(a,l,f,m,y){switch(l){case"focusin":return $o=Jf($o,a,l,f,m,y),!0;case"dragenter":return qo=Jf(qo,a,l,f,m,y),!0;case"mouseover":return Xo=Jf(Xo,a,l,f,m,y),!0;case"pointerover":var T=y.pointerId;return Zf.set(T,Jf(Zf.get(T)||null,a,l,f,m,y)),!0;case"gotpointercapture":return T=y.pointerId,Qf.set(T,Jf(Qf.get(T)||null,a,l,f,m,y)),!0}return!1}function S1(a){var l=Ao(a.target);if(l!==null){var f=s(l);if(f!==null){if(l=f.tag,l===13){if(l=o(f),l!==null){a.blockedOn=l,qu(a.priority,function(){y1(f)});return}}else if(l===31){if(l=u(f),l!==null){a.blockedOn=l,qu(a.priority,function(){y1(f)});return}}else if(l===3&&f.stateNode.current.memoizedState.isDehydrated){a.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Gm(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var f=yy(a.nativeEvent);if(f===null){f=a.nativeEvent;var m=new f.constructor(f.type,f);x0=m,f.target.dispatchEvent(m),x0=null}else return l=wo(f),l!==null&&v1(l),a.blockedOn=f,!1;l.shift()}return!0}function T1(a,l,f){Gm(a)&&f.delete(l)}function kU(){by=!1,$o!==null&&Gm($o)&&($o=null),qo!==null&&Gm(qo)&&(qo=null),Xo!==null&&Gm(Xo)&&(Xo=null),Zf.forEach(T1),Qf.forEach(T1)}function Vm(a,l){a.blockedOn===l&&(a.blockedOn=null,by||(by=!0,i.unstable_scheduleCallback(i.unstable_NormalPriority,kU)))}var Hm=null;function M1(a){Hm!==a&&(Hm=a,i.unstable_scheduleCallback(i.unstable_NormalPriority,function(){Hm===a&&(Hm=null);for(var l=0;l<a.length;l+=3){var f=a[l],m=a[l+1],y=a[l+2];if(typeof m!="function"){if(xy(m||f)===null)continue;break}var T=wo(f);T!==null&&(a.splice(l,3),l-=3,yv(T,{pending:!0,data:y,method:f.method,action:m},m,y))}}))}function Ec(a){function l(q){return Vm(q,a)}$o!==null&&Vm($o,a),qo!==null&&Vm(qo,a),Xo!==null&&Vm(Xo,a),Zf.forEach(l),Qf.forEach(l);for(var f=0;f<Yo.length;f++){var m=Yo[f];m.blockedOn===a&&(m.blockedOn=null)}for(;0<Yo.length&&(f=Yo[0],f.blockedOn===null);)S1(f),f.blockedOn===null&&Yo.shift();if(f=(a.ownerDocument||a).$$reactFormReplay,f!=null)for(m=0;m<f.length;m+=3){var y=f[m],T=f[m+1],R=y[Ti]||null;if(typeof T=="function")R||M1(f);else if(R){var U=null;if(T&&T.hasAttribute("formAction")){if(y=T,R=T[Ti]||null)U=R.formAction;else if(xy(y)!==null)continue}else U=R.action;typeof U=="function"?f[m+1]=U:(f.splice(m,3),m-=3),M1(f)}}}function E1(){function a(T){T.canIntercept&&T.info==="react-transition"&&T.intercept({handler:function(){return new Promise(function(R){return y=R})},focusReset:"manual",scroll:"manual"})}function l(){y!==null&&(y(),y=null),m||setTimeout(f,20)}function f(){if(!m&&!navigation.transition){var T=navigation.currentEntry;T&&T.url!=null&&navigation.navigate(T.url,{state:T.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var m=!1,y=null;return navigation.addEventListener("navigate",a),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(f,100),function(){m=!0,navigation.removeEventListener("navigate",a),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),y!==null&&(y(),y=null)}}}function Sy(a){this._internalRoot=a}jm.prototype.render=Sy.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(n(409));var f=l.current,m=Xr();g1(f,m,a,l,null,null)},jm.prototype.unmount=Sy.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;g1(a.current,2,null,a,null,null),Mm(),l[Ca]=null}};function jm(a){this._internalRoot=a}jm.prototype.unstable_scheduleHydration=function(a){if(a){var l=Ws();a={blockedOn:null,target:a,priority:l};for(var f=0;f<Yo.length&&l!==0&&l<Yo[f].priority;f++);Yo.splice(f,0,a),f===0&&S1(a)}};var A1=e.version;if(A1!=="19.2.4")throw Error(n(527,A1,"19.2.4"));F.findDOMNode=function(a){var l=a._reactInternals;if(l===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=h(l),a=a!==null?d(a):null,a=a===null?null:a.stateNode,a};var GU={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:I,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Wm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Wm.isDisabled&&Wm.supportsFiber)try{Fe=Wm.inject(GU),Oe=Wm}catch{}}return td.createRoot=function(a,l){if(!r(a))throw Error(n(299));var f=!1,m="",y=PE,T=UE,R=OE;return l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(y=l.onUncaughtError),l.onCaughtError!==void 0&&(T=l.onCaughtError),l.onRecoverableError!==void 0&&(R=l.onRecoverableError)),l=p1(a,1,!1,null,null,f,m,null,y,T,R,E1),a[Ca]=l.current,iy(a),new Sy(l)},td.hydrateRoot=function(a,l,f){if(!r(a))throw Error(n(299));var m=!1,y="",T=PE,R=UE,U=OE,q=null;return f!=null&&(f.unstable_strictMode===!0&&(m=!0),f.identifierPrefix!==void 0&&(y=f.identifierPrefix),f.onUncaughtError!==void 0&&(T=f.onUncaughtError),f.onCaughtError!==void 0&&(R=f.onCaughtError),f.onRecoverableError!==void 0&&(U=f.onRecoverableError),f.formState!==void 0&&(q=f.formState)),l=p1(a,1,!0,l,f??null,m,y,q,T,R,U,E1),l.context=m1(null),f=l.current,m=Xr(),m=Wu(m),y=Uo(m),y.callback=null,Oo(f,y,m),f=m,l.current.lanes=f,sr(l,f),Ys(l),a[Ca]=l.current,iy(a),new jm(l)},td.version="19.2.4",td}var B1;function ZU(){if(B1)return Ey.exports;B1=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Ey.exports=KU(),Ey.exports}var QU=ZU();const JU=k_(QU),eO="";async function zn(i,e={}){const t=new URL(i,window.location.origin);Object.entries(e).forEach(([r,s])=>{s!=null&&t.searchParams.set(r,s)});const n=await fetch(t.toString());if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);return n.json()}function tO(){return zn("/api/story-runtime/health")}function nO(i,e={}){const{onOpen:t,onError:n}=e,r=new EventSource(`${eO}/api/events`);return r.onopen=()=>{t&&t()},r.onmessage=s=>{try{i(JSON.parse(s.data))}catch{}},r.onerror=s=>{n&&n(s)},()=>r.close()}function iO(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,o,u=[],c=!0,h=!1;try{if(s=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=s.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(d){h=!0,r=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw r}}return u}}function rO(i,e,t){return e=fO(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function F1(i,e){return oO(i)||iO(i,e)||LN(i,e)||cO()}function sO(i){return aO(i)||lO(i)||LN(i)||uO()}function aO(i){if(Array.isArray(i))return Sb(i)}function oO(i){if(Array.isArray(i))return i}function lO(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function LN(i,e){if(i){if(typeof i=="string")return Sb(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Sb(i,e)}}function Sb(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=i[t];return n}function uO(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hO(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function fO(i){var e=hO(i,"string");return typeof e=="symbol"?e:String(e)}var dO=function(e,t){var n=new Set(t);return Object.assign.apply(Object,[{}].concat(sO(Object.entries(e).filter(function(r){var s=F1(r,1),o=s[0];return!n.has(o)}).map(function(r){var s=F1(r,2),o=s[0],u=s[1];return rO({},o,u)}))))};function Tb(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function pO(i){if(Array.isArray(i))return i}function mO(i){if(Array.isArray(i))return Tb(i)}function gO(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function _O(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,o,u=[],c=!0,h=!1;try{if(s=(t=t.call(i)).next,e!==0)for(;!(c=(n=s.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(d){h=!0,r=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw r}}return u}}function vO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yO(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xO(i,e){return pO(i)||_O(i,e)||PN(i,e)||vO()}function I1(i){return mO(i)||gO(i)||PN(i)||yO()}function PN(i,e){if(i){if(typeof i=="string")return Tb(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Tb(i,e):void 0}}function bO(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.wrapperElementType,n=t===void 0?"div":t,r=e.nodeMapper,s=r===void 0?function(d){return d}:r,o=e.methodNames,u=o===void 0?[]:o,c=e.initPropNames,h=c===void 0?[]:c;return Et.forwardRef(function(d,p){var g=Et.useRef(),_=Et.useMemo(function(){var b=Object.fromEntries(h.filter(function(x){return d.hasOwnProperty(x)}).map(function(x){return[x,d[x]]}));return i(b)},[]);z1(function(){_(s(g.current))},Et.useLayoutEffect),z1(function(){return _._destructor instanceof Function?_._destructor:void 0});var v=Et.useCallback(function(b){for(var x=arguments.length,M=new Array(x>1?x-1:0),E=1;E<x;E++)M[E-1]=arguments[E];return _[b]instanceof Function?_[b].apply(_,M):void 0},[_]),S=Et.useRef({});return Object.keys(dO(d,[].concat(I1(u),I1(h)))).filter(function(b){return S.current[b]!==d[b]}).forEach(function(b){return v(b,d[b])}),S.current=d,Et.useImperativeHandle(p,function(){return Object.fromEntries(u.map(function(b){return[b,function(){for(var x=arguments.length,M=new Array(x),E=0;E<x;E++)M[E]=arguments[E];return v.apply(void 0,[b].concat(M))}]}))},[v]),DN.createElement(n,{ref:g})})}function z1(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Et.useEffect,t=Et.useRef(),n=Et.useRef(!1),r=Et.useRef(!1),s=Et.useState(0),o=xO(s,2);o[0];var u=o[1];n.current&&(r.current=!0),e(function(){return n.current||(t.current=i(),n.current=!0),u(function(c){return c+1}),function(){r.current&&t.current&&t.current()}},[])}/**
 * @license
 * Copyright 2010-2026 Three.js Authors
 * SPDX-License-Identifier: MIT
 */const Fu="183",Hi={ROTATE:0,DOLLY:1,PAN:2},co={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},UN=0,Mb=1,ON=2,SO=0,nh=1,BN=2,da=3,xr=0,Tn=1,Ui=2,Bi=0,pr=1,cl=2,hl=3,fl=4,gu=5,FN=6,nr=100,xS=101,bS=102,IN=103,zN=104,ro=200,SS=201,TS=202,MS=203,Kd=204,Zd=205,ES=206,AS=207,wS=208,RS=209,CS=210,TO=211,MO=212,EO=213,AO=214,Qd=0,Jd=1,ep=2,Tl=3,tp=4,np=5,ip=6,rp=7,yp=0,kN=1,GN=2,ji=0,NS=1,DS=2,LS=3,PS=4,VN=5,US=6,OS=7,BS=300,js=301,xa=302,ih=303,rh=304,Mu=306,Eu=1e3,Pr=1001,Au=1002,hn=1003,FS=1004,ho=1005,Rn=1006,sh=1007,Ur=1008,Gn=1009,_u=1010,vu=1011,Gs=1012,Li=1013,bn=1014,ri=1015,Qn=1016,G_=1017,V_=1018,is=1020,H_=35902,j_=35899,IS=1021,xp=1022,si=1023,Wi=1026,_r=1027,bp=1028,qh=1029,vr=1030,Xh=1031,wO=1032,Yh=1033,gl=33776,_l=33777,vl=33778,yl=33779,sp=35840,ap=35841,op=35842,lp=35843,fh=36196,dh=37492,ph=37496,mh=37488,gh=37489,wu=37490,_h=37491,vh=37808,yh=37809,xh=37810,bh=37811,Sh=37812,Th=37813,Mh=37814,Eh=37815,Ah=37816,wh=37817,Rh=37818,Ch=37819,Nh=37820,Dh=37821,Lh=36492,Eb=36494,Ab=36495,Ph=36283,Uh=36284,Ru=36285,Oh=36286,RO=3200,va=0,HN=1,Dr="",dr="srgb",Cu="srgb-linear",Bh="linear",Ye="srgb",Cy="",jN="rg",CO="ga",NO=0,au=7680,DO=7681,LO=7682,PO=7683,UO=34055,OO=34056,BO=5386,FO=512,IO=513,zO=514,kO=515,GO=516,VO=517,HO=518,wb=519,zS=512,W_=513,kS=514,wl=515,up=516,GS=517,bo=518,VS=519,Fh=35044,p_=35048,k1="300 es",yr=2e3,ba=2001,pa={COMPUTE:"compute",RENDER:"render"},mo={TEXTURE_COMPARE:"depthTextureCompare"};function jO(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function m_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function cp(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function WN(){const i=cp("canvas");return i.style.display="block",i}const G1={};function hp(...i){const e="THREE."+i.shift();console.log(e,...i)}function $N(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ne(...i){i=$N(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Pe(...i){i=$N(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function xn(...i){const e=i.join(" ");e in G1||(G1[e]=!0,Ne(...i))}function WO(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const HS={[Qd]:Jd,[ep]:ip,[tp]:rp,[Tl]:np,[Jd]:Qd,[ip]:ep,[rp]:tp,[np]:Tl};class Aa{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}}const Zi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let V1=1234567;const Od=Math.PI/180,Nu=180/Math.PI;function go(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Zi[i&255]+Zi[i>>8&255]+Zi[i>>16&255]+Zi[i>>24&255]+"-"+Zi[e&255]+Zi[e>>8&255]+"-"+Zi[e>>16&15|64]+Zi[e>>24&255]+"-"+Zi[t&63|128]+Zi[t>>8&255]+"-"+Zi[t>>16&255]+Zi[t>>24&255]+Zi[n&255]+Zi[n>>8&255]+Zi[n>>16&255]+Zi[n>>24&255]).toLowerCase()}function kt(i,e,t){return Math.max(e,Math.min(t,i))}function jS(i,e){return(i%e+e)%e}function $O(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function qO(i,e,t){return i!==e?(t-i)/(e-i):0}function Bd(i,e,t){return(1-t)*i+t*e}function XO(i,e,t,n){return Bd(i,e,1-Math.exp(-t*n))}function YO(i,e=1){return e-Math.abs(jS(i,e*2)-e)}function KO(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function ZO(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function QO(i,e){return i+Math.floor(Math.random()*(e-i+1))}function JO(i,e){return i+Math.random()*(e-i)}function eB(i){return i*(.5-Math.random())}function tB(i){i!==void 0&&(V1=i);let e=V1+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function nB(i){return i*Od}function iB(i){return i*Nu}function rB(i){return(i&i-1)===0&&i!==0}function sB(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function aB(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function oB(i,e,t,n,r){const s=Math.cos,o=Math.sin,u=s(t/2),c=o(t/2),h=s((e+n)/2),d=o((e+n)/2),p=s((e-n)/2),g=o((e-n)/2),_=s((n-e)/2),v=o((n-e)/2);switch(r){case"XYX":i.set(u*d,c*p,c*g,u*h);break;case"YZY":i.set(c*g,u*d,c*p,u*h);break;case"ZXZ":i.set(c*p,c*g,u*d,u*h);break;case"XZX":i.set(u*d,c*v,c*_,u*h);break;case"YXY":i.set(c*_,u*d,c*v,u*h);break;case"ZYZ":i.set(c*v,c*_,u*d,u*h);break;default:Ne("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function mr(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function zt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const g_={DEG2RAD:Od,RAD2DEG:Nu,generateUUID:go,clamp:kt,euclideanModulo:jS,mapLinear:$O,inverseLerp:qO,lerp:Bd,damp:XO,pingpong:YO,smoothstep:KO,smootherstep:ZO,randInt:QO,randFloat:JO,randFloatSpread:eB,seededRandom:tB,degToRad:nB,radToDeg:iB,isPowerOfTwo:rB,ceilPowerOfTwo:sB,floorPowerOfTwo:aB,setQuaternionFromProperEuler:oB,normalize:zt,denormalize:mr};class Ie{constructor(e=0,t=0){Ie.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=kt(this.x,e.x,t.x),this.y=kt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=kt(this.x,e,t),this.y=kt(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(kt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(kt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*r+e.x,this.y=s*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ss{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,o,u){let c=n[r+0],h=n[r+1],d=n[r+2],p=n[r+3],g=s[o+0],_=s[o+1],v=s[o+2],S=s[o+3];if(p!==S||c!==g||h!==_||d!==v){let b=c*g+h*_+d*v+p*S;b<0&&(g=-g,_=-_,v=-v,S=-S,b=-b);let x=1-u;if(b<.9995){const M=Math.acos(b),E=Math.sin(M);x=Math.sin(x*M)/E,u=Math.sin(u*M)/E,c=c*x+g*u,h=h*x+_*u,d=d*x+v*u,p=p*x+S*u}else{c=c*x+g*u,h=h*x+_*u,d=d*x+v*u,p=p*x+S*u;const M=1/Math.sqrt(c*c+h*h+d*d+p*p);c*=M,h*=M,d*=M,p*=M}}e[t]=c,e[t+1]=h,e[t+2]=d,e[t+3]=p}static multiplyQuaternionsFlat(e,t,n,r,s,o){const u=n[r],c=n[r+1],h=n[r+2],d=n[r+3],p=s[o],g=s[o+1],_=s[o+2],v=s[o+3];return e[t]=u*v+d*p+c*_-h*g,e[t+1]=c*v+d*g+h*p-u*_,e[t+2]=h*v+d*_+u*g-c*p,e[t+3]=d*v-u*p-c*g-h*_,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,o=e._order,u=Math.cos,c=Math.sin,h=u(n/2),d=u(r/2),p=u(s/2),g=c(n/2),_=c(r/2),v=c(s/2);switch(o){case"XYZ":this._x=g*d*p+h*_*v,this._y=h*_*p-g*d*v,this._z=h*d*v+g*_*p,this._w=h*d*p-g*_*v;break;case"YXZ":this._x=g*d*p+h*_*v,this._y=h*_*p-g*d*v,this._z=h*d*v-g*_*p,this._w=h*d*p+g*_*v;break;case"ZXY":this._x=g*d*p-h*_*v,this._y=h*_*p+g*d*v,this._z=h*d*v+g*_*p,this._w=h*d*p-g*_*v;break;case"ZYX":this._x=g*d*p-h*_*v,this._y=h*_*p+g*d*v,this._z=h*d*v-g*_*p,this._w=h*d*p+g*_*v;break;case"YZX":this._x=g*d*p+h*_*v,this._y=h*_*p+g*d*v,this._z=h*d*v-g*_*p,this._w=h*d*p-g*_*v;break;case"XZY":this._x=g*d*p-h*_*v,this._y=h*_*p-g*d*v,this._z=h*d*v+g*_*p,this._w=h*d*p+g*_*v;break;default:Ne("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],o=t[1],u=t[5],c=t[9],h=t[2],d=t[6],p=t[10],g=n+u+p;if(g>0){const _=.5/Math.sqrt(g+1);this._w=.25/_,this._x=(d-c)*_,this._y=(s-h)*_,this._z=(o-r)*_}else if(n>u&&n>p){const _=2*Math.sqrt(1+n-u-p);this._w=(d-c)/_,this._x=.25*_,this._y=(r+o)/_,this._z=(s+h)/_}else if(u>p){const _=2*Math.sqrt(1+u-n-p);this._w=(s-h)/_,this._x=(r+o)/_,this._y=.25*_,this._z=(c+d)/_}else{const _=2*Math.sqrt(1+p-n-u);this._w=(o-r)/_,this._x=(s+h)/_,this._y=(c+d)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(kt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,o=e._w,u=t._x,c=t._y,h=t._z,d=t._w;return this._x=n*d+o*u+r*h-s*c,this._y=r*d+o*c+s*u-n*h,this._z=s*d+o*h+n*c-r*u,this._w=o*d-n*u-r*c-s*h,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,s=e._z,o=e._w,u=this.dot(e);u<0&&(n=-n,r=-r,s=-s,o=-o,u=-u);let c=1-t;if(u<.9995){const h=Math.acos(u),d=Math.sin(h);c=Math.sin(c*h)/d,t=Math.sin(t*h)/d,this._x=this._x*c+n*t,this._y=this._y*c+r*t,this._z=this._z*c+s*t,this._w=this._w*c+o*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+r*t,this._z=this._z*c+s*t,this._w=this._w*c+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class G{constructor(e=0,t=0,n=0){G.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(H1.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(H1.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,o=e.y,u=e.z,c=e.w,h=2*(o*r-u*n),d=2*(u*t-s*r),p=2*(s*n-o*t);return this.x=t+c*h+o*p-u*d,this.y=n+c*d+u*h-s*p,this.z=r+c*p+s*d-o*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=kt(this.x,e.x,t.x),this.y=kt(this.y,e.y,t.y),this.z=kt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=kt(this.x,e,t),this.y=kt(this.y,e,t),this.z=kt(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(kt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,o=t.x,u=t.y,c=t.z;return this.x=r*c-s*u,this.y=s*o-n*c,this.z=n*u-r*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ny.copy(this).projectOnVector(e),this.sub(Ny)}reflect(e){return this.sub(Ny.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(kt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ny=new G,H1=new Ss;class Nt{constructor(e,t,n,r,s,o,u,c,h){Nt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,u,c,h)}set(e,t,n,r,s,o,u,c,h){const d=this.elements;return d[0]=e,d[1]=r,d[2]=u,d[3]=t,d[4]=s,d[5]=c,d[6]=n,d[7]=o,d[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,o=n[0],u=n[3],c=n[6],h=n[1],d=n[4],p=n[7],g=n[2],_=n[5],v=n[8],S=r[0],b=r[3],x=r[6],M=r[1],E=r[4],w=r[7],D=r[2],C=r[5],N=r[8];return s[0]=o*S+u*M+c*D,s[3]=o*b+u*E+c*C,s[6]=o*x+u*w+c*N,s[1]=h*S+d*M+p*D,s[4]=h*b+d*E+p*C,s[7]=h*x+d*w+p*N,s[2]=g*S+_*M+v*D,s[5]=g*b+_*E+v*C,s[8]=g*x+_*w+v*N,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],u=e[5],c=e[6],h=e[7],d=e[8];return t*o*d-t*u*h-n*s*d+n*u*c+r*s*h-r*o*c}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],u=e[5],c=e[6],h=e[7],d=e[8],p=d*o-u*h,g=u*c-d*s,_=h*s-o*c,v=t*p+n*g+r*_;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/v;return e[0]=p*S,e[1]=(r*h-d*n)*S,e[2]=(u*n-r*o)*S,e[3]=g*S,e[4]=(d*t-r*c)*S,e[5]=(r*s-u*t)*S,e[6]=_*S,e[7]=(n*c-h*t)*S,e[8]=(o*t-n*s)*S,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,o,u){const c=Math.cos(s),h=Math.sin(s);return this.set(n*c,n*h,-n*(c*o+h*u)+o+e,-r*h,r*c,-r*(-h*o+c*u)+u+t,0,0,1),this}scale(e,t){return this.premultiply(Dy.makeScale(e,t)),this}rotate(e){return this.premultiply(Dy.makeRotation(-e)),this}translate(e,t){return this.premultiply(Dy.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Dy=new Nt,j1=new Nt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),W1=new Nt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function lB(){const i={enabled:!0,workingColorSpace:Cu,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Ye&&(r.r=_o(r.r),r.g=_o(r.g),r.b=_o(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Ye&&(r.r=ah(r.r),r.g=ah(r.g),r.b=ah(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Dr?Bh:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return xn("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return xn("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Cu]:{primaries:e,whitePoint:n,transfer:Bh,toXYZ:j1,fromXYZ:W1,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:dr},outputColorSpaceConfig:{drawingBufferColorSpace:dr}},[dr]:{primaries:e,whitePoint:n,transfer:Ye,toXYZ:j1,fromXYZ:W1,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:dr}}}),i}const xt=lB();function _o(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ah(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Ac;class uB{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Ac===void 0&&(Ac=cp("canvas")),Ac.width=e.width,Ac.height=e.height;const r=Ac.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Ac}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=cp("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=_o(s[o]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(_o(t[n]/255)*255):t[n]=_o(t[n]);return{data:t,width:e.width,height:e.height}}else return Ne("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let cB=0;class WS{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cB++}),this.uuid=go(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,u=r.length;o<u;o++)r[o].isDataTexture?s.push(Ly(r[o].image)):s.push(Ly(r[o]))}else s=Ly(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function Ly(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?uB.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ne("Texture: Unable to serialize Texture."),{})}let hB=0;const Py=new G;class vi extends Aa{constructor(e=vi.DEFAULT_IMAGE,t=vi.DEFAULT_MAPPING,n=Pr,r=Pr,s=Rn,o=Ur,u=si,c=Gn,h=vi.DEFAULT_ANISOTROPY,d=Dr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:hB++}),this.uuid=go(),this.name="",this.source=new WS(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=h,this.format=u,this.internalFormat=null,this.type=c,this.offset=new Ie(0,0),this.repeat=new Ie(1,1),this.center=new Ie(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Nt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Py).x}get height(){return this.source.getSize(Py).y}get depth(){return this.source.getSize(Py).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Ne(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ne(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==BS)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Eu:e.x=e.x-Math.floor(e.x);break;case Pr:e.x=e.x<0?0:1;break;case Au: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 Eu:e.y=e.y-Math.floor(e.y);break;case Pr:e.y=e.y<0?0:1;break;case Au: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++}}vi.DEFAULT_IMAGE=null;vi.DEFAULT_MAPPING=BS;vi.DEFAULT_ANISOTROPY=1;class Pt{constructor(e=0,t=0,n=0,r=1){Pt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const c=e.elements,h=c[0],d=c[4],p=c[8],g=c[1],_=c[5],v=c[9],S=c[2],b=c[6],x=c[10];if(Math.abs(d-g)<.01&&Math.abs(p-S)<.01&&Math.abs(v-b)<.01){if(Math.abs(d+g)<.1&&Math.abs(p+S)<.1&&Math.abs(v+b)<.1&&Math.abs(h+_+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(h+1)/2,w=(_+1)/2,D=(x+1)/2,C=(d+g)/4,N=(p+S)/4,A=(v+b)/4;return E>w&&E>D?E<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(E),r=C/n,s=N/n):w>D?w<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(w),n=C/r,s=A/r):D<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(D),n=N/s,r=A/s),this.set(n,r,s,t),this}let M=Math.sqrt((b-v)*(b-v)+(p-S)*(p-S)+(g-d)*(g-d));return Math.abs(M)<.001&&(M=1),this.x=(b-v)/M,this.y=(p-S)/M,this.z=(g-d)/M,this.w=Math.acos((h+_+x-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=kt(this.x,e.x,t.x),this.y=kt(this.y,e.y,t.y),this.z=kt(this.z,e.z,t.z),this.w=kt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=kt(this.x,e,t),this.y=kt(this.y,e,t),this.z=kt(this.z,e,t),this.w=kt(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(kt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Rl extends Aa{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Pt(0,0,e,t),this.scissorTest=!1,this.viewport=new Pt(0,0,e,t),this.textures=[];const r={width:e,height:t,depth:n.depth},s=new vi(r),o=n.count;for(let u=0;u<o;u++)this.textures[u]=s.clone(),this.textures[u].isRenderTargetTexture=!0,this.textures[u].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:Rn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new WS(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Hs extends Rl{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class $S extends vi{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=hn,this.minFilter=hn,this.wrapR=Pr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class fB extends vi{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=hn,this.minFilter=hn,this.wrapR=Pr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Wt{constructor(e,t,n,r,s,o,u,c,h,d,p,g,_,v,S,b){Wt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,u,c,h,d,p,g,_,v,S,b)}set(e,t,n,r,s,o,u,c,h,d,p,g,_,v,S,b){const x=this.elements;return x[0]=e,x[4]=t,x[8]=n,x[12]=r,x[1]=s,x[5]=o,x[9]=u,x[13]=c,x[2]=h,x[6]=d,x[10]=p,x[14]=g,x[3]=_,x[7]=v,x[11]=S,x[15]=b,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 Wt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,r=1/wc.setFromMatrixColumn(e,0).length(),s=1/wc.setFromMatrixColumn(e,1).length(),o=1/wc.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,o=Math.cos(n),u=Math.sin(n),c=Math.cos(r),h=Math.sin(r),d=Math.cos(s),p=Math.sin(s);if(e.order==="XYZ"){const g=o*d,_=o*p,v=u*d,S=u*p;t[0]=c*d,t[4]=-c*p,t[8]=h,t[1]=_+v*h,t[5]=g-S*h,t[9]=-u*c,t[2]=S-g*h,t[6]=v+_*h,t[10]=o*c}else if(e.order==="YXZ"){const g=c*d,_=c*p,v=h*d,S=h*p;t[0]=g+S*u,t[4]=v*u-_,t[8]=o*h,t[1]=o*p,t[5]=o*d,t[9]=-u,t[2]=_*u-v,t[6]=S+g*u,t[10]=o*c}else if(e.order==="ZXY"){const g=c*d,_=c*p,v=h*d,S=h*p;t[0]=g-S*u,t[4]=-o*p,t[8]=v+_*u,t[1]=_+v*u,t[5]=o*d,t[9]=S-g*u,t[2]=-o*h,t[6]=u,t[10]=o*c}else if(e.order==="ZYX"){const g=o*d,_=o*p,v=u*d,S=u*p;t[0]=c*d,t[4]=v*h-_,t[8]=g*h+S,t[1]=c*p,t[5]=S*h+g,t[9]=_*h-v,t[2]=-h,t[6]=u*c,t[10]=o*c}else if(e.order==="YZX"){const g=o*c,_=o*h,v=u*c,S=u*h;t[0]=c*d,t[4]=S-g*p,t[8]=v*p+_,t[1]=p,t[5]=o*d,t[9]=-u*d,t[2]=-h*d,t[6]=_*p+v,t[10]=g-S*p}else if(e.order==="XZY"){const g=o*c,_=o*h,v=u*c,S=u*h;t[0]=c*d,t[4]=-p,t[8]=h*d,t[1]=g*p+S,t[5]=o*d,t[9]=_*p-v,t[2]=v*p-_,t[6]=u*d,t[10]=S*p+g}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(dB,e,pB)}lookAt(e,t,n){const r=this.elements;return Yr.subVectors(e,t),Yr.lengthSq()===0&&(Yr.z=1),Yr.normalize(),Zo.crossVectors(n,Yr),Zo.lengthSq()===0&&(Math.abs(n.z)===1?Yr.x+=1e-4:Yr.z+=1e-4,Yr.normalize(),Zo.crossVectors(n,Yr)),Zo.normalize(),$m.crossVectors(Yr,Zo),r[0]=Zo.x,r[4]=$m.x,r[8]=Yr.x,r[1]=Zo.y,r[5]=$m.y,r[9]=Yr.y,r[2]=Zo.z,r[6]=$m.z,r[10]=Yr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,o=n[0],u=n[4],c=n[8],h=n[12],d=n[1],p=n[5],g=n[9],_=n[13],v=n[2],S=n[6],b=n[10],x=n[14],M=n[3],E=n[7],w=n[11],D=n[15],C=r[0],N=r[4],A=r[8],L=r[12],j=r[1],z=r[5],H=r[9],K=r[13],te=r[2],Z=r[6],I=r[10],F=r[14],Y=r[3],se=r[7],Te=r[11],O=r[15];return s[0]=o*C+u*j+c*te+h*Y,s[4]=o*N+u*z+c*Z+h*se,s[8]=o*A+u*H+c*I+h*Te,s[12]=o*L+u*K+c*F+h*O,s[1]=d*C+p*j+g*te+_*Y,s[5]=d*N+p*z+g*Z+_*se,s[9]=d*A+p*H+g*I+_*Te,s[13]=d*L+p*K+g*F+_*O,s[2]=v*C+S*j+b*te+x*Y,s[6]=v*N+S*z+b*Z+x*se,s[10]=v*A+S*H+b*I+x*Te,s[14]=v*L+S*K+b*F+x*O,s[3]=M*C+E*j+w*te+D*Y,s[7]=M*N+E*z+w*Z+D*se,s[11]=M*A+E*H+w*I+D*Te,s[15]=M*L+E*K+w*F+D*O,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],o=e[1],u=e[5],c=e[9],h=e[13],d=e[2],p=e[6],g=e[10],_=e[14],v=e[3],S=e[7],b=e[11],x=e[15],M=c*_-h*g,E=u*_-h*p,w=u*g-c*p,D=o*_-h*d,C=o*g-c*d,N=o*p-u*d;return t*(S*M-b*E+x*w)-n*(v*M-b*D+x*C)+r*(v*E-S*D+x*N)-s*(v*w-S*C+b*N)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],u=e[5],c=e[6],h=e[7],d=e[8],p=e[9],g=e[10],_=e[11],v=e[12],S=e[13],b=e[14],x=e[15],M=t*u-n*o,E=t*c-r*o,w=t*h-s*o,D=n*c-r*u,C=n*h-s*u,N=r*h-s*c,A=d*S-p*v,L=d*b-g*v,j=d*x-_*v,z=p*b-g*S,H=p*x-_*S,K=g*x-_*b,te=M*K-E*H+w*z+D*j-C*L+N*A;if(te===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const Z=1/te;return e[0]=(u*K-c*H+h*z)*Z,e[1]=(r*H-n*K-s*z)*Z,e[2]=(S*N-b*C+x*D)*Z,e[3]=(g*C-p*N-_*D)*Z,e[4]=(c*j-o*K-h*L)*Z,e[5]=(t*K-r*j+s*L)*Z,e[6]=(b*w-v*N-x*E)*Z,e[7]=(d*N-g*w+_*E)*Z,e[8]=(o*H-u*j+h*A)*Z,e[9]=(n*j-t*H-s*A)*Z,e[10]=(v*C-S*w+x*M)*Z,e[11]=(p*w-d*C-_*M)*Z,e[12]=(u*L-o*z-c*A)*Z,e[13]=(t*z-n*L+r*A)*Z,e[14]=(S*E-v*D-b*M)*Z,e[15]=(d*D-p*E+g*M)*Z,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,o=e.x,u=e.y,c=e.z,h=s*o,d=s*u;return this.set(h*o+n,h*u-r*c,h*c+r*u,0,h*u+r*c,d*u+n,d*c-r*o,0,h*c-r*u,d*c+r*o,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,o){return this.set(1,n,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,o=t._y,u=t._z,c=t._w,h=s+s,d=o+o,p=u+u,g=s*h,_=s*d,v=s*p,S=o*d,b=o*p,x=u*p,M=c*h,E=c*d,w=c*p,D=n.x,C=n.y,N=n.z;return r[0]=(1-(S+x))*D,r[1]=(_+w)*D,r[2]=(v-E)*D,r[3]=0,r[4]=(_-w)*C,r[5]=(1-(g+x))*C,r[6]=(b+M)*C,r[7]=0,r[8]=(v+E)*N,r[9]=(b-M)*N,r[10]=(1-(g+S))*N,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const s=this.determinant();if(s===0)return n.set(1,1,1),t.identity(),this;let o=wc.set(r[0],r[1],r[2]).length();const u=wc.set(r[4],r[5],r[6]).length(),c=wc.set(r[8],r[9],r[10]).length();s<0&&(o=-o),Ps.copy(this);const h=1/o,d=1/u,p=1/c;return Ps.elements[0]*=h,Ps.elements[1]*=h,Ps.elements[2]*=h,Ps.elements[4]*=d,Ps.elements[5]*=d,Ps.elements[6]*=d,Ps.elements[8]*=p,Ps.elements[9]*=p,Ps.elements[10]*=p,t.setFromRotationMatrix(Ps),n.x=o,n.y=u,n.z=c,this}makePerspective(e,t,n,r,s,o,u=yr,c=!1){const h=this.elements,d=2*s/(t-e),p=2*s/(n-r),g=(t+e)/(t-e),_=(n+r)/(n-r);let v,S;if(c)v=s/(o-s),S=o*s/(o-s);else if(u===yr)v=-(o+s)/(o-s),S=-2*o*s/(o-s);else if(u===ba)v=-o/(o-s),S=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+u);return h[0]=d,h[4]=0,h[8]=g,h[12]=0,h[1]=0,h[5]=p,h[9]=_,h[13]=0,h[2]=0,h[6]=0,h[10]=v,h[14]=S,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,n,r,s,o,u=yr,c=!1){const h=this.elements,d=2/(t-e),p=2/(n-r),g=-(t+e)/(t-e),_=-(n+r)/(n-r);let v,S;if(c)v=1/(o-s),S=o/(o-s);else if(u===yr)v=-2/(o-s),S=-(o+s)/(o-s);else if(u===ba)v=-1/(o-s),S=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+u);return h[0]=d,h[4]=0,h[8]=0,h[12]=g,h[1]=0,h[5]=p,h[9]=0,h[13]=_,h[2]=0,h[6]=0,h[10]=v,h[14]=S,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const wc=new G,Ps=new Wt,dB=new G(0,0,0),pB=new G(1,1,1),Zo=new G,$m=new G,Yr=new G,$1=new Wt,q1=new Ss;class Br{constructor(e=0,t=0,n=0,r=Br.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],o=r[4],u=r[8],c=r[1],h=r[5],d=r[9],p=r[2],g=r[6],_=r[10];switch(t){case"XYZ":this._y=Math.asin(kt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-d,_),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(g,h),this._z=0);break;case"YXZ":this._x=Math.asin(-kt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(u,_),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-p,s),this._z=0);break;case"ZXY":this._x=Math.asin(kt(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-p,_),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-kt(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(g,_),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,h));break;case"YZX":this._z=Math.asin(kt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,h),this._y=Math.atan2(-p,s)):(this._x=0,this._y=Math.atan2(u,_));break;case"XZY":this._z=Math.asin(-kt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,h),this._y=Math.atan2(u,s)):(this._x=Math.atan2(-d,_),this._y=0);break;default:Ne("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return $1.makeRotationFromQuaternion(e),this.setFromRotationMatrix($1,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return q1.setFromEuler(this),this.setFromQuaternion(q1,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Br.DEFAULT_ORDER="XYZ";class qS{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 mB=0;const X1=new G,Rc=new Ss,Xa=new Wt,qm=new G,nd=new G,gB=new G,_B=new Ss,Y1=new G(1,0,0),K1=new G(0,1,0),Z1=new G(0,0,1),Q1={type:"added"},vB={type:"removed"},Cc={type:"childadded",child:null},Uy={type:"childremoved",child:null};class yi extends Aa{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:mB++}),this.uuid=go(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=yi.DEFAULT_UP.clone();const e=new G,t=new Br,n=new Ss,r=new G(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Wt},normalMatrix:{value:new Nt}}),this.matrix=new Wt,this.matrixWorld=new Wt,this.matrixAutoUpdate=yi.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=yi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qS,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,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Rc.setFromAxisAngle(e,t),this.quaternion.multiply(Rc),this}rotateOnWorldAxis(e,t){return Rc.setFromAxisAngle(e,t),this.quaternion.premultiply(Rc),this}rotateX(e){return this.rotateOnAxis(Y1,e)}rotateY(e){return this.rotateOnAxis(K1,e)}rotateZ(e){return this.rotateOnAxis(Z1,e)}translateOnAxis(e,t){return X1.copy(e).applyQuaternion(this.quaternion),this.position.add(X1.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Y1,e)}translateY(e){return this.translateOnAxis(K1,e)}translateZ(e){return this.translateOnAxis(Z1,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Xa.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?qm.copy(e):qm.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),nd.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Xa.lookAt(nd,qm,this.up):Xa.lookAt(qm,nd,this.up),this.quaternion.setFromRotationMatrix(Xa),r&&(Xa.extractRotation(r.matrixWorld),Rc.setFromRotationMatrix(Xa),this.quaternion.premultiply(Rc.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Pe("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(Q1),Cc.child=e,this.dispatchEvent(Cc),Cc.child=null):Pe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(vB),Uy.child=e,this.dispatchEvent(Uy),Uy.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),Xa.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Xa.multiply(e.parent.matrixWorld)),e.applyMatrix4(Xa),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Q1),Cc.child=e,this.dispatchEvent(Cc),Cc.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nd,e,gB),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nd,_B,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,r=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*n-s[8]*r,s[13]+=n-s[1]*t-s[5]*n-s[9]*r,s[14]+=r-s[2]*t-s[6]*n-s[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(u=>({...u,boundingBox:u.boundingBox?u.boundingBox.toJSON():void 0,boundingSphere:u.boundingSphere?u.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(u=>({...u})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(u,c){return u[c.uuid]===void 0&&(u[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const u=this.geometry.parameters;if(u!==void 0&&u.shapes!==void 0){const c=u.shapes;if(Array.isArray(c))for(let h=0,d=c.length;h<d;h++){const p=c[h];s(e.shapes,p)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const u=[];for(let c=0,h=this.material.length;c<h;c++)u.push(s(e.materials,this.material[c]));r.material=u}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let u=0;u<this.children.length;u++)r.children.push(this.children[u].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let u=0;u<this.animations.length;u++){const c=this.animations[u];r.animations.push(s(e.animations,c))}}if(t){const u=o(e.geometries),c=o(e.materials),h=o(e.textures),d=o(e.images),p=o(e.shapes),g=o(e.skeletons),_=o(e.animations),v=o(e.nodes);u.length>0&&(n.geometries=u),c.length>0&&(n.materials=c),h.length>0&&(n.textures=h),d.length>0&&(n.images=d),p.length>0&&(n.shapes=p),g.length>0&&(n.skeletons=g),_.length>0&&(n.animations=_),v.length>0&&(n.nodes=v)}return n.object=r,n;function o(u){const c=[];for(const h in u){const d=u[h];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),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)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}yi.DEFAULT_UP=new G(0,1,0);yi.DEFAULT_MATRIX_AUTO_UPDATE=!0;yi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;let Jc=class extends yi{constructor(){super(),this.isGroup=!0,this.type="Group"}};const yB={type:"move"};class i_{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Jc,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 Jc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new G,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new G),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Jc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new G,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new G),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,o=null;const u=this._targetRay,c=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){o=!0;for(const S of e.hand.values()){const b=t.getJointPose(S,n),x=this._getHandJoint(h,S);b!==null&&(x.matrix.fromArray(b.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=b.radius),x.visible=b!==null}const d=h.joints["index-finger-tip"],p=h.joints["thumb-tip"],g=d.position.distanceTo(p.position),_=.02,v=.005;h.inputState.pinching&&g>_+v?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&g<=_-v&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));u!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(u.matrix.fromArray(r.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,r.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(r.linearVelocity)):u.hasLinearVelocity=!1,r.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(r.angularVelocity)):u.hasAngularVelocity=!1,this.dispatchEvent(yB)))}return u!==null&&(u.visible=r!==null),c!==null&&(c.visible=s!==null),h!==null&&(h.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Jc;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const qN={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},Qo={h:0,s:0,l:0},Xm={h:0,s:0,l:0};function Oy(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class pt{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=dr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,xt.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=xt.workingColorSpace){return this.r=e,this.g=t,this.b=n,xt.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=xt.workingColorSpace){if(e=jS(e,1),t=kt(t,0,1),n=kt(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=Oy(o,s,e+1/3),this.g=Oy(o,s,e),this.b=Oy(o,s,e-1/3)}return xt.colorSpaceToWorking(this,r),this}setStyle(e,t=dr){function n(s){s!==void 0&&parseFloat(s)<1&&Ne("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=r[1],u=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Ne("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);Ne("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=dr){const n=qN[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ne("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=_o(e.r),this.g=_o(e.g),this.b=_o(e.b),this}copyLinearToSRGB(e){return this.r=ah(e.r),this.g=ah(e.g),this.b=ah(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=dr){return xt.workingToColorSpace(Qi.copy(this),e),Math.round(kt(Qi.r*255,0,255))*65536+Math.round(kt(Qi.g*255,0,255))*256+Math.round(kt(Qi.b*255,0,255))}getHexString(e=dr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=xt.workingColorSpace){xt.workingToColorSpace(Qi.copy(this),t);const n=Qi.r,r=Qi.g,s=Qi.b,o=Math.max(n,r,s),u=Math.min(n,r,s);let c,h;const d=(u+o)/2;if(u===o)c=0,h=0;else{const p=o-u;switch(h=d<=.5?p/(o+u):p/(2-o-u),o){case n:c=(r-s)/p+(r<s?6:0);break;case r:c=(s-n)/p+2;break;case s:c=(n-r)/p+4;break}c/=6}return e.h=c,e.s=h,e.l=d,e}getRGB(e,t=xt.workingColorSpace){return xt.workingToColorSpace(Qi.copy(this),t),e.r=Qi.r,e.g=Qi.g,e.b=Qi.b,e}getStyle(e=dr){xt.workingToColorSpace(Qi.copy(this),e);const t=Qi.r,n=Qi.g,r=Qi.b;return e!==dr?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Qo),this.setHSL(Qo.h+e,Qo.s+t,Qo.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Qo),e.getHSL(Xm);const n=Bd(Qo.h,Xm.h,t),r=Bd(Qo.s,Xm.s,t),s=Bd(Qo.l,Xm.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Qi=new pt;pt.NAMES=qN;class XS extends yi{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 Br,this.environmentIntensity=1,this.environmentRotation=new Br,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Us=new G,Ya=new G,By=new G,Ka=new G,Nc=new G,Dc=new G,J1=new G,Fy=new G,Iy=new G,zy=new G,ky=new Pt,Gy=new Pt,Vy=new Pt;class ks{constructor(e=new G,t=new G,n=new G){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Us.subVectors(e,t),r.cross(Us);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Us.subVectors(r,t),Ya.subVectors(n,t),By.subVectors(e,t);const o=Us.dot(Us),u=Us.dot(Ya),c=Us.dot(By),h=Ya.dot(Ya),d=Ya.dot(By),p=o*h-u*u;if(p===0)return s.set(0,0,0),null;const g=1/p,_=(h*c-u*d)*g,v=(o*d-u*c)*g;return s.set(1-_-v,v,_)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Ka)===null?!1:Ka.x>=0&&Ka.y>=0&&Ka.x+Ka.y<=1}static getInterpolation(e,t,n,r,s,o,u,c){return this.getBarycoord(e,t,n,r,Ka)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Ka.x),c.addScaledVector(o,Ka.y),c.addScaledVector(u,Ka.z),c)}static getInterpolatedAttribute(e,t,n,r,s,o){return ky.setScalar(0),Gy.setScalar(0),Vy.setScalar(0),ky.fromBufferAttribute(e,t),Gy.fromBufferAttribute(e,n),Vy.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(ky,s.x),o.addScaledVector(Gy,s.y),o.addScaledVector(Vy,s.z),o}static isFrontFacing(e,t,n,r){return Us.subVectors(n,t),Ya.subVectors(e,t),Us.cross(Ya).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Us.subVectors(this.c,this.b),Ya.subVectors(this.a,this.b),Us.cross(Ya).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ks.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ks.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return ks.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return ks.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ks.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let o,u;Nc.subVectors(r,n),Dc.subVectors(s,n),Fy.subVectors(e,n);const c=Nc.dot(Fy),h=Dc.dot(Fy);if(c<=0&&h<=0)return t.copy(n);Iy.subVectors(e,r);const d=Nc.dot(Iy),p=Dc.dot(Iy);if(d>=0&&p<=d)return t.copy(r);const g=c*p-d*h;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),t.copy(n).addScaledVector(Nc,o);zy.subVectors(e,s);const _=Nc.dot(zy),v=Dc.dot(zy);if(v>=0&&_<=v)return t.copy(s);const S=_*h-c*v;if(S<=0&&h>=0&&v<=0)return u=h/(h-v),t.copy(n).addScaledVector(Dc,u);const b=d*v-_*p;if(b<=0&&p-d>=0&&_-v>=0)return J1.subVectors(s,r),u=(p-d)/(p-d+(_-v)),t.copy(r).addScaledVector(J1,u);const x=1/(b+S+g);return o=S*x,u=g*x,t.copy(n).addScaledVector(Nc,o).addScaledVector(Dc,u)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Iu{constructor(e=new G(1/0,1/0,1/0),t=new G(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Os.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Os.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Os.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,u=s.count;o<u;o++)e.isMesh===!0?e.getVertexPosition(o,Os):Os.fromBufferAttribute(s,o),Os.applyMatrix4(e.matrixWorld),this.expandByPoint(Os);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ym.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Ym.copy(n.boundingBox)),Ym.applyMatrix4(e.matrixWorld),this.union(Ym)}const r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Os),Os.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(id),Km.subVectors(this.max,id),Lc.subVectors(e.a,id),Pc.subVectors(e.b,id),Uc.subVectors(e.c,id),Jo.subVectors(Pc,Lc),el.subVectors(Uc,Pc),Zl.subVectors(Lc,Uc);let t=[0,-Jo.z,Jo.y,0,-el.z,el.y,0,-Zl.z,Zl.y,Jo.z,0,-Jo.x,el.z,0,-el.x,Zl.z,0,-Zl.x,-Jo.y,Jo.x,0,-el.y,el.x,0,-Zl.y,Zl.x,0];return!Hy(t,Lc,Pc,Uc,Km)||(t=[1,0,0,0,1,0,0,0,1],!Hy(t,Lc,Pc,Uc,Km))?!1:(Zm.crossVectors(Jo,el),t=[Zm.x,Zm.y,Zm.z],Hy(t,Lc,Pc,Uc,Km))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Os).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Os).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:(Za[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Za[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Za[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Za[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Za[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Za[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Za[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Za[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Za),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 Za=[new G,new G,new G,new G,new G,new G,new G,new G],Os=new G,Ym=new Iu,Lc=new G,Pc=new G,Uc=new G,Jo=new G,el=new G,Zl=new G,id=new G,Km=new G,Zm=new G,Ql=new G;function Hy(i,e,t,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){Ql.fromArray(i,s);const u=r.x*Math.abs(Ql.x)+r.y*Math.abs(Ql.y)+r.z*Math.abs(Ql.z),c=e.dot(Ql),h=t.dot(Ql),d=n.dot(Ql);if(Math.max(-Math.max(c,h,d),Math.min(c,h,d))>u)return!1}return!0}const ao=xB();function xB(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let c=0;c<256;++c){const h=c-127;h<-27?(n[c]=0,n[c|256]=32768,r[c]=24,r[c|256]=24):h<-14?(n[c]=1024>>-h-14,n[c|256]=1024>>-h-14|32768,r[c]=-h-1,r[c|256]=-h-1):h<=15?(n[c]=h+15<<10,n[c|256]=h+15<<10|32768,r[c]=13,r[c|256]=13):h<128?(n[c]=31744,n[c|256]=64512,r[c]=24,r[c|256]=24):(n[c]=31744,n[c|256]=64512,r[c]=13,r[c|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),u=new Uint32Array(64);for(let c=1;c<1024;++c){let h=c<<13,d=0;for(;(h&8388608)===0;)h<<=1,d-=8388608;h&=-8388609,d+=947912704,s[c]=h|d}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(u[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:u}}function Kr(i){Math.abs(i)>65504&&Ne("DataUtils.toHalfFloat(): Value out of range."),i=kt(i,-65504,65504),ao.floatView[0]=i;const e=ao.uint32View[0],t=e>>23&511;return ao.baseTable[t]+((e&8388607)>>ao.shiftTable[t])}function Qm(i){const e=i>>10;return ao.uint32View[0]=ao.mantissaTable[ao.offsetTable[e]+(i&1023)]+ao.exponentTable[e],ao.floatView[0]}const _i=new G,Jm=new Ie;let bB=0;class $i{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:bB++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Fh,this.updateRanges=[],this.gpuType=ri,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Jm.fromBufferAttribute(this,t),Jm.applyMatrix3(e),this.setXY(t,Jm.x,Jm.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)_i.fromBufferAttribute(this,t),_i.applyMatrix3(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)_i.fromBufferAttribute(this,t),_i.applyMatrix4(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)_i.fromBufferAttribute(this,t),_i.applyNormalMatrix(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)_i.fromBufferAttribute(this,t),_i.transformDirection(e),this.setXYZ(t,_i.x,_i.y,_i.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=mr(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=zt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=mr(t,this.array)),t}setX(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=mr(t,this.array)),t}setY(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=mr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=mr(t,this.array)),t}setW(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=zt(t,this.array),n=zt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=zt(t,this.array),n=zt(n,this.array),r=zt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=zt(t,this.array),n=zt(n,this.array),r=zt(r,this.array),s=zt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,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!==Fh&&(e.usage=this.usage),e}}class YS extends $i{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class KS extends $i{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class XN extends $i{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Qm(this.array[e*this.itemSize]);return this.normalized&&(t=mr(t,this.array)),t}setX(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize]=Kr(t),this}getY(e){let t=Qm(this.array[e*this.itemSize+1]);return this.normalized&&(t=mr(t,this.array)),t}setY(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize+1]=Kr(t),this}getZ(e){let t=Qm(this.array[e*this.itemSize+2]);return this.normalized&&(t=mr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize+2]=Kr(t),this}getW(e){let t=Qm(this.array[e*this.itemSize+3]);return this.normalized&&(t=mr(t,this.array)),t}setW(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize+3]=Kr(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=zt(t,this.array),n=zt(n,this.array)),this.array[e+0]=Kr(t),this.array[e+1]=Kr(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=zt(t,this.array),n=zt(n,this.array),r=zt(r,this.array)),this.array[e+0]=Kr(t),this.array[e+1]=Kr(n),this.array[e+2]=Kr(r),this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=zt(t,this.array),n=zt(n,this.array),r=zt(r,this.array),s=zt(s,this.array)),this.array[e+0]=Kr(t),this.array[e+1]=Kr(n),this.array[e+2]=Kr(r),this.array[e+3]=Kr(s),this}}class ti extends $i{constructor(e,t,n){super(new Float32Array(e),t,n)}}const SB=new Iu,rd=new G,jy=new G;class Sp{constructor(e=new G,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):SB.setFromPoints(e).getCenter(n);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;rd.subVectors(e,this.center);const t=rd.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(rd,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(jy.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(rd.copy(e.center).add(jy)),this.expandByPoint(rd.copy(e.center).sub(jy))),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 TB=0;const ds=new Wt,Wy=new yi,Oc=new G,Zr=new Iu,sd=new Iu,Ni=new G;class Fi extends Aa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:TB++}),this.uuid=go(),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={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(jO(e)?KS:YS)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Nt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return ds.makeRotationFromQuaternion(e),this.applyMatrix4(ds),this}rotateX(e){return ds.makeRotationX(e),this.applyMatrix4(ds),this}rotateY(e){return ds.makeRotationY(e),this.applyMatrix4(ds),this}rotateZ(e){return ds.makeRotationZ(e),this.applyMatrix4(ds),this}translate(e,t,n){return ds.makeTranslation(e,t,n),this.applyMatrix4(ds),this}scale(e,t,n){return ds.makeScale(e,t,n),this.applyMatrix4(ds),this}lookAt(e){return Wy.lookAt(e),Wy.updateMatrix(),this.applyMatrix4(Wy.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Oc).negate(),this.translate(Oc.x,Oc.y,Oc.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new ti(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&Ne("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Iu);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Pe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new G(-1/0,-1/0,-1/0),new G(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];Zr.setFromBufferAttribute(s),this.morphTargetsRelative?(Ni.addVectors(this.boundingBox.min,Zr.min),this.boundingBox.expandByPoint(Ni),Ni.addVectors(this.boundingBox.max,Zr.max),this.boundingBox.expandByPoint(Ni)):(this.boundingBox.expandByPoint(Zr.min),this.boundingBox.expandByPoint(Zr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Pe('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 Sp);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Pe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new G,1/0);return}if(e){const n=this.boundingSphere.center;if(Zr.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const u=t[s];sd.setFromBufferAttribute(u),this.morphTargetsRelative?(Ni.addVectors(Zr.min,sd.min),Zr.expandByPoint(Ni),Ni.addVectors(Zr.max,sd.max),Zr.expandByPoint(Ni)):(Zr.expandByPoint(sd.min),Zr.expandByPoint(sd.max))}Zr.getCenter(n);let r=0;for(let s=0,o=e.count;s<o;s++)Ni.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(Ni));if(t)for(let s=0,o=t.length;s<o;s++){const u=t[s],c=this.morphTargetsRelative;for(let h=0,d=u.count;h<d;h++)Ni.fromBufferAttribute(u,h),c&&(Oc.fromBufferAttribute(e,h),Ni.add(Oc)),r=Math.max(r,n.distanceToSquared(Ni))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Pe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Pe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new $i(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),u=[],c=[];for(let A=0;A<n.count;A++)u[A]=new G,c[A]=new G;const h=new G,d=new G,p=new G,g=new Ie,_=new Ie,v=new Ie,S=new G,b=new G;function x(A,L,j){h.fromBufferAttribute(n,A),d.fromBufferAttribute(n,L),p.fromBufferAttribute(n,j),g.fromBufferAttribute(s,A),_.fromBufferAttribute(s,L),v.fromBufferAttribute(s,j),d.sub(h),p.sub(h),_.sub(g),v.sub(g);const z=1/(_.x*v.y-v.x*_.y);isFinite(z)&&(S.copy(d).multiplyScalar(v.y).addScaledVector(p,-_.y).multiplyScalar(z),b.copy(p).multiplyScalar(_.x).addScaledVector(d,-v.x).multiplyScalar(z),u[A].add(S),u[L].add(S),u[j].add(S),c[A].add(b),c[L].add(b),c[j].add(b))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let A=0,L=M.length;A<L;++A){const j=M[A],z=j.start,H=j.count;for(let K=z,te=z+H;K<te;K+=3)x(e.getX(K+0),e.getX(K+1),e.getX(K+2))}const E=new G,w=new G,D=new G,C=new G;function N(A){D.fromBufferAttribute(r,A),C.copy(D);const L=u[A];E.copy(L),E.sub(D.multiplyScalar(D.dot(L))).normalize(),w.crossVectors(C,L);const z=w.dot(c[A])<0?-1:1;o.setXYZW(A,E.x,E.y,E.z,z)}for(let A=0,L=M.length;A<L;++A){const j=M[A],z=j.start,H=j.count;for(let K=z,te=z+H;K<te;K+=3)N(e.getX(K+0)),N(e.getX(K+1)),N(e.getX(K+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new $i(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let g=0,_=n.count;g<_;g++)n.setXYZ(g,0,0,0);const r=new G,s=new G,o=new G,u=new G,c=new G,h=new G,d=new G,p=new G;if(e)for(let g=0,_=e.count;g<_;g+=3){const v=e.getX(g+0),S=e.getX(g+1),b=e.getX(g+2);r.fromBufferAttribute(t,v),s.fromBufferAttribute(t,S),o.fromBufferAttribute(t,b),d.subVectors(o,s),p.subVectors(r,s),d.cross(p),u.fromBufferAttribute(n,v),c.fromBufferAttribute(n,S),h.fromBufferAttribute(n,b),u.add(d),c.add(d),h.add(d),n.setXYZ(v,u.x,u.y,u.z),n.setXYZ(S,c.x,c.y,c.z),n.setXYZ(b,h.x,h.y,h.z)}else for(let g=0,_=t.count;g<_;g+=3)r.fromBufferAttribute(t,g+0),s.fromBufferAttribute(t,g+1),o.fromBufferAttribute(t,g+2),d.subVectors(o,s),p.subVectors(r,s),d.cross(p),n.setXYZ(g+0,d.x,d.y,d.z),n.setXYZ(g+1,d.x,d.y,d.z),n.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ni.fromBufferAttribute(e,t),Ni.normalize(),e.setXYZ(t,Ni.x,Ni.y,Ni.z)}toNonIndexed(){function e(u,c){const h=u.array,d=u.itemSize,p=u.normalized,g=new h.constructor(c.length*d);let _=0,v=0;for(let S=0,b=c.length;S<b;S++){u.isInterleavedBufferAttribute?_=c[S]*u.data.stride+u.offset:_=c[S]*d;for(let x=0;x<d;x++)g[v++]=h[_++]}return new $i(g,d,p)}if(this.index===null)return Ne("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Fi,n=this.index.array,r=this.attributes;for(const u in r){const c=r[u],h=e(c,n);t.setAttribute(u,h)}const s=this.morphAttributes;for(const u in s){const c=[],h=s[u];for(let d=0,p=h.length;d<p;d++){const g=h[d],_=e(g,n);c.push(_)}t.morphAttributes[u]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let u=0,c=o.length;u<c;u++){const h=o[u];t.addGroup(h.start,h.count,h.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const h in c)c[h]!==void 0&&(e[h]=c[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const h=n[c];e.data.attributes[c]=h.toJSON(e.data)}const r={};let s=!1;for(const c in this.morphAttributes){const h=this.morphAttributes[c],d=[];for(let p=0,g=h.length;p<g;p++){const _=h[p];d.push(_.toJSON(e.data))}d.length>0&&(r[c]=d,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const u=this.boundingSphere;return u!==null&&(e.data.boundingSphere=u.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const h in r){const d=r[h];this.setAttribute(h,d.clone(t))}const s=e.morphAttributes;for(const h in s){const d=[],p=s[h];for(let g=0,_=p.length;g<_;g++)d.push(p[g].clone(t));this.morphAttributes[h]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let h=0,d=o.length;h<d;h++){const p=o[h];this.addGroup(p.start,p.count,p.materialIndex)}const u=e.boundingBox;u!==null&&(this.boundingBox=u.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}class YN{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Fh,this.updateRanges=[],this.version=0,this.uuid=go()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=go()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=go()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const cr=new G;class ZS{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)cr.fromBufferAttribute(this,t),cr.applyMatrix4(e),this.setXYZ(t,cr.x,cr.y,cr.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cr.fromBufferAttribute(this,t),cr.applyNormalMatrix(e),this.setXYZ(t,cr.x,cr.y,cr.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cr.fromBufferAttribute(this,t),cr.transformDirection(e),this.setXYZ(t,cr.x,cr.y,cr.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=mr(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=zt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=zt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=mr(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=mr(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=mr(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=mr(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=zt(t,this.array),n=zt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=zt(t,this.array),n=zt(n,this.array),r=zt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=zt(t,this.array),n=zt(n,this.array),r=zt(r,this.array),s=zt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){hp("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new $i(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ZS(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){hp("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let MB=0;class ir extends Aa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:MB++}),this.uuid=go(),this.name="",this.type="Material",this.blending=pr,this.side=xr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Kd,this.blendDst=Zd,this.blendEquation=nr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new pt(0,0,0),this.blendAlpha=0,this.depthFunc=Tl,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wb,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=au,this.stencilZFail=au,this.stencilZPass=au,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Ne(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ne(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==pr&&(n.blending=this.blending),this.side!==xr&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Kd&&(n.blendSrc=this.blendSrc),this.blendDst!==Zd&&(n.blendDst=this.blendDst),this.blendEquation!==nr&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Tl&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wb&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==au&&(n.stencilFail=this.stencilFail),this.stencilZFail!==au&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==au&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const o=[];for(const u in s){const c=s[u];delete c.metadata,o.push(c)}return o}if(t){const s=r(e.textures),o=r(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.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++}}class EB extends ir{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new pt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Qa=new G,$y=new G,eg=new G,tl=new G,qy=new G,tg=new G,Xy=new G;class $_{constructor(e=new G,t=new G(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Qa)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Qa.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Qa.copy(this.origin).addScaledVector(this.direction,t),Qa.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){$y.copy(e).add(t).multiplyScalar(.5),eg.copy(t).sub(e).normalize(),tl.copy(this.origin).sub($y);const s=e.distanceTo(t)*.5,o=-this.direction.dot(eg),u=tl.dot(this.direction),c=-tl.dot(eg),h=tl.lengthSq(),d=Math.abs(1-o*o);let p,g,_,v;if(d>0)if(p=o*c-u,g=o*u-c,v=s*d,p>=0)if(g>=-v)if(g<=v){const S=1/d;p*=S,g*=S,_=p*(p+o*g+2*u)+g*(o*p+g+2*c)+h}else g=s,p=Math.max(0,-(o*g+u)),_=-p*p+g*(g+2*c)+h;else g=-s,p=Math.max(0,-(o*g+u)),_=-p*p+g*(g+2*c)+h;else g<=-v?(p=Math.max(0,-(-o*s+u)),g=p>0?-s:Math.min(Math.max(-s,-c),s),_=-p*p+g*(g+2*c)+h):g<=v?(p=0,g=Math.min(Math.max(-s,-c),s),_=g*(g+2*c)+h):(p=Math.max(0,-(o*s+u)),g=p>0?s:Math.min(Math.max(-s,-c),s),_=-p*p+g*(g+2*c)+h);else g=o>0?-s:s,p=Math.max(0,-(o*g+u)),_=-p*p+g*(g+2*c)+h;return n&&n.copy(this.origin).addScaledVector(this.direction,p),r&&r.copy($y).addScaledVector(eg,g),_}intersectSphere(e,t){Qa.subVectors(e.center,this.origin);const n=Qa.dot(this.direction),r=Qa.dot(Qa)-n*n,s=e.radius*e.radius;if(r>s)return null;const o=Math.sqrt(s-r),u=n-o,c=n+o;return c<0?null:u<0?this.at(c,t):this.at(u,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,o,u,c;const h=1/this.direction.x,d=1/this.direction.y,p=1/this.direction.z,g=this.origin;return h>=0?(n=(e.min.x-g.x)*h,r=(e.max.x-g.x)*h):(n=(e.max.x-g.x)*h,r=(e.min.x-g.x)*h),d>=0?(s=(e.min.y-g.y)*d,o=(e.max.y-g.y)*d):(s=(e.max.y-g.y)*d,o=(e.min.y-g.y)*d),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o<r||isNaN(r))&&(r=o),p>=0?(u=(e.min.z-g.z)*p,c=(e.max.z-g.z)*p):(u=(e.max.z-g.z)*p,c=(e.min.z-g.z)*p),n>c||u>r)||((u>n||n!==n)&&(n=u),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Qa)!==null}intersectTriangle(e,t,n,r,s){qy.subVectors(t,e),tg.subVectors(n,e),Xy.crossVectors(qy,tg);let o=this.direction.dot(Xy),u;if(o>0){if(r)return null;u=1}else if(o<0)u=-1,o=-o;else return null;tl.subVectors(this.origin,e);const c=u*this.direction.dot(tg.crossVectors(tl,tg));if(c<0)return null;const h=u*this.direction.dot(qy.cross(tl));if(h<0||c+h>o)return null;const d=-u*tl.dot(Xy);return d<0?null:this.at(d/o,s)}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 ca extends ir{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new pt(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 Br,this.combine=yp,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 ew=new Wt,Jl=new $_,ng=new Sp,tw=new G,ig=new G,rg=new G,sg=new G,Yy=new G,ag=new G,nw=new G,og=new G;class xi extends yi{constructor(e=new Fi,t=new ca){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const u=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[u]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const u=this.morphTargetInfluences;if(s&&u){ag.set(0,0,0);for(let c=0,h=s.length;c<h;c++){const d=u[c],p=s[c];d!==0&&(Yy.fromBufferAttribute(p,e),o?ag.addScaledVector(Yy,d):ag.addScaledVector(Yy.sub(t),d))}t.add(ag)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ng.copy(n.boundingSphere),ng.applyMatrix4(s),Jl.copy(e.ray).recast(e.near),!(ng.containsPoint(Jl.origin)===!1&&(Jl.intersectSphere(ng,tw)===null||Jl.origin.distanceToSquared(tw)>(e.far-e.near)**2))&&(ew.copy(s).invert(),Jl.copy(e.ray).applyMatrix4(ew),!(n.boundingBox!==null&&Jl.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Jl)))}_computeIntersections(e,t,n){let r;const s=this.geometry,o=this.material,u=s.index,c=s.attributes.position,h=s.attributes.uv,d=s.attributes.uv1,p=s.attributes.normal,g=s.groups,_=s.drawRange;if(u!==null)if(Array.isArray(o))for(let v=0,S=g.length;v<S;v++){const b=g[v],x=o[b.materialIndex],M=Math.max(b.start,_.start),E=Math.min(u.count,Math.min(b.start+b.count,_.start+_.count));for(let w=M,D=E;w<D;w+=3){const C=u.getX(w),N=u.getX(w+1),A=u.getX(w+2);r=lg(this,x,e,n,h,d,p,C,N,A),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=b.materialIndex,t.push(r))}}else{const v=Math.max(0,_.start),S=Math.min(u.count,_.start+_.count);for(let b=v,x=S;b<x;b+=3){const M=u.getX(b),E=u.getX(b+1),w=u.getX(b+2);r=lg(this,o,e,n,h,d,p,M,E,w),r&&(r.faceIndex=Math.floor(b/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let v=0,S=g.length;v<S;v++){const b=g[v],x=o[b.materialIndex],M=Math.max(b.start,_.start),E=Math.min(c.count,Math.min(b.start+b.count,_.start+_.count));for(let w=M,D=E;w<D;w+=3){const C=w,N=w+1,A=w+2;r=lg(this,x,e,n,h,d,p,C,N,A),r&&(r.faceIndex=Math.floor(w/3),r.face.materialIndex=b.materialIndex,t.push(r))}}else{const v=Math.max(0,_.start),S=Math.min(c.count,_.start+_.count);for(let b=v,x=S;b<x;b+=3){const M=b,E=b+1,w=b+2;r=lg(this,o,e,n,h,d,p,M,E,w),r&&(r.faceIndex=Math.floor(b/3),t.push(r))}}}}function AB(i,e,t,n,r,s,o,u){let c;if(e.side===Tn?c=n.intersectTriangle(o,s,r,!0,u):c=n.intersectTriangle(r,s,o,e.side===xr,u),c===null)return null;og.copy(u),og.applyMatrix4(i.matrixWorld);const h=t.ray.origin.distanceTo(og);return h<t.near||h>t.far?null:{distance:h,point:og.clone(),object:i}}function lg(i,e,t,n,r,s,o,u,c,h){i.getVertexPosition(u,ig),i.getVertexPosition(c,rg),i.getVertexPosition(h,sg);const d=AB(i,e,t,n,ig,rg,sg,nw);if(d){const p=new G;ks.getBarycoord(nw,ig,rg,sg,p),r&&(d.uv=ks.getInterpolatedAttribute(r,u,c,h,p,new Ie)),s&&(d.uv1=ks.getInterpolatedAttribute(s,u,c,h,p,new Ie)),o&&(d.normal=ks.getInterpolatedAttribute(o,u,c,h,p,new G),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const g={a:u,b:c,c:h,normal:new G,materialIndex:0};ks.getNormal(ig,rg,sg,g.normal),d.face=g,d.barycoord=p}return d}class QS extends vi{constructor(e=null,t=1,n=1,r,s,o,u,c,h=hn,d=hn,p,g){super(null,o,u,c,h,d,r,s,p,g),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class wB extends $i{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Ky=new G,RB=new G,CB=new Nt;class zs{constructor(e=new G(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Ky.subVectors(n,t).cross(RB.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Ky),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||CB.getNormalMatrix(e),r=this.coplanarPoint(Ky).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),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 eu=new Sp,NB=new Ie(.5,.5),ug=new G;class Tp{constructor(e=new zs,t=new zs,n=new zs,r=new zs,s=new zs,o=new zs){this.planes=[e,t,n,r,s,o]}set(e,t,n,r,s,o){const u=this.planes;return u[0].copy(e),u[1].copy(t),u[2].copy(n),u[3].copy(r),u[4].copy(s),u[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=yr,n=!1){const r=this.planes,s=e.elements,o=s[0],u=s[1],c=s[2],h=s[3],d=s[4],p=s[5],g=s[6],_=s[7],v=s[8],S=s[9],b=s[10],x=s[11],M=s[12],E=s[13],w=s[14],D=s[15];if(r[0].setComponents(h-o,_-d,x-v,D-M).normalize(),r[1].setComponents(h+o,_+d,x+v,D+M).normalize(),r[2].setComponents(h+u,_+p,x+S,D+E).normalize(),r[3].setComponents(h-u,_-p,x-S,D-E).normalize(),n)r[4].setComponents(c,g,b,w).normalize(),r[5].setComponents(h-c,_-g,x-b,D-w).normalize();else if(r[4].setComponents(h-c,_-g,x-b,D-w).normalize(),t===yr)r[5].setComponents(h+c,_+g,x+b,D+w).normalize();else if(t===ba)r[5].setComponents(c,g,b,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),eu.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),eu.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(eu)}intersectsSprite(e){eu.center.set(0,0,0);const t=NB.distanceTo(e.center);return eu.radius=.7071067811865476+t,eu.applyMatrix4(e.matrixWorld),this.intersectsSphere(eu)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(ug.x=r.normal.x>0?e.max.x:e.min.x,ug.y=r.normal.y>0?e.max.y:e.min.y,ug.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(ug)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Ks=new Wt,Zs=new Tp;class JS{constructor(){this.coordinateSystem=yr}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(Ks.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Zs.setFromProjectionMatrix(Ks,r.coordinateSystem,r.reversedDepth),Zs.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(Ks.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Zs.setFromProjectionMatrix(Ks,r.coordinateSystem,r.reversedDepth),Zs.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(Ks.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Zs.setFromProjectionMatrix(Ks,r.coordinateSystem,r.reversedDepth),Zs.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(Ks.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Zs.setFromProjectionMatrix(Ks,r.coordinateSystem,r.reversedDepth),Zs.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(Ks.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Zs.setFromProjectionMatrix(Ks,r.coordinateSystem,r.reversedDepth),Zs.containsPoint(e))return!0}return!1}clone(){return new JS}}class q_ extends ir{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new pt(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 __=new G,v_=new G,iw=new Wt,ad=new $_,cg=new Sp,Zy=new G,rw=new G;class DB extends yi{constructor(e=new Fi,t=new q_){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r<s;r++)__.fromBufferAttribute(t,r-1),v_.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=__.distanceTo(v_);e.setAttribute("lineDistance",new ti(n,1))}else Ne("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),cg.copy(n.boundingSphere),cg.applyMatrix4(r),cg.radius+=s,e.ray.intersectsSphere(cg)===!1)return;iw.copy(r).invert(),ad.copy(e.ray).applyMatrix4(iw);const u=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=u*u,h=this.isLineSegments?2:1,d=n.index,g=n.attributes.position;if(d!==null){const _=Math.max(0,o.start),v=Math.min(d.count,o.start+o.count);for(let S=_,b=v-1;S<b;S+=h){const x=d.getX(S),M=d.getX(S+1),E=hg(this,e,ad,c,x,M,S);E&&t.push(E)}if(this.isLineLoop){const S=d.getX(v-1),b=d.getX(_),x=hg(this,e,ad,c,S,b,v-1);x&&t.push(x)}}else{const _=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let S=_,b=v-1;S<b;S+=h){const x=hg(this,e,ad,c,S,S+1,S);x&&t.push(x)}if(this.isLineLoop){const S=hg(this,e,ad,c,v-1,_,v-1);S&&t.push(S)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const u=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[u]=s}}}}}function hg(i,e,t,n,r,s,o){const u=i.geometry.attributes.position;if(__.fromBufferAttribute(u,r),v_.fromBufferAttribute(u,s),t.distanceSqToSegment(__,v_,Zy,rw)>n)return;Zy.applyMatrix4(i.matrixWorld);const h=e.ray.origin.distanceTo(Zy);if(!(h<e.near||h>e.far))return{distance:h,point:rw.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}class LB extends ir{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new pt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}class KN extends vi{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=hn,this.minFilter=hn,this.generateMipmaps=!1,this.needsUpdate=!0}}class Kh extends vi{constructor(e=[],t=js,n,r,s,o,u,c,h,d){super(e,t,n,r,s,o,u,c,h,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class br extends vi{constructor(e,t,n=bn,r,s,o,u=hn,c=hn,h,d=Wi,p=1){if(d!==Wi&&d!==_r)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:t,depth:p};super(g,r,s,o,u,c,d,n,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new WS(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class ZN extends br{constructor(e,t=bn,n=js,r,s,o=hn,u=hn,c,h=Wi){const d={width:e,height:e,depth:1},p=[d,d,d,d,d,d];super(e,e,t,n,r,s,o,u,c,h),this.image=p,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class QN extends vi{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class zu extends Fi{constructor(e=1,t=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};const u=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const c=[],h=[],d=[],p=[];let g=0,_=0;v("z","y","x",-1,-1,n,t,e,o,s,0),v("z","y","x",1,-1,n,t,-e,o,s,1),v("x","z","y",1,1,e,n,t,r,o,2),v("x","z","y",1,-1,e,n,-t,r,o,3),v("x","y","z",1,-1,e,t,n,r,s,4),v("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new ti(h,3)),this.setAttribute("normal",new ti(d,3)),this.setAttribute("uv",new ti(p,2));function v(S,b,x,M,E,w,D,C,N,A,L){const j=w/N,z=D/A,H=w/2,K=D/2,te=C/2,Z=N+1,I=A+1;let F=0,Y=0;const se=new G;for(let Te=0;Te<I;Te++){const O=Te*z-K;for(let W=0;W<Z;W++){const ce=W*j-H;se[S]=ce*M,se[b]=O*E,se[x]=te,h.push(se.x,se.y,se.z),se[S]=0,se[b]=0,se[x]=C>0?1:-1,d.push(se.x,se.y,se.z),p.push(W/N),p.push(1-Te/A),F+=1}}for(let Te=0;Te<A;Te++)for(let O=0;O<N;O++){const W=g+O+Z*Te,ce=g+O+Z*(Te+1),Le=g+(O+1)+Z*(Te+1),ee=g+(O+1)+Z*Te;c.push(W,ce,ee),c.push(ce,Le,ee),Y+=6}u.addGroup(_,Y,L),_+=Y,g+=F}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zu(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Mp extends Fi{constructor(e=1,t=1,n=1,r=32,s=1,o=!1,u=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:u,thetaLength:c};const h=this;r=Math.floor(r),s=Math.floor(s);const d=[],p=[],g=[],_=[];let v=0;const S=[],b=n/2;let x=0;M(),o===!1&&(e>0&&E(!0),t>0&&E(!1)),this.setIndex(d),this.setAttribute("position",new ti(p,3)),this.setAttribute("normal",new ti(g,3)),this.setAttribute("uv",new ti(_,2));function M(){const w=new G,D=new G;let C=0;const N=(t-e)/n;for(let A=0;A<=s;A++){const L=[],j=A/s,z=j*(t-e)+e;for(let H=0;H<=r;H++){const K=H/r,te=K*c+u,Z=Math.sin(te),I=Math.cos(te);D.x=z*Z,D.y=-j*n+b,D.z=z*I,p.push(D.x,D.y,D.z),w.set(Z,N,I).normalize(),g.push(w.x,w.y,w.z),_.push(K,1-j),L.push(v++)}S.push(L)}for(let A=0;A<r;A++)for(let L=0;L<s;L++){const j=S[L][A],z=S[L+1][A],H=S[L+1][A+1],K=S[L][A+1];(e>0||L!==0)&&(d.push(j,z,K),C+=3),(t>0||L!==s-1)&&(d.push(z,H,K),C+=3)}h.addGroup(x,C,0),x+=C}function E(w){const D=v,C=new Ie,N=new G;let A=0;const L=w===!0?e:t,j=w===!0?1:-1;for(let H=1;H<=r;H++)p.push(0,b*j,0),g.push(0,j,0),_.push(.5,.5),v++;const z=v;for(let H=0;H<=r;H++){const te=H/r*c+u,Z=Math.cos(te),I=Math.sin(te);N.x=L*I,N.y=b*j,N.z=L*Z,p.push(N.x,N.y,N.z),g.push(0,j,0),C.x=Z*.5+.5,C.y=I*.5*j+.5,_.push(C.x,C.y),v++}for(let H=0;H<r;H++){const K=D+H,te=z+H;w===!0?d.push(te,te+1,K):d.push(te+1,te,K),A+=3}h.addGroup(x,A,w===!0?1:2),x+=A}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mp(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class eT extends Mp{constructor(e=1,t=1,n=32,r=1,s=!1,o=0,u=Math.PI*2){super(0,e,t,n,r,s,o,u),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:u}}static fromJSON(e){return new eT(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class To{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Ne("Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let r=0;const s=n.length;let o;t?o=t:o=e*n[s-1];let u=0,c=s-1,h;for(;u<=c;)if(r=Math.floor(u+(c-u)/2),h=n[r]-o,h<0)u=r+1;else if(h>0)c=r-1;else{c=r;break}if(r=c,n[r]===o)return r/(s-1);const d=n[r],g=n[r+1]-d,_=(o-d)/g;return(r+_)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),u=this.getPoint(s),c=t||(o.isVector2?new Ie:new G);return c.copy(u).sub(o).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new G,r=[],s=[],o=[],u=new G,c=new Wt;for(let _=0;_<=e;_++){const v=_/e;r[_]=this.getTangentAt(v,new G)}s[0]=new G,o[0]=new G;let h=Number.MAX_VALUE;const d=Math.abs(r[0].x),p=Math.abs(r[0].y),g=Math.abs(r[0].z);d<=h&&(h=d,n.set(1,0,0)),p<=h&&(h=p,n.set(0,1,0)),g<=h&&n.set(0,0,1),u.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],u),o[0].crossVectors(r[0],s[0]);for(let _=1;_<=e;_++){if(s[_]=s[_-1].clone(),o[_]=o[_-1].clone(),u.crossVectors(r[_-1],r[_]),u.length()>Number.EPSILON){u.normalize();const v=Math.acos(kt(r[_-1].dot(r[_]),-1,1));s[_].applyMatrix4(c.makeRotationAxis(u,v))}o[_].crossVectors(r[_],s[_])}if(t===!0){let _=Math.acos(kt(s[0].dot(s[e]),-1,1));_/=e,r[0].dot(u.crossVectors(s[0],s[e]))>0&&(_=-_);for(let v=1;v<=e;v++)s[v].applyMatrix4(c.makeRotationAxis(r[v],_*v)),o[v].crossVectors(r[v],s[v])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class JN extends To{constructor(e=0,t=0,n=1,r=1,s=0,o=Math.PI*2,u=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=u,this.aRotation=c}getPoint(e,t=new Ie){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);const u=this.aStartAngle+e*s;let c=this.aX+this.xRadius*Math.cos(u),h=this.aY+this.yRadius*Math.sin(u);if(this.aRotation!==0){const d=Math.cos(this.aRotation),p=Math.sin(this.aRotation),g=c-this.aX,_=h-this.aY;c=g*d-_*p+this.aX,h=g*p+_*d+this.aY}return n.set(c,h)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class PB extends JN{constructor(e,t,n,r,s,o){super(e,t,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function tT(){let i=0,e=0,t=0,n=0;function r(s,o,u,c){i=s,e=u,t=-3*s+3*o-2*u-c,n=2*s-2*o+u+c}return{initCatmullRom:function(s,o,u,c,h){r(o,u,h*(u-s),h*(c-o))},initNonuniformCatmullRom:function(s,o,u,c,h,d,p){let g=(o-s)/h-(u-s)/(h+d)+(u-o)/d,_=(u-o)/d-(c-o)/(d+p)+(c-u)/p;g*=d,_*=d,r(o,u,g,_)},calc:function(s){const o=s*s,u=o*s;return i+e*s+t*o+n*u}}}const fg=new G,Qy=new tT,Jy=new tT,ex=new tT;class UB extends To{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new G){const n=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e;let u=Math.floor(o),c=o-u;this.closed?u+=u>0?0:(Math.floor(Math.abs(u)/s)+1)*s:c===0&&u===s-1&&(u=s-2,c=1);let h,d;this.closed||u>0?h=r[(u-1)%s]:(fg.subVectors(r[0],r[1]).add(r[0]),h=fg);const p=r[u%s],g=r[(u+1)%s];if(this.closed||u+2<s?d=r[(u+2)%s]:(fg.subVectors(r[s-1],r[s-2]).add(r[s-1]),d=fg),this.curveType==="centripetal"||this.curveType==="chordal"){const _=this.curveType==="chordal"?.5:.25;let v=Math.pow(h.distanceToSquared(p),_),S=Math.pow(p.distanceToSquared(g),_),b=Math.pow(g.distanceToSquared(d),_);S<1e-4&&(S=1),v<1e-4&&(v=S),b<1e-4&&(b=S),Qy.initNonuniformCatmullRom(h.x,p.x,g.x,d.x,v,S,b),Jy.initNonuniformCatmullRom(h.y,p.y,g.y,d.y,v,S,b),ex.initNonuniformCatmullRom(h.z,p.z,g.z,d.z,v,S,b)}else this.curveType==="catmullrom"&&(Qy.initCatmullRom(h.x,p.x,g.x,d.x,this.tension),Jy.initCatmullRom(h.y,p.y,g.y,d.y,this.tension),ex.initCatmullRom(h.z,p.z,g.z,d.z,this.tension));return n.set(Qy.calc(c),Jy.calc(c),ex.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new G().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function sw(i,e,t,n,r){const s=(n-e)*.5,o=(r-t)*.5,u=i*i,c=i*u;return(2*t-2*n+s+o)*c+(-3*t+3*n-2*s-o)*u+s*i+t}function OB(i,e){const t=1-i;return t*t*e}function BB(i,e){return 2*(1-i)*i*e}function FB(i,e){return i*i*e}function Fd(i,e,t,n){return OB(i,e)+BB(i,t)+FB(i,n)}function IB(i,e){const t=1-i;return t*t*t*e}function zB(i,e){const t=1-i;return 3*t*t*i*e}function kB(i,e){return 3*(1-i)*i*i*e}function GB(i,e){return i*i*i*e}function Id(i,e,t,n,r){return IB(i,e)+zB(i,t)+kB(i,n)+GB(i,r)}class VB extends To{constructor(e=new Ie,t=new Ie,n=new Ie,r=new Ie){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Ie){const n=t,r=this.v0,s=this.v1,o=this.v2,u=this.v3;return n.set(Id(e,r.x,s.x,o.x,u.x),Id(e,r.y,s.y,o.y,u.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class e2 extends To{constructor(e=new G,t=new G,n=new G,r=new G){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new G){const n=t,r=this.v0,s=this.v1,o=this.v2,u=this.v3;return n.set(Id(e,r.x,s.x,o.x,u.x),Id(e,r.y,s.y,o.y,u.y),Id(e,r.z,s.z,o.z,u.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class HB extends To{constructor(e=new Ie,t=new Ie){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ie){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ie){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class jB extends To{constructor(e=new G,t=new G){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new G){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new G){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class WB extends To{constructor(e=new Ie,t=new Ie,n=new Ie){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Ie){const n=t,r=this.v0,s=this.v1,o=this.v2;return n.set(Fd(e,r.x,s.x,o.x),Fd(e,r.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class nT extends To{constructor(e=new G,t=new G,n=new G){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new G){const n=t,r=this.v0,s=this.v1,o=this.v2;return n.set(Fd(e,r.x,s.x,o.x),Fd(e,r.y,s.y,o.y),Fd(e,r.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class $B extends To{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ie){const n=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),u=s-o,c=r[o===0?o:o-1],h=r[o],d=r[o>r.length-2?r.length-1:o+1],p=r[o>r.length-3?r.length-1:o+2];return n.set(sw(u,c.x,h.x,d.x,p.x),sw(u,c.y,h.y,d.y,p.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new Ie().fromArray(r))}return this}}var qB=Object.freeze({__proto__:null,ArcCurve:PB,CatmullRomCurve3:UB,CubicBezierCurve:VB,CubicBezierCurve3:e2,EllipseCurve:JN,LineCurve:HB,LineCurve3:jB,QuadraticBezierCurve:WB,QuadraticBezierCurve3:nT,SplineCurve:$B});class Ep extends Fi{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,o=t/2,u=Math.floor(n),c=Math.floor(r),h=u+1,d=c+1,p=e/u,g=t/c,_=[],v=[],S=[],b=[];for(let x=0;x<d;x++){const M=x*g-o;for(let E=0;E<h;E++){const w=E*p-s;v.push(w,-M,0),S.push(0,0,1),b.push(E/u),b.push(1-x/c)}}for(let x=0;x<c;x++)for(let M=0;M<u;M++){const E=M+h*x,w=M+h*(x+1),D=M+1+h*(x+1),C=M+1+h*x;_.push(E,w,C),_.push(w,D,C)}this.setIndex(_),this.setAttribute("position",new ti(v,3)),this.setAttribute("normal",new ti(S,3)),this.setAttribute("uv",new ti(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ep(e.width,e.height,e.widthSegments,e.heightSegments)}}class Ap extends Fi{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,o=0,u=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:u},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(o+u,Math.PI);let h=0;const d=[],p=new G,g=new G,_=[],v=[],S=[],b=[];for(let x=0;x<=n;x++){const M=[],E=x/n;let w=0;x===0&&o===0?w=.5/t:x===n&&c===Math.PI&&(w=-.5/t);for(let D=0;D<=t;D++){const C=D/t;p.x=-e*Math.cos(r+C*s)*Math.sin(o+E*u),p.y=e*Math.cos(o+E*u),p.z=e*Math.sin(r+C*s)*Math.sin(o+E*u),v.push(p.x,p.y,p.z),g.copy(p).normalize(),S.push(g.x,g.y,g.z),b.push(C+w,1-E),M.push(h++)}d.push(M)}for(let x=0;x<n;x++)for(let M=0;M<t;M++){const E=d[x][M+1],w=d[x][M],D=d[x+1][M],C=d[x+1][M+1];(x!==0||o>0)&&_.push(E,w,C),(x!==n-1||c<Math.PI)&&_.push(w,D,C)}this.setIndex(_),this.setAttribute("position",new ti(v,3)),this.setAttribute("normal",new ti(S,3)),this.setAttribute("uv",new ti(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ap(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class iT extends Fi{constructor(e=new nT(new G(-1,-1,0),new G(-1,1,0),new G(1,1,0)),t=64,n=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:s};const o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const u=new G,c=new G,h=new Ie;let d=new G;const p=[],g=[],_=[],v=[];S(),this.setIndex(v),this.setAttribute("position",new ti(p,3)),this.setAttribute("normal",new ti(g,3)),this.setAttribute("uv",new ti(_,2));function S(){for(let E=0;E<t;E++)b(E);b(s===!1?t:0),M(),x()}function b(E){d=e.getPointAt(E/t,d);const w=o.normals[E],D=o.binormals[E];for(let C=0;C<=r;C++){const N=C/r*Math.PI*2,A=Math.sin(N),L=-Math.cos(N);c.x=L*w.x+A*D.x,c.y=L*w.y+A*D.y,c.z=L*w.z+A*D.z,c.normalize(),g.push(c.x,c.y,c.z),u.x=d.x+n*c.x,u.y=d.y+n*c.y,u.z=d.z+n*c.z,p.push(u.x,u.y,u.z)}}function x(){for(let E=1;E<=t;E++)for(let w=1;w<=r;w++){const D=(r+1)*(E-1)+(w-1),C=(r+1)*E+(w-1),N=(r+1)*E+w,A=(r+1)*(E-1)+w;v.push(D,C,A),v.push(C,N,A)}}function M(){for(let E=0;E<=t;E++)for(let w=0;w<=r;w++)h.x=E/t,h.y=w/r,_.push(h.x,h.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new iT(new qB[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class XB extends ir{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new pt(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}function Ih(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Ne("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function hr(i){const e={};for(let t=0;t<i.length;t++){const n=Ih(i[t]);for(const r in n)e[r]=n[r]}return e}function YB(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function t2(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:xt.workingColorSpace}const n2={clone:Ih,merge:hr};var KB=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,ZB=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class Ts extends ir{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=KB,this.fragmentShader=ZB,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=Ih(e.uniforms),this.uniformsGroups=YB(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 t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class QB extends Ts{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class i2 extends ir{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new pt(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 pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new Ie(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 Br,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 JB extends i2{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ie(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return kt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new pt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new pt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new pt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class eF extends ir{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new pt(16777215),this.specular=new pt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Br,this.combine=yp,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class tF extends ir{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new pt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class nF extends ir{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class r2 extends ir{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new pt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Br,this.combine=yp,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class iF extends ir{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=RO,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 rF extends ir{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 sF extends ir{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new pt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class aF extends q_{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const tx={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(aw(i)||(this.files[i]=e))},get:function(i){if(this.enabled!==!1&&!aw(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function aw(i){try{const e=i.slice(i.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class oF{constructor(e,t,n){const r=this;let s=!1,o=0,u=0,c;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(d){u++,s===!1&&r.onStart!==void 0&&r.onStart(d,o,u),s=!0},this.itemEnd=function(d){o++,r.onProgress!==void 0&&r.onProgress(d,o,u),o===u&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return c?c(d):d},this.setURLModifier=function(d){return c=d,this},this.addHandler=function(d,p){return h.push(d,p),this},this.removeHandler=function(d){const p=h.indexOf(d);return p!==-1&&h.splice(p,2),this},this.getHandler=function(d){for(let p=0,g=h.length;p<g;p+=2){const _=h[p],v=h[p+1];if(_.global&&(_.lastIndex=0),_.test(d))return v}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const lF=new oF;class rT{constructor(e){this.manager=e!==void 0?e:lF,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}rT.DEFAULT_MATERIAL_NAME="__DEFAULT";const Bc=new WeakMap;class uF extends rT{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=tx.get(`image:${e}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0);else{let p=Bc.get(o);p===void 0&&(p=[],Bc.set(o,p)),p.push({onLoad:t,onError:r})}return o}const u=cp("img");function c(){d(),t&&t(this);const p=Bc.get(this)||[];for(let g=0;g<p.length;g++){const _=p[g];_.onLoad&&_.onLoad(this)}Bc.delete(this),s.manager.itemEnd(e)}function h(p){d(),r&&r(p),tx.remove(`image:${e}`);const g=Bc.get(this)||[];for(let _=0;_<g.length;_++){const v=g[_];v.onError&&v.onError(p)}Bc.delete(this),s.manager.itemError(e),s.manager.itemEnd(e)}function d(){u.removeEventListener("load",c,!1),u.removeEventListener("error",h,!1)}return u.addEventListener("load",c,!1),u.addEventListener("error",h,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(u.crossOrigin=this.crossOrigin),tx.add(`image:${e}`,u),s.manager.itemStart(e),u.src=e,u}}class cF extends rT{constructor(e){super(e)}load(e,t,n,r){const s=new vi,o=new uF(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(u){s.image=u,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}}class ku extends yi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new pt(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class hF extends ku{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(yi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new pt(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const nx=new Wt,ow=new G,lw=new G;class sT{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 Ie(512,512),this.mapType=Gn,this.map=null,this.mapPass=null,this.matrix=new Wt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Tp,this._frameExtents=new Ie(1,1),this._viewportCount=1,this._viewports=[new Pt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;ow.setFromMatrixPosition(e.matrixWorld),t.position.copy(ow),lw.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(lw),t.updateMatrixWorld(),nx.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(nx,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===ba||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(nx)}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 dg=new G,pg=new Ss,Qs=new G;class s2 extends yi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Wt,this.projectionMatrix=new Wt,this.projectionMatrixInverse=new Wt,this.coordinateSystem=yr,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(dg,pg,Qs),Qs.x===1&&Qs.y===1&&Qs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(dg,pg,Qs.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(dg,pg,Qs),Qs.x===1&&Qs.y===1&&Qs.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(dg,pg,Qs.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const nl=new G,uw=new Ie,cw=new Ie;class Pi extends s2{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Nu*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Od*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Nu*2*Math.atan(Math.tan(Od*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){nl.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(nl.x,nl.y).multiplyScalar(-e/nl.z),nl.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(nl.x,nl.y).multiplyScalar(-e/nl.z)}getViewSize(e,t){return this.getViewBounds(e,uw,cw),t.subVectors(cw,uw)}setViewOffset(e,t,n,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Od*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,h=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*n/h,r*=o.width/c,n*=o.height/h}const u=this.filmOffset;u!==0&&(s+=e*u/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class fF extends sT{constructor(){super(new Pi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=Nu*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class aT extends ku{constructor(e,t,n=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(yi.DEFAULT_UP),this.updateMatrix(),this.target=new yi,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new fF}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class dF extends sT{constructor(){super(new Pi(90,1,.5,500)),this.isPointLightShadow=!0}}class pF extends ku{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new dF}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Zh extends s2{constructor(e=-1,t=1,n=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,o=n+e,u=r+t,c=r-t;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=h*this.view.offsetX,o=s+h*this.view.width,u-=d*this.view.offsetY,c=u-d*this.view.height}this.projectionMatrix.makeOrthographic(s,o,u,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class mF extends sT{constructor(){super(new Zh(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class a2 extends ku{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(yi.DEFAULT_UP),this.updateMatrix(),this.target=new yi,this.shadow=new mF}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 t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class o2 extends ku{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class gF extends ku{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class _F{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new G)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(n*s)),t.addScaledVector(o[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*n*s),t.addScaledVector(o[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const n=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-r*r)}}class vF extends ku{constructor(e=new _F,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}const Fc=-90,Ic=1;class l2 extends yi{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Pi(Fc,Ic,e,t);r.layers=this.layers,this.add(r);const s=new Pi(Fc,Ic,e,t);s.layers=this.layers,this.add(s);const o=new Pi(Fc,Ic,e,t);o.layers=this.layers,this.add(o);const u=new Pi(Fc,Ic,e,t);u.layers=this.layers,this.add(u);const c=new Pi(Fc,Ic,e,t);c.layers=this.layers,this.add(c);const h=new Pi(Fc,Ic,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,o,u,c]=t;for(const h of t)this.remove(h);if(e===yr)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),u.up.set(0,1,0),u.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===ba)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),u.up.set(0,-1,0),u.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,u,c,h,d]=this.children,p=e.getRenderTarget(),g=e.getActiveCubeFace(),_=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const S=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let b=!1;e.isWebGLRenderer===!0?b=e.state.buffers.depth.getReversed():b=e.reversedDepthBuffer,e.setRenderTarget(n,0,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,1,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(n,3,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),n.texture.generateMipmaps=S,e.setRenderTarget(n,5,r),b&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(p,g,_),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class u2 extends Pi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}let yF=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=xF.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function xF(){this._document.hidden===!1&&this.reset()}class bF extends YN{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}const hw=new Wt;class c2{constructor(e,t,n=0,r=1/0){this.ray=new $_(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new qS,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Pe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return hw.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(hw),this}intersectObject(e,t=!0,n=[]){return Rb(e,this,n,t),n.sort(fw),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)Rb(e[r],this,n,t);return n.sort(fw),n}}function fw(i,e){return i.distance-e.distance}function Rb(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let o=0,u=s.length;o<u;o++)Rb(s[o],e,t,!0)}}class SF{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,Ne("THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.")}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}class dw{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=kt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(kt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class X_{constructor(e,t,n,r){X_.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}}class Y_ extends Aa{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ne("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Cb(i,e,t,n){const r=TF(n);switch(t){case IS:return i*e;case bp:return i*e/r.components*r.byteLength;case qh:return i*e/r.components*r.byteLength;case vr:return i*e*2/r.components*r.byteLength;case Xh:return i*e*2/r.components*r.byteLength;case xp:return i*e*3/r.components*r.byteLength;case si:return i*e*4/r.components*r.byteLength;case Yh:return i*e*4/r.components*r.byteLength;case gl:case _l:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case vl:case yl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case ap:case lp:return Math.max(i,16)*Math.max(e,8)/4;case sp:case op:return Math.max(i,8)*Math.max(e,8)/2;case fh:case dh:case mh:case gh:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ph:case wu:case _h:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case vh:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case yh:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case xh:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case bh:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Sh:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Th:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Mh:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Eh:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Ah:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case wh:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Rh:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Ch:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Nh:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Dh:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Lh:case Eb:case Ab:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Ph:case Uh:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Ru:case Oh:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function TF(i){switch(i){case Gn:case _u:return{byteLength:1,components:1};case Gs:case vu:case Qn:return{byteLength:2,components:1};case G_:case V_:return{byteLength:2,components:4};case bn:case Li:case ri:return{byteLength:4,components:1};case H_:case j_:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Fu}}));typeof window<"u"&&(window.__THREE__?Ne("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Fu);/**
 * @license
 * Copyright 2010-2026 Three.js Authors
 * SPDX-License-Identifier: MIT
 */function h2(){let i=null,e=!1,t=null,n=null;function r(s,o){t(s,o),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function MF(i){const e=new WeakMap;function t(u,c){const h=u.array,d=u.usage,p=h.byteLength,g=i.createBuffer();i.bindBuffer(c,g),i.bufferData(c,h,d),u.onUploadCallback();let _;if(h instanceof Float32Array)_=i.FLOAT;else if(typeof Float16Array<"u"&&h instanceof Float16Array)_=i.HALF_FLOAT;else if(h instanceof Uint16Array)u.isFloat16BufferAttribute?_=i.HALF_FLOAT:_=i.UNSIGNED_SHORT;else if(h instanceof Int16Array)_=i.SHORT;else if(h instanceof Uint32Array)_=i.UNSIGNED_INT;else if(h instanceof Int32Array)_=i.INT;else if(h instanceof Int8Array)_=i.BYTE;else if(h instanceof Uint8Array)_=i.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)_=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:g,type:_,bytesPerElement:h.BYTES_PER_ELEMENT,version:u.version,size:p}}function n(u,c,h){const d=c.array,p=c.updateRanges;if(i.bindBuffer(h,u),p.length===0)i.bufferSubData(h,0,d);else{p.sort((_,v)=>_.start-v.start);let g=0;for(let _=1;_<p.length;_++){const v=p[g],S=p[_];S.start<=v.start+v.count+1?v.count=Math.max(v.count,S.start+S.count-v.start):(++g,p[g]=S)}p.length=g+1;for(let _=0,v=p.length;_<v;_++){const S=p[_];i.bufferSubData(h,S.start*d.BYTES_PER_ELEMENT,d,S.start,S.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(u){return u.isInterleavedBufferAttribute&&(u=u.data),e.get(u)}function s(u){u.isInterleavedBufferAttribute&&(u=u.data);const c=e.get(u);c&&(i.deleteBuffer(c.buffer),e.delete(u))}function o(u,c){if(u.isInterleavedBufferAttribute&&(u=u.data),u.isGLBufferAttribute){const d=e.get(u);(!d||d.version<u.version)&&e.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}const h=e.get(u);if(h===void 0)e.set(u,t(u,c));else if(h.version<u.version){if(h.size!==u.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.");n(h.buffer,u,c),h.version=u.version}}return{get:r,remove:s,update:o}}var EF=`#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,AF=`#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`,wF=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,RF=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,CF=`#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`,NF=`#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`,DF=`#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`,LF=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,PF=`#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`,UF=`#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,OF=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`,BF=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,FF=`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`,IF=`#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`,zF=`#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`,kF=`#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`,GF=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,VF=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,HF=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,jF=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#endif`,WF=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#endif`,$F=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec4 vColor;
#endif`,qF=`#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`,XF=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,YF=`#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`,KF=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,ZF=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,QF=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,JF=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
		emissiveColor = sRGBTransferEOTF( emissiveColor );
	#endif
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,eI=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,tI="gl_FragColor = linearToOutputTexel( gl_FragColor );",nI=`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 );
}`,iI=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
		#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`,rI=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
#endif`,sI=`#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`,aI=`#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`,oI=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`,lI=`#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`,uI=`#ifdef USE_FOG
	varying float vFogDepth;
#endif`,cI=`#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`,hI=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,fI=`#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
}`,dI=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,pI=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,mI=`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`,gI=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if ( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`,_I=`#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`,vI=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,yI=`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`,xI=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,bI=`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`,SI=`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`,TI=`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 ) );
		float v = 0.5 / ( gv + gl );
		return v;
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.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 );
}`,MI=`
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
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,EI=`#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`,AI=`#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`,wI=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,RI=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,CI=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,NI=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,DI=`#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`,LI=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,PI=`#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`,UI=`#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`,OI=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`,BI=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,FI=`#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`,II=`#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`,zI=`#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`,kI=`#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`,GI=`#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`,VI=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`,HI=`#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,jI=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,WI=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,$I=`#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`,qI=`#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`,XI=`#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,YI=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,KI=`#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`,ZI=`#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`,QI=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,JI=`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
}`,ez=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,tz=`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;`,nz=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,iz=`#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`,rz=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`,sz=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,az=`#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`,oz=`#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`,lz=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`,uz=`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;
}`,cz=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,hz=`#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`,fz=`#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`,dz=`#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`,pz=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,mz=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,gz=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,_z=`#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; }`,vz=`#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.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`,yz=`#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`,xz=`#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`,bz=`#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`,Sz=`#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`,Tz=`#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 Mz=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,Ez=`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>
}`,Az=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,wz=`#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,Rz=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,Cz=`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>
}`,Nz=`#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;
}`,Dz=`#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
}`,Lz=`#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;
}`,Pz=`#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 );
}`,Uz=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,Oz=`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>
}`,Bz=`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>
}`,Fz=`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>
}`,Iz=`#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>
}`,zz=`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>
}`,kz=`#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>
}`,Gz=`#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>
}`,Vz=`#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;
}`,Hz=`#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>
}`,jz=`#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
}`,Wz=`#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
}`,$z=`#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>
}`,qz=`#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>
}`,Xz=`#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
}`,Yz=`#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>
}`,Kz=`#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>
}`,Zz=`#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>
}`,Qz=`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>
}`,Jz=`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>
}`,ek=`#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>
}`,tk=`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>
}`,nk=`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>
}`,ik=`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>
}`,jt={alphahash_fragment:EF,alphahash_pars_fragment:AF,alphamap_fragment:wF,alphamap_pars_fragment:RF,alphatest_fragment:CF,alphatest_pars_fragment:NF,aomap_fragment:DF,aomap_pars_fragment:LF,batching_pars_vertex:PF,batching_vertex:UF,begin_vertex:OF,beginnormal_vertex:BF,bsdfs:FF,iridescence_fragment:IF,bumpmap_pars_fragment:zF,clipping_planes_fragment:kF,clipping_planes_pars_fragment:GF,clipping_planes_pars_vertex:VF,clipping_planes_vertex:HF,color_fragment:jF,color_pars_fragment:WF,color_pars_vertex:$F,color_vertex:qF,common:XF,cube_uv_reflection_fragment:YF,defaultnormal_vertex:KF,displacementmap_pars_vertex:ZF,displacementmap_vertex:QF,emissivemap_fragment:JF,emissivemap_pars_fragment:eI,colorspace_fragment:tI,colorspace_pars_fragment:nI,envmap_fragment:iI,envmap_common_pars_fragment:rI,envmap_pars_fragment:sI,envmap_pars_vertex:aI,envmap_physical_pars_fragment:_I,envmap_vertex:oI,fog_vertex:lI,fog_pars_vertex:uI,fog_fragment:cI,fog_pars_fragment:hI,gradientmap_pars_fragment:fI,lightmap_pars_fragment:dI,lights_lambert_fragment:pI,lights_lambert_pars_fragment:mI,lights_pars_begin:gI,lights_toon_fragment:vI,lights_toon_pars_fragment:yI,lights_phong_fragment:xI,lights_phong_pars_fragment:bI,lights_physical_fragment:SI,lights_physical_pars_fragment:TI,lights_fragment_begin:MI,lights_fragment_maps:EI,lights_fragment_end:AI,logdepthbuf_fragment:wI,logdepthbuf_pars_fragment:RI,logdepthbuf_pars_vertex:CI,logdepthbuf_vertex:NI,map_fragment:DI,map_pars_fragment:LI,map_particle_fragment:PI,map_particle_pars_fragment:UI,metalnessmap_fragment:OI,metalnessmap_pars_fragment:BI,morphinstance_vertex:FI,morphcolor_vertex:II,morphnormal_vertex:zI,morphtarget_pars_vertex:kI,morphtarget_vertex:GI,normal_fragment_begin:VI,normal_fragment_maps:HI,normal_pars_fragment:jI,normal_pars_vertex:WI,normal_vertex:$I,normalmap_pars_fragment:qI,clearcoat_normal_fragment_begin:XI,clearcoat_normal_fragment_maps:YI,clearcoat_pars_fragment:KI,iridescence_pars_fragment:ZI,opaque_fragment:QI,packing:JI,premultiplied_alpha_fragment:ez,project_vertex:tz,dithering_fragment:nz,dithering_pars_fragment:iz,roughnessmap_fragment:rz,roughnessmap_pars_fragment:sz,shadowmap_pars_fragment:az,shadowmap_pars_vertex:oz,shadowmap_vertex:lz,shadowmask_pars_fragment:uz,skinbase_vertex:cz,skinning_pars_vertex:hz,skinning_vertex:fz,skinnormal_vertex:dz,specularmap_fragment:pz,specularmap_pars_fragment:mz,tonemapping_fragment:gz,tonemapping_pars_fragment:_z,transmission_fragment:vz,transmission_pars_fragment:yz,uv_pars_fragment:xz,uv_pars_vertex:bz,uv_vertex:Sz,worldpos_vertex:Tz,background_vert:Mz,background_frag:Ez,backgroundCube_vert:Az,backgroundCube_frag:wz,cube_vert:Rz,cube_frag:Cz,depth_vert:Nz,depth_frag:Dz,distance_vert:Lz,distance_frag:Pz,equirect_vert:Uz,equirect_frag:Oz,linedashed_vert:Bz,linedashed_frag:Fz,meshbasic_vert:Iz,meshbasic_frag:zz,meshlambert_vert:kz,meshlambert_frag:Gz,meshmatcap_vert:Vz,meshmatcap_frag:Hz,meshnormal_vert:jz,meshnormal_frag:Wz,meshphong_vert:$z,meshphong_frag:qz,meshphysical_vert:Xz,meshphysical_frag:Yz,meshtoon_vert:Kz,meshtoon_frag:Zz,points_vert:Qz,points_frag:Jz,shadow_vert:ek,shadow_frag:tk,sprite_vert:nk,sprite_frag:ik},qe={common:{diffuse:{value:new pt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Nt},alphaMap:{value:null},alphaMapTransform:{value:new Nt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Nt}},envmap:{envMap:{value:null},envMapRotation:{value:new Nt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Nt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Nt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Nt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Nt},normalScale:{value:new Ie(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Nt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Nt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Nt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Nt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new pt(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}},points:{diffuse:{value:new pt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Nt},alphaTest:{value:0},uvTransform:{value:new Nt}},sprite:{diffuse:{value:new pt(16777215)},opacity:{value:1},center:{value:new Ie(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Nt},alphaMap:{value:null},alphaMapTransform:{value:new Nt},alphaTest:{value:0}}},oa={basic:{uniforms:hr([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.fog]),vertexShader:jt.meshbasic_vert,fragmentShader:jt.meshbasic_frag},lambert:{uniforms:hr([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,qe.lights,{emissive:{value:new pt(0)},envMapIntensity:{value:1}}]),vertexShader:jt.meshlambert_vert,fragmentShader:jt.meshlambert_frag},phong:{uniforms:hr([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,qe.lights,{emissive:{value:new pt(0)},specular:{value:new pt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:jt.meshphong_vert,fragmentShader:jt.meshphong_frag},standard:{uniforms:hr([qe.common,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.roughnessmap,qe.metalnessmap,qe.fog,qe.lights,{emissive:{value:new pt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag},toon:{uniforms:hr([qe.common,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.gradientmap,qe.fog,qe.lights,{emissive:{value:new pt(0)}}]),vertexShader:jt.meshtoon_vert,fragmentShader:jt.meshtoon_frag},matcap:{uniforms:hr([qe.common,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,{matcap:{value:null}}]),vertexShader:jt.meshmatcap_vert,fragmentShader:jt.meshmatcap_frag},points:{uniforms:hr([qe.points,qe.fog]),vertexShader:jt.points_vert,fragmentShader:jt.points_frag},dashed:{uniforms:hr([qe.common,qe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jt.linedashed_vert,fragmentShader:jt.linedashed_frag},depth:{uniforms:hr([qe.common,qe.displacementmap]),vertexShader:jt.depth_vert,fragmentShader:jt.depth_frag},normal:{uniforms:hr([qe.common,qe.bumpmap,qe.normalmap,qe.displacementmap,{opacity:{value:1}}]),vertexShader:jt.meshnormal_vert,fragmentShader:jt.meshnormal_frag},sprite:{uniforms:hr([qe.sprite,qe.fog]),vertexShader:jt.sprite_vert,fragmentShader:jt.sprite_frag},background:{uniforms:{uvTransform:{value:new Nt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:jt.background_vert,fragmentShader:jt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Nt}},vertexShader:jt.backgroundCube_vert,fragmentShader:jt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:jt.cube_vert,fragmentShader:jt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:jt.equirect_vert,fragmentShader:jt.equirect_frag},distance:{uniforms:hr([qe.common,qe.displacementmap,{referencePosition:{value:new G},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:jt.distance_vert,fragmentShader:jt.distance_frag},shadow:{uniforms:hr([qe.lights,qe.fog,{color:{value:new pt(0)},opacity:{value:1}}]),vertexShader:jt.shadow_vert,fragmentShader:jt.shadow_frag}};oa.physical={uniforms:hr([oa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Nt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Nt},clearcoatNormalScale:{value:new Ie(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Nt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Nt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Nt},sheen:{value:0},sheenColor:{value:new pt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Nt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Nt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Nt},transmissionSamplerSize:{value:new Ie},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Nt},attenuationDistance:{value:0},attenuationColor:{value:new pt(0)},specularColor:{value:new pt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Nt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Nt},anisotropyVector:{value:new Ie},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Nt}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag};const mg={r:0,b:0,g:0},tu=new Br,rk=new Wt;function sk(i,e,t,n,r,s){const o=new pt(0);let u=r===!0?0:1,c,h,d=null,p=0,g=null;function _(M){let E=M.isScene===!0?M.background:null;if(E&&E.isTexture){const w=M.backgroundBlurriness>0;E=e.get(E,w)}return E}function v(M){let E=!1;const w=_(M);w===null?b(o,u):w&&w.isColor&&(b(w,1),E=!0);const D=i.xr.getEnvironmentBlendMode();D==="additive"?t.buffers.color.setClear(0,0,0,1,s):D==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(i.autoClear||E)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function S(M,E){const w=_(E);w&&(w.isCubeTexture||w.mapping===Mu)?(h===void 0&&(h=new xi(new zu(1,1,1),new Ts({name:"BackgroundCubeMaterial",uniforms:Ih(oa.backgroundCube.uniforms),vertexShader:oa.backgroundCube.vertexShader,fragmentShader:oa.backgroundCube.fragmentShader,side:Tn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(D,C,N){this.matrixWorld.copyPosition(N.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(h)),tu.copy(E.backgroundRotation),tu.x*=-1,tu.y*=-1,tu.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(tu.y*=-1,tu.z*=-1),h.material.uniforms.envMap.value=w,h.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(rk.makeRotationFromEuler(tu)),h.material.toneMapped=xt.getTransfer(w.colorSpace)!==Ye,(d!==w||p!==w.version||g!==i.toneMapping)&&(h.material.needsUpdate=!0,d=w,p=w.version,g=i.toneMapping),h.layers.enableAll(),M.unshift(h,h.geometry,h.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new xi(new Ep(2,2),new Ts({name:"BackgroundMaterial",uniforms:Ih(oa.background.uniforms),vertexShader:oa.background.vertexShader,fragmentShader:oa.background.fragmentShader,side:xr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=w,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.toneMapped=xt.getTransfer(w.colorSpace)!==Ye,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(d!==w||p!==w.version||g!==i.toneMapping)&&(c.material.needsUpdate=!0,d=w,p=w.version,g=i.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null))}function b(M,E){M.getRGB(mg,t2(i)),t.buffers.color.setClear(mg.r,mg.g,mg.b,E,s)}function x(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(M,E=1){o.set(M),u=E,b(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(M){u=M,b(o,u)},render:v,addToRenderList:S,dispose:x}}function ak(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=g(null);let s=r,o=!1;function u(z,H,K,te,Z){let I=!1;const F=p(z,te,K,H);s!==F&&(s=F,h(s.object)),I=_(z,te,K,Z),I&&v(z,te,K,Z),Z!==null&&e.update(Z,i.ELEMENT_ARRAY_BUFFER),(I||o)&&(o=!1,w(z,H,K,te),Z!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(Z).buffer))}function c(){return i.createVertexArray()}function h(z){return i.bindVertexArray(z)}function d(z){return i.deleteVertexArray(z)}function p(z,H,K,te){const Z=te.wireframe===!0;let I=n[H.id];I===void 0&&(I={},n[H.id]=I);const F=z.isInstancedMesh===!0?z.id:0;let Y=I[F];Y===void 0&&(Y={},I[F]=Y);let se=Y[K.id];se===void 0&&(se={},Y[K.id]=se);let Te=se[Z];return Te===void 0&&(Te=g(c()),se[Z]=Te),Te}function g(z){const H=[],K=[],te=[];for(let Z=0;Z<t;Z++)H[Z]=0,K[Z]=0,te[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:H,enabledAttributes:K,attributeDivisors:te,object:z,attributes:{},index:null}}function _(z,H,K,te){const Z=s.attributes,I=H.attributes;let F=0;const Y=K.getAttributes();for(const se in Y)if(Y[se].location>=0){const O=Z[se];let W=I[se];if(W===void 0&&(se==="instanceMatrix"&&z.instanceMatrix&&(W=z.instanceMatrix),se==="instanceColor"&&z.instanceColor&&(W=z.instanceColor)),O===void 0||O.attribute!==W||W&&O.data!==W.data)return!0;F++}return s.attributesNum!==F||s.index!==te}function v(z,H,K,te){const Z={},I=H.attributes;let F=0;const Y=K.getAttributes();for(const se in Y)if(Y[se].location>=0){let O=I[se];O===void 0&&(se==="instanceMatrix"&&z.instanceMatrix&&(O=z.instanceMatrix),se==="instanceColor"&&z.instanceColor&&(O=z.instanceColor));const W={};W.attribute=O,O&&O.data&&(W.data=O.data),Z[se]=W,F++}s.attributes=Z,s.attributesNum=F,s.index=te}function S(){const z=s.newAttributes;for(let H=0,K=z.length;H<K;H++)z[H]=0}function b(z){x(z,0)}function x(z,H){const K=s.newAttributes,te=s.enabledAttributes,Z=s.attributeDivisors;K[z]=1,te[z]===0&&(i.enableVertexAttribArray(z),te[z]=1),Z[z]!==H&&(i.vertexAttribDivisor(z,H),Z[z]=H)}function M(){const z=s.newAttributes,H=s.enabledAttributes;for(let K=0,te=H.length;K<te;K++)H[K]!==z[K]&&(i.disableVertexAttribArray(K),H[K]=0)}function E(z,H,K,te,Z,I,F){F===!0?i.vertexAttribIPointer(z,H,K,Z,I):i.vertexAttribPointer(z,H,K,te,Z,I)}function w(z,H,K,te){S();const Z=te.attributes,I=K.getAttributes(),F=H.defaultAttributeValues;for(const Y in I){const se=I[Y];if(se.location>=0){let Te=Z[Y];if(Te===void 0&&(Y==="instanceMatrix"&&z.instanceMatrix&&(Te=z.instanceMatrix),Y==="instanceColor"&&z.instanceColor&&(Te=z.instanceColor)),Te!==void 0){const O=Te.normalized,W=Te.itemSize,ce=e.get(Te);if(ce===void 0)continue;const Le=ce.buffer,ee=ce.type,$=ce.bytesPerElement,ue=ee===i.INT||ee===i.UNSIGNED_INT||Te.gpuType===Li;if(Te.isInterleavedBufferAttribute){const Ee=Te.data,ke=Ee.stride,We=Te.offset;if(Ee.isInstancedInterleavedBuffer){for(let Ke=0;Ke<se.locationSize;Ke++)x(se.location+Ke,Ee.meshPerAttribute);z.isInstancedMesh!==!0&&te._maxInstanceCount===void 0&&(te._maxInstanceCount=Ee.meshPerAttribute*Ee.count)}else for(let Ke=0;Ke<se.locationSize;Ke++)b(se.location+Ke);i.bindBuffer(i.ARRAY_BUFFER,Le);for(let Ke=0;Ke<se.locationSize;Ke++)E(se.location+Ke,W/se.locationSize,ee,O,ke*$,(We+W/se.locationSize*Ke)*$,ue)}else{if(Te.isInstancedBufferAttribute){for(let Ee=0;Ee<se.locationSize;Ee++)x(se.location+Ee,Te.meshPerAttribute);z.isInstancedMesh!==!0&&te._maxInstanceCount===void 0&&(te._maxInstanceCount=Te.meshPerAttribute*Te.count)}else for(let Ee=0;Ee<se.locationSize;Ee++)b(se.location+Ee);i.bindBuffer(i.ARRAY_BUFFER,Le);for(let Ee=0;Ee<se.locationSize;Ee++)E(se.location+Ee,W/se.locationSize,ee,O,W*$,W/se.locationSize*Ee*$,ue)}}else if(F!==void 0){const O=F[Y];if(O!==void 0)switch(O.length){case 2:i.vertexAttrib2fv(se.location,O);break;case 3:i.vertexAttrib3fv(se.location,O);break;case 4:i.vertexAttrib4fv(se.location,O);break;default:i.vertexAttrib1fv(se.location,O)}}}}M()}function D(){L();for(const z in n){const H=n[z];for(const K in H){const te=H[K];for(const Z in te){const I=te[Z];for(const F in I)d(I[F].object),delete I[F];delete te[Z]}}delete n[z]}}function C(z){if(n[z.id]===void 0)return;const H=n[z.id];for(const K in H){const te=H[K];for(const Z in te){const I=te[Z];for(const F in I)d(I[F].object),delete I[F];delete te[Z]}}delete n[z.id]}function N(z){for(const H in n){const K=n[H];for(const te in K){const Z=K[te];if(Z[z.id]===void 0)continue;const I=Z[z.id];for(const F in I)d(I[F].object),delete I[F];delete Z[z.id]}}}function A(z){for(const H in n){const K=n[H],te=z.isInstancedMesh===!0?z.id:0,Z=K[te];if(Z!==void 0){for(const I in Z){const F=Z[I];for(const Y in F)d(F[Y].object),delete F[Y];delete Z[I]}delete K[te],Object.keys(K).length===0&&delete n[H]}}}function L(){j(),o=!0,s!==r&&(s=r,h(s.object))}function j(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:u,reset:L,resetDefaultState:j,dispose:D,releaseStatesOfGeometry:C,releaseStatesOfObject:A,releaseStatesOfProgram:N,initAttributes:S,enableAttribute:b,disableUnusedAttributes:M}}function ok(i,e,t){let n;function r(h){n=h}function s(h,d){i.drawArrays(n,h,d),t.update(d,n,1)}function o(h,d,p){p!==0&&(i.drawArraysInstanced(n,h,d,p),t.update(d,n,p))}function u(h,d,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,h,0,d,0,p);let _=0;for(let v=0;v<p;v++)_+=d[v];t.update(_,n,1)}function c(h,d,p,g){if(p===0)return;const _=e.get("WEBGL_multi_draw");if(_===null)for(let v=0;v<h.length;v++)o(h[v],d[v],g[v]);else{_.multiDrawArraysInstancedWEBGL(n,h,0,d,0,g,0,p);let v=0;for(let S=0;S<p;S++)v+=d[S]*g[S];t.update(v,n,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=u,this.renderMultiDrawInstances=c}function lk(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(N){return!(N!==si&&n.convert(N)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function u(N){const A=N===Qn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==Gn&&n.convert(N)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==ri&&!A)}function c(N){if(N==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const d=c(h);d!==h&&(Ne("WebGLRenderer:",h,"not supported, using",d,"instead."),h=d);const p=t.logarithmicDepthBuffer===!0,g=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),_=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),S=i.getParameter(i.MAX_TEXTURE_SIZE),b=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),x=i.getParameter(i.MAX_VERTEX_ATTRIBS),M=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),E=i.getParameter(i.MAX_VARYING_VECTORS),w=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),D=i.getParameter(i.MAX_SAMPLES),C=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:u,precision:h,logarithmicDepthBuffer:p,reversedDepthBuffer:g,maxTextures:_,maxVertexTextures:v,maxTextureSize:S,maxCubemapSize:b,maxAttributes:x,maxVertexUniforms:M,maxVaryings:E,maxFragmentUniforms:w,maxSamples:D,samples:C}}function uk(i){const e=this;let t=null,n=0,r=!1,s=!1;const o=new zs,u=new Nt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(p,g){const _=p.length!==0||g||n!==0||r;return r=g,n=p.length,_},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(p,g){t=d(p,g,0)},this.setState=function(p,g,_){const v=p.clippingPlanes,S=p.clipIntersection,b=p.clipShadows,x=i.get(p);if(!r||v===null||v.length===0||s&&!b)s?d(null):h();else{const M=s?0:n,E=M*4;let w=x.clippingState||null;c.value=w,w=d(v,g,E,_);for(let D=0;D!==E;++D)w[D]=t[D];x.clippingState=w,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=M}};function h(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function d(p,g,_,v){const S=p!==null?p.length:0;let b=null;if(S!==0){if(b=c.value,v!==!0||b===null){const x=_+S*4,M=g.matrixWorldInverse;u.getNormalMatrix(M),(b===null||b.length<x)&&(b=new Float32Array(x));for(let E=0,w=_;E!==S;++E,w+=4)o.copy(p[E]).applyMatrix4(M,u),o.normal.toArray(b,w),b[w+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=S,e.numIntersection=0,b}}const dl=4,pw=[.125,.215,.35,.446,.526,.582],uu=20,ck=256,od=new Zh,mw=new pt;let ix=null,rx=0,sx=0,ax=!1;const hk=new G;let gw=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,r=100,s={}){const{size:o=256,position:u=hk}=s;ix=this._renderer.getRenderTarget(),rx=this._renderer.getActiveCubeFace(),sx=this._renderer.getActiveMipmapLevel(),ax=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,r,c,u),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=yw(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=vw(),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(ix,rx,sx),this._renderer.xr.enabled=ax,e.scissorTest=!1,zc(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===js||e.mapping===xa?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ix=this._renderer.getRenderTarget(),rx=this._renderer.getActiveCubeFace(),sx=this._renderer.getActiveMipmapLevel(),ax=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Rn,minFilter:Rn,generateMipmaps:!1,type:Qn,format:si,colorSpace:Cu,depthBuffer:!1},r=_w(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=_w(e,t,n);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=fk(s)),this._blurMaterial=pk(s,e,t),this._ggxMaterial=dk(s,e,t)}return r}_compileMaterial(e){const t=new xi(new Fi,e);this._renderer.compile(t,od)}_sceneToCubeUV(e,t,n,r,s){const c=new Pi(90,1,t,n),h=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],p=this._renderer,g=p.autoClear,_=p.toneMapping;p.getClearColor(mw),p.toneMapping=ji,p.autoClear=!1,p.state.buffers.depth.getReversed()&&(p.setRenderTarget(r),p.clearDepth(),p.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new xi(new zu,new ca({name:"PMREM.Background",side:Tn,depthWrite:!1,depthTest:!1})));const S=this._backgroundBox,b=S.material;let x=!1;const M=e.background;M?M.isColor&&(b.color.copy(M),e.background=null,x=!0):(b.color.copy(mw),x=!0);for(let E=0;E<6;E++){const w=E%3;w===0?(c.up.set(0,h[E],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+d[E],s.y,s.z)):w===1?(c.up.set(0,0,h[E]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+d[E],s.z)):(c.up.set(0,h[E],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+d[E]));const D=this._cubeSize;zc(r,w*D,E>2?D:0,D,D),p.setRenderTarget(r),x&&p.render(S,c),p.render(e,c)}p.toneMapping=_,p.autoClear=g,e.background=M}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===js||e.mapping===xa;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=yw()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=vw());const s=r?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=s;const u=s.uniforms;u.envMap.value=e;const c=this._cubeSize;zc(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,od)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,s=this._pingPongRenderTarget,o=this._ggxMaterial,u=this._lodMeshes[n];u.material=o;const c=o.uniforms,h=n/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),p=Math.sqrt(h*h-d*d),g=0+h*1.25,_=p*g,{_lodMax:v}=this,S=this._sizeLods[n],b=3*S*(n>v-dl?n-v+dl:0),x=4*(this._cubeSize-S);c.envMap.value=e.texture,c.roughness.value=_,c.mipInt.value=v-t,zc(s,b,x,3*S,2*S),r.setRenderTarget(s),r.render(u,od),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=v-n,zc(e,b,x,3*S,2*S),r.setRenderTarget(e),r.render(u,od)}_blur(e,t,n,r,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",s),this._halfBlur(o,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,o,u){const c=this._renderer,h=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Pe("blur direction must be either latitudinal or longitudinal!");const d=3,p=this._lodMeshes[r];p.material=h;const g=h.uniforms,_=this._sizeLods[n]-1,v=isFinite(s)?Math.PI/(2*_):2*Math.PI/(2*uu-1),S=s/v,b=isFinite(s)?1+Math.floor(d*S):uu;b>uu&&Ne(`sigmaRadians, ${s}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${uu}`);const x=[];let M=0;for(let N=0;N<uu;++N){const A=N/S,L=Math.exp(-A*A/2);x.push(L),N===0?M+=L:N<b&&(M+=2*L)}for(let N=0;N<x.length;N++)x[N]=x[N]/M;g.envMap.value=e.texture,g.samples.value=b,g.weights.value=x,g.latitudinal.value=o==="latitudinal",u&&(g.poleAxis.value=u);const{_lodMax:E}=this;g.dTheta.value=v,g.mipInt.value=E-n;const w=this._sizeLods[r],D=3*w*(r>E-dl?r-E+dl:0),C=4*(this._cubeSize-w);zc(t,D,C,3*w,2*w),c.setRenderTarget(t),c.render(p,od)}};function fk(i){const e=[],t=[],n=[];let r=i;const s=i-dl+1+pw.length;for(let o=0;o<s;o++){const u=Math.pow(2,r);e.push(u);let c=1/u;o>i-dl?c=pw[o-i+dl-1]:o===0&&(c=0),t.push(c);const h=1/(u-2),d=-h,p=1+h,g=[d,d,p,d,p,p,d,d,p,p,d,p],_=6,v=6,S=3,b=2,x=1,M=new Float32Array(S*v*_),E=new Float32Array(b*v*_),w=new Float32Array(x*v*_);for(let C=0;C<_;C++){const N=C%3*2/3-1,A=C>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];M.set(L,S*v*C),E.set(g,b*v*C);const j=[C,C,C,C,C,C];w.set(j,x*v*C)}const D=new Fi;D.setAttribute("position",new $i(M,S)),D.setAttribute("uv",new $i(E,b)),D.setAttribute("faceIndex",new $i(w,x)),n.push(new xi(D,null)),r>dl&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function _w(i,e,t){const n=new Hs(i,e,t);return n.texture.mapping=Mu,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function zc(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function dk(i,e,t){return new Ts({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:ck,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:K_(),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:Bi,depthTest:!1,depthWrite:!1})}function pk(i,e,t){const n=new Float32Array(uu),r=new G(0,1,0);return new Ts({name:"SphericalGaussianBlur",defines:{n:uu,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:K_(),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:Bi,depthTest:!1,depthWrite:!1})}function vw(){return new Ts({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:K_(),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:Bi,depthTest:!1,depthWrite:!1})}function yw(){return new Ts({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:K_(),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:Bi,depthTest:!1,depthWrite:!1})}function K_(){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 f2 extends Hs{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Kh(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`

				varying vec3 vWorldDirection;

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

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

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`,fragmentShader:`

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`},r=new zu(5,5,5),s=new Ts({name:"CubemapFromEquirect",uniforms:Ih(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Tn,blending:Bi});s.uniforms.tEquirect.value=t;const o=new xi(r,s),u=t.minFilter;return t.minFilter===Ur&&(t.minFilter=Rn),new l2(1,10,this).update(e,o),t.minFilter=u,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,r);e.setRenderTarget(s)}}function mk(i){let e=new WeakMap,t=new WeakMap,n=null;function r(g,_=!1){return g==null?null:_?o(g):s(g)}function s(g){if(g&&g.isTexture){const _=g.mapping;if(_===ih||_===rh)if(e.has(g)){const v=e.get(g).texture;return u(v,g.mapping)}else{const v=g.image;if(v&&v.height>0){const S=new f2(v.height);return S.fromEquirectangularTexture(i,g),e.set(g,S),g.addEventListener("dispose",h),u(S.texture,g.mapping)}else return null}}return g}function o(g){if(g&&g.isTexture){const _=g.mapping,v=_===ih||_===rh,S=_===js||_===xa;if(v||S){let b=t.get(g);const x=b!==void 0?b.texture.pmremVersion:0;if(g.isRenderTargetTexture&&g.pmremVersion!==x)return n===null&&(n=new gw(i)),b=v?n.fromEquirectangular(g,b):n.fromCubemap(g,b),b.texture.pmremVersion=g.pmremVersion,t.set(g,b),b.texture;if(b!==void 0)return b.texture;{const M=g.image;return v&&M&&M.height>0||S&&M&&c(M)?(n===null&&(n=new gw(i)),b=v?n.fromEquirectangular(g):n.fromCubemap(g),b.texture.pmremVersion=g.pmremVersion,t.set(g,b),g.addEventListener("dispose",d),b.texture):null}}}return g}function u(g,_){return _===ih?g.mapping=js:_===rh&&(g.mapping=xa),g}function c(g){let _=0;const v=6;for(let S=0;S<v;S++)g[S]!==void 0&&_++;return _===v}function h(g){const _=g.target;_.removeEventListener("dispose",h);const v=e.get(_);v!==void 0&&(e.delete(_),v.dispose())}function d(g){const _=g.target;_.removeEventListener("dispose",d);const v=t.get(_);v!==void 0&&(t.delete(_),v.dispose())}function p(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:p}}function gk(i){const e={};function t(n){if(e[n]!==void 0)return e[n];const r=i.getExtension(n);return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const r=t(n);return r===null&&xn("WebGLRenderer: "+n+" extension not supported."),r}}}function _k(i,e,t,n){const r={},s=new WeakMap;function o(p){const g=p.target;g.index!==null&&e.remove(g.index);for(const v in g.attributes)e.remove(g.attributes[v]);g.removeEventListener("dispose",o),delete r[g.id];const _=s.get(g);_&&(e.remove(_),s.delete(g)),n.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,t.memory.geometries--}function u(p,g){return r[g.id]===!0||(g.addEventListener("dispose",o),r[g.id]=!0,t.memory.geometries++),g}function c(p){const g=p.attributes;for(const _ in g)e.update(g[_],i.ARRAY_BUFFER)}function h(p){const g=[],_=p.index,v=p.attributes.position;let S=0;if(v===void 0)return;if(_!==null){const M=_.array;S=_.version;for(let E=0,w=M.length;E<w;E+=3){const D=M[E+0],C=M[E+1],N=M[E+2];g.push(D,C,C,N,N,D)}}else{const M=v.array;S=v.version;for(let E=0,w=M.length/3-1;E<w;E+=3){const D=E+0,C=E+1,N=E+2;g.push(D,C,C,N,N,D)}}const b=new(v.count>=65535?KS:YS)(g,1);b.version=S;const x=s.get(p);x&&e.remove(x),s.set(p,b)}function d(p){const g=s.get(p);if(g){const _=p.index;_!==null&&g.version<_.version&&h(p)}else h(p);return s.get(p)}return{get:u,update:c,getWireframeAttribute:d}}function vk(i,e,t){let n;function r(g){n=g}let s,o;function u(g){s=g.type,o=g.bytesPerElement}function c(g,_){i.drawElements(n,_,s,g*o),t.update(_,n,1)}function h(g,_,v){v!==0&&(i.drawElementsInstanced(n,_,s,g*o,v),t.update(_,n,v))}function d(g,_,v){if(v===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,_,0,s,g,0,v);let b=0;for(let x=0;x<v;x++)b+=_[x];t.update(b,n,1)}function p(g,_,v,S){if(v===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let x=0;x<g.length;x++)h(g[x]/o,_[x],S[x]);else{b.multiDrawElementsInstancedWEBGL(n,_,0,s,g,0,S,0,v);let x=0;for(let M=0;M<v;M++)x+=_[M]*S[M];t.update(x,n,1)}}this.setMode=r,this.setIndex=u,this.render=c,this.renderInstances=h,this.renderMultiDraw=d,this.renderMultiDrawInstances=p}function yk(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,u){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=u*(s/3);break;case i.LINES:t.lines+=u*(s/2);break;case i.LINE_STRIP:t.lines+=u*(s-1);break;case i.LINE_LOOP:t.lines+=u*s;break;case i.POINTS:t.points+=u*s;break;default:Pe("WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function xk(i,e,t){const n=new WeakMap,r=new Pt;function s(o,u,c){const h=o.morphTargetInfluences,d=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,p=d!==void 0?d.length:0;let g=n.get(u);if(g===void 0||g.count!==p){let j=function(){A.dispose(),n.delete(u),u.removeEventListener("dispose",j)};var _=j;g!==void 0&&g.texture.dispose();const v=u.morphAttributes.position!==void 0,S=u.morphAttributes.normal!==void 0,b=u.morphAttributes.color!==void 0,x=u.morphAttributes.position||[],M=u.morphAttributes.normal||[],E=u.morphAttributes.color||[];let w=0;v===!0&&(w=1),S===!0&&(w=2),b===!0&&(w=3);let D=u.attributes.position.count*w,C=1;D>e.maxTextureSize&&(C=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const N=new Float32Array(D*C*4*p),A=new $S(N,D,C,p);A.type=ri,A.needsUpdate=!0;const L=w*4;for(let z=0;z<p;z++){const H=x[z],K=M[z],te=E[z],Z=D*C*4*z;for(let I=0;I<H.count;I++){const F=I*L;v===!0&&(r.fromBufferAttribute(H,I),N[Z+F+0]=r.x,N[Z+F+1]=r.y,N[Z+F+2]=r.z,N[Z+F+3]=0),S===!0&&(r.fromBufferAttribute(K,I),N[Z+F+4]=r.x,N[Z+F+5]=r.y,N[Z+F+6]=r.z,N[Z+F+7]=0),b===!0&&(r.fromBufferAttribute(te,I),N[Z+F+8]=r.x,N[Z+F+9]=r.y,N[Z+F+10]=r.z,N[Z+F+11]=te.itemSize===4?r.w:1)}}g={count:p,texture:A,size:new Ie(D,C)},n.set(u,g),u.addEventListener("dispose",j)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let v=0;for(let b=0;b<h.length;b++)v+=h[b];const S=u.morphTargetsRelative?1:1-v;c.getUniforms().setValue(i,"morphTargetBaseInfluence",S),c.getUniforms().setValue(i,"morphTargetInfluences",h)}c.getUniforms().setValue(i,"morphTargetsTexture",g.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",g.size)}return{update:s}}function bk(i,e,t,n,r){let s=new WeakMap;function o(h){const d=r.render.frame,p=h.geometry,g=e.get(h,p);if(s.get(g)!==d&&(e.update(g),s.set(g,d)),h.isInstancedMesh&&(h.hasEventListener("dispose",c)===!1&&h.addEventListener("dispose",c),s.get(h)!==d&&(t.update(h.instanceMatrix,i.ARRAY_BUFFER),h.instanceColor!==null&&t.update(h.instanceColor,i.ARRAY_BUFFER),s.set(h,d))),h.isSkinnedMesh){const _=h.skeleton;s.get(_)!==d&&(_.update(),s.set(_,d))}return g}function u(){s=new WeakMap}function c(h){const d=h.target;d.removeEventListener("dispose",c),n.releaseStatesOfObject(d),t.remove(d.instanceMatrix),d.instanceColor!==null&&t.remove(d.instanceColor)}return{update:o,dispose:u}}const Sk={[NS]:"LINEAR_TONE_MAPPING",[DS]:"REINHARD_TONE_MAPPING",[LS]:"CINEON_TONE_MAPPING",[PS]:"ACES_FILMIC_TONE_MAPPING",[US]:"AGX_TONE_MAPPING",[OS]:"NEUTRAL_TONE_MAPPING",[VN]:"CUSTOM_TONE_MAPPING"};function Tk(i,e,t,n,r){const s=new Hs(e,t,{type:i,depthBuffer:n,stencilBuffer:r}),o=new Hs(e,t,{type:Qn,depthBuffer:!1,stencilBuffer:!1}),u=new Fi;u.setAttribute("position",new ti([-1,3,0,-1,-1,0,3,-1,0],3)),u.setAttribute("uv",new ti([0,2,0,0,2,0],2));const c=new QB({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}),h=new xi(u,c),d=new Zh(-1,1,1,-1,0,1);let p=null,g=null,_=!1,v,S=null,b=[],x=!1;this.setSize=function(M,E){s.setSize(M,E),o.setSize(M,E);for(let w=0;w<b.length;w++){const D=b[w];D.setSize&&D.setSize(M,E)}},this.setEffects=function(M){b=M,x=b.length>0&&b[0].isRenderPass===!0;const E=s.width,w=s.height;for(let D=0;D<b.length;D++){const C=b[D];C.setSize&&C.setSize(E,w)}},this.begin=function(M,E){if(_||M.toneMapping===ji&&b.length===0)return!1;if(S=E,E!==null){const w=E.width,D=E.height;(s.width!==w||s.height!==D)&&this.setSize(w,D)}return x===!1&&M.setRenderTarget(s),v=M.toneMapping,M.toneMapping=ji,!0},this.hasRenderPass=function(){return x},this.end=function(M,E){M.toneMapping=v,_=!0;let w=s,D=o;for(let C=0;C<b.length;C++){const N=b[C];if(N.enabled!==!1&&(N.render(M,D,w,E),N.needsSwap!==!1)){const A=w;w=D,D=A}}if(p!==M.outputColorSpace||g!==M.toneMapping){p=M.outputColorSpace,g=M.toneMapping,c.defines={},xt.getTransfer(p)===Ye&&(c.defines.SRGB_TRANSFER="");const C=Sk[g];C&&(c.defines[C]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=w.texture,M.setRenderTarget(S),M.render(h,d),S=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){s.dispose(),o.dispose(),u.dispose(),c.dispose()}}const d2=new vi,Nb=new br(1,1),p2=new $S,m2=new fB,g2=new Kh,xw=[],bw=[],Sw=new Float32Array(16),Tw=new Float32Array(9),Mw=new Float32Array(4);function Qh(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=xw[r];if(s===void 0&&(s=new Float32Array(r),xw[r]=s),e!==0){n.toArray(s,0);for(let o=1,u=0;o!==e;++o)u+=t,i[o].toArray(s,u)}return s}function wi(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Ri(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Z_(i,e){let t=bw[e];t===void 0&&(t=new Int32Array(e),bw[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Mk(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function Ek(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wi(t,e))return;i.uniform2fv(this.addr,e),Ri(t,e)}}function Ak(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(wi(t,e))return;i.uniform3fv(this.addr,e),Ri(t,e)}}function wk(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(wi(t,e))return;i.uniform4fv(this.addr,e),Ri(t,e)}}function Rk(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(wi(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Ri(t,e)}else{if(wi(t,n))return;Mw.set(n),i.uniformMatrix2fv(this.addr,!1,Mw),Ri(t,n)}}function Ck(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(wi(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Ri(t,e)}else{if(wi(t,n))return;Tw.set(n),i.uniformMatrix3fv(this.addr,!1,Tw),Ri(t,n)}}function Nk(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(wi(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Ri(t,e)}else{if(wi(t,n))return;Sw.set(n),i.uniformMatrix4fv(this.addr,!1,Sw),Ri(t,n)}}function Dk(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Lk(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wi(t,e))return;i.uniform2iv(this.addr,e),Ri(t,e)}}function Pk(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(wi(t,e))return;i.uniform3iv(this.addr,e),Ri(t,e)}}function Uk(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(wi(t,e))return;i.uniform4iv(this.addr,e),Ri(t,e)}}function Ok(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Bk(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wi(t,e))return;i.uniform2uiv(this.addr,e),Ri(t,e)}}function Fk(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(wi(t,e))return;i.uniform3uiv(this.addr,e),Ri(t,e)}}function Ik(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(wi(t,e))return;i.uniform4uiv(this.addr,e),Ri(t,e)}}function zk(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Nb.compareFunction=t.isReversedDepthBuffer()?bo:wl,s=Nb):s=d2,t.setTexture2D(e||s,r)}function kk(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||m2,r)}function Gk(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||g2,r)}function Vk(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||p2,r)}function Hk(i){switch(i){case 5126:return Mk;case 35664:return Ek;case 35665:return Ak;case 35666:return wk;case 35674:return Rk;case 35675:return Ck;case 35676:return Nk;case 5124:case 35670:return Dk;case 35667:case 35671:return Lk;case 35668:case 35672:return Pk;case 35669:case 35673:return Uk;case 5125:return Ok;case 36294:return Bk;case 36295:return Fk;case 36296:return Ik;case 35678:case 36198:case 36298:case 36306:case 35682:return zk;case 35679:case 36299:case 36307:return kk;case 35680:case 36300:case 36308:case 36293:return Gk;case 36289:case 36303:case 36311:case 36292:return Vk}}function jk(i,e){i.uniform1fv(this.addr,e)}function Wk(i,e){const t=Qh(e,this.size,2);i.uniform2fv(this.addr,t)}function $k(i,e){const t=Qh(e,this.size,3);i.uniform3fv(this.addr,t)}function qk(i,e){const t=Qh(e,this.size,4);i.uniform4fv(this.addr,t)}function Xk(i,e){const t=Qh(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Yk(i,e){const t=Qh(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Kk(i,e){const t=Qh(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Zk(i,e){i.uniform1iv(this.addr,e)}function Qk(i,e){i.uniform2iv(this.addr,e)}function Jk(i,e){i.uniform3iv(this.addr,e)}function eG(i,e){i.uniform4iv(this.addr,e)}function tG(i,e){i.uniform1uiv(this.addr,e)}function nG(i,e){i.uniform2uiv(this.addr,e)}function iG(i,e){i.uniform3uiv(this.addr,e)}function rG(i,e){i.uniform4uiv(this.addr,e)}function sG(i,e,t){const n=this.cache,r=e.length,s=Z_(t,r);wi(n,s)||(i.uniform1iv(this.addr,s),Ri(n,s));let o;this.type===i.SAMPLER_2D_SHADOW?o=Nb:o=d2;for(let u=0;u!==r;++u)t.setTexture2D(e[u]||o,s[u])}function aG(i,e,t){const n=this.cache,r=e.length,s=Z_(t,r);wi(n,s)||(i.uniform1iv(this.addr,s),Ri(n,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||m2,s[o])}function oG(i,e,t){const n=this.cache,r=e.length,s=Z_(t,r);wi(n,s)||(i.uniform1iv(this.addr,s),Ri(n,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||g2,s[o])}function lG(i,e,t){const n=this.cache,r=e.length,s=Z_(t,r);wi(n,s)||(i.uniform1iv(this.addr,s),Ri(n,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||p2,s[o])}function uG(i){switch(i){case 5126:return jk;case 35664:return Wk;case 35665:return $k;case 35666:return qk;case 35674:return Xk;case 35675:return Yk;case 35676:return Kk;case 5124:case 35670:return Zk;case 35667:case 35671:return Qk;case 35668:case 35672:return Jk;case 35669:case 35673:return eG;case 5125:return tG;case 36294:return nG;case 36295:return iG;case 36296:return rG;case 35678:case 36198:case 36298:case 36306:case 35682:return sG;case 35679:case 36299:case 36307:return aG;case 35680:case 36300:case 36308:case 36293:return oG;case 36289:case 36303:case 36311:case 36292:return lG}}class cG{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Hk(t.type)}}class hG{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=uG(t.type)}}class fG{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,o=r.length;s!==o;++s){const u=r[s];u.setValue(e,t[u.id],n)}}}const ox=/(\w+)(\])?(\[|\.)?/g;function Ew(i,e){i.seq.push(e),i.map[e.id]=e}function dG(i,e,t){const n=i.name,r=n.length;for(ox.lastIndex=0;;){const s=ox.exec(n),o=ox.lastIndex;let u=s[1];const c=s[2]==="]",h=s[3];if(c&&(u=u|0),h===void 0||h==="["&&o+2===r){Ew(t,h===void 0?new cG(u,i,e):new hG(u,i,e));break}else{let p=t.map[u];p===void 0&&(p=new fG(u),Ew(t,p)),t=p}}}class r_{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let o=0;o<n;++o){const u=e.getActiveUniform(t,o),c=e.getUniformLocation(t,u.name);dG(u,c,this)}const r=[],s=[];for(const o of this.seq)o.type===e.SAMPLER_2D_SHADOW||o.type===e.SAMPLER_CUBE_SHADOW||o.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(o):s.push(o);r.length>0&&(this.seq=r.concat(s))}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,o=t.length;s!==o;++s){const u=t[s],c=n[u.id];c.needsUpdate!==!1&&u.setValue(e,c.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const o=e[r];o.id in t&&n.push(o)}return n}}function Aw(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const pG=37297;let mG=0;function gG(i,e){const t=i.split(`
`),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){const u=o+1;n.push(`${u===e?">":" "} ${u}: ${t[o]}`)}return n.join(`
`)}const ww=new Nt;function _G(i){xt._getMatrix(ww,xt.workingColorSpace,i);const e=`mat3( ${ww.elements.map(t=>t.toFixed(4))} )`;switch(xt.getTransfer(i)){case Bh:return[e,"LinearTransferOETF"];case Ye:return[e,"sRGBTransferOETF"];default:return Ne("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Rw(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";const o=/ERROR: 0:(\d+)/.exec(s);if(o){const u=parseInt(o[1]);return t.toUpperCase()+`

`+s+`

`+gG(i.getShaderSource(e),u)}else return s}function vG(i,e){const t=_G(e);return[`vec4 ${i}( vec4 value ) {`,`	return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}const yG={[NS]:"Linear",[DS]:"Reinhard",[LS]:"Cineon",[PS]:"ACESFilmic",[US]:"AgX",[OS]:"Neutral",[VN]:"Custom"};function xG(i,e){const t=yG[e];return t===void 0?(Ne("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const gg=new G;function bG(){xt.getLuminanceCoefficients(gg);const i=gg.x.toFixed(4),e=gg.y.toFixed(4),t=gg.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",`	const vec3 weights = vec3( ${i}, ${e}, ${t} );`,"	return dot( weights, rgb );","}"].join(`
`)}function SG(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(wd).join(`
`)}function TG(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
`)}function MG(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),o=s.name;let u=1;s.type===i.FLOAT_MAT2&&(u=2),s.type===i.FLOAT_MAT3&&(u=3),s.type===i.FLOAT_MAT4&&(u=4),t[o]={type:s.type,location:i.getAttribLocation(e,o),locationSize:u}}return t}function wd(i){return i!==""}function Cw(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Nw(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const EG=/^[ \t]*#include +<([\w\d./]+)>/gm;function Db(i){return i.replace(EG,wG)}const AG=new Map;function wG(i,e){let t=jt[e];if(t===void 0){const n=AG.get(e);if(n!==void 0)t=jt[n],Ne('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Db(t)}const RG=/#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 Dw(i){return i.replace(RG,CG)}function CG(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Lw(i){let e=`precision ${i.precision} float;
	precision ${i.precision} int;
	precision ${i.precision} sampler2D;
	precision ${i.precision} samplerCube;
	precision ${i.precision} sampler3D;
	precision ${i.precision} sampler2DArray;
	precision ${i.precision} sampler2DShadow;
	precision ${i.precision} samplerCubeShadow;
	precision ${i.precision} sampler2DArrayShadow;
	precision ${i.precision} isampler2D;
	precision ${i.precision} isampler3D;
	precision ${i.precision} isamplerCube;
	precision ${i.precision} isampler2DArray;
	precision ${i.precision} usampler2D;
	precision ${i.precision} usampler3D;
	precision ${i.precision} usamplerCube;
	precision ${i.precision} usampler2DArray;
	`;return i.precision==="highp"?e+=`
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}const NG={[nh]:"SHADOWMAP_TYPE_PCF",[da]:"SHADOWMAP_TYPE_VSM"};function DG(i){return NG[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const LG={[js]:"ENVMAP_TYPE_CUBE",[xa]:"ENVMAP_TYPE_CUBE",[Mu]:"ENVMAP_TYPE_CUBE_UV"};function PG(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":LG[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const UG={[xa]:"ENVMAP_MODE_REFRACTION"};function OG(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":UG[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const BG={[yp]:"ENVMAP_BLENDING_MULTIPLY",[kN]:"ENVMAP_BLENDING_MIX",[GN]:"ENVMAP_BLENDING_ADD"};function FG(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":BG[i.combine]||"ENVMAP_BLENDING_NONE"}function IG(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function zG(i,e,t,n){const r=i.getContext(),s=t.defines;let o=t.vertexShader,u=t.fragmentShader;const c=DG(t),h=PG(t),d=OG(t),p=FG(t),g=IG(t),_=SG(t),v=TG(s),S=r.createProgram();let b,x,M=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(b=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(wd).join(`
`),b.length>0&&(b+=`
`),x=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(wd).join(`
`),x.length>0&&(x+=`
`)):(b=[Lw(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","	attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","	attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","	uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","	attribute vec2 uv1;","#endif","#ifdef USE_UV2","	attribute vec2 uv2;","#endif","#ifdef USE_UV3","	attribute vec2 uv3;","#endif","#ifdef USE_TANGENT","	attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","	attribute vec4 color;","#elif defined( USE_COLOR )","	attribute vec3 color;","#endif","#ifdef USE_SKINNING","	attribute vec4 skinIndex;","	attribute vec4 skinWeight;","#endif",`
`].filter(wd).join(`
`),x=[Lw(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",t.envMap?"#define "+p:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ji?"#define TONE_MAPPING":"",t.toneMapping!==ji?jt.tonemapping_pars_fragment:"",t.toneMapping!==ji?xG("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",jt.colorspace_pars_fragment,vG("linearToOutputTexel",t.outputColorSpace),bG(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(wd).join(`
`)),o=Db(o),o=Cw(o,t),o=Nw(o,t),u=Db(u),u=Cw(u,t),u=Nw(u,t),o=Dw(o),u=Dw(u),t.isRawShaderMaterial!==!0&&(M=`#version 300 es
`,b=[_,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+b,x=["#define varying in",t.glslVersion===k1?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===k1?"":"#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 E=M+b+o,w=M+x+u,D=Aw(r,r.VERTEX_SHADER,E),C=Aw(r,r.FRAGMENT_SHADER,w);r.attachShader(S,D),r.attachShader(S,C),t.index0AttributeName!==void 0?r.bindAttribLocation(S,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(S,0,"position"),r.linkProgram(S);function N(z){if(i.debug.checkShaderErrors){const H=r.getProgramInfoLog(S)||"",K=r.getShaderInfoLog(D)||"",te=r.getShaderInfoLog(C)||"",Z=H.trim(),I=K.trim(),F=te.trim();let Y=!0,se=!0;if(r.getProgramParameter(S,r.LINK_STATUS)===!1)if(Y=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,S,D,C);else{const Te=Rw(r,D,"vertex"),O=Rw(r,C,"fragment");Pe("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(S,r.VALIDATE_STATUS)+`

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

Program Info Log: `+Z+`
`+Te+`
`+O)}else Z!==""?Ne("WebGLProgram: Program Info Log:",Z):(I===""||F==="")&&(se=!1);se&&(z.diagnostics={runnable:Y,programLog:Z,vertexShader:{log:I,prefix:b},fragmentShader:{log:F,prefix:x}})}r.deleteShader(D),r.deleteShader(C),A=new r_(r,S),L=MG(r,S)}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=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return j===!1&&(j=r.getProgramParameter(S,pG)),j},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=mG++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=D,this.fragmentShader=C,this}let kG=0;class GG{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new VG(e),t.set(e,n)),n}}class VG{constructor(e){this.id=kG++,this.code=e,this.usedTimes=0}}function HG(i,e,t,n,r,s){const o=new qS,u=new GG,c=new Set,h=[],d=new Map,p=n.logarithmicDepthBuffer;let g=n.precision;const _={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 v(A){return c.add(A),A===0?"uv":`uv${A}`}function S(A,L,j,z,H){const K=z.fog,te=H.geometry,Z=A.isMeshStandardMaterial||A.isMeshLambertMaterial||A.isMeshPhongMaterial?z.environment:null,I=A.isMeshStandardMaterial||A.isMeshLambertMaterial&&!A.envMap||A.isMeshPhongMaterial&&!A.envMap,F=e.get(A.envMap||Z,I),Y=F&&F.mapping===Mu?F.image.height:null,se=_[A.type];A.precision!==null&&(g=n.getMaxPrecision(A.precision),g!==A.precision&&Ne("WebGLProgram.getParameters:",A.precision,"not supported, using",g,"instead."));const Te=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,O=Te!==void 0?Te.length:0;let W=0;te.morphAttributes.position!==void 0&&(W=1),te.morphAttributes.normal!==void 0&&(W=2),te.morphAttributes.color!==void 0&&(W=3);let ce,Le,ee,$;if(se){const an=oa[se];ce=an.vertexShader,Le=an.fragmentShader}else ce=A.vertexShader,Le=A.fragmentShader,u.update(A),ee=u.getVertexShaderID(A),$=u.getFragmentShaderID(A);const ue=i.getRenderTarget(),Ee=i.state.buffers.depth.getReversed(),ke=H.isInstancedMesh===!0,We=H.isBatchedMesh===!0,Ke=!!A.map,sn=!!A.matcap,Ut=!!F,Rt=!!A.aoMap,qt=!!A.lightMap,St=!!A.bumpMap,on=!!A.normalMap,Q=!!A.displacementMap,$n=!!A.emissiveMap,nn=!!A.metalnessMap,_n=!!A.roughnessMap,ht=A.anisotropy>0,V=A.clearcoat>0,P=A.dispersion>0,ae=A.iridescence>0,Re=A.sheen>0,Ue=A.transmission>0,Ae=ht&&!!A.anisotropyMap,lt=V&&!!A.clearcoatMap,He=V&&!!A.clearcoatNormalMap,gt=V&&!!A.clearcoatRoughnessMap,Tt=ae&&!!A.iridescenceMap,Fe=ae&&!!A.iridescenceThicknessMap,Oe=Re&&!!A.sheenColorMap,Ze=Re&&!!A.sheenRoughnessMap,Xe=!!A.specularMap,Qe=!!A.specularColorMap,Gt=!!A.specularIntensityMap,re=Ue&&!!A.transmissionMap,Ge=Ue&&!!A.thicknessMap,ze=!!A.gradientMap,Je=!!A.alphaMap,Be=A.alphaTest>0,Me=!!A.alphaHash,nt=!!A.extensions;let Ct=ji;A.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(Ct=i.toneMapping);const Mn={shaderID:se,shaderType:A.type,shaderName:A.name,vertexShader:ce,fragmentShader:Le,defines:A.defines,customVertexShaderID:ee,customFragmentShaderID:$,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:g,batching:We,batchingColor:We&&H._colorsTexture!==null,instancing:ke,instancingColor:ke&&H.instanceColor!==null,instancingMorph:ke&&H.morphTexture!==null,outputColorSpace:ue===null?i.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:Cu,alphaToCoverage:!!A.alphaToCoverage,map:Ke,matcap:sn,envMap:Ut,envMapMode:Ut&&F.mapping,envMapCubeUVHeight:Y,aoMap:Rt,lightMap:qt,bumpMap:St,normalMap:on,displacementMap:Q,emissiveMap:$n,normalMapObjectSpace:on&&A.normalMapType===HN,normalMapTangentSpace:on&&A.normalMapType===va,metalnessMap:nn,roughnessMap:_n,anisotropy:ht,anisotropyMap:Ae,clearcoat:V,clearcoatMap:lt,clearcoatNormalMap:He,clearcoatRoughnessMap:gt,dispersion:P,iridescence:ae,iridescenceMap:Tt,iridescenceThicknessMap:Fe,sheen:Re,sheenColorMap:Oe,sheenRoughnessMap:Ze,specularMap:Xe,specularColorMap:Qe,specularIntensityMap:Gt,transmission:Ue,transmissionMap:re,thicknessMap:Ge,gradientMap:ze,opaque:A.transparent===!1&&A.blending===pr&&A.alphaToCoverage===!1,alphaMap:Je,alphaTest:Be,alphaHash:Me,combine:A.combine,mapUv:Ke&&v(A.map.channel),aoMapUv:Rt&&v(A.aoMap.channel),lightMapUv:qt&&v(A.lightMap.channel),bumpMapUv:St&&v(A.bumpMap.channel),normalMapUv:on&&v(A.normalMap.channel),displacementMapUv:Q&&v(A.displacementMap.channel),emissiveMapUv:$n&&v(A.emissiveMap.channel),metalnessMapUv:nn&&v(A.metalnessMap.channel),roughnessMapUv:_n&&v(A.roughnessMap.channel),anisotropyMapUv:Ae&&v(A.anisotropyMap.channel),clearcoatMapUv:lt&&v(A.clearcoatMap.channel),clearcoatNormalMapUv:He&&v(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:gt&&v(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Tt&&v(A.iridescenceMap.channel),iridescenceThicknessMapUv:Fe&&v(A.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&v(A.sheenColorMap.channel),sheenRoughnessMapUv:Ze&&v(A.sheenRoughnessMap.channel),specularMapUv:Xe&&v(A.specularMap.channel),specularColorMapUv:Qe&&v(A.specularColorMap.channel),specularIntensityMapUv:Gt&&v(A.specularIntensityMap.channel),transmissionMapUv:re&&v(A.transmissionMap.channel),thicknessMapUv:Ge&&v(A.thicknessMap.channel),alphaMapUv:Je&&v(A.alphaMap.channel),vertexTangents:!!te.attributes.tangent&&(on||ht),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!te.attributes.color&&te.attributes.color.itemSize===4,pointsUvs:H.isPoints===!0&&!!te.attributes.uv&&(Ke||Je),fog:!!K,useFog:A.fog===!0,fogExp2:!!K&&K.isFogExp2,flatShading:A.wireframe===!1&&(A.flatShading===!0||te.attributes.normal===void 0&&on===!1&&(A.isMeshLambertMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isMeshPhysicalMaterial)),sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:p,reversedDepthBuffer:Ee,skinning:H.isSkinnedMesh===!0,morphTargets:te.morphAttributes.position!==void 0,morphNormals:te.morphAttributes.normal!==void 0,morphColors:te.morphAttributes.color!==void 0,morphTargetsCount:O,morphTextureStride:W,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,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:A.dithering,shadowMapEnabled:i.shadowMap.enabled&&j.length>0,shadowMapType:i.shadowMap.type,toneMapping:Ct,decodeVideoTexture:Ke&&A.map.isVideoTexture===!0&&xt.getTransfer(A.map.colorSpace)===Ye,decodeVideoTextureEmissive:$n&&A.emissiveMap.isVideoTexture===!0&&xt.getTransfer(A.emissiveMap.colorSpace)===Ye,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===Ui,flipSided:A.side===Tn,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:nt&&A.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(nt&&A.extensions.multiDraw===!0||We)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return Mn.vertexUv1s=c.has(1),Mn.vertexUv2s=c.has(2),Mn.vertexUv3s=c.has(3),c.clear(),Mn}function b(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),M(L,A),L.push(i.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 M(A,L){o.disableAll(),L.instancing&&o.enable(0),L.instancingColor&&o.enable(1),L.instancingMorph&&o.enable(2),L.matcap&&o.enable(3),L.envMap&&o.enable(4),L.normalMapObjectSpace&&o.enable(5),L.normalMapTangentSpace&&o.enable(6),L.clearcoat&&o.enable(7),L.iridescence&&o.enable(8),L.alphaTest&&o.enable(9),L.vertexColors&&o.enable(10),L.vertexAlphas&&o.enable(11),L.vertexUv1s&&o.enable(12),L.vertexUv2s&&o.enable(13),L.vertexUv3s&&o.enable(14),L.vertexTangents&&o.enable(15),L.anisotropy&&o.enable(16),L.alphaHash&&o.enable(17),L.batching&&o.enable(18),L.dispersion&&o.enable(19),L.batchingColor&&o.enable(20),L.gradientMap&&o.enable(21),A.push(o.mask),o.disableAll(),L.fog&&o.enable(0),L.useFog&&o.enable(1),L.flatShading&&o.enable(2),L.logarithmicDepthBuffer&&o.enable(3),L.reversedDepthBuffer&&o.enable(4),L.skinning&&o.enable(5),L.morphTargets&&o.enable(6),L.morphNormals&&o.enable(7),L.morphColors&&o.enable(8),L.premultipliedAlpha&&o.enable(9),L.shadowMapEnabled&&o.enable(10),L.doubleSided&&o.enable(11),L.flipSided&&o.enable(12),L.useDepthPacking&&o.enable(13),L.dithering&&o.enable(14),L.transmission&&o.enable(15),L.sheen&&o.enable(16),L.opaque&&o.enable(17),L.pointsUvs&&o.enable(18),L.decodeVideoTexture&&o.enable(19),L.decodeVideoTextureEmissive&&o.enable(20),L.alphaToCoverage&&o.enable(21),A.push(o.mask)}function E(A){const L=_[A.type];let j;if(L){const z=oa[L];j=n2.clone(z.uniforms)}else j=A.uniforms;return j}function w(A,L){let j=d.get(L);return j!==void 0?++j.usedTimes:(j=new zG(i,L,A,r),h.push(j),d.set(L,j)),j}function D(A){if(--A.usedTimes===0){const L=h.indexOf(A);h[L]=h[h.length-1],h.pop(),d.delete(A.cacheKey),A.destroy()}}function C(A){u.remove(A)}function N(){u.dispose()}return{getParameters:S,getProgramCacheKey:b,getUniforms:E,acquireProgram:w,releaseProgram:D,releaseShaderCache:C,programs:h,dispose:N}}function jG(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let u=i.get(o);return u===void 0&&(u={},i.set(o,u)),u}function n(o){i.delete(o)}function r(o,u,c){i.get(o)[u]=c}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function WG(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function Pw(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Uw(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function o(g){let _=0;return g.isInstancedMesh&&(_+=2),g.isSkinnedMesh&&(_+=1),_}function u(g,_,v,S,b,x){let M=i[e];return M===void 0?(M={id:g.id,object:g,geometry:_,material:v,materialVariant:o(g),groupOrder:S,renderOrder:g.renderOrder,z:b,group:x},i[e]=M):(M.id=g.id,M.object=g,M.geometry=_,M.material=v,M.materialVariant=o(g),M.groupOrder=S,M.renderOrder=g.renderOrder,M.z=b,M.group=x),e++,M}function c(g,_,v,S,b,x){const M=u(g,_,v,S,b,x);v.transmission>0?n.push(M):v.transparent===!0?r.push(M):t.push(M)}function h(g,_,v,S,b,x){const M=u(g,_,v,S,b,x);v.transmission>0?n.unshift(M):v.transparent===!0?r.unshift(M):t.unshift(M)}function d(g,_){t.length>1&&t.sort(g||WG),n.length>1&&n.sort(_||Pw),r.length>1&&r.sort(_||Pw)}function p(){for(let g=e,_=i.length;g<_;g++){const v=i[g];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:c,unshift:h,finish:p,sort:d}}function $G(){let i=new WeakMap;function e(n,r){const s=i.get(n);let o;return s===void 0?(o=new Uw,i.set(n,[o])):r>=s.length?(o=new Uw,s.push(o)):o=s[r],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function qG(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new G,color:new pt};break;case"SpotLight":t={position:new G,direction:new G,color:new pt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new G,color:new pt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new G,skyColor:new pt,groundColor:new pt};break;case"RectAreaLight":t={color:new pt,position:new G,halfWidth:new G,halfHeight:new G};break}return i[e.id]=t,t}}}function XG(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let YG=0;function KG(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function ZG(i){const e=new qG,t=XG(),n={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++)n.probe.push(new G);const r=new G,s=new Wt,o=new Wt;function u(h){let d=0,p=0,g=0;for(let L=0;L<9;L++)n.probe[L].set(0,0,0);let _=0,v=0,S=0,b=0,x=0,M=0,E=0,w=0,D=0,C=0,N=0;h.sort(KG);for(let L=0,j=h.length;L<j;L++){const z=h[L],H=z.color,K=z.intensity,te=z.distance;let Z=null;if(z.shadow&&z.shadow.map&&(z.shadow.map.texture.format===vr?Z=z.shadow.map.texture:Z=z.shadow.map.depthTexture||z.shadow.map.texture),z.isAmbientLight)d+=H.r*K,p+=H.g*K,g+=H.b*K;else if(z.isLightProbe){for(let I=0;I<9;I++)n.probe[I].addScaledVector(z.sh.coefficients[I],K);N++}else if(z.isDirectionalLight){const I=e.get(z);if(I.color.copy(z.color).multiplyScalar(z.intensity),z.castShadow){const F=z.shadow,Y=t.get(z);Y.shadowIntensity=F.intensity,Y.shadowBias=F.bias,Y.shadowNormalBias=F.normalBias,Y.shadowRadius=F.radius,Y.shadowMapSize=F.mapSize,n.directionalShadow[_]=Y,n.directionalShadowMap[_]=Z,n.directionalShadowMatrix[_]=z.shadow.matrix,M++}n.directional[_]=I,_++}else if(z.isSpotLight){const I=e.get(z);I.position.setFromMatrixPosition(z.matrixWorld),I.color.copy(H).multiplyScalar(K),I.distance=te,I.coneCos=Math.cos(z.angle),I.penumbraCos=Math.cos(z.angle*(1-z.penumbra)),I.decay=z.decay,n.spot[S]=I;const F=z.shadow;if(z.map&&(n.spotLightMap[D]=z.map,D++,F.updateMatrices(z),z.castShadow&&C++),n.spotLightMatrix[S]=F.matrix,z.castShadow){const Y=t.get(z);Y.shadowIntensity=F.intensity,Y.shadowBias=F.bias,Y.shadowNormalBias=F.normalBias,Y.shadowRadius=F.radius,Y.shadowMapSize=F.mapSize,n.spotShadow[S]=Y,n.spotShadowMap[S]=Z,w++}S++}else if(z.isRectAreaLight){const I=e.get(z);I.color.copy(H).multiplyScalar(K),I.halfWidth.set(z.width*.5,0,0),I.halfHeight.set(0,z.height*.5,0),n.rectArea[b]=I,b++}else if(z.isPointLight){const I=e.get(z);if(I.color.copy(z.color).multiplyScalar(z.intensity),I.distance=z.distance,I.decay=z.decay,z.castShadow){const F=z.shadow,Y=t.get(z);Y.shadowIntensity=F.intensity,Y.shadowBias=F.bias,Y.shadowNormalBias=F.normalBias,Y.shadowRadius=F.radius,Y.shadowMapSize=F.mapSize,Y.shadowCameraNear=F.camera.near,Y.shadowCameraFar=F.camera.far,n.pointShadow[v]=Y,n.pointShadowMap[v]=Z,n.pointShadowMatrix[v]=z.shadow.matrix,E++}n.point[v]=I,v++}else if(z.isHemisphereLight){const I=e.get(z);I.skyColor.copy(z.color).multiplyScalar(K),I.groundColor.copy(z.groundColor).multiplyScalar(K),n.hemi[x]=I,x++}}b>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=qe.LTC_FLOAT_1,n.rectAreaLTC2=qe.LTC_FLOAT_2):(n.rectAreaLTC1=qe.LTC_HALF_1,n.rectAreaLTC2=qe.LTC_HALF_2)),n.ambient[0]=d,n.ambient[1]=p,n.ambient[2]=g;const A=n.hash;(A.directionalLength!==_||A.pointLength!==v||A.spotLength!==S||A.rectAreaLength!==b||A.hemiLength!==x||A.numDirectionalShadows!==M||A.numPointShadows!==E||A.numSpotShadows!==w||A.numSpotMaps!==D||A.numLightProbes!==N)&&(n.directional.length=_,n.spot.length=S,n.rectArea.length=b,n.point.length=v,n.hemi.length=x,n.directionalShadow.length=M,n.directionalShadowMap.length=M,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=w,n.spotShadowMap.length=w,n.directionalShadowMatrix.length=M,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=w+D-C,n.spotLightMap.length=D,n.numSpotLightShadowsWithMaps=C,n.numLightProbes=N,A.directionalLength=_,A.pointLength=v,A.spotLength=S,A.rectAreaLength=b,A.hemiLength=x,A.numDirectionalShadows=M,A.numPointShadows=E,A.numSpotShadows=w,A.numSpotMaps=D,A.numLightProbes=N,n.version=YG++)}function c(h,d){let p=0,g=0,_=0,v=0,S=0;const b=d.matrixWorldInverse;for(let x=0,M=h.length;x<M;x++){const E=h[x];if(E.isDirectionalLight){const w=n.directional[p];w.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(b),p++}else if(E.isSpotLight){const w=n.spot[_];w.position.setFromMatrixPosition(E.matrixWorld),w.position.applyMatrix4(b),w.direction.setFromMatrixPosition(E.matrixWorld),r.setFromMatrixPosition(E.target.matrixWorld),w.direction.sub(r),w.direction.transformDirection(b),_++}else if(E.isRectAreaLight){const w=n.rectArea[v];w.position.setFromMatrixPosition(E.matrixWorld),w.position.applyMatrix4(b),o.identity(),s.copy(E.matrixWorld),s.premultiply(b),o.extractRotation(s),w.halfWidth.set(E.width*.5,0,0),w.halfHeight.set(0,E.height*.5,0),w.halfWidth.applyMatrix4(o),w.halfHeight.applyMatrix4(o),v++}else if(E.isPointLight){const w=n.point[g];w.position.setFromMatrixPosition(E.matrixWorld),w.position.applyMatrix4(b),g++}else if(E.isHemisphereLight){const w=n.hemi[S];w.direction.setFromMatrixPosition(E.matrixWorld),w.direction.transformDirection(b),S++}}}return{setup:u,setupView:c,state:n}}function Ow(i){const e=new ZG(i),t=[],n=[];function r(d){h.camera=d,t.length=0,n.length=0}function s(d){t.push(d)}function o(d){n.push(d)}function u(){e.setup(t)}function c(d){e.setupView(t,d)}const h={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:h,setupLights:u,setupLightsView:c,pushLight:s,pushShadow:o}}function QG(i){let e=new WeakMap;function t(r,s=0){const o=e.get(r);let u;return o===void 0?(u=new Ow(i),e.set(r,[u])):s>=o.length?(u=new Ow(i),o.push(u)):u=o[s],u}function n(){e=new WeakMap}return{get:t,dispose:n}}const JG=`void main() {
	gl_Position = vec4( position, 1.0 );
}`,e4=`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 );
}`,t4=[new G(1,0,0),new G(-1,0,0),new G(0,1,0),new G(0,-1,0),new G(0,0,1),new G(0,0,-1)],n4=[new G(0,-1,0),new G(0,-1,0),new G(0,0,1),new G(0,0,-1),new G(0,-1,0),new G(0,-1,0)],Bw=new Wt,ld=new G,lx=new G;function i4(i,e,t){let n=new Tp;const r=new Ie,s=new Ie,o=new Pt,u=new iF,c=new rF,h={},d=t.maxTextureSize,p={[xr]:Tn,[Tn]:xr,[Ui]:Ui},g=new Ts({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ie},radius:{value:4}},vertexShader:JG,fragmentShader:e4}),_=g.clone();_.defines.HORIZONTAL_PASS=1;const v=new Fi;v.setAttribute("position",new $i(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new xi(v,g),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=nh;let x=this.type;this.render=function(C,N,A){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||C.length===0)return;this.type===BN&&(Ne("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=nh);const L=i.getRenderTarget(),j=i.getActiveCubeFace(),z=i.getActiveMipmapLevel(),H=i.state;H.setBlending(Bi),H.buffers.depth.getReversed()===!0?H.buffers.color.setClear(0,0,0,0):H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const K=x!==this.type;K&&N.traverse(function(te){te.material&&(Array.isArray(te.material)?te.material.forEach(Z=>Z.needsUpdate=!0):te.material.needsUpdate=!0)});for(let te=0,Z=C.length;te<Z;te++){const I=C[te],F=I.shadow;if(F===void 0){Ne("WebGLShadowMap:",I,"has no shadow.");continue}if(F.autoUpdate===!1&&F.needsUpdate===!1)continue;r.copy(F.mapSize);const Y=F.getFrameExtents();r.multiply(Y),s.copy(F.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(s.x=Math.floor(d/Y.x),r.x=s.x*Y.x,F.mapSize.x=s.x),r.y>d&&(s.y=Math.floor(d/Y.y),r.y=s.y*Y.y,F.mapSize.y=s.y));const se=i.state.buffers.depth.getReversed();if(F.camera._reversedDepth=se,F.map===null||K===!0){if(F.map!==null&&(F.map.depthTexture!==null&&(F.map.depthTexture.dispose(),F.map.depthTexture=null),F.map.dispose()),this.type===da){if(I.isPointLight){Ne("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}F.map=new Hs(r.x,r.y,{format:vr,type:Qn,minFilter:Rn,magFilter:Rn,generateMipmaps:!1}),F.map.texture.name=I.name+".shadowMap",F.map.depthTexture=new br(r.x,r.y,ri),F.map.depthTexture.name=I.name+".shadowMapDepth",F.map.depthTexture.format=Wi,F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=hn,F.map.depthTexture.magFilter=hn}else I.isPointLight?(F.map=new f2(r.x),F.map.depthTexture=new ZN(r.x,bn)):(F.map=new Hs(r.x,r.y),F.map.depthTexture=new br(r.x,r.y,bn)),F.map.depthTexture.name=I.name+".shadowMap",F.map.depthTexture.format=Wi,this.type===nh?(F.map.depthTexture.compareFunction=se?bo:wl,F.map.depthTexture.minFilter=Rn,F.map.depthTexture.magFilter=Rn):(F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=hn,F.map.depthTexture.magFilter=hn);F.camera.updateProjectionMatrix()}const Te=F.map.isWebGLCubeRenderTarget?6:1;for(let O=0;O<Te;O++){if(F.map.isWebGLCubeRenderTarget)i.setRenderTarget(F.map,O),i.clear();else{O===0&&(i.setRenderTarget(F.map),i.clear());const W=F.getViewport(O);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),H.viewport(o)}if(I.isPointLight){const W=F.camera,ce=F.matrix,Le=I.distance||W.far;Le!==W.far&&(W.far=Le,W.updateProjectionMatrix()),ld.setFromMatrixPosition(I.matrixWorld),W.position.copy(ld),lx.copy(W.position),lx.add(t4[O]),W.up.copy(n4[O]),W.lookAt(lx),W.updateMatrixWorld(),ce.makeTranslation(-ld.x,-ld.y,-ld.z),Bw.multiplyMatrices(W.projectionMatrix,W.matrixWorldInverse),F._frustum.setFromProjectionMatrix(Bw,W.coordinateSystem,W.reversedDepth)}else F.updateMatrices(I);n=F.getFrustum(),w(N,A,F.camera,I,this.type)}F.isPointLightShadow!==!0&&this.type===da&&M(F,A),F.needsUpdate=!1}x=this.type,b.needsUpdate=!1,i.setRenderTarget(L,j,z)};function M(C,N){const A=e.update(S);g.defines.VSM_SAMPLES!==C.blurSamples&&(g.defines.VSM_SAMPLES=C.blurSamples,_.defines.VSM_SAMPLES=C.blurSamples,g.needsUpdate=!0,_.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new Hs(r.x,r.y,{format:vr,type:Qn})),g.uniforms.shadow_pass.value=C.map.depthTexture,g.uniforms.resolution.value=C.mapSize,g.uniforms.radius.value=C.radius,i.setRenderTarget(C.mapPass),i.clear(),i.renderBufferDirect(N,null,A,g,S,null),_.uniforms.shadow_pass.value=C.mapPass.texture,_.uniforms.resolution.value=C.mapSize,_.uniforms.radius.value=C.radius,i.setRenderTarget(C.map),i.clear(),i.renderBufferDirect(N,null,A,_,S,null)}function E(C,N,A,L){let j=null;const z=A.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(z!==void 0)j=z;else if(j=A.isPointLight===!0?c:u,i.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 H=j.uuid,K=N.uuid;let te=h[H];te===void 0&&(te={},h[H]=te);let Z=te[K];Z===void 0&&(Z=j.clone(),te[K]=Z,N.addEventListener("dispose",D)),j=Z}if(j.visible=N.visible,j.wireframe=N.wireframe,L===da?j.side=N.shadowSide!==null?N.shadowSide:N.side:j.side=N.shadowSide!==null?N.shadowSide:p[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 H=i.properties.get(j);H.light=A}return j}function w(C,N,A,L,j){if(C.visible===!1)return;if(C.layers.test(N.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&j===da)&&(!C.frustumCulled||n.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,C.matrixWorld);const K=e.update(C),te=C.material;if(Array.isArray(te)){const Z=K.groups;for(let I=0,F=Z.length;I<F;I++){const Y=Z[I],se=te[Y.materialIndex];if(se&&se.visible){const Te=E(C,se,L,j);C.onBeforeShadow(i,C,N,A,K,Te,Y),i.renderBufferDirect(A,null,K,Te,C,Y),C.onAfterShadow(i,C,N,A,K,Te,Y)}}}else if(te.visible){const Z=E(C,te,L,j);C.onBeforeShadow(i,C,N,A,K,Z,null),i.renderBufferDirect(A,null,K,Z,C,null),C.onAfterShadow(i,C,N,A,K,Z,null)}}const H=C.children;for(let K=0,te=H.length;K<te;K++)w(H[K],N,A,L,j)}function D(C){C.target.removeEventListener("dispose",D);for(const A in h){const L=h[A],j=C.target.uuid;j in L&&(L[j].dispose(),delete L[j])}}}function r4(i,e){function t(){let re=!1;const Ge=new Pt;let ze=null;const Je=new Pt(0,0,0,0);return{setMask:function(Be){ze!==Be&&!re&&(i.colorMask(Be,Be,Be,Be),ze=Be)},setLocked:function(Be){re=Be},setClear:function(Be,Me,nt,Ct,Mn){Mn===!0&&(Be*=Ct,Me*=Ct,nt*=Ct),Ge.set(Be,Me,nt,Ct),Je.equals(Ge)===!1&&(i.clearColor(Be,Me,nt,Ct),Je.copy(Ge))},reset:function(){re=!1,ze=null,Je.set(-1,0,0,0)}}}function n(){let re=!1,Ge=!1,ze=null,Je=null,Be=null;return{setReversed:function(Me){if(Ge!==Me){const nt=e.get("EXT_clip_control");Me?nt.clipControlEXT(nt.LOWER_LEFT_EXT,nt.ZERO_TO_ONE_EXT):nt.clipControlEXT(nt.LOWER_LEFT_EXT,nt.NEGATIVE_ONE_TO_ONE_EXT),Ge=Me;const Ct=Be;Be=null,this.setClear(Ct)}},getReversed:function(){return Ge},setTest:function(Me){Me?ue(i.DEPTH_TEST):Ee(i.DEPTH_TEST)},setMask:function(Me){ze!==Me&&!re&&(i.depthMask(Me),ze=Me)},setFunc:function(Me){if(Ge&&(Me=HS[Me]),Je!==Me){switch(Me){case Qd:i.depthFunc(i.NEVER);break;case Jd:i.depthFunc(i.ALWAYS);break;case ep:i.depthFunc(i.LESS);break;case Tl:i.depthFunc(i.LEQUAL);break;case tp:i.depthFunc(i.EQUAL);break;case np:i.depthFunc(i.GEQUAL);break;case ip:i.depthFunc(i.GREATER);break;case rp:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}Je=Me}},setLocked:function(Me){re=Me},setClear:function(Me){Be!==Me&&(Be=Me,Ge&&(Me=1-Me),i.clearDepth(Me))},reset:function(){re=!1,ze=null,Je=null,Be=null,Ge=!1}}}function r(){let re=!1,Ge=null,ze=null,Je=null,Be=null,Me=null,nt=null,Ct=null,Mn=null;return{setTest:function(an){re||(an?ue(i.STENCIL_TEST):Ee(i.STENCIL_TEST))},setMask:function(an){Ge!==an&&!re&&(i.stencilMask(an),Ge=an)},setFunc:function(an,sr,As){(ze!==an||Je!==sr||Be!==As)&&(i.stencilFunc(an,sr,As),ze=an,Je=sr,Be=As)},setOp:function(an,sr,As){(Me!==an||nt!==sr||Ct!==As)&&(i.stencilOp(an,sr,As),Me=an,nt=sr,Ct=As)},setLocked:function(an){re=an},setClear:function(an){Mn!==an&&(i.clearStencil(an),Mn=an)},reset:function(){re=!1,Ge=null,ze=null,Je=null,Be=null,Me=null,nt=null,Ct=null,Mn=null}}}const s=new t,o=new n,u=new r,c=new WeakMap,h=new WeakMap;let d={},p={},g=new WeakMap,_=[],v=null,S=!1,b=null,x=null,M=null,E=null,w=null,D=null,C=null,N=new pt(0,0,0),A=0,L=!1,j=null,z=null,H=null,K=null,te=null;const Z=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let I=!1,F=0;const Y=i.getParameter(i.VERSION);Y.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL (\d)/.exec(Y)[1]),I=F>=1):Y.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),I=F>=2);let se=null,Te={};const O=i.getParameter(i.SCISSOR_BOX),W=i.getParameter(i.VIEWPORT),ce=new Pt().fromArray(O),Le=new Pt().fromArray(W);function ee(re,Ge,ze,Je){const Be=new Uint8Array(4),Me=i.createTexture();i.bindTexture(re,Me),i.texParameteri(re,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(re,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let nt=0;nt<ze;nt++)re===i.TEXTURE_3D||re===i.TEXTURE_2D_ARRAY?i.texImage3D(Ge,0,i.RGBA,1,1,Je,0,i.RGBA,i.UNSIGNED_BYTE,Be):i.texImage2D(Ge+nt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Be);return Me}const $={};$[i.TEXTURE_2D]=ee(i.TEXTURE_2D,i.TEXTURE_2D,1),$[i.TEXTURE_CUBE_MAP]=ee(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),$[i.TEXTURE_2D_ARRAY]=ee(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),$[i.TEXTURE_3D]=ee(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),u.setClear(0),ue(i.DEPTH_TEST),o.setFunc(Tl),St(!1),on(Mb),ue(i.CULL_FACE),Rt(Bi);function ue(re){d[re]!==!0&&(i.enable(re),d[re]=!0)}function Ee(re){d[re]!==!1&&(i.disable(re),d[re]=!1)}function ke(re,Ge){return p[re]!==Ge?(i.bindFramebuffer(re,Ge),p[re]=Ge,re===i.DRAW_FRAMEBUFFER&&(p[i.FRAMEBUFFER]=Ge),re===i.FRAMEBUFFER&&(p[i.DRAW_FRAMEBUFFER]=Ge),!0):!1}function We(re,Ge){let ze=_,Je=!1;if(re){ze=g.get(Ge),ze===void 0&&(ze=[],g.set(Ge,ze));const Be=re.textures;if(ze.length!==Be.length||ze[0]!==i.COLOR_ATTACHMENT0){for(let Me=0,nt=Be.length;Me<nt;Me++)ze[Me]=i.COLOR_ATTACHMENT0+Me;ze.length=Be.length,Je=!0}}else ze[0]!==i.BACK&&(ze[0]=i.BACK,Je=!0);Je&&i.drawBuffers(ze)}function Ke(re){return v!==re?(i.useProgram(re),v=re,!0):!1}const sn={[nr]:i.FUNC_ADD,[xS]:i.FUNC_SUBTRACT,[bS]:i.FUNC_REVERSE_SUBTRACT};sn[IN]=i.MIN,sn[zN]=i.MAX;const Ut={[ro]:i.ZERO,[SS]:i.ONE,[TS]:i.SRC_COLOR,[Kd]:i.SRC_ALPHA,[CS]:i.SRC_ALPHA_SATURATE,[wS]:i.DST_COLOR,[ES]:i.DST_ALPHA,[MS]:i.ONE_MINUS_SRC_COLOR,[Zd]:i.ONE_MINUS_SRC_ALPHA,[RS]:i.ONE_MINUS_DST_COLOR,[AS]:i.ONE_MINUS_DST_ALPHA,[TO]:i.CONSTANT_COLOR,[MO]:i.ONE_MINUS_CONSTANT_COLOR,[EO]:i.CONSTANT_ALPHA,[AO]:i.ONE_MINUS_CONSTANT_ALPHA};function Rt(re,Ge,ze,Je,Be,Me,nt,Ct,Mn,an){if(re===Bi){S===!0&&(Ee(i.BLEND),S=!1);return}if(S===!1&&(ue(i.BLEND),S=!0),re!==gu){if(re!==b||an!==L){if((x!==nr||w!==nr)&&(i.blendEquation(i.FUNC_ADD),x=nr,w=nr),an)switch(re){case pr:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case cl:i.blendFunc(i.ONE,i.ONE);break;case hl:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case fl:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Pe("WebGLState: Invalid blending: ",re);break}else switch(re){case pr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case cl:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case hl:Pe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case fl:Pe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Pe("WebGLState: Invalid blending: ",re);break}M=null,E=null,D=null,C=null,N.set(0,0,0),A=0,b=re,L=an}return}Be=Be||Ge,Me=Me||ze,nt=nt||Je,(Ge!==x||Be!==w)&&(i.blendEquationSeparate(sn[Ge],sn[Be]),x=Ge,w=Be),(ze!==M||Je!==E||Me!==D||nt!==C)&&(i.blendFuncSeparate(Ut[ze],Ut[Je],Ut[Me],Ut[nt]),M=ze,E=Je,D=Me,C=nt),(Ct.equals(N)===!1||Mn!==A)&&(i.blendColor(Ct.r,Ct.g,Ct.b,Mn),N.copy(Ct),A=Mn),b=re,L=!1}function qt(re,Ge){re.side===Ui?Ee(i.CULL_FACE):ue(i.CULL_FACE);let ze=re.side===Tn;Ge&&(ze=!ze),St(ze),re.blending===pr&&re.transparent===!1?Rt(Bi):Rt(re.blending,re.blendEquation,re.blendSrc,re.blendDst,re.blendEquationAlpha,re.blendSrcAlpha,re.blendDstAlpha,re.blendColor,re.blendAlpha,re.premultipliedAlpha),o.setFunc(re.depthFunc),o.setTest(re.depthTest),o.setMask(re.depthWrite),s.setMask(re.colorWrite);const Je=re.stencilWrite;u.setTest(Je),Je&&(u.setMask(re.stencilWriteMask),u.setFunc(re.stencilFunc,re.stencilRef,re.stencilFuncMask),u.setOp(re.stencilFail,re.stencilZFail,re.stencilZPass)),$n(re.polygonOffset,re.polygonOffsetFactor,re.polygonOffsetUnits),re.alphaToCoverage===!0?ue(i.SAMPLE_ALPHA_TO_COVERAGE):Ee(i.SAMPLE_ALPHA_TO_COVERAGE)}function St(re){j!==re&&(re?i.frontFace(i.CW):i.frontFace(i.CCW),j=re)}function on(re){re!==UN?(ue(i.CULL_FACE),re!==z&&(re===Mb?i.cullFace(i.BACK):re===ON?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Ee(i.CULL_FACE),z=re}function Q(re){re!==H&&(I&&i.lineWidth(re),H=re)}function $n(re,Ge,ze){re?(ue(i.POLYGON_OFFSET_FILL),(K!==Ge||te!==ze)&&(K=Ge,te=ze,o.getReversed()&&(Ge=-Ge),i.polygonOffset(Ge,ze))):Ee(i.POLYGON_OFFSET_FILL)}function nn(re){re?ue(i.SCISSOR_TEST):Ee(i.SCISSOR_TEST)}function _n(re){re===void 0&&(re=i.TEXTURE0+Z-1),se!==re&&(i.activeTexture(re),se=re)}function ht(re,Ge,ze){ze===void 0&&(se===null?ze=i.TEXTURE0+Z-1:ze=se);let Je=Te[ze];Je===void 0&&(Je={type:void 0,texture:void 0},Te[ze]=Je),(Je.type!==re||Je.texture!==Ge)&&(se!==ze&&(i.activeTexture(ze),se=ze),i.bindTexture(re,Ge||$[re]),Je.type=re,Je.texture=Ge)}function V(){const re=Te[se];re!==void 0&&re.type!==void 0&&(i.bindTexture(re.type,null),re.type=void 0,re.texture=void 0)}function P(){try{i.compressedTexImage2D(...arguments)}catch(re){Pe("WebGLState:",re)}}function ae(){try{i.compressedTexImage3D(...arguments)}catch(re){Pe("WebGLState:",re)}}function Re(){try{i.texSubImage2D(...arguments)}catch(re){Pe("WebGLState:",re)}}function Ue(){try{i.texSubImage3D(...arguments)}catch(re){Pe("WebGLState:",re)}}function Ae(){try{i.compressedTexSubImage2D(...arguments)}catch(re){Pe("WebGLState:",re)}}function lt(){try{i.compressedTexSubImage3D(...arguments)}catch(re){Pe("WebGLState:",re)}}function He(){try{i.texStorage2D(...arguments)}catch(re){Pe("WebGLState:",re)}}function gt(){try{i.texStorage3D(...arguments)}catch(re){Pe("WebGLState:",re)}}function Tt(){try{i.texImage2D(...arguments)}catch(re){Pe("WebGLState:",re)}}function Fe(){try{i.texImage3D(...arguments)}catch(re){Pe("WebGLState:",re)}}function Oe(re){ce.equals(re)===!1&&(i.scissor(re.x,re.y,re.z,re.w),ce.copy(re))}function Ze(re){Le.equals(re)===!1&&(i.viewport(re.x,re.y,re.z,re.w),Le.copy(re))}function Xe(re,Ge){let ze=h.get(Ge);ze===void 0&&(ze=new WeakMap,h.set(Ge,ze));let Je=ze.get(re);Je===void 0&&(Je=i.getUniformBlockIndex(Ge,re.name),ze.set(re,Je))}function Qe(re,Ge){const Je=h.get(Ge).get(re);c.get(Ge)!==Je&&(i.uniformBlockBinding(Ge,Je,re.__bindingPointIndex),c.set(Ge,Je))}function Gt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),d={},se=null,Te={},p={},g=new WeakMap,_=[],v=null,S=!1,b=null,x=null,M=null,E=null,w=null,D=null,C=null,N=new pt(0,0,0),A=0,L=!1,j=null,z=null,H=null,K=null,te=null,ce.set(0,0,i.canvas.width,i.canvas.height),Le.set(0,0,i.canvas.width,i.canvas.height),s.reset(),o.reset(),u.reset()}return{buffers:{color:s,depth:o,stencil:u},enable:ue,disable:Ee,bindFramebuffer:ke,drawBuffers:We,useProgram:Ke,setBlending:Rt,setMaterial:qt,setFlipSided:St,setCullFace:on,setLineWidth:Q,setPolygonOffset:$n,setScissorTest:nn,activeTexture:_n,bindTexture:ht,unbindTexture:V,compressedTexImage2D:P,compressedTexImage3D:ae,texImage2D:Tt,texImage3D:Fe,updateUBOMapping:Xe,uniformBlockBinding:Qe,texStorage2D:He,texStorage3D:gt,texSubImage2D:Re,texSubImage3D:Ue,compressedTexSubImage2D:Ae,compressedTexSubImage3D:lt,scissor:Oe,viewport:Ze,reset:Gt}}function s4(i,e,t,n,r,s,o){const u=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new Ie,d=new WeakMap;let p;const g=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(V,P){return _?new OffscreenCanvas(V,P):cp("canvas")}function S(V,P,ae){let Re=1;const Ue=ht(V);if((Ue.width>ae||Ue.height>ae)&&(Re=ae/Math.max(Ue.width,Ue.height)),Re<1)if(typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&V instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&V instanceof ImageBitmap||typeof VideoFrame<"u"&&V instanceof VideoFrame){const Ae=Math.floor(Re*Ue.width),lt=Math.floor(Re*Ue.height);p===void 0&&(p=v(Ae,lt));const He=P?v(Ae,lt):p;return He.width=Ae,He.height=lt,He.getContext("2d").drawImage(V,0,0,Ae,lt),Ne("WebGLRenderer: Texture has been resized from ("+Ue.width+"x"+Ue.height+") to ("+Ae+"x"+lt+")."),He}else return"data"in V&&Ne("WebGLRenderer: Image in DataTexture is too big ("+Ue.width+"x"+Ue.height+")."),V;return V}function b(V){return V.generateMipmaps}function x(V){i.generateMipmap(V)}function M(V){return V.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:V.isWebGL3DRenderTarget?i.TEXTURE_3D:V.isWebGLArrayRenderTarget||V.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function E(V,P,ae,Re,Ue=!1){if(V!==null){if(i[V]!==void 0)return i[V];Ne("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+V+"'")}let Ae=P;if(P===i.RED&&(ae===i.FLOAT&&(Ae=i.R32F),ae===i.HALF_FLOAT&&(Ae=i.R16F),ae===i.UNSIGNED_BYTE&&(Ae=i.R8)),P===i.RED_INTEGER&&(ae===i.UNSIGNED_BYTE&&(Ae=i.R8UI),ae===i.UNSIGNED_SHORT&&(Ae=i.R16UI),ae===i.UNSIGNED_INT&&(Ae=i.R32UI),ae===i.BYTE&&(Ae=i.R8I),ae===i.SHORT&&(Ae=i.R16I),ae===i.INT&&(Ae=i.R32I)),P===i.RG&&(ae===i.FLOAT&&(Ae=i.RG32F),ae===i.HALF_FLOAT&&(Ae=i.RG16F),ae===i.UNSIGNED_BYTE&&(Ae=i.RG8)),P===i.RG_INTEGER&&(ae===i.UNSIGNED_BYTE&&(Ae=i.RG8UI),ae===i.UNSIGNED_SHORT&&(Ae=i.RG16UI),ae===i.UNSIGNED_INT&&(Ae=i.RG32UI),ae===i.BYTE&&(Ae=i.RG8I),ae===i.SHORT&&(Ae=i.RG16I),ae===i.INT&&(Ae=i.RG32I)),P===i.RGB_INTEGER&&(ae===i.UNSIGNED_BYTE&&(Ae=i.RGB8UI),ae===i.UNSIGNED_SHORT&&(Ae=i.RGB16UI),ae===i.UNSIGNED_INT&&(Ae=i.RGB32UI),ae===i.BYTE&&(Ae=i.RGB8I),ae===i.SHORT&&(Ae=i.RGB16I),ae===i.INT&&(Ae=i.RGB32I)),P===i.RGBA_INTEGER&&(ae===i.UNSIGNED_BYTE&&(Ae=i.RGBA8UI),ae===i.UNSIGNED_SHORT&&(Ae=i.RGBA16UI),ae===i.UNSIGNED_INT&&(Ae=i.RGBA32UI),ae===i.BYTE&&(Ae=i.RGBA8I),ae===i.SHORT&&(Ae=i.RGBA16I),ae===i.INT&&(Ae=i.RGBA32I)),P===i.RGB&&(ae===i.UNSIGNED_INT_5_9_9_9_REV&&(Ae=i.RGB9_E5),ae===i.UNSIGNED_INT_10F_11F_11F_REV&&(Ae=i.R11F_G11F_B10F)),P===i.RGBA){const lt=Ue?Bh:xt.getTransfer(Re);ae===i.FLOAT&&(Ae=i.RGBA32F),ae===i.HALF_FLOAT&&(Ae=i.RGBA16F),ae===i.UNSIGNED_BYTE&&(Ae=lt===Ye?i.SRGB8_ALPHA8:i.RGBA8),ae===i.UNSIGNED_SHORT_4_4_4_4&&(Ae=i.RGBA4),ae===i.UNSIGNED_SHORT_5_5_5_1&&(Ae=i.RGB5_A1)}return(Ae===i.R16F||Ae===i.R32F||Ae===i.RG16F||Ae===i.RG32F||Ae===i.RGBA16F||Ae===i.RGBA32F)&&e.get("EXT_color_buffer_float"),Ae}function w(V,P){let ae;return V?P===null||P===bn||P===is?ae=i.DEPTH24_STENCIL8:P===ri?ae=i.DEPTH32F_STENCIL8:P===Gs&&(ae=i.DEPTH24_STENCIL8,Ne("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):P===null||P===bn||P===is?ae=i.DEPTH_COMPONENT24:P===ri?ae=i.DEPTH_COMPONENT32F:P===Gs&&(ae=i.DEPTH_COMPONENT16),ae}function D(V,P){return b(V)===!0||V.isFramebufferTexture&&V.minFilter!==hn&&V.minFilter!==Rn?Math.log2(Math.max(P.width,P.height))+1:V.mipmaps!==void 0&&V.mipmaps.length>0?V.mipmaps.length:V.isCompressedTexture&&Array.isArray(V.image)?P.mipmaps.length:1}function C(V){const P=V.target;P.removeEventListener("dispose",C),A(P),P.isVideoTexture&&d.delete(P)}function N(V){const P=V.target;P.removeEventListener("dispose",N),j(P)}function A(V){const P=n.get(V);if(P.__webglInit===void 0)return;const ae=V.source,Re=g.get(ae);if(Re){const Ue=Re[P.__cacheKey];Ue.usedTimes--,Ue.usedTimes===0&&L(V),Object.keys(Re).length===0&&g.delete(ae)}n.remove(V)}function L(V){const P=n.get(V);i.deleteTexture(P.__webglTexture);const ae=V.source,Re=g.get(ae);delete Re[P.__cacheKey],o.memory.textures--}function j(V){const P=n.get(V);if(V.depthTexture&&(V.depthTexture.dispose(),n.remove(V.depthTexture)),V.isWebGLCubeRenderTarget)for(let Re=0;Re<6;Re++){if(Array.isArray(P.__webglFramebuffer[Re]))for(let Ue=0;Ue<P.__webglFramebuffer[Re].length;Ue++)i.deleteFramebuffer(P.__webglFramebuffer[Re][Ue]);else i.deleteFramebuffer(P.__webglFramebuffer[Re]);P.__webglDepthbuffer&&i.deleteRenderbuffer(P.__webglDepthbuffer[Re])}else{if(Array.isArray(P.__webglFramebuffer))for(let Re=0;Re<P.__webglFramebuffer.length;Re++)i.deleteFramebuffer(P.__webglFramebuffer[Re]);else i.deleteFramebuffer(P.__webglFramebuffer);if(P.__webglDepthbuffer&&i.deleteRenderbuffer(P.__webglDepthbuffer),P.__webglMultisampledFramebuffer&&i.deleteFramebuffer(P.__webglMultisampledFramebuffer),P.__webglColorRenderbuffer)for(let Re=0;Re<P.__webglColorRenderbuffer.length;Re++)P.__webglColorRenderbuffer[Re]&&i.deleteRenderbuffer(P.__webglColorRenderbuffer[Re]);P.__webglDepthRenderbuffer&&i.deleteRenderbuffer(P.__webglDepthRenderbuffer)}const ae=V.textures;for(let Re=0,Ue=ae.length;Re<Ue;Re++){const Ae=n.get(ae[Re]);Ae.__webglTexture&&(i.deleteTexture(Ae.__webglTexture),o.memory.textures--),n.remove(ae[Re])}n.remove(V)}let z=0;function H(){z=0}function K(){const V=z;return V>=r.maxTextures&&Ne("WebGLTextures: Trying to use "+V+" texture units while this GPU supports only "+r.maxTextures),z+=1,V}function te(V){const P=[];return P.push(V.wrapS),P.push(V.wrapT),P.push(V.wrapR||0),P.push(V.magFilter),P.push(V.minFilter),P.push(V.anisotropy),P.push(V.internalFormat),P.push(V.format),P.push(V.type),P.push(V.generateMipmaps),P.push(V.premultiplyAlpha),P.push(V.flipY),P.push(V.unpackAlignment),P.push(V.colorSpace),P.join()}function Z(V,P){const ae=n.get(V);if(V.isVideoTexture&&nn(V),V.isRenderTargetTexture===!1&&V.isExternalTexture!==!0&&V.version>0&&ae.__version!==V.version){const Re=V.image;if(Re===null)Ne("WebGLRenderer: Texture marked for update but no image data found.");else if(Re.complete===!1)Ne("WebGLRenderer: Texture marked for update but image is incomplete");else{$(ae,V,P);return}}else V.isExternalTexture&&(ae.__webglTexture=V.sourceTexture?V.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,ae.__webglTexture,i.TEXTURE0+P)}function I(V,P){const ae=n.get(V);if(V.isRenderTargetTexture===!1&&V.version>0&&ae.__version!==V.version){$(ae,V,P);return}else V.isExternalTexture&&(ae.__webglTexture=V.sourceTexture?V.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,ae.__webglTexture,i.TEXTURE0+P)}function F(V,P){const ae=n.get(V);if(V.isRenderTargetTexture===!1&&V.version>0&&ae.__version!==V.version){$(ae,V,P);return}t.bindTexture(i.TEXTURE_3D,ae.__webglTexture,i.TEXTURE0+P)}function Y(V,P){const ae=n.get(V);if(V.isCubeDepthTexture!==!0&&V.version>0&&ae.__version!==V.version){ue(ae,V,P);return}t.bindTexture(i.TEXTURE_CUBE_MAP,ae.__webglTexture,i.TEXTURE0+P)}const se={[Eu]:i.REPEAT,[Pr]:i.CLAMP_TO_EDGE,[Au]:i.MIRRORED_REPEAT},Te={[hn]:i.NEAREST,[FS]:i.NEAREST_MIPMAP_NEAREST,[ho]:i.NEAREST_MIPMAP_LINEAR,[Rn]:i.LINEAR,[sh]:i.LINEAR_MIPMAP_NEAREST,[Ur]:i.LINEAR_MIPMAP_LINEAR},O={[zS]:i.NEVER,[VS]:i.ALWAYS,[W_]:i.LESS,[wl]:i.LEQUAL,[kS]:i.EQUAL,[bo]:i.GEQUAL,[up]:i.GREATER,[GS]:i.NOTEQUAL};function W(V,P){if(P.type===ri&&e.has("OES_texture_float_linear")===!1&&(P.magFilter===Rn||P.magFilter===sh||P.magFilter===ho||P.magFilter===Ur||P.minFilter===Rn||P.minFilter===sh||P.minFilter===ho||P.minFilter===Ur)&&Ne("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(V,i.TEXTURE_WRAP_S,se[P.wrapS]),i.texParameteri(V,i.TEXTURE_WRAP_T,se[P.wrapT]),(V===i.TEXTURE_3D||V===i.TEXTURE_2D_ARRAY)&&i.texParameteri(V,i.TEXTURE_WRAP_R,se[P.wrapR]),i.texParameteri(V,i.TEXTURE_MAG_FILTER,Te[P.magFilter]),i.texParameteri(V,i.TEXTURE_MIN_FILTER,Te[P.minFilter]),P.compareFunction&&(i.texParameteri(V,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(V,i.TEXTURE_COMPARE_FUNC,O[P.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(P.magFilter===hn||P.minFilter!==ho&&P.minFilter!==Ur||P.type===ri&&e.has("OES_texture_float_linear")===!1)return;if(P.anisotropy>1||n.get(P).__currentAnisotropy){const ae=e.get("EXT_texture_filter_anisotropic");i.texParameterf(V,ae.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(P.anisotropy,r.getMaxAnisotropy())),n.get(P).__currentAnisotropy=P.anisotropy}}}function ce(V,P){let ae=!1;V.__webglInit===void 0&&(V.__webglInit=!0,P.addEventListener("dispose",C));const Re=P.source;let Ue=g.get(Re);Ue===void 0&&(Ue={},g.set(Re,Ue));const Ae=te(P);if(Ae!==V.__cacheKey){Ue[Ae]===void 0&&(Ue[Ae]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,ae=!0),Ue[Ae].usedTimes++;const lt=Ue[V.__cacheKey];lt!==void 0&&(Ue[V.__cacheKey].usedTimes--,lt.usedTimes===0&&L(P)),V.__cacheKey=Ae,V.__webglTexture=Ue[Ae].texture}return ae}function Le(V,P,ae){return Math.floor(Math.floor(V/ae)/P)}function ee(V,P,ae,Re){const Ae=V.updateRanges;if(Ae.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,P.width,P.height,ae,Re,P.data);else{Ae.sort((Fe,Oe)=>Fe.start-Oe.start);let lt=0;for(let Fe=1;Fe<Ae.length;Fe++){const Oe=Ae[lt],Ze=Ae[Fe],Xe=Oe.start+Oe.count,Qe=Le(Ze.start,P.width,4),Gt=Le(Oe.start,P.width,4);Ze.start<=Xe+1&&Qe===Gt&&Le(Ze.start+Ze.count-1,P.width,4)===Qe?Oe.count=Math.max(Oe.count,Ze.start+Ze.count-Oe.start):(++lt,Ae[lt]=Ze)}Ae.length=lt+1;const He=i.getParameter(i.UNPACK_ROW_LENGTH),gt=i.getParameter(i.UNPACK_SKIP_PIXELS),Tt=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,P.width);for(let Fe=0,Oe=Ae.length;Fe<Oe;Fe++){const Ze=Ae[Fe],Xe=Math.floor(Ze.start/4),Qe=Math.ceil(Ze.count/4),Gt=Xe%P.width,re=Math.floor(Xe/P.width),Ge=Qe,ze=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Gt),i.pixelStorei(i.UNPACK_SKIP_ROWS,re),t.texSubImage2D(i.TEXTURE_2D,0,Gt,re,Ge,ze,ae,Re,P.data)}V.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,He),i.pixelStorei(i.UNPACK_SKIP_PIXELS,gt),i.pixelStorei(i.UNPACK_SKIP_ROWS,Tt)}}function $(V,P,ae){let Re=i.TEXTURE_2D;(P.isDataArrayTexture||P.isCompressedArrayTexture)&&(Re=i.TEXTURE_2D_ARRAY),P.isData3DTexture&&(Re=i.TEXTURE_3D);const Ue=ce(V,P),Ae=P.source;t.bindTexture(Re,V.__webglTexture,i.TEXTURE0+ae);const lt=n.get(Ae);if(Ae.version!==lt.__version||Ue===!0){t.activeTexture(i.TEXTURE0+ae);const He=xt.getPrimaries(xt.workingColorSpace),gt=P.colorSpace===Dr?null:xt.getPrimaries(P.colorSpace),Tt=P.colorSpace===Dr||He===gt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,P.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,P.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Tt);let Fe=S(P.image,!1,r.maxTextureSize);Fe=_n(P,Fe);const Oe=s.convert(P.format,P.colorSpace),Ze=s.convert(P.type);let Xe=E(P.internalFormat,Oe,Ze,P.colorSpace,P.isVideoTexture);W(Re,P);let Qe;const Gt=P.mipmaps,re=P.isVideoTexture!==!0,Ge=lt.__version===void 0||Ue===!0,ze=Ae.dataReady,Je=D(P,Fe);if(P.isDepthTexture)Xe=w(P.format===_r,P.type),Ge&&(re?t.texStorage2D(i.TEXTURE_2D,1,Xe,Fe.width,Fe.height):t.texImage2D(i.TEXTURE_2D,0,Xe,Fe.width,Fe.height,0,Oe,Ze,null));else if(P.isDataTexture)if(Gt.length>0){re&&Ge&&t.texStorage2D(i.TEXTURE_2D,Je,Xe,Gt[0].width,Gt[0].height);for(let Be=0,Me=Gt.length;Be<Me;Be++)Qe=Gt[Be],re?ze&&t.texSubImage2D(i.TEXTURE_2D,Be,0,0,Qe.width,Qe.height,Oe,Ze,Qe.data):t.texImage2D(i.TEXTURE_2D,Be,Xe,Qe.width,Qe.height,0,Oe,Ze,Qe.data);P.generateMipmaps=!1}else re?(Ge&&t.texStorage2D(i.TEXTURE_2D,Je,Xe,Fe.width,Fe.height),ze&&ee(P,Fe,Oe,Ze)):t.texImage2D(i.TEXTURE_2D,0,Xe,Fe.width,Fe.height,0,Oe,Ze,Fe.data);else if(P.isCompressedTexture)if(P.isCompressedArrayTexture){re&&Ge&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Je,Xe,Gt[0].width,Gt[0].height,Fe.depth);for(let Be=0,Me=Gt.length;Be<Me;Be++)if(Qe=Gt[Be],P.format!==si)if(Oe!==null)if(re){if(ze)if(P.layerUpdates.size>0){const nt=Cb(Qe.width,Qe.height,P.format,P.type);for(const Ct of P.layerUpdates){const Mn=Qe.data.subarray(Ct*nt/Qe.data.BYTES_PER_ELEMENT,(Ct+1)*nt/Qe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Be,0,0,Ct,Qe.width,Qe.height,1,Oe,Mn)}P.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Be,0,0,0,Qe.width,Qe.height,Fe.depth,Oe,Qe.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Be,Xe,Qe.width,Qe.height,Fe.depth,0,Qe.data,0,0);else Ne("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else re?ze&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Be,0,0,0,Qe.width,Qe.height,Fe.depth,Oe,Ze,Qe.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Be,Xe,Qe.width,Qe.height,Fe.depth,0,Oe,Ze,Qe.data)}else{re&&Ge&&t.texStorage2D(i.TEXTURE_2D,Je,Xe,Gt[0].width,Gt[0].height);for(let Be=0,Me=Gt.length;Be<Me;Be++)Qe=Gt[Be],P.format!==si?Oe!==null?re?ze&&t.compressedTexSubImage2D(i.TEXTURE_2D,Be,0,0,Qe.width,Qe.height,Oe,Qe.data):t.compressedTexImage2D(i.TEXTURE_2D,Be,Xe,Qe.width,Qe.height,0,Qe.data):Ne("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):re?ze&&t.texSubImage2D(i.TEXTURE_2D,Be,0,0,Qe.width,Qe.height,Oe,Ze,Qe.data):t.texImage2D(i.TEXTURE_2D,Be,Xe,Qe.width,Qe.height,0,Oe,Ze,Qe.data)}else if(P.isDataArrayTexture)if(re){if(Ge&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Je,Xe,Fe.width,Fe.height,Fe.depth),ze)if(P.layerUpdates.size>0){const Be=Cb(Fe.width,Fe.height,P.format,P.type);for(const Me of P.layerUpdates){const nt=Fe.data.subarray(Me*Be/Fe.data.BYTES_PER_ELEMENT,(Me+1)*Be/Fe.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Me,Fe.width,Fe.height,1,Oe,Ze,nt)}P.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Fe.width,Fe.height,Fe.depth,Oe,Ze,Fe.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Xe,Fe.width,Fe.height,Fe.depth,0,Oe,Ze,Fe.data);else if(P.isData3DTexture)re?(Ge&&t.texStorage3D(i.TEXTURE_3D,Je,Xe,Fe.width,Fe.height,Fe.depth),ze&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Fe.width,Fe.height,Fe.depth,Oe,Ze,Fe.data)):t.texImage3D(i.TEXTURE_3D,0,Xe,Fe.width,Fe.height,Fe.depth,0,Oe,Ze,Fe.data);else if(P.isFramebufferTexture){if(Ge)if(re)t.texStorage2D(i.TEXTURE_2D,Je,Xe,Fe.width,Fe.height);else{let Be=Fe.width,Me=Fe.height;for(let nt=0;nt<Je;nt++)t.texImage2D(i.TEXTURE_2D,nt,Xe,Be,Me,0,Oe,Ze,null),Be>>=1,Me>>=1}}else if(Gt.length>0){if(re&&Ge){const Be=ht(Gt[0]);t.texStorage2D(i.TEXTURE_2D,Je,Xe,Be.width,Be.height)}for(let Be=0,Me=Gt.length;Be<Me;Be++)Qe=Gt[Be],re?ze&&t.texSubImage2D(i.TEXTURE_2D,Be,0,0,Oe,Ze,Qe):t.texImage2D(i.TEXTURE_2D,Be,Xe,Oe,Ze,Qe);P.generateMipmaps=!1}else if(re){if(Ge){const Be=ht(Fe);t.texStorage2D(i.TEXTURE_2D,Je,Xe,Be.width,Be.height)}ze&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Oe,Ze,Fe)}else t.texImage2D(i.TEXTURE_2D,0,Xe,Oe,Ze,Fe);b(P)&&x(Re),lt.__version=Ae.version,P.onUpdate&&P.onUpdate(P)}V.__version=P.version}function ue(V,P,ae){if(P.image.length!==6)return;const Re=ce(V,P),Ue=P.source;t.bindTexture(i.TEXTURE_CUBE_MAP,V.__webglTexture,i.TEXTURE0+ae);const Ae=n.get(Ue);if(Ue.version!==Ae.__version||Re===!0){t.activeTexture(i.TEXTURE0+ae);const lt=xt.getPrimaries(xt.workingColorSpace),He=P.colorSpace===Dr?null:xt.getPrimaries(P.colorSpace),gt=P.colorSpace===Dr||lt===He?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,P.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,P.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,gt);const Tt=P.isCompressedTexture||P.image[0].isCompressedTexture,Fe=P.image[0]&&P.image[0].isDataTexture,Oe=[];for(let Me=0;Me<6;Me++)!Tt&&!Fe?Oe[Me]=S(P.image[Me],!0,r.maxCubemapSize):Oe[Me]=Fe?P.image[Me].image:P.image[Me],Oe[Me]=_n(P,Oe[Me]);const Ze=Oe[0],Xe=s.convert(P.format,P.colorSpace),Qe=s.convert(P.type),Gt=E(P.internalFormat,Xe,Qe,P.colorSpace),re=P.isVideoTexture!==!0,Ge=Ae.__version===void 0||Re===!0,ze=Ue.dataReady;let Je=D(P,Ze);W(i.TEXTURE_CUBE_MAP,P);let Be;if(Tt){re&&Ge&&t.texStorage2D(i.TEXTURE_CUBE_MAP,Je,Gt,Ze.width,Ze.height);for(let Me=0;Me<6;Me++){Be=Oe[Me].mipmaps;for(let nt=0;nt<Be.length;nt++){const Ct=Be[nt];P.format!==si?Xe!==null?re?ze&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,nt,0,0,Ct.width,Ct.height,Xe,Ct.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,nt,Gt,Ct.width,Ct.height,0,Ct.data):Ne("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):re?ze&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,nt,0,0,Ct.width,Ct.height,Xe,Qe,Ct.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,nt,Gt,Ct.width,Ct.height,0,Xe,Qe,Ct.data)}}}else{if(Be=P.mipmaps,re&&Ge){Be.length>0&&Je++;const Me=ht(Oe[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Je,Gt,Me.width,Me.height)}for(let Me=0;Me<6;Me++)if(Fe){re?ze&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,Oe[Me].width,Oe[Me].height,Xe,Qe,Oe[Me].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,Gt,Oe[Me].width,Oe[Me].height,0,Xe,Qe,Oe[Me].data);for(let nt=0;nt<Be.length;nt++){const Mn=Be[nt].image[Me].image;re?ze&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,nt+1,0,0,Mn.width,Mn.height,Xe,Qe,Mn.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,nt+1,Gt,Mn.width,Mn.height,0,Xe,Qe,Mn.data)}}else{re?ze&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,Xe,Qe,Oe[Me]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,Gt,Xe,Qe,Oe[Me]);for(let nt=0;nt<Be.length;nt++){const Ct=Be[nt];re?ze&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,nt+1,0,0,Xe,Qe,Ct.image[Me]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Me,nt+1,Gt,Xe,Qe,Ct.image[Me])}}}b(P)&&x(i.TEXTURE_CUBE_MAP),Ae.__version=Ue.version,P.onUpdate&&P.onUpdate(P)}V.__version=P.version}function Ee(V,P,ae,Re,Ue,Ae){const lt=s.convert(ae.format,ae.colorSpace),He=s.convert(ae.type),gt=E(ae.internalFormat,lt,He,ae.colorSpace),Tt=n.get(P),Fe=n.get(ae);if(Fe.__renderTarget=P,!Tt.__hasExternalTextures){const Oe=Math.max(1,P.width>>Ae),Ze=Math.max(1,P.height>>Ae);Ue===i.TEXTURE_3D||Ue===i.TEXTURE_2D_ARRAY?t.texImage3D(Ue,Ae,gt,Oe,Ze,P.depth,0,lt,He,null):t.texImage2D(Ue,Ae,gt,Oe,Ze,0,lt,He,null)}t.bindFramebuffer(i.FRAMEBUFFER,V),$n(P)?u.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Re,Ue,Fe.__webglTexture,0,Q(P)):(Ue===i.TEXTURE_2D||Ue>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Ue<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Re,Ue,Fe.__webglTexture,Ae),t.bindFramebuffer(i.FRAMEBUFFER,null)}function ke(V,P,ae){if(i.bindRenderbuffer(i.RENDERBUFFER,V),P.depthBuffer){const Re=P.depthTexture,Ue=Re&&Re.isDepthTexture?Re.type:null,Ae=w(P.stencilBuffer,Ue),lt=P.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;$n(P)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Q(P),Ae,P.width,P.height):ae?i.renderbufferStorageMultisample(i.RENDERBUFFER,Q(P),Ae,P.width,P.height):i.renderbufferStorage(i.RENDERBUFFER,Ae,P.width,P.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,lt,i.RENDERBUFFER,V)}else{const Re=P.textures;for(let Ue=0;Ue<Re.length;Ue++){const Ae=Re[Ue],lt=s.convert(Ae.format,Ae.colorSpace),He=s.convert(Ae.type),gt=E(Ae.internalFormat,lt,He,Ae.colorSpace);$n(P)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Q(P),gt,P.width,P.height):ae?i.renderbufferStorageMultisample(i.RENDERBUFFER,Q(P),gt,P.width,P.height):i.renderbufferStorage(i.RENDERBUFFER,gt,P.width,P.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function We(V,P,ae){const Re=P.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,V),!(P.depthTexture&&P.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Ue=n.get(P.depthTexture);if(Ue.__renderTarget=P,(!Ue.__webglTexture||P.depthTexture.image.width!==P.width||P.depthTexture.image.height!==P.height)&&(P.depthTexture.image.width=P.width,P.depthTexture.image.height=P.height,P.depthTexture.needsUpdate=!0),Re){if(Ue.__webglInit===void 0&&(Ue.__webglInit=!0,P.depthTexture.addEventListener("dispose",C)),Ue.__webglTexture===void 0){Ue.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,Ue.__webglTexture),W(i.TEXTURE_CUBE_MAP,P.depthTexture);const Tt=s.convert(P.depthTexture.format),Fe=s.convert(P.depthTexture.type);let Oe;P.depthTexture.format===Wi?Oe=i.DEPTH_COMPONENT24:P.depthTexture.format===_r&&(Oe=i.DEPTH24_STENCIL8);for(let Ze=0;Ze<6;Ze++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Ze,0,Oe,P.width,P.height,0,Tt,Fe,null)}}else Z(P.depthTexture,0);const Ae=Ue.__webglTexture,lt=Q(P),He=Re?i.TEXTURE_CUBE_MAP_POSITIVE_X+ae:i.TEXTURE_2D,gt=P.depthTexture.format===_r?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(P.depthTexture.format===Wi)$n(P)?u.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,gt,He,Ae,0,lt):i.framebufferTexture2D(i.FRAMEBUFFER,gt,He,Ae,0);else if(P.depthTexture.format===_r)$n(P)?u.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,gt,He,Ae,0,lt):i.framebufferTexture2D(i.FRAMEBUFFER,gt,He,Ae,0);else throw new Error("Unknown depthTexture format")}function Ke(V){const P=n.get(V),ae=V.isWebGLCubeRenderTarget===!0;if(P.__boundDepthTexture!==V.depthTexture){const Re=V.depthTexture;if(P.__depthDisposeCallback&&P.__depthDisposeCallback(),Re){const Ue=()=>{delete P.__boundDepthTexture,delete P.__depthDisposeCallback,Re.removeEventListener("dispose",Ue)};Re.addEventListener("dispose",Ue),P.__depthDisposeCallback=Ue}P.__boundDepthTexture=Re}if(V.depthTexture&&!P.__autoAllocateDepthBuffer)if(ae)for(let Re=0;Re<6;Re++)We(P.__webglFramebuffer[Re],V,Re);else{const Re=V.texture.mipmaps;Re&&Re.length>0?We(P.__webglFramebuffer[0],V,0):We(P.__webglFramebuffer,V,0)}else if(ae){P.__webglDepthbuffer=[];for(let Re=0;Re<6;Re++)if(t.bindFramebuffer(i.FRAMEBUFFER,P.__webglFramebuffer[Re]),P.__webglDepthbuffer[Re]===void 0)P.__webglDepthbuffer[Re]=i.createRenderbuffer(),ke(P.__webglDepthbuffer[Re],V,!1);else{const Ue=V.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ae=P.__webglDepthbuffer[Re];i.bindRenderbuffer(i.RENDERBUFFER,Ae),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ue,i.RENDERBUFFER,Ae)}}else{const Re=V.texture.mipmaps;if(Re&&Re.length>0?t.bindFramebuffer(i.FRAMEBUFFER,P.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,P.__webglFramebuffer),P.__webglDepthbuffer===void 0)P.__webglDepthbuffer=i.createRenderbuffer(),ke(P.__webglDepthbuffer,V,!1);else{const Ue=V.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ae=P.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Ae),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ue,i.RENDERBUFFER,Ae)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function sn(V,P,ae){const Re=n.get(V);P!==void 0&&Ee(Re.__webglFramebuffer,V,V.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),ae!==void 0&&Ke(V)}function Ut(V){const P=V.texture,ae=n.get(V),Re=n.get(P);V.addEventListener("dispose",N);const Ue=V.textures,Ae=V.isWebGLCubeRenderTarget===!0,lt=Ue.length>1;if(lt||(Re.__webglTexture===void 0&&(Re.__webglTexture=i.createTexture()),Re.__version=P.version,o.memory.textures++),Ae){ae.__webglFramebuffer=[];for(let He=0;He<6;He++)if(P.mipmaps&&P.mipmaps.length>0){ae.__webglFramebuffer[He]=[];for(let gt=0;gt<P.mipmaps.length;gt++)ae.__webglFramebuffer[He][gt]=i.createFramebuffer()}else ae.__webglFramebuffer[He]=i.createFramebuffer()}else{if(P.mipmaps&&P.mipmaps.length>0){ae.__webglFramebuffer=[];for(let He=0;He<P.mipmaps.length;He++)ae.__webglFramebuffer[He]=i.createFramebuffer()}else ae.__webglFramebuffer=i.createFramebuffer();if(lt)for(let He=0,gt=Ue.length;He<gt;He++){const Tt=n.get(Ue[He]);Tt.__webglTexture===void 0&&(Tt.__webglTexture=i.createTexture(),o.memory.textures++)}if(V.samples>0&&$n(V)===!1){ae.__webglMultisampledFramebuffer=i.createFramebuffer(),ae.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglMultisampledFramebuffer);for(let He=0;He<Ue.length;He++){const gt=Ue[He];ae.__webglColorRenderbuffer[He]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,ae.__webglColorRenderbuffer[He]);const Tt=s.convert(gt.format,gt.colorSpace),Fe=s.convert(gt.type),Oe=E(gt.internalFormat,Tt,Fe,gt.colorSpace,V.isXRRenderTarget===!0),Ze=Q(V);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ze,Oe,V.width,V.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+He,i.RENDERBUFFER,ae.__webglColorRenderbuffer[He])}i.bindRenderbuffer(i.RENDERBUFFER,null),V.depthBuffer&&(ae.__webglDepthRenderbuffer=i.createRenderbuffer(),ke(ae.__webglDepthRenderbuffer,V,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Ae){t.bindTexture(i.TEXTURE_CUBE_MAP,Re.__webglTexture),W(i.TEXTURE_CUBE_MAP,P);for(let He=0;He<6;He++)if(P.mipmaps&&P.mipmaps.length>0)for(let gt=0;gt<P.mipmaps.length;gt++)Ee(ae.__webglFramebuffer[He][gt],V,P,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+He,gt);else Ee(ae.__webglFramebuffer[He],V,P,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+He,0);b(P)&&x(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(lt){for(let He=0,gt=Ue.length;He<gt;He++){const Tt=Ue[He],Fe=n.get(Tt);let Oe=i.TEXTURE_2D;(V.isWebGL3DRenderTarget||V.isWebGLArrayRenderTarget)&&(Oe=V.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Oe,Fe.__webglTexture),W(Oe,Tt),Ee(ae.__webglFramebuffer,V,Tt,i.COLOR_ATTACHMENT0+He,Oe,0),b(Tt)&&x(Oe)}t.unbindTexture()}else{let He=i.TEXTURE_2D;if((V.isWebGL3DRenderTarget||V.isWebGLArrayRenderTarget)&&(He=V.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(He,Re.__webglTexture),W(He,P),P.mipmaps&&P.mipmaps.length>0)for(let gt=0;gt<P.mipmaps.length;gt++)Ee(ae.__webglFramebuffer[gt],V,P,i.COLOR_ATTACHMENT0,He,gt);else Ee(ae.__webglFramebuffer,V,P,i.COLOR_ATTACHMENT0,He,0);b(P)&&x(He),t.unbindTexture()}V.depthBuffer&&Ke(V)}function Rt(V){const P=V.textures;for(let ae=0,Re=P.length;ae<Re;ae++){const Ue=P[ae];if(b(Ue)){const Ae=M(V),lt=n.get(Ue).__webglTexture;t.bindTexture(Ae,lt),x(Ae),t.unbindTexture()}}}const qt=[],St=[];function on(V){if(V.samples>0){if($n(V)===!1){const P=V.textures,ae=V.width,Re=V.height;let Ue=i.COLOR_BUFFER_BIT;const Ae=V.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,lt=n.get(V),He=P.length>1;if(He)for(let Tt=0;Tt<P.length;Tt++)t.bindFramebuffer(i.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Tt,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,lt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Tt,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,lt.__webglMultisampledFramebuffer);const gt=V.texture.mipmaps;gt&&gt.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,lt.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,lt.__webglFramebuffer);for(let Tt=0;Tt<P.length;Tt++){if(V.resolveDepthBuffer&&(V.depthBuffer&&(Ue|=i.DEPTH_BUFFER_BIT),V.stencilBuffer&&V.resolveStencilBuffer&&(Ue|=i.STENCIL_BUFFER_BIT)),He){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,lt.__webglColorRenderbuffer[Tt]);const Fe=n.get(P[Tt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Fe,0)}i.blitFramebuffer(0,0,ae,Re,0,0,ae,Re,Ue,i.NEAREST),c===!0&&(qt.length=0,St.length=0,qt.push(i.COLOR_ATTACHMENT0+Tt),V.depthBuffer&&V.resolveDepthBuffer===!1&&(qt.push(Ae),St.push(Ae),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,St)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,qt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),He)for(let Tt=0;Tt<P.length;Tt++){t.bindFramebuffer(i.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Tt,i.RENDERBUFFER,lt.__webglColorRenderbuffer[Tt]);const Fe=n.get(P[Tt]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,lt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Tt,i.TEXTURE_2D,Fe,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,lt.__webglMultisampledFramebuffer)}else if(V.depthBuffer&&V.resolveDepthBuffer===!1&&c){const P=V.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[P])}}}function Q(V){return Math.min(r.maxSamples,V.samples)}function $n(V){const P=n.get(V);return V.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&P.__useRenderToTexture!==!1}function nn(V){const P=o.render.frame;d.get(V)!==P&&(d.set(V,P),V.update())}function _n(V,P){const ae=V.colorSpace,Re=V.format,Ue=V.type;return V.isCompressedTexture===!0||V.isVideoTexture===!0||ae!==Cu&&ae!==Dr&&(xt.getTransfer(ae)===Ye?(Re!==si||Ue!==Gn)&&Ne("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Pe("WebGLTextures: Unsupported texture color space:",ae)),P}function ht(V){return typeof HTMLImageElement<"u"&&V instanceof HTMLImageElement?(h.width=V.naturalWidth||V.width,h.height=V.naturalHeight||V.height):typeof VideoFrame<"u"&&V instanceof VideoFrame?(h.width=V.displayWidth,h.height=V.displayHeight):(h.width=V.width,h.height=V.height),h}this.allocateTextureUnit=K,this.resetTextureUnits=H,this.setTexture2D=Z,this.setTexture2DArray=I,this.setTexture3D=F,this.setTextureCube=Y,this.rebindTextures=sn,this.setupRenderTarget=Ut,this.updateRenderTargetMipmap=Rt,this.updateMultisampleRenderTarget=on,this.setupDepthRenderbuffer=Ke,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=$n,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function a4(i,e){function t(n,r=Dr){let s;const o=xt.getTransfer(r);if(n===Gn)return i.UNSIGNED_BYTE;if(n===G_)return i.UNSIGNED_SHORT_4_4_4_4;if(n===V_)return i.UNSIGNED_SHORT_5_5_5_1;if(n===H_)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===j_)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===_u)return i.BYTE;if(n===vu)return i.SHORT;if(n===Gs)return i.UNSIGNED_SHORT;if(n===Li)return i.INT;if(n===bn)return i.UNSIGNED_INT;if(n===ri)return i.FLOAT;if(n===Qn)return i.HALF_FLOAT;if(n===IS)return i.ALPHA;if(n===xp)return i.RGB;if(n===si)return i.RGBA;if(n===Wi)return i.DEPTH_COMPONENT;if(n===_r)return i.DEPTH_STENCIL;if(n===bp)return i.RED;if(n===qh)return i.RED_INTEGER;if(n===vr)return i.RG;if(n===Xh)return i.RG_INTEGER;if(n===Yh)return i.RGBA_INTEGER;if(n===gl||n===_l||n===vl||n===yl)if(o===Ye)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===gl)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===_l)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===vl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===yl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===gl)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===_l)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===vl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===yl)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===sp||n===ap||n===op||n===lp)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===sp)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ap)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===op)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===lp)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===fh||n===dh||n===ph||n===mh||n===gh||n===wu||n===_h)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===fh||n===dh)return o===Ye?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===ph)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===mh)return s.COMPRESSED_R11_EAC;if(n===gh)return s.COMPRESSED_SIGNED_R11_EAC;if(n===wu)return s.COMPRESSED_RG11_EAC;if(n===_h)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===vh||n===yh||n===xh||n===bh||n===Sh||n===Th||n===Mh||n===Eh||n===Ah||n===wh||n===Rh||n===Ch||n===Nh||n===Dh)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===vh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===yh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===xh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===bh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Sh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Th)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Mh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Eh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ah)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===wh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Rh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ch)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Nh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Dh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Lh||n===Eb||n===Ab)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Lh)return o===Ye?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Eb)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ab)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ph||n===Uh||n===Ru||n===Oh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Ph)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Uh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ru)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Oh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===is?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const o4=`
void main() {

	gl_Position = vec4( position, 1.0 );

}`,l4=`
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 u4{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new QN(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Ts({vertexShader:o4,fragmentShader:l4,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new xi(new Ep(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class c4 extends Aa{constructor(e,t){super();const n=this;let r=null,s=1,o=null,u="local-floor",c=1,h=null,d=null,p=null,g=null,_=null,v=null;const S=typeof XRWebGLBinding<"u",b=new u4,x={},M=t.getContextAttributes();let E=null,w=null;const D=[],C=[],N=new Ie;let A=null;const L=new Pi;L.viewport=new Pt;const j=new Pi;j.viewport=new Pt;const z=[L,j],H=new u2;let K=null,te=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let ue=D[$];return ue===void 0&&(ue=new i_,D[$]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function($){let ue=D[$];return ue===void 0&&(ue=new i_,D[$]=ue),ue.getGripSpace()},this.getHand=function($){let ue=D[$];return ue===void 0&&(ue=new i_,D[$]=ue),ue.getHandSpace()};function Z($){const ue=C.indexOf($.inputSource);if(ue===-1)return;const Ee=D[ue];Ee!==void 0&&(Ee.update($.inputSource,$.frame,h||o),Ee.dispatchEvent({type:$.type,data:$.inputSource}))}function I(){r.removeEventListener("select",Z),r.removeEventListener("selectstart",Z),r.removeEventListener("selectend",Z),r.removeEventListener("squeeze",Z),r.removeEventListener("squeezestart",Z),r.removeEventListener("squeezeend",Z),r.removeEventListener("end",I),r.removeEventListener("inputsourceschange",F);for(let $=0;$<D.length;$++){const ue=C[$];ue!==null&&(C[$]=null,D[$].disconnect(ue))}K=null,te=null,b.reset();for(const $ in x)delete x[$];e.setRenderTarget(E),_=null,g=null,p=null,r=null,w=null,ee.stop(),n.isPresenting=!1,e.setPixelRatio(A),e.setSize(N.width,N.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){s=$,n.isPresenting===!0&&Ne("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){u=$,n.isPresenting===!0&&Ne("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return h||o},this.setReferenceSpace=function($){h=$},this.getBaseLayer=function(){return g!==null?g:_},this.getBinding=function(){return p===null&&S&&(p=new XRWebGLBinding(r,t)),p},this.getFrame=function(){return v},this.getSession=function(){return r},this.setSession=async function($){if(r=$,r!==null){if(E=e.getRenderTarget(),r.addEventListener("select",Z),r.addEventListener("selectstart",Z),r.addEventListener("selectend",Z),r.addEventListener("squeeze",Z),r.addEventListener("squeezestart",Z),r.addEventListener("squeezeend",Z),r.addEventListener("end",I),r.addEventListener("inputsourceschange",F),M.xrCompatible!==!0&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(N),S&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ee=null,ke=null,We=null;M.depth&&(We=M.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ee=M.stencil?_r:Wi,ke=M.stencil?is:bn);const Ke={colorFormat:t.RGBA8,depthFormat:We,scaleFactor:s};p=this.getBinding(),g=p.createProjectionLayer(Ke),r.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),w=new Hs(g.textureWidth,g.textureHeight,{format:si,type:Gn,depthTexture:new br(g.textureWidth,g.textureHeight,ke,void 0,void 0,void 0,void 0,void 0,void 0,Ee),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Ee={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:s};_=new XRWebGLLayer(r,t,Ee),r.updateRenderState({baseLayer:_}),e.setPixelRatio(1),e.setSize(_.framebufferWidth,_.framebufferHeight,!1),w=new Hs(_.framebufferWidth,_.framebufferHeight,{format:si,type:Gn,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:_.ignoreDepthValues===!1,resolveStencilBuffer:_.ignoreDepthValues===!1})}w.isXRRenderTarget=!0,this.setFoveation(c),h=null,o=await r.requestReferenceSpace(u),ee.setContext(r),ee.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function F($){for(let ue=0;ue<$.removed.length;ue++){const Ee=$.removed[ue],ke=C.indexOf(Ee);ke>=0&&(C[ke]=null,D[ke].disconnect(Ee))}for(let ue=0;ue<$.added.length;ue++){const Ee=$.added[ue];let ke=C.indexOf(Ee);if(ke===-1){for(let Ke=0;Ke<D.length;Ke++)if(Ke>=C.length){C.push(Ee),ke=Ke;break}else if(C[Ke]===null){C[Ke]=Ee,ke=Ke;break}if(ke===-1)break}const We=D[ke];We&&We.connect(Ee)}}const Y=new G,se=new G;function Te($,ue,Ee){Y.setFromMatrixPosition(ue.matrixWorld),se.setFromMatrixPosition(Ee.matrixWorld);const ke=Y.distanceTo(se),We=ue.projectionMatrix.elements,Ke=Ee.projectionMatrix.elements,sn=We[14]/(We[10]-1),Ut=We[14]/(We[10]+1),Rt=(We[9]+1)/We[5],qt=(We[9]-1)/We[5],St=(We[8]-1)/We[0],on=(Ke[8]+1)/Ke[0],Q=sn*St,$n=sn*on,nn=ke/(-St+on),_n=nn*-St;if(ue.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(_n),$.translateZ(nn),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),We[10]===-1)$.projectionMatrix.copy(ue.projectionMatrix),$.projectionMatrixInverse.copy(ue.projectionMatrixInverse);else{const ht=sn+nn,V=Ut+nn,P=Q-_n,ae=$n+(ke-_n),Re=Rt*Ut/V*ht,Ue=qt*Ut/V*ht;$.projectionMatrix.makePerspective(P,ae,Re,Ue,ht,V),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function O($,ue){ue===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(ue.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(r===null)return;let ue=$.near,Ee=$.far;b.texture!==null&&(b.depthNear>0&&(ue=b.depthNear),b.depthFar>0&&(Ee=b.depthFar)),H.near=j.near=L.near=ue,H.far=j.far=L.far=Ee,(K!==H.near||te!==H.far)&&(r.updateRenderState({depthNear:H.near,depthFar:H.far}),K=H.near,te=H.far),H.layers.mask=$.layers.mask|6,L.layers.mask=H.layers.mask&-5,j.layers.mask=H.layers.mask&-3;const ke=$.parent,We=H.cameras;O(H,ke);for(let Ke=0;Ke<We.length;Ke++)O(We[Ke],ke);We.length===2?Te(H,L,j):H.projectionMatrix.copy(L.projectionMatrix),W($,H,ke)};function W($,ue,Ee){Ee===null?$.matrix.copy(ue.matrixWorld):($.matrix.copy(Ee.matrixWorld),$.matrix.invert(),$.matrix.multiply(ue.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(ue.projectionMatrix),$.projectionMatrixInverse.copy(ue.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Nu*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return H},this.getFoveation=function(){if(!(g===null&&_===null))return c},this.setFoveation=function($){c=$,g!==null&&(g.fixedFoveation=$),_!==null&&_.fixedFoveation!==void 0&&(_.fixedFoveation=$)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(H)},this.getCameraTexture=function($){return x[$]};let ce=null;function Le($,ue){if(d=ue.getViewerPose(h||o),v=ue,d!==null){const Ee=d.views;_!==null&&(e.setRenderTargetFramebuffer(w,_.framebuffer),e.setRenderTarget(w));let ke=!1;Ee.length!==H.cameras.length&&(H.cameras.length=0,ke=!0);for(let Ut=0;Ut<Ee.length;Ut++){const Rt=Ee[Ut];let qt=null;if(_!==null)qt=_.getViewport(Rt);else{const on=p.getViewSubImage(g,Rt);qt=on.viewport,Ut===0&&(e.setRenderTargetTextures(w,on.colorTexture,on.depthStencilTexture),e.setRenderTarget(w))}let St=z[Ut];St===void 0&&(St=new Pi,St.layers.enable(Ut),St.viewport=new Pt,z[Ut]=St),St.matrix.fromArray(Rt.transform.matrix),St.matrix.decompose(St.position,St.quaternion,St.scale),St.projectionMatrix.fromArray(Rt.projectionMatrix),St.projectionMatrixInverse.copy(St.projectionMatrix).invert(),St.viewport.set(qt.x,qt.y,qt.width,qt.height),Ut===0&&(H.matrix.copy(St.matrix),H.matrix.decompose(H.position,H.quaternion,H.scale)),ke===!0&&H.cameras.push(St)}const We=r.enabledFeatures;if(We&&We.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&S){p=n.getBinding();const Ut=p.getDepthInformation(Ee[0]);Ut&&Ut.isValid&&Ut.texture&&b.init(Ut,r.renderState)}if(We&&We.includes("camera-access")&&S){e.state.unbindTexture(),p=n.getBinding();for(let Ut=0;Ut<Ee.length;Ut++){const Rt=Ee[Ut].camera;if(Rt){let qt=x[Rt];qt||(qt=new QN,x[Rt]=qt);const St=p.getCameraImage(Rt);qt.sourceTexture=St}}}}for(let Ee=0;Ee<D.length;Ee++){const ke=C[Ee],We=D[Ee];ke!==null&&We!==void 0&&We.update(ke,ue,h||o)}ce&&ce($,ue),ue.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ue}),v=null}const ee=new h2;ee.setAnimationLoop(Le),this.setAnimationLoop=function($){ce=$},this.dispose=function(){}}}const nu=new Br,h4=new Wt;function f4(i,e){function t(b,x){b.matrixAutoUpdate===!0&&b.updateMatrix(),x.value.copy(b.matrix)}function n(b,x){x.color.getRGB(b.fogColor.value,t2(i)),x.isFog?(b.fogNear.value=x.near,b.fogFar.value=x.far):x.isFogExp2&&(b.fogDensity.value=x.density)}function r(b,x,M,E,w){x.isMeshBasicMaterial?s(b,x):x.isMeshLambertMaterial?(s(b,x),x.envMap&&(b.envMapIntensity.value=x.envMapIntensity)):x.isMeshToonMaterial?(s(b,x),p(b,x)):x.isMeshPhongMaterial?(s(b,x),d(b,x),x.envMap&&(b.envMapIntensity.value=x.envMapIntensity)):x.isMeshStandardMaterial?(s(b,x),g(b,x),x.isMeshPhysicalMaterial&&_(b,x,w)):x.isMeshMatcapMaterial?(s(b,x),v(b,x)):x.isMeshDepthMaterial?s(b,x):x.isMeshDistanceMaterial?(s(b,x),S(b,x)):x.isMeshNormalMaterial?s(b,x):x.isLineBasicMaterial?(o(b,x),x.isLineDashedMaterial&&u(b,x)):x.isPointsMaterial?c(b,x,M,E):x.isSpriteMaterial?h(b,x):x.isShadowMaterial?(b.color.value.copy(x.color),b.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function s(b,x){b.opacity.value=x.opacity,x.color&&b.diffuse.value.copy(x.color),x.emissive&&b.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(b.map.value=x.map,t(x.map,b.mapTransform)),x.alphaMap&&(b.alphaMap.value=x.alphaMap,t(x.alphaMap,b.alphaMapTransform)),x.bumpMap&&(b.bumpMap.value=x.bumpMap,t(x.bumpMap,b.bumpMapTransform),b.bumpScale.value=x.bumpScale,x.side===Tn&&(b.bumpScale.value*=-1)),x.normalMap&&(b.normalMap.value=x.normalMap,t(x.normalMap,b.normalMapTransform),b.normalScale.value.copy(x.normalScale),x.side===Tn&&b.normalScale.value.negate()),x.displacementMap&&(b.displacementMap.value=x.displacementMap,t(x.displacementMap,b.displacementMapTransform),b.displacementScale.value=x.displacementScale,b.displacementBias.value=x.displacementBias),x.emissiveMap&&(b.emissiveMap.value=x.emissiveMap,t(x.emissiveMap,b.emissiveMapTransform)),x.specularMap&&(b.specularMap.value=x.specularMap,t(x.specularMap,b.specularMapTransform)),x.alphaTest>0&&(b.alphaTest.value=x.alphaTest);const M=e.get(x),E=M.envMap,w=M.envMapRotation;E&&(b.envMap.value=E,nu.copy(w),nu.x*=-1,nu.y*=-1,nu.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(nu.y*=-1,nu.z*=-1),b.envMapRotation.value.setFromMatrix4(h4.makeRotationFromEuler(nu)),b.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=x.reflectivity,b.ior.value=x.ior,b.refractionRatio.value=x.refractionRatio),x.lightMap&&(b.lightMap.value=x.lightMap,b.lightMapIntensity.value=x.lightMapIntensity,t(x.lightMap,b.lightMapTransform)),x.aoMap&&(b.aoMap.value=x.aoMap,b.aoMapIntensity.value=x.aoMapIntensity,t(x.aoMap,b.aoMapTransform))}function o(b,x){b.diffuse.value.copy(x.color),b.opacity.value=x.opacity,x.map&&(b.map.value=x.map,t(x.map,b.mapTransform))}function u(b,x){b.dashSize.value=x.dashSize,b.totalSize.value=x.dashSize+x.gapSize,b.scale.value=x.scale}function c(b,x,M,E){b.diffuse.value.copy(x.color),b.opacity.value=x.opacity,b.size.value=x.size*M,b.scale.value=E*.5,x.map&&(b.map.value=x.map,t(x.map,b.uvTransform)),x.alphaMap&&(b.alphaMap.value=x.alphaMap,t(x.alphaMap,b.alphaMapTransform)),x.alphaTest>0&&(b.alphaTest.value=x.alphaTest)}function h(b,x){b.diffuse.value.copy(x.color),b.opacity.value=x.opacity,b.rotation.value=x.rotation,x.map&&(b.map.value=x.map,t(x.map,b.mapTransform)),x.alphaMap&&(b.alphaMap.value=x.alphaMap,t(x.alphaMap,b.alphaMapTransform)),x.alphaTest>0&&(b.alphaTest.value=x.alphaTest)}function d(b,x){b.specular.value.copy(x.specular),b.shininess.value=Math.max(x.shininess,1e-4)}function p(b,x){x.gradientMap&&(b.gradientMap.value=x.gradientMap)}function g(b,x){b.metalness.value=x.metalness,x.metalnessMap&&(b.metalnessMap.value=x.metalnessMap,t(x.metalnessMap,b.metalnessMapTransform)),b.roughness.value=x.roughness,x.roughnessMap&&(b.roughnessMap.value=x.roughnessMap,t(x.roughnessMap,b.roughnessMapTransform)),x.envMap&&(b.envMapIntensity.value=x.envMapIntensity)}function _(b,x,M){b.ior.value=x.ior,x.sheen>0&&(b.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),b.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(b.sheenColorMap.value=x.sheenColorMap,t(x.sheenColorMap,b.sheenColorMapTransform)),x.sheenRoughnessMap&&(b.sheenRoughnessMap.value=x.sheenRoughnessMap,t(x.sheenRoughnessMap,b.sheenRoughnessMapTransform))),x.clearcoat>0&&(b.clearcoat.value=x.clearcoat,b.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(b.clearcoatMap.value=x.clearcoatMap,t(x.clearcoatMap,b.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,t(x.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(b.clearcoatNormalMap.value=x.clearcoatNormalMap,t(x.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===Tn&&b.clearcoatNormalScale.value.negate())),x.dispersion>0&&(b.dispersion.value=x.dispersion),x.iridescence>0&&(b.iridescence.value=x.iridescence,b.iridescenceIOR.value=x.iridescenceIOR,b.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(b.iridescenceMap.value=x.iridescenceMap,t(x.iridescenceMap,b.iridescenceMapTransform)),x.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=x.iridescenceThicknessMap,t(x.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),x.transmission>0&&(b.transmission.value=x.transmission,b.transmissionSamplerMap.value=M.texture,b.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(b.transmissionMap.value=x.transmissionMap,t(x.transmissionMap,b.transmissionMapTransform)),b.thickness.value=x.thickness,x.thicknessMap&&(b.thicknessMap.value=x.thicknessMap,t(x.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=x.attenuationDistance,b.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(b.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(b.anisotropyMap.value=x.anisotropyMap,t(x.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=x.specularIntensity,b.specularColor.value.copy(x.specularColor),x.specularColorMap&&(b.specularColorMap.value=x.specularColorMap,t(x.specularColorMap,b.specularColorMapTransform)),x.specularIntensityMap&&(b.specularIntensityMap.value=x.specularIntensityMap,t(x.specularIntensityMap,b.specularIntensityMapTransform))}function v(b,x){x.matcap&&(b.matcap.value=x.matcap)}function S(b,x){const M=e.get(x).light;b.referencePosition.value.setFromMatrixPosition(M.matrixWorld),b.nearDistance.value=M.shadow.camera.near,b.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function d4(i,e,t,n){let r={},s={},o=[];const u=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,E){const w=E.program;n.uniformBlockBinding(M,w)}function h(M,E){let w=r[M.id];w===void 0&&(v(M),w=d(M),r[M.id]=w,M.addEventListener("dispose",b));const D=E.program;n.updateUBOMapping(M,D);const C=e.render.frame;s[M.id]!==C&&(g(M),s[M.id]=C)}function d(M){const E=p();M.__bindingPointIndex=E;const w=i.createBuffer(),D=M.__size,C=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,w),i.bufferData(i.UNIFORM_BUFFER,D,C),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,E,w),w}function p(){for(let M=0;M<u;M++)if(o.indexOf(M)===-1)return o.push(M),M;return Pe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const E=r[M.id],w=M.uniforms,D=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,E);for(let C=0,N=w.length;C<N;C++){const A=Array.isArray(w[C])?w[C]:[w[C]];for(let L=0,j=A.length;L<j;L++){const z=A[L];if(_(z,C,L,D)===!0){const H=z.__offset,K=Array.isArray(z.value)?z.value:[z.value];let te=0;for(let Z=0;Z<K.length;Z++){const I=K[Z],F=S(I);typeof I=="number"||typeof I=="boolean"?(z.__data[0]=I,i.bufferSubData(i.UNIFORM_BUFFER,H+te,z.__data)):I.isMatrix3?(z.__data[0]=I.elements[0],z.__data[1]=I.elements[1],z.__data[2]=I.elements[2],z.__data[3]=0,z.__data[4]=I.elements[3],z.__data[5]=I.elements[4],z.__data[6]=I.elements[5],z.__data[7]=0,z.__data[8]=I.elements[6],z.__data[9]=I.elements[7],z.__data[10]=I.elements[8],z.__data[11]=0):(I.toArray(z.__data,te),te+=F.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,H,z.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function _(M,E,w,D){const C=M.value,N=E+"_"+w;if(D[N]===void 0)return typeof C=="number"||typeof C=="boolean"?D[N]=C:D[N]=C.clone(),!0;{const A=D[N];if(typeof C=="number"||typeof C=="boolean"){if(A!==C)return D[N]=C,!0}else if(A.equals(C)===!1)return A.copy(C),!0}return!1}function v(M){const E=M.uniforms;let w=0;const D=16;for(let N=0,A=E.length;N<A;N++){const L=Array.isArray(E[N])?E[N]:[E[N]];for(let j=0,z=L.length;j<z;j++){const H=L[j],K=Array.isArray(H.value)?H.value:[H.value];for(let te=0,Z=K.length;te<Z;te++){const I=K[te],F=S(I),Y=w%D,se=Y%F.boundary,Te=Y+se;w+=se,Te!==0&&D-Te<F.storage&&(w+=D-Te),H.__data=new Float32Array(F.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=w,w+=F.storage}}}const C=w%D;return C>0&&(w+=D-C),M.__size=w,M.__cache={},this}function S(M){const E={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(E.boundary=4,E.storage=4):M.isVector2?(E.boundary=8,E.storage=8):M.isVector3||M.isColor?(E.boundary=16,E.storage=12):M.isVector4?(E.boundary=16,E.storage=16):M.isMatrix3?(E.boundary=48,E.storage=48):M.isMatrix4?(E.boundary=64,E.storage=64):M.isTexture?Ne("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Ne("WebGLRenderer: Unsupported uniform value type.",M),E}function b(M){const E=M.target;E.removeEventListener("dispose",b);const w=o.indexOf(E.__bindingPointIndex);o.splice(w,1),i.deleteBuffer(r[E.id]),delete r[E.id],delete s[E.id]}function x(){for(const M in r)i.deleteBuffer(r[M]);o=[],r={},s={}}return{bind:c,update:h,dispose:x}}const p4=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 Js=null;function m4(){return Js===null&&(Js=new QS(p4,16,16,vr,Qn),Js.name="DFG_LUT",Js.minFilter=Rn,Js.magFilter=Rn,Js.wrapS=Pr,Js.wrapT=Pr,Js.generateMipmaps=!1,Js.needsUpdate=!0),Js}class g4{constructor(e={}){const{canvas:t=WN(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:u=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:h=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:p=!1,reversedDepthBuffer:g=!1,outputBufferType:_=Gn}=e;this.isWebGLRenderer=!0;let v;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");v=n.getContextAttributes().alpha}else v=o;const S=_,b=new Set([Yh,Xh,qh]),x=new Set([Gn,bn,Gs,is,G_,V_]),M=new Uint32Array(4),E=new Int32Array(4);let w=null,D=null;const C=[],N=[];let A=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ji,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const L=this;let j=!1;this._outputColorSpace=dr;let z=0,H=0,K=null,te=-1,Z=null;const I=new Pt,F=new Pt;let Y=null;const se=new pt(0);let Te=0,O=t.width,W=t.height,ce=1,Le=null,ee=null;const $=new Pt(0,0,O,W),ue=new Pt(0,0,O,W);let Ee=!1;const ke=new Tp;let We=!1,Ke=!1;const sn=new Wt,Ut=new G,Rt=new Pt,qt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let St=!1;function on(){return K===null?ce:1}let Q=n;function $n(B,ne){return t.getContext(B,ne)}try{const B={alpha:!0,depth:r,stencil:s,antialias:u,premultipliedAlpha:c,preserveDrawingBuffer:h,powerPreference:d,failIfMajorPerformanceCaveat:p};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Fu}`),t.addEventListener("webglcontextlost",nt,!1),t.addEventListener("webglcontextrestored",Ct,!1),t.addEventListener("webglcontextcreationerror",Mn,!1),Q===null){const ne="webgl2";if(Q=$n(ne,B),Q===null)throw $n(ne)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(B){throw Pe("WebGLRenderer: "+B.message),B}let nn,_n,ht,V,P,ae,Re,Ue,Ae,lt,He,gt,Tt,Fe,Oe,Ze,Xe,Qe,Gt,re,Ge,ze,Je;function Be(){nn=new gk(Q),nn.init(),Ge=new a4(Q,nn),_n=new lk(Q,nn,e,Ge),ht=new r4(Q,nn),_n.reversedDepthBuffer&&g&&ht.buffers.depth.setReversed(!0),V=new yk(Q),P=new jG,ae=new s4(Q,nn,ht,P,_n,Ge,V),Re=new mk(L),Ue=new MF(Q),ze=new ak(Q,Ue),Ae=new _k(Q,Ue,V,ze),lt=new bk(Q,Ae,Ue,ze,V),Qe=new xk(Q,_n,ae),Oe=new uk(P),He=new HG(L,Re,nn,_n,ze,Oe),gt=new f4(L,P),Tt=new $G,Fe=new QG(nn),Xe=new sk(L,Re,ht,lt,v,c),Ze=new i4(L,lt,_n),Je=new d4(Q,V,_n,ht),Gt=new ok(Q,nn,V),re=new vk(Q,nn,V),V.programs=He.programs,L.capabilities=_n,L.extensions=nn,L.properties=P,L.renderLists=Tt,L.shadowMap=Ze,L.state=ht,L.info=V}Be(),S!==Gn&&(A=new Tk(S,t.width,t.height,r,s));const Me=new c4(L,Q);this.xr=Me,this.getContext=function(){return Q},this.getContextAttributes=function(){return Q.getContextAttributes()},this.forceContextLoss=function(){const B=nn.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){const B=nn.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return ce},this.setPixelRatio=function(B){B!==void 0&&(ce=B,this.setSize(O,W,!1))},this.getSize=function(B){return B.set(O,W)},this.setSize=function(B,ne,ge=!0){if(Me.isPresenting){Ne("WebGLRenderer: Can't change size while VR device is presenting.");return}O=B,W=ne,t.width=Math.floor(B*ce),t.height=Math.floor(ne*ce),ge===!0&&(t.style.width=B+"px",t.style.height=ne+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,B,ne)},this.getDrawingBufferSize=function(B){return B.set(O*ce,W*ce).floor()},this.setDrawingBufferSize=function(B,ne,ge){O=B,W=ne,ce=ge,t.width=Math.floor(B*ge),t.height=Math.floor(ne*ge),this.setViewport(0,0,B,ne)},this.setEffects=function(B){if(S===Gn){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(B){for(let ne=0;ne<B.length;ne++)if(B[ne].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(B||[])},this.getCurrentViewport=function(B){return B.copy(I)},this.getViewport=function(B){return B.copy($)},this.setViewport=function(B,ne,ge,pe){B.isVector4?$.set(B.x,B.y,B.z,B.w):$.set(B,ne,ge,pe),ht.viewport(I.copy($).multiplyScalar(ce).round())},this.getScissor=function(B){return B.copy(ue)},this.setScissor=function(B,ne,ge,pe){B.isVector4?ue.set(B.x,B.y,B.z,B.w):ue.set(B,ne,ge,pe),ht.scissor(F.copy(ue).multiplyScalar(ce).round())},this.getScissorTest=function(){return Ee},this.setScissorTest=function(B){ht.setScissorTest(Ee=B)},this.setOpaqueSort=function(B){Le=B},this.setTransparentSort=function(B){ee=B},this.getClearColor=function(B){return B.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(B=!0,ne=!0,ge=!0){let pe=0;if(B){let he=!1;if(K!==null){const je=K.texture.format;he=b.has(je)}if(he){const je=K.texture.type,tt=x.has(je),$e=Xe.getClearColor(),ut=Xe.getClearAlpha(),dt=$e.r,At=$e.g,Ot=$e.b;tt?(M[0]=dt,M[1]=At,M[2]=Ot,M[3]=ut,Q.clearBufferuiv(Q.COLOR,0,M)):(E[0]=dt,E[1]=At,E[2]=Ot,E[3]=ut,Q.clearBufferiv(Q.COLOR,0,E))}else pe|=Q.COLOR_BUFFER_BIT}ne&&(pe|=Q.DEPTH_BUFFER_BIT),ge&&(pe|=Q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),pe!==0&&Q.clear(pe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",nt,!1),t.removeEventListener("webglcontextrestored",Ct,!1),t.removeEventListener("webglcontextcreationerror",Mn,!1),Xe.dispose(),Tt.dispose(),Fe.dispose(),P.dispose(),Re.dispose(),lt.dispose(),ze.dispose(),Je.dispose(),He.dispose(),Me.dispose(),Me.removeEventListener("sessionstart",Wu),Me.removeEventListener("sessionend",$u),Ws.stop()};function nt(B){B.preventDefault(),hp("WebGLRenderer: Context Lost."),j=!0}function Ct(){hp("WebGLRenderer: Context Restored."),j=!1;const B=V.autoReset,ne=Ze.enabled,ge=Ze.autoUpdate,pe=Ze.needsUpdate,he=Ze.type;Be(),V.autoReset=B,Ze.enabled=ne,Ze.autoUpdate=ge,Ze.needsUpdate=pe,Ze.type=he}function Mn(B){Pe("WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function an(B){const ne=B.target;ne.removeEventListener("dispose",an),sr(ne)}function sr(B){As(B),P.remove(B)}function As(B){const ne=P.get(B).programs;ne!==void 0&&(ne.forEach(function(ge){He.releaseProgram(ge)}),B.isShaderMaterial&&He.releaseShaderCache(B))}this.renderBufferDirect=function(B,ne,ge,pe,he,je){ne===null&&(ne=qt);const tt=he.isMesh&&he.matrixWorld.determinant()<0,$e=Bp(B,ne,ge,pe,he);ht.setMaterial(pe,tt);let ut=ge.index,dt=1;if(pe.wireframe===!0){if(ut=Ae.getWireframeAttribute(ge),ut===void 0)return;dt=2}const At=ge.drawRange,Ot=ge.attributes.position;let it=At.start*dt,Vt=(At.start+At.count)*dt;je!==null&&(it=Math.max(it,je.start*dt),Vt=Math.min(Vt,(je.start+je.count)*dt)),ut!==null?(it=Math.max(it,0),Vt=Math.min(Vt,ut.count)):Ot!=null&&(it=Math.max(it,0),Vt=Math.min(Vt,Ot.count));const qn=Vt-it;if(qn<0||qn===1/0)return;ze.setup(he,pe,$e,ge,ut);let Xn,ln=Gt;if(ut!==null&&(Xn=Ue.get(ut),ln=re,ln.setIndex(Xn)),he.isMesh)pe.wireframe===!0?(ht.setLineWidth(pe.wireframeLinewidth*on()),ln.setMode(Q.LINES)):ln.setMode(Q.TRIANGLES);else if(he.isLine){let Mi=pe.linewidth;Mi===void 0&&(Mi=1),ht.setLineWidth(Mi*on()),he.isLineSegments?ln.setMode(Q.LINES):he.isLineLoop?ln.setMode(Q.LINE_LOOP):ln.setMode(Q.LINE_STRIP)}else he.isPoints?ln.setMode(Q.POINTS):he.isSprite&&ln.setMode(Q.TRIANGLES);if(he.isBatchedMesh)if(he._multiDrawInstances!==null)xn("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),ln.renderMultiDrawInstances(he._multiDrawStarts,he._multiDrawCounts,he._multiDrawCount,he._multiDrawInstances);else if(nn.get("WEBGL_multi_draw"))ln.renderMultiDraw(he._multiDrawStarts,he._multiDrawCounts,he._multiDrawCount);else{const Mi=he._multiDrawStarts,at=he._multiDrawCounts,ar=he._multiDrawCount,Lt=ut?Ue.get(ut).bytesPerElement:1,or=P.get(pe).currentProgram.getUniforms();for(let kr=0;kr<ar;kr++)or.setValue(Q,"_gl_DrawID",kr),ln.render(Mi[kr]/Lt,at[kr])}else if(he.isInstancedMesh)ln.renderInstances(it,qn,he.count);else if(ge.isInstancedBufferGeometry){const Mi=ge._maxInstanceCount!==void 0?ge._maxInstanceCount:1/0,at=Math.min(ge.instanceCount,Mi);ln.renderInstances(it,qn,at)}else ln.render(it,qn)};function hf(B,ne,ge){B.transparent===!0&&B.side===Ui&&B.forceSinglePass===!1?(B.side=Tn,B.needsUpdate=!0,Eo(B,ne,ge),B.side=xr,B.needsUpdate=!0,Eo(B,ne,ge),B.side=Ui):Eo(B,ne,ge)}this.compile=function(B,ne,ge=null){ge===null&&(ge=B),D=Fe.get(ge),D.init(ne),N.push(D),ge.traverseVisible(function(he){he.isLight&&he.layers.test(ne.layers)&&(D.pushLight(he),he.castShadow&&D.pushShadow(he))}),B!==ge&&B.traverseVisible(function(he){he.isLight&&he.layers.test(ne.layers)&&(D.pushLight(he),he.castShadow&&D.pushShadow(he))}),D.setupLights();const pe=new Set;return B.traverse(function(he){if(!(he.isMesh||he.isPoints||he.isLine||he.isSprite))return;const je=he.material;if(je)if(Array.isArray(je))for(let tt=0;tt<je.length;tt++){const $e=je[tt];hf($e,ge,he),pe.add($e)}else hf(je,ge,he),pe.add(je)}),D=N.pop(),pe},this.compileAsync=function(B,ne,ge=null){const pe=this.compile(B,ne,ge);return new Promise(he=>{function je(){if(pe.forEach(function(tt){P.get(tt).currentProgram.isReady()&&pe.delete(tt)}),pe.size===0){he(B);return}setTimeout(je,10)}nn.get("KHR_parallel_shader_compile")!==null?je():setTimeout(je,10)})};let ju=null;function Pp(B){ju&&ju(B)}function Wu(){Ws.stop()}function $u(){Ws.start()}const Ws=new h2;Ws.setAnimationLoop(Pp),typeof self<"u"&&Ws.setContext(self),this.setAnimationLoop=function(B){ju=B,Me.setAnimationLoop(B),B===null?Ws.stop():Ws.start()},Me.addEventListener("sessionstart",Wu),Me.addEventListener("sessionend",$u),this.render=function(B,ne){if(ne!==void 0&&ne.isCamera!==!0){Pe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(j===!0)return;const ge=Me.enabled===!0&&Me.isPresenting===!0,pe=A!==null&&(K===null||ge)&&A.begin(L,K);if(B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ne.parent===null&&ne.matrixWorldAutoUpdate===!0&&ne.updateMatrixWorld(),Me.enabled===!0&&Me.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(Me.cameraAutoUpdate===!0&&Me.updateCamera(ne),ne=Me.getCamera()),B.isScene===!0&&B.onBeforeRender(L,B,ne,K),D=Fe.get(B,N.length),D.init(ne),N.push(D),sn.multiplyMatrices(ne.projectionMatrix,ne.matrixWorldInverse),ke.setFromProjectionMatrix(sn,yr,ne.reversedDepth),Ke=this.localClippingEnabled,We=Oe.init(this.clippingPlanes,Ke),w=Tt.get(B,C.length),w.init(),C.push(w),Me.enabled===!0&&Me.isPresenting===!0){const tt=L.xr.getDepthSensingMesh();tt!==null&&qu(tt,ne,-1/0,L.sortObjects)}qu(B,ne,0,L.sortObjects),w.finish(),L.sortObjects===!0&&w.sort(Le,ee),St=Me.enabled===!1||Me.isPresenting===!1||Me.hasDepthSensing()===!1,St&&Xe.addToRenderList(w,B),this.info.render.frame++,We===!0&&Oe.beginShadows();const he=D.state.shadowsArray;if(Ze.render(he,B,ne),We===!0&&Oe.endShadows(),this.info.autoReset===!0&&this.info.reset(),(pe&&A.hasRenderPass())===!1){const tt=w.opaque,$e=w.transmissive;if(D.setupLights(),ne.isArrayCamera){const ut=ne.cameras;if($e.length>0)for(let dt=0,At=ut.length;dt<At;dt++){const Ot=ut[dt];ci(tt,$e,B,Ot)}St&&Xe.render(B);for(let dt=0,At=ut.length;dt<At;dt++){const Ot=ut[dt];ws(w,B,Ot,Ot.viewport)}}else $e.length>0&&ci(tt,$e,B,ne),St&&Xe.render(B),ws(w,B,ne)}K!==null&&H===0&&(ae.updateMultisampleRenderTarget(K),ae.updateRenderTargetMipmap(K)),pe&&A.end(L),B.isScene===!0&&B.onAfterRender(L,B,ne),ze.resetDefaultState(),te=-1,Z=null,N.pop(),N.length>0?(D=N[N.length-1],We===!0&&Oe.setGlobalState(L.clippingPlanes,D.state.camera)):D=null,C.pop(),C.length>0?w=C[C.length-1]:w=null};function qu(B,ne,ge,pe){if(B.visible===!1)return;if(B.layers.test(ne.layers)){if(B.isGroup)ge=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(ne);else if(B.isLight)D.pushLight(B),B.castShadow&&D.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||ke.intersectsSprite(B)){pe&&Rt.setFromMatrixPosition(B.matrixWorld).applyMatrix4(sn);const tt=lt.update(B),$e=B.material;$e.visible&&w.push(B,tt,$e,ge,Rt.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(!B.frustumCulled||ke.intersectsObject(B))){const tt=lt.update(B),$e=B.material;if(pe&&(B.boundingSphere!==void 0?(B.boundingSphere===null&&B.computeBoundingSphere(),Rt.copy(B.boundingSphere.center)):(tt.boundingSphere===null&&tt.computeBoundingSphere(),Rt.copy(tt.boundingSphere.center)),Rt.applyMatrix4(B.matrixWorld).applyMatrix4(sn)),Array.isArray($e)){const ut=tt.groups;for(let dt=0,At=ut.length;dt<At;dt++){const Ot=ut[dt],it=$e[Ot.materialIndex];it&&it.visible&&w.push(B,tt,it,ge,Rt.z,Ot)}}else $e.visible&&w.push(B,tt,$e,ge,Rt.z,null)}}const je=B.children;for(let tt=0,$e=je.length;tt<$e;tt++)qu(je[tt],ne,ge,pe)}function ws(B,ne,ge,pe){const{opaque:he,transmissive:je,transparent:tt}=B;D.setupLightsView(ge),We===!0&&Oe.setGlobalState(L.clippingPlanes,ge),pe&&ht.viewport(I.copy(pe)),he.length>0&&Ti(he,ne,ge),je.length>0&&Ti(je,ne,ge),tt.length>0&&Ti(tt,ne,ge),ht.buffers.depth.setTest(!0),ht.buffers.depth.setMask(!0),ht.buffers.color.setMask(!0),ht.setPolygonOffset(!1)}function ci(B,ne,ge,pe){if((ge.isScene===!0?ge.overrideMaterial:null)!==null)return;if(D.state.transmissionRenderTarget[pe.id]===void 0){const it=nn.has("EXT_color_buffer_half_float")||nn.has("EXT_color_buffer_float");D.state.transmissionRenderTarget[pe.id]=new Hs(1,1,{generateMipmaps:!0,type:it?Qn:Gn,minFilter:Ur,samples:Math.max(4,_n.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:xt.workingColorSpace})}const je=D.state.transmissionRenderTarget[pe.id],tt=pe.viewport||I;je.setSize(tt.z*L.transmissionResolutionScale,tt.w*L.transmissionResolutionScale);const $e=L.getRenderTarget(),ut=L.getActiveCubeFace(),dt=L.getActiveMipmapLevel();L.setRenderTarget(je),L.getClearColor(se),Te=L.getClearAlpha(),Te<1&&L.setClearColor(16777215,.5),L.clear(),St&&Xe.render(ge);const At=L.toneMapping;L.toneMapping=ji;const Ot=pe.viewport;if(pe.viewport!==void 0&&(pe.viewport=void 0),D.setupLightsView(pe),We===!0&&Oe.setGlobalState(L.clippingPlanes,pe),Ti(B,ge,pe),ae.updateMultisampleRenderTarget(je),ae.updateRenderTargetMipmap(je),nn.has("WEBGL_multisampled_render_to_texture")===!1){let it=!1;for(let Vt=0,qn=ne.length;Vt<qn;Vt++){const Xn=ne[Vt],{object:ln,geometry:Mi,material:at,group:ar}=Xn;if(at.side===Ui&&ln.layers.test(pe.layers)){const Lt=at.side;at.side=Tn,at.needsUpdate=!0,Ca(ln,ge,pe,Mi,at,ar),at.side=Lt,at.needsUpdate=!0,it=!0}}it===!0&&(ae.updateMultisampleRenderTarget(je),ae.updateRenderTargetMipmap(je))}L.setRenderTarget($e,ut,dt),L.setClearColor(se,Te),Ot!==void 0&&(pe.viewport=Ot),L.toneMapping=At}function Ti(B,ne,ge){const pe=ne.isScene===!0?ne.overrideMaterial:null;for(let he=0,je=B.length;he<je;he++){const tt=B[he],{object:$e,geometry:ut,group:dt}=tt;let At=tt.material;At.allowOverride===!0&&pe!==null&&(At=pe),$e.layers.test(ge.layers)&&Ca($e,ne,ge,ut,At,dt)}}function Ca(B,ne,ge,pe,he,je){B.onBeforeRender(L,ne,ge,pe,he,je),B.modelViewMatrix.multiplyMatrices(ge.matrixWorldInverse,B.matrixWorld),B.normalMatrix.getNormalMatrix(B.modelViewMatrix),he.onBeforeRender(L,ne,ge,pe,B,je),he.transparent===!0&&he.side===Ui&&he.forceSinglePass===!1?(he.side=Tn,he.needsUpdate=!0,L.renderBufferDirect(ge,ne,pe,he,B,je),he.side=xr,he.needsUpdate=!0,L.renderBufferDirect(ge,ne,pe,he,B,je),he.side=Ui):L.renderBufferDirect(ge,ne,pe,he,B,je),B.onAfterRender(L,ne,ge,pe,he,je)}function Eo(B,ne,ge){ne.isScene!==!0&&(ne=qt);const pe=P.get(B),he=D.state.lights,je=D.state.shadowsArray,tt=he.state.version,$e=He.getParameters(B,he.state,je,ne,ge),ut=He.getProgramCacheKey($e);let dt=pe.programs;pe.environment=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?ne.environment:null,pe.fog=ne.fog;const At=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap;pe.envMap=Re.get(B.envMap||pe.environment,At),pe.envMapRotation=pe.environment!==null&&B.envMap===null?ne.environmentRotation:B.envMapRotation,dt===void 0&&(B.addEventListener("dispose",an),dt=new Map,pe.programs=dt);let Ot=dt.get(ut);if(Ot!==void 0){if(pe.currentProgram===Ot&&pe.lightsStateVersion===tt)return Op(B,$e),Ot}else $e.uniforms=He.getUniforms(B),B.onBeforeCompile($e,L),Ot=He.acquireProgram($e,ut),dt.set(ut,Ot),pe.uniforms=$e.uniforms;const it=pe.uniforms;return(!B.isShaderMaterial&&!B.isRawShaderMaterial||B.clipping===!0)&&(it.clippingPlanes=Oe.uniform),Op(B,$e),pe.needsLights=ff(B),pe.lightsStateVersion=tt,pe.needsLights&&(it.ambientLightColor.value=he.state.ambient,it.lightProbe.value=he.state.probe,it.directionalLights.value=he.state.directional,it.directionalLightShadows.value=he.state.directionalShadow,it.spotLights.value=he.state.spot,it.spotLightShadows.value=he.state.spotShadow,it.rectAreaLights.value=he.state.rectArea,it.ltc_1.value=he.state.rectAreaLTC1,it.ltc_2.value=he.state.rectAreaLTC2,it.pointLights.value=he.state.point,it.pointLightShadows.value=he.state.pointShadow,it.hemisphereLights.value=he.state.hemi,it.directionalShadowMatrix.value=he.state.directionalShadowMatrix,it.spotLightMatrix.value=he.state.spotLightMatrix,it.spotLightMap.value=he.state.spotLightMap,it.pointShadowMatrix.value=he.state.pointShadowMatrix),pe.currentProgram=Ot,pe.uniformsList=null,Ot}function Up(B){if(B.uniformsList===null){const ne=B.currentProgram.getUniforms();B.uniformsList=r_.seqWithValue(ne.seq,B.uniforms)}return B.uniformsList}function Op(B,ne){const ge=P.get(B);ge.outputColorSpace=ne.outputColorSpace,ge.batching=ne.batching,ge.batchingColor=ne.batchingColor,ge.instancing=ne.instancing,ge.instancingColor=ne.instancingColor,ge.instancingMorph=ne.instancingMorph,ge.skinning=ne.skinning,ge.morphTargets=ne.morphTargets,ge.morphNormals=ne.morphNormals,ge.morphColors=ne.morphColors,ge.morphTargetsCount=ne.morphTargetsCount,ge.numClippingPlanes=ne.numClippingPlanes,ge.numIntersection=ne.numClipIntersection,ge.vertexAlphas=ne.vertexAlphas,ge.vertexTangents=ne.vertexTangents,ge.toneMapping=ne.toneMapping}function Bp(B,ne,ge,pe,he){ne.isScene!==!0&&(ne=qt),ae.resetTextureUnits();const je=ne.fog,tt=pe.isMeshStandardMaterial||pe.isMeshLambertMaterial||pe.isMeshPhongMaterial?ne.environment:null,$e=K===null?L.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:Cu,ut=pe.isMeshStandardMaterial||pe.isMeshLambertMaterial&&!pe.envMap||pe.isMeshPhongMaterial&&!pe.envMap,dt=Re.get(pe.envMap||tt,ut),At=pe.vertexColors===!0&&!!ge.attributes.color&&ge.attributes.color.itemSize===4,Ot=!!ge.attributes.tangent&&(!!pe.normalMap||pe.anisotropy>0),it=!!ge.morphAttributes.position,Vt=!!ge.morphAttributes.normal,qn=!!ge.morphAttributes.color;let Xn=ji;pe.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(Xn=L.toneMapping);const ln=ge.morphAttributes.position||ge.morphAttributes.normal||ge.morphAttributes.color,Mi=ln!==void 0?ln.length:0,at=P.get(pe),ar=D.state.lights;if(We===!0&&(Ke===!0||B!==Z)){const fi=B===Z&&pe.id===te;Oe.setState(pe,B,fi)}let Lt=!1;pe.version===at.__version?(at.needsLights&&at.lightsStateVersion!==ar.state.version||at.outputColorSpace!==$e||he.isBatchedMesh&&at.batching===!1||!he.isBatchedMesh&&at.batching===!0||he.isBatchedMesh&&at.batchingColor===!0&&he.colorTexture===null||he.isBatchedMesh&&at.batchingColor===!1&&he.colorTexture!==null||he.isInstancedMesh&&at.instancing===!1||!he.isInstancedMesh&&at.instancing===!0||he.isSkinnedMesh&&at.skinning===!1||!he.isSkinnedMesh&&at.skinning===!0||he.isInstancedMesh&&at.instancingColor===!0&&he.instanceColor===null||he.isInstancedMesh&&at.instancingColor===!1&&he.instanceColor!==null||he.isInstancedMesh&&at.instancingMorph===!0&&he.morphTexture===null||he.isInstancedMesh&&at.instancingMorph===!1&&he.morphTexture!==null||at.envMap!==dt||pe.fog===!0&&at.fog!==je||at.numClippingPlanes!==void 0&&(at.numClippingPlanes!==Oe.numPlanes||at.numIntersection!==Oe.numIntersection)||at.vertexAlphas!==At||at.vertexTangents!==Ot||at.morphTargets!==it||at.morphNormals!==Vt||at.morphColors!==qn||at.toneMapping!==Xn||at.morphTargetsCount!==Mi)&&(Lt=!0):(Lt=!0,at.__version=pe.version);let or=at.currentProgram;Lt===!0&&(or=Eo(pe,ne,he));let kr=!1,Rs=!1,Gr=!1;const vn=or.getUniforms(),hi=at.uniforms;if(ht.useProgram(or.program)&&(kr=!0,Rs=!0,Gr=!0),pe.id!==te&&(te=pe.id,Rs=!0),kr||Z!==B){ht.buffers.depth.getReversed()&&B.reversedDepth!==!0&&(B._reversedDepth=!0,B.updateProjectionMatrix()),vn.setValue(Q,"projectionMatrix",B.projectionMatrix),vn.setValue(Q,"viewMatrix",B.matrixWorldInverse);const Cs=vn.map.cameraPosition;Cs!==void 0&&Cs.setValue(Q,Ut.setFromMatrixPosition(B.matrixWorld)),_n.logarithmicDepthBuffer&&vn.setValue(Q,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),(pe.isMeshPhongMaterial||pe.isMeshToonMaterial||pe.isMeshLambertMaterial||pe.isMeshBasicMaterial||pe.isMeshStandardMaterial||pe.isShaderMaterial)&&vn.setValue(Q,"isOrthographic",B.isOrthographicCamera===!0),Z!==B&&(Z=B,Rs=!0,Gr=!0)}if(at.needsLights&&(ar.state.directionalShadowMap.length>0&&vn.setValue(Q,"directionalShadowMap",ar.state.directionalShadowMap,ae),ar.state.spotShadowMap.length>0&&vn.setValue(Q,"spotShadowMap",ar.state.spotShadowMap,ae),ar.state.pointShadowMap.length>0&&vn.setValue(Q,"pointShadowMap",ar.state.pointShadowMap,ae)),he.isSkinnedMesh){vn.setOptional(Q,he,"bindMatrix"),vn.setOptional(Q,he,"bindMatrixInverse");const fi=he.skeleton;fi&&(fi.boneTexture===null&&fi.computeBoneTexture(),vn.setValue(Q,"boneTexture",fi.boneTexture,ae))}he.isBatchedMesh&&(vn.setOptional(Q,he,"batchingTexture"),vn.setValue(Q,"batchingTexture",he._matricesTexture,ae),vn.setOptional(Q,he,"batchingIdTexture"),vn.setValue(Q,"batchingIdTexture",he._indirectTexture,ae),vn.setOptional(Q,he,"batchingColorTexture"),he._colorsTexture!==null&&vn.setValue(Q,"batchingColorTexture",he._colorsTexture,ae));const lr=ge.morphAttributes;if((lr.position!==void 0||lr.normal!==void 0||lr.color!==void 0)&&Qe.update(he,ge,or),(Rs||at.receiveShadow!==he.receiveShadow)&&(at.receiveShadow=he.receiveShadow,vn.setValue(Q,"receiveShadow",he.receiveShadow)),(pe.isMeshStandardMaterial||pe.isMeshLambertMaterial||pe.isMeshPhongMaterial)&&pe.envMap===null&&ne.environment!==null&&(hi.envMapIntensity.value=ne.environmentIntensity),hi.dfgLUT!==void 0&&(hi.dfgLUT.value=m4()),Rs&&(vn.setValue(Q,"toneMappingExposure",L.toneMappingExposure),at.needsLights&&Pl(hi,Gr),je&&pe.fog===!0&&gt.refreshFogUniforms(hi,je),gt.refreshMaterialUniforms(hi,pe,ce,W,D.state.transmissionRenderTarget[B.id]),r_.upload(Q,Up(at),hi,ae)),pe.isShaderMaterial&&pe.uniformsNeedUpdate===!0&&(r_.upload(Q,Up(at),hi,ae),pe.uniformsNeedUpdate=!1),pe.isSpriteMaterial&&vn.setValue(Q,"center",he.center),vn.setValue(Q,"modelViewMatrix",he.modelViewMatrix),vn.setValue(Q,"normalMatrix",he.normalMatrix),vn.setValue(Q,"modelMatrix",he.matrixWorld),pe.isShaderMaterial||pe.isRawShaderMaterial){const fi=pe.uniformsGroups;for(let Cs=0,Na=fi.length;Cs<Na;Cs++){const Xu=fi[Cs];Je.update(Xu,or),Je.bind(Xu,or)}}return or}function Pl(B,ne){B.ambientLightColor.needsUpdate=ne,B.lightProbe.needsUpdate=ne,B.directionalLights.needsUpdate=ne,B.directionalLightShadows.needsUpdate=ne,B.pointLights.needsUpdate=ne,B.pointLightShadows.needsUpdate=ne,B.spotLights.needsUpdate=ne,B.spotLightShadows.needsUpdate=ne,B.rectAreaLights.needsUpdate=ne,B.hemisphereLights.needsUpdate=ne}function ff(B){return B.isMeshLambertMaterial||B.isMeshToonMaterial||B.isMeshPhongMaterial||B.isMeshStandardMaterial||B.isShadowMaterial||B.isShaderMaterial&&B.lights===!0}this.getActiveCubeFace=function(){return z},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return K},this.setRenderTargetTextures=function(B,ne,ge){const pe=P.get(B);pe.__autoAllocateDepthBuffer=B.resolveDepthBuffer===!1,pe.__autoAllocateDepthBuffer===!1&&(pe.__useRenderToTexture=!1),P.get(B.texture).__webglTexture=ne,P.get(B.depthTexture).__webglTexture=pe.__autoAllocateDepthBuffer?void 0:ge,pe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(B,ne){const ge=P.get(B);ge.__webglFramebuffer=ne,ge.__useDefaultFramebuffer=ne===void 0};const Ao=Q.createFramebuffer();this.setRenderTarget=function(B,ne=0,ge=0){K=B,z=ne,H=ge;let pe=null,he=!1,je=!1;if(B){const $e=P.get(B);if($e.__useDefaultFramebuffer!==void 0){ht.bindFramebuffer(Q.FRAMEBUFFER,$e.__webglFramebuffer),I.copy(B.viewport),F.copy(B.scissor),Y=B.scissorTest,ht.viewport(I),ht.scissor(F),ht.setScissorTest(Y),te=-1;return}else if($e.__webglFramebuffer===void 0)ae.setupRenderTarget(B);else if($e.__hasExternalTextures)ae.rebindTextures(B,P.get(B.texture).__webglTexture,P.get(B.depthTexture).__webglTexture);else if(B.depthBuffer){const At=B.depthTexture;if($e.__boundDepthTexture!==At){if(At!==null&&P.has(At)&&(B.width!==At.image.width||B.height!==At.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ae.setupDepthRenderbuffer(B)}}const ut=B.texture;(ut.isData3DTexture||ut.isDataArrayTexture||ut.isCompressedArrayTexture)&&(je=!0);const dt=P.get(B).__webglFramebuffer;B.isWebGLCubeRenderTarget?(Array.isArray(dt[ne])?pe=dt[ne][ge]:pe=dt[ne],he=!0):B.samples>0&&ae.useMultisampledRTT(B)===!1?pe=P.get(B).__webglMultisampledFramebuffer:Array.isArray(dt)?pe=dt[ge]:pe=dt,I.copy(B.viewport),F.copy(B.scissor),Y=B.scissorTest}else I.copy($).multiplyScalar(ce).floor(),F.copy(ue).multiplyScalar(ce).floor(),Y=Ee;if(ge!==0&&(pe=Ao),ht.bindFramebuffer(Q.FRAMEBUFFER,pe)&&ht.drawBuffers(B,pe),ht.viewport(I),ht.scissor(F),ht.setScissorTest(Y),he){const $e=P.get(B.texture);Q.framebufferTexture2D(Q.FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_CUBE_MAP_POSITIVE_X+ne,$e.__webglTexture,ge)}else if(je){const $e=ne;for(let ut=0;ut<B.textures.length;ut++){const dt=P.get(B.textures[ut]);Q.framebufferTextureLayer(Q.FRAMEBUFFER,Q.COLOR_ATTACHMENT0+ut,dt.__webglTexture,ge,$e)}}else if(B!==null&&ge!==0){const $e=P.get(B.texture);Q.framebufferTexture2D(Q.FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_2D,$e.__webglTexture,ge)}te=-1},this.readRenderTargetPixels=function(B,ne,ge,pe,he,je,tt,$e=0){if(!(B&&B.isWebGLRenderTarget)){Pe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ut=P.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&tt!==void 0&&(ut=ut[tt]),ut){ht.bindFramebuffer(Q.FRAMEBUFFER,ut);try{const dt=B.textures[$e],At=dt.format,Ot=dt.type;if(B.textures.length>1&&Q.readBuffer(Q.COLOR_ATTACHMENT0+$e),!_n.textureFormatReadable(At)){Pe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!_n.textureTypeReadable(Ot)){Pe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ne>=0&&ne<=B.width-pe&&ge>=0&&ge<=B.height-he&&Q.readPixels(ne,ge,pe,he,Ge.convert(At),Ge.convert(Ot),je)}finally{const dt=K!==null?P.get(K).__webglFramebuffer:null;ht.bindFramebuffer(Q.FRAMEBUFFER,dt)}}},this.readRenderTargetPixelsAsync=async function(B,ne,ge,pe,he,je,tt,$e=0){if(!(B&&B.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ut=P.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&tt!==void 0&&(ut=ut[tt]),ut)if(ne>=0&&ne<=B.width-pe&&ge>=0&&ge<=B.height-he){ht.bindFramebuffer(Q.FRAMEBUFFER,ut);const dt=B.textures[$e],At=dt.format,Ot=dt.type;if(B.textures.length>1&&Q.readBuffer(Q.COLOR_ATTACHMENT0+$e),!_n.textureFormatReadable(At))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!_n.textureTypeReadable(Ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const it=Q.createBuffer();Q.bindBuffer(Q.PIXEL_PACK_BUFFER,it),Q.bufferData(Q.PIXEL_PACK_BUFFER,je.byteLength,Q.STREAM_READ),Q.readPixels(ne,ge,pe,he,Ge.convert(At),Ge.convert(Ot),0);const Vt=K!==null?P.get(K).__webglFramebuffer:null;ht.bindFramebuffer(Q.FRAMEBUFFER,Vt);const qn=Q.fenceSync(Q.SYNC_GPU_COMMANDS_COMPLETE,0);return Q.flush(),await WO(Q,qn,4),Q.bindBuffer(Q.PIXEL_PACK_BUFFER,it),Q.getBufferSubData(Q.PIXEL_PACK_BUFFER,0,je),Q.deleteBuffer(it),Q.deleteSync(qn),je}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(B,ne=null,ge=0){const pe=Math.pow(2,-ge),he=Math.floor(B.image.width*pe),je=Math.floor(B.image.height*pe),tt=ne!==null?ne.x:0,$e=ne!==null?ne.y:0;ae.setTexture2D(B,0),Q.copyTexSubImage2D(Q.TEXTURE_2D,ge,0,0,tt,$e,he,je),ht.unbindTexture()};const wo=Q.createFramebuffer(),Ul=Q.createFramebuffer();this.copyTextureToTexture=function(B,ne,ge=null,pe=null,he=0,je=0){let tt,$e,ut,dt,At,Ot,it,Vt,qn;const Xn=B.isCompressedTexture?B.mipmaps[je]:B.image;if(ge!==null)tt=ge.max.x-ge.min.x,$e=ge.max.y-ge.min.y,ut=ge.isBox3?ge.max.z-ge.min.z:1,dt=ge.min.x,At=ge.min.y,Ot=ge.isBox3?ge.min.z:0;else{const hi=Math.pow(2,-he);tt=Math.floor(Xn.width*hi),$e=Math.floor(Xn.height*hi),B.isDataArrayTexture?ut=Xn.depth:B.isData3DTexture?ut=Math.floor(Xn.depth*hi):ut=1,dt=0,At=0,Ot=0}pe!==null?(it=pe.x,Vt=pe.y,qn=pe.z):(it=0,Vt=0,qn=0);const ln=Ge.convert(ne.format),Mi=Ge.convert(ne.type);let at;ne.isData3DTexture?(ae.setTexture3D(ne,0),at=Q.TEXTURE_3D):ne.isDataArrayTexture||ne.isCompressedArrayTexture?(ae.setTexture2DArray(ne,0),at=Q.TEXTURE_2D_ARRAY):(ae.setTexture2D(ne,0),at=Q.TEXTURE_2D),Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL,ne.flipY),Q.pixelStorei(Q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ne.premultiplyAlpha),Q.pixelStorei(Q.UNPACK_ALIGNMENT,ne.unpackAlignment);const ar=Q.getParameter(Q.UNPACK_ROW_LENGTH),Lt=Q.getParameter(Q.UNPACK_IMAGE_HEIGHT),or=Q.getParameter(Q.UNPACK_SKIP_PIXELS),kr=Q.getParameter(Q.UNPACK_SKIP_ROWS),Rs=Q.getParameter(Q.UNPACK_SKIP_IMAGES);Q.pixelStorei(Q.UNPACK_ROW_LENGTH,Xn.width),Q.pixelStorei(Q.UNPACK_IMAGE_HEIGHT,Xn.height),Q.pixelStorei(Q.UNPACK_SKIP_PIXELS,dt),Q.pixelStorei(Q.UNPACK_SKIP_ROWS,At),Q.pixelStorei(Q.UNPACK_SKIP_IMAGES,Ot);const Gr=B.isDataArrayTexture||B.isData3DTexture,vn=ne.isDataArrayTexture||ne.isData3DTexture;if(B.isDepthTexture){const hi=P.get(B),lr=P.get(ne),fi=P.get(hi.__renderTarget),Cs=P.get(lr.__renderTarget);ht.bindFramebuffer(Q.READ_FRAMEBUFFER,fi.__webglFramebuffer),ht.bindFramebuffer(Q.DRAW_FRAMEBUFFER,Cs.__webglFramebuffer);for(let Na=0;Na<ut;Na++)Gr&&(Q.framebufferTextureLayer(Q.READ_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,P.get(B).__webglTexture,he,Ot+Na),Q.framebufferTextureLayer(Q.DRAW_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,P.get(ne).__webglTexture,je,qn+Na)),Q.blitFramebuffer(dt,At,tt,$e,it,Vt,tt,$e,Q.DEPTH_BUFFER_BIT,Q.NEAREST);ht.bindFramebuffer(Q.READ_FRAMEBUFFER,null),ht.bindFramebuffer(Q.DRAW_FRAMEBUFFER,null)}else if(he!==0||B.isRenderTargetTexture||P.has(B)){const hi=P.get(B),lr=P.get(ne);ht.bindFramebuffer(Q.READ_FRAMEBUFFER,wo),ht.bindFramebuffer(Q.DRAW_FRAMEBUFFER,Ul);for(let fi=0;fi<ut;fi++)Gr?Q.framebufferTextureLayer(Q.READ_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,hi.__webglTexture,he,Ot+fi):Q.framebufferTexture2D(Q.READ_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_2D,hi.__webglTexture,he),vn?Q.framebufferTextureLayer(Q.DRAW_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,lr.__webglTexture,je,qn+fi):Q.framebufferTexture2D(Q.DRAW_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_2D,lr.__webglTexture,je),he!==0?Q.blitFramebuffer(dt,At,tt,$e,it,Vt,tt,$e,Q.COLOR_BUFFER_BIT,Q.NEAREST):vn?Q.copyTexSubImage3D(at,je,it,Vt,qn+fi,dt,At,tt,$e):Q.copyTexSubImage2D(at,je,it,Vt,dt,At,tt,$e);ht.bindFramebuffer(Q.READ_FRAMEBUFFER,null),ht.bindFramebuffer(Q.DRAW_FRAMEBUFFER,null)}else vn?B.isDataTexture||B.isData3DTexture?Q.texSubImage3D(at,je,it,Vt,qn,tt,$e,ut,ln,Mi,Xn.data):ne.isCompressedArrayTexture?Q.compressedTexSubImage3D(at,je,it,Vt,qn,tt,$e,ut,ln,Xn.data):Q.texSubImage3D(at,je,it,Vt,qn,tt,$e,ut,ln,Mi,Xn):B.isDataTexture?Q.texSubImage2D(Q.TEXTURE_2D,je,it,Vt,tt,$e,ln,Mi,Xn.data):B.isCompressedTexture?Q.compressedTexSubImage2D(Q.TEXTURE_2D,je,it,Vt,Xn.width,Xn.height,ln,Xn.data):Q.texSubImage2D(Q.TEXTURE_2D,je,it,Vt,tt,$e,ln,Mi,Xn);Q.pixelStorei(Q.UNPACK_ROW_LENGTH,ar),Q.pixelStorei(Q.UNPACK_IMAGE_HEIGHT,Lt),Q.pixelStorei(Q.UNPACK_SKIP_PIXELS,or),Q.pixelStorei(Q.UNPACK_SKIP_ROWS,kr),Q.pixelStorei(Q.UNPACK_SKIP_IMAGES,Rs),je===0&&ne.generateMipmaps&&Q.generateMipmap(at),ht.unbindTexture()},this.initRenderTarget=function(B){P.get(B).__webglFramebuffer===void 0&&ae.setupRenderTarget(B)},this.initTexture=function(B){B.isCubeTexture?ae.setTextureCube(B,0):B.isData3DTexture?ae.setTexture3D(B,0):B.isDataArrayTexture||B.isCompressedArrayTexture?ae.setTexture2DArray(B,0):ae.setTexture2D(B,0),ht.unbindTexture()},this.resetState=function(){z=0,H=0,K=null,ht.reset(),ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return yr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=xt._getDrawingBufferColorSpace(e),t.unpackColorSpace=xt._getUnpackColorSpace()}}const oh=new zs,oo=new Ie,_2=new G,ux=new Ie,s_=new Ie,y_=new G,Lb=new G,v2=new Wt,y2=new G,x2=new G;let tr=null,sa=null;const lo=[],xl={NONE:-1,PAN:0,ROTATE:1};class _4 extends Y_{constructor(e,t,n=null){super(t,n),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new c2,this.mouseButtons={LEFT:Hi.PAN,MIDDLE:Hi.PAN,RIGHT:Hi.ROTATE},this.touches={ONE:co.PAN},this._onPointerMove=v4.bind(this),this._onPointerDown=y4.bind(this),this._onPointerCancel=x4.bind(this),this._onContextMenu=b4.bind(this),n!==null&&this.connect(n)}connect(e){super.connect(e),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerCancel),this.domElement.addEventListener("pointerleave",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerCancel),this.domElement.removeEventListener("pointerleave",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto",this.domElement.style.cursor=""}dispose(){this.disconnect()}_updatePointer(e){const t=this.domElement.getBoundingClientRect();oo.x=(e.clientX-t.left)/t.width*2-1,oo.y=-(e.clientY-t.top)/t.height*2+1}_updateState(e){let t;if(e.pointerType==="touch")t=this.touches.ONE;else switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=null}switch(t){case Hi.PAN:case co.PAN:this.state=xl.PAN;break;case Hi.ROTATE:case co.ROTATE:this.state=xl.ROTATE;break;default:this.state=xl.NONE}}}function v4(i){const e=this.object,t=this.domElement,n=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(i),n.setFromCamera(oo,e),tr)this.state===xl.PAN?n.ray.intersectPlane(oh,y_)&&(tr.position.copy(y_.sub(_2).applyMatrix4(v2)),this.dispatchEvent({type:"drag",object:tr})):this.state===xl.ROTATE&&(ux.subVectors(oo,s_).multiplyScalar(this.rotateSpeed),tr.rotateOnWorldAxis(y2,ux.x),tr.rotateOnWorldAxis(x2.normalize(),-ux.y),this.dispatchEvent({type:"drag",object:tr})),s_.copy(oo);else if(i.pointerType==="mouse"||i.pointerType==="pen")if(lo.length=0,n.setFromCamera(oo,e),n.intersectObjects(this.objects,this.recursive,lo),lo.length>0){const r=lo[0].object;oh.setFromNormalAndCoplanarPoint(e.getWorldDirection(oh.normal),Lb.setFromMatrixPosition(r.matrixWorld)),sa!==r&&sa!==null&&(this.dispatchEvent({type:"hoveroff",object:sa}),t.style.cursor="auto",sa=null),sa!==r&&(this.dispatchEvent({type:"hoveron",object:r}),t.style.cursor="pointer",sa=r)}else sa!==null&&(this.dispatchEvent({type:"hoveroff",object:sa}),t.style.cursor="auto",sa=null);s_.copy(oo)}}function y4(i){const e=this.object,t=this.domElement,n=this.raycaster;this.enabled!==!1&&(this._updatePointer(i),this._updateState(i),lo.length=0,n.setFromCamera(oo,e),n.intersectObjects(this.objects,this.recursive,lo),lo.length>0&&(this.transformGroup===!0?tr=b2(lo[0].object):tr=lo[0].object,oh.setFromNormalAndCoplanarPoint(e.getWorldDirection(oh.normal),Lb.setFromMatrixPosition(tr.matrixWorld)),n.ray.intersectPlane(oh,y_)&&(this.state===xl.PAN?(v2.copy(tr.parent.matrixWorld).invert(),_2.copy(y_).sub(Lb.setFromMatrixPosition(tr.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:tr})):this.state===xl.ROTATE&&(y2.set(0,1,0).applyQuaternion(e.quaternion).normalize(),x2.set(1,0,0).applyQuaternion(e.quaternion).normalize(),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:tr})))),s_.copy(oo))}function x4(){this.enabled!==!1&&(tr&&(this.dispatchEvent({type:"dragend",object:tr}),tr=null),this.domElement.style.cursor=sa?"pointer":"auto",this.state=xl.NONE)}function b4(i){this.enabled!==!1&&i.preventDefault()}function b2(i,e=null){return i.isGroup&&(e=i),i.parent===null?e:b2(i.parent,e)}function S4(i,e,t){var n,r=1;i==null&&(i=0),e==null&&(e=0),t==null&&(t=0);function s(){var o,u=n.length,c,h=0,d=0,p=0;for(o=0;o<u;++o)c=n[o],h+=c.x||0,d+=c.y||0,p+=c.z||0;for(h=(h/u-i)*r,d=(d/u-e)*r,p=(p/u-t)*r,o=0;o<u;++o)c=n[o],h&&(c.x-=h),d&&(c.y-=d),p&&(c.z-=p)}return s.initialize=function(o){n=o},s.x=function(o){return arguments.length?(i=+o,s):i},s.y=function(o){return arguments.length?(e=+o,s):e},s.z=function(o){return arguments.length?(t=+o,s):t},s.strength=function(o){return arguments.length?(r=+o,s):r},s}function T4(i){const e=+this._x.call(null,i);return S2(this.cover(e),e,i)}function S2(i,e,t){if(isNaN(e))return i;var n,r=i._root,s={data:t},o=i._x0,u=i._x1,c,h,d,p,g;if(!r)return i._root=s,i;for(;r.length;)if((d=e>=(c=(o+u)/2))?o=c:u=c,n=r,!(r=r[p=+d]))return n[p]=s,i;if(h=+i._x.call(null,r.data),e===h)return s.next=r,n?n[p]=s:i._root=s,i;do n=n?n[p]=new Array(2):i._root=new Array(2),(d=e>=(c=(o+u)/2))?o=c:u=c;while((p=+d)==(g=+(h>=c)));return n[g]=r,n[p]=s,i}function M4(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e);let n=1/0,r=-1/0;for(let s=0,o;s<e;++s)isNaN(o=+this._x.call(null,i[s]))||(t[s]=o,o<n&&(n=o),o>r&&(r=o));if(n>r)return this;this.cover(n).cover(r);for(let s=0;s<e;++s)S2(this,t[s],i[s]);return this}function E4(i){if(isNaN(i=+i))return this;var e=this._x0,t=this._x1;if(isNaN(e))t=(e=Math.floor(i))+1;else{for(var n=t-e||1,r=this._root,s,o;e>i||i>=t;)switch(o=+(i<e),s=new Array(2),s[o]=r,r=s,n*=2,o){case 0:t=e+n;break;case 1:e=t-n;break}this._root&&this._root.length&&(this._root=r)}return this._x0=e,this._x1=t,this}function A4(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function w4(i){return arguments.length?this.cover(+i[0][0]).cover(+i[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function vo(i,e,t){this.node=i,this.x0=e,this.x1=t}function R4(i,e){var t,n=this._x0,r,s,o=this._x1,u=[],c=this._root,h,d;for(c&&u.push(new vo(c,n,o)),e==null?e=1/0:(n=i-e,o=i+e);h=u.pop();)if(!(!(c=h.node)||(r=h.x0)>o||(s=h.x1)<n))if(c.length){var p=(r+s)/2;u.push(new vo(c[1],p,s),new vo(c[0],r,p)),(d=+(i>=p))&&(h=u[u.length-1],u[u.length-1]=u[u.length-1-d],u[u.length-1-d]=h)}else{var g=Math.abs(i-+this._x.call(null,c.data));g<e&&(e=g,n=i-g,o=i+g,t=c.data)}return t}function C4(i){if(isNaN(c=+this._x.call(null,i)))return this;var e,t=this._root,n,r,s,o=this._x0,u=this._x1,c,h,d,p,g;if(!t)return this;if(t.length)for(;;){if((d=c>=(h=(o+u)/2))?o=h:u=h,e=t,!(t=t[p=+d]))return this;if(!t.length)break;e[p+1&1]&&(n=e,g=p)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[p]=s:delete e[p],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(n?n[g]=t:this._root=t),this):(this._root=s,this)}function N4(i){for(var e=0,t=i.length;e<t;++e)this.remove(i[e]);return this}function D4(){return this._root}function L4(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function P4(i){var e=[],t,n=this._root,r,s,o;for(n&&e.push(new vo(n,this._x0,this._x1));t=e.pop();)if(!i(n=t.node,s=t.x0,o=t.x1)&&n.length){var u=(s+o)/2;(r=n[1])&&e.push(new vo(r,u,o)),(r=n[0])&&e.push(new vo(r,s,u))}return this}function U4(i){var e=[],t=[],n;for(this._root&&e.push(new vo(this._root,this._x0,this._x1));n=e.pop();){var r=n.node;if(r.length){var s,o=n.x0,u=n.x1,c=(o+u)/2;(s=r[0])&&e.push(new vo(s,o,c)),(s=r[1])&&e.push(new vo(s,c,u))}t.push(n)}for(;n=t.pop();)i(n.node,n.x0,n.x1);return this}function O4(i){return i[0]}function B4(i){return arguments.length?(this._x=i,this):this._x}function T2(i,e){var t=new oT(e??O4,NaN,NaN);return i==null?t:t.addAll(i)}function oT(i,e,t){this._x=i,this._x0=e,this._x1=t,this._root=void 0}function Fw(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var zr=T2.prototype=oT.prototype;zr.copy=function(){var i=new oT(this._x,this._x0,this._x1),e=this._root,t,n;if(!e)return i;if(!e.length)return i._root=Fw(e),i;for(t=[{source:e,target:i._root=new Array(2)}];e=t.pop();)for(var r=0;r<2;++r)(n=e.source[r])&&(n.length?t.push({source:n,target:e.target[r]=new Array(2)}):e.target[r]=Fw(n));return i};zr.add=T4;zr.addAll=M4;zr.cover=E4;zr.data=A4;zr.extent=w4;zr.find=R4;zr.remove=C4;zr.removeAll=N4;zr.root=D4;zr.size=L4;zr.visit=P4;zr.visitAfter=U4;zr.x=B4;function F4(i){const e=+this._x.call(null,i),t=+this._y.call(null,i);return M2(this.cover(e,t),e,t,i)}function M2(i,e,t,n){if(isNaN(e)||isNaN(t))return i;var r,s=i._root,o={data:n},u=i._x0,c=i._y0,h=i._x1,d=i._y1,p,g,_,v,S,b,x,M;if(!s)return i._root=o,i;for(;s.length;)if((S=e>=(p=(u+h)/2))?u=p:h=p,(b=t>=(g=(c+d)/2))?c=g:d=g,r=s,!(s=s[x=b<<1|S]))return r[x]=o,i;if(_=+i._x.call(null,s.data),v=+i._y.call(null,s.data),e===_&&t===v)return o.next=s,r?r[x]=o:i._root=o,i;do r=r?r[x]=new Array(4):i._root=new Array(4),(S=e>=(p=(u+h)/2))?u=p:h=p,(b=t>=(g=(c+d)/2))?c=g:d=g;while((x=b<<1|S)===(M=(v>=g)<<1|_>=p));return r[M]=s,r[x]=o,i}function I4(i){var e,t,n=i.length,r,s,o=new Array(n),u=new Array(n),c=1/0,h=1/0,d=-1/0,p=-1/0;for(t=0;t<n;++t)isNaN(r=+this._x.call(null,e=i[t]))||isNaN(s=+this._y.call(null,e))||(o[t]=r,u[t]=s,r<c&&(c=r),r>d&&(d=r),s<h&&(h=s),s>p&&(p=s));if(c>d||h>p)return this;for(this.cover(c,h).cover(d,p),t=0;t<n;++t)M2(this,o[t],u[t],i[t]);return this}function z4(i,e){if(isNaN(i=+i)||isNaN(e=+e))return this;var t=this._x0,n=this._y0,r=this._x1,s=this._y1;if(isNaN(t))r=(t=Math.floor(i))+1,s=(n=Math.floor(e))+1;else{for(var o=r-t||1,u=this._root,c,h;t>i||i>=r||n>e||e>=s;)switch(h=(e<n)<<1|i<t,c=new Array(4),c[h]=u,u=c,o*=2,h){case 0:r=t+o,s=n+o;break;case 1:t=r-o,s=n+o;break;case 2:r=t+o,n=s-o;break;case 3:t=r-o,n=s-o;break}this._root&&this._root.length&&(this._root=u)}return this._x0=t,this._y0=n,this._x1=r,this._y1=s,this}function k4(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function G4(i){return arguments.length?this.cover(+i[0][0],+i[0][1]).cover(+i[1][0],+i[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function gr(i,e,t,n,r){this.node=i,this.x0=e,this.y0=t,this.x1=n,this.y1=r}function V4(i,e,t){var n,r=this._x0,s=this._y0,o,u,c,h,d=this._x1,p=this._y1,g=[],_=this._root,v,S;for(_&&g.push(new gr(_,r,s,d,p)),t==null?t=1/0:(r=i-t,s=e-t,d=i+t,p=e+t,t*=t);v=g.pop();)if(!(!(_=v.node)||(o=v.x0)>d||(u=v.y0)>p||(c=v.x1)<r||(h=v.y1)<s))if(_.length){var b=(o+c)/2,x=(u+h)/2;g.push(new gr(_[3],b,x,c,h),new gr(_[2],o,x,b,h),new gr(_[1],b,u,c,x),new gr(_[0],o,u,b,x)),(S=(e>=x)<<1|i>=b)&&(v=g[g.length-1],g[g.length-1]=g[g.length-1-S],g[g.length-1-S]=v)}else{var M=i-+this._x.call(null,_.data),E=e-+this._y.call(null,_.data),w=M*M+E*E;if(w<t){var D=Math.sqrt(t=w);r=i-D,s=e-D,d=i+D,p=e+D,n=_.data}}return n}function H4(i){if(isNaN(d=+this._x.call(null,i))||isNaN(p=+this._y.call(null,i)))return this;var e,t=this._root,n,r,s,o=this._x0,u=this._y0,c=this._x1,h=this._y1,d,p,g,_,v,S,b,x;if(!t)return this;if(t.length)for(;;){if((v=d>=(g=(o+c)/2))?o=g:c=g,(S=p>=(_=(u+h)/2))?u=_:h=_,e=t,!(t=t[b=S<<1|v]))return this;if(!t.length)break;(e[b+1&3]||e[b+2&3]||e[b+3&3])&&(n=e,x=b)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[b]=s:delete e[b],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[x]=t:this._root=t),this):(this._root=s,this)}function j4(i){for(var e=0,t=i.length;e<t;++e)this.remove(i[e]);return this}function W4(){return this._root}function $4(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function q4(i){var e=[],t,n=this._root,r,s,o,u,c;for(n&&e.push(new gr(n,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!i(n=t.node,s=t.x0,o=t.y0,u=t.x1,c=t.y1)&&n.length){var h=(s+u)/2,d=(o+c)/2;(r=n[3])&&e.push(new gr(r,h,d,u,c)),(r=n[2])&&e.push(new gr(r,s,d,h,c)),(r=n[1])&&e.push(new gr(r,h,o,u,d)),(r=n[0])&&e.push(new gr(r,s,o,h,d))}return this}function X4(i){var e=[],t=[],n;for(this._root&&e.push(new gr(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var r=n.node;if(r.length){var s,o=n.x0,u=n.y0,c=n.x1,h=n.y1,d=(o+c)/2,p=(u+h)/2;(s=r[0])&&e.push(new gr(s,o,u,d,p)),(s=r[1])&&e.push(new gr(s,d,u,c,p)),(s=r[2])&&e.push(new gr(s,o,p,d,h)),(s=r[3])&&e.push(new gr(s,d,p,c,h))}t.push(n)}for(;n=t.pop();)i(n.node,n.x0,n.y0,n.x1,n.y1);return this}function Y4(i){return i[0]}function K4(i){return arguments.length?(this._x=i,this):this._x}function Z4(i){return i[1]}function Q4(i){return arguments.length?(this._y=i,this):this._y}function E2(i,e,t){var n=new lT(e??Y4,t??Z4,NaN,NaN,NaN,NaN);return i==null?n:n.addAll(i)}function lT(i,e,t,n,r,s){this._x=i,this._y=e,this._x0=t,this._y0=n,this._x1=r,this._y1=s,this._root=void 0}function Iw(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var Sr=E2.prototype=lT.prototype;Sr.copy=function(){var i=new lT(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,n;if(!e)return i;if(!e.length)return i._root=Iw(e),i;for(t=[{source:e,target:i._root=new Array(4)}];e=t.pop();)for(var r=0;r<4;++r)(n=e.source[r])&&(n.length?t.push({source:n,target:e.target[r]=new Array(4)}):e.target[r]=Iw(n));return i};Sr.add=F4;Sr.addAll=I4;Sr.cover=z4;Sr.data=k4;Sr.extent=G4;Sr.find=V4;Sr.remove=H4;Sr.removeAll=j4;Sr.root=W4;Sr.size=$4;Sr.visit=q4;Sr.visitAfter=X4;Sr.x=K4;Sr.y=Q4;function J4(i){const e=+this._x.call(null,i),t=+this._y.call(null,i),n=+this._z.call(null,i);return A2(this.cover(e,t,n),e,t,n,i)}function A2(i,e,t,n,r){if(isNaN(e)||isNaN(t)||isNaN(n))return i;var s,o=i._root,u={data:r},c=i._x0,h=i._y0,d=i._z0,p=i._x1,g=i._y1,_=i._z1,v,S,b,x,M,E,w,D,C,N,A;if(!o)return i._root=u,i;for(;o.length;)if((w=e>=(v=(c+p)/2))?c=v:p=v,(D=t>=(S=(h+g)/2))?h=S:g=S,(C=n>=(b=(d+_)/2))?d=b:_=b,s=o,!(o=o[N=C<<2|D<<1|w]))return s[N]=u,i;if(x=+i._x.call(null,o.data),M=+i._y.call(null,o.data),E=+i._z.call(null,o.data),e===x&&t===M&&n===E)return u.next=o,s?s[N]=u:i._root=u,i;do s=s?s[N]=new Array(8):i._root=new Array(8),(w=e>=(v=(c+p)/2))?c=v:p=v,(D=t>=(S=(h+g)/2))?h=S:g=S,(C=n>=(b=(d+_)/2))?d=b:_=b;while((N=C<<2|D<<1|w)===(A=(E>=b)<<2|(M>=S)<<1|x>=v));return s[A]=o,s[N]=u,i}function eV(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e),n=new Float64Array(e),r=new Float64Array(e);let s=1/0,o=1/0,u=1/0,c=-1/0,h=-1/0,d=-1/0;for(let p=0,g,_,v,S;p<e;++p)isNaN(_=+this._x.call(null,g=i[p]))||isNaN(v=+this._y.call(null,g))||isNaN(S=+this._z.call(null,g))||(t[p]=_,n[p]=v,r[p]=S,_<s&&(s=_),_>c&&(c=_),v<o&&(o=v),v>h&&(h=v),S<u&&(u=S),S>d&&(d=S));if(s>c||o>h||u>d)return this;this.cover(s,o,u).cover(c,h,d);for(let p=0;p<e;++p)A2(this,t[p],n[p],r[p],i[p]);return this}function tV(i,e,t){if(isNaN(i=+i)||isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,s=this._z0,o=this._x1,u=this._y1,c=this._z1;if(isNaN(n))o=(n=Math.floor(i))+1,u=(r=Math.floor(e))+1,c=(s=Math.floor(t))+1;else{for(var h=o-n||1,d=this._root,p,g;n>i||i>=o||r>e||e>=u||s>t||t>=c;)switch(g=(t<s)<<2|(e<r)<<1|i<n,p=new Array(8),p[g]=d,d=p,h*=2,g){case 0:o=n+h,u=r+h,c=s+h;break;case 1:n=o-h,u=r+h,c=s+h;break;case 2:o=n+h,r=u-h,c=s+h;break;case 3:n=o-h,r=u-h,c=s+h;break;case 4:o=n+h,u=r+h,s=c-h;break;case 5:n=o-h,u=r+h,s=c-h;break;case 6:o=n+h,r=u-h,s=c-h;break;case 7:n=o-h,r=u-h,s=c-h;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=r,this._z0=s,this._x1=o,this._y1=u,this._z1=c,this}function nV(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function iV(i){return arguments.length?this.cover(+i[0][0],+i[0][1],+i[0][2]).cover(+i[1][0],+i[1][1],+i[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function Bn(i,e,t,n,r,s,o){this.node=i,this.x0=e,this.y0=t,this.z0=n,this.x1=r,this.y1=s,this.z1=o}function rV(i,e,t,n){var r,s=this._x0,o=this._y0,u=this._z0,c,h,d,p,g,_,v=this._x1,S=this._y1,b=this._z1,x=[],M=this._root,E,w;for(M&&x.push(new Bn(M,s,o,u,v,S,b)),n==null?n=1/0:(s=i-n,o=e-n,u=t-n,v=i+n,S=e+n,b=t+n,n*=n);E=x.pop();)if(!(!(M=E.node)||(c=E.x0)>v||(h=E.y0)>S||(d=E.z0)>b||(p=E.x1)<s||(g=E.y1)<o||(_=E.z1)<u))if(M.length){var D=(c+p)/2,C=(h+g)/2,N=(d+_)/2;x.push(new Bn(M[7],D,C,N,p,g,_),new Bn(M[6],c,C,N,D,g,_),new Bn(M[5],D,h,N,p,C,_),new Bn(M[4],c,h,N,D,C,_),new Bn(M[3],D,C,d,p,g,N),new Bn(M[2],c,C,d,D,g,N),new Bn(M[1],D,h,d,p,C,N),new Bn(M[0],c,h,d,D,C,N)),(w=(t>=N)<<2|(e>=C)<<1|i>=D)&&(E=x[x.length-1],x[x.length-1]=x[x.length-1-w],x[x.length-1-w]=E)}else{var A=i-+this._x.call(null,M.data),L=e-+this._y.call(null,M.data),j=t-+this._z.call(null,M.data),z=A*A+L*L+j*j;if(z<n){var H=Math.sqrt(n=z);s=i-H,o=e-H,u=t-H,v=i+H,S=e+H,b=t+H,r=M.data}}return r}const sV=(i,e,t,n,r,s)=>Math.sqrt((i-n)**2+(e-r)**2+(t-s)**2);function aV(i,e,t,n){const r=[],s=i-n,o=e-n,u=t-n,c=i+n,h=e+n,d=t+n;return this.visit((p,g,_,v,S,b,x)=>{if(!p.length)do{const M=p.data;sV(i,e,t,this._x(M),this._y(M),this._z(M))<=n&&r.push(M)}while(p=p.next);return g>c||_>h||v>d||S<s||b<o||x<u}),r}function oV(i){if(isNaN(g=+this._x.call(null,i))||isNaN(_=+this._y.call(null,i))||isNaN(v=+this._z.call(null,i)))return this;var e,t=this._root,n,r,s,o=this._x0,u=this._y0,c=this._z0,h=this._x1,d=this._y1,p=this._z1,g,_,v,S,b,x,M,E,w,D,C;if(!t)return this;if(t.length)for(;;){if((M=g>=(S=(o+h)/2))?o=S:h=S,(E=_>=(b=(u+d)/2))?u=b:d=b,(w=v>=(x=(c+p)/2))?c=x:p=x,e=t,!(t=t[D=w<<2|E<<1|M]))return this;if(!t.length)break;(e[D+1&7]||e[D+2&7]||e[D+3&7]||e[D+4&7]||e[D+5&7]||e[D+6&7]||e[D+7&7])&&(n=e,C=D)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[D]=s:delete e[D],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[C]=t:this._root=t),this):(this._root=s,this)}function lV(i){for(var e=0,t=i.length;e<t;++e)this.remove(i[e]);return this}function uV(){return this._root}function cV(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function hV(i){var e=[],t,n=this._root,r,s,o,u,c,h,d;for(n&&e.push(new Bn(n,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=e.pop();)if(!i(n=t.node,s=t.x0,o=t.y0,u=t.z0,c=t.x1,h=t.y1,d=t.z1)&&n.length){var p=(s+c)/2,g=(o+h)/2,_=(u+d)/2;(r=n[7])&&e.push(new Bn(r,p,g,_,c,h,d)),(r=n[6])&&e.push(new Bn(r,s,g,_,p,h,d)),(r=n[5])&&e.push(new Bn(r,p,o,_,c,g,d)),(r=n[4])&&e.push(new Bn(r,s,o,_,p,g,d)),(r=n[3])&&e.push(new Bn(r,p,g,u,c,h,_)),(r=n[2])&&e.push(new Bn(r,s,g,u,p,h,_)),(r=n[1])&&e.push(new Bn(r,p,o,u,c,g,_)),(r=n[0])&&e.push(new Bn(r,s,o,u,p,g,_))}return this}function fV(i){var e=[],t=[],n;for(this._root&&e.push(new Bn(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=e.pop();){var r=n.node;if(r.length){var s,o=n.x0,u=n.y0,c=n.z0,h=n.x1,d=n.y1,p=n.z1,g=(o+h)/2,_=(u+d)/2,v=(c+p)/2;(s=r[0])&&e.push(new Bn(s,o,u,c,g,_,v)),(s=r[1])&&e.push(new Bn(s,g,u,c,h,_,v)),(s=r[2])&&e.push(new Bn(s,o,_,c,g,d,v)),(s=r[3])&&e.push(new Bn(s,g,_,c,h,d,v)),(s=r[4])&&e.push(new Bn(s,o,u,v,g,_,p)),(s=r[5])&&e.push(new Bn(s,g,u,v,h,_,p)),(s=r[6])&&e.push(new Bn(s,o,_,v,g,d,p)),(s=r[7])&&e.push(new Bn(s,g,_,v,h,d,p))}t.push(n)}for(;n=t.pop();)i(n.node,n.x0,n.y0,n.z0,n.x1,n.y1,n.z1);return this}function dV(i){return i[0]}function pV(i){return arguments.length?(this._x=i,this):this._x}function mV(i){return i[1]}function gV(i){return arguments.length?(this._y=i,this):this._y}function _V(i){return i[2]}function vV(i){return arguments.length?(this._z=i,this):this._z}function w2(i,e,t,n){var r=new uT(e??dV,t??mV,n??_V,NaN,NaN,NaN,NaN,NaN,NaN);return i==null?r:r.addAll(i)}function uT(i,e,t,n,r,s,o,u,c){this._x=i,this._y=e,this._z=t,this._x0=n,this._y0=r,this._z0=s,this._x1=o,this._y1=u,this._z1=c,this._root=void 0}function zw(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var Yi=w2.prototype=uT.prototype;Yi.copy=function(){var i=new uT(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,t,n;if(!e)return i;if(!e.length)return i._root=zw(e),i;for(t=[{source:e,target:i._root=new Array(8)}];e=t.pop();)for(var r=0;r<8;++r)(n=e.source[r])&&(n.length?t.push({source:n,target:e.target[r]=new Array(8)}):e.target[r]=zw(n));return i};Yi.add=J4;Yi.addAll=eV;Yi.cover=tV;Yi.data=nV;Yi.extent=iV;Yi.find=rV;Yi.findAllWithinRadius=aV;Yi.remove=oV;Yi.removeAll=lV;Yi.root=uV;Yi.size=cV;Yi.visit=hV;Yi.visitAfter=fV;Yi.x=pV;Yi.y=gV;Yi.z=vV;function fo(i){return function(){return i}}function so(i){return(i()-.5)*1e-6}function yV(i){return i.index}function kw(i,e){var t=i.get(e);if(!t)throw new Error("node not found: "+e);return t}function xV(i){var e=yV,t=g,n,r=fo(30),s,o,u,c,h,d,p=1;i==null&&(i=[]);function g(x){return 1/Math.min(c[x.source.index],c[x.target.index])}function _(x){for(var M=0,E=i.length;M<p;++M)for(var w=0,D,C,N,A=0,L=0,j=0,z,H;w<E;++w)D=i[w],C=D.source,N=D.target,A=N.x+N.vx-C.x-C.vx||so(d),u>1&&(L=N.y+N.vy-C.y-C.vy||so(d)),u>2&&(j=N.z+N.vz-C.z-C.vz||so(d)),z=Math.sqrt(A*A+L*L+j*j),z=(z-s[w])/z*x*n[w],A*=z,L*=z,j*=z,N.vx-=A*(H=h[w]),u>1&&(N.vy-=L*H),u>2&&(N.vz-=j*H),C.vx+=A*(H=1-H),u>1&&(C.vy+=L*H),u>2&&(C.vz+=j*H)}function v(){if(o){var x,M=o.length,E=i.length,w=new Map(o.map((C,N)=>[e(C,N,o),C])),D;for(x=0,c=new Array(M);x<E;++x)D=i[x],D.index=x,typeof D.source!="object"&&(D.source=kw(w,D.source)),typeof D.target!="object"&&(D.target=kw(w,D.target)),c[D.source.index]=(c[D.source.index]||0)+1,c[D.target.index]=(c[D.target.index]||0)+1;for(x=0,h=new Array(E);x<E;++x)D=i[x],h[x]=c[D.source.index]/(c[D.source.index]+c[D.target.index]);n=new Array(E),S(),s=new Array(E),b()}}function S(){if(o)for(var x=0,M=i.length;x<M;++x)n[x]=+t(i[x],x,i)}function b(){if(o)for(var x=0,M=i.length;x<M;++x)s[x]=+r(i[x],x,i)}return _.initialize=function(x,...M){o=x,d=M.find(E=>typeof E=="function")||Math.random,u=M.find(E=>[1,2,3].includes(E))||2,v()},_.links=function(x){return arguments.length?(i=x,v(),_):i},_.id=function(x){return arguments.length?(e=x,_):e},_.iterations=function(x){return arguments.length?(p=+x,_):p},_.strength=function(x){return arguments.length?(t=typeof x=="function"?x:fo(+x),S(),_):t},_.distance=function(x){return arguments.length?(r=typeof x=="function"?x:fo(+x),b(),_):r},_}var bV={value:()=>{}};function R2(){for(var i=0,e=arguments.length,t={},n;i<e;++i){if(!(n=arguments[i]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new a_(t)}function a_(i){this._=i}function SV(i,e){return i.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");if(r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}a_.prototype=R2.prototype={constructor:a_,on:function(i,e){var t=this._,n=SV(i+"",t),r,s=-1,o=n.length;if(arguments.length<2){for(;++s<o;)if((r=(i=n[s]).type)&&(r=TV(t[r],i.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(r=(i=n[s]).type)t[r]=Gw(t[r],i.name,e);else if(e==null)for(r in t)t[r]=Gw(t[r],i.name,null);return this},copy:function(){var i={},e=this._;for(var t in e)i[t]=e[t].slice();return new a_(i)},call:function(i,e){if((r=arguments.length-2)>0)for(var t=new Array(r),n=0,r,s;n<r;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(s=this._[i],n=0,r=s.length;n<r;++n)s[n].value.apply(e,t)},apply:function(i,e,t){if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(var n=this._[i],r=0,s=n.length;r<s;++r)n[r].value.apply(e,t)}};function TV(i,e){for(var t=0,n=i.length,r;t<n;++t)if((r=i[t]).name===e)return r.value}function Gw(i,e,t){for(var n=0,r=i.length;n<r;++n)if(i[n].name===e){i[n]=bV,i=i.slice(0,n).concat(i.slice(n+1));break}return t!=null&&i.push({name:e,value:t}),i}var zh=0,Rd=0,ud=0,C2=1e3,x_,Cd,b_=0,Du=0,Q_=0,fp=typeof performance=="object"&&performance.now?performance:Date,N2=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(i){setTimeout(i,17)};function D2(){return Du||(N2(MV),Du=fp.now()+Q_)}function MV(){Du=0}function Pb(){this._call=this._time=this._next=null}Pb.prototype=L2.prototype={constructor:Pb,restart:function(i,e,t){if(typeof i!="function")throw new TypeError("callback is not a function");t=(t==null?D2():+t)+(e==null?0:+e),!this._next&&Cd!==this&&(Cd?Cd._next=this:x_=this,Cd=this),this._call=i,this._time=t,Ub()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ub())}};function L2(i,e,t){var n=new Pb;return n.restart(i,e,t),n}function EV(){D2(),++zh;for(var i=x_,e;i;)(e=Du-i._time)>=0&&i._call.call(void 0,e),i=i._next;--zh}function Vw(){Du=(b_=fp.now())+Q_,zh=Rd=0;try{EV()}finally{zh=0,wV(),Du=0}}function AV(){var i=fp.now(),e=i-b_;e>C2&&(Q_-=e,b_=i)}function wV(){for(var i,e=x_,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),i=e,e=e._next):(t=e._next,e._next=null,e=i?i._next=t:x_=t);Cd=i,Ub(n)}function Ub(i){if(!zh){Rd&&(Rd=clearTimeout(Rd));var e=i-Du;e>24?(i<1/0&&(Rd=setTimeout(Vw,i-fp.now()-Q_)),ud&&(ud=clearInterval(ud))):(ud||(b_=fp.now(),ud=setInterval(AV,C2)),zh=1,N2(Vw))}}const RV=1664525,CV=1013904223,Hw=4294967296;function NV(){let i=1;return()=>(i=(RV*i+CV)%Hw)/Hw}var jw=3;function cx(i){return i.x}function Ww(i){return i.y}function DV(i){return i.z}var LV=10,PV=Math.PI*(3-Math.sqrt(5)),UV=Math.PI*20/(9+Math.sqrt(221));function OV(i,e){e=e||2;var t=Math.min(jw,Math.max(1,Math.round(e))),n,r=1,s=.001,o=1-Math.pow(s,1/300),u=0,c=.6,h=new Map,d=L2(_),p=R2("tick","end"),g=NV();i==null&&(i=[]);function _(){v(),p.call("tick",n),r<s&&(d.stop(),p.call("end",n))}function v(x){var M,E=i.length,w;x===void 0&&(x=1);for(var D=0;D<x;++D)for(r+=(u-r)*o,h.forEach(function(C){C(r)}),M=0;M<E;++M)w=i[M],w.fx==null?w.x+=w.vx*=c:(w.x=w.fx,w.vx=0),t>1&&(w.fy==null?w.y+=w.vy*=c:(w.y=w.fy,w.vy=0)),t>2&&(w.fz==null?w.z+=w.vz*=c:(w.z=w.fz,w.vz=0));return n}function S(){for(var x=0,M=i.length,E;x<M;++x){if(E=i[x],E.index=x,E.fx!=null&&(E.x=E.fx),E.fy!=null&&(E.y=E.fy),E.fz!=null&&(E.z=E.fz),isNaN(E.x)||t>1&&isNaN(E.y)||t>2&&isNaN(E.z)){var w=LV*(t>2?Math.cbrt(.5+x):t>1?Math.sqrt(.5+x):x),D=x*PV,C=x*UV;t===1?E.x=w:t===2?(E.x=w*Math.cos(D),E.y=w*Math.sin(D)):(E.x=w*Math.sin(D)*Math.cos(C),E.y=w*Math.cos(D),E.z=w*Math.sin(D)*Math.sin(C))}(isNaN(E.vx)||t>1&&isNaN(E.vy)||t>2&&isNaN(E.vz))&&(E.vx=0,t>1&&(E.vy=0),t>2&&(E.vz=0))}}function b(x){return x.initialize&&x.initialize(i,g,t),x}return S(),n={tick:v,restart:function(){return d.restart(_),n},stop:function(){return d.stop(),n},numDimensions:function(x){return arguments.length?(t=Math.min(jw,Math.max(1,Math.round(x))),h.forEach(b),n):t},nodes:function(x){return arguments.length?(i=x,S(),h.forEach(b),n):i},alpha:function(x){return arguments.length?(r=+x,n):r},alphaMin:function(x){return arguments.length?(s=+x,n):s},alphaDecay:function(x){return arguments.length?(o=+x,n):+o},alphaTarget:function(x){return arguments.length?(u=+x,n):u},velocityDecay:function(x){return arguments.length?(c=1-x,n):1-c},randomSource:function(x){return arguments.length?(g=x,h.forEach(b),n):g},force:function(x,M){return arguments.length>1?(M==null?h.delete(x):h.set(x,b(M)),n):h.get(x)},find:function(){var x=Array.prototype.slice.call(arguments),M=x.shift()||0,E=(t>1?x.shift():null)||0,w=(t>2?x.shift():null)||0,D=x.shift()||1/0,C=0,N=i.length,A,L,j,z,H,K;for(D*=D,C=0;C<N;++C)H=i[C],A=M-H.x,L=E-(H.y||0),j=w-(H.z||0),z=A*A+L*L+j*j,z<D&&(K=H,D=z);return K},on:function(x,M){return arguments.length>1?(p.on(x,M),n):p.on(x)}}}function BV(){var i,e,t,n,r,s=fo(-30),o,u=1,c=1/0,h=.81;function d(v){var S,b=i.length,x=(e===1?T2(i,cx):e===2?E2(i,cx,Ww):e===3?w2(i,cx,Ww,DV):null).visitAfter(g);for(r=v,S=0;S<b;++S)t=i[S],x.visit(_)}function p(){if(i){var v,S=i.length,b;for(o=new Array(S),v=0;v<S;++v)b=i[v],o[b.index]=+s(b,v,i)}}function g(v){var S=0,b,x,M=0,E,w,D,C,N=v.length;if(N){for(E=w=D=C=0;C<N;++C)(b=v[C])&&(x=Math.abs(b.value))&&(S+=b.value,M+=x,E+=x*(b.x||0),w+=x*(b.y||0),D+=x*(b.z||0));S*=Math.sqrt(4/N),v.x=E/M,e>1&&(v.y=w/M),e>2&&(v.z=D/M)}else{b=v,b.x=b.data.x,e>1&&(b.y=b.data.y),e>2&&(b.z=b.data.z);do S+=o[b.data.index];while(b=b.next)}v.value=S}function _(v,S,b,x,M){if(!v.value)return!0;var E=[b,x,M][e-1],w=v.x-t.x,D=e>1?v.y-t.y:0,C=e>2?v.z-t.z:0,N=E-S,A=w*w+D*D+C*C;if(N*N/h<A)return A<c&&(w===0&&(w=so(n),A+=w*w),e>1&&D===0&&(D=so(n),A+=D*D),e>2&&C===0&&(C=so(n),A+=C*C),A<u&&(A=Math.sqrt(u*A)),t.vx+=w*v.value*r/A,e>1&&(t.vy+=D*v.value*r/A),e>2&&(t.vz+=C*v.value*r/A)),!0;if(v.length||A>=c)return;(v.data!==t||v.next)&&(w===0&&(w=so(n),A+=w*w),e>1&&D===0&&(D=so(n),A+=D*D),e>2&&C===0&&(C=so(n),A+=C*C),A<u&&(A=Math.sqrt(u*A)));do v.data!==t&&(N=o[v.data.index]*r/A,t.vx+=w*N,e>1&&(t.vy+=D*N),e>2&&(t.vz+=C*N));while(v=v.next)}return d.initialize=function(v,...S){i=v,n=S.find(b=>typeof b=="function")||Math.random,e=S.find(b=>[1,2,3].includes(b))||2,p()},d.strength=function(v){return arguments.length?(s=typeof v=="function"?v:fo(+v),p(),d):s},d.distanceMin=function(v){return arguments.length?(u=v*v,d):Math.sqrt(u)},d.distanceMax=function(v){return arguments.length?(c=v*v,d):Math.sqrt(c)},d.theta=function(v){return arguments.length?(h=v*v,d):Math.sqrt(h)},d}function FV(i,e,t,n){var r,s,o=fo(.1),u,c;typeof i!="function"&&(i=fo(+i)),e==null&&(e=0),t==null&&(t=0),n==null&&(n=0);function h(p){for(var g=0,_=r.length;g<_;++g){var v=r[g],S=v.x-e||1e-6,b=(v.y||0)-t||1e-6,x=(v.z||0)-n||1e-6,M=Math.sqrt(S*S+b*b+x*x),E=(c[g]-M)*u[g]*p/M;v.vx+=S*E,s>1&&(v.vy+=b*E),s>2&&(v.vz+=x*E)}}function d(){if(r){var p,g=r.length;for(u=new Array(g),c=new Array(g),p=0;p<g;++p)c[p]=+i(r[p],p,r),u[p]=isNaN(c[p])?0:+o(r[p],p,r)}}return h.initialize=function(p,...g){r=p,s=g.find(_=>[1,2,3].includes(_))||2,d()},h.strength=function(p){return arguments.length?(o=typeof p=="function"?p:fo(+p),d(),h):o},h.radius=function(p){return arguments.length?(i=typeof p=="function"?p:fo(+p),d(),h):i},h.x=function(p){return arguments.length?(e=+p,h):e},h.y=function(p){return arguments.length?(t=+p,h):t},h.z=function(p){return arguments.length?(n=+p,h):n},h}function IV(i){kV(i);const e=zV(i);return i.on=e.on,i.off=e.off,i.fire=e.fire,i}function zV(i){let e=Object.create(null);return{on:function(t,n,r){if(typeof n!="function")throw new Error("callback is expected to be a function");let s=e[t];return s||(s=e[t]=[]),s.push({callback:n,ctx:r}),i},off:function(t,n){if(typeof t>"u")return e=Object.create(null),i;if(e[t])if(typeof n!="function")delete e[t];else{const o=e[t];for(let u=0;u<o.length;++u)o[u].callback===n&&o.splice(u,1)}return i},fire:function(t){const n=e[t];if(!n)return i;let r;arguments.length>1&&(r=Array.prototype.slice.call(arguments,1));for(let s=0;s<n.length;++s){const o=n[s];o.callback.apply(o.ctx,r)}return i}}}function kV(i){if(!i)throw new Error("Eventify cannot use falsy object as events subject");const e=["on","fire","off"];for(let t=0;t<e.length;++t)if(i.hasOwnProperty(e[t]))throw new Error("Subject cannot be eventified, since it already has property '"+e[t]+"'")}function GV(i){if(i=i||{},"uniqueLinkId"in i&&(console.warn("ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\nUse `multigraph` option instead\n",`
`,`Note: there is also change in default behavior: From now on each graph
is considered to be not a multigraph by default (each edge is unique).`),i.multigraph=i.uniqueLinkId),i.multigraph===void 0&&(i.multigraph=!1),typeof Map!="function")throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph");var e=new Map,t=new Map,n={},r=0,s=i.multigraph?w:E,o=[],u=F,c=F,h=F,d=F,p={version:20,addNode:S,addLink:M,removeLink:A,removeNode:x,getNode:b,getNodeCount:D,getLinkCount:C,getEdgeCount:C,getLinksCount:C,getNodesCount:D,getLinks:N,forEachNode:Te,forEachLinkedNode:te,forEachLink:K,beginUpdate:h,endUpdate:d,clear:H,hasLink:j,hasNode:b,getLink:j,getLinkById:z};return IV(p),g(),p;function g(){var O=p.on;p.on=W;function W(){return p.beginUpdate=h=Y,p.endUpdate=d=se,u=_,c=v,p.on=O,O.apply(p,arguments)}}function _(O,W){o.push({link:O,changeType:W})}function v(O,W){o.push({node:O,changeType:W})}function S(O,W){if(O===void 0)throw new Error("Invalid node identifier");h();var ce=b(O);return ce?(ce.data=W,c(ce,"update")):(ce=new VV(O,W),c(ce,"add")),e.set(O,ce),d(),ce}function b(O){return e.get(O)}function x(O){var W=b(O);if(!W)return!1;h();var ce=W.links;return ce&&(ce.forEach(L),W.links=null),e.delete(O),c(W,"remove"),d(),!0}function M(O,W,ce){h();var Le=b(O)||S(O),ee=b(W)||S(W),$=s(O,W,ce),ue=t.has($.id);return t.set($.id,$),$w(Le,$),O!==W&&$w(ee,$),u($,ue?"update":"add"),d(),$}function E(O,W,ce){var Le=_g(O,W),ee=t.get(Le);return ee?(ee.data=ce,ee):new qw(O,W,ce,Le)}function w(O,W,ce){var Le=_g(O,W),ee=n.hasOwnProperty(Le);if(ee||j(O,W)){ee||(n[Le]=0);var $="@"+ ++n[Le];Le=_g(O+$,W+$)}return new qw(O,W,ce,Le)}function D(){return e.size}function C(){return t.size}function N(O){var W=b(O);return W?W.links:null}function A(O,W){return W!==void 0&&(O=j(O,W)),L(O)}function L(O){if(!O||!t.get(O.id))return!1;h(),t.delete(O.id);var W=b(O.fromId),ce=b(O.toId);return W&&W.links.delete(O),ce&&ce.links.delete(O),u(O,"remove"),d(),!0}function j(O,W){if(!(O===void 0||W===void 0))return t.get(_g(O,W))}function z(O){if(O!==void 0)return t.get(O)}function H(){h(),Te(function(O){x(O.id)}),d()}function K(O){if(typeof O=="function")for(var W=t.values(),ce=W.next();!ce.done;){if(O(ce.value))return!0;ce=W.next()}}function te(O,W,ce){var Le=b(O);if(Le&&Le.links&&typeof W=="function")return ce?I(Le.links,O,W):Z(Le.links,O,W)}function Z(O,W,ce){for(var Le,ee=O.values(),$=ee.next();!$.done;){var ue=$.value,Ee=ue.fromId===W?ue.toId:ue.fromId;if(Le=ce(e.get(Ee),ue),Le)return!0;$=ee.next()}}function I(O,W,ce){for(var Le,ee=O.values(),$=ee.next();!$.done;){var ue=$.value;if(ue.fromId===W&&(Le=ce(e.get(ue.toId),ue),Le))return!0;$=ee.next()}}function F(){}function Y(){r+=1}function se(){r-=1,r===0&&o.length>0&&(p.fire("changed",o),o.length=0)}function Te(O){if(typeof O!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+O);for(var W=e.values(),ce=W.next();!ce.done;){if(O(ce.value))return!0;ce=W.next()}}}function VV(i,e){this.id=i,this.links=null,this.data=e}function $w(i,e){i.links?i.links.add(e):i.links=new Set([e])}function qw(i,e,t,n){this.fromId=i,this.toId=e,this.data=t,this.id=n}function _g(i,e){return i.toString()+"👉 "+e.toString()}var vg={exports:{}},kc={exports:{}},hx,Xw;function P2(){return Xw||(Xw=1,hx=function(e){return e===0?"x":e===1?"y":e===2?"z":"c"+(e+1)}),hx}var fx,Yw;function Jh(){if(Yw)return fx;Yw=1;const i=P2();return fx=function(t){return n;function n(r,s){let o=s&&s.indent||0,u=s&&s.join!==void 0?s.join:`
`,c=Array(o+1).join(" "),h=[];for(let d=0;d<t;++d){let p=i(d),g=d===0?"":c;h.push(g+r.replace(/{var}/g,p))}return h.join(u)}},fx}var Kw;function HV(){if(Kw)return kc.exports;Kw=1;const i=Jh();kc.exports=e,kc.exports.generateCreateBodyFunctionBody=t,kc.exports.getVectorCode=r,kc.exports.getBodyCode=n;function e(s,o){let u=t(s,o),{Body:c}=new Function(u)();return c}function t(s,o){return`
${r(s,o)}
${n(s)}
return {Body: Body, Vector: Vector};
`}function n(s){let o=i(s),u=o("{var}",{join:", "});return`
function Body(${u}) {
  this.isPinned = false;
  this.pos = new Vector(${u});
  this.force = new Vector();
  this.velocity = new Vector();
  this.mass = 1;

  this.springCount = 0;
  this.springLength = 0;
}

Body.prototype.reset = function() {
  this.force.reset();
  this.springCount = 0;
  this.springLength = 0;
}

Body.prototype.setPosition = function (${u}) {
  ${o("this.pos.{var} = {var} || 0;",{indent:2})}
};`}function r(s,o){let u=i(s),c="";return o&&(c=`${u(`
	   var v{var};
	Object.defineProperty(this, '{var}', {
	  set: function(v) { 
	    if (!Number.isFinite(v)) throw new Error('Cannot set non-numbers to {var}');
	    v{var} = v; 
	  },
	  get: function() { return v{var}; }
	});`)}`),`function Vector(${u("{var}",{join:", "})}) {
  ${c}
    if (typeof arguments[0] === 'object') {
      // could be another vector
      let v = arguments[0];
      ${u('if (!Number.isFinite(v.{var})) throw new Error("Expected value is not a finite number at Vector constructor ({var})");',{indent:4})}
      ${u("this.{var} = v.{var};",{indent:4})}
    } else {
      ${u('this.{var} = typeof {var} === "number" ? {var} : 0;',{indent:4})}
    }
  }
  
  Vector.prototype.reset = function () {
    ${u("this.{var} = ",{join:""})}0;
  };`}return kc.exports}var Ja={exports:{}},Zw;function jV(){if(Zw)return Ja.exports;Zw=1;const i=Jh(),e=P2();Ja.exports=t,Ja.exports.generateQuadTreeFunctionBody=n,Ja.exports.getInsertStackCode=c,Ja.exports.getQuadNodeCode=u,Ja.exports.isSamePosition=r,Ja.exports.getChildBodyCode=o,Ja.exports.setChildBodyCode=s;function t(h){let d=n(h);return new Function(d)()}function n(h){let d=i(h),p=Math.pow(2,h);return`
${c()}
${u(h)}
${r(h)}
${o(h)}
${s(h)}

function createQuadTree(options, random) {
  options = options || {};
  options.gravity = typeof options.gravity === 'number' ? options.gravity : -1;
  options.theta = typeof options.theta === 'number' ? options.theta : 0.8;

  var gravity = options.gravity;
  var updateQueue = [];
  var insertStack = new InsertStack();
  var theta = options.theta;

  var nodesCache = [];
  var currentInCache = 0;
  var root = newNode();

  return {
    insertBodies: insertBodies,

    /**
     * Gets root node if it is present
     */
    getRoot: function() {
      return root;
    },

    updateBodyForce: update,

    options: function(newOptions) {
      if (newOptions) {
        if (typeof newOptions.gravity === 'number') {
          gravity = newOptions.gravity;
        }
        if (typeof newOptions.theta === 'number') {
          theta = newOptions.theta;
        }

        return this;
      }

      return {
        gravity: gravity,
        theta: theta
      };
    }
  };

  function newNode() {
    // To avoid pressure on GC we reuse nodes.
    var node = nodesCache[currentInCache];
    if (node) {
${S("      node.")}
      node.body = null;
      node.mass = ${d("node.mass_{var} = ",{join:""})}0;
      ${d("node.min_{var} = node.max_{var} = ",{join:""})}0;
    } else {
      node = new QuadNode();
      nodesCache[currentInCache] = node;
    }

    ++currentInCache;
    return node;
  }

  function update(sourceBody) {
    var queue = updateQueue;
    var v;
    ${d("var d{var};",{indent:4})}
    var r; 
    ${d("var f{var} = 0;",{indent:4})}
    var queueLength = 1;
    var shiftIdx = 0;
    var pushIdx = 1;

    queue[0] = root;

    while (queueLength) {
      var node = queue[shiftIdx];
      var body = node.body;

      queueLength -= 1;
      shiftIdx += 1;
      var differentBody = (body !== sourceBody);
      if (body && differentBody) {
        // If the current node is a leaf node (and it is not source body),
        // calculate the force exerted by the current node on body, and add this
        // amount to body's net force.
        ${d("d{var} = body.pos.{var} - sourceBody.pos.{var};",{indent:8})}
        r = Math.sqrt(${d("d{var} * d{var}",{join:" + "})});

        if (r === 0) {
          // Poor man's protection against zero distance.
          ${d("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
          r = Math.sqrt(${d("d{var} * d{var}",{join:" + "})});
        }

        // This is standard gravitation force calculation but we divide
        // by r^3 to save two operations when normalizing force vector.
        v = gravity * body.mass * sourceBody.mass / (r * r * r);
        ${d("f{var} += v * d{var};",{indent:8})}
      } else if (differentBody) {
        // Otherwise, calculate the ratio s / r,  where s is the width of the region
        // represented by the internal node, and r is the distance between the body
        // and the node's center-of-mass
        ${d("d{var} = node.mass_{var} / node.mass - sourceBody.pos.{var};",{indent:8})}
        r = Math.sqrt(${d("d{var} * d{var}",{join:" + "})});

        if (r === 0) {
          // Sorry about code duplication. I don't want to create many functions
          // right away. Just want to see performance first.
          ${d("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
          r = Math.sqrt(${d("d{var} * d{var}",{join:" + "})});
        }
        // If s / r < θ, treat this internal node as a single body, and calculate the
        // force it exerts on sourceBody, and add this amount to sourceBody's net force.
        if ((node.max_${e(0)} - node.min_${e(0)}) / r < theta) {
          // in the if statement above we consider node's width only
          // because the region was made into square during tree creation.
          // Thus there is no difference between using width or height.
          v = gravity * node.mass * sourceBody.mass / (r * r * r);
          ${d("f{var} += v * d{var};",{indent:10})}
        } else {
          // Otherwise, run the procedure recursively on each of the current node's children.

          // I intentionally unfolded this loop, to save several CPU cycles.
${v()}
        }
      }
    }

    ${d("sourceBody.force.{var} += f{var};",{indent:4})}
  }

  function insertBodies(bodies) {
    ${d("var {var}min = Number.MAX_VALUE;",{indent:4})}
    ${d("var {var}max = Number.MIN_VALUE;",{indent:4})}
    var i = bodies.length;

    // To reduce quad tree depth we are looking for exact bounding box of all particles.
    while (i--) {
      var pos = bodies[i].pos;
      ${d("if (pos.{var} < {var}min) {var}min = pos.{var};",{indent:6})}
      ${d("if (pos.{var} > {var}max) {var}max = pos.{var};",{indent:6})}
    }

    // Makes the bounds square.
    var maxSideLength = -Infinity;
    ${d("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;",{indent:4})}

    currentInCache = 0;
    root = newNode();
    ${d("root.min_{var} = {var}min;",{indent:4})}
    ${d("root.max_{var} = {var}min + maxSideLength;",{indent:4})}

    i = bodies.length - 1;
    if (i >= 0) {
      root.body = bodies[i];
    }
    while (i--) {
      insert(bodies[i], root);
    }
  }

  function insert(newBody) {
    insertStack.reset();
    insertStack.push(root, newBody);

    while (!insertStack.isEmpty()) {
      var stackItem = insertStack.pop();
      var node = stackItem.node;
      var body = stackItem.body;

      if (!node.body) {
        // This is internal node. Update the total mass of the node and center-of-mass.
        ${d("var {var} = body.pos.{var};",{indent:8})}
        node.mass += body.mass;
        ${d("node.mass_{var} += body.mass * {var};",{indent:8})}

        // Recursively insert the body in the appropriate quadrant.
        // But first find the appropriate quadrant.
        var quadIdx = 0; // Assume we are in the 0's quad.
        ${d("var min_{var} = node.min_{var};",{indent:8})}
        ${d("var max_{var} = (min_{var} + node.max_{var}) / 2;",{indent:8})}

${_(8)}

        var child = getChild(node, quadIdx);

        if (!child) {
          // The node is internal but this quadrant is not taken. Add
          // subnode to it.
          child = newNode();
          ${d("child.min_{var} = min_{var};",{indent:10})}
          ${d("child.max_{var} = max_{var};",{indent:10})}
          child.body = body;

          setChild(node, quadIdx, child);
        } else {
          // continue searching in this quadrant.
          insertStack.push(child, body);
        }
      } else {
        // We are trying to add to the leaf node.
        // We have to convert current leaf into internal node
        // and continue adding two nodes.
        var oldBody = node.body;
        node.body = null; // internal nodes do not cary bodies

        if (isSamePosition(oldBody.pos, body.pos)) {
          // Prevent infinite subdivision by bumping one node
          // anywhere in this quadrant
          var retriesCount = 3;
          do {
            var offset = random.nextDouble();
            ${d("var d{var} = (node.max_{var} - node.min_{var}) * offset;",{indent:12})}

            ${d("oldBody.pos.{var} = node.min_{var} + d{var};",{indent:12})}
            retriesCount -= 1;
            // Make sure we don't bump it out of the box. If we do, next iteration should fix it
          } while (retriesCount > 0 && isSamePosition(oldBody.pos, body.pos));

          if (retriesCount === 0 && isSamePosition(oldBody.pos, body.pos)) {
            // This is very bad, we ran out of precision.
            // if we do not return from the method we'll get into
            // infinite loop here. So we sacrifice correctness of layout, and keep the app running
            // Next layout iteration should get larger bounding box in the first step and fix this
            return;
          }
        }
        // Next iteration should subdivide node further.
        insertStack.push(node, oldBody);
        insertStack.push(node, body);
      }
    }
  }
}
return createQuadTree;

`;function _(b){let x=[],M=Array(b+1).join(" ");for(let E=0;E<h;++E)x.push(M+`if (${e(E)} > max_${e(E)}) {`),x.push(M+`  quadIdx = quadIdx + ${Math.pow(2,E)};`),x.push(M+`  min_${e(E)} = max_${e(E)};`),x.push(M+`  max_${e(E)} = node.max_${e(E)};`),x.push(M+"}");return x.join(`
`)}function v(){let b=Array(11).join(" "),x=[];for(let M=0;M<p;++M)x.push(b+`if (node.quad${M}) {`),x.push(b+`  queue[pushIdx] = node.quad${M};`),x.push(b+"  queueLength += 1;"),x.push(b+"  pushIdx += 1;"),x.push(b+"}");return x.join(`
`)}function S(b){let x=[];for(let M=0;M<p;++M)x.push(`${b}quad${M} = null;`);return x.join(`
`)}}function r(h){let d=i(h);return`
  function isSamePosition(point1, point2) {
    ${d("var d{var} = Math.abs(point1.{var} - point2.{var});",{indent:2})}
  
    return ${d("d{var} < 1e-8",{join:" && "})};
  }  
`}function s(h){var d=Math.pow(2,h);return`
function setChild(node, idx, child) {
  ${p()}
}`;function p(){let g=[];for(let _=0;_<d;++_){let v=_===0?"  ":"  else ";g.push(`${v}if (idx === ${_}) node.quad${_} = child;`)}return g.join(`
`)}}function o(h){return`function getChild(node, idx) {
${d()}
  return null;
}`;function d(){let p=[],g=Math.pow(2,h);for(let _=0;_<g;++_)p.push(`  if (idx === ${_}) return node.quad${_};`);return p.join(`
`)}}function u(h){let d=i(h),p=Math.pow(2,h);var g=`
function QuadNode() {
  // body stored inside this node. In quad tree only leaf nodes (by construction)
  // contain bodies:
  this.body = null;

  // Child nodes are stored in quads. Each quad is presented by number:
  // 0 | 1
  // -----
  // 2 | 3
${_("  this.")}

  // Total mass of current node
  this.mass = 0;

  // Center of mass coordinates
  ${d("this.mass_{var} = 0;",{indent:2})}

  // bounding box coordinates
  ${d("this.min_{var} = 0;",{indent:2})}
  ${d("this.max_{var} = 0;",{indent:2})}
}
`;return g;function _(v){let S=[];for(let b=0;b<p;++b)S.push(`${v}quad${b} = null;`);return S.join(`
`)}}function c(){return`
/**
 * Our implementation of QuadTree is non-recursive to avoid GC hit
 * This data structure represent stack of elements
 * which we are trying to insert into quad tree.
 */
function InsertStack () {
    this.stack = [];
    this.popIdx = 0;
}

InsertStack.prototype = {
    isEmpty: function() {
        return this.popIdx === 0;
    },
    push: function (node, body) {
        var item = this.stack[this.popIdx];
        if (!item) {
            // we are trying to avoid memory pressure: create new element
            // only when absolutely necessary
            this.stack[this.popIdx] = new InsertStackElement(node, body);
        } else {
            item.node = node;
            item.body = body;
        }
        ++this.popIdx;
    },
    pop: function () {
        if (this.popIdx > 0) {
            return this.stack[--this.popIdx];
        }
    },
    reset: function () {
        this.popIdx = 0;
    }
};

function InsertStackElement(node, body) {
    this.node = node; // QuadTree node
    this.body = body; // physical body which needs to be inserted to node
}
`}return Ja.exports}var yg={exports:{}},Qw;function WV(){if(Qw)return yg.exports;Qw=1,yg.exports=e,yg.exports.generateFunctionBody=t;const i=Jh();function e(n){let r=t(n);return new Function("bodies","settings","random",r)}function t(n){let r=i(n);return`
  var boundingBox = {
    ${r("min_{var}: 0, max_{var}: 0,",{indent:4})}
  };

  return {
    box: boundingBox,

    update: updateBoundingBox,

    reset: resetBoundingBox,

    getBestNewPosition: function (neighbors) {
      var ${r("base_{var} = 0",{join:", "})};

      if (neighbors.length) {
        for (var i = 0; i < neighbors.length; ++i) {
          let neighborPos = neighbors[i].pos;
          ${r("base_{var} += neighborPos.{var};",{indent:10})}
        }

        ${r("base_{var} /= neighbors.length;",{indent:8})}
      } else {
        ${r("base_{var} = (boundingBox.min_{var} + boundingBox.max_{var}) / 2;",{indent:8})}
      }

      var springLength = settings.springLength;
      return {
        ${r("{var}: base_{var} + (random.nextDouble() - 0.5) * springLength,",{indent:8})}
      };
    }
  };

  function updateBoundingBox() {
    var i = bodies.length;
    if (i === 0) return; // No bodies - no borders.

    ${r("var max_{var} = -Infinity;",{indent:4})}
    ${r("var min_{var} = Infinity;",{indent:4})}

    while(i--) {
      // this is O(n), it could be done faster with quadtree, if we check the root node bounds
      var bodyPos = bodies[i].pos;
      ${r("if (bodyPos.{var} < min_{var}) min_{var} = bodyPos.{var};",{indent:6})}
      ${r("if (bodyPos.{var} > max_{var}) max_{var} = bodyPos.{var};",{indent:6})}
    }

    ${r("boundingBox.min_{var} = min_{var};",{indent:4})}
    ${r("boundingBox.max_{var} = max_{var};",{indent:4})}
  }

  function resetBoundingBox() {
    ${r("boundingBox.min_{var} = boundingBox.max_{var} = 0;",{indent:4})}
  }
`}return yg.exports}var xg={exports:{}},Jw;function $V(){if(Jw)return xg.exports;Jw=1;const i=Jh();xg.exports=e,xg.exports.generateCreateDragForceFunctionBody=t;function e(n){let r=t(n);return new Function("options",r)}function t(n){return`
  if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number');

  return {
    update: function(body) {
      ${i(n)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})}
    }
  };
`}return xg.exports}var bg={exports:{}},eR;function qV(){if(eR)return bg.exports;eR=1;const i=Jh();bg.exports=e,bg.exports.generateCreateSpringForceFunctionBody=t;function e(n){let r=t(n);return new Function("options","random",r)}function t(n){let r=i(n);return`
  if (!Number.isFinite(options.springCoefficient)) throw new Error('Spring coefficient is not a number');
  if (!Number.isFinite(options.springLength)) throw new Error('Spring length is not a number');

  return {
    /**
     * Updates forces acting on a spring
     */
    update: function (spring) {
      var body1 = spring.from;
      var body2 = spring.to;
      var length = spring.length < 0 ? options.springLength : spring.length;
      ${r("var d{var} = body2.pos.{var} - body1.pos.{var};",{indent:6})}
      var r = Math.sqrt(${r("d{var} * d{var}",{join:" + "})});

      if (r === 0) {
        ${r("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:8})}
        r = Math.sqrt(${r("d{var} * d{var}",{join:" + "})});
      }

      var d = r - length;
      var coefficient = ((spring.coefficient > 0) ? spring.coefficient : options.springCoefficient) * d / r;

      ${r("body1.force.{var} += coefficient * d{var}",{indent:6})};
      body1.springCount += 1;
      body1.springLength += r;

      ${r("body2.force.{var} -= coefficient * d{var}",{indent:6})};
      body2.springCount += 1;
      body2.springLength += r;
    }
  };
`}return bg.exports}var Sg={exports:{}},tR;function XV(){if(tR)return Sg.exports;tR=1;const i=Jh();Sg.exports=e,Sg.exports.generateIntegratorFunctionBody=t;function e(n){let r=t(n);return new Function("bodies","timeStep","adaptiveTimeStepWeight",r)}function t(n){let r=i(n);return`
  var length = bodies.length;
  if (length === 0) return 0;

  ${r("var d{var} = 0, t{var} = 0;",{indent:2})}

  for (var i = 0; i < length; ++i) {
    var body = bodies[i];
    if (body.isPinned) continue;

    if (adaptiveTimeStepWeight && body.springCount) {
      timeStep = (adaptiveTimeStepWeight * body.springLength/body.springCount);
    }

    var coeff = timeStep / body.mass;

    ${r("body.velocity.{var} += coeff * body.force.{var};",{indent:4})}
    ${r("var v{var} = body.velocity.{var};",{indent:4})}
    var v = Math.sqrt(${r("v{var} * v{var}",{join:" + "})});

    if (v > 1) {
      // We normalize it so that we move within timeStep range. 
      // for the case when v <= 1 - we let velocity to fade out.
      ${r("body.velocity.{var} = v{var} / v;",{indent:6})}
    }

    ${r("d{var} = timeStep * body.velocity.{var};",{indent:4})}

    ${r("body.pos.{var} += d{var};",{indent:4})}

    ${r("t{var} += Math.abs(d{var});",{indent:4})}
  }

  return (${r("t{var} * t{var}",{join:" + "})})/length;
`}return Sg.exports}var dx,nR;function YV(){if(nR)return dx;nR=1,dx=i;function i(e,t,n,r){this.from=e,this.to=t,this.length=n,this.coefficient=r}return dx}var px,iR;function KV(){if(iR)return px;iR=1,px=i;function i(e,t){var n;if(e||(e={}),t){for(n in t)if(t.hasOwnProperty(n)){var r=e.hasOwnProperty(n),s=typeof t[n],o=!r||typeof e[n]!==s;o?e[n]=t[n]:s==="object"&&(e[n]=i(e[n],t[n]))}}return e}return px}var mx,rR;function U2(){if(rR)return mx;rR=1;function i(n){t(n);const r=e(n);return n.on=r.on,n.off=r.off,n.fire=r.fire,n}function e(n){let r=Object.create(null);return{on:function(s,o,u){if(typeof o!="function")throw new Error("callback is expected to be a function");let c=r[s];return c||(c=r[s]=[]),c.push({callback:o,ctx:u}),n},off:function(s,o){if(typeof s>"u")return r=Object.create(null),n;if(r[s])if(typeof o!="function")delete r[s];else{const u=r[s];for(let c=0;c<u.length;++c)u[c].callback===o&&u.splice(c,1)}return n},fire:function(s){const o=r[s];if(!o)return n;let u;arguments.length>1&&(u=Array.prototype.slice.call(arguments,1));for(let c=0;c<o.length;++c){const h=o[c];h.callback.apply(h.ctx,u)}return n}}}function t(n){if(!n)throw new Error("Eventify cannot use falsy object as events subject");const r=["on","fire","off"];for(let s=0;s<r.length;++s)if(n.hasOwnProperty(r[s]))throw new Error("Subject cannot be eventified, since it already has property '"+r[s]+"'")}return mx=i,mx}var cd={exports:{}},sR;function ZV(){if(sR)return cd.exports;sR=1,cd.exports=i,cd.exports.random=i,cd.exports.randomIterator=u;function i(c){var h=typeof c=="number"?c:+new Date;return new e(h)}function e(c){this.seed=c}e.prototype.next=o,e.prototype.nextDouble=s,e.prototype.uniform=s,e.prototype.gaussian=t,e.prototype.random=s;function t(){var c,h,d;do h=this.nextDouble()*2-1,d=this.nextDouble()*2-1,c=h*h+d*d;while(c>=1||c===0);return h*Math.sqrt(-2*Math.log(c)/c)}e.prototype.levy=n;function n(){var c=1.5,h=Math.pow(r(1+c)*Math.sin(Math.PI*c/2)/(r((1+c)/2)*c*Math.pow(2,(c-1)/2)),1/c);return this.gaussian()*h/Math.pow(Math.abs(this.gaussian()),1/c)}function r(c){return Math.sqrt(2*Math.PI/c)*Math.pow(1/Math.E*(c+1/(12*c-1/(10*c))),c)}function s(){var c=this.seed;return c=c+2127912214+(c<<12)&4294967295,c=(c^3345072700^c>>>19)&4294967295,c=c+374761393+(c<<5)&4294967295,c=(c+3550635116^c<<9)&4294967295,c=c+4251993797+(c<<3)&4294967295,c=(c^3042594569^c>>>16)&4294967295,this.seed=c,(c&268435455)/268435456}function o(c){return Math.floor(this.nextDouble()*c)}function u(c,h){var d=h||i();if(typeof d.next!="function")throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:g,shuffle:p};function p(){var _,v,S;for(_=c.length-1;_>0;--_)v=d.next(_+1),S=c[v],c[v]=c[_],c[_]=S;return c}function g(_){var v,S,b;for(v=c.length-1;v>0;--v)S=d.next(v+1),b=c[S],c[S]=c[v],c[v]=b,_(b);c.length&&_(c[0])}}return cd.exports}var gx,aR;function oR(){if(aR)return gx;aR=1,gx=u;var i=HV(),e=jV(),t=WV(),n=$V(),r=qV(),s=XV(),o={};function u(d){var p=YV(),g=KV(),_=U2();if(d){if(d.springCoeff!==void 0)throw new Error("springCoeff was renamed to springCoefficient");if(d.dragCoeff!==void 0)throw new Error("dragCoeff was renamed to dragCoefficient")}d=g(d,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var v=o[d.dimensions];if(!v){var S=d.dimensions;v={Body:i(S,d.debug),createQuadTree:e(S),createBounds:t(S),createDragForce:n(S),createSpringForce:r(S),integrate:s(S)},o[S]=v}var b=v.Body,x=v.createQuadTree,M=v.createBounds,E=v.createDragForce,w=v.createSpringForce,D=v.integrate,C=ee=>new b(ee),N=ZV().random(42),A=[],L=[],j=x(d,N),z=M(A,d,N),H=w(d,N),K=E(d),te=0,Z=[],I=new Map,F=0;Te("nbody",ce),Te("spring",Le);var Y={bodies:A,quadTree:j,springs:L,settings:d,addForce:Te,removeForce:O,getForces:W,step:function(){for(var ee=0;ee<Z.length;++ee)Z[ee](F);var $=D(A,d.timeStep,d.adaptiveTimeStepWeight);return F+=1,$},addBody:function(ee){if(!ee)throw new Error("Body is required");return A.push(ee),ee},addBodyAt:function(ee){if(!ee)throw new Error("Body position is required");var $=C(ee);return A.push($),$},removeBody:function(ee){if(ee){var $=A.indexOf(ee);if(!($<0))return A.splice($,1),A.length===0&&z.reset(),!0}},addSpring:function(ee,$,ue,Ee){if(!ee||!$)throw new Error("Cannot add null spring to force simulator");typeof ue!="number"&&(ue=-1);var ke=new p(ee,$,ue,Ee>=0?Ee:-1);return L.push(ke),ke},getTotalMovement:function(){return te},removeSpring:function(ee){if(ee){var $=L.indexOf(ee);if($>-1)return L.splice($,1),!0}},getBestNewBodyPosition:function(ee){return z.getBestNewPosition(ee)},getBBox:se,getBoundingBox:se,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(ee){return ee!==void 0?(d.gravity=ee,j.options({gravity:ee}),this):d.gravity},theta:function(ee){return ee!==void 0?(d.theta=ee,j.options({theta:ee}),this):d.theta},random:N};return c(d,Y),_(Y),Y;function se(){return z.update(),z.box}function Te(ee,$){if(I.has(ee))throw new Error("Force "+ee+" is already added");I.set(ee,$),Z.push($)}function O(ee){var $=Z.indexOf(I.get(ee));$<0||(Z.splice($,1),I.delete(ee))}function W(){return I}function ce(){if(A.length!==0){j.insertBodies(A);for(var ee=A.length;ee--;){var $=A[ee];$.isPinned||($.reset(),j.updateBodyForce($),K.update($))}}}function Le(){for(var ee=L.length;ee--;)H.update(L[ee])}}function c(d,p){for(var g in d)h(d,p,g)}function h(d,p,g){if(d.hasOwnProperty(g)&&typeof p[g]!="function"){var _=Number.isFinite(d[g]);_?p[g]=function(v){if(v!==void 0){if(!Number.isFinite(v))throw new Error("Value of "+g+" should be a valid number.");return d[g]=v,p}return d[g]}:p[g]=function(v){return v!==void 0?(d[g]=v,p):d[g]}}}return gx}var lR;function QV(){if(lR)return vg.exports;lR=1,vg.exports=e,vg.exports.simulator=oR();var i=U2();function e(n,r){if(!n)throw new Error("Graph structure cannot be undefined");var s=r&&r.createSimulator||oR(),o=s(r);if(Array.isArray(r))throw new Error("Physics settings is expected to be an object");var u=n.version>19?I:Z;r&&typeof r.nodeMass=="function"&&(u=r.nodeMass);var c=new Map,h={},d=0,p=o.settings.springTransform||t;C(),E();var g=!1,_={step:function(){if(d===0)return v(!0),!0;var F=o.step();_.lastMove=F,_.fire("step");var Y=F/d,se=Y<=.01;return v(se),se},getNodePosition:function(F){return te(F).pos},setNodePosition:function(F){var Y=te(F);Y.setPosition.apply(Y,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(F){var Y=h[F];if(Y)return{from:Y.from.pos,to:Y.to.pos}},getGraphRect:function(){return o.getBBox()},forEachBody:S,pinNode:function(F,Y){var se=te(F.id);se.isPinned=!!Y},isNodePinned:function(F){return te(F.id).isPinned},dispose:function(){n.off("changed",D),_.fire("disposed")},getBody:M,getSpring:x,getForceVectorLength:b,simulator:o,graph:n,lastMove:0};return i(_),_;function v(F){g!==F&&(g=F,w(F))}function S(F){c.forEach(F)}function b(){var F=0,Y=0;return S(function(se){F+=Math.abs(se.force.x),Y+=Math.abs(se.force.y)}),Math.sqrt(F*F+Y*Y)}function x(F,Y){var se;if(Y===void 0)typeof F!="object"?se=F:se=F.id;else{var Te=n.hasLink(F,Y);if(!Te)return;se=Te.id}return h[se]}function M(F){return c.get(F)}function E(){n.on("changed",D)}function w(F){_.fire("stable",F)}function D(F){for(var Y=0;Y<F.length;++Y){var se=F[Y];se.changeType==="add"?(se.node&&N(se.node.id),se.link&&L(se.link)):se.changeType==="remove"&&(se.node&&A(se.node),se.link&&j(se.link))}d=n.getNodesCount()}function C(){d=0,n.forEachNode(function(F){N(F.id),d+=1}),n.forEachLink(L)}function N(F){var Y=c.get(F);if(!Y){var se=n.getNode(F);if(!se)throw new Error("initBody() was called with unknown node id");var Te=se.position;if(!Te){var O=z(se);Te=o.getBestNewBodyPosition(O)}Y=o.addBodyAt(Te),Y.id=F,c.set(F,Y),H(F),K(se)&&(Y.isPinned=!0)}}function A(F){var Y=F.id,se=c.get(Y);se&&(c.delete(Y),o.removeBody(se))}function L(F){H(F.fromId),H(F.toId);var Y=c.get(F.fromId),se=c.get(F.toId),Te=o.addSpring(Y,se,F.length);p(F,Te),h[F.id]=Te}function j(F){var Y=h[F.id];if(Y){var se=n.getNode(F.fromId),Te=n.getNode(F.toId);se&&H(se.id),Te&&H(Te.id),delete h[F.id],o.removeSpring(Y)}}function z(F){var Y=[];if(!F.links)return Y;for(var se=Math.min(F.links.length,2),Te=0;Te<se;++Te){var O=F.links[Te],W=O.fromId!==F.id?c.get(O.fromId):c.get(O.toId);W&&W.pos&&Y.push(W)}return Y}function H(F){var Y=c.get(F);if(Y.mass=u(F),Number.isNaN(Y.mass))throw new Error("Node mass should be a number")}function K(F){return F&&(F.isPinned||F.data&&F.data.isPinned)}function te(F){var Y=c.get(F);return Y||(N(F),Y=c.get(F)),Y}function Z(F){var Y=n.getLinks(F);return Y?1+Y.length/3:1}function I(F){var Y=n.getLinks(F);return Y?1+Y.size/3:1}}function t(){}return vg.exports}var JV=QV();const e5=k_(JV);function Ob(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var t5=typeof global=="object"&&global&&global.Object===Object&&global,n5=typeof self=="object"&&self&&self.Object===Object&&self,O2=t5||n5||Function("return this")(),_x=function(){return O2.Date.now()},i5=/\s/;function r5(i){for(var e=i.length;e--&&i5.test(i.charAt(e)););return e}var s5=/^\s+/;function a5(i){return i&&i.slice(0,r5(i)+1).replace(s5,"")}var S_=O2.Symbol,B2=Object.prototype,o5=B2.hasOwnProperty,l5=B2.toString,hd=S_?S_.toStringTag:void 0;function u5(i){var e=o5.call(i,hd),t=i[hd];try{i[hd]=void 0;var n=!0}catch{}var r=l5.call(i);return n&&(e?i[hd]=t:delete i[hd]),r}var c5=Object.prototype,h5=c5.toString;function f5(i){return h5.call(i)}var d5="[object Null]",p5="[object Undefined]",uR=S_?S_.toStringTag:void 0;function m5(i){return i==null?i===void 0?p5:d5:uR&&uR in Object(i)?u5(i):f5(i)}function g5(i){return i!=null&&typeof i=="object"}var _5="[object Symbol]";function v5(i){return typeof i=="symbol"||g5(i)&&m5(i)==_5}var cR=NaN,y5=/^[-+]0x[0-9a-f]+$/i,x5=/^0b[01]+$/i,b5=/^0o[0-7]+$/i,S5=parseInt;function hR(i){if(typeof i=="number")return i;if(v5(i))return cR;if(Ob(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=Ob(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=a5(i);var t=x5.test(i);return t||b5.test(i)?S5(i.slice(2),t?2:8):y5.test(i)?cR:+i}var T5="Expected a function",M5=Math.max,E5=Math.min;function A5(i,e,t){var n,r,s,o,u,c,h=0,d=!1,p=!1,g=!0;if(typeof i!="function")throw new TypeError(T5);e=hR(e)||0,Ob(t)&&(d=!!t.leading,p="maxWait"in t,s=p?M5(hR(t.maxWait)||0,e):s,g="trailing"in t?!!t.trailing:g);function _(C){var N=n,A=r;return n=r=void 0,h=C,o=i.apply(A,N),o}function v(C){return h=C,u=setTimeout(x,e),d?_(C):o}function S(C){var N=C-c,A=C-h,L=e-N;return p?E5(L,s-A):L}function b(C){var N=C-c,A=C-h;return c===void 0||N>=e||N<0||p&&A>=s}function x(){var C=_x();if(b(C))return M(C);u=setTimeout(x,S(C))}function M(C){return u=void 0,g&&n?_(C):(n=r=void 0,o)}function E(){u!==void 0&&clearTimeout(u),h=0,n=c=r=u=void 0}function w(){return u===void 0?o:M(_x())}function D(){var C=_x(),N=b(C);if(n=arguments,r=this,c=C,N){if(u===void 0)return v(c);if(p)return clearTimeout(u),u=setTimeout(x,e),_(c)}return u===void 0&&(u=setTimeout(x,e)),o}return D.cancel=E,D.flush=w,D}function fR(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function w5(i){if(Array.isArray(i))return i}function R5(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function C5(i,e,t){return Object.defineProperty(i,"prototype",{writable:!1}),i}function N5(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,o,u=[],c=!0,h=!1;try{if(s=(t=t.call(i)).next,e!==0)for(;!(c=(n=s.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(d){h=!0,r=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw r}}return u}}function D5(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function L5(i,e){return w5(i)||N5(i,e)||P5(i,e)||D5()}function P5(i,e){if(i){if(typeof i=="string")return fR(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?fR(i,e):void 0}}var U5=C5(function i(e,t){var n=t.default,r=n===void 0?null:n,s=t.triggerUpdate,o=s===void 0?!0:s,u=t.onChange,c=u===void 0?function(h,d){}:u;R5(this,i),this.name=e,this.defaultVal=r,this.triggerUpdate=o,this.onChange=c});function J_(i){var e=i.stateInit,t=e===void 0?function(){return{}}:e,n=i.props,r=n===void 0?{}:n,s=i.methods,o=s===void 0?{}:s,u=i.aliases,c=u===void 0?{}:u,h=i.init,d=h===void 0?function(){}:h,p=i.update,g=p===void 0?function(){}:p,_=Object.keys(r).map(function(v){return new U5(v,r[v])});return function v(){for(var S=arguments.length,b=new Array(S),x=0;x<S;x++)b[x]=arguments[x];var M=!!(this instanceof v&&this.constructor),E=M?b.shift():void 0,w=b[0],D=w===void 0?{}:w,C=Object.assign({},t instanceof Function?t(D):t,{initialised:!1}),N={};function A(z){return L(z,D),j(),A}var L=function(H,K){d.call(A,H,C,K),C.initialised=!0},j=A5(function(){C.initialised&&(g.call(A,C,N),N={})},1);return _.forEach(function(z){A[z.name]=H(z);function H(K){var te=K.name,Z=K.triggerUpdate,I=Z===void 0?!1:Z,F=K.onChange,Y=F===void 0?function(O,W){}:F,se=K.defaultVal,Te=se===void 0?null:se;return function(O){var W=C[te];if(!arguments.length)return W;var ce=O===void 0?Te:O;return C[te]=ce,Y.call(A,ce,C,W),!N.hasOwnProperty(te)&&(N[te]=W),I&&j(),A}}}),Object.keys(o).forEach(function(z){A[z]=function(){for(var H,K=arguments.length,te=new Array(K),Z=0;Z<K;Z++)te[Z]=arguments[Z];return(H=o[z]).call.apply(H,[A,C].concat(te))}}),Object.entries(c).forEach(function(z){var H=L5(z,2),K=H[0],te=H[1];return A[K]=A[te]}),A.resetProps=function(){return _.forEach(function(z){A[z.name](z.defaultVal)}),A},A.resetProps(),C._rerender=j,M&&E&&A(E),A}}var Zt=(function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}});class dR extends Map{constructor(e,t=F5){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const[n,r]of e)this.set(n,r)}get(e){return super.get(pR(this,e))}has(e){return super.has(pR(this,e))}set(e,t){return super.set(O5(this,e),t)}delete(e){return super.delete(B5(this,e))}}function pR({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):t}function O5({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):(i.set(n,t),t)}function B5({_intern:i,_key:e},t){const n=e(t);return i.has(n)&&(t=i.get(n),i.delete(n)),t}function F5(i){return i!==null&&typeof i=="object"?i.valueOf():i}function I5(i,e){let t;if(e===void 0)for(const n of i)n!=null&&(t<n||t===void 0&&n>=n)&&(t=n);else{let n=-1;for(let r of i)(r=e(r,++n,i))!=null&&(t<r||t===void 0&&r>=r)&&(t=r)}return t}function z5(i,e){let t;if(e===void 0)for(const n of i)n!=null&&(t>n||t===void 0&&n>=n)&&(t=n);else{let n=-1;for(let r of i)(r=e(r,++n,i))!=null&&(t>r||t===void 0&&r>=r)&&(t=r)}return t}function Bb(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function k5(i){if(Array.isArray(i))return i}function G5(i){if(Array.isArray(i))return Bb(i)}function F2(i,e,t){if(typeof i=="function"?i===e:i.has(e))return arguments.length<3?e:t;throw new TypeError("Private element is not present on this object")}function V5(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function H5(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function Ji(i,e){return i.get(F2(i,e))}function Gc(i,e,t){V5(i,e),e.set(i,t)}function Tg(i,e,t){return i.set(F2(i,e),t),t}function j5(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,J5(n.key),n)}}function W5(i,e,t){return e&&j5(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function $5(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function q5(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,o,u=[],c=!0,h=!1;try{if(s=(t=t.call(i)).next,e!==0)for(;!(c=(n=s.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(d){h=!0,r=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw r}}return u}}function X5(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Y5(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function K5(i,e){return k5(i)||q5(i,e)||I2(i,e)||X5()}function Z5(i){return G5(i)||$5(i)||I2(i)||Y5()}function Q5(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function J5(i){var e=Q5(i,"string");return typeof e=="symbol"?e:e+""}function I2(i,e){if(i){if(typeof i=="string")return Bb(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Bb(i,e):void 0}}var Vc=new WeakMap,fd=new WeakMap,Hc=new WeakMap,vx=new WeakMap,yx=new WeakMap,xx=new WeakMap,e6=(function(){function i(){H5(this,i),Gc(this,Vc,new Map),Gc(this,fd,new Map),Gc(this,Hc,function(e){return e}),Gc(this,vx,function(){return{}}),Gc(this,yx,function(){}),Gc(this,xx,function(){})}return W5(i,[{key:"getObj",value:function(t){return Ji(Vc,this).get(Ji(Hc,this).call(this,t))}},{key:"getData",value:function(t){return Ji(fd,this).get(t)}},{key:"entries",value:function(){return Z5(Ji(fd,this).entries()).map(function(t){var n=K5(t,2),r=n[0],s=n[1];return[s,r]})}},{key:"id",value:function(t){return Tg(Hc,this,Zt(t)),this}},{key:"onCreateObj",value:function(t){return Tg(vx,this,t),this}},{key:"onUpdateObj",value:function(t){return Tg(yx,this,t),this}},{key:"onRemoveObj",value:function(t){return Tg(xx,this,t),this}},{key:"digest",value:function(t){var n=this;t.filter(function(s){return!Ji(Vc,n).has(Ji(Hc,n).call(n,s))}).forEach(function(s){var o=Ji(vx,n).call(n,s);Ji(Vc,n).set(Ji(Hc,n).call(n,s),o),Ji(fd,n).set(o,s)});var r=new Map(t.map(function(s){return[Ji(Hc,n).call(n,s),s]}));return Ji(Vc,this).forEach(function(s,o){r.has(o)?Ji(yx,n).call(n,s,r.get(o)):(Ji(xx,n).call(n,s,o),Ji(Vc,n).delete(o),Ji(fd,n).delete(s))}),this}},{key:"clear",value:function(){return this.digest([]),this}}])})();function t6(i,e){switch(arguments.length){case 0:break;case 1:this.range(i);break;default:this.range(e).domain(i);break}return this}const mR=Symbol("implicit");function z2(){var i=new dR,e=[],t=[],n=mR;function r(s){let o=i.get(s);if(o===void 0){if(n!==mR)return n;i.set(s,o=e.push(s)-1)}return t[o%t.length]}return r.domain=function(s){if(!arguments.length)return e.slice();e=[],i=new dR;for(const o of s)i.has(o)||i.set(o,e.push(o)-1);return r},r.range=function(s){return arguments.length?(t=Array.from(s),r):t.slice()},r.unknown=function(s){return arguments.length?(n=s,r):n},r.copy=function(){return z2(e,t).unknown(n)},t6.apply(r,arguments),r}function n6(i){for(var e=i.length/6|0,t=new Array(e),n=0;n<e;)t[n]="#"+i.slice(n*6,++n*6);return t}const i6=n6("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");function T_(i){"@babel/helpers - typeof";return T_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T_(i)}var r6=/^\s+/,s6=/\s+$/;function mt(i,e){if(i=i||"",e=e||{},i instanceof mt)return i;if(!(this instanceof mt))return new mt(i,e);var t=a6(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}mt.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,n,r,s,o,u;return t=e.r/255,n=e.g/255,r=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),n<=.03928?o=n/12.92:o=Math.pow((n+.055)/1.055,2.4),r<=.03928?u=r/12.92:u=Math.pow((r+.055)/1.055,2.4),.2126*s+.7152*o+.0722*u},setAlpha:function(e){return this._a=k2(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=_R(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=_R(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=gR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=gR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return vR(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return c6(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(Zn(this._r,255)*100)+"%",g:Math.round(Zn(this._g,255)*100)+"%",b:Math.round(Zn(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Zn(this._r,255)*100)+"%, "+Math.round(Zn(this._g,255)*100)+"%, "+Math.round(Zn(this._b,255)*100)+"%)":"rgba("+Math.round(Zn(this._r,255)*100)+"%, "+Math.round(Zn(this._g,255)*100)+"%, "+Math.round(Zn(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:S6[vR(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+yR(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var s=mt(e);n="#"+yR(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0,s=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return mt(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(p6,arguments)},brighten:function(){return this._applyModification(m6,arguments)},darken:function(){return this._applyModification(g6,arguments)},desaturate:function(){return this._applyModification(h6,arguments)},saturate:function(){return this._applyModification(f6,arguments)},greyscale:function(){return this._applyModification(d6,arguments)},spin:function(){return this._applyModification(_6,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(x6,arguments)},complement:function(){return this._applyCombination(v6,arguments)},monochromatic:function(){return this._applyCombination(b6,arguments)},splitcomplement:function(){return this._applyCombination(y6,arguments)},triad:function(){return this._applyCombination(xR,[3])},tetrad:function(){return this._applyCombination(xR,[4])}};mt.fromRatio=function(i,e){if(T_(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=Nd(i[n]));i=t}return mt(i,e)};function a6(i){var e={r:0,g:0,b:0},t=1,n=null,r=null,s=null,o=!1,u=!1;return typeof i=="string"&&(i=A6(i)),T_(i)=="object"&&(eo(i.r)&&eo(i.g)&&eo(i.b)?(e=o6(i.r,i.g,i.b),o=!0,u=String(i.r).substr(-1)==="%"?"prgb":"rgb"):eo(i.h)&&eo(i.s)&&eo(i.v)?(n=Nd(i.s),r=Nd(i.v),e=u6(i.h,n,r),o=!0,u="hsv"):eo(i.h)&&eo(i.s)&&eo(i.l)&&(n=Nd(i.s),s=Nd(i.l),e=l6(i.h,n,s),o=!0,u="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=k2(t),{ok:o,format:i.format||u,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function o6(i,e,t){return{r:Zn(i,255)*255,g:Zn(e,255)*255,b:Zn(t,255)*255}}function gR(i,e,t){i=Zn(i,255),e=Zn(e,255),t=Zn(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,o,u=(n+r)/2;if(n==r)s=o=0;else{var c=n-r;switch(o=u>.5?c/(2-n-r):c/(n+r),n){case i:s=(e-t)/c+(e<t?6:0);break;case e:s=(t-i)/c+2;break;case t:s=(i-e)/c+4;break}s/=6}return{h:s,s:o,l:u}}function l6(i,e,t){var n,r,s;i=Zn(i,360),e=Zn(e,100),t=Zn(t,100);function o(h,d,p){return p<0&&(p+=1),p>1&&(p-=1),p<1/6?h+(d-h)*6*p:p<1/2?d:p<2/3?h+(d-h)*(2/3-p)*6:h}if(e===0)n=r=s=t;else{var u=t<.5?t*(1+e):t+e-t*e,c=2*t-u;n=o(c,u,i+1/3),r=o(c,u,i),s=o(c,u,i-1/3)}return{r:n*255,g:r*255,b:s*255}}function _R(i,e,t){i=Zn(i,255),e=Zn(e,255),t=Zn(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,o,u=n,c=n-r;if(o=n===0?0:c/n,n==r)s=0;else{switch(n){case i:s=(e-t)/c+(e<t?6:0);break;case e:s=(t-i)/c+2;break;case t:s=(i-e)/c+4;break}s/=6}return{h:s,s:o,v:u}}function u6(i,e,t){i=Zn(i,360)*6,e=Zn(e,100),t=Zn(t,100);var n=Math.floor(i),r=i-n,s=t*(1-e),o=t*(1-r*e),u=t*(1-(1-r)*e),c=n%6,h=[t,o,s,s,u,t][c],d=[u,t,t,o,s,s][c],p=[s,s,u,t,t,o][c];return{r:h*255,g:d*255,b:p*255}}function vR(i,e,t,n){var r=[Vs(Math.round(i).toString(16)),Vs(Math.round(e).toString(16)),Vs(Math.round(t).toString(16))];return n&&r[0].charAt(0)==r[0].charAt(1)&&r[1].charAt(0)==r[1].charAt(1)&&r[2].charAt(0)==r[2].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")}function c6(i,e,t,n,r){var s=[Vs(Math.round(i).toString(16)),Vs(Math.round(e).toString(16)),Vs(Math.round(t).toString(16)),Vs(G2(n))];return r&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)&&s[3].charAt(0)==s[3].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0)+s[3].charAt(0):s.join("")}function yR(i,e,t,n){var r=[Vs(G2(n)),Vs(Math.round(i).toString(16)),Vs(Math.round(e).toString(16)),Vs(Math.round(t).toString(16))];return r.join("")}mt.equals=function(i,e){return!i||!e?!1:mt(i).toRgbString()==mt(e).toRgbString()};mt.random=function(){return mt.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function h6(i,e){e=e===0?0:e||10;var t=mt(i).toHsl();return t.s-=e/100,t.s=e0(t.s),mt(t)}function f6(i,e){e=e===0?0:e||10;var t=mt(i).toHsl();return t.s+=e/100,t.s=e0(t.s),mt(t)}function d6(i){return mt(i).desaturate(100)}function p6(i,e){e=e===0?0:e||10;var t=mt(i).toHsl();return t.l+=e/100,t.l=e0(t.l),mt(t)}function m6(i,e){e=e===0?0:e||10;var t=mt(i).toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(255*-(e/100)))),t.g=Math.max(0,Math.min(255,t.g-Math.round(255*-(e/100)))),t.b=Math.max(0,Math.min(255,t.b-Math.round(255*-(e/100)))),mt(t)}function g6(i,e){e=e===0?0:e||10;var t=mt(i).toHsl();return t.l-=e/100,t.l=e0(t.l),mt(t)}function _6(i,e){var t=mt(i).toHsl(),n=(t.h+e)%360;return t.h=n<0?360+n:n,mt(t)}function v6(i){var e=mt(i).toHsl();return e.h=(e.h+180)%360,mt(e)}function xR(i,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var t=mt(i).toHsl(),n=[mt(i)],r=360/e,s=1;s<e;s++)n.push(mt({h:(t.h+s*r)%360,s:t.s,l:t.l}));return n}function y6(i){var e=mt(i).toHsl(),t=e.h;return[mt(i),mt({h:(t+72)%360,s:e.s,l:e.l}),mt({h:(t+216)%360,s:e.s,l:e.l})]}function x6(i,e,t){e=e||6,t=t||30;var n=mt(i).toHsl(),r=360/t,s=[mt(i)];for(n.h=(n.h-(r*e>>1)+720)%360;--e;)n.h=(n.h+r)%360,s.push(mt(n));return s}function b6(i,e){e=e||6;for(var t=mt(i).toHsv(),n=t.h,r=t.s,s=t.v,o=[],u=1/e;e--;)o.push(mt({h:n,s:r,v:s})),s=(s+u)%1;return o}mt.mix=function(i,e,t){t=t===0?0:t||50;var n=mt(i).toRgb(),r=mt(e).toRgb(),s=t/100,o={r:(r.r-n.r)*s+n.r,g:(r.g-n.g)*s+n.g,b:(r.b-n.b)*s+n.b,a:(r.a-n.a)*s+n.a};return mt(o)};mt.readability=function(i,e){var t=mt(i),n=mt(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)};mt.isReadable=function(i,e,t){var n=mt.readability(i,e),r,s;switch(s=!1,r=w6(t),r.level+r.size){case"AAsmall":case"AAAlarge":s=n>=4.5;break;case"AAlarge":s=n>=3;break;case"AAAsmall":s=n>=7;break}return s};mt.mostReadable=function(i,e,t){var n=null,r=0,s,o,u,c;t=t||{},o=t.includeFallbackColors,u=t.level,c=t.size;for(var h=0;h<e.length;h++)s=mt.readability(i,e[h]),s>r&&(r=s,n=mt(e[h]));return mt.isReadable(i,n,{level:u,size:c})||!o?n:(t.includeFallbackColors=!1,mt.mostReadable(i,["#fff","#000"],t))};var Fb=mt.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},S6=mt.hexNames=T6(Fb);function T6(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function k2(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function Zn(i,e){M6(i)&&(i="100%");var t=E6(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function e0(i){return Math.min(1,Math.max(0,i))}function Jr(i){return parseInt(i,16)}function M6(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function E6(i){return typeof i=="string"&&i.indexOf("%")!=-1}function Vs(i){return i.length==1?"0"+i:""+i}function Nd(i){return i<=1&&(i=i*100+"%"),i}function G2(i){return Math.round(parseFloat(i)*255).toString(16)}function bR(i){return Jr(i)/255}var Fs=(function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function eo(i){return!!Fs.CSS_UNIT.exec(i)}function A6(i){i=i.replace(r6,"").replace(s6,"").toLowerCase();var e=!1;if(Fb[i])i=Fb[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=Fs.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=Fs.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=Fs.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=Fs.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=Fs.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=Fs.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=Fs.hex8.exec(i))?{r:Jr(t[1]),g:Jr(t[2]),b:Jr(t[3]),a:bR(t[4]),format:e?"name":"hex8"}:(t=Fs.hex6.exec(i))?{r:Jr(t[1]),g:Jr(t[2]),b:Jr(t[3]),format:e?"name":"hex"}:(t=Fs.hex4.exec(i))?{r:Jr(t[1]+""+t[1]),g:Jr(t[2]+""+t[2]),b:Jr(t[3]+""+t[3]),a:bR(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=Fs.hex3.exec(i))?{r:Jr(t[1]+""+t[1]),g:Jr(t[2]+""+t[2]),b:Jr(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function w6(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function Ib(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function R6(i){if(Array.isArray(i))return i}function C6(i){if(Array.isArray(i))return Ib(i)}function V2(i,e,t){if(typeof i=="function"?i===e:i.has(e))return arguments.length<3?e:t;throw new TypeError("Private element is not present on this object")}function N6(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function H2(i,e,t){return e=kh(e),I6(i,cT()?Reflect.construct(e,t||[],kh(i).constructor):e.apply(i,t))}function D6(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function j2(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function bx(i,e){return i.get(V2(i,e))}function SR(i,e,t){D6(i,e),e.set(i,t)}function TR(i,e,t){return i.set(V2(i,e),t),t}function W2(i,e,t){if(cT())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var r=new(i.bind.apply(i,n));return r}function L6(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,X2(n.key),n)}}function $2(i,e,t){return e&&L6(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function t0(i,e,t){return(e=X2(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function zb(){return zb=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(i,e,t){var n=z6(i,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?i:t):r.value}},zb.apply(null,arguments)}function kh(i){return kh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},kh(i)}function q2(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&kb(i,e)}function cT(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(cT=function(){return!!i})()}function P6(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function U6(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,o,u=[],c=!0,h=!1;try{if(s=(t=t.call(i)).next,e!==0)for(;!(c=(n=s.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(d){h=!0,r=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw r}}return u}}function O6(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function B6(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MR(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function F6(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?MR(Object(t),!0).forEach(function(n){t0(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):MR(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function I6(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return N6(i)}function kb(i,e){return kb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},kb(i,e)}function zd(i,e){return R6(i)||U6(i,e)||Y2(i,e)||O6()}function z6(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=kh(i))!==null;);return i}function Sx(i,e,t,n){var r=zb(kh(i.prototype),e,t);return typeof r=="function"?function(s){return r.apply(t,s)}:r}function Is(i){return C6(i)||P6(i)||Y2(i)||B6()}function k6(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function X2(i){var e=k6(i,"string");return typeof e=="symbol"?e:e+""}function Gb(i){"@babel/helpers - typeof";return Gb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gb(i)}function Y2(i,e){if(i){if(typeof i=="string")return Ib(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ib(i,e):void 0}}var K2=function(e){e instanceof Array?e.forEach(K2):(e.map&&e.map.dispose(),e.dispose())},Z2=function(e){e.geometry&&e.geometry.dispose(),e.material&&K2(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(Z2)},Vb=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),Z2(t)}},Tx=new WeakMap,Mg=new WeakMap,dd=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.dataBindAttr,o=s===void 0?"__data":s,u=r.objBindAttr,c=u===void 0?"__threeObj":u;return j2(this,e),n=H2(this,e),t0(n,"scene",void 0),SR(n,Tx,void 0),SR(n,Mg,void 0),n.scene=t,TR(Tx,n,o),TR(Mg,n,c),n.onRemoveObj(function(){}),n}return q2(e,i),$2(e,[{key:"onCreateObj",value:function(n){var r=this;return Sx(e,"onCreateObj",this)([function(s){var o=n(s);return s[bx(Mg,r)]=o,o[bx(Tx,r)]=s,r.scene.add(o),o}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return Sx(e,"onRemoveObj",this)([function(s,o){var u=Sx(e,"getData",r)([s]);n(s,o),r.scene.remove(s),Vb(s),delete u[bx(Mg,r)]}]),this}}])})(e6),pd=function(e){return isNaN(e)?parseInt(mt(e).toHex(),16):e},Mx=function(e){return isNaN(e)?mt(e).getAlpha():1},G6=z2(i6);function ER(i,e,t){!e||typeof t!="string"||i.filter(function(n){return!n[t]}).forEach(function(n){n[t]=G6(e(n))})}function V6(i,e){var t=i.nodes,n=i.links,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=r.nodeFilter,o=s===void 0?function(){return!0}:s,u=r.onLoopError,c=u===void 0?function(_){throw"Invalid DAG structure! Found cycle in node path: ".concat(_.join(" -> "),".")}:u,h={};t.forEach(function(_){return h[e(_)]={data:_,out:[],depth:-1,skip:!o(_)}}),n.forEach(function(_){var v=_.source,S=_.target,b=w(v),x=w(S);if(!h.hasOwnProperty(b))throw"Missing source node with id: ".concat(b);if(!h.hasOwnProperty(x))throw"Missing target node with id: ".concat(x);var M=h[b],E=h[x];M.out.push(E);function w(D){return Gb(D)==="object"?e(D):D}});var d=[];g(Object.values(h));var p=Object.assign.apply(Object,[{}].concat(Is(Object.entries(h).filter(function(_){var v=zd(_,2),S=v[1];return!S.skip}).map(function(_){var v=zd(_,2),S=v[0],b=v[1];return t0({},S,b.depth)}))));return p;function g(_){for(var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,b=function(){var w=_[x];if(v.indexOf(w)!==-1){var D=[].concat(Is(v.slice(v.indexOf(w))),[w]).map(function(C){return e(C.data)});return d.some(function(C){return C.length===D.length&&C.every(function(N,A){return N===D[A]})})||(d.push(D),c(D)),1}S>w.depth&&(w.depth=S,g(w.out,[].concat(Is(v),[w]),S+(w.skip?0:1)))},x=0,M=_.length;x<M;x++)b()}}var Mt=window.THREE?window.THREE:{Group:Jc,Mesh:xi,MeshLambertMaterial:r2,Color:pt,BufferGeometry:Fi,BufferAttribute:$i,Matrix4:Wt,Vector3:G,SphereGeometry:Ap,CylinderGeometry:Mp,TubeGeometry:iT,ConeGeometry:eT,Line:DB,LineBasicMaterial:q_,QuadraticBezierCurve3:nT,CubicBezierCurve3:e2,Box3:Iu},AR={graph:GV,forcelayout:e5},H6=2,Ex=new Mt.BufferGeometry().setAttribute?"setAttribute":"addAttribute",Eg=new Mt.BufferGeometry().applyMatrix4?"applyMatrix4":"applyMatrix",j6=J_({props:{jsonUrl:{onChange:function(e,t){var n=this;e&&!t.fetchingJson&&(t.fetchingJson=!0,t.onLoading(),fetch(e).then(function(r){return r.json()}).then(function(r){t.fetchingJson=!1,t.onFinishLoading(r),n.graphData(r)}))},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(e,t){t.engineRunning=!1}},numDimensions:{default:3,onChange:function(e,t){var n=t.d3ForceLayout.force("charge");n&&n.strength(e>2?-60:-30),e<3&&r(t.graphData.nodes,"z"),e<2&&r(t.graphData.nodes,"y");function r(s,o){s.forEach(function(u){delete u[o],delete u["v".concat(o)]})}}},dagMode:{onChange:function(e,t){!e&&t.forceEngine==="d3"&&(t.graphData.nodes||[]).forEach(function(n){return n.fx=n.fy=n.fz=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(e){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4},nodeId:{default:"id"},nodeVal:{default:"val"},nodeResolution:{default:8},nodeColor:{default:"color"},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeVisibility:{default:!0},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},nodePositionUpdate:{triggerUpdate:!1},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0},linkColor:{default:"color"},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{},linkResolution:{default:6},linkCurvature:{default:0,triggerUpdate:!1},linkCurveRotation:{default:0,triggerUpdate:!1},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{triggerUpdate:!1},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:"d3"},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaDecay(e)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaTarget(e)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.velocityDecay(e)}},ngraphPhysics:{default:{timeStep:20,gravity:-1.2,theta:.8,springLength:30,springCoefficient:8e-4,dragCoefficient:.02}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onLoading:{default:function(){},triggerUpdate:!1},onFinishLoading:{default:function(){},triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1}},methods:{refresh:function(e){return e._flushObjects=!0,e._rerender(),this},d3Force:function(e,t,n){return n===void 0?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,n),this)},d3ReheatSimulation:function(e){return e.d3ForceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(e){return e.cntTicks=0,e.startTickTime=new Date,e.engineRunning=!0,this},tickFrame:function(e){var t=e.forceEngine!=="ngraph";return e.engineRunning&&n(),r(),s(),this;function n(){++e.cntTicks>e.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||t&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin?(e.engineRunning=!1,e.onEngineStop()):(e.layout[t?"tick":"step"](),e.onEngineTick());var o=Zt(e.nodeThreeObjectExtend);e.nodeDataMapper.entries().forEach(function(g){var _=zd(g,2),v=_[0],S=_[1];if(S){var b=t?v:e.layout.getNodePosition(v[e.nodeId]),x=o(v);(!e.nodePositionUpdate||!e.nodePositionUpdate(x?S.children[0]:S,{x:b.x,y:b.y,z:b.z},v)||x)&&(S.position.x=b.x,S.position.y=b.y||0,S.position.z=b.z||0)}});var u=Zt(e.linkWidth),c=Zt(e.linkCurvature),h=Zt(e.linkCurveRotation),d=Zt(e.linkThreeObjectExtend);e.linkDataMapper.entries().forEach(function(g){var _=zd(g,2),v=_[0],S=_[1];if(S){var b=t?v:e.layout.getLinkPosition(e.layout.graph.getLink(v.source,v.target).id),x=b[t?"source":"from"],M=b[t?"target":"to"];if(!(!x||!M||!x.hasOwnProperty("x")||!M.hasOwnProperty("x"))){p(v);var E=d(v);if(!(e.linkPositionUpdate&&e.linkPositionUpdate(E?S.children[1]:S,{start:{x:x.x,y:x.y,z:x.z},end:{x:M.x,y:M.y,z:M.z}},v)&&!E)){var w=30,D=v.__curve,C=S.children.length?S.children[0]:S;if(C.type==="Line"){if(D){var A=D.getPoints(w);C.geometry.getAttribute("position").array.length!==A.length*3&&C.geometry[Ex]("position",new Mt.BufferAttribute(new Float32Array(A.length*3),3)),C.geometry.setFromPoints(A)}else{var N=C.geometry.getAttribute("position");(!N||!N.array||N.array.length!==6)&&C.geometry[Ex]("position",N=new Mt.BufferAttribute(new Float32Array(6),3)),N.array[0]=x.x,N.array[1]=x.y||0,N.array[2]=x.z||0,N.array[3]=M.x,N.array[4]=M.y||0,N.array[5]=M.z||0,N.needsUpdate=!0}C.geometry.computeBoundingSphere()}else if(C.type==="Mesh")if(D){C.geometry.type.match(/^Tube(Buffer)?Geometry$/)||(C.position.set(0,0,0),C.rotation.set(0,0,0),C.scale.set(1,1,1));var Z=Math.ceil(u(v)*10)/10,I=Z/2,F=new Mt.TubeGeometry(D,w,I,e.linkResolution,!1);C.geometry.dispose(),C.geometry=F}else{if(!C.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)){var L=Math.ceil(u(v)*10)/10,j=L/2,z=new Mt.CylinderGeometry(j,j,1,e.linkResolution,1,!1);z[Eg](new Mt.Matrix4().makeTranslation(0,1/2,0)),z[Eg](new Mt.Matrix4().makeRotationX(Math.PI/2)),C.geometry.dispose(),C.geometry=z}var H=new Mt.Vector3(x.x,x.y||0,x.z||0),K=new Mt.Vector3(M.x,M.y||0,M.z||0),te=H.distanceTo(K);C.position.x=H.x,C.position.y=H.y,C.position.z=H.z,C.scale.z=te,C.parent.localToWorld(K),C.lookAt(K)}}}}});function p(g){var _=t?g:e.layout.getLinkPosition(e.layout.graph.getLink(g.source,g.target).id),v=_[t?"source":"from"],S=_[t?"target":"to"];if(!(!v||!S||!v.hasOwnProperty("x")||!S.hasOwnProperty("x"))){var b=c(g);if(!b)g.__curve=null;else{var x=new Mt.Vector3(v.x,v.y||0,v.z||0),M=new Mt.Vector3(S.x,S.y||0,S.z||0),E=x.distanceTo(M),w,D=h(g);if(E>0){var C=S.x-v.x,N=S.y-v.y||0,A=new Mt.Vector3().subVectors(M,x),L=A.clone().multiplyScalar(b).cross(C!==0||N!==0?new Mt.Vector3(0,0,1):new Mt.Vector3(0,1,0)).applyAxisAngle(A.normalize(),D).add(new Mt.Vector3().addVectors(x,M).divideScalar(2));w=new Mt.QuadraticBezierCurve3(x,L,M)}else{var j=b*70,z=-D,H=z+Math.PI/2;w=new Mt.CubicBezierCurve3(x,new Mt.Vector3(j*Math.cos(H),j*Math.sin(H),0).add(x),new Mt.Vector3(j*Math.cos(z),j*Math.sin(z),0).add(x),M)}g.__curve=w}}}}function r(){var o=Zt(e.linkDirectionalArrowRelPos),u=Zt(e.linkDirectionalArrowLength),c=Zt(e.nodeVal);e.arrowDataMapper.entries().forEach(function(h){var d=zd(h,2),p=d[0],g=d[1];if(g){var _=t?p:e.layout.getLinkPosition(e.layout.graph.getLink(p.source,p.target).id),v=_[t?"source":"from"],S=_[t?"target":"to"];if(!(!v||!S||!v.hasOwnProperty("x")||!S.hasOwnProperty("x"))){var b=Math.cbrt(Math.max(0,c(v)||1))*e.nodeRelSize,x=Math.cbrt(Math.max(0,c(S)||1))*e.nodeRelSize,M=u(p),E=o(p),w=p.__curve?function(j){return p.__curve.getPoint(j)}:function(j){var z=function(K,te,Z,I){return te[K]+(Z[K]-te[K])*I||0};return{x:z("x",v,S,j),y:z("y",v,S,j),z:z("z",v,S,j)}},D=p.__curve?p.__curve.getLength():Math.sqrt(["x","y","z"].map(function(j){return Math.pow((S[j]||0)-(v[j]||0),2)}).reduce(function(j,z){return j+z},0)),C=b+M+(D-b-x-M)*E,N=w(C/D),A=w((C-M)/D);["x","y","z"].forEach(function(j){return g.position[j]=A[j]});var L=W2(Mt.Vector3,Is(["x","y","z"].map(function(j){return N[j]})));g.parent.localToWorld(L),g.lookAt(L)}}})}function s(){var o=Zt(e.linkDirectionalParticleSpeed),u=Zt(e.linkDirectionalParticleOffset);e.graphData.links.forEach(function(c){var h=e.particlesDataMapper.getObj(c),d=h&&h.children,p=c.__singleHopPhotonsObj&&c.__singleHopPhotonsObj.children;if(!((!p||!p.length)&&(!d||!d.length))){var g=t?c:e.layout.getLinkPosition(e.layout.graph.getLink(c.source,c.target).id),_=g[t?"source":"from"],v=g[t?"target":"to"];if(!(!_||!v||!_.hasOwnProperty("x")||!v.hasOwnProperty("x"))){var S=o(c),b=Math.abs(u(c)),x=c.__curve?function(E){return c.__curve.getPoint(E)}:function(E){var w=function(C,N,A,L){return N[C]+(A[C]-N[C])*L||0};return{x:w("x",_,v,E),y:w("y",_,v,E),z:w("z",_,v,E)}},M=[].concat(Is(d||[]),Is(p||[]));M.forEach(function(E,w){var D=E.parent.__linkThreeObjType==="singleHopPhotons";if(E.hasOwnProperty("__progressRatio")||(E.__progressRatio=D?0:(w+b)/d.length),E.__progressRatio+=S,E.__progressRatio>=1)if(!D)E.__progressRatio=E.__progressRatio%1;else{E.parent.remove(E),Vb(E);return}var C=E.__progressRatio,N=x(C);E.geometry.type!=="SphereGeometry"&&E.lookAt(N.x,N.y,N.z),["x","y","z"].forEach(function(A){return E.position[A]=N[A]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var n=new Mt.Group;n.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=n,e.graphScene.add(n)}var r=Zt(e.linkDirectionalParticleThreeObject)(t);if(r&&e.linkDirectionalParticleThreeObject===r&&(r=r.clone()),!r){var s=Zt(e.linkDirectionalParticleWidth),o=Math.ceil(s(t)*10)/10/2,u=e.linkDirectionalParticleResolution,c=new Mt.SphereGeometry(o,u,u),h=Zt(e.linkColor),d=Zt(e.linkDirectionalParticleColor),p=d(t)||h(t)||"#f0f0f0",g=new Mt.Color(pd(p)),_=e.linkOpacity*3,v=new Mt.MeshLambertMaterial({color:g,transparent:!0,opacity:_});r=new Mt.Mesh(c,v)}t.__singleHopPhotonsObj.add(r)}return this},getGraphBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0};if(!e.initialised)return null;var n=(function r(s){var o=[];if(s.geometry){s.geometry.computeBoundingBox();var u=new Mt.Box3;u.copy(s.geometry.boundingBox).applyMatrix4(s.matrixWorld),o.push(u)}return o.concat.apply(o,Is((s.children||[]).filter(function(c){return!c.hasOwnProperty("__graphObjType")||c.__graphObjType==="node"&&t(c.__data)}).map(r)))})(e.graphScene);return n.length?Object.assign.apply(Object,Is(["x","y","z"].map(function(r){return t0({},r,[z5(n,function(s){return s.min[r]}),I5(n,function(s){return s.max[r]})])}))):null}},stateInit:function(){return{d3ForceLayout:OV().force("link",xV()).force("charge",BV()).force("center",S4()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new dd(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new dd(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new dd(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new dd(e,{objBindAttr:"__photonsObj"})},update:function(e,t){var n=function($){return $.some(function(ue){return t.hasOwnProperty(ue)})};if(e.engineRunning=!1,typeof e.onUpdate=="function"&&e.onUpdate(),e.nodeAutoColorBy!==null&&n(["nodeAutoColorBy","graphData","nodeColor"])&&ER(e.graphData.nodes,Zt(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&n(["linkAutoColorBy","graphData","linkColor"])&&ER(e.graphData.links,Zt(e.linkAutoColorBy),e.linkColor),e._flushObjects||n(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var r=Zt(e.nodeThreeObject),s=Zt(e.nodeThreeObjectExtend),o=Zt(e.nodeVal),u=Zt(e.nodeColor),c=Zt(e.nodeVisibility),h={},d={};(e._flushObjects||n(["nodeThreeObject","nodeThreeObjectExtend"]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(ee){var $=r(ee),ue=s(ee);$&&e.nodeThreeObject===$&&($=$.clone());var Ee;return $&&!ue?Ee=$:(Ee=new Mt.Mesh,Ee.__graphDefaultObj=!0,$&&ue&&Ee.add($)),Ee.__graphObjType="node",Ee}).onUpdateObj(function(ee,$){if(ee.__graphDefaultObj){var ue=o($)||1,Ee=Math.cbrt(ue)*e.nodeRelSize,ke=e.nodeResolution;(!ee.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||ee.geometry.parameters.radius!==Ee||ee.geometry.parameters.widthSegments!==ke)&&(h.hasOwnProperty(ue)||(h[ue]=new Mt.SphereGeometry(Ee,ke,ke)),ee.geometry.dispose(),ee.geometry=h[ue]);var We=u($),Ke=new Mt.Color(pd(We||"#ffffaa")),sn=e.nodeOpacity*Mx(We);(ee.material.type!=="MeshLambertMaterial"||!ee.material.color.equals(Ke)||ee.material.opacity!==sn)&&(d.hasOwnProperty(We)||(d[We]=new Mt.MeshLambertMaterial({color:Ke,transparent:!0,opacity:sn})),ee.material.dispose(),ee.material=d[We])}}).digest(e.graphData.nodes.filter(c))}if(e._flushObjects||n(["graphData","linkThreeObject","linkThreeObjectExtend","linkMaterial","linkColor","linkWidth","linkVisibility","linkResolution","linkOpacity","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject"])){var p=Zt(e.linkThreeObject),g=Zt(e.linkThreeObjectExtend),_=Zt(e.linkMaterial),v=Zt(e.linkVisibility),S=Zt(e.linkColor),b=Zt(e.linkWidth),x={},M={},E={},w=e.graphData.links.filter(v);if((e._flushObjects||n(["linkThreeObject","linkThreeObjectExtend","linkWidth"]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(ee){var $=ee.__data&&ee.__data.__singleHopPhotonsObj;$&&($.parent.remove($),Vb($),delete ee.__data.__singleHopPhotonsObj)}).onCreateObj(function(ee){var $=p(ee),ue=g(ee);$&&e.linkThreeObject===$&&($=$.clone());var Ee;if(!$||ue){var ke=!!b(ee);if(ke)Ee=new Mt.Mesh;else{var We=new Mt.BufferGeometry;We[Ex]("position",new Mt.BufferAttribute(new Float32Array(6),3)),Ee=new Mt.Line(We)}}var Ke;return $?ue?(Ke=new Mt.Group,Ke.__graphDefaultObj=!0,Ke.add(Ee),Ke.add($)):Ke=$:(Ke=Ee,Ke.__graphDefaultObj=!0),Ke.renderOrder=10,Ke.__graphObjType="link",Ke}).onUpdateObj(function(ee,$){if(ee.__graphDefaultObj){var ue=ee.children.length?ee.children[0]:ee,Ee=Math.ceil(b($)*10)/10,ke=!!Ee;if(ke){var We=Ee/2,Ke=e.linkResolution;if(!ue.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||ue.geometry.parameters.radiusTop!==We||ue.geometry.parameters.radialSegments!==Ke){if(!x.hasOwnProperty(Ee)){var sn=new Mt.CylinderGeometry(We,We,1,Ke,1,!1);sn[Eg](new Mt.Matrix4().makeTranslation(0,1/2,0)),sn[Eg](new Mt.Matrix4().makeRotationX(Math.PI/2)),x[Ee]=sn}ue.geometry.dispose(),ue.geometry=x[Ee]}}var Ut=_($);if(Ut)ue.material=Ut;else{var Rt=S($),qt=new Mt.Color(pd(Rt||"#f0f0f0")),St=e.linkOpacity*Mx(Rt),on=ke?"MeshLambertMaterial":"LineBasicMaterial";if(ue.material.type!==on||!ue.material.color.equals(qt)||ue.material.opacity!==St){var Q=ke?M:E;Q.hasOwnProperty(Rt)||(Q[Rt]=new Mt[on]({color:qt,transparent:St<1,opacity:St,depthWrite:St>=1})),ue.material.dispose(),ue.material=Q[Rt]}}}}).digest(w),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var D=Zt(e.linkDirectionalArrowLength),C=Zt(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var ee=new Mt.Mesh(void 0,new Mt.MeshLambertMaterial({transparent:!0}));return ee.__linkThreeObjType="arrow",ee}).onUpdateObj(function(ee,$){var ue=D($),Ee=e.linkDirectionalArrowResolution;if(!ee.geometry.type.match(/^Cone(Buffer)?Geometry$/)||ee.geometry.parameters.height!==ue||ee.geometry.parameters.radialSegments!==Ee){var ke=new Mt.ConeGeometry(ue*.25,ue,Ee);ke.translate(0,ue/2,0),ke.rotateX(Math.PI/2),ee.geometry.dispose(),ee.geometry=ke}var We=C($)||S($)||"#f0f0f0";ee.material.color=new Mt.Color(pd(We)),ee.material.opacity=e.linkOpacity*3*Mx(We)}).digest(w.filter(D))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var N=Zt(e.linkDirectionalParticles),A=Zt(e.linkDirectionalParticleWidth),L=Zt(e.linkDirectionalParticleColor),j=Zt(e.linkDirectionalParticleThreeObject),z={},H={};e.particlesDataMapper.onCreateObj(function(){var ee=new Mt.Group;return ee.__linkThreeObjType="photons",ee.__photonDataMapper=new dd(ee),ee}).onUpdateObj(function(ee,$){var ue=!!ee.children.length&&ee.children[0],Ee=j($),ke,We;if(Ee)ke=Ee.geometry,We=Ee.material;else{var Ke=Math.ceil(A($)*10)/10/2,sn=e.linkDirectionalParticleResolution;ue&&ue.geometry.parameters.radius===Ke&&ue.geometry.parameters.widthSegments===sn?ke=ue.geometry:(H.hasOwnProperty(Ke)||(H[Ke]=new Mt.SphereGeometry(Ke,sn,sn)),ke=H[Ke]);var Ut=L($)||S($)||"#f0f0f0",Rt=new Mt.Color(pd(Ut)),qt=e.linkOpacity*3;ue&&ue.material.color.equals(Rt)&&ue.material.opacity===qt?We=ue.material:(z.hasOwnProperty(Ut)||(z[Ut]=new Mt.MeshLambertMaterial({color:Rt,transparent:!0,opacity:qt})),We=z[Ut])}ue&&(ue.geometry!==ke&&ue.geometry.dispose(),ue.material!==We&&ue.material.dispose());var St=Math.round(Math.abs(N($)));ee.__photonDataMapper.id(function(on){return on.idx}).onCreateObj(function(){return new Mt.Mesh(ke,We)}).onUpdateObj(function(on){on.geometry=ke,on.material=We}).digest(Is(new Array(St)).map(function(on,Q){return{idx:Q}}))}).digest(w.filter(N))}}if(e._flushObjects=!1,n(["graphData","nodeId","linkSource","linkTarget","numDimensions","forceEngine","dagMode","dagNodeFilter","dagLevelDistance"])){e.engineRunning=!1,e.graphData.links.forEach(function(ee){ee.source=ee[e.linkSource],ee.target=ee[e.linkTarget]});var K=e.forceEngine!=="ngraph",te;if(K){(te=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var Z=e.d3ForceLayout.force("link");Z&&Z.id(function(ee){return ee[e.nodeId]}).links(e.graphData.links);var I=e.dagMode&&V6(e.graphData,function(ee){return ee[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),F=Math.max.apply(Math,Is(Object.values(I||[]))),Y=e.dagLevelDistance||e.graphData.nodes.length/(F||1)*H6*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu","zin","zout"].includes(t.dagMode)){var se=["lr","rl"].includes(t.dagMode)?"fx":["td","bu"].includes(t.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(ee){return delete ee[se]})}if(["lr","rl","td","bu","zin","zout"].includes(e.dagMode)){var Te=["rl","td","zout"].includes(e.dagMode),O=function($){return(I[$[e.nodeId]]-F/2)*Y*(Te?-1:1)},W=["lr","rl"].includes(e.dagMode)?"fx":["td","bu"].includes(e.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(ee){return ee[W]=O(ee)})}e.d3ForceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?FV(function(ee){var $=I[ee[e.nodeId]]||-1;return(e.dagMode==="radialin"?F-$:$)*Y}).strength(function(ee){return e.dagNodeFilter(ee)?1:0}):null)}else{var ce=AR.graph();e.graphData.nodes.forEach(function(ee){ce.addNode(ee[e.nodeId])}),e.graphData.links.forEach(function(ee){ce.addLink(ee.source,ee.target)}),te=AR.forcelayout(ce,F6({dimensions:e.numDimensions},e.ngraphPhysics)),te.graph=ce}for(var Le=0;Le<e.warmupTicks&&!(K&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin);Le++)te[K?"tick":"step"]();e.layout=te,this.resetCountdown()}e.engineRunning=!0,e.onFinishUpdate()}});function W6(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=(function(r){function s(){var o;j2(this,s);for(var u=arguments.length,c=new Array(u),h=0;h<u;h++)c[h]=arguments[h];return o=H2(this,s,[].concat(c)),o.__kapsuleInstance=W2(i,[].concat(Is(t?[o]:[]),c)),o}return q2(s,r),$2(s)})(e);return Object.keys(i()).forEach(function(r){return n.prototype[r]=function(){var s,o=(s=this.__kapsuleInstance)[r].apply(s,arguments);return o===this.__kapsuleInstance?this:o}}),n}var $6=window.THREE?window.THREE:{Group:Jc},Q2=W6(j6,$6.Group,!0);/**
 * @license
 * Copyright 2010-2026 Three.js Authors
 * SPDX-License-Identifier: MIT
 */const q6=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],Ax=new WeakMap;class X6{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=q6,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){const t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:n,material:r,object:s}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexId:n.index?n.index.id:null,indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:s.matrixWorld.clone()},s.center&&(t.center=s.center.clone()),s.morphTargetInfluences&&(t.morphTargetInfluences=s.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:o,height:u}=e.context;t.bufferWidth=o,t.bufferHeight=u}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={id:r.id,version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e,t){const{object:n,material:r,geometry:s}=e,o=this.getRenderObjectData(e);if(o.worldMatrix.equals(n.matrixWorld)!==!0)return o.worldMatrix.copy(n.matrixWorld),!1;const u=o.material;for(const M in u){const E=u[M],w=r[M];if(E.equals!==void 0){if(E.equals(w)===!1)return E.copy(w),!1}else if(w.isTexture===!0){if(E.id!==w.id||E.version!==w.version)return E.id=w.id,E.version=w.version,!1}else if(E!==w)return u[M]=w,!1}if(u.transmission>0){const{width:M,height:E}=e.context;if(o.bufferWidth!==M||o.bufferHeight!==E)return o.bufferWidth=M,o.bufferHeight=E,!1}const c=o.geometry,h=s.attributes,d=c.attributes,p=Object.keys(d),g=Object.keys(h);if(c.id!==s.id)return c.id=s.id,!1;if(p.length!==g.length)return o.geometry.attributes=this.getAttributesData(h),!1;for(const M of p){const E=d[M],w=h[M];if(w===void 0)return delete d[M],!1;if(E.id!==w.id||E.version!==w.version)return E.id=w.id,E.version=w.version,!1}const _=s.index,v=c.indexId,S=c.indexVersion,b=_?_.id:null,x=_?_.version:null;if(v!==b||S!==x)return c.indexId=b,c.indexVersion=x,!1;if(c.drawRange.start!==s.drawRange.start||c.drawRange.count!==s.drawRange.count)return c.drawRange.start=s.drawRange.start,c.drawRange.count=s.drawRange.count,!1;if(o.morphTargetInfluences){let M=!1;for(let E=0;E<o.morphTargetInfluences.length;E++)o.morphTargetInfluences[E]!==n.morphTargetInfluences[E]&&(o.morphTargetInfluences[E]=n.morphTargetInfluences[E],M=!0);if(M)return!1}if(o.lights){for(let M=0;M<t.length;M++)if(o.lights[M].map!==t[M].map)return!1}return o.center&&o.center.equals(n.center)===!1?(o.center.copy(n.center),!0):(e.bundle!==null&&(o.version=e.bundle.version),!0)}getLightsData(e){const t=[];for(const n of e)n.isSpotLight===!0&&n.map!==null&&t.push({map:n.map.version});return t}getLights(e,t){if(Ax.has(e)){const r=Ax.get(e);if(r.renderId===t)return r.lightsData}const n=this.getLightsData(e.getLights());return Ax.set(e,{renderId:t,lightsData:n}),n}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;const r=e.object.static===!0,s=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||s)return!1;const o=this.getLights(e.lightsNode,n);return this.equals(e,o)!==!0}}const Y6=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];function K6(i){const e=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return i.split(`
`).map(t=>{const n=t.match(e);if(!n)return null;const r=n[1]||n[2]||"",s=n[3].split("?")[0],o=parseInt(n[4],10),u=parseInt(n[5],10),c=s.split("/").pop();return{fn:r,file:c,line:o,column:u}}).filter(t=>t&&!Y6.some(n=>n.test(t.file)))}class rr{constructor(e=null){this.isStackTrace=!0,this.stack=K6(e||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(this.stack.length===0)return e;const t=this.stack.map(n=>{const r=`${n.file}:${n.line}:${n.column}`;return n.fn?`    at ${n.fn} (${r})`:`    at ${r}`}).join(`
`);return`${e}
${t}`}}function hT(i,e=0){let t=3735928559^e,n=1103547991^e;if(i instanceof Array)for(let r=0,s;r<i.length;r++)s=i[r],t=Math.imul(t^s,2654435761),n=Math.imul(n^s,1597334677);else for(let r=0,s;r<i.length;r++)s=i.charCodeAt(r),t=Math.imul(t^s,2654435761),n=Math.imul(n^s,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const ef=i=>hT(i),wp=i=>hT(i),kd=(...i)=>hT(i),Z6=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),wR=new WeakMap;function J2(i){return Z6.get(i)}function M_(i){if(i==null)return null;const e=typeof i;return i.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":i.isVector2===!0?"vec2":i.isVector3===!0?"vec3":i.isVector4===!0?"vec4":i.isMatrix2===!0?"mat2":i.isMatrix3===!0?"mat3":i.isMatrix4===!0?"mat4":i.isColor===!0?"color":i instanceof ArrayBuffer?"ArrayBuffer":null}function fT(i,...e){const t=i?i.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),i==="color"?new pt(...e):t==="vec2"?new Ie(...e):t==="vec3"?new G(...e):t==="vec4"?new Pt(...e):t==="mat2"?new X_(...e):t==="mat3"?new Nt(...e):t==="mat4"?new Wt(...e):i==="bool"?e[0]||!1:i==="float"||i==="int"||i==="uint"?e[0]||0:i==="string"?e[0]||"":i==="ArrayBuffer"?J6(e[0]):null}function eD(i){let e=wR.get(i);return e===void 0&&(e={},wR.set(i,e)),e}function Q6(i){let e="";const t=new Uint8Array(i);for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function J6(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0)).buffer}const Ag={VERTEX:"vertex"},Dt={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},ys={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},eH=["fragment","vertex"],RR=["setup","analyze","generate"],CR=[...eH,"compute"],tf=["x","y","z","w"],tH={analyze:"setup",generate:"analyze"};let nH=0;class ct extends Aa{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Dt.NONE,this.updateBeforeType=Dt.NONE,this.updateAfterType=Dt.NONE,this.uuid=g_.generateUUID(),this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:nH++}),this.stackTrace=null,ct.captureStackTrace===!0&&(this.stackTrace=new rr)}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,Dt.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Dt.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Dt.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const n of Object.getOwnPropertyNames(this)){const r=this[n];if(!(n.startsWith("_")===!0||e.has(r))){if(Array.isArray(r)===!0)for(let s=0;s<r.length;s++){const o=r[s];o&&o.isNode===!0&&t.push({property:n,index:s,childNode:o})}else if(r&&r.isNode===!0)t.push({property:n,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(const s in r){if(s.startsWith("_")===!0)continue;const o=r[s];o&&o.isNode===!0&&t.push({property:n,index:s,childNode:o})}}}return t}getCacheKey(e=!1,t=null){if(e=e||this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);const n=[];for(const{property:r,childNode:s}of this._getChildren(t))n.push(ef(r.slice(0,-4)),s.getCacheKey(e,t));this._cacheKey=kd(wp(n),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e,t=null){const n=e.increaseUsage(this);if(this.parents===!0){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(n===1){const r=e.getNodeProperties(this);for(const s of Object.values(r))s&&s.isNode===!0&&s.build(e,this)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){Ne("Abstract function.")}updateAfter(){Ne("Abstract function.")}update(){Ne("Abstract function.")}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);if(this._beforeNodes!==null){const c=this._beforeNodes;this._beforeNodes=null;for(const h of c)h.build(e,t);this._beforeNodes=c}const r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;const s=tH[e.buildStage];if(s&&r.buildStages[s]!==!0){const c=e.getBuildStage();e.setBuildStage(s),this.build(e),e.setBuildStage(c)}e.addChain(this);let o=null;const u=e.getBuildStage();if(u==="setup"){e.addNode(this),this.updateReference(e);const c=e.getNodeProperties(this);if(c.initialized!==!0){c.initialized=!0,c.outputNode=this.setup(e)||c.outputNode||null;for(const h of Object.values(c))if(h&&h.isNode===!0){if(h.parents===!0){const d=e.getNodeProperties(h);d.parents=d.parents||[],d.parents.push(this)}h.build(e)}e.addSequentialNode(this)}o=c.outputNode}else if(u==="analyze")this.analyze(e,t);else if(u==="generate"){if(this.generate.length<2){const h=this.getNodeType(e),d=e.getDataFromNode(this);o=d.snippet,o===void 0?d.generated===void 0?(d.generated=!0,o=this.generate(e)||"",d.snippet=o):(Ne("Node: Recursion detected.",this),o="/* Recursion detected. */"):d.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),o=e.format(o,h,t)}else o=this.generate(e,t)||"";o===""&&t!==null&&t!=="void"&&t!=="OutputType"&&(Pe(`TSL: Invalid generated code, expected a "${t}".`),o=e.generateConst(t))}return e.removeChain(this),o}getSerializeChildren(){return this._getChildren()}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:s,childNode:o}of t)s!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(s)?[]:{}),n[r][s]=o.toJSON(e.meta).uuid):n[r]=o.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const s of e.inputNodes[n])r.push(t[s]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const s in e.inputNodes[n]){const o=e.inputNodes[n][s];r[s]=t[o]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:n,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function o(u){const c=[];for(const h in u){const d=u[h];delete d.metadata,c.push(d)}return c}if(r){const u=o(e.textures),c=o(e.images),h=o(e.nodes);u.length>0&&(s.textures=u),c.length>0&&(s.images=c),h.length>0&&(s.nodes=h)}return s}}ct.captureStackTrace=!1;class nf extends ct{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){const t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${r} ]`}}class tD extends ct{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),s=n.build(e,r);return e.format(s,r,t)}}class bi extends ct{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const o=super.build(e,r),u=e.getVarFromNode(this,null,r),c=e.getPropertyName(u);return e.addLineFlowCode(`${c} = ${o}`,this),s.snippet=o,s.propertyName=c,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class iH extends bi{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=e.getTypeLength(n),s=this.nodes,o=e.getComponentType(n),u=[];let c=0;for(const d of s){if(c>=r){Pe(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`,this.stackTrace);break}let p=d.getNodeType(e),g=e.getTypeLength(p),_;if(c+g>r&&(Pe(`TSL: Length of '${n}()' data exceeds maximum length of output type.`,this.stackTrace),g=r-c,p=e.getTypeFromLength(g)),c+=g,_=d.build(e,p),e.getComponentType(p)!==o){const S=e.getTypeFromLength(g,o);_=e.format(_,p,S)}u.push(_)}const h=`${e.getType(n)}( ${u.join(", ")} )`;return e.format(h,n,t)}}const rH=tf.join("");class sH extends ct{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(tf.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let s=null;if(r>1){let o=null;this.getVectorLength()>=r&&(o=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const c=n.build(e,o);this.components.length===r&&this.components===rH.slice(0,this.components.length)?s=e.format(c,o,t):s=e.format(`${c}.${this.components}`,this.getNodeType(e),t)}else s=n.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class aH extends bi{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,s=this.getNodeType(e),o=e.getComponentType(r.getNodeType(e)),u=e.getTypeFromLength(n.length,o),c=r.build(e,u),h=t.build(e,s),d=e.getTypeLength(s),p=[];for(let g=0;g<d;g++){const _=tf[g];_===n[0]?(p.push(c),g+=n.length-1):p.push(h+"."+_)}return`${e.getType(s)}( ${p.join(", ")} )`}}class oH extends bi{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:n}=this,r=this.getNodeType(e),s=n.build(e),o=e.getVarFromNode(this),u=e.getPropertyName(o);e.addLineFlowCode(u+" = "+s,this);const c=e.getTypeLength(r),h=[];let d=0;for(let p=0;p<c;p++){const g=tf[p];g===t[d]?(h.push("1.0 - "+(u+"."+g)),d++):h.push(u+"."+g)}return`${e.getType(r)}( ${h.join(", ")} )`}}class dT extends ct{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?M_(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=M_(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=Q6(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?fT(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){Ne("Abstract function.")}}const NR=/float|u?int/;class wa extends dT{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const n=this.getNodeType(e);return NR.test(n)&&NR.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}}class lH extends ct{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!=="void"}getNodeType(e){return this.hasMember(e)===!1?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return"float";const n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){Ne(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);const n=this.getNodeType(e);return e.generateConst(n)}return this.structNode.build(e)+"."+this.property}}let Lu=null;const Hb=new Map;function xe(i,e){if(Hb.has(i)){Ne(`TSL: Redefinition of method chaining '${i}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${i} is not a function`);Hb.set(i,e),i!=="assign"&&(ct.prototype[i]=function(...t){return this.isStackNode?this.addToStack(e(...t)):e(this,...t)},ct.prototype[i+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}const uH=i=>i.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),DR=i=>uH(i).split("").sort().join("");ct.prototype.assign=function(...i){if(this.isStackNode!==!0)return Lu!==null?Lu.assign(this,...i):Pe("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new rr),this;{const e=Hb.get("assign");return this.addToStack(e(...i))}};ct.prototype.toVarIntent=function(){return this};ct.prototype.get=function(i){return new lH(this,i)};const Gd={};function wg(i,e,t){Gd[i]=Gd[e]=Gd[t]={get(){this._cache=this._cache||{};let o=this._cache[i];return o===void 0&&(o=new sH(this,i),this._cache[i]=o),o},set(o){this[i].assign(ot(o))}};const n=i.toUpperCase(),r=e.toUpperCase(),s=t.toUpperCase();ct.prototype["set"+n]=ct.prototype["set"+r]=ct.prototype["set"+s]=function(o){const u=DR(i);return new aH(this,u,ot(o))},ct.prototype["flip"+n]=ct.prototype["flip"+r]=ct.prototype["flip"+s]=function(){const o=DR(i);return new oH(this,o)}}const ea=["x","y","z","w"],ta=["r","g","b","a"],na=["s","t","p","q"];for(let i=0;i<4;i++){let e=ea[i],t=ta[i],n=na[i];wg(e,t,n);for(let r=0;r<4;r++){e=ea[i]+ea[r],t=ta[i]+ta[r],n=na[i]+na[r],wg(e,t,n);for(let s=0;s<4;s++){e=ea[i]+ea[r]+ea[s],t=ta[i]+ta[r]+ta[s],n=na[i]+na[r]+na[s],wg(e,t,n);for(let o=0;o<4;o++)e=ea[i]+ea[r]+ea[s]+ea[o],t=ta[i]+ta[r]+ta[s]+ta[o],n=na[i]+na[r]+na[s]+na[o],wg(e,t,n)}}}for(let i=0;i<32;i++)Gd[i]={get(){this._cache=this._cache||{};let e=this._cache[i];return e===void 0&&(e=new nf(this,new wa(i,"uint")),this._cache[i]=e),e},set(e){this[i].assign(ot(e))}};Object.defineProperties(ct.prototype,Gd);const LR=new WeakMap,cH=function(i,e=null){const t=M_(i);return t==="node"?i:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?ot(jb(i,e)):t==="shader"?i.isFn?i:Se(i):i},hH=function(i,e=null){for(const t in i)i[t]=ot(i[t],e);return i},fH=function(i,e=null){const t=i.length;for(let n=0;n<t;n++)i[n]=ot(i[n],e);return i},nD=function(i,e=null,t=null,n=null){function r(d){return n!==null?(d=ot(Object.assign(d,n)),n.intent===!0&&(d=d.toVarIntent())):d=ot(d),d}let s,o=e,u,c;function h(d){let p;return o?p=/[a-z]/i.test(o)?o+"()":o:p=i.type,u!==void 0&&d.length<u?(Pe(`TSL: "${p}" parameter length is less than minimum required.`,new rr),d.concat(new Array(u-d.length).fill(0))):c!==void 0&&d.length>c?(Pe(`TSL: "${p}" parameter length exceeds limit.`,new rr),d.slice(0,c)):d}return e===null?s=(...d)=>r(new i(...lh(h(d)))):t!==null?(t=ot(t),s=(...d)=>r(new i(e,...lh(h(d)),t))):s=(...d)=>r(new i(e,...lh(h(d)))),s.setParameterLength=(...d)=>(d.length===1?u=c=d[0]:d.length===2&&([u,c]=d),s),s.setName=d=>(o=d,s),s},dH=function(i,...e){return new i(...lh(e))};class pH extends ct{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:n}=this,r=e.getNodeProperties(t),s=e.getClosestSubBuild(t.subBuilds)||"",o=s||"default";if(r[o])return r[o];const u=e.subBuildFn,c=e.fnCall;e.subBuildFn=s,e.fnCall=this;let h=null;if(t.layout){let d=LR.get(e.constructor);d===void 0&&(d=new WeakMap,LR.set(e.constructor,d));let p=d.get(t);p===void 0&&(p=ot(e.buildFunctionNode(t)),d.set(t,p)),e.addInclude(p);const g=n?mH(n):null;h=ot(p.call(g))}else{const d=new Proxy(e,{get:(S,b,x)=>{let M;return Symbol.iterator===b?M=function*(){yield void 0}:M=Reflect.get(S,b,x),M}}),p=n?gH(n):null,g=Array.isArray(n)?n.length>0:n!==null,_=t.jsFunc,v=g||_.length>1?_(p,d):_(d);h=ot(v)}return e.subBuildFn=u,e.fnCall=c,t.once&&(r[o]=h),h}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null;const r=e.getBuildStage(),s=e.getNodeProperties(this),o=e.getSubBuildOutput(this),u=this.getOutputNode(e),c=e.fnCall;if(e.fnCall=this,r==="setup"){const h=e.getSubBuildProperty("initialized",this);if(s[h]!==!0&&(s[h]=!0,s[o]=this.getOutputNode(e),s[o].build(e),this.shaderNode.subBuilds))for(const d of e.chaining){const p=e.getDataFromNode(d,"any");p.subBuilds=p.subBuilds||new Set;for(const g of this.shaderNode.subBuilds)p.subBuilds.add(g)}n=s[o]}else r==="analyze"?u.build(e,t):r==="generate"&&(n=u.build(e,t)||"");return e.fnCall=c,n}}function mH(i){let e;return _T(i),i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)?e=[...i]:e=i[0],e}function gH(i){let e=0;return _T(i),new Proxy(i,{get:(t,n,r)=>{let s;if(n==="length")return s=i.length,s;if(Symbol.iterator===n)s=function*(){for(const o of i)yield ot(o)};else{if(i.length>0)if(Object.getPrototypeOf(i[0])===Object.prototype){const o=i[0];o[n]===void 0?s=o[e++]:s=Reflect.get(o,n,r)}else i[0]instanceof ct&&(i[n]===void 0?s=i[e++]:s=Reflect.get(i,n,r));else s=Reflect.get(t,n,r);s=ot(s)}return s}})}class _H extends ct{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new pH(this,e)}setup(){return this.call()}}const vH=[!1,!0],yH=[0,1,2,3],xH=[-1,-2],iD=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],pT=new Map;for(const i of vH)pT.set(i,new wa(i));const mT=new Map;for(const i of yH)mT.set(i,new wa(i,"uint"));const gT=new Map([...mT].map(i=>new wa(i.value,"int")));for(const i of xH)gT.set(i,new wa(i,"int"));const n0=new Map([...gT].map(i=>new wa(i.value)));for(const i of iD)n0.set(i,new wa(i));for(const i of iD)n0.set(-i,new wa(-i));const i0={bool:pT,uint:mT,ints:gT,float:n0},PR=new Map([...pT,...n0]),jb=(i,e)=>PR.has(i)?PR.get(i):i.isNode===!0?i:new wa(i,e),Si=function(i,e=null){return(...t)=>{for(const r of t)if(r===void 0)return Pe(`TSL: Invalid parameter for the type "${i}".`,new rr),new wa(0,i);if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(r=>{const s=typeof r;return s!=="object"&&s!=="function"}))&&(t=[fT(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return Rg(e.get(t[0]));if(t.length===1){const r=jb(t[0],i);return r.nodeType===i?Rg(r):Rg(new tD(r,i))}const n=t.map(r=>jb(r));return Rg(new iH(n,i))}},UR=i=>typeof i=="object"&&i!==null?i.value:i,bH=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Dd(i,e){return new _H(i,e)}const ot=(i,e=null)=>cH(i,e),Rg=(i,e=null)=>ot(i,e).toVarIntent(),_T=(i,e=null)=>new hH(i,e),lh=(i,e=null)=>new fH(i,e),fn=(i,e=null,t=null,n=null)=>new nD(i,e,t,n),Ve=(i,...e)=>new dH(i,...e),et=(i,e=null,t=null,n={})=>new nD(i,e,t,{...n,intent:!0});let SH=0;class TH extends ct{constructor(e,t=null){super();let n=null;t!==null&&(typeof t=="object"?n=t.return:(typeof t=="string"?n=t:Pe("TSL: Invalid layout type.",new rr),t=null)),this.shaderNode=new Dd(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const n={name:"fn"+SH++,type:t,inputs:[]};for(const r in e)r!=="return"&&n.inputs.push({name:r,type:e[r]});e=n}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return Pe('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}function Se(i,e=null){const t=new TH(i,e);return new Proxy(()=>{},{apply(n,r,s){return t.call(...s)},get(n,r,s){return Reflect.get(t,r,s)},set(n,r,s,o){return Reflect.set(t,r,s,o)}})}const E_=i=>{Lu=i},rD=()=>Lu,wn=(...i)=>Lu.If(...i);function sD(i){return Lu&&Lu.addToStack(i),i}xe("toStack",sD);const MH=new Si("color"),ye=new Si("float",i0.float),kn=new Si("int",i0.ints),$t=new Si("uint",i0.uint),vT=new Si("bool",i0.bool),rt=new Si("vec2"),la=new Si("ivec2"),aD=new Si("uvec2"),EH=new Si("bvec2"),ve=new Si("vec3"),oD=new Si("ivec3"),lD=new Si("uvec3"),AH=new Si("bvec3"),wt=new Si("vec4"),uD=new Si("ivec4"),cD=new Si("uvec4"),wH=new Si("bvec4"),yT=new Si("mat2"),qi=new Si("mat3"),yu=new Si("mat4");xe("toColor",MH);xe("toFloat",ye);xe("toInt",kn);xe("toUint",$t);xe("toBool",vT);xe("toVec2",rt);xe("toIVec2",la);xe("toUVec2",aD);xe("toBVec2",EH);xe("toVec3",ve);xe("toIVec3",oD);xe("toUVec3",lD);xe("toBVec3",AH);xe("toVec4",wt);xe("toIVec4",uD);xe("toUVec4",cD);xe("toBVec4",wH);xe("toMat2",yT);xe("toMat3",qi);xe("toMat4",yu);const RH=fn(nf).setParameterLength(2),CH=(i,e)=>new tD(ot(i),e);xe("element",RH);xe("convert",CH);xe("append",i=>(Ne("TSL: .append() has been renamed to .toStack().",new rr),sD(i)));class dn extends ct{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return ef(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const bl=(i,e)=>new dn(i,e),A_=(i,e)=>new dn(i,e,!0),yn=Ve(dn,"vec4","DiffuseColor"),Qc=Ve(dn,"vec3","DiffuseContribution"),OR=Ve(dn,"vec3","EmissiveColor"),uo=Ve(dn,"float","Roughness"),pl=Ve(dn,"float","Metalness"),Wb=Ve(dn,"float","Clearcoat"),Vd=Ve(dn,"float","ClearcoatRoughness"),ms=Ve(dn,"vec3","Sheen"),cu=Ve(dn,"float","SheenRoughness"),xT=Ve(dn,"float","Iridescence"),$b=Ve(dn,"float","IridescenceIOR"),qb=Ve(dn,"float","IridescenceThickness"),Xb=Ve(dn,"float","AlphaT"),ou=Ve(dn,"float","Anisotropy"),o_=Ve(dn,"vec3","AnisotropyT"),uh=Ve(dn,"vec3","AnisotropyB"),Pu=Ve(dn,"color","SpecularColor"),eh=Ve(dn,"color","SpecularColorBlended"),th=Ve(dn,"float","SpecularF90"),Yb=Ve(dn,"float","Shininess"),Hd=Ve(dn,"vec4","Output"),wx=Ve(dn,"float","dashSize"),BR=Ve(dn,"float","gapSize"),l_=Ve(dn,"float","IOR"),Kb=Ve(dn,"float","Transmission"),hD=Ve(dn,"float","Thickness"),fD=Ve(dn,"float","AttenuationDistance"),dD=Ve(dn,"color","AttenuationColor"),pD=Ve(dn,"float","Dispersion");class mD extends ct{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const NH=i=>new mD(i),bT=(i,e=0)=>new mD(i,!0,e),DH=bT("frame"),_t=bT("render"),gD=NH("object");class Rp extends dT{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=gD}setName(e){return this.name=e,this}label(e){return Ne('TSL: "label()" has been deprecated. Use "setName()" instead.',new rr),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(n=>{const r=e(n,this);r!==void 0&&(this.value=r)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const o=s.getInputType(e),u=e.getUniformFromNode(s,o,e.shaderStage,this.name||e.context.nodeName),c=e.getPropertyName(u);e.context.nodeName!==void 0&&delete e.context.nodeName;let h=c;if(n==="bool"){const d=e.getDataFromNode(this);let p=d.propertyName;if(p===void 0){const g=e.getVarFromNode(this,null,"bool");p=e.getPropertyName(g),d.propertyName=p,h=e.format(c,o,n),e.addLineFlowCode(`${p} = ${h}`,this)}h=p}return e.format(h,n,t)}}const yt=(i,e)=>{const t=bH(e||i);if(t===i&&(i=fT(t)),i&&i.isNode===!0){let n=i.value;i.traverse(r=>{r.isConstNode===!0&&(n=r.value)}),i=n}return new Rp(i,t)};class FR extends bi{static get type(){return"ArrayNode"}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const LH=(...i)=>{let e;if(i.length===1){const t=i[0];e=new FR(null,t.length,t)}else{const t=i[0],n=i[1];e=new FR(t,n)}return ot(e)};xe("toArray",(i,e)=>LH(Array(e).fill(i)));class PH extends bi{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return tf.join("").slice(0,n)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:n}=this,r=t.getScope(),s=e.getDataFromNode(r);s.assign=!0;const o=e.getNodeProperties(this);o.sourceNode=n,o.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:n,sourceNode:r}=e.getNodeProperties(this),s=this.needsSplitAssign(e),o=n.build(e),u=n.getNodeType(e),c=r.build(e,u),h=r.getNodeType(e),d=e.getDataFromNode(this);let p;if(d.initialized===!0)t!=="void"&&(p=o);else if(s){const g=e.getVarFromNode(this,null,u),_=e.getPropertyName(g);e.addLineFlowCode(`${_} = ${c}`,this);const v=n.node,b=v.node.context({assign:!0}).build(e);for(let x=0;x<v.components.length;x++){const M=v.components[x];e.addLineFlowCode(`${b}.${M} = ${_}[ ${x} ]`,this)}t!=="void"&&(p=o)}else p=`${o} = ${c}`,(t==="void"||h==="void")&&(e.addLineFlowCode(p,this),t!=="void"&&(p=o));return d.initialized=!0,e.format(p,u,t)}}const UH=fn(PH).setParameterLength(2);xe("assign",UH);class OH extends bi{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){const t=[],n=this.functionNode,r=n.getInputs(e),s=this.parameters,o=(c,h)=>{const d=h.type,p=d==="pointer";let g;return p?g="&"+c.build(e):g=c.build(e,d),g};if(Array.isArray(s)){if(s.length>r.length)Pe("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=r.length;else if(s.length<r.length)for(Pe("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<r.length;)s.push(ye(0));for(let c=0;c<s.length;c++)t.push(o(s[c],r[c]))}else for(const c of r){const h=s[c.name];h!==void 0?t.push(o(h,c)):(Pe(`TSL: Input '${c.name}' not found in 'Fn()'.`),t.push(o(ye(0),c)))}return`${n.build(e,"property")}( ${t.join(", ")} )`}}const BH=(i,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?lh(e):_T(e[0]),new OH(ot(i),e));xe("call",BH);const FH={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class ei extends bi{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let s=new ei(e,t,n);for(let o=0;o<r.length-1;o++)s=new ei(e,s,r[o]);t=s,n=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=n,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(FH[this.op],t)}getNodeType(e,t=null){const n=this.op,r=this.aNode,s=this.bNode,o=r.getNodeType(e),u=s?s.getNodeType(e):null;if(o==="void"||u==="void")return t||"void";if(n==="%")return o;if(n==="~"||n==="&"||n==="|"||n==="^"||n===">>"||n==="<<")return e.getIntegerType(o);if(n==="!"||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">="){const c=Math.max(e.getTypeLength(o),e.getTypeLength(u));return c>1?`bvec${c}`:"bool"}else{if(e.isMatrix(o)){if(u==="float")return o;if(e.isVector(u))return e.getVectorFromMatrix(o);if(e.isMatrix(u))return o}else if(e.isMatrix(u)){if(o==="float")return u;if(e.isVector(o))return e.getVectorFromMatrix(u)}return e.getTypeLength(u)>e.getTypeLength(o)?u:o}}generate(e,t){const n=this.op,{aNode:r,bNode:s}=this,o=this.getNodeType(e,t);let u=null,c=null;o!=="void"?(u=r.getNodeType(e),c=s?s.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?e.isVector(u)?c=u:e.isVector(c)?u=c:u!==c&&(u=c="float"):n===">>"||n==="<<"?(u=o,c=e.changeComponentType(c,"uint")):n==="%"?(u=o,c=e.isInteger(u)&&e.isInteger(c)?c:u):e.isMatrix(u)?c==="float"?c="float":e.isVector(c)?c=e.getVectorFromMatrix(u):e.isMatrix(c)||(u=c=o):e.isMatrix(c)?u==="float"?u="float":e.isVector(u)?u=e.getVectorFromMatrix(c):u=c=o:u=c=o):u=c=o;const h=r.build(e,u),d=s?s.build(e,c):null,p=e.getFunctionOperator(n);if(t!=="void"){const g=e.renderer.coordinateSystem===yr;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return g?e.isVector(u)?e.format(`${this.getOperatorMethod(e,t)}( ${h}, ${d} )`,o,t):e.format(`( ${h} ${n} ${d} )`,o,t):e.format(`( ${h} ${n} ${d} )`,o,t);if(n==="%")return e.isInteger(c)?e.format(`( ${h} % ${d} )`,o,t):e.format(`${this.getOperatorMethod(e,o)}( ${h}, ${d} )`,o,t);if(n==="!"||n==="~")return e.format(`(${n}${h})`,u,t);if(p)return e.format(`${p}( ${h}, ${d} )`,o,t);if(e.isMatrix(u)&&c==="float")return e.format(`( ${d} ${n} ${h} )`,o,t);if(u==="float"&&e.isMatrix(c))return e.format(`${h} ${n} ${d}`,o,t);{let _=`( ${h} ${n} ${d} )`;return!g&&o==="bool"&&e.isVector(u)&&e.isVector(c)&&(_=`all${_}`),e.format(_,o,t)}}else if(u!=="void")return p?e.format(`${p}( ${h}, ${d} )`,o,t):e.isMatrix(u)&&c==="float"?e.format(`${d} ${n} ${h}`,o,t):e.format(`${h} ${n} ${d}`,o,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Fr=et(ei,"+").setParameterLength(2,1/0).setName("add"),Nr=et(ei,"-").setParameterLength(2,1/0).setName("sub"),Ft=et(ei,"*").setParameterLength(2,1/0).setName("mul"),Sa=et(ei,"/").setParameterLength(2,1/0).setName("div"),ST=et(ei,"%").setParameterLength(2).setName("mod"),IH=et(ei,"==").setParameterLength(2).setName("equal"),zH=et(ei,"!=").setParameterLength(2).setName("notEqual"),kH=et(ei,"<").setParameterLength(2).setName("lessThan"),GH=et(ei,">").setParameterLength(2).setName("greaterThan"),VH=et(ei,"<=").setParameterLength(2).setName("lessThanEqual"),HH=et(ei,">=").setParameterLength(2).setName("greaterThanEqual"),jH=et(ei,"&&").setParameterLength(2,1/0).setName("and"),WH=et(ei,"||").setParameterLength(2,1/0).setName("or"),$H=et(ei,"!").setParameterLength(1).setName("not"),qH=et(ei,"^^").setParameterLength(2).setName("xor"),XH=et(ei,"&").setParameterLength(2).setName("bitAnd"),YH=et(ei,"~").setParameterLength(1).setName("bitNot"),KH=et(ei,"|").setParameterLength(2).setName("bitOr"),ZH=et(ei,"^").setParameterLength(2).setName("bitXor"),QH=et(ei,"<<").setParameterLength(2).setName("shiftLeft"),JH=et(ei,">>").setParameterLength(2).setName("shiftRight"),e8=Se(([i])=>(i.addAssign(1),i)),t8=Se(([i])=>(i.subAssign(1),i)),n8=Se(([i])=>{const e=kn(i).toConst();return i.addAssign(1),e}),i8=Se(([i])=>{const e=kn(i).toConst();return i.subAssign(1),e});xe("add",Fr);xe("sub",Nr);xe("mul",Ft);xe("div",Sa);xe("mod",ST);xe("equal",IH);xe("notEqual",zH);xe("lessThan",kH);xe("greaterThan",GH);xe("lessThanEqual",VH);xe("greaterThanEqual",HH);xe("and",jH);xe("or",WH);xe("not",$H);xe("xor",qH);xe("bitAnd",XH);xe("bitNot",YH);xe("bitOr",KH);xe("bitXor",ZH);xe("shiftLeft",QH);xe("shiftRight",JH);xe("incrementBefore",e8);xe("decrementBefore",t8);xe("increment",n8);xe("decrement",i8);const r8=(i,e)=>(Ne('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.',new rr),ST(kn(i),kn(e)));xe("modInt",r8);class le extends bi{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){if(super(),(e===le.MAX||e===le.MIN)&&arguments.length>3){let s=new le(e,t,n);for(let o=2;o<arguments.length-1;o++)s=new le(e,s,arguments[o]);t=s,n=arguments[arguments.length-1],r=null}this.method=e,this.aNode=t,this.bNode=n,this.cNode=r,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),o=e.isMatrix(n)?0:e.getTypeLength(n),u=e.isMatrix(r)?0:e.getTypeLength(r);return s>o&&s>u?t:o>u?n:u>s?r:t}getNodeType(e){const t=this.method;return t===le.LENGTH||t===le.DISTANCE||t===le.DOT?"float":t===le.CROSS?"vec3":t===le.ALL||t===le.ANY?"bool":t===le.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:n,method:r}=this;let s=null;if(r===le.ONE_MINUS)s=Nr(1,t);else if(r===le.RECIPROCAL)s=Sa(1,t);else if(r===le.DIFFERENCE)s=ts(Nr(t,n));else if(r===le.TRANSFORM_DIRECTION){let o=t,u=n;e.isMatrix(o.getNodeType(e))?u=wt(ve(u),0):o=wt(ve(o),0);const c=Ft(o,u).xyz;s=ya(c)}return s!==null?s:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),o=this.getInputType(e),u=this.aNode,c=this.bNode,h=this.cNode,d=e.renderer.coordinateSystem;if(r===le.NEGATE)return e.format("( - "+u.build(e,o)+" )",s,t);{const p=[];return r===le.CROSS?p.push(u.build(e,s),c.build(e,s)):d===yr&&r===le.STEP?p.push(u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":o),c.build(e,o)):d===yr&&(r===le.MIN||r===le.MAX)?p.push(u.build(e,o),c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":o)):r===le.REFRACT?p.push(u.build(e,o),c.build(e,o),h.build(e,"float")):r===le.MIX?p.push(u.build(e,o),c.build(e,o),h.build(e,e.getTypeLength(h.getNodeType(e))===1?"float":o)):(d===ba&&r===le.ATAN&&c!==null&&(r="atan2"),e.shaderStage!=="fragment"&&(r===le.DFDX||r===le.DFDY)&&(Ne(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),r="/*"+r+"*/"),p.push(u.build(e,o)),c!==null&&p.push(c.build(e,o)),h!==null&&p.push(h.build(e,o))),e.format(`${e.getMethod(r,s)}( ${p.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}le.ALL="all";le.ANY="any";le.RADIANS="radians";le.DEGREES="degrees";le.EXP="exp";le.EXP2="exp2";le.LOG="log";le.LOG2="log2";le.SQRT="sqrt";le.INVERSE_SQRT="inversesqrt";le.FLOOR="floor";le.CEIL="ceil";le.NORMALIZE="normalize";le.FRACT="fract";le.SIN="sin";le.COS="cos";le.TAN="tan";le.ASIN="asin";le.ACOS="acos";le.ATAN="atan";le.ABS="abs";le.SIGN="sign";le.LENGTH="length";le.NEGATE="negate";le.ONE_MINUS="oneMinus";le.DFDX="dFdx";le.DFDY="dFdy";le.ROUND="round";le.RECIPROCAL="reciprocal";le.TRUNC="trunc";le.FWIDTH="fwidth";le.TRANSPOSE="transpose";le.DETERMINANT="determinant";le.INVERSE="inverse";le.EQUALS="equals";le.MIN="min";le.MAX="max";le.STEP="step";le.REFLECT="reflect";le.DISTANCE="distance";le.DIFFERENCE="difference";le.DOT="dot";le.CROSS="cross";le.POW="pow";le.TRANSFORM_DIRECTION="transformDirection";le.MIX="mix";le.CLAMP="clamp";le.REFRACT="refract";le.SMOOTHSTEP="smoothstep";le.FACEFORWARD="faceforward";const _D=ye(1e-6),s8=ye(Math.PI),a8=et(le,le.ALL).setParameterLength(1),o8=et(le,le.ANY).setParameterLength(1),l8=et(le,le.RADIANS).setParameterLength(1),u8=et(le,le.DEGREES).setParameterLength(1),vD=et(le,le.EXP).setParameterLength(1),dp=et(le,le.EXP2).setParameterLength(1),yD=et(le,le.LOG).setParameterLength(1),yo=et(le,le.LOG2).setParameterLength(1),Sl=et(le,le.SQRT).setParameterLength(1),c8=et(le,le.INVERSE_SQRT).setParameterLength(1),xu=et(le,le.FLOOR).setParameterLength(1),TT=et(le,le.CEIL).setParameterLength(1),ya=et(le,le.NORMALIZE).setParameterLength(1),Ta=et(le,le.FRACT).setParameterLength(1),es=et(le,le.SIN).setParameterLength(1),ua=et(le,le.COS).setParameterLength(1),h8=et(le,le.TAN).setParameterLength(1),f8=et(le,le.ASIN).setParameterLength(1),xD=et(le,le.ACOS).setParameterLength(1),d8=et(le,le.ATAN).setParameterLength(1,2),ts=et(le,le.ABS).setParameterLength(1),bD=et(le,le.SIGN).setParameterLength(1),xo=et(le,le.LENGTH).setParameterLength(1),SD=et(le,le.NEGATE).setParameterLength(1),p8=et(le,le.ONE_MINUS).setParameterLength(1),TD=et(le,le.DFDX).setParameterLength(1),MD=et(le,le.DFDY).setParameterLength(1),m8=et(le,le.ROUND).setParameterLength(1),g8=et(le,le.RECIPROCAL).setParameterLength(1),_8=et(le,le.TRUNC).setParameterLength(1),ED=et(le,le.FWIDTH).setParameterLength(1),v8=et(le,le.TRANSPOSE).setParameterLength(1),y8=et(le,le.DETERMINANT).setParameterLength(1),x8=et(le,le.INVERSE).setParameterLength(1),Gh=et(le,le.MIN).setParameterLength(2,1/0),Xi=et(le,le.MAX).setParameterLength(2,1/0),pp=et(le,le.STEP).setParameterLength(2),b8=et(le,le.REFLECT).setParameterLength(2),S8=et(le,le.DISTANCE).setParameterLength(2),T8=et(le,le.DIFFERENCE).setParameterLength(2),Uu=et(le,le.DOT).setParameterLength(2),Ou=et(le,le.CROSS).setParameterLength(2),r0=et(le,le.POW).setParameterLength(2),AD=i=>Ft(i,i),M8=i=>Ft(i,i,i),wD=i=>Ft(i,i,i,i),E8=et(le,le.TRANSFORM_DIRECTION).setParameterLength(2),A8=i=>Ft(bD(i),r0(ts(i),1/3)),RD=i=>Uu(i,i),Sn=et(le,le.MIX).setParameterLength(3),Ml=(i,e=0,t=1)=>new le(le.CLAMP,ot(i),ot(e),ot(t)),MT=i=>Ml(i),CD=et(le,le.REFRACT).setParameterLength(3),So=et(le,le.SMOOTHSTEP).setParameterLength(3),w8=et(le,le.FACEFORWARD).setParameterLength(3),R8=Se(([i])=>{const n=43758.5453,r=Uu(i.xy,rt(12.9898,78.233)),s=ST(r,s8);return Ta(es(s).mul(n))}),C8=(i,e,t)=>Sn(e,t,i),N8=(i,e,t)=>So(e,t,i),D8=(i,e)=>pp(e,i);xe("all",a8);xe("any",o8);xe("radians",l8);xe("degrees",u8);xe("exp",vD);xe("exp2",dp);xe("log",yD);xe("log2",yo);xe("sqrt",Sl);xe("inverseSqrt",c8);xe("floor",xu);xe("ceil",TT);xe("normalize",ya);xe("fract",Ta);xe("sin",es);xe("cos",ua);xe("tan",h8);xe("asin",f8);xe("acos",xD);xe("atan",d8);xe("abs",ts);xe("sign",bD);xe("length",xo);xe("lengthSq",RD);xe("negate",SD);xe("oneMinus",p8);xe("dFdx",TD);xe("dFdy",MD);xe("round",m8);xe("reciprocal",g8);xe("trunc",_8);xe("fwidth",ED);xe("min",Gh);xe("max",Xi);xe("step",D8);xe("reflect",b8);xe("distance",S8);xe("dot",Uu);xe("cross",Ou);xe("pow",r0);xe("pow2",AD);xe("pow3",M8);xe("pow4",wD);xe("transformDirection",E8);xe("mix",C8);xe("clamp",Ml);xe("refract",CD);xe("smoothstep",N8);xe("faceForward",w8);xe("difference",T8);xe("saturate",MT);xe("cbrt",A8);xe("transpose",v8);xe("determinant",y8);xe("inverse",x8);xe("rand",R8);class L8 extends ct{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const s=n.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(r))return s}return r}setup(e){const t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,s=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const o=e.context.uniformFlow,u=e.getNodeProperties(this);u.condNode=t,u.ifNode=o?n:n.context({nodeBlock:n}),u.elseNode=r?o?r:r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:o,elseNode:u}=e.getNodeProperties(this),c=e.currentFunctionNode,h=t!=="void",d=h?bl(n).build(e):"";r.nodeProperty=d;const p=s.build(e,"bool");if(e.context.uniformFlow&&u!==null){const v=o.build(e,n),S=u.build(e,n),b=e.getTernary(p,v,S);return e.format(b,n,t)}e.addFlowCode(`
${e.tab}if ( ${p} ) {

`).addFlowTab();let _=o.build(e,n);if(_&&(h?_=d+" = "+_+";":(_="return "+_+";",c===null&&(Ne("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),_="// "+_))),e.removeFlowTab().addFlowCode(e.tab+"	"+_+`

`+e.tab+"}"),u!==null){e.addFlowCode(` else {

`).addFlowTab();let v=u.build(e,n);v&&(h?v=d+" = "+v+";":(v="return "+v+";",c===null&&(Ne("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),v="// "+v))),e.removeFlowTab().addFlowCode(e.tab+"	"+v+`

`+e.tab+`}

`)}else e.addFlowCode(`

`);return e.format(d,n,t)}}const ns=fn(L8).setParameterLength(2,3);xe("select",ns);class ND extends ct{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}}const Gu=(i=null,e={})=>{let t=i;return(t===null||t.isNode!==!0)&&(e=t||e,t=null),new ND(t,e)},P8=i=>Gu(i,{uniformFlow:!0}),DD=(i,e)=>Gu(i,{nodeName:e});function U8(i,e,t=null){return Gu(t,{getShadow:({light:n,shadowColorNode:r})=>e===n?r.mul(i):r})}function O8(i,e=null){return Gu(e,{getAO:(t,{material:n})=>n.transparent===!0?t:t!==null?t.mul(i):i})}function B8(i,e){return Ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),DD(i,e)}xe("context",Gu);xe("label",B8);xe("uniformFlow",P8);xe("setName",DD);xe("builtinShadowContext",(i,e,t)=>U8(e,t,i));xe("builtinAOContext",(i,e)=>O8(e,i));class u_ extends ct{static get type(){return"VarNode"}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0];if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let n=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){const o=t.getDataFromNode(this);o.forceDeclaration=!0,n=!0}const r=t.getBaseStack();n?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:n,readOnly:r}=this,{renderer:s}=e,o=s.backend.isWebGPUBackend===!0;let u=!1,c=!1;r&&(u=e.isDeterministic(t),c=o?r:u);const h=this.getNodeType(e);if(h=="void")return this.isIntent(e)!==!0&&Pe('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);const d=e.getVectorType(h),p=t.build(e,d),g=e.getVarFromNode(this,n,d,void 0,c),_=e.getPropertyName(g);let v=_;if(c)if(o)v=u?`const ${_}`:`let ${_}`;else{const S=t.getArrayCount(e);v=`const ${e.getVar(g.type,_,S)}`}return e.addLineFlowCode(`${v} = ${p}`,this),_}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}const ET=fn(u_),F8=(i,e=null)=>ET(i,e).toStack(),I8=(i,e=null)=>ET(i,e,!0).toStack(),z8=i=>ET(i).setIntent(!0).toStack();xe("toVar",F8);xe("toConst",I8);xe("toVarIntent",z8);class k8 extends ct{static get type(){return"SubBuild"}constructor(e,t,n=null){super(n),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const n=this.node.build(e,...t);return e.removeSubBuild(),n}}const ch=(i,e,t=null)=>new k8(ot(i),e,t);class G8 extends ct{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=ch(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const r=this.name,s=this.getNodeType(e),o=this.interpolationType,u=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,s,o,u),t.node=ch(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ag.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Ag.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){const s=this.getNodeType(e),o=e.getPropertyName(r,Ag.VERTEX);e.flowNodeFromShaderStage(Ag.VERTEX,n.node,s,o),n[t]=o}return e.getPropertyName(r)}}const Vu=fn(G8).setParameterLength(1,2),V8=i=>Vu(i);xe("toVarying",Vu);xe("toVertexStage",V8);const H8=Se(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return Sn(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),j8=Se(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return Sn(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),AT="WorkingColorSpace",W8="OutputColorSpace";class LD extends bi{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===AT?xt.workingColorSpace:t===W8?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let s=t;return xt.enabled===!1||n===r||!n||!r||(xt.getTransfer(n)===Ye&&(s=wt(H8(s.rgb),s.a)),xt.getPrimaries(n)!==xt.getPrimaries(r)&&(s=wt(qi(xt._getMatrix(new Nt,n,r)).mul(s.rgb),s.a)),xt.getTransfer(r)===Ye&&(s=wt(j8(s.rgb),s.a))),s}}const $8=(i,e)=>new LD(ot(i),AT,e),wT=(i,e)=>new LD(ot(i),e,AT);xe("workingToColorSpace",$8);xe("colorSpaceToWorking",wT);let q8=class extends nf{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class PD extends ct{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=Dt.OBJECT}setGroup(e){return this.group=e,this}element(e){return new q8(this,ot(e))}setNodeType(e){const t=yt(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;r<t.length;r++)n=n[t[r]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const X8=(i,e,t)=>new PD(i,e,t);class Y8 extends PD{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(_t)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const K8=(i,e,t=null)=>new Y8(i,e,t);class Z8 extends bi{static get type(){return"ToneMappingNode"}constructor(e,t=J8,n=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return kd(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,n=this._toneMapping;if(n===ji)return t;let r=null;const s=e.renderer.library.getToneMappingFunction(n);return s!==null?r=wt(s(t.rgb,this.exposureNode),t.a):(Pe("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const Q8=(i,e,t)=>new Z8(i,ot(e),ot(t)),J8=K8("toneMappingExposure","float");xe("toneMapping",(i,e,t)=>Q8(e,t,i));const IR=new WeakMap;function zR(i,e){let t=IR.get(i);return t===void 0&&(t=new YN(i,e),IR.set(i,t)),t}class il extends dT{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=Fh,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=e.getTypeLength(t),r=this.value,s=this.bufferStride||n,o=this.bufferOffset;let u;r.isInterleavedBuffer===!0?u=r:r.isBufferAttribute===!0?u=zR(r.array,s):u=zR(r,s);const c=new ZS(u,n,o);u.setUsage(this.usage),this.attribute=c,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=Vu(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function RT(i,e=null,t=0,n=0,r=Fh,s=!1){return e==="mat3"||e===null&&i.itemSize===9?qi(new il(i,"vec3",9,0).setUsage(r).setInstanced(s),new il(i,"vec3",9,3).setUsage(r).setInstanced(s),new il(i,"vec3",9,6).setUsage(r).setInstanced(s)):e==="mat4"||e===null&&i.itemSize===16?yu(new il(i,"vec4",16,0).setUsage(r).setInstanced(s),new il(i,"vec4",16,4).setUsage(r).setInstanced(s),new il(i,"vec4",16,8).setUsage(r).setInstanced(s),new il(i,"vec4",16,12).setUsage(r).setInstanced(s)):new il(i,e,t,n).setUsage(r)}const UD=(i,e=null,t=0,n=0)=>RT(i,e,t,n),kR=(i,e=null,t=0,n=0)=>RT(i,e,t,n,Fh,!0),GR=(i,e=null,t=0,n=0)=>RT(i,e,t,n,p_,!0);xe("toAttribute",i=>UD(i.value));class e9 extends ct{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=Dt.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return Ne('TSL: "label()" has been deprecated. Use "setName()" instead.',new rr),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const t=this.computeNode.build(e);if(t){const n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:n}=e;if(n==="compute"){const r=this.computeNode.build(e,"void");r!==""&&e.addLineFlowCode(r,this)}else{const s=e.getNodeProperties(this).outputComputeNode;if(s)return s.build(e,t)}}}const OD=(i,e=[64])=>{(e.length===0||e.length>3)&&Pe("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new rr);for(let t=0;t<e.length;t++){const n=e[t];(typeof n!="number"||n<=0||!Number.isInteger(n))&&Pe(`TSL: compute() workgroupSize element at index [ ${t} ] must be a positive integer`,new rr)}for(;e.length<3;)e.push(1);return new e9(ot(i),e)},t9=(i,e,t)=>OD(i,t).setCount(e);xe("compute",t9);xe("computeKernel",OD);class n9 extends ct{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(n),s}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const jd=i=>new n9(ot(i));function i9(i,e=!0){return Ne('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),jd(i).setParent(e)}xe("cache",i9);xe("isolate",jd);class r9 extends ct{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const s9=fn(r9).setParameterLength(2);xe("bypass",s9);class BD extends ct{static get type(){return"RemapNode"}constructor(e,t,n,r=ye(0),s=ye(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:s,doClamp:o}=this;let u=e.sub(t).div(n.sub(t));return o===!0&&(u=u.clamp()),u.mul(s.sub(r)).add(r)}}const a9=fn(BD,null,null,{doClamp:!1}).setParameterLength(3,5),o9=fn(BD).setParameterLength(3,5);xe("remap",a9);xe("remapClamp",o9);class c_ extends ct{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if(n==="void")e.addLineFlowCode(r,this);else return e.format(r,n,t)}}const ha=fn(c_).setParameterLength(1,2),l9=i=>(i?ns(i,ha("discard")):ha("discard")).toStack();xe("discard",l9);class u9 extends bi{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;const n=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||ji,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Dr;return n!==ji&&(t=t.toneMapping(n)),r!==Dr&&r!==xt.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const c9=(i,e=null,t=null)=>new u9(ot(i),e,t);xe("renderOutput",c9);class h9 extends bi{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,n=this.node.build(e);if(t!==null)t(e,n);else{const r="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(r.length);let o="";o+="// #"+r+`#
`,o+=e.flow.code.replace(/^\t/mg,"")+`
`,o+="/* ... */ "+n+` /* ... */
`,o+="// #"+s+`#
`,hp(o)}return n}}const f9=(i,e=null)=>new h9(ot(i),e).toStack();xe("debug",f9);class FD{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class d9 extends ct{static get type(){return"InspectorNode"}constructor(e,t="",n=null){super(),this.node=e,this.name=t,this.callback=n,this.updateType=Dt.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==FD&&xn('TSL: ".toInspector()" is only available with WebGPU.'),t}}function p9(i,e="",t=null){return i=ot(i),i.before(new d9(i,e,t))}xe("toInspector",p9);class ID extends ct{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const s=e.geometry.getAttribute(t),o=e.getTypeFromAttribute(s),u=e.getAttribute(t,o);return e.shaderStage==="vertex"?e.format(u.name,o,n):Vu(this).build(e,n)}else return Ne(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const El=(i,e=null)=>new ID(i,e),rf=(i=0)=>El("uv"+(i>0?i:""),"vec2");class m9 extends ct{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const hh=fn(m9).setParameterLength(1,2);class g9 extends Rp{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Dt.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:r,height:s}=n;this.value=Math.log2(Math.max(r,s))}}}const _9=fn(g9).setParameterLength(1);class v9 extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const zD=new vi;class sf extends Rp{static get type(){return"TextureNode"}constructor(e=zD,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Dt.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===bn?"uvec4":this.value.type===Li?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return rf(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=yt(this.value.matrix)),this._matrixUniform.mul(ve(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=yt(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(kn(hh(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new v9("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const r=Se(()=>{let c=this.uvNode;return(c===null||e.context.forceUVContext===!0)&&e.context.getUV&&(c=e.context.getUV(this,e)),c||(c=this.getDefaultUV()),this.updateMatrix===!0&&(c=this.getTransformedUV(c)),c=this.setupUV(e,c),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?Dt.OBJECT:Dt.NONE,c})();let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this));let o=null,u=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(mo.TEXTURE_COMPARE))o=this.compareNode;else{const c=n.compareFunction;c===null||c===W_||c===wl||c===up||c===bo?u=this.compareNode:(o=this.compareNode,xn('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=o,t.compareStepNode=u,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,n,r,s,o,u,c,h){const d=this.value;let p;return s?p=e.generateTextureBias(d,t,n,s,o,h):c?p=e.generateTextureGrad(d,t,n,c,o,h):u?p=e.generateTextureCompare(d,t,n,u,o,h):this.sampler===!1?p=e.generateTextureLoad(d,t,n,r,o,h):r?p=e.generateTextureLevel(d,t,n,r,o,h):p=e.generateTexture(d,t,n,o,h),p}generate(e,t){const n=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(/^sampler/.test(t))return s+"_sampler";if(e.isReference(t))return s;{const o=e.getDataFromNode(this),u=this.getNodeType(e);let c=o.propertyName;if(c===void 0){const{uvNode:d,levelNode:p,biasNode:g,compareNode:_,compareStepNode:v,depthNode:S,gradNode:b,offsetNode:x}=r,M=this.generateUV(e,d),E=p?p.build(e,"float"):null,w=g?g.build(e,"float"):null,D=S?S.build(e,"int"):null,C=_?_.build(e,"float"):null,N=v?v.build(e,"float"):null,A=b?[b[0].build(e,"vec2"),b[1].build(e,"vec2")]:null,L=x?this.generateOffset(e,x):null,j=e.getVarFromNode(this);c=e.getPropertyName(j);let z=this.generateSnippet(e,s,M,E,w,D,C,A,L);if(N!==null){const H=n.compareFunction;H===up||H===bo?z=pp(ha(z,u),ha(N,"float")).build(e,u):z=pp(ha(N,"float"),ha(z,u)).build(e,u)}e.addLineFlowCode(`${c} = ${z}`,this),o.snippet=z,o.propertyName=c}let h=c;return e.needsToWorkingColorSpace(n)&&(h=wT(ha(h,u),n.colorSpace).setup(e).build(e,u)),e.format(h,u,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=ot(e),t.referenceNode=this.getBase(),ot(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=ot(e).mul(_9(t)),t.referenceNode=this.getBase();const n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===hn||n.magFilter===hn)&&(Ne("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),ot(t)}level(e){const t=this.clone();return t.levelNode=ot(e),t.referenceNode=this.getBase(),ot(t)}size(e){return hh(this,e)}bias(e){const t=this.clone();return t.biasNode=ot(e),t.referenceNode=this.getBase(),ot(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=ot(e),t.referenceNode=this.getBase(),ot(t)}grad(e,t){const n=this.clone();return n.gradNode=[ot(e),ot(t)],n.referenceNode=this.getBase(),ot(n)}depth(e){const t=this.clone();return t.depthNode=ot(e),t.referenceNode=this.getBase(),ot(t)}offset(e){const t=this.clone();return t.offsetNode=ot(e),t.referenceNode=this.getBase(),ot(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();const n=this._flipYUniform;n!==null&&(n.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}const y9=fn(sf).setParameterLength(1,4).setName("texture"),Fn=(i=zD,e=null,t=null,n=null)=>{let r;return i&&i.isTextureNode===!0?(r=ot(i.clone()),r.referenceNode=i.getBase(),e!==null&&(r.uvNode=ot(e)),t!==null&&(r.levelNode=ot(t)),n!==null&&(r.biasNode=ot(n))):r=y9(i,e,t,n),r},gs=(...i)=>Fn(...i).setSampler(!1);class CT extends Rp{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const kD=(i,e,t)=>new CT(i,e,t);class x9 extends nf{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class b9 extends CT{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?M_(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Dt.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let r=0;r<e.length;r++){const s=r*4;t[s]=e[r]}else if(n==="color")for(let r=0;r<e.length;r++){const s=r*4,o=e[r];t[s]=o.r,t[s+1]=o.g,t[s+2]=o.b||0}else if(n==="mat2")for(let r=0;r<e.length;r++){const s=r*4,o=e[r];t[s]=o.elements[0],t[s+1]=o.elements[1],t[s+2]=o.elements[2],t[s+3]=o.elements[3]}else if(n==="mat3")for(let r=0;r<e.length;r++){const s=r*16,o=e[r];t[s]=o.elements[0],t[s+1]=o.elements[1],t[s+2]=o.elements[2],t[s+4]=o.elements[3],t[s+5]=o.elements[4],t[s+6]=o.elements[5],t[s+8]=o.elements[6],t[s+9]=o.elements[7],t[s+10]=o.elements[8],t[s+15]=1}else if(n==="mat4")for(let r=0;r<e.length;r++){const s=r*16,o=e[r];for(let u=0;u<o.elements.length;u++)t[s+u]=o.elements[u]}else for(let r=0;r<e.length;r++){const s=r*4,o=e[r];t[s]=o.x,t[s+1]=o.y,t[s+2]=o.z||0,t[s+3]=o.w||0}}setup(e){const t=this.array.length,n=this.elementType;let r=Float32Array;const s=this.paddedType,o=e.getTypeLength(s);return n.charAt(0)==="i"&&(r=Int32Array),n.charAt(0)==="u"&&(r=Uint32Array),this.value=new r(t*o),this.bufferCount=t,this.bufferType=s,this.update(),super.setup(e)}element(e){return new x9(this,ot(e))}}const _s=(i,e)=>new b9(i,e);class S9 extends ct{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const af=fn(S9).setParameterLength(1);let md,gd;class Un extends ct{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Un.DPR?"float":this.scope===Un.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Dt.NONE;return(this.scope===Un.SIZE||this.scope===Un.VIEWPORT||this.scope===Un.DPR)&&(e=Dt.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Un.VIEWPORT?t!==null?gd.copy(t.viewport):(e.getViewport(gd),gd.multiplyScalar(e.getPixelRatio())):this.scope===Un.DPR?this._output.value=e.getPixelRatio():t!==null?(md.width=t.width,md.height=t.height):e.getDrawingBufferSize(md)}setup(){const e=this.scope;let t=null;return e===Un.SIZE?t=yt(md||(md=new Ie)):e===Un.VIEWPORT?t=yt(gd||(gd=new Pt)):e===Un.DPR?t=yt(1):t=rt(of.div(Zb)),this._output=t,t}generate(e){if(this.scope===Un.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(Zb).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}Un.COORDINATE="coordinate";Un.VIEWPORT="viewport";Un.SIZE="size";Un.UV="uv";Un.DPR="dpr";const T9=Ve(Un,Un.DPR),bu=Ve(Un,Un.UV),Zb=Ve(Un,Un.SIZE),of=Ve(Un,Un.COORDINATE),GD=Ve(Un,Un.VIEWPORT),M9=GD.zw;GD.xy;let Rx=null,Cg=null,Cx=null,Ng=null,Nx=null,Dg=null,Dx=null,Lg=null;const s0=yt(0,"uint").setName("u_cameraIndex").setGroup(bT("cameraIndex")).toVarying("v_cameraIndex"),hu=yt("float").setName("cameraNear").setGroup(_t).onRenderUpdate(({camera:i})=>i.near),fu=yt("float").setName("cameraFar").setGroup(_t).onRenderUpdate(({camera:i})=>i.far),Wd=Se(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const n of i.cameras)t.push(n.projectionMatrix);Cg===null?Cg=_s(t).setGroup(_t).setName("cameraProjectionMatrices"):Cg.array=t,e=Cg.element(i.isMultiViewCamera?af("gl_ViewID_OVR"):s0).toConst("cameraProjectionMatrix")}else Rx===null&&(Rx=yt(i.projectionMatrix).setName("cameraProjectionMatrix").setGroup(_t).onRenderUpdate(({camera:t})=>t.projectionMatrix)),e=Rx;return e}).once()(),E9=Se(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const n of i.cameras)t.push(n.projectionMatrixInverse);Ng===null?Ng=_s(t).setGroup(_t).setName("cameraProjectionMatricesInverse"):Ng.array=t,e=Ng.element(i.isMultiViewCamera?af("gl_ViewID_OVR"):s0).toConst("cameraProjectionMatrixInverse")}else Cx===null&&(Cx=yt(i.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(_t).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse)),e=Cx;return e}).once()(),Mo=Se(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const n of i.cameras)t.push(n.matrixWorldInverse);Dg===null?Dg=_s(t).setGroup(_t).setName("cameraViewMatrices"):Dg.array=t,e=Dg.element(i.isMultiViewCamera?af("gl_ViewID_OVR"):s0).toConst("cameraViewMatrix")}else Nx===null&&(Nx=yt(i.matrixWorldInverse).setName("cameraViewMatrix").setGroup(_t).onRenderUpdate(({camera:t})=>t.matrixWorldInverse)),e=Nx;return e}).once()(),A9=Se(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(let n=0,r=i.cameras.length;n<r;n++)t.push(new G);Lg===null?Lg=_s(t).setGroup(_t).setName("cameraPositions").onRenderUpdate(({camera:n},r)=>{const s=n.cameras,o=r.array;for(let u=0,c=s.length;u<c;u++)o[u].setFromMatrixPosition(s[u].matrixWorld)}):Lg.array=t,e=Lg.element(i.isMultiViewCamera?af("gl_ViewID_OVR"):s0).toConst("cameraPosition")}else Dx===null&&(Dx=yt(new G).setName("cameraPosition").setGroup(_t).onRenderUpdate(({camera:t},n)=>n.value.setFromMatrixPosition(t.matrixWorld))),e=Dx;return e}).once()(),VR=new Sp;class In extends ct{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Dt.OBJECT,this.uniformNode=new Rp(null)}getNodeType(){const e=this.scope;if(e===In.WORLD_MATRIX)return"mat4";if(e===In.POSITION||e===In.VIEW_POSITION||e===In.DIRECTION||e===In.SCALE)return"vec3";if(e===In.RADIUS)return"float"}update(e){const t=this.object3d,n=this.uniformNode,r=this.scope;if(r===In.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===In.POSITION)n.value=n.value||new G,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===In.SCALE)n.value=n.value||new G,n.value.setFromMatrixScale(t.matrixWorld);else if(r===In.DIRECTION)n.value=n.value||new G,t.getWorldDirection(n.value);else if(r===In.VIEW_POSITION){const s=e.camera;n.value=n.value||new G,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}else if(r===In.RADIUS){const s=e.object.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),VR.copy(s.boundingSphere).applyMatrix4(t.matrixWorld),n.value=VR.radius}}generate(e){const t=this.scope;return t===In.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===In.POSITION||t===In.VIEW_POSITION||t===In.DIRECTION||t===In.SCALE?this.uniformNode.nodeType="vec3":t===In.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}In.WORLD_MATRIX="worldMatrix";In.POSITION="position";In.SCALE="scale";In.VIEW_POSITION="viewPosition";In.DIRECTION="direction";In.RADIUS="radius";class Ms extends In{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}Ms.DIRECTION;const Bu=Ve(Ms,Ms.WORLD_MATRIX);Ms.POSITION;Ms.SCALE;Ms.VIEW_POSITION;Ms.RADIUS;const w9=yt(new Nt).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),Cp=Se(i=>i.context.modelViewMatrix||R9).once()().toVar("modelViewMatrix"),R9=Mo.mul(Bu),HR=Se(i=>(i.context.isHighPrecisionModelViewMatrix=!0,yt("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),jR=Se(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return yt("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),C9=Se(i=>i.shaderStage!=="fragment"?(xn("TSL: `clipSpace` is only available in fragment stage."),wt()):i.context.clipSpace.toVarying("v_clipSpace")).once()(),a0=El("position","vec3"),Oi=a0.toVarying("positionLocal"),w_=a0.toVarying("positionPrevious"),Vh=Se(i=>Bu.mul(Oi).xyz.toVarying(i.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),VD=Se(()=>Oi.transformDirection(Bu).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),li=Se(i=>{if(i.shaderStage==="fragment"&&i.material.vertexNode){const e=E9.mul(C9);return e.xyz.div(e.w).toVar("positionView")}return i.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),On=Se(i=>{let e;return i.camera.isOrthographicCamera?e=ve(0,0,1):e=li.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class N9 extends ct{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===Tn?"false":e.getFrontFacing()}}const D9=Ve(N9),HD=ye(D9).mul(2).sub(1),Np=Se(([i],{material:e})=>{const t=e.side;return t===Tn?i=i.mul(-1):t===Ui&&(i=i.mul(HD)),i}),jD=El("normal","vec3"),Ma=Se(i=>i.geometry.hasAttribute("normal")===!1?(Ne('TSL: Vertex attribute "normal" not found on geometry.'),ve(0,1,0)):jD,"vec3").once()().toVar("normalLocal"),L9=li.dFdx().cross(li.dFdy()).normalize().toVar("normalFlat"),mp=Se(i=>{let e;return i.isFlatShading()?e=L9:e=WD(Ma).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),P9=Se(i=>{let e=mp.transformDirection(Mo);return i.isFlatShading()!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),tn=Se(i=>{let e;return i.subBuildFn==="NORMAL"||i.subBuildFn==="VERTEX"?(e=mp,i.isFlatShading()!==!0&&(e=Np(e))):e=i.context.setupNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),lf=tn.transformDirection(Mo).toVar("normalWorld"),du=Se(({subBuildFn:i,context:e})=>{let t;return i==="NORMAL"||i==="VERTEX"?t=tn:t=e.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),U9=Se(([i,e=Bu])=>{const t=qi(e),n=i.div(ve(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),WD=Se(([i],e)=>{const t=e.context.modelNormalViewMatrix;if(t)return t.transformDirection(i);const n=w9.mul(i);return Mo.transformDirection(n)});Se(()=>(Ne('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),tn)).once(["NORMAL","VERTEX"])();Se(()=>(Ne('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),lf)).once(["NORMAL","VERTEX"])();Se(()=>(Ne('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),du)).once(["NORMAL","VERTEX"])();const WR=new Br,Lx=new Wt,O9=yt(0).onReference(({material:i})=>i).onObjectUpdate(({material:i})=>i.refractionRatio),Px=yt(1).onReference(({material:i})=>i).onObjectUpdate(function({material:i,scene:e}){return i.envMap?i.envMapIntensity:e.environmentIntensity}),$D=yt(new Wt).onReference(function(i){return i.material}).onObjectUpdate(function({material:i,scene:e}){const t=e.environment!==null&&i.envMap===null?e.environmentRotation:i.envMapRotation;return t?(WR.copy(t),Lx.makeRotationFromEuler(WR)):Lx.identity(),Lx}),B9=On.negate().reflect(tn),F9=On.negate().refract(tn,O9),I9=B9.transformDirection(Mo).toVar("reflectVector"),z9=F9.transformDirection(Mo).toVar("reflectVector"),k9=new Kh;class G9 extends sf{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===js?I9:e.mapping===xa?z9:(Pe('CubeTextureNode: Mapping "%s" not supported.',e.mapping),ve(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===ba?ve(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===ba||!n.isRenderTargetTexture)&&(t=ve(t.x.negate(),t.yz)),$D.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}const V9=fn(G9).setParameterLength(1,4).setName("cubeTexture"),Lr=(i=k9,e=null,t=null,n=null)=>{let r;return i&&i.isCubeTextureNode===!0?(r=ot(i.clone()),r.referenceNode=i,e!==null&&(r.uvNode=ot(e)),t!==null&&(r.levelNode=ot(t)),n!==null&&(r.biasNode=ot(n))):r=V9(i,e,t,n),r};class H9 extends nf{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class NT extends ct{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Dt.OBJECT}element(e){return new H9(this,ot(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return Ne('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=kD(null,e,this.count):Array.isArray(this.getValueFromReference())?t=_s(null,e):e==="texture"?t=Fn(null):e==="cubeTexture"?t=Lr(null):t=yt(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;r<t.length;r++)n=n[t[r]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const jn=(i,e,t)=>new NT(i,e,t),$R=(i,e,t,n)=>new NT(i,e,n,t);class j9 extends NT{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const ll=(i,e,t=null)=>new j9(i,e,t),qD=rf(),W9=li.dFdx(),$9=li.dFdy(),XD=qD.dFdx(),YD=qD.dFdy(),KD=tn,ZD=$9.cross(KD),QD=KD.cross(W9),Qb=ZD.mul(XD.x).add(QD.mul(YD.x)),Jb=ZD.mul(XD.y).add(QD.mul(YD.y)),qR=Qb.dot(Qb).max(Jb.dot(Jb)),JD=qR.equal(0).select(0,qR.inverseSqrt()),q9=Qb.mul(JD).toVar("tangentViewFrame"),X9=Jb.mul(JD).toVar("bitangentViewFrame"),e3=El("tangent","vec4"),R_=e3.xyz.toVar("tangentLocal"),t3=Se(i=>{let e;return i.subBuildFn==="VERTEX"||i.geometry.hasAttribute("tangent")?e=Cp.mul(wt(R_,0)).xyz.toVarying("v_tangentView").normalize():e=q9,i.isFlatShading()!==!0&&(e=Np(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),Y9=Se(([i,e],t)=>{let n=i.mul(e3.w).xyz;return t.subBuildFn==="NORMAL"&&t.isFlatShading()!==!0&&(n=n.toVarying(e)),n}).once(["NORMAL"]),K9=Se(i=>{let e;return i.subBuildFn==="VERTEX"||i.geometry.hasAttribute("tangent")?e=Y9(tn.cross(t3),"v_bitangentView").normalize():e=X9,i.isFlatShading()!==!0&&(e=Np(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),Ld=qi(t3,K9,tn).toVar("TBNViewMatrix"),Z9=Se(()=>{let i=uh.cross(On);return i=i.cross(uh).normalize(),i=Sn(i,tn,ou.mul(uo.oneMinus()).oneMinus().pow2().pow2()).normalize(),i}).once()(),Q9=i=>ot(i).mul(.5).add(.5),XR=i=>ve(i,Sl(MT(ye(1).sub(Uu(i,i)))));class J9 extends bi{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=va,this.unpackNormalMode=Cy}setup(e){const{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this;let s=this.node.mul(2).sub(1);if(t===va?r===jN?s=XR(s.xy):r===CO?s=XR(s.yw):r!==Cy&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==Cy&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let u=n;e.isFlatShading()===!0&&(u=Np(u)),s=ve(s.xy.mul(u),s.z)}let o=null;return t===HN?o=WD(s):t===va?o=Ld.mul(s).normalize():(Pe(`NodeMaterial: Unsupported normal map type: ${t}`),o=tn),o}}const YR=fn(J9).setParameterLength(1,2),ej=Se(({textureNode:i,bumpScale:e})=>{const t=r=>i.isolate().context({getUV:s=>r(s.uvNode||rf()),forceUVContext:!0}),n=ye(t(r=>r));return rt(ye(t(r=>r.add(r.dFdx()))).sub(n),ye(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),tj=Se(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,r=e.dFdx().normalize(),s=e.dFdy().normalize(),o=t,u=s.cross(o),c=o.cross(r),h=r.dot(u).mul(HD),d=h.sign().mul(n.x.mul(u).add(n.y.mul(c)));return h.abs().mul(t).sub(d).normalize()});class nj extends bi{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=ej({textureNode:this.textureNode,bumpScale:e});return tj({surf_pos:li,surf_norm:tn,dHdxy:t})}}const ij=fn(nj).setParameterLength(1,2),KR=new Map;class be extends ct{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=KR.get(e);return n===void 0&&(n=ll(e,t),KR.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let r=null;if(n===be.COLOR){const s=t.color!==void 0?this.getColor(n):ve();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(n===be.OPACITY){const s=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(n===be.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=ye(1);else if(n===be.SPECULAR_INTENSITY){const s=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s}else if(n===be.SPECULAR_COLOR){const s=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(n).rgb):r=s}else if(n===be.ROUGHNESS){const s=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).g):r=s}else if(n===be.METALNESS){const s=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(n).b):r=s}else if(n===be.EMISSIVE){const s=this.getFloat("emissiveIntensity"),o=this.getColor(n).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=o.mul(this.getTexture(n)):r=o}else if(n===be.NORMAL)t.normalMap?(r=YR(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType,(t.normalMap.format==vr||t.normalMap.format==Ru||t.normalMap.format==wu)&&(r.unpackNormalMode=jN)):t.bumpMap?r=ij(this.getTexture("bump").r,this.getFloat("bumpScale")):r=tn;else if(n===be.CLEARCOAT){const s=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===be.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===be.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=YR(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=tn;else if(n===be.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(n===be.SHEEN_ROUGHNESS){const s=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s,r=r.clamp(1e-4,1)}else if(n===be.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(n);r=yT(_d.x,_d.y,_d.y.negate(),_d.x).mul(s.rg.mul(2).sub(rt(1)).normalize().mul(s.b))}else r=_d;else if(n===be.IRIDESCENCE_THICKNESS){const s=jn("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const o=jn("0","float",t.iridescenceThicknessRange);r=s.sub(o).mul(this.getTexture(n).g).add(o)}else r=s}else if(n===be.TRANSMISSION){const s=this.getFloat(n);t.transmissionMap?r=s.mul(this.getTexture(n).r):r=s}else if(n===be.THICKNESS){const s=this.getFloat(n);t.thicknessMap?r=s.mul(this.getTexture(n).g):r=s}else if(n===be.IOR)r=this.getFloat(n);else if(n===be.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===be.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(n===be.LINE_DASH_OFFSET)r=t.dashOffset?this.getFloat(n):ye(0);else{const s=this.getNodeType(e);r=this.getCache(n,s)}return r}}be.ALPHA_TEST="alphaTest";be.COLOR="color";be.OPACITY="opacity";be.SHININESS="shininess";be.SPECULAR="specular";be.SPECULAR_STRENGTH="specularStrength";be.SPECULAR_INTENSITY="specularIntensity";be.SPECULAR_COLOR="specularColor";be.REFLECTIVITY="reflectivity";be.ROUGHNESS="roughness";be.METALNESS="metalness";be.NORMAL="normal";be.CLEARCOAT="clearcoat";be.CLEARCOAT_ROUGHNESS="clearcoatRoughness";be.CLEARCOAT_NORMAL="clearcoatNormal";be.EMISSIVE="emissive";be.ROTATION="rotation";be.SHEEN="sheen";be.SHEEN_ROUGHNESS="sheenRoughness";be.ANISOTROPY="anisotropy";be.IRIDESCENCE="iridescence";be.IRIDESCENCE_IOR="iridescenceIOR";be.IRIDESCENCE_THICKNESS="iridescenceThickness";be.IOR="ior";be.TRANSMISSION="transmission";be.THICKNESS="thickness";be.ATTENUATION_DISTANCE="attenuationDistance";be.ATTENUATION_COLOR="attenuationColor";be.LINE_SCALE="scale";be.LINE_DASH_SIZE="dashSize";be.LINE_GAP_SIZE="gapSize";be.LINE_WIDTH="linewidth";be.LINE_DASH_OFFSET="dashOffset";be.POINT_SIZE="size";be.DISPERSION="dispersion";be.LIGHT_MAP="light";be.AO="ao";const rj=Ve(be,be.ALPHA_TEST),sj=Ve(be,be.COLOR),aj=Ve(be,be.SHININESS),oj=Ve(be,be.EMISSIVE),n3=Ve(be,be.OPACITY),lj=Ve(be,be.SPECULAR),ZR=Ve(be,be.SPECULAR_INTENSITY),uj=Ve(be,be.SPECULAR_COLOR),h_=Ve(be,be.SPECULAR_STRENGTH),Ux=Ve(be,be.REFLECTIVITY),cj=Ve(be,be.ROUGHNESS),hj=Ve(be,be.METALNESS),fj=Ve(be,be.NORMAL),dj=Ve(be,be.CLEARCOAT),pj=Ve(be,be.CLEARCOAT_ROUGHNESS),mj=Ve(be,be.CLEARCOAT_NORMAL),gj=Ve(be,be.ROTATION),_j=Ve(be,be.SHEEN),vj=Ve(be,be.SHEEN_ROUGHNESS),yj=Ve(be,be.ANISOTROPY),xj=Ve(be,be.IRIDESCENCE),bj=Ve(be,be.IRIDESCENCE_IOR),Sj=Ve(be,be.IRIDESCENCE_THICKNESS),Tj=Ve(be,be.TRANSMISSION),Mj=Ve(be,be.THICKNESS),Ej=Ve(be,be.IOR),Aj=Ve(be,be.ATTENUATION_DISTANCE),wj=Ve(be,be.ATTENUATION_COLOR),Rj=Ve(be,be.LINE_SCALE),Cj=Ve(be,be.LINE_DASH_SIZE),Nj=Ve(be,be.LINE_GAP_SIZE);be.LINE_WIDTH;const Dj=Ve(be,be.LINE_DASH_OFFSET),Lj=Ve(be,be.POINT_SIZE),Pj=Ve(be,be.DISPERSION),i3=Ve(be,be.LIGHT_MAP),Uj=Ve(be,be.AO),_d=yt(new Ie).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),Oj=Se(i=>i.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class Bj extends nf{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}const Fj=fn(Bj).setParameterLength(2);class Ij extends CT{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){let r,s=null;t&&t.isStruct?(r="struct",s=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=J2(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=ys.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Fj(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(ys.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=UD(this.value),this._varying=Vu(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}}const QR=(i,e=null,t=0)=>new Ij(i,e,t);class Wn extends ct{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r;if(n===Wn.VERTEX)r=e.getVertexIndex();else if(n===Wn.INSTANCE)r=e.getInstanceIndex();else if(n===Wn.DRAW)r=e.getDrawIndex();else if(n===Wn.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===Wn.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===Wn.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=Vu(this).build(e,t),s}}Wn.VERTEX="vertex";Wn.INSTANCE="instance";Wn.SUBGROUP="subgroup";Wn.INVOCATION_LOCAL="invocationLocal";Wn.INVOCATION_SUBGROUP="invocationSubgroup";Wn.DRAW="draw";const zj=Ve(Wn,Wn.VERTEX),$d=Ve(Wn,Wn.INSTANCE);Wn.SUBGROUP;Wn.INVOCATION_SUBGROUP;Wn.INVOCATION_LOCAL;const kj=Ve(Wn,Wn.DRAW);class Gj extends ct{static get type(){return"InstanceNode"}constructor(e,t,n=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Dt.FRAME,this.buffer=null,this.bufferColor=null,this.previousInstanceMatrixNode=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){const{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){let{instanceMatrixNode:t,instanceColorNode:n}=this;t===null&&(t=this._createInstanceMatrixNode(!0,e),this.instanceMatrixNode=t);const{instanceColor:r,isStorageColor:s}=this;if(r&&n===null){if(s)n=QR(r,"vec3",Math.max(r.count,1)).element($d);else{const u=new wB(r.array,3),c=r.usage===p_?GR:kR;this.bufferColor=u,n=ve(c(u,"vec3",3,0))}this.instanceColorNode=n}const o=t.mul(Oi).xyz;if(Oi.assign(o),e.needsPreviousData()&&w_.assign(this.getPreviousInstancedPosition(e)),e.hasGeometryAttribute("normal")){const u=U9(Ma,t);Ma.assign(u)}this.instanceColorNode!==null&&A_("vec3","vInstanceColor").assign(this.instanceColorNode)}update(e){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)),this.previousInstanceMatrixNode!==null&&e.object.previousInstanceMatrix.array.set(this.instanceMatrix.array)}getPreviousInstancedPosition(e){const t=e.object;return this.previousInstanceMatrixNode===null&&(t.previousInstanceMatrix=this.instanceMatrix.clone(),this.previousInstanceMatrixNode=this._createInstanceMatrixNode(!1,e)),this.previousInstanceMatrixNode.mul(w_).xyz}_createInstanceMatrixNode(e,t){let n;const{instanceMatrix:r}=this,{count:s}=r;if(this.isStorageMatrix)n=QR(r,"mat4",Math.max(s,1)).element($d);else if(s*16*4<=t.getUniformBufferLimit())n=kD(r.array,"mat4",Math.max(s,1)).element($d);else{const u=new bF(r.array,16,1);e===!0&&(this.buffer=u);const c=r.usage===p_?GR:kR,h=[c(u,"vec4",16,0),c(u,"vec4",16,4),c(u,"vec4",16,8),c(u,"vec4",16,12)];n=yu(...h)}return n}}class Vj extends Gj{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const Hj=fn(Vj).setParameterLength(1);class jj extends ct{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=$d:this.batchingIdNode=kj);const n=Se(([v])=>{const S=kn(hh(gs(this.batchMesh._indirectTexture),0).x).toConst(),b=kn(v).mod(S).toConst(),x=kn(v).div(S).toConst();return gs(this.batchMesh._indirectTexture,la(b,x)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(kn(this.batchingIdNode)),r=this.batchMesh._matricesTexture,s=kn(hh(gs(r),0).x).toConst(),o=ye(n).mul(4).toInt().toConst(),u=o.mod(s).toConst(),c=o.div(s).toConst(),h=yu(gs(r,la(u,c)),gs(r,la(u.add(1),c)),gs(r,la(u.add(2),c)),gs(r,la(u.add(3),c))),d=this.batchMesh._colorsTexture;if(d!==null){const S=Se(([b])=>{const x=kn(hh(gs(d),0).x).toConst(),M=b,E=M.mod(x).toConst(),w=M.div(x).toConst();return gs(d,la(E,w)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);A_("vec3","vBatchColor").assign(S)}const p=qi(h);Oi.assign(h.mul(Oi));const g=Ma.div(ve(p[0].dot(p[0]),p[1].dot(p[1]),p[2].dot(p[2]))),_=p.mul(g).xyz;Ma.assign(_),e.hasGeometryAttribute("tangent")&&R_.mulAssign(p)}}const Wj=fn(jj).setParameterLength(1),JR=new WeakMap;class $j extends ct{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Dt.OBJECT,this.skinIndexNode=El("skinIndex","uvec4"),this.skinWeightNode=El("skinWeight","vec4"),this.bindMatrixNode=jn("bindMatrix","mat4"),this.bindMatrixInverseNode=jn("bindMatrixInverse","mat4"),this.boneMatricesNode=$R("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Oi,this.toPositionNode=Oi,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:o}=this,u=e.element(n.x),c=e.element(n.y),h=e.element(n.z),d=e.element(n.w),p=s.mul(t),g=Fr(u.mul(r.x).mul(p),c.mul(r.y).mul(p),h.mul(r.z).mul(p),d.mul(r.w).mul(p));return o.mul(g).xyz}getSkinnedNormalAndTangent(e=this.boneMatricesNode,t=Ma,n=R_){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:o,bindMatrixInverseNode:u}=this,c=e.element(r.x),h=e.element(r.y),d=e.element(r.z),p=e.element(r.w);let g=Fr(s.x.mul(c),s.y.mul(h),s.z.mul(d),s.w.mul(p));g=u.mul(g).mul(o);const _=g.transformDirection(t).xyz,v=g.transformDirection(n).xyz;return{skinNormal:_,skinTangent:v}}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=$R("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,w_)}setup(e){e.needsPreviousData()&&w_.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const{skinNormal:n,skinTangent:r}=this.getSkinnedNormalAndTangent();Ma.assign(n),e.hasGeometryAttribute("tangent")&&R_.assign(r)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;JR.get(t)!==e.frameId&&(JR.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const qj=i=>new $j(i);class Xj extends ct{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let u=0,c=this.params.length-1;u<c;u++){const h=this.params[u],d=h.isNode!==!0&&h.name||this.getVarName(u),p=h.isNode!==!0&&h.type||"int";n[d]=ha(d,p)}const r=e.addStack(),s=this.params[this.params.length-1](n);t.returnsNode=s.context({nodeLoop:s}),t.stackNode=r;const o=this.params[0];if(o.isNode!==!0&&typeof o.update=="function"){const u=Se(this.params[0].update)(n);t.updateNode=u.context({nodeLoop:u})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){const t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){const t=this.getProperties(e),n=this.params,r=t.stackNode;for(let o=0,u=n.length-1;o<u;o++){const c=n[o];let h=!1,d=null,p=null,g=null,_=null,v=null,S=null;c.isNode?c.getNodeType(e)==="bool"?(h=!0,_="bool",p=c.build(e,_)):(_="int",g=this.getVarName(o),d="0",p=c.build(e,_),v="<"):(_=c.type||"int",g=c.name||this.getVarName(o),d=c.start,p=c.end,v=c.condition,S=c.update,typeof d=="number"?d=e.generateConst(_,d):d&&d.isNode&&(d=d.build(e,_)),typeof p=="number"?p=e.generateConst(_,p):p&&p.isNode&&(p=p.build(e,_)),d!==void 0&&p===void 0?(d=d+" - 1",p="0",v=">="):p!==void 0&&d===void 0&&(d="0",v="<"),v===void 0&&(Number(d)>Number(p)?v=">=":v="<"));let b;if(h)b=`while ( ${p} )`;else{const x={start:d,end:p},M=x.start,E=x.end;let w;const D=()=>v.includes("<")?"+=":"-=";if(S!=null)switch(typeof S){case"function":w=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":w=g+" "+D()+" "+e.generateConst(_,S);break;case"string":w=g+" "+S;break;default:S.isNode?w=g+" "+D()+" "+S.build(e):(Pe("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),w="break /* invalid update */")}else _==="int"||_==="uint"?S=v.includes("<")?"++":"--":S=D()+" 1.",w=g+" "+S;const C=e.getVar(_,g)+" = "+M,N=g+" "+v+" "+E;b=`for ( ${C}; ${N}; ${w} )`}e.addFlowCode((o===0?`
`:"")+e.tab+b+` {

`).addFlowTab()}const s=r.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(`
`+e.tab+s);for(let o=0,u=this.params.length-1;o<u;o++)e.addFlowCode((o===0?"":e.tab)+`}

`).removeFlowTab();e.addFlowTab()}}const vs=(...i)=>new Xj(lh(i,"int")).toStack(),Yj=()=>ha("break").toStack(),Ox=new WeakMap,Qr=new Pt,eC=Se(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:s})=>{const o=kn(zj).mul(t).add(s),u=o.div(n),c=o.sub(u.mul(n));return gs(i,la(c,u)).depth(r).xyz.mul(e)});function Kj(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,s=r!==void 0?r.length:0;let o=Ox.get(i);if(o===void 0||o.count!==s){let M=function(){b.dispose(),Ox.delete(i),i.removeEventListener("dispose",M)};var u=M;o!==void 0&&o.texture.dispose();const c=i.morphAttributes.position||[],h=i.morphAttributes.normal||[],d=i.morphAttributes.color||[];let p=0;e===!0&&(p=1),t===!0&&(p=2),n===!0&&(p=3);let g=i.attributes.position.count*p,_=1;const v=4096;g>v&&(_=Math.ceil(g/v),g=v);const S=new Float32Array(g*_*4*s),b=new $S(S,g,_,s);b.type=ri,b.needsUpdate=!0;const x=p*4;for(let E=0;E<s;E++){const w=c[E],D=h[E],C=d[E],N=g*_*4*E;for(let A=0;A<w.count;A++){const L=A*x;e===!0&&(Qr.fromBufferAttribute(w,A),S[N+L+0]=Qr.x,S[N+L+1]=Qr.y,S[N+L+2]=Qr.z,S[N+L+3]=0),t===!0&&(Qr.fromBufferAttribute(D,A),S[N+L+4]=Qr.x,S[N+L+5]=Qr.y,S[N+L+6]=Qr.z,S[N+L+7]=0),n===!0&&(Qr.fromBufferAttribute(C,A),S[N+L+8]=Qr.x,S[N+L+9]=Qr.y,S[N+L+10]=Qr.z,S[N+L+11]=C.itemSize===4?Qr.w:1)}}o={count:s,texture:b,stride:p,size:new Ie(g,_)},Ox.set(i,o),i.addEventListener("dispose",M)}return o}class Zj extends ct{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=yt(1),this.updateType=Dt.OBJECT}setup(e){const{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,o=s!==void 0?s.length:0,{texture:u,stride:c,size:h}=Kj(t);n===!0&&Oi.mulAssign(this.morphBaseInfluence),r===!0&&Ma.mulAssign(this.morphBaseInfluence);const d=kn(h.width);vs(o,({i:p})=>{const g=ye(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?g.assign(gs(this.mesh.morphTexture,la(kn(p).add(1),kn($d))).r):g.assign(jn("morphTargetInfluences","float").element(p).toVar()),wn(g.notEqual(0),()=>{n===!0&&Oi.addAssign(eC({bufferMap:u,influence:g,stride:c,width:d,depth:p,offset:kn(0)})),r===!0&&Ma.addAssign(eC({bufferMap:u,influence:g,stride:c,width:d,depth:p,offset:kn(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const Qj=fn(Zj).setParameterLength(1);class uf extends ct{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Jj extends uf{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class eW extends ND{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=ve().toVar("directDiffuse"),r=ve().toVar("directSpecular"),s=ve().toVar("indirectDiffuse"),o=ve().toVar("indirectSpecular"),u={directDiffuse:n,directSpecular:r,indirectDiffuse:s,indirectSpecular:o};return{radiance:ve().toVar("radiance"),irradiance:ve().toVar("irradiance"),iblIrradiance:ve().toVar("iblIrradiance"),ambientOcclusion:ye(1).toVar("ambientOcclusion"),reflectedLight:u,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const tW=fn(eW);class nW extends uf{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const jc=new Ie;class r3 extends sf{static get type(){return"ViewportTextureNode"}constructor(e=bu,t=null,n=null){let r=null;n===null?(r=new KN,r.minFilter=Ur,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=Dt.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){const r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const t=e.renderer,n=t.getRenderTarget();n===null?t.getDrawingBufferSize(jc):jc.set(n.width,n.height);const r=this.getTextureForReference(n);(r.image.width!==jc.width||r.image.height!==jc.height)&&(r.image.width=jc.width,r.image.height=jc.height,r.needsUpdate=!0);const s=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=s}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const s3=fn(r3,null,null,{generateMipmaps:!0}).setParameterLength(0,3),iW=s3(),rW=(i=bu,e=null)=>iW.sample(i,e);let Pg=null;class sW extends r3{static get type(){return"ViewportDepthTextureNode"}constructor(e=bu,t=null){Pg===null&&(Pg=new br),super(e,t,Pg)}getTextureForReference(){return Pg}}const aW=fn(sW).setParameterLength(0,2);class Or extends ct{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Or.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===Or.DEPTH_BASE)n!==null&&(r=u3().assign(n));else if(t===Or.DEPTH)e.isPerspectiveCamera?r=a3(li.z,hu,fu):r=qd(li.z,hu,fu);else if(t===Or.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const s=o3(n,hu,fu);r=qd(s,hu,fu)}else r=n;else r=qd(li.z,hu,fu);return r}}Or.DEPTH_BASE="depthBase";Or.DEPTH="depth";Or.LINEAR_DEPTH="linearDepth";const qd=(i,e,t)=>i.add(e).div(e.sub(t)),a3=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),oW=(i,e,t)=>e.mul(i.add(t)).div(i.mul(e.sub(t))),o3=Se(([i,e,t],n)=>n.renderer.reversedDepthBuffer===!0?e.mul(t).div(e.sub(t).mul(i).sub(e)):e.mul(t).div(t.sub(e).mul(i).sub(t))),l3=(i,e,t)=>{e=e.max(1e-6).toVar();const n=yo(i.negate().div(e)),r=yo(t.div(e));return n.div(r)},u3=fn(Or,Or.DEPTH_BASE),c3=Ve(Or,Or.DEPTH),lW=fn(Or,Or.LINEAR_DEPTH).setParameterLength(0,1);aW();c3.assign=i=>u3(i);class bs extends ct{static get type(){return"ClippingNode"}constructor(e=bs.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===bs.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===bs.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return Se(()=>{const n=ye().toVar("distanceToPlane"),r=ye().toVar("distanceToGradient"),s=ye(1).toVar("clipOpacity"),o=t.length;if(this.hardwareClipping===!1&&o>0){const c=_s(t).setGroup(_t);vs(o,({i:h})=>{const d=c.element(h);n.assign(li.dot(d.xyz).negate().add(d.w)),r.assign(n.fwidth().div(2)),s.mulAssign(So(r.negate(),r,n))})}const u=e.length;if(u>0){const c=_s(e).setGroup(_t),h=ye(1).toVar("intersectionClipOpacity");vs(u,({i:d})=>{const p=c.element(d);n.assign(li.dot(p.xyz).negate().add(p.w)),r.assign(n.fwidth().div(2)),h.mulAssign(So(r.negate(),r,n).oneMinus())}),s.mulAssign(h.oneMinus())}yn.a.mulAssign(s),yn.a.equal(0).discard()})()}setupDefault(e,t){return Se(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const s=_s(t).setGroup(_t);vs(n,({i:o})=>{const u=s.element(o);li.dot(u.xyz).greaterThan(u.w).discard()})}const r=e.length;if(r>0){const s=_s(e).setGroup(_t),o=vT(!0).toVar("clipped");vs(r,({i:u})=>{const c=s.element(u);o.assign(li.dot(c.xyz).greaterThan(c.w).and(o))}),o.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Se(()=>{const r=_s(e).setGroup(_t),s=af(t.getClipDistance());vs(n,({i:o})=>{const u=r.element(o),c=li.dot(u.xyz).sub(u.w).negate();s.element(o).assign(c)})})()}}bs.ALPHA_TO_COVERAGE="alphaToCoverage";bs.DEFAULT="default";bs.HARDWARE="hardware";const uW=()=>new bs,cW=()=>new bs(bs.ALPHA_TO_COVERAGE),hW=()=>new bs(bs.HARDWARE),fW=.05,tC=Se(([i])=>Ta(Ft(1e4,es(Ft(17,i.x).add(Ft(.1,i.y)))).mul(Fr(.1,ts(es(Ft(13,i.y).add(i.x))))))),nC=Se(([i])=>tC(rt(tC(i.xy),i.z))),dW=Se(([i])=>{const e=Xi(xo(TD(i.xyz)),xo(MD(i.xyz))),t=ye(1).div(ye(fW).mul(e)).toVar("pixScale"),n=rt(dp(xu(yo(t))),dp(TT(yo(t)))),r=rt(nC(xu(n.x.mul(i.xyz))),nC(xu(n.y.mul(i.xyz)))),s=Ta(yo(t)),o=Fr(Ft(s.oneMinus(),r.x),Ft(s,r.y)),u=Gh(s,s.oneMinus()),c=ve(o.mul(o).div(Ft(2,u).mul(Nr(1,u))),o.sub(Ft(.5,u)).div(Nr(1,u)),Nr(1,Nr(1,o).mul(Nr(1,o)).div(Ft(2,u).mul(Nr(1,u))))),h=o.lessThan(u.oneMinus()).select(o.lessThan(u).select(c.x,c.y),c.z);return Ml(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class pW extends ID{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let r;return n===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new Pt(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const mW=(i=0)=>new pW(i),gW=Se(([i])=>wt(i.rgb.mul(i.a),i.a),{color:"vec4",return:"vec4"});class ui extends ir{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;const n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:n}of this._getNodeChildren())e.push(ef(t.slice(0,-4)),n.getCacheKey());return this.type+wp(e)}build(e){this.setup(e)}setupObserver(e){return new X6(e)}setup(e){e.context.setupNormal=()=>ch(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();t.contextNode.isContextNode===!0?e.context={...e.context,...t.contextNode.getFlowContextData()}:Pe('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context={...e.context,...this.contextNode.getFlowContextData()}:Pe('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();const r=this.setupVertex(e),s=ch(this.vertexNode||r,"VERTEX");e.context.clipSpace=s,e.stack.outputNode=s,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let o;const u=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const c=this.setupLighting(e);u!==null&&e.stack.addToStack(u);const h=wt(c,yn.a).max(0);o=this.setupOutput(e,h),Hd.assign(o);const d=this.outputNode!==null;if(d&&(o=this.outputNode),e.context.getOutput&&(o=e.context.getOutput(o,e)),n!==null){const p=t.getMRT(),g=this.mrtNode;p!==null?(d&&Hd.assign(o),o=p,g!==null&&(o=p.merge(g))):g!==null&&(o=g)}}else{let c=this.fragmentNode;c.isOutputStructNode!==!0&&(c=wt(c)),o=this.setupOutput(e,c)}e.stack.outputNode=o,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const s=e.renderer.currentSamples;this.alphaToCoverage&&s>1?r=cW():e.stack.addToStack(uW())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(hW()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(r===null){const s=t.getMRT();s&&s.has("depth")?r=s.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?r=l3(li.z,hu,fu):r=qd(li.z,hu,fu))}r!==null&&c3.assign(r).toStack()}setupPositionView(){return Cp.mul(Oi).xyz}setupModelViewProjection(){return Wd.mul(li)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),Oj}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&Qj(t).toStack(),t.isSkinnedMesh===!0&&qj(t).toStack(),this.displacementMap){const r=ll("displacementMap","texture"),s=ll("displacementScale","float"),o=ll("displacementBias","float");Oi.addAssign(Ma.normalize().mul(r.x.mul(s).add(o)))}return t.isBatchedMesh&&Wj(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&Hj(t).toStack(),this.positionNode!==null&&Oi.assign(ch(this.positionNode,"POSITION","vec3")),Oi}setupDiffuseColor(e){const{object:t,geometry:n}=e;this.maskNode!==null&&vT(this.maskNode).not().discard();let r=this.colorNode?wt(this.colorNode):sj;this.vertexColors===!0&&n.hasAttribute("color")&&(r=r.mul(mW())),t.instanceColor&&(r=A_("vec3","vInstanceColor").mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=A_("vec3","vBatchColor").mul(r)),yn.assign(r);const s=this.opacityNode?ye(this.opacityNode):n3;yn.a.assign(yn.a.mul(s));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?ye(this.alphaTestNode):rj,this.alphaToCoverage===!0?(yn.a=So(o,o.add(ED(yn.a)),yn.a),yn.a.lessThanEqual(0).discard()):yn.a.lessThanEqual(o).discard()),this.alphaHash===!0&&yn.a.lessThan(dW(Oi)).discard(),e.isOpaque()&&yn.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?ve(0):yn.rgb}setupNormal(){return this.normalNode?ve(this.normalNode):fj}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?ll("envMap","cubeTexture"):ll("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new nW(i3)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);r&&r.isLightingNode&&t.push(r);let s=this.aoNode;s===null&&e.material.aoMap&&(s=Uj),e.context.getAO&&(s=e.context.getAO(s,e)),s&&t.push(new Jj(s));let o=this.lightsNode||e.lightsNode;return t.length>0&&(o=e.renderer.lighting.createNode([...o.getLights(),...t])),o}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:s}=this,u=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let c=this.setupOutgoingLight(e);if(u&&u.getScope().hasLights){const h=this.setupLightingModel(e)||null;c=tW(u,h,n,r)}else n!==null&&(c=ve(r!==null?Sn(c,n,r):n));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(OR.assign(ve(s||oj)),c=c.add(OR)),c}setupFog(e,t){const n=e.fogNode;return n&&(Hd.assign(t),t=wt(n.toVar())),t}setupPremultipliedAlpha(e,t){return gW(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const n in e){const r=e[n];this[n]===void 0&&(this[n]=r,r&&r.clone&&(this[n]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=ir.prototype.toJSON.call(this,e);n.inputNodes={};for(const{property:s,childNode:o}of this._getNodeChildren())n.inputNodes[s]=o.toJSON(e).uuid;function r(s){const o=[];for(const u in s){const c=s[u];delete c.metadata,o.push(c)}return o}if(t){const s=r(e.textures),o=r(e.images),u=r(e.nodes);s.length>0&&(n.textures=s),o.length>0&&(n.images=o),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.maskShadowNode=e.maskShadowNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,this.contextNode=e.contextNode,super.copy(e)}}const _W=new q_;class vW extends ui{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(_W),this.setValues(e)}}const yW=new aF;class xW extends ui{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(yW),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ye(this.offsetNode):Dj,t=this.dashScaleNode?ye(this.dashScaleNode):Rj,n=this.dashSizeNode?ye(this.dashSizeNode):Cj,r=this.gapSizeNode?ye(this.gapSizeNode):Nj;wx.assign(n),BR.assign(r);const s=Vu(El("lineDistance").mul(t));(e?s.add(e):s).mod(wx.add(BR)).greaterThan(wx).discard()}}const bW=new nF;class SW extends ui{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(bW),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ye(this.opacityNode):n3;yn.assign(wT(wt(Q9(tn),e),dr))}}const h3=Se(([i=VD])=>{const e=i.z.atan(i.x).mul(1/(Math.PI*2)).add(.5),t=i.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return rt(e,t)});class f3 extends Rl{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Kh(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s=new zu(5,5,5),o=h3(VD),u=new ui;u.colorNode=Fn(t,o,0),u.side=Tn,u.blending=Bi;const c=new xi(s,u),h=new XS;h.add(c),t.minFilter===Ur&&(t.minFilter=Rn);const d=new l2(1,10,this),p=e.getMRT();return e.setMRT(null),d.update(e,h),e.setMRT(p),t.minFilter=n,t.currentGenerateMipmaps=r,c.geometry.dispose(),c.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,r);e.setRenderTarget(s)}}const Xd=new WeakMap;class TW extends bi{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Lr(null);const t=new Kh;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Dt.RENDER}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:n[r.property];if(s&&s.isTexture){const o=s.mapping;if(o===ih||o===rh){if(Xd.has(s)){const u=Xd.get(s);iC(u,s.mapping),this._cubeTexture=u}else{const u=s.image;if(MW(u)){const c=new f3(u.height);c.fromEquirectangularTexture(t,s),iC(c.texture,s.mapping),this._cubeTexture=c.texture,Xd.set(s,c.texture),s.addEventListener("dispose",d3)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function MW(i){return i==null?!1:i.height>0}function d3(i){const e=i.target;e.removeEventListener("dispose",d3);const t=Xd.get(e);t!==void 0&&(Xd.delete(e),t.dispose())}function iC(i,e){e===ih?i.mapping=js:e===rh&&(i.mapping=xa)}const p3=fn(TW).setParameterLength(1);class DT extends uf{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=p3(this.envNode)}}class EW extends uf{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ye(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class o0{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class m3 extends o0{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(wt(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(wt(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(yn.rgb)}finish(e){const{material:t,context:n}=e,r=n.outgoingLight,s=e.context.environment;if(s)switch(t.combine){case yp:r.rgb.assign(Sn(r.rgb,r.rgb.mul(s.rgb),h_.mul(Ux)));break;case kN:r.rgb.assign(Sn(r.rgb,s.rgb,h_.mul(Ux)));break;case GN:r.rgb.addAssign(s.rgb.mul(h_.mul(Ux)));break;default:Ne("BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const AW=new ca;class wW extends ui{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(AW),this.setValues(e)}setupNormal(){return Np(mp)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new DT(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new EW(i3)),t}setupOutgoingLight(){return yn.rgb}setupLightingModel(){return new m3}}const gp=Se(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),Hh=Se(i=>i.diffuseColor.mul(1/Math.PI)),RW=()=>ye(.25),CW=Se(({dotNH:i})=>Yb.mul(ye(.5)).add(1).mul(ye(1/Math.PI)).mul(i.pow(Yb))),NW=Se(({lightDirection:i})=>{const e=i.add(On).normalize(),t=tn.dot(e).clamp(),n=On.dot(e).clamp(),r=gp({f0:Pu,f90:1,dotVH:n}),s=RW(),o=CW({dotNH:t});return r.mul(s).mul(o)});class g3 extends m3{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=tn.dot(e).clamp().mul(t);n.directDiffuse.addAssign(s.mul(Hh({diffuseColor:yn.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(NW({lightDirection:e})).mul(h_))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(Hh({diffuseColor:yn}))),r.indirectDiffuse.mulAssign(t)}}const DW=new r2;class LW extends ui{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(DW),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new DT(t):null}setupLightingModel(){return new g3(!1)}}const PW=new eF;class UW extends ui{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(PW),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new DT(t):null}setupLightingModel(){return new g3}setupVariants(){const e=(this.shininessNode?ye(this.shininessNode):aj).max(1e-4);Yb.assign(e);const t=this.specularNode||lj;Pu.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const OW=Se(i=>{if(i.geometry.hasAttribute("normal")===!1)return ye(0);const e=mp.dFdx().abs().max(mp.dFdy().abs());return e.x.max(e.y).max(e.z)}),_3=Se(i=>{const{roughness:e}=i,t=OW();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),BW=Se(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),r=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Sa(.5,r.add(s).max(_D))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),FW=Se(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:s,dotNV:o,dotNL:u})=>{const c=u.mul(ve(i.mul(t),e.mul(n),o).length()),h=o.mul(ve(i.mul(r),e.mul(s),u).length());return Sa(.5,c.add(h))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),IW=Se(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),zW=ye(1/Math.PI),kW=Se(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const s=i.mul(e),o=ve(e.mul(n),i.mul(r),s.mul(t)),u=o.dot(o),c=s.div(u);return zW.mul(s.mul(c.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),v3=Se(({lightDirection:i,f0:e,f90:t,roughness:n,f:r,normalView:s=tn,USE_IRIDESCENCE:o,USE_ANISOTROPY:u})=>{const c=n.pow2(),h=i.add(On).normalize(),d=s.dot(i).clamp(),p=s.dot(On).clamp(),g=s.dot(h).clamp(),_=On.dot(h).clamp();let v=gp({f0:e,f90:t,dotVH:_}),S,b;if(UR(o)&&(v=xT.mix(v,r)),UR(u)){const x=o_.dot(i),M=o_.dot(On),E=o_.dot(h),w=uh.dot(i),D=uh.dot(On),C=uh.dot(h);S=FW({alphaT:Xb,alphaB:c,dotTV:M,dotBV:D,dotTL:x,dotBL:w,dotNV:p,dotNL:d}),b=kW({alphaT:Xb,alphaB:c,dotNH:g,dotTH:E,dotBH:C})}else S=BW({alpha:c,dotNL:d,dotNV:p}),b=IW({alpha:c,dotNH:g});return v.mul(S).mul(b)}),GW=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;const C_=Se(({roughness:i,dotNV:e})=>{ia===null&&(ia=new QS(GW,16,16,vr,Qn),ia.name="DFG_LUT",ia.minFilter=Rn,ia.magFilter=Rn,ia.wrapS=Pr,ia.wrapT=Pr,ia.generateMipmaps=!1,ia.needsUpdate=!0);const t=rt(i,e);return Fn(ia,t).rg}),VW=Se(({lightDirection:i,f0:e,f90:t,roughness:n,f:r,USE_IRIDESCENCE:s,USE_ANISOTROPY:o})=>{const u=v3({lightDirection:i,f0:e,f90:t,roughness:n,f:r,USE_IRIDESCENCE:s,USE_ANISOTROPY:o}),c=tn.dot(i).clamp(),h=tn.dot(On).clamp(),d=C_({roughness:n,dotNV:h}),p=C_({roughness:n,dotNV:c}),g=e.mul(d.x).add(t.mul(d.y)),_=e.mul(p.x).add(t.mul(p.y)),v=d.x.add(d.y),S=p.x.add(p.y),b=ye(1).sub(v),x=ye(1).sub(S),M=e.add(e.oneMinus().mul(.047619)),E=g.mul(_).mul(M).div(ye(1).sub(b.mul(x).mul(M).mul(M)).add(_D)),w=b.mul(x),D=E.mul(w);return u.add(D)}),y3=Se(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,s=C_({dotNV:e,roughness:r});return t.mul(s.x).add(n.mul(s.y))}),rC=Se(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),r=n.mul(n),s=n.mul(r,r).clamp(0,.9999);return i.sub(ve(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),HW=Se(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=ye(1).div(t),s=e.pow2().oneMinus().max(.0078125);return ye(2).add(n).mul(s.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),jW=Se(({dotNV:i,dotNL:e})=>ye(1).div(ye(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),WW=Se(({lightDirection:i})=>{const e=i.add(On).normalize(),t=tn.dot(i).clamp(),n=tn.dot(On).clamp(),r=tn.dot(e).clamp(),s=HW({roughness:cu,dotNH:r}),o=jW({dotNV:n,dotNL:t});return ms.mul(s).mul(o)}),sC=Se(({N:i,V:e,roughness:t})=>{const s=.0078125,o=i.dot(e).saturate(),u=rt(t,o.oneMinus().sqrt());return u.assign(u.mul(.984375).add(s)),u}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),$W=Se(({f:i})=>{const e=i.length();return Xi(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),Ug=Se(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),r=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),s=n.add(4.1616724).mul(n).add(3.417594).toVar(),o=r.div(s),u=t.greaterThan(0).select(o,Xi(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return i.cross(e).mul(u)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),Bx=Se(({N:i,V:e,P:t,mInv:n,p0:r,p1:s,p2:o,p3:u})=>{const c=s.sub(r).toVar(),h=u.sub(r).toVar(),d=c.cross(h),p=ve().toVar();return wn(d.dot(t.sub(r)).greaterThanEqual(0),()=>{const g=e.sub(i.mul(e.dot(i))).normalize(),_=i.cross(g).negate(),v=n.mul(qi(g,_,i).transpose()).toVar(),S=v.mul(r.sub(t)).normalize().toVar(),b=v.mul(s.sub(t)).normalize().toVar(),x=v.mul(o.sub(t)).normalize().toVar(),M=v.mul(u.sub(t)).normalize().toVar(),E=ve(0).toVar();E.addAssign(Ug({v1:S,v2:b})),E.addAssign(Ug({v1:b,v2:x})),E.addAssign(Ug({v1:x,v2:M})),E.addAssign(Ug({v1:M,v2:S})),p.assign(ve($W({f:E})))}),p}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),l0=1/6,x3=i=>Ft(l0,Ft(i,Ft(i,i.negate().add(3)).sub(3)).add(1)),eS=i=>Ft(l0,Ft(i,Ft(i,Ft(3,i).sub(6))).add(4)),b3=i=>Ft(l0,Ft(i,Ft(i,Ft(-3,i).add(3)).add(3)).add(1)),tS=i=>Ft(l0,r0(i,3)),aC=i=>x3(i).add(eS(i)),oC=i=>b3(i).add(tS(i)),lC=i=>Fr(-1,eS(i).div(x3(i).add(eS(i)))),uC=i=>Fr(1,tS(i).div(b3(i).add(tS(i)))),cC=(i,e,t)=>{const n=i.uvNode,r=Ft(n,e.zw).add(.5),s=xu(r),o=Ta(r),u=aC(o.x),c=oC(o.x),h=lC(o.x),d=uC(o.x),p=lC(o.y),g=uC(o.y),_=rt(s.x.add(h),s.y.add(p)).sub(.5).mul(e.xy),v=rt(s.x.add(d),s.y.add(p)).sub(.5).mul(e.xy),S=rt(s.x.add(h),s.y.add(g)).sub(.5).mul(e.xy),b=rt(s.x.add(d),s.y.add(g)).sub(.5).mul(e.xy),x=aC(o.y).mul(Fr(u.mul(i.sample(_).level(t)),c.mul(i.sample(v).level(t)))),M=oC(o.y).mul(Fr(u.mul(i.sample(S).level(t)),c.mul(i.sample(b).level(t))));return x.add(M)},qW=Se(([i,e])=>{const t=rt(i.size(kn(e))),n=rt(i.size(kn(e.add(1)))),r=Sa(1,t),s=Sa(1,n),o=cC(i,wt(r,t),xu(e)),u=cC(i,wt(s,n),TT(e));return Ta(e).mix(o,u)}),hC=Se(([i,e,t,n,r])=>{const s=ve(CD(e.negate(),ya(i),Sa(1,n))),o=ve(xo(r[0].xyz),xo(r[1].xyz),xo(r[2].xyz));return ya(s).mul(t.mul(o))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),XW=Se(([i,e])=>i.mul(Ml(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),YW=s3(),KW=rW(),fC=Se(([i,e,t],{material:n})=>{const s=(n.side===Tn?YW:KW).sample(i),o=yo(Zb.x).mul(XW(e,t));return qW(s,o)}),dC=Se(([i,e,t])=>(wn(t.notEqual(0),()=>{const n=yD(e).negate().div(t);return vD(n.negate().mul(i))}),ve(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),ZW=Se(([i,e,t,n,r,s,o,u,c,h,d,p,g,_,v])=>{let S,b;if(v){S=wt().toVar(),b=ve().toVar();const D=d.sub(1).mul(v.mul(.025)),C=ve(d.sub(D),d,d.add(D));vs({start:0,end:3},({i:N})=>{const A=C.element(N),L=hC(i,e,p,A,u),j=o.add(L),z=h.mul(c.mul(wt(j,1))),H=rt(z.xy.div(z.w)).toVar();H.addAssign(1),H.divAssign(2),H.assign(rt(H.x,H.y.oneMinus()));const K=fC(H,t,A);S.element(N).assign(K.element(N)),S.a.addAssign(K.a),b.element(N).assign(n.element(N).mul(dC(xo(L),g,_).element(N)))}),S.a.divAssign(3)}else{const D=hC(i,e,p,d,u),C=o.add(D),N=h.mul(c.mul(wt(C,1))),A=rt(N.xy.div(N.w)).toVar();A.addAssign(1),A.divAssign(2),A.assign(rt(A.x,A.y.oneMinus())),S=fC(A,t,d),b=n.mul(dC(xo(D),g,_))}const x=b.rgb.mul(S.rgb),M=i.dot(e).clamp(),E=ve(y3({dotNV:M,specularColor:r,specularF90:s,roughness:t})),w=b.r.add(b.g,b.b).div(3);return wt(E.oneMinus().mul(x),S.a.oneMinus().mul(w).oneMinus())}),QW=qi(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),JW=i=>{const e=i.sqrt();return ve(1).add(e).div(ve(1).sub(e))},pC=(i,e)=>i.sub(e).div(i.add(e)).pow2(),e$=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=ve(54856e-17,44201e-17,52481e-17),r=ve(1681e3,1795300,2208400),s=ve(43278e5,93046e5,66121e5),o=ye(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let u=n.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return u=ve(u.x.add(o),u.y,u.z).div(10685e-11),QW.mul(u)},mC=Se(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const s=Sn(i,e,So(0,.03,n)),u=i.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();wn(u.lessThan(0),()=>ve(1));const c=u.sqrt(),h=pC(s,i),d=gp({f0:h,f90:1,dotVH:t}),p=d.oneMinus(),g=s.lessThan(i).select(Math.PI,0),_=ye(Math.PI).sub(g),v=JW(r.clamp(0,.9999)),S=pC(v,s.toVec3()),b=gp({f0:S,f90:1,dotVH:c}),x=ve(v.x.lessThan(s).select(Math.PI,0),v.y.lessThan(s).select(Math.PI,0),v.z.lessThan(s).select(Math.PI,0)),M=s.mul(n,c,2),E=ve(_).add(x),w=d.mul(b).clamp(1e-5,.9999),D=w.sqrt(),C=p.pow2().mul(b).div(ve(1).sub(w)),A=d.add(C).toVar(),L=C.sub(p).toVar();return vs({start:1,end:2,condition:"<=",name:"m"},({m:j})=>{L.mulAssign(D);const z=e$(ye(j).mul(M),ye(j).mul(E)).mul(2);A.addAssign(L.mul(z))}),A.max(ve(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),vd=Se(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.mul(t),s=t.add(.1).reciprocal(),o=ye(-1.9362).add(t.mul(1.0678)).add(r.mul(.4573)).sub(s.mul(.8469)),u=ye(-.6014).add(t.mul(.5538)).sub(r.mul(.467)).sub(s.mul(.1255));return o.mul(n).add(u).exp().saturate()}),yd=ve(.04),Og=ye(1);class S3 extends o0{constructor(e=!1,t=!1,n=!1,r=!1,s=!1,o=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=s,this.dispersion=o,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=ve().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=ve().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=ve().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=ve().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=ve().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=tn.dot(On).clamp(),n=mC({outsideIOR:ye(1),eta2:$b,cosTheta1:t,thinFilmThickness:qb,baseF0:Pu}),r=mC({outsideIOR:ye(1),eta2:$b,cosTheta1:t,thinFilmThickness:qb,baseF0:yn.rgb});this.iridescenceFresnel=Sn(n,r,pl),this.iridescenceF0Dielectric=rC({f:n,f90:1,dotVH:t}),this.iridescenceF0Metallic=rC({f:r,f90:1,dotVH:t}),this.iridescenceF0=Sn(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,pl)}if(this.transmission===!0){const t=Vh,n=A9.sub(Vh).normalize(),r=lf,s=e.context;s.backdrop=ZW(r,n,uo,Qc,eh,th,t,Bu,Mo,Wd,l_,hD,dD,fD,this.dispersion?pD:null),s.backdropAlpha=Kb,yn.a.mulAssign(Sn(1,s.backdrop.a,Kb))}super.start(e)}computeMultiscattering(e,t,n,r,s=null){const o=tn.dot(On).clamp(),u=C_({roughness:uo,dotNV:o}),c=s?xT.mix(r,s):r,h=c.mul(u.x).add(n.mul(u.y)),p=u.x.add(u.y).oneMinus(),g=c.add(c.oneMinus().mul(.047619)),_=h.mul(g).div(p.mul(g).oneMinus());e.addAssign(h),t.addAssign(_.mul(p))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=tn.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(s.mul(WW({lightDirection:e})));const o=vd({normal:tn,viewDir:On,roughness:cu}),u=vd({normal:tn,viewDir:e,roughness:cu}),c=ms.r.max(ms.g).max(ms.b).mul(o.max(u)).oneMinus();s.mulAssign(c)}if(this.clearcoat===!0){const u=du.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(u.mul(v3({lightDirection:e,f0:yd,f90:Og,roughness:Vd,normalView:du})))}n.directDiffuse.addAssign(s.mul(Hh({diffuseColor:Qc}))),n.directSpecular.addAssign(s.mul(VW({lightDirection:e,f0:eh,f90:1,roughness:uo,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:s,ltc_1:o,ltc_2:u}){const c=t.add(n).sub(r),h=t.sub(n).sub(r),d=t.sub(n).add(r),p=t.add(n).add(r),g=tn,_=On,v=li.toVar(),S=sC({N:g,V:_,roughness:uo}),b=o.sample(S).toVar(),x=u.sample(S).toVar(),M=qi(ve(b.x,0,b.y),ve(0,1,0),ve(b.z,0,b.w)).toVar(),E=eh.mul(x.x).add(th.sub(eh).mul(x.y)).toVar();if(s.directSpecular.addAssign(e.mul(E).mul(Bx({N:g,V:_,P:v,mInv:M,p0:c,p1:h,p2:d,p3:p}))),s.directDiffuse.addAssign(e.mul(Qc).mul(Bx({N:g,V:_,P:v,mInv:qi(1,0,0,0,1,0,0,0,1),p0:c,p1:h,p2:d,p3:p}))),this.clearcoat===!0){const w=du,D=sC({N:w,V:_,roughness:Vd}),C=o.sample(D),N=u.sample(D),A=qi(ve(C.x,0,C.y),ve(0,1,0),ve(C.z,0,C.w)),L=yd.mul(N.x).add(Og.sub(yd).mul(N.y));this.clearcoatSpecularDirect.addAssign(e.mul(L).mul(Bx({N:w,V:_,P:v,mInv:A,p0:c,p1:h,p2:d,p3:p})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:n}=e.context,r=t.mul(Hh({diffuseColor:Qc})).toVar();if(this.sheen===!0){const s=vd({normal:tn,viewDir:On,roughness:cu}),o=ms.r.max(ms.g).max(ms.b).mul(s).oneMinus();r.mulAssign(o)}n.indirectDiffuse.addAssign(r)}indirectSpecular(e){const{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(ms,vd({normal:tn,viewDir:On,roughness:cu}))),this.clearcoat===!0){const b=du.dot(On).clamp(),x=y3({dotNV:b,specularColor:yd,specularF90:Og,roughness:Vd});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(x))}const s=ve().toVar("singleScatteringDielectric"),o=ve().toVar("multiScatteringDielectric"),u=ve().toVar("singleScatteringMetallic"),c=ve().toVar("multiScatteringMetallic");this.computeMultiscattering(s,o,th,Pu,this.iridescenceF0Dielectric),this.computeMultiscattering(u,c,th,yn.rgb,this.iridescenceF0Metallic);const h=Sn(s,u,pl),d=Sn(o,c,pl),p=s.add(o),g=Qc.mul(p.oneMinus()),_=n.mul(1/Math.PI),v=t.mul(h).add(d.mul(_)).toVar(),S=g.mul(_).toVar();if(this.sheen===!0){const b=vd({normal:tn,viewDir:On,roughness:cu}),x=ms.r.max(ms.g).max(ms.b).mul(b).oneMinus();v.mulAssign(x),S.mulAssign(x)}r.indirectSpecular.addAssign(v),r.indirectDiffuse.addAssign(S)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:n}=e.context,s=tn.dot(On).clamp().add(t),o=uo.mul(-16).oneMinus().negate().exp2(),u=t.sub(s.pow(o).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(u)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=du.dot(On).clamp(),r=gp({dotVH:n,f0:yd,f90:Og}),s=t.mul(Wb.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Wb));t.assign(s)}if(this.sheen===!0){const n=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(n)}}}const gC=ye(1),nS=ye(-2),Bg=ye(.8),Fx=ye(-1),Fg=ye(.4),Ix=ye(2),Ig=ye(.305),zx=ye(3),_C=ye(.21),t$=ye(4),vC=ye(4),n$=ye(16),i$=Se(([i])=>{const e=ve(ts(i)).toVar(),t=ye(-1).toVar();return wn(e.x.greaterThan(e.z),()=>{wn(e.x.greaterThan(e.y),()=>{t.assign(ns(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(ns(i.y.greaterThan(0),1,4))})}).Else(()=>{wn(e.z.greaterThan(e.y),()=>{t.assign(ns(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(ns(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),r$=Se(([i,e])=>{const t=rt().toVar();return wn(e.equal(0),()=>{t.assign(rt(i.z,i.y).div(ts(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(rt(i.x.negate(),i.z.negate()).div(ts(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(rt(i.x.negate(),i.y).div(ts(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(rt(i.z.negate(),i.y).div(ts(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(rt(i.x.negate(),i.z).div(ts(i.y)))}).Else(()=>{t.assign(rt(i.x,i.y).div(ts(i.z)))}),Ft(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),s$=Se(([i])=>{const e=ye(0).toVar();return wn(i.greaterThanEqual(Bg),()=>{e.assign(gC.sub(i).mul(Fx.sub(nS)).div(gC.sub(Bg)).add(nS))}).ElseIf(i.greaterThanEqual(Fg),()=>{e.assign(Bg.sub(i).mul(Ix.sub(Fx)).div(Bg.sub(Fg)).add(Fx))}).ElseIf(i.greaterThanEqual(Ig),()=>{e.assign(Fg.sub(i).mul(zx.sub(Ix)).div(Fg.sub(Ig)).add(Ix))}).ElseIf(i.greaterThanEqual(_C),()=>{e.assign(Ig.sub(i).mul(t$.sub(zx)).div(Ig.sub(_C)).add(zx))}).Else(()=>{e.assign(ye(-2).mul(yo(Ft(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),a$=Se(([i,e])=>{const t=i.toVar();t.assign(Ft(2,t).sub(1));const n=ve(t,1).toVar();return wn(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),o$=Se(([i,e,t,n,r,s])=>{const o=ye(t),u=ve(e),c=Ml(s$(o),nS,s),h=Ta(c),d=xu(c),p=ve(_p(i,u,d,n,r,s)).toVar();return wn(h.notEqual(0),()=>{const g=ve(_p(i,u,d.add(1),n,r,s)).toVar();p.assign(Sn(p,g,h))}),p}),_p=Se(([i,e,t,n,r,s])=>{const o=ye(t).toVar(),u=ve(e),c=ye(i$(u)).toVar(),h=ye(Xi(vC.sub(o),0)).toVar();o.assign(Xi(o,vC));const d=ye(dp(o)).toVar(),p=rt(r$(u,c).mul(d.sub(2)).add(1)).toVar();return wn(c.greaterThan(2),()=>{p.y.addAssign(d),c.subAssign(3)}),p.x.addAssign(c.mul(d)),p.x.addAssign(h.mul(Ft(3,n$))),p.y.addAssign(Ft(4,dp(s).sub(d))),p.x.mulAssign(n),p.y.mulAssign(r),i.sample(p).grad(rt(),rt())}),kx=Se(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:u})=>{const c=ua(n),h=t.mul(c).add(r.cross(t).mul(es(n))).add(r.mul(r.dot(t).mul(c.oneMinus())));return _p(i,h,e,s,o,u)}),l$=Se(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:r,samples:s,dTheta:o,mipInt:u,envMap:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p})=>{const g=ve(ns(e,t,Ou(t,n))).toVar();wn(g.equal(ve(0)),()=>{g.assign(ve(n.z,0,n.x.negate()))}),g.assign(ya(g));const _=ve().toVar();return _.addAssign(r.element(0).mul(kx({theta:0,axis:g,outputDirection:n,mipInt:u,envMap:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p}))),vs({start:kn(1),end:i},({i:v})=>{wn(v.greaterThanEqual(s),()=>{Yj()});const S=ye(o.mul(ye(v))).toVar();_.addAssign(r.element(v).mul(kx({theta:S.mul(-1),axis:g,outputDirection:n,mipInt:u,envMap:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p}))),_.addAssign(r.element(v).mul(kx({theta:S,axis:g,outputDirection:n,mipInt:u,envMap:c,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p})))}),wt(_,1)}),u$=Se(([i])=>{const e=$t(i).toVar();return e.assign(e.shiftLeft($t(16)).bitOr(e.shiftRight($t(16)))),e.assign(e.bitAnd($t(1431655765)).shiftLeft($t(1)).bitOr(e.bitAnd($t(2863311530)).shiftRight($t(1)))),e.assign(e.bitAnd($t(858993459)).shiftLeft($t(2)).bitOr(e.bitAnd($t(3435973836)).shiftRight($t(2)))),e.assign(e.bitAnd($t(252645135)).shiftLeft($t(4)).bitOr(e.bitAnd($t(4042322160)).shiftRight($t(4)))),e.assign(e.bitAnd($t(16711935)).shiftLeft($t(8)).bitOr(e.bitAnd($t(4278255360)).shiftRight($t(8)))),ye(e).mul(23283064365386963e-26)}),c$=Se(([i,e])=>rt(ye(i).div(ye(e)),u$(i))),h$=Se(([i,e,t])=>{const n=t.mul(t).toConst(),r=ve(1,0,0).toConst(),s=Ou(e,r).toConst(),o=Sl(i.x).toConst(),u=Ft(2,3.14159265359).mul(i.y).toConst(),c=o.mul(ua(u)).toConst(),h=o.mul(es(u)).toVar(),d=Ft(.5,e.z.add(1)).toConst();h.assign(d.oneMinus().mul(Sl(c.mul(c).oneMinus())).add(d.mul(h)));const p=r.mul(c).add(s.mul(h)).add(e.mul(Sl(Xi(0,c.mul(c).add(h.mul(h)).oneMinus()))));return ya(ve(n.mul(p.x),n.mul(p.y),Xi(0,p.z)))}),f$=Se(({roughness:i,mipInt:e,envMap:t,N_immutable:n,GGX_SAMPLES:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:u})=>{const c=ve(n).toVar(),h=ve(0).toVar(),d=ye(0).toVar();return wn(i.lessThan(.001),()=>{h.assign(_p(t,c,e,s,o,u))}).Else(()=>{const p=ns(ts(c.z).lessThan(.999),ve(0,0,1),ve(1,0,0)),g=ya(Ou(p,c)).toVar(),_=Ou(c,g).toVar();vs({start:$t(0),end:r},({i:v})=>{const S=c$(v,r),b=h$(S,ve(0,0,1),i),x=ya(g.mul(b.x).add(_.mul(b.y)).add(c.mul(b.z))),M=ya(x.mul(Uu(c,x).mul(2)).sub(c)),E=Xi(Uu(c,M),0);wn(E.greaterThan(0),()=>{const w=_p(t,M,e,s,o,u);h.addAssign(w.mul(E)),d.addAssign(E)})}),wn(d.greaterThan(0),()=>{h.assign(h.div(d))})}),wt(h,1)}),ml=4,yC=[.125,.215,.35,.446,.526,.582],pu=20,d$=512,xd=new Zh(-1,1,1,-1,0,1),p$=new Pi(90,1),xC=new pt;let Gx=null,Vx=0,Hx=0;const m$=new G,N_=new WeakMap,g$=[3,1,5,0,4,2],jx=a$(rf(),El("faceIndex")).normalize(),u0=ve(jx.x,jx.y,jx.z);class _${constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,s={}){const{size:o=256,position:u=m$,renderTarget:c=null}=s;if(this._setSize(o),this._hasInitialized===!1){Ne('PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.');const d=c||this._allocateTarget();return s.renderTarget=d,this.fromSceneAsync(e,t,n,r,s),d}Gx=this._renderer.getRenderTarget(),Vx=this._renderer.getActiveCubeFace(),Hx=this._renderer.getActiveMipmapLevel();const h=c||this._allocateTarget();return h.depthBuffer=!0,this._init(h),this._sceneToCubeUV(e,n,r,h,u),t>0&&this._blur(h,0,0,t),this._applyPMREM(h),this._cleanup(h),h}async fromSceneAsync(e,t=0,n=.1,r=100,s={}){return xn('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,n,r,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){Ne('PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" instead.'),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return xn('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){Ne("PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return xn('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=SC(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=TC(),await 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())}_setSizeFromTexture(e){e.mapping===js||e.mapping===xa?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_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(Gx,Vx,Hx),e.scissorTest=!1,Wc(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),Gx=this._renderer.getRenderTarget(),Vx=this._renderer.getActiveCubeFace(),Hx=this._renderer.getActiveMipmapLevel();const n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize;return bC(e,t)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=bC(e.width,e.height);const{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=v$(t)),this._blurMaterial=y$(t,e.width,e.height),this._ggxMaterial=x$(t,e.width,e.height)}}async _compileMaterial(e){const t=new xi(new Fi,e);await this._renderer.compile(t,xd)}_sceneToCubeUV(e,t,n,r,s){const o=p$;o.near=t,o.far=n;const u=[1,1,1,1,-1,1],c=[1,-1,1,-1,1,-1],h=this._renderer,d=h.autoClear;h.getClearColor(xC),h.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new xi(new zu,new ca({name:"PMREM.Background",side:Tn,depthWrite:!1,depthTest:!1})));const p=this._backgroundBox,g=p.material;let _=!1;const v=e.background;v?v.isColor&&(g.color.copy(v),e.background=null,_=!0):(g.color.copy(xC),_=!0),h.setRenderTarget(r),h.clear(),_&&h.render(p,o);for(let S=0;S<6;S++){const b=S%3;b===0?(o.up.set(0,u[S],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x+c[S],s.y,s.z)):b===1?(o.up.set(0,0,u[S]),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y+c[S],s.z)):(o.up.set(0,u[S],0),o.position.set(s.x,s.y,s.z),o.lookAt(s.x,s.y,s.z+c[S]));const x=this._cubeSize;Wc(r,b*x,S>2?x:0,x,x),h.render(e,o)}h.autoClear=d,e.background=v}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===js||e.mapping===xa;r?this._cubemapMaterial===null&&(this._cubemapMaterial=SC(e)):this._equirectMaterial===null&&(this._equirectMaterial=TC(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const o=this._lodMeshes[0];o.material=s;const u=this._cubeSize;Wc(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(o,xd)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,s=this._pingPongRenderTarget,o=this._ggxMaterial,u=this._lodMeshes[n];u.material=o;const c=N_.get(o),h=n/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),p=Math.sqrt(h*h-d*d),g=0+h*1.25,_=p*g,{_lodMax:v}=this,S=this._sizeLods[n],b=3*S*(n>v-ml?n-v+ml:0),x=4*(this._cubeSize-S);e.texture.frame=(e.texture.frame||0)+1,c.envMap.value=e.texture,c.roughness.value=_,c.mipInt.value=v-t,Wc(s,b,x,3*S,2*S),r.setRenderTarget(s),r.render(u,xd),s.texture.frame=(s.texture.frame||0)+1,c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=v-n,Wc(e,b,x,3*S,2*S),r.setRenderTarget(e),r.render(u,xd)}_blur(e,t,n,r,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",s),this._halfBlur(o,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,o,u){const c=this._renderer,h=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Pe("blur direction must be either latitudinal or longitudinal!");const d=3,p=this._lodMeshes[r];p.material=h;const g=N_.get(h),_=this._sizeLods[n]-1,v=isFinite(s)?Math.PI/(2*_):2*Math.PI/(2*pu-1),S=s/v,b=isFinite(s)?1+Math.floor(d*S):pu;b>pu&&Ne(`sigmaRadians, ${s}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${pu}`);const x=[];let M=0;for(let N=0;N<pu;++N){const A=N/S,L=Math.exp(-A*A/2);x.push(L),N===0?M+=L:N<b&&(M+=2*L)}for(let N=0;N<x.length;N++)x[N]=x[N]/M;e.texture.frame=(e.texture.frame||0)+1,g.envMap.value=e.texture,g.samples.value=b,g.weights.array=x,g.latitudinal.value=o==="latitudinal"?1:0,u&&(g.poleAxis.value=u);const{_lodMax:E}=this;g.dTheta.value=v,g.mipInt.value=E-n;const w=this._sizeLods[r],D=3*w*(r>E-ml?r-E+ml:0),C=4*(this._cubeSize-w);Wc(t,D,C,3*w,2*w),c.setRenderTarget(t),c.render(p,xd)}}function v$(i){const e=[],t=[],n=[];let r=i;const s=i-ml+1+yC.length;for(let o=0;o<s;o++){const u=Math.pow(2,r);e.push(u);let c=1/u;o>i-ml?c=yC[o-i+ml-1]:o===0&&(c=0),t.push(c);const h=1/(u-2),d=-h,p=1+h,g=[d,d,p,d,p,p,d,d,p,p,d,p],_=6,v=6,S=3,b=2,x=1,M=new Float32Array(S*v*_),E=new Float32Array(b*v*_),w=new Float32Array(x*v*_);for(let C=0;C<_;C++){const N=C%3*2/3-1,A=C>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],j=g$[C];M.set(L,S*v*j),E.set(g,b*v*j);const z=[j,j,j,j,j,j];w.set(z,x*v*j)}const D=new Fi;D.setAttribute("position",new $i(M,S)),D.setAttribute("uv",new $i(E,b)),D.setAttribute("faceIndex",new $i(w,x)),n.push(new xi(D,null)),r>ml&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function bC(i,e){const t={magFilter:Rn,minFilter:Rn,generateMipmaps:!1,type:Qn,format:si,colorSpace:Cu},n=new Rl(i,e,t);return n.texture.mapping=Mu,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function Wc(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function c0(i){const e=new ui;return e.depthTest=!1,e.depthWrite=!1,e.blending=Bi,e.name=`PMREM_${i}`,e}function y$(i,e,t){const n=_s(new Array(pu).fill(0)),r=yt(new G(0,1,0)),s=yt(0),o=ye(pu),u=yt(0),c=yt(1),h=Fn(),d=yt(0),p=ye(1/e),g=ye(1/t),_=ye(i),v={n:o,latitudinal:u,weights:n,poleAxis:r,outputDirection:u0,dTheta:s,samples:c,envMap:h,mipInt:d,CUBEUV_TEXEL_WIDTH:p,CUBEUV_TEXEL_HEIGHT:g,CUBEUV_MAX_MIP:_},S=c0("blur");return S.fragmentNode=l$({...v,latitudinal:u.equal(1)}),N_.set(S,v),S}function x$(i,e,t){const n=Fn(),r=yt(0),s=yt(0),o=ye(1/e),u=ye(1/t),c=ye(i),h={envMap:n,roughness:r,mipInt:s,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c},d=c0("ggx");return d.fragmentNode=f$({...h,N_immutable:u0,GGX_SAMPLES:$t(d$)}),N_.set(d,h),d}function SC(i){const e=c0("cubemap");return e.fragmentNode=Lr(i,u0),e}function TC(i){const e=c0("equirect");return e.fragmentNode=Fn(i,h3(u0),0),e}const MC=new WeakMap;function b$(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function S$(i,e,t){const n=T$(e);let r=n.get(i);if((r!==void 0?r.pmremVersion:-1)!==i.pmremVersion){const o=i.image;if(i.isCubeTexture)if(E$(o))r=t.fromCubemap(i,r);else return null;else if(A$(o))r=t.fromEquirectangular(i,r);else return null;r.pmremVersion=i.pmremVersion,n.set(i,r)}return r.texture}function T$(i){let e=MC.get(i);return e===void 0&&(e=new WeakMap,MC.set(i,e)),e}class M$ extends bi{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new vi;r.isRenderTargetTexture=!0,this._texture=Fn(r),this._width=yt(0),this._height=yt(0),this._maxMip=yt(0),this.updateBeforeType=Dt.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=b$(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(r.isPMREMTexture===!0?t=r:t=S$(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new _$(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=$D.mul(ve(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),o$(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function E$(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n<t;n++)i[n]!==void 0&&e++;return e===t}function A$(i){return i==null?!1:i.height>0}const T3=fn(M$).setParameterLength(1,3),EC=new WeakMap;class w$ extends uf{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const p=n.isTextureNode?n.value:t[n.property],g=this._getPMREMNodeCache(e.renderer);let _=g.get(p);_===void 0&&(_=T3(p),g.set(p,_)),n=_}const s=t.useAnisotropy===!0||t.anisotropy>0?Z9:tn,o=n.context(AC(uo,s)).mul(Px),u=n.context(R$(lf)).mul(Math.PI).mul(Px),c=jd(o),h=jd(u);e.context.radiance.addAssign(c),e.context.iblIrradiance.addAssign(h);const d=e.context.lightingModel.clearcoatRadiance;if(d){const p=n.context(AC(Vd,du)).mul(Px),g=jd(p);d.addAssign(g)}}_getPMREMNodeCache(e){let t=EC.get(e);return t===void 0&&(t=new WeakMap,EC.set(e,t)),t}}const AC=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=On.negate().reflect(e),t=wD(i).mix(t,e).normalize(),t=t.transformDirection(Mo)),t),getTextureLevel:()=>i}},R$=i=>({getUV:()=>i,getTextureLevel:()=>ye(1)}),C$=new i2;class M3 extends ui{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(C$),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new w$(t):null}setupLightingModel(){return new S3}setupSpecular(){const e=Sn(ve(.04),yn.rgb,pl);Pu.assign(ve(.04)),eh.assign(e),th.assign(1)}setupVariants(){const e=this.metalnessNode?ye(this.metalnessNode):hj;pl.assign(e);let t=this.roughnessNode?ye(this.roughnessNode):cj;t=_3({roughness:t}),uo.assign(t),this.setupSpecular(),Qc.assign(yn.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const N$=new JB;class D$ extends M3{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(N$),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?ye(this.iorNode):Ej;l_.assign(e),Pu.assign(Gh(AD(l_.sub(1).div(l_.add(1))).mul(uj),ve(1)).mul(ZR)),eh.assign(Sn(Pu,yn.rgb,pl)),th.assign(Sn(ZR,1,pl))}setupLightingModel(){return new S3(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?ye(this.clearcoatNode):dj,n=this.clearcoatRoughnessNode?ye(this.clearcoatRoughnessNode):pj;Wb.assign(t),Vd.assign(_3({roughness:n}))}if(this.useSheen){const t=this.sheenNode?ve(this.sheenNode):_j,n=this.sheenRoughnessNode?ye(this.sheenRoughnessNode):vj;ms.assign(t),cu.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?ye(this.iridescenceNode):xj,n=this.iridescenceIORNode?ye(this.iridescenceIORNode):bj,r=this.iridescenceThicknessNode?ye(this.iridescenceThicknessNode):Sj;xT.assign(t),$b.assign(n),qb.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?rt(this.anisotropyNode):yj).toVar();ou.assign(t.length()),wn(ou.equal(0),()=>{t.assign(rt(1,0))}).Else(()=>{t.divAssign(rt(ou)),ou.assign(ou.saturate())}),Xb.assign(ou.pow2().mix(uo.pow2(),1)),o_.assign(Ld[0].mul(t.x).add(Ld[1].mul(t.y))),uh.assign(Ld[1].mul(t.x).sub(Ld[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?ye(this.transmissionNode):Tj,n=this.thicknessNode?ye(this.thicknessNode):Mj,r=this.attenuationDistanceNode?ye(this.attenuationDistanceNode):Aj,s=this.attenuationColorNode?ve(this.attenuationColorNode):wj;if(Kb.assign(t),hD.assign(n),fD.assign(r),dD.assign(s),this.useDispersion){const o=this.dispersionNode?ye(this.dispersionNode):Pj;pD.assign(o)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?ve(this.clearcoatNormalNode):mj}setup(e){e.context.setupClearcoatNormal=()=>ch(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.iorNode=e.iorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const L$=Se(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=rt(n.mul(.5).add(.5),0);if(t.material.gradientMap){const s=ll("gradientMap","texture").context({getUV:()=>r});return ve(s.r)}else{const s=r.fwidth().mul(.5);return Sn(ve(.7),ve(1),So(ye(.7).sub(s.x),ye(.7).add(s.x),r.x))}});class P$ extends o0{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){const s=L$({normal:jD,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(s.mul(Hh({diffuseColor:yn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(Hh({diffuseColor:yn}))),r.indirectDiffuse.mulAssign(t)}}const U$=new tF;class O$ extends ui{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(U$),this.setValues(e)}setupLightingModel(){return new P$}}const B$=Se(()=>{const i=ve(On.z,0,On.x.negate()).normalize(),e=On.cross(i);return rt(i.dot(tn),e.dot(tn)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),F$=new sF;class I$ extends ui{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(F$),this.setValues(e)}setupVariants(e){const t=B$;let n;e.material.matcap?n=ll("matcap","texture").context({getUV:()=>t}):n=ve(Sn(.2,.8,t.y)),yn.rgb.mulAssign(n.rgb)}}class z$ extends bi{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const s=t.cos(),o=t.sin();return yT(s,o,o.negate(),s).mul(n)}else{const s=t,o=yu(wt(1,0,0,0),wt(0,ua(s.x),es(s.x).negate(),0),wt(0,es(s.x),ua(s.x),0),wt(0,0,0,1)),u=yu(wt(ua(s.y),0,es(s.y),0),wt(0,1,0,0),wt(es(s.y).negate(),0,ua(s.y),0),wt(0,0,0,1)),c=yu(wt(ua(s.z),es(s.z).negate(),0,0),wt(es(s.z),ua(s.z),0,0),wt(0,0,1,0),wt(0,0,0,1));return o.mul(u).mul(c).mul(wt(n,1)).xyz}}}const E3=fn(z$).setParameterLength(2),k$=new EB;class A3 extends ui{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(k$),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,{positionNode:r,rotationNode:s,scaleNode:o,sizeAttenuation:u}=this,c=Cp.mul(ve(r||0));let h=rt(Bu[0].xyz.length(),Bu[1].xyz.length());o!==null&&(h=h.mul(rt(o))),n.isPerspectiveCamera&&u===!1&&(h=h.mul(c.z.negate()));let d=a0.xy;if(t.center&&t.center.isVector2===!0){const _=X8("center","vec2",t);d=d.sub(_.sub(.5))}d=d.mul(h);const p=ye(s||gj),g=E3(d,p);return wt(c.xy.add(g),c.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const G$=new LB,V$=new Ie;class H$ extends A3{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(G$),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Cp.mul(ve(e||Oi)).xyz}setupVertexSprite(e){const{material:t,camera:n}=e,{rotationNode:r,scaleNode:s,sizeNode:o,sizeAttenuation:u}=this;let c=super.setupVertex(e);if(t.isNodeMaterial!==!0)return c;let h=o!==null?rt(o):Lj;h=h.mul(T9),n.isPerspectiveCamera&&u===!0&&(h=h.mul(j$.div(li.z.negate()))),s&&s.isNode&&(h=h.mul(rt(s)));let d=a0.xy;if(r&&r.isNode){const p=ye(r);d=E3(d,p)}return d=d.mul(h),d=d.div(M9.div(2)),d=d.mul(c.w),c=c.add(wt(d,0,0)),c}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const j$=yt(1).onFrameUpdate(function({renderer:i}){const e=i.getSize(V$);this.value=.5*e.y});class W$ extends o0{constructor(){super(),this.shadowNode=ye(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){yn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(yn.rgb)}}const $$=new XB;class q$ extends ui{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues($$),this.setValues(e)}setupLightingModel(){return new W$}}bl("vec3");bl("vec3");bl("vec3");class X${constructor(e,t,n){this.renderer=e,this.nodes=t,this.info=n,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,n),this.renderer._inspector.finish()};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class Al{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let n=this.weakMaps[t];return n===void 0&&(n=new WeakMap,this.weakMaps[t]=n),n}get(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this._getWeakMap(e);for(let r=0;r<e.length-1;r++){const s=e[r];n.has(s)===!1&&n.set(s,new WeakMap),n=n.get(s)}return n.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}}let Y$=0;function K$(i){const e=Object.keys(i);let t=Object.getPrototypeOf(i);for(;t;){const n=Object.getOwnPropertyDescriptors(t);for(const r in n)if(n[r]!==void 0){const s=n[r];s&&typeof s.get=="function"&&e.push(r)}t=Object.getPrototypeOf(t)}return e}class Z${constructor(e,t,n,r,s,o,u,c,h,d){this.id=Y$++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=r,this.material=s,this.scene=o,this.camera=u,this.lightsNode=c,this.context=h,this.geometry=r.geometry,this.version=s.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=d,this.clippingContextCacheKey=d!==null?d.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set,s={};for(const o of e){let u;if(o.node&&o.node.attribute?u=o.node.attribute:(u=t.getAttribute(o.name),s[o.name]=u.id),u===void 0)continue;n.push(u);const c=u.isInterleavedBufferAttribute?u.data:u;r.add(c)}return this.attributes=n,this.attributesId=s,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:s}=this,o=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),u=this.getIndex(),c=u!==null;let h=1;if(n.isInstancedBufferGeometry===!0?h=n.instanceCount:e.count!==void 0&&(h=Math.max(0,e.count)),h===0)return null;if(o.instanceCount=h,e.isBatchedMesh===!0)return o;let d=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(d=2);let p=s.start*d,g=(s.start+s.count)*d;r!==null&&(p=Math.max(p,r.start*d),g=Math.min(g,(r.start+r.count)*d));const _=n.attributes.position;let v=1/0;c?v=u.count:_!=null&&(v=_.count),p=Math.max(p,0),g=Math.min(g,v);const S=g-p;return S<0||S===1/0?null:(o.vertexCount=S,o.firstVertex=p,o)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}for(const n of Object.keys(e.morphAttributes).sort()){const r=e.morphAttributes[n];t+="morph-"+n+",";for(let s=0,o=r.length;s<o;s++){const u=r[s];t+=u.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t,renderer:n}=this;let r=t.customProgramCacheKey();for(const s of K$(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(s))continue;const o=t[s];let u;if(o!==null){const c=typeof o;c==="number"?u=o!==0?"1":"0":c==="object"?(u="{",o.isTexture&&(u+=o.mapping,n.backend.isWebGPUBackend===!0&&(u+=o.magFilter,u+=o.minFilter,u+=o.wrapS,u+=o.wrapT,u+=o.wrapR)),u+="}"):u=String(o)}else u=String(o);r+=u+","}return r+=this.clippingContextCacheKey+",",e.geometry&&(r+=this.getGeometryCacheKey()),e.skeleton&&(r+=e.skeleton.bones.length+","),e.isBatchedMesh&&(r+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(r+=e._colorsTexture.uuid+",")),(e.isInstancedMesh||e.count>1||Array.isArray(e.morphTargetInfluences))&&(r+=e.uuid+","),r+=this.context.id+",",r+=e.receiveShadow+",",ef(r)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){const e=this.attributesId;for(const t in e){const n=this.geometry.getAttribute(t);if(n===void 0||e[t]!==n.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=kd(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=kd(e,1)),e=kd(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const ra=[];class Q${constructor(e,t,n,r,s,o){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=s,this.info=o,this.chainMaps={}}get(e,t,n,r,s,o,u,c){const h=this.getChainMap(c);ra[0]=e,ra[1]=t,ra[2]=o,ra[3]=s;let d=h.get(ra);return d===void 0?(d=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,s,o,u,c),h.set(ra,d)):(d.camera=r,d.updateClipping(u),d.needsGeometryUpdate&&d.setGeometry(e.geometry),(d.version!==t.version||d.needsUpdate)&&(d.initialCacheKey!==d.getCacheKey()?(d.dispose(),d=this.get(e,t,n,r,s,o,u,c)):d.version=t.version)),ra[0]=null,ra[1]=null,ra[2]=null,ra[3]=null,d}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Al)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,s,o,u,c,h,d,p){const g=this.getChainMap(p),_=new Z$(e,t,n,r,s,o,u,c,h,d);return _.onDispose=()=>{this.pipelines.delete(_),this.bindings.deleteForRender(_),this.nodes.delete(_),g.delete(_.getChainArray())},_}}class Cl{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const xs={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},ul=16,J$=211,eq=212;class tq extends Cl{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===xs.VERTEX?this.backend.createAttribute(e):t===xs.INDEX?this.backend.createIndexAttribute(e):t===xs.STORAGE?this.backend.createStorageAttribute(e):t===xs.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version<r.version||r.usage===p_)&&(this.backend.updateAttribute(e),n.version=r.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function w3(i){return i.index!==null?i.index.version:i.attributes.position.version}function R3(i){return i.index!==null?i.index.id:i.attributes.position.id}function wC(i){const e=[],t=i.index,n=i.attributes.position;if(t!==null){const s=t.array;for(let o=0,u=s.length;o<u;o+=3){const c=s[o+0],h=s[o+1],d=s[o+2];e.push(c,h,h,d,d,c)}}else{const s=n.array;for(let o=0,u=s.length/3-1;o<u;o+=3){const c=o+0,h=o+1,d=o+2;e.push(c,h,h,d,d,c)}}const r=new(n.count>=65535?KS:YS)(e,1);return r.version=w3(i),r.__id=R3(i),r}class nq extends Cl{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const s=t.index,o=e.getAttributes();s!==null&&this.attributes.delete(s);for(const c of o)this.attributes.delete(c);const u=this.wireframes.get(t);u!==void 0&&this.attributes.delete(u),t.removeEventListener("dispose",r),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){const t=e.getAttributes();for(const s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,xs.STORAGE):this.updateAttribute(s,xs.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,xs.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,xs.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const s=this.wireframes;let o=s.get(t);o===void 0?(o=wC(t),s.set(t,o)):(o.version!==w3(t)||o.__id!==R3(t))&&(this.attributes.delete(o),o=wC(t),s.set(t,o)),r=o}return r}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class iq{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):Pe("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class C3{constructor(e){this.cacheKey=e,this.usedTimes=0}}class rq extends C3{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class sq extends C3{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let aq=0;class Wx{constructor(e,t,n,r=null,s=null){this.id=aq++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=s,this.usedTimes=0}}class oq extends Cl{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);const o=this.nodes.getForCompute(e);let u=this.programs.compute.get(o.computeShader);u===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),u=new Wx(o.computeShader,"compute",e.name,o.transforms,o.nodeAttributes),this.programs.compute.set(o.computeShader,u),n.createProgram(u));const c=this._getComputeCacheKey(e,u);let h=this.caches.get(c);h===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),h=this._getComputePipeline(e,u,c,t)),h.usedTimes++,u.usedTimes++,r.version=e.version,r.pipeline=h}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);const o=e.getNodeBuilderState(),u=e.material?e.material.name:"";let c=this.programs.vertex.get(o.vertexShader);c===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),c=new Wx(o.vertexShader,"vertex",u),this.programs.vertex.set(o.vertexShader,c),n.createProgram(c));let h=this.programs.fragment.get(o.fragmentShader);h===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),h=new Wx(o.fragmentShader,"fragment",u),this.programs.fragment.set(o.fragmentShader,h),n.createProgram(h));const d=this._getRenderCacheKey(e,c,h);let p=this.caches.get(d);p===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),p=this._getRenderPipeline(e,c,h,d,t)):e.pipeline=p,p.usedTimes++,c.usedTimes++,h.usedTimes++,r.pipeline=p}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n=n||this._getComputeCacheKey(e,t);let s=this.caches.get(n);return s===void 0&&(s=new sq(n,t),this.caches.set(n,s),this.backend.createComputePipeline(s,r)),s}_getRenderPipeline(e,t,n,r,s){r=r||this._getRenderCacheKey(e,t,n);let o=this.caches.get(r);return o===void 0&&(o=new rq(r,t,n),this.caches.set(r,o),e.pipeline=o,this.backend.createRenderPipeline(e,s)),o}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class lq extends Cl{constructor(e,t,n,r,s,o){super(),this.backend=e,this.textures=n,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=o,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t)this.backend.deleteBindGroupData(n),this.delete(n)}deleteForRender(e){const t=e.getBindings();for(const n of t)this.backend.deleteBindGroupData(n),this.delete(n)}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isSampler)this.textures.updateSampler(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?xs.INDIRECT:xs.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,s=!0,o=0,u=0;for(const c of e.bindings)if(this.nodes.updateGroup(c)!==!1){if(c.isStorageBuffer){const d=c.attribute,p=d.isIndirectStorageBufferAttribute?xs.INDIRECT:xs.STORAGE,g=n.get(c);this.attributes.update(d,p),g.attribute!==d&&(g.attribute=d,r=!0)}if(c.isUniformBuffer)c.update()&&n.updateBinding(c);else if(c.isSampledTexture){const d=c.update(),p=c.texture,g=this.textures.get(p);if(d&&(this.textures.updateTexture(p),c.generation!==g.generation&&(c.generation=g.generation,r=!0),g.bindGroups.add(e)),n.get(p).externalTexture!==void 0||g.isDefaultTexture?s=!1:(o=o*10+p.id,u+=p.version),p.isStorageTexture===!0&&p.mipmapsAutoUpdate===!0){const v=this.get(p);c.store===!0?v.needsMipmap=!0:this.textures.needsMipmaps(p)&&v.needsMipmap===!0&&(this.backend.generateMipmaps(p),v.needsMipmap=!1)}}else if(c.isSampler&&c.update()){const p=this.textures.updateSampler(c.texture);c.samplerKey!==p&&(c.samplerKey=p,r=!0)}c.isBuffer&&c.updateRanges.length>0&&c.clearUpdateRanges()}r===!0&&this.backend.updateBindings(e,t,s?o:0,u)}}function uq(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?i.z-e.z:i.id-e.id}function RC(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function CC(i){return(i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode)&&i.side===Ui&&i.forceSinglePass===!1}class cq{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,s,o,u){let c=this.renderItems[this.renderItemsIndex];return c===void 0?(c={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:s,group:o,clippingContext:u},this.renderItems[this.renderItemsIndex]=c):(c.id=e.id,c.object=e,c.geometry=t,c.material=n,c.groupOrder=r,c.renderOrder=e.renderOrder,c.z=s,c.group=o,c.clippingContext=u),this.renderItemsIndex++,c}push(e,t,n,r,s,o,u){const c=this.getNextRenderItem(e,t,n,r,s,o,u);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(CC(n)&&this.transparentDoublePass.push(c),this.transparent.push(c)):this.opaque.push(c)}unshift(e,t,n,r,s,o,u){const c=this.getNextRenderItem(e,t,n,r,s,o,u);n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(CC(n)&&this.transparentDoublePass.unshift(c),this.transparent.unshift(c)):this.opaque.unshift(c)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||uq),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||RC),this.transparent.length>1&&this.transparent.sort(t||RC)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){const n=this.renderItems[e];if(n.id===null)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.groupOrder=null,n.renderOrder=null,n.z=null,n.group=null,n.clippingContext=null}}}const $c=[];class hq{constructor(e){this.lighting=e,this.lists=new Al}get(e,t){const n=this.lists;$c[0]=e,$c[1]=t;let r=n.get($c);return r===void 0&&(r=new cq(this.lighting,e,t),n.set($c,r)),$c[0]=null,$c[1]=null,r}dispose(){this.lists=new Al}}let fq=0;class dq{constructor(){this.id=fq++,this.mrt=null,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new Pt,this.scissor=!1,this.scissorValue=new Pt,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.camera=null,this.isRenderContext=!0}getCacheKey(){return N3(this)}}function N3(i){const{textures:e,activeCubeFace:t,activeMipmapLevel:n}=i,r=[t,n];for(const s of e)r.push(s.id);return wp(r)}class pq{constructor(e){this.renderer=e,this._renderContexts={}}get(e=null,t=null,n=0){let r;if(e===null)r="default";else{const c=e.texture.format,h=e.texture.type;r=`${e.textures.length}:${c}:${h}:${e.samples}:${e.depthBuffer}:${e.stencilBuffer}`}const s=t!==null?t.id:"default",o=r+"-"+s+"-"+n;let u=this._renderContexts[o];return u===void 0&&(u=new dq,u.mrt=t,this._renderContexts[o]=u),e!==null&&(u.sampleCount=e.samples===0?1:e.samples),u.clearDepthValue=this.renderer.getClearDepth(),u.clearStencilValue=this.renderer.getClearStencil(),u}dispose(){this._renderContexts={}}}const mq=new G;class gq extends Cl{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n}updateRenderTarget(e,t=0){const n=this.get(e),r=e.samples===0?1:e.samples,s=n.depthTextureMips||(n.depthTextureMips={}),o=e.textures,u=this.getSize(o[0]),c=u.width>>t,h=u.height>>t;let d=e.depthTexture||s[t];const p=e.depthBuffer===!0||e.stencilBuffer===!0;let g=!1;d===void 0&&p&&(d=new br,d.format=e.stencilBuffer?_r:Wi,d.type=e.stencilBuffer?is:bn,d.image.width=c,d.image.height=h,d.image.depth=u.depth,d.renderTarget=e,d.isArrayTexture=e.multiview===!0&&u.depth>1,s[t]=d),(n.width!==u.width||u.height!==n.height)&&(g=!0,d&&(d.needsUpdate=!0,d.image.width=c,d.image.height=h,d.image.depth=d.isArrayTexture?d.image.depth:1)),n.width=u.width,n.height=u.height,n.textures=o,n.depthTexture=d||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(g=!0,d&&(d.needsUpdate=!0),n.sampleCount=r);const _={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let v=0;v<o.length;v++){const S=o[v];g&&(S.needsUpdate=!0),this.updateTexture(S,_)}d&&this.updateTexture(d,_)}n.initialized!==!0&&(n.initialized=!0,n.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener("dispose",n.onDispose))}updateTexture(e,t={}){const n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;const r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,s=this.backend;if(r&&n.initialized===!0&&s.destroyTexture(e),e.isFramebufferTexture){const h=this.renderer.getRenderTarget();h?e.type=h.texture.type:e.type=Gn}const{width:o,height:u,depth:c}=this.getSize(e);if(t.width=o,t.height=u,t.depth=c,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,o,u):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||e.isStorageTexture===!0||e.isExternalTexture===!0)s.createTexture(e,t),n.generation=e.version;else if(e.version>0){const h=e.image;if(h===void 0)Ne("Renderer: Texture marked for update but image is undefined.");else if(h.complete===!1)Ne("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const p=[];for(const g of e.images)p.push(g);t.images=p}else t.image=h;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t);const d=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!d&&s.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;n.initialized!==!0&&(n.initialized=!0,n.generation=e.version,n.bindGroups=new Set,this.info.memory.textures++,e.isVideoTexture&&xt.enabled===!0&&xt.getTransfer(e.colorSpace)!==Ye&&Ne("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),n.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",n.onDispose)),n.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=mq){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):typeof VideoFrame<"u"&&n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.mipmaps.length>0?r=e.mipmaps.length:e.isCompressedTexture===!0?r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){const t=this.get(e),n=t.textures,r=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let s=0;s<n.length;s++)this._destroyTexture(n[s]);r&&this._destroyTexture(r),this.delete(e),this.backend.delete(e)}}_destroyTexture(e){if(this.has(e)===!0){const t=this.get(e);e.removeEventListener("dispose",t.onDispose);const n=t.isDefaultTexture;if(this.backend.destroyTexture(e,n),t.bindGroups)for(const r of t.bindGroups){const s=this.backend.get(r);s.groups=void 0,s.versions=void 0}this.delete(e),this.info.memory.textures--}}}class LT extends pt{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class _q extends dn{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){const n=this.getNodeType(e),r=e.getStructTypeNode(n);let s;return r!==null?s=r.getMemberType(e,t):(Pe(`TSL: Member "${t}" not found in struct "${n}".`,new rr),s="float"),s}getHash(){return this.uuid}generate(){return this.name}}class vq extends ct{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this.isStackNode=!0}getElementType(e){return this.hasOutput(e)?this.outputNode.getElementType(e):"void"}getNodeType(e){return this.hasOutput(e)?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput(e)?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=this.nodes.length){return e.isNode!==!0?(Pe("TSL: Invalid node added to stack.",new rr),this):(this.nodes.splice(t,0,e),this)}addToStackBefore(e){const t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){const n=new Dd(t);return this._currentCond=ns(e,n),this.addToStack(this._currentCond)}ElseIf(e,t){const n=new Dd(t),r=ns(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Dd(e),this}Switch(e){return this._expressionNode=ot(e),this}Case(...e){const t=[];if(e.length>=2)for(let u=0;u<e.length-1;u++)t.push(this._expressionNode.equal(ot(e[u])));else Pe("TSL: Invalid parameter length. Case() requires at least two parameters.",new rr);const n=e[e.length-1],r=new Dd(n);let s=t[0];for(let u=1;u<t.length;u++)s=s.or(t[u]);const o=ns(s,r);return this._currentCond===null?(this._currentCond=o,this.addToStack(this._currentCond)):(this._currentCond.elseNode=o,this._currentCond=o,this)}Default(e){return this.Else(e),this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())r.isVarNode&&r.isIntent(e)&&r.isAssign(e)!==!0||(t["node"+n++]=r);return t.outputNode||null}hasOutput(e){return this.outputNode&&this.outputNode.isNode&&this.outputNode.getNodeType(e)!=="void"}build(e,...t){const n=rD(),r=e.buildStage;E_(this),e.setActiveStack(this);const s=h=>{if(this._currentNode=h,!(h.isVarNode&&h.isIntent(e)&&h.isAssign(e)!==!0)){if(r==="setup")h.build(e);else if(r==="analyze")h.build(e,this);else if(r==="generate"){const d=e.getDataFromNode(h,"any").stages,p=d&&d[e.shaderStage];if(h.isVarNode&&p&&p.length===1&&p[0]&&p[0].isStackNode)return;h.build(e,"void")}}},o=[...this.nodes];for(const h of o)s(h);this._currentNode=null;const u=this.nodes.filter(h=>o.indexOf(h)===-1);for(const h of u)s(h);let c;return this.hasOutput(e)?c=this.outputNode.build(e,...t):c=super.build(e,...t),E_(n),e.removeActiveStack(this),c}}const $x=fn(vq).setParameterLength(0,1);class D3 extends bi{static get type(){return"BitcastNode"}constructor(e,t,n=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=n,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){const t=this.valueNode.getNodeType(e),n=e.getTypeLength(t);return e.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(e){const t=this.getNodeType(e);let n="";if(this.inputType!==null){const r=this.valueNode.getNodeType(e);n=e.getTypeLength(r)===1?this.inputType:e.changeComponentType(r,this.inputType)}else n=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,n)}( ${this.valueNode.build(e,n)} )`}}const yq=et(D3).setParameterLength(2),xq=i=>new D3(i,"uint","float"),zg={};class Su extends le{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n==="int"?t.assign(yq(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return $t;case"int":return kn;case"uvec2":return aD;case"uvec3":return lD;case"uvec4":return cD;case"ivec2":return la;case"ivec3":return oD;case"ivec4":return uD}}_createTrailingZerosBaseLayout(e,t){const n=this._returnDataNode(t);return Se(([s])=>{const o=$t(0);this._resolveElementType(s,o,t);const u=ye(o.bitAnd(SD(o))),h=xq(u).shiftRight(23).sub(127);return n(h)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const n=this._returnDataNode(t);return Se(([s])=>{wn(s.equal($t(0)),()=>$t(32));const o=$t(0),u=$t(0);return this._resolveElementType(s,o,t),wn(o.shiftRight(16).equal(0),()=>{u.addAssign(16),o.shiftLeftAssign(16)}),wn(o.shiftRight(24).equal(0),()=>{u.addAssign(8),o.shiftLeftAssign(8)}),wn(o.shiftRight(28).equal(0),()=>{u.addAssign(4),o.shiftLeftAssign(4)}),wn(o.shiftRight(30).equal(0),()=>{u.addAssign(2),o.shiftLeftAssign(2)}),wn(o.shiftRight(31).equal(0),()=>{u.addAssign(1)}),n(u)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const n=this._returnDataNode(t);return Se(([s])=>{const o=$t(0);this._resolveElementType(s,o,t),o.assign(o.sub(o.shiftRight($t(1)).bitAnd($t(1431655765)))),o.assign(o.bitAnd($t(858993459)).add(o.shiftRight($t(2)).bitAnd($t(858993459))));const u=o.add(o.shiftRight($t(4))).bitAnd($t(252645135)).mul($t(16843009)).shiftRight($t(24));return n(u)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,n,r){const s=this._returnDataNode(t);return Se(([u])=>{if(n===1)return s(r(u));{const c=s(0),h=["x","y","z","w"];for(let d=0;d<n;d++){const p=h[d];c[p].assign(r(u[p]))}return c}}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}setup(e){const{method:t,aNode:n}=this,{renderer:r}=e;if(r.backend.isWebGPUBackend)return super.setup(e);const s=this.getInputType(e),o=e.getElementType(s),u=e.getTypeLength(s),c=`${t}_base_${o}`,h=`${t}_${s}`;let d=zg[c];if(d===void 0){switch(t){case Su.COUNT_LEADING_ZEROS:{d=this._createLeadingZerosBaseLayout(c,o);break}case Su.COUNT_TRAILING_ZEROS:{d=this._createTrailingZerosBaseLayout(c,o);break}case Su.COUNT_ONE_BITS:{d=this._createOneBitsBaseLayout(c,o);break}}zg[c]=d}let p=zg[h];return p===void 0&&(p=this._createMainLayout(h,s,u,d),zg[h]=p),Se(()=>p(n))()}}Su.COUNT_TRAILING_ZEROS="countTrailingZeros";Su.COUNT_LEADING_ZEROS="countLeadingZeros";Su.COUNT_ONE_BITS="countOneBits";new zs;new G;new G;new G;new Wt;new G(0,0,-1);new Pt;new G;new G;new Pt;new Ie;const bq=new Rl;bu.flipX();bq.depthTexture=new br(1,1);const qx=new Zh(-1,1,1,-1,0,1);class Sq extends Fi{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new ti([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ti(t,2))}}const Tq=new Sq;class PT extends xi{constructor(e=null){super(Tq,e),this.camera=qx,this.isQuadMesh=!0}async renderAsync(e){xn('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,qx)}render(e){e.render(this,qx)}}const L3=Se(([i])=>Ta(ye(52.9829189).mul(Ta(Uu(i,rt(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),fa=Se(([i,e,t])=>{const n=ye(2.399963229728653),r=Sl(ye(i).add(.5).div(ye(e))),s=ye(i).mul(n).add(t);return rt(ua(s),es(s)).mul(r)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class po extends ct{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===po.OBJECT?this.updateType=Dt.OBJECT:e===po.MATERIAL?this.updateType=Dt.RENDER:e===po.BEFORE_OBJECT?this.updateBeforeType=Dt.OBJECT:e===po.BEFORE_MATERIAL&&(this.updateBeforeType=Dt.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}po.OBJECT="object";po.MATERIAL="material";po.BEFORE_OBJECT="beforeObject";po.BEFORE_MATERIAL="beforeMaterial";const bd=new Br,Xx=new Wt,Mq=yt(0).setGroup(_t).onRenderUpdate(({scene:i})=>i.backgroundBlurriness),NC=yt(1).setGroup(_t).onRenderUpdate(({scene:i})=>i.backgroundIntensity),Eq=yt(new Wt).setGroup(_t).onRenderUpdate(({scene:i})=>{const e=i.background;return e!==null&&e.isTexture&&e.mapping!==BS?(bd.copy(i.backgroundRotation),bd.x*=-1,bd.y*=-1,bd.z*=-1,Xx.makeRotationFromEuler(bd)):Xx.identity(),Xx}),Aq=Se(({texture:i,uv:e})=>{const n=ve().toVar();return wn(e.x.lessThan(1e-4),()=>{n.assign(ve(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(ve(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(ve(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(ve(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(ve(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(ve(0,0,-1))}).Else(()=>{const s=i.sample(e.add(ve(-.01,0,0))).r.sub(i.sample(e.add(ve(.01,0,0))).r),o=i.sample(e.add(ve(0,-.01,0))).r.sub(i.sample(e.add(ve(0,.01,0))).r),u=i.sample(e.add(ve(0,0,-.01))).r.sub(i.sample(e.add(ve(0,0,.01))).r);n.assign(ve(s,o,u))}),n.normalize()});class wq extends sf{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return ve(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return Aq({texture:this,uv:e})}}const Rq=fn(wq).setParameterLength(1,3);Se(([i,e])=>i.mul(e).floor().div(e));const kg=new Ie;class Cq extends sf{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){const t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class DC extends Cq{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}class h0 extends bi{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new br;s.isRenderTargetTexture=!0,s.name="depth";const o=new Rl(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Qn,...r});o.texture.name="output",o.depthTexture=s,this.renderTarget=o,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:o.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=yt(0),this._cameraFar=yt(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=Dt.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return Ne("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return Ne("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=new DC(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new DC(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=o3(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=qd(s,n,r)}return t}async compileAsync(e){const t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),this.scope===h0.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n}=this;let r,s;const o=t.getOutputRenderTarget();o&&o.isXRRenderTarget===!0?(s=1,r=t.xr.getCamera(),t.xr.updateCamera(r),kg.set(o.width,o.height)):(r=this.camera,s=t.getPixelRatio(),t.getSize(kg)),this._pixelRatio=s,this.setSize(kg.width,kg.height);const u=t.getRenderTarget(),c=t.getMRT(),h=t.autoClear,d=t.transparent,p=t.opaque,g=r.layers.mask,_=t.contextNode,v=n.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(const b in this._previousTextures)this.toggleTexture(b);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:Gu({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const S=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=S,n.overrideMaterial=v,t.setRenderTarget(u),t.setMRT(c),t.autoClear=h,t.transparent=d,t.opaque=p,t.contextNode=_,r.layers.mask=g}setSize(e,t){this._width=e,this._height=t;const n=Math.floor(this._width*this._pixelRatio*this._resolutionScale),r=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new Pt),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new Pt),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}h0.COLOR="color";h0.DEPTH="depth";const Nq=Se(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Dq=Se(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Lq=Se(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Pq=Se(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),Uq=Se(([i,e])=>{const t=qi(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=qi(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=Pq(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Oq=qi(ve(1.6605,-.1246,-.0182),ve(-.5876,1.1329,-.1006),ve(-.0728,-.0083,1.1187)),Bq=qi(ve(.6274,.0691,.0164),ve(.3293,.9195,.088),ve(.0433,.0113,.8956)),Fq=Se(([i])=>{const e=ve(i).toVar(),t=ve(e.mul(e)).toVar(),n=ve(t.mul(t)).toVar();return ye(15.5).mul(n.mul(t)).sub(Ft(40.14,n.mul(e))).add(Ft(31.96,n).sub(Ft(6.868,t.mul(e))).add(Ft(.4298,t).add(Ft(.1191,e).sub(.00232))))}),Iq=Se(([i,e])=>{const t=ve(i).toVar(),n=qi(ve(.856627153315983,.137318972929847,.11189821299995),ve(.0951212405381588,.761241990602591,.0767994186031903),ve(.0482516061458583,.101439036467562,.811302368396859)),r=qi(ve(1.1271005818144368,-.1413297634984383,-.14132976349843826),ve(-.11060664309660323,1.157823702216272,-.11060664309660294),ve(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=ye(-12.47393),o=ye(4.026069);return t.mulAssign(e),t.assign(Bq.mul(t)),t.assign(n.mul(t)),t.assign(Xi(t,1e-10)),t.assign(yo(t)),t.assign(t.sub(s).div(o.sub(s))),t.assign(Ml(t,0,1)),t.assign(Fq(t)),t.assign(r.mul(t)),t.assign(r0(Xi(ve(0),t),ve(2.2))),t.assign(Oq.mul(t)),t.assign(Ml(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),zq=Se(([i,e])=>{const t=ye(.76),n=ye(.15);i=i.mul(e);const r=Gh(i.r,Gh(i.g,i.b)),s=ns(r.lessThan(.08),r.sub(Ft(6.25,r.mul(r))),.04);i.subAssign(s);const o=Xi(i.r,Xi(i.g,i.b));wn(o.lessThan(t),()=>i);const u=Nr(1,t),c=Nr(1,u.mul(u).div(o.add(u.sub(t))));i.mulAssign(c.div(o));const h=Nr(1,Sa(1,n.mul(o.sub(c)).add(1)));return Sn(i,ve(c),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Di extends ct{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}class kq extends Di{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,s=n.type,o=e.getCodeFromNode(this,s);r!==""&&(o.name=r);const u=e.getPropertyName(o),c=this.getNodeFunction(e).getCode(u);return o.code=c+`
`,t==="property"?u:e.format(`${u}()`,s,t)}}function UT(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||li.z).negate()}const Gq=Se(([i,e],t)=>{const n=UT(t);return So(i,e,n)}),Vq=Se(([i],e)=>{const t=UT(e);return i.mul(i,t,t).negate().exp().oneMinus()});Se(([i,e],t)=>{const n=UT(t),s=e.sub(Vh.y).max(0).toConst().mul(n).toConst();return i.mul(i,s,s).negate().exp().oneMinus()});const LC=Se(([i,e])=>wt(e.toFloat().mix(Hd.rgb,i.toVec3()),Hd.a));class Hq extends ct{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`	// ${t}Barrier 
`):e.addLineFlowCode(`${t}Barrier()`,this)}}fn(Hq);class Ra extends ct{static get type(){return"AtomicFunctionNode"}constructor(e,t,n){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),n=t.parents,r=this.method,s=this.getNodeType(e),o=this.getInputType(e),u=this.pointerNode,c=this.valueNode,h=[];h.push(`&${u.build(e,o)}`),c!==null&&h.push(c.build(e,o));const d=`${e.getMethod(r,s)}( ${h.join(", ")} )`;if(n?n.length===1&&n[0].isStackNode===!0:!1)e.addLineFlowCode(d,this);else return t.constNode===void 0&&(t.constNode=ha(d,s).toConst()),t.constNode.build(e)}}Ra.ATOMIC_LOAD="atomicLoad";Ra.ATOMIC_STORE="atomicStore";Ra.ATOMIC_ADD="atomicAdd";Ra.ATOMIC_SUB="atomicSub";Ra.ATOMIC_MAX="atomicMax";Ra.ATOMIC_MIN="atomicMin";Ra.ATOMIC_AND="atomicAnd";Ra.ATOMIC_OR="atomicOr";Ra.ATOMIC_XOR="atomicXor";fn(Ra);class rn extends bi{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),s=e.isMatrix(n)?0:e.getTypeLength(n);return r>s?t:n}getNodeType(e){const t=this.method;return t===rn.SUBGROUP_ELECT?"bool":t===rn.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const n=this.method,r=this.getNodeType(e),s=this.getInputType(e),o=this.aNode,u=this.bNode,c=[];if(n===rn.SUBGROUP_BROADCAST||n===rn.SUBGROUP_SHUFFLE||n===rn.QUAD_BROADCAST){const d=u.getNodeType(e);c.push(o.build(e,r),u.build(e,d==="float"?"int":r))}else n===rn.SUBGROUP_SHUFFLE_XOR||n===rn.SUBGROUP_SHUFFLE_DOWN||n===rn.SUBGROUP_SHUFFLE_UP?c.push(o.build(e,r),u.build(e,"uint")):(o!==null&&c.push(o.build(e,s)),u!==null&&c.push(u.build(e,s)));const h=c.length===0?"()":`( ${c.join(", ")} )`;return e.format(`${e.getMethod(n,r)}${h}`,r,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}rn.SUBGROUP_ELECT="subgroupElect";rn.SUBGROUP_BALLOT="subgroupBallot";rn.SUBGROUP_ADD="subgroupAdd";rn.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd";rn.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd";rn.SUBGROUP_MUL="subgroupMul";rn.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul";rn.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul";rn.SUBGROUP_AND="subgroupAnd";rn.SUBGROUP_OR="subgroupOr";rn.SUBGROUP_XOR="subgroupXor";rn.SUBGROUP_MIN="subgroupMin";rn.SUBGROUP_MAX="subgroupMax";rn.SUBGROUP_ALL="subgroupAll";rn.SUBGROUP_ANY="subgroupAny";rn.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst";rn.QUAD_SWAP_X="quadSwapX";rn.QUAD_SWAP_Y="quadSwapY";rn.QUAD_SWAP_DIAGONAL="quadSwapDiagonal";rn.SUBGROUP_BROADCAST="subgroupBroadcast";rn.SUBGROUP_SHUFFLE="subgroupShuffle";rn.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor";rn.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp";rn.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown";rn.QUAD_BROADCAST="quadBroadcast";let Gg;function f0(i){Gg=Gg||new WeakMap;let e=Gg.get(i);return e===void 0&&Gg.set(i,e={}),e}function OT(i){const e=f0(i);return e.shadowMatrix||(e.shadowMatrix=yt("mat4").setGroup(_t).onRenderUpdate(t=>((i.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(i.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(i.shadow.camera.coordinateSystem=t.camera.coordinateSystem,i.shadow.camera.updateProjectionMatrix()),i.shadow.updateMatrices(i)),i.shadow.matrix)))}function jq(i,e=Vh){const t=OT(i).mul(e);return t.xyz.div(t.w)}function P3(i){const e=f0(i);return e.position||(e.position=yt(new G).setGroup(_t).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function Wq(i){const e=f0(i);return e.targetPosition||(e.targetPosition=yt(new G).setGroup(_t).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function U3(i){const e=f0(i);return e.viewPosition||(e.viewPosition=yt(new G).setGroup(_t).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new G,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const O3=i=>Mo.transformDirection(P3(i).sub(Wq(i))),$q=i=>i.sort((e,t)=>e.id-t.id),qq=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},Yx=new WeakMap,Sd=[];class B3 extends ct{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=bl("vec3","totalDiffuse"),this.totalSpecularNode=bl("vec3","totalSpecular"),this.outgoingLightNode=bl("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let n=0;n<e.length;n++){const r=e[n];if(Sd.push(r.id),Sd.push(r.castShadow?1:0),r.isSpotLight===!0){const s=r.map!==null?r.map.id:-1,o=r.colorNode?r.colorNode.getCacheKey():-1;Sd.push(s,o)}}const t=wp(Sd);return Sd.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const n of this._lightNodes)t.push(n.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getNodeProperties(this);for(const n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){const t=[],n=this._lightNodes,r=$q(this._lights),s=e.renderer.library;for(const o of r)if(o.isNode)t.push(ot(o));else{let u=null;if(n!==null&&(u=qq(o.id,n)),u===null){const c=s.getLightNodeClass(o.constructor);if(c===null){Ne(`LightsNode.setupNodeLights: Light node not found for ${o.constructor.name}`);continue}let h=null;Yx.has(o)?h=Yx.get(o):(h=new c(o),Yx.set(o,h)),t.push(h)}}this._lightNodes=t}setupDirectLight(e,t,n){const{lightingModel:r,reflectedLight:s}=e.context;r.direct({...n,lightNode:t,reflectedLight:s},e)}setupDirectRectAreaLight(e,t,n){const{lightingModel:r,reflectedLight:s}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:s},e)}setupLights(e,t){for(const n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode;const r=e.context,s=r.lightingModel,o=e.getNodeProperties(this);if(s){const{totalDiffuseNode:u,totalSpecularNode:c}=this;r.outgoingLight=n;const h=e.addStack();o.nodes=h.nodes,s.start(e);const{backdrop:d,backdropAlpha:p}=r,{directDiffuse:g,directSpecular:_,indirectDiffuse:v,indirectSpecular:S}=r.reflectedLight;let b=g.add(v);d!==null&&(p!==null?b=ve(p.mix(b,d)):b=ve(d)),u.assign(b),c.assign(_.add(S)),n.assign(u.add(c)),s.finish(e),n=n.bypass(e.removeStack())}else o.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class Xq extends ct{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Dt.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){F3.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Vh)}}const F3=bl("vec3","shadowPositionWorld");function Yq(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new pt),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function Kq(i,e){return e=Yq(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function Zq(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function Qq(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function Jq(i,e){return e=Qq(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function e7(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function t7(i,e,t){return t=Kq(i,t),t=Jq(e,t),t}function n7(i,e,t){Zq(i,t),e7(e,t)}const D_=new WeakMap,i7=Se(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let n=Fn(i,e.xy).setName("t_basic");return i.isArrayTexture&&(n=n.depth(t)),n.compare(e.z)}),r7=Se(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const r=(d,p)=>{let g=Fn(i,d);return i.isArrayTexture&&(g=g.depth(n)),g.compare(p)},s=jn("mapSize","vec2",t).setGroup(_t),o=jn("radius","float",t).setGroup(_t),u=rt(1).div(s),c=o.mul(u.x),h=L3(of.xy).mul(6.28318530718);return Fr(r(e.xy.add(fa(0,5,h).mul(c)),e.z),r(e.xy.add(fa(1,5,h).mul(c)),e.z),r(e.xy.add(fa(2,5,h).mul(c)),e.z),r(e.xy.add(fa(3,5,h).mul(c)),e.z),r(e.xy.add(fa(4,5,h).mul(c)),e.z)).mul(1/5)}),s7=Se(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const r=(p,g)=>{let _=Fn(i,p);return i.isArrayTexture&&(_=_.depth(n)),_.compare(g)},s=jn("mapSize","vec2",t).setGroup(_t),o=rt(1).div(s),u=o.x,c=o.y,h=e.xy,d=Ta(h.mul(s).add(.5));return h.subAssign(d.mul(o)),Fr(r(h,e.z),r(h.add(rt(u,0)),e.z),r(h.add(rt(0,c)),e.z),r(h.add(o),e.z),Sn(r(h.add(rt(u.negate(),0)),e.z),r(h.add(rt(u.mul(2),0)),e.z),d.x),Sn(r(h.add(rt(u.negate(),c)),e.z),r(h.add(rt(u.mul(2),c)),e.z),d.x),Sn(r(h.add(rt(0,c.negate())),e.z),r(h.add(rt(0,c.mul(2))),e.z),d.y),Sn(r(h.add(rt(u,c.negate())),e.z),r(h.add(rt(u,c.mul(2))),e.z),d.y),Sn(Sn(r(h.add(rt(u.negate(),c.negate())),e.z),r(h.add(rt(u.mul(2),c.negate())),e.z),d.x),Sn(r(h.add(rt(u.negate(),c.mul(2))),e.z),r(h.add(rt(u.mul(2),c.mul(2))),e.z),d.x),d.y)).mul(1/9)}),a7=Se(({depthTexture:i,shadowCoord:e,depthLayer:t},n)=>{let r=Fn(i).sample(e.xy);i.isArrayTexture&&(r=r.depth(t)),r=r.rg;const s=r.x,o=Xi(1e-7,r.y.mul(r.y)),u=n.renderer.reversedDepthBuffer?pp(s,e.z):pp(e.z,s),c=ye(1).toVar();return wn(u.notEqual(1),()=>{const h=e.z.sub(s);let d=o.div(o.add(h.mul(h)));d=Ml(Nr(d,.3).div(.65)),c.assign(Xi(u,d))}),c}),o7=i=>{let e=D_.get(i);return e===void 0&&(e=new ui,e.colorNode=wt(0,0,0,1),e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.blending=Bi,e.fog=!1,D_.set(i,e)),e},l7=i=>{const e=D_.get(i);e!==void 0&&(e.dispose(),D_.delete(i))},PC=new Al,qc=[],u7=(i,e,t,n)=>{qc[0]=i,qc[1]=e;let r=PC.get(qc);return(r===void 0||r.shadowType!==t||r.useVelocity!==n)&&(r=(s,o,u,c,h,d,...p)=>{(s.castShadow===!0||s.receiveShadow&&t===da)&&(n&&(eD(s).useVelocity=!0),s.onBeforeShadow(i,s,u,e.camera,c,o.overrideMaterial,d),i.renderObject(s,o,u,c,h,d,...p),s.onAfterShadow(i,s,u,e.camera,c,o.overrideMaterial,d))},r.shadowType=t,r.useVelocity=n,PC.set(qc,r)),qc[0]=null,qc[1]=null,r},c7=Se(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:r})=>{const s=ye(0).toVar("meanVertical"),o=ye(0).toVar("squareMeanVertical"),u=i.lessThanEqual(ye(1)).select(ye(0),ye(2).div(i.sub(1))),c=i.lessThanEqual(ye(1)).select(ye(0),ye(-1));vs({start:kn(0),end:kn(i),type:"int",condition:"<"},({i:d})=>{const p=c.add(ye(d).mul(u));let g=n.sample(Fr(of.xy,rt(0,p).mul(e)).div(t));n.value.isArrayTexture&&(g=g.depth(r)),g=g.x,s.addAssign(g),o.addAssign(g.mul(g))}),s.divAssign(i),o.divAssign(i);const h=Sl(o.sub(s.mul(s)).max(0));return rt(s,h)}),h7=Se(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:r})=>{const s=ye(0).toVar("meanHorizontal"),o=ye(0).toVar("squareMeanHorizontal"),u=i.lessThanEqual(ye(1)).select(ye(0),ye(2).div(i.sub(1))),c=i.lessThanEqual(ye(1)).select(ye(0),ye(-1));vs({start:kn(0),end:kn(i),type:"int",condition:"<"},({i:d})=>{const p=c.add(ye(d).mul(u));let g=n.sample(Fr(of.xy,rt(p,0).mul(e)).div(t));n.value.isArrayTexture&&(g=g.depth(r)),s.addAssign(g.x),o.addAssign(Fr(g.y.mul(g.y),g.x.mul(g.x)))}),s.divAssign(i),o.divAssign(i);const h=Sl(o.sub(s.mul(s)).max(0));return rt(s,h)}),f7=[i7,r7,s7,a7];let Kx;const Vg=new PT;class I3 extends Xq{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:s,depthLayer:o}){const u=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),c=t({depthTexture:n,shadowCoord:r,shadow:s,depthLayer:o});return u.select(c,ye(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,s=n.biasNode||jn("bias","float",n).setGroup(_t);let o=t,u;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)o=o.xyz.div(o.w),u=o.z;else{const c=o.w;o=o.xy.div(c);const h=jn("near","float",n.camera).setGroup(_t),d=jn("far","float",n.camera).setGroup(_t);u=l3(c.negate(),h,d)}return o=ve(o.x,o.y.oneMinus(),r.reversedDepthBuffer?u.sub(s):u.add(s)),o}getShadowFilterFn(e){return f7[e]}setupRenderTarget(e,t){const n=new br(e.mapSize.width,e.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=t.renderer.reversedDepthBuffer?bo:wl;const r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name="ShadowMap",r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){const{renderer:t,camera:n}=e,{light:r,shadow:s}=this,{depthTexture:o,shadowMap:u}=this.setupRenderTarget(s,e),c=t.shadowMap.type,h=t.hasCompatibility(mo.TEXTURE_COMPARE);if((c===nh||c===BN)&&h?(o.minFilter=Rn,o.magFilter=Rn):(o.minFilter=hn,o.magFilter=hn),s.camera.coordinateSystem=n.coordinateSystem,s.camera.updateProjectionMatrix(),c===da&&s.isPointLightShadow!==!0){o.compareFunction=null,u.depth>1?(u._vsmShadowMapVertical||(u._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:vr,type:Qn,depth:u.depth,depthBuffer:!1}),u._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=u._vsmShadowMapVertical,u._vsmShadowMapHorizontal||(u._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:vr,type:Qn,depth:u.depth,depthBuffer:!1}),u._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=u._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:vr,type:Qn,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:vr,type:Qn,depthBuffer:!1}));let w=Fn(o);o.isArrayTexture&&(w=w.depth(this.depthLayer));let D=Fn(this.vsmShadowMapVertical.texture);o.isArrayTexture&&(D=D.depth(this.depthLayer));const C=jn("blurSamples","float",s).setGroup(_t),N=jn("radius","float",s).setGroup(_t),A=jn("mapSize","vec2",s).setGroup(_t);let L=this.vsmMaterialVertical||(this.vsmMaterialVertical=new ui);L.fragmentNode=c7({samples:C,radius:N,size:A,shadowPass:w,depthLayer:this.depthLayer}).context(e.getSharedContext()),L.name="VSMVertical",L=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new ui),L.fragmentNode=h7({samples:C,radius:N,size:A,shadowPass:D,depthLayer:this.depthLayer}).context(e.getSharedContext()),L.name="VSMHorizontal"}const d=jn("intensity","float",s).setGroup(_t),p=jn("normalBias","float",s).setGroup(_t),g=OT(r).mul(F3.add(lf.mul(p))),_=this.setupShadowCoord(e,g),v=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(v===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const S=c===da&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:o,b=this.setupShadowFilter(e,{filterFn:v,shadowTexture:u.texture,depthTexture:S,shadowCoord:_,shadow:s,depthLayer:this.depthLayer});let x;t.shadowMap.transmitted===!0&&(u.texture.isCubeTexture?x=Lr(u.texture,_.xyz):(x=Fn(u.texture,_),o.isArrayTexture&&(x=x.depth(this.depthLayer))));let M;x?M=Sn(1,b.rgb.mix(x,1),d.mul(x.a)).toVar():M=Sn(1,b,d).toVar(),this.shadowMap=u,this.shadow.map=u;const E=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return x&&M.toInspector(`${E} / Color`,()=>this.shadowMap.texture.isCubeTexture?Lr(this.shadowMap.texture):Fn(this.shadowMap.texture)),M.toInspector(`${E} / Depth`,()=>this.shadowMap.texture.isCubeTexture?Lr(this.shadowMap.texture).r.oneMinus():gs(this.shadowMap.depthTexture,rf().mul(hh(Fn(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled!==!1)return Se(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(e),n===null&&(this._node=n=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:o}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth);const u=o.name;o.name=`Shadow Map [ ${r.name||"ID: "+r.id} ]`,s.render(o,t.camera),o.name=u}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:s,scene:o,camera:u}=e,c=s.shadowMap.type,h=t.depthTexture.version;this._depthVersionCached=h;const d=r.camera.layers.mask;(r.camera.layers.mask&4294967294)===0&&(r.camera.layers.mask=u.layers.mask);const p=s.getRenderObjectFunction(),g=s.getMRT(),_=g?g.has("velocity"):!1;Kx=t7(s,o,Kx),o.overrideMaterial=o7(n),s.setRenderObjectFunction(u7(s,r,c,_)),s.setClearColor(0,0),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(p),c===da&&r.isPointLightShadow!==!0&&this.vsmPass(s),r.camera.layers.mask=d,n7(s,o,Kx)}vsmPass(e){const{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),Vg.material=this.vsmMaterialVertical,Vg.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Vg.material=this.vsmMaterialHorizontal,Vg.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,l7(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){const{shadow:t}=this;let n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const d7=(i,e)=>new I3(i,e),p7=new pt,UC=new Wt,Td=new G,Zx=new G,m7=[new G(1,0,0),new G(-1,0,0),new G(0,-1,0),new G(0,1,0),new G(0,0,1),new G(0,0,-1)],g7=[new G(0,-1,0),new G(0,-1,0),new G(0,0,-1),new G(0,0,1),new G(0,-1,0),new G(0,-1,0)],_7=[new G(1,0,0),new G(-1,0,0),new G(0,1,0),new G(0,-1,0),new G(0,0,1),new G(0,0,-1)],v7=[new G(0,-1,0),new G(0,-1,0),new G(0,0,1),new G(0,0,-1),new G(0,-1,0),new G(0,-1,0)],y7=Se(({depthTexture:i,bd3D:e,dp:t})=>Lr(i,e).compare(t)),x7=Se(({depthTexture:i,bd3D:e,dp:t,shadow:n})=>{const r=jn("radius","float",n).setGroup(_t),s=jn("mapSize","vec2",n).setGroup(_t),o=r.div(s.x),u=ts(e),c=ya(Ou(e,u.x.greaterThan(u.z).select(ve(0,1,0),ve(1,0,0)))),h=Ou(e,c),d=L3(of.xy).mul(6.28318530718),p=fa(0,5,d),g=fa(1,5,d),_=fa(2,5,d),v=fa(3,5,d),S=fa(4,5,d);return Lr(i,e.add(c.mul(p.x).add(h.mul(p.y)).mul(o))).compare(t).add(Lr(i,e.add(c.mul(g.x).add(h.mul(g.y)).mul(o))).compare(t)).add(Lr(i,e.add(c.mul(_.x).add(h.mul(_.y)).mul(o))).compare(t)).add(Lr(i,e.add(c.mul(v.x).add(h.mul(v.y)).mul(o))).compare(t)).add(Lr(i,e.add(c.mul(S.x).add(h.mul(S.y)).mul(o))).compare(t)).mul(1/5)}),b7=Se(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n},r)=>{const s=t.xyz.toConst(),o=s.abs().toConst(),u=o.x.max(o.y).max(o.z),c=yt("float").setGroup(_t).onRenderUpdate(()=>n.camera.near),h=yt("float").setGroup(_t).onRenderUpdate(()=>n.camera.far),d=jn("bias","float",n).setGroup(_t),p=ye(1).toVar();return wn(u.sub(h).lessThanEqual(0).and(u.sub(c).greaterThanEqual(0)),()=>{let g;r.renderer.reversedDepthBuffer?(g=oW(u.negate(),c,h),g.subAssign(d)):(g=a3(u.negate(),c,h),g.addAssign(d));const _=s.normalize();p.assign(i({depthTexture:e,bd3D:_,dp:g,shadow:n}))}),p});class S7 extends I3{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===SO?y7:x7}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:s}){return b7({filterFn:t,depthTexture:n,shadowCoord:r,shadow:s})}setupRenderTarget(e,t){const n=new ZN(e.mapSize.width);n.name="PointShadowDepthTexture",n.compareFunction=t.renderer.reversedDepthBuffer?bo:wl;const r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name="PointShadowMap",r.depthTexture=n,{shadowMap:r,depthTexture:n}}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:o}=e,u=t.camera,c=t.matrix,h=s.coordinateSystem===ba,d=h?m7:_7,p=h?g7:v7;n.setSize(t.mapSize.width,t.mapSize.width);const g=s.autoClear,_=s.getClearColor(p7),v=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha);for(let S=0;S<6;S++){s.setRenderTarget(n,S),s.clear();const b=r.distance||u.far;b!==u.far&&(u.far=b,u.updateProjectionMatrix()),Td.setFromMatrixPosition(r.matrixWorld),u.position.copy(Td),Zx.copy(u.position),Zx.add(d[S]),u.up.copy(p[S]),u.lookAt(Zx),u.updateMatrixWorld(),c.makeTranslation(-Td.x,-Td.y,-Td.z),UC.multiplyMatrices(u.projectionMatrix,u.matrixWorldInverse),t._frustum.setFromProjectionMatrix(UC,u.coordinateSystem,u.reversedDepth);const x=o.name;o.name=`Point Light Shadow [ ${r.name||"ID: "+r.id} ] - Face ${S+1}`,s.render(o,u),o.name=x}s.autoClear=g,s.setClearColor(_,v)}}const T7=(i,e)=>new S7(i,e);class Hu extends uf{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new pt,this.colorNode=e&&e.colorNode||yt(this.color).setGroup(_t),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Dt.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return U3(this.light).sub(e.context.positionView||li)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return d7(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const r=this.light.shadow.shadowNode;let s;r!==void 0?s=ot(r):s=this.setupShadowNode(),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}e.context.getShadow&&(n=e.context.getShadow(this,e)),this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const z3=Se(({lightDistance:i,cutoffDistance:e,decayExponent:t})=>{const n=i.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(n.mul(i.div(e).pow4().oneMinus().clamp().pow2()),n)}),M7=({color:i,lightVector:e,cutoffDistance:t,decayExponent:n})=>{const r=e.normalize(),s=e.length(),o=z3({lightDistance:s,cutoffDistance:t,decayExponent:n}),u=i.mul(o);return{lightDirection:r,lightColor:u}};class E7 extends Hu{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=yt(0).setGroup(_t),this.decayExponentNode=yt(2).setGroup(_t)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return T7(this.light)}setupDirect(e){return M7({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}Se(([i=rf()],{renderer:e,material:t})=>{const n=RD(i.mul(2).sub(1));let r;if(t.alphaToCoverage&&e.currentSamples>0){const s=ye(n.fwidth()).toVar();r=So(s.oneMinus(),s.add(1),n).oneMinus()}else r=ns(n.greaterThan(1),0,1);return r});const A7=Se(([i,e])=>{const t=i.x,n=i.y,r=i.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(n)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(n)),s=s.add(e.element(5).mul(2*.429043).mul(n).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(Ft(t,t).sub(Ft(n,n)))),s}),Bs=new LT;class w7 extends Cl{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background;let o=!1;if(s===null)r._clearColor.getRGB(Bs),Bs.a=r._clearColor.a;else if(s.isColor===!0)s.getRGB(Bs),Bs.a=1,o=!0;else if(s.isNode===!0){const h=this.get(e),d=s;Bs.copy(r._clearColor);let p=h.backgroundMesh;if(p===void 0){let w=function(){s.removeEventListener("dispose",w),p.material.dispose(),p.geometry.dispose()};var c=w;const _=wt(d).mul(NC).context({getUV:()=>Eq.mul(P9),getTextureLevel:()=>Mq}),v=Wd.element(3).element(3).equal(1),S=Sa(1,Wd.element(1).element(1)).mul(3),b=v.select(Oi.mul(S),Oi),x=Cp.mul(wt(b,0));let M=Wd.mul(wt(x.xyz,1));M=M.setZ(M.w);const E=new ui;E.name="Background.material",E.side=Tn,E.depthTest=!1,E.depthWrite=!1,E.allowOverride=!1,E.fog=!1,E.lights=!1,E.vertexNode=M,E.colorNode=_,h.backgroundMeshNode=_,h.backgroundMesh=p=new xi(new Ap(1,32,32),E),p.frustumCulled=!1,p.name="Background.mesh",s.addEventListener("dispose",w)}const g=d.getCacheKey();h.backgroundCacheKey!==g&&(h.backgroundMeshNode.node=wt(d).mul(NC),h.backgroundMeshNode.needsUpdate=!0,p.material.needsUpdate=!0,h.backgroundCacheKey=g),t.unshift(p,p.geometry,p.material,0,0,null,null)}else Pe("Renderer: Unsupported background configuration.",s);const u=r.xr.getEnvironmentBlendMode();if(u==="additive"?Bs.set(0,0,0,1):u==="alpha-blend"&&Bs.set(0,0,0,0),r.autoClear===!0||o===!0){const h=n.clearColorValue;h.r=Bs.r,h.g=Bs.g,h.b=Bs.b,h.a=Bs.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(h.r*=h.a,h.g*=h.a,h.b*=h.a),n.depthClearValue=r.getClearDepth(),n.stencilClearValue=r.getClearStencil(),n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let R7=0;class iS{constructor(e="",t=[],n=0){this.name=e,this.bindings=t,this.index=n,this.id=R7++}}class C7{constructor(e,t,n,r,s,o,u,c,h,d=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=d,this.nodeAttributes=r,this.bindings=s,this.updateNodes=o,this.updateBeforeNodes=u,this.updateAfterNodes=c,this.observer=h,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new iS(t.name,[],t.index);e.push(r);for(const s of t.bindings)r.bindings.push(s.clone())}else e.push(t);return e}}class OC{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class N7{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class k3{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}}class D7 extends k3{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}}class L7{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let P7=0;class Qx{constructor(e=null){this.id=P7++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class U7{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class Nl{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class O7 extends Nl{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class B7 extends Nl{constructor(e,t=new Ie){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class F7 extends Nl{constructor(e,t=new G){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class I7 extends Nl{constructor(e,t=new Pt){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class z7 extends Nl{constructor(e,t=new pt){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class k7 extends Nl{constructor(e,t=new X_){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class G7 extends Nl{constructor(e,t=new Nt){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class V7 extends Nl{constructor(e,t=new Wt){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class H7 extends O7{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class j7 extends B7{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class W7 extends F7{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class $7 extends I7{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class q7 extends z7{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class X7 extends k7{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Y7 extends G7{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class K7 extends V7{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let Z7=0;const BC=new WeakMap,Q7=new WeakMap,J7=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Hg=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class G3{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=$x(),this.stacks=[],this.tab="	",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new Qx,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:Z7++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute("normal")===!1}isOpaque(){const e=this.material;return e.transparent===!1&&e.blending===pr&&e.alphaToCoverage===!1}createRenderTarget(e,t,n){return new Rl(e,t,n)}createCubeRenderTarget(e,t){return new f3(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const n=t[0].groupNode;let r=n.shared;if(r)for(let o=1;o<t.length;o++)n!==t[o].groupNode&&(r=!1);let s;if(r){let o="";for(const d of t)if(d.isNodeUniformsGroup){d.uniforms.sort((p,g)=>p.nodeUniform.node.id-g.nodeUniform.node.id);for(const p of d.uniforms)o+=p.nodeUniform.node.id}else o+=d.nodeUniform.id;const u=this.renderer._currentRenderContext||this.renderer;let c=BC.get(u);c===void 0&&(c=new Map,BC.set(u,c));const h=ef(o);s=c.get(h),s===void 0&&(s=new iS(e,t,this.bindingsIndexes[e].group),c.set(h,s))}else s=new iS(e,t,this.bindingsIndexes[e].group);return s}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const r of CR)for(const s in n[r]){const o=n[r][s],u=t[s]||(t[s]=[]);for(const c of o)u.includes(c)===!1&&u.push(c)}e=[];for(const r in t){const s=t[r],o=this._getBindGroup(r,s);e.push(o)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const n=e[t];this.bindingsIndexes[n.name].group=t,n.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){const t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();(t!==Dt.NONE||n!==Dt.NONE)&&this.sequentialNodes.includes(e)===!1&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(const e of this.nodes)e.getUpdateType()!==Dt.NONE&&this.updateNodes.push(e);for(const e of this.sequentialNodes){const t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==Dt.NONE&&this.updateBeforeNodes.push(e),n!==Dt.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Rn||e.magFilter===sh||e.magFilter===ho||e.magFilter===Ur||e.minFilter===Rn||e.minFilter===sh||e.minFilter===ho||e.minFilter===Ur}getUniformBufferLimit(){return 16384}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}addContext(e){const t=this.getContext();return this.setContext({...this.context,...e}),t}getSharedContext(){const e={...this.context};return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new Qx(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){Ne("Abstract function.")}getInstanceIndex(){Ne("Abstract function.")}getDrawIndex(){Ne("Abstract function.")}getFrontFacing(){Ne("Abstract function.")}getFragCoord(){Ne("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){Ne("Abstract function.")}generateTextureLod(){Ne("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,n=null){let r=this.generateArrayDeclaration(e,t)+"( ";for(let s=0;s<t;s++){const o=n?n[s]:null;o!==null?r+=o.build(this,e):r+=this.generateConst(e),s<t-1&&(r+=", ")}return r+=" )",r}generateStruct(e,t,n=null){const r=[];for(const s of t){const{name:o,type:u}=s;n&&n[o]&&n[o].isNode?r.push(n[o].build(this,u)):r.push(this.generateConst(u))}return e+"( "+r.join(", ")+" )"}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new pt:e==="vec2"||e==="uvec2"||e==="ivec2"?t=new Ie:e==="vec3"||e==="uvec3"||e==="ivec3"?t=new G:(e==="vec4"||e==="uvec4"||e==="ivec4")&&(t=new Pt)),e==="float")return Hg(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Hg(t.r)}, ${Hg(t.g)}, ${Hg(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),s=o=>this.generateConst(r,o);if(n===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(n===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(n===4&&e!=="mat2")return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const s of n)if(s.name===e)return s;const r=new OC(e,t);return this.registerDeclaration(r),n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===Li)return"int";if(t===bn)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let n=J2(e);const r=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(n=n.replace("vec","mat")),r+n}getTypeFromArray(e){return J7.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,s=e.normalized;let o;return!(e instanceof XN)&&s!==!0&&(o=this.getTypeFromArray(n)),this.getTypeFromLength(r,o)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw new Error("NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=$x(this.stack);const e=rD();return this.stacks.push(e),E_(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){const n=this.getDataFromNode(t);n.stack=e}return this.stack=e.parent,E_(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={});let s=r[t];const o=r.any?r.any.subBuilds:null,u=this.getClosestSubBuild(o);return u&&(s.subBuildsCache===void 0&&(s.subBuildsCache={}),s=s.subBuildsCache[u]||(s.subBuildsCache[u]={}),s.subBuilds=o),s}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e,"vertex");let r=n.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new OC("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,r=this.shaderStage){const s=this.getDataFromNode(e,r,this.globalCache);let o=s.structType;if(o===void 0){const u=this.structs.index++;n===null&&(n="StructType"+u),o=new U7(n,t),this.structs[r].push(o),this.types[r][n]=e,s.structType=o}return o}getOutputStructTypeFromNode(e,t){const n=this.getStructTypeFromNode(e,t,"OutputType","fragment");return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,r=null){const s=this.getDataFromNode(e,n,this.globalCache);let o=s.uniform;if(o===void 0){const u=this.uniforms.index++;o=new N7(r||"nodeUniform"+u,t,e),this.uniforms[n].push(o),this.registerDeclaration(o),s.uniform=o}return o}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage,s=!1){const o=this.getDataFromNode(e,r),u=this.getSubBuildProperty("variable",o.subBuilds);let c=o[u];if(c===void 0){const h=s?"_const":"_var",d=this.vars[r]||(this.vars[r]=[]),p=this.vars[h]||(this.vars[h]=0);t===null&&(t=(s?"nodeConst":"nodeVar")+p,this.vars[h]++),u!=="variable"&&(t=this.getSubBuildProperty(t,o.subBuilds));const g=e.getArrayCount(this);c=new k3(t,n,s,g),s||d.push(c),this.registerDeclaration(c),o[u]=c}return c}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(const t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,n=e.getNodeType(this),r=null,s=null){const o=this.getDataFromNode(e,"any"),u=this.getSubBuildProperty("varying",o.subBuilds);let c=o[u];if(c===void 0){const h=this.varyings,d=h.length;t===null&&(t="nodeVarying"+d),u!=="varying"&&(t=this.getSubBuildProperty(t,o.subBuilds)),c=new D7(t,n,r,s),h.push(c),this.registerDeclaration(c),o[u]=c}return c}registerDeclaration(e){const t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),r=this.getPropertyName(e);let s=1,o=r;for(;n[o]!==void 0;)o=r+"_"+s++;s>1&&(e.name=o,Ne(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${o}'.`)),n[o]=e}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const o=this.codes[n]||(this.codes[n]=[]),u=o.length;s=new L7("nodeCode"+u,t),o.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,o=t;for(;o;){if(r.get(o)===!0){s=!1;break}o=this.getDataFromNode(o).parentNodeBlock}if(s)for(const u of n)this.addLineFlowCode(u)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),o=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),o.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="	",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new kq,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let o=0;const u=Object.values(this);return{next:()=>({value:u[o],done:o++>=u.length})}}};for(const o of t.inputs)n[o.name]=new _q(o.type,o.name);e.layout=null;const r=e.call(n),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowBuildStage(e,t,n=null){const r=this.getBuildStage();this.setBuildStage(t);const s=e.build(this,n);return this.setBuildStage(r),s}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,s=this.declarations,o=this.cache,u=this.buildStage,c=this.stack,h={code:""};this.flow=h,this.vars={},this.declarations={},this.cache=new Qx,this.stack=$x();for(const d of RR)this.setBuildStage(d),h.result=e.build(this,t);return h.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.declarations=s,this.cache=o,this.stack=c,this.setBuildStage(u),h}getFunctionOperator(){return null}buildFunctionCode(){Ne("Abstract function.")}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const s=this.tab,o=this.cache,u=this.shaderStage,c=this.context;this.setShaderStage(e);const h={...this.context};delete h.nodeBlock,this.cache=this.globalCache,this.tab="	",this.context=h;let d=null;if(this.buildStage==="generate"){const p=this.flowChildNode(t,n);r!==null&&(p.code+=`${this.tab+r} = ${p.result};
`),this.flowCode[e]=this.flowCode[e]+p.code,d=p}else d=t.build(this);return this.setShaderStage(u),this.cache=o,this.tab=s,this.context=c,d}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){Ne("Abstract function.")}getVaryings(){Ne("Abstract function.")}getVar(e,t,n=null){return`${n!==null?this.generateArrayDeclaration(e,n):this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const r of n)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){Ne("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const r of t)n+=r.code+`
`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){Ne("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;const n=this.subBuildLayers;for(let r=t.length-1;r>=0;r--){const s=t[r];if(n.includes(s))return s}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let n;t!==null?n=this.getClosestSubBuild(t):n=this.subBuildFn;let r;return n?r=e?n+"_"+e:n:r=e,r}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let r=n.library.fromMaterial(t);r===null&&(Pe(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new ui),r.build(this)}else this.addFlow("compute",e);for(const r of RR){this.setBuildStage(r),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const s of CR){this.setShaderStage(s);const o=this.flowNodes[s];for(const u of o)r==="generate"?this.flowNode(u):u.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=Q7.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){const n=this.getSharedDataFromNode(e);let r=n.cache;if(r===void 0){if(t==="float"||t==="int"||t==="uint")r=new H7(e);else if(t==="vec2"||t==="ivec2"||t==="uvec2")r=new j7(e);else if(t==="vec3"||t==="ivec3"||t==="uvec3")r=new W7(e);else if(t==="vec4"||t==="ivec4"||t==="uvec4")r=new $7(e);else if(t==="color")r=new q7(e);else if(t==="mat2")r=new X7(e);else if(t==="mat3")r=new Y7(e);else if(t==="mat4")r=new K7(e);else throw new Error(`Uniform "${t}" not implemented.`);n.cache=r}return r}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const r=this.getTypeLength(t),s=this.getTypeLength(n);return r===16&&s===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&s===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||s>4||s===0?e:r===s?`${this.getType(n)}( ${e} )`:r>s?(e=n==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,s)}`,this.format(e,this.getTypeFromLength(s,this.getComponentType(t)),n)):s===4&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${Fu} - Node System
`}needsPreviousData(){const e=this.renderer.getMRT();return e&&e.has("velocity")||eD(this.object).useVelocity===!0}}class FC{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderId:0,frameId:0},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===Dt.FRAME){const r=this._getMaps(this.updateBeforeMap,n);if(r.frameId!==this.frameId){const s=r.frameId;r.frameId=this.frameId,e.updateBefore(this)===!1&&(r.frameId=s)}}else if(t===Dt.RENDER){const r=this._getMaps(this.updateBeforeMap,n);if(r.renderId!==this.renderId){const s=r.renderId;r.renderId=this.renderId,e.updateBefore(this)===!1&&(r.renderId=s)}}else t===Dt.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===Dt.FRAME){const r=this._getMaps(this.updateAfterMap,n);r.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(r.frameId=this.frameId)}else if(t===Dt.RENDER){const r=this._getMaps(this.updateAfterMap,n);r.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(r.renderId=this.renderId)}else t===Dt.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===Dt.FRAME){const r=this._getMaps(this.updateMap,n);r.frameId!==this.frameId&&e.update(this)!==!1&&(r.frameId=this.frameId)}else if(t===Dt.RENDER){const r=this._getMaps(this.updateMap,n);r.renderId!==this.renderId&&e.update(this)!==!1&&(r.renderId=this.renderId)}else t===Dt.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class BT{constructor(e,t,n=null,r="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=s}}BT.isNodeFunctionInput=!0;class eX extends Hu{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class tX extends Hu{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:O3(this.light),lightColor:e}}}class nX extends Hu{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=P3(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=yt(new pt).setGroup(_t)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,o=lf.dot(r).mul(.5).add(.5),u=Sn(n,t,o);e.context.irradiance.addAssign(u)}}class FT extends Hu{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=yt(0).setGroup(_t),this.penumbraCosNode=yt(0).setGroup(_t),this.cutoffDistanceNode=yt(0).setGroup(_t),this.decayExponentNode=yt(0).setGroup(_t),this.colorNode=yt(this.color).setGroup(_t)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:n,penumbraCosNode:r}=this;return So(n,r,t)}getLightCoord(e){const t=e.getNodeProperties(this);let n=t.projectionUV;return n===void 0&&(n=jq(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){const{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:s}=this,o=this.getLightVector(e),u=o.normalize(),c=u.dot(O3(s)),h=this.getSpotAttenuation(e,c),d=o.length(),p=z3({lightDistance:d,cutoffDistance:n,decayExponent:r});let g=t.mul(h).mul(p),_,v;return s.colorNode?(v=this.getLightCoord(e),_=s.colorNode(v)):s.map&&(v=this.getLightCoord(e),_=Fn(s.map,v.xy).onRenderUpdate(()=>s.map)),_&&(g=v.mul(2).sub(1).abs().lessThan(1).all().select(g.mul(_),g)),{lightColor:g,lightDirection:u}}}class iX extends FT{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const n=this.light.iesMap;let r=null;if(n&&n.isTexture===!0){const s=t.acos().mul(1/Math.PI);r=Fn(n,rt(s,0),0).r}else r=super.getSpotAttenuation(t);return r}}class rX extends Hu{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new G);this.lightProbe=_s(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=A7(lf,this.lightProbe);e.context.irradiance.addAssign(t)}}const sX=Se(([i,e])=>{const t=i.abs().sub(e);return xo(Xi(t,0)).add(Gh(Xi(t.x,t.y),0))});class aX extends FT{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let n=1;t.map!==null&&(n=t.map.width/t.map.height),t.shadow.aspect=n}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=ye(0),n=this.penumbraCosNode,r=OT(this.light).mul(e.context.positionWorld||Vh);return wn(r.w.greaterThan(0),()=>{const s=r.xyz.div(r.w),o=sX(s.xy.sub(rt(.5)),rt(.5)),u=Sa(-1,Nr(1,xD(n)).sub(1));t.assign(MT(o.mul(-2).mul(u)))}),t}}const Jx=new Wt,jg=new Wt;let Md=null;class oX extends Hu{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=yt(new G).setGroup(_t),this.halfWidth=yt(new G).setGroup(_t),this.updateType=Dt.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;jg.identity(),Jx.copy(t.matrixWorld),Jx.premultiply(n),jg.extractRotation(Jx),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(jg),this.halfHeight.value.applyMatrix4(jg)}setupDirectRectArea(e){let t,n;e.isAvailable("float32Filterable")?(t=Fn(Md.LTC_FLOAT_1),n=Fn(Md.LTC_FLOAT_2)):(t=Fn(Md.LTC_HALF_1),n=Fn(Md.LTC_HALF_2));const{colorNode:r,light:s}=this,o=U3(s);return{lightColor:r,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){Md=e}}class V3{parseFunction(){Ne("Abstract function.")}}class IT{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){Ne("Abstract function.")}}IT.isNodeFunction=!0;const lX=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,uX=/[a-z_0-9]+/ig,IC="#pragma main",cX=i=>{i=i.trim();const e=i.indexOf(IC),t=e!==-1?i.slice(e+IC.length):i,n=t.match(lX);if(n!==null&&n.length===5){const r=n[4],s=[];let o=null;for(;(o=uX.exec(r))!==null;)s.push(o);const u=[];let c=0;for(;c<s.length;){const v=s[c][0]==="const";v===!0&&c++;let S=s[c][0];S==="in"||S==="out"||S==="inout"?c++:S="";const b=s[c++][0];let x=Number.parseInt(s[c][0]);Number.isNaN(x)===!1?c++:x=null;const M=s[c++][0];u.push(new BT(b,M,x,S,v))}const h=t.substring(n[0].length),d=n[3]!==void 0?n[3]:"",p=n[2],g=n[1]!==void 0?n[1]:"",_=e!==-1?i.slice(0,e):"";return{type:p,inputs:u,name:d,precision:g,inputsCode:r,blockCode:h,headerCode:_}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class hX extends IT{constructor(e){const{type:t,inputs:n,name:r,precision:s,inputsCode:o,blockCode:u,headerCode:c}=cX(e);super(t,n,r,s),this.inputsCode=o,this.blockCode=u,this.headerCode=c}getCode(e=this.name){let t;const n=this.blockCode;if(n!==""){const{type:r,inputsCode:s,headerCode:o,precision:u}=this;let c=`${r} ${e} ( ${s.trim()} )`;u!==""&&(c=`${u} ${c}`),t=o+c+n}else t="";return t}}class fX extends V3{parseFunction(e){return new hX(e)}}const zC=new WeakMap,ps=[],rl=[];class dX extends Cl{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new FC,this.nodeBuilderCache=new Map,this.callHashCache=new Al,this.groupsData=new Al,this.cacheLib={}}updateGroup(e){const t=e.groupNode,n=t.name;if(n===gD.name)return!0;if(n===_t.name){const s=this.get(e),o=this.nodeFrame.renderId;return s.renderId!==o?(s.renderId=o,!0):!1}if(n===DH.name){const s=this.get(e),o=this.nodeFrame.frameId;return s.frameId!==o?(s.frameId=o,!0):!1}ps[0]=t,ps[1]=e;let r=this.groupsData.get(ps);return r===void 0&&this.groupsData.set(ps,r={}),ps[0]=null,ps[1]=null,r.version!==t.version?(r.version=t.version,!0):!1}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){const t=this.get(e);let n=t.nodeBuilderState;if(n===void 0){const{nodeBuilderCache:r}=this,s=this.getForRenderCacheKey(e);if(n=r.get(s),n===void 0){const o=c=>{const h=this.backend.createNodeBuilder(e.object,this.renderer);return h.scene=e.scene,h.material=c,h.camera=e.camera,h.context.material=c,h.lightsNode=e.lightsNode,h.environmentNode=this.getEnvironmentNode(e.scene),h.fogNode=this.getFogNode(e.scene),h.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&h.enableMultiview(),h};let u=o(e.material);try{u.build()}catch(c){u=o(new ui),u.build();let h=c.stackTrace;!h&&c.stack&&(h=new rr(c.stack)),Pe("TSL: "+c,h)}n=this._createNodeBuilderState(u),r.set(s,n)}n.usedTimes++,t.nodeBuilderState=n}return n}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){const t=this.get(e);let n=t.nodeBuilderState;if(n===void 0){const r=this.backend.createNodeBuilder(e,this.renderer);r.build(),n=this._createNodeBuilderState(r),t.nodeBuilderState=n}return n}_createNodeBuilderState(e){return new C7(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){ps[0]=e,ps[1]=t;const n=this.renderer.info.calls,r=this.callHashCache.get(ps)||{};if(r.callId!==n){const s=this.getEnvironmentNode(e),o=this.getFogNode(e);t&&rl.push(t.getCacheKey(!0)),s&&rl.push(s.getCacheKey()),o&&rl.push(o.getCacheKey()),rl.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),rl.push(this.renderer.shadowMap.enabled?1:0),rl.push(this.renderer.shadowMap.type),r.callId=n,r.cacheKey=wp(rl),this.callHashCache.set(ps,r),rl.length=0}return ps[0]=null,ps[1]=null,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),n=e.background;if(n){const r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){const s=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===ih||n.mapping===rh||n.mapping===Mu){if(e.backgroundBlurriness>0||n.mapping===Mu)return T3(n);{let o;return n.isCubeTexture===!0?o=Lr(n):o=Fn(n),p3(o)}}else{if(n.isTexture===!0)return Fn(n,bu.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&Pe("WebGPUNodes: Unsupported background configuration.",n)}},r);t.backgroundNode=s,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let o=s.get(t);return(o===void 0||r)&&(o=n(),s.set(t,o)),o}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const r=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const s=jn("color","color",n).setGroup(_t),o=jn("density","float",n).setGroup(_t);return LC(s,Vq(o))}else if(n.isFog){const s=jn("color","color",n).setGroup(_t),o=jn("near","float",n).setGroup(_t),u=jn("far","float",n).setGroup(_t);return LC(s,Gq(o,u))}else Pe("Renderer: Unsupported fog configuration.",n)});t.fogNode=r,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const r=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return Lr(n);if(n.isTexture===!0)return Fn(n);Pe("Nodes: Unsupported environment configuration.",n)});t.environmentNode=r,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,s=null){const o=this.nodeFrame;return o.renderer=e,o.scene=t,o.object=n,o.camera=r,o.material=s,o}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return zC.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=e.isArrayTexture?Rq(e,ve(bu,af("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Fn(e,bu).renderOutput(t.toneMapping,t.currentColorSpace);return zC.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const r of n.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const r of n.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new FC,this.nodeBuilderCache=new Map,this.cacheLib={}}}const eb=new zs;class L_{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Nt,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const r=e.length;for(let s=0;s<r;s++){eb.copy(e[s]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const o=t[n+s],u=eb.normal;o.x=-u.x,o.y=-u.y,o.z=-u.z,o.w=eb.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix=t.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let n=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);const r=t.clippingPlanes,s=r.length;let o,u;if(this.clipIntersection?(o=this.intersectionPlanes,u=e.intersectionPlanes.length):(o=this.unionPlanes,u=e.unionPlanes.length),o.length!==u+s){o.length=u+s;for(let c=0;c<s;c++)o[u+c]=new Pt;n=!0}this.projectPlanes(r,o,u),n&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return t===void 0&&(t=new L_(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class pX{constructor(e,t){this.bundleGroup=e,this.camera=t}}const Xc=[];class mX{constructor(){this.bundles=new Al}get(e,t){const n=this.bundles;Xc[0]=e,Xc[1]=t;let r=n.get(Xc);return r===void 0&&(r=new pX(e,t),n.set(Xc,r)),Xc[0]=null,Xc[1]=null,r}dispose(){this.bundles=new Al}}class H3{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(const r in e)t[r]=e[r]}return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){Ne(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){Ne(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);n.set(t,e)}}const gX=new B3,kC=new WeakMap;class _X{createNode(e=[]){return new B3().setLights(e)}getNode(e){if(e.isQuadMesh)return gX;let t=kC.get(e);return t===void 0&&(t=this.createNode(),kC.set(e,t)),t}}class Pd extends Rl{constructor(e=1,t=1,n={}){super(e,t,n),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}}const GC=new G,VC=new G;class vX extends Aa{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new Pi,this._cameraL.viewport=new Pt,this._cameraR=new Pi,this._cameraR.viewport=new Pt,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new u2,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding=typeof XRWebGLBinding<"u",this._frameBufferTargets=null,this._createXRLayer=MX.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new Ie,this._onSessionEvent=bX.bind(this),this._onSessionEnd=SX.bind(this),this._onInputSourcesChange=TX.bind(this),this._onAnimationFrame=EX.bind(this),this._referenceSpace=null,this._referenceSpaceType="local-floor",this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){if(!(this._glProjLayer===null&&this._glBaseLayer===null))return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&Ne("XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&Ne("XRManager: Cannot change reference space type while presenting.")}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getBinding(){return this._glBinding===null&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,n,r,s,o,u,c={}){const h=new Ep(e,t),d=new Pd(s,o,{format:si,type:Gn,depthTexture:new br(s,o,c.stencil?is:bn,void 0,void 0,void 0,void 0,void 0,void 0,c.stencil?_r:Wi),stencilBuffer:c.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});d._autoAllocateDepthBuffer=!0;const p=new ca({color:16777215,side:xr});p.map=d.texture,p.map.offset.y=1,p.map.repeat.y=-1;const g=new xi(h,p);g.position.copy(n),g.quaternion.copy(r);const _={type:"quad",width:e,height:t,translation:n,quaternion:r,pixelwidth:s,pixelheight:o,plane:g,material:p,rendercall:u,renderTarget:d};if(this._layers.push(_),this._session!==null){_.plane.material=new ca({color:16777215,side:xr}),_.plane.material.blending=gu,_.plane.material.blendEquation=nr,_.plane.material.blendSrc=ro,_.plane.material.blendDst=ro,_.xrlayer=this._createXRLayer(_);const v=this._session.renderState.layers;v.unshift(_.xrlayer),this._session.updateRenderState({layers:v})}else d.isXRRenderTarget=!1;return g}createCylinderLayer(e,t,n,r,s,o,u,c,h={}){const d=new Mp(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),p=new Pd(o,u,{format:si,type:Gn,depthTexture:new br(o,u,h.stencil?is:bn,void 0,void 0,void 0,void 0,void 0,void 0,h.stencil?_r:Wi),stencilBuffer:h.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});p._autoAllocateDepthBuffer=!0;const g=new ca({color:16777215,side:Tn});g.map=p.texture,g.map.offset.y=1,g.map.repeat.y=-1;const _=new xi(d,g);_.position.copy(r),_.quaternion.copy(s);const v={type:"cylinder",radius:e,centralAngle:t,aspectratio:n,translation:r,quaternion:s,pixelwidth:o,pixelheight:u,plane:_,material:g,rendercall:c,renderTarget:p};if(this._layers.push(v),this._session!==null){v.plane.material=new ca({color:16777215,side:Tn}),v.plane.material.blending=gu,v.plane.material.blendEquation=nr,v.plane.material.blendSrc=ro,v.plane.material.blendDst=ro,v.xrlayer=this._createXRLayer(v);const S=this._session.renderState.layers;S.unshift(v.xrlayer),this._session.updateRenderState({layers:S})}else p.isXRRenderTarget=!1;return _}renderLayers(){const e=new G,t=new Ss,n=this._renderer,r=this.isPresenting,s=n.getOutputRenderTarget(),o=n._frameBufferTarget;this.isPresenting=!1;const u=new Ie;n.getSize(u);const c=n._quad;for(const h of this._layers)if(h.renderTarget.isXRRenderTarget=this._session!==null,h.renderTarget._hasExternalTextures=h.renderTarget.isXRRenderTarget,h.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){h.xrlayer.transform=new XRRigidTransform(h.plane.getWorldPosition(e),h.plane.getWorldQuaternion(t));const d=this._glBinding.getSubImage(h.xrlayer,this._xrFrame);n.backend.setXRRenderTargetTextures(h.renderTarget,d.colorTexture,void 0),n._setXRLayerSize(h.renderTarget.width,h.renderTarget.height),n.setOutputRenderTarget(h.renderTarget),n.setRenderTarget(null),n._frameBufferTarget=null,this._frameBufferTargets||(this._frameBufferTargets=new WeakMap);const{frameBufferTarget:p,quad:g}=this._frameBufferTargets.get(h.renderTarget)||{frameBufferTarget:null,quad:null};p?(n._frameBufferTarget=p,n._quad=g):(n._quad=new PT(new ui),this._frameBufferTargets.set(h.renderTarget,{frameBufferTarget:n._getFrameBufferTarget(),quad:n._quad})),h.rendercall(),n._frameBufferTarget=null}else n.setRenderTarget(h.renderTarget),h.rendercall();n.setRenderTarget(null),n.setOutputRenderTarget(s),n._frameBufferTarget=o,n._setXRLayerSize(u.x,u.y),n._quad=c,this.isPresenting=r}getSession(){return this._session}async setSession(e){const t=this._renderer,n=t.backend;this._gl=t.getContext();const r=this._gl,s=r.getContextAttributes();if(this._session=e,e!==null){if(n.isWebGPUBackend===!0)throw new Error('THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.');if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),await n.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._supportsLayers===!0){let o=null,u=null,c=null;t.depth&&(c=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,o=t.stencil?_r:Wi,u=t.stencil?is:bn);const h={colorFormat:r.RGBA8,depthFormat:c,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(h.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const d=this._glBinding.createProjectionLayer(h),p=[d];this._glProjLayer=d,t.setPixelRatio(1),t._setXRLayerSize(d.textureWidth,d.textureHeight);const g=this._useMultiview?2:1,_=new br(d.textureWidth,d.textureHeight,u,void 0,void 0,void 0,void 0,void 0,void 0,o,g);if(this._xrRenderTarget=new Pd(d.textureWidth,d.textureHeight,{format:si,type:Gn,colorSpace:t.outputColorSpace,depthTexture:_,stencilBuffer:t.stencil,samples:s.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const v of this._layers)v.plane.material=new ca({color:16777215,side:v.type==="cylinder"?Tn:xr}),v.plane.material.blending=gu,v.plane.material.blendEquation=nr,v.plane.material.blendSrc=ro,v.plane.material.blendDst=ro,v.xrlayer=this._createXRLayer(v),p.unshift(v.xrlayer);e.updateRenderState({layers:p})}else{const o={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},u=new XRWebGLLayer(e,r,o);this._glBaseLayer=u,e.updateRenderState({baseLayer:u}),t.setPixelRatio(1),t._setXRLayerSize(u.framebufferWidth,u.framebufferHeight),this._xrRenderTarget=new Pd(u.framebufferWidth,u.framebufferHeight,{format:si,type:Gn,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(t===null)return;const n=e.near,r=e.far,s=this._cameraXR,o=this._cameraL,u=this._cameraR;s.near=u.near=o.near=n,s.far=u.far=o.far=r,s.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==s.near||this._currentDepthFar!==s.far)&&(t.updateRenderState({depthNear:s.near,depthFar:s.far}),this._currentDepthNear=s.near,this._currentDepthFar=s.far),s.layers.mask=e.layers.mask|6,o.layers.mask=s.layers.mask&-5,u.layers.mask=s.layers.mask&-3;const c=e.parent,h=s.cameras;HC(s,c);for(let d=0;d<h.length;d++)HC(h[d],c);h.length===2?yX(s,o,u):s.projectionMatrix.copy(o.projectionMatrix),xX(e,s,c)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new i_,this._controllers[e]=t),t}}function yX(i,e,t){GC.setFromMatrixPosition(e.matrixWorld),VC.setFromMatrixPosition(t.matrixWorld);const n=GC.distanceTo(VC),r=e.projectionMatrix.elements,s=t.projectionMatrix.elements,o=r[14]/(r[10]-1),u=r[14]/(r[10]+1),c=(r[9]+1)/r[5],h=(r[9]-1)/r[5],d=(r[8]-1)/r[0],p=(s[8]+1)/s[0],g=o*d,_=o*p,v=n/(-d+p),S=v*-d;if(e.matrixWorld.decompose(i.position,i.quaternion,i.scale),i.translateX(S),i.translateZ(v),i.matrixWorld.compose(i.position,i.quaternion,i.scale),i.matrixWorldInverse.copy(i.matrixWorld).invert(),r[10]===-1)i.projectionMatrix.copy(e.projectionMatrix),i.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const b=o+v,x=u+v,M=g-S,E=_+(n-S),w=c*u/x*b,D=h*u/x*b;i.projectionMatrix.makePerspective(M,E,w,D,b,x),i.projectionMatrixInverse.copy(i.projectionMatrix).invert()}}function HC(i,e){e===null?i.matrixWorld.copy(i.matrix):i.matrixWorld.multiplyMatrices(e.matrixWorld,i.matrix),i.matrixWorldInverse.copy(i.matrixWorld).invert()}function xX(i,e,t){t===null?i.matrix.copy(e.matrixWorld):(i.matrix.copy(t.matrixWorld),i.matrix.invert(),i.matrix.multiply(e.matrixWorld)),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0),i.projectionMatrix.copy(e.projectionMatrix),i.projectionMatrixInverse.copy(e.projectionMatrixInverse),i.isPerspectiveCamera&&(i.fov=Nu*2*Math.atan(1/i.projectionMatrix.elements[5]),i.zoom=1)}function bX(i){const e=this._controllerInputSources.indexOf(i.inputSource);if(e===-1)return;const t=this._controllers[e];if(t!==void 0){const n=this.getReferenceSpace();t.update(i.inputSource,i.frame,n),t.dispatchEvent({type:i.type,data:i.inputSource})}}function SX(){const i=this._session,e=this._renderer;i.removeEventListener("select",this._onSessionEvent),i.removeEventListener("selectstart",this._onSessionEvent),i.removeEventListener("selectend",this._onSessionEvent),i.removeEventListener("squeeze",this._onSessionEvent),i.removeEventListener("squeezestart",this._onSessionEvent),i.removeEventListener("squeezeend",this._onSessionEvent),i.removeEventListener("end",this._onSessionEnd),i.removeEventListener("inputsourceschange",this._onInputSourcesChange);for(let t=0;t<this._controllers.length;t++){const n=this._controllerInputSources[t];n!==null&&(this._controllerInputSources[t]=null,this._controllers[t].disconnect(n))}if(this._currentDepthNear=null,this._currentDepthFar=null,e._resetXRState(),this._session=null,this._xrRenderTarget=null,this._glBinding=null,this._glBaseLayer=null,this._glProjLayer=null,this._sessionUsesLayers===!0)for(const t of this._layers)t.renderTarget=new Pd(t.pixelwidth,t.pixelheight,{format:si,type:Gn,depthTexture:new br(t.pixelwidth,t.pixelheight,t.stencilBuffer?is:bn,void 0,void 0,void 0,void 0,void 0,void 0,t.stencilBuffer?_r:Wi),stencilBuffer:t.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),t.renderTarget.isXRRenderTarget=!1,t.plane.material=t.material,t.material.map=t.renderTarget.texture,t.material.map.offset.y=1,t.material.map.repeat.y=-1,delete t.xrlayer;this.isPresenting=!1,this._useMultiview=!1,e._animation.stop(),e._animation.setAnimationLoop(this._currentAnimationLoop),e._animation.setContext(this._currentAnimationContext),e._animation.start(),e.setPixelRatio(this._currentPixelRatio),e.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:"sessionend"})}function TX(i){const e=this._controllers,t=this._controllerInputSources;for(let n=0;n<i.removed.length;n++){const r=i.removed[n],s=t.indexOf(r);s>=0&&(t[s]=null,e[s].disconnect(r))}for(let n=0;n<i.added.length;n++){const r=i.added[n];let s=t.indexOf(r);if(s===-1){for(let u=0;u<e.length;u++)if(u>=t.length){t.push(r),s=u;break}else if(t[u]===null){t[u]=r,s=u;break}if(s===-1)break}const o=e[s];o&&o.connect(r)}}function MX(i){return i.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(i.translation,i.quaternion),width:i.width/2,height:i.height/2,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(i.translation,i.quaternion),radius:i.radius,centralAngle:i.centralAngle,aspectRatio:i.aspectRatio,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1})}function EX(i,e){if(e===void 0)return;const t=this._cameraXR,n=this._renderer,r=n.backend,s=this._glBaseLayer,o=this.getReferenceSpace(),u=e.getViewerPose(o);if(this._xrFrame=e,u!==null){const c=u.views;this._glBaseLayer!==null&&r.setXRTarget(s.framebuffer);let h=!1;c.length!==t.cameras.length&&(t.cameras.length=0,h=!0);for(let d=0;d<c.length;d++){const p=c[d];let g;if(this._supportsLayers===!0){const v=this._glBinding.getViewSubImage(this._glProjLayer,p);g=v.viewport,d===0&&r.setXRRenderTargetTextures(this._xrRenderTarget,v.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:v.depthStencilTexture)}else g=s.getViewport(p);let _=this._cameras[d];_===void 0&&(_=new Pi,_.layers.enable(d),_.viewport=new Pt,this._cameras[d]=_),_.matrix.fromArray(p.transform.matrix),_.matrix.decompose(_.position,_.quaternion,_.scale),_.projectionMatrix.fromArray(p.projectionMatrix),_.projectionMatrixInverse.copy(_.projectionMatrix).invert(),_.viewport.set(g.x,g.y,g.width,g.height),d===0&&(t.matrix.copy(_.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale)),h===!0&&t.cameras.push(_)}n.setOutputRenderTarget(this._xrRenderTarget)}for(let c=0;c<this._controllers.length;c++){const h=this._controllerInputSources[c],d=this._controllers[c];h!==null&&d!==void 0&&d.update(h,e,o)}this._currentAnimationLoop&&this._currentAnimationLoop(i,e),e.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:e}),this._xrFrame=null}class AX extends Aa{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new Pt(0,0,this._width,this._height),this._scissor=new Pt(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new KN,this.depthTexture=new br}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._dispatchResize())}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._dispatchResize())}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){const s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,s=0,o=1){const u=this._viewport;e.isVector4?u.copy(e):u.set(e,t,n,r),u.minDepth=s,u.maxDepth=o}_dispatchResize(){this.dispatchEvent({type:"resize"})}dispose(){this.dispatchEvent({type:"dispose"})}}const jC=new XS,Yc=new Ie,tb=new Pt,nb=new Tp,ib=new JS,Wg=new Wt,to=new Pt,wX={[xr]:Tn,[Tn]:xr,[Ui]:Ui};class RX{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:n=!1,reversedDepthBuffer:r=!1,alpha:s=!0,depth:o=!0,stencil:u=!1,antialias:c=!1,samples:h=0,getFallback:d=null,outputBufferType:p=Qn,multiview:g=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=s,this.logarithmicDepthBuffer=n,this.reversedDepthBuffer=r,this.outputColorSpace=dr,this.toneMapping=ji,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=o,this.stencil=u,this.info=new iq,this.contextNode=Gu(),this.library=new H3,this.lighting=new _X,this._samples=h||c===!0?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new AX(e.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new FD,this._inspector.setRenderer(this),this._getFallback=d,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new PT(new ui),this._quad.name="Output Color Transform",this._quad.material.name="outputColorTransform",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const _=this.alpha===!0?0:1;this._clearColor=new LT(0,0,0,_),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._outputBufferType=p,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._callDepth=-1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,transmitted:!1,type:nh},this.xr=new vX(this,g),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(v,S,b)=>{await this.compileAsync(v,S);const x=this._renderLists.get(v,S),M=this._renderContexts.get(this._renderTarget,this._mrt),E=v.overrideMaterial||b.material,w=this._objects.get(b,E,v,S,x.lightsNode,M,M.clippingContext),{fragmentShader:D,vertexShader:C}=w.getNodeBuilderState();return{fragmentShader:D,vertexShader:C}}}}async init(){return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=n=this._getFallback(r),await n.init(this)}catch(s){t(s);return}else{t(r);return}}this._nodes=new dX(this,n),this._animation=new X$(this,this._nodes,this.info),this._attributes=new tq(n),this._background=new w7(this,this._nodes),this._geometries=new nq(this._attributes,this.info),this._textures=new gq(this,n,this.info),this._pipelines=new oq(n,this._nodes),this._bindings=new lq(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new Q$(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new hq(this.lighting),this._bundles=new mX,this._renderContexts=new pq(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)}),this._initPromise)}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,s=r.renderId,o=this._currentRenderContext,u=this._currentRenderObjectFunction,c=this._handleObjectFunction,h=this._compilationPromises,d=e.isScene===!0?e:jC;n===null&&(n=e);const p=this._renderTarget,g=this._renderContexts.get(p,this._mrt),_=this._activeMipmapLevel,v=[];this._currentRenderContext=g,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=v,r.renderId++,r.update(),g.depth=this.depth,g.stencil=this.stencil,g.clippingContext||(g.clippingContext=new L_),g.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,p);const S=this._renderLists.get(e,t);if(S.begin(),this._projectObject(e,t,0,S,g.clippingContext),n!==e&&n.traverseVisible(function(w){w.isLight&&w.layers.test(t.layers)&&S.pushLight(w)}),S.finish(),p!==null){this._textures.updateRenderTarget(p,_);const w=this._textures.get(p);g.textures=w.textures,g.depthTexture=w.depthTexture}else g.textures=null,g.depthTexture=null;n!==e?this._background.update(n,S,g):this._background.update(d,S,g);const b=S.opaque,x=S.transparent,M=S.transparentDoublePass,E=S.lightsNode;this.opaque===!0&&b.length>0&&this._renderObjects(b,t,d,E),this.transparent===!0&&x.length>0&&this._renderTransparents(x,M,t,d,E),r.renderId=s,this._currentRenderContext=o,this._currentRenderObjectFunction=u,this._handleObjectFunction=c,this._compilationPromises=h,await Promise.all(v)}async renderAsync(e,t){xn('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){Pe("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;e===!0?(t.modelViewMatrix=HR,t.modelNormalViewMatrix=jR):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===HR&&e.modelNormalViewMatrix===jR}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return xn('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:

Message: ${e.message}`;e.reason&&(t+=`
Reason: ${e.reason}`),Pe(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:s,renderList:o}=e,u=this._currentRenderContext,c=this._bundles.get(r,s),h=this.backend.get(c);h.renderContexts===void 0&&(h.renderContexts=new Set);const d=r.version!==h.version,p=h.renderContexts.has(u)===!1||d;if(h.renderContexts.add(u),p){this.backend.beginBundle(u),(h.renderObjects===void 0||d)&&(h.renderObjects=[]),this._currentRenderBundle=c;const{transparentDoublePass:g,transparent:_,opaque:v}=o;this.opaque===!0&&v.length>0&&this._renderObjects(v,s,t,n),this.transparent===!0&&_.length>0&&this._renderTransparents(_,g,s,t,n),this._currentRenderBundle=null,this.backend.finishBundle(u,c),h.version=r.version}else{const{renderObjects:g}=h;for(let _=0,v=g.length;_<v;_++){const S=g[_];this._nodes.needsRefresh(S)&&(this._nodes.updateBefore(S),this._nodes.updateForRender(S),this._bindings.updateForRender(S),this._nodes.updateAfter(S))}}this.backend.addBundle(u,c)}render(e,t){if(this._initialized===!1)throw new Error('Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.');this._renderScene(e,t)}get initialized(){return this._initialized}_getFrameBufferTarget(){const{currentToneMapping:e,currentColorSpace:t}=this,n=e!==ji,r=t!==xt.workingColorSpace;if(n===!1&&r===!1)return null;const{width:s,height:o}=this.getDrawingBufferSize(Yc),{depth:u,stencil:c}=this;let h=this._frameBufferTarget;h===null&&(h=new Rl(s,o,{depthBuffer:u,stencilBuffer:c,type:this._outputBufferType,format:si,colorSpace:xt.workingColorSpace,generateMipmaps:!1,minFilter:Rn,magFilter:Rn,samples:this.samples}),h.isPostProcessingRenderTarget=!0,this._frameBufferTarget=h);const d=this.getOutputRenderTarget();h.depthBuffer=u,h.stencilBuffer=c,d!==null?h.setSize(d.width,d.height,d.depth):h.setSize(s,o,1);const p=this._canvasTarget;return h.viewport.copy(p._viewport),h.scissor.copy(p._scissor),h.viewport.multiplyScalar(p._pixelRatio),h.scissor.multiplyScalar(p._pixelRatio),h.scissorTest=p._scissorTest,h.multiview=d!==null?d.multiview:!1,h.resolveDepthBuffer=d!==null?d.resolveDepthBuffer:!0,h._autoAllocateDepthBuffer=d!==null?d._autoAllocateDepthBuffer:!1,h}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;const r=n?this._getFrameBufferTarget():null,s=this._nodes.nodeFrame,o=s.renderId,u=this._currentRenderContext,c=this._currentRenderObjectFunction,h=this._handleObjectFunction;this._callDepth++;const d=e.isScene===!0?e:jC,p=this._renderTarget||this._outputRenderTarget,g=this._activeCubeFace,_=this._activeMipmapLevel;let v;r!==null?(v=r,this.setRenderTarget(v)):v=p;const S=this._renderContexts.get(v,this._mrt,this._callDepth);this._currentRenderContext=S,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,s.renderId=this.info.calls,this.backend.updateTimeStampUID(S),this.inspector.beginRender(this.backend.getTimestampUID(S),e,t,v);const b=this.xr;if(b.isPresenting===!1){let te=!1;if(this.reversedDepthBuffer===!0&&t.reversedDepth!==!0){if(t._reversedDepth=!0,t.isArrayCamera)for(const I of t.cameras)I._reversedDepth=!0;te=!0}const Z=this.coordinateSystem;if(t.coordinateSystem!==Z){if(t.coordinateSystem=Z,t.isArrayCamera)for(const I of t.cameras)I.coordinateSystem=Z;te=!0}if(te===!0&&(t.updateProjectionMatrix(),t.isArrayCamera))for(const I of t.cameras)I.updateProjectionMatrix()}e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),b.enabled===!0&&b.isPresenting===!0&&(b.cameraAutoUpdate===!0&&b.updateCamera(t),t=b.getCamera());const x=this._canvasTarget;let M=x._viewport,E=x._scissor,w=x._pixelRatio;v!==null&&(M=v.viewport,E=v.scissor,w=1),this.getDrawingBufferSize(Yc),tb.set(0,0,Yc.width,Yc.height);const D=M.minDepth===void 0?0:M.minDepth,C=M.maxDepth===void 0?1:M.maxDepth;S.viewportValue.copy(M).multiplyScalar(w).floor(),S.viewportValue.width>>=_,S.viewportValue.height>>=_,S.viewportValue.minDepth=D,S.viewportValue.maxDepth=C,S.viewport=S.viewportValue.equals(tb)===!1,S.scissorValue.copy(E).multiplyScalar(w).floor(),S.scissor=x._scissorTest&&S.scissorValue.equals(tb)===!1,S.scissorValue.width>>=_,S.scissorValue.height>>=_,S.clippingContext||(S.clippingContext=new L_),S.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,v);const N=t.isArrayCamera?ib:nb;t.isArrayCamera||(Wg.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),N.setFromProjectionMatrix(Wg,t.coordinateSystem,t.reversedDepth));const A=this._renderLists.get(e,t);if(A.begin(),this._projectObject(e,t,0,A,S.clippingContext),A.finish(),this.sortObjects===!0&&A.sort(this._opaqueSort,this._transparentSort),v!==null){this._textures.updateRenderTarget(v,_);const te=this._textures.get(v);S.textures=te.textures,S.depthTexture=te.depthTexture,S.width=te.width,S.height=te.height,S.renderTarget=v,S.depth=v.depthBuffer,S.stencil=v.stencilBuffer}else S.textures=null,S.depthTexture=null,S.width=Yc.width,S.height=Yc.height,S.depth=this.depth,S.stencil=this.stencil;S.width>>=_,S.height>>=_,S.activeCubeFace=g,S.activeMipmapLevel=_,S.occlusionQueryCount=A.occlusionQueryCount,S.scissorValue.max(to.set(0,0,0,0)),S.scissorValue.x+S.scissorValue.width>S.width&&(S.scissorValue.width=Math.max(S.width-S.scissorValue.x,0)),S.scissorValue.y+S.scissorValue.height>S.height&&(S.scissorValue.height=Math.max(S.height-S.scissorValue.y,0)),this._background.update(d,A,S),S.camera=t,this.backend.beginRender(S);const{bundles:L,lightsNode:j,transparentDoublePass:z,transparent:H,opaque:K}=A;return L.length>0&&this._renderBundles(L,d,j),this.opaque===!0&&K.length>0&&this._renderObjects(K,t,d,j),this.transparent===!0&&H.length>0&&this._renderTransparents(H,z,t,d,j),this.backend.finishRender(S),s.renderId=o,this._currentRenderContext=u,this._currentRenderObjectFunction=c,this._handleObjectFunction=h,this._callDepth--,r!==null&&(this.setRenderTarget(p,g,_),this._renderOutput(v)),d.onAfterRender(this,e,t,v),this.inspector.finishRender(this.backend.getTimestampUID(S)),S}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const n=this.autoClear,r=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=n,this.xr.enabled=r}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,n){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,n)}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,n)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,n,r){this._canvasTarget.setScissor(e,t,n,r)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,n,r,s=0,o=1){this._canvasTarget.setViewport(e,t,n,r,s,o)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)throw new Error('Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.');const r=this._renderTarget||this._getFrameBufferTarget();let s=null;if(r!==null){this._textures.updateRenderTarget(r);const o=this._textures.get(r);s=this._renderContexts.get(r),s.textures=o.textures,s.depthTexture=o.depthTexture,s.width=o.width,s.height=o.height,s.renderTarget=r,s.depth=r.depthBuffer,s.stencil=r.stencilBuffer;const u=this.backend.getClearColor();s.clearColorValue.r=u.r,s.clearColorValue.g=u.g,s.clearColorValue.b=u.b,s.clearColorValue.a=u.a,s.clearDepthValue=this.getClearDepth(),s.clearStencilValue=this.getClearStencil(),s.activeCubeFace=this.getActiveCubeFace(),s.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,n,s),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){xn('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,n)}async clearColorAsync(){xn('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){xn('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){xn('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=this.currentToneMapping!==ji,t=this.currentColorSpace!==xt.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget!==null?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:ji}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:xt.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){this._initialized===!0&&(this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this._frameBufferTarget!==null&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return Ne("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const n=this._nodes.nodeFrame,r=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const s=this.backend,o=this._pipelines,u=this._bindings,c=this._nodes,h=Array.isArray(e)?e:[e];if(h[0]===void 0||h[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const d of h){if(o.has(d)===!1){const _=()=>{d.removeEventListener("dispose",_),o.delete(d),u.deleteForCompute(d),c.delete(d)};d.addEventListener("dispose",_);const v=d.onInitFunction;v!==null&&v.call(d,{renderer:this})}c.updateForCompute(d),u.updateForCompute(d);const p=u.getForCompute(d),g=o.getForCompute(d,p);s.compute(e,d,p,g,t)}s.finishCompute(e),n.renderId=r,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return xn('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw new Error('Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){xn('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw new Error('Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw new Error('Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before before using this method.');this._textures.updateRenderTarget(e);const t=this._textures.get(e),n=this._renderContexts.get(e);n.textures=t.textures,n.depthTexture=t.depthTexture,n.width=t.width,n.height=t.height,n.renderTarget=e,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,this.backend.initRenderTarget(n)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=to.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=to.copy(t).floor();else{Pe("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=to.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n!==null?r=n.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,n=null,r=null,s=0,o=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,s,o),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,n,r,s,o=0,u=0){return this.backend.copyTextureToBuffer(e.textures[o],t,n,r,s,u)}_projectObject(e,t,n,r,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){const c=t.isArrayCamera?ib:nb;if(!e.frustumCulled||c.intersectsSprite(e,t)){this.sortObjects===!0&&to.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Wg);const{geometry:h,material:d}=e;d.visible&&r.push(e,h,d,n,to.z,null,s)}}else if(e.isLineLoop)Pe("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const c=t.isArrayCamera?ib:nb;if(!e.frustumCulled||c.intersectsObject(e,t)){const{geometry:h,material:d}=e;if(this.sortObjects===!0&&(h.boundingSphere===null&&h.computeBoundingSphere(),to.copy(h.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(Wg)),Array.isArray(d)){const p=h.groups;for(let g=0,_=p.length;g<_;g++){const v=p[g],S=d[v.materialIndex];S&&S.visible&&r.push(e,h,S,n,to.z,v,s)}}else d.visible&&r.push(e,h,d,n,to.z,null,s)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){const c=r;r=this._renderLists.get(e,t),r.begin(),c.pushBundle({bundleGroup:e,camera:t,renderList:r}),r.finish()}const u=e.children;for(let c=0,h=u.length;c<h;c++)this._projectObject(u[c],t,n,r,s)}_renderBundles(e,t,n){for(const r of e)this._renderBundle(r,t,n)}_renderTransparents(e,t,n,r,s){if(t.length>0){for(const{material:o}of t)o.side=Tn;this._renderObjects(t,n,r,s,"backSide");for(const{material:o}of t)o.side=xr;this._renderObjects(e,n,r,s);for(const{material:o}of t)o.side=Ui}else this._renderObjects(e,n,r,s)}_renderObjects(e,t,n,r,s=null){for(let o=0,u=e.length;o<u;o++){const{object:c,geometry:h,material:d,group:p,clippingContext:g}=e[o];this._currentRenderObjectFunction(c,n,t,h,d,p,r,g,s)}}_getShadowNodes(e){const t=e.version;let n=this._cacheShadowNodes.get(e);if(n===void 0||n.version!==t){const r=e.map!==null,s=e.colorNode&&e.colorNode.isNode,o=e.castShadowNode&&e.castShadowNode.isNode,u=e.maskShadowNode&&e.maskShadowNode.isNode||e.maskNode&&e.maskNode.isNode;let c=null,h=null,d=null;if(r||s||o||u){let p,g;if(o?(p=e.castShadowNode.rgb,g=e.castShadowNode.a,this.shadowMap.transmitted!==!0&&xn("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(p=ve(0),g=ye(1)),r&&(g=g.mul(jn("map","texture",e).a)),s&&(g=g.mul(e.colorNode.a)),h=wt(p,g),u){const _=e.maskShadowNode||e.maskNode;h=Se(([v])=>(_.not().discard(),v))(h)}}e.depthNode&&e.depthNode.isNode&&(d=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?c=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(c=e.positionNode),n={version:t,colorNode:h,depthNode:d,positionNode:c},this._cacheShadowNodes.set(e,n)}return n}renderObject(e,t,n,r,s,o,u,c=null,h=null){let d=!1,p,g,_,v;if(e.onBeforeRender(this,t,n,r,s,o),s.allowOverride===!0&&t.overrideMaterial!==null){const S=t.overrideMaterial;if(d=!0,p=S.isNodeMaterial?S.colorNode:null,g=S.isNodeMaterial?S.depthNode:null,_=S.isNodeMaterial?S.positionNode:null,v=t.overrideMaterial.side,s.positionNode&&s.positionNode.isNode&&(S.positionNode=s.positionNode),S.alphaTest=s.alphaTest,S.alphaMap=s.alphaMap,S.transparent=s.transparent||s.transmission>0||s.transmissionNode&&s.transmissionNode.isNode||s.backdropNode&&s.backdropNode.isNode,S.isShadowPassMaterial){const{colorNode:b,depthNode:x,positionNode:M}=this._getShadowNodes(s);this.shadowMap.type===da?S.side=s.shadowSide!==null?s.shadowSide:s.side:S.side=s.shadowSide!==null?s.shadowSide:wX[s.side],b!==null&&(S.colorNode=b),x!==null&&(S.depthNode=x),M!==null&&(S.positionNode=M)}s=S}s.transparent===!0&&s.side===Ui&&s.forceSinglePass===!1?(s.side=Tn,this._handleObjectFunction(e,s,t,n,u,o,c,"backSide"),s.side=xr,this._handleObjectFunction(e,s,t,n,u,o,c,h),s.side=Ui):this._handleObjectFunction(e,s,t,n,u,o,c,h),d&&(t.overrideMaterial.colorNode=p,t.overrideMaterial.depthNode=g,t.overrideMaterial.positionNode=_,t.overrideMaterial.side=v),e.onAfterRender(this,t,n,r,s,o)}hasCompatibility(e){return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,n,r,s,o,u,c){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,u,c);h.drawRange=e.geometry.drawRange,h.group=o,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(h),h.bundle=this._currentRenderBundle.bundleGroup);const d=this._nodes.needsRefresh(h);d&&(this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h)),this._pipelines.updateForRender(h),this.backend.draw(h,this.info),d&&this._nodes.updateAfter(h)}_createObjectPipeline(e,t,n,r,s,o,u,c){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,u,c);h.drawRange=e.geometry.drawRange,h.group=o,this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h),this._pipelines.getForRender(h,this._compilationPromises),this._nodes.updateAfter(h)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class j3{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function CX(i){return i+(ul-i%ul)%ul}class W3 extends j3{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return CX(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class $3 extends W3{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let NX=0;class q3 extends $3{constructor(e,t){super("UniformBuffer_"+NX++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get buffer(){return this.nodeUniform.value}}class DX extends $3{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map}addUniformUpdateRange(e){const t=e.index;if(this._updateRangeCache.has(t)!==!0){const n=this.updateRanges,r=e.offset,s=e.itemSize,o={start:r,count:s};n.push(o),this._updateRangeCache.set(t,o)}}clearUpdateRanges(){this._updateRangeCache.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let n=0,r=this.uniforms.length;n<r;n++){const s=this.uniforms[n],o=s.boundary,u=s.itemSize*e,c=t%ul,h=c%o,d=c+h;t+=h,d!==0&&ul-d<u&&(t+=ul-d),s.offset=t/e,s.index=n,t+=u}return Math.ceil(t/ul)*ul}update(){let e=!1;for(const t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);Pe("WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1;const n=this.values,r=e.getValue(),s=e.offset,o=e.getType();if(n[s]!==r){const u=this._getBufferForType(o);u[s]=n[s]=r,t=!0,this.addUniformUpdateRange(e)}return t}updateVector2(e){let t=!1;const n=this.values,r=e.getValue(),s=e.offset,o=e.getType();if(n[s+0]!==r.x||n[s+1]!==r.y){const u=this._getBufferForType(o);u[s+0]=n[s+0]=r.x,u[s+1]=n[s+1]=r.y,t=!0,this.addUniformUpdateRange(e)}return t}updateVector3(e){let t=!1;const n=this.values,r=e.getValue(),s=e.offset,o=e.getType();if(n[s+0]!==r.x||n[s+1]!==r.y||n[s+2]!==r.z){const u=this._getBufferForType(o);u[s+0]=n[s+0]=r.x,u[s+1]=n[s+1]=r.y,u[s+2]=n[s+2]=r.z,t=!0,this.addUniformUpdateRange(e)}return t}updateVector4(e){let t=!1;const n=this.values,r=e.getValue(),s=e.offset,o=e.getType();if(n[s+0]!==r.x||n[s+1]!==r.y||n[s+2]!==r.z||n[s+4]!==r.w){const u=this._getBufferForType(o);u[s+0]=n[s+0]=r.x,u[s+1]=n[s+1]=r.y,u[s+2]=n[s+2]=r.z,u[s+3]=n[s+3]=r.w,t=!0,this.addUniformUpdateRange(e)}return t}updateColor(e){let t=!1;const n=this.values,r=e.getValue(),s=e.offset;if(n[s+0]!==r.r||n[s+1]!==r.g||n[s+2]!==r.b){const o=this.buffer;o[s+0]=n[s+0]=r.r,o[s+1]=n[s+1]=r.g,o[s+2]=n[s+2]=r.b,t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix3(e){let t=!1;const n=this.values,r=e.getValue().elements,s=e.offset;if(n[s+0]!==r[0]||n[s+1]!==r[1]||n[s+2]!==r[2]||n[s+4]!==r[3]||n[s+5]!==r[4]||n[s+6]!==r[5]||n[s+8]!==r[6]||n[s+9]!==r[7]||n[s+10]!==r[8]){const o=this.buffer;o[s+0]=n[s+0]=r[0],o[s+1]=n[s+1]=r[1],o[s+2]=n[s+2]=r[2],o[s+4]=n[s+4]=r[3],o[s+5]=n[s+5]=r[4],o[s+6]=n[s+6]=r[5],o[s+8]=n[s+8]=r[6],o[s+9]=n[s+9]=r[7],o[s+10]=n[s+10]=r[8],t=!0,this.addUniformUpdateRange(e)}return t}updateMatrix4(e){let t=!1;const n=this.values,r=e.getValue().elements,s=e.offset;return PX(n,r,s)===!1&&(this.buffer.set(r,s),LX(n,r,s),t=!0,this.addUniformUpdateRange(e)),t}_getBufferForType(e){return e==="int"||e==="ivec2"||e==="ivec3"||e==="ivec4"?new Int32Array(this.buffer.buffer):e==="uint"||e==="uvec2"||e==="uvec3"||e==="uvec4"?new Uint32Array(this.buffer.buffer):this.buffer}}function LX(i,e,t){for(let n=0,r=e.length;n<r;n++)i[t+n]=e[n]}function PX(i,e,t){for(let n=0,r=e.length;n<r;n++)if(i[t+n]!==e[n])return!1;return!0}let UX=0;class X3 extends DX{constructor(e,t){super(e),this.id=UX++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class Y3 extends j3{constructor(e,t){super(e),this._texture=null,this._onTextureDispose=()=>{this.generation=null,this.version=-1},this.texture=t,this.version=t?t.version:-1,this.generation=null,this.samplerKey="",this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture&&this._texture.removeEventListener("dispose",this._onTextureDispose),this._texture=e,this.generation=null,this.version=-1,this._texture&&this._texture.addEventListener("dispose",this._onTextureDispose))}get texture(){return this._texture}update(){const{texture:e,version:t}=this;return t!==e.version?(this.version=e.version,!0):!1}clone(){const e=super.clone();return e._texture=null,e._onTextureDispose=()=>{e.generation=null,e.version=-1},e.texture=this.texture,e}}let OX=0;class BX extends Y3{constructor(e,t){super(e,t),this.id=OX++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}}class d0 extends BX{constructor(e,t,n,r=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class K3 extends d0{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}}class rS extends d0{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}}const WC={bitcast_int_uint:new Di("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),bitcast_uint_int:new Di("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }")},FX={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint",bitcast_uint_int:"tsl_bitcast_uint_to_int",bitcast_int_uint:"tsl_bitcast_int_to_uint",floatpack_snorm_2x16:"packSnorm2x16",floatpack_unorm_2x16:"packUnorm2x16",floatpack_float16_2x16:"packHalf2x16",floatunpack_snorm_2x16:"unpackSnorm2x16",floatunpack_unorm_2x16:"unpackUnorm2x16",floatunpack_float16_2x16:"unpackHalf2x16"},$C={low:"lowp",medium:"mediump",high:"highp"},qC={swizzleAssign:!0,storageBuffer:!1},XC={perspective:"smooth",linear:"noperspective"},YC={centroid:"centroid"},KC=`
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler3D;
precision highp samplerCube;
precision highp sampler2DArray;

precision highp usampler2D;
precision highp usampler3D;
precision highp usamplerCube;
precision highp usampler2DArray;

precision highp isampler2D;
precision highp isampler3D;
precision highp isamplerCube;
precision highp isampler2DArray;

precision highp sampler2DShadow;
precision highp sampler2DArrayShadow;
precision highp samplerCubeShadow;
`;class IX extends G3{constructor(e,t){super(e,t,new fX),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Dr}_include(e){const t=WC[e];return t.build(this),this.addInclude(t),t}getMethod(e){return WC[e]!==void 0&&this._include(e),FX[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`${e} ? ${t} : ${n}`}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),r=[];for(const o of t.inputs)r.push(this.getType(o.type)+" "+o.name);return`${this.getType(t.type)} ${t.name}( ${r.join(", ")} ) {

	${n.vars}

${n.code}
	return ${n.result};

}`}setupPBO(e){const t=e.value;if(t.pbo===void 0){const n=t.array,r=t.count*t.itemSize,{itemSize:s}=t,o=t.array.constructor.name.toLowerCase().includes("int");let u=o?qh:bp;s===2?u=o?Xh:vr:s===3?u=o?wO:xp:s===4&&(u=o?Yh:si);const c={Float32Array:ri,Uint8Array:Gn,Uint16Array:Gs,Uint32Array:bn,Int8Array:_u,Int16Array:vu,Int32Array:Li,Uint8ClampedArray:Gn},h=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(r/s))));let d=Math.ceil(r/s/h);h*d*s<r&&d++;const p=h*d*s,g=new n.constructor(p);g.set(n,0),t.array=g;const _=new QS(t.array,h,d,u,c[t.array.constructor.name]||ri);_.needsUpdate=!0,_.isPBOTexture=!0;const v=new sf(_,null,null);v.setPrecision("high"),t.pboNode=v,t.pbo=v.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.nodeName)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?e.name:super.getPropertyName(e,t)}generatePBO(e){const{node:t,indexNode:n}=e,r=t.value;if(this.renderer.backend.has(r)){const d=this.renderer.backend.get(r);d.pbo=r.pbo}const s=this.getUniformFromNode(r.pboNode,"texture",this.shaderStage,this.context.nodeName),o=this.getPropertyName(s);this.increaseUsage(n);const u=n.build(this,"uint"),c=this.getDataFromNode(e);let h=c.propertyName;if(h===void 0){const d=this.getVarFromNode(e);h=this.getPropertyName(d);const p=this.getDataFromNode(t);let g=p.propertySizeName;g===void 0&&(g=h+"Size",this.getVarFromNode(t,g,"uint"),this.addLineFlowCode(`${g} = uint( textureSize( ${o}, 0 ).x )`,e),p.propertySizeName=g);const{itemSize:_}=r,v="."+tf.join("").slice(0,_),S=`ivec2(${u} % ${g}, ${u} / ${g})`,b=this.generateTextureLoad(null,o,S,"0",null,null);let x="vec4";r.pbo.type===bn?x="uvec4":r.pbo.type===Li&&(x="ivec4"),this.addLineFlowCode(`${h} = ${x}(${b})${v}`,e),c.propertyName=h}return h}generateTextureLoad(e,t,n,r,s,o){r===null&&(r="0");let u;return s?o?u=`texelFetchOffset( ${t}, ivec3( ${n}, ${s} ), ${r}, ${o} )`:u=`texelFetch( ${t}, ivec3( ${n}, ${s} ), ${r} )`:o?u=`texelFetchOffset( ${t}, ${n}, ${r}, ${o} )`:u=`texelFetch( ${t}, ${n}, ${r} )`,e!==null&&e.isDepthTexture&&(u+=".x"),u}generateTexture(e,t,n,r,s){return r&&(n=`vec3( ${n}, ${r} )`),e.isDepthTexture?s?`textureOffset( ${t}, ${n}, ${s} ).x`:`texture( ${t}, ${n} ).x`:s?`textureOffset( ${t}, ${n}, ${s} )`:`texture( ${t}, ${n} )`}generateTextureLevel(e,t,n,r,s,o){return s&&(n=`vec3( ${n}, ${s} )`),o?`textureLodOffset( ${t}, ${n}, ${r}, ${o} )`:`textureLod( ${t}, ${n}, ${r} )`}generateTextureBias(e,t,n,r,s,o){return s&&(n=`vec3( ${n}, ${s} )`),o?`textureOffset( ${t}, ${n}, ${o}, ${r} )`:`texture( ${t}, ${n}, ${r} )`}generateTextureGrad(e,t,n,r,s,o){return s&&(n=`vec3( ${n}, ${s} )`),o?`textureGradOffset( ${t}, ${n}, ${r[0]}, ${r[1]}, ${o} )`:`textureGrad( ${t}, ${n}, ${r[0]}, ${r[1]} )`}generateTextureCompare(e,t,n,r,s,o,u=this.shaderStage){if(u==="fragment")return e.isCubeTexture?`texture( ${t}, vec4( ${n}, ${r} ) )`:s?o?`textureOffset( ${t}, vec4( ${n}, ${s}, ${r} ), ${o} )`:`texture( ${t}, vec4( ${n}, ${s}, ${r} ) )`:o?`textureOffset( ${t}, vec3( ${n}, ${r} ), ${o} )`:`texture( ${t}, vec3( ${n}, ${r} ) )`;Pe(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${u} shader.`)}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(`${this.getVar(r.type,r.name,r.count)};`);return t.join(`
	`)}getUniforms(e){const t=this.uniforms[e],n=[],r={};for(const o of t){let u=null,c=!1;if(o.type==="texture"||o.type==="texture3D"){const h=o.node.value;let d="";(h.isDataTexture===!0||h.isData3DTexture===!0)&&(h.type===bn?d="u":h.type===Li&&(d="i")),o.type==="texture3D"&&h.isArrayTexture===!1?u=`${d}sampler3D ${o.name};`:h.compareFunction?h.isArrayTexture===!0?u=`sampler2DArrayShadow ${o.name};`:u=`sampler2DShadow ${o.name};`:h.isArrayTexture===!0||h.isDataArrayTexture===!0||h.isCompressedArrayTexture===!0?u=`${d}sampler2DArray ${o.name};`:u=`${d}sampler2D ${o.name};`}else if(o.type==="cubeTexture")u=`samplerCube ${o.name};`;else if(o.type==="cubeDepthTexture")o.node.value.compareFunction?u=`samplerCubeShadow ${o.name};`:u=`samplerCube ${o.name};`;else if(o.type==="buffer"){const h=o.node,d=this.getType(h.bufferType),p=h.bufferCount,g=p>0?p:"";u=`${h.name} {
	${d} ${o.name}[${g}];
};
`}else{const h=o.groupNode.name;if(r[h]===void 0){const d=this.uniformGroups[h];if(d!==void 0){const p=[];for(const g of d.uniforms){const _=g.getType(),v=this.getVectorType(_),S=g.nodeUniform.node.precision;let b=`${v} ${g.name};`;S!==null&&(b=$C[S]+" "+b),p.push("	"+b)}r[h]=p}}c=!0}if(!c){const h=o.node.precision;h!==null&&(u=$C[h]+" "+u),u="uniform "+u,n.push(u)}}let s="";for(const o in r){const u=r[o];s+=this._getGLSLUniformStruct(o,u.join(`
`))+`
`}return s+=n.join(`
`),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Li){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let r=0;for(const s of n)t+=`layout( location = ${r++} ) in ${s.type} ${s.name};
`}return t}getStructMembers(e){const t=[];for(const n of e.members)t.push(`	${n.type} ${n.name};`);return t.join(`
`)}getStructs(e){const t=[],n=this.structs[e],r=[];for(const s of n)if(s.output)for(const o of s.members)r.push(`layout( location = ${o.index} ) out ${o.type} ${o.name};`);else{let o="struct "+s.name+` {
`;o+=this.getStructMembers(s),o+=`
};
`,t.push(o)}return r.length===0&&r.push("layout( location = 0 ) out vec4 fragColor;"),`
`+r.join(`
`)+`

`+t.join(`
`)}getVaryings(e){let t="";const n=this.varyings;if(e==="vertex"||e==="compute")for(const r of n){e==="compute"&&(r.needsInterpolation=!0);const s=this.getType(r.type);if(r.needsInterpolation)if(r.interpolationType){const o=XC[r.interpolationType]||r.interpolationType,u=YC[r.interpolationSampling]||"";t+=`${o} ${u} out ${s} ${r.name};
`}else{const o=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${o}out ${s} ${r.name};
`}else t+=`${s} ${r.name};
`}else if(e==="fragment"){for(const r of n)if(r.needsInterpolation){const s=this.getType(r.type);if(r.interpolationType){const o=XC[r.interpolationType]||r.interpolationType,u=YC[r.interpolationSampling]||"";t+=`${o} ${u} in ${s} ${r.name};
`}else{const o=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${o}in ${s} ${r.name};
`}}}for(const r of this.builtins[e])t+=`${r};
`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((n,r)=>n*r,1)}u`}getSubgroupSize(){Pe("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){Pe("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){Pe("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:r,behavior:s}of n.values())t.push(`#extension ${r} : ${s}`);return t.join(`
`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=qC[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const r=this.renderer.backend.extensions;r.has(n)&&(r.get(n),t=!0)}qC[e]=t}return t}isFlipY(){return!0}getUniformBufferLimit(){const e=this.renderer.backend.gl;return e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE)}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let n=0;n<e.length;n++){const r=e[n],s=this.getPropertyName(r.attributeNode);s&&(t+=`${r.varyingName} = ${s};
	`)}return t}_getGLSLUniformStruct(e,t){return`
layout( std140 ) uniform ${e} {
${t}
};`}_getGLSLVertexCode(e){return`#version 300 es

${this.getSignature()}

// extensions
${e.extensions}

// precision
${KC}

// uniforms
${e.uniforms}

// varyings
${e.varyings}

// attributes
${e.attributes}

// codes
${e.codes}

void main() {

	// vars
	${e.vars}

	// transforms
	${e.transforms}

	// flow
	${e.flow}

	gl_PointSize = 1.0;

}
`}_getGLSLFragmentCode(e){return`#version 300 es

${this.getSignature()}

// extensions
${e.extensions}

// precision
${KC}

// structs
${e.structs}

// uniforms
${e.uniforms}

// varyings
${e.varyings}

// codes
${e.codes}

void main() {

	// vars
	${e.vars}

	// flow
	${e.flow}

}
`}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){let n=`// code

`;n+=this.flowCode[t];const r=this.flowNodes[t],s=r[r.length-1];for(const u of r){const c=this.getFlowData(u),h=u.name;h&&(n.length>0&&(n+=`
`),n+=`	// flow -> ${h}
	`),n+=`${c.code}
	`,u===s&&t!=="compute"&&(n+=`// result
	`,t==="vertex"?(n+="gl_Position = ",n+=`${c.result};`):t==="fragment"&&(u.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${c.result};`)))}const o=e[t];o.extensions=this.getExtensions(t),o.uniforms=this.getUniforms(t),o.attributes=this.getAttributes(t),o.varyings=this.getVaryings(t),o.vars=this.getVars(t),o.structs=this.getStructs(t),o.codes=this.getCodes(t),o.transforms=this.getTransforms(t),o.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),o=this.getDataFromNode(e,n,this.globalCache);let u=o.uniformGPU;if(u===void 0){const c=e.groupNode,h=c.name,d=this.getBindGroupArray(h,n);if(t==="texture")u=new d0(s.name,s.node,c),d.push(u);else if(t==="cubeTexture"||t==="cubeDepthTexture")u=new K3(s.name,s.node,c),d.push(u);else if(t==="texture3D")u=new rS(s.name,s.node,c),d.push(u);else if(t==="buffer"){s.name=`buffer${e.id}`;const p=this.getSharedDataFromNode(e);let g=p.buffer;g===void 0&&(e.name=`NodeBuffer_${e.id}`,g=new q3(e,c),g.name=e.name,p.buffer=g),d.push(g),u=g}else{let p=this.uniformGroups[h];p===void 0?(p=new X3(h,c),this.uniformGroups[h]=p,d.push(p)):d.indexOf(p)===-1&&d.push(p),u=this.getNodeUniform(s,t);const g=u.name;p.uniforms.some(v=>v.name===g)||p.addUniform(u)}o.uniformGPU=u}return s}}let rb=null,Kc=null;class Z3{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[pa.RENDER]:null,[pa.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),n=this.renderer.info.frame;let r;e.isComputeNode===!0?r="c:"+this.renderer.info.compute.frameCalls:r="r:"+this.renderer.info.render.frameCalls,t.timestampUID=r+":"+e.id+":f"+n}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?pa.COMPUTE:pa.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){xn("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t)return;const n=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return rb=rb||new Ie,this.renderer.getDrawingBufferSize(rb)}setScissorTest(){}getClearColor(){const e=this.renderer;return Kc=Kc||new LT,e.getClearColor(Kc),Kc.getRGB(Kc),Kc}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:WN(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Fu} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}}let zX=0;class kX{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class GX{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,s=e.array,o=e.usage||r.STATIC_DRAW,u=e.isInterleavedBufferAttribute?e.data:e,c=n.get(u);let h=c.bufferGPU;h===void 0&&(h=this._createBuffer(r,t,s,o),c.bufferGPU=h,c.bufferType=t,c.version=u.version);let d;if(s instanceof Float32Array)d=r.FLOAT;else if(typeof Float16Array<"u"&&s instanceof Float16Array)d=r.HALF_FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?d=r.HALF_FLOAT:d=r.UNSIGNED_SHORT;else if(s instanceof Int16Array)d=r.SHORT;else if(s instanceof Uint32Array)d=r.UNSIGNED_INT;else if(s instanceof Int32Array)d=r.INT;else if(s instanceof Int8Array)d=r.BYTE;else if(s instanceof Uint8Array)d=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)d=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let p={bufferGPU:h,bufferType:t,type:d,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:d===r.INT||d===r.UNSIGNED_INT||e.gpuType===Li,id:zX++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const g=this._createBuffer(r,t,s,o);p=new kX(p,g)}n.set(e,p)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,s=e.isInterleavedBufferAttribute?e.data:e,o=t.get(s),u=o.bufferType,c=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(u,o.bufferGPU),c.length===0)n.bufferSubData(u,0,r);else{for(let h=0,d=c.length;h<d;h++){const p=c[h];n.bufferSubData(u,p.start*r.BYTES_PER_ELEMENT,r,p.start,p.count)}s.clearUpdateRanges()}n.bindBuffer(u,null),o.version=s.version}destroyAttribute(e){const t=this.backend,{gl:n}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);const r=t.get(e);n.deleteBuffer(r.bufferGPU),t.delete(e)}async getArrayBufferAsync(e){const t=this.backend,{gl:n}=t,r=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:s}=t.get(r),o=e.array,u=o.byteLength;n.bindBuffer(n.COPY_READ_BUFFER,s);const c=n.createBuffer();n.bindBuffer(n.COPY_WRITE_BUFFER,c),n.bufferData(n.COPY_WRITE_BUFFER,u,n.STREAM_READ),n.copyBufferSubData(n.COPY_READ_BUFFER,n.COPY_WRITE_BUFFER,0,0,u),await t.utils._clientWaitAsync();const h=new e.array.constructor(o.length);return n.bindBuffer(n.COPY_WRITE_BUFFER,c),n.getBufferSubData(n.COPY_WRITE_BUFFER,0,h),n.deleteBuffer(c),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),h.buffer}_createBuffer(e,t,n,r){const s=e.createBuffer();return e.bindBuffer(t,s),e.bufferData(t,n,r),e.bindBuffer(t,null),s}}let Ed,no;class VX{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;Ed={[nr]:e.FUNC_ADD,[xS]:e.FUNC_SUBTRACT,[bS]:e.FUNC_REVERSE_SUBTRACT},no={[ro]:e.ZERO,[SS]:e.ONE,[TS]:e.SRC_COLOR,[Kd]:e.SRC_ALPHA,[CS]:e.SRC_ALPHA_SATURATE,[wS]:e.DST_COLOR,[ES]:e.DST_ALPHA,[MS]:e.ONE_MINUS_SRC_COLOR,[Zd]:e.ONE_MINUS_SRC_ALPHA,[RS]:e.ONE_MINUS_DST_COLOR,[AS]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new Pt().fromArray(t),this.currentViewport=new Pt().fromArray(n),this._tempVec4=new Pt}enable(e){const{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==UN?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===Mb?t.cullFace(t.BACK):e===ON?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,n){const r=this.gl,s=this.backend.drawBuffersIndexedExt;if(!s){xn("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.");return}for(let o=0;o<e.length;o++){const u=e[o];let c=null;if(t!==null){const h=t.getBlendMode(u.name);h.blending===FN?c=n:h.blending!==Bi&&(c=h)}else c=n;c!==null?this._setMRTBlendingIndex(o,c):s.blendFuncSeparateiOES(o,r.ONE,r.ZERO,r.ONE,r.ZERO)}}_setMRTBlendingIndex(e,t){const{gl:n}=this,r=this.backend.drawBuffersIndexedExt,s=t.blending,o=t.blendSrc,u=t.blendDst,c=t.blendEquation,h=t.premultipliedAlpha;if(s===gu){const d=t.blendSrcAlpha!==null?t.blendSrcAlpha:o,p=t.blendDstAlpha!==null?t.blendDstAlpha:u,g=t.blendEquationAlpha!==null?t.blendEquationAlpha:c;r.blendEquationSeparateiOES(e,Ed[c],Ed[g]),r.blendFuncSeparateiOES(e,no[o],no[u],no[d],no[p])}else if(r.blendEquationSeparateiOES(e,n.FUNC_ADD,n.FUNC_ADD),h)switch(s){case pr:r.blendFuncSeparateiOES(e,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case cl:r.blendFuncSeparateiOES(e,n.ONE,n.ONE,n.ONE,n.ONE);break;case hl:r.blendFuncSeparateiOES(e,n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case fl:r.blendFuncSeparateiOES(e,n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:r.blendFuncSeparateiOES(e,n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break}else switch(s){case pr:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case cl:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case hl:r.blendFuncSeparateiOES(e,n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case fl:r.blendFuncSeparateiOES(e,n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:r.blendFuncSeparateiOES(e,n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break}}setBlending(e,t,n,r,s,o,u,c){const{gl:h}=this;if(e===Bi){this.currentBlendingEnabled===!0&&(this.disable(h.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(h.BLEND),this.currentBlendingEnabled=!0),e!==gu){if(e!==this.currentBlending||c!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==nr||this.currentBlendEquationAlpha!==nr)&&(h.blendEquation(h.FUNC_ADD),this.currentBlendEquation=nr,this.currentBlendEquationAlpha=nr),c)switch(e){case pr:h.blendFuncSeparate(h.ONE,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA);break;case cl:h.blendFunc(h.ONE,h.ONE);break;case hl:h.blendFuncSeparate(h.ZERO,h.ONE_MINUS_SRC_COLOR,h.ZERO,h.ONE);break;case fl:h.blendFuncSeparate(h.DST_COLOR,h.ONE_MINUS_SRC_ALPHA,h.ZERO,h.ONE);break;default:Pe("WebGLState: Invalid blending: ",e);break}else switch(e){case pr:h.blendFuncSeparate(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA);break;case cl:h.blendFuncSeparate(h.SRC_ALPHA,h.ONE,h.ONE,h.ONE);break;case hl:Pe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case fl:Pe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Pe("WebGLState: Invalid blending: ",e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=c}return}s=s||t,o=o||n,u=u||r,(t!==this.currentBlendEquation||s!==this.currentBlendEquationAlpha)&&(h.blendEquationSeparate(Ed[t],Ed[s]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=s),(n!==this.currentBlendSrc||r!==this.currentBlendDst||o!==this.currentBlendSrcAlpha||u!==this.currentBlendDstAlpha)&&(h.blendFuncSeparate(no[n],no[r],no[o],no[u]),this.currentBlendSrc=n,this.currentBlendDst=r,this.currentBlendSrcAlpha=o,this.currentBlendDstAlpha=u),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){const{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setReversedDepth(e){if(this.currentDepthReversed!==e){const t=this.backend.extensions.get("EXT_clip_control");e?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT),this.currentDepthReversed=e}}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthReversed&&(e=HS[e]),this.currentDepthFunc!==e){const{gl:t}=this;switch(e){case Qd:t.depthFunc(t.NEVER);break;case Jd:t.depthFunc(t.ALWAYS);break;case ep:t.depthFunc(t.LESS);break;case Tl:t.depthFunc(t.LEQUAL);break;case tp:t.depthFunc(t.EQUAL);break;case np:t.depthFunc(t.GEQUAL);break;case ip:t.depthFunc(t.GREATER);break;case rp:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,n,r){const s=this._tempVec4.set(e,t,n,r);if(this.currentScissor.equals(s)===!1){const{gl:o}=this;o.scissor(s.x,s.y,s.z,s.w),this.currentScissor.copy(s)}}viewport(e,t,n,r){const s=this._tempVec4.set(e,t,n,r);if(this.currentViewport.equals(s)===!1){const{gl:o}=this;o.viewport(s.x,s.y,s.z,s.w),this.currentViewport.copy(s)}}setScissorTest(e){const t=this.gl;e?this.enable(t.SCISSOR_TEST):this.disable(t.SCISSOR_TEST)}setStencilTest(e){const{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,n){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==n)&&(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)}setStencilOp(e,t,n){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==n)&&(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)}setMaterial(e,t,n){const{gl:r}=this;e.side===Ui?this.disable(r.CULL_FACE):this.enable(r.CULL_FACE);let s=e.side===Tn;t&&(s=!s),this.setFlipSided(s),e.blending===pr&&e.transparent===!1?this.setBlending(Bi):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);const o=e.stencilWrite;if(this.setStencilTest(o),o&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.currentSamples>0?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let c=0;c<8;c++)c<n?this.enable(12288+c):this.disable(12288+c)}setPolygonOffset(e,t,n){const{gl:r}=this;e?(this.enable(r.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==n)&&(r.polygonOffset(t,n),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=n)):this.disable(r.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e?(this.gl.useProgram(e),this.currentProgram=e,!0):!1}setVertexState(e,t=null){const n=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(n.bindVertexArray(e),t!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){const e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){const{gl:n,currentBoundFramebuffers:r}=this;return r[e]!==t?(n.bindFramebuffer(e,t),r[e]=t,e===n.DRAW_FRAMEBUFFER&&(r[n.FRAMEBUFFER]=t),e===n.FRAMEBUFFER&&(r[n.DRAW_FRAMEBUFFER]=t),!0):!1}drawBuffers(e,t){const{gl:n}=this;let r=[],s=!1;if(e.textures!==null){r=this.currentDrawbuffers.get(t),r===void 0&&(r=[],this.currentDrawbuffers.set(t,r));const o=e.textures;if(r.length!==o.length||r[0]!==n.COLOR_ATTACHMENT0){for(let u=0,c=o.length;u<c;u++)r[u]=n.COLOR_ATTACHMENT0+u;r.length=o.length,s=!0}}else r[0]!==n.BACK&&(r[0]=n.BACK,s=!0);s&&n.drawBuffers(r)}activeTexture(e){const{gl:t,currentTextureSlot:n,maxTextures:r}=this;e===void 0&&(e=t.TEXTURE0+r-1),n!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,n){const{gl:r,currentTextureSlot:s,currentBoundTextures:o,maxTextures:u}=this;n===void 0&&(s===null?n=r.TEXTURE0+u-1:n=s);let c=o[n];c===void 0&&(c={type:void 0,texture:void 0},o[n]=c),(c.type!==e||c.texture!==t)&&(s!==n&&(r.activeTexture(n),this.currentTextureSlot=n),r.bindTexture(e,t),c.type=e,c.texture=t)}bindBufferBase(e,t,n){const{gl:r}=this,s=`${e}-${t}`;return this.currentBoundBufferBases[s]!==n?(r.bindBufferBase(e,t,n),this.currentBoundBufferBases[s]=n,!0):!1}unbindTexture(){const{gl:e,currentTextureSlot:t,currentBoundTextures:n}=this,r=n[t];r!==void 0&&r.type!==void 0&&(e.bindTexture(r.type,null),r.type=void 0,r.texture=void 0)}}class HX{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=Dr){const{gl:n,extensions:r}=this;let s;const o=xt.getTransfer(t);if(e===Gn)return n.UNSIGNED_BYTE;if(e===G_)return n.UNSIGNED_SHORT_4_4_4_4;if(e===V_)return n.UNSIGNED_SHORT_5_5_5_1;if(e===H_)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===j_)return n.UNSIGNED_INT_10F_11F_11F_REV;if(e===_u)return n.BYTE;if(e===vu)return n.SHORT;if(e===Gs)return n.UNSIGNED_SHORT;if(e===Li)return n.INT;if(e===bn)return n.UNSIGNED_INT;if(e===ri)return n.FLOAT;if(e===Qn)return n.HALF_FLOAT;if(e===IS)return n.ALPHA;if(e===xp)return n.RGB;if(e===si)return n.RGBA;if(e===Wi)return n.DEPTH_COMPONENT;if(e===_r)return n.DEPTH_STENCIL;if(e===bp)return n.RED;if(e===qh)return n.RED_INTEGER;if(e===vr)return n.RG;if(e===Xh)return n.RG_INTEGER;if(e===Yh)return n.RGBA_INTEGER;if(e===gl||e===_l||e===vl||e===yl)if(o===Ye)if(s=r.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(e===gl)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===_l)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===vl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===yl)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=r.get("WEBGL_compressed_texture_s3tc"),s!==null){if(e===gl)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===_l)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===vl)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===yl)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===sp||e===ap||e===op||e===lp)if(s=r.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(e===sp)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===ap)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===op)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===lp)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===fh||e===dh||e===ph||e===mh||e===gh||e===wu||e===_h)if(s=r.get("WEBGL_compressed_texture_etc"),s!==null){if(e===fh||e===dh)return o===Ye?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(e===ph)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(e===mh)return s.COMPRESSED_R11_EAC;if(e===gh)return s.COMPRESSED_SIGNED_R11_EAC;if(e===wu)return s.COMPRESSED_RG11_EAC;if(e===_h)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(e===vh||e===yh||e===xh||e===bh||e===Sh||e===Th||e===Mh||e===Eh||e===Ah||e===wh||e===Rh||e===Ch||e===Nh||e===Dh)if(s=r.get("WEBGL_compressed_texture_astc"),s!==null){if(e===vh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===yh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===xh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===bh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===Sh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===Th)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===Mh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===Eh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===Ah)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===wh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===Rh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===Ch)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===Nh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===Dh)return o===Ye?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===Lh)if(s=r.get("EXT_texture_compression_bptc"),s!==null){if(e===Lh)return o===Ye?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===Ph||e===Uh||e===Ru||e===Oh)if(s=r.get("EXT_texture_compression_rgtc"),s!==null){if(e===Ph)return s.COMPRESSED_RED_RGTC1_EXT;if(e===Uh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===Ru)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===Oh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===is?n.UNSIGNED_INT_24_8:n[e]!==void 0?n[e]:null}_clientWaitAsync(){const{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((n,r)=>{function s(){const o=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(o===e.WAIT_FAILED){e.deleteSync(t),r();return}if(o===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),n()}s()})}}let ZC=!1,$g,sb,QC;class jX{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,ZC===!1&&(this._init(),ZC=!0)}_init(){const e=this.gl;$g={[Eu]:e.REPEAT,[Pr]:e.CLAMP_TO_EDGE,[Au]:e.MIRRORED_REPEAT},sb={[hn]:e.NEAREST,[FS]:e.NEAREST_MIPMAP_NEAREST,[ho]:e.NEAREST_MIPMAP_LINEAR,[Rn]:e.LINEAR,[sh]:e.LINEAR_MIPMAP_NEAREST,[Ur]:e.LINEAR_MIPMAP_LINEAR},QC={[zS]:e.NEVER,[VS]:e.ALWAYS,[W_]:e.LESS,[wl]:e.LEQUAL,[kS]:e.EQUAL,[bo]:e.GEQUAL,[up]:e.GREATER,[GS]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,s=!1){const{gl:o,extensions:u}=this;if(e!==null){if(o[e]!==void 0)return o[e];Ne("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let c=t;if(t===o.RED&&(n===o.FLOAT&&(c=o.R32F),n===o.HALF_FLOAT&&(c=o.R16F),n===o.UNSIGNED_BYTE&&(c=o.R8),n===o.UNSIGNED_SHORT&&(c=o.R16),n===o.UNSIGNED_INT&&(c=o.R32UI),n===o.BYTE&&(c=o.R8I),n===o.SHORT&&(c=o.R16I),n===o.INT&&(c=o.R32I)),t===o.RED_INTEGER&&(n===o.UNSIGNED_BYTE&&(c=o.R8UI),n===o.UNSIGNED_SHORT&&(c=o.R16UI),n===o.UNSIGNED_INT&&(c=o.R32UI),n===o.BYTE&&(c=o.R8I),n===o.SHORT&&(c=o.R16I),n===o.INT&&(c=o.R32I)),t===o.RG&&(n===o.FLOAT&&(c=o.RG32F),n===o.HALF_FLOAT&&(c=o.RG16F),n===o.UNSIGNED_BYTE&&(c=o.RG8),n===o.UNSIGNED_SHORT&&(c=o.RG16),n===o.UNSIGNED_INT&&(c=o.RG32UI),n===o.BYTE&&(c=o.RG8I),n===o.SHORT&&(c=o.RG16I),n===o.INT&&(c=o.RG32I)),t===o.RG_INTEGER&&(n===o.UNSIGNED_BYTE&&(c=o.RG8UI),n===o.UNSIGNED_SHORT&&(c=o.RG16UI),n===o.UNSIGNED_INT&&(c=o.RG32UI),n===o.BYTE&&(c=o.RG8I),n===o.SHORT&&(c=o.RG16I),n===o.INT&&(c=o.RG32I)),t===o.RGB){const h=s?Bh:xt.getTransfer(r);n===o.FLOAT&&(c=o.RGB32F),n===o.HALF_FLOAT&&(c=o.RGB16F),n===o.UNSIGNED_BYTE&&(c=o.RGB8),n===o.UNSIGNED_SHORT&&(c=o.RGB16),n===o.UNSIGNED_INT&&(c=o.RGB32UI),n===o.BYTE&&(c=o.RGB8I),n===o.SHORT&&(c=o.RGB16I),n===o.INT&&(c=o.RGB32I),n===o.UNSIGNED_BYTE&&(c=h===Ye?o.SRGB8:o.RGB8),n===o.UNSIGNED_SHORT_5_6_5&&(c=o.RGB565),n===o.UNSIGNED_SHORT_5_5_5_1&&(c=o.RGB5_A1),n===o.UNSIGNED_SHORT_4_4_4_4&&(c=o.RGB4),n===o.UNSIGNED_INT_5_9_9_9_REV&&(c=o.RGB9_E5),n===o.UNSIGNED_INT_10F_11F_11F_REV&&(c=o.R11F_G11F_B10F)}if(t===o.RGB_INTEGER&&(n===o.UNSIGNED_BYTE&&(c=o.RGB8UI),n===o.UNSIGNED_SHORT&&(c=o.RGB16UI),n===o.UNSIGNED_INT&&(c=o.RGB32UI),n===o.BYTE&&(c=o.RGB8I),n===o.SHORT&&(c=o.RGB16I),n===o.INT&&(c=o.RGB32I)),t===o.RGBA){const h=s?Bh:xt.getTransfer(r);n===o.FLOAT&&(c=o.RGBA32F),n===o.HALF_FLOAT&&(c=o.RGBA16F),n===o.UNSIGNED_BYTE&&(c=o.RGBA8),n===o.UNSIGNED_SHORT&&(c=o.RGBA16),n===o.UNSIGNED_INT&&(c=o.RGBA32UI),n===o.BYTE&&(c=o.RGBA8I),n===o.SHORT&&(c=o.RGBA16I),n===o.INT&&(c=o.RGBA32I),n===o.UNSIGNED_BYTE&&(c=h===Ye?o.SRGB8_ALPHA8:o.RGBA8),n===o.UNSIGNED_SHORT_4_4_4_4&&(c=o.RGBA4),n===o.UNSIGNED_SHORT_5_5_5_1&&(c=o.RGB5_A1)}return t===o.RGBA_INTEGER&&(n===o.UNSIGNED_BYTE&&(c=o.RGBA8UI),n===o.UNSIGNED_SHORT&&(c=o.RGBA16UI),n===o.UNSIGNED_INT&&(c=o.RGBA32UI),n===o.BYTE&&(c=o.RGBA8I),n===o.SHORT&&(c=o.RGBA16I),n===o.INT&&(c=o.RGBA32I)),t===o.DEPTH_COMPONENT&&(n===o.UNSIGNED_SHORT&&(c=o.DEPTH_COMPONENT16),n===o.UNSIGNED_INT&&(c=o.DEPTH_COMPONENT24),n===o.FLOAT&&(c=o.DEPTH_COMPONENT32F)),t===o.DEPTH_STENCIL&&n===o.UNSIGNED_INT_24_8&&(c=o.DEPTH24_STENCIL8),(c===o.R16F||c===o.R32F||c===o.RG16F||c===o.RG32F||c===o.RGBA16F||c===o.RGBA32F)&&u.get("EXT_color_buffer_float"),c}setTextureParameters(e,t){const{gl:n,extensions:r,backend:s}=this,o=xt.getPrimaries(xt.workingColorSpace),u=t.colorSpace===Dr?null:xt.getPrimaries(t.colorSpace),c=t.colorSpace===Dr||o===u?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,c),n.texParameteri(e,n.TEXTURE_WRAP_S,$g[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,$g[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,$g[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,sb[t.magFilter]);const h=t.mipmaps!==void 0&&t.mipmaps.length>0,d=t.minFilter===Rn&&h?Ur:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,sb[d]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,QC[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===hn||t.minFilter!==ho&&t.minFilter!==Ur||t.type===ri&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const p=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,p.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,s=this.getGLTextureType(e);let o=r[s];o===void 0&&(o=t.createTexture(),n.state.bindTexture(s,o),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),r[s]=o),n.set(e,{textureGPU:o,glTextureType:s})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:s,width:o,height:u,depth:c}=t,h=r.utils.convert(e.format,e.colorSpace),d=r.utils.convert(e.type),p=this.getInternalFormat(e.internalFormat,h,d,e.colorSpace,e.isVideoTexture),g=n.createTexture(),_=this.getGLTextureType(e);r.state.bindTexture(_,g),this.setTextureParameters(_,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,s,p,o,u,c):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,s,p,o,u,c):e.isVideoTexture||n.texStorage2D(_,s,p,o,u),r.set(e,{textureGPU:g,glTextureType:_,glFormat:h,glType:d,glInternalFormat:p})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:s,glTextureType:o,glFormat:u,glType:c}=r.get(t),{width:h,height:d}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(o,s),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(o,0,0,0,h,d,u,c,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:s}=t,{textureGPU:o,glTextureType:u,glFormat:c,glType:h,glInternalFormat:d}=this.backend.get(e);if(!(e.isRenderTargetTexture||o===void 0))if(this.backend.state.bindTexture(u,o),this.setTextureParameters(u,e),e.isCompressedTexture){const p=e.mipmaps,g=t.image;for(let _=0;_<p.length;_++){const v=p[_];e.isCompressedArrayTexture?e.format!==n.RGBA?c!==null?n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,_,0,0,0,v.width,v.height,g.depth,c,v.data):Ne("WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texSubImage3D(n.TEXTURE_2D_ARRAY,_,0,0,0,v.width,v.height,g.depth,c,h,v.data):c!==null?n.compressedTexSubImage2D(n.TEXTURE_2D,_,0,0,v.width,v.height,c,v.data):Ne("WebGLBackend: Unsupported compressed texture format")}}else if(e.isCubeTexture){const p=t.images,g=e.mipmaps;for(let _=0;_<6;_++){const v=qg(p[_]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+_,0,0,0,r,s,c,h,v);for(let S=0;S<g.length;S++){const b=g[S],x=qg(b.images[_]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+_,S+1,0,0,x.width,x.height,c,h,x)}}}else if(e.isDataArrayTexture||e.isArrayTexture){const p=t.image;if(e.layerUpdates.size>0){const g=Cb(p.width,p.height,e.format,e.type);for(const _ of e.layerUpdates){const v=p.data.subarray(_*g/p.data.BYTES_PER_ELEMENT,(_+1)*g/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,_,p.width,p.height,1,c,h,v)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,c,h,p.data)}else if(e.isData3DTexture){const p=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,c,h,p.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(u,0,d,c,h,t.image);else{const p=e.mipmaps;if(p.length>0)for(let g=0,_=p.length;g<_;g++){const v=p[g],S=qg(v);n.texSubImage2D(u,g,0,0,v.width,v.height,c,h,S)}else{const g=qg(t.image);n.texSubImage2D(u,0,0,0,r,s,c,h,g)}}}generateMipmaps(e){const{gl:t,backend:n}=this,{textureGPU:r,glTextureType:s}=n.get(e);n.state.bindTexture(s,r),t.generateMipmap(s)}deallocateRenderBuffers(e){const{gl:t,backend:n}=this;if(e){const r=n.get(e);if(r.renderBufferStorageSetup=void 0,r.framebuffers){for(const s in r.framebuffers)t.deleteFramebuffer(r.framebuffers[s]);delete r.framebuffers}if(r.depthRenderbuffer&&(t.deleteRenderbuffer(r.depthRenderbuffer),delete r.depthRenderbuffer),r.stencilRenderbuffer&&(t.deleteRenderbuffer(r.stencilRenderbuffer),delete r.stencilRenderbuffer),r.msaaFrameBuffer&&(t.deleteFramebuffer(r.msaaFrameBuffer),delete r.msaaFrameBuffer),r.msaaRenderbuffers){for(let s=0;s<r.msaaRenderbuffers.length;s++)t.deleteRenderbuffer(r.msaaRenderbuffers[s]);delete r.msaaRenderbuffers}}}destroyTexture(e,t=!1){const{gl:n,backend:r}=this,{textureGPU:s,renderTarget:o}=r.get(e);this.deallocateRenderBuffers(o),t===!1&&n.deleteTexture(s),r.delete(e)}copyTextureToTexture(e,t,n=null,r=null,s=0,o=0){const{gl:u,backend:c}=this,{state:h}=this.backend,{textureGPU:d,glTextureType:p,glType:g,glFormat:_}=c.get(t);h.bindTexture(p,d);let v,S,b,x,M,E,w,D,C;const N=e.isCompressedTexture?e.mipmaps[o]:e.image;if(n!==null)v=n.max.x-n.min.x,S=n.max.y-n.min.y,b=n.isBox3?n.max.z-n.min.z:1,x=n.min.x,M=n.min.y,E=n.isBox3?n.min.z:0;else{const Z=Math.pow(2,-s);v=Math.floor(N.width*Z),S=Math.floor(N.height*Z),e.isDataArrayTexture||e.isArrayTexture?b=N.depth:e.isData3DTexture?b=Math.floor(N.depth*Z):b=1,x=0,M=0,E=0}r!==null?(w=r.x,D=r.y,C=r.z):(w=0,D=0,C=0),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,t.flipY),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),u.pixelStorei(u.UNPACK_ALIGNMENT,t.unpackAlignment);const A=u.getParameter(u.UNPACK_ROW_LENGTH),L=u.getParameter(u.UNPACK_IMAGE_HEIGHT),j=u.getParameter(u.UNPACK_SKIP_PIXELS),z=u.getParameter(u.UNPACK_SKIP_ROWS),H=u.getParameter(u.UNPACK_SKIP_IMAGES);u.pixelStorei(u.UNPACK_ROW_LENGTH,N.width),u.pixelStorei(u.UNPACK_IMAGE_HEIGHT,N.height),u.pixelStorei(u.UNPACK_SKIP_PIXELS,x),u.pixelStorei(u.UNPACK_SKIP_ROWS,M),u.pixelStorei(u.UNPACK_SKIP_IMAGES,E);const K=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,te=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){const Z=c.get(e),I=c.get(t),F=c.get(Z.renderTarget),Y=c.get(I.renderTarget),se=F.framebuffers[Z.cacheKey],Te=Y.framebuffers[I.cacheKey];h.bindFramebuffer(u.READ_FRAMEBUFFER,se),h.bindFramebuffer(u.DRAW_FRAMEBUFFER,Te);for(let O=0;O<b;O++)K&&(u.framebufferTextureLayer(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,Z.textureGPU,s,E+O),u.framebufferTextureLayer(u.DRAW_FRAMEBUFFER,u.COLOR_ATTACHMENT0,d,o,C+O)),u.blitFramebuffer(x,M,v,S,w,D,v,S,u.DEPTH_BUFFER_BIT,u.NEAREST);h.bindFramebuffer(u.READ_FRAMEBUFFER,null),h.bindFramebuffer(u.DRAW_FRAMEBUFFER,null)}else if(s!==0||e.isRenderTargetTexture||c.has(e)){const Z=c.get(e);this._srcFramebuffer===null&&(this._srcFramebuffer=u.createFramebuffer()),this._dstFramebuffer===null&&(this._dstFramebuffer=u.createFramebuffer()),h.bindFramebuffer(u.READ_FRAMEBUFFER,this._srcFramebuffer),h.bindFramebuffer(u.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let I=0;I<b;I++)K?u.framebufferTextureLayer(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,Z.textureGPU,s,E+I):u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,Z.textureGPU,s),te?u.framebufferTextureLayer(u.DRAW_FRAMEBUFFER,u.COLOR_ATTACHMENT0,d,o,C+I):u.framebufferTexture2D(u.DRAW_FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,d,o),s!==0?u.blitFramebuffer(x,M,v,S,w,D,v,S,u.COLOR_BUFFER_BIT,u.NEAREST):te?u.copyTexSubImage3D(p,o,w,D,C+I,x,M,v,S):u.copyTexSubImage2D(p,o,w,D,x,M,v,S);h.bindFramebuffer(u.READ_FRAMEBUFFER,null),h.bindFramebuffer(u.DRAW_FRAMEBUFFER,null)}else te?e.isDataTexture||e.isData3DTexture?u.texSubImage3D(p,o,w,D,C,v,S,b,_,g,N.data):t.isCompressedArrayTexture?u.compressedTexSubImage3D(p,o,w,D,C,v,S,b,_,N.data):u.texSubImage3D(p,o,w,D,C,v,S,b,_,g,N):e.isDataTexture?u.texSubImage2D(u.TEXTURE_2D,o,w,D,v,S,_,g,N.data):e.isCompressedTexture?u.compressedTexSubImage2D(u.TEXTURE_2D,o,w,D,N.width,N.height,_,N.data):u.texSubImage2D(u.TEXTURE_2D,o,w,D,v,S,_,g,N);u.pixelStorei(u.UNPACK_ROW_LENGTH,A),u.pixelStorei(u.UNPACK_IMAGE_HEIGHT,L),u.pixelStorei(u.UNPACK_SKIP_PIXELS,j),u.pixelStorei(u.UNPACK_SKIP_ROWS,z),u.pixelStorei(u.UNPACK_SKIP_IMAGES,H),o===0&&t.generateMipmaps&&u.generateMipmap(p),h.unbindTexture()}copyFramebufferToTexture(e,t,n){const{gl:r}=this,{state:s}=this.backend,{textureGPU:o}=this.backend.get(e),{x:u,y:c,z:h,w:d}=n,p=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,g=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(p){const _=u!==0||c!==0;let v,S;if(e.isDepthTexture===!0?(v=r.DEPTH_BUFFER_BIT,S=r.DEPTH_ATTACHMENT,t.stencil&&(v|=r.STENCIL_BUFFER_BIT)):(v=r.COLOR_BUFFER_BIT,S=r.COLOR_ATTACHMENT0),_){const b=this.backend.get(t.renderTarget),x=b.framebuffers[t.getCacheKey()],M=b.msaaFrameBuffer;s.bindFramebuffer(r.DRAW_FRAMEBUFFER,x),s.bindFramebuffer(r.READ_FRAMEBUFFER,M);const E=g-c-d;r.blitFramebuffer(u,E,u+h,E+d,u,E,u+h,E+d,v,r.NEAREST),s.bindFramebuffer(r.READ_FRAMEBUFFER,x),s.bindTexture(r.TEXTURE_2D,o),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,u,E,h,d),s.unbindTexture()}else{const b=r.createFramebuffer();s.bindFramebuffer(r.DRAW_FRAMEBUFFER,b),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,S,r.TEXTURE_2D,o,0),r.blitFramebuffer(0,0,h,d,0,0,h,d,v,r.NEAREST),r.deleteFramebuffer(b)}}else s.bindTexture(r.TEXTURE_2D,o),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,u,g-d-c,h,d),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,r=!1){const{gl:s}=this,o=t.renderTarget,{depthTexture:u,depthBuffer:c,stencilBuffer:h,width:d,height:p}=o;if(s.bindRenderbuffer(s.RENDERBUFFER,e),c&&!h){let g=s.DEPTH_COMPONENT24;r===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(s.RENDERBUFFER,o.samples,g,d,p):n>0?(u&&u.isDepthTexture&&u.type===s.FLOAT&&(g=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,n,g,d,p)):s.renderbufferStorage(s.RENDERBUFFER,g,d,p),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else c&&h&&(n>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH24_STENCIL8,d,p):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,d,p),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e));s.bindRenderbuffer(s.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,n,r,s,o){const{backend:u,gl:c}=this,{textureGPU:h,glFormat:d,glType:p}=this.backend.get(e),g=c.createFramebuffer();u.state.bindFramebuffer(c.READ_FRAMEBUFFER,g);const _=e.isCubeTexture?c.TEXTURE_CUBE_MAP_POSITIVE_X+o:c.TEXTURE_2D;c.framebufferTexture2D(c.READ_FRAMEBUFFER,c.COLOR_ATTACHMENT0,_,h,0);const v=this._getTypedArrayType(p),S=this._getBytesPerTexel(p,d),x=r*s*S,M=c.createBuffer();c.bindBuffer(c.PIXEL_PACK_BUFFER,M),c.bufferData(c.PIXEL_PACK_BUFFER,x,c.STREAM_READ),c.readPixels(t,n,r,s,d,p,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),await u.utils._clientWaitAsync();const E=new v(x/v.BYTES_PER_ELEMENT);return c.bindBuffer(c.PIXEL_PACK_BUFFER,M),c.getBufferSubData(c.PIXEL_PACK_BUFFER,0,E),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),u.state.bindFramebuffer(c.READ_FRAMEBUFFER,null),c.deleteFramebuffer(g),E}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}dispose(){const{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}}function qg(i){return i.isDataTexture?i.image.data:typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?i:i.data}class WX{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class $X{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const JC={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class qX{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:n,mode:r,object:s,type:o,info:u,index:c}=this;c!==0?n.drawElements(r,t,o,e):n.drawArrays(r,e,t),u.update(s,t,1)}renderInstances(e,t,n){const{gl:r,mode:s,type:o,index:u,object:c,info:h}=this;n!==0&&(u!==0?r.drawElementsInstanced(s,t,o,e,n):r.drawArraysInstanced(s,e,t,n),h.update(c,t,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:s,object:o,info:u}=this;if(n===0)return;const c=r.get("WEBGL_multi_draw");if(c===null)for(let h=0;h<n;h++)this.render(e[h],t[h]);else{this.index!==0?c.multiDrawElementsWEBGL(s,t,0,this.type,e,0,n):c.multiDrawArraysWEBGL(s,e,0,t,0,n);let h=0;for(let d=0;d<n;d++)h+=t[d];u.update(o,h,1)}}renderMultiDrawInstances(e,t,n,r){const{extensions:s,mode:o,object:u,info:c}=this;if(n===0)return;const h=s.get("WEBGL_multi_draw");if(h===null)for(let d=0;d<n;d++)this.renderInstances(e[d],t[d],r[d]);else{this.index!==0?h.multiDrawElementsInstancedWEBGL(o,t,0,this.type,e,0,r,0,n):h.multiDrawArraysInstancedWEBGL(o,e,0,t,0,r,0,n);let d=0;for(let p=0;p<n;p++)d+=t[p]*r[p];c.update(u,d,1)}}}class Q3{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return t===void 0&&(Ne(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestamp(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}}class XX extends Q3{constructor(e,t,n=2048){if(super(n),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext){Ne("EXT_disjoint_timer_query not supported; timestamps will be disabled."),this.trackTimestamp=!1;return}this.queries=[];for(let r=0;r<this.maxQueries;r++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return xn(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;const n=this.queries[t];if(n)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(r){Pe("Error in beginQuery:",r),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(n){Pe("Error in endQuery:",n),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[s,o]of this.queryOffsets)if(this.queryStates.get(o)==="ended"){const c=this.queries[o];e.set(s,this.resolveQuery(c))}if(e.size===0)return this.lastValue;const t={},n=[];for(const[s,o]of e){const u=s.match(/^(.*):f(\d+)$/),c=parseInt(u[2]);n.includes(c)===!1&&n.push(c),t[c]===void 0&&(t[c]=0);const h=await o;this.timestamps.set(s,h),t[c]+=h}const r=t[n[n.length-1]];return this.lastValue=r,this.frames=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,r}catch(e){return Pe("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,r=!1;const s=()=>{n&&(clearTimeout(n),n=null)},o=c=>{r||(r=!0,s(),t(c))},u=()=>{if(this.isDisposed){o(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){o(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(u,1);return}const d=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(d)/1e6)}catch(c){Pe("Error checking query:",c),t(this.lastValue)}};u()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class eN extends Z3{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,n={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context!==void 0?t.context:e.domElement.getContext("webgl2",n);function s(o){o.preventDefault();const u={api:"WebGL",message:o.statusMessage||"Unknown reason",reason:null,originalEvent:o};e.onDeviceLost(u)}this._onContextLost=s,e.domElement.addEventListener("webglcontextlost",s,!1),this.gl=r,this.extensions=new WX(this),this.capabilities=new $X(this),this.attributeUtils=new GX(this),this.textureUtils=new jX(this),this.bufferRenderer=new qX(this),this.state=new VX(this),this.utils=new HX(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer===!0&&this.extensions.has("EXT_clip_control")&&this.state.setReversedDepth(!0)}get coordinateSystem(){return yr}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){const r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),n!==null){const s=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:s}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&Ne("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new XX(this.gl,e,2048));const n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,n=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:s,height:o}=this.getDrawingBufferSize();t.viewport(0,0,s,o)}if(e.scissor)this.updateScissor(e);else{const{width:s,height:o}=this.getDrawingBufferSize();t.scissor(0,0,s,o)}this.initTimestampQuery(pa.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const r=e.occlusionQueryCount;r>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),s=r.previousContext;n.resetVertexState();const o=e.occlusionQueryCount;o>0&&(o>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const u=e.textures;if(u!==null)for(let c=0;c<u.length;c++){const h=u[c];h.generateMipmaps&&this.generateMipmaps(h)}if(this._currentContext=s,this._resolveRenderTarget(e),s!==null){if(this._setFramebuffer(s),s.viewport)this.updateViewport(s);else{const{width:c,height:h}=this.getDrawingBufferSize();n.viewport(0,0,c,h)}if(s.scissor)this.updateScissor(s);else{const{width:c,height:h}=this.getDrawingBufferSize();n.scissor(0,0,c,h)}}this.prepareTimestampBuffer(pa.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueries:n,currentOcclusionQueryObjects:r}=t;if(n&&r){const s=new WeakSet,{gl:o}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;const u=()=>{let c=0;for(let h=0;h<n.length;h++){const d=n[h];d!==null&&o.getQueryParameter(d,o.QUERY_RESULT_AVAILABLE)&&(o.getQueryParameter(d,o.QUERY_RESULT)===0&&s.add(r[h]),n[h]=null,o.deleteQuery(d),c++)}c<n.length?requestAnimationFrame(u):t.occluded=s};u()}}isOccluded(e,t){const n=this.get(e);return n.occluded&&n.occluded.has(t)}updateViewport(e){const{state:t}=this,{x:n,y:r,width:s,height:o}=e.viewportValue;t.viewport(n,e.height-o-r,s,o)}updateScissor(e){const{state:t}=this,{x:n,y:r,width:s,height:o}=e.scissorValue;t.scissor(n,e.height-o-r,s,o)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){const e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,n,r=null,s=!0,o=!0){const{gl:u,renderer:c}=this;r===null&&(r={textures:null,clearColorValue:this.getClearColor()});let h=0;if(e&&(h|=u.COLOR_BUFFER_BIT),t&&(h|=u.DEPTH_BUFFER_BIT),n&&(h|=u.STENCIL_BUFFER_BIT),h!==0){let d;r.clearColorValue?d=r.clearColorValue:d=this.getClearColor();const p=c.getClearDepth(),g=c.getClearStencil();if(t&&this.state.setDepthMask(!0),r.textures===null)u.clearColor(d.r,d.g,d.b,d.a),u.clear(h);else{if(s&&this._setFramebuffer(r),e)for(let _=0;_<r.textures.length;_++)_===0?u.clearBufferfv(u.COLOR,_,[d.r,d.g,d.b,d.a]):u.clearBufferfv(u.COLOR,_,[0,0,0,1]);t&&n?u.clearBufferfi(u.DEPTH_STENCIL,0,p,g):t?u.clearBufferfv(u.DEPTH,0,[p]):n&&u.clearBufferiv(u.STENCIL,0,[g]),s&&o&&this._resolveRenderTarget(r)}}}beginCompute(e){const{state:t,gl:n}=this;t.bindFramebuffer(n.FRAMEBUFFER,null),this.initTimestampQuery(pa.COMPUTE,this.getTimestampUID(e))}compute(e,t,n,r,s=null){const{state:o,gl:u}=this;this.discard===!1&&(o.enable(u.RASTERIZER_DISCARD),this.discard=!0);const{programGPU:c,transformBuffers:h,attributes:d}=this.get(r),p=this._getVaoKey(d),g=this.vaoCache[p];g===void 0?this.vaoCache[p]=this._createVao(d):o.setVertexState(g),o.useProgram(c),this._bindUniforms(n);const _=this._getTransformFeedback(h);u.bindTransformFeedback(u.TRANSFORM_FEEDBACK,_),u.beginTransformFeedback(u.POINTS),s=s!==null?s:t.count,Array.isArray(s)?(xn("WebGLBackend.compute(): The count parameter must be a single number, not an array."),s=s[0]):s&&typeof s=="object"&&s.isIndirectStorageBufferAttribute&&(xn("WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute"),s=t.count),d[0].isStorageInstancedBufferAttribute?u.drawArraysInstanced(u.POINTS,0,1,s):u.drawArrays(u.POINTS,0,s),u.endTransformFeedback(),u.bindTransformFeedback(u.TRANSFORM_FEEDBACK,null);for(let v=0;v<h.length;v++){const S=h[v];S.pbo&&this.has(S.pbo)&&this.textureUtils.copyBufferToTexture(S.transformBuffer,S.pbo),S.switchBuffers()}}finishCompute(e){const{state:t,gl:n}=this;this.discard=!1,t.disable(n.RASTERIZER_DISCARD),this.prepareTimestampBuffer(pa.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}draw(e){const{object:t,pipeline:n,material:r,context:s,hardwareClippingPlanes:o}=e,{programGPU:u}=this.get(n),{gl:c,state:h}=this,d=this.get(s),p=e.getDrawParameters();if(p===null)return;this._bindUniforms(e.getBindings());const g=t.isMesh&&t.matrixWorld.determinant()<0;h.setMaterial(r,g,o),s.mrt!==null&&s.textures!==null&&h.setMRTBlending(s.textures,s.mrt,r),h.useProgram(u);const _=e.getAttributes(),v=this.get(_);let S=v.vaoGPU;if(S===void 0){const A=this._getVaoKey(_);S=this.vaoCache[A],S===void 0&&(S=this._createVao(_),this.vaoCache[A]=S,v.vaoGPU=S)}const b=e.getIndex(),x=b!==null?this.get(b).bufferGPU:null;h.setVertexState(S,x);const M=d.lastOcclusionObject;if(M!==t&&M!==void 0){if(M!==null&&M.occlusionTest===!0&&(c.endQuery(c.ANY_SAMPLES_PASSED),d.occlusionQueryIndex++),t.occlusionTest===!0){const A=c.createQuery();c.beginQuery(c.ANY_SAMPLES_PASSED,A),d.occlusionQueries[d.occlusionQueryIndex]=A,d.occlusionQueryObjects[d.occlusionQueryIndex]=t}d.lastOcclusionObject=t}const E=this.bufferRenderer;t.isPoints?E.mode=c.POINTS:t.isLineSegments?E.mode=c.LINES:t.isLine?E.mode=c.LINE_STRIP:t.isLineLoop?E.mode=c.LINE_LOOP:r.wireframe===!0?(h.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),E.mode=c.LINES):E.mode=c.TRIANGLES;const{vertexCount:w,instanceCount:D}=p;let{firstVertex:C}=p;if(E.object=t,b!==null){C*=b.array.BYTES_PER_ELEMENT;const A=this.get(b);E.index=b.count,E.type=A.type}else E.index=0;const N=()=>{t.isBatchedMesh?t._multiDrawInstances!==null?(xn("WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),E.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?E.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):xn("WebGLBackend: WEBGL_multi_draw not supported."):D>1?E.renderInstances(C,w,D):E.render(C,w)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const A=this.get(e.camera),L=e.camera.cameras,j=e.getBindingGroup("cameraIndex").bindings[0];if(A.indexesGPU===void 0||A.indexesGPU.length!==L.length){const I=new Uint32Array([0,0,0,0]),F=[];for(let Y=0,se=L.length;Y<se;Y++){const Te=c.createBuffer();I[0]=Y,c.bindBuffer(c.UNIFORM_BUFFER,Te),c.bufferData(c.UNIFORM_BUFFER,I,c.STATIC_DRAW),F.push(Te)}A.indexesGPU=F}const z=this.get(j),H=this.renderer.getPixelRatio(),K=this._currentContext.renderTarget,te=this._isRenderCameraDepthArray(this._currentContext),Z=this._currentContext.activeCubeFace;if(te){const I=this.get(K.depthTexture);if(I.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){I.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;const{stencilBuffer:F}=K;for(let Y=0,se=L.length;Y<se;Y++)this.renderer._activeCubeFace=Y,this._currentContext.activeCubeFace=Y,this._setFramebuffer(this._currentContext),this.clear(!1,!0,F,this._currentContext,!1,!1);this.renderer._activeCubeFace=Z,this._currentContext.activeCubeFace=Z}}for(let I=0,F=L.length;I<F;I++){const Y=L[I];if(t.layers.test(Y.layers)){te&&(this.renderer._activeCubeFace=I,this._currentContext.activeCubeFace=I,this._setFramebuffer(this._currentContext));const se=Y.viewport;if(se!==void 0){const Te=se.x*H,O=se.y*H,W=se.width*H,ce=se.height*H;h.viewport(Math.floor(Te),Math.floor(e.context.height-ce-O),Math.floor(W),Math.floor(ce))}h.bindBufferBase(c.UNIFORM_BUFFER,z.index,A.indexesGPU[I]),N()}this._currentContext.activeCubeFace=Z,this.renderer._activeCubeFace=Z}}else N()}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,r,s,o){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,o)}updateSampler(){return""}createNodeBuilder(e,t){return new IX(e,t)}createProgram(e){const t=this.gl,{stage:n,code:r}=e,s=n==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(s,r),t.compileShader(s),this.set(e,{shaderGPU:s})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,r=e.pipeline,{fragmentProgram:s,vertexProgram:o}=r,u=n.createProgram(),c=this.get(s).shaderGPU,h=this.get(o).shaderGPU;if(n.attachShader(u,c),n.attachShader(u,h),n.linkProgram(u),this.set(r,{programGPU:u,fragmentShader:c,vertexShader:h}),t!==null&&this.parallel){const d=new Promise(p=>{const g=this.parallel,_=()=>{n.getProgramParameter(u,g.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),p()):requestAnimationFrame(_)};_()});t.push(d);return}this._completeCompile(e,r)}_handleSource(e,t){const n=e.split(`
`),r=[],s=Math.max(t-6,0),o=Math.min(t+6,n.length);for(let u=s;u<o;u++){const c=u+1;r.push(`${c===t?">":" "} ${c}: ${n[u]}`)}return r.join(`
`)}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),o=(e.getShaderInfoLog(t)||"").trim();if(r&&o==="")return"";const u=/ERROR: 0:(\d+)/.exec(o);if(u){const c=parseInt(u[1]);return n.toUpperCase()+`

`+o+`

`+this._handleSource(e.getShaderSource(t),c)}else return o}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const r=this.gl,o=(r.getProgramInfoLog(e)||"").trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,n,t);else{const u=this._getShaderErrors(r,n,"vertex"),c=this._getShaderErrors(r,t,"fragment");Pe("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+`

Program Info Log: `+o+`
`+u+`
`+c)}else o!==""&&Ne("WebGLProgram: Program Info Log:",o)}}_completeCompile(e,t){const{state:n,gl:r}=this,s=this.get(t),{programGPU:o,fragmentShader:u,vertexShader:c}=s;r.getProgramParameter(o,r.LINK_STATUS)===!1&&this._logProgramError(o,u,c),n.useProgram(o);const h=e.getBindings();this._setupBindings(h,o),this.set(t,{programGPU:o})}createComputePipeline(e,t){const{state:n,gl:r}=this,s={stage:"fragment",code:`#version 300 es
precision highp float;
void main() {}`};this.createProgram(s);const{computeProgram:o}=e,u=r.createProgram(),c=this.get(s).shaderGPU,h=this.get(o).shaderGPU,d=o.transforms,p=[],g=[];for(let b=0;b<d.length;b++){const x=d[b];p.push(x.varyingName),g.push(x.attributeNode)}r.attachShader(u,c),r.attachShader(u,h),r.transformFeedbackVaryings(u,p,r.SEPARATE_ATTRIBS),r.linkProgram(u),r.getProgramParameter(u,r.LINK_STATUS)===!1&&this._logProgramError(u,c,h),n.useProgram(u),this._setupBindings(t,u);const _=o.attributes,v=[],S=[];for(let b=0;b<_.length;b++){const x=_[b].node.attribute;v.push(x),this.has(x)||this.attributeUtils.createAttribute(x,r.ARRAY_BUFFER)}for(let b=0;b<g.length;b++){const x=g[b].attribute;this.has(x)||this.attributeUtils.createAttribute(x,r.ARRAY_BUFFER);const M=this.get(x);S.push(M)}this.set(e,{programGPU:u,transformBuffers:S,attributes:v})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let n=0,r=0;for(const s of t){this.set(s,{textures:r,uniformBuffers:n});for(const o of s.bindings)o.isUniformBuffer&&n++,o.isSampledTexture&&r++}}this.updateBindings(e,t)}updateBindings(e){const{gl:t}=this,n=this.get(e);let r=n.uniformBuffers,s=n.textures;for(const o of e.bindings){const u=this.get(o);if(o.isUniformsGroup||o.isUniformBuffer){const c=o.buffer;let{bufferGPU:h}=this.get(c);h===void 0?(h=t.createBuffer(),t.bindBuffer(t.UNIFORM_BUFFER,h),t.bufferData(t.UNIFORM_BUFFER,c.byteLength,t.DYNAMIC_DRAW),this.set(c,{bufferGPU:h})):t.bindBuffer(t.UNIFORM_BUFFER,h);const d=o.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,h),d.length===0)t.bufferData(t.UNIFORM_BUFFER,c,t.DYNAMIC_DRAW);else{const p=m_(c),g=p?1:c.BYTES_PER_ELEMENT;for(let _=0,v=d.length;_<v;_++){const S=d[_],b=S.start*g,x=S.count*g,M=b*(p?c.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,M,c,b,x)}}u.index=r++,u.bufferGPU=h,this.set(o,u)}else if(o.isSampledTexture){const{textureGPU:c,glTextureType:h}=this.get(o.texture);u.index=s++,u.textureGPU=c,u.glTextureType=h,this.set(o,u)}}}updateBinding(e){const t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){const r=this.get(e).bufferGPU,s=e.buffer,o=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,r),o.length===0)t.bufferData(t.UNIFORM_BUFFER,s,t.DYNAMIC_DRAW);else{const u=m_(s),c=u?1:s.BYTES_PER_ELEMENT;for(let h=0,d=o.length;h<d;h++){const p=o[h],g=p.start*c,_=p.count*c,v=g*(u?s.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,v,s,g,_)}}}}createIndexAttribute(e){const t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){const t=Object.keys(JC).filter(r=>JC[r]===e),n=this.extensions;for(let r=0;r<t.length;r++)if(n.has(t[r]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,n=null,r=null,s=0,o=0){this.textureUtils.copyTextureToTexture(e,t,n,r,s,o)}copyFramebufferToTexture(e,t,n){this.textureUtils.copyFramebufferToTexture(e,t,n)}hasCompatibility(e){return e===mo.TEXTURE_COMPARE?!0:super.hasCompatibility(e)}initRenderTarget(e){const{gl:t,state:n}=this;this._setFramebuffer(e),n.bindFramebuffer(t.FRAMEBUFFER,null)}_setFramebuffer(e){const{gl:t,state:n}=this;let r=null;if(e.textures!==null){const s=e.renderTarget,o=this.get(s),{samples:u,depthBuffer:c,stencilBuffer:h}=s,d=s.isCubeRenderTarget===!0,p=s.isRenderTarget3D===!0,g=s.depth>1,_=s.isXRRenderTarget===!0,v=_===!0&&s._hasExternalTextures===!0;let S=o.msaaFrameBuffer,b=o.depthRenderbuffer;const x=this.extensions.get("WEBGL_multisampled_render_to_texture"),M=this.extensions.get("OVR_multiview2"),E=this._useMultisampledExtension(s),w=N3(e);let D;if(d?(o.cubeFramebuffers||(o.cubeFramebuffers={}),D=o.cubeFramebuffers[w]):_&&v===!1?D=this._xrFramebuffer:(o.framebuffers||(o.framebuffers={}),D=o.framebuffers[w]),D===void 0){D=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,D);const C=e.textures,N=[];if(d){o.cubeFramebuffers[w]=D;const{textureGPU:L}=this.get(C[0]),j=this.renderer._activeCubeFace,z=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+j,L,z)}else{o.framebuffers[w]=D;for(let L=0;L<C.length;L++){const j=C[L],z=this.get(j);z.renderTarget=e.renderTarget,z.cacheKey=w;const H=t.COLOR_ATTACHMENT0+L;if(s.multiview)M.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,H,z.textureGPU,0,u,0,2);else if(p||g){const K=this.renderer._activeCubeFace,te=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,H,z.textureGPU,te,K)}else if(E)x.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,H,t.TEXTURE_2D,z.textureGPU,0,u);else{const K=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,H,t.TEXTURE_2D,z.textureGPU,K)}}}const A=h?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(s._autoAllocateDepthBuffer===!0){const L=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(L,e,0,E),o.xrDepthRenderbuffer=L,N.push(h?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,L),t.framebufferRenderbuffer(t.FRAMEBUFFER,A,t.RENDERBUFFER,L)}else if(e.depthTexture!==null){N.push(h?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);const L=this.get(e.depthTexture);if(L.renderTarget=e.renderTarget,L.cacheKey=w,s.multiview)M.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,A,L.textureGPU,0,u,0,2);else if(v&&E)x.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,A,t.TEXTURE_2D,L.textureGPU,0,u);else if(e.depthTexture.isArrayTexture){const j=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,A,L.textureGPU,0,j)}else if(e.depthTexture.isCubeTexture){const j=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,A,t.TEXTURE_CUBE_MAP_POSITIVE_X+j,L.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,A,t.TEXTURE_2D,L.textureGPU,0)}o.depthInvalidationArray=N}else{if(this._isRenderCameraDepthArray(e)){n.bindFramebuffer(t.FRAMEBUFFER,D);const N=this.renderer._activeCubeFace,A=this.get(e.depthTexture),L=h?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,L,A.textureGPU,0,N)}if((_||E||s.multiview)&&s._isOpaqueFramebuffer!==!0){n.bindFramebuffer(t.FRAMEBUFFER,D);const N=this.get(e.textures[0]);s.multiview?M.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,N.textureGPU,0,u,0,2):E?x.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,N.textureGPU,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,N.textureGPU,0);const A=h?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(s._autoAllocateDepthBuffer===!0){const L=o.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,L),t.framebufferRenderbuffer(t.FRAMEBUFFER,A,t.RENDERBUFFER,L)}else{const L=this.get(e.depthTexture);s.multiview?M.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,A,L.textureGPU,0,u,0,2):E?x.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,A,t.TEXTURE_2D,L.textureGPU,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,A,t.TEXTURE_2D,L.textureGPU,0)}}}if(u>0&&E===!1&&!s.multiview){if(S===void 0){const C=[];S=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,S);const N=[],A=e.textures;for(let L=0;L<A.length;L++){N[L]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,N[L]),C.push(t.COLOR_ATTACHMENT0+L);const j=e.textures[L],z=this.get(j);t.renderbufferStorageMultisample(t.RENDERBUFFER,u,z.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+L,t.RENDERBUFFER,N[L])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),o.msaaFrameBuffer=S,o.msaaRenderbuffers=N,c&&b===void 0){b=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(b,e,u),o.depthRenderbuffer=b;const L=h?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;C.push(L)}o.invalidationArray=C}r=o.msaaFrameBuffer}else r=D;n.drawBuffers(e,D)}n.bindFramebuffer(t.FRAMEBUFFER,r)}_getVaoKey(e){let t="";for(let n=0;n<e.length;n++){const r=this.get(e[n]);t+=":"+r.id}return t}_createVao(e){const{gl:t}=this,n=t.createVertexArray();t.bindVertexArray(n);for(let r=0;r<e.length;r++){const s=e[r],o=this.get(s);t.bindBuffer(t.ARRAY_BUFFER,o.bufferGPU),t.enableVertexAttribArray(r);let u,c;s.isInterleavedBufferAttribute===!0?(u=s.data.stride*o.bytesPerElement,c=s.offset*o.bytesPerElement):(u=0,c=0),o.isInteger?t.vertexAttribIPointer(r,s.itemSize,o.type,u,c):t.vertexAttribPointer(r,s.itemSize,o.type,s.normalized,u,c),s.isInstancedBufferAttribute&&!s.isInterleavedBufferAttribute?t.vertexAttribDivisor(r,s.meshPerAttribute):s.isInterleavedBufferAttribute&&s.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(r,s.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),n}_getTransformFeedback(e){let t="";for(let s=0;s<e.length;s++)t+=":"+e[s].id;let n=this.transformFeedbackCache[t];if(n!==void 0)return n;const{gl:r}=this;n=r.createTransformFeedback(),r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,n);for(let s=0;s<e.length;s++){const o=e[s];r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,s,o.transformBuffer)}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=n,n}_setupBindings(e,t){const n=this.gl;for(const r of e)for(const s of r.bindings){const u=this.get(s).index;if(s.isUniformsGroup||s.isUniformBuffer){const c=n.getUniformBlockIndex(t,s.name);n.uniformBlockBinding(t,c,u)}else if(s.isSampledTexture){const c=n.getUniformLocation(t,s.name);n.uniform1i(c,u)}}}_bindUniforms(e){const{gl:t,state:n}=this;for(const r of e)for(const s of r.bindings){const o=this.get(s),u=o.index;s.isUniformsGroup||s.isUniformBuffer?n.bindBufferBase(t.UNIFORM_BUFFER,u,o.bufferGPU):s.isSampledTexture&&n.bindTexture(o.glTextureType,o.textureGPU,t.TEXTURE0+u)}}_resolveRenderTarget(e){const{gl:t,state:n}=this,r=e.renderTarget;if(e.textures!==null&&r){const s=this.get(r);if(r.samples>0&&this._useMultisampledExtension(r)===!1){const o=s.framebuffers[e.getCacheKey()];let u=t.COLOR_BUFFER_BIT;r.resolveDepthBuffer&&(r.depthBuffer&&(u|=t.DEPTH_BUFFER_BIT),r.stencilBuffer&&r.resolveStencilBuffer&&(u|=t.STENCIL_BUFFER_BIT));const c=s.msaaFrameBuffer,h=s.msaaRenderbuffers,d=e.textures,p=d.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,c),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,o),p)for(let g=0;g<d.length;g++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+g,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+g,t.TEXTURE_2D,null,0);for(let g=0;g<d.length;g++){if(p){const{textureGPU:_}=this.get(d[g]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,h[g]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,_,0)}if(e.scissor){const{x:_,y:v,width:S,height:b}=e.scissorValue,x=e.height-b-v;t.blitFramebuffer(_,x,_+S,x+b,_,x,_+S,x+b,u,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,u,t.NEAREST)}if(p)for(let g=0;g<d.length;g++){const{textureGPU:_}=this.get(d[g]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+g,t.RENDERBUFFER,h[g]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+g,t.TEXTURE_2D,_,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,s.invalidationArray)}else if(r.resolveDepthBuffer===!1&&s.framebuffers){const o=s.framebuffers[e.getCacheKey()];n.bindFramebuffer(t.DRAW_FRAMEBUFFER,o),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,s.depthInvalidationArray)}}}_useMultisampledExtension(e){return e.multiview===!0?!0:e.samples>0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const Xg={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list"},ma=typeof self<"u"&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Vi={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},fr={Store:"store"},mn={Load:"load",Clear:"clear"},tN={CCW:"ccw",CW:"cw"},nN={None:"none",Back:"back"},P_={Uint16:"uint16",Uint32:"uint32"},X={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},ab={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},aa={Linear:"linear",Nearest:"nearest"},Kt={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},iu={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},iN={None:0,All:15},sl={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},ob={Storage:"storage",ReadOnlyStorage:"read-only-storage"},lb={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},rN={NonFiltering:"non-filtering",Comparison:"comparison"},ru={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},sN={TwoD:"2d",ThreeD:"3d"},er={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},YX={All:"all"},Yg={Vertex:"vertex",Instance:"instance"},sS={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},aN={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class KX extends Y3{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class ZX extends W3{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let QX=0;class JX extends ZX{constructor(e,t){super("StorageBuffer_"+QX++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:ys.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}class eY extends Cl{constructor(e){super(),this.device=e;const t=`
struct VarysStruct {
	@builtin( position ) Position: vec4f,
	@location( 0 ) vTex : vec2f,
	@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,
};

@group( 0 ) @binding ( 2 )
var<uniform> flipY: u32;

@vertex
fn mainVS(
		@builtin( vertex_index ) vertexIndex : u32,
		@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {

	var Varys : VarysStruct;

	var pos = array(
		vec2f( -1, -1 ),
		vec2f( -1,  3 ),
		vec2f(  3, -1 ),
	);

	let p = pos[ vertexIndex ];
	let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );
	Varys.vTex = p * mult + vec2f( 0.5 );
	Varys.Position = vec4f( p, 0, 1 );
	Varys.vBaseArrayLayer = instanceIndex;

	return Varys;

}

@group( 0 ) @binding( 0 )
var imgSampler : sampler;

@group( 0 ) @binding( 1 )
var img2d : texture_2d<f32>;

@fragment
fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {

	return textureSample( img2d, imgSampler, Varys.vTex );

}

@group( 0 ) @binding( 1 )
var img2dArray : texture_2d_array<f32>;

@fragment
fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {

	return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );

}

const faceMat = array(
  mat3x3f(  0,  0,  -2,  0, -2,   0,  1,  1,   1 ),   // pos-x
  mat3x3f(  0,  0,   2,  0, -2,   0, -1,  1,  -1 ),   // neg-x
  mat3x3f(  2,  0,   0,  0,  0,   2, -1,  1,  -1 ),   // pos-y
  mat3x3f(  2,  0,   0,  0,  0,  -2, -1, -1,   1 ),   // neg-y
  mat3x3f(  2,  0,   0,  0, -2,   0, -1,  1,   1 ),   // pos-z
  mat3x3f( -2,  0,   0,  0, -2,   0,  1,  1,  -1 ),   // neg-z
);

@group( 0 ) @binding( 1 )
var imgCube : texture_cube<f32>;

@fragment
fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {

	return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );

}
`;this.mipmapSampler=e.createSampler({minFilter:aa.Linear}),this.flipYSampler=e.createSampler({minFilter:aa.Nearest}),this.flipUniformBuffer=e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),this.noFlipUniformBuffer=e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM}),this.transferPipelines={},this.mipmapShaderModule=e.createShaderModule({label:"mipmap",code:t})}getTransferPipeline(e,t){t=t||"2d-array";const n=`${e}-${t}`;let r=this.transferPipelines[n];return r===void 0&&(r=this.device.createRenderPipeline({label:`mipmap-${e}-${t}`,vertex:{module:this.mipmapShaderModule},fragment:{module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},layout:"auto"}),this.transferPipelines[n]=r),r}flipY(e,t,n=0){const r=t.format,{width:s,height:o}=t.size,u=this.device.createTexture({size:{width:s,height:o},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),c=this.getTransferPipeline(r,e.textureBindingViewDimension),h=this.getTransferPipeline(r,u.textureBindingViewDimension),d=this.device.createCommandEncoder({}),p=(g,_,v,S,b,x)=>{const M=g.getBindGroupLayout(0),E=this.device.createBindGroup({layout:M,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:_.createView({dimension:_.textureBindingViewDimension||"2d-array",baseMipLevel:0,mipLevelCount:1})},{binding:2,resource:{buffer:x?this.flipUniformBuffer:this.noFlipUniformBuffer}}]}),w=d.beginRenderPass({colorAttachments:[{view:S.createView({dimension:"2d",baseMipLevel:0,mipLevelCount:1,baseArrayLayer:b,arrayLayerCount:1}),loadOp:mn.Clear,storeOp:fr.Store}]});w.setPipeline(g),w.setBindGroup(0,E),w.draw(3,1,0,v),w.end()};p(c,e,n,u,0,!1),p(h,u,0,e,n,!0),this.device.queue.submit([d.finish()]),u.destroy()}generateMipmaps(e,t=null){const n=this.get(e),r=n.layers||this._mipmapCreateBundles(e),s=t||this.device.createCommandEncoder({label:"mipmapEncoder"});this._mipmapRunBundles(s,r),t===null&&this.device.queue.submit([s.finish()]),n.layers=r}_mipmapCreateBundles(e){const t=e.textureBindingViewDimension||"2d-array",n=this.getTransferPipeline(e.format,t),r=n.getBindGroupLayout(0),s=[];for(let o=1;o<e.mipLevelCount;o++)for(let u=0;u<e.depthOrArrayLayers;u++){const c=this.device.createBindGroup({layout:r,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:e.createView({dimension:t,baseMipLevel:o-1,mipLevelCount:1})},{binding:2,resource:{buffer:this.noFlipUniformBuffer}}]}),h={colorAttachments:[{view:e.createView({dimension:"2d",baseMipLevel:o,mipLevelCount:1,baseArrayLayer:u,arrayLayerCount:1}),loadOp:mn.Clear,storeOp:fr.Store}]},d=this.device.createRenderBundleEncoder({colorFormats:[e.format]});d.setPipeline(n),d.setBindGroup(0,c),d.draw(3,1,0,u),s.push({renderBundles:[d.finish()],passDescriptor:h})}return s}_mipmapRunBundles(e,t){const n=t.length;for(let r=0;r<n;r++){const s=t[r],o=e.beginRenderPass(s.passDescriptor);o.executeBundles(s.renderBundles),o.end()}}}const tY={[zS]:"never",[W_]:"less",[kS]:"equal",[wl]:"less-equal",[up]:"greater",[bo]:"greater-equal",[VS]:"always",[GS]:"not-equal"},nY=[0,1,3,2,4,5];class iY{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){const t=this.backend,n=e.minFilter+"-"+e.magFilter+"-"+e.wrapS+"-"+e.wrapT+"-"+(e.wrapR||"0")+"-"+e.anisotropy+"-"+(e.compareFunction||0);let r=this._samplerCache.get(n);if(r===void 0){const o={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};e.isDepthTexture&&e.compareFunction===null&&(o.magFilter=aa.Nearest,o.minFilter=aa.Nearest,o.mipmapFilter=aa.Nearest),o.magFilter===aa.Linear&&o.minFilter===aa.Linear&&o.mipmapFilter===aa.Linear&&(o.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&t.hasCompatibility(mo.TEXTURE_COMPARE)&&(o.compare=tY[e.compareFunction]),r={sampler:t.device.createSampler(o),usedTimes:0},this._samplerCache.set(n,r)}const s=t.get(e);if(s.sampler!==r.sampler){if(s.sampler!==void 0){const o=this._samplerCache.get(s.samplerKey);o.usedTimes--,o.usedTimes===0&&this._samplerCache.delete(s.samplerKey)}s.samplerKey=n,s.sampler=r.sampler,r.usedTimes++}return n}createDefaultTexture(e){let t;const n=aS(e);e.isCubeTexture?t=this._getDefaultCubeTextureGPU(n):t=this._getDefaultTextureGPU(n),this.backend.get(e).texture=t}createTexture(e,t={}){const n=this.backend,r=n.get(e);if(r.initialized)throw new Error("WebGPUTextureUtils: Texture already initialized.");if(e.isExternalTexture){r.texture=e.sourceTexture,r.initialized=!0;return}t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);const{width:s,height:o,depth:u,levels:c}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());const h=this._getDimension(e),d=e.internalFormat||t.format||aS(e,n.device);r.format=d;const{samples:p,primarySamples:g,isMSAA:_}=n.utils.getTextureSampleData(e);let v=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(v|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&d!==X.RGB9E5UFloat&&(v|=GPUTextureUsage.RENDER_ATTACHMENT);const S={label:e.name,size:{width:s,height:o,depthOrArrayLayers:u},mipLevelCount:c,sampleCount:g,dimension:h,format:d,usage:v};if(d===void 0){Ne("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}e.isCubeTexture&&(S.textureBindingViewDimension=er.Cube);try{r.texture=n.device.createTexture(S)}catch{Ne("WebGPURenderer: Failed to create texture with descriptor:",S),this.createDefaultTexture(e);return}if(_){const b=Object.assign({},S);b.label=b.label+"-msaa",b.sampleCount=p,b.mipLevelCount=1,r.msaaTexture=n.device.createTexture(b)}r.initialized=!0,r.textureDescriptorGPU=S}destroyTexture(e,t=!1){const n=this.backend,r=n.get(e);r.texture!==void 0&&t===!1&&r.texture.destroy(),r.msaaTexture!==void 0&&r.msaaTexture.destroy(),n.delete(e)}generateMipmaps(e,t=null){const n=this.backend.get(e);this._generateMipmaps(n.texture,t)}getColorBuffer(){const e=this.backend,t=e.renderer.getCanvasTarget(),{width:n,height:r}=e.getDrawingBufferSize(),s=e.renderer.currentSamples,o=t.colorTexture,u=e.get(o);if(o.width===n&&o.height===r&&o.samples===s)return u.texture;let c=u.texture;return c&&c.destroy(),c=e.device.createTexture({label:"colorBuffer",size:{width:n,height:r,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.currentSamples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),o.source.width=n,o.source.height=r,o.samples=s,u.texture=c,c}getDepthBuffer(e=!0,t=!1){const n=this.backend,r=n.renderer.getCanvasTarget(),{width:s,height:o}=n.getDrawingBufferSize(),u=n.renderer.currentSamples,c=r.depthTexture;if(c.width===s&&c.height===o&&c.samples===u&&c.depth===e&&c.stencil===t)return n.get(c).texture;const h=n.get(c).texture;let d,p;if(t?(d=_r,p=is):e&&(d=Wi,p=bn),h!==void 0){if(c.image.width===s&&c.image.height===o&&c.format===d&&c.type===p&&c.samples===u)return h;this.destroyTexture(c)}return c.name="depthBuffer",c.format=d,c.type=p,c.image.width=s,c.image.height=o,c.samples=u,this.createTexture(c,{width:s,height:o}),n.get(c).texture}updateTexture(e,t){const n=this.backend.get(e),r=e.mipmaps,{textureDescriptorGPU:s}=n;if(!(e.isRenderTargetTexture||s===void 0)){if(e.isDataTexture)if(r.length>0)for(let o=0,u=r.length;o<u;o++){const c=r[o];this._copyBufferToTexture(c,n.texture,s,0,e.flipY,0,o)}else this._copyBufferToTexture(t.image,n.texture,s,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let o=0;o<t.image.depth;o++)this._copyBufferToTexture(t.image,n.texture,s,o,e.flipY,o);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,n.texture,s);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,n.texture,s);else if(r.length>0)for(let o=0,u=r.length;o<u;o++){const c=r[o];this._copyImageToTexture(c,n.texture,s,0,e.flipY,e.premultiplyAlpha,o)}else this._copyImageToTexture(t.image,n.texture,s,0,e.flipY,e.premultiplyAlpha);n.version=e.version}}async copyTextureToBuffer(e,t,n,r,s,o){const u=this.backend.device,c=this.backend.get(e),h=c.texture,d=c.textureDescriptorGPU.format,p=this._getBytesPerTexel(d);let g=r*p;g=Math.ceil(g/256)*256;const _=u.createBuffer({size:(s-1)*g+r*p,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),v=u.createCommandEncoder();v.copyTextureToBuffer({texture:h,origin:{x:t,y:n,z:o}},{buffer:_,bytesPerRow:g},{width:r,height:s});const S=this._getTypedArrayType(d);u.queue.submit([v.finish()]),await _.mapAsync(GPUMapMode.READ);const b=_.getMappedRange();return new S(b)}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const n=new vi;n.minFilter=hn,n.magFilter=hn,this.createTexture(n,{width:1,height:1,format:e}),this.defaultTexture[e]=t=n}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultCubeTexture[e];if(t===void 0){const n=new Kh;n.minFilter=hn,n.magFilter=hn,this.createTexture(n,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=n}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,n){const r=e.images,s=e.mipmaps;for(let o=0;o<6;o++){const u=r[o],c=e.flipY===!0?nY[o]:o;u.isDataTexture?this._copyBufferToTexture(u.image,t,n,c,e.flipY):this._copyImageToTexture(u,t,n,c,e.flipY,e.premultiplyAlpha);for(let h=0;h<s.length;h++){const p=s[h].images[o];p.isDataTexture?this._copyBufferToTexture(p.image,t,n,c,e.flipY,0,h+1):this._copyImageToTexture(p,t,n,c,e.flipY,e.premultiplyAlpha,h+1)}}}_copyImageToTexture(e,t,n,r,s,o,u=0){const c=this.backend.device,h=u>0?e.width:n.size.width,d=u>0?e.height:n.size.height;try{c.queue.copyExternalImageToTexture({source:e,flipY:s},{texture:t,mipLevel:u,origin:{x:0,y:0,z:r},premultipliedAlpha:o},{width:h,height:d,depthOrArrayLayers:1})}catch{}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new eY(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,r,s,o=0,u=0){const c=this.backend.device,h=e.data,d=this._getBytesPerTexel(n.format),p=e.width*d;c.queue.writeTexture({texture:t,mipLevel:u,origin:{x:0,y:0,z:r}},h,{offset:e.width*e.height*d*o,bytesPerRow:p},{width:e.width,height:e.height,depthOrArrayLayers:1}),s===!0&&this._flipY(t,n,r)}_copyCompressedBufferToTexture(e,t,n){const r=this.backend.device,s=this._getBlockData(n.format),o=n.size.depthOrArrayLayers>1;for(let u=0;u<e.length;u++){const c=e[u],h=c.width,d=c.height,p=o?n.size.depthOrArrayLayers:1,g=Math.ceil(h/s.width)*s.byteLength,_=g*Math.ceil(d/s.height);for(let v=0;v<p;v++)r.queue.writeTexture({texture:t,mipLevel:u,origin:{x:0,y:0,z:v}},c.data,{offset:v*_,bytesPerRow:g,rowsPerImage:Math.ceil(d/s.height)},{width:Math.ceil(h/s.width)*s.width,height:Math.ceil(d/s.height)*s.height,depthOrArrayLayers:1})}}_getBlockData(e){if(e===X.BC1RGBAUnorm||e===X.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===X.BC2RGBAUnorm||e===X.BC2RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===X.BC3RGBAUnorm||e===X.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===X.BC4RUnorm||e===X.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===X.BC5RGUnorm||e===X.BC5RGSnorm)return{byteLength:16,width:4,height:4};if(e===X.BC6HRGBUFloat||e===X.BC6HRGBFloat)return{byteLength:16,width:4,height:4};if(e===X.BC7RGBAUnorm||e===X.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===X.ETC2RGB8Unorm||e===X.ETC2RGB8UnormSRGB)return{byteLength:8,width:4,height:4};if(e===X.ETC2RGB8A1Unorm||e===X.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===X.ETC2RGBA8Unorm||e===X.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===X.EACR11Unorm)return{byteLength:8,width:4,height:4};if(e===X.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===X.EACRG11Unorm)return{byteLength:16,width:4,height:4};if(e===X.EACRG11Snorm)return{byteLength:16,width:4,height:4};if(e===X.ASTC4x4Unorm||e===X.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===X.ASTC5x4Unorm||e===X.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===X.ASTC5x5Unorm||e===X.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===X.ASTC6x5Unorm||e===X.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===X.ASTC6x6Unorm||e===X.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===X.ASTC8x5Unorm||e===X.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===X.ASTC8x6Unorm||e===X.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===X.ASTC8x8Unorm||e===X.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===X.ASTC10x5Unorm||e===X.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===X.ASTC10x6Unorm||e===X.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===X.ASTC10x8Unorm||e===X.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===X.ASTC10x10Unorm||e===X.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===X.ASTC12x10Unorm||e===X.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===X.ASTC12x12Unorm||e===X.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=ab.ClampToEdge;return e===Eu?t=ab.Repeat:e===Au&&(t=ab.MirrorRepeat),t}_convertFilterMode(e){let t=aa.Linear;return(e===hn||e===FS||e===ho)&&(t=aa.Nearest),t}_getBytesPerTexel(e){if(e===X.R8Unorm||e===X.R8Snorm||e===X.R8Uint||e===X.R8Sint)return 1;if(e===X.R16Uint||e===X.R16Sint||e===X.R16Float||e===X.RG8Unorm||e===X.RG8Snorm||e===X.RG8Uint||e===X.RG8Sint)return 2;if(e===X.R32Uint||e===X.R32Sint||e===X.R32Float||e===X.RG16Uint||e===X.RG16Sint||e===X.RG16Float||e===X.RGBA8Unorm||e===X.RGBA8UnormSRGB||e===X.RGBA8Snorm||e===X.RGBA8Uint||e===X.RGBA8Sint||e===X.BGRA8Unorm||e===X.BGRA8UnormSRGB||e===X.RGB9E5UFloat||e===X.RGB10A2Unorm||e===X.RG11B10UFloat||e===X.Depth32Float||e===X.Depth24Plus||e===X.Depth24PlusStencil8||e===X.Depth32FloatStencil8)return 4;if(e===X.RG32Uint||e===X.RG32Sint||e===X.RG32Float||e===X.RGBA16Uint||e===X.RGBA16Sint||e===X.RGBA16Float)return 8;if(e===X.RGBA32Uint||e===X.RGBA32Sint||e===X.RGBA32Float)return 16}_getTypedArrayType(e){if(e===X.R8Uint)return Uint8Array;if(e===X.R8Sint)return Int8Array;if(e===X.R8Unorm)return Uint8Array;if(e===X.R8Snorm)return Int8Array;if(e===X.RG8Uint)return Uint8Array;if(e===X.RG8Sint)return Int8Array;if(e===X.RG8Unorm)return Uint8Array;if(e===X.RG8Snorm)return Int8Array;if(e===X.RGBA8Uint)return Uint8Array;if(e===X.RGBA8Sint)return Int8Array;if(e===X.RGBA8Unorm||e===X.RGBA8UnormSRGB)return Uint8Array;if(e===X.RGBA8Snorm)return Int8Array;if(e===X.R16Uint)return Uint16Array;if(e===X.R16Sint)return Int16Array;if(e===X.RG16Uint)return Uint16Array;if(e===X.RG16Sint)return Int16Array;if(e===X.RGBA16Uint)return Uint16Array;if(e===X.RGBA16Sint)return Int16Array;if(e===X.R16Float||e===X.RG16Float||e===X.RGBA16Float)return Uint16Array;if(e===X.R32Uint)return Uint32Array;if(e===X.R32Sint)return Int32Array;if(e===X.R32Float)return Float32Array;if(e===X.RG32Uint)return Uint32Array;if(e===X.RG32Sint)return Int32Array;if(e===X.RG32Float)return Float32Array;if(e===X.RGBA32Uint)return Uint32Array;if(e===X.RGBA32Sint)return Int32Array;if(e===X.RGBA32Float)return Float32Array;if(e===X.BGRA8Unorm||e===X.BGRA8UnormSRGB)return Uint8Array;if(e===X.RGB10A2Unorm||e===X.RGB9E5UFloat||e===X.RG11B10UFloat)return Uint32Array;if(e===X.Depth32Float)return Float32Array;if(e===X.Depth24Plus||e===X.Depth24PlusStencil8)return Uint32Array;if(e===X.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return e.is3DTexture||e.isData3DTexture?t=sN.ThreeD:t=sN.TwoD,t}}function aS(i,e=null){const t=i.format,n=i.type,r=i.colorSpace,s=xt.getTransfer(r);let o;if(i.isCompressedTexture===!0||i.isCompressedArrayTexture===!0)switch(t){case gl:case _l:o=s===Ye?X.BC1RGBAUnormSRGB:X.BC1RGBAUnorm;break;case vl:o=s===Ye?X.BC2RGBAUnormSRGB:X.BC2RGBAUnorm;break;case yl:o=s===Ye?X.BC3RGBAUnormSRGB:X.BC3RGBAUnorm;break;case Ph:o=X.BC4RUnorm;break;case Uh:o=X.BC4RSnorm;break;case Ru:o=X.BC5RGUnorm;break;case Oh:o=X.BC5RGSnorm;break;case Lh:o=s===Ye?X.BC7RGBAUnormSRGB:X.BC7RGBAUnorm;break;case dh:case fh:o=s===Ye?X.ETC2RGB8UnormSRGB:X.ETC2RGB8Unorm;break;case ph:o=s===Ye?X.ETC2RGBA8UnormSRGB:X.ETC2RGBA8Unorm;break;case mh:o=X.EACR11Unorm;break;case gh:o=X.EACR11Snorm;break;case wu:o=X.EACRG11Unorm;break;case _h:o=X.EACRG11Snorm;break;case vh:o=s===Ye?X.ASTC4x4UnormSRGB:X.ASTC4x4Unorm;break;case yh:o=s===Ye?X.ASTC5x4UnormSRGB:X.ASTC5x4Unorm;break;case xh:o=s===Ye?X.ASTC5x5UnormSRGB:X.ASTC5x5Unorm;break;case bh:o=s===Ye?X.ASTC6x5UnormSRGB:X.ASTC6x5Unorm;break;case Sh:o=s===Ye?X.ASTC6x6UnormSRGB:X.ASTC6x6Unorm;break;case Th:o=s===Ye?X.ASTC8x5UnormSRGB:X.ASTC8x5Unorm;break;case Mh:o=s===Ye?X.ASTC8x6UnormSRGB:X.ASTC8x6Unorm;break;case Eh:o=s===Ye?X.ASTC8x8UnormSRGB:X.ASTC8x8Unorm;break;case Ah:o=s===Ye?X.ASTC10x5UnormSRGB:X.ASTC10x5Unorm;break;case wh:o=s===Ye?X.ASTC10x6UnormSRGB:X.ASTC10x6Unorm;break;case Rh:o=s===Ye?X.ASTC10x8UnormSRGB:X.ASTC10x8Unorm;break;case Ch:o=s===Ye?X.ASTC10x10UnormSRGB:X.ASTC10x10Unorm;break;case Nh:o=s===Ye?X.ASTC12x10UnormSRGB:X.ASTC12x10Unorm;break;case Dh:o=s===Ye?X.ASTC12x12UnormSRGB:X.ASTC12x12Unorm;break;case si:o=s===Ye?X.RGBA8UnormSRGB:X.RGBA8Unorm;break;default:Pe("WebGPURenderer: Unsupported texture format.",t)}else switch(t){case si:switch(n){case _u:o=X.RGBA8Snorm;break;case vu:o=X.RGBA16Sint;break;case Gs:o=X.RGBA16Uint;break;case bn:o=X.RGBA32Uint;break;case Li:o=X.RGBA32Sint;break;case Gn:o=s===Ye?X.RGBA8UnormSRGB:X.RGBA8Unorm;break;case Qn:o=X.RGBA16Float;break;case ri:o=X.RGBA32Float;break;default:Pe("WebGPURenderer: Unsupported texture type with RGBAFormat.",n)}break;case xp:switch(n){case H_:o=X.RGB9E5UFloat;break;case j_:o=X.RG11B10UFloat;break;default:Pe("WebGPURenderer: Unsupported texture type with RGBFormat.",n)}break;case bp:switch(n){case _u:o=X.R8Snorm;break;case vu:o=X.R16Sint;break;case Gs:o=X.R16Uint;break;case bn:o=X.R32Uint;break;case Li:o=X.R32Sint;break;case Gn:o=X.R8Unorm;break;case Qn:o=X.R16Float;break;case ri:o=X.R32Float;break;default:Pe("WebGPURenderer: Unsupported texture type with RedFormat.",n)}break;case vr:switch(n){case _u:o=X.RG8Snorm;break;case vu:o=X.RG16Sint;break;case Gs:o=X.RG16Uint;break;case bn:o=X.RG32Uint;break;case Li:o=X.RG32Sint;break;case Gn:o=X.RG8Unorm;break;case Qn:o=X.RG16Float;break;case ri:o=X.RG32Float;break;default:Pe("WebGPURenderer: Unsupported texture type with RGFormat.",n)}break;case Wi:switch(n){case Gs:o=X.Depth16Unorm;break;case bn:o=X.Depth24Plus;break;case ri:o=X.Depth32Float;break;default:Pe("WebGPURenderer: Unsupported texture type with DepthFormat.",n)}break;case _r:switch(n){case is:o=X.Depth24PlusStencil8;break;case ri:e&&e.features.has(sS.Depth32FloatStencil8)===!1&&Pe('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),o=X.Depth32FloatStencil8;break;default:Pe("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",n)}break;case qh:switch(n){case Li:o=X.R32Sint;break;case bn:o=X.R32Uint;break;default:Pe("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",n)}break;case Xh:switch(n){case Li:o=X.RG32Sint;break;case bn:o=X.RG32Uint;break;default:Pe("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",n)}break;case Yh:switch(n){case Li:o=X.RGBA32Sint;break;case bn:o=X.RGBA32Uint;break;default:Pe("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",n)}break;default:Pe("WebGPURenderer: Unsupported texture format.",t)}return o}const rY=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,sY=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,oN={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},aY=i=>{i=i.trim();const e=i.match(rY);if(e!==null&&e.length===4){const t=e[2],n=[];let r=null;for(;(r=sY.exec(t))!==null;)n.push({name:r[1],type:r[2]});const s=[];for(let d=0;d<n.length;d++){const{name:p,type:g}=n[d];let _=g;_.startsWith("ptr")?_="pointer":(_.startsWith("texture")&&(_=g.split("<")[0]),_=oN[_]),s.push(new BT(_,p))}const o=i.substring(e[0].length),u=e[3]||"void",c=e[1]!==void 0?e[1]:"";return{type:oN[u]||u,inputs:s,name:c,inputsCode:t,blockCode:o,outputType:u}}else throw new Error("FunctionNode: Function is not a WGSL code.")};class oY extends IT{constructor(e){const{type:t,inputs:n,name:r,inputsCode:s,blockCode:o,outputType:u}=aY(e);super(t,n,r),this.inputsCode=s,this.blockCode=o,this.outputType=u}getCode(e=this.name){const t=this.outputType!=="void"?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class lY extends V3{parseFunction(e){return new oY(e)}}const uY={[ys.READ_ONLY]:"read",[ys.WRITE_ONLY]:"write",[ys.READ_WRITE]:"read_write"},lN={[Eu]:"repeat",[Pr]:"clamp",[Au]:"mirror"},ub={vertex:ma.VERTEX,fragment:ma.FRAGMENT,compute:ma.COMPUTE},uN={instance:!0,swizzleAssign:!1,storageBuffer:!0},cY={"^^":"tsl_xor"},hY={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},cN={},Ad={tsl_xor:new Di("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Di("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Di("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Di("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Di("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Di("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Di("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Di("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Di("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Di("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Di("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Di("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Di(`
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {

	let res = vec2f( iRes );

	let uvScaled = coord * res;
	let uvWrapping = ( ( uvScaled % res ) + res ) % res;

	// https://www.shadertoy.com/view/WtyXRy

	let uv = uvWrapping - 0.5;
	let iuv = floor( uv );
	let f = fract( uv );

	let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
	let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
	let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
	let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );

	return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );

}
`),biquadraticTextureArray:new Di(`
fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {

	let res = vec2f( iRes );

	let uvScaled = coord * res;
	let uvWrapping = ( ( uvScaled % res ) + res ) % res;

	// https://www.shadertoy.com/view/WtyXRy

	let uv = uvWrapping - 0.5;
	let iuv = floor( uv );
	let f = fract( uv );

	let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );
	let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );
	let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );
	let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );

	return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );

}
`)},fY={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let J3="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(J3+=`diagnostic( off, derivative_uniformity );
`);class dY extends G3{constructor(e,t){super(e,t,new lY),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,n,r,s,o=this.shaderStage){return o==="fragment"?r?s?`textureSample( ${t}, ${t}_sampler, ${n}, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:s?`textureSample( ${t}, ${t}_sampler, ${n}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,"0",r)}generateTextureSampleLevel(e,t,n,r,s,o){return this.isUnfilterable(e)===!1?s?o?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${r}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${r} )`:o?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,o,r,s):this.generateTextureLod(e,t,n,s,o,r)}generateWrapFunction(e){const t=`tsl_coord_${lN[e.wrapS]}S_${lN[e.wrapT]}_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}T`;let n=cN[t];if(n===void 0){const r=[],s=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let o=`fn ${t}( coord : ${s} ) -> ${s} {

	return ${s}(
`;const u=(c,h)=>{c===Eu?(r.push(Ad.repeatWrapping_float),o+=`		tsl_repeatWrapping_float( coord.${h} )`):c===Pr?(r.push(Ad.clampWrapping_float),o+=`		tsl_clampWrapping_float( coord.${h} )`):c===Au?(r.push(Ad.mirrorWrapping_float),o+=`		tsl_mirrorWrapping_float( coord.${h} )`):(o+=`		coord.${h}`,Ne(`WebGPURenderer: Unsupported texture wrap type "${c}" for vertex shader.`))};u(e.wrapS,"x"),o+=`,
`,u(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(o+=`,
`,u(e.wrapR,"z")),o+=`
	);

}
`,cN[t]=n=new Di(o,r)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let s=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let o,u;const{primarySamples:c}=this.renderer.backend.utils.getTextureSampleData(e),h=c>1;e.is3DTexture||e.isData3DTexture?u="vec3<u32>":u="vec2<u32>",h||e.isStorageTexture?o=t:o=`${t}${n?`, u32( ${n} )`:""}`,s=new u_(new c_(`textureDimensions( ${o} )`,u)),r.dimensionsSnippet[n]=s,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(r.arrayLayerCount=new u_(new c_(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new u_(new c_("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,n,r,s="0u",o){const u=this.generateWrapFunction(e),c=this.generateTextureDimension(e,t,s);return r&&(n=`${n} + vec2<f32>(${r}) / ${c}`),o?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${u}( ${n} ), ${c}, u32( ${o} ), u32( ${s} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${u}( ${n} ), ${c}, u32( ${s} ) )`)}generateTextureLod(e,t,n,r,s,o="0u"){if(e.isCubeTexture===!0){s&&(n=`${n} + vec3<f32>(${s})`);const _=e.isDepthTexture?"u32":"f32";return`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${_}( ${o} ) )`}const u=this.generateWrapFunction(e),c=this.generateTextureDimension(e,t,o),h=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",d=h==="vec3"?"vec3<u32>( 1, 1, 1 )":"vec2<u32>( 1, 1 )";s&&(n=`${n} + ${h}<f32>(${s}) / ${h}<f32>( ${c} )`);const p=`${h}<f32>( 0 )`,g=`${h}<f32>( ${c} - ${d} )`;return n=`${h}<u32>( clamp( floor( ${u}( ${n} ) * ${h}<f32>( ${c} ) ), ${p}, ${g} ) )`,this.generateTextureLoad(e,t,n,o,r,null)}generateStorageTextureLoad(e,t,n,r,s,o){o&&(n=`${n} + ${o}`);let u;return s?u=`textureLoad( ${t}, ${n}, ${s} )`:u=`textureLoad( ${t}, ${n} )`,u}generateTextureLoad(e,t,n,r,s,o){r===null&&(r="0u"),o&&(n=`${n} + ${o}`);let u;return s?u=`textureLoad( ${t}, ${n}, ${s}, u32( ${r} ) )`:(u=`textureLoad( ${t}, ${n}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(u+=".x")),u}generateTextureStore(e,t,n,r,s){let o;return r?o=`textureStore( ${t}, ${n}, ${r}, ${s} )`:o=`textureStore( ${t}, ${n}, ${s} )`,o}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(mo.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===ri||this.isSampleCompare(e)===!1&&e.minFilter===hn&&e.magFilter===hn||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,s,o=this.shaderStage){let u=null;return this.isUnfilterable(e)?u=this.generateTextureLod(e,t,n,r,s,"0",o):u=this._generateTextureSample(e,t,n,r,s,o),u}generateTextureGrad(e,t,n,r,s,o,u=this.shaderStage){if(u==="fragment")return s?o?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${s}, ${r[0]}, ${r[1]}, ${o} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${s}, ${r[0]}, ${r[1]} )`:o?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]}, ${o} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;Pe(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${u} shader.`)}generateTextureCompare(e,t,n,r,s,o,u=this.shaderStage){if(u==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?o?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s}, ${r}, ${o} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${s}, ${r} )`:o?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${o} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;Pe(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${u} shader.`)}generateTextureLevel(e,t,n,r,s,o){return this.isUnfilterable(e)===!1?s?o?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${r}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${s}, ${r} )`:o?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,o,r,s):this.generateTextureLod(e,t,n,s,o,r)}generateTextureBias(e,t,n,r,s,o,u=this.shaderStage){if(u==="fragment")return s?o?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${s}, ${r}, ${o} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${s}, ${r} )`:o?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r}, ${o} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;Pe(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${u} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const n=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="cubeDepthTexture"||r==="storageTexture"||r==="texture3D"?n:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?this.isCustomStruct(e)?n:n+".value":e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=cY[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(Ne("WebGPURenderer: Atomic operations are only supported in compute shaders."),ys.READ_WRITE):ys.READ_ONLY:e.access}getStorageAccess(e,t){return uY[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),o=this.getDataFromNode(e,n,this.globalCache);if(o.uniformGPU===void 0){let u;const c=e.groupNode,h=c.name,d=this.getBindGroupArray(h,n);if(t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"){let p=null;const g=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?p=new rS(s.name,s.node,c,g):p=new d0(s.name,s.node,c,g):t==="cubeTexture"||t==="cubeDepthTexture"?p=new K3(s.name,s.node,c,g):t==="texture3D"&&(p=new rS(s.name,s.node,c,g)),p.store=e.isStorageTextureNode===!0,p.mipLevel=p.store?e.mipLevel:0,p.setVisibility(ub[n]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&p.store===!1){const v=new KX(`${s.name}_sampler`,s.node,c);v.setVisibility(ub[n]),d.push(v,p),u=[v,p]}else d.push(p),u=[p]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const p=this.getSharedDataFromNode(e);let g=p.buffer;if(g===void 0){const _=t==="buffer"?q3:JX;g=new _(e,c),p.buffer=g}g.setVisibility(g.getVisibility()|ub[n]),d.push(g),u=g,s.name=r||"NodeBuffer_"+s.id}else{let p=this.uniformGroups[h];p===void 0&&(p=new X3(h,c),p.setVisibility(ma.VERTEX|ma.FRAGMENT|ma.COMPUTE),this.uniformGroups[h]=p),d.indexOf(p)===-1&&d.push(p),u=this.getNodeUniform(s,t);const g=u.name;p.uniforms.some(v=>v.name===g)||p.addUniform(u)}o.uniformGPU=u}return s}getBuiltin(e,t,n,r=this.shaderStage){const s=this.builtins[r]||(this.builtins[r]=new Map);return s.has(e)===!1&&s.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),r=[];for(const o of t.inputs)r.push(o.name+" : "+this.getType(o.type));let s=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} {
${n.vars}
${n.code}
`;return n.result&&(s+=`	return ${n.result};
`),s+=`
}
`,s}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],n=this.directives[e];if(n!==void 0)for(const r of n)t.push(`enable ${r};`);return t.join(`
`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){const t=[],n=this.builtins[e];if(n!==void 0)for(const{name:r,property:s,type:o}of n.values())t.push(`@builtin( ${r} ) ${s} : ${o}`);return t.join(`,
	`)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:r,bufferType:s,bufferCount:o}of this.scopedArrays.values()){const u=this.getType(s);t.push(`var<${r}> ${n}: array< ${u}, ${o} >;`)}return t.join(`
`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const n=this.getBuiltins("attribute");n&&t.push(n);const r=this.getAttributesArray();for(let s=0,o=r.length;s<o;s++){const u=r[s],c=u.name,h=this.getType(u.type);t.push(`@location( ${s} ) ${c} : ${h}`)}}return t.join(`,
	`)}getStructMembers(e){const t=[];for(const n of e.members){const r=e.output?"@location( "+n.index+" ) ":"";let s=this.getType(n.type);n.atomic&&(s="atomic< "+s+" >"),t.push(`	${r+n.name} : ${s}`)}return e.output&&t.push(`	${this.getBuiltins("output")}`),t.join(`,
`)}getStructs(e){let t="";const n=this.structs[e];if(n.length>0){const r=[];for(const s of n){let o=`struct ${s.name} {
`;o+=this.getStructMembers(s),o+=`
};`,r.push(o)}t=`
`+r.join(`

`)+`
`}return t}getVar(e,t,n=null){let r=`var ${t} : `;return n!==null?r+=this.generateArrayDeclaration(e,n):r+=this.getType(e),r}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(`	${this.getVar(r.type,r.name,r.count)};`);return`
${t.join(`
`)}
`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","builtinClipSpace","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){const s=this.varyings,o=this.vars[e];for(let u=0;u<s.length;u++){const c=s[u];if(c.needsInterpolation){let h=`@location( ${u} )`;if(c.interpolationType){const d=c.interpolationSampling!==null?`, ${c.interpolationSampling} )`:" )";h+=` @interpolate( ${c.interpolationType}${d}`}else/^(int|uint|ivec|uvec)/.test(c.type)&&(h+=" @interpolate(flat, either)");t.push(`${h} ${c.name} : ${this.getType(c.type)}`)}else e==="vertex"&&o.includes(c)===!1&&o.push(c)}}const n=this.getBuiltins(e);n&&t.push(n);const r=t.join(`,
	`);return e==="vertex"?this._getWGSLStruct("VaryingsStruct","	"+r):r}isCustomStruct(e){const t=e.value,n=e.node,r=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&n.structTypeNode!==null,s=n.value&&n.value.array&&typeof n.value.itemSize=="number"&&n.value.array.length>n.value.itemSize;return r&&!s}getUniforms(e){const t=this.uniforms[e],n=[],r=[],s=[],o={};for(const c of t){const h=c.groupNode.name,d=this.bindingsIndexes[h];if(c.type==="texture"||c.type==="cubeTexture"||c.type==="cubeDepthTexture"||c.type==="storageTexture"||c.type==="texture3D"){const p=c.node.value;(p.isCubeTexture===!0||this.isUnfilterable(p)===!1&&c.node.isStorageTextureNode!==!0)&&(this.isSampleCompare(p)?n.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${c.name}_sampler : sampler_comparison;`):n.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${c.name}_sampler : sampler;`));let _,v="";const{primarySamples:S}=this.renderer.backend.utils.getTextureSampleData(p);if(S>1&&(v="_multisampled"),p.isCubeTexture===!0&&p.isDepthTexture===!0)_="texture_depth_cube";else if(p.isCubeTexture===!0)_="texture_cube<f32>";else if(p.isDepthTexture===!0)this.renderer.backend.compatibilityMode&&p.compareFunction===null?_=`texture${v}_2d<f32>`:_=`texture_depth${v}_2d${p.isArrayTexture===!0?"_array":""}`;else if(c.node.isStorageTextureNode===!0){const b=aS(p),x=this.getStorageAccess(c.node,e),M=c.node.value.is3DTexture,E=c.node.value.isArrayTexture;_=`texture_storage_${M?"3d":`2d${E?"_array":""}`}<${b}, ${x}>`}else if(p.isArrayTexture===!0||p.isDataArrayTexture===!0||p.isCompressedArrayTexture===!0)_="texture_2d_array<f32>";else if(p.is3DTexture===!0||p.isData3DTexture===!0)_="texture_3d<f32>";else{const b=this.getComponentTypeFromTexture(p).charAt(0);_=`texture${v}_2d<${b}32>`}n.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${c.name} : ${_};`)}else if(c.type==="buffer"||c.type==="storageBuffer"||c.type==="indirectStorageBuffer"){const p=c.node,g=this.getType(p.getNodeType(this)),_=p.bufferCount,v=_>0&&c.type==="buffer"?", "+_:"",S=p.isStorageBufferNode?`storage, ${this.getStorageAccess(p,e)}`:"uniform";if(this.isCustomStruct(c))r.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var<${S}> ${c.name} : ${g};`);else{const x=`	value : array< ${p.isAtomic?`atomic<${g}>`:`${g}`}${v} >`;r.push(this._getWGSLStructBinding(c.name,x,S,d.binding++,d.group))}}else{const p=c.groupNode.name;if(o[p]===void 0){const g=this.uniformGroups[p];if(g!==void 0){const _=[];for(const S of g.uniforms){const b=S.getType(),x=this.getType(this.getVectorType(b));_.push(`	${S.name} : ${x}`)}let v=this.uniformGroupsBindings[p];v===void 0&&(v={index:d.binding++,id:d.group},this.uniformGroupsBindings[p]=v),o[p]={index:v.index,id:v.id,snippets:_}}}}}for(const c in o){const h=o[c];s.push(this._getWGSLStructBinding(c,h.snippets.join(`,
`),"uniform",h.index,h.id))}return[...n,...r,...s].join(`
`)}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code

`;r+=this.flowCode[t];const s=this.flowNodes[t],o=s[s.length-1],u=o.outputNode,c=u!==void 0&&u.isOutputStructNode===!0;for(const h of s){const d=this.getFlowData(h),p=h.name;if(p&&(r.length>0&&(r+=`
`),r+=`	// flow -> ${p}
`),r+=`${d.code}
	`,h===o&&t!=="compute"){if(r+=`// result

	`,t==="vertex")r+=`varyings.builtinClipSpace = ${d.result};`;else if(t==="fragment")if(c)n.returnType=u.getNodeType(this),n.structs+="var<private> output : "+n.returnType+";",r+=`return ${d.result};`;else{let g="	@location(0) color: vec4<f32>";const _=this.getBuiltins("output");_&&(g+=`,
	`+_),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",g),n.structs+=`
var<private> output : OutputStruct;`,r+=`output.color = ${d.result};

	return output;`}}}n.flow=r}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return hY[e]||e}isAvailable(e){let t=uN[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),uN[e]=t),t}getUniformBufferLimit(){return this.renderer.backend.device.limits.maxUniformBufferBindingSize}_getWGSLMethod(e){return Ad[e]!==void 0&&this._include(e),fY[e]}_include(e){const t=Ad[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
// directives
${e.directives}

// structs
${e.structs}

// uniforms
${e.uniforms}

// varyings
${e.varyings}
var<private> varyings : VaryingsStruct;

// codes
${e.codes}

@vertex
fn main( ${e.attributes} ) -> VaryingsStruct {

	// vars
	${e.vars}

	// flow
	${e.flow}

	return varyings;

}
`}_getWGSLFragmentCode(e){return`${this.getSignature()}
// global
${J3}

// structs
${e.structs}

// uniforms
${e.uniforms}

// codes
${e.codes}

@fragment
fn main( ${e.varyings} ) -> ${e.returnType} {

	// vars
	${e.vars}

	// flow
	${e.flow}

}
`}_getWGSLComputeCode(e,t){const[n,r,s]=t;return`${this.getSignature()}
// directives
${e.directives}

// system
var<private> instanceIndex : u32;

// locals
${e.scopedArrays}

// structs
${e.structs}

// uniforms
${e.uniforms}

// codes
${e.codes}

@compute @workgroup_size( ${n}, ${r}, ${s} )
fn main( ${e.attributes} ) {

	// system
	instanceIndex = globalId.x
		+ globalId.y * ( ${n} * numWorkgroups.x )
		+ globalId.z * ( ${n} * numWorkgroups.x ) * ( ${r} * numWorkgroups.y );

	// vars
	${e.vars}

	// flow
	${e.flow}

}
`}_getWGSLStruct(e,t){return`
struct ${e} {
${t}
};`}_getWGSLStructBinding(e,t,n,r=0,s=0){const o=e+"Struct";return`${this._getWGSLStruct(o,t)}
@binding( ${r} ) @group( ${s} )
var<${n}> ${e} : ${o};`}}class pY{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depth&&(e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.stencil?t=X.Depth24PlusStencil8:t=X.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const s=this.backend.renderer,o=s.getRenderTarget();t=o?o.samples:s.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return e.textures!==null?e.textures.map(t=>this.getTextureFormatGPU(t)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return Xg.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return Xg.LineList;if(e.isLine)return Xg.LineStrip;if(e.isMesh)return Xg.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const t=this.backend.parameters.outputType;if(t===void 0)return navigator.gpu.getPreferredCanvasFormat();if(t===Gn)return X.BGRA8Unorm;if(t===Qn)return X.RGBA16Float;throw new Error("Unsupported output buffer type.")}}const eL=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array<"u"&&eL.set(Float16Array,["float16"]);const mY=new Map([[XN,["float16"]]]),gY=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class _Y{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,s=r.get(n);let o=s.buffer;if(o===void 0){const u=r.device;let c=n.array;if(e.normalized===!1){if(c.constructor===Int16Array||c.constructor===Int8Array)c=new Int32Array(c);else if((c.constructor===Uint16Array||c.constructor===Uint8Array)&&(c=new Uint32Array(c),t&GPUBufferUsage.INDEX))for(let p=0;p<c.length;p++)c[p]===65535&&(c[p]=4294967295)}if(n.array=c,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){c=new c.constructor(n.count*4);for(let p=0;p<n.count;p++)c.set(n.array.subarray(p*3,p*3+3),p*4);n.itemSize=4,n.array=c,s._force3to4BytesAlignment=!0}const h=c.byteLength,d=h+(4-h%4)%4;o=u.createBuffer({label:n.name,size:d,usage:t,mappedAtCreation:!0}),new c.constructor(o.getMappedRange()).set(c),o.unmap(),s.buffer=o}}updateAttribute(e){const t=this._getBufferAttribute(e),n=this.backend,r=n.device,s=n.get(t),o=n.get(t).buffer;let u=t.array;if(s._force3to4BytesAlignment===!0){u=new u.constructor(t.count*4);for(let h=0;h<t.count;h++)u.set(t.array.subarray(h*3,h*3+3),h*4);t.array=u}const c=t.updateRanges;if(c.length===0)r.queue.writeBuffer(o,0,u,0);else{const h=m_(u),d=h?1:u.BYTES_PER_ELEMENT;for(let p=0,g=c.length;p<g;p++){const _=c[p];let v,S;if(s._force3to4BytesAlignment===!0){const x=Math.floor(_.start/3),M=Math.ceil(_.count/3);v=x*4*d,S=M*4*d}else v=_.start*d,S=_.count*d;const b=v*(h?u.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(o,b,u,v,S)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){const t=e.getAttributes(),n=new Map;for(let r=0;r<t.length;r++){const s=t[r],o=s.array.BYTES_PER_ELEMENT,u=this._getBufferAttribute(s);let c=n.get(u);if(c===void 0){let p,g;s.isInterleavedBufferAttribute===!0?(p=s.data.stride*o,g=s.data.isInstancedInterleavedBuffer?Yg.Instance:Yg.Vertex):(p=s.itemSize*o,g=s.isInstancedBufferAttribute?Yg.Instance:Yg.Vertex),s.normalized===!1&&(s.array.constructor===Int16Array||s.array.constructor===Uint16Array)&&(p=4),c={arrayStride:p,attributes:[],stepMode:g},n.set(u,c)}const h=this._getVertexFormat(s),d=s.isInterleavedBufferAttribute===!0?s.offset*o:0;c.attributes.push({shaderLocation:r,offset:d,format:h})}return Array.from(n.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){const t=this.backend,n=t.device,s=t.get(this._getBufferAttribute(e)).buffer,o=s.size,u=n.createBuffer({label:`${e.name}_readback`,size:o,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),c=n.createCommandEncoder({label:`readback_encoder_${e.name}`});c.copyBufferToBuffer(s,0,u,0,o);const h=c.finish();n.queue.submit([h]),await u.mapAsync(GPUMapMode.READ);const d=u.getMappedRange(),p=new e.array.constructor(d.slice(0));return u.unmap(),p.buffer}_getVertexFormat(e){const{itemSize:t,normalized:n}=e,r=e.array.constructor,s=e.constructor;let o;if(t===1)o=gY.get(r);else{const c=(mY.get(s)||eL.get(r))[n?1:0];if(c){const h=r.BYTES_PER_ELEMENT*t,p=Math.floor((h+3)/4)*4/r.BYTES_PER_ELEMENT;if(p%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");o=`${c}x${p}`}}return o||Pe("WebGPUAttributeUtils: Vertex format not supported yet."),o}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}class vY{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class yY{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const t=this.backend,n=t.device,r=t.get(e);if(r.layout)return r.layout.layoutGPU;const s=this._createLayoutEntries(e),o=ef(JSON.stringify(s));let u=this._bindGroupLayoutCache.get(o);return u===void 0&&(u=new vY(n.createBindGroupLayout({entries:s})),this._bindGroupLayoutCache.set(o,u)),u.usedTimes++,r.layout=u,r.layoutKey=o,u.layoutGPU}createBindings(e,t,n,r=0){const{backend:s}=this,o=s.get(e),u=this.createBindingsLayout(e);let c;n>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[n]===r&&(c=o.groups[n])),c===void 0&&(c=this.createBindGroup(e,u),n>0&&(o.groups[n]=c,o.versions[n]=r)),o.group=c}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,s=t.get(e).buffer,o=e.updateRanges;if(o.length===0)n.queue.writeBuffer(s,0,r,0);else{const u=m_(r),c=u?1:r.BYTES_PER_ELEMENT;for(let h=0,d=o.length;h<d;h++){const p=o[h],g=p.start*c,_=p.count*c,v=g*(u?r.BYTES_PER_ELEMENT:1);n.queue.writeBuffer(s,v,r,g,_)}}}createBindGroupIndex(e,t){const r=this.backend.device,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,o=e[0],u=r.createBuffer({label:"bindingCameraIndex_"+o,size:16,usage:s});r.queue.writeBuffer(u,0,e,0);const c=[{binding:0,resource:{buffer:u}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+o,layout:t,entries:c})}createBindGroup(e,t){const n=this.backend,r=n.device;let s=0;const o=[];for(const u of e.bindings){if(u.isUniformBuffer){const c=n.get(u);if(c.buffer===void 0){const h=u.byteLength,d=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,p=[];u.visibility&ma.VERTEX&&p.push("vertex"),u.visibility&ma.FRAGMENT&&p.push("fragment"),u.visibility&ma.COMPUTE&&p.push("compute");const g=`(${p.join(",")})`,_=r.createBuffer({label:`bindingBuffer${u.id}_${u.name}_${g}`,size:h,usage:d});c.buffer=_}o.push({binding:s,resource:{buffer:c.buffer}})}else if(u.isStorageBuffer){const c=n.get(u.attribute).buffer;o.push({binding:s,resource:{buffer:c}})}else if(u.isSampledTexture){const c=n.get(u.texture);let h;if(c.externalTexture!==void 0)h=r.importExternalTexture({source:c.externalTexture});else{const d=u.store?1:c.texture.mipLevelCount,p=u.store?u.mipLevel:0;let g=`view-${c.texture.width}-${c.texture.height}`;if(c.texture.depthOrArrayLayers>1&&(g+=`-${c.texture.depthOrArrayLayers}`),g+=`-${d}-${p}`,h=c[g],h===void 0){const _=YX.All;let v;u.isSampledCubeTexture?v=er.Cube:u.isSampledTexture3D?v=er.ThreeD:u.texture.isArrayTexture||u.texture.isDataArrayTexture||u.texture.isCompressedArrayTexture?v=er.TwoDArray:v=er.TwoD,h=c[g]=c.texture.createView({aspect:_,dimension:v,mipLevelCount:d,baseMipLevel:p})}}o.push({binding:s,resource:h})}else if(u.isSampler){const c=n.get(u.texture);o.push({binding:s,resource:c.sampler})}s++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:o})}_createLayoutEntries(e){const t=[];let n=0;for(const r of e.bindings){const s=this.backend,o={binding:n,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){const u={};r.isStorageBuffer&&(r.visibility&ma.COMPUTE&&(r.access===ys.READ_WRITE||r.access===ys.WRITE_ONLY)?u.type=ob.Storage:u.type=ob.ReadOnlyStorage),o.buffer=u}else if(r.isSampledTexture&&r.store){const u={};u.format=this.backend.get(r.texture).texture.format;const c=r.access;c===ys.READ_WRITE?u.access=lb.ReadWrite:c===ys.WRITE_ONLY?u.access=lb.WriteOnly:u.access=lb.ReadOnly,r.texture.isArrayTexture?u.viewDimension=er.TwoDArray:r.texture.is3DTexture&&(u.viewDimension=er.ThreeD),o.storageTexture=u}else if(r.isSampledTexture){const u={},{primarySamples:c}=s.utils.getTextureSampleData(r.texture);if(c>1&&(u.multisampled=!0,r.texture.isDepthTexture||(u.sampleType=ru.UnfilterableFloat)),r.texture.isDepthTexture)s.compatibilityMode&&r.texture.compareFunction===null?u.sampleType=ru.UnfilterableFloat:u.sampleType=ru.Depth;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const h=r.texture.type;h===Li?u.sampleType=ru.SInt:h===bn?u.sampleType=ru.UInt:h===ri&&(this.backend.hasFeature("float32-filterable")?u.sampleType=ru.Float:u.sampleType=ru.UnfilterableFloat)}r.isSampledCubeTexture?u.viewDimension=er.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?u.viewDimension=er.TwoDArray:r.isSampledTexture3D&&(u.viewDimension=er.ThreeD),o.texture=u}else if(r.isSampler){const u={};r.texture.isDepthTexture&&(r.texture.compareFunction!==null&&s.hasCompatibility(mo.TEXTURE_COMPARE)?u.type=rN.Comparison:u.type=rN.NonFiltering),o.sampler=u}else Pe(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(o),n++}return t}deleteBindGroupData(e){const{backend:t}=this,n=t.get(e);n.layout&&(n.layout.usedTimes--,n.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(n.layoutKey),n.layout=void 0,n.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class xY{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:r,geometry:s,pipeline:o}=e,{vertexProgram:u,fragmentProgram:c}=o,h=this.backend,d=h.device,p=h.utils,g=h.get(o),_=[];for(const K of e.getBindings()){const te=h.get(K),{layoutGPU:Z}=te.layout;_.push(Z)}const v=h.attributeUtils.createShaderVertexBuffers(e);let S;r.blending!==Bi&&(r.blending!==pr||r.transparent!==!1)&&(S=this._getBlending(r));let b={};r.stencilWrite===!0&&(b={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const x=this._getColorWriteMask(r),M=[];if(e.context.textures!==null){const K=e.context.textures,te=e.context.mrt;for(let Z=0;Z<K.length;Z++){const I=K[Z],F=p.getTextureFormatGPU(I);let Y;if(te!==null)if(this.backend.compatibilityMode!==!0){const se=te.getBlendMode(I.name);se.blending===FN?Y=S:se.blending!==Bi&&(Y=this._getBlending(se))}else xn("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets."),Y=S;else Y=S;M.push({format:F,blend:Y,writeMask:x})}}else{const K=p.getCurrentColorFormat(e.context);M.push({format:K,blend:S,writeMask:x})}const E=h.get(u).module,w=h.get(c).module,D=this._getPrimitiveState(n,s,r),C=this._getDepthCompare(r),N=p.getCurrentDepthStencilFormat(e.context),A=this._getSampleCount(e.context),L={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},E,{buffers:v}),fragment:Object.assign({},w,{targets:M}),primitive:D,multisample:{count:A,alphaToCoverageEnabled:r.alphaToCoverage&&A>1},layout:d.createPipelineLayout({bindGroupLayouts:_})},j={},z=e.context.depth,H=e.context.stencil;if((z===!0||H===!0)&&(z===!0&&(j.format=N,j.depthWriteEnabled=r.depthWrite,j.depthCompare=C),H===!0&&(j.stencilFront=b,j.stencilBack=b,j.stencilReadMask=r.stencilFuncMask,j.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(j.depthBias=r.polygonOffsetUnits,j.depthBiasSlopeScale=r.polygonOffsetFactor,j.depthBiasClamp=0),L.depthStencil=j),d.pushErrorScope("validation"),t===null)g.pipeline=d.createRenderPipeline(L),d.popErrorScope().then(K=>{K!==null&&(g.error=!0,Pe(K.message))});else{const K=new Promise(async te=>{try{g.pipeline=await d.createRenderPipelineAsync(L)}catch{}const Z=await d.popErrorScope();Z!==null&&(g.error=!0,Pe(Z.message)),te()});t.push(K)}}createBundleEncoder(e,t="renderBundleEncoder"){const n=this.backend,{utils:r,device:s}=n,o=r.getCurrentDepthStencilFormat(e),u=r.getCurrentColorFormats(e),c=this._getSampleCount(e),h={label:t,colorFormats:u,depthStencilFormat:o,sampleCount:c};return s.createRenderBundleEncoder(h)}createComputePipeline(e,t){const n=this.backend,r=n.device,s=n.get(e.computeProgram).module,o=n.get(e),u=[];for(const c of t){const h=n.get(c),{layoutGPU:d}=h.layout;u.push(d)}o.pipeline=r.createComputePipeline({compute:s,layout:r.createPipelineLayout({bindGroupLayouts:u})})}_getBlending(e){let t,n;const r=e.blending,s=e.blendSrc,o=e.blendDst,u=e.blendEquation;if(r===gu){const c=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,h=e.blendDstAlpha!==null?e.blendDstAlpha:o,d=e.blendEquationAlpha!==null?e.blendEquationAlpha:u;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(u)},n={srcFactor:this._getBlendFactor(c),dstFactor:this._getBlendFactor(h),operation:this._getBlendOperation(d)}}else{const c=e.premultipliedAlpha,h=(d,p,g,_)=>{t={srcFactor:d,dstFactor:p,operation:iu.Add},n={srcFactor:g,dstFactor:_,operation:iu.Add}};if(c)switch(r){case pr:h(Kt.One,Kt.OneMinusSrcAlpha,Kt.One,Kt.OneMinusSrcAlpha);break;case cl:h(Kt.One,Kt.One,Kt.One,Kt.One);break;case hl:h(Kt.Zero,Kt.OneMinusSrc,Kt.Zero,Kt.One);break;case fl:h(Kt.Dst,Kt.OneMinusSrcAlpha,Kt.Zero,Kt.One);break}else switch(r){case pr:h(Kt.SrcAlpha,Kt.OneMinusSrcAlpha,Kt.One,Kt.OneMinusSrcAlpha);break;case cl:h(Kt.SrcAlpha,Kt.One,Kt.One,Kt.One);break;case hl:Pe(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case fl:Pe(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};Pe("WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case ro:t=Kt.Zero;break;case SS:t=Kt.One;break;case TS:t=Kt.Src;break;case MS:t=Kt.OneMinusSrc;break;case Kd:t=Kt.SrcAlpha;break;case Zd:t=Kt.OneMinusSrcAlpha;break;case wS:t=Kt.Dst;break;case RS:t=Kt.OneMinusDst;break;case ES:t=Kt.DstAlpha;break;case AS:t=Kt.OneMinusDstAlpha;break;case CS:t=Kt.SrcAlphaSaturated;break;case J$:t=Kt.Constant;break;case eq:t=Kt.OneMinusConstant;break;default:Pe("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case FO:t=Vi.Never;break;case wb:t=Vi.Always;break;case IO:t=Vi.Less;break;case kO:t=Vi.LessEqual;break;case zO:t=Vi.Equal;break;case HO:t=Vi.GreaterEqual;break;case GO:t=Vi.Greater;break;case VO:t=Vi.NotEqual;break;default:Pe("WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case au:t=sl.Keep;break;case NO:t=sl.Zero;break;case DO:t=sl.Replace;break;case BO:t=sl.Invert;break;case LO:t=sl.IncrementClamp;break;case PO:t=sl.DecrementClamp;break;case UO:t=sl.IncrementWrap;break;case OO:t=sl.DecrementWrap;break;default:Pe("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case nr:t=iu.Add;break;case xS:t=iu.Subtract;break;case bS:t=iu.ReverseSubtract;break;case IN:t=iu.Min;break;case zN:t=iu.Max;break;default:Pe("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},s=this.backend.utils;r.topology=s.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?P_.Uint16:P_.Uint32);let o=n.side===Tn;return e.isMesh&&e.matrixWorld.determinant()<0&&(o=!o),r.frontFace=o===!0?tN.CW:tN.CCW,r.cullMode=n.side===Ui?nN.None:nN.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?iN.All:iN.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Vi.Always;else{const n=this.backend.parameters.reversedDepthBuffer?HS[e.depthFunc]:e.depthFunc;switch(n){case Qd:t=Vi.Never;break;case Jd:t=Vi.Always;break;case ep:t=Vi.Less;break;case Tl:t=Vi.LessEqual;break;case tp:t=Vi.Equal;break;case np:t=Vi.GreaterEqual;break;case ip:t=Vi.Greater;break;case rp:t=Vi.NotEqual;break;default:Pe("WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class bY extends Q3{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return xn(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);const s=r.finish();if(this.device.queue.submit([s]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const o=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),u={},c=[];for(const[d,p]of e){const g=d.match(/^(.*):f(\d+)$/),_=parseInt(g[2]);c.includes(_)===!1&&c.push(_),u[_]===void 0&&(u[_]=0);const v=o[p],S=o[p+1],b=Number(S-v)/1e6;this.timestamps.set(d,b),u[_]+=b}const h=u[c[c.length-1]];return this.resultBuffer.unmap(),this.lastValue=h,this.frames=c,h}catch(e){return Pe("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){Pe("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){Pe("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class SY extends Z3{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new pY(this),this.attributeUtils=new _Y(this),this.bindingUtils=new yY(this),this.pipelineUtils=new xY(this),this.textureUtils=new iY(this),this.occludedResolveCache=new Map;const t=typeof navigator>"u"?!0:/Android/.test(navigator.userAgent)===!1;this._compatibility={[mo.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);const t=this.parameters;let n;if(t.device===void 0){const r={powerPreference:t.powerPreference,featureLevel:"compatibility"},s=typeof navigator<"u"?await navigator.gpu.requestAdapter(r):null;if(s===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const o=Object.values(sS),u=[];for(const h of o)s.features.has(h)&&u.push(h);const c={requiredFeatures:u,requiredLimits:t.requiredLimits};n=await s.requestDevice(c)}else n=t.device;this.compatibilityMode=!n.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),n.lost.then(r=>{if(r.reason==="destroyed")return;const s={api:"WebGPU",message:r.message||"Unknown reason",reason:r.reason||null,originalEvent:r};e.onDeviceLost(s)}),this.device=n,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(sS.TimestampQuery),this.updateSize()}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let n=t.context;if(n===void 0){const r=this.parameters;e.isDefaultCanvasTarget===!0&&r.context!==void 0?n=r.context:n=e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${Fu} webgpu`);const s=r.alpha?"premultiplied":"opaque",o=r.outputType===Qn?"extended":"standard";n.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,toneMapping:{mode:o}}),t.context=n}return n}get coordinateSystem(){return ba}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),n=this.get(t),r=e.currentSamples;let s=n.descriptor;if(s===void 0||n.samples!==r){s={colorAttachments:[{view:null}]},(e.depth===!0||e.stencil===!0)&&(s.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView()});const u=s.colorAttachments[0];r>0?u.view=this.textureUtils.getColorBuffer().createView():u.resolveTarget=void 0,n.descriptor=s,n.samples=r}const o=s.colorAttachments[0];return r>0?o.resolveTarget=this.context.getCurrentTexture().createView():o.view=this.context.getCurrentTexture().createView(),s}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let s=r.descriptors;(s===void 0||r.width!==n.width||r.height!==n.height||r.samples!==n.samples)&&(s={},r.descriptors=s);const o=e.getCacheKey();let u=s[o];if(u===void 0){const h=e.textures,d=[];let p;const g=this._isRenderCameraDepthArray(e);for(let _=0;_<h.length;_++){const v=this.get(h[_]),S={label:`colorAttachment_${_}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:er.TwoD};if(n.isRenderTarget3D)p=e.activeCubeFace,S.baseArrayLayer=0,S.dimension=er.ThreeD,S.depthOrArrayLayers=h[_].image.depth;else if(n.isRenderTarget&&h[_].image.depth>1)if(g===!0){const b=e.camera.cameras;for(let x=0;x<b.length;x++){const M={...S,baseArrayLayer:x,arrayLayerCount:1,dimension:er.TwoD},E=v.texture.createView(M);d.push({view:E,resolveTarget:void 0,depthSlice:void 0})}}else S.dimension=er.TwoDArray,S.depthOrArrayLayers=h[_].image.depth;if(g!==!0){const b=v.texture.createView(S);let x,M;v.msaaTexture!==void 0?(x=v.msaaTexture.createView(),M=b):(x=b,M=void 0),d.push({view:x,resolveTarget:M,depthSlice:p})}}if(u={textureViews:d},e.depth){const _=this.get(e.depthTexture),v={};(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(v.dimension=er.TwoD,v.arrayLayerCount=1,v.baseArrayLayer=e.activeCubeFace),u.depthStencilView=_.texture.createView(v)}s[o]=u,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace}const c={colorAttachments:[]};for(let h=0;h<u.textureViews.length;h++){const d=u.textureViews[h];let p={r:0,g:0,b:0,a:1};h===0&&t.clearValue&&(p=t.clearValue),c.colorAttachments.push({view:d.view,depthSlice:d.depthSlice,resolveTarget:d.resolveTarget,loadOp:t.loadOp||mn.Load,storeOp:t.storeOp||fr.Store,clearValue:p})}return u.depthStencilView&&(c.depthStencilAttachment={view:u.depthStencilView}),c}beginRender(e){const t=this.get(e),n=this.device,r=e.occlusionQueryCount;let s;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let o;e.textures===null?o=this._getDefaultRenderPassDescriptor():o=this._getRenderPassDescriptor(e,{loadOp:mn.Load}),this.initTimestampQuery(pa.RENDER,this.getTimestampUID(e),o),o.occlusionQuerySet=s;const u=o.depthStencilAttachment;if(e.textures!==null){const h=o.colorAttachments;for(let d=0;d<h.length;d++){const p=h[d];e.clearColor?(p.clearValue=d===0?e.clearColorValue:{r:0,g:0,b:0,a:1},p.loadOp=mn.Clear):p.loadOp=mn.Load,p.storeOp=fr.Store}}else{const h=o.colorAttachments[0];e.clearColor?(h.clearValue=e.clearColorValue,h.loadOp=mn.Clear):h.loadOp=mn.Load,h.storeOp=fr.Store}e.depth&&(e.clearDepth?(u.depthClearValue=e.clearDepthValue,u.depthLoadOp=mn.Clear):u.depthLoadOp=mn.Load,u.depthStoreOp=fr.Store),e.stencil&&(e.clearStencil?(u.stencilClearValue=e.clearStencilValue,u.stencilLoadOp=mn.Clear):u.stencilLoadOp=mn.Load,u.stencilStoreOp=fr.Store);const c=n.createCommandEncoder({label:"renderContext_"+e.id});if(this._isRenderCameraDepthArray(e)===!0){const h=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==h.length?this._createDepthLayerDescriptors(e,t,o,h):this._updateDepthLayerDescriptors(e,t,h),t.bundleEncoders=[],t.bundleSets=[];for(let d=0;d<h.length;d++){const p=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+d),g={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(p),t.bundleSets.push(g)}t.currentPass=null}else{const h=c.beginRenderPass(o);t.currentPass=h,e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e)}t.descriptor=o,t.encoder=c,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){const s=n.depthStencilAttachment;t.layerDescriptors=[];const o=this.get(e.depthTexture);o.viewCache||(o.viewCache=[]);for(let u=0;u<r.length;u++){const c={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[u].view}]};if(n.depthStencilAttachment){const h=u;o.viewCache[h]||(o.viewCache[h]=o.texture.createView({dimension:er.TwoD,baseArrayLayer:u,arrayLayerCount:1})),c.depthStencilAttachment={view:o.viewCache[h],depthLoadOp:s.depthLoadOp||mn.Clear,depthStoreOp:s.depthStoreOp||fr.Store,depthClearValue:s.depthClearValue||1},e.stencil&&(c.depthStencilAttachment.stencilLoadOp=s.stencilLoadOp,c.depthStencilAttachment.stencilStoreOp=s.stencilStoreOp,c.depthStencilAttachment.stencilClearValue=s.stencilClearValue)}else c.depthStencilAttachment={...s};t.layerDescriptors.push(c)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){const s=t.layerDescriptors[r];if(s.depthStencilAttachment){const o=s.depthStencilAttachment;e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=mn.Clear):o.depthLoadOp=mn.Load),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=mn.Clear):o.stencilLoadOp=mn.Load)}}}finishRender(e){const t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const s=[];for(let o=0;o<t.bundleEncoders.length;o++){const u=t.bundleEncoders[o];s.push(u.finish())}for(let o=0;o<t.layerDescriptors.length;o++)if(o<s.length){const u=t.layerDescriptors[o],c=r.beginRenderPass(u);if(e.viewport){const{x:h,y:d,width:p,height:g,minDepth:_,maxDepth:v}=e.viewportValue;c.setViewport(h,d,p,g,_,v)}if(e.scissor){const{x:h,y:d,width:p,height:g}=e.scissorValue;c.setScissorRect(h,d,p,g)}c.executeBundles([s[o]]),c.end()}}else t.currentPass&&t.currentPass.end();if(n>0){const s=n*8;let o=this.occludedResolveCache.get(s);o===void 0&&(o=this.device.createBuffer({size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(s,o));const u=this.device.createBuffer({size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,o,0),t.encoder.copyBufferToBuffer(o,0,u,0,s),t.occlusionQueryBuffer=u,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const s=e.textures;for(let o=0;o<s.length;o++){const u=s[o];u.generateMipmaps===!0&&this.textureUtils.generateMipmaps(u)}}}isOccluded(e,t){const n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){const s=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);const o=n.getMappedRange(),u=new BigUint64Array(o);for(let c=0;c<r.length;c++)u[c]===BigInt(0)&&s.add(r[c]);n.destroy(),t.occluded=s}}updateViewport(e){const{currentPass:t}=this.get(e),{x:n,y:r,width:s,height:o,minDepth:u,maxDepth:c}=e.viewportValue;t.setViewport(n,r,s,o,u,c)}updateScissor(e){const{currentPass:t}=this.get(e),{x:n,y:r,width:s,height:o}=e.scissorValue;t.setScissorRect(n,r,s,o)}getClearColor(){const e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){const s=this.device,o=this.renderer;let u=[],c,h,d,p;if(e){const v=this.getClearColor();h={r:v.r,g:v.g,b:v.b,a:v.a}}if(r===null){d=o.depth,p=o.stencil;const v=this._getDefaultRenderPassDescriptor();if(e){u=v.colorAttachments;const S=u[0];S.clearValue=h,S.loadOp=mn.Clear,S.storeOp=fr.Store}(d||p)&&(c=v.depthStencilAttachment)}else{d=r.depth,p=r.stencil;const v={loadOp:e?mn.Clear:mn.Load,clearValue:e?h:void 0};d&&(v.depthLoadOp=t?mn.Clear:mn.Load,v.depthClearValue=t?o.getClearDepth():void 0,v.depthStoreOp=fr.Store),p&&(v.stencilLoadOp=n?mn.Clear:mn.Load,v.stencilClearValue=n?o.getClearStencil():void 0,v.stencilStoreOp=fr.Store);const S=this._getRenderPassDescriptor(r,v);u=S.colorAttachments,c=S.depthStencilAttachment}d&&c&&(t?(c.depthLoadOp=mn.Clear,c.depthClearValue=o.getClearDepth(),c.depthStoreOp=fr.Store):(c.depthLoadOp=mn.Load,c.depthStoreOp=fr.Store)),p&&c&&(n?(c.stencilLoadOp=mn.Clear,c.stencilClearValue=o.getClearStencil(),c.stencilStoreOp=fr.Store):(c.stencilLoadOp=mn.Load,c.stencilStoreOp=fr.Store));const g=s.createCommandEncoder({label:"clear"});g.beginRenderPass({colorAttachments:u,depthStencilAttachment:c}).end(),s.queue.submit([g.finish()])}beginCompute(e){const t=this.get(e),n={label:"computeGroup_"+e.id};this.initTimestampQuery(pa.COMPUTE,this.getTimestampUID(e),n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r,s=null){const o=this.get(t),{passEncoderGPU:u}=this.get(e),c=this.get(r).pipeline;this.pipelineUtils.setPipeline(u,c);for(let h=0,d=n.length;h<d;h++){const p=n[h],g=this.get(p);u.setBindGroup(h,g.group)}if(s===null&&(s=t.count),s&&typeof s=="object"&&s.isIndirectStorageBufferAttribute){const h=this.get(s).buffer;u.dispatchWorkgroupsIndirect(h,0);return}if(typeof s=="number"){const h=s;if(o.dispatchSize===void 0||o.count!==h){o.dispatchSize=[0,1,1],o.count=h;const d=t.workgroupSize;let p=d[0];for(let v=1;v<d.length;v++)p*=d[v];const g=Math.ceil(h/p),_=this.device.limits.maxComputeWorkgroupsPerDimension;s=[g,1,1],g>_&&(s[0]=Math.min(g,_),s[1]=Math.ceil(g/_)),o.dispatchSize=s}s=o.dispatchSize}u.dispatchWorkgroups(s[0],s[1]||1,s[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}draw(e,t){const{object:n,material:r,context:s,pipeline:o}=e,u=e.getBindings(),c=this.get(s),h=this.get(o),d=h.pipeline;if(h.error===!0)return;const p=e.getIndex(),g=p!==null,_=e.getDrawParameters();if(_===null)return;const v=(b,x)=>{this.pipelineUtils.setPipeline(b,d),x.pipeline=d;const M=x.bindingGroups;for(let w=0,D=u.length;w<D;w++){const C=u[w],N=this.get(C);M[C.index]!==C.id&&(b.setBindGroup(C.index,N.group),M[C.index]=C.id)}if(g===!0&&x.index!==p){const w=this.get(p).buffer,D=p.array instanceof Uint16Array?P_.Uint16:P_.Uint32;b.setIndexBuffer(w,D),x.index=p}const E=e.getVertexBuffers();for(let w=0,D=E.length;w<D;w++){const C=E[w];if(x.attributes[w]!==C){const N=this.get(C).buffer;b.setVertexBuffer(w,N),x.attributes[w]=C}}s.stencil===!0&&r.stencilWrite===!0&&c.currentStencilRef!==r.stencilRef&&(b.setStencilReference(r.stencilRef),c.currentStencilRef=r.stencilRef)},S=(b,x)=>{if(v(b,x),n.isBatchedMesh===!0){const M=n._multiDrawStarts,E=n._multiDrawCounts,w=n._multiDrawCount,D=n._multiDrawInstances;D!==null&&xn("WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");let C=g===!0?p.array.BYTES_PER_ELEMENT:1;r.wireframe&&(C=n.geometry.attributes.position.count>65535?4:2);for(let N=0;N<w;N++){const A=D?D[N]:1,L=A>1?0:N;g===!0?b.drawIndexed(E[N],A,M[N]/C,0,L):b.draw(E[N],A,M[N],L),t.update(n,E[N],A)}}else if(g===!0){const{vertexCount:M,instanceCount:E,firstVertex:w}=_,D=e.getIndirect();if(D!==null){const C=this.get(D).buffer,N=e.getIndirectOffset(),A=Array.isArray(N)?N:[N];for(let L=0;L<A.length;L++)b.drawIndexedIndirect(C,A[L])}else b.drawIndexed(M,E,w,0,0);t.update(n,M,E)}else{const{vertexCount:M,instanceCount:E,firstVertex:w}=_,D=e.getIndirect();if(D!==null){const C=this.get(D).buffer,N=e.getIndirectOffset(),A=Array.isArray(N)?N:[N];for(let L=0;L<A.length;L++)b.drawIndirect(C,A[L])}else b.draw(M,E,w,0);t.update(n,M,E)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const b=this.get(e.camera),x=e.camera.cameras,M=e.getBindingGroup("cameraIndex");if(b.indexesGPU===void 0||b.indexesGPU.length!==x.length){const w=this.get(M),D=[],C=new Uint32Array([0,0,0,0]);for(let N=0,A=x.length;N<A;N++){C[0]=N;const{layoutGPU:L}=w.layout,j=this.bindingUtils.createBindGroupIndex(C,L);D.push(j)}b.indexesGPU=D}const E=this.renderer.getPixelRatio();for(let w=0,D=x.length;w<D;w++){const C=x[w];if(n.layers.test(C.layers)){const N=C.viewport;let A=c.currentPass,L=c.currentSets;if(c.bundleEncoders){const j=c.bundleEncoders[w],z=c.bundleSets[w];A=j,L=z}N&&A.setViewport(Math.floor(N.x*E),Math.floor(N.y*E),Math.floor(N.width*E),Math.floor(N.height*E),s.viewportValue.minDepth,s.viewportValue.maxDepth),M&&b.indexesGPU&&(A.setBindGroup(M.index,b.indexesGPU[w]),L.bindingGroups[M.index]=M.id),S(A,L)}}}else if(c.currentPass){if(c.occlusionQuerySet!==void 0){const b=c.lastOcclusionObject;b!==n&&(b!==null&&b.occlusionTest===!0&&(c.currentPass.endOcclusionQuery(),c.occlusionQueryIndex++),n.occlusionTest===!0&&(c.currentPass.beginOcclusionQuery(c.occlusionQueryIndex),c.occlusionQueryObjects[c.occlusionQueryIndex]=n),c.lastOcclusionObject=n)}S(c.currentPass,c.currentSets)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:r}=e,s=this.utils,o=s.getSampleCountRenderContext(e.context),u=s.getCurrentColorSpace(e.context),c=s.getCurrentColorFormat(e.context),h=s.getCurrentDepthStencilFormat(e.context),d=s.getPrimitiveTopology(n,r);let p=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==o||t.colorSpace!==u||t.colorFormat!==c||t.depthStencilFormat!==h||t.primitiveTopology!==d||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=o,t.colorSpace=u,t.colorFormat=c,t.depthStencilFormat=h,t.primitiveTopology=d,t.clippingContextCacheKey=e.clippingContextCacheKey,p=!0),p}getRenderCacheKey(e){const{object:t,material:n}=e,r=this.utils,s=e.context,o=t.isMesh&&t.matrixWorld.determinant()<0;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,o,r.getSampleCountRenderContext(s),r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}createDefaultTexture(e){return this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,n,r,s,o){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,o)}initTimestampQuery(e,t,n){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new bY(this.device,e,2048));const r=this.timestampQueryPool[e],s=r.allocateQueriesForContext(t);n.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:s,endOfPassWriteIndex:s+1}}createNodeBuilder(e,t){return new dY(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),s=n.currentPass.finish();this.get(t).bundleGPU=s,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}getMaxAnisotropy(){return 16}hasFeature(e){return aN[e]!==void 0&&(e=aN[e]),this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,s=0,o=0){let u=0,c=0,h=0,d=0,p=0,g=0,_=e.image.width,v=e.image.height,S=1;n!==null&&(n.isBox3===!0?(d=n.min.x,p=n.min.y,g=n.min.z,_=n.max.x-n.min.x,v=n.max.y-n.min.y,S=n.max.z-n.min.z):(d=n.min.x,p=n.min.y,_=n.max.x-n.min.x,v=n.max.y-n.min.y,S=1)),r!==null&&(u=r.x,c=r.y,h=r.z||0);const b=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),x=this.get(e).texture,M=this.get(t).texture;b.copyTextureToTexture({texture:x,mipLevel:s,origin:{x:d,y:p,z:g}},{texture:M,mipLevel:o,origin:{x:u,y:c,z:h}},[_,v,S]),this.device.queue.submit([b.finish()]),o===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){const r=this.get(t);let s=null;t.renderTarget?e.isDepthTexture?s=this.get(t.depthTexture).texture:s=this.get(t.textures[0]).texture:e.isDepthTexture?s=this.textureUtils.getDepthBuffer(t.depth,t.stencil):s=this.context.getCurrentTexture();const o=this.get(e).texture;if(s.format!==o.format){Pe("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,o.format);return}let u;if(r.currentPass?(r.currentPass.end(),u=r.encoder):u=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),u.copyTextureToTexture({texture:s,origin:[n.x,n.y,0]},{texture:o},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,u),r.currentPass){const{descriptor:c}=r;for(let h=0;h<c.colorAttachments.length;h++)c.colorAttachments[h].loadOp=mn.Load;t.depth&&(c.depthStencilAttachment.depthLoadOp=mn.Load),t.stencil&&(c.depthStencilAttachment.stencilLoadOp=mn.Load),r.currentPass=u.beginRenderPass(c),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else this.device.queue.submit([u.finish()])}hasCompatibility(e){return this._compatibility[mo.TEXTURE_COMPARE]!==void 0?this._compatibility[mo.TEXTURE_COMPARE]:super.hasCompatibility(e)}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(const e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(const e of Object.values(this.timestampQueryPool))e!==null&&e.dispose();this.parameters.device===void 0&&this.device!==null&&this.device.destroy()}}class TY extends aT{constructor(e,t,n,r,s,o){super(e,t,n,r,s,o),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class MY extends aT{constructor(e,t,n,r,s,o){super(e,t,n,r,s,o),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}class EY extends H3{constructor(){super(),this.addMaterial(UW,"MeshPhongMaterial"),this.addMaterial(M3,"MeshStandardMaterial"),this.addMaterial(D$,"MeshPhysicalMaterial"),this.addMaterial(O$,"MeshToonMaterial"),this.addMaterial(wW,"MeshBasicMaterial"),this.addMaterial(LW,"MeshLambertMaterial"),this.addMaterial(SW,"MeshNormalMaterial"),this.addMaterial(I$,"MeshMatcapMaterial"),this.addMaterial(vW,"LineBasicMaterial"),this.addMaterial(xW,"LineDashedMaterial"),this.addMaterial(H$,"PointsMaterial"),this.addMaterial(A3,"SpriteMaterial"),this.addMaterial(q$,"ShadowMaterial"),this.addLight(E7,pF),this.addLight(tX,a2),this.addLight(oX,gF),this.addLight(FT,aT),this.addLight(eX,o2),this.addLight(nX,hF),this.addLight(rX,vF),this.addLight(iX,TY),this.addLight(aX,MY),this.addToneMapping(Nq,NS),this.addToneMapping(Dq,DS),this.addToneMapping(Lq,LS),this.addToneMapping(Uq,PS),this.addToneMapping(Iq,US),this.addToneMapping(zq,OS)}}class AY extends RX{constructor(e={}){let t;e.forceWebGL?t=eN:(t=SY,e.getFallback=()=>(Ne("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new eN(e)));const n=new t(e);super(n,e),this.library=new EY,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}const cb={type:"change"},zT={type:"start"},kT={type:"end"},hN=1e-6,gn={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},Kg=new Ie,al=new Ie,wY=new G,Zg=new G,hb=new G,Zc=new Ss,fN=new G,Qg=new G,fb=new G,Jg=new G;class RY extends Y_{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=["KeyA","KeyS","KeyD"],this.mouseButtons={LEFT:Hi.ROTATE,MIDDLE:Hi.DOLLY,RIGHT:Hi.PAN},this.target=new G,this.state=gn.NONE,this.keyState=gn.NONE,this._lastPosition=new G,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new G,this._movePrev=new Ie,this._moveCurr=new Ie,this._lastAxis=new G,this._zoomStart=new Ie,this._zoomEnd=new Ie,this._panStart=new Ie,this._panEnd=new Ie,this._pointers=[],this._pointerPositions={},this._onPointerMove=NY.bind(this),this._onPointerDown=CY.bind(this),this._onPointerUp=DY.bind(this),this._onPointerCancel=LY.bind(this),this._onContextMenu=zY.bind(this),this._onMouseWheel=IY.bind(this),this._onKeyDown=UY.bind(this),this._onKeyUp=PY.bind(this),this._onTouchStart=kY.bind(this),this._onTouchMove=GY.bind(this),this._onTouchEnd=VY.bind(this),this._onMouseDown=OY.bind(this),this._onMouseMove=BY.bind(this),this._onMouseUp=FY.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),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._onPointerCancel),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}handleResize(){const e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>hN&&(this.dispatchEvent(cb),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>hN||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(cb),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=gn.NONE,this.keyState=gn.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(cb),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(al.copy(this._panEnd).sub(this._panStart),al.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;al.x*=e,al.y*=t}al.multiplyScalar(this._eye.length()*this.panSpeed),Zg.copy(this._eye).cross(this.object.up).setLength(al.x),Zg.add(wY.copy(this.object.up).setLength(al.y)),this.object.position.add(Zg),this.target.add(Zg),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(al.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Jg.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Jg.length();e?(this._eye.copy(this.object.position).sub(this.target),fN.copy(this._eye).normalize(),Qg.copy(this.object.up).normalize(),fb.crossVectors(Qg,fN).normalize(),Qg.setLength(this._moveCurr.y-this._movePrev.y),fb.setLength(this._moveCurr.x-this._movePrev.x),Jg.copy(Qg.add(fb)),hb.crossVectors(Jg,this._eye).normalize(),e*=this.rotateSpeed,Zc.setFromAxisAngle(hb,e),this._eye.applyQuaternion(Zc),this.object.up.applyQuaternion(Zc),this._lastAxis.copy(hb),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),Zc.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(Zc),this.object.up.applyQuaternion(Zc)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===gn.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=g_.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=g_.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Kg.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Kg}_getMouseOnCircle(e,t){return Kg.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Kg}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t].pointerId==e.pointerId){this._pointers.splice(t,1);return}}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ie,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0].pointerId?this._pointers[1]:this._pointers[0];return this._pointerPositions[t.pointerId]}_checkDistances(){(!this.noZoom||!this.noPan)&&(this._eye.lengthSq()>this.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()<this.minDistance*this.minDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.minDistance)),this._zoomStart.copy(this._zoomEnd)))}}function CY(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i))}function NY(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function DY(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchEnd(i):this._onMouseUp(),this._removePointer(i),this._pointers.length===0&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp)))}function LY(i){this._removePointer(i)}function PY(){this.enabled!==!1&&(this.keyState=gn.NONE,window.addEventListener("keydown",this._onKeyDown))}function UY(i){this.enabled!==!1&&(window.removeEventListener("keydown",this._onKeyDown),this.keyState===gn.NONE&&(i.code===this.keys[gn.ROTATE]&&!this.noRotate?this.keyState=gn.ROTATE:i.code===this.keys[gn.ZOOM]&&!this.noZoom?this.keyState=gn.ZOOM:i.code===this.keys[gn.PAN]&&!this.noPan&&(this.keyState=gn.PAN)))}function OY(i){let e;switch(i.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 Hi.DOLLY:this.state=gn.ZOOM;break;case Hi.ROTATE:this.state=gn.ROTATE;break;case Hi.PAN:this.state=gn.PAN;break;default:this.state=gn.NONE}const t=this.keyState!==gn.NONE?this.keyState:this.state;t===gn.ROTATE&&!this.noRotate?(this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr)):t===gn.ZOOM&&!this.noZoom?(this._zoomStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._zoomEnd.copy(this._zoomStart)):t===gn.PAN&&!this.noPan&&(this._panStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._panEnd.copy(this._panStart)),this.dispatchEvent(zT)}function BY(i){const e=this.keyState!==gn.NONE?this.keyState:this.state;e===gn.ROTATE&&!this.noRotate?(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY))):e===gn.ZOOM&&!this.noZoom?this._zoomEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY)):e===gn.PAN&&!this.noPan&&this._panEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY))}function FY(){this.state=gn.NONE,this.dispatchEvent(kT)}function IY(i){if(this.enabled!==!1&&this.noZoom!==!0){switch(i.preventDefault(),i.deltaMode){case 2:this._zoomStart.y-=i.deltaY*.025;break;case 1:this._zoomStart.y-=i.deltaY*.01;break;default:this._zoomStart.y-=i.deltaY*25e-5;break}this.dispatchEvent(zT),this.dispatchEvent(kT)}}function zY(i){this.enabled!==!1&&i.preventDefault()}function kY(i){switch(this._trackPointer(i),this._pointers.length){case 1:this.state=gn.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this.state=gn.TOUCH_ZOOM_PAN;const e=this._pointers[0].pageX-this._pointers[1].pageX,t=this._pointers[0].pageY-this._pointers[1].pageY;this._touchZoomDistanceEnd=this._touchZoomDistanceStart=Math.sqrt(e*e+t*t);const n=(this._pointers[0].pageX+this._pointers[1].pageX)/2,r=(this._pointers[0].pageY+this._pointers[1].pageY)/2;this._panStart.copy(this._getMouseOnScreen(n,r)),this._panEnd.copy(this._panStart);break}this.dispatchEvent(zT)}function GY(i){switch(this._trackPointer(i),this._pointers.length){case 1:this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY));break;default:const e=this._getSecondPointerPosition(i),t=i.pageX-e.x,n=i.pageY-e.y;this._touchZoomDistanceEnd=Math.sqrt(t*t+n*n);const r=(i.pageX+e.x)/2,s=(i.pageY+e.y)/2;this._panEnd.copy(this._getMouseOnScreen(r,s));break}}function VY(i){switch(this._pointers.length){case 0:this.state=gn.NONE;break;case 1:this.state=gn.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=gn.TOUCH_ZOOM_PAN;for(let e=0;e<this._pointers.length;e++)if(this._pointers[e].pointerId!==i.pointerId){const t=this._pointerPositions[this._pointers[e].pointerId];this._moveCurr.copy(this._getMouseOnCircle(t.x,t.y)),this._movePrev.copy(this._moveCurr);break}break}this.dispatchEvent(kT)}const dN={type:"change"},GT={type:"start"},tL={type:"end"},e_=new $_,pN=new zs,HY=Math.cos(70*g_.DEG2RAD),Ai=new G,Cr=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},db=1e-6;class jY extends Y_{constructor(e,t=null){super(e,t),this.state=Ln.NONE,this.target=new G,this.cursor=new G,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:Hi.ROTATE,MIDDLE:Hi.DOLLY,RIGHT:Hi.PAN},this.touches={ONE:co.ROTATE,TWO:co.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 G,this._lastQuaternion=new Ss,this._lastTargetPosition=new G,this._quat=new Ss().setFromUnitVectors(e.up,new G(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new dw,this._sphericalDelta=new dw,this._scale=1,this._panOffset=new G,this._rotateStart=new Ie,this._rotateEnd=new Ie,this._rotateDelta=new Ie,this._panStart=new Ie,this._panEnd=new Ie,this._panDelta=new Ie,this._dollyStart=new Ie,this._dollyEnd=new Ie,this._dollyDelta=new Ie,this._dollyDirection=new G,this._mouse=new Ie,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=$Y.bind(this),this._onPointerDown=WY.bind(this),this._onPointerUp=qY.bind(this),this._onContextMenu=eK.bind(this),this._onMouseWheel=KY.bind(this),this._onKeyDown=ZY.bind(this),this._onTouchStart=QY.bind(this),this._onTouchMove=JY.bind(this),this._onMouseDown=XY.bind(this),this._onMouseMove=YY.bind(this),this._interceptControlDown=tK.bind(this),this._interceptControlUp=nK.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="auto"}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(dN),this.update(),this.state=Ln.NONE}pan(e,t){this._pan(e,t),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 t=this.object.position;Ai.copy(t).sub(this.target),Ai.applyQuaternion(this._quat),this._spherical.setFromVector3(Ai),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 n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=Cr:n>Math.PI&&(n-=Cr),r<-Math.PI?r+=Cr:r>Math.PI&&(r-=Cr),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,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 s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(Ai.setFromSpherical(this._spherical),Ai.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ai),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 o=null;if(this.object.isPerspectiveCamera){const u=Ai.length();o=this._clampDistance(u*this._scale);const c=u-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const u=new G(this._mouse.x,this._mouse.y,0);u.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const h=new G(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(u),this.object.updateMatrixWorld(),o=Ai.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(e_.origin.copy(this.object.position),e_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(e_.direction))<HY?this.object.lookAt(this.target):(pN.setFromNormalAndCoplanarPoint(this.object.up,this.target),e_.intersectPlane(pN,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>db||8*(1-this._lastQuaternion.dot(this.object.quaternion))>db||this._lastTargetPosition.distanceToSquared(this.target)>db?(this.dispatchEvent(dN),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Cr/60*this.autoRotateSpeed*e:Cr/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ai.setFromMatrixColumn(t,0),Ai.multiplyScalar(-e),this._panOffset.add(Ai)}_panUp(e,t){this.screenSpacePanning===!0?Ai.setFromMatrixColumn(t,1):(Ai.setFromMatrixColumn(t,0),Ai.crossVectors(this.object.up,Ai)),Ai.multiplyScalar(e),this._panOffset.add(Ai)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;Ai.copy(r).sub(this.target);let s=Ai.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.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,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,o=n.width,u=n.height;this._mouse.x=r/o*2-1,this._mouse.y=-(s/u)*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 t=this.domElement;this._rotateLeft(Cr*this._rotateDelta.x/t.clientHeight),this._rotateUp(Cr*this._rotateDelta.y/t.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 t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Cr*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Cr*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Cr*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Cr*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_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 n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Cr*this._rotateDelta.x/t.clientHeight),this._rotateUp(Cr*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}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 t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),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 o=(e.pageX+t.x)*.5,u=(e.pageY+t.y)*.5;this._updateZoomParameters(o,u)}_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 t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ie,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function WY(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function $Y(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function qY(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(tL),this.state=Ln.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function XY(i){let e;switch(i.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 Hi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Ln.DOLLY;break;case Hi.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Ln.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Ln.ROTATE}break;case Hi.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Ln.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Ln.PAN}break;default:this.state=Ln.NONE}this.state!==Ln.NONE&&this.dispatchEvent(GT)}function YY(i){switch(this.state){case Ln.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Ln.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Ln.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function KY(i){this.enabled===!1||this.enableZoom===!1||this.state!==Ln.NONE||(i.preventDefault(),this.dispatchEvent(GT),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(tL))}function ZY(i){this.enabled!==!1&&this._handleKeyDown(i)}function QY(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case co.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Ln.TOUCH_ROTATE;break;case co.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Ln.TOUCH_PAN;break;default:this.state=Ln.NONE}break;case 2:switch(this.touches.TWO){case co.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Ln.TOUCH_DOLLY_PAN;break;case co.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Ln.TOUCH_DOLLY_ROTATE;break;default:this.state=Ln.NONE}break;default:this.state=Ln.NONE}this.state!==Ln.NONE&&this.dispatchEvent(GT)}function JY(i){switch(this._trackPointer(i),this.state){case Ln.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Ln.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Ln.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Ln.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Ln.NONE}}function eK(i){this.enabled!==!1&&i.preventDefault()}function tK(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function nK(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const iK={type:"change"},mN=1e-6,gN=new Ss;class rK extends Y_{constructor(e,t=null){super(e,t),this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1,this._moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this._moveVector=new G(0,0,0),this._rotationVector=new G(0,0,0),this._lastQuaternion=new Ss,this._lastPosition=new G,this._status=0,this._onKeyDown=sK.bind(this),this._onKeyUp=aK.bind(this),this._onPointerMove=lK.bind(this),this._onPointerDown=oK.bind(this),this._onPointerUp=uK.bind(this),this._onPointerCancel=cK.bind(this),this._onContextMenu=hK.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu)}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu)}dispose(){this.disconnect()}update(e){if(this.enabled===!1)return;const t=this.object,n=e*this.movementSpeed,r=e*this.rollSpeed;t.translateX(this._moveVector.x*n),t.translateY(this._moveVector.y*n),t.translateZ(this._moveVector.z*n),gN.set(this._rotationVector.x*r,this._rotationVector.y*r,this._rotationVector.z*r,1).normalize(),t.quaternion.multiply(gN),(this._lastPosition.distanceToSquared(t.position)>mN||8*(1-this._lastQuaternion.dot(t.quaternion))>mN)&&(this.dispatchEvent(iK),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function sK(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function aK(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function oK(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function lK(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function uK(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function cK(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function hK(i){this.enabled!==!1&&i.preventDefault()}const fK={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`

		varying vec2 vUv;

		void main() {

			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`

		uniform float opacity;

		uniform sampler2D tDiffuse;

		varying vec2 vUv;

		void main() {

			vec4 texel = texture2D( tDiffuse, vUv );
			gl_FragColor = opacity * texel;


		}`};class p0{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const dK=new Zh(-1,1,1,-1,0,1);class pK extends Fi{constructor(){super(),this.setAttribute("position",new ti([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ti([0,2,0,0,2,0],2))}}const mK=new pK;class gK{constructor(e){this._mesh=new xi(mK,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,dK)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class _K extends p0{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Ts?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=n2.clone(e.uniforms),this.material=new Ts({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new gK(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class _N extends p0{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let o,u;this.inverse?(o=0,u=1):(o=1,u=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,o,4294967295),s.buffers.stencil.setClear(u),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}}class vK extends p0{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class yK{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new Ie);this._width=n.width,this._height=n.height,t=new Hs(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Qn}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new _K(fK),this.copyPass.material.blending=Bi,this.timer=new yF}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let r=0,s=this.passes.length;r<s;r++){const o=this.passes[r];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(r),o.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),o.needsSwap){if(n){const u=this.renderer.getContext(),c=this.renderer.state.buffers.stencil;c.setFunc(u.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),c.setFunc(u.EQUAL,1,4294967295)}this.swapBuffers()}_N!==void 0&&(o instanceof _N?n=!0:o instanceof vK&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new Ie);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let s=0;s<this.passes.length;s++)this.passes[s].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class xK extends p0{constructor(e,t,n=null,r=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new pt}render(e,t,n){const r=e.autoClear;e.autoClear=!1;let s,o;this.overrideMaterial!==null&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=o),e.autoClear=r}}function Ir(){return Ir=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},Ir.apply(null,arguments)}function bK(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function vp(i,e){return vp=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},vp(i,e)}function SK(i,e){i.prototype=Object.create(e.prototype),i.prototype.constructor=i,vp(i,e)}function oS(i){return oS=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},oS(i)}function TK(i){try{return Function.toString.call(i).indexOf("[native code]")!==-1}catch{return typeof i=="function"}}function nL(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(nL=function(){return!!i})()}function MK(i,e,t){if(nL())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var r=new(i.bind.apply(i,n));return t&&vp(r,t.prototype),r}function lS(i){var e=typeof Map=="function"?new Map:void 0;return lS=function(n){if(n===null||!TK(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(n))return e.get(n);e.set(n,r)}function r(){return MK(n,arguments,oS(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),vp(r,n)},lS(i)}var ga=(function(i){SK(e,i);function e(t){var n;return n=i.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this,bK(n)}return e})(lS(Error));function pb(i){return Math.round(i*255)}function EK(i,e,t){return pb(i)+","+pb(e)+","+pb(t)}function U_(i,e,t,n){if(n===void 0&&(n=EK),e===0)return n(t,t,t);var r=(i%360+360)%360/60,s=(1-Math.abs(2*t-1))*e,o=s*(1-Math.abs(r%2-1)),u=0,c=0,h=0;r>=0&&r<1?(u=s,c=o):r>=1&&r<2?(u=o,c=s):r>=2&&r<3?(c=s,h=o):r>=3&&r<4?(c=o,h=s):r>=4&&r<5?(u=o,h=s):r>=5&&r<6&&(u=s,h=o);var d=t-s/2,p=u+d,g=c+d,_=h+d;return n(p,g,_)}var vN={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function AK(i){if(typeof i!="string")return i;var e=i.toLowerCase();return vN[e]?"#"+vN[e]:i}var wK=/^#[a-fA-F0-9]{6}$/,RK=/^#[a-fA-F0-9]{8}$/,CK=/^#[a-fA-F0-9]{3}$/,NK=/^#[a-fA-F0-9]{4}$/,mb=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,DK=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,LK=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,PK=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function jh(i){if(typeof i!="string")throw new ga(3);var e=AK(i);if(e.match(wK))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(RK)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(CK))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(NK)){var n=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:n}}var r=mb.exec(e);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var s=DK.exec(e.substring(0,50));if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10),alpha:parseFloat(""+s[4])>1?parseFloat(""+s[4])/100:parseFloat(""+s[4])};var o=LK.exec(e);if(o){var u=parseInt(""+o[1],10),c=parseInt(""+o[2],10)/100,h=parseInt(""+o[3],10)/100,d="rgb("+U_(u,c,h)+")",p=mb.exec(d);if(!p)throw new ga(4,e,d);return{red:parseInt(""+p[1],10),green:parseInt(""+p[2],10),blue:parseInt(""+p[3],10)}}var g=PK.exec(e.substring(0,50));if(g){var _=parseInt(""+g[1],10),v=parseInt(""+g[2],10)/100,S=parseInt(""+g[3],10)/100,b="rgb("+U_(_,v,S)+")",x=mb.exec(b);if(!x)throw new ga(4,e,b);return{red:parseInt(""+x[1],10),green:parseInt(""+x[2],10),blue:parseInt(""+x[3],10),alpha:parseFloat(""+g[4])>1?parseFloat(""+g[4])/100:parseFloat(""+g[4])}}throw new ga(5)}function UK(i){var e=i.red/255,t=i.green/255,n=i.blue/255,r=Math.max(e,t,n),s=Math.min(e,t,n),o=(r+s)/2;if(r===s)return i.alpha!==void 0?{hue:0,saturation:0,lightness:o,alpha:i.alpha}:{hue:0,saturation:0,lightness:o};var u,c=r-s,h=o>.5?c/(2-r-s):c/(r+s);switch(r){case e:u=(t-n)/c+(t<n?6:0);break;case t:u=(n-e)/c+2;break;default:u=(e-t)/c+4;break}return u*=60,i.alpha!==void 0?{hue:u,saturation:h,lightness:o,alpha:i.alpha}:{hue:u,saturation:h,lightness:o}}function Dl(i){return UK(jh(i))}var OK=function(e){return e.length===7&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e},uS=OK;function lu(i){var e=i.toString(16);return e.length===1?"0"+e:e}function gb(i){return lu(Math.round(i*255))}function BK(i,e,t){return uS("#"+gb(i)+gb(e)+gb(t))}function iL(i,e,t){return U_(i,e,t,BK)}function FK(i,e,t){if(typeof i=="object"&&e===void 0&&t===void 0)return iL(i.hue,i.saturation,i.lightness);throw new ga(1)}function IK(i,e,t,n){if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?iL(i.hue,i.saturation,i.lightness):"rgba("+U_(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new ga(2)}function rL(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return uS("#"+lu(i)+lu(e)+lu(t));if(typeof i=="object"&&e===void 0&&t===void 0)return uS("#"+lu(i.red)+lu(i.green)+lu(i.blue));throw new ga(6)}function m0(i,e,t,n){if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?rL(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")";throw new ga(7)}var zK=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},kK=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},GK=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},VK=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function Ll(i){if(typeof i!="object")throw new ga(8);if(kK(i))return m0(i);if(zK(i))return rL(i);if(VK(i))return IK(i);if(GK(i))return FK(i);throw new ga(8)}function sL(i,e,t){return function(){var r=t.concat(Array.prototype.slice.call(arguments));return r.length>=e?i.apply(this,r):sL(i,e,r)}}function rs(i){return sL(i,i.length,[])}function HK(i,e){if(e==="transparent")return e;var t=Dl(e);return Ll(Ir({},t,{hue:t.hue+parseFloat(i)}))}rs(HK);function cf(i,e,t){return Math.max(i,Math.min(e,t))}function jK(i,e){if(e==="transparent")return e;var t=Dl(e);return Ll(Ir({},t,{lightness:cf(0,1,t.lightness-parseFloat(i))}))}rs(jK);function WK(i,e){if(e==="transparent")return e;var t=Dl(e);return Ll(Ir({},t,{saturation:cf(0,1,t.saturation-parseFloat(i))}))}rs(WK);function $K(i,e){if(e==="transparent")return e;var t=Dl(e);return Ll(Ir({},t,{lightness:cf(0,1,t.lightness+parseFloat(i))}))}rs($K);function qK(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var n=jh(e),r=Ir({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),s=jh(t),o=Ir({},s,{alpha:typeof s.alpha=="number"?s.alpha:1}),u=r.alpha-o.alpha,c=parseFloat(i)*2-1,h=c*u===-1?c:c+u,d=1+c*u,p=(h/d+1)/2,g=1-p,_={red:Math.floor(r.red*p+o.red*g),green:Math.floor(r.green*p+o.green*g),blue:Math.floor(r.blue*p+o.blue*g),alpha:r.alpha*parseFloat(i)+o.alpha*(1-parseFloat(i))};return m0(_)}var XK=rs(qK),aL=XK;function YK(i,e){if(e==="transparent")return e;var t=jh(e),n=typeof t.alpha=="number"?t.alpha:1,r=Ir({},t,{alpha:cf(0,1,(n*100+parseFloat(i)*100)/100)});return m0(r)}var KK=rs(YK),ZK=KK;function QK(i,e){if(e==="transparent")return e;var t=Dl(e);return Ll(Ir({},t,{saturation:cf(0,1,t.saturation+parseFloat(i))}))}rs(QK);function JK(i,e){return e==="transparent"?e:Ll(Ir({},Dl(e),{hue:parseFloat(i)}))}rs(JK);function eZ(i,e){return e==="transparent"?e:Ll(Ir({},Dl(e),{lightness:parseFloat(i)}))}rs(eZ);function tZ(i,e){return e==="transparent"?e:Ll(Ir({},Dl(e),{saturation:parseFloat(i)}))}rs(tZ);function nZ(i,e){return e==="transparent"?e:aL(parseFloat(i),"rgb(0, 0, 0)",e)}rs(nZ);function iZ(i,e){return e==="transparent"?e:aL(parseFloat(i),"rgb(255, 255, 255)",e)}rs(iZ);function rZ(i,e){if(e==="transparent")return e;var t=jh(e),n=typeof t.alpha=="number"?t.alpha:1,r=Ir({},t,{alpha:cf(0,1,+(n*100-parseFloat(i)*100).toFixed(2)/100)});return m0(r)}rs(rZ);var Tu=Object.freeze({Linear:Object.freeze({None:function(i){return i},In:function(i){return i},Out:function(i){return i},InOut:function(i){return i}}),Quadratic:Object.freeze({In:function(i){return i*i},Out:function(i){return i*(2-i)},InOut:function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)}}),Cubic:Object.freeze({In:function(i){return i*i*i},Out:function(i){return--i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)}}),Quartic:Object.freeze({In:function(i){return i*i*i*i},Out:function(i){return 1- --i*i*i*i},InOut:function(i){return(i*=2)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2)}}),Quintic:Object.freeze({In:function(i){return i*i*i*i*i},Out:function(i){return--i*i*i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2)}}),Sinusoidal:Object.freeze({In:function(i){return 1-Math.sin((1-i)*Math.PI/2)},Out:function(i){return Math.sin(i*Math.PI/2)},InOut:function(i){return .5*(1-Math.sin(Math.PI*(.5-i)))}}),Exponential:Object.freeze({In:function(i){return i===0?0:Math.pow(1024,i-1)},Out:function(i){return i===1?1:1-Math.pow(2,-10*i)},InOut:function(i){return i===0?0:i===1?1:(i*=2)<1?.5*Math.pow(1024,i-1):.5*(-Math.pow(2,-10*(i-1))+2)}}),Circular:Object.freeze({In:function(i){return 1-Math.sqrt(1-i*i)},Out:function(i){return Math.sqrt(1- --i*i)},InOut:function(i){return(i*=2)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1)}}),Elastic:Object.freeze({In:function(i){return i===0?0:i===1?1:-Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI)},Out:function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin((i-.1)*5*Math.PI)+1},InOut:function(i){return i===0?0:i===1?1:(i*=2,i<1?-.5*Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI):.5*Math.pow(2,-10*(i-1))*Math.sin((i-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(i){var e=1.70158;return i===1?1:i*i*((e+1)*i-e)},Out:function(i){var e=1.70158;return i===0?0:--i*i*((e+1)*i+e)+1},InOut:function(i){var e=2.5949095;return(i*=2)<1?.5*(i*i*((e+1)*i-e)):.5*((i-=2)*i*((e+1)*i+e)+2)}}),Bounce:Object.freeze({In:function(i){return 1-Tu.Bounce.Out(1-i)},Out:function(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},InOut:function(i){return i<.5?Tu.Bounce.In(i*2)*.5:Tu.Bounce.Out(i*2-1)*.5+.5}}),generatePow:function(i){return i===void 0&&(i=4),i=i<Number.EPSILON?Number.EPSILON:i,i=i>1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),Ud=function(){return performance.now()},oL=(function(){function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,e)}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=0,s=t;r<s.length;r++){var o=s[r];(e=o._group)===null||e===void 0||e.remove(o),o._group=this,this._tweens[o.getId()]=o,this._tweensAddedDuringUpdate[o.getId()]=o}},i.prototype.remove=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=0,r=e;n<r.length;n++){var s=r[n];s._group=void 0,delete this._tweens[s.getId()],delete this._tweensAddedDuringUpdate[s.getId()]}},i.prototype.allStopped=function(){return this.getAll().every(function(e){return!e.isPlaying()})},i.prototype.update=function(e,t){e===void 0&&(e=Ud()),t===void 0&&(t=!0);var n=Object.keys(this._tweens);if(n.length!==0)for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var s=this._tweens[n[r]],o=!t;s&&s.update(e,o)===!1&&!t&&this.remove(s)}n=Object.keys(this._tweensAddedDuringUpdate)}},i})(),cS={Linear:function(i,e){var t=i.length-1,n=t*e,r=Math.floor(n),s=cS.Utils.Linear;return e<0?s(i[0],i[1],n):e>1?s(i[t],i[t-1],t-n):s(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},lL=(function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i})(),hS=new oL,yN=(function(){function i(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Tu.Linear.None,this._interpolationFunction=cS.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=lL.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof t=="object"?(this._group=t,t.add(this)):t===!0&&(this._group=hS,hS.add(this))}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=Ud()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,s){for(var o in n){var u=e[o],c=Array.isArray(u),h=c?"array":typeof u,d=!c&&Array.isArray(n[o]);if(!(h==="undefined"||h==="function")){if(d){var p=n[o];if(p.length===0)continue;for(var g=[u],_=0,v=p.length;_<v;_+=1){var S=this._handleRelativeValue(u,p[_]);if(isNaN(S)){d=!1,console.warn("Found invalid interpolation list. Skipping.");break}g.push(S)}d&&(n[o]=g)}if((h==="object"||c)&&u&&!d){t[o]=c?[]:{};var b=u;for(var x in b)t[o][x]=b[x];r[o]=c?[]:{};var p=n[o];if(!this._isDynamic){var M={};for(var x in p)M[x]=p[x];n[o]=p=M}this._setupProperties(b,t[o],p,r[o],s)}else(typeof t[o]>"u"||s)&&(t[o]=u),c||(t[o]*=1),d?r[o]=n[o].slice().reverse():r[o]=t[o]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},i.prototype.pause=function(e){return e===void 0&&(e=Ud()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},i.prototype.resume=function(e){return e===void 0&&(e=Ud()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},i.prototype.group=function(e){return e?(e.add(this),this):(console.warn("tween.group() without args has been removed, use group.add(tween) instead."),this)},i.prototype.remove=function(){var e;return(e=this._group)===null||e===void 0||e.remove(this),this},i.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},i.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},i.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},i.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},i.prototype.easing=function(e){return e===void 0&&(e=Tu.Linear.None),this._easingFunction=e,this},i.prototype.interpolation=function(e){return e===void 0&&(e=cS.Linear),this._interpolationFunction=e,this},i.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},i.prototype.onStart=function(e){return this._onStartCallback=e,this},i.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},i.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},i.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},i.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},i.prototype.onStop=function(e){return this._onStopCallback=e,this},i.prototype.update=function(e,t){var n=this,r;if(e===void 0&&(e=Ud()),t===void 0&&(t=i.autoStartOnUpdate),this._isPaused)return!0;var s;if(!this._goToEnd&&!this._isPlaying)if(t)this.start(e,!0);else return!1;if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var o=e-this._startTime,u=this._duration+((r=this._repeatDelayTime)!==null&&r!==void 0?r:this._delayTime),c=this._duration+this._repeat*u,h=function(){if(n._duration===0||o>c)return 1;var S=Math.trunc(o/u),b=o-S*u,x=Math.min(b/n._duration,1);return x===0&&o===n._duration?1:x},d=h(),p=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||o>=this._duration)if(this._repeat>0){var g=Math.min(Math.trunc((o-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=g);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*g,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var _=0,v=this._chainedTweens.length;_<v;_++)this._chainedTweens[_].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},i.prototype._updateProperties=function(e,t,n,r){for(var s in n)if(t[s]!==void 0){var o=t[s]||0,u=n[s],c=Array.isArray(e[s]),h=Array.isArray(u),d=!c&&h;d?e[s]=this._interpolationFunction(u,r):typeof u=="object"&&u?this._updateProperties(e[s],o,u,r):(u=this._handleRelativeValue(o,u),typeof u=="number"&&(e[s]=o+(u-o)*r))}},i.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},i.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},i.autoStartOnUpdate=!1,i})();lL.nextId;var Ea=hS;Ea.getAll.bind(Ea);Ea.removeAll.bind(Ea);Ea.add.bind(Ea);Ea.remove.bind(Ea);Ea.update.bind(Ea);var fS="http://www.w3.org/1999/xhtml";const xN={svg:"http://www.w3.org/2000/svg",xhtml:fS,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function uL(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),xN.hasOwnProperty(e)?{space:xN[e],local:i}:i}function sZ(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===fS&&e.documentElement.namespaceURI===fS?e.createElement(i):e.createElementNS(t,i)}}function aZ(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function cL(i){var e=uL(i);return(e.local?aZ:sZ)(e)}function oZ(){}function hL(i){return i==null?oZ:function(){return this.querySelector(i)}}function lZ(i){typeof i!="function"&&(i=hL(i));for(var e=this._groups,t=e.length,n=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,u=n[r]=new Array(o),c,h,d=0;d<o;++d)(c=s[d])&&(h=i.call(c,c.__data__,d,s))&&("__data__"in c&&(h.__data__=c.__data__),u[d]=h);return new Es(n,this._parents)}function uZ(i){return i==null?[]:Array.isArray(i)?i:Array.from(i)}function cZ(){return[]}function hZ(i){return i==null?cZ:function(){return this.querySelectorAll(i)}}function fZ(i){return function(){return uZ(i.apply(this,arguments))}}function dZ(i){typeof i=="function"?i=fZ(i):i=hZ(i);for(var e=this._groups,t=e.length,n=[],r=[],s=0;s<t;++s)for(var o=e[s],u=o.length,c,h=0;h<u;++h)(c=o[h])&&(n.push(i.call(c,c.__data__,h,o)),r.push(c));return new Es(n,r)}function pZ(i){return function(){return this.matches(i)}}function fL(i){return function(e){return e.matches(i)}}var mZ=Array.prototype.find;function gZ(i){return function(){return mZ.call(this.children,i)}}function _Z(){return this.firstElementChild}function vZ(i){return this.select(i==null?_Z:gZ(typeof i=="function"?i:fL(i)))}var yZ=Array.prototype.filter;function xZ(){return Array.from(this.children)}function bZ(i){return function(){return yZ.call(this.children,i)}}function SZ(i){return this.selectAll(i==null?xZ:bZ(typeof i=="function"?i:fL(i)))}function TZ(i){typeof i!="function"&&(i=pZ(i));for(var e=this._groups,t=e.length,n=new Array(t),r=0;r<t;++r)for(var s=e[r],o=s.length,u=n[r]=[],c,h=0;h<o;++h)(c=s[h])&&i.call(c,c.__data__,h,s)&&u.push(c);return new Es(n,this._parents)}function dL(i){return new Array(i.length)}function MZ(){return new Es(this._enter||this._groups.map(dL),this._parents)}function O_(i,e){this.ownerDocument=i.ownerDocument,this.namespaceURI=i.namespaceURI,this._next=null,this._parent=i,this.__data__=e}O_.prototype={constructor:O_,appendChild:function(i){return this._parent.insertBefore(i,this._next)},insertBefore:function(i,e){return this._parent.insertBefore(i,e)},querySelector:function(i){return this._parent.querySelector(i)},querySelectorAll:function(i){return this._parent.querySelectorAll(i)}};function EZ(i){return function(){return i}}function AZ(i,e,t,n,r,s){for(var o=0,u,c=e.length,h=s.length;o<h;++o)(u=e[o])?(u.__data__=s[o],n[o]=u):t[o]=new O_(i,s[o]);for(;o<c;++o)(u=e[o])&&(r[o]=u)}function wZ(i,e,t,n,r,s,o){var u,c,h=new Map,d=e.length,p=s.length,g=new Array(d),_;for(u=0;u<d;++u)(c=e[u])&&(g[u]=_=o.call(c,c.__data__,u,e)+"",h.has(_)?r[u]=c:h.set(_,c));for(u=0;u<p;++u)_=o.call(i,s[u],u,s)+"",(c=h.get(_))?(n[u]=c,c.__data__=s[u],h.delete(_)):t[u]=new O_(i,s[u]);for(u=0;u<d;++u)(c=e[u])&&h.get(g[u])===c&&(r[u]=c)}function RZ(i){return i.__data__}function CZ(i,e){if(!arguments.length)return Array.from(this,RZ);var t=e?wZ:AZ,n=this._parents,r=this._groups;typeof i!="function"&&(i=EZ(i));for(var s=r.length,o=new Array(s),u=new Array(s),c=new Array(s),h=0;h<s;++h){var d=n[h],p=r[h],g=p.length,_=NZ(i.call(d,d&&d.__data__,h,n)),v=_.length,S=u[h]=new Array(v),b=o[h]=new Array(v),x=c[h]=new Array(g);t(d,p,S,b,x,_,e);for(var M=0,E=0,w,D;M<v;++M)if(w=S[M]){for(M>=E&&(E=M+1);!(D=b[E])&&++E<v;);w._next=D||null}}return o=new Es(o,n),o._enter=u,o._exit=c,o}function NZ(i){return typeof i=="object"&&"length"in i?i:Array.from(i)}function DZ(){return new Es(this._exit||this._groups.map(dL),this._parents)}function LZ(i,e,t){var n=this.enter(),r=this,s=this.exit();return typeof i=="function"?(n=i(n),n&&(n=n.selection())):n=n.append(i+""),e!=null&&(r=e(r),r&&(r=r.selection())),t==null?s.remove():t(s),n&&r?n.merge(r).order():r}function PZ(i){for(var e=i.selection?i.selection():i,t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),u=new Array(r),c=0;c<o;++c)for(var h=t[c],d=n[c],p=h.length,g=u[c]=new Array(p),_,v=0;v<p;++v)(_=h[v]||d[v])&&(g[v]=_);for(;c<r;++c)u[c]=t[c];return new Es(u,this._parents)}function UZ(){for(var i=this._groups,e=-1,t=i.length;++e<t;)for(var n=i[e],r=n.length-1,s=n[r],o;--r>=0;)(o=n[r])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function OZ(i){i||(i=BZ);function e(p,g){return p&&g?i(p.__data__,g.__data__):!p-!g}for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s){for(var o=t[s],u=o.length,c=r[s]=new Array(u),h,d=0;d<u;++d)(h=o[d])&&(c[d]=h);c.sort(e)}return new Es(r,this._parents).order()}function BZ(i,e){return i<e?-1:i>e?1:i>=e?0:NaN}function FZ(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function IZ(){return Array.from(this)}function zZ(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],r=0,s=n.length;r<s;++r){var o=n[r];if(o)return o}return null}function kZ(){let i=0;for(const e of this)++i;return i}function GZ(){return!this.node()}function VZ(i){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length,u;s<o;++s)(u=r[s])&&i.call(u,u.__data__,s,r);return this}function HZ(i){return function(){this.removeAttribute(i)}}function jZ(i){return function(){this.removeAttributeNS(i.space,i.local)}}function WZ(i,e){return function(){this.setAttribute(i,e)}}function $Z(i,e){return function(){this.setAttributeNS(i.space,i.local,e)}}function qZ(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(i):this.setAttribute(i,t)}}function XZ(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(i.space,i.local):this.setAttributeNS(i.space,i.local,t)}}function YZ(i,e){var t=uL(i);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?jZ:HZ:typeof e=="function"?t.local?XZ:qZ:t.local?$Z:WZ)(t,e))}function pL(i){return i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView}function KZ(i){return function(){this.style.removeProperty(i)}}function ZZ(i,e,t){return function(){this.style.setProperty(i,e,t)}}function QZ(i,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(i):this.style.setProperty(i,n,t)}}function JZ(i,e,t){return arguments.length>1?this.each((e==null?KZ:typeof e=="function"?QZ:ZZ)(i,e,t??"")):eQ(this.node(),i)}function eQ(i,e){return i.style.getPropertyValue(e)||pL(i).getComputedStyle(i,null).getPropertyValue(e)}function tQ(i){return function(){delete this[i]}}function nQ(i,e){return function(){this[i]=e}}function iQ(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function rQ(i,e){return arguments.length>1?this.each((e==null?tQ:typeof e=="function"?iQ:nQ)(i,e)):this.node()[i]}function mL(i){return i.trim().split(/^|\s+/)}function VT(i){return i.classList||new gL(i)}function gL(i){this._node=i,this._names=mL(i.getAttribute("class")||"")}gL.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function _L(i,e){for(var t=VT(i),n=-1,r=e.length;++n<r;)t.add(e[n])}function vL(i,e){for(var t=VT(i),n=-1,r=e.length;++n<r;)t.remove(e[n])}function sQ(i){return function(){_L(this,i)}}function aQ(i){return function(){vL(this,i)}}function oQ(i,e){return function(){(e.apply(this,arguments)?_L:vL)(this,i)}}function lQ(i,e){var t=mL(i+"");if(arguments.length<2){for(var n=VT(this.node()),r=-1,s=t.length;++r<s;)if(!n.contains(t[r]))return!1;return!0}return this.each((typeof e=="function"?oQ:e?sQ:aQ)(t,e))}function uQ(){this.textContent=""}function cQ(i){return function(){this.textContent=i}}function hQ(i){return function(){var e=i.apply(this,arguments);this.textContent=e??""}}function fQ(i){return arguments.length?this.each(i==null?uQ:(typeof i=="function"?hQ:cQ)(i)):this.node().textContent}function dQ(){this.innerHTML=""}function pQ(i){return function(){this.innerHTML=i}}function mQ(i){return function(){var e=i.apply(this,arguments);this.innerHTML=e??""}}function gQ(i){return arguments.length?this.each(i==null?dQ:(typeof i=="function"?mQ:pQ)(i)):this.node().innerHTML}function _Q(){this.nextSibling&&this.parentNode.appendChild(this)}function vQ(){return this.each(_Q)}function yQ(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function xQ(){return this.each(yQ)}function bQ(i){var e=typeof i=="function"?i:cL(i);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function SQ(){return null}function TQ(i,e){var t=typeof i=="function"?i:cL(i),n=e==null?SQ:typeof e=="function"?e:hL(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function MQ(){var i=this.parentNode;i&&i.removeChild(this)}function EQ(){return this.each(MQ)}function AQ(){var i=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function wQ(){var i=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function RQ(i){return this.select(i?wQ:AQ)}function CQ(i){return arguments.length?this.property("__data__",i):this.node().__data__}function NQ(i){return function(e){i.call(this,e,this.__data__)}}function DQ(i){return i.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function LQ(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,r=e.length,s;t<r;++t)s=e[t],(!i.type||s.type===i.type)&&s.name===i.name?this.removeEventListener(s.type,s.listener,s.options):e[++n]=s;++n?e.length=n:delete this.__on}}}function PQ(i,e,t){return function(){var n=this.__on,r,s=NQ(e);if(n){for(var o=0,u=n.length;o<u;++o)if((r=n[o]).type===i.type&&r.name===i.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=t),r.value=e;return}}this.addEventListener(i.type,s,t),r={type:i.type,name:i.name,value:e,listener:s,options:t},n?n.push(r):this.__on=[r]}}function UQ(i,e,t){var n=DQ(i+""),r,s=n.length,o;if(arguments.length<2){var u=this.node().__on;if(u){for(var c=0,h=u.length,d;c<h;++c)for(r=0,d=u[c];r<s;++r)if((o=n[r]).type===d.type&&o.name===d.name)return d.value}return}for(u=e?PQ:LQ,r=0;r<s;++r)this.each(u(n[r],e,t));return this}function yL(i,e,t){var n=pL(i),r=n.CustomEvent;typeof r=="function"?r=new r(e,t):(r=n.document.createEvent("Event"),t?(r.initEvent(e,t.bubbles,t.cancelable),r.detail=t.detail):r.initEvent(e,!1,!1)),i.dispatchEvent(r)}function OQ(i,e){return function(){return yL(this,i,e)}}function BQ(i,e){return function(){return yL(this,i,e.apply(this,arguments))}}function FQ(i,e){return this.each((typeof e=="function"?BQ:OQ)(i,e))}function*IQ(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],r=0,s=n.length,o;r<s;++r)(o=n[r])&&(yield o)}var zQ=[null];function Es(i,e){this._groups=i,this._parents=e}function kQ(){return this}Es.prototype={constructor:Es,select:lZ,selectAll:dZ,selectChild:vZ,selectChildren:SZ,filter:TZ,data:CZ,enter:MZ,exit:DZ,join:LZ,merge:PZ,selection:kQ,order:UZ,sort:OZ,call:FZ,nodes:IZ,node:zZ,size:kZ,empty:GZ,each:VZ,attr:YZ,style:JZ,property:rQ,classed:lQ,text:fQ,html:gQ,raise:vQ,lower:xQ,append:bQ,insert:TQ,remove:EQ,clone:RQ,datum:CQ,on:UQ,dispatch:FQ,[Symbol.iterator]:IQ};function GQ(i){return typeof i=="string"?new Es([[document.querySelector(i)]],[document.documentElement]):new Es([[i]],zQ)}function VQ(i){let e;for(;e=i.sourceEvent;)i=e;return i}function HQ(i,e){if(i=VQ(i),e===void 0&&(e=i.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=i.clientX,n.y=i.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[i.clientX-r.left-e.clientLeft,i.clientY-r.top-e.clientTop]}}return[i.pageX,i.pageY]}var Dp,Jn,xL,bL,mu,bN,SL,TL,ML,HT,dS,pS,B_={},F_=[],jQ=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,g0=Array.isArray;function _a(i,e){for(var t in e)i[t]=e[t];return i}function jT(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function WQ(i,e,t){var n,r,s,o={};for(s in e)s=="key"?n=e[s]:s=="ref"?r=e[s]:o[s]=e[s];if(arguments.length>2&&(o.children=arguments.length>3?Dp.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(s in i.defaultProps)o[s]===void 0&&(o[s]=i.defaultProps[s]);return Yd(i,o,n,r,null)}function Yd(i,e,t,n,r){var s={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++xL,__i:-1,__u:0};return r==null&&Jn.vnode!=null&&Jn.vnode(s),s}function _0(i){return i.children}function f_(i,e){this.props=i,this.context=e}function Wh(i,e){if(e==null)return i.__?Wh(i.__,i.__i+1):null;for(var t;e<i.__k.length;e++)if((t=i.__k[e])!=null&&t.__e!=null)return t.__e;return typeof i.type=="function"?Wh(i):null}function $Q(i){if(i.__P&&i.__d){var e=i.__v,t=e.__e,n=[],r=[],s=_a({},e);s.__v=e.__v+1,Jn.vnode&&Jn.vnode(s),WT(i.__P,s,e,i.__n,i.__P.namespaceURI,32&e.__u?[t]:null,n,t??Wh(e),!!(32&e.__u),r),s.__v=e.__v,s.__.__k[s.__i]=s,RL(n,s,r),e.__e=e.__=null,s.__e!=t&&EL(s)}}function EL(i){if((i=i.__)!=null&&i.__c!=null)return i.__e=i.__c.base=null,i.__k.some(function(e){if(e!=null&&e.__e!=null)return i.__e=i.__c.base=e.__e}),EL(i)}function SN(i){(!i.__d&&(i.__d=!0)&&mu.push(i)&&!I_.__r++||bN!=Jn.debounceRendering)&&((bN=Jn.debounceRendering)||SL)(I_)}function I_(){for(var i,e=1;mu.length;)mu.length>e&&mu.sort(TL),i=mu.shift(),e=mu.length,$Q(i);I_.__r=0}function AL(i,e,t,n,r,s,o,u,c,h,d){var p,g,_,v,S,b,x,M=n&&n.__k||F_,E=e.length;for(c=qQ(t,e,M,c,E),p=0;p<E;p++)(_=t.__k[p])!=null&&(g=_.__i!=-1&&M[_.__i]||B_,_.__i=p,b=WT(i,_,g,r,s,o,u,c,h,d),v=_.__e,_.ref&&g.ref!=_.ref&&(g.ref&&$T(g.ref,null,_),d.push(_.ref,_.__c||v,_)),S==null&&v!=null&&(S=v),(x=!!(4&_.__u))||g.__k===_.__k?c=wL(_,c,i,x):typeof _.type=="function"&&b!==void 0?c=b:v&&(c=v.nextSibling),_.__u&=-7);return t.__e=S,c}function qQ(i,e,t,n,r){var s,o,u,c,h,d=t.length,p=d,g=0;for(i.__k=new Array(r),s=0;s<r;s++)(o=e[s])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=i.__k[s]=Yd(null,o,null,null,null):g0(o)?o=i.__k[s]=Yd(_0,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=i.__k[s]=Yd(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):i.__k[s]=o,c=s+g,o.__=i,o.__b=i.__b+1,u=null,(h=o.__i=XQ(o,t,c,p))!=-1&&(p--,(u=t[h])&&(u.__u|=2)),u==null||u.__v==null?(h==-1&&(r>d?g--:r<d&&g++),typeof o.type!="function"&&(o.__u|=4)):h!=c&&(h==c-1?g--:h==c+1?g++:(h>c?g--:g++,o.__u|=4))):i.__k[s]=null;if(p)for(s=0;s<d;s++)(u=t[s])!=null&&(2&u.__u)==0&&(u.__e==n&&(n=Wh(u)),NL(u,u));return n}function wL(i,e,t,n){var r,s;if(typeof i.type=="function"){for(r=i.__k,s=0;r&&s<r.length;s++)r[s]&&(r[s].__=i,e=wL(r[s],e,t,n));return e}i.__e!=e&&(n&&(e&&i.type&&!e.parentNode&&(e=Wh(i)),t.insertBefore(i.__e,e||null)),e=i.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function XQ(i,e,t,n){var r,s,o,u=i.key,c=i.type,h=e[t],d=h!=null&&(2&h.__u)==0;if(h===null&&u==null||d&&u==h.key&&c==h.type)return t;if(n>(d?1:0)){for(r=t-1,s=t+1;r>=0||s<e.length;)if((h=e[o=r>=0?r--:s++])!=null&&(2&h.__u)==0&&u==h.key&&c==h.type)return o}return-1}function TN(i,e,t){e[0]=="-"?i.setProperty(e,t??""):i[e]=t==null?"":typeof t!="number"||jQ.test(e)?t:t+"px"}function t_(i,e,t,n,r){var s,o;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||TN(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||TN(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(ML,"$1")),o=e.toLowerCase(),e=o in i||e=="onFocusOut"||e=="onFocusIn"?o.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+s]=t,t?n?t.u=n.u:(t.u=HT,i.addEventListener(e,s?pS:dS,s)):i.removeEventListener(e,s?pS:dS,s);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{i[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function MN(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=HT++;else if(e.t<t.u)return;return t(Jn.event?Jn.event(e):e)}}}function WT(i,e,t,n,r,s,o,u,c,h){var d,p,g,_,v,S,b,x,M,E,w,D,C,N,A,L=e.type;if(e.constructor!==void 0)return null;128&t.__u&&(c=!!(32&t.__u),s=[u=e.__e=t.__e]),(d=Jn.__b)&&d(e);e:if(typeof L=="function")try{if(x=e.props,M="prototype"in L&&L.prototype.render,E=(d=L.contextType)&&n[d.__c],w=d?E?E.props.value:d.__:n,t.__c?b=(p=e.__c=t.__c).__=p.__E:(M?e.__c=p=new L(x,w):(e.__c=p=new f_(x,w),p.constructor=L,p.render=KQ),E&&E.sub(p),p.state||(p.state={}),p.__n=n,g=p.__d=!0,p.__h=[],p._sb=[]),M&&p.__s==null&&(p.__s=p.state),M&&L.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=_a({},p.__s)),_a(p.__s,L.getDerivedStateFromProps(x,p.__s))),_=p.props,v=p.state,p.__v=e,g)M&&L.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),M&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(M&&L.getDerivedStateFromProps==null&&x!==_&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(x,w),e.__v==t.__v||!p.__e&&p.shouldComponentUpdate!=null&&p.shouldComponentUpdate(x,p.__s,w)===!1){e.__v!=t.__v&&(p.props=x,p.state=p.__s,p.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(j){j&&(j.__=e)}),F_.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&o.push(p);break e}p.componentWillUpdate!=null&&p.componentWillUpdate(x,p.__s,w),M&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(_,v,S)})}if(p.context=w,p.props=x,p.__P=i,p.__e=!1,D=Jn.__r,C=0,M)p.state=p.__s,p.__d=!1,D&&D(e),d=p.render(p.props,p.state,p.context),F_.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,D&&D(e),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++C<25);p.state=p.__s,p.getChildContext!=null&&(n=_a(_a({},n),p.getChildContext())),M&&!g&&p.getSnapshotBeforeUpdate!=null&&(S=p.getSnapshotBeforeUpdate(_,v)),N=d!=null&&d.type===_0&&d.key==null?CL(d.props.children):d,u=AL(i,g0(N)?N:[N],e,t,n,r,s,o,u,c,h),p.base=e.__e,e.__u&=-161,p.__h.length&&o.push(p),b&&(p.__E=p.__=null)}catch(j){if(e.__v=null,c||s!=null)if(j.then){for(e.__u|=c?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;s[s.indexOf(u)]=null,e.__e=u}else{for(A=s.length;A--;)jT(s[A]);mS(e)}else e.__e=t.__e,e.__k=t.__k,j.then||mS(e);Jn.__e(j,e,t)}else s==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):u=e.__e=YQ(t.__e,e,t,n,r,s,o,c,h);return(d=Jn.diffed)&&d(e),128&e.__u?void 0:u}function mS(i){i&&(i.__c&&(i.__c.__e=!0),i.__k&&i.__k.some(mS))}function RL(i,e,t){for(var n=0;n<t.length;n++)$T(t[n],t[++n],t[++n]);Jn.__c&&Jn.__c(e,i),i.some(function(r){try{i=r.__h,r.__h=[],i.some(function(s){s.call(r)})}catch(s){Jn.__e(s,r.__v)}})}function CL(i){return typeof i!="object"||i==null||i.__b>0?i:g0(i)?i.map(CL):_a({},i)}function YQ(i,e,t,n,r,s,o,u,c){var h,d,p,g,_,v,S,b=t.props||B_,x=e.props,M=e.type;if(M=="svg"?r="http://www.w3.org/2000/svg":M=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s!=null){for(h=0;h<s.length;h++)if((_=s[h])&&"setAttribute"in _==!!M&&(M?_.localName==M:_.nodeType==3)){i=_,s[h]=null;break}}if(i==null){if(M==null)return document.createTextNode(x);i=document.createElementNS(r,M,x.is&&x),u&&(Jn.__m&&Jn.__m(e,s),u=!1),s=null}if(M==null)b===x||u&&i.data==x||(i.data=x);else{if(s=s&&Dp.call(i.childNodes),!u&&s!=null)for(b={},h=0;h<i.attributes.length;h++)b[(_=i.attributes[h]).name]=_.value;for(h in b)_=b[h],h=="dangerouslySetInnerHTML"?p=_:h=="children"||h in x||h=="value"&&"defaultValue"in x||h=="checked"&&"defaultChecked"in x||t_(i,h,null,_,r);for(h in x)_=x[h],h=="children"?g=_:h=="dangerouslySetInnerHTML"?d=_:h=="value"?v=_:h=="checked"?S=_:u&&typeof _!="function"||b[h]===_||t_(i,h,_,b[h],r);if(d)u||p&&(d.__html==p.__html||d.__html==i.innerHTML)||(i.innerHTML=d.__html),e.__k=[];else if(p&&(i.innerHTML=""),AL(e.type=="template"?i.content:i,g0(g)?g:[g],e,t,n,M=="foreignObject"?"http://www.w3.org/1999/xhtml":r,s,o,s?s[0]:t.__k&&Wh(t,0),u,c),s!=null)for(h=s.length;h--;)jT(s[h]);u||(h="value",M=="progress"&&v==null?i.removeAttribute("value"):v!=null&&(v!==i[h]||M=="progress"&&!v||M=="option"&&v!=b[h])&&t_(i,h,v,b[h],r),h="checked",S!=null&&S!=i[h]&&t_(i,h,S,b[h],r))}return i}function $T(i,e,t){try{if(typeof i=="function"){var n=typeof i.__u=="function";n&&i.__u(),n&&e==null||(i.__u=i(e))}else i.current=e}catch(r){Jn.__e(r,t)}}function NL(i,e,t){var n,r;if(Jn.unmount&&Jn.unmount(i),(n=i.ref)&&(n.current&&n.current!=i.__e||$T(n,null,e)),(n=i.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(s){Jn.__e(s,e)}n.base=n.__P=null}if(n=i.__k)for(r=0;r<n.length;r++)n[r]&&NL(n[r],e,t||typeof i.type!="function");t||jT(i.__e),i.__c=i.__=i.__e=void 0}function KQ(i,e,t){return this.constructor(i,t)}function ZQ(i,e,t){var n,r,s,o;e==document&&(e=document.documentElement),Jn.__&&Jn.__(i,e),r=(n=!1)?null:e.__k,s=[],o=[],WT(e,i=e.__k=WQ(_0,null,[i]),r||B_,B_,e.namespaceURI,r?null:e.firstChild?Dp.call(e.childNodes):null,s,r?r.__e:e.firstChild,n,o),RL(s,i,o)}function DL(i,e,t){var n,r,s,o,u=_a({},i.props);for(s in i.type&&i.type.defaultProps&&(o=i.type.defaultProps),e)s=="key"?n=e[s]:s=="ref"?r=e[s]:u[s]=e[s]===void 0&&o!=null?o[s]:e[s];return arguments.length>2&&(u.children=arguments.length>3?Dp.call(arguments,2):t),Yd(i.type,u,n||i.key,r||i.ref,null)}Dp=F_.slice,Jn={__e:function(i,e,t,n){for(var r,s,o;e=e.__;)if((r=e.__c)&&!r.__)try{if((s=r.constructor)&&s.getDerivedStateFromError!=null&&(r.setState(s.getDerivedStateFromError(i)),o=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(i,n||{}),o=r.__d),o)return r.__E=r}catch(u){i=u}throw i}},xL=0,bL=function(i){return i!=null&&i.constructor===void 0},f_.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=_a({},this.state),typeof i=="function"&&(i=i(_a({},t),this.props)),i&&_a(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),SN(this))},f_.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),SN(this))},f_.prototype.render=_0,mu=[],SL=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,TL=function(i,e){return i.__v.__b-e.__v.__b},I_.__r=0,ML=/(PointerCapture)$|Capture$/i,HT=0,dS=MN(!1),pS=MN(!0);function EN(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function QQ(i){if(Array.isArray(i))return i}function JQ(i,e,t){return(e=sJ(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function eJ(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,o,u=[],c=!0,h=!1;try{if(s=(t=t.call(i)).next,e!==0)for(;!(c=(n=s.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(d){h=!0,r=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw r}}return u}}function tJ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function AN(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function nJ(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?AN(Object(t),!0).forEach(function(n){JQ(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):AN(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function iJ(i,e){return QQ(i)||eJ(i,e)||aJ(i,e)||tJ()}function rJ(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function sJ(i){var e=rJ(i,"string");return typeof e=="symbol"?e:e+""}function z_(i){"@babel/helpers - typeof";return z_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},z_(i)}function aJ(i,e){if(i){if(typeof i=="string")return EN(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?EN(i,e):void 0}}var gS=function(e){if(z_(e)!=="object")return e;var t=DL(e);if(t.props){var n;t.props=nJ({},t.props),t!=null&&(n=t.props)!==null&&n!==void 0&&n.children&&(t.props.children=Array.isArray(t.props.children)?t.props.children.map(gS):gS(t.props.children))}return t},oJ=function(e){return bL(DL(e))},lJ=function(e,t){delete t.__k,ZQ(gS(e),t)};function uJ(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var cJ=`.float-tooltip-kap {
  position: absolute;
  width: max-content; /* prevent shrinking near right edge */
  max-width: max(50%, 150px);
  padding: 3px 5px;
  border-radius: 3px;
  font: 12px sans-serif;
  color: #eee;
  background: rgba(0,0,0,0.6);
  pointer-events: none;
}
`;uJ(cJ);var hJ=J_({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.style,s=r===void 0?{}:r,o=!!e&&z_(e)==="object"&&!!e.node&&typeof e.node=="function",u=GQ(o?e.node():e);u.style("position")==="static"&&u.style("position","relative"),t.tooltipEl=u.append("div").attr("class","float-tooltip-kap"),Object.entries(s).forEach(function(h){var d=iJ(h,2),p=d[0],g=d[1];return t.tooltipEl.style(p,g)}),t.tooltipEl.style("left","-10000px").style("display","none");var c="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,u.on("mousemove.".concat(c),function(h){t.mouseInside=!0;var d=HQ(h),p=u.node(),g=p.offsetWidth,_=p.offsetHeight,v=[t.offsetX===null||t.offsetX===void 0?"-".concat(d[0]/g*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?_>130&&_-d[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",d[0]+"px").style("top",d[1]+"px").style("transform","translate(".concat(v.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),u.on("mouseover.".concat(c),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),u.on("mouseout.".concat(c),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):oJ(e.content)?(e.tooltipEl.text(""),lJ(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function fJ(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var dJ=`.scene-nav-info {
  position: absolute;
  bottom: 5px;
  width: 100%;
  text-align: center;
  color: slategrey;
  opacity: 0.7;
  font-size: 10px;
  font-family: sans-serif;
  pointer-events: none;
  user-select: none;
}

.scene-container canvas:focus {
  outline: none;
}`;fJ(dJ);function _S(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function pJ(i){if(Array.isArray(i))return i}function mJ(i){if(Array.isArray(i))return _S(i)}function gJ(i,e,t){return(e=TJ(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _J(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function vJ(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,o,u=[],c=!0,h=!1;try{if(s=(t=t.call(i)).next,e!==0)for(;!(c=(n=s.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(d){h=!0,r=d}finally{try{if(!c&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw r}}return u}}function yJ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xJ(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bJ(i,e){return pJ(i)||vJ(i,e)||LL(i,e)||yJ()}function su(i){return mJ(i)||_J(i)||LL(i)||xJ()}function SJ(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function TJ(i){var e=SJ(i,"string");return typeof e=="symbol"?e:e+""}function LL(i,e){if(i){if(typeof i=="string")return _S(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_S(i,e):void 0}}var Kn=window.THREE?window.THREE:{WebGLRenderer:g4,Scene:XS,PerspectiveCamera:Pi,Raycaster:c2,SRGBColorSpace:dr,TextureLoader:cF,Vector2:Ie,Vector3:G,Box3:Iu,Color:pt,Mesh:xi,SphereGeometry:Ap,MeshBasicMaterial:ca,BackSide:Tn,Clock:SF},PL=J_({props:{width:{default:window.innerWidth,onChange:function(e,t,n){isNaN(e)&&(t.width=n)}},height:{default:window.innerHeight,onChange:function(e,t,n){isNaN(e)&&(t.height=n)}},viewOffset:{default:[0,0]},backgroundColor:{default:"#000011"},backgroundImageUrl:{},onBackgroundImageLoaded:{},showNavInfo:{default:!0},skyRadius:{default:5e4},objects:{default:[]},lights:{default:[]},enablePointerInteraction:{default:!0,onChange:function(e,t){t.hoverObj=null,t.tooltip&&t.tooltip.content(null)},triggerUpdate:!1},pointerRaycasterThrottleMs:{default:50,triggerUpdate:!1},lineHoverPrecision:{default:1,triggerUpdate:!1},pointsHoverPrecision:{default:1,triggerUpdate:!1},hoverOrderComparator:{triggerUpdate:!1},hoverFilter:{default:function(){return!0},triggerUpdate:!1},tooltipContent:{triggerUpdate:!1},hoverDuringDrag:{default:!1,triggerUpdate:!1},clickAfterDrag:{default:!1,triggerUpdate:!1},onHover:{default:function(){},triggerUpdate:!1},onClick:{default:function(){},triggerUpdate:!1},onRightClick:{triggerUpdate:!1}},methods:{tick:function(e){if(e.initialised){e.controls.enabled&&e.controls.update&&e.controls.update(Math.min(1,e.clock.getDelta())),e.postProcessingComposer?e.postProcessingComposer.render():e.renderer.render(e.scene,e.camera),e.extraRenderers.forEach(function(o){return o.render(e.scene,e.camera)});var t=+new Date;if(e.enablePointerInteraction&&t-e.lastRaycasterCheck>=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(o,u){return e.hoverOrderComparator(o.object,u.object)});var s=r.find(function(o){return e.hoverFilter(o.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&Zt(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var o=t,u=n||{x:0,y:0,z:0};if(!r)d(o),p(u);else{var c=Object.assign({},s.position),h=g();e.tweenGroup.add(new yN(c).to(o,r).easing(Tu.Quadratic.Out).onUpdate(d).start()),e.tweenGroup.add(new yN(h).to(u,r/3).easing(Tu.Quadratic.Out).onUpdate(p).start())}return this}return Object.assign({},s.position,{lookAt:g()});function d(_){var v=_.x,S=_.y,b=_.z;v!==void 0&&(s.position.x=v),S!==void 0&&(s.position.y=S),b!==void 0&&(s.position.z=b)}function p(_){var v=new Kn.Vector3(_.x,_.y,_.z);e.controls.enabled&&e.controls.target?e.controls.target=v:s.lookAt(v)}function g(){return Object.assign(new Kn.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),o=3;o<r;o++)s[o-3]=arguments[o];return this.fitToBbox(this.getBbox.apply(this,s),t,n)},fitToBbox:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var o=new Kn.Vector3(0,0,0),u=Math.max.apply(Math,su(Object.entries(t).map(function(_){var v=bJ(_,2),S=v[0],b=v[1];return Math.max.apply(Math,su(b.map(function(x){return Math.abs(o[S]-x)})))})))*2,c=(1-r*2/e.height)*s.fov,h=u/Math.atan(c*Math.PI/180),d=h/s.aspect,p=Math.max(h,d);if(p>0){var g=o.clone().sub(s.position).normalize().multiplyScalar(-p);this.cameraPosition(g,o,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new Kn.Box3(new Kn.Vector3(0,0,0),new Kn.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(s){return n.expandByObject(s)}),Object.assign.apply(Object,su(["x","y","z"].map(function(s){return gJ({},s,[n.min[s],n.max[s]])})))):null},getScreenCoords:function(e,t,n,r){var s=new Kn.Vector3(t,n,r);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new Kn.Vector2(t/e.width*2-1,-(n/e.height)*2+1),o=new Kn.Raycaster;return o.setFromCamera(s,e.camera),Object.assign({},o.ray.at(r,new Kn.Vector3))},intersectingObjects:function(e,t,n){var r=new Kn.Vector2(t/e.width*2-1,-(n/e.height)*2+1),s=new Kn.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(r,e.camera),s.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new Kn.Scene,camera:new Kn.PerspectiveCamera,clock:new Kn.Clock,tweenGroup:new oL,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,s=r===void 0?"trackball":r,o=n.useWebGPU,u=o===void 0?!1:o,c=n.rendererConfig,h=c===void 0?{}:c,d=n.extraRenderers,p=d===void 0?[]:d,g=n.waitForLoadComplete,_=g===void 0?!0:g;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new hJ(t.container),t.pointerPos=new Kn.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(v){return t.container.addEventListener(v,function(S){if(v==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&S.type==="pointermove"&&(S.pressure>0||t.isPointerPressed)&&(S.pointerType==="mouse"||S.movementX===void 0||[S.movementX,S.movementY].some(function(M){return Math.abs(M)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var b=x(t.container);t.pointerPos.x=S.pageX-b.left,t.pointerPos.y=S.pageY-b.top}function x(M){var E=M.getBoundingClientRect(),w=window.pageXOffset||document.documentElement.scrollLeft,D=window.pageYOffset||document.documentElement.scrollTop;return{top:E.top+D,left:E.left+w}}},{passive:!0})}),t.container.addEventListener("pointerup",function(v){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){v.button===0&&t.onClick(t.hoverObj||null,v,t.intersection),v.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,v,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(v){t.onRightClick&&v.preventDefault()}),t.renderer=new(u?AY:Kn.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},h)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=p,t.extraRenderers.forEach(function(v){v.domElement.style.position="absolute",v.domElement.style.top="0px",v.domElement.style.pointerEvents="none",t.container.appendChild(v.domElement)}),t.postProcessingComposer=new yK(t.renderer),t.postProcessingComposer.addPass(new xK(t.scene,t.camera)),t.controls=new{trackball:RY,orbit:jY,fly:rK}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(su(t.extraRenderers)).forEach(function(v){return v.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new Kn.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!_,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,s=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(su(e.extraRenderers)).forEach(function(_){return _.setSize(r,s)}),e.camera.aspect=r/s;var o=e.viewOffset.slice(0,2);o.some(function(_){return _})&&(n=e.camera).setViewOffset.apply(n,[r,s].concat(su(o),[r,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var u,c=e.width,h=e.height,d=e.viewOffset.slice(0,2);d.some(function(_){return _})?(u=e.camera).setViewOffset.apply(u,[c,h].concat(su(d),[c,h])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new Kn.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var p=jh(e.backgroundColor).alpha;p===void 0&&(p=1),e.renderer.setClearColor(new Kn.Color(ZK(1,e.backgroundColor)),p)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new Kn.TextureLoader().load(e.backgroundImageUrl,function(_){_.colorSpace=Kn.SRGBColorSpace,e.skysphere.material=new Kn.MeshBasicMaterial({map:_,side:Kn.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&g()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&g())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(_){return e.scene.remove(_)}),e.lights.forEach(function(_){return e.scene.add(_)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(_){return e.scene.remove(_)}),e.objects.forEach(function(_){return e.scene.add(_)}));function g(){e.loadComplete=e.scene.visible=!0}}});function MJ(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var EJ=`.graph-info-msg {
  top: 50%;
  width: 100%;
  text-align: center;
  color: lavender;
  opacity: 0.7;
  font-size: 22px;
  position: absolute;
  font-family: Sans-serif;
}

.scene-container .clickable {
  cursor: pointer;
}

.scene-container .grabbable {
  cursor: move;
  cursor: grab;
  cursor: -moz-grab;
  cursor: -webkit-grab;
}

.scene-container .grabbable:active {
  cursor: grabbing;
  cursor: -moz-grabbing;
  cursor: -webkit-grabbing;
}`;MJ(EJ);function vS(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function AJ(i){if(Array.isArray(i))return vS(i)}function Lp(i,e,t){return(e=NJ(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function wJ(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function RJ(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wN(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function n_(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?wN(Object(t),!0).forEach(function(n){Lp(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):wN(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function v0(i){return AJ(i)||wJ(i)||DJ(i)||RJ()}function CJ(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function NJ(i){var e=CJ(i,"string");return typeof e=="symbol"?e:e+""}function DJ(i,e){if(i){if(typeof i=="string")return vS(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?vS(i,e):void 0}}function UL(i,e){var t=new e;return t._destructor&&t._destructor(),{linkProp:function(r){return{default:t[r](),onChange:function(o,u){u[i][r](o)},triggerUpdate:!1}},linkMethod:function(r){return function(s){for(var o=s[i],u=arguments.length,c=new Array(u>1?u-1:0),h=1;h<u;h++)c[h-1]=arguments[h];var d=o[r].apply(o,c);return d===o?this:d}}}}var _b=window.THREE?window.THREE:{AmbientLight:o2,DirectionalLight:a2,REVISION:Fu},LJ=170,OL=UL("forceGraph",Q2),PJ=Object.assign.apply(Object,v0(["jsonUrl","graphData","numDimensions","dagMode","dagLevelDistance","dagNodeFilter","onDagError","nodeRelSize","nodeId","nodeVal","nodeResolution","nodeColor","nodeAutoColorBy","nodeOpacity","nodeVisibility","nodeThreeObject","nodeThreeObjectExtend","nodePositionUpdate","linkSource","linkTarget","linkVisibility","linkColor","linkAutoColorBy","linkOpacity","linkWidth","linkResolution","linkCurvature","linkCurveRotation","linkMaterial","linkThreeObject","linkThreeObjectExtend","linkPositionUpdate","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowRelPos","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleSpeed","linkDirectionalParticleOffset","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject","forceEngine","d3AlphaDecay","d3VelocityDecay","d3AlphaMin","ngraphPhysics","warmupTicks","cooldownTicks","cooldownTime","onEngineTick","onEngineStop"].map(function(i){return Lp({},i,OL.linkProp(i))}))),UJ=Object.assign.apply(Object,v0(["refresh","getGraphBbox","d3Force","d3ReheatSimulation","emitParticle"].map(function(i){return Lp({},i,OL.linkMethod(i))}))),d_=UL("renderObjs",PL),OJ=Object.assign.apply(Object,v0(["width","height","backgroundColor","showNavInfo","enablePointerInteraction"].map(function(i){return Lp({},i,d_.linkProp(i))}))),BJ=Object.assign.apply(Object,v0(["lights","cameraPosition","postProcessingComposer"].map(function(i){return Lp({},i,d_.linkMethod(i))})).concat([{graph2ScreenCoords:d_.linkMethod("getScreenCoords"),screen2GraphCoords:d_.linkMethod("getSceneCoords")}])),FJ=J_({props:n_(n_({nodeLabel:{default:"name",triggerUpdate:!1},linkLabel:{default:"name",triggerUpdate:!1},linkHoverPrecision:{default:1,onChange:function(e,t){return t.renderObjs.lineHoverPrecision(e)},triggerUpdate:!1},enableNavigationControls:{default:!0,onChange:function(e,t){var n=t.renderObjs.controls();n&&(n.enabled=e,e&&n.domElement&&n.domElement.dispatchEvent(new PointerEvent("pointerup")))},triggerUpdate:!1},enableNodeDrag:{default:!0,triggerUpdate:!1},onNodeDrag:{default:function(){},triggerUpdate:!1},onNodeDragEnd:{default:function(){},triggerUpdate:!1},onNodeClick:{triggerUpdate:!1},onNodeRightClick:{triggerUpdate:!1},onNodeHover:{triggerUpdate:!1},onLinkClick:{triggerUpdate:!1},onLinkRightClick:{triggerUpdate:!1},onLinkHover:{triggerUpdate:!1},onBackgroundClick:{triggerUpdate:!1},onBackgroundRightClick:{triggerUpdate:!1},showPointerCursor:{default:!0,triggerUpdate:!1}},PJ),OJ),methods:n_(n_({zoomToFit:function(e,t,n){for(var r,s=arguments.length,o=new Array(s>3?s-3:0),u=3;u<s;u++)o[u-3]=arguments[u];return e.renderObjs.fitToBbox((r=e.forceGraph).getGraphBbox.apply(r,o),t,n),this},pauseAnimation:function(e){return e.animationFrameRequestId!==null&&(cancelAnimationFrame(e.animationFrameRequestId),e.animationFrameRequestId=null),this},resumeAnimation:function(e){return e.animationFrameRequestId===null&&this._animationCycle(),this},_animationCycle:function(e){e.enablePointerInteraction&&(this.renderer().domElement.style.cursor=null),e.forceGraph.tickFrame(),e.renderObjs.tick(),e.animationFrameRequestId=requestAnimationFrame(this._animationCycle)},scene:function(e){return e.renderObjs.scene()},camera:function(e){return e.renderObjs.camera()},renderer:function(e){return e.renderObjs.renderer()},controls:function(e){return e.renderObjs.controls()},tbControls:function(e){return e.renderObjs.tbControls()},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},UJ),BJ),stateInit:function(e){var t=e.controlType,n=e.rendererConfig,r=e.extraRenderers,s=new Q2;return{forceGraph:s,renderObjs:PL({controlType:t,rendererConfig:n,extraRenderers:r}).objects([s]).lights([new _b.AmbientLight(13421772,Math.PI),new _b.DirectionalLight(16777215,.6*Math.PI)])}},init:function(e,t){e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.style.position="relative";var n=document.createElement("div");t.container.appendChild(n),t.renderObjs(n);var r=t.renderObjs.camera(),s=t.renderObjs.renderer(),o=t.renderObjs.controls();o.enabled=!!t.enableNavigationControls,t.lastSetCameraZ=r.position.z;var u;t.container.appendChild(u=document.createElement("div")),u.className="graph-info-msg",u.textContent="",t.forceGraph.onLoading(function(){u.textContent="Loading..."}).onFinishLoading(function(){u.textContent=""}).onUpdate(function(){t.graphData=t.forceGraph.graphData(),r.position.x===0&&r.position.y===0&&r.position.z===t.lastSetCameraZ&&t.graphData.nodes.length&&(r.lookAt(t.forceGraph.position),t.lastSetCameraZ=r.position.z=Math.cbrt(t.graphData.nodes.length)*LJ)}).onFinishUpdate(function(){if(t._dragControls){var c=t.graphData.nodes.find(function(d){return d.__initialFixedPos&&!d.__disposeControlsAfterDrag});c?c.__disposeControlsAfterDrag=!0:t._dragControls.dispose(),t._dragControls=void 0}if(t.enableNodeDrag&&t.enablePointerInteraction&&t.forceEngine==="d3"){var h=t._dragControls=new _4(t.graphData.nodes.map(function(d){return d.__threeObj}).filter(function(d){return d}),r,s.domElement);h.addEventListener("dragstart",function(d){var p=io(d.object);if(p){o.enabled=!1,d.object.__initialPos=d.object.position.clone(),d.object.__prevPos=d.object.position.clone();var g=p.__data;!g.__initialFixedPos&&(g.__initialFixedPos={fx:g.fx,fy:g.fy,fz:g.fz}),!g.__initialPos&&(g.__initialPos={x:g.x,y:g.y,z:g.z}),["x","y","z"].forEach(function(_){return g["f".concat(_)]=g[_]}),s.domElement.classList.add("grabbable")}}),h.addEventListener("drag",function(d){var p=io(d.object);if(p){if(!d.object.hasOwnProperty("__graphObjType")){var g=d.object.__initialPos,_=d.object.__prevPos,v=d.object.position;p.position.add(v.clone().sub(_)),_.copy(v),v.copy(g)}var S=p.__data,b=p.position,x={x:b.x-S.x,y:b.y-S.y,z:b.z-S.z};["x","y","z"].forEach(function(M){return S["f".concat(M)]=S[M]=b[M]}),t.forceGraph.d3AlphaTarget(.3).resetCountdown(),S.__dragged=!0,t.onNodeDrag(S,x)}}),h.addEventListener("dragend",function(d){var p=io(d.object);if(p){delete d.object.__initialPos,delete d.object.__prevPos;var g=p.__data;g.__disposeControlsAfterDrag&&(h.dispose(),delete g.__disposeControlsAfterDrag);var _=g.__initialFixedPos,v=g.__initialPos,S={x:v.x-g.x,y:v.y-g.y,z:v.z-g.z};if(_&&(["x","y","z"].forEach(function(x){var M="f".concat(x);_[M]===void 0&&delete g[M]}),delete g.__initialFixedPos,delete g.__initialPos,g.__dragged&&(delete g.__dragged,t.onNodeDragEnd(g,S))),t.forceGraph.d3AlphaTarget(0).resetCountdown(),t.enableNavigationControls){var b;o.enabled=!0,o._status&&((b=o._onPointerCancel)===null||b===void 0||b.call(o)),o.domElement&&o.domElement.ownerDocument&&o.domElement.ownerDocument.dispatchEvent(new PointerEvent("pointerup",{pointerType:"touch"}))}s.domElement.classList.remove("grabbable")}})}}),_b.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverOrderComparator(function(c,h){var d=io(c);if(!d)return 1;var p=io(h);if(!p)return-1;var g=function(v){return v.__graphObjType==="node"};return g(p)-g(d)}).tooltipContent(function(c){var h=io(c);return h&&Zt(t["".concat(h.__graphObjType,"Label")])(h.__data)||""}).hoverDuringDrag(!1).onHover(function(c){var h=io(c);if(h!==t.hoverObj){var d=t.hoverObj?t.hoverObj.__graphObjType:null,p=t.hoverObj?t.hoverObj.__data:null,g=h?h.__graphObjType:null,_=h?h.__data:null;if(d&&d!==g){var v=t["on".concat(d==="node"?"Node":"Link","Hover")];v&&v(null,p)}if(g){var S=t["on".concat(g==="node"?"Node":"Link","Hover")];S&&S(_,d===g?p:null)}s.domElement.classList[(h&&t["on".concat(g==="node"?"Node":"Link","Click")]||!h&&t.onBackgroundClick)&&Zt(t.showPointerCursor)(_)?"add":"remove"]("clickable"),t.hoverObj=h}}).clickAfterDrag(!1).onClick(function(c,h){var d=io(c);if(d){var p=t["on".concat(d.__graphObjType==="node"?"Node":"Link","Click")];p&&p(d.__data,h)}else t.onBackgroundClick&&t.onBackgroundClick(h)}).onRightClick(function(c,h){var d=io(c);if(d){var p=t["on".concat(d.__graphObjType==="node"?"Node":"Link","RightClick")];p&&p(d.__data,h)}else t.onBackgroundRightClick&&t.onBackgroundRightClick(h)}),this._animationCycle()}});function io(i){for(var e=i;e&&!e.hasOwnProperty("__graphObjType");)e=e.parent;return e}var vb={exports:{}},yb,RN;function IJ(){if(RN)return yb;RN=1;var i="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return yb=i,yb}var xb,CN;function zJ(){if(CN)return xb;CN=1;var i=IJ();function e(){}function t(){}return t.resetWarningCache=e,xb=function(){function n(o,u,c,h,d,p){if(p!==i){var g=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw g.name="Invariant Violation",g}}n.isRequired=n;function r(){return n}var s={array:n,bigint:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:r,element:n,elementType:n,instanceOf:r,node:n,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:t,resetWarningCache:e};return s.PropTypes=s,s},xb}var NN;function kJ(){return NN||(NN=1,vb.exports=zJ()()),vb.exports}var GJ=kJ();const ie=k_(GJ),y0={width:ie.number,height:ie.number,graphData:ie.shape({nodes:ie.arrayOf(ie.object).isRequired,links:ie.arrayOf(ie.object).isRequired}),backgroundColor:ie.string,nodeRelSize:ie.number,nodeId:ie.string,nodeLabel:ie.oneOfType([ie.string,ie.func]),nodeVal:ie.oneOfType([ie.number,ie.string,ie.func]),nodeVisibility:ie.oneOfType([ie.bool,ie.string,ie.func]),nodeColor:ie.oneOfType([ie.string,ie.func]),nodeAutoColorBy:ie.oneOfType([ie.string,ie.func]),onNodeHover:ie.func,onNodeClick:ie.func,linkSource:ie.string,linkTarget:ie.string,linkLabel:ie.oneOfType([ie.string,ie.func]),linkVisibility:ie.oneOfType([ie.bool,ie.string,ie.func]),linkColor:ie.oneOfType([ie.string,ie.func]),linkAutoColorBy:ie.oneOfType([ie.string,ie.func]),linkWidth:ie.oneOfType([ie.number,ie.string,ie.func]),linkCurvature:ie.oneOfType([ie.number,ie.string,ie.func]),linkDirectionalArrowLength:ie.oneOfType([ie.number,ie.string,ie.func]),linkDirectionalArrowColor:ie.oneOfType([ie.string,ie.func]),linkDirectionalArrowRelPos:ie.oneOfType([ie.number,ie.string,ie.func]),linkDirectionalParticles:ie.oneOfType([ie.number,ie.string,ie.func]),linkDirectionalParticleSpeed:ie.oneOfType([ie.number,ie.string,ie.func]),linkDirectionalParticleOffset:ie.oneOfType([ie.number,ie.string,ie.func]),linkDirectionalParticleWidth:ie.oneOfType([ie.number,ie.string,ie.func]),linkDirectionalParticleColor:ie.oneOfType([ie.string,ie.func]),onLinkHover:ie.func,onLinkClick:ie.func,dagMode:ie.oneOf(["td","bu","lr","rl","zin","zout","radialin","radialout"]),dagLevelDistance:ie.number,dagNodeFilter:ie.func,onDagError:ie.func,d3AlphaMin:ie.number,d3AlphaDecay:ie.number,d3VelocityDecay:ie.number,warmupTicks:ie.number,cooldownTicks:ie.number,cooldownTime:ie.number,onEngineTick:ie.func,onEngineStop:ie.func,getGraphBbox:ie.func},BL={zoomToFit:ie.func,onNodeRightClick:ie.func,onNodeDrag:ie.func,onNodeDragEnd:ie.func,onLinkRightClick:ie.func,linkHoverPrecision:ie.number,onBackgroundClick:ie.func,onBackgroundRightClick:ie.func,showPointerCursor:ie.oneOfType([ie.bool,ie.func]),enablePointerInteraction:ie.bool,enableNodeDrag:ie.bool},qT={showNavInfo:ie.bool,nodeOpacity:ie.number,nodeResolution:ie.number,nodeThreeObject:ie.oneOfType([ie.object,ie.string,ie.func]),nodeThreeObjectExtend:ie.oneOfType([ie.bool,ie.string,ie.func]),nodePositionUpdate:ie.func,linkOpacity:ie.number,linkResolution:ie.number,linkCurveRotation:ie.oneOfType([ie.number,ie.string,ie.func]),linkMaterial:ie.oneOfType([ie.object,ie.string,ie.func]),linkThreeObject:ie.oneOfType([ie.object,ie.string,ie.func]),linkThreeObjectExtend:ie.oneOfType([ie.bool,ie.string,ie.func]),linkPositionUpdate:ie.func,linkDirectionalArrowResolution:ie.number,linkDirectionalParticleResolution:ie.number,linkDirectionalParticleThreeObject:ie.oneOfType([ie.object,ie.string,ie.func]),forceEngine:ie.oneOf(["d3","ngraph"]),ngraphPhysics:ie.object,numDimensions:ie.oneOf([1,2,3])};Object.assign({},y0,BL,{linkLineDash:ie.oneOfType([ie.arrayOf(ie.number),ie.string,ie.func]),nodeCanvasObjectMode:ie.oneOfType([ie.string,ie.func]),nodeCanvasObject:ie.func,nodePointerAreaPaint:ie.func,linkCanvasObjectMode:ie.oneOfType([ie.string,ie.func]),linkCanvasObject:ie.func,linkPointerAreaPaint:ie.func,linkDirectionalParticleCanvasObject:ie.func,autoPauseRedraw:ie.bool,minZoom:ie.number,maxZoom:ie.number,enableZoomInteraction:ie.oneOfType([ie.bool,ie.func]),enablePanInteraction:ie.oneOfType([ie.bool,ie.func]),onZoom:ie.func,onZoomEnd:ie.func,onRenderFramePre:ie.func,onRenderFramePost:ie.func});const VJ=Object.assign({},y0,BL,qT,{enableNavigationControls:ie.bool,controlType:ie.oneOf(["trackball","orbit","fly"]),rendererConfig:ie.object,extraRenderers:ie.arrayOf(ie.shape({render:ie.func.isRequired}))});Object.assign({},y0,qT,{nodeDesc:ie.oneOfType([ie.string,ie.func]),linkDesc:ie.oneOfType([ie.string,ie.func])});Object.assign({},y0,qT,{markerAttrs:ie.object,yOffset:ie.number,glScale:ie.number});const XT=bO(FJ,{methodNames:["emitParticle","d3Force","d3ReheatSimulation","stopAnimation","pauseAnimation","resumeAnimation","cameraPosition","zoomToFit","getGraphBbox","screen2GraphCoords","graph2ScreenCoords","postProcessingComposer","lights","scene","camera","renderer","controls","refresh"],initPropNames:["controlType","rendererConfig","extraRenderers"]});XT.displayName="ForceGraph3D";XT.propTypes=VJ;function HJ(){var d;const[i,e]=Et.useState("dashboard"),[t,n]=Et.useState(null),[r,s]=Et.useState(0),[o,u]=Et.useState(!1),c=Et.useCallback(()=>{zn("/api/project/info").then(n).catch(()=>n(null))},[]);Et.useEffect(()=>{c()},[c,r]),Et.useEffect(()=>{const p=nO(()=>{s(g=>g+1)},{onOpen:()=>u(!0),onError:()=>u(!1)});return()=>{p(),u(!1)}},[]);const h=((d=t==null?void 0:t.project_info)==null?void 0:d.title)||"未加载";return k.jsxs("div",{className:"app-layout",children:[k.jsxs("aside",{className:"sidebar",children:[k.jsxs("div",{className:"sidebar-header",children:[k.jsx("h1",{children:"PIXEL WRITER HUB"}),k.jsx("div",{className:"subtitle",children:h})]}),k.jsx("nav",{className:"sidebar-nav",children:jJ.map(p=>k.jsxs("button",{className:`nav-item ${i===p.id?"active":""}`,onClick:()=>e(p.id),children:[k.jsx("span",{className:"icon",children:p.icon}),k.jsx("span",{children:p.label})]},p.id))}),k.jsxs("div",{className:"live-indicator",children:[k.jsx("span",{className:`live-dot ${o?"":"disconnected"}`}),o?"实时同步中":"未连接"]})]}),k.jsxs("main",{className:"main-content",children:[i==="dashboard"&&k.jsx(WJ,{data:t},r),i==="entities"&&k.jsx($J,{},r),i==="graph"&&k.jsx(qJ,{},r),i==="chapters"&&k.jsx(XJ,{},r),i==="files"&&k.jsx(YJ,{}),i==="reading"&&k.jsx(KJ,{},r)]})]})}const jJ=[{id:"dashboard",icon:"📊",label:"数据总览"},{id:"entities",icon:"👤",label:"设定词典"},{id:"graph",icon:"🕸️",label:"关系图谱"},{id:"chapters",icon:"📝",label:"章节一览"},{id:"files",icon:"📁",label:"文档浏览"},{id:"reading",icon:"🔥",label:"追读力"}],ol=[{key:"entities",title:"实体",columns:["id","canonical_name","type","tier","first_appearance","last_appearance"],domain:"core"},{key:"chapters",title:"章节",columns:["chapter","title","word_count","location","characters"],domain:"core"},{key:"scenes",title:"场景",columns:["chapter","scene_index","location","time","summary"],domain:"core"},{key:"aliases",title:"别名",columns:["alias","entity_id","entity_type"],domain:"core"},{key:"stateChanges",title:"状态变化",columns:["entity_id","field","old_value","new_value","chapter"],domain:"core"},{key:"relationships",title:"关系",columns:["from_entity","to_entity","type","chapter","description"],domain:"network"},{key:"relationshipEvents",title:"关系事件",columns:["from_entity","to_entity","type","chapter","event_type","description"],domain:"network"},{key:"readingPower",title:"追读力",columns:["chapter","hook_type","hook_strength","is_transition","override_count","debt_balance"],domain:"network"},{key:"overrides",title:"Override 合约",columns:["chapter","constraint_type","constraint_id","due_chapter","status"],domain:"network"},{key:"debts",title:"追读债务",columns:["id","debt_type","current_amount","interest_rate","due_chapter","status"],domain:"network"},{key:"debtEvents",title:"债务事件",columns:["debt_id","event_type","amount","chapter","note"],domain:"network"},{key:"reviewMetrics",title:"审查指标",columns:["start_chapter","end_chapter","overall_score","severity_counts","created_at"],domain:"quality"},{key:"invalidFacts",title:"无效事实",columns:["source_type","source_id","reason","status","chapter_discovered"],domain:"quality"},{key:"checklistScores",title:"写作清单评分",columns:["chapter","template","score","completion_rate","completed_items","total_items"],domain:"quality"},{key:"ragQueries",title:"RAG 查询日志",columns:["query_type","query","results_count","latency_ms","chapter","created_at"],domain:"ops"},{key:"toolStats",title:"工具调用统计",columns:["tool_name","success","retry_count","error_code","chapter","created_at"],domain:"ops"}],bb=[{id:"overview",label:"总览"},{id:"core",label:"基础档案"},{id:"network",label:"关系与剧情"},{id:"quality",label:"质量审查"},{id:"ops",label:"RAG 与工具"}];function WJ({data:i}){var S,b,x;const[e,t]=Et.useState(null);if(Et.useEffect(()=>{tO().then(t).catch(()=>t(null))},[]),!i)return k.jsx("div",{className:"loading",children:"加载中…"});const n=i.project_info||{},r=i.progress||{},s=i.protagonist_state||{},o=i.strand_tracker||{},u=((S=i.plot_threads)==null?void 0:S.foreshadowing)||[],c=r.total_words||0,h=n.target_words||2e6,d=h>0?Math.min(100,c/h*100).toFixed(1):0,p=u.filter(M=>{const E=(M.status||"").toLowerCase();return E!=="已回收"&&E!=="已兑现"&&E!=="resolved"}),g=o.history||[],_={quest:0,fire:0,constellation:0};g.forEach(M=>{_[M.strand]!==void 0&&_[M.strand]++});const v=g.length||1;return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"page-header",children:[k.jsx("h2",{children:"📊 数据总览"}),k.jsx("span",{className:"card-badge badge-blue",children:n.genre||"未知题材"})]}),k.jsxs("div",{className:"dashboard-grid",children:[k.jsxs("div",{className:"card stat-card",children:[k.jsx("span",{className:"stat-label",children:"总字数"}),k.jsx("span",{className:"stat-value",children:$h(c)}),k.jsxs("span",{className:"stat-sub",children:["目标 ",$h(h)," 字 · ",d,"%"]}),k.jsx("div",{className:"progress-track",children:k.jsx("div",{className:"progress-fill",style:{width:`${d}%`}})})]}),k.jsxs("div",{className:"card stat-card",children:[k.jsx("span",{className:"stat-label",children:"当前章节"}),k.jsxs("span",{className:"stat-value",children:["第 ",r.current_chapter||0," 章"]}),k.jsxs("span",{className:"stat-sub",children:["目标 ",n.target_chapters||"?"," 章 · 卷 ",r.current_volume||1]})]}),e?k.jsxs("div",{className:"card stat-card",children:[k.jsx("span",{className:"stat-label",children:"Story Runtime"}),k.jsx("span",{className:"stat-value plain",children:e.mainline_ready?"Mainline":"Fallback"}),k.jsxs("span",{className:"stat-sub",children:[e.latest_commit_status||"missing"," · ",iee(e.fallback_sources)]})]}):null,k.jsxs("div",{className:"card stat-card",children:[k.jsx("span",{className:"stat-label",children:"主角状态"}),k.jsx("span",{className:"stat-value plain",children:s.name||"未设定"}),k.jsxs("span",{className:"stat-sub",children:[((b=s.power)==null?void 0:b.realm)||"未知境界",(x=s.location)!=null&&x.current?` · ${s.location.current}`:""]})]}),k.jsxs("div",{className:"card stat-card",children:[k.jsx("span",{className:"stat-label",children:"未回收伏笔"}),k.jsx("span",{className:"stat-value",style:{color:p.length>10?"var(--accent-red)":"var(--accent-amber)"},children:p.length}),k.jsxs("span",{className:"stat-sub",children:["总计 ",u.length," 条伏笔"]})]})]}),k.jsxs("div",{className:"card dashboard-section-card",children:[k.jsxs("div",{className:"card-header",children:[k.jsx("span",{className:"card-title",children:"Strand Weave 节奏分布"}),k.jsx("span",{className:"card-badge badge-purple",children:o.current_dominant||"?"})]}),k.jsxs("div",{className:"strand-bar",children:[k.jsx("div",{className:"segment strand-quest",style:{width:`${(_.quest/v*100).toFixed(1)}%`}}),k.jsx("div",{className:"segment strand-fire",style:{width:`${(_.fire/v*100).toFixed(1)}%`}}),k.jsx("div",{className:"segment strand-constellation",style:{width:`${(_.constellation/v*100).toFixed(1)}%`}})]}),k.jsxs("div",{className:"strand-legend",children:[k.jsxs("span",{children:["🔵 Quest ",(_.quest/v*100).toFixed(0),"%"]}),k.jsxs("span",{children:["🔴 Fire ",(_.fire/v*100).toFixed(0),"%"]}),k.jsxs("span",{children:["🟣 Constellation ",(_.constellation/v*100).toFixed(0),"%"]})]})]}),p.length>0?k.jsxs("div",{className:"card dashboard-section-card",children:[k.jsx("div",{className:"card-header",children:k.jsx("span",{className:"card-title",children:"⚠️ 待回收伏笔 (Top 20)"})}),k.jsx("div",{className:"table-wrap",children:k.jsxs("table",{className:"data-table",children:[k.jsx("thead",{children:k.jsxs("tr",{children:[k.jsx("th",{children:"内容"}),k.jsx("th",{children:"状态"}),k.jsx("th",{children:"埋设章"})]})}),k.jsx("tbody",{children:p.slice(0,20).map((M,E)=>k.jsxs("tr",{children:[k.jsx("td",{className:"truncate",style:{maxWidth:400},children:M.content||M.description||"—"}),k.jsx("td",{children:k.jsx("span",{className:"card-badge badge-amber",children:M.status||"未知"})}),k.jsx("td",{children:M.chapter||M.planted_chapter||"—"})]},E))})]})})]}):null,k.jsx(QJ,{})]})}function $J(){const[i,e]=Et.useState([]),[t,n]=Et.useState(""),[r,s]=Et.useState(null),[o,u]=Et.useState([]);Et.useEffect(()=>{zn("/api/entities").then(e).catch(()=>{})},[]),Et.useEffect(()=>{r&&zn("/api/state-changes",{entity:r.id,limit:30}).then(u).catch(()=>u([]))},[r]);const c=[...new Set(i.map(d=>d.type))].sort(),h=t?i.filter(d=>d.type===t):i;return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"page-header",children:[k.jsx("h2",{children:"👤 设定词典"}),k.jsxs("span",{className:"card-badge badge-green",children:[h.length," / ",i.length," 个实体"]})]}),k.jsxs("div",{className:"filter-group",children:[k.jsx("button",{className:`filter-btn ${t===""?"active":""}`,onClick:()=>n(""),children:"全部"}),c.map(d=>k.jsx("button",{className:`filter-btn ${t===d?"active":""}`,onClick:()=>n(d),children:d},d))]}),k.jsxs("div",{className:"split-layout",children:[k.jsx("div",{className:"split-main",children:k.jsx("div",{className:"card",children:k.jsx("div",{className:"table-wrap",children:k.jsxs("table",{className:"data-table",children:[k.jsx("thead",{children:k.jsxs("tr",{children:[k.jsx("th",{children:"名称"}),k.jsx("th",{children:"类型"}),k.jsx("th",{children:"层级"}),k.jsx("th",{children:"首现"}),k.jsx("th",{children:"末现"})]})}),k.jsx("tbody",{children:h.map(d=>k.jsxs("tr",{role:"button",tabIndex:0,className:`entity-row ${(r==null?void 0:r.id)===d.id?"selected":""}`,onKeyDown:p=>(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),s(d)),onClick:()=>s(d),children:[k.jsxs("td",{className:d.is_protagonist?"entity-name protagonist":"entity-name",children:[d.canonical_name," ",d.is_protagonist?"⭐":""]}),k.jsx("td",{children:k.jsx("span",{className:"card-badge badge-blue",children:d.type})}),k.jsx("td",{children:d.tier}),k.jsx("td",{children:d.first_appearance||"—"}),k.jsx("td",{children:d.last_appearance||"—"})]},d.id))})]})})})}),r&&k.jsx("div",{className:"split-side",children:k.jsxs("div",{className:"card",children:[k.jsxs("div",{className:"card-header",children:[k.jsx("span",{className:"card-title",children:r.canonical_name}),k.jsx("span",{className:"card-badge badge-purple",children:r.tier})]}),k.jsxs("div",{className:"entity-detail",children:[k.jsxs("p",{children:[k.jsx("strong",{children:"类型："}),r.type]}),k.jsxs("p",{children:[k.jsx("strong",{children:"ID："}),k.jsx("code",{children:r.id})]}),r.desc&&k.jsx("p",{className:"entity-desc",children:r.desc}),r.current_json&&k.jsxs("div",{className:"entity-current-block",children:[k.jsx("strong",{children:"当前状态："}),k.jsx("pre",{className:"entity-json",children:tee(r.current_json)})]})]}),o.length>0?k.jsxs("div",{className:"entity-history",children:[k.jsx("div",{className:"card-title",children:"状态变化历史"}),k.jsx("div",{className:"table-wrap",children:k.jsxs("table",{className:"data-table",children:[k.jsx("thead",{children:k.jsxs("tr",{children:[k.jsx("th",{children:"章"}),k.jsx("th",{children:"字段"}),k.jsx("th",{children:"变化"})]})}),k.jsx("tbody",{children:o.map((d,p)=>k.jsxs("tr",{children:[k.jsx("td",{children:d.chapter}),k.jsx("td",{children:d.field}),k.jsxs("td",{children:[d.old_value," → ",d.new_value]})]},p))})]})})]}):null]})})]})]})}function qJ(){const[i,e]=Et.useState([]),[t,n]=Et.useState({nodes:[],links:[]});return Et.useEffect(()=>{Promise.all([zn("/api/relationships",{limit:1e3}),zn("/api/entities")]).then(([r,s])=>{e(r);const o={角色:"#4f8ff7",地点:"#34d399",星球:"#22d3ee",神仙:"#f59e0b",势力:"#8b5cf6",招式:"#ef4444",法宝:"#ec4899"},u=new Set;r.forEach(p=>{u.add(p.from_entity),u.add(p.to_entity)});const c={};s.forEach(p=>{c[p.id]=p});const h=[...u].map(p=>{var g,_,v,S;return{id:p,name:((g=c[p])==null?void 0:g.canonical_name)||p,val:((_=c[p])==null?void 0:_.tier)==="S"?8:((v=c[p])==null?void 0:v.tier)==="A"?5:2,color:o[(S=c[p])==null?void 0:S.type]||"#5c6078"}}),d=r.map(p=>({source:p.from_entity,target:p.to_entity,name:p.type}));n({nodes:h,links:d})}).catch(()=>{})},[]),k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"page-header",children:[k.jsx("h2",{children:"🕸️ 关系图谱"}),k.jsxs("span",{className:"card-badge badge-blue",children:[i.length," 条引力链接"]})]}),k.jsx("div",{className:"card graph-shell",children:k.jsx(XT,{graphData:t,nodeLabel:"name",nodeColor:"color",nodeRelSize:6,linkColor:()=>"rgba(127, 90, 240, 0.35)",linkWidth:1,linkDirectionalParticles:2,linkDirectionalParticleWidth:1.5,linkDirectionalParticleSpeed:r=>.005+Math.random()*.005,backgroundColor:"#fffaf0",showNavInfo:!1})})]})}function XJ(){const[i,e]=Et.useState([]);Et.useEffect(()=>{zn("/api/chapters").then(e).catch(()=>{})},[]);const t=i.reduce((n,r)=>n+(r.word_count||0),0);return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"page-header",children:[k.jsx("h2",{children:"📝 章节一览"}),k.jsxs("span",{className:"card-badge badge-green",children:[i.length," 章 · ",$h(t)," 字"]})]}),k.jsxs("div",{className:"card",children:[k.jsx("div",{className:"table-wrap",children:k.jsxs("table",{className:"data-table",children:[k.jsx("thead",{children:k.jsxs("tr",{children:[k.jsx("th",{children:"章节"}),k.jsx("th",{children:"标题"}),k.jsx("th",{children:"字数"}),k.jsx("th",{children:"地点"}),k.jsx("th",{children:"角色"})]})}),k.jsx("tbody",{children:i.map(n=>k.jsxs("tr",{children:[k.jsxs("td",{className:"chapter-no",children:["第 ",n.chapter," 章"]}),k.jsx("td",{children:n.title||"—"}),k.jsx("td",{children:$h(n.word_count||0)}),k.jsx("td",{children:n.location||"—"}),k.jsx("td",{className:"truncate chapter-characters",children:n.characters||"—"})]},n.chapter))})]})}),i.length===0?k.jsxs("div",{className:"empty-state",children:[k.jsx("div",{className:"empty-icon",children:"📭"}),k.jsx("p",{children:"暂无章节数据"})]}):null]})]})}function YJ(){const[i,e]=Et.useState({}),[t,n]=Et.useState(null),[r,s]=Et.useState("");return Et.useEffect(()=>{zn("/api/files/tree").then(e).catch(()=>{})},[]),Et.useEffect(()=>{t&&zn("/api/files/read",{path:t}).then(o=>s(o.content)).catch(()=>s("[读取失败]"))},[t]),Et.useEffect(()=>{if(t)return;const o=ZJ(i);o&&n(o)},[i,t]),k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"page-header",children:k.jsx("h2",{children:"📁 文档浏览"})}),k.jsxs("div",{className:"file-layout",children:[k.jsx("div",{className:"file-tree-pane",children:Object.entries(i).map(([o,u])=>k.jsxs("div",{className:"folder-block",children:[k.jsxs("div",{className:"folder-title",children:["📂 ",o]}),k.jsx("ul",{className:"file-tree",children:k.jsx(IL,{items:u,selected:t,onSelect:n})})]},o))}),k.jsx("div",{className:"file-content-pane",children:t?k.jsxs("div",{children:[k.jsx("div",{className:"selected-path",children:t}),k.jsx("div",{className:"file-preview",children:r})]}):k.jsxs("div",{className:"empty-state",children:[k.jsx("div",{className:"empty-icon",children:"📄"}),k.jsx("p",{children:"选择左侧文件以预览内容"})]})})]})]})}function KJ(){const[i,e]=Et.useState([]);return Et.useEffect(()=>{zn("/api/reading-power",{limit:50}).then(e).catch(()=>{})},[]),k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"page-header",children:[k.jsx("h2",{children:"🔥 追读力分析"}),k.jsxs("span",{className:"card-badge badge-amber",children:[i.length," 章数据"]})]}),k.jsxs("div",{className:"card",children:[k.jsx("div",{className:"table-wrap",children:k.jsxs("table",{className:"data-table",children:[k.jsx("thead",{children:k.jsxs("tr",{children:[k.jsx("th",{children:"章节"}),k.jsx("th",{children:"钩子类型"}),k.jsx("th",{children:"钩子强度"}),k.jsx("th",{children:"过渡章"}),k.jsx("th",{children:"Override"}),k.jsx("th",{children:"债务余额"})]})}),k.jsx("tbody",{children:i.map(t=>k.jsxs("tr",{children:[k.jsxs("td",{className:"chapter-no",children:["第 ",t.chapter," 章"]}),k.jsx("td",{children:t.hook_type||"—"}),k.jsx("td",{children:k.jsx("span",{className:`card-badge ${t.hook_strength==="strong"?"badge-green":t.hook_strength==="weak"?"badge-red":"badge-amber"}`,children:t.hook_strength||"—"})}),k.jsx("td",{children:t.is_transition?"✅":"—"}),k.jsx("td",{children:t.override_count||0}),k.jsx("td",{className:t.debt_balance>0?"debt-positive":"debt-normal",children:(t.debt_balance||0).toFixed(2)})]},t.chapter))})]})}),i.length===0?k.jsxs("div",{className:"empty-state",children:[k.jsx("div",{className:"empty-icon",children:"🔥"}),k.jsx("p",{children:"暂无追读力数据"})]}):null]})]})}function ZJ(i){const e=Object.values(i||{});for(const t of e){const n=FL(t);if(n)return n}return null}function FL(i){if(!Array.isArray(i))return null;for(const e of i){if((e==null?void 0:e.type)==="file"&&(e!=null&&e.path))return e.path;if((e==null?void 0:e.type)==="dir"&&Array.isArray(e.children)){const t=FL(e.children);if(t)return t}}return null}function QJ(){var p;const[i,e]=Et.useState(!0),[t,n]=Et.useState({}),[r,s]=Et.useState("overview");if(Et.useEffect(()=>{let g=!1;async function _(){e(!0);const v=[["entities",zn("/api/entities")],["chapters",zn("/api/chapters")],["scenes",zn("/api/scenes",{limit:200})],["relationships",zn("/api/relationships",{limit:300})],["relationshipEvents",zn("/api/relationship-events",{limit:200})],["readingPower",zn("/api/reading-power",{limit:100})],["reviewMetrics",zn("/api/review-metrics",{limit:50})],["stateChanges",zn("/api/state-changes",{limit:120})],["aliases",zn("/api/aliases")],["overrides",zn("/api/overrides",{limit:120})],["debts",zn("/api/debts",{limit:120})],["debtEvents",zn("/api/debt-events",{limit:150})],["invalidFacts",zn("/api/invalid-facts",{limit:120})],["ragQueries",zn("/api/rag-queries",{limit:150})],["toolStats",zn("/api/tool-stats",{limit:200})],["checklistScores",zn("/api/checklist-scores",{limit:120})]],S=await Promise.all(v.map(async([b,x])=>{try{const M=await x;return[b,M]}catch{return[b,[]]}}));g||(n(Object.fromEntries(S)),e(!1))}return _(),()=>{g=!0}},[]),i)return k.jsx("div",{className:"loading",children:"加载全量数据中…"});const o=r==="overview"?ol:ol.filter(g=>g.domain===r),u=ol.reduce((g,_)=>g+(t[_.key]||[]).length,0),c=ol.filter(g=>(t[g.key]||[]).length>0).length,h=ol.reduce((g,_)=>((t[_.key]||[]).slice(0,120).forEach(S=>{const b=eee(S);b>g&&(g=b)}),g),0),d=bb.filter(g=>g.id!=="overview").map(g=>{const _=ol.filter(b=>b.domain===g.id),v=_.reduce((b,x)=>b+(t[x.key]||[]).length,0),S=_.filter(b=>(t[b.key]||[]).length>0).length;return{...g,rowCount:v,filled:S,total:_.length}});return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"page-header section-page-header",children:[k.jsx("h2",{children:"🧪 全量数据视图"}),k.jsxs("span",{className:"card-badge badge-cyan",children:[ol.length," 类数据源"]})]}),k.jsxs("div",{className:"demo-summary-grid",children:[k.jsxs("div",{className:"card stat-card",children:[k.jsx("span",{className:"stat-label",children:"总记录数"}),k.jsx("span",{className:"stat-value",children:$h(u)}),k.jsx("span",{className:"stat-sub",children:"当前返回的全部数据行"})]}),k.jsxs("div",{className:"card stat-card",children:[k.jsx("span",{className:"stat-label",children:"已覆盖数据源"}),k.jsxs("span",{className:"stat-value plain",children:[c,"/",ol.length]}),k.jsx("span",{className:"stat-sub",children:"有数据的表 / 总表数"})]}),k.jsxs("div",{className:"card stat-card",children:[k.jsx("span",{className:"stat-label",children:"最新章节触达"}),k.jsx("span",{className:"stat-value plain",children:h>0?`第 ${h} 章`:"—"}),k.jsx("span",{className:"stat-sub",children:"按可识别 chapter 字段估算"})]}),k.jsxs("div",{className:"card stat-card",children:[k.jsx("span",{className:"stat-label",children:"当前视图"}),k.jsx("span",{className:"stat-value plain",children:(p=bb.find(g=>g.id===r))==null?void 0:p.label}),k.jsxs("span",{className:"stat-sub",children:[o.length," 个数据分组"]})]})]}),k.jsx("div",{className:"demo-domain-tabs",children:bb.map(g=>k.jsx("button",{className:`demo-domain-tab ${r===g.id?"active":""}`,onClick:()=>s(g.id),children:g.label},g.id))}),r==="overview"?k.jsx("div",{className:"demo-domain-grid",children:d.map(g=>k.jsxs("div",{className:"card",children:[k.jsxs("div",{className:"card-header",children:[k.jsx("span",{className:"card-title",children:g.label}),k.jsxs("span",{className:"card-badge badge-purple",children:[g.filled,"/",g.total]})]}),k.jsx("div",{className:"domain-stat-number",children:$h(g.rowCount)}),k.jsx("div",{className:"stat-sub",children:"该数据域总记录数"})]},g.id))}):null,o.map(g=>{const _=(t[g.key]||[]).length;return k.jsxs("div",{className:"card demo-group-card",children:[k.jsxs("div",{className:"card-header",children:[k.jsx("span",{className:"card-title",children:g.title}),k.jsxs("span",{className:`card-badge ${_>0?"badge-blue":"badge-amber"}`,children:[_," 条"]})]}),k.jsx(JJ,{rows:t[g.key]||[],columns:g.columns,pageSize:12})]},g.key)})]})}function JJ({rows:i,columns:e,pageSize:t=12}){const[n,r]=Et.useState(1);if(Et.useEffect(()=>{r(1)},[i,e,t]),!i||i.length===0)return k.jsx("div",{className:"empty-state compact",children:k.jsx("p",{children:"暂无数据"})});const s=Math.max(1,Math.ceil(i.length/t)),o=Math.min(n,s),u=(o-1)*t,c=i.slice(u,u+t);return k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"table-wrap",children:k.jsxs("table",{className:"data-table",children:[k.jsx("thead",{children:k.jsx("tr",{children:e.map(h=>k.jsx("th",{children:h},h))})}),k.jsx("tbody",{children:c.map((h,d)=>k.jsx("tr",{children:e.map(p=>k.jsx("td",{className:"truncate",style:{maxWidth:240},children:nee(h==null?void 0:h[p])},p))},d))})]})}),k.jsxs("div",{className:"table-pagination",children:[k.jsx("button",{className:"page-btn",type:"button",onClick:()=>r(h=>Math.max(1,h-1)),disabled:o<=1,children:"上一页"}),k.jsxs("span",{className:"page-info",children:["第 ",o," / ",s," 页 · 共 ",i.length," 条"]}),k.jsx("button",{className:"page-btn",type:"button",onClick:()=>r(h=>Math.min(s,h+1)),disabled:o>=s,children:"下一页"})]})]})}function eee(i){if(!i||typeof i!="object")return 0;const e=[i.chapter,i.start_chapter,i.end_chapter,i.chapter_discovered,i.first_appearance,i.last_appearance];for(const t of e){const n=Number(t);if(Number.isFinite(n)&&n>0)return n}return 0}function IL({items:i,selected:e,onSelect:t,depth:n=0}){const[r,s]=Et.useState({});return!i||i.length===0?null:i.map((o,u)=>{const c=o.path||`${n}-${u}`;if(o.type==="dir"){const h=r[c];return k.jsxs("li",{children:[k.jsxs("div",{className:"tree-item",role:"button",tabIndex:0,onKeyDown:d=>(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),s(p=>({...p,[c]:!p[c]}))),onClick:()=>s(d=>({...d,[c]:!d[c]})),children:[k.jsx("span",{className:"tree-icon",children:h?"📂":"📁"}),k.jsx("span",{children:o.name})]}),h&&o.children&&k.jsx("ul",{className:"tree-children",children:k.jsx(IL,{items:o.children,selected:e,onSelect:t,depth:n+1})})]},c)}return k.jsx("li",{children:k.jsxs("div",{className:`tree-item ${e===o.path?"active":""}`,role:"button",tabIndex:0,onKeyDown:h=>(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),t(o.path)),onClick:()=>t(o.path),children:[k.jsx("span",{className:"tree-icon",children:"📄"}),k.jsx("span",{children:o.name})]})},c)})}function $h(i){return i>=1e4?new Intl.NumberFormat("zh-CN",{maximumFractionDigits:1}).format(i/1e4)+" 万":new Intl.NumberFormat("zh-CN").format(i)}function tee(i){try{return JSON.stringify(JSON.parse(i),null,2)}catch{return i}}function nee(i){if(i==null)return"—";if(typeof i=="boolean")return i?"true":"false";if(typeof i=="object")try{return JSON.stringify(i)}catch{return String(i)}const e=String(i);return e.length>180?`${e.slice(0,180)}...`:e}function iee(i){return!Array.isArray(i)||i.length===0?"no fallback":i.join(", ")}JU.createRoot(document.getElementById("root")).render(k.jsx(DN.StrictMode,{children:k.jsx(HJ,{})}));
