(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();var U0={exports:{}},uf={};/** * @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 iM;function GL(){if(iM)return uf;iM=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(i,a,o){var l=null;if(o!==void 0&&(l=""+o),a.key!==void 0&&(l=""+a.key),"key"in a){o={};for(var u in a)u!=="key"&&(o[u]=a[u])}else o=a;return a=o.ref,{$$typeof:e,type:i,key:l,ref:a!==void 0?a:null,props:o}}return uf.Fragment=t,uf.jsx=n,uf.jsxs=n,uf}var sM;function HL(){return sM||(sM=1,U0.exports=GL()),U0.exports}var xt=HL(),P0={exports:{}},pe={};/** * @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 aM;function jL(){if(aM)return pe;aM=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),b=Symbol.iterator;function _(z){return z===null||typeof z!="object"?null:(z=b&&z[b]||z["@@iterator"],typeof z=="function"?z:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},A=Object.assign,x={};function y(z,it,Tt){this.props=z,this.context=it,this.refs=x,this.updater=Tt||S}y.prototype.isReactComponent={},y.prototype.setState=function(z,it){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,it,"setState")},y.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function E(){}E.prototype=y.prototype;function w(z,it,Tt){this.props=z,this.context=it,this.refs=x,this.updater=Tt||S}var T=w.prototype=new E;T.constructor=w,A(T,y.prototype),T.isPureReactComponent=!0;var P=Array.isArray;function O(){}var U={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function C(z,it,Tt){var J=Tt.ref;return{$$typeof:e,type:z,key:it,ref:J!==void 0?J:null,props:Tt}}function R(z,it){return C(z.type,it,z.props)}function F(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function Y(z){var it={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(Tt){return it[Tt]})}var $=/\/+/g;function lt(z,it){return typeof z=="object"&&z!==null&&z.key!=null?Y(""+z.key):it.toString(36)}function ut(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(O,O):(z.status="pending",z.then(function(it){z.status==="pending"&&(z.status="fulfilled",z.value=it)},function(it){z.status==="pending"&&(z.status="rejected",z.reason=it)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function k(z,it,Tt,J,ht){var Et=typeof z;(Et==="undefined"||Et==="boolean")&&(z=null);var Mt=!1;if(z===null)Mt=!0;else switch(Et){case"bigint":case"string":case"number":Mt=!0;break;case"object":switch(z.$$typeof){case e:case t:Mt=!0;break;case p:return Mt=z._init,k(Mt(z._payload),it,Tt,J,ht)}}if(Mt)return ht=ht(z),Mt=J===""?"."+lt(z,0):J,P(ht)?(Tt="",Mt!=null&&(Tt=Mt.replace($,"$&/")+"/"),k(ht,it,Tt,"",function(oe){return oe})):ht!=null&&(F(ht)&&(ht=R(ht,Tt+(ht.key==null||z&&z.key===ht.key?"":(""+ht.key).replace($,"$&/")+"/")+Mt)),it.push(ht)),1;Mt=0;var Ht=J===""?".":J+":";if(P(z))for(var ee=0;ee>>1,At=k[yt];if(0>>1;yta(Tt,X))Ja(ht,Tt)?(k[yt]=ht,k[J]=X,yt=J):(k[yt]=Tt,k[it]=X,yt=it);else if(Ja(ht,X))k[yt]=ht,k[J]=X,yt=J;else break t}}return Q}function a(k,Q){var X=k.sortIndex-Q.sortIndex;return X!==0?X:k.id-Q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var h=[],d=[],p=1,m=null,b=3,_=!1,S=!1,A=!1,x=!1,y=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function T(k){for(var Q=n(d);Q!==null;){if(Q.callback===null)i(d);else if(Q.startTime<=k)i(d),Q.sortIndex=Q.expirationTime,t(h,Q);else break;Q=n(d)}}function P(k){if(A=!1,T(k),!S)if(n(h)!==null)S=!0,O||(O=!0,Y());else{var Q=n(d);Q!==null&&ut(P,Q.startTime-k)}}var O=!1,U=-1,I=5,C=-1;function R(){return x?!0:!(e.unstable_now()-Ck&&R());){var yt=m.callback;if(typeof yt=="function"){m.callback=null,b=m.priorityLevel;var At=yt(m.expirationTime<=k);if(k=e.unstable_now(),typeof At=="function"){m.callback=At,T(k),Q=!0;break e}m===n(h)&&i(h),T(k)}else i(h);m=n(h)}if(m!==null)Q=!0;else{var z=n(d);z!==null&&ut(P,z.startTime-k),Q=!1}}break t}finally{m=null,b=X,_=!1}Q=void 0}}finally{Q?Y():O=!1}}}var Y;if(typeof w=="function")Y=function(){w(F)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,lt=$.port2;$.port1.onmessage=F,Y=function(){lt.postMessage(null)}}else Y=function(){y(F,0)};function ut(k,Q){U=y(function(){k(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(k){k.callback=null},e.unstable_forceFrameRate=function(k){0>k||125yt?(k.sortIndex=X,t(d,k),n(h)===null&&k===n(d)&&(A?(E(U),U=-1):A=!0,ut(P,X-yt))):(k.sortIndex=At,t(h,k),S||_||(S=!0,O||(O=!0,Y()))),k},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(k){var Q=b;return function(){var X=b;b=Q;try{return k.apply(this,arguments)}finally{b=X}}}})(F0)),F0}var lM;function XL(){return lM||(lM=1,I0.exports=WL()),I0.exports}var B0={exports:{}},yi={};/** * @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 cM;function qL(){if(cM)return yi;cM=1;var e=w1();function t(h){var d="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),B0.exports=qL(),B0.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 fM;function KL(){if(fM)return ff;fM=1;var e=XL(),t=w1(),n=YL();function i(s){var r="https://react.dev/errors/"+s;if(1At||(s.current=yt[At],yt[At]=null,At--)}function Tt(s,r){At++,yt[At]=s.current,s.current=r}var J=z(null),ht=z(null),Et=z(null),Mt=z(null);function Ht(s,r){switch(Tt(Et,r),Tt(ht,s),Tt(J,null),r.nodeType){case 9:case 11:s=(s=r.documentElement)&&(s=s.namespaceURI)?ES(s):0;break;default:if(s=r.tagName,r=r.namespaceURI)r=ES(r),s=wS(r,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}it(J),Tt(J,s)}function ee(){it(J),it(ht),it(Et)}function oe(s){s.memoizedState!==null&&Tt(Mt,s);var r=J.current,c=wS(r,s.type);r!==c&&(Tt(ht,s),Tt(J,c))}function on(s){ht.current===s&&(it(J),it(ht)),Mt.current===s&&(it(Mt),rf._currentValue=X)}var $e,Me;function G(s){if($e===void 0)try{throw Error()}catch(c){var r=c.stack.trim().match(/\n( *(at )?)/);$e=r&&r[1]||"",Me=-1)":-1g||V[f]!==et[g]){var ft=` `+V[f].replace(" at new "," at ");return s.displayName&&ft.includes("")&&(ft=ft.replace("",s.displayName)),ft}while(1<=f&&0<=g);break}}}finally{ii=!1,Error.prepareStackTrace=c}return(c=s?s.displayName||s.name:"")?G(c):""}function Se(s,r){switch(s.tag){case 26:case 27:case 5:return G(s.type);case 16:return G("Lazy");case 13:return s.child!==r&&r!==null?G("Suspense Fallback"):G("Suspense");case 19:return G("SuspenseList");case 0:case 15:return me(s.type,!1);case 11:return me(s.type.render,!1);case 1:return me(s.type,!0);case 31:return G("Activity");default:return""}}function Zt(s){try{var r="",c=null;do r+=Se(s,c),c=s,s=s.return;while(s);return r}catch(f){return` Error generating stack: `+f.message+` `+f.stack}}var He=Object.prototype.hasOwnProperty,Yt=e.unstable_scheduleCallback,B=e.unstable_cancelCallback,L=e.unstable_shouldYield,nt=e.unstable_requestPaint,dt=e.unstable_now,St=e.unstable_getCurrentPriorityLevel,bt=e.unstable_ImmediatePriority,kt=e.unstable_UserBlockingPriority,Pt=e.unstable_NormalPriority,zt=e.unstable_LowPriority,ye=e.unstable_IdlePriority,Dt=e.log,Gt=e.unstable_setDisableYieldValue,te=null,qt=null;function mt(s){if(typeof Dt=="function"&&Gt(s),qt&&typeof qt.setStrictMode=="function")try{qt.setStrictMode(te,s)}catch{}}var Ut=Math.clz32?Math.clz32:j,Vt=Math.log,Lt=Math.LN2;function j(s){return s>>>=0,s===0?32:31-(Vt(s)/Lt|0)|0}var Ct=256,ot=262144,vt=4194304;function wt(s){var r=s&42;if(r!==0)return r;switch(s&-s){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 s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Nt(s,r,c){var f=s.pendingLanes;if(f===0)return 0;var g=0,v=s.suspendedLanes,M=s.pingedLanes;s=s.warmLanes;var D=f&134217727;return D!==0?(f=D&~v,f!==0?g=wt(f):(M&=D,M!==0?g=wt(M):c||(c=D&~s,c!==0&&(g=wt(c))))):(D=f&~v,D!==0?g=wt(D):M!==0?g=wt(M):c||(c=f&~s,c!==0&&(g=wt(c)))),g===0?0:r!==0&&r!==g&&(r&v)===0&&(v=g&-g,c=r&-r,v>=c||v===32&&(c&4194048)!==0)?r:g}function ne(s,r){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&r)===0}function je(s,r){switch(s){case 1:case 2:case 4:case 8:case 64:return r+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 r+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 hn(){var s=vt;return vt<<=1,(vt&62914560)===0&&(vt=4194304),s}function Te(s){for(var r=[],c=0;31>c;c++)r.push(s);return r}function ln(s,r){s.pendingLanes|=r,r!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function bn(s,r,c,f,g,v){var M=s.pendingLanes;s.pendingLanes=c,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=c,s.entangledLanes&=c,s.errorRecoveryDisabledLanes&=c,s.shellSuspendCounter=0;var D=s.entanglements,V=s.expirationTimes,et=s.hiddenUpdates;for(c=M&~c;0"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var wi=/[\n"\\]/g;function si(s){return s.replace(wi,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function tn(s,r,c,f,g,v,M,D){s.name="",M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?s.type=M:s.removeAttribute("type"),r!=null?M==="number"?(r===0&&s.value===""||s.value!=r)&&(s.value=""+he(r)):s.value!==""+he(r)&&(s.value=""+he(r)):M!=="submit"&&M!=="reset"||s.removeAttribute("value"),r!=null?_i(s,M,he(r)):c!=null?_i(s,M,he(c)):f!=null&&s.removeAttribute("value"),g==null&&v!=null&&(s.defaultChecked=!!v),g!=null&&(s.checked=g&&typeof g!="function"&&typeof g!="symbol"),D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?s.name=""+he(D):s.removeAttribute("name")}function Ri(s,r,c,f,g,v,M,D){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(s.type=v),r!=null||c!=null){if(!(v!=="submit"&&v!=="reset"||r!=null)){Oe(s);return}c=c!=null?""+he(c):"",r=r!=null?""+he(r):c,D||r===s.value||(s.value=r),s.defaultValue=r}f=f??g,f=typeof f!="function"&&typeof f!="symbol"&&!!f,s.checked=D?s.checked:!!f,s.defaultChecked=!!f,M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(s.name=M),Oe(s)}function _i(s,r,c){r==="number"&&Ws(s.ownerDocument)===s||s.defaultValue===""+c||(s.defaultValue=""+c)}function Rn(s,r,c,f){if(s=s.options,r){r={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Um=!1;if(Ba)try{var Mu={};Object.defineProperty(Mu,"passive",{get:function(){Um=!0}}),window.addEventListener("test",Mu,Mu),window.removeEventListener("test",Mu,Mu)}catch{Um=!1}var vr=null,Pm=null,bh=null;function wy(){if(bh)return bh;var s,r=Pm,c=r.length,f,g="value"in vr?vr.value:vr.textContent,v=g.length;for(s=0;s=Eu),Uy=" ",Py=!1;function Oy(s,r){switch(s){case"keyup":return uD.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Iy(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Ml=!1;function hD(s,r){switch(s){case"compositionend":return Iy(r);case"keypress":return r.which!==32?null:(Py=!0,Uy);case"textInput":return s=r.data,s===Uy&&Py?null:s;default:return null}}function dD(s,r){if(Ml)return s==="compositionend"||!km&&Oy(s,r)?(s=wy(),bh=Pm=vr=null,Ml=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:c,offset:r-s};s=f}t:{for(;c;){if(c.nextSibling){c=c.nextSibling;break t}c=c.parentNode}c=void 0}c=jy(c)}}function Xy(s,r){return s&&r?s===r?!0:s&&s.nodeType===3?!1:r&&r.nodeType===3?Xy(s,r.parentNode):"contains"in s?s.contains(r):s.compareDocumentPosition?!!(s.compareDocumentPosition(r)&16):!1:!1}function qy(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var r=Ws(s.document);r instanceof s.HTMLIFrameElement;){try{var c=typeof r.contentWindow.location.href=="string"}catch{c=!1}if(c)s=r.contentWindow;else break;r=Ws(s.document)}return r}function Gm(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r&&(r==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||r==="textarea"||s.contentEditable==="true")}var xD=Ba&&"documentMode"in document&&11>=document.documentMode,Al=null,Hm=null,Du=null,jm=!1;function Yy(s,r,c){var f=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;jm||Al==null||Al!==Ws(f)||(f=Al,"selectionStart"in f&&Gm(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),Du&&Cu(Du,f)||(Du=f,f=ud(Hm,"onSelect"),0>=M,g-=M,ha=1<<32-Ut(r)+g|c<be?(Le=Kt,Kt=null):Le=Kt.sibling;var Ve=st(Z,Kt,tt[be],gt);if(Ve===null){Kt===null&&(Kt=Le);break}s&&Kt&&Ve.alternate===null&&r(Z,Kt),W=v(Ve,W,be),ze===null?se=Ve:ze.sibling=Ve,ze=Ve,Kt=Le}if(be===tt.length)return c(Z,Kt),Pe&&za(Z,be),se;if(Kt===null){for(;bebe?(Le=Kt,Kt=null):Le=Kt.sibling;var zr=st(Z,Kt,Ve.value,gt);if(zr===null){Kt===null&&(Kt=Le);break}s&&Kt&&zr.alternate===null&&r(Z,Kt),W=v(zr,W,be),ze===null?se=zr:ze.sibling=zr,ze=zr,Kt=Le}if(Ve.done)return c(Z,Kt),Pe&&za(Z,be),se;if(Kt===null){for(;!Ve.done;be++,Ve=tt.next())Ve=_t(Z,Ve.value,gt),Ve!==null&&(W=v(Ve,W,be),ze===null?se=Ve:ze.sibling=Ve,ze=Ve);return Pe&&za(Z,be),se}for(Kt=f(Kt);!Ve.done;be++,Ve=tt.next())Ve=ct(Kt,Z,be,Ve.value,gt),Ve!==null&&(s&&Ve.alternate!==null&&Kt.delete(Ve.key===null?be:Ve.key),W=v(Ve,W,be),ze===null?se=Ve:ze.sibling=Ve,ze=Ve);return s&&Kt.forEach(function(VL){return r(Z,VL)}),Pe&&za(Z,be),se}function sn(Z,W,tt,gt){if(typeof tt=="object"&&tt!==null&&tt.type===A&&tt.key===null&&(tt=tt.props.children),typeof tt=="object"&&tt!==null){switch(tt.$$typeof){case _:t:{for(var se=tt.key;W!==null;){if(W.key===se){if(se=tt.type,se===A){if(W.tag===7){c(Z,W.sibling),gt=g(W,tt.props.children),gt.return=Z,Z=gt;break t}}else if(W.elementType===se||typeof se=="object"&&se!==null&&se.$$typeof===I&&wo(se)===W.type){c(Z,W.sibling),gt=g(W,tt.props),Iu(gt,tt),gt.return=Z,Z=gt;break t}c(Z,W);break}else r(Z,W);W=W.sibling}tt.type===A?(gt=So(tt.props.children,Z.mode,gt,tt.key),gt.return=Z,Z=gt):(gt=wh(tt.type,tt.key,tt.props,null,Z.mode,gt),Iu(gt,tt),gt.return=Z,Z=gt)}return M(Z);case S:t:{for(se=tt.key;W!==null;){if(W.key===se)if(W.tag===4&&W.stateNode.containerInfo===tt.containerInfo&&W.stateNode.implementation===tt.implementation){c(Z,W.sibling),gt=g(W,tt.children||[]),gt.return=Z,Z=gt;break t}else{c(Z,W);break}else r(Z,W);W=W.sibling}gt=Qm(tt,Z.mode,gt),gt.return=Z,Z=gt}return M(Z);case I:return tt=wo(tt),sn(Z,W,tt,gt)}if(ut(tt))return jt(Z,W,tt,gt);if(Y(tt)){if(se=Y(tt),typeof se!="function")throw Error(i(150));return tt=se.call(tt),le(Z,W,tt,gt)}if(typeof tt.then=="function")return sn(Z,W,Ph(tt),gt);if(tt.$$typeof===w)return sn(Z,W,Dh(Z,tt),gt);Oh(Z,tt)}return typeof tt=="string"&&tt!==""||typeof tt=="number"||typeof tt=="bigint"?(tt=""+tt,W!==null&&W.tag===6?(c(Z,W.sibling),gt=g(W,tt),gt.return=Z,Z=gt):(c(Z,W),gt=Zm(tt,Z.mode,gt),gt.return=Z,Z=gt),M(Z)):c(Z,W)}return function(Z,W,tt,gt){try{Ou=0;var se=sn(Z,W,tt,gt);return Ol=null,se}catch(Kt){if(Kt===Pl||Kt===Nh)throw Kt;var ze=ns(29,Kt,null,Z.mode);return ze.lanes=gt,ze.return=Z,ze}finally{}}}var Co=bx(!0),vx=bx(!1),Mr=!1;function cg(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ug(s,r){s=s.updateQueue,r.updateQueue===s&&(r.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function Ar(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function Tr(s,r,c){var f=s.updateQueue;if(f===null)return null;if(f=f.shared,(We&2)!==0){var g=f.pending;return g===null?r.next=r:(r.next=g.next,g.next=r),f.pending=r,r=Eh(s),ex(s,null,c),r}return Th(s,f,r,c),Eh(s)}function Fu(s,r,c){if(r=r.updateQueue,r!==null&&(r=r.shared,(c&4194048)!==0)){var f=r.lanes;f&=s.pendingLanes,c|=f,r.lanes=c,fa(s,c)}}function fg(s,r){var c=s.updateQueue,f=s.alternate;if(f!==null&&(f=f.updateQueue,c===f)){var g=null,v=null;if(c=c.firstBaseUpdate,c!==null){do{var M={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};v===null?g=v=M:v=v.next=M,c=c.next}while(c!==null);v===null?g=v=r:v=v.next=r}else g=v=r;c={baseState:f.baseState,firstBaseUpdate:g,lastBaseUpdate:v,shared:f.shared,callbacks:f.callbacks},s.updateQueue=c;return}s=c.lastBaseUpdate,s===null?c.firstBaseUpdate=r:s.next=r,c.lastBaseUpdate=r}var hg=!1;function Bu(){if(hg){var s=Ul;if(s!==null)throw s}}function ku(s,r,c,f){hg=!1;var g=s.updateQueue;Mr=!1;var v=g.firstBaseUpdate,M=g.lastBaseUpdate,D=g.shared.pending;if(D!==null){g.shared.pending=null;var V=D,et=V.next;V.next=null,M===null?v=et:M.next=et,M=V;var ft=s.alternate;ft!==null&&(ft=ft.updateQueue,D=ft.lastBaseUpdate,D!==M&&(D===null?ft.firstBaseUpdate=et:D.next=et,ft.lastBaseUpdate=V))}if(v!==null){var _t=g.baseState;M=0,ft=et=V=null,D=v;do{var st=D.lane&-536870913,ct=st!==D.lane;if(ct?(De&st)===st:(f&st)===st){st!==0&&st===Nl&&(hg=!0),ft!==null&&(ft=ft.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});t:{var jt=s,le=D;st=r;var sn=c;switch(le.tag){case 1:if(jt=le.payload,typeof jt=="function"){_t=jt.call(sn,_t,st);break t}_t=jt;break t;case 3:jt.flags=jt.flags&-65537|128;case 0:if(jt=le.payload,st=typeof jt=="function"?jt.call(sn,_t,st):jt,st==null)break t;_t=m({},_t,st);break t;case 2:Mr=!0}}st=D.callback,st!==null&&(s.flags|=64,ct&&(s.flags|=8192),ct=g.callbacks,ct===null?g.callbacks=[st]:ct.push(st))}else ct={lane:st,tag:D.tag,payload:D.payload,callback:D.callback,next:null},ft===null?(et=ft=ct,V=_t):ft=ft.next=ct,M|=st;if(D=D.next,D===null){if(D=g.shared.pending,D===null)break;ct=D,D=ct.next,ct.next=null,g.lastBaseUpdate=ct,g.shared.pending=null}}while(!0);ft===null&&(V=_t),g.baseState=V,g.firstBaseUpdate=et,g.lastBaseUpdate=ft,v===null&&(g.shared.lanes=0),Dr|=M,s.lanes=M,s.memoizedState=_t}}function _x(s,r){if(typeof s!="function")throw Error(i(191,s));s.call(r)}function yx(s,r){var c=s.callbacks;if(c!==null)for(s.callbacks=null,s=0;sv?v:8;var M=k.T,D={};k.T=D,Lg(s,!1,r,c);try{var V=g(),et=k.S;if(et!==null&&et(D,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var ft=DD(V,f);Gu(s,r,ft,os(s))}else Gu(s,r,f,os(s))}catch(_t){Gu(s,r,{then:function(){},status:"rejected",reason:_t},os())}finally{Q.p=v,M!==null&&D.types!==null&&(M.types=D.types),k.T=M}}function ID(){}function Cg(s,r,c,f){if(s.tag!==5)throw Error(i(476));var g=Jx(s).queue;Qx(s,g,r,X,c===null?ID:function(){return $x(s),c(f)})}function Jx(s){var r=s.memoizedState;if(r!==null)return r;r={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ja,lastRenderedState:X},next:null};var c={};return r.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ja,lastRenderedState:c},next:null},s.memoizedState=r,s=s.alternate,s!==null&&(s.memoizedState=r),r}function $x(s){var r=Jx(s);r.next===null&&(r=s.alternate.memoizedState),Gu(s,r.next.queue,{},os())}function Dg(){return di(rf)}function t2(){return On().memoizedState}function e2(){return On().memoizedState}function FD(s){for(var r=s.return;r!==null;){switch(r.tag){case 24:case 3:var c=os();s=Ar(c);var f=Tr(r,s,c);f!==null&&(Xi(f,r,c),Fu(f,r,c)),r={cache:ag()},s.payload=r;return}r=r.return}}function BD(s,r,c){var f=os();c={lane:f,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Wh(s)?i2(r,c):(c=Ym(s,r,c,f),c!==null&&(Xi(c,s,f),s2(c,r,f)))}function n2(s,r,c){var f=os();Gu(s,r,c,f)}function Gu(s,r,c,f){var g={lane:f,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(Wh(s))i2(r,g);else{var v=s.alternate;if(s.lanes===0&&(v===null||v.lanes===0)&&(v=r.lastRenderedReducer,v!==null))try{var M=r.lastRenderedState,D=v(M,c);if(g.hasEagerState=!0,g.eagerState=D,es(D,M))return Th(s,r,g,0),cn===null&&Ah(),!1}catch{}finally{}if(c=Ym(s,r,g,f),c!==null)return Xi(c,s,f),s2(c,r,f),!0}return!1}function Lg(s,r,c,f){if(f={lane:2,revertLane:c0(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Wh(s)){if(r)throw Error(i(479))}else r=Ym(s,c,f,2),r!==null&&Xi(r,s,2)}function Wh(s){var r=s.alternate;return s===ge||r!==null&&r===ge}function i2(s,r){Fl=Bh=!0;var c=s.pending;c===null?r.next=r:(r.next=c.next,c.next=r),s.pending=r}function s2(s,r,c){if((c&4194048)!==0){var f=r.lanes;f&=s.pendingLanes,c|=f,r.lanes=c,fa(s,c)}}var Hu={readContext:di,use:Vh,useCallback:Cn,useContext:Cn,useEffect:Cn,useImperativeHandle:Cn,useLayoutEffect:Cn,useInsertionEffect:Cn,useMemo:Cn,useReducer:Cn,useRef:Cn,useState:Cn,useDebugValue:Cn,useDeferredValue:Cn,useTransition:Cn,useSyncExternalStore:Cn,useId:Cn,useHostTransitionStatus:Cn,useFormState:Cn,useActionState:Cn,useOptimistic:Cn,useMemoCache:Cn,useCacheRefresh:Cn};Hu.useEffectEvent=Cn;var a2={readContext:di,use:Vh,useCallback:function(s,r){return Ci().memoizedState=[s,r===void 0?null:r],s},useContext:di,useEffect:Gx,useImperativeHandle:function(s,r,c){c=c!=null?c.concat([s]):null,Hh(4194308,4,Xx.bind(null,r,s),c)},useLayoutEffect:function(s,r){return Hh(4194308,4,s,r)},useInsertionEffect:function(s,r){Hh(4,2,s,r)},useMemo:function(s,r){var c=Ci();r=r===void 0?null:r;var f=s();if(Do){mt(!0);try{s()}finally{mt(!1)}}return c.memoizedState=[f,r],f},useReducer:function(s,r,c){var f=Ci();if(c!==void 0){var g=c(r);if(Do){mt(!0);try{c(r)}finally{mt(!1)}}}else g=r;return f.memoizedState=f.baseState=g,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:g},f.queue=s,s=s.dispatch=BD.bind(null,ge,s),[f.memoizedState,s]},useRef:function(s){var r=Ci();return s={current:s},r.memoizedState=s},useState:function(s){s=Ag(s);var r=s.queue,c=n2.bind(null,ge,r);return r.dispatch=c,[s.memoizedState,c]},useDebugValue:wg,useDeferredValue:function(s,r){var c=Ci();return Rg(c,s,r)},useTransition:function(){var s=Ag(!1);return s=Qx.bind(null,ge,s.queue,!0,!1),Ci().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,r,c){var f=ge,g=Ci();if(Pe){if(c===void 0)throw Error(i(407));c=c()}else{if(c=r(),cn===null)throw Error(i(349));(De&127)!==0||Ex(f,r,c)}g.memoizedState=c;var v={value:c,getSnapshot:r};return g.queue=v,Gx(Rx.bind(null,f,v,s),[s]),f.flags|=2048,kl(9,{destroy:void 0},wx.bind(null,f,v,c,r),null),c},useId:function(){var s=Ci(),r=cn.identifierPrefix;if(Pe){var c=da,f=ha;c=(f&~(1<<32-Ut(f)-1)).toString(32)+c,r="_"+r+"R_"+c,c=kh++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof f.is=="string"?M.createElement("select",{is:f.is}):M.createElement("select"),f.multiple?v.multiple=!0:f.size&&(v.size=f.size);break;default:v=typeof f.is=="string"?M.createElement(g,{is:f.is}):M.createElement(g)}}v[wn]=r,v[ui]=f;t:for(M=r.child;M!==null;){if(M.tag===5||M.tag===6)v.appendChild(M.stateNode);else if(M.tag!==4&&M.tag!==27&&M.child!==null){M.child.return=M,M=M.child;continue}if(M===r)break t;for(;M.sibling===null;){if(M.return===null||M.return===r)break t;M=M.return}M.sibling.return=M.return,M=M.sibling}r.stateNode=v;t:switch(mi(v,g,f),g){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break t;case"img":f=!0;break t;default:f=!1}f&&Xa(r)}}return mn(r),Wg(r,r.type,s===null?null:s.memoizedProps,r.pendingProps,c),null;case 6:if(s&&r.stateNode!=null)s.memoizedProps!==f&&Xa(r);else{if(typeof f!="string"&&r.stateNode===null)throw Error(i(166));if(s=Et.current,Dl(r)){if(s=r.stateNode,c=r.memoizedProps,f=null,g=hi,g!==null)switch(g.tag){case 27:case 5:f=g.memoizedProps}s[wn]=r,s=!!(s.nodeValue===c||f!==null&&f.suppressHydrationWarning===!0||AS(s.nodeValue,c)),s||xr(r,!0)}else s=fd(s).createTextNode(f),s[wn]=r,r.stateNode=s}return mn(r),null;case 31:if(c=r.memoizedState,s===null||s.memoizedState!==null){if(f=Dl(r),c!==null){if(s===null){if(!f)throw Error(i(318));if(s=r.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(i(557));s[wn]=r}else Mo(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;mn(r),s=!1}else c=eg(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=c),s=!0;if(!s)return r.flags&256?(ss(r),r):(ss(r),null);if((r.flags&128)!==0)throw Error(i(558))}return mn(r),null;case 13:if(f=r.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(g=Dl(r),f!==null&&f.dehydrated!==null){if(s===null){if(!g)throw Error(i(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(i(317));g[wn]=r}else Mo(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;mn(r),g=!1}else g=eg(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=g),g=!0;if(!g)return r.flags&256?(ss(r),r):(ss(r),null)}return ss(r),(r.flags&128)!==0?(r.lanes=c,r):(c=f!==null,s=s!==null&&s.memoizedState!==null,c&&(f=r.child,g=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(g=f.alternate.memoizedState.cachePool.pool),v=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(v=f.memoizedState.cachePool.pool),v!==g&&(f.flags|=2048)),c!==s&&c&&(r.child.flags|=8192),Zh(r,r.updateQueue),mn(r),null);case 4:return ee(),s===null&&d0(r.stateNode.containerInfo),mn(r),null;case 10:return Ga(r.type),mn(r),null;case 19:if(it(Pn),f=r.memoizedState,f===null)return mn(r),null;if(g=(r.flags&128)!==0,v=f.rendering,v===null)if(g)Wu(f,!1);else{if(Dn!==0||s!==null&&(s.flags&128)!==0)for(s=r.child;s!==null;){if(v=Fh(s),v!==null){for(r.flags|=128,Wu(f,!1),s=v.updateQueue,r.updateQueue=s,Zh(r,s),r.subtreeFlags=0,s=c,c=r.child;c!==null;)nx(c,s),c=c.sibling;return Tt(Pn,Pn.current&1|2),Pe&&za(r,f.treeForkCount),r.child}s=s.sibling}f.tail!==null&&dt()>ed&&(r.flags|=128,g=!0,Wu(f,!1),r.lanes=4194304)}else{if(!g)if(s=Fh(v),s!==null){if(r.flags|=128,g=!0,s=s.updateQueue,r.updateQueue=s,Zh(r,s),Wu(f,!0),f.tail===null&&f.tailMode==="hidden"&&!v.alternate&&!Pe)return mn(r),null}else 2*dt()-f.renderingStartTime>ed&&c!==536870912&&(r.flags|=128,g=!0,Wu(f,!1),r.lanes=4194304);f.isBackwards?(v.sibling=r.child,r.child=v):(s=f.last,s!==null?s.sibling=v:r.child=v,f.last=v)}return f.tail!==null?(s=f.tail,f.rendering=s,f.tail=s.sibling,f.renderingStartTime=dt(),s.sibling=null,c=Pn.current,Tt(Pn,g?c&1|2:c&1),Pe&&za(r,f.treeForkCount),s):(mn(r),null);case 22:case 23:return ss(r),pg(),f=r.memoizedState!==null,s!==null?s.memoizedState!==null!==f&&(r.flags|=8192):f&&(r.flags|=8192),f?(c&536870912)!==0&&(r.flags&128)===0&&(mn(r),r.subtreeFlags&6&&(r.flags|=8192)):mn(r),c=r.updateQueue,c!==null&&Zh(r,c.retryQueue),c=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(c=s.memoizedState.cachePool.pool),f=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(f=r.memoizedState.cachePool.pool),f!==c&&(r.flags|=2048),s!==null&&it(Eo),null;case 24:return c=null,s!==null&&(c=s.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),Ga(Fn),mn(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function HD(s,r){switch($m(r),r.tag){case 1:return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 3:return Ga(Fn),ee(),s=r.flags,(s&65536)!==0&&(s&128)===0?(r.flags=s&-65537|128,r):null;case 26:case 27:case 5:return on(r),null;case 31:if(r.memoizedState!==null){if(ss(r),r.alternate===null)throw Error(i(340));Mo()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 13:if(ss(r),s=r.memoizedState,s!==null&&s.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Mo()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 19:return it(Pn),null;case 4:return ee(),null;case 10:return Ga(r.type),null;case 22:case 23:return ss(r),pg(),s!==null&&it(Eo),s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 24:return Ga(Fn),null;case 25:return null;default:return null}}function C2(s,r){switch($m(r),r.tag){case 3:Ga(Fn),ee();break;case 26:case 27:case 5:on(r);break;case 4:ee();break;case 31:r.memoizedState!==null&&ss(r);break;case 13:ss(r);break;case 19:it(Pn);break;case 10:Ga(r.type);break;case 22:case 23:ss(r),pg(),s!==null&&it(Eo);break;case 24:Ga(Fn)}}function Xu(s,r){try{var c=r.updateQueue,f=c!==null?c.lastEffect:null;if(f!==null){var g=f.next;c=g;do{if((c.tag&s)===s){f=void 0;var v=c.create,M=c.inst;f=v(),M.destroy=f}c=c.next}while(c!==g)}}catch(D){Qe(r,r.return,D)}}function Rr(s,r,c){try{var f=r.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var v=g.next;f=v;do{if((f.tag&s)===s){var M=f.inst,D=M.destroy;if(D!==void 0){M.destroy=void 0,g=r;var V=c,et=D;try{et()}catch(ft){Qe(g,V,ft)}}}f=f.next}while(f!==v)}}catch(ft){Qe(r,r.return,ft)}}function D2(s){var r=s.updateQueue;if(r!==null){var c=s.stateNode;try{yx(r,c)}catch(f){Qe(s,s.return,f)}}}function L2(s,r,c){c.props=Lo(s.type,s.memoizedProps),c.state=s.memoizedState;try{c.componentWillUnmount()}catch(f){Qe(s,r,f)}}function qu(s,r){try{var c=s.ref;if(c!==null){switch(s.tag){case 26:case 27:case 5:var f=s.stateNode;break;case 30:f=s.stateNode;break;default:f=s.stateNode}typeof c=="function"?s.refCleanup=c(f):c.current=f}}catch(g){Qe(s,r,g)}}function pa(s,r){var c=s.ref,f=s.refCleanup;if(c!==null)if(typeof f=="function")try{f()}catch(g){Qe(s,r,g)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(g){Qe(s,r,g)}else c.current=null}function N2(s){var r=s.type,c=s.memoizedProps,f=s.stateNode;try{t:switch(r){case"button":case"input":case"select":case"textarea":c.autoFocus&&f.focus();break t;case"img":c.src?f.src=c.src:c.srcSet&&(f.srcset=c.srcSet)}}catch(g){Qe(s,s.return,g)}}function Xg(s,r,c){try{var f=s.stateNode;fL(f,s.type,c,r),f[ui]=r}catch(g){Qe(s,s.return,g)}}function U2(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Or(s.type)||s.tag===4}function qg(s){t:for(;;){for(;s.sibling===null;){if(s.return===null||U2(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Or(s.type)||s.flags&2||s.child===null||s.tag===4)continue t;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Yg(s,r,c){var f=s.tag;if(f===5||f===6)s=s.stateNode,r?(c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c).insertBefore(s,r):(r=c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c,r.appendChild(s),c=c._reactRootContainer,c!=null||r.onclick!==null||(r.onclick=Fa));else if(f!==4&&(f===27&&Or(s.type)&&(c=s.stateNode,r=null),s=s.child,s!==null))for(Yg(s,r,c),s=s.sibling;s!==null;)Yg(s,r,c),s=s.sibling}function Qh(s,r,c){var f=s.tag;if(f===5||f===6)s=s.stateNode,r?c.insertBefore(s,r):c.appendChild(s);else if(f!==4&&(f===27&&Or(s.type)&&(c=s.stateNode),s=s.child,s!==null))for(Qh(s,r,c),s=s.sibling;s!==null;)Qh(s,r,c),s=s.sibling}function P2(s){var r=s.stateNode,c=s.memoizedProps;try{for(var f=s.type,g=r.attributes;g.length;)r.removeAttributeNode(g[0]);mi(r,f,c),r[wn]=s,r[ui]=c}catch(v){Qe(s,s.return,v)}}var qa=!1,zn=!1,Kg=!1,O2=typeof WeakSet=="function"?WeakSet:Set,ai=null;function jD(s,r){if(s=s.containerInfo,g0=vd,s=qy(s),Gm(s)){if("selectionStart"in s)var c={start:s.selectionStart,end:s.selectionEnd};else t:{c=(c=s.ownerDocument)&&c.defaultView||window;var f=c.getSelection&&c.getSelection();if(f&&f.rangeCount!==0){c=f.anchorNode;var g=f.anchorOffset,v=f.focusNode;f=f.focusOffset;try{c.nodeType,v.nodeType}catch{c=null;break t}var M=0,D=-1,V=-1,et=0,ft=0,_t=s,st=null;e:for(;;){for(var ct;_t!==c||g!==0&&_t.nodeType!==3||(D=M+g),_t!==v||f!==0&&_t.nodeType!==3||(V=M+f),_t.nodeType===3&&(M+=_t.nodeValue.length),(ct=_t.firstChild)!==null;)st=_t,_t=ct;for(;;){if(_t===s)break e;if(st===c&&++et===g&&(D=M),st===v&&++ft===f&&(V=M),(ct=_t.nextSibling)!==null)break;_t=st,st=_t.parentNode}_t=ct}c=D===-1||V===-1?null:{start:D,end:V}}else c=null}c=c||{start:0,end:0}}else c=null;for(b0={focusedElem:s,selectionRange:c},vd=!1,ai=r;ai!==null;)if(r=ai,s=r.child,(r.subtreeFlags&1028)!==0&&s!==null)s.return=r,ai=s;else for(;ai!==null;){switch(r=ai,v=r.alternate,s=r.flags,r.tag){case 0:if((s&4)!==0&&(s=r.updateQueue,s=s!==null?s.events:null,s!==null))for(c=0;c title"))),mi(v,f,c),v[wn]=s,q(v),f=v;break t;case"link":var M=VS("link","href",g).get(f+(c.href||""));if(M){for(var D=0;Dsn&&(M=sn,sn=le,le=M);var Z=Wy(D,le),W=Wy(D,sn);if(Z&&W&&(ct.rangeCount!==1||ct.anchorNode!==Z.node||ct.anchorOffset!==Z.offset||ct.focusNode!==W.node||ct.focusOffset!==W.offset)){var tt=_t.createRange();tt.setStart(Z.node,Z.offset),ct.removeAllRanges(),le>sn?(ct.addRange(tt),ct.extend(W.node,W.offset)):(tt.setEnd(W.node,W.offset),ct.addRange(tt))}}}}for(_t=[],ct=D;ct=ct.parentNode;)ct.nodeType===1&&_t.push({element:ct,left:ct.scrollLeft,top:ct.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;D<_t.length;D++){var gt=_t[D];gt.element.scrollLeft=gt.left,gt.element.scrollTop=gt.top}}vd=!!g0,b0=g0=null}finally{We=g,Q.p=f,k.T=c}}s.current=r,Yn=2}}function lS(){if(Yn===2){Yn=0;var s=Nr,r=jl,c=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||c){c=k.T,k.T=null;var f=Q.p;Q.p=2;var g=We;We|=4;try{I2(s,r.alternate,r)}finally{We=g,Q.p=f,k.T=c}}Yn=3}}function cS(){if(Yn===4||Yn===3){Yn=0,nt();var s=Nr,r=jl,c=Ja,f=K2;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Yn=5:(Yn=0,jl=Nr=null,uS(s,s.pendingLanes));var g=s.pendingLanes;if(g===0&&(Lr=null),_l(c),r=r.stateNode,qt&&typeof qt.onCommitFiberRoot=="function")try{qt.onCommitFiberRoot(te,r,void 0,(r.current.flags&128)===128)}catch{}if(f!==null){r=k.T,g=Q.p,Q.p=2,k.T=null;try{for(var v=s.onRecoverableError,M=0;Mc?32:c,k.T=null,c=n0,n0=null;var v=Nr,M=Ja;if(Yn=0,jl=Nr=null,Ja=0,(We&6)!==0)throw Error(i(331));var D=We;if(We|=4,X2(v.current),H2(v,v.current,M,c),We=D,$u(0,!1),qt&&typeof qt.onPostCommitFiberRoot=="function")try{qt.onPostCommitFiberRoot(te,v)}catch{}return!0}finally{Q.p=g,k.T=f,uS(s,r)}}function hS(s,r,c){r=As(c,r),r=Og(s.stateNode,r,2),s=Tr(s,r,2),s!==null&&(ln(s,2),ma(s))}function Qe(s,r,c){if(s.tag===3)hS(s,s,c);else for(;r!==null;){if(r.tag===3){hS(r,s,c);break}else if(r.tag===1){var f=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(Lr===null||!Lr.has(f))){s=As(c,s),c=d2(2),f=Tr(r,c,2),f!==null&&(p2(c,f,r,s),ln(f,2),ma(f));break}}r=r.return}}function r0(s,r,c){var f=s.pingCache;if(f===null){f=s.pingCache=new qD;var g=new Set;f.set(r,g)}else g=f.get(r),g===void 0&&(g=new Set,f.set(r,g));g.has(c)||(Jg=!0,g.add(c),s=JD.bind(null,s,r,c),r.then(s,s))}function JD(s,r,c){var f=s.pingCache;f!==null&&f.delete(r),s.pingedLanes|=s.suspendedLanes&c,s.warmLanes&=~c,cn===s&&(De&c)===c&&(Dn===4||Dn===3&&(De&62914560)===De&&300>dt()-td?(We&2)===0&&Wl(s,0):$g|=c,Hl===De&&(Hl=0)),ma(s)}function dS(s,r){r===0&&(r=hn()),s=xo(s,r),s!==null&&(ln(s,r),ma(s))}function $D(s){var r=s.memoizedState,c=0;r!==null&&(c=r.retryLane),dS(s,c)}function tL(s,r){var c=0;switch(s.tag){case 31:case 13:var f=s.stateNode,g=s.memoizedState;g!==null&&(c=g.retryLane);break;case 19:f=s.stateNode;break;case 22:f=s.stateNode._retryCache;break;default:throw Error(i(314))}f!==null&&f.delete(r),dS(s,c)}function eL(s,r){return Yt(s,r)}var od=null,ql=null,o0=!1,ld=!1,l0=!1,Pr=0;function ma(s){s!==ql&&s.next===null&&(ql===null?od=ql=s:ql=ql.next=s),ld=!0,o0||(o0=!0,iL())}function $u(s,r){if(!l0&&ld){l0=!0;do for(var c=!1,f=od;f!==null;){if(s!==0){var g=f.pendingLanes;if(g===0)var v=0;else{var M=f.suspendedLanes,D=f.pingedLanes;v=(1<<31-Ut(42|s)+1)-1,v&=g&~(M&~D),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(c=!0,bS(f,v))}else v=De,v=Nt(f,f===cn?v:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(v&3)===0||ne(f,v)||(c=!0,bS(f,v));f=f.next}while(c);l0=!1}}function nL(){pS()}function pS(){ld=o0=!1;var s=0;Pr!==0&&dL()&&(s=Pr);for(var r=dt(),c=null,f=od;f!==null;){var g=f.next,v=mS(f,r);v===0?(f.next=null,c===null?od=g:c.next=g,g===null&&(ql=c)):(c=f,(s!==0||(v&3)!==0)&&(ld=!0)),f=g}Yn!==0&&Yn!==5||$u(s),Pr!==0&&(Pr=0)}function mS(s,r){for(var c=s.suspendedLanes,f=s.pingedLanes,g=s.expirationTimes,v=s.pendingLanes&-62914561;0D)break;var ft=V.transferSize,_t=V.initiatorType;ft&&TS(_t)&&(V=V.responseEnd,M+=ft*(V"u"?null:document;function FS(s,r,c){var f=Yl;if(f&&typeof r=="string"&&r){var g=si(r);g='link[rel="'+s+'"][href="'+g+'"]',typeof c=="string"&&(g+='[crossorigin="'+c+'"]'),IS.has(g)||(IS.add(g),s={rel:s,crossOrigin:c,href:r},f.querySelector(g)===null&&(r=f.createElement("link"),mi(r,"link",s),q(r),f.head.appendChild(r)))}}function SL(s){$a.D(s),FS("dns-prefetch",s,null)}function ML(s,r){$a.C(s,r),FS("preconnect",s,r)}function AL(s,r,c){$a.L(s,r,c);var f=Yl;if(f&&s&&r){var g='link[rel="preload"][as="'+si(r)+'"]';r==="image"&&c&&c.imageSrcSet?(g+='[imagesrcset="'+si(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(g+='[imagesizes="'+si(c.imageSizes)+'"]')):g+='[href="'+si(s)+'"]';var v=g;switch(r){case"style":v=Kl(s);break;case"script":v=Zl(s)}Ds.has(v)||(s=m({rel:"preload",href:r==="image"&&c&&c.imageSrcSet?void 0:s,as:r},c),Ds.set(v,s),f.querySelector(g)!==null||r==="style"&&f.querySelector(sf(v))||r==="script"&&f.querySelector(af(v))||(r=f.createElement("link"),mi(r,"link",s),q(r),f.head.appendChild(r)))}}function TL(s,r){$a.m(s,r);var c=Yl;if(c&&s){var f=r&&typeof r.as=="string"?r.as:"script",g='link[rel="modulepreload"][as="'+si(f)+'"][href="'+si(s)+'"]',v=g;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Zl(s)}if(!Ds.has(v)&&(s=m({rel:"modulepreload",href:s},r),Ds.set(v,s),c.querySelector(g)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(af(v)))return}f=c.createElement("link"),mi(f,"link",s),q(f),c.head.appendChild(f)}}}function EL(s,r,c){$a.S(s,r,c);var f=Yl;if(f&&s){var g=rt(f).hoistableStyles,v=Kl(s);r=r||"default";var M=g.get(v);if(!M){var D={loading:0,preload:null};if(M=f.querySelector(sf(v)))D.loading=5;else{s=m({rel:"stylesheet",href:s,"data-precedence":r},c),(c=Ds.get(v))&&A0(s,c);var V=M=f.createElement("link");q(V),mi(V,"link",s),V._p=new Promise(function(et,ft){V.onload=et,V.onerror=ft}),V.addEventListener("load",function(){D.loading|=1}),V.addEventListener("error",function(){D.loading|=2}),D.loading|=4,dd(M,r,f)}M={type:"stylesheet",instance:M,count:1,state:D},g.set(v,M)}}}function wL(s,r){$a.X(s,r);var c=Yl;if(c&&s){var f=rt(c).hoistableScripts,g=Zl(s),v=f.get(g);v||(v=c.querySelector(af(g)),v||(s=m({src:s,async:!0},r),(r=Ds.get(g))&&T0(s,r),v=c.createElement("script"),q(v),mi(v,"link",s),c.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function RL(s,r){$a.M(s,r);var c=Yl;if(c&&s){var f=rt(c).hoistableScripts,g=Zl(s),v=f.get(g);v||(v=c.querySelector(af(g)),v||(s=m({src:s,async:!0,type:"module"},r),(r=Ds.get(g))&&T0(s,r),v=c.createElement("script"),q(v),mi(v,"link",s),c.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function BS(s,r,c,f){var g=(g=Et.current)?hd(g):null;if(!g)throw Error(i(446));switch(s){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(r=Kl(c.href),c=rt(g).hoistableStyles,f=c.get(r),f||(f={type:"style",instance:null,count:0,state:null},c.set(r,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){s=Kl(c.href);var v=rt(g).hoistableStyles,M=v.get(s);if(M||(g=g.ownerDocument||g,M={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(s,M),(v=g.querySelector(sf(s)))&&!v._p&&(M.instance=v,M.state.loading=5),Ds.has(s)||(c={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},Ds.set(s,c),v||CL(g,s,c,M.state))),r&&f===null)throw Error(i(528,""));return M}if(r&&f!==null)throw Error(i(529,""));return null;case"script":return r=c.async,c=c.src,typeof c=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Zl(c),c=rt(g).hoistableScripts,f=c.get(r),f||(f={type:"script",instance:null,count:0,state:null},c.set(r,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,s))}}function Kl(s){return'href="'+si(s)+'"'}function sf(s){return'link[rel="stylesheet"]['+s+"]"}function kS(s){return m({},s,{"data-precedence":s.precedence,precedence:null})}function CL(s,r,c,f){s.querySelector('link[rel="preload"][as="style"]['+r+"]")?f.loading=1:(r=s.createElement("link"),f.preload=r,r.addEventListener("load",function(){return f.loading|=1}),r.addEventListener("error",function(){return f.loading|=2}),mi(r,"link",c),q(r),s.head.appendChild(r))}function Zl(s){return'[src="'+si(s)+'"]'}function af(s){return"script[async]"+s}function zS(s,r,c){if(r.count++,r.instance===null)switch(r.type){case"style":var f=s.querySelector('style[data-href~="'+si(c.href)+'"]');if(f)return r.instance=f,q(f),f;var g=m({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return f=(s.ownerDocument||s).createElement("style"),q(f),mi(f,"style",g),dd(f,c.precedence,s),r.instance=f;case"stylesheet":g=Kl(c.href);var v=s.querySelector(sf(g));if(v)return r.state.loading|=4,r.instance=v,q(v),v;f=kS(c),(g=Ds.get(g))&&A0(f,g),v=(s.ownerDocument||s).createElement("link"),q(v);var M=v;return M._p=new Promise(function(D,V){M.onload=D,M.onerror=V}),mi(v,"link",f),r.state.loading|=4,dd(v,c.precedence,s),r.instance=v;case"script":return v=Zl(c.src),(g=s.querySelector(af(v)))?(r.instance=g,q(g),g):(f=c,(g=Ds.get(v))&&(f=m({},c),T0(f,g)),s=s.ownerDocument||s,g=s.createElement("script"),q(g),mi(g,"link",f),s.head.appendChild(g),r.instance=g);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(f=r.instance,r.state.loading|=4,dd(f,c.precedence,s));return r.instance}function dd(s,r,c){for(var f=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=f.length?f[f.length-1]:null,v=g,M=0;M title"):null)}function DL(s,r,c){if(c===1||r.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return s=r.disabled,typeof r.precedence=="string"&&s==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function HS(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function LL(s,r,c,f){if(c.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var g=Kl(f.href),v=r.querySelector(sf(g));if(v){r=v._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(s.count++,s=md.bind(s),r.then(s,s)),c.state.loading|=4,c.instance=v,q(v);return}v=r.ownerDocument||r,f=kS(f),(g=Ds.get(g))&&A0(f,g),v=v.createElement("link"),q(v);var M=v;M._p=new Promise(function(D,V){M.onload=D,M.onerror=V}),mi(v,"link",f),c.instance=v}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(c,r),(r=c.state.preload)&&(c.state.loading&3)===0&&(s.count++,c=md.bind(s),r.addEventListener("load",c),r.addEventListener("error",c))}}var E0=0;function NL(s,r){return s.stylesheets&&s.count===0&&bd(s,s.stylesheets),0E0?50:800)+r);return s.unsuspend=c,function(){s.unsuspend=null,clearTimeout(f),clearTimeout(g)}}:null}function md(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)bd(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var gd=null;function bd(s,r){s.stylesheets=null,s.unsuspend!==null&&(s.count++,gd=new Map,r.forEach(UL,s),gd=null,md.call(s))}function UL(s,r){if(!(r.state.loading&4)){var c=gd.get(s);if(c)var f=c.get(null);else{c=new Map,gd.set(s,c);for(var g=s.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),O0.exports=KL(),O0.exports}var QL=ZL();/** * @license * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */const R1="174",JL=0,dM=1,$L=2,n3=1,t5=2,rr=3,hr=0,Ji=1,Is=2,so=0,Ac=1,Lf=2,pM=3,mM=4,e5=5,Yo=100,n5=101,i5=102,s5=103,a5=104,r5=200,o5=201,l5=202,c5=203,Yb=204,Kb=205,u5=206,f5=207,h5=208,d5=209,p5=210,m5=211,g5=212,b5=213,v5=214,Zb=0,Qb=1,Jb=2,Dc=3,$b=4,tv=5,ev=6,nv=7,i3=0,_5=1,y5=2,ao=0,x5=1,S5=2,M5=3,A5=4,T5=5,E5=6,w5=7,gM="attached",R5="detached",s3=300,Lc=301,Nc=302,iv=303,sv=304,Yp=306,Uc=1e3,eo=1001,Ep=1002,Ii=1003,a3=1004,Tf=1005,ps=1006,cp=1007,cr=1008,dr=1009,r3=1010,o3=1011,Gf=1012,C1=1013,cl=1014,na=1015,eh=1016,D1=1017,L1=1018,Pc=1020,l3=35902,c3=1021,u3=1022,Fs=1023,f3=1024,h3=1025,Tc=1026,Oc=1027,N1=1028,U1=1029,d3=1030,P1=1031,O1=1033,up=33776,fp=33777,hp=33778,dp=33779,av=35840,rv=35841,ov=35842,lv=35843,cv=36196,uv=37492,fv=37496,hv=37808,dv=37809,pv=37810,mv=37811,gv=37812,bv=37813,vv=37814,_v=37815,yv=37816,xv=37817,Sv=37818,Mv=37819,Av=37820,Tv=37821,pp=36492,Ev=36494,wv=36495,p3=36283,Rv=36284,Cv=36285,Dv=36286,Ef=2200,C5=2201,D5=2202,Hf=2300,jf=2301,k0=2302,bc=2400,vc=2401,wp=2402,I1=2500,L5=2501,N5=0,m3=1,Lv=2,U5=3200,P5=3201,g3=0,O5=1,$r="",ci="srgb",Bi="srgb-linear",Rp="linear",an="srgb",Jl=7680,bM=519,I5=512,F5=513,B5=514,b3=515,k5=516,z5=517,V5=518,G5=519,Nv=35044,vM="300 es",ur=2e3,Cp=2001;class ml{addEventListener(t,n){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(n)===-1&&i[t].push(n)}hasEventListener(t,n){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(n)!==-1}removeEventListener(t,n){const i=this._listeners;if(i===void 0)return;const a=i[t];if(a!==void 0){const o=a.indexOf(n);o!==-1&&a.splice(o,1)}}dispatchEvent(t){const n=this._listeners;if(n===void 0)return;const i=n[t.type];if(i!==void 0){t.target=this;const a=i.slice(0);for(let o=0,l=a.length;o>8&255]+xi[e>>16&255]+xi[e>>24&255]+"-"+xi[t&255]+xi[t>>8&255]+"-"+xi[t>>16&15|64]+xi[t>>24&255]+"-"+xi[n&63|128]+xi[n>>8&255]+"-"+xi[n>>16&255]+xi[n>>24&255]+xi[i&255]+xi[i>>8&255]+xi[i>>16&255]+xi[i>>24&255]).toLowerCase()}function Re(e,t,n){return Math.max(t,Math.min(n,e))}function F1(e,t){return(e%t+t)%t}function H5(e,t,n,i,a){return i+(e-t)*(a-i)/(n-t)}function j5(e,t,n){return e!==t?(n-e)/(t-e):0}function Uf(e,t,n){return(1-n)*e+n*t}function W5(e,t,n,i){return Uf(e,t,1-Math.exp(-n*i))}function X5(e,t=1){return t-Math.abs(F1(e,t*2)-t)}function q5(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function Y5(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function K5(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Z5(e,t){return e+Math.random()*(t-e)}function Q5(e){return e*(.5-Math.random())}function J5(e){e!==void 0&&(_M=e);let t=_M+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function $5(e){return e*Nf}function tN(e){return e*Ic}function eN(e){return(e&e-1)===0&&e!==0}function nN(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function iN(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function sN(e,t,n,i,a){const o=Math.cos,l=Math.sin,u=o(n/2),h=l(n/2),d=o((t+i)/2),p=l((t+i)/2),m=o((t-i)/2),b=l((t-i)/2),_=o((i-t)/2),S=l((i-t)/2);switch(a){case"XYX":e.set(u*p,h*m,h*b,u*d);break;case"YZY":e.set(h*b,u*p,h*m,u*d);break;case"ZXZ":e.set(h*m,h*b,u*p,u*d);break;case"XZX":e.set(u*p,h*S,h*_,u*d);break;case"YXY":e.set(h*_,u*p,h*S,u*d);break;case"ZYZ":e.set(h*S,h*_,u*p,u*d);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+a)}}function ta(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Je(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw new Error("Invalid component type.")}}const Ki={DEG2RAD:Nf,RAD2DEG:Ic,generateUUID:ia,clamp:Re,euclideanModulo:F1,mapLinear:H5,inverseLerp:j5,lerp:Uf,damp:W5,pingpong:X5,smoothstep:q5,smootherstep:Y5,randInt:K5,randFloat:Z5,randFloatSpread:Q5,seededRandom:J5,degToRad:$5,radToDeg:tN,isPowerOfTwo:eN,ceilPowerOfTwo:nN,floorPowerOfTwo:iN,setQuaternionFromProperEuler:sN,normalize:Je,denormalize:ta};class Ae{constructor(t=0,n=0){Ae.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,n){return this.x=t,this.y=n,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const n=this.x,i=this.y,a=t.elements;return this.x=a[0]*n+a[3]*i+a[6],this.y=a[1]*n+a[4]*i+a[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,n){return this.x=Re(this.x,t.x,n.x),this.y=Re(this.y,t.y,n.y),this}clampScalar(t,n){return this.x=Re(this.x,t,n),this.y=Re(this.y,t,n),this}clampLength(t,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Re(i,t,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const i=this.dot(t)/n;return Math.acos(Re(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,i=this.y-t.y;return n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this}lerpVectors(t,n,i){return this.x=t.x+(n.x-t.x)*i,this.y=t.y+(n.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t}fromBufferAttribute(t,n){return this.x=t.getX(n),this.y=t.getY(n),this}rotateAround(t,n){const i=Math.cos(n),a=Math.sin(n),o=this.x-t.x,l=this.y-t.y;return this.x=o*i-l*a+t.x,this.y=o*a+l*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ve{constructor(t,n,i,a,o,l,u,h,d){ve.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,i,a,o,l,u,h,d)}set(t,n,i,a,o,l,u,h,d){const p=this.elements;return p[0]=t,p[1]=a,p[2]=u,p[3]=n,p[4]=o,p[5]=h,p[6]=i,p[7]=l,p[8]=d,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const n=this.elements,i=t.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this}extractBasis(t,n,i){return t.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const n=t.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const i=t.elements,a=n.elements,o=this.elements,l=i[0],u=i[3],h=i[6],d=i[1],p=i[4],m=i[7],b=i[2],_=i[5],S=i[8],A=a[0],x=a[3],y=a[6],E=a[1],w=a[4],T=a[7],P=a[2],O=a[5],U=a[8];return o[0]=l*A+u*E+h*P,o[3]=l*x+u*w+h*O,o[6]=l*y+u*T+h*U,o[1]=d*A+p*E+m*P,o[4]=d*x+p*w+m*O,o[7]=d*y+p*T+m*U,o[2]=b*A+_*E+S*P,o[5]=b*x+_*w+S*O,o[8]=b*y+_*T+S*U,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=t,n[4]*=t,n[7]*=t,n[2]*=t,n[5]*=t,n[8]*=t,this}determinant(){const t=this.elements,n=t[0],i=t[1],a=t[2],o=t[3],l=t[4],u=t[5],h=t[6],d=t[7],p=t[8];return n*l*p-n*u*d-i*o*p+i*u*h+a*o*d-a*l*h}invert(){const t=this.elements,n=t[0],i=t[1],a=t[2],o=t[3],l=t[4],u=t[5],h=t[6],d=t[7],p=t[8],m=p*l-u*d,b=u*h-p*o,_=d*o-l*h,S=n*m+i*b+a*_;if(S===0)return this.set(0,0,0,0,0,0,0,0,0);const A=1/S;return t[0]=m*A,t[1]=(a*d-p*i)*A,t[2]=(u*i-a*l)*A,t[3]=b*A,t[4]=(p*n-a*h)*A,t[5]=(a*o-u*n)*A,t[6]=_*A,t[7]=(i*h-d*n)*A,t[8]=(l*n-i*o)*A,this}transpose(){let t;const n=this.elements;return t=n[1],n[1]=n[3],n[3]=t,t=n[2],n[2]=n[6],n[6]=t,t=n[5],n[5]=n[7],n[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const n=this.elements;return t[0]=n[0],t[1]=n[3],t[2]=n[6],t[3]=n[1],t[4]=n[4],t[5]=n[7],t[6]=n[2],t[7]=n[5],t[8]=n[8],this}setUvTransform(t,n,i,a,o,l,u){const h=Math.cos(o),d=Math.sin(o);return this.set(i*h,i*d,-i*(h*l+d*u)+l+t,-a*d,a*h,-a*(-d*l+h*u)+u+n,0,0,1),this}scale(t,n){return this.premultiply(z0.makeScale(t,n)),this}rotate(t){return this.premultiply(z0.makeRotation(-t)),this}translate(t,n){return this.premultiply(z0.makeTranslation(t,n)),this}makeTranslation(t,n){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,n,0,0,1),this}makeRotation(t){const n=Math.cos(t),i=Math.sin(t);return this.set(n,-i,0,i,n,0,0,0,1),this}makeScale(t,n){return this.set(t,0,0,0,n,0,0,0,1),this}equals(t){const n=this.elements,i=t.elements;for(let a=0;a<9;a++)if(n[a]!==i[a])return!1;return!0}fromArray(t,n=0){for(let i=0;i<9;i++)this.elements[i]=t[i+n];return this}toArray(t=[],n=0){const i=this.elements;return t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3],t[n+4]=i[4],t[n+5]=i[5],t[n+6]=i[6],t[n+7]=i[7],t[n+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const z0=new ve;function v3(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Wf(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function aN(){const e=Wf("canvas");return e.style.display="block",e}const yM={};function jo(e){e in yM||(yM[e]=!0,console.warn(e))}function rN(e,t,n){return new Promise(function(i,a){function o(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:a();break;case e.TIMEOUT_EXPIRED:setTimeout(o,n);break;default:i()}}setTimeout(o,n)})}function oN(e){const t=e.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function lN(e){const t=e.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const xM=new ve().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),SM=new ve().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function cN(){const e={enabled:!0,workingColorSpace:Bi,spaces:{},convert:function(a,o,l){return this.enabled===!1||o===l||!o||!l||(this.spaces[o].transfer===an&&(a.r=fr(a.r),a.g=fr(a.g),a.b=fr(a.b)),this.spaces[o].primaries!==this.spaces[l].primaries&&(a.applyMatrix3(this.spaces[o].toXYZ),a.applyMatrix3(this.spaces[l].fromXYZ)),this.spaces[l].transfer===an&&(a.r=Ec(a.r),a.g=Ec(a.g),a.b=Ec(a.b))),a},fromWorkingColorSpace:function(a,o){return this.convert(a,this.workingColorSpace,o)},toWorkingColorSpace:function(a,o){return this.convert(a,o,this.workingColorSpace)},getPrimaries:function(a){return this.spaces[a].primaries},getTransfer:function(a){return a===$r?Rp:this.spaces[a].transfer},getLuminanceCoefficients:function(a,o=this.workingColorSpace){return a.fromArray(this.spaces[o].luminanceCoefficients)},define:function(a){Object.assign(this.spaces,a)},_getMatrix:function(a,o,l){return a.copy(this.spaces[o].toXYZ).multiply(this.spaces[l].fromXYZ)},_getDrawingBufferColorSpace:function(a){return this.spaces[a].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(a=this.workingColorSpace){return this.spaces[a].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return e.define({[Bi]:{primaries:t,whitePoint:i,transfer:Rp,toXYZ:xM,fromXYZ:SM,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:ci},outputColorSpaceConfig:{drawingBufferColorSpace:ci}},[ci]:{primaries:t,whitePoint:i,transfer:an,toXYZ:xM,fromXYZ:SM,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:ci}}}),e}const Ie=cN();function fr(e){return e<.04045?e*.0773993808:Math.pow(e*.9478672986+.0521327014,2.4)}function Ec(e){return e<.0031308?e*12.92:1.055*Math.pow(e,.41666)-.055}let $l;class uN{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{$l===void 0&&($l=Wf("canvas")),$l.width=t.width,$l.height=t.height;const i=$l.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=$l}return n.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const n=Wf("canvas");n.width=t.width,n.height=t.height;const i=n.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const a=i.getImageData(0,0,t.width,t.height),o=a.data;for(let l=0;l0&&(i.userData=this.userData),n||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==s3)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Uc:t.x=t.x-Math.floor(t.x);break;case eo:t.x=t.x<0?0:1;break;case Ep:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Uc:t.y=t.y-Math.floor(t.y);break;case eo:t.y=t.y<0?0:1;break;case Ep:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Qn.DEFAULT_IMAGE=null;Qn.DEFAULT_MAPPING=s3;Qn.DEFAULT_ANISOTROPY=1;class qe{constructor(t=0,n=0,i=0,a=1){qe.prototype.isVector4=!0,this.x=t,this.y=n,this.z=i,this.w=a}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,n,i,a){return this.x=t,this.y=n,this.z=i,this.w=a,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this.w=t.w+n.w,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this.w+=t.w*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this.w=t.w-n.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const n=this.x,i=this.y,a=this.z,o=this.w,l=t.elements;return this.x=l[0]*n+l[4]*i+l[8]*a+l[12]*o,this.y=l[1]*n+l[5]*i+l[9]*a+l[13]*o,this.z=l[2]*n+l[6]*i+l[10]*a+l[14]*o,this.w=l[3]*n+l[7]*i+l[11]*a+l[15]*o,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const n=Math.sqrt(1-t.w*t.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/n,this.y=t.y/n,this.z=t.z/n),this}setAxisAngleFromRotationMatrix(t){let n,i,a,o;const h=t.elements,d=h[0],p=h[4],m=h[8],b=h[1],_=h[5],S=h[9],A=h[2],x=h[6],y=h[10];if(Math.abs(p-b)<.01&&Math.abs(m-A)<.01&&Math.abs(S-x)<.01){if(Math.abs(p+b)<.1&&Math.abs(m+A)<.1&&Math.abs(S+x)<.1&&Math.abs(d+_+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(d+1)/2,T=(_+1)/2,P=(y+1)/2,O=(p+b)/4,U=(m+A)/4,I=(S+x)/4;return w>T&&w>P?w<.01?(i=0,a=.707106781,o=.707106781):(i=Math.sqrt(w),a=O/i,o=U/i):T>P?T<.01?(i=.707106781,a=0,o=.707106781):(a=Math.sqrt(T),i=O/a,o=I/a):P<.01?(i=.707106781,a=.707106781,o=0):(o=Math.sqrt(P),i=U/o,a=I/o),this.set(i,a,o,n),this}let E=Math.sqrt((x-S)*(x-S)+(m-A)*(m-A)+(b-p)*(b-p));return Math.abs(E)<.001&&(E=1),this.x=(x-S)/E,this.y=(m-A)/E,this.z=(b-p)/E,this.w=Math.acos((d+_+y-1)/2),this}setFromMatrixPosition(t){const n=t.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,n){return this.x=Re(this.x,t.x,n.x),this.y=Re(this.y,t.y,n.y),this.z=Re(this.z,t.z,n.z),this.w=Re(this.w,t.w,n.w),this}clampScalar(t,n){return this.x=Re(this.x,t,n),this.y=Re(this.y,t,n),this.z=Re(this.z,t,n),this.w=Re(this.w,t,n),this}clampLength(t,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Re(i,t,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this.w+=(t.w-this.w)*n,this}lerpVectors(t,n,i){return this.x=t.x+(n.x-t.x)*i,this.y=t.y+(n.y-t.y)*i,this.z=t.z+(n.z-t.z)*i,this.w=t.w+(n.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this.z=t[n+2],this.w=t[n+3],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t[n+3]=this.w,t}fromBufferAttribute(t,n){return this.x=t.getX(n),this.y=t.getY(n),this.z=t.getZ(n),this.w=t.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class dN extends ml{constructor(t=1,n=1,i={}){super(),this.isRenderTarget=!0,this.width=t,this.height=n,this.depth=1,this.scissor=new qe(0,0,t,n),this.scissorTest=!1,this.viewport=new qe(0,0,t,n);const a={width:t,height:n,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ps,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const o=new Qn(a,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);o.flipY=!1,o.generateMipmaps=i.generateMipmaps,o.internalFormat=i.internalFormat,this.textures=[];const l=i.count;for(let u=0;u=0?1:-1,w=1-y*y;if(w>Number.EPSILON){const P=Math.sqrt(w),O=Math.atan2(P,y*E);x=Math.sin(x*O)/P,u=Math.sin(u*O)/P}const T=u*E;if(h=h*x+b*T,d=d*x+_*T,p=p*x+S*T,m=m*x+A*T,x===1-u){const P=1/Math.sqrt(h*h+d*d+p*p+m*m);h*=P,d*=P,p*=P,m*=P}}t[n]=h,t[n+1]=d,t[n+2]=p,t[n+3]=m}static multiplyQuaternionsFlat(t,n,i,a,o,l){const u=i[a],h=i[a+1],d=i[a+2],p=i[a+3],m=o[l],b=o[l+1],_=o[l+2],S=o[l+3];return t[n]=u*S+p*m+h*_-d*b,t[n+1]=h*S+p*b+d*m-u*_,t[n+2]=d*S+p*_+u*b-h*m,t[n+3]=p*S-u*m-h*b-d*_,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,n,i,a){return this._x=t,this._y=n,this._z=i,this._w=a,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,n=!0){const i=t._x,a=t._y,o=t._z,l=t._order,u=Math.cos,h=Math.sin,d=u(i/2),p=u(a/2),m=u(o/2),b=h(i/2),_=h(a/2),S=h(o/2);switch(l){case"XYZ":this._x=b*p*m+d*_*S,this._y=d*_*m-b*p*S,this._z=d*p*S+b*_*m,this._w=d*p*m-b*_*S;break;case"YXZ":this._x=b*p*m+d*_*S,this._y=d*_*m-b*p*S,this._z=d*p*S-b*_*m,this._w=d*p*m+b*_*S;break;case"ZXY":this._x=b*p*m-d*_*S,this._y=d*_*m+b*p*S,this._z=d*p*S+b*_*m,this._w=d*p*m-b*_*S;break;case"ZYX":this._x=b*p*m-d*_*S,this._y=d*_*m+b*p*S,this._z=d*p*S-b*_*m,this._w=d*p*m+b*_*S;break;case"YZX":this._x=b*p*m+d*_*S,this._y=d*_*m+b*p*S,this._z=d*p*S-b*_*m,this._w=d*p*m-b*_*S;break;case"XZY":this._x=b*p*m-d*_*S,this._y=d*_*m-b*p*S,this._z=d*p*S+b*_*m,this._w=d*p*m+b*_*S;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+l)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,n){const i=n/2,a=Math.sin(i);return this._x=t.x*a,this._y=t.y*a,this._z=t.z*a,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const n=t.elements,i=n[0],a=n[4],o=n[8],l=n[1],u=n[5],h=n[9],d=n[2],p=n[6],m=n[10],b=i+u+m;if(b>0){const _=.5/Math.sqrt(b+1);this._w=.25/_,this._x=(p-h)*_,this._y=(o-d)*_,this._z=(l-a)*_}else if(i>u&&i>m){const _=2*Math.sqrt(1+i-u-m);this._w=(p-h)/_,this._x=.25*_,this._y=(a+l)/_,this._z=(o+d)/_}else if(u>m){const _=2*Math.sqrt(1+u-i-m);this._w=(o-d)/_,this._x=(a+l)/_,this._y=.25*_,this._z=(h+p)/_}else{const _=2*Math.sqrt(1+m-i-u);this._w=(l-a)/_,this._x=(o+d)/_,this._y=(h+p)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(t,n){let i=t.dot(n)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*n.z-t.z*n.y,this._y=t.z*n.x-t.x*n.z,this._z=t.x*n.y-t.y*n.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Re(this.dot(t),-1,1)))}rotateTowards(t,n){const i=this.angleTo(t);if(i===0)return this;const a=Math.min(1,n/i);return this.slerp(t,a),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,n){const i=t._x,a=t._y,o=t._z,l=t._w,u=n._x,h=n._y,d=n._z,p=n._w;return this._x=i*p+l*u+a*d-o*h,this._y=a*p+l*h+o*u-i*d,this._z=o*p+l*d+i*h-a*u,this._w=l*p-i*u-a*h-o*d,this._onChangeCallback(),this}slerp(t,n){if(n===0)return this;if(n===1)return this.copy(t);const i=this._x,a=this._y,o=this._z,l=this._w;let u=l*t._w+i*t._x+a*t._y+o*t._z;if(u<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,u=-u):this.copy(t),u>=1)return this._w=l,this._x=i,this._y=a,this._z=o,this;const h=1-u*u;if(h<=Number.EPSILON){const _=1-n;return this._w=_*l+n*this._w,this._x=_*i+n*this._x,this._y=_*a+n*this._y,this._z=_*o+n*this._z,this.normalize(),this}const d=Math.sqrt(h),p=Math.atan2(d,u),m=Math.sin((1-n)*p)/d,b=Math.sin(n*p)/d;return this._w=l*m+this._w*b,this._x=i*m+this._x*b,this._y=a*m+this._y*b,this._z=o*m+this._z*b,this._onChangeCallback(),this}slerpQuaternions(t,n,i){return this.copy(t).slerp(n,i)}random(){const t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),i=Math.random(),a=Math.sqrt(1-i),o=Math.sqrt(i);return this.set(a*Math.sin(t),a*Math.cos(t),o*Math.sin(n),o*Math.cos(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,n=0){return this._x=t[n],this._y=t[n+1],this._z=t[n+2],this._w=t[n+3],this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w,t}fromBufferAttribute(t,n){return this._x=t.getX(n),this._y=t.getY(n),this._z=t.getZ(n),this._w=t.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class H{constructor(t=0,n=0,i=0){H.prototype.isVector3=!0,this.x=t,this.y=n,this.z=i}set(t,n,i){return i===void 0&&(i=this.z),this.x=t,this.y=n,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this}applyEuler(t){return this.applyQuaternion(MM.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(MM.setFromAxisAngle(t,n))}applyMatrix3(t){const n=this.x,i=this.y,a=this.z,o=t.elements;return this.x=o[0]*n+o[3]*i+o[6]*a,this.y=o[1]*n+o[4]*i+o[7]*a,this.z=o[2]*n+o[5]*i+o[8]*a,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const n=this.x,i=this.y,a=this.z,o=t.elements,l=1/(o[3]*n+o[7]*i+o[11]*a+o[15]);return this.x=(o[0]*n+o[4]*i+o[8]*a+o[12])*l,this.y=(o[1]*n+o[5]*i+o[9]*a+o[13])*l,this.z=(o[2]*n+o[6]*i+o[10]*a+o[14])*l,this}applyQuaternion(t){const n=this.x,i=this.y,a=this.z,o=t.x,l=t.y,u=t.z,h=t.w,d=2*(l*a-u*i),p=2*(u*n-o*a),m=2*(o*i-l*n);return this.x=n+h*d+l*m-u*p,this.y=i+h*p+u*d-o*m,this.z=a+h*m+o*p-l*d,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const n=this.x,i=this.y,a=this.z,o=t.elements;return this.x=o[0]*n+o[4]*i+o[8]*a,this.y=o[1]*n+o[5]*i+o[9]*a,this.z=o[2]*n+o[6]*i+o[10]*a,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,n){return this.x=Re(this.x,t.x,n.x),this.y=Re(this.y,t.y,n.y),this.z=Re(this.z,t.z,n.z),this}clampScalar(t,n){return this.x=Re(this.x,t,n),this.y=Re(this.y,t,n),this.z=Re(this.z,t,n),this}clampLength(t,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Re(i,t,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this}lerpVectors(t,n,i){return this.x=t.x+(n.x-t.x)*i,this.y=t.y+(n.y-t.y)*i,this.z=t.z+(n.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,n){const i=t.x,a=t.y,o=t.z,l=n.x,u=n.y,h=n.z;return this.x=a*h-o*u,this.y=o*l-i*h,this.z=i*u-a*l,this}projectOnVector(t){const n=t.lengthSq();if(n===0)return this.set(0,0,0);const i=t.dot(this)/n;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return G0.copy(this).projectOnVector(t),this.sub(G0)}reflect(t){return this.sub(G0.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const i=this.dot(t)/n;return Math.acos(Re(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,i=this.y-t.y,a=this.z-t.z;return n*n+i*i+a*a}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,n,i){const a=Math.sin(n)*t;return this.x=a*Math.sin(i),this.y=Math.cos(n)*t,this.z=a*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,n,i){return this.x=t*Math.sin(n),this.y=i,this.z=t*Math.cos(n),this}setFromMatrixPosition(t){const n=t.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(t){const n=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),a=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=i,this.z=a,this}setFromMatrixColumn(t,n){return this.fromArray(t.elements,n*4)}setFromMatrix3Column(t,n){return this.fromArray(t.elements,n*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this.z=t[n+2],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t}fromBufferAttribute(t,n){return this.x=t.getX(n),this.y=t.getY(n),this.z=t.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,n=Math.random()*2-1,i=Math.sqrt(1-n*n);return this.x=i*Math.cos(t),this.y=n,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const G0=new H,MM=new sa;class Qi{constructor(t=new H(1/0,1/0,1/0),n=new H(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=n}set(t,n){return this.min.copy(t),this.max.copy(n),this}setFromArray(t){this.makeEmpty();for(let n=0,i=t.length;n=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,n){return n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Ks),Ks.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let n,i;return t.normal.x>0?(n=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(n=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(n+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(n+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(n+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(n+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),n<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(hf),Ed.subVectors(this.max,hf),tc.subVectors(t.a,hf),ec.subVectors(t.b,hf),nc.subVectors(t.c,hf),Vr.subVectors(ec,tc),Gr.subVectors(nc,ec),Po.subVectors(tc,nc);let n=[0,-Vr.z,Vr.y,0,-Gr.z,Gr.y,0,-Po.z,Po.y,Vr.z,0,-Vr.x,Gr.z,0,-Gr.x,Po.z,0,-Po.x,-Vr.y,Vr.x,0,-Gr.y,Gr.x,0,-Po.y,Po.x,0];return!H0(n,tc,ec,nc,Ed)||(n=[1,0,0,0,1,0,0,0,1],!H0(n,tc,ec,nc,Ed))?!1:(wd.crossVectors(Vr,Gr),n=[wd.x,wd.y,wd.z],H0(n,tc,ec,nc,Ed))}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ks).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ks).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(tr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),tr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),tr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),tr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),tr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),tr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),tr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),tr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(tr),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const tr=[new H,new H,new H,new H,new H,new H,new H,new H],Ks=new H,Td=new Qi,tc=new H,ec=new H,nc=new H,Vr=new H,Gr=new H,Po=new H,hf=new H,Ed=new H,wd=new H,Oo=new H;function H0(e,t,n,i,a){for(let o=0,l=e.length-3;o<=l;o+=3){Oo.fromArray(e,o);const u=a.x*Math.abs(Oo.x)+a.y*Math.abs(Oo.y)+a.z*Math.abs(Oo.z),h=t.dot(Oo),d=n.dot(Oo),p=i.dot(Oo);if(Math.max(-Math.max(h,d,p),Math.min(h,d,p))>u)return!1}return!0}const mN=new Qi,df=new H,j0=new H;class Ra{constructor(t=new H,n=-1){this.isSphere=!0,this.center=t,this.radius=n}set(t,n){return this.center.copy(t),this.radius=n,this}setFromPoints(t,n){const i=this.center;n!==void 0?i.copy(n):mN.setFromPoints(t).getCenter(i);let a=0;for(let o=0,l=t.length;othis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;df.subVectors(t,this.center);const n=df.lengthSq();if(n>this.radius*this.radius){const i=Math.sqrt(n),a=(i-this.radius)*.5;this.center.addScaledVector(df,a/i),this.radius+=a}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(j0.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(df.copy(t.center).add(j0)),this.expandByPoint(df.copy(t.center).sub(j0))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const er=new H,W0=new H,Rd=new H,Hr=new H,X0=new H,Cd=new H,q0=new H;class Kp{constructor(t=new H,n=new H(0,0,-1)){this.origin=t,this.direction=n}set(t,n){return this.origin.copy(t),this.direction.copy(n),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,n){return n.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,er)),this}closestPointToPoint(t,n){n.subVectors(t,this.origin);const i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const n=er.subVectors(t,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(t):(er.copy(this.origin).addScaledVector(this.direction,n),er.distanceToSquared(t))}distanceSqToSegment(t,n,i,a){W0.copy(t).add(n).multiplyScalar(.5),Rd.copy(n).sub(t).normalize(),Hr.copy(this.origin).sub(W0);const o=t.distanceTo(n)*.5,l=-this.direction.dot(Rd),u=Hr.dot(this.direction),h=-Hr.dot(Rd),d=Hr.lengthSq(),p=Math.abs(1-l*l);let m,b,_,S;if(p>0)if(m=l*h-u,b=l*u-h,S=o*p,m>=0)if(b>=-S)if(b<=S){const A=1/p;m*=A,b*=A,_=m*(m+l*b+2*u)+b*(l*m+b+2*h)+d}else b=o,m=Math.max(0,-(l*b+u)),_=-m*m+b*(b+2*h)+d;else b=-o,m=Math.max(0,-(l*b+u)),_=-m*m+b*(b+2*h)+d;else b<=-S?(m=Math.max(0,-(-l*o+u)),b=m>0?-o:Math.min(Math.max(-o,-h),o),_=-m*m+b*(b+2*h)+d):b<=S?(m=0,b=Math.min(Math.max(-o,-h),o),_=b*(b+2*h)+d):(m=Math.max(0,-(l*o+u)),b=m>0?o:Math.min(Math.max(-o,-h),o),_=-m*m+b*(b+2*h)+d);else b=l>0?-o:o,m=Math.max(0,-(l*b+u)),_=-m*m+b*(b+2*h)+d;return i&&i.copy(this.origin).addScaledVector(this.direction,m),a&&a.copy(W0).addScaledVector(Rd,b),_}intersectSphere(t,n){er.subVectors(t.center,this.origin);const i=er.dot(this.direction),a=er.dot(er)-i*i,o=t.radius*t.radius;if(a>o)return null;const l=Math.sqrt(o-a),u=i-l,h=i+l;return h<0?null:u<0?this.at(h,n):this.at(u,n)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const n=t.normal.dot(this.direction);if(n===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/n;return i>=0?i:null}intersectPlane(t,n){const i=this.distanceToPlane(t);return i===null?null:this.at(i,n)}intersectsPlane(t){const n=t.distanceToPoint(this.origin);return n===0||t.normal.dot(this.direction)*n<0}intersectBox(t,n){let i,a,o,l,u,h;const d=1/this.direction.x,p=1/this.direction.y,m=1/this.direction.z,b=this.origin;return d>=0?(i=(t.min.x-b.x)*d,a=(t.max.x-b.x)*d):(i=(t.max.x-b.x)*d,a=(t.min.x-b.x)*d),p>=0?(o=(t.min.y-b.y)*p,l=(t.max.y-b.y)*p):(o=(t.max.y-b.y)*p,l=(t.min.y-b.y)*p),i>l||o>a||((o>i||isNaN(i))&&(i=o),(l=0?(u=(t.min.z-b.z)*m,h=(t.max.z-b.z)*m):(u=(t.max.z-b.z)*m,h=(t.min.z-b.z)*m),i>h||u>a)||((u>i||i!==i)&&(i=u),(h=0?i:a,n)}intersectsBox(t){return this.intersectBox(t,er)!==null}intersectTriangle(t,n,i,a,o){X0.subVectors(n,t),Cd.subVectors(i,t),q0.crossVectors(X0,Cd);let l=this.direction.dot(q0),u;if(l>0){if(a)return null;u=1}else if(l<0)u=-1,l=-l;else return null;Hr.subVectors(this.origin,t);const h=u*this.direction.dot(Cd.crossVectors(Hr,Cd));if(h<0)return null;const d=u*this.direction.dot(X0.cross(Hr));if(d<0||h+d>l)return null;const p=-u*Hr.dot(q0);return p<0?null:this.at(p/l,o)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class _e{constructor(t,n,i,a,o,l,u,h,d,p,m,b,_,S,A,x){_e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,i,a,o,l,u,h,d,p,m,b,_,S,A,x)}set(t,n,i,a,o,l,u,h,d,p,m,b,_,S,A,x){const y=this.elements;return y[0]=t,y[4]=n,y[8]=i,y[12]=a,y[1]=o,y[5]=l,y[9]=u,y[13]=h,y[2]=d,y[6]=p,y[10]=m,y[14]=b,y[3]=_,y[7]=S,y[11]=A,y[15]=x,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 _e().fromArray(this.elements)}copy(t){const n=this.elements,i=t.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this}copyPosition(t){const n=this.elements,i=t.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[14],this}setFromMatrix3(t){const n=t.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(t,n,i){return t.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,n,i){return this.set(t.x,n.x,i.x,0,t.y,n.y,i.y,0,t.z,n.z,i.z,0,0,0,0,1),this}extractRotation(t){const n=this.elements,i=t.elements,a=1/ic.setFromMatrixColumn(t,0).length(),o=1/ic.setFromMatrixColumn(t,1).length(),l=1/ic.setFromMatrixColumn(t,2).length();return n[0]=i[0]*a,n[1]=i[1]*a,n[2]=i[2]*a,n[3]=0,n[4]=i[4]*o,n[5]=i[5]*o,n[6]=i[6]*o,n[7]=0,n[8]=i[8]*l,n[9]=i[9]*l,n[10]=i[10]*l,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(t){const n=this.elements,i=t.x,a=t.y,o=t.z,l=Math.cos(i),u=Math.sin(i),h=Math.cos(a),d=Math.sin(a),p=Math.cos(o),m=Math.sin(o);if(t.order==="XYZ"){const b=l*p,_=l*m,S=u*p,A=u*m;n[0]=h*p,n[4]=-h*m,n[8]=d,n[1]=_+S*d,n[5]=b-A*d,n[9]=-u*h,n[2]=A-b*d,n[6]=S+_*d,n[10]=l*h}else if(t.order==="YXZ"){const b=h*p,_=h*m,S=d*p,A=d*m;n[0]=b+A*u,n[4]=S*u-_,n[8]=l*d,n[1]=l*m,n[5]=l*p,n[9]=-u,n[2]=_*u-S,n[6]=A+b*u,n[10]=l*h}else if(t.order==="ZXY"){const b=h*p,_=h*m,S=d*p,A=d*m;n[0]=b-A*u,n[4]=-l*m,n[8]=S+_*u,n[1]=_+S*u,n[5]=l*p,n[9]=A-b*u,n[2]=-l*d,n[6]=u,n[10]=l*h}else if(t.order==="ZYX"){const b=l*p,_=l*m,S=u*p,A=u*m;n[0]=h*p,n[4]=S*d-_,n[8]=b*d+A,n[1]=h*m,n[5]=A*d+b,n[9]=_*d-S,n[2]=-d,n[6]=u*h,n[10]=l*h}else if(t.order==="YZX"){const b=l*h,_=l*d,S=u*h,A=u*d;n[0]=h*p,n[4]=A-b*m,n[8]=S*m+_,n[1]=m,n[5]=l*p,n[9]=-u*p,n[2]=-d*p,n[6]=_*m+S,n[10]=b-A*m}else if(t.order==="XZY"){const b=l*h,_=l*d,S=u*h,A=u*d;n[0]=h*p,n[4]=-m,n[8]=d*p,n[1]=b*m+A,n[5]=l*p,n[9]=_*m-S,n[2]=S*m-_,n[6]=u*p,n[10]=A*m+b}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(t){return this.compose(gN,t,bN)}lookAt(t,n,i){const a=this.elements;return ls.subVectors(t,n),ls.lengthSq()===0&&(ls.z=1),ls.normalize(),jr.crossVectors(i,ls),jr.lengthSq()===0&&(Math.abs(i.z)===1?ls.x+=1e-4:ls.z+=1e-4,ls.normalize(),jr.crossVectors(i,ls)),jr.normalize(),Dd.crossVectors(ls,jr),a[0]=jr.x,a[4]=Dd.x,a[8]=ls.x,a[1]=jr.y,a[5]=Dd.y,a[9]=ls.y,a[2]=jr.z,a[6]=Dd.z,a[10]=ls.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const i=t.elements,a=n.elements,o=this.elements,l=i[0],u=i[4],h=i[8],d=i[12],p=i[1],m=i[5],b=i[9],_=i[13],S=i[2],A=i[6],x=i[10],y=i[14],E=i[3],w=i[7],T=i[11],P=i[15],O=a[0],U=a[4],I=a[8],C=a[12],R=a[1],F=a[5],Y=a[9],$=a[13],lt=a[2],ut=a[6],k=a[10],Q=a[14],X=a[3],yt=a[7],At=a[11],z=a[15];return o[0]=l*O+u*R+h*lt+d*X,o[4]=l*U+u*F+h*ut+d*yt,o[8]=l*I+u*Y+h*k+d*At,o[12]=l*C+u*$+h*Q+d*z,o[1]=p*O+m*R+b*lt+_*X,o[5]=p*U+m*F+b*ut+_*yt,o[9]=p*I+m*Y+b*k+_*At,o[13]=p*C+m*$+b*Q+_*z,o[2]=S*O+A*R+x*lt+y*X,o[6]=S*U+A*F+x*ut+y*yt,o[10]=S*I+A*Y+x*k+y*At,o[14]=S*C+A*$+x*Q+y*z,o[3]=E*O+w*R+T*lt+P*X,o[7]=E*U+w*F+T*ut+P*yt,o[11]=E*I+w*Y+T*k+P*At,o[15]=E*C+w*$+T*Q+P*z,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[4]*=t,n[8]*=t,n[12]*=t,n[1]*=t,n[5]*=t,n[9]*=t,n[13]*=t,n[2]*=t,n[6]*=t,n[10]*=t,n[14]*=t,n[3]*=t,n[7]*=t,n[11]*=t,n[15]*=t,this}determinant(){const t=this.elements,n=t[0],i=t[4],a=t[8],o=t[12],l=t[1],u=t[5],h=t[9],d=t[13],p=t[2],m=t[6],b=t[10],_=t[14],S=t[3],A=t[7],x=t[11],y=t[15];return S*(+o*h*m-a*d*m-o*u*b+i*d*b+a*u*_-i*h*_)+A*(+n*h*_-n*d*b+o*l*b-a*l*_+a*d*p-o*h*p)+x*(+n*d*m-n*u*_-o*l*m+i*l*_+o*u*p-i*d*p)+y*(-a*u*p-n*h*m+n*u*b+a*l*m-i*l*b+i*h*p)}transpose(){const t=this.elements;let n;return n=t[1],t[1]=t[4],t[4]=n,n=t[2],t[2]=t[8],t[8]=n,n=t[6],t[6]=t[9],t[9]=n,n=t[3],t[3]=t[12],t[12]=n,n=t[7],t[7]=t[13],t[13]=n,n=t[11],t[11]=t[14],t[14]=n,this}setPosition(t,n,i){const a=this.elements;return t.isVector3?(a[12]=t.x,a[13]=t.y,a[14]=t.z):(a[12]=t,a[13]=n,a[14]=i),this}invert(){const t=this.elements,n=t[0],i=t[1],a=t[2],o=t[3],l=t[4],u=t[5],h=t[6],d=t[7],p=t[8],m=t[9],b=t[10],_=t[11],S=t[12],A=t[13],x=t[14],y=t[15],E=m*x*d-A*b*d+A*h*_-u*x*_-m*h*y+u*b*y,w=S*b*d-p*x*d-S*h*_+l*x*_+p*h*y-l*b*y,T=p*A*d-S*m*d+S*u*_-l*A*_-p*u*y+l*m*y,P=S*m*h-p*A*h-S*u*b+l*A*b+p*u*x-l*m*x,O=n*E+i*w+a*T+o*P;if(O===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const U=1/O;return t[0]=E*U,t[1]=(A*b*o-m*x*o-A*a*_+i*x*_+m*a*y-i*b*y)*U,t[2]=(u*x*o-A*h*o+A*a*d-i*x*d-u*a*y+i*h*y)*U,t[3]=(m*h*o-u*b*o-m*a*d+i*b*d+u*a*_-i*h*_)*U,t[4]=w*U,t[5]=(p*x*o-S*b*o+S*a*_-n*x*_-p*a*y+n*b*y)*U,t[6]=(S*h*o-l*x*o-S*a*d+n*x*d+l*a*y-n*h*y)*U,t[7]=(l*b*o-p*h*o+p*a*d-n*b*d-l*a*_+n*h*_)*U,t[8]=T*U,t[9]=(S*m*o-p*A*o-S*i*_+n*A*_+p*i*y-n*m*y)*U,t[10]=(l*A*o-S*u*o+S*i*d-n*A*d-l*i*y+n*u*y)*U,t[11]=(p*u*o-l*m*o-p*i*d+n*m*d+l*i*_-n*u*_)*U,t[12]=P*U,t[13]=(p*A*a-S*m*a+S*i*b-n*A*b-p*i*x+n*m*x)*U,t[14]=(S*u*a-l*A*a-S*i*h+n*A*h+l*i*x-n*u*x)*U,t[15]=(l*m*a-p*u*a+p*i*h-n*m*h-l*i*b+n*u*b)*U,this}scale(t){const n=this.elements,i=t.x,a=t.y,o=t.z;return n[0]*=i,n[4]*=a,n[8]*=o,n[1]*=i,n[5]*=a,n[9]*=o,n[2]*=i,n[6]*=a,n[10]*=o,n[3]*=i,n[7]*=a,n[11]*=o,this}getMaxScaleOnAxis(){const t=this.elements,n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],a=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,i,a))}makeTranslation(t,n,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,n,0,0,1,i,0,0,0,1),this}makeRotationX(t){const n=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this}makeRotationY(t){const n=Math.cos(t),i=Math.sin(t);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this}makeRotationZ(t){const n=Math.cos(t),i=Math.sin(t);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,n){const i=Math.cos(n),a=Math.sin(n),o=1-i,l=t.x,u=t.y,h=t.z,d=o*l,p=o*u;return this.set(d*l+i,d*u-a*h,d*h+a*u,0,d*u+a*h,p*u+i,p*h-a*l,0,d*h-a*u,p*h+a*l,o*h*h+i,0,0,0,0,1),this}makeScale(t,n,i){return this.set(t,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,n,i,a,o,l){return this.set(1,i,o,0,t,1,l,0,n,a,1,0,0,0,0,1),this}compose(t,n,i){const a=this.elements,o=n._x,l=n._y,u=n._z,h=n._w,d=o+o,p=l+l,m=u+u,b=o*d,_=o*p,S=o*m,A=l*p,x=l*m,y=u*m,E=h*d,w=h*p,T=h*m,P=i.x,O=i.y,U=i.z;return a[0]=(1-(A+y))*P,a[1]=(_+T)*P,a[2]=(S-w)*P,a[3]=0,a[4]=(_-T)*O,a[5]=(1-(b+y))*O,a[6]=(x+E)*O,a[7]=0,a[8]=(S+w)*U,a[9]=(x-E)*U,a[10]=(1-(b+A))*U,a[11]=0,a[12]=t.x,a[13]=t.y,a[14]=t.z,a[15]=1,this}decompose(t,n,i){const a=this.elements;let o=ic.set(a[0],a[1],a[2]).length();const l=ic.set(a[4],a[5],a[6]).length(),u=ic.set(a[8],a[9],a[10]).length();this.determinant()<0&&(o=-o),t.x=a[12],t.y=a[13],t.z=a[14],Zs.copy(this);const d=1/o,p=1/l,m=1/u;return Zs.elements[0]*=d,Zs.elements[1]*=d,Zs.elements[2]*=d,Zs.elements[4]*=p,Zs.elements[5]*=p,Zs.elements[6]*=p,Zs.elements[8]*=m,Zs.elements[9]*=m,Zs.elements[10]*=m,n.setFromRotationMatrix(Zs),i.x=o,i.y=l,i.z=u,this}makePerspective(t,n,i,a,o,l,u=ur){const h=this.elements,d=2*o/(n-t),p=2*o/(i-a),m=(n+t)/(n-t),b=(i+a)/(i-a);let _,S;if(u===ur)_=-(l+o)/(l-o),S=-2*l*o/(l-o);else if(u===Cp)_=-l/(l-o),S=-l*o/(l-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+u);return h[0]=d,h[4]=0,h[8]=m,h[12]=0,h[1]=0,h[5]=p,h[9]=b,h[13]=0,h[2]=0,h[6]=0,h[10]=_,h[14]=S,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(t,n,i,a,o,l,u=ur){const h=this.elements,d=1/(n-t),p=1/(i-a),m=1/(l-o),b=(n+t)*d,_=(i+a)*p;let S,A;if(u===ur)S=(l+o)*m,A=-2*m;else if(u===Cp)S=o*m,A=-1*m;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+u);return h[0]=2*d,h[4]=0,h[8]=0,h[12]=-b,h[1]=0,h[5]=2*p,h[9]=0,h[13]=-_,h[2]=0,h[6]=0,h[10]=A,h[14]=-S,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(t){const n=this.elements,i=t.elements;for(let a=0;a<16;a++)if(n[a]!==i[a])return!1;return!0}fromArray(t,n=0){for(let i=0;i<16;i++)this.elements[i]=t[i+n];return this}toArray(t=[],n=0){const i=this.elements;return t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3],t[n+4]=i[4],t[n+5]=i[5],t[n+6]=i[6],t[n+7]=i[7],t[n+8]=i[8],t[n+9]=i[9],t[n+10]=i[10],t[n+11]=i[11],t[n+12]=i[12],t[n+13]=i[13],t[n+14]=i[14],t[n+15]=i[15],t}}const ic=new H,Zs=new _e,gN=new H(0,0,0),bN=new H(1,1,1),jr=new H,Dd=new H,ls=new H,AM=new _e,TM=new sa;class Ta{constructor(t=0,n=0,i=0,a=Ta.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=i,this._order=a}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,n,i,a=this._order){return this._x=t,this._y=n,this._z=i,this._order=a,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,n=this._order,i=!0){const a=t.elements,o=a[0],l=a[4],u=a[8],h=a[1],d=a[5],p=a[9],m=a[2],b=a[6],_=a[10];switch(n){case"XYZ":this._y=Math.asin(Re(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-p,_),this._z=Math.atan2(-l,o)):(this._x=Math.atan2(b,d),this._z=0);break;case"YXZ":this._x=Math.asin(-Re(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(u,_),this._z=Math.atan2(h,d)):(this._y=Math.atan2(-m,o),this._z=0);break;case"ZXY":this._x=Math.asin(Re(b,-1,1)),Math.abs(b)<.9999999?(this._y=Math.atan2(-m,_),this._z=Math.atan2(-l,d)):(this._y=0,this._z=Math.atan2(h,o));break;case"ZYX":this._y=Math.asin(-Re(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(b,_),this._z=Math.atan2(h,o)):(this._x=0,this._z=Math.atan2(-l,d));break;case"YZX":this._z=Math.asin(Re(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-p,d),this._y=Math.atan2(-m,o)):(this._x=0,this._y=Math.atan2(u,_));break;case"XZY":this._z=Math.asin(-Re(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(b,d),this._y=Math.atan2(u,o)):(this._x=Math.atan2(-p,_),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,n,i){return AM.makeRotationFromQuaternion(t),this.setFromRotationMatrix(AM,n,i)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return TM.setFromEuler(this),this.setFromQuaternion(TM,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ta.DEFAULT_ORDER="XYZ";class y3{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let n=0;n1){for(let i=0;i0&&(a.userData=this.userData),a.layers=this.layers.mask,a.matrix=this.matrix.toArray(),a.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(a.matrixAutoUpdate=!1),this.isInstancedMesh&&(a.type="InstancedMesh",a.count=this.count,a.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(a.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(a.type="BatchedMesh",a.perObjectFrustumCulled=this.perObjectFrustumCulled,a.sortObjects=this.sortObjects,a.drawRanges=this._drawRanges,a.reservedRanges=this._reservedRanges,a.visibility=this._visibility,a.active=this._active,a.bounds=this._bounds.map(u=>({boxInitialized:u.boxInitialized,boxMin:u.box.min.toArray(),boxMax:u.box.max.toArray(),sphereInitialized:u.sphereInitialized,sphereRadius:u.sphere.radius,sphereCenter:u.sphere.center.toArray()})),a.maxInstanceCount=this._maxInstanceCount,a.maxVertexCount=this._maxVertexCount,a.maxIndexCount=this._maxIndexCount,a.geometryInitialized=this._geometryInitialized,a.geometryCount=this._geometryCount,a.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(a.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(a.boundingSphere={center:a.boundingSphere.center.toArray(),radius:a.boundingSphere.radius}),this.boundingBox!==null&&(a.boundingBox={min:a.boundingBox.min.toArray(),max:a.boundingBox.max.toArray()}));function o(u,h){return u[h.uuid]===void 0&&(u[h.uuid]=h.toJSON(t)),h.uuid}if(this.isScene)this.background&&(this.background.isColor?a.background=this.background.toJSON():this.background.isTexture&&(a.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(a.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){a.geometry=o(t.geometries,this.geometry);const u=this.geometry.parameters;if(u!==void 0&&u.shapes!==void 0){const h=u.shapes;if(Array.isArray(h))for(let d=0,p=h.length;d0){a.children=[];for(let u=0;u0){a.animations=[];for(let u=0;u0&&(i.geometries=u),h.length>0&&(i.materials=h),d.length>0&&(i.textures=d),p.length>0&&(i.images=p),m.length>0&&(i.shapes=m),b.length>0&&(i.skeletons=b),_.length>0&&(i.animations=_),S.length>0&&(i.nodes=S)}return i.object=a,i;function l(u){const h=[];for(const d in u){const p=u[d];delete p.metadata,h.push(p)}return h}}clone(t){return new this.constructor().copy(this,t)}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i0?a.multiplyScalar(1/Math.sqrt(o)):a.set(0,0,0)}static getBarycoord(t,n,i,a,o){Qs.subVectors(a,n),ir.subVectors(i,n),K0.subVectors(t,n);const l=Qs.dot(Qs),u=Qs.dot(ir),h=Qs.dot(K0),d=ir.dot(ir),p=ir.dot(K0),m=l*d-u*u;if(m===0)return o.set(0,0,0),null;const b=1/m,_=(d*h-u*p)*b,S=(l*p-u*h)*b;return o.set(1-_-S,S,_)}static containsPoint(t,n,i,a){return this.getBarycoord(t,n,i,a,sr)===null?!1:sr.x>=0&&sr.y>=0&&sr.x+sr.y<=1}static getInterpolation(t,n,i,a,o,l,u,h){return this.getBarycoord(t,n,i,a,sr)===null?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(o,sr.x),h.addScaledVector(l,sr.y),h.addScaledVector(u,sr.z),h)}static getInterpolatedAttribute(t,n,i,a,o,l){return $0.setScalar(0),tb.setScalar(0),eb.setScalar(0),$0.fromBufferAttribute(t,n),tb.fromBufferAttribute(t,i),eb.fromBufferAttribute(t,a),l.setScalar(0),l.addScaledVector($0,o.x),l.addScaledVector(tb,o.y),l.addScaledVector(eb,o.z),l}static isFrontFacing(t,n,i,a){return Qs.subVectors(i,n),ir.subVectors(t,n),Qs.cross(ir).dot(a)<0}set(t,n,i){return this.a.copy(t),this.b.copy(n),this.c.copy(i),this}setFromPointsAndIndices(t,n,i,a){return this.a.copy(t[n]),this.b.copy(t[i]),this.c.copy(t[a]),this}setFromAttributeAndIndices(t,n,i,a){return this.a.fromBufferAttribute(t,n),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,a),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Qs.subVectors(this.c,this.b),ir.subVectors(this.a,this.b),Qs.cross(ir).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return ea.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return ea.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,i,a,o){return ea.getInterpolation(t,this.a,this.b,this.c,n,i,a,o)}containsPoint(t){return ea.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return ea.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,n){const i=this.a,a=this.b,o=this.c;let l,u;rc.subVectors(a,i),oc.subVectors(o,i),Z0.subVectors(t,i);const h=rc.dot(Z0),d=oc.dot(Z0);if(h<=0&&d<=0)return n.copy(i);Q0.subVectors(t,a);const p=rc.dot(Q0),m=oc.dot(Q0);if(p>=0&&m<=p)return n.copy(a);const b=h*m-p*d;if(b<=0&&h>=0&&p<=0)return l=h/(h-p),n.copy(i).addScaledVector(rc,l);J0.subVectors(t,o);const _=rc.dot(J0),S=oc.dot(J0);if(S>=0&&_<=S)return n.copy(o);const A=_*d-h*S;if(A<=0&&d>=0&&S<=0)return u=d/(d-S),n.copy(i).addScaledVector(oc,u);const x=p*S-_*m;if(x<=0&&m-p>=0&&_-S>=0)return LM.subVectors(o,a),u=(m-p)/(m-p+(_-S)),n.copy(a).addScaledVector(LM,u);const y=1/(x+A+b);return l=A*y,u=b*y,n.copy(i).addScaledVector(rc,l).addScaledVector(oc,u)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const x3={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},Wr={h:0,s:0,l:0},Nd={h:0,s:0,l:0};function nb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}class de{constructor(t,n,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,n,i)}set(t,n,i){if(n===void 0&&i===void 0){const a=t;a&&a.isColor?this.copy(a):typeof a=="number"?this.setHex(a):typeof a=="string"&&this.setStyle(a)}else this.setRGB(t,n,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,n=ci){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Ie.toWorkingColorSpace(this,n),this}setRGB(t,n,i,a=Ie.workingColorSpace){return this.r=t,this.g=n,this.b=i,Ie.toWorkingColorSpace(this,a),this}setHSL(t,n,i,a=Ie.workingColorSpace){if(t=F1(t,1),n=Re(n,0,1),i=Re(i,0,1),n===0)this.r=this.g=this.b=i;else{const o=i<=.5?i*(1+n):i+n-i*n,l=2*i-o;this.r=nb(l,o,t+1/3),this.g=nb(l,o,t),this.b=nb(l,o,t-1/3)}return Ie.toWorkingColorSpace(this,a),this}setStyle(t,n=ci){function i(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let a;if(a=/^(\w+)\(([^\)]*)\)/.exec(t)){let o;const l=a[1],u=a[2];switch(l){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,n);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,n);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(a=/^\#([A-Fa-f\d]+)$/.exec(t)){const o=a[1],l=o.length;if(l===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,n);if(l===6)return this.setHex(parseInt(o,16),n);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,n);return this}setColorName(t,n=ci){const i=x3[t.toLowerCase()];return i!==void 0?this.setHex(i,n):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=fr(t.r),this.g=fr(t.g),this.b=fr(t.b),this}copyLinearToSRGB(t){return this.r=Ec(t.r),this.g=Ec(t.g),this.b=Ec(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ci){return Ie.fromWorkingColorSpace(Si.copy(this),t),Math.round(Re(Si.r*255,0,255))*65536+Math.round(Re(Si.g*255,0,255))*256+Math.round(Re(Si.b*255,0,255))}getHexString(t=ci){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,n=Ie.workingColorSpace){Ie.fromWorkingColorSpace(Si.copy(this),n);const i=Si.r,a=Si.g,o=Si.b,l=Math.max(i,a,o),u=Math.min(i,a,o);let h,d;const p=(u+l)/2;if(u===l)h=0,d=0;else{const m=l-u;switch(d=p<=.5?m/(l+u):m/(2-l-u),l){case i:h=(a-o)/m+(a0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const n in t){const i=t[n];if(i===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const a=this[n];if(a===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}a&&a.isColor?a.set(i):a&&a.isVector3&&i&&i.isVector3?a.copy(i):this[n]=i}}toJSON(t){const n=t===void 0||typeof t=="string";n&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Ac&&(i.blending=this.blending),this.side!==hr&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Yb&&(i.blendSrc=this.blendSrc),this.blendDst!==Kb&&(i.blendDst=this.blendDst),this.blendEquation!==Yo&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Dc&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==bM&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Jl&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Jl&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Jl&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function a(o){const l=[];for(const u in o){const h=o[u];delete h.metadata,l.push(h)}return l}if(n){const o=a(t.textures),l=a(t.images);o.length>0&&(i.textures=o),l.length>0&&(i.images=l)}return i}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const n=t.clippingPlanes;let i=null;if(n!==null){const a=n.length;i=new Array(a);for(let o=0;o!==a;++o)i[o]=n[o].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Ni extends Sa{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new de(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 Ta,this.combine=i3,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Vn=new H,Ud=new Ae;let MN=0;class Fi{constructor(t,n,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:MN++}),this.name="",this.array=t,this.itemSize=n,this.count=t!==void 0?t.length/n:0,this.normalized=i,this.usage=Nv,this.updateRanges=[],this.gpuType=na,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,n){this.updateRanges.push({start:t,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,n,i){t*=this.itemSize,i*=n.itemSize;for(let a=0,o=this.itemSize;an.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Qi);const t=this.attributes.position,n=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new H(-1/0,-1/0,-1/0),new H(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),n)for(let i=0,a=n.length;i0&&(t.userData=this.userData),this.parameters!==void 0){const h=this.parameters;for(const d in h)h[d]!==void 0&&(t[d]=h[d]);return t}t.data={attributes:{}};const n=this.index;n!==null&&(t.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const i=this.attributes;for(const h in i){const d=i[h];t.data.attributes[h]=d.toJSON(t.data)}const a={};let o=!1;for(const h in this.morphAttributes){const d=this.morphAttributes[h],p=[];for(let m=0,b=d.length;m0&&(a[h]=p,o=!0)}o&&(t.data.morphAttributes=a,t.data.morphTargetsRelative=this.morphTargetsRelative);const l=this.groups;l.length>0&&(t.data.groups=JSON.parse(JSON.stringify(l)));const u=this.boundingSphere;return u!==null&&(t.data.boundingSphere={center:u.center.toArray(),radius:u.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone(n));const a=t.attributes;for(const d in a){const p=a[d];this.setAttribute(d,p.clone(n))}const o=t.morphAttributes;for(const d in o){const p=[],m=o[d];for(let b=0,_=m.length;b<_;b++)p.push(m[b].clone(n));this.morphAttributes[d]=p}this.morphTargetsRelative=t.morphTargetsRelative;const l=t.groups;for(let d=0,p=l.length;d0){const a=n[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,l=a.length;o(t.far-t.near)**2))&&(NM.copy(o).invert(),Io.copy(t.ray).applyMatrix4(NM),!(i.boundingBox!==null&&Io.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,n,Io)))}_computeIntersections(t,n,i){let a;const o=this.geometry,l=this.material,u=o.index,h=o.attributes.position,d=o.attributes.uv,p=o.attributes.uv1,m=o.attributes.normal,b=o.groups,_=o.drawRange;if(u!==null)if(Array.isArray(l))for(let S=0,A=b.length;Sn.far?null:{distance:d,point:kd.clone(),object:e}}function zd(e,t,n,i,a,o,l,u,h,d){e.getVertexPosition(u,Od),e.getVertexPosition(h,Id),e.getVertexPosition(d,Fd);const p=TN(e,t,n,i,Od,Id,Fd,PM);if(p){const m=new H;ea.getBarycoord(PM,Od,Id,Fd,m),a&&(p.uv=ea.getInterpolatedAttribute(a,u,h,d,m,new Ae)),o&&(p.uv1=ea.getInterpolatedAttribute(o,u,h,d,m,new Ae)),l&&(p.normal=ea.getInterpolatedAttribute(l,u,h,d,m,new H),p.normal.dot(i.direction)>0&&p.normal.multiplyScalar(-1));const b={a:u,b:h,c:d,normal:new H,materialIndex:0};ea.getNormal(Od,Id,Fd,b.normal),p.face=b,p.barycoord=m}return p}class fl extends $i{constructor(t=1,n=1,i=1,a=1,o=1,l=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:n,depth:i,widthSegments:a,heightSegments:o,depthSegments:l};const u=this;a=Math.floor(a),o=Math.floor(o),l=Math.floor(l);const h=[],d=[],p=[],m=[];let b=0,_=0;S("z","y","x",-1,-1,i,n,t,l,o,0),S("z","y","x",1,-1,i,n,-t,l,o,1),S("x","z","y",1,1,t,i,n,a,l,2),S("x","z","y",1,-1,t,i,-n,a,l,3),S("x","y","z",1,-1,t,n,i,a,o,4),S("x","y","z",-1,-1,t,n,-i,a,o,5),this.setIndex(h),this.setAttribute("position",new Wn(d,3)),this.setAttribute("normal",new Wn(p,3)),this.setAttribute("uv",new Wn(m,2));function S(A,x,y,E,w,T,P,O,U,I,C){const R=T/U,F=P/I,Y=T/2,$=P/2,lt=O/2,ut=U+1,k=I+1;let Q=0,X=0;const yt=new H;for(let At=0;At0?1:-1,p.push(yt.x,yt.y,yt.z),m.push(it/U),m.push(1-At/I),Q+=1}}for(let At=0;At0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const i={};for(const a in this.extensions)this.extensions[a]===!0&&(i[a]=!0);return Object.keys(i).length>0&&(n.extensions=i),n}}class T3 extends Tn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new _e,this.projectionMatrix=new _e,this.projectionMatrixInverse=new _e,this.coordinateSystem=ur}copy(t,n){return super.copy(t,n),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Xr=new H,OM=new Ae,IM=new Ae;class Ui extends T3{constructor(t=50,n=1,i=.1,a=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=a,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,n){return super.copy(t,n),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const n=.5*this.getFilmHeight()/t;this.fov=Ic*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Nf*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Ic*2*Math.atan(Math.tan(Nf*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,n,i){Xr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Xr.x,Xr.y).multiplyScalar(-t/Xr.z),Xr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Xr.x,Xr.y).multiplyScalar(-t/Xr.z)}getViewSize(t,n){return this.getViewBounds(t,OM,IM),n.subVectors(IM,OM)}setViewOffset(t,n,i,a,o,l){this.aspect=t/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=a,this.view.width=o,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let n=t*Math.tan(Nf*.5*this.fov)/this.zoom,i=2*n,a=this.aspect*i,o=-.5*a;const l=this.view;if(this.view!==null&&this.view.enabled){const h=l.fullWidth,d=l.fullHeight;o+=l.offsetX*a/h,n-=l.offsetY*i/d,a*=l.width/h,i*=l.height/d}const u=this.filmOffset;u!==0&&(o+=t*u/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+a,n,n-i,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const n=super.toJSON(t);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const cc=-90,uc=1;class DN extends Tn{constructor(t,n,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const a=new Ui(cc,uc,t,n);a.layers=this.layers,this.add(a);const o=new Ui(cc,uc,t,n);o.layers=this.layers,this.add(o);const l=new Ui(cc,uc,t,n);l.layers=this.layers,this.add(l);const u=new Ui(cc,uc,t,n);u.layers=this.layers,this.add(u);const h=new Ui(cc,uc,t,n);h.layers=this.layers,this.add(h);const d=new Ui(cc,uc,t,n);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const t=this.coordinateSystem,n=this.children.concat(),[i,a,o,l,u,h]=n;for(const d of n)this.remove(d);if(t===ur)i.up.set(0,1,0),i.lookAt(1,0,0),a.up.set(0,1,0),a.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),l.up.set(0,0,1),l.lookAt(0,-1,0),u.up.set(0,1,0),u.lookAt(0,0,1),h.up.set(0,1,0),h.lookAt(0,0,-1);else if(t===Cp)i.up.set(0,-1,0),i.lookAt(-1,0,0),a.up.set(0,-1,0),a.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),l.up.set(0,0,-1),l.lookAt(0,-1,0),u.up.set(0,-1,0),u.lookAt(0,0,1),h.up.set(0,-1,0),h.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const d of n)this.add(d),d.updateMatrixWorld()}update(t,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:a}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[o,l,u,h,d,p]=this.children,m=t.getRenderTarget(),b=t.getActiveCubeFace(),_=t.getActiveMipmapLevel(),S=t.xr.enabled;t.xr.enabled=!1;const A=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,a),t.render(n,o),t.setRenderTarget(i,1,a),t.render(n,l),t.setRenderTarget(i,2,a),t.render(n,u),t.setRenderTarget(i,3,a),t.render(n,h),t.setRenderTarget(i,4,a),t.render(n,d),i.texture.generateMipmaps=A,t.setRenderTarget(i,5,a),t.render(n,p),t.setRenderTarget(m,b,_),t.xr.enabled=S,i.texture.needsPMREMUpdate=!0}}class E3 extends Qn{constructor(t,n,i,a,o,l,u,h,d,p){t=t!==void 0?t:[],n=n!==void 0?n:Lc,super(t,n,i,a,o,l,u,h,d,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class LN extends ul{constructor(t=1,n={}){super(t,t,n),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},a=[i,i,i,i,i,i];this.texture=new E3(a,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:ps}fromEquirectangularTexture(t,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},a=new fl(5,5,5),o=new oo({name:"CubemapFromEquirect",uniforms:Fc(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ji,blending:so});o.uniforms.tEquirect.value=n;const l=new Ye(a,o),u=n.minFilter;return n.minFilter===cr&&(n.minFilter=ps),new DN(1,10,this).update(t,l),n.minFilter=u,l.geometry.dispose(),l.material.dispose(),this}clear(t,n,i,a){const o=t.getRenderTarget();for(let l=0;l<6;l++)t.setRenderTarget(this,l),t.clear(n,i,a);t.setRenderTarget(o)}}class Zi extends Tn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const NN={type:"move"};class ab{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Zi,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 Zi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new H,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new H),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Zi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new H,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new H),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const n=this._hand;if(n)for(const i of t.hand.values())this._getHandJoint(n,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,n,i){let a=null,o=null,l=null;const u=this._targetRay,h=this._grip,d=this._hand;if(t&&n.session.visibilityState!=="visible-blurred"){if(d&&t.hand){l=!0;for(const A of t.hand.values()){const x=n.getJointPose(A,i),y=this._getHandJoint(d,A);x!==null&&(y.matrix.fromArray(x.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=x.radius),y.visible=x!==null}const p=d.joints["index-finger-tip"],m=d.joints["thumb-tip"],b=p.position.distanceTo(m.position),_=.02,S=.005;d.inputState.pinching&&b>_+S?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!d.inputState.pinching&&b<=_-S&&(d.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else h!==null&&t.gripSpace&&(o=n.getPose(t.gripSpace,i),o!==null&&(h.matrix.fromArray(o.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,o.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(o.linearVelocity)):h.hasLinearVelocity=!1,o.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(o.angularVelocity)):h.hasAngularVelocity=!1));u!==null&&(a=n.getPose(t.targetRaySpace,i),a===null&&o!==null&&(a=o),a!==null&&(u.matrix.fromArray(a.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,a.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(a.linearVelocity)):u.hasLinearVelocity=!1,a.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(a.angularVelocity)):u.hasAngularVelocity=!1,this.dispatchEvent(NN)))}return u!==null&&(u.visible=a!==null),h!==null&&(h.visible=o!==null),d!==null&&(d.visible=l!==null),this}_getHandJoint(t,n){if(t.joints[n.jointName]===void 0){const i=new Zi;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[n.jointName]=i,t.add(i)}return t.joints[n.jointName]}}class UN extends Tn{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 Ta,this.environmentIntensity=1,this.environmentRotation=new Ta,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,n){return super.copy(t,n),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const n=super.toJSON(t);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}}class PN{constructor(t,n){this.isInterleavedBuffer=!0,this.array=t,this.stride=n,this.count=t!==void 0?t.length/n:0,this.usage=Nv,this.updateRanges=[],this.version=0,this.uuid=ia()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,n){this.updateRanges.push({start:t,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,n,i){t*=this.stride,i*=n.stride;for(let a=0,o=this.stride;a1?null:n.copy(t.start).addScaledVector(i,o)}intersectsLine(t){const n=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return n<0&&i>0||i<0&&n>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,n){const i=n||zN.getNormalMatrix(t),a=this.coplanarPoint(lb).applyMatrix4(t),o=this.normal.applyMatrix3(i).normalize();return this.constant=-a.dot(o),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Fo=new Ra,Hd=new H;class V1{constructor(t=new Wo,n=new Wo,i=new Wo,a=new Wo,o=new Wo,l=new Wo){this.planes=[t,n,i,a,o,l]}set(t,n,i,a,o,l){const u=this.planes;return u[0].copy(t),u[1].copy(n),u[2].copy(i),u[3].copy(a),u[4].copy(o),u[5].copy(l),this}copy(t){const n=this.planes;for(let i=0;i<6;i++)n[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,n=ur){const i=this.planes,a=t.elements,o=a[0],l=a[1],u=a[2],h=a[3],d=a[4],p=a[5],m=a[6],b=a[7],_=a[8],S=a[9],A=a[10],x=a[11],y=a[12],E=a[13],w=a[14],T=a[15];if(i[0].setComponents(h-o,b-d,x-_,T-y).normalize(),i[1].setComponents(h+o,b+d,x+_,T+y).normalize(),i[2].setComponents(h+l,b+p,x+S,T+E).normalize(),i[3].setComponents(h-l,b-p,x-S,T-E).normalize(),i[4].setComponents(h-u,b-m,x-A,T-w).normalize(),n===ur)i[5].setComponents(h+u,b+m,x+A,T+w).normalize();else if(n===Cp)i[5].setComponents(u,m,A,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Fo.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const n=t.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Fo.copy(n.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Fo)}intersectsSprite(t){return Fo.center.set(0,0,0),Fo.radius=.7071067811865476,Fo.applyMatrix4(t.matrixWorld),this.intersectsSphere(Fo)}intersectsSphere(t){const n=this.planes,i=t.center,a=-t.radius;for(let o=0;o<6;o++)if(n[o].distanceToPoint(i)0?t.max.x:t.min.x,Hd.y=a.normal.y>0?t.max.y:t.min.y,Hd.z=a.normal.z>0?t.max.z:t.min.z,a.distanceToPoint(Hd)<0)return!1}return!0}containsPoint(t){const n=this.planes;for(let i=0;i<6;i++)if(n[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class G1 extends Sa{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new de(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Dp=new H,Lp=new H,WM=new _e,vf=new Kp,jd=new Ra,cb=new H,XM=new H;class H1 extends Tn{constructor(t=new $i,n=new G1){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,n){return super.copy(t,n),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const n=t.attributes.position,i=[0];for(let a=1,o=n.count;a0){const a=n[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,l=a.length;oi)return;cb.applyMatrix4(e.matrixWorld);const d=t.ray.origin.distanceTo(cb);if(!(dt.far))return{distance:d,point:XM.clone().applyMatrix4(e.matrixWorld),index:l,face:null,faceIndex:null,barycoord:null,object:e}}const qM=new H,YM=new H;class D3 extends H1{constructor(t,n){super(t,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const n=t.attributes.position,i=[];for(let a=0,o=n.count;a0){const a=n[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,l=a.length;oa.far)return;o.push({distance:d,distanceToRay:Math.sqrt(u),point:h,index:t,face:null,faceIndex:null,barycoord:null,object:l})}}class QM extends Qn{constructor(t,n,i,a,o,l,u,h,d){super(t,n,i,a,o,l,u,h,d),this.isCanvasTexture=!0,this.needsUpdate=!0}}class N3 extends Qn{constructor(t,n,i,a,o,l,u,h,d,p=Tc){if(p!==Tc&&p!==Oc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&p===Tc&&(i=cl),i===void 0&&p===Oc&&(i=Pc),super(null,a,o,l,u,h,p,i,d),this.isDepthTexture=!0,this.image={width:t,height:n},this.magFilter=u!==void 0?u:Ii,this.minFilter=h!==void 0?h:Ii,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new B1(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const n=super.toJSON(t);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}class Qo extends $i{constructor(t=1,n=1,i=1,a=32,o=1,l=!1,u=0,h=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:n,height:i,radialSegments:a,heightSegments:o,openEnded:l,thetaStart:u,thetaLength:h};const d=this;a=Math.floor(a),o=Math.floor(o);const p=[],m=[],b=[],_=[];let S=0;const A=[],x=i/2;let y=0;E(),l===!1&&(t>0&&w(!0),n>0&&w(!1)),this.setIndex(p),this.setAttribute("position",new Wn(m,3)),this.setAttribute("normal",new Wn(b,3)),this.setAttribute("uv",new Wn(_,2));function E(){const T=new H,P=new H;let O=0;const U=(n-t)/i;for(let I=0;I<=o;I++){const C=[],R=I/o,F=R*(n-t)+t;for(let Y=0;Y<=a;Y++){const $=Y/a,lt=$*h+u,ut=Math.sin(lt),k=Math.cos(lt);P.x=F*ut,P.y=-R*i+x,P.z=F*k,m.push(P.x,P.y,P.z),T.set(ut,U,k).normalize(),b.push(T.x,T.y,T.z),_.push($,1-R),C.push(S++)}A.push(C)}for(let I=0;I0||C!==0)&&(p.push(R,F,$),O+=3),(n>0||C!==o-1)&&(p.push(F,Y,$),O+=3)}d.addGroup(y,O,0),y+=O}function w(T){const P=S,O=new Ae,U=new H;let I=0;const C=T===!0?t:n,R=T===!0?1:-1;for(let Y=1;Y<=a;Y++)m.push(0,x*R,0),b.push(0,R,0),_.push(.5,.5),S++;const F=S;for(let Y=0;Y<=a;Y++){const lt=Y/a*h+u,ut=Math.cos(lt),k=Math.sin(lt);U.x=C*k,U.y=x*R,U.z=C*ut,m.push(U.x,U.y,U.z),b.push(0,R,0),O.x=ut*.5+.5,O.y=k*.5*R+.5,_.push(O.x,O.y),S++}for(let Y=0;Y.9&&U<.1&&(w<.2&&(l[E+0]+=1),T<.2&&(l[E+2]+=1),P<.2&&(l[E+4]+=1))}}function b(E){o.push(E.x,E.y,E.z)}function _(E,w){const T=E*3;w.x=t[T+0],w.y=t[T+1],w.z=t[T+2]}function S(){const E=new H,w=new H,T=new H,P=new H,O=new Ae,U=new Ae,I=new Ae;for(let C=0,R=0;C0)&&_.push(w,T,O),(y!==i-1||h0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class HN extends Sa{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=U5,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class jN extends Sa{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Yd(e,t,n){return!e||!n&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function WN(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function XN(e){function t(a,o){return e[a]-e[o]}const n=e.length,i=new Array(n);for(let a=0;a!==n;++a)i[a]=a;return i.sort(t),i}function JM(e,t,n){const i=e.length,a=new e.constructor(i);for(let o=0,l=0;l!==i;++o){const u=n[o]*t;for(let h=0;h!==t;++h)a[l++]=e[u+h]}return a}function U3(e,t,n,i){let a=1,o=e[0];for(;o!==void 0&&o[i]===void 0;)o=e[a++];if(o===void 0)return;let l=o[i];if(l!==void 0)if(Array.isArray(l))do l=o[i],l!==void 0&&(t.push(o.time),n.push(...l)),o=e[a++];while(o!==void 0);else if(l.toArray!==void 0)do l=o[i],l!==void 0&&(t.push(o.time),l.toArray(n,n.length)),o=e[a++];while(o!==void 0);else do l=o[i],l!==void 0&&(t.push(o.time),n.push(l)),o=e[a++];while(o!==void 0)}class nh{constructor(t,n,i,a){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=a!==void 0?a:new n.constructor(i),this.sampleValues=n,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const n=this.parameterPositions;let i=this._cachedIndex,a=n[i],o=n[i-1];t:{e:{let l;n:{i:if(!(t=o)){const u=n[1];t=o)break e}l=i,i=0;break n}break t}for(;i>>1;tn;)--l;if(++l,o!==0||l!==a){o>=l&&(l=Math.max(l,1),o=l-1);const u=this.getValueSize();this.times=i.slice(o,l),this.values=this.values.slice(o*u,l*u)}return this}validate(){let t=!0;const n=this.getValueSize();n-Math.floor(n)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,a=this.values,o=i.length;o===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let l=null;for(let u=0;u!==o;u++){const h=i[u];if(typeof h=="number"&&isNaN(h)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,u,h),t=!1;break}if(l!==null&&l>h){console.error("THREE.KeyframeTrack: Out of order keys.",this,u,h,l),t=!1;break}l=h}if(a!==void 0&&WN(a))for(let u=0,h=a.length;u!==h;++u){const d=a[u];if(isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,u,d),t=!1;break}}return t}optimize(){const t=this.times.slice(),n=this.values.slice(),i=this.getValueSize(),a=this.getInterpolation()===k0,o=t.length-1;let l=1;for(let u=1;u0){t[l]=t[o];for(let u=o*i,h=l*i,d=0;d!==i;++d)n[h+d]=n[u+d];++l}return l!==t.length?(this.times=t.slice(0,l),this.values=n.slice(0,l*i)):(this.times=t,this.values=n),this}clone(){const t=this.times.slice(),n=this.values.slice(),i=this.constructor,a=new i(this.name,t,n);return a.createInterpolant=this.createInterpolant,a}}Ca.prototype.TimeBufferType=Float32Array;Ca.prototype.ValueBufferType=Float32Array;Ca.prototype.DefaultInterpolation=jf;class tu extends Ca{constructor(t,n,i){super(t,n,i)}}tu.prototype.ValueTypeName="bool";tu.prototype.ValueBufferType=Array;tu.prototype.DefaultInterpolation=Hf;tu.prototype.InterpolantFactoryMethodLinear=void 0;tu.prototype.InterpolantFactoryMethodSmooth=void 0;class O3 extends Ca{}O3.prototype.ValueTypeName="color";class Bc extends Ca{}Bc.prototype.ValueTypeName="number";class KN extends nh{constructor(t,n,i,a){super(t,n,i,a)}interpolate_(t,n,i,a){const o=this.resultBuffer,l=this.sampleValues,u=this.valueSize,h=(i-n)/(a-n);let d=t*u;for(let p=d+u;d!==p;d+=4)sa.slerpFlat(o,0,l,d-u,l,d,h);return o}}class kc extends Ca{InterpolantFactoryMethodLinear(t){return new KN(this.times,this.values,this.getValueSize(),t)}}kc.prototype.ValueTypeName="quaternion";kc.prototype.InterpolantFactoryMethodSmooth=void 0;class eu extends Ca{constructor(t,n,i){super(t,n,i)}}eu.prototype.ValueTypeName="string";eu.prototype.ValueBufferType=Array;eu.prototype.DefaultInterpolation=Hf;eu.prototype.InterpolantFactoryMethodLinear=void 0;eu.prototype.InterpolantFactoryMethodSmooth=void 0;class zc extends Ca{}zc.prototype.ValueTypeName="vector";class Ov{constructor(t="",n=-1,i=[],a=I1){this.name=t,this.tracks=i,this.duration=n,this.blendMode=a,this.uuid=ia(),this.duration<0&&this.resetDuration()}static parse(t){const n=[],i=t.tracks,a=1/(t.fps||1);for(let l=0,u=i.length;l!==u;++l)n.push(QN(i[l]).scale(a));const o=new this(t.name,t.duration,n,t.blendMode);return o.uuid=t.uuid,o}static toJSON(t){const n=[],i=t.tracks,a={name:t.name,duration:t.duration,tracks:n,uuid:t.uuid,blendMode:t.blendMode};for(let o=0,l=i.length;o!==l;++o)n.push(Ca.toJSON(i[o]));return a}static CreateFromMorphTargetSequence(t,n,i,a){const o=n.length,l=[];for(let u=0;u1){const m=p[1];let b=a[m];b||(a[m]=b=[]),b.push(d)}}const l=[];for(const u in a)l.push(this.CreateFromMorphTargetSequence(u,a[u],n,i));return l}static parseAnimation(t,n){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(m,b,_,S,A){if(_.length!==0){const x=[],y=[];U3(_,x,y,S),x.length!==0&&A.push(new m(b,x,y))}},a=[],o=t.name||"default",l=t.fps||30,u=t.blendMode;let h=t.length||-1;const d=t.hierarchy||[];for(let m=0;m{n&&n(o),this.manager.itemEnd(t)},0),o;if(ar[t]!==void 0){ar[t].push({onLoad:n,onProgress:i,onError:a});return}ar[t]=[],ar[t].push({onLoad:n,onProgress:i,onError:a});const l=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),u=this.mimeType,h=this.responseType;fetch(l).then(d=>{if(d.status===200||d.status===0){if(d.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||d.body===void 0||d.body.getReader===void 0)return d;const p=ar[t],m=d.body.getReader(),b=d.headers.get("X-File-Size")||d.headers.get("Content-Length"),_=b?parseInt(b):0,S=_!==0;let A=0;const x=new ReadableStream({start(y){E();function E(){m.read().then(({done:w,value:T})=>{if(w)y.close();else{A+=T.byteLength;const P=new ProgressEvent("progress",{lengthComputable:S,loaded:A,total:_});for(let O=0,U=p.length;O{y.error(w)})}}});return new Response(x)}else throw new tU(`fetch for "${d.url}" responded with ${d.status}: ${d.statusText}`,d)}).then(d=>{switch(h){case"arraybuffer":return d.arrayBuffer();case"blob":return d.blob();case"document":return d.text().then(p=>new DOMParser().parseFromString(p,u));case"json":return d.json();default:if(u===void 0)return d.text();{const m=/charset="?([^;"\s]*)"?/i.exec(u),b=m&&m[1]?m[1].toLowerCase():void 0,_=new TextDecoder(b);return d.arrayBuffer().then(S=>_.decode(S))}}}).then(d=>{no.add(t,d);const p=ar[t];delete ar[t];for(let m=0,b=p.length;m{const p=ar[t];if(p===void 0)throw this.manager.itemError(t),d;delete ar[t];for(let m=0,b=p.length;m{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class eU extends nu{constructor(t){super(t)}load(t,n,i,a){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const o=this,l=no.get(t);if(l!==void 0)return o.manager.itemStart(t),setTimeout(function(){n&&n(l),o.manager.itemEnd(t)},0),l;const u=Wf("img");function h(){p(),no.add(t,this),n&&n(this),o.manager.itemEnd(t)}function d(m){p(),a&&a(m),o.manager.itemError(t),o.manager.itemEnd(t)}function p(){u.removeEventListener("load",h,!1),u.removeEventListener("error",d,!1)}return u.addEventListener("load",h,!1),u.addEventListener("error",d,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(u.crossOrigin=this.crossOrigin),o.manager.itemStart(t),u.src=t,u}}class nU extends nu{constructor(t){super(t)}load(t,n,i,a){const o=new Qn,l=new eU(this.manager);return l.setCrossOrigin(this.crossOrigin),l.setPath(this.path),l.load(t,function(u){o.image=u,o.needsUpdate=!0,n!==void 0&&n(o)},i,a),o}}class Qp extends Tn{constructor(t,n=1){super(),this.isLight=!0,this.type="Light",this.color=new de(t),this.intensity=n}dispose(){}copy(t,n){return super.copy(t,n),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const n=super.toJSON(t);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}}const ub=new _e,$M=new H,tA=new H;class q1{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ae(512,512),this.map=null,this.mapPass=null,this.matrix=new _e,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new V1,this._frameExtents=new Ae(1,1),this._viewportCount=1,this._viewports=[new qe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const n=this.camera,i=this.matrix;$M.setFromMatrixPosition(t.matrixWorld),n.position.copy($M),tA.setFromMatrixPosition(t.target.matrixWorld),n.lookAt(tA),n.updateMatrixWorld(),ub.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ub),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(ub)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class iU extends q1{constructor(){super(new Ui(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const n=this.camera,i=Ic*2*t.angle*this.focus,a=this.mapSize.width/this.mapSize.height,o=t.distance||n.far;(i!==n.fov||a!==n.aspect||o!==n.far)&&(n.fov=i,n.aspect=a,n.far=o,n.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class sU extends Qp{constructor(t,n,i=0,a=Math.PI/3,o=0,l=2){super(t,n),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Tn.DEFAULT_UP),this.updateMatrix(),this.target=new Tn,this.distance=i,this.angle=a,this.penumbra=o,this.decay=l,this.map=null,this.shadow=new iU}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,n){return super.copy(t,n),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const eA=new _e,_f=new H,fb=new H;class aU extends q1{constructor(){super(new Ui(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ae(4,2),this._viewportCount=6,this._viewports=[new qe(2,1,1,1),new qe(0,1,1,1),new qe(3,1,1,1),new qe(1,1,1,1),new qe(3,0,1,1),new qe(1,0,1,1)],this._cubeDirections=[new H(1,0,0),new H(-1,0,0),new H(0,0,1),new H(0,0,-1),new H(0,1,0),new H(0,-1,0)],this._cubeUps=[new H(0,1,0),new H(0,1,0),new H(0,1,0),new H(0,1,0),new H(0,0,1),new H(0,0,-1)]}updateMatrices(t,n=0){const i=this.camera,a=this.matrix,o=t.distance||i.far;o!==i.far&&(i.far=o,i.updateProjectionMatrix()),_f.setFromMatrixPosition(t.matrixWorld),i.position.copy(_f),fb.copy(i.position),fb.add(this._cubeDirections[n]),i.up.copy(this._cubeUps[n]),i.lookAt(fb),i.updateMatrixWorld(),a.makeTranslation(-_f.x,-_f.y,-_f.z),eA.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(eA)}}class rU extends Qp{constructor(t,n,i=0,a=2){super(t,n),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=a,this.shadow=new aU}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,n){return super.copy(t,n),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class Y1 extends T3{constructor(t=-1,n=1,i=1,a=-1,o=.1,l=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=n,this.top=i,this.bottom=a,this.near=o,this.far=l,this.updateProjectionMatrix()}copy(t,n){return super.copy(t,n),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,n,i,a,o,l){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=t,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=a,this.view.width=o,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,a=(this.top+this.bottom)/2;let o=i-t,l=i+t,u=a+n,h=a-n;if(this.view!==null&&this.view.enabled){const d=(this.right-this.left)/this.view.fullWidth/this.zoom,p=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=d*this.view.offsetX,l=o+d*this.view.width,u-=p*this.view.offsetY,h=u-p*this.view.height}this.projectionMatrix.makeOrthographic(o,l,u,h,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const n=super.toJSON(t);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}class oU extends q1{constructor(){super(new Y1(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class F3 extends Qp{constructor(t,n){super(t,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Tn.DEFAULT_UP),this.updateMatrix(),this.target=new Tn,this.shadow=new oU}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class lU extends Qp{constructor(t,n){super(t,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class Pf{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let n="";for(let i=0,a=t.length;i"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,n,i,a){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const o=this,l=no.get(t);if(l!==void 0){if(o.manager.itemStart(t),l.then){l.then(d=>{n&&n(d),o.manager.itemEnd(t)}).catch(d=>{a&&a(d)});return}return setTimeout(function(){n&&n(l),o.manager.itemEnd(t)},0),l}const u={};u.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",u.headers=this.requestHeader;const h=fetch(t,u).then(function(d){return d.blob()}).then(function(d){return createImageBitmap(d,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(d){return no.add(t,d),n&&n(d),o.manager.itemEnd(t),d}).catch(function(d){a&&a(d),no.remove(t),o.manager.itemError(t),o.manager.itemEnd(t)});no.add(t,h),o.manager.itemStart(t)}}class uU extends Ui{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t,this.index=0}}class fU{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=nA(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const n=nA();t=(n-this.oldTime)/1e3,this.oldTime=n,this.elapsedTime+=t}return t}}function nA(){return performance.now()}class hU{constructor(t,n,i){this.binding=t,this.valueSize=i;let a,o,l;switch(n){case"quaternion":a=this._slerp,o=this._slerpAdditive,l=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":a=this._select,o=this._select,l=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:a=this._lerp,o=this._lerpAdditive,l=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=a,this._mixBufferRegionAdditive=o,this._setIdentity=l,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,n){const i=this.buffer,a=this.valueSize,o=t*a+a;let l=this.cumulativeWeight;if(l===0){for(let u=0;u!==a;++u)i[o+u]=i[u];l=n}else{l+=n;const u=n/l;this._mixBufferRegion(i,o,0,u,a)}this.cumulativeWeight=l}accumulateAdditive(t){const n=this.buffer,i=this.valueSize,a=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(n,a,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const n=this.valueSize,i=this.buffer,a=t*n+n,o=this.cumulativeWeight,l=this.cumulativeWeightAdditive,u=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){const h=n*this._origIndex;this._mixBufferRegion(i,a,h,1-o,n)}l>0&&this._mixBufferRegionAdditive(i,a,this._addIndex*n,1,n);for(let h=n,d=n+n;h!==d;++h)if(i[h]!==i[h+n]){u.setValue(i,a);break}}saveOriginalState(){const t=this.binding,n=this.buffer,i=this.valueSize,a=i*this._origIndex;t.getValue(n,a);for(let o=i,l=a;o!==l;++o)n[o]=n[a+o%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,n=t+this.valueSize;for(let i=t;i=.5)for(let l=0;l!==o;++l)t[n+l]=t[i+l]}_slerp(t,n,i,a){sa.slerpFlat(t,n,t,n,t,i,a)}_slerpAdditive(t,n,i,a,o){const l=this._workIndex*o;sa.multiplyQuaternionsFlat(t,l,t,n,t,i),sa.slerpFlat(t,n,t,n,t,l,a)}_lerp(t,n,i,a,o){const l=1-a;for(let u=0;u!==o;++u){const h=n+u;t[h]=t[h]*l+t[i+u]*a}}_lerpAdditive(t,n,i,a,o){for(let l=0;l!==o;++l){const u=n+l;t[u]=t[u]+t[i+l]*a}}}const K1="\\[\\]\\.:\\/",dU=new RegExp("["+K1+"]","g"),Z1="[^"+K1+"]",pU="[^"+K1.replace("\\.","")+"]",mU=/((?:WC+[\/:])*)/.source.replace("WC",Z1),gU=/(WCOD+)?/.source.replace("WCOD",pU),bU=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Z1),vU=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Z1),_U=new RegExp("^"+mU+gU+bU+vU+"$"),yU=["material","materials","bones","map"];class xU{constructor(t,n,i){const a=i||Ke.parseTrackName(n);this._targetGroup=t,this._bindings=t.subscribe_(n,a)}getValue(t,n){this.bind();const i=this._targetGroup.nCachedObjects_,a=this._bindings[i];a!==void 0&&a.getValue(t,n)}setValue(t,n){const i=this._bindings;for(let a=this._targetGroup.nCachedObjects_,o=i.length;a!==o;++a)i[a].setValue(t,n)}bind(){const t=this._bindings;for(let n=this._targetGroup.nCachedObjects_,i=t.length;n!==i;++n)t[n].bind()}unbind(){const t=this._bindings;for(let n=this._targetGroup.nCachedObjects_,i=t.length;n!==i;++n)t[n].unbind()}}class Ke{constructor(t,n,i){this.path=n,this.parsedPath=i||Ke.parseTrackName(n),this.node=Ke.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,i){return t&&t.isAnimationObjectGroup?new Ke.Composite(t,n,i):new Ke(t,n,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(dU,"")}static parseTrackName(t){const n=_U.exec(t);if(n===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},a=i.nodeName&&i.nodeName.lastIndexOf(".");if(a!==void 0&&a!==-1){const o=i.nodeName.substring(a+1);yU.indexOf(o)!==-1&&(i.nodeName=i.nodeName.substring(0,a),i.objectName=o)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,n){if(n===void 0||n===""||n==="."||n===-1||n===t.name||n===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(n);if(i!==void 0)return i}if(t.children){const i=function(o){for(let l=0;l0){const h=this._interpolants,d=this._propertyBindings;switch(this.blendMode){case L5:for(let p=0,m=h.length;p!==m;++p)h[p].evaluate(l),d[p].accumulateAdditive(u);break;case I1:default:for(let p=0,m=h.length;p!==m;++p)h[p].evaluate(l),d[p].accumulate(a,u)}}}_updateWeight(t){let n=0;if(this.enabled){n=this.weight;const i=this._weightInterpolant;if(i!==null){const a=i.evaluate(t)[0];n*=a,t>i.parameterPositions[1]&&(this.stopFading(),a===0&&(this.enabled=!1))}}return this._effectiveWeight=n,n}_updateTimeScale(t){let n=0;if(!this.paused){n=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const a=i.evaluate(t)[0];n*=a,t>i.parameterPositions[1]&&(this.stopWarping(),n===0?this.paused=!0:this.timeScale=n)}}return this._effectiveTimeScale=n,n}_updateTime(t){const n=this._clip.duration,i=this.loop;let a=this.time+t,o=this._loopCount;const l=i===D5;if(t===0)return o===-1?a:l&&(o&1)===1?n-a:a;if(i===Ef){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(a>=n)a=n;else if(a<0)a=0;else{this.time=a;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(o===-1&&(t>=0?(o=0,this._setEndings(!0,this.repetitions===0,l)):this._setEndings(this.repetitions===0,!0,l)),a>=n||a<0){const u=Math.floor(a/n);a-=n*u,o+=Math.abs(u);const h=this.repetitions-o;if(h<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a=t>0?n:0,this.time=a,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(h===1){const d=t<0;this._setEndings(d,!d,l)}else this._setEndings(!1,!1,l);this._loopCount=o,this.time=a,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:u})}}else this.time=a;if(l&&(o&1)===1)return n-a}return a}_setEndings(t,n,i){const a=this._interpolantSettings;i?(a.endingStart=vc,a.endingEnd=vc):(t?a.endingStart=this.zeroSlopeAtStart?vc:bc:a.endingStart=wp,n?a.endingEnd=this.zeroSlopeAtEnd?vc:bc:a.endingEnd=wp)}_scheduleFading(t,n,i){const a=this._mixer,o=a.time;let l=this._weightInterpolant;l===null&&(l=a._lendControlInterpolant(),this._weightInterpolant=l);const u=l.parameterPositions,h=l.sampleValues;return u[0]=o,h[0]=n,u[1]=o+t,h[1]=i,this}}const MU=new Float32Array(1);class AU extends ml{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,n){const i=t._localRoot||this._root,a=t._clip.tracks,o=a.length,l=t._propertyBindings,u=t._interpolants,h=i.uuid,d=this._bindingsByRootAndName;let p=d[h];p===void 0&&(p={},d[h]=p);for(let m=0;m!==o;++m){const b=a[m],_=b.name;let S=p[_];if(S!==void 0)++S.referenceCount,l[m]=S;else{if(S=l[m],S!==void 0){S._cacheIndex===null&&(++S.referenceCount,this._addInactiveBinding(S,h,_));continue}const A=n&&n._propertyBindings[m].binding.parsedPath;S=new hU(Ke.create(i,_,A),b.ValueTypeName,b.getValueSize()),++S.referenceCount,this._addInactiveBinding(S,h,_),l[m]=S}u[m].resultBuffer=S.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const i=(t._localRoot||this._root).uuid,a=t._clip.uuid,o=this._actionsByClip[a];this._bindAction(t,o&&o.knownActions[0]),this._addInactiveAction(t,a,i)}const n=t._propertyBindings;for(let i=0,a=n.length;i!==a;++i){const o=n[i];o.useCount++===0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const n=t._propertyBindings;for(let i=0,a=n.length;i!==a;++i){const o=n[i];--o.useCount===0&&(o.restoreOriginalState(),this._takeBackBinding(o))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const n=t._cacheIndex;return n!==null&&n=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;const n=this._actions,i=this._nActiveActions,a=this.time+=t,o=Math.sign(t),l=this._accuIndex^=1;for(let d=0;d!==i;++d)n[d]._update(a,t,o,l);const u=this._bindings,h=this._nActiveBindings;for(let d=0;d!==h;++d)u[d].apply(l);return this}setTime(t){this.time=0;for(let n=0;n_.start-S.start);let b=0;for(let _=1;_ 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`,jU=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,WU=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,XU=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,qU=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,YU=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,KU=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,ZU=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif #ifdef USE_BATCHING_COLOR vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); vColor.xyz *= batchingColor.xyz; #endif`,QU=`#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 ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } 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`,JU=`#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`,$U=`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`,tP=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,eP=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,nP=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,iP=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,sP="gl_FragColor = linearToOutputTexel( gl_FragColor );",aP=`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 ); }`,rP=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,oP=`#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`,lP=`#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`,cP=`#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`,uP=`#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`,fP=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,hP=`#ifdef USE_FOG varying float vFogDepth; #endif`,dP=`#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`,pP=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,mP=`#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 }`,gP=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,bP=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,vP=`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`,_P=`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`,yP=`#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, roughness * 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`,xP=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,SP=`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`,MP=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,AP=`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`,TP=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,EP=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return saturate(v); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColor; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); #endif reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,wP=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,RP=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,CP=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`,DP=`#if defined( USE_LOGDEPTHBUF ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,LP=`#if defined( USE_LOGDEPTHBUF ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,NP=`#ifdef USE_LOGDEPTHBUF varying float vFragDepth; varying float vIsPerspective; #endif`,UP=`#ifdef USE_LOGDEPTHBUF vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,PP=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,OP=`#ifdef USE_MAP uniform sampler2D map; #endif`,IP=`#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`,FP=`#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`,BP=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,kP=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,zP=`#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`,VP=`#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`,GP=`#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`,HP=`#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`,jP=`#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`,WP=`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;`,XP=`#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`,qP=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,YP=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,KP=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,ZP=`#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`,QP=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,JP=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,$P=`#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`,t9=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,e9=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,n9=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; const float Inv255 = 1. / 255.; const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); vec4 packDepthToRGBA( const in float v ) { if( v <= 0.0 ) return vec4( 0., 0., 0., 0. ); if( v >= 1.0 ) return vec4( 1., 1., 1., 1. ); float vuf; float af = modf( v * PackFactors.a, vuf ); float bf = modf( vuf * ShiftRight8, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); } vec3 packDepthToRGB( const in float v ) { if( v <= 0.0 ) return vec3( 0., 0., 0. ); if( v >= 1.0 ) return vec3( 1., 1., 1. ); float vuf; float bf = modf( v * PackFactors.b, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec3( vuf * Inv255, gf * PackUpscale, bf ); } vec2 packDepthToRG( const in float v ) { if( v <= 0.0 ) return vec2( 0., 0. ); if( v >= 1.0 ) return vec2( 1., 1. ); float vuf; float gf = modf( v * 256., vuf ); return vec2( vuf * Inv255, gf ); } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors4 ); } float unpackRGBToDepth( const in vec3 v ) { return dot( v, UnpackFactors3 ); } float unpackRGToDepth( const in vec2 v ) { return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; } vec4 pack2HalfToRGBA( const in vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( const in vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`,i9=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,s9=`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;`,a9=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,r9=`#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`,o9=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,l9=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,c9=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return mix( 1.0, shadow, shadowIntensity ); } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; float lightToPositionLength = length( lightToPosition ); if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; shadow = ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif`,u9=`#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`,f9=`#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`,h9=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,d9=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,p9=`#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`,m9=`#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`,g9=`#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`,b9=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,v9=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,_9=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,y9=`#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; }`,x9=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,S9=`#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`,M9=`#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`,A9=`#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`,T9=`#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`,E9=`#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 w9=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,R9=`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 #include }`,C9=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,D9=`#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 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 #include }`,L9=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,N9=`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 #include }`,U9=`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,P9=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #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 }`,O9=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,I9=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,F9=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,B9=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,k9=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,z9=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,V9=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,G9=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include 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 reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,H9=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,j9=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,W9=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,X9=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include 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 #include #include #include #include #include }`,q9=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,Y9=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,K9=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,Z9=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,Q9=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,J9=`#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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,$9=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,tO=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,eO=`uniform float size; uniform float scale; #include #include #include #include #include #include #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 #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,nO=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,iO=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,sO=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,aO=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include 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 #include #include }`,rO=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,xe={alphahash_fragment:RU,alphahash_pars_fragment:CU,alphamap_fragment:DU,alphamap_pars_fragment:LU,alphatest_fragment:NU,alphatest_pars_fragment:UU,aomap_fragment:PU,aomap_pars_fragment:OU,batching_pars_vertex:IU,batching_vertex:FU,begin_vertex:BU,beginnormal_vertex:kU,bsdfs:zU,iridescence_fragment:VU,bumpmap_pars_fragment:GU,clipping_planes_fragment:HU,clipping_planes_pars_fragment:jU,clipping_planes_pars_vertex:WU,clipping_planes_vertex:XU,color_fragment:qU,color_pars_fragment:YU,color_pars_vertex:KU,color_vertex:ZU,common:QU,cube_uv_reflection_fragment:JU,defaultnormal_vertex:$U,displacementmap_pars_vertex:tP,displacementmap_vertex:eP,emissivemap_fragment:nP,emissivemap_pars_fragment:iP,colorspace_fragment:sP,colorspace_pars_fragment:aP,envmap_fragment:rP,envmap_common_pars_fragment:oP,envmap_pars_fragment:lP,envmap_pars_vertex:cP,envmap_physical_pars_fragment:yP,envmap_vertex:uP,fog_vertex:fP,fog_pars_vertex:hP,fog_fragment:dP,fog_pars_fragment:pP,gradientmap_pars_fragment:mP,lightmap_pars_fragment:gP,lights_lambert_fragment:bP,lights_lambert_pars_fragment:vP,lights_pars_begin:_P,lights_toon_fragment:xP,lights_toon_pars_fragment:SP,lights_phong_fragment:MP,lights_phong_pars_fragment:AP,lights_physical_fragment:TP,lights_physical_pars_fragment:EP,lights_fragment_begin:wP,lights_fragment_maps:RP,lights_fragment_end:CP,logdepthbuf_fragment:DP,logdepthbuf_pars_fragment:LP,logdepthbuf_pars_vertex:NP,logdepthbuf_vertex:UP,map_fragment:PP,map_pars_fragment:OP,map_particle_fragment:IP,map_particle_pars_fragment:FP,metalnessmap_fragment:BP,metalnessmap_pars_fragment:kP,morphinstance_vertex:zP,morphcolor_vertex:VP,morphnormal_vertex:GP,morphtarget_pars_vertex:HP,morphtarget_vertex:jP,normal_fragment_begin:WP,normal_fragment_maps:XP,normal_pars_fragment:qP,normal_pars_vertex:YP,normal_vertex:KP,normalmap_pars_fragment:ZP,clearcoat_normal_fragment_begin:QP,clearcoat_normal_fragment_maps:JP,clearcoat_pars_fragment:$P,iridescence_pars_fragment:t9,opaque_fragment:e9,packing:n9,premultiplied_alpha_fragment:i9,project_vertex:s9,dithering_fragment:a9,dithering_pars_fragment:r9,roughnessmap_fragment:o9,roughnessmap_pars_fragment:l9,shadowmap_pars_fragment:c9,shadowmap_pars_vertex:u9,shadowmap_vertex:f9,shadowmask_pars_fragment:h9,skinbase_vertex:d9,skinning_pars_vertex:p9,skinning_vertex:m9,skinnormal_vertex:g9,specularmap_fragment:b9,specularmap_pars_fragment:v9,tonemapping_fragment:_9,tonemapping_pars_fragment:y9,transmission_fragment:x9,transmission_pars_fragment:S9,uv_pars_fragment:M9,uv_pars_vertex:A9,uv_vertex:T9,worldpos_vertex:E9,background_vert:w9,background_frag:R9,backgroundCube_vert:C9,backgroundCube_frag:D9,cube_vert:L9,cube_frag:N9,depth_vert:U9,depth_frag:P9,distanceRGBA_vert:O9,distanceRGBA_frag:I9,equirect_vert:F9,equirect_frag:B9,linedashed_vert:k9,linedashed_frag:z9,meshbasic_vert:V9,meshbasic_frag:G9,meshlambert_vert:H9,meshlambert_frag:j9,meshmatcap_vert:W9,meshmatcap_frag:X9,meshnormal_vert:q9,meshnormal_frag:Y9,meshphong_vert:K9,meshphong_frag:Z9,meshphysical_vert:Q9,meshphysical_frag:J9,meshtoon_vert:$9,meshtoon_frag:tO,points_vert:eO,points_frag:nO,shadow_vert:iO,shadow_frag:sO,sprite_vert:aO,sprite_frag:rO},It={common:{diffuse:{value:new de(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ve},alphaMap:{value:null},alphaMapTransform:{value:new ve},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ve}},envmap:{envMap:{value:null},envMapRotation:{value:new ve},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ve}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ve}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ve},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ve},normalScale:{value:new Ae(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ve},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ve}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ve}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ve}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new de(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new de(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ve},alphaTest:{value:0},uvTransform:{value:new ve}},sprite:{diffuse:{value:new de(16777215)},opacity:{value:1},center:{value:new Ae(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ve},alphaMap:{value:null},alphaMapTransform:{value:new ve},alphaTest:{value:0}}},_a={basic:{uniforms:Li([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.fog]),vertexShader:xe.meshbasic_vert,fragmentShader:xe.meshbasic_frag},lambert:{uniforms:Li([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new de(0)}}]),vertexShader:xe.meshlambert_vert,fragmentShader:xe.meshlambert_frag},phong:{uniforms:Li([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new de(0)},specular:{value:new de(1118481)},shininess:{value:30}}]),vertexShader:xe.meshphong_vert,fragmentShader:xe.meshphong_frag},standard:{uniforms:Li([It.common,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.roughnessmap,It.metalnessmap,It.fog,It.lights,{emissive:{value:new de(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:xe.meshphysical_vert,fragmentShader:xe.meshphysical_frag},toon:{uniforms:Li([It.common,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.gradientmap,It.fog,It.lights,{emissive:{value:new de(0)}}]),vertexShader:xe.meshtoon_vert,fragmentShader:xe.meshtoon_frag},matcap:{uniforms:Li([It.common,It.bumpmap,It.normalmap,It.displacementmap,It.fog,{matcap:{value:null}}]),vertexShader:xe.meshmatcap_vert,fragmentShader:xe.meshmatcap_frag},points:{uniforms:Li([It.points,It.fog]),vertexShader:xe.points_vert,fragmentShader:xe.points_frag},dashed:{uniforms:Li([It.common,It.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xe.linedashed_vert,fragmentShader:xe.linedashed_frag},depth:{uniforms:Li([It.common,It.displacementmap]),vertexShader:xe.depth_vert,fragmentShader:xe.depth_frag},normal:{uniforms:Li([It.common,It.bumpmap,It.normalmap,It.displacementmap,{opacity:{value:1}}]),vertexShader:xe.meshnormal_vert,fragmentShader:xe.meshnormal_frag},sprite:{uniforms:Li([It.sprite,It.fog]),vertexShader:xe.sprite_vert,fragmentShader:xe.sprite_frag},background:{uniforms:{uvTransform:{value:new ve},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:xe.background_vert,fragmentShader:xe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ve}},vertexShader:xe.backgroundCube_vert,fragmentShader:xe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:xe.cube_vert,fragmentShader:xe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:xe.equirect_vert,fragmentShader:xe.equirect_frag},distanceRGBA:{uniforms:Li([It.common,It.displacementmap,{referencePosition:{value:new H},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xe.distanceRGBA_vert,fragmentShader:xe.distanceRGBA_frag},shadow:{uniforms:Li([It.lights,It.fog,{color:{value:new de(0)},opacity:{value:1}}]),vertexShader:xe.shadow_vert,fragmentShader:xe.shadow_frag}};_a.physical={uniforms:Li([_a.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ve},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ve},clearcoatNormalScale:{value:new Ae(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ve},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ve},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ve},sheen:{value:0},sheenColor:{value:new de(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ve},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ve},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ve},transmissionSamplerSize:{value:new Ae},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ve},attenuationDistance:{value:0},attenuationColor:{value:new de(0)},specularColor:{value:new de(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ve},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ve},anisotropyVector:{value:new Ae},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ve}}]),vertexShader:xe.meshphysical_vert,fragmentShader:xe.meshphysical_frag};const Kd={r:0,b:0,g:0},Bo=new Ta,oO=new _e;function lO(e,t,n,i,a,o,l){const u=new de(0);let h=o===!0?0:1,d,p,m=null,b=0,_=null;function S(w){let T=w.isScene===!0?w.background:null;return T&&T.isTexture&&(T=(w.backgroundBlurriness>0?n:t).get(T)),T}function A(w){let T=!1;const P=S(w);P===null?y(u,h):P&&P.isColor&&(y(P,1),T=!0);const O=e.xr.getEnvironmentBlendMode();O==="additive"?i.buffers.color.setClear(0,0,0,1,l):O==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,l),(e.autoClear||T)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function x(w,T){const P=S(T);P&&(P.isCubeTexture||P.mapping===Yp)?(p===void 0&&(p=new Ye(new fl(1,1,1),new oo({name:"BackgroundCubeMaterial",uniforms:Fc(_a.backgroundCube.uniforms),vertexShader:_a.backgroundCube.vertexShader,fragmentShader:_a.backgroundCube.fragmentShader,side:Ji,depthTest:!1,depthWrite:!1,fog:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(O,U,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(p)),Bo.copy(T.backgroundRotation),Bo.x*=-1,Bo.y*=-1,Bo.z*=-1,P.isCubeTexture&&P.isRenderTargetTexture===!1&&(Bo.y*=-1,Bo.z*=-1),p.material.uniforms.envMap.value=P,p.material.uniforms.flipEnvMap.value=P.isCubeTexture&&P.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(oO.makeRotationFromEuler(Bo)),p.material.toneMapped=Ie.getTransfer(P.colorSpace)!==an,(m!==P||b!==P.version||_!==e.toneMapping)&&(p.material.needsUpdate=!0,m=P,b=P.version,_=e.toneMapping),p.layers.enableAll(),w.unshift(p,p.geometry,p.material,0,0,null)):P&&P.isTexture&&(d===void 0&&(d=new Ye(new Zp(2,2),new oo({name:"BackgroundMaterial",uniforms:Fc(_a.background.uniforms),vertexShader:_a.background.vertexShader,fragmentShader:_a.background.fragmentShader,side:hr,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(d)),d.material.uniforms.t2D.value=P,d.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,d.material.toneMapped=Ie.getTransfer(P.colorSpace)!==an,P.matrixAutoUpdate===!0&&P.updateMatrix(),d.material.uniforms.uvTransform.value.copy(P.matrix),(m!==P||b!==P.version||_!==e.toneMapping)&&(d.material.needsUpdate=!0,m=P,b=P.version,_=e.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null))}function y(w,T){w.getRGB(Kd,A3(e)),i.buffers.color.setClear(Kd.r,Kd.g,Kd.b,T,l)}function E(){p!==void 0&&(p.geometry.dispose(),p.material.dispose(),p=void 0),d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0)}return{getClearColor:function(){return u},setClearColor:function(w,T=1){u.set(w),h=T,y(u,h)},getClearAlpha:function(){return h},setClearAlpha:function(w){h=w,y(u,h)},render:A,addToRenderList:x,dispose:E}}function cO(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},a=b(null);let o=a,l=!1;function u(R,F,Y,$,lt){let ut=!1;const k=m($,Y,F);o!==k&&(o=k,d(o.object)),ut=_(R,$,Y,lt),ut&&S(R,$,Y,lt),lt!==null&&t.update(lt,e.ELEMENT_ARRAY_BUFFER),(ut||l)&&(l=!1,T(R,F,Y,$),lt!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(lt).buffer))}function h(){return e.createVertexArray()}function d(R){return e.bindVertexArray(R)}function p(R){return e.deleteVertexArray(R)}function m(R,F,Y){const $=Y.wireframe===!0;let lt=i[R.id];lt===void 0&&(lt={},i[R.id]=lt);let ut=lt[F.id];ut===void 0&&(ut={},lt[F.id]=ut);let k=ut[$];return k===void 0&&(k=b(h()),ut[$]=k),k}function b(R){const F=[],Y=[],$=[];for(let lt=0;lt=0){const At=lt[X];let z=ut[X];if(z===void 0&&(X==="instanceMatrix"&&R.instanceMatrix&&(z=R.instanceMatrix),X==="instanceColor"&&R.instanceColor&&(z=R.instanceColor)),At===void 0||At.attribute!==z||z&&At.data!==z.data)return!0;k++}return o.attributesNum!==k||o.index!==$}function S(R,F,Y,$){const lt={},ut=F.attributes;let k=0;const Q=Y.getAttributes();for(const X in Q)if(Q[X].location>=0){let At=ut[X];At===void 0&&(X==="instanceMatrix"&&R.instanceMatrix&&(At=R.instanceMatrix),X==="instanceColor"&&R.instanceColor&&(At=R.instanceColor));const z={};z.attribute=At,At&&At.data&&(z.data=At.data),lt[X]=z,k++}o.attributes=lt,o.attributesNum=k,o.index=$}function A(){const R=o.newAttributes;for(let F=0,Y=R.length;F=0){let yt=lt[Q];if(yt===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(yt=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(yt=R.instanceColor)),yt!==void 0){const At=yt.normalized,z=yt.itemSize,it=t.get(yt);if(it===void 0)continue;const Tt=it.buffer,J=it.type,ht=it.bytesPerElement,Et=J===e.INT||J===e.UNSIGNED_INT||yt.gpuType===C1;if(yt.isInterleavedBufferAttribute){const Mt=yt.data,Ht=Mt.stride,ee=yt.offset;if(Mt.isInstancedInterleavedBuffer){for(let oe=0;oe0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";U="mediump"}return U==="mediump"&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let d=n.precision!==void 0?n.precision:"highp";const p=h(d);p!==d&&(console.warn("THREE.WebGLRenderer:",d,"not supported, using",p,"instead."),d=p);const m=n.logarithmicDepthBuffer===!0,b=n.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),_=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),S=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),A=e.getParameter(e.MAX_TEXTURE_SIZE),x=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),y=e.getParameter(e.MAX_VERTEX_ATTRIBS),E=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),w=e.getParameter(e.MAX_VARYING_VECTORS),T=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),P=S>0,O=e.getParameter(e.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:o,getMaxPrecision:h,textureFormatReadable:l,textureTypeReadable:u,precision:d,logarithmicDepthBuffer:m,reverseDepthBuffer:b,maxTextures:_,maxVertexTextures:S,maxTextureSize:A,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:E,maxVaryings:w,maxFragmentUniforms:T,vertexTextures:P,maxSamples:O}}function hO(e){const t=this;let n=null,i=0,a=!1,o=!1;const l=new Wo,u=new ve,h={value:null,needsUpdate:!1};this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(m,b){const _=m.length!==0||b||i!==0||a;return a=b,i=m.length,_},this.beginShadows=function(){o=!0,p(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(m,b){n=p(m,b,0)},this.setState=function(m,b,_){const S=m.clippingPlanes,A=m.clipIntersection,x=m.clipShadows,y=e.get(m);if(!a||S===null||S.length===0||o&&!x)o?p(null):d();else{const E=o?0:i,w=E*4;let T=y.clippingState||null;h.value=T,T=p(S,b,w,_);for(let P=0;P!==w;++P)T[P]=n[P];y.clippingState=T,this.numIntersection=A?this.numPlanes:0,this.numPlanes+=E}};function d(){h.value!==n&&(h.value=n,h.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function p(m,b,_,S){const A=m!==null?m.length:0;let x=null;if(A!==0){if(x=h.value,S!==!0||x===null){const y=_+A*4,E=b.matrixWorldInverse;u.getNormalMatrix(E),(x===null||x.length0){const d=new LN(h.height);return d.fromEquirectangularTexture(e,l),t.set(l,d),l.addEventListener("dispose",a),n(d.texture,l.mapping)}else return null}}return l}function a(l){const u=l.target;u.removeEventListener("dispose",a);const h=t.get(u);h!==void 0&&(t.delete(u),h.dispose())}function o(){t=new WeakMap}return{get:i,dispose:o}}const _c=4,sA=[.125,.215,.35,.446,.526,.582],Zo=20,hb=new Y1,aA=new de;let db=null,pb=0,mb=0,gb=!1;const Xo=(1+Math.sqrt(5))/2,hc=1/Xo,rA=[new H(-Xo,hc,0),new H(Xo,hc,0),new H(-hc,0,Xo),new H(hc,0,Xo),new H(0,Xo,-hc),new H(0,Xo,hc),new H(-1,1,-1),new H(1,1,-1),new H(-1,1,1),new H(1,1,1)],pO=new H;class oA{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,n=0,i=.1,a=100,o={}){const{size:l=256,position:u=pO}=o;db=this._renderer.getRenderTarget(),pb=this._renderer.getActiveCubeFace(),mb=this._renderer.getActiveMipmapLevel(),gb=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(l);const h=this._allocateTargets();return h.depthBuffer=!0,this._sceneToCubeUV(t,i,a,h,u),n>0&&this._blur(h,0,0,n),this._applyPMREM(h),this._cleanup(h),h}fromEquirectangular(t,n=null){return this._fromTexture(t,n)}fromCubemap(t,n=null){return this._fromTexture(t,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=uA(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=cA(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?T:0,T,T),m.setRenderTarget(a),x&&m.render(A,h),m.render(t,h)}A.geometry.dispose(),A.material.dispose(),m.toneMapping=_,m.autoClear=b,t.background=y}_textureToCubeUV(t,n){const i=this._renderer,a=t.mapping===Lc||t.mapping===Nc;a?(this._cubemapMaterial===null&&(this._cubemapMaterial=uA()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=cA());const o=a?this._cubemapMaterial:this._equirectMaterial,l=new Ye(this._lodPlanes[0],o),u=o.uniforms;u.envMap.value=t;const h=this._cubeSize;Zd(n,0,0,3*h,2*h),i.setRenderTarget(n),i.render(l,hb)}_applyPMREM(t){const n=this._renderer,i=n.autoClear;n.autoClear=!1;const a=this._lodPlanes.length;for(let o=1;oZo&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${Zo}`);const y=[];let E=0;for(let U=0;Uw-_c?a-w+_c:0),O=4*(this._cubeSize-T);Zd(n,P,O,3*T,2*T),h.setRenderTarget(n),h.render(m,hb)}}function mO(e){const t=[],n=[],i=[];let a=e;const o=e-_c+1+sA.length;for(let l=0;le-_c?h=sA[l-e+_c-1]:l===0&&(h=0),i.push(h);const d=1/(u-2),p=-d,m=1+d,b=[p,p,m,p,m,m,p,p,m,m,p,m],_=6,S=6,A=3,x=2,y=1,E=new Float32Array(A*S*_),w=new Float32Array(x*S*_),T=new Float32Array(y*S*_);for(let O=0;O<_;O++){const U=O%3*2/3-1,I=O>2?0:-1,C=[U,I,0,U+2/3,I,0,U+2/3,I+1,0,U,I,0,U+2/3,I+1,0,U,I+1,0];E.set(C,A*S*O),w.set(b,x*S*O);const R=[O,O,O,O,O,O];T.set(R,y*S*O)}const P=new $i;P.setAttribute("position",new Fi(E,A)),P.setAttribute("uv",new Fi(w,x)),P.setAttribute("faceIndex",new Fi(T,y)),t.push(P),a>_c&&a--}return{lodPlanes:t,sizeLods:n,sigmas:i}}function lA(e,t,n){const i=new ul(e,t,n);return i.texture.mapping=Yp,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Zd(e,t,n,i,a){e.viewport.set(t,n,i,a),e.scissor.set(t,n,i,a)}function gO(e,t,n){const i=new Float32Array(Zo),a=new H(0,1,0);return new oo({name:"SphericalGaussianBlur",defines:{n:Zo,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:a}},vertexShader:Q1(),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 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:so,depthTest:!1,depthWrite:!1})}function cA(){return new oo({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Q1(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:so,depthTest:!1,depthWrite:!1})}function uA(){return new oo({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Q1(),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:so,depthTest:!1,depthWrite:!1})}function Q1(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function bO(e){let t=new WeakMap,n=null;function i(u){if(u&&u.isTexture){const h=u.mapping,d=h===iv||h===sv,p=h===Lc||h===Nc;if(d||p){let m=t.get(u);const b=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==b)return n===null&&(n=new oA(e)),m=d?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),m.texture;if(m!==void 0)return m.texture;{const _=u.image;return d&&_&&_.height>0||p&&_&&a(_)?(n===null&&(n=new oA(e)),m=d?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),u.addEventListener("dispose",o),m.texture):null}}}return u}function a(u){let h=0;const d=6;for(let p=0;pt.maxTextureSize&&(O=Math.ceil(P/t.maxTextureSize),P=t.maxTextureSize);const U=new Float32Array(P*O*4*m),I=new _3(U,P,O,m);I.type=na,I.needsUpdate=!0;const C=T*4;for(let F=0;F0)return e;const a=t*n;let o=hA[a];if(o===void 0&&(o=new Float32Array(a),hA[a]=o),t!==0){i.toArray(o,0);for(let l=1,u=0;l!==t;++l)u+=n,e[l].toArray(o,u)}return o}function ti(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${u}: ${n[l]}`)}return i.join(` `)}const _A=new ve;function b6(e){Ie._getMatrix(_A,Ie.workingColorSpace,e);const t=`mat3( ${_A.elements.map(n=>n.toFixed(4))} )`;switch(Ie.getTransfer(e)){case Rp:return[t,"LinearTransferOETF"];case an:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}function yA(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),a=e.getShaderInfoLog(t).trim();if(i&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+` `+a+` `+g6(e.getShaderSource(t),l)}else return a}function v6(e,t){const n=b6(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(` `)}function _6(e,t){let n;switch(t){case x5:n="Linear";break;case S5:n="Reinhard";break;case M5:n="Cineon";break;case A5:n="ACESFilmic";break;case E5:n="AgX";break;case w5:n="Neutral";break;case T5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Qd=new H;function y6(){Ie.getLuminanceCoefficients(Qd);const e=Qd.x.toFixed(4),t=Qd.y.toFixed(4),n=Qd.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${e}, ${t}, ${n} );`," return dot( weights, rgb );","}"].join(` `)}function x6(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(wf).join(` `)}function S6(e){const t=[];for(const n in e){const i=e[n];i!==!1&&t.push("#define "+n+" "+i)}return t.join(` `)}function M6(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let a=0;a/gm;function Iv(e){return e.replace(A6,E6)}const T6=new Map;function E6(e,t){let n=xe[t];if(n===void 0){const i=T6.get(t);if(i!==void 0)n=xe[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,i);else throw new Error("Can not resolve #include <"+t+">")}return Iv(n)}const w6=/#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 MA(e){return e.replace(w6,R6)}function R6(e,t,n,i){let a="";for(let o=parseInt(t);o0&&(x+=` `),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,S].filter(wf).join(` `),y.length>0&&(y+=` `)):(x=[AA(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,S,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+p:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","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(wf).join(` `),y=[AA(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,S,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.envMap?"#define "+p:"",n.envMap?"#define "+m:"",b?"#define CUBEUV_TEXEL_WIDTH "+b.texelWidth:"",b?"#define CUBEUV_TEXEL_HEIGHT "+b.texelHeight:"",b?"#define CUBEUV_MAX_MIP "+b.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ao?"#define TONE_MAPPING":"",n.toneMapping!==ao?xe.tonemapping_pars_fragment:"",n.toneMapping!==ao?_6("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",xe.colorspace_pars_fragment,v6("linearToOutputTexel",n.outputColorSpace),y6(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",` `].filter(wf).join(` `)),l=Iv(l),l=xA(l,n),l=SA(l,n),u=Iv(u),u=xA(u,n),u=SA(u,n),l=MA(l),u=MA(u),n.isRawShaderMaterial!==!0&&(E=`#version 300 es `,x=[_,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+x,y=["#define varying in",n.glslVersion===vM?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===vM?"":"#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(` `)+` `+y);const w=E+x+l,T=E+y+u,P=vA(a,a.VERTEX_SHADER,w),O=vA(a,a.FRAGMENT_SHADER,T);a.attachShader(A,P),a.attachShader(A,O),n.index0AttributeName!==void 0?a.bindAttribLocation(A,0,n.index0AttributeName):n.morphTargets===!0&&a.bindAttribLocation(A,0,"position"),a.linkProgram(A);function U(F){if(e.debug.checkShaderErrors){const Y=a.getProgramInfoLog(A).trim(),$=a.getShaderInfoLog(P).trim(),lt=a.getShaderInfoLog(O).trim();let ut=!0,k=!0;if(a.getProgramParameter(A,a.LINK_STATUS)===!1)if(ut=!1,typeof e.debug.onShaderError=="function")e.debug.onShaderError(a,A,P,O);else{const Q=yA(a,P,"vertex"),X=yA(a,O,"fragment");console.error("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(A,a.VALIDATE_STATUS)+` Material Name: `+F.name+` Material Type: `+F.type+` Program Info Log: `+Y+` `+Q+` `+X)}else Y!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Y):($===""||lt==="")&&(k=!1);k&&(F.diagnostics={runnable:ut,programLog:Y,vertexShader:{log:$,prefix:x},fragmentShader:{log:lt,prefix:y}})}a.deleteShader(P),a.deleteShader(O),I=new mp(a,A),C=M6(a,A)}let I;this.getUniforms=function(){return I===void 0&&U(this),I};let C;this.getAttributes=function(){return C===void 0&&U(this),C};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=a.getProgramParameter(A,p6)),R},this.destroy=function(){i.releaseStatesOfProgram(this),a.deleteProgram(A),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=m6++,this.cacheKey=t,this.usedTimes=1,this.program=A,this.vertexShader=P,this.fragmentShader=O,this}let O6=0;class I6{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const n=t.vertexShader,i=t.fragmentShader,a=this._getShaderStage(n),o=this._getShaderStage(i),l=this._getShaderCacheForMaterial(t);return l.has(a)===!1&&(l.add(a),a.usedTimes++),l.has(o)===!1&&(l.add(o),o.usedTimes++),this}remove(t){const n=this.materialCache.get(t);for(const i of n)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const n=this.materialCache;let i=n.get(t);return i===void 0&&(i=new Set,n.set(t,i)),i}_getShaderStage(t){const n=this.shaderCache;let i=n.get(t);return i===void 0&&(i=new F6(t),n.set(t,i)),i}}class F6{constructor(t){this.id=O6++,this.code=t,this.usedTimes=0}}function B6(e,t,n,i,a,o,l){const u=new y3,h=new I6,d=new Set,p=[],m=a.logarithmicDepthBuffer,b=a.vertexTextures;let _=a.precision;const S={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function A(C){return d.add(C),C===0?"uv":`uv${C}`}function x(C,R,F,Y,$){const lt=Y.fog,ut=$.geometry,k=C.isMeshStandardMaterial?Y.environment:null,Q=(C.isMeshStandardMaterial?n:t).get(C.envMap||k),X=Q&&Q.mapping===Yp?Q.image.height:null,yt=S[C.type];C.precision!==null&&(_=a.getMaxPrecision(C.precision),_!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",_,"instead."));const At=ut.morphAttributes.position||ut.morphAttributes.normal||ut.morphAttributes.color,z=At!==void 0?At.length:0;let it=0;ut.morphAttributes.position!==void 0&&(it=1),ut.morphAttributes.normal!==void 0&&(it=2),ut.morphAttributes.color!==void 0&&(it=3);let Tt,J,ht,Et;if(yt){const Te=_a[yt];Tt=Te.vertexShader,J=Te.fragmentShader}else Tt=C.vertexShader,J=C.fragmentShader,h.update(C),ht=h.getVertexShaderID(C),Et=h.getFragmentShaderID(C);const Mt=e.getRenderTarget(),Ht=e.state.buffers.depth.getReversed(),ee=$.isInstancedMesh===!0,oe=$.isBatchedMesh===!0,on=!!C.map,$e=!!C.matcap,Me=!!Q,G=!!C.aoMap,ii=!!C.lightMap,me=!!C.bumpMap,Se=!!C.normalMap,Zt=!!C.displacementMap,He=!!C.emissiveMap,Yt=!!C.metalnessMap,B=!!C.roughnessMap,L=C.anisotropy>0,nt=C.clearcoat>0,dt=C.dispersion>0,St=C.iridescence>0,bt=C.sheen>0,kt=C.transmission>0,Pt=L&&!!C.anisotropyMap,zt=nt&&!!C.clearcoatMap,ye=nt&&!!C.clearcoatNormalMap,Dt=nt&&!!C.clearcoatRoughnessMap,Gt=St&&!!C.iridescenceMap,te=St&&!!C.iridescenceThicknessMap,qt=bt&&!!C.sheenColorMap,mt=bt&&!!C.sheenRoughnessMap,Ut=!!C.specularMap,Vt=!!C.specularColorMap,Lt=!!C.specularIntensityMap,j=kt&&!!C.transmissionMap,Ct=kt&&!!C.thicknessMap,ot=!!C.gradientMap,vt=!!C.alphaMap,wt=C.alphaTest>0,Nt=!!C.alphaHash,ne=!!C.extensions;let je=ao;C.toneMapped&&(Mt===null||Mt.isXRRenderTarget===!0)&&(je=e.toneMapping);const hn={shaderID:yt,shaderType:C.type,shaderName:C.name,vertexShader:Tt,fragmentShader:J,defines:C.defines,customVertexShaderID:ht,customFragmentShaderID:Et,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:_,batching:oe,batchingColor:oe&&$._colorsTexture!==null,instancing:ee,instancingColor:ee&&$.instanceColor!==null,instancingMorph:ee&&$.morphTexture!==null,supportsVertexTextures:b,outputColorSpace:Mt===null?e.outputColorSpace:Mt.isXRRenderTarget===!0?Mt.texture.colorSpace:Bi,alphaToCoverage:!!C.alphaToCoverage,map:on,matcap:$e,envMap:Me,envMapMode:Me&&Q.mapping,envMapCubeUVHeight:X,aoMap:G,lightMap:ii,bumpMap:me,normalMap:Se,displacementMap:b&&Zt,emissiveMap:He,normalMapObjectSpace:Se&&C.normalMapType===O5,normalMapTangentSpace:Se&&C.normalMapType===g3,metalnessMap:Yt,roughnessMap:B,anisotropy:L,anisotropyMap:Pt,clearcoat:nt,clearcoatMap:zt,clearcoatNormalMap:ye,clearcoatRoughnessMap:Dt,dispersion:dt,iridescence:St,iridescenceMap:Gt,iridescenceThicknessMap:te,sheen:bt,sheenColorMap:qt,sheenRoughnessMap:mt,specularMap:Ut,specularColorMap:Vt,specularIntensityMap:Lt,transmission:kt,transmissionMap:j,thicknessMap:Ct,gradientMap:ot,opaque:C.transparent===!1&&C.blending===Ac&&C.alphaToCoverage===!1,alphaMap:vt,alphaTest:wt,alphaHash:Nt,combine:C.combine,mapUv:on&&A(C.map.channel),aoMapUv:G&&A(C.aoMap.channel),lightMapUv:ii&&A(C.lightMap.channel),bumpMapUv:me&&A(C.bumpMap.channel),normalMapUv:Se&&A(C.normalMap.channel),displacementMapUv:Zt&&A(C.displacementMap.channel),emissiveMapUv:He&&A(C.emissiveMap.channel),metalnessMapUv:Yt&&A(C.metalnessMap.channel),roughnessMapUv:B&&A(C.roughnessMap.channel),anisotropyMapUv:Pt&&A(C.anisotropyMap.channel),clearcoatMapUv:zt&&A(C.clearcoatMap.channel),clearcoatNormalMapUv:ye&&A(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Dt&&A(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Gt&&A(C.iridescenceMap.channel),iridescenceThicknessMapUv:te&&A(C.iridescenceThicknessMap.channel),sheenColorMapUv:qt&&A(C.sheenColorMap.channel),sheenRoughnessMapUv:mt&&A(C.sheenRoughnessMap.channel),specularMapUv:Ut&&A(C.specularMap.channel),specularColorMapUv:Vt&&A(C.specularColorMap.channel),specularIntensityMapUv:Lt&&A(C.specularIntensityMap.channel),transmissionMapUv:j&&A(C.transmissionMap.channel),thicknessMapUv:Ct&&A(C.thicknessMap.channel),alphaMapUv:vt&&A(C.alphaMap.channel),vertexTangents:!!ut.attributes.tangent&&(Se||L),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!ut.attributes.color&&ut.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!ut.attributes.uv&&(on||vt),fog:!!lt,useFog:C.fog===!0,fogExp2:!!lt&<.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:m,reverseDepthBuffer:Ht,skinning:$.isSkinnedMesh===!0,morphTargets:ut.morphAttributes.position!==void 0,morphNormals:ut.morphAttributes.normal!==void 0,morphColors:ut.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:it,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:l.numPlanes,numClipIntersection:l.numIntersection,dithering:C.dithering,shadowMapEnabled:e.shadowMap.enabled&&F.length>0,shadowMapType:e.shadowMap.type,toneMapping:je,decodeVideoTexture:on&&C.map.isVideoTexture===!0&&Ie.getTransfer(C.map.colorSpace)===an,decodeVideoTextureEmissive:He&&C.emissiveMap.isVideoTexture===!0&&Ie.getTransfer(C.emissiveMap.colorSpace)===an,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Is,flipSided:C.side===Ji,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:ne&&C.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&C.extensions.multiDraw===!0||oe)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return hn.vertexUv1s=d.has(1),hn.vertexUv2s=d.has(2),hn.vertexUv3s=d.has(3),d.clear(),hn}function y(C){const R=[];if(C.shaderID?R.push(C.shaderID):(R.push(C.customVertexShaderID),R.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)R.push(F),R.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(E(R,C),w(R,C),R.push(e.outputColorSpace)),R.push(C.customProgramCacheKey),R.join()}function E(C,R){C.push(R.precision),C.push(R.outputColorSpace),C.push(R.envMapMode),C.push(R.envMapCubeUVHeight),C.push(R.mapUv),C.push(R.alphaMapUv),C.push(R.lightMapUv),C.push(R.aoMapUv),C.push(R.bumpMapUv),C.push(R.normalMapUv),C.push(R.displacementMapUv),C.push(R.emissiveMapUv),C.push(R.metalnessMapUv),C.push(R.roughnessMapUv),C.push(R.anisotropyMapUv),C.push(R.clearcoatMapUv),C.push(R.clearcoatNormalMapUv),C.push(R.clearcoatRoughnessMapUv),C.push(R.iridescenceMapUv),C.push(R.iridescenceThicknessMapUv),C.push(R.sheenColorMapUv),C.push(R.sheenRoughnessMapUv),C.push(R.specularMapUv),C.push(R.specularColorMapUv),C.push(R.specularIntensityMapUv),C.push(R.transmissionMapUv),C.push(R.thicknessMapUv),C.push(R.combine),C.push(R.fogExp2),C.push(R.sizeAttenuation),C.push(R.morphTargetsCount),C.push(R.morphAttributeCount),C.push(R.numDirLights),C.push(R.numPointLights),C.push(R.numSpotLights),C.push(R.numSpotLightMaps),C.push(R.numHemiLights),C.push(R.numRectAreaLights),C.push(R.numDirLightShadows),C.push(R.numPointLightShadows),C.push(R.numSpotLightShadows),C.push(R.numSpotLightShadowsWithMaps),C.push(R.numLightProbes),C.push(R.shadowMapType),C.push(R.toneMapping),C.push(R.numClippingPlanes),C.push(R.numClipIntersection),C.push(R.depthPacking)}function w(C,R){u.disableAll(),R.supportsVertexTextures&&u.enable(0),R.instancing&&u.enable(1),R.instancingColor&&u.enable(2),R.instancingMorph&&u.enable(3),R.matcap&&u.enable(4),R.envMap&&u.enable(5),R.normalMapObjectSpace&&u.enable(6),R.normalMapTangentSpace&&u.enable(7),R.clearcoat&&u.enable(8),R.iridescence&&u.enable(9),R.alphaTest&&u.enable(10),R.vertexColors&&u.enable(11),R.vertexAlphas&&u.enable(12),R.vertexUv1s&&u.enable(13),R.vertexUv2s&&u.enable(14),R.vertexUv3s&&u.enable(15),R.vertexTangents&&u.enable(16),R.anisotropy&&u.enable(17),R.alphaHash&&u.enable(18),R.batching&&u.enable(19),R.dispersion&&u.enable(20),R.batchingColor&&u.enable(21),C.push(u.mask),u.disableAll(),R.fog&&u.enable(0),R.useFog&&u.enable(1),R.flatShading&&u.enable(2),R.logarithmicDepthBuffer&&u.enable(3),R.reverseDepthBuffer&&u.enable(4),R.skinning&&u.enable(5),R.morphTargets&&u.enable(6),R.morphNormals&&u.enable(7),R.morphColors&&u.enable(8),R.premultipliedAlpha&&u.enable(9),R.shadowMapEnabled&&u.enable(10),R.doubleSided&&u.enable(11),R.flipSided&&u.enable(12),R.useDepthPacking&&u.enable(13),R.dithering&&u.enable(14),R.transmission&&u.enable(15),R.sheen&&u.enable(16),R.opaque&&u.enable(17),R.pointsUvs&&u.enable(18),R.decodeVideoTexture&&u.enable(19),R.decodeVideoTextureEmissive&&u.enable(20),R.alphaToCoverage&&u.enable(21),C.push(u.mask)}function T(C){const R=S[C.type];let F;if(R){const Y=_a[R];F=wN.clone(Y.uniforms)}else F=C.uniforms;return F}function P(C,R){let F;for(let Y=0,$=p.length;Y<$;Y++){const lt=p[Y];if(lt.cacheKey===R){F=lt,++F.usedTimes;break}}return F===void 0&&(F=new P6(e,R,C,o),p.push(F)),F}function O(C){if(--C.usedTimes===0){const R=p.indexOf(C);p[R]=p[p.length-1],p.pop(),C.destroy()}}function U(C){h.remove(C)}function I(){h.dispose()}return{getParameters:x,getProgramCacheKey:y,getUniforms:T,acquireProgram:P,releaseProgram:O,releaseShaderCache:U,programs:p,dispose:I}}function k6(){let e=new WeakMap;function t(l){return e.has(l)}function n(l){let u=e.get(l);return u===void 0&&(u={},e.set(l,u)),u}function i(l){e.delete(l)}function a(l,u,h){e.get(l)[u]=h}function o(){e=new WeakMap}return{has:t,get:n,remove:i,update:a,dispose:o}}function z6(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function TA(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function EA(){const e=[];let t=0;const n=[],i=[],a=[];function o(){t=0,n.length=0,i.length=0,a.length=0}function l(m,b,_,S,A,x){let y=e[t];return y===void 0?(y={id:m.id,object:m,geometry:b,material:_,groupOrder:S,renderOrder:m.renderOrder,z:A,group:x},e[t]=y):(y.id=m.id,y.object=m,y.geometry=b,y.material=_,y.groupOrder=S,y.renderOrder=m.renderOrder,y.z=A,y.group=x),t++,y}function u(m,b,_,S,A,x){const y=l(m,b,_,S,A,x);_.transmission>0?i.push(y):_.transparent===!0?a.push(y):n.push(y)}function h(m,b,_,S,A,x){const y=l(m,b,_,S,A,x);_.transmission>0?i.unshift(y):_.transparent===!0?a.unshift(y):n.unshift(y)}function d(m,b){n.length>1&&n.sort(m||z6),i.length>1&&i.sort(b||TA),a.length>1&&a.sort(b||TA)}function p(){for(let m=t,b=e.length;m=o.length?(l=new EA,o.push(l)):l=o[a],l}function n(){e=new WeakMap}return{get:t,dispose:n}}function G6(){const e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new H,color:new de};break;case"SpotLight":n={position:new H,direction:new H,color:new de,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new H,color:new de,distance:0,decay:0};break;case"HemisphereLight":n={direction:new H,skyColor:new de,groundColor:new de};break;case"RectAreaLight":n={color:new de,position:new H,halfWidth:new H,halfHeight:new H};break}return e[t.id]=n,n}}}function H6(){const e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}let j6=0;function W6(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function X6(e){const t=new G6,n=H6(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)i.probe.push(new H);const a=new H,o=new _e,l=new _e;function u(d){let p=0,m=0,b=0;for(let C=0;C<9;C++)i.probe[C].set(0,0,0);let _=0,S=0,A=0,x=0,y=0,E=0,w=0,T=0,P=0,O=0,U=0;d.sort(W6);for(let C=0,R=d.length;C0&&(e.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=It.LTC_FLOAT_1,i.rectAreaLTC2=It.LTC_FLOAT_2):(i.rectAreaLTC1=It.LTC_HALF_1,i.rectAreaLTC2=It.LTC_HALF_2)),i.ambient[0]=p,i.ambient[1]=m,i.ambient[2]=b;const I=i.hash;(I.directionalLength!==_||I.pointLength!==S||I.spotLength!==A||I.rectAreaLength!==x||I.hemiLength!==y||I.numDirectionalShadows!==E||I.numPointShadows!==w||I.numSpotShadows!==T||I.numSpotMaps!==P||I.numLightProbes!==U)&&(i.directional.length=_,i.spot.length=A,i.rectArea.length=x,i.point.length=S,i.hemi.length=y,i.directionalShadow.length=E,i.directionalShadowMap.length=E,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=T,i.spotShadowMap.length=T,i.directionalShadowMatrix.length=E,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=T+P-O,i.spotLightMap.length=P,i.numSpotLightShadowsWithMaps=O,i.numLightProbes=U,I.directionalLength=_,I.pointLength=S,I.spotLength=A,I.rectAreaLength=x,I.hemiLength=y,I.numDirectionalShadows=E,I.numPointShadows=w,I.numSpotShadows=T,I.numSpotMaps=P,I.numLightProbes=U,i.version=j6++)}function h(d,p){let m=0,b=0,_=0,S=0,A=0;const x=p.matrixWorldInverse;for(let y=0,E=d.length;y=l.length?(u=new wA(e),l.push(u)):u=l[o],u}function i(){t=new WeakMap}return{get:n,dispose:i}}const Y6=`void main() { gl_Position = vec4( position, 1.0 ); }`,K6=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function Z6(e,t,n){let i=new V1;const a=new Ae,o=new Ae,l=new qe,u=new HN({depthPacking:P5}),h=new jN,d={},p=n.maxTextureSize,m={[hr]:Ji,[Ji]:hr,[Is]:Is},b=new oo({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ae},radius:{value:4}},vertexShader:Y6,fragmentShader:K6}),_=b.clone();_.defines.HORIZONTAL_PASS=1;const S=new $i;S.setAttribute("position",new Fi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const A=new Ye(S,b),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=n3;let y=this.type;this.render=function(O,U,I){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||O.length===0)return;const C=e.getRenderTarget(),R=e.getActiveCubeFace(),F=e.getActiveMipmapLevel(),Y=e.state;Y.setBlending(so),Y.buffers.color.setClear(1,1,1,1),Y.buffers.depth.setTest(!0),Y.setScissorTest(!1);const $=y!==rr&&this.type===rr,lt=y===rr&&this.type!==rr;for(let ut=0,k=O.length;utp||a.y>p)&&(a.x>p&&(o.x=Math.floor(p/yt.x),a.x=o.x*yt.x,X.mapSize.x=o.x),a.y>p&&(o.y=Math.floor(p/yt.y),a.y=o.y*yt.y,X.mapSize.y=o.y)),X.map===null||$===!0||lt===!0){const z=this.type!==rr?{minFilter:Ii,magFilter:Ii}:{};X.map!==null&&X.map.dispose(),X.map=new ul(a.x,a.y,z),X.map.texture.name=Q.name+".shadowMap",X.camera.updateProjectionMatrix()}e.setRenderTarget(X.map),e.clear();const At=X.getViewportCount();for(let z=0;z0||U.map&&U.alphaTest>0){const Y=R.uuid,$=U.uuid;let lt=d[Y];lt===void 0&&(lt={},d[Y]=lt);let ut=lt[$];ut===void 0&&(ut=R.clone(),lt[$]=ut,U.addEventListener("dispose",P)),R=ut}if(R.visible=U.visible,R.wireframe=U.wireframe,C===rr?R.side=U.shadowSide!==null?U.shadowSide:U.side:R.side=U.shadowSide!==null?U.shadowSide:m[U.side],R.alphaMap=U.alphaMap,R.alphaTest=U.alphaTest,R.map=U.map,R.clipShadows=U.clipShadows,R.clippingPlanes=U.clippingPlanes,R.clipIntersection=U.clipIntersection,R.displacementMap=U.displacementMap,R.displacementScale=U.displacementScale,R.displacementBias=U.displacementBias,R.wireframeLinewidth=U.wireframeLinewidth,R.linewidth=U.linewidth,I.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const Y=e.properties.get(R);Y.light=I}return R}function T(O,U,I,C,R){if(O.visible===!1)return;if(O.layers.test(U.layers)&&(O.isMesh||O.isLine||O.isPoints)&&(O.castShadow||O.receiveShadow&&R===rr)&&(!O.frustumCulled||i.intersectsObject(O))){O.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,O.matrixWorld);const $=t.update(O),lt=O.material;if(Array.isArray(lt)){const ut=$.groups;for(let k=0,Q=ut.length;k=1):X.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),k=Q>=2);let yt=null,At={};const z=e.getParameter(e.SCISSOR_BOX),it=e.getParameter(e.VIEWPORT),Tt=new qe().fromArray(z),J=new qe().fromArray(it);function ht(j,Ct,ot,vt){const wt=new Uint8Array(4),Nt=e.createTexture();e.bindTexture(j,Nt),e.texParameteri(j,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(j,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let ne=0;ne"u"?!1:/OculusBrowser/g.test(navigator.userAgent),d=new Ae,p=new WeakMap;let m;const b=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(B,L){return _?new OffscreenCanvas(B,L):Wf("canvas")}function A(B,L,nt){let dt=1;const St=Yt(B);if((St.width>nt||St.height>nt)&&(dt=nt/Math.max(St.width,St.height)),dt<1)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap||typeof VideoFrame<"u"&&B instanceof VideoFrame){const bt=Math.floor(dt*St.width),kt=Math.floor(dt*St.height);m===void 0&&(m=S(bt,kt));const Pt=L?S(bt,kt):m;return Pt.width=bt,Pt.height=kt,Pt.getContext("2d").drawImage(B,0,0,bt,kt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+St.width+"x"+St.height+") to ("+bt+"x"+kt+")."),Pt}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+St.width+"x"+St.height+")."),B;return B}function x(B){return B.generateMipmaps}function y(B){e.generateMipmap(B)}function E(B){return B.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:B.isWebGL3DRenderTarget?e.TEXTURE_3D:B.isWebGLArrayRenderTarget||B.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function w(B,L,nt,dt,St=!1){if(B!==null){if(e[B]!==void 0)return e[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let bt=L;if(L===e.RED&&(nt===e.FLOAT&&(bt=e.R32F),nt===e.HALF_FLOAT&&(bt=e.R16F),nt===e.UNSIGNED_BYTE&&(bt=e.R8)),L===e.RED_INTEGER&&(nt===e.UNSIGNED_BYTE&&(bt=e.R8UI),nt===e.UNSIGNED_SHORT&&(bt=e.R16UI),nt===e.UNSIGNED_INT&&(bt=e.R32UI),nt===e.BYTE&&(bt=e.R8I),nt===e.SHORT&&(bt=e.R16I),nt===e.INT&&(bt=e.R32I)),L===e.RG&&(nt===e.FLOAT&&(bt=e.RG32F),nt===e.HALF_FLOAT&&(bt=e.RG16F),nt===e.UNSIGNED_BYTE&&(bt=e.RG8)),L===e.RG_INTEGER&&(nt===e.UNSIGNED_BYTE&&(bt=e.RG8UI),nt===e.UNSIGNED_SHORT&&(bt=e.RG16UI),nt===e.UNSIGNED_INT&&(bt=e.RG32UI),nt===e.BYTE&&(bt=e.RG8I),nt===e.SHORT&&(bt=e.RG16I),nt===e.INT&&(bt=e.RG32I)),L===e.RGB_INTEGER&&(nt===e.UNSIGNED_BYTE&&(bt=e.RGB8UI),nt===e.UNSIGNED_SHORT&&(bt=e.RGB16UI),nt===e.UNSIGNED_INT&&(bt=e.RGB32UI),nt===e.BYTE&&(bt=e.RGB8I),nt===e.SHORT&&(bt=e.RGB16I),nt===e.INT&&(bt=e.RGB32I)),L===e.RGBA_INTEGER&&(nt===e.UNSIGNED_BYTE&&(bt=e.RGBA8UI),nt===e.UNSIGNED_SHORT&&(bt=e.RGBA16UI),nt===e.UNSIGNED_INT&&(bt=e.RGBA32UI),nt===e.BYTE&&(bt=e.RGBA8I),nt===e.SHORT&&(bt=e.RGBA16I),nt===e.INT&&(bt=e.RGBA32I)),L===e.RGB&&nt===e.UNSIGNED_INT_5_9_9_9_REV&&(bt=e.RGB9_E5),L===e.RGBA){const kt=St?Rp:Ie.getTransfer(dt);nt===e.FLOAT&&(bt=e.RGBA32F),nt===e.HALF_FLOAT&&(bt=e.RGBA16F),nt===e.UNSIGNED_BYTE&&(bt=kt===an?e.SRGB8_ALPHA8:e.RGBA8),nt===e.UNSIGNED_SHORT_4_4_4_4&&(bt=e.RGBA4),nt===e.UNSIGNED_SHORT_5_5_5_1&&(bt=e.RGB5_A1)}return(bt===e.R16F||bt===e.R32F||bt===e.RG16F||bt===e.RG32F||bt===e.RGBA16F||bt===e.RGBA32F)&&t.get("EXT_color_buffer_float"),bt}function T(B,L){let nt;return B?L===null||L===cl||L===Pc?nt=e.DEPTH24_STENCIL8:L===na?nt=e.DEPTH32F_STENCIL8:L===Gf&&(nt=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===cl||L===Pc?nt=e.DEPTH_COMPONENT24:L===na?nt=e.DEPTH_COMPONENT32F:L===Gf&&(nt=e.DEPTH_COMPONENT16),nt}function P(B,L){return x(B)===!0||B.isFramebufferTexture&&B.minFilter!==Ii&&B.minFilter!==ps?Math.log2(Math.max(L.width,L.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?L.mipmaps.length:1}function O(B){const L=B.target;L.removeEventListener("dispose",O),I(L),L.isVideoTexture&&p.delete(L)}function U(B){const L=B.target;L.removeEventListener("dispose",U),R(L)}function I(B){const L=i.get(B);if(L.__webglInit===void 0)return;const nt=B.source,dt=b.get(nt);if(dt){const St=dt[L.__cacheKey];St.usedTimes--,St.usedTimes===0&&C(B),Object.keys(dt).length===0&&b.delete(nt)}i.remove(B)}function C(B){const L=i.get(B);e.deleteTexture(L.__webglTexture);const nt=B.source,dt=b.get(nt);delete dt[L.__cacheKey],l.memory.textures--}function R(B){const L=i.get(B);if(B.depthTexture&&(B.depthTexture.dispose(),i.remove(B.depthTexture)),B.isWebGLCubeRenderTarget)for(let dt=0;dt<6;dt++){if(Array.isArray(L.__webglFramebuffer[dt]))for(let St=0;St=a.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+a.maxTextures),F+=1,B}function lt(B){const L=[];return L.push(B.wrapS),L.push(B.wrapT),L.push(B.wrapR||0),L.push(B.magFilter),L.push(B.minFilter),L.push(B.anisotropy),L.push(B.internalFormat),L.push(B.format),L.push(B.type),L.push(B.generateMipmaps),L.push(B.premultiplyAlpha),L.push(B.flipY),L.push(B.unpackAlignment),L.push(B.colorSpace),L.join()}function ut(B,L){const nt=i.get(B);if(B.isVideoTexture&&Zt(B),B.isRenderTargetTexture===!1&&B.version>0&&nt.__version!==B.version){const dt=B.image;if(dt===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(dt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{J(nt,B,L);return}}n.bindTexture(e.TEXTURE_2D,nt.__webglTexture,e.TEXTURE0+L)}function k(B,L){const nt=i.get(B);if(B.version>0&&nt.__version!==B.version){J(nt,B,L);return}n.bindTexture(e.TEXTURE_2D_ARRAY,nt.__webglTexture,e.TEXTURE0+L)}function Q(B,L){const nt=i.get(B);if(B.version>0&&nt.__version!==B.version){J(nt,B,L);return}n.bindTexture(e.TEXTURE_3D,nt.__webglTexture,e.TEXTURE0+L)}function X(B,L){const nt=i.get(B);if(B.version>0&&nt.__version!==B.version){ht(nt,B,L);return}n.bindTexture(e.TEXTURE_CUBE_MAP,nt.__webglTexture,e.TEXTURE0+L)}const yt={[Uc]:e.REPEAT,[eo]:e.CLAMP_TO_EDGE,[Ep]:e.MIRRORED_REPEAT},At={[Ii]:e.NEAREST,[a3]:e.NEAREST_MIPMAP_NEAREST,[Tf]:e.NEAREST_MIPMAP_LINEAR,[ps]:e.LINEAR,[cp]:e.LINEAR_MIPMAP_NEAREST,[cr]:e.LINEAR_MIPMAP_LINEAR},z={[I5]:e.NEVER,[G5]:e.ALWAYS,[F5]:e.LESS,[b3]:e.LEQUAL,[B5]:e.EQUAL,[V5]:e.GEQUAL,[k5]:e.GREATER,[z5]:e.NOTEQUAL};function it(B,L){if(L.type===na&&t.has("OES_texture_float_linear")===!1&&(L.magFilter===ps||L.magFilter===cp||L.magFilter===Tf||L.magFilter===cr||L.minFilter===ps||L.minFilter===cp||L.minFilter===Tf||L.minFilter===cr)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(B,e.TEXTURE_WRAP_S,yt[L.wrapS]),e.texParameteri(B,e.TEXTURE_WRAP_T,yt[L.wrapT]),(B===e.TEXTURE_3D||B===e.TEXTURE_2D_ARRAY)&&e.texParameteri(B,e.TEXTURE_WRAP_R,yt[L.wrapR]),e.texParameteri(B,e.TEXTURE_MAG_FILTER,At[L.magFilter]),e.texParameteri(B,e.TEXTURE_MIN_FILTER,At[L.minFilter]),L.compareFunction&&(e.texParameteri(B,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(B,e.TEXTURE_COMPARE_FUNC,z[L.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===Ii||L.minFilter!==Tf&&L.minFilter!==cr||L.type===na&&t.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||i.get(L).__currentAnisotropy){const nt=t.get("EXT_texture_filter_anisotropic");e.texParameterf(B,nt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,a.getMaxAnisotropy())),i.get(L).__currentAnisotropy=L.anisotropy}}}function Tt(B,L){let nt=!1;B.__webglInit===void 0&&(B.__webglInit=!0,L.addEventListener("dispose",O));const dt=L.source;let St=b.get(dt);St===void 0&&(St={},b.set(dt,St));const bt=lt(L);if(bt!==B.__cacheKey){St[bt]===void 0&&(St[bt]={texture:e.createTexture(),usedTimes:0},l.memory.textures++,nt=!0),St[bt].usedTimes++;const kt=St[B.__cacheKey];kt!==void 0&&(St[B.__cacheKey].usedTimes--,kt.usedTimes===0&&C(L)),B.__cacheKey=bt,B.__webglTexture=St[bt].texture}return nt}function J(B,L,nt){let dt=e.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(dt=e.TEXTURE_2D_ARRAY),L.isData3DTexture&&(dt=e.TEXTURE_3D);const St=Tt(B,L),bt=L.source;n.bindTexture(dt,B.__webglTexture,e.TEXTURE0+nt);const kt=i.get(bt);if(bt.version!==kt.__version||St===!0){n.activeTexture(e.TEXTURE0+nt);const Pt=Ie.getPrimaries(Ie.workingColorSpace),zt=L.colorSpace===$r?null:Ie.getPrimaries(L.colorSpace),ye=L.colorSpace===$r||Pt===zt?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,L.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,L.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,ye);let Dt=A(L.image,!1,a.maxTextureSize);Dt=He(L,Dt);const Gt=o.convert(L.format,L.colorSpace),te=o.convert(L.type);let qt=w(L.internalFormat,Gt,te,L.colorSpace,L.isVideoTexture);it(dt,L);let mt;const Ut=L.mipmaps,Vt=L.isVideoTexture!==!0,Lt=kt.__version===void 0||St===!0,j=bt.dataReady,Ct=P(L,Dt);if(L.isDepthTexture)qt=T(L.format===Oc,L.type),Lt&&(Vt?n.texStorage2D(e.TEXTURE_2D,1,qt,Dt.width,Dt.height):n.texImage2D(e.TEXTURE_2D,0,qt,Dt.width,Dt.height,0,Gt,te,null));else if(L.isDataTexture)if(Ut.length>0){Vt&&Lt&&n.texStorage2D(e.TEXTURE_2D,Ct,qt,Ut[0].width,Ut[0].height);for(let ot=0,vt=Ut.length;ot0){const wt=iA(mt.width,mt.height,L.format,L.type);for(const Nt of L.layerUpdates){const ne=mt.data.subarray(Nt*wt/mt.data.BYTES_PER_ELEMENT,(Nt+1)*wt/mt.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ot,0,0,Nt,mt.width,mt.height,1,Gt,ne)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,ot,0,0,0,mt.width,mt.height,Dt.depth,Gt,mt.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,ot,qt,mt.width,mt.height,Dt.depth,0,mt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Vt?j&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,ot,0,0,0,mt.width,mt.height,Dt.depth,Gt,te,mt.data):n.texImage3D(e.TEXTURE_2D_ARRAY,ot,qt,mt.width,mt.height,Dt.depth,0,Gt,te,mt.data)}else{Vt&&Lt&&n.texStorage2D(e.TEXTURE_2D,Ct,qt,Ut[0].width,Ut[0].height);for(let ot=0,vt=Ut.length;ot0){const ot=iA(Dt.width,Dt.height,L.format,L.type);for(const vt of L.layerUpdates){const wt=Dt.data.subarray(vt*ot/Dt.data.BYTES_PER_ELEMENT,(vt+1)*ot/Dt.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,vt,Dt.width,Dt.height,1,Gt,te,wt)}L.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,Dt.width,Dt.height,Dt.depth,Gt,te,Dt.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,qt,Dt.width,Dt.height,Dt.depth,0,Gt,te,Dt.data);else if(L.isData3DTexture)Vt?(Lt&&n.texStorage3D(e.TEXTURE_3D,Ct,qt,Dt.width,Dt.height,Dt.depth),j&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,Dt.width,Dt.height,Dt.depth,Gt,te,Dt.data)):n.texImage3D(e.TEXTURE_3D,0,qt,Dt.width,Dt.height,Dt.depth,0,Gt,te,Dt.data);else if(L.isFramebufferTexture){if(Lt)if(Vt)n.texStorage2D(e.TEXTURE_2D,Ct,qt,Dt.width,Dt.height);else{let ot=Dt.width,vt=Dt.height;for(let wt=0;wt>=1,vt>>=1}}else if(Ut.length>0){if(Vt&&Lt){const ot=Yt(Ut[0]);n.texStorage2D(e.TEXTURE_2D,Ct,qt,ot.width,ot.height)}for(let ot=0,vt=Ut.length;ot0&&Ct++;const vt=Yt(Gt[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,Ct,Ut,vt.width,vt.height)}for(let vt=0;vt<6;vt++)if(Dt){Vt?j&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+vt,0,0,0,Gt[vt].width,Gt[vt].height,qt,mt,Gt[vt].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+vt,0,Ut,Gt[vt].width,Gt[vt].height,0,qt,mt,Gt[vt].data);for(let wt=0;wt>bt),te=Math.max(1,L.height>>bt);St===e.TEXTURE_3D||St===e.TEXTURE_2D_ARRAY?n.texImage3D(St,bt,zt,Gt,te,L.depth,0,kt,Pt,null):n.texImage2D(St,bt,zt,Gt,te,0,kt,Pt,null)}n.bindFramebuffer(e.FRAMEBUFFER,B),Se(L)?u.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,dt,St,Dt.__webglTexture,0,me(L)):(St===e.TEXTURE_2D||St>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&St<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,dt,St,Dt.__webglTexture,bt),n.bindFramebuffer(e.FRAMEBUFFER,null)}function Mt(B,L,nt){if(e.bindRenderbuffer(e.RENDERBUFFER,B),L.depthBuffer){const dt=L.depthTexture,St=dt&&dt.isDepthTexture?dt.type:null,bt=T(L.stencilBuffer,St),kt=L.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,Pt=me(L);Se(L)?u.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,Pt,bt,L.width,L.height):nt?e.renderbufferStorageMultisample(e.RENDERBUFFER,Pt,bt,L.width,L.height):e.renderbufferStorage(e.RENDERBUFFER,bt,L.width,L.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,kt,e.RENDERBUFFER,B)}else{const dt=L.textures;for(let St=0;St{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,dt.removeEventListener("dispose",St)};dt.addEventListener("dispose",St),L.__depthDisposeCallback=St}L.__boundDepthTexture=dt}if(B.depthTexture&&!L.__autoAllocateDepthBuffer){if(nt)throw new Error("target.depthTexture not supported in Cube render targets");Ht(L.__webglFramebuffer,B)}else if(nt){L.__webglDepthbuffer=[];for(let dt=0;dt<6;dt++)if(n.bindFramebuffer(e.FRAMEBUFFER,L.__webglFramebuffer[dt]),L.__webglDepthbuffer[dt]===void 0)L.__webglDepthbuffer[dt]=e.createRenderbuffer(),Mt(L.__webglDepthbuffer[dt],B,!1);else{const St=B.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,bt=L.__webglDepthbuffer[dt];e.bindRenderbuffer(e.RENDERBUFFER,bt),e.framebufferRenderbuffer(e.FRAMEBUFFER,St,e.RENDERBUFFER,bt)}}else if(n.bindFramebuffer(e.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=e.createRenderbuffer(),Mt(L.__webglDepthbuffer,B,!1);else{const dt=B.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,St=L.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,St),e.framebufferRenderbuffer(e.FRAMEBUFFER,dt,e.RENDERBUFFER,St)}n.bindFramebuffer(e.FRAMEBUFFER,null)}function oe(B,L,nt){const dt=i.get(B);L!==void 0&&Et(dt.__webglFramebuffer,B,B.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),nt!==void 0&&ee(B)}function on(B){const L=B.texture,nt=i.get(B),dt=i.get(L);B.addEventListener("dispose",U);const St=B.textures,bt=B.isWebGLCubeRenderTarget===!0,kt=St.length>1;if(kt||(dt.__webglTexture===void 0&&(dt.__webglTexture=e.createTexture()),dt.__version=L.version,l.memory.textures++),bt){nt.__webglFramebuffer=[];for(let Pt=0;Pt<6;Pt++)if(L.mipmaps&&L.mipmaps.length>0){nt.__webglFramebuffer[Pt]=[];for(let zt=0;zt0){nt.__webglFramebuffer=[];for(let Pt=0;Pt0&&Se(B)===!1){nt.__webglMultisampledFramebuffer=e.createFramebuffer(),nt.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,nt.__webglMultisampledFramebuffer);for(let Pt=0;Pt0)for(let zt=0;zt0)for(let zt=0;zt0){if(Se(B)===!1){const L=B.textures,nt=B.width,dt=B.height;let St=e.COLOR_BUFFER_BIT;const bt=B.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,kt=i.get(B),Pt=L.length>1;if(Pt)for(let zt=0;zt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Zt(B){const L=l.render.frame;p.get(B)!==L&&(p.set(B,L),B.update())}function He(B,L){const nt=B.colorSpace,dt=B.format,St=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||nt!==Bi&&nt!==$r&&(Ie.getTransfer(nt)===an?(dt!==Fs||St!==dr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",nt)),L}function Yt(B){return typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement?(d.width=B.naturalWidth||B.width,d.height=B.naturalHeight||B.height):typeof VideoFrame<"u"&&B instanceof VideoFrame?(d.width=B.displayWidth,d.height=B.displayHeight):(d.width=B.width,d.height=B.height),d}this.allocateTextureUnit=$,this.resetTextureUnits=Y,this.setTexture2D=ut,this.setTexture2DArray=k,this.setTexture3D=Q,this.setTextureCube=X,this.rebindTextures=oe,this.setupRenderTarget=on,this.updateRenderTargetMipmap=$e,this.updateMultisampleRenderTarget=ii,this.setupDepthRenderbuffer=ee,this.setupFrameBufferTexture=Et,this.useMultisampledRTT=Se}function t8(e,t){function n(i,a=$r){let o;const l=Ie.getTransfer(a);if(i===dr)return e.UNSIGNED_BYTE;if(i===D1)return e.UNSIGNED_SHORT_4_4_4_4;if(i===L1)return e.UNSIGNED_SHORT_5_5_5_1;if(i===l3)return e.UNSIGNED_INT_5_9_9_9_REV;if(i===r3)return e.BYTE;if(i===o3)return e.SHORT;if(i===Gf)return e.UNSIGNED_SHORT;if(i===C1)return e.INT;if(i===cl)return e.UNSIGNED_INT;if(i===na)return e.FLOAT;if(i===eh)return e.HALF_FLOAT;if(i===c3)return e.ALPHA;if(i===u3)return e.RGB;if(i===Fs)return e.RGBA;if(i===f3)return e.LUMINANCE;if(i===h3)return e.LUMINANCE_ALPHA;if(i===Tc)return e.DEPTH_COMPONENT;if(i===Oc)return e.DEPTH_STENCIL;if(i===N1)return e.RED;if(i===U1)return e.RED_INTEGER;if(i===d3)return e.RG;if(i===P1)return e.RG_INTEGER;if(i===O1)return e.RGBA_INTEGER;if(i===up||i===fp||i===hp||i===dp)if(l===an)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(i===up)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===fp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===hp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===dp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(i===up)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===fp)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===hp)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===dp)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===av||i===rv||i===ov||i===lv)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(i===av)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===rv)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ov)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===lv)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===cv||i===uv||i===fv)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(i===cv||i===uv)return l===an?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(i===fv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===hv||i===dv||i===pv||i===mv||i===gv||i===bv||i===vv||i===_v||i===yv||i===xv||i===Sv||i===Mv||i===Av||i===Tv)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(i===hv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===dv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===pv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===mv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===gv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===bv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===vv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===_v)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===yv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===xv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Sv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Mv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Av)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Tv)return l===an?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===pp||i===Ev||i===wv)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(i===pp)return l===an?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Ev)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===wv)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===p3||i===Rv||i===Cv||i===Dv)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(i===pp)return o.COMPRESSED_RED_RGTC1_EXT;if(i===Rv)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Cv)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Dv)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Pc?e.UNSIGNED_INT_24_8:e[i]!==void 0?e[i]:null}return{convert:n}}const e8=` void main() { gl_Position = vec4( position, 1.0 ); }`,n8=` 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 i8{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,n,i){if(this.texture===null){const a=new Qn,o=t.properties.get(a);o.__webglTexture=n.texture,(n.depthNear!==i.depthNear||n.depthFar!==i.depthFar)&&(this.depthNear=n.depthNear,this.depthFar=n.depthFar),this.texture=a}}getMesh(t){if(this.texture!==null&&this.mesh===null){const n=t.cameras[0].viewport,i=new oo({vertexShader:e8,fragmentShader:n8,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Ye(new Zp(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class s8 extends ml{constructor(t,n){super();const i=this;let a=null,o=1,l=null,u="local-floor",h=1,d=null,p=null,m=null,b=null,_=null,S=null;const A=new i8,x=n.getContextAttributes();let y=null,E=null;const w=[],T=[],P=new Ae;let O=null;const U=new Ui;U.viewport=new qe;const I=new Ui;I.viewport=new qe;const C=[U,I],R=new uU;let F=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let ht=w[J];return ht===void 0&&(ht=new ab,w[J]=ht),ht.getTargetRaySpace()},this.getControllerGrip=function(J){let ht=w[J];return ht===void 0&&(ht=new ab,w[J]=ht),ht.getGripSpace()},this.getHand=function(J){let ht=w[J];return ht===void 0&&(ht=new ab,w[J]=ht),ht.getHandSpace()};function $(J){const ht=T.indexOf(J.inputSource);if(ht===-1)return;const Et=w[ht];Et!==void 0&&(Et.update(J.inputSource,J.frame,d||l),Et.dispatchEvent({type:J.type,data:J.inputSource}))}function lt(){a.removeEventListener("select",$),a.removeEventListener("selectstart",$),a.removeEventListener("selectend",$),a.removeEventListener("squeeze",$),a.removeEventListener("squeezestart",$),a.removeEventListener("squeezeend",$),a.removeEventListener("end",lt),a.removeEventListener("inputsourceschange",ut);for(let J=0;J=0&&(T[Mt]=null,w[Mt].disconnect(Et))}for(let ht=0;ht=T.length){T.push(Et),Mt=ee;break}else if(T[ee]===null){T[ee]=Et,Mt=ee;break}if(Mt===-1)break}const Ht=w[Mt];Ht&&Ht.connect(Et)}}const k=new H,Q=new H;function X(J,ht,Et){k.setFromMatrixPosition(ht.matrixWorld),Q.setFromMatrixPosition(Et.matrixWorld);const Mt=k.distanceTo(Q),Ht=ht.projectionMatrix.elements,ee=Et.projectionMatrix.elements,oe=Ht[14]/(Ht[10]-1),on=Ht[14]/(Ht[10]+1),$e=(Ht[9]+1)/Ht[5],Me=(Ht[9]-1)/Ht[5],G=(Ht[8]-1)/Ht[0],ii=(ee[8]+1)/ee[0],me=oe*G,Se=oe*ii,Zt=Mt/(-G+ii),He=Zt*-G;if(ht.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(He),J.translateZ(Zt),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert(),Ht[10]===-1)J.projectionMatrix.copy(ht.projectionMatrix),J.projectionMatrixInverse.copy(ht.projectionMatrixInverse);else{const Yt=oe+Zt,B=on+Zt,L=me-He,nt=Se+(Mt-He),dt=$e*on/B*Yt,St=Me*on/B*Yt;J.projectionMatrix.makePerspective(L,nt,dt,St,Yt,B),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}}function yt(J,ht){ht===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(ht.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(a===null)return;let ht=J.near,Et=J.far;A.texture!==null&&(A.depthNear>0&&(ht=A.depthNear),A.depthFar>0&&(Et=A.depthFar)),R.near=I.near=U.near=ht,R.far=I.far=U.far=Et,(F!==R.near||Y!==R.far)&&(a.updateRenderState({depthNear:R.near,depthFar:R.far}),F=R.near,Y=R.far),U.layers.mask=J.layers.mask|2,I.layers.mask=J.layers.mask|4,R.layers.mask=U.layers.mask|I.layers.mask;const Mt=J.parent,Ht=R.cameras;yt(R,Mt);for(let ee=0;ee0&&(x.alphaTest.value=y.alphaTest);const E=t.get(y),w=E.envMap,T=E.envMapRotation;w&&(x.envMap.value=w,ko.copy(T),ko.x*=-1,ko.y*=-1,ko.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(ko.y*=-1,ko.z*=-1),x.envMapRotation.value.setFromMatrix4(a8.makeRotationFromEuler(ko)),x.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=y.reflectivity,x.ior.value=y.ior,x.refractionRatio.value=y.refractionRatio),y.lightMap&&(x.lightMap.value=y.lightMap,x.lightMapIntensity.value=y.lightMapIntensity,n(y.lightMap,x.lightMapTransform)),y.aoMap&&(x.aoMap.value=y.aoMap,x.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,x.aoMapTransform))}function l(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform))}function u(x,y){x.dashSize.value=y.dashSize,x.totalSize.value=y.dashSize+y.gapSize,x.scale.value=y.scale}function h(x,y,E,w){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.size.value=y.size*E,x.scale.value=w*.5,y.map&&(x.map.value=y.map,n(y.map,x.uvTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function d(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.rotation.value=y.rotation,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function p(x,y){x.specular.value.copy(y.specular),x.shininess.value=Math.max(y.shininess,1e-4)}function m(x,y){y.gradientMap&&(x.gradientMap.value=y.gradientMap)}function b(x,y){x.metalness.value=y.metalness,y.metalnessMap&&(x.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,x.metalnessMapTransform)),x.roughness.value=y.roughness,y.roughnessMap&&(x.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,x.roughnessMapTransform)),y.envMap&&(x.envMapIntensity.value=y.envMapIntensity)}function _(x,y,E){x.ior.value=y.ior,y.sheen>0&&(x.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),x.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(x.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,x.sheenColorMapTransform)),y.sheenRoughnessMap&&(x.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,x.sheenRoughnessMapTransform))),y.clearcoat>0&&(x.clearcoat.value=y.clearcoat,x.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(x.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,x.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(x.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===Ji&&x.clearcoatNormalScale.value.negate())),y.dispersion>0&&(x.dispersion.value=y.dispersion),y.iridescence>0&&(x.iridescence.value=y.iridescence,x.iridescenceIOR.value=y.iridescenceIOR,x.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(x.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,x.iridescenceMapTransform)),y.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),y.transmission>0&&(x.transmission.value=y.transmission,x.transmissionSamplerMap.value=E.texture,x.transmissionSamplerSize.value.set(E.width,E.height),y.transmissionMap&&(x.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,x.transmissionMapTransform)),x.thickness.value=y.thickness,y.thicknessMap&&(x.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=y.attenuationDistance,x.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(x.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(x.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=y.specularIntensity,x.specularColor.value.copy(y.specularColor),y.specularColorMap&&(x.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,x.specularColorMapTransform)),y.specularIntensityMap&&(x.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,x.specularIntensityMapTransform))}function S(x,y){y.matcap&&(x.matcap.value=y.matcap)}function A(x,y){const E=t.get(y).light;x.referencePosition.value.setFromMatrixPosition(E.matrixWorld),x.nearDistance.value=E.shadow.camera.near,x.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:a}}function o8(e,t,n,i){let a={},o={},l=[];const u=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function h(E,w){const T=w.program;i.uniformBlockBinding(E,T)}function d(E,w){let T=a[E.id];T===void 0&&(S(E),T=p(E),a[E.id]=T,E.addEventListener("dispose",x));const P=w.program;i.updateUBOMapping(E,P);const O=t.render.frame;o[E.id]!==O&&(b(E),o[E.id]=O)}function p(E){const w=m();E.__bindingPointIndex=w;const T=e.createBuffer(),P=E.__size,O=E.usage;return e.bindBuffer(e.UNIFORM_BUFFER,T),e.bufferData(e.UNIFORM_BUFFER,P,O),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,w,T),T}function m(){for(let E=0;E0&&(T+=P-O),E.__size=T,E.__cache={},this}function A(E){const w={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),w}function x(E){const w=E.target;w.removeEventListener("dispose",x);const T=l.indexOf(w.__bindingPointIndex);l.splice(T,1),e.deleteBuffer(a[w.id]),delete a[w.id],delete o[w.id]}function y(){for(const E in a)e.deleteBuffer(a[E]);l=[],a={},o={}}return{bind:h,update:d,dispose:y}}class l8{constructor(t={}){const{canvas:n=aN(),context:i=null,depth:a=!0,stencil:o=!1,alpha:l=!1,antialias:u=!1,premultipliedAlpha:h=!0,preserveDrawingBuffer:d=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:m=!1,reverseDepthBuffer:b=!1}=t;this.isWebGLRenderer=!0;let _;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=i.getContextAttributes().alpha}else _=l;const S=new Uint32Array(4),A=new Int32Array(4);let x=null,y=null;const E=[],w=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=ci,this.toneMapping=ao,this.toneMappingExposure=1;const T=this;let P=!1,O=0,U=0,I=null,C=-1,R=null;const F=new qe,Y=new qe;let $=null;const lt=new de(0);let ut=0,k=n.width,Q=n.height,X=1,yt=null,At=null;const z=new qe(0,0,k,Q),it=new qe(0,0,k,Q);let Tt=!1;const J=new V1;let ht=!1,Et=!1;this.transmissionResolutionScale=1;const Mt=new _e,Ht=new _e,ee=new H,oe=new qe,on={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let $e=!1;function Me(){return I===null?X:1}let G=i;function ii(N,K){return n.getContext(N,K)}try{const N={alpha:!0,depth:a,stencil:o,antialias:u,premultipliedAlpha:h,preserveDrawingBuffer:d,powerPreference:p,failIfMajorPerformanceCaveat:m};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${R1}`),n.addEventListener("webglcontextlost",vt,!1),n.addEventListener("webglcontextrestored",wt,!1),n.addEventListener("webglcontextcreationerror",Nt,!1),G===null){const K="webgl2";if(G=ii(K,N),G===null)throw ii(K)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let me,Se,Zt,He,Yt,B,L,nt,dt,St,bt,kt,Pt,zt,ye,Dt,Gt,te,qt,mt,Ut,Vt,Lt,j;function Ct(){me=new vO(G),me.init(),Vt=new t8(G,me),Se=new fO(G,me,t,Vt),Zt=new J6(G,me),Se.reverseDepthBuffer&&b&&Zt.buffers.depth.setReversed(!0),He=new xO(G),Yt=new k6,B=new $6(G,me,Zt,Yt,Se,Vt,He),L=new dO(T),nt=new bO(T),dt=new wU(G),Lt=new cO(G,dt),St=new _O(G,dt,He,Lt),bt=new MO(G,St,dt,He),qt=new SO(G,Se,B),Dt=new hO(Yt),kt=new B6(T,L,nt,me,Se,Lt,Dt),Pt=new r8(T,Yt),zt=new V6,ye=new q6(me),te=new lO(T,L,nt,Zt,bt,_,h),Gt=new Z6(T,bt,Se),j=new o8(G,He,Se,Zt),mt=new uO(G,me,He),Ut=new yO(G,me,He),He.programs=kt.programs,T.capabilities=Se,T.extensions=me,T.properties=Yt,T.renderLists=zt,T.shadowMap=Gt,T.state=Zt,T.info=He}Ct();const ot=new s8(T,G);this.xr=ot,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){const N=me.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){const N=me.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return X},this.setPixelRatio=function(N){N!==void 0&&(X=N,this.setSize(k,Q,!1))},this.getSize=function(N){return N.set(k,Q)},this.setSize=function(N,K,at=!0){if(ot.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}k=N,Q=K,n.width=Math.floor(N*X),n.height=Math.floor(K*X),at===!0&&(n.style.width=N+"px",n.style.height=K+"px"),this.setViewport(0,0,N,K)},this.getDrawingBufferSize=function(N){return N.set(k*X,Q*X).floor()},this.setDrawingBufferSize=function(N,K,at){k=N,Q=K,X=at,n.width=Math.floor(N*at),n.height=Math.floor(K*at),this.setViewport(0,0,N,K)},this.getCurrentViewport=function(N){return N.copy(F)},this.getViewport=function(N){return N.copy(z)},this.setViewport=function(N,K,at,rt){N.isVector4?z.set(N.x,N.y,N.z,N.w):z.set(N,K,at,rt),Zt.viewport(F.copy(z).multiplyScalar(X).round())},this.getScissor=function(N){return N.copy(it)},this.setScissor=function(N,K,at,rt){N.isVector4?it.set(N.x,N.y,N.z,N.w):it.set(N,K,at,rt),Zt.scissor(Y.copy(it).multiplyScalar(X).round())},this.getScissorTest=function(){return Tt},this.setScissorTest=function(N){Zt.setScissorTest(Tt=N)},this.setOpaqueSort=function(N){yt=N},this.setTransparentSort=function(N){At=N},this.getClearColor=function(N){return N.copy(te.getClearColor())},this.setClearColor=function(){te.setClearColor(...arguments)},this.getClearAlpha=function(){return te.getClearAlpha()},this.setClearAlpha=function(){te.setClearAlpha(...arguments)},this.clear=function(N=!0,K=!0,at=!0){let rt=0;if(N){let q=!1;if(I!==null){const Rt=I.texture.format;q=Rt===O1||Rt===P1||Rt===U1}if(q){const Rt=I.texture.type,Ot=Rt===dr||Rt===cl||Rt===Gf||Rt===Pc||Rt===D1||Rt===L1,Ft=te.getClearColor(),Bt=te.getClearAlpha(),ue=Ft.r,fe=Ft.g,ie=Ft.b;Ot?(S[0]=ue,S[1]=fe,S[2]=ie,S[3]=Bt,G.clearBufferuiv(G.COLOR,0,S)):(A[0]=ue,A[1]=fe,A[2]=ie,A[3]=Bt,G.clearBufferiv(G.COLOR,0,A))}else rt|=G.COLOR_BUFFER_BIT}K&&(rt|=G.DEPTH_BUFFER_BIT),at&&(rt|=G.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G.clear(rt)},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(){n.removeEventListener("webglcontextlost",vt,!1),n.removeEventListener("webglcontextrestored",wt,!1),n.removeEventListener("webglcontextcreationerror",Nt,!1),te.dispose(),zt.dispose(),ye.dispose(),Yt.dispose(),L.dispose(),nt.dispose(),bt.dispose(),Lt.dispose(),j.dispose(),kt.dispose(),ot.dispose(),ot.removeEventListener("sessionstart",Oa),ot.removeEventListener("sessionend",fa),Hs.stop()};function vt(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),P=!0}function wt(){console.log("THREE.WebGLRenderer: Context Restored."),P=!1;const N=He.autoReset,K=Gt.enabled,at=Gt.autoUpdate,rt=Gt.needsUpdate,q=Gt.type;Ct(),He.autoReset=N,Gt.enabled=K,Gt.autoUpdate=at,Gt.needsUpdate=rt,Gt.type=q}function Nt(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function ne(N){const K=N.target;K.removeEventListener("dispose",ne),je(K)}function je(N){hn(N),Yt.remove(N)}function hn(N){const K=Yt.get(N).programs;K!==void 0&&(K.forEach(function(at){kt.releaseProgram(at)}),N.isShaderMaterial&&kt.releaseShaderCache(N))}this.renderBufferDirect=function(N,K,at,rt,q,Rt){K===null&&(K=on);const Ot=q.isMesh&&q.matrixWorld.determinant()<0,Ft=yu(N,K,at,rt,q);Zt.setMaterial(rt,Ot);let Bt=at.index,ue=1;if(rt.wireframe===!0){if(Bt=St.getWireframeAttribute(at),Bt===void 0)return;ue=2}const fe=at.drawRange,ie=at.attributes.position;let Ne=fe.start*ue,Ue=(fe.start+fe.count)*ue;Rt!==null&&(Ne=Math.max(Ne,Rt.start*ue),Ue=Math.min(Ue,(Rt.start+Rt.count)*ue)),Bt!==null?(Ne=Math.max(Ne,0),Ue=Math.min(Ue,Bt.count)):ie!=null&&(Ne=Math.max(Ne,0),Ue=Math.min(Ue,ie.count));const dn=Ue-Ne;if(dn<0||dn===1/0)return;Lt.setup(q,rt,Ft,at,Bt);let ke,he=mt;if(Bt!==null&&(ke=dt.get(Bt),he=Ut,he.setIndex(ke)),q.isMesh)rt.wireframe===!0?(Zt.setLineWidth(rt.wireframeLinewidth*Me()),he.setMode(G.LINES)):he.setMode(G.TRIANGLES);else if(q.isLine){let re=rt.linewidth;re===void 0&&(re=1),Zt.setLineWidth(re*Me()),q.isLineSegments?he.setMode(G.LINES):q.isLineLoop?he.setMode(G.LINE_LOOP):he.setMode(G.LINE_STRIP)}else q.isPoints?he.setMode(G.POINTS):q.isSprite&&he.setMode(G.TRIANGLES);if(q.isBatchedMesh)if(q._multiDrawInstances!==null)jo("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),he.renderMultiDrawInstances(q._multiDrawStarts,q._multiDrawCounts,q._multiDrawCount,q._multiDrawInstances);else if(me.get("WEBGL_multi_draw"))he.renderMultiDraw(q._multiDrawStarts,q._multiDrawCounts,q._multiDrawCount);else{const re=q._multiDrawStarts,qn=q._multiDrawCounts,Oe=q._multiDrawCount,ki=Bt?dt.get(Bt).bytesPerElement:1,Ws=Yt.get(rt).currentProgram.getUniforms();for(let wi=0;wi{function Rt(){if(rt.forEach(function(Ot){Yt.get(Ot).currentProgram.isReady()&&rt.delete(Ot)}),rt.size===0){q(N);return}setTimeout(Rt,10)}me.get("KHR_parallel_shader_compile")!==null?Rt():setTimeout(Rt,10)})};let ln=null;function bn(N){ln&&ln(N)}function Oa(){Hs.stop()}function fa(){Hs.start()}const Hs=new B3;Hs.setAnimationLoop(bn),typeof self<"u"&&Hs.setContext(self),this.setAnimationLoop=function(N){ln=N,ot.setAnimationLoop(N),N===null?Hs.stop():Hs.start()},ot.addEventListener("sessionstart",Oa),ot.addEventListener("sessionend",fa),this.render=function(N,K){if(K!==void 0&&K.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),ot.enabled===!0&&ot.isPresenting===!0&&(ot.cameraAutoUpdate===!0&&ot.updateCamera(K),K=ot.getCamera()),N.isScene===!0&&N.onBeforeRender(T,N,K,I),y=ye.get(N,w.length),y.init(K),w.push(y),Ht.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),J.setFromProjectionMatrix(Ht),Et=this.localClippingEnabled,ht=Dt.init(this.clippingPlanes,Et),x=zt.get(N,E.length),x.init(),E.push(x),ot.enabled===!0&&ot.isPresenting===!0){const Rt=T.xr.getDepthSensingMesh();Rt!==null&&mo(Rt,K,-1/0,T.sortObjects)}mo(N,K,0,T.sortObjects),x.finish(),T.sortObjects===!0&&x.sort(yt,At),$e=ot.enabled===!1||ot.isPresenting===!1||ot.hasDepthSensing()===!1,$e&&te.addToRenderList(x,N),this.info.render.frame++,ht===!0&&Dt.beginShadows();const at=y.state.shadowsArray;Gt.render(at,N,K),ht===!0&&Dt.endShadows(),this.info.autoReset===!0&&this.info.reset();const rt=x.opaque,q=x.transmissive;if(y.setupLights(),K.isArrayCamera){const Rt=K.cameras;if(q.length>0)for(let Ot=0,Ft=Rt.length;Ot0&&_u(rt,q,N,K),$e&&te.render(N),_l(x,N,K);I!==null&&U===0&&(B.updateMultisampleRenderTarget(I),B.updateRenderTargetMipmap(I)),N.isScene===!0&&N.onAfterRender(T,N,K),Lt.resetDefaultState(),C=-1,R=null,w.pop(),w.length>0?(y=w[w.length-1],ht===!0&&Dt.setGlobalState(T.clippingPlanes,y.state.camera)):y=null,E.pop(),E.length>0?x=E[E.length-1]:x=null};function mo(N,K,at,rt){if(N.visible===!1)return;if(N.layers.test(K.layers)){if(N.isGroup)at=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(K);else if(N.isLight)y.pushLight(N),N.castShadow&&y.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||J.intersectsSprite(N)){rt&&oe.setFromMatrixPosition(N.matrixWorld).applyMatrix4(Ht);const Ot=bt.update(N),Ft=N.material;Ft.visible&&x.push(N,Ot,Ft,at,oe.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(!N.frustumCulled||J.intersectsObject(N))){const Ot=bt.update(N),Ft=N.material;if(rt&&(N.boundingSphere!==void 0?(N.boundingSphere===null&&N.computeBoundingSphere(),oe.copy(N.boundingSphere.center)):(Ot.boundingSphere===null&&Ot.computeBoundingSphere(),oe.copy(Ot.boundingSphere.center)),oe.applyMatrix4(N.matrixWorld).applyMatrix4(Ht)),Array.isArray(Ft)){const Bt=Ot.groups;for(let ue=0,fe=Bt.length;ue0&&go(q,K,at),Rt.length>0&&go(Rt,K,at),Ot.length>0&&go(Ot,K,at),Zt.buffers.depth.setTest(!0),Zt.buffers.depth.setMask(!0),Zt.buffers.color.setMask(!0),Zt.setPolygonOffset(!1)}function _u(N,K,at,rt){if((at.isScene===!0?at.overrideMaterial:null)!==null)return;y.state.transmissionRenderTarget[rt.id]===void 0&&(y.state.transmissionRenderTarget[rt.id]=new ul(1,1,{generateMipmaps:!0,type:me.has("EXT_color_buffer_half_float")||me.has("EXT_color_buffer_float")?eh:dr,minFilter:cr,samples:4,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ie.workingColorSpace}));const Rt=y.state.transmissionRenderTarget[rt.id],Ot=rt.viewport||F;Rt.setSize(Ot.z*T.transmissionResolutionScale,Ot.w*T.transmissionResolutionScale);const Ft=T.getRenderTarget();T.setRenderTarget(Rt),T.getClearColor(lt),ut=T.getClearAlpha(),ut<1&&T.setClearColor(16777215,.5),T.clear(),$e&&te.render(at);const Bt=T.toneMapping;T.toneMapping=ao;const ue=rt.viewport;if(rt.viewport!==void 0&&(rt.viewport=void 0),y.setupLightsView(rt),ht===!0&&Dt.setGlobalState(T.clippingPlanes,rt),go(N,at,rt),B.updateMultisampleRenderTarget(Rt),B.updateRenderTargetMipmap(Rt),me.has("WEBGL_multisampled_render_to_texture")===!1){let fe=!1;for(let ie=0,Ne=K.length;ie0),ie=!!at.morphAttributes.position,Ne=!!at.morphAttributes.normal,Ue=!!at.morphAttributes.color;let dn=ao;rt.toneMapped&&(I===null||I.isXRRenderTarget===!0)&&(dn=T.toneMapping);const ke=at.morphAttributes.position||at.morphAttributes.normal||at.morphAttributes.color,he=ke!==void 0?ke.length:0,re=Yt.get(rt),qn=y.state.lights;if(ht===!0&&(Et===!0||N!==R)){const Rn=N===R&&rt.id===C;Dt.setState(rt,N,Rn)}let Oe=!1;rt.version===re.__version?(re.needsLights&&re.lightsStateVersion!==qn.state.version||re.outputColorSpace!==Ft||q.isBatchedMesh&&re.batching===!1||!q.isBatchedMesh&&re.batching===!0||q.isBatchedMesh&&re.batchingColor===!0&&q.colorTexture===null||q.isBatchedMesh&&re.batchingColor===!1&&q.colorTexture!==null||q.isInstancedMesh&&re.instancing===!1||!q.isInstancedMesh&&re.instancing===!0||q.isSkinnedMesh&&re.skinning===!1||!q.isSkinnedMesh&&re.skinning===!0||q.isInstancedMesh&&re.instancingColor===!0&&q.instanceColor===null||q.isInstancedMesh&&re.instancingColor===!1&&q.instanceColor!==null||q.isInstancedMesh&&re.instancingMorph===!0&&q.morphTexture===null||q.isInstancedMesh&&re.instancingMorph===!1&&q.morphTexture!==null||re.envMap!==Bt||rt.fog===!0&&re.fog!==Rt||re.numClippingPlanes!==void 0&&(re.numClippingPlanes!==Dt.numPlanes||re.numIntersection!==Dt.numIntersection)||re.vertexAlphas!==ue||re.vertexTangents!==fe||re.morphTargets!==ie||re.morphNormals!==Ne||re.morphColors!==Ue||re.toneMapping!==dn||re.morphTargetsCount!==he)&&(Oe=!0):(Oe=!0,re.__version=rt.version);let ki=re.currentProgram;Oe===!0&&(ki=wn(rt,K,q));let Ws=!1,wi=!1,si=!1;const tn=ki.getUniforms(),Ri=re.uniforms;if(Zt.useProgram(ki.program)&&(Ws=!0,wi=!0,si=!0),rt.id!==C&&(C=rt.id,wi=!0),Ws||R!==N){Zt.buffers.depth.getReversed()?(Mt.copy(N.projectionMatrix),oN(Mt),lN(Mt),tn.setValue(G,"projectionMatrix",Mt)):tn.setValue(G,"projectionMatrix",N.projectionMatrix),tn.setValue(G,"viewMatrix",N.matrixWorldInverse);const fi=tn.map.cameraPosition;fi!==void 0&&fi.setValue(G,ee.setFromMatrixPosition(N.matrixWorld)),Se.logarithmicDepthBuffer&&tn.setValue(G,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),(rt.isMeshPhongMaterial||rt.isMeshToonMaterial||rt.isMeshLambertMaterial||rt.isMeshBasicMaterial||rt.isMeshStandardMaterial||rt.isShaderMaterial)&&tn.setValue(G,"isOrthographic",N.isOrthographicCamera===!0),R!==N&&(R=N,wi=!0,si=!0)}if(q.isSkinnedMesh){tn.setOptional(G,q,"bindMatrix"),tn.setOptional(G,q,"bindMatrixInverse");const Rn=q.skeleton;Rn&&(Rn.boneTexture===null&&Rn.computeBoneTexture(),tn.setValue(G,"boneTexture",Rn.boneTexture,B))}q.isBatchedMesh&&(tn.setOptional(G,q,"batchingTexture"),tn.setValue(G,"batchingTexture",q._matricesTexture,B),tn.setOptional(G,q,"batchingIdTexture"),tn.setValue(G,"batchingIdTexture",q._indirectTexture,B),tn.setOptional(G,q,"batchingColorTexture"),q._colorsTexture!==null&&tn.setValue(G,"batchingColorTexture",q._colorsTexture,B));const _i=at.morphAttributes;if((_i.position!==void 0||_i.normal!==void 0||_i.color!==void 0)&&qt.update(q,at,ki),(wi||re.receiveShadow!==q.receiveShadow)&&(re.receiveShadow=q.receiveShadow,tn.setValue(G,"receiveShadow",q.receiveShadow)),rt.isMeshGouraudMaterial&&rt.envMap!==null&&(Ri.envMap.value=Bt,Ri.flipEnvMap.value=Bt.isCubeTexture&&Bt.isRenderTargetTexture===!1?-1:1),rt.isMeshStandardMaterial&&rt.envMap===null&&K.environment!==null&&(Ri.envMapIntensity.value=K.environmentIntensity),wi&&(tn.setValue(G,"toneMappingExposure",T.toneMappingExposure),re.needsLights&&wm(Ri,si),Rt&&rt.fog===!0&&Pt.refreshFogUniforms(Ri,Rt),Pt.refreshMaterialUniforms(Ri,rt,X,Q,y.state.transmissionRenderTarget[N.id]),mp.upload(G,ui(re),Ri,B)),rt.isShaderMaterial&&rt.uniformsNeedUpdate===!0&&(mp.upload(G,ui(re),Ri,B),rt.uniformsNeedUpdate=!1),rt.isSpriteMaterial&&tn.setValue(G,"center",q.center),tn.setValue(G,"modelViewMatrix",q.modelViewMatrix),tn.setValue(G,"normalMatrix",q.normalMatrix),tn.setValue(G,"modelMatrix",q.matrixWorld),rt.isShaderMaterial||rt.isRawShaderMaterial){const Rn=rt.uniformsGroups;for(let fi=0,yl=Rn.length;fi0&&B.useMultisampledRTT(N)===!1?q=Yt.get(N).__webglMultisampledFramebuffer:Array.isArray(fe)?q=fe[at]:q=fe,F.copy(N.viewport),Y.copy(N.scissor),$=N.scissorTest}else F.copy(z).multiplyScalar(X).floor(),Y.copy(it).multiplyScalar(X).floor(),$=Tt;if(at!==0&&(q=mh),Zt.bindFramebuffer(G.FRAMEBUFFER,q)&&rt&&Zt.drawBuffers(N,q),Zt.viewport(F),Zt.scissor(Y),Zt.setScissorTest($),Rt){const Bt=Yt.get(N.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+K,Bt.__webglTexture,at)}else if(Ot){const Bt=Yt.get(N.texture),ue=K;G.framebufferTextureLayer(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,Bt.__webglTexture,at,ue)}else if(N!==null&&at!==0){const Bt=Yt.get(N.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,Bt.__webglTexture,at)}C=-1},this.readRenderTargetPixels=function(N,K,at,rt,q,Rt,Ot){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ft=Yt.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Ot!==void 0&&(Ft=Ft[Ot]),Ft){Zt.bindFramebuffer(G.FRAMEBUFFER,Ft);try{const Bt=N.texture,ue=Bt.format,fe=Bt.type;if(!Se.textureFormatReadable(ue)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Se.textureTypeReadable(fe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=N.width-rt&&at>=0&&at<=N.height-q&&G.readPixels(K,at,rt,q,Vt.convert(ue),Vt.convert(fe),Rt)}finally{const Bt=I!==null?Yt.get(I).__webglFramebuffer:null;Zt.bindFramebuffer(G.FRAMEBUFFER,Bt)}}},this.readRenderTargetPixelsAsync=async function(N,K,at,rt,q,Rt,Ot){if(!(N&&N.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ft=Yt.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Ot!==void 0&&(Ft=Ft[Ot]),Ft){const Bt=N.texture,ue=Bt.format,fe=Bt.type;if(!Se.textureFormatReadable(ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Se.textureTypeReadable(fe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(K>=0&&K<=N.width-rt&&at>=0&&at<=N.height-q){Zt.bindFramebuffer(G.FRAMEBUFFER,Ft);const ie=G.createBuffer();G.bindBuffer(G.PIXEL_PACK_BUFFER,ie),G.bufferData(G.PIXEL_PACK_BUFFER,Rt.byteLength,G.STREAM_READ),G.readPixels(K,at,rt,q,Vt.convert(ue),Vt.convert(fe),0);const Ne=I!==null?Yt.get(I).__webglFramebuffer:null;Zt.bindFramebuffer(G.FRAMEBUFFER,Ne);const Ue=G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE,0);return G.flush(),await rN(G,Ue,4),G.bindBuffer(G.PIXEL_PACK_BUFFER,ie),G.getBufferSubData(G.PIXEL_PACK_BUFFER,0,Rt),G.deleteBuffer(ie),G.deleteSync(Ue),Rt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(N,K=null,at=0){N.isTexture!==!0&&(jo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),K=arguments[0]||null,N=arguments[1]);const rt=Math.pow(2,-at),q=Math.floor(N.image.width*rt),Rt=Math.floor(N.image.height*rt),Ot=K!==null?K.x:0,Ft=K!==null?K.y:0;B.setTexture2D(N,0),G.copyTexSubImage2D(G.TEXTURE_2D,at,0,0,Ot,Ft,q,Rt),Zt.unbindTexture()};const bo=G.createFramebuffer(),xu=G.createFramebuffer();this.copyTextureToTexture=function(N,K,at=null,rt=null,q=0,Rt=null){N.isTexture!==!0&&(jo("WebGLRenderer: copyTextureToTexture function signature has changed."),rt=arguments[0]||null,N=arguments[1],K=arguments[2],Rt=arguments[3]||0,at=null),Rt===null&&(q!==0?(jo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Rt=q,q=0):Rt=0);let Ot,Ft,Bt,ue,fe,ie,Ne,Ue,dn;const ke=N.isCompressedTexture?N.mipmaps[Rt]:N.image;if(at!==null)Ot=at.max.x-at.min.x,Ft=at.max.y-at.min.y,Bt=at.isBox3?at.max.z-at.min.z:1,ue=at.min.x,fe=at.min.y,ie=at.isBox3?at.min.z:0;else{const _i=Math.pow(2,-q);Ot=Math.floor(ke.width*_i),Ft=Math.floor(ke.height*_i),N.isDataArrayTexture?Bt=ke.depth:N.isData3DTexture?Bt=Math.floor(ke.depth*_i):Bt=1,ue=0,fe=0,ie=0}rt!==null?(Ne=rt.x,Ue=rt.y,dn=rt.z):(Ne=0,Ue=0,dn=0);const he=Vt.convert(K.format),re=Vt.convert(K.type);let qn;K.isData3DTexture?(B.setTexture3D(K,0),qn=G.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?(B.setTexture2DArray(K,0),qn=G.TEXTURE_2D_ARRAY):(B.setTexture2D(K,0),qn=G.TEXTURE_2D),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,K.flipY),G.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),G.pixelStorei(G.UNPACK_ALIGNMENT,K.unpackAlignment);const Oe=G.getParameter(G.UNPACK_ROW_LENGTH),ki=G.getParameter(G.UNPACK_IMAGE_HEIGHT),Ws=G.getParameter(G.UNPACK_SKIP_PIXELS),wi=G.getParameter(G.UNPACK_SKIP_ROWS),si=G.getParameter(G.UNPACK_SKIP_IMAGES);G.pixelStorei(G.UNPACK_ROW_LENGTH,ke.width),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,ke.height),G.pixelStorei(G.UNPACK_SKIP_PIXELS,ue),G.pixelStorei(G.UNPACK_SKIP_ROWS,fe),G.pixelStorei(G.UNPACK_SKIP_IMAGES,ie);const tn=N.isDataArrayTexture||N.isData3DTexture,Ri=K.isDataArrayTexture||K.isData3DTexture;if(N.isDepthTexture){const _i=Yt.get(N),Rn=Yt.get(K),fi=Yt.get(_i.__renderTarget),yl=Yt.get(Rn.__renderTarget);Zt.bindFramebuffer(G.READ_FRAMEBUFFER,fi.__webglFramebuffer),Zt.bindFramebuffer(G.DRAW_FRAMEBUFFER,yl.__webglFramebuffer);for(let zi=0;zi=2.0 are supported."));return}const d=new G8(o,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p=0&&u[m]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+m+'".')}}d.setExtensions(l),d.setPlugins(u),d.parse(i,a)}parseAsync(t,n){const i=this;return new Promise(function(a,o){i.parse(t,n,a,o)})}}function u8(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Ce={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class f8{constructor(t){this.parser=t,this.name=Ce.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,n=this.parser.json.nodes||[];for(let i=0,a=n.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(t,o.source,l)}}class T8{constructor(t){this.parser=t,this.name=Ce.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const n=this.name,i=this.parser,a=i.json,o=a.textures[t];if(!o.extensions||!o.extensions[n])return null;const l=o.extensions[n],u=a.images[l.source];let h=i.textureLoader;if(u.uri){const d=i.options.manager.getHandler(u.uri);d!==null&&(h=d)}return this.detectSupport().then(function(d){if(d)return i.loadTextureImage(t,l.source,h);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){t(n.height===1)}})),this.isSupported}}class E8{constructor(t){this.parser=t,this.name=Ce.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const n=this.name,i=this.parser,a=i.json,o=a.textures[t];if(!o.extensions||!o.extensions[n])return null;const l=o.extensions[n],u=a.images[l.source];let h=i.textureLoader;if(u.uri){const d=i.options.manager.getHandler(u.uri);d!==null&&(h=d)}return this.detectSupport().then(function(d){if(d)return i.loadTextureImage(t,l.source,h);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){t(n.height===1)}})),this.isSupported}}class w8{constructor(t){this.name=Ce.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const n=this.parser.json,i=n.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const a=i.extensions[this.name],o=this.parser.getDependency("buffer",a.buffer),l=this.parser.options.meshoptDecoder;if(!l||!l.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(u){const h=a.byteOffset||0,d=a.byteLength||0,p=a.count,m=a.byteStride,b=new Uint8Array(u,h,d);return l.decodeGltfBufferAsync?l.decodeGltfBufferAsync(p,m,b,a.mode,a.filter).then(function(_){return _.buffer}):l.ready.then(function(){const _=new ArrayBuffer(p*m);return l.decodeGltfBuffer(new Uint8Array(_),p,m,b,a.mode,a.filter),_})})}else return null}}class R8{constructor(t){this.name=Ce.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const n=this.parser.json,i=n.nodes[t];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const a=n.meshes[i.mesh];for(const d of a.primitives)if(d.mode!==Os.TRIANGLES&&d.mode!==Os.TRIANGLE_STRIP&&d.mode!==Os.TRIANGLE_FAN&&d.mode!==void 0)return null;const l=i.extensions[this.name].attributes,u=[],h={};for(const d in l)u.push(this.parser.getDependency("accessor",l[d]).then(p=>(h[d]=p,h[d])));return u.length<1?null:(u.push(this.parser.createNodeMesh(t)),Promise.all(u).then(d=>{const p=d.pop(),m=p.isGroup?p.children:[p],b=d[0].count,_=[];for(const S of m){const A=new _e,x=new H,y=new sa,E=new H(1,1,1),w=new BN(S.geometry,S.material,b);for(let T=0;T0||e.search(/^data\:image\/jpeg/)===0?"image/jpeg":e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?"image/webp":e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const V8=new _e;class G8{constructor(t={},n={}){this.json=t,this.extensions={},this.plugins={},this.options=n,this.cache=new u8,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,a=-1,o=!1,l=-1;if(typeof navigator<"u"){const u=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(u)===!0;const h=u.match(/Version\/(\d+)/);a=i&&h?parseInt(h[1],10):-1,o=u.indexOf("Firefox")>-1,l=o?u.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&a<17||o&&l<98?this.textureLoader=new nU(this.options.manager):this.textureLoader=new cU(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new I3(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,n){const i=this,a=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(l){return l._markDefs&&l._markDefs()}),Promise.all(this._invokeAll(function(l){return l.beforeRoot&&l.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(l){const u={scene:l[0][a.scene||0],scenes:l[0],animations:l[1],cameras:l[2],asset:a.asset,parser:i,userData:{}};return zo(o,u,a),or(u,a),Promise.all(i._invokeAll(function(h){return h.afterRoot&&h.afterRoot(u)})).then(function(){for(const h of u.scenes)h.updateMatrixWorld();t(u)})}).catch(n)}_markDefs(){const t=this.json.nodes||[],n=this.json.skins||[],i=this.json.meshes||[];for(let a=0,o=n.length;a{const h=this.associations.get(l);h!=null&&this.associations.set(u,h);for(const[d,p]of l.children.entries())o(p,u.children[d])};return o(i,a),a.name+="_instance_"+t.uses[n]++,a}_invokeOne(t){const n=Object.values(this.plugins);n.push(this);for(let i=0;i=2&&x.setY(C,O[U*h+1]),h>=3&&x.setZ(C,O[U*h+2]),h>=4&&x.setW(C,O[U*h+3]),h>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}x.normalized=S}return x})}loadTexture(t){const n=this.json,i=this.options,o=n.textures[t].source,l=n.images[o];let u=this.textureLoader;if(l.uri){const h=i.manager.getHandler(l.uri);h!==null&&(u=h)}return this.loadTextureImage(t,o,u)}loadTextureImage(t,n,i){const a=this,o=this.json,l=o.textures[t],u=o.images[n],h=(u.uri||u.bufferView)+":"+l.sampler;if(this.textureCache[h])return this.textureCache[h];const d=this.loadImageSource(n,i).then(function(p){p.flipY=!1,p.name=l.name||u.name||"",p.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(p.name=u.uri);const b=(o.samplers||{})[l.sampler]||{};return p.magFilter=DA[b.magFilter]||ps,p.minFilter=DA[b.minFilter]||cr,p.wrapS=LA[b.wrapS]||Uc,p.wrapT=LA[b.wrapT]||Uc,p.generateMipmaps=!p.isCompressedTexture&&p.minFilter!==Ii&&p.minFilter!==ps,a.associations.set(p,{textures:t}),p}).catch(function(){return null});return this.textureCache[h]=d,d}loadImageSource(t,n){const i=this,a=this.json,o=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(m=>m.clone());const l=a.images[t],u=self.URL||self.webkitURL;let h=l.uri||"",d=!1;if(l.bufferView!==void 0)h=i.getDependency("bufferView",l.bufferView).then(function(m){d=!0;const b=new Blob([m],{type:l.mimeType});return h=u.createObjectURL(b),h});else if(l.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const p=Promise.resolve(h).then(function(m){return new Promise(function(b,_){let S=b;n.isImageBitmapLoader===!0&&(S=function(A){const x=new Qn(A);x.needsUpdate=!0,b(x)}),n.load(Pf.resolveURL(m,o.path),S,void 0,_)})}).then(function(m){return d===!0&&u.revokeObjectURL(h),or(m,l),m.userData.mimeType=l.mimeType||z8(l.uri),m}).catch(function(m){throw console.error("THREE.GLTFLoader: Couldn't load texture",h),m});return this.sourceCache[t]=p,p}assignTexture(t,n,i,a){const o=this;return this.getDependency("texture",i.index).then(function(l){if(!l)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(l=l.clone(),l.channel=i.texCoord),o.extensions[Ce.KHR_TEXTURE_TRANSFORM]){const u=i.extensions!==void 0?i.extensions[Ce.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const h=o.associations.get(l);l=o.extensions[Ce.KHR_TEXTURE_TRANSFORM].extendTexture(l,u),o.associations.set(l,h)}}return a!==void 0&&(l.colorSpace=a),t[n]=l,l})}assignFinalMaterial(t){const n=t.geometry;let i=t.material;const a=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,l=n.attributes.normal===void 0;if(t.isPoints){const u="PointsMaterial:"+i.uuid;let h=this.cache.get(u);h||(h=new L3,Sa.prototype.copy.call(h,i),h.color.copy(i.color),h.map=i.map,h.sizeAttenuation=!1,this.cache.add(u,h)),i=h}else if(t.isLine){const u="LineBasicMaterial:"+i.uuid;let h=this.cache.get(u);h||(h=new G1,Sa.prototype.copy.call(h,i),h.color.copy(i.color),h.map=i.map,this.cache.add(u,h)),i=h}if(a||o||l){let u="ClonedMaterial:"+i.uuid+":";a&&(u+="derivative-tangents:"),o&&(u+="vertex-colors:"),l&&(u+="flat-shading:");let h=this.cache.get(u);h||(h=i.clone(),o&&(h.vertexColors=!0),l&&(h.flatShading=!0),a&&(h.normalScale&&(h.normalScale.y*=-1),h.clearcoatNormalScale&&(h.clearcoatNormalScale.y*=-1)),this.cache.add(u,h),this.associations.set(h,this.associations.get(i))),i=h}t.material=i}getMaterialType(){return Xf}loadMaterial(t){const n=this,i=this.json,a=this.extensions,o=i.materials[t];let l;const u={},h=o.extensions||{},d=[];if(h[Ce.KHR_MATERIALS_UNLIT]){const m=a[Ce.KHR_MATERIALS_UNLIT];l=m.getMaterialType(),d.push(m.extendParams(u,o,n))}else{const m=o.pbrMetallicRoughness||{};if(u.color=new de(1,1,1),u.opacity=1,Array.isArray(m.baseColorFactor)){const b=m.baseColorFactor;u.color.setRGB(b[0],b[1],b[2],Bi),u.opacity=b[3]}m.baseColorTexture!==void 0&&d.push(n.assignTexture(u,"map",m.baseColorTexture,ci)),u.metalness=m.metallicFactor!==void 0?m.metallicFactor:1,u.roughness=m.roughnessFactor!==void 0?m.roughnessFactor:1,m.metallicRoughnessTexture!==void 0&&(d.push(n.assignTexture(u,"metalnessMap",m.metallicRoughnessTexture)),d.push(n.assignTexture(u,"roughnessMap",m.metallicRoughnessTexture))),l=this._invokeOne(function(b){return b.getMaterialType&&b.getMaterialType(t)}),d.push(Promise.all(this._invokeAll(function(b){return b.extendMaterialParams&&b.extendMaterialParams(t,u)})))}o.doubleSided===!0&&(u.side=Is);const p=o.alphaMode||_b.OPAQUE;if(p===_b.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,p===_b.MASK&&(u.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&l!==Ni&&(d.push(n.assignTexture(u,"normalMap",o.normalTexture)),u.normalScale=new Ae(1,1),o.normalTexture.scale!==void 0)){const m=o.normalTexture.scale;u.normalScale.set(m,m)}if(o.occlusionTexture!==void 0&&l!==Ni&&(d.push(n.assignTexture(u,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&l!==Ni){const m=o.emissiveFactor;u.emissive=new de().setRGB(m[0],m[1],m[2],Bi)}return o.emissiveTexture!==void 0&&l!==Ni&&d.push(n.assignTexture(u,"emissiveMap",o.emissiveTexture,ci)),Promise.all(d).then(function(){const m=new l(u);return o.name&&(m.name=o.name),or(m,o),n.associations.set(m,{materials:t}),o.extensions&&zo(a,m,o),m})}createUniqueName(t){const n=Ke.sanitizeNodeName(t||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(t){const n=this,i=this.extensions,a=this.primitiveCache;function o(u){return i[Ce.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,n).then(function(h){return NA(h,u,n)})}const l=[];for(let u=0,h=t.length;u0&&B8(y,o),y.name=n.createUniqueName(o.name||"mesh_"+t),or(y,o),x.extensions&&zo(a,y,x),n.assignFinalMaterial(y),m.push(y)}for(let _=0,S=m.length;_1?p=new Zi:d.length===1?p=d[0]:p=new Tn,p!==d[0])for(let m=0,b=d.length;m{const m=new Map;for(const[b,_]of a.associations)(b instanceof Sa||b instanceof Qn)&&m.set(b,_);return p.traverse(b=>{const _=a.associations.get(b);_!=null&&m.set(b,_)}),m};return a.associations=d(o),o})}_createAnimationTracks(t,n,i,a,o){const l=[],u=t.name?t.name:t.uuid,h=[];qr[o.path]===qr.weights?t.traverse(function(b){b.morphTargetInfluences&&h.push(b.name?b.name:b.uuid)}):h.push(u);let d;switch(qr[o.path]){case qr.weights:d=Bc;break;case qr.rotation:d=kc;break;case qr.position:case qr.scale:d=zc;break;default:switch(i.itemSize){case 1:d=Bc;break;case 2:case 3:default:d=zc;break}break}const p=a.interpolation!==void 0?O8[a.interpolation]:jf,m=this._getArrayFromAccessor(i);for(let b=0,_=h.length;b<_;b++){const S=new d(h[b]+"."+qr[o.path],n.array,m,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(S),l.push(S)}return l}_getArrayFromAccessor(t){let n=t.array;if(t.normalized){const i=Bv(n.constructor),a=new Float32Array(n.length);for(let o=0,l=n.length;o96?T-97:T>64?T-39:T+4}for(var P=0,w=0;w0?A(y,E,w,p[T],d[P]):l.then(function(){var O=new Uint8Array(y*E);return h(o.exports[p[T]],O,y,E,w,o.exports[d[P]]),O})}}})();class W8{constructor(t,n,i){this.gltfLoader=new c8,this.hasBallModel=!1,this.playerMixer=null,this.playerKickAction=null,this.playerRunAction=null,this.strikerKickBone=null,this.strikerKickRig=null,this.gloveFollowState=new Map,this.lastGloveLandmarks=null,this.gloveStaticWrap=!0,this.swapGloveHands=!1,this.gloveTrackingMode="both",this.gloveCalibration={left:{scale:.42,forwardMul:.02,sideMul:-.015,rotationOffset:Math.PI/2,offsetX:0,offsetY:0,offsetZ:0,rotationFine:0},right:{scale:.42,forwardMul:.02,sideMul:.015,rotationOffset:-Math.PI/2,offsetX:0,offsetY:0,offsetZ:0,rotationFine:0}},this.trailMeshes=[],this.trailCount=20,this.particles=[],this.ballVelocity=new H,this.ballSpin=new H,this.isBallActive=!1,this.isSuperBall=!1,this.ballStartZ=-15,this.catchPlaneZ=-2,this.goalLineZ=-1,this.timeScale=1,this.timeScaleTimer=0,this.animationId=0,this.clock=new fU,this.kickAnimFrame=0,this.kickContactTimer=null,this.difficultyMultiplier=1,this.pendingBallLaunch=!1,this.playerAnimState="idle",this.kickContactRatio=.42,this.onPlayerActionFinished=a=>{const o=a==null?void 0:a.action;if(o){if(this.playerRunAction&&o===this.playerRunAction&&this.playerAnimState==="runup"){this.playKickClip();return}this.playerKickAction&&o===this.playerKickAction&&this.playerAnimState==="kick"&&(this.playerAnimState="idle",this.clearKickContactTimer(),this.pendingBallLaunch=!1)}},this.onWindowResize=()=>{this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(window.innerWidth,window.innerHeight)},this.container=t,this.onSave=n,this.onGoal=i,this.gltfLoader.setMeshoptDecoder(j8),this.scene=new UN,this.camera=new Ui(60,window.innerWidth/window.innerHeight,.1,100),this.camera.position.set(0,1.5,0),this.renderer=new l8({alpha:!0,antialias:!0}),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.container.appendChild(this.renderer.domElement),this.setupLights(),this.setupScene(),window.addEventListener("resize",this.onWindowResize),this.animate=this.animate.bind(this),this.animationId=requestAnimationFrame(this.animate)}setupLights(){const t=new lU(16777215,.7);this.scene.add(t);const n=new F3(16777215,.8);n.position.set(5,10,5),this.scene.add(n)}setupScene(){const t=this.createBallTexture(),n=new Ko(.2,64,64),i=new oa({map:t.diff,bumpMap:t.bump,bumpScale:.005,roughness:.5,metalness:.1,clearcoat:.4,clearcoatRoughness:.2});this.ballFallbackMaterial=i,this.ball=new Ye(n,i);const a=new Ko(.205,32,32),o=new Ni({color:65382,wireframe:!0,transparent:!0,opacity:0});this.ballWire=new Ye(a,o),this.ball.add(this.ballWire),this.ball.position.set(0,.2,this.ballStartZ),this.scene.add(this.ball),this.trailGroup=new Zi;const l=new Ko(.18,16,16);for(let lt=0;lt{const n=t.scene;this.fitModel(n,.42),n.traverse(i=>{i instanceof Ye&&(i.castShadow=!1,i.receiveShadow=!1)}),this.ball.add(n),this.ballFallbackMaterial.transparent=!0,this.ballFallbackMaterial.opacity=0,this.ballFallbackMaterial.depthWrite=!1,this.hasBallModel=!0},void 0,t=>console.warn("ball.glb failed to load, using fallback ball mesh.",t))}loadPlayerModel(){this.gltfLoader.load("/models/player.glb",t=>{const n=t.scene;n.traverse(a=>{if(!(a instanceof Ye))return;a.frustumCulled=!1,a.castShadow=!1,a.receiveShadow=!1;const o=Array.isArray(a.material)?a.material:[a.material];for(const l of o)l&&("transparent"in l&&(l.transparent=!1),"opacity"in l&&(l.opacity=1),"alphaTest"in l&&(l.alphaTest=0),"depthWrite"in l&&(l.depthWrite=!0),"depthTest"in l&&(l.depthTest=!0),"side"in l&&(l.side=Is),l.needsUpdate=!0)}),this.fitModel(n,2,!0),this.striker.add(n),this.strikerBodyFallback.visible=!1,this.strikerKickBone=this.findKickBone(n),this.strikerKickRig=this.findKickRigBones(n),this.playerMixer&&this.playerMixer.removeEventListener("finished",this.onPlayerActionFinished),this.playerMixer=null,this.playerKickAction=null,this.playerRunAction=null,this.playerAnimState="idle";const i=t.animations.filter(a=>a.duration>.05);if(i.length>0){const a=i.find(u=>{const h=u.name.toLowerCase();return h.includes("kick")||h.includes("soccer")||h.includes("shoot")})||i[0],o=i.find(u=>u.name.toLowerCase().includes("run"))||null;this.playerMixer=new AU(n),this.playerMixer.addEventListener("finished",this.onPlayerActionFinished);const l=this.playerMixer.clipAction(a);if(l.clampWhenFinished=!0,l.loop=Ef,l.enabled=!0,this.playerKickAction=l,o){const u=this.playerMixer.clipAction(o);u.loop=Ef,u.clampWhenFinished=!0,u.enabled=!0,this.playerRunAction=u}console.info(`Using player animations: kick=${a.name} (${a.duration.toFixed(2)}s)`+(o?`, run=${o.name} (${o.duration.toFixed(2)}s)`:""))}else console.warn("player.glb has no playable animation clip (duration > 0). Using procedural kick fallback.")},void 0,t=>console.warn("player.glb failed to load, using fallback striker.",t))}loadGloveModel(){this.gltfLoader.load("/models/glove.glb",t=>{const n=UA(t.scene),i=UA(t.scene);this.prepareGloveModel(n,!0),this.prepareGloveModel(i,!1),this.leftGlove.clear(),this.rightGlove.clear(),this.leftGlove.add(n),this.rightGlove.add(i)},void 0,t=>console.warn("glove.glb failed to load, using fallback glove meshes.",t))}prepareGloveModel(t,n){const a=new Qi().setFromObject(t).getSize(new H),l=1/Math.max(a.y,1e-4);t.scale.setScalar(l),n&&(t.scale.x*=-1),t.updateMatrixWorld(!0);const u=new H;let h=!1;if(t.traverse(d=>{if(h||!(d instanceof w3))return;const p=d.skeleton;if(!p||p.bones.length===0)return;(p.bones.find(b=>!b.parent||b.parent.type!=="Bone")||p.bones[0]).getWorldPosition(u),t.worldToLocal(u),h=!0}),!h){const d=new Qi().setFromObject(t);u.set((d.min.x+d.max.x)*.5,d.min.y,(d.min.z+d.max.z)*.5)}t.position.sub(u)}fitModel(t,n,i=!1){const o=new Qi().setFromObject(t).getSize(new H),l=Math.max(o.y,1e-4),u=n/l;t.scale.setScalar(u);const d=new Qi().setFromObject(t).getCenter(new H);if(t.position.sub(d),i){const p=new Qi().setFromObject(t);t.position.y-=p.min.y}}findKickBone(t){let n=null;return t.traverse(i=>{if(i.type!=="Bone")return;const a=i.name.toLowerCase();(!n&&a.includes("right")&&(a.includes("upleg")||a.includes("thigh")||a.includes("leg"))||!n&&(a.includes("leg")||a.includes("thigh")))&&(n=i)}),n}findBoneByAliases(t,n){let i=null;return t.traverse(a=>{if(i||a.type!=="Bone")return;const o=a.name.toLowerCase();n.some(l=>o.includes(l))&&(i=a)}),i}findKickRigBones(t){const n=this.findBoneByAliases(t,["rightupleg","right_thigh","rthigh","mixamorigrightupleg"]),i=this.findBoneByAliases(t,["rightleg","right_calf","rcalf","mixamorigrightleg"]),a=this.findBoneByAliases(t,["rightfoot","rfoot","mixamorigrightfoot"]),o=this.findBoneByAliases(t,["leftupleg","left_thigh","lthigh","mixamorigleftupleg"]),l=this.findBoneByAliases(t,["hips","pelvis","mixamorighips"]),u=this.findBoneByAliases(t,["spine02","spine2"])||this.findBoneByAliases(t,["spine01","spine1"])||this.findBoneByAliases(t,["spine"]);return{hips:l,spine:u,rightUpLeg:n,rightLeg:i,rightFoot:a,leftUpLeg:o}}screenToWorld(t,n,i){const a=Math.abs(this.camera.position.z-i),o=Ki.degToRad(this.camera.fov),l=2*Math.tan(o/2)*a,u=l*this.camera.aspect,h=this.camera.position.x+(t-.5)*u,d=this.camera.position.y-(n-.5)*l;return new H(h,d,i)}updateGloveLandmarks(t){if(this.lastGloveLandmarks=t,!t){this.gloveTrackingMode==="both"?this.applyGlovePose(this.leftGlove,null,!0):this.leftGlove.visible=!1,this.applyGlovePose(this.rightGlove,null,!1);return}const n=this.getGlovePose(t,!0),i=this.getGlovePose(t,!1),a=this.swapGloveHands?i:n,o=this.swapGloveHands?n:i;this.gloveTrackingMode==="both"?this.applyGlovePose(this.leftGlove,a,!0):this.leftGlove.visible=!1,this.applyGlovePose(this.rightGlove,o,!1)}setGloveStaticWrap(t){this.gloveStaticWrap=t}setSwapGloveHands(t){this.swapGloveHands=t}getSwapGloveHands(){return this.swapGloveHands}setGloveTrackingMode(t){this.gloveTrackingMode=t,t==="right-only"&&(this.leftGlove.visible=!1)}getGloveTrackingMode(){return this.gloveTrackingMode}getHandDetectionStatus(t=this.lastGloveLandmarks){if(!t)return{leftDetected:!1,rightDetected:!1};const n=this.pickBestLandmark(t,[15]),i=this.pickBestLandmark(t,[16]),a=!!n&&(n.visibility??1)>=.12,o=!!i&&(i.visibility??1)>=.12;return{leftDetected:a,rightDetected:o}}autoDetectHandMapping(t=this.lastGloveLandmarks){if(!t)return{resolved:!1,swapped:this.swapGloveHands};const n=this.pickBestLandmark(t,[15]),i=this.pickBestLandmark(t,[16]);if(!n||!i)return{resolved:!1,swapped:this.swapGloveHands};if((n.visibility??1)<.15||(i.visibility??1)<.15)return{resolved:!1,swapped:this.swapGloveHands};const a=1-n.x,o=1-i.x;if(Math.abs(o-a)<.06)return{resolved:!1,swapped:this.swapGloveHands};const u=o{if(!p)return;const m=this.gloveCalibration[d];m.scale=Ki.clamp(p.handLength*3.6,.3,.62),u=!0};return h("left",o),h("right",l),u}pickBestLandmark(t,n){let i=null,a=-1;for(const o of n){const l=t[o];if(!l)continue;const u=l.visibility??1;u>a&&(i=l,a=u)}return i}getGlovePose(t,n){const i=this.pickBestLandmark(t,n?[15]:[16]);if(!i||(i.visibility??1)<.08)return null;const a=this.pickBestLandmark(t,n?[19,17,21]:[20,18,22]),o=this.pickBestLandmark(t,n?[19]:[20]),l=this.pickBestLandmark(t,n?[17]:[18]),u=this.pickBestLandmark(t,n?[21]:[22]),h=this.pickBestLandmark(t,n?[13]:[14]),d=this.pickBestLandmark(t,n?[11]:[12]),p=-.52,m=R=>this.screenToWorld(1-R.x,R.y,p),b=(R,F=.08)=>R&&(R.visibility??1)>=F?m(R):null,_=m(i),S=b(o),A=b(l),x=b(u),y=b(a,.05),E=b(h,.05),w=b(d,.05);let T=new H(n?-1:1,0,0),P=.08,O=!1;const U=[S,A,x].filter(R=>!!R).filter(R=>{const F=R.distanceTo(_);return F>.02&&F<.55});if(U.length>0){const R=new H;for(const $ of U)R.add($);R.multiplyScalar(1/U.length);const F=new H().subVectors(R,_),Y=F.length();Y>1e-4&&(T=F.multiplyScalar(1/Y),P=Ki.clamp(Y,.045,.18),O=!0)}if(!O&&E){const R=new H().subVectors(_,E),F=R.length();F>1e-4&&(T=R.multiplyScalar(1/F),P=Ki.clamp(F*.45,.045,.16),O=!0)}if(!O&&w){const R=new H().subVectors(_,w),F=R.length();F>1e-4&&(T=R.multiplyScalar(1/F),P=Ki.clamp(F*.3,.045,.16))}let I=_.clone().addScaledVector(T,P*.18);if(U.length>=2){const R=new H;for(const F of U)R.add(F);R.multiplyScalar(1/U.length),I=_.clone().multiplyScalar(.42).add(R.multiplyScalar(.58))}else y&&I.lerp(y,.2);const C=Math.atan2(T.y,T.x);return{palm:I,dir:T,handLength:P,angle:C}}applyGlovePose(t,n,i){const a=i?"left":"right",o=i?"left":"right",l=this.gloveCalibration[o],u=new H;let h=l.rotationOffset;if(!n)u.set(i?-.18:.18,1.02,-.55);else{u.copy(n.palm).addScaledVector(n.dir,n.handLength*l.forwardMul);const p=new H(-n.dir.y,n.dir.x,0).normalize();u.addScaledVector(p,n.handLength*l.sideMul),h=this.gloveStaticWrap?l.rotationOffset:n.angle+l.rotationOffset}u.x+=l.offsetX,u.y+=l.offsetY,u.z+=l.offsetZ,h+=l.rotationFine;let d=this.gloveFollowState.get(a);if(!d)d={pos:u.clone(),angle:h},this.gloveFollowState.set(a,d);else{d.pos.lerp(u,.55);let p=h-d.angle;for(;p>Math.PI;)p-=Math.PI*2;for(;p<-Math.PI;)p+=Math.PI*2;d.angle+=p*.55}t.visible=!0,t.position.copy(d.pos),t.rotation.set(0,0,d.angle),t.scale.set(l.scale,l.scale,l.scale)}clearKickContactTimer(){this.kickContactTimer&&(clearTimeout(this.kickContactTimer),this.kickContactTimer=null)}startBallFlight(){!this.pendingBallLaunch||this.isBallActive||(this.isBallActive=!0,this.pendingBallLaunch=!1,this.timeScale=.25,this.timeScaleTimer=4)}scheduleBallLaunch(t){this.clearKickContactTimer(),this.kickContactTimer=setTimeout(()=>{this.kickContactTimer=null,this.startBallFlight()},Math.max(0,t))}playKickClip(){if(!this.playerKickAction)return;this.playerAnimState="kick";const t=this.playerKickAction.getClip().duration,n=Math.round(t*this.kickContactRatio*1e3);this.scheduleBallLaunch(n),this.playerKickAction.enabled=!0,this.playerKickAction.clampWhenFinished=!0,this.playerKickAction.reset(),this.playerKickAction.setLoop(Ef,1),this.playerKickAction.fadeIn(.06),this.playerKickAction.play()}shootBall(t,n){this.difficultyMultiplier=t,this.clearKickContactTimer(),this.pendingBallLaunch=!1,this.playerAnimState="idle",this.ball.position.set((Math.random()-.5)*2,.2,this.ballStartZ),this.isBallActive=!1,this.isSuperBall=!1,this.timeScale=1,this.timeScaleTimer=0;const i=this.ballFallbackMaterial,a=this.ballWire.material;this.isSuperBall?(i.color.setHex(16777215),i.emissive.setHex(16711765),i.emissiveIntensity=.8,a.color.setHex(65535),a.opacity=1,this.strikerAura.material.opacity=.5):(i.color.setHex(16777215),i.emissive.setHex(0),i.emissiveIntensity=0,a.opacity=0,this.strikerAura.material.opacity=0);let o=0,l=1.5;const u=Math.abs(this.camera.position.z-this.catchPlaneZ),h=Ki.degToRad(this.camera.fov),d=2*Math.tan(h/2)*u,p=d*this.camera.aspect;if(n!==void 0){let E,w;n===0?(E=.1,w=.35):n===1?(E=.375,w=.625):(E=.65,w=.9);const T=.3,P=.6,O=E+Math.random()*(w-E),U=T+Math.random()*(P-T);o=this.camera.position.x+(O-.5)*p,l=this.camera.position.y-(U-.5)*d}else o=this.camera.position.x+(Math.random()-.5)*p*.8,l=this.camera.position.y+(Math.random()-.5)*d*.6;const m=this.isSuperBall?1.2/t:2/t,b=o-this.ball.position.x,_=l-this.ball.position.y,S=this.catchPlaneZ-this.ball.position.z;this.ballVelocity.set(b/m,_/m,S/m);const A=9.8*.2;this.ballVelocity.y+=A*m/2;const x=15+t*5;this.ballSpin.set((Math.random()-.2)*x,(Math.random()-.5)*x*1.5,(Math.random()-.5)*x*.2);const y=new H().crossVectors(this.ballSpin,this.ballVelocity).multiplyScalar(.015);this.ballVelocity.sub(y.multiplyScalar(m*.5)),this.pendingBallLaunch=!0,this.striker.position.x=this.ball.position.x,this.triggerKickAnimation()}triggerKickAnimation(){var m;if(this.playerMixer&&this.playerKickAction){(m=this.playerRunAction)==null||m.stop(),this.playerKickAction.stop(),this.playerRunAction?(this.playerAnimState="runup",this.playerRunAction.enabled=!0,this.playerRunAction.clampWhenFinished=!0,this.playerRunAction.reset(),this.playerRunAction.setLoop(Ef,1),this.playerRunAction.fadeIn(.05),this.playerRunAction.play()):this.playKickClip();return}this.startBallFlight(),this.kickAnimFrame&&cancelAnimationFrame(this.kickAnimFrame);const t=performance.now(),n=480,i=this.striker.rotation.x,a=this.striker.position.y,o=this.strikerKickBone,l=o?o.rotation.x:0,u=this.strikerKickRig,h=["hips","spine","rightUpLeg","rightLeg","rightFoot","leftUpLeg"],d=new Map;if(u)for(const b of h){const _=u[b];_&&d.set(b,_.rotation.clone())}const p=b=>{const _=Math.min(1,(b-t)/n),S=Ki.clamp(_/.32,0,1),A=Ki.clamp((_-.32)/.34,0,1),x=Ki.clamp((_-.66)/.34,0,1),y=S*S,E=A<.5?2*A*A:1-Math.pow(-2*A+2,2)/2,w=x<.5?2*x*x:1-Math.pow(-2*x+2,2)/2,T=y*(1-w)+E*(1-w);if(this.striker.position.y=a+Math.sin(_*Math.PI)*.4,u&&d.size>0){const P=u.hips,O=u.spine,U=u.rightUpLeg,I=u.rightLeg,C=u.rightFoot,R=u.leftUpLeg,F=d.get("hips");P&&F&&(P.rotation.x=F.x-.2*y+.14*E-.06*w,P.rotation.y=F.y+.06*E);const Y=d.get("spine");O&&Y&&(O.rotation.x=Y.x+.18*y-.12*E+.05*w);const $=d.get("rightUpLeg");U&&$&&(U.rotation.x=$.x+.75*y-1.25*E+.35*w,U.rotation.y=$.y-.08*E);const lt=d.get("rightLeg");I&<&&(I.rotation.x=lt.x-.95*y+1.05*E-.15*w);const ut=d.get("rightFoot");C&&ut&&(C.rotation.x=ut.x+.35*E-.08*w);const k=d.get("leftUpLeg");R&&k&&(R.rotation.x=k.x+.2*T)}else this.striker.rotation.x=i+Math.sin(_*Math.PI*2)*.2,o&&(o.rotation.x=l-Math.sin(_*Math.PI)*1);if(_<1)this.kickAnimFrame=requestAnimationFrame(p);else if(this.striker.position.y=a,this.striker.rotation.x=i,u&&d.size>0)for(const[P,O]of d.entries()){const U=u[P];U&&U.rotation.copy(O)}else o&&(o.rotation.x=l)};this.kickAnimFrame=requestAnimationFrame(p)}animate(){this.animationId=requestAnimationFrame(this.animate);const t=this.clock.getDelta();this.playerMixer&&this.playerMixer.update(t),this.timeScaleTimer>0&&(this.timeScaleTimer-=t,this.timeScaleTimer<=0?this.timeScale=1:this.timeScale=Math.min(1,.25+(4-this.timeScaleTimer)*.25));const n=t*this.timeScale;if(this.isBallActive){const i=1.9600000000000002;this.ballVelocity.y-=i*n;const a=new H().crossVectors(this.ballSpin,this.ballVelocity).multiplyScalar(.015);if(this.ballVelocity.addScaledVector(a,n),this.ball.position.addScaledVector(this.ballVelocity,n),this.ball.rotateX(this.ballSpin.x*n),this.ball.rotateY(this.ballSpin.y*n),this.ball.rotateZ(this.ballSpin.z*n),this.isSuperBall){this.ball.scale.set(1+Math.random()*.3,1+Math.random()*.3,1+Math.random()*.3);for(let o=this.trailCount-1;o>0;o--)this.trailMeshes[o].position.copy(this.trailMeshes[o-1].position),this.trailMeshes[o].position.x+=(Math.random()-.5)*.4,this.trailMeshes[o].position.y+=(Math.random()-.5)*.4,this.trailMeshes[o].visible=this.trailMeshes[o-1].visible,this.trailMeshes[o].material.opacity=1-o/this.trailCount,this.trailMeshes[o].material.color.setHSL(Math.random(),1,.5);this.trailMeshes[0].position.copy(this.ball.position),this.trailMeshes[0].visible=!0,this.trailMeshes[0].material.opacity=1,this.trailMeshes[0].material.color.setHex(65535)}else{this.ball.scale.set(1,1,1);for(let o=0;othis.catchPlaneZ+.5){this.isBallActive=!1,this.strikerAura.material.opacity=0,this.ball.scale.set(1,1,1);for(let o=0;o-2.9&&this.ball.position.x<2.9&&this.ball.position.y>0&&this.ball.position.y<2.9?(this.onGoal(),this.triggerExplosion(this.ball.position,this.isSuperBall)):this.onSave()}}for(let i=this.particles.length-1;i>=0;i--){const a=this.particles[i];if(a.life-=n*1.5,a.life<=0){this.particleGroup.remove(a.mesh),this.particles.splice(i,1);continue}a.mesh.position.addScaledVector(a.velocity,n),a.mesh.rotation.x+=n*5,a.mesh.rotation.y+=n*5,a.velocity.y-=9.8*n,a.isSuper&&a.mesh.scale.multiplyScalar(1+n),a.mesh.material.opacity=a.life}this.renderer.render(this.scene,this.camera)}hideTrails(){for(let t=0;t{n.beginPath();for(let m=0;m<5;m++){const b=m/5*Math.PI*2-Math.PI/2,_=d+Math.cos(b)*55,S=p+Math.sin(b)*55;m===0?n.moveTo(_,S):n.lineTo(_,S)}n.closePath(),n.fill()});const a=new QM(t);a.colorSpace=ci;const o=document.createElement("canvas");o.width=512,o.height=512;const l=o.getContext("2d");l.fillStyle="#808080",l.fillRect(0,0,512,512);const u=l.getImageData(0,0,512,512);for(let d=0;d{l.beginPath();for(let m=0;m<5;m++){const b=m/5*Math.PI*2-Math.PI/2,_=d+Math.cos(b)*57,S=p+Math.sin(b)*57;m===0?l.moveTo(_,S):l.lineTo(_,S)}l.closePath(),l.stroke();for(let m=0;m<5;m++){const b=m/5*Math.PI*2-Math.PI/2,_=d+Math.cos(b)*57,S=p+Math.sin(b)*57,A=d+Math.cos(b)*110,x=p+Math.sin(b)*110;l.beginPath(),l.moveTo(_,S),l.lineTo(A,x),l.stroke()}});const h=new QM(o);return{diff:a,bump:h}}getBallScreenPosition(){if(!this.isBallActive||this.ball.position.zthis.catchPlaneZ+1)return null;const t=this.ball.position.clone();return t.project(this.camera),{x:(t.x+1)/2,y:(-t.y+1)/2,zDepth:this.ball.position.z}}getGloveScreenPosition(t){const n=t==="left"?this.leftGlove:this.rightGlove;if(!n.visible)return null;const i=n.position.clone().project(this.camera);return{x:(i.x+1)/2,y:(-i.y+1)/2}}getActiveDefensePoints(){const t=this.getGloveScreenPosition("right"),n=this.getGloveScreenPosition("left");if(this.gloveTrackingMode==="right-only")return t?[t]:[];const i=[];return n&&i.push(n),t&&i.push(t),i}triggerParticleSave(){this.triggerExplosion(this.ball.position,this.isSuperBall),this.ball.visible=!1,setTimeout(()=>this.ball.visible=!0,500)}triggerExplosion(t,n){const i=n?100:30,a=n?65535:16776960;for(let o=0;o>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&a=56320&&o<=57343){t=1024*(t-55296)+o-56320+65536,i[n++]=t>>18|240,i[n++]=t>>12&63|128,i[n++]=t>>6&63|128,i[n++]=63&t|128;continue}a--}t=65533}i[n++]=t>>12|224,i[n++]=t>>6&63|128}i[n++]=63&t|128}}e=n===i.length?i:i.subarray(0,n)}return e}function Y3(e){Vc.setTimeout((()=>{throw e}),0)}var kv,K8=X3(610401301,!1),OA=X3(748402147,!0);function IA(){var e=Vc.navigator;return e&&(e=e.userAgent)?e:""}const FA=Vc.navigator;function $p(e){return $p[" "](e),e}kv=FA&&FA.userAgentData||null,$p[" "]=function(){};const K3={};let Rf=null;function Z8(e){const t=e.length;let n=3*t/4;n%3?n=Math.floor(n):"=.".indexOf(e[t-1])!=-1&&(n="=.".indexOf(e[t-2])!=-1?n-2:n-1);const i=new Uint8Array(n);let a=0;return(function(o,l){function u(d){for(;h>4),m!=64&&(l(p<<4&240|m>>2),b!=64&&l(m<<6&192|b))}})(e,(function(o){i[a++]=o})),a!==n?i.subarray(0,a):i}function Z3(){if(!Rf){Rf={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let n=0;n<5;n++){const i=e.concat(t[n].split(""));K3[n]=i;for(let a=0;a0)&&(IA().indexOf("Trident")!=-1||IA().indexOf("MSIE")!=-1))&&typeof btoa=="function";const BA=/[-_.]/g,J8={"-":"+",_:"/",".":"="};function $8(e){return J8[e]||""}function J3(e){if(!Q3)return Z8(e);e=BA.test(e)?e.replace(BA,$8):e,e=atob(e);const t=new Uint8Array(e.length);for(let n=0;n=t||(n[e]=i+1,tw(e=Error(),"incident"),Y3(e))}}function su(){return typeof BigInt=="function"}var au=typeof Symbol=="function"&&typeof Symbol()=="symbol";function Da(e,t,n=!1){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?n&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t}var nI=Da("jas",void 0,!0),kA=Da(void 0,"0di"),xf=Da(void 0,"1oa"),ms=Da(void 0,Symbol()),iI=Da(void 0,"0ub"),sI=Da(void 0,"0ubs"),Vv=Da(void 0,"0ubsb"),aI=Da(void 0,"0actk"),jc=Da("m_m","Pa",!0),zA=Da();const ew={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},nw=Object.defineProperties,Qt=au?nI:"Ga";var gl;const VA=[];function ih(e,t){au||Qt in e||nw(e,ew),e[Qt]|=t}function ni(e,t){au||Qt in e||nw(e,ew),e[Qt]=t}function sh(e){return ih(e,34),e}function qf(e){return ih(e,8192),e}ni(VA,7),gl=Object.freeze(VA);var Wc={};function vs(e,t){return t===void 0?e.h!==dl&&!!(2&(0|e.v[Qt])):!!(2&t)&&e.h!==dl}const dl={};function t_(e,t){if(e!=null){if(typeof e=="string")e=e?new Ma(e,Gc):hl();else if(e.constructor!==Ma)if(J1(e))e=e.length?new Ma(new Uint8Array(e),Gc):hl();else{if(!t)throw Error();e=void 0}}return e}class GA{constructor(t,n,i){this.g=t,this.h=n,this.l=i}next(){const t=this.g.next();return t.done||(t.value=this.h.call(this.l,t.value)),t}[Symbol.iterator](){return this}}var rI=Object.freeze({});function iw(e,t,n){const i=128&t?0:-1,a=e.length;var o;(o=!!a)&&(o=(o=e[a-1])!=null&&typeof o=="object"&&o.constructor===Object);const l=a+(o?-1:0);for(t=128&t?1:0;ttypeof e=="number")),HA=tm((e=>typeof e=="string")),lI=tm((e=>typeof e=="boolean")),em=typeof Vc.BigInt=="function"&&typeof Vc.BigInt(0)=="bigint";function gs(e){var t=e;if(HA(t)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(t))throw Error(String(t))}else if(oI(t)&&!Number.isSafeInteger(t))throw Error(String(t));return em?BigInt(e):e=lI(e)?e?"1":"0":HA(e)?e.trim()||"0":String(e)}var Gv=tm((e=>em?e>=uI&&e<=hI:e[0]==="-"?jA(e,cI):jA(e,fI)));const cI=Number.MIN_SAFE_INTEGER.toString(),uI=em?BigInt(Number.MIN_SAFE_INTEGER):void 0,fI=Number.MAX_SAFE_INTEGER.toString(),hI=em?BigInt(Number.MAX_SAFE_INTEGER):void 0;function jA(e,t){if(e.length>t.length)return!1;if(e.lengtha)return!1;if(i>>0;Sn=t,Hn=(e-t)/4294967296>>>0}function Xc(e){if(e<0){WA(-e);const[t,n]=i_(Sn,Hn);Sn=t>>>0,Hn=n>>>0}else WA(e)}function e_(e){const t=pI||(pI=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),Hn=0,Sn=t.getUint32(0,!0)}function aw(e,t){const n=4294967296*t+(e>>>0);return Number.isSafeInteger(n)?n:Yf(e,t)}function mI(e,t){return gs(su()?BigInt.asUintN(64,(BigInt(t>>>0)<>>0)):Yf(e,t))}function rw(e,t){return su()?gs(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(t))<>>=0,(t>>>=0)<=2097151)var n=""+(4294967296*t+e);else su()?n=""+(BigInt(t)<>>24|t<<8))+6710656*(t=t>>16&65535),n+=8147497*t,t*=2,e>=1e7&&(n+=e/1e7>>>0,e%=1e7),n>=1e7&&(t+=n/1e7>>>0,n%=1e7),n=t+XA(n)+XA(e));return n}function XA(e){return e=String(e),"0000000".slice(e.length)+e}function n_(e,t){if(2147483648&t)if(su())e=""+(BigInt(0|t)<>>0));else{const[n,i]=i_(e,t);e="-"+Yf(n,i)}else e=Yf(e,t);return e}function nm(e){if(e.length<16)Xc(Number(e));else if(su())e=BigInt(e),Sn=Number(e&BigInt(4294967295))>>>0,Hn=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+(e[0]==="-");Hn=Sn=0;const n=e.length;for(let i=t,a=(n-t)%6+t;a<=n;i=a,a+=6){const o=Number(e.slice(i,a));Hn*=1e6,Sn=1e6*Sn+o,Sn>=4294967296&&(Hn+=Math.trunc(Sn/4294967296),Hn>>>=0,Sn>>>=0)}if(t){const[i,a]=i_(Sn,Hn);Sn=i,Hn=a}}}function i_(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function aa(e){return Array.prototype.slice.call(e)}const ah=typeof BigInt=="function"?BigInt.asIntN:void 0,gI=typeof BigInt=="function"?BigInt.asUintN:void 0,pl=Number.isSafeInteger,im=Number.isFinite,qc=Math.trunc,bI=gs(0);function Cf(e){if(e!=null&&typeof e!="number")throw Error(`Value of float/double field must be a number, found ${typeof e}: ${e}`);return e}function xa(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function Kf(e){if(e!=null&&typeof e!="boolean"){var t=typeof e;throw Error(`Expected boolean but got ${t!="object"?t:e?Array.isArray(e)?"array":t:"null"}: ${e}`)}return e}function ow(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}const vI=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function rh(e){switch(typeof e){case"bigint":return!0;case"number":return im(e);case"string":return vI.test(e);default:return!1}}function ou(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return im(e)?0|e:void 0}function lw(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return im(e)?e>>>0:void 0}function cw(e){const t=e.length;return(e[0]==="-"?t<20||t===20&&e<="-9223372036854775808":t<19||t===19&&e<="9223372036854775807")?e:(nm(e),n_(Sn,Hn))}function s_(e){if(e=qc(e),!pl(e)){Xc(e);var t=Sn,n=Hn;(e=2147483648&n)&&(n=~n>>>0,(t=1+~t>>>0)==0&&(n=n+1>>>0)),e=typeof(t=aw(t,n))=="number"?e?-t:t:e?"-"+t:t}return e}function uw(e){var t=qc(Number(e));return pl(t)?String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),cw(e))}function fw(e){var t=qc(Number(e));return pl(t)?gs(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),su()?gs(ah(64,BigInt(e))):gs(cw(e)))}function hw(e){return pl(e)?e=gs(s_(e)):(e=qc(e),pl(e)?e=String(e):(Xc(e),e=n_(Sn,Hn)),e=gs(e)),e}function Np(e){const t=typeof e;return e==null?e:t==="bigint"?gs(ah(64,e)):rh(e)?t==="string"?fw(e):hw(e):void 0}function dw(e){if(typeof e!="string")throw Error();return e}function oh(e){if(e!=null&&typeof e!="string")throw Error();return e}function vi(e){return e==null||typeof e=="string"?e:void 0}function a_(e,t,n,i){return e!=null&&e[jc]===Wc?e:Array.isArray(e)?((i=(n=0|e[Qt])|32&i|2&i)!==n&&ni(e,i),new t(e)):(n?2&i?((e=t[kA])||(sh((e=new t).v),e=t[kA]=e),t=e):t=new t:t=void 0,t)}function _I(e,t,n){if(t)t:{if(!rh(t=e))throw zv("int64");switch(typeof t){case"string":t=fw(t);break t;case"bigint":t=gs(ah(64,t));break t;default:t=hw(t)}}else t=Np(e);return(e=t)==null?n?bI:void 0:e}const yI={};let xI=(function(){try{return $p(new class extends Map{constructor(){super()}}),!1}catch{return!0}})();class Sb{constructor(){this.g=new Map}get(t){return this.g.get(t)}set(t,n){return this.g.set(t,n),this.size=this.g.size,this}delete(t){return t=this.g.delete(t),this.size=this.g.size,t}clear(){this.g.clear(),this.size=this.g.size}has(t){return this.g.has(t)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(t,n){return this.g.forEach(t,n)}[Symbol.iterator](){return this.entries()}}const SI=xI?(Object.setPrototypeOf(Sb.prototype,Map.prototype),Object.defineProperties(Sb.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Sb):class extends Map{constructor(){super()}};function qA(e){return e}function Mb(e){if(2&e.J)throw Error("Cannot mutate an immutable Map")}var pr=class extends SI{constructor(e,t,n=qA,i=qA){super(),this.J=0|e[Qt],this.K=t,this.S=n,this.fa=this.K?MI:i;for(let a=0;a{e.call(t,a.get(i),i,a)})):super.forEach(e,t)}set(e,t){return Mb(this),(e=this.S(e,!0,!1))==null?this:t==null?(super.delete(e),this):super.set(e,this.fa(t,!0,!0,this.K,!1,this.J))}Ma(e){const t=this.S(e[0],!1,!0);e=e[1],e=this.K?e===void 0?null:e:this.fa(e,!1,!0,void 0,!1,this.J),super.set(t,e)}has(e){return super.has(this.S(e,!1,!1))}get(e){e=this.S(e,!1,!1);const t=super.get(e);if(t!==void 0){var n=this.K;return n?((n=this.fa(t,!1,!0,n,this.ra,this.J))!==t&&super.set(e,n),n):t}}[Symbol.iterator](){return this.entries()}};function MI(e,t,n,i,a,o){return e=a_(e,i,n,o),a&&(e=o_(e)),e}function AI(e){return[e,this.get(e)]}let TI;function YA(){return TI||(TI=new pr(sh([]),void 0,void 0,void 0,yI))}function sm(e){return ms?e[ms]:void 0}function Up(e,t){for(const n in e)!isNaN(n)&&t(e,+n,e[n])}pr.prototype.toJSON=void 0;var Hv=class{};const EI={Ka:!0};function wI(e,t){t<100||Hc(sI,1)}function am(e,t,n,i){const a=i!==void 0;i=!!i;var o,l=ms;!a&&au&&l&&(o=e[l])&&Up(o,wI),l=[];var u=e.length;let h;o=4294967295;let d=!1;const p=!!(64&t),m=p?128&t?0:-1:void 0;1&t||(h=u&&e[u-1],h!=null&&typeof h=="object"&&h.constructor===Object?o=--u:h=void 0,!p||128&t||a||(d=!0,o=o-m+m)),t=void 0;for(var b=0;b=o){const S=b-m;(t??(t={}))[S]=_}else l[b]=_}if(h)for(let _ in h){if((u=h[_])==null||(u=n(u,i))==null)continue;let S;b=+_,p&&!Number.isNaN(b)&&(S=b+m){S[x]=aa(y)})),S.da=_.da,S})(e)),l}function RI(e){return e[0]=Zf(e[0]),e[1]=Zf(e[1]),e}function Zf(e){switch(typeof e){case"number":return Number.isFinite(e)?e:""+e;case"bigint":return Gv(e)?Number(e):""+e;case"boolean":return e?1:0;case"object":if(Array.isArray(e)){var t=0|e[Qt];return e.length===0&&1&t?void 0:am(e,t,Zf)}if(e!=null&&e[jc]===Wc)return pw(e);if(e instanceof Ma){if((t=e.g)==null)e="";else if(typeof t=="string")e=t;else{if(Q3){for(var n="",i=0,a=t.length-10240;i>2];o=n[(3&o)<<4|l>>4],l=n[(15&l)<<2|u>>6],u=n[63&u],i[p++]=h+o+l+u}switch(h=0,u=a,t.length-d){case 2:u=n[(15&(h=t[d+1]))<<2]||a;case 1:t=t[d],i[p]=n[t>>2]+n[(3&t)<<4|h>>4]+u+a}t=i.join("")}e=e.g=t}return e}return e instanceof pr?e=e.size!==0?e.V(RI):void 0:void 0}return e}let CI,DI;function pw(e){return am(e=e.v,0|e[Qt],Zf)}function nl(e,t){return mw(e,t[0],t[1])}function mw(e,t,n,i=0){if(e==null){var a=32;n?(e=[n],a|=128):e=[],t&&(a=-16760833&a|(1023&t)<<14)}else{if(!Array.isArray(e))throw Error("narr");if(a=0|e[Qt],OA&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&(function(){if(OA)throw Error("carr");Hc(aI,5)})(),256&a)throw Error("farr");if(64&a)return(a|i)!==a&&ni(e,a|i),e;if(n&&(a|=128,n!==e[0]))throw Error("mid");t:{a|=64;var o=(n=e).length;if(o){var l=o-1;const h=n[l];if(h!=null&&typeof h=="object"&&h.constructor===Object){if((l-=t=128&a?0:-1)>=1024)throw Error("pvtlmt");for(var u in h)(o=+u)1024)throw Error("spvt");a=-16760833&a|(1023&u)<<14}}}return ni(e,64|a|i),e}function LI(e,t){if(typeof e!="object")return e;if(Array.isArray(e)){var n=0|e[Qt];return e.length===0&&1&n?void 0:KA(e,n,t)}if(e!=null&&e[jc]===Wc)return ZA(e);if(e instanceof pr){if(2&(t=e.J))return e;if(!e.size)return;if(n=sh(e.V()),e.K)for(e=0;e=o)if(l=e[o],l!=null&&typeof l=="object"&&l.constructor===Object)n=l[t],u=!0;else{if(a!==o)return;n=l}else n=e[a];if(i&&n!=null){if((i=i(n))==null)return i;if(!Object.is(i,n))return u?l[t]=i:e[a]=i,i}return n}}function rn(e,t,n,i){uu(e),Jn(e=e.v,0|e[Qt],t,n,i)}function Jn(e,t,n,i,a){const o=n+(a?0:-1);var l=e.length-1;if(l>=1+(a?0:-1)&&o>=l){const u=e[l];if(u!=null&&typeof u=="object"&&u.constructor===Object)return u[n]=i,t}return o<=l?(e[o]=i,t):(i!==void 0&&(n>=(l=(t??(t=0|e[Qt]))>>14&1023||536870912)?i!=null&&(e[l+(a?0:-1)]={[n]:i}):e[o]=i),t)}function Jo(){return rI===void 0?2:4}function $o(e,t,n,i,a){let o=e.v,l=0|o[Qt];i=vs(e,l)?1:i,a=!!a||i===3,i===2&&cu(e)&&(o=e.v,l=0|o[Qt]);let u=(e=c_(o,t))===gl?7:0|e[Qt],h=u_(u,l);var d=!(4&h);if(d){4&h&&(e=aa(e),u=0,h=sl(h,l),l=Jn(o,l,t,e));let p=0,m=0;for(;p{const u=a_(l,n,!1,t);return o=u!==l&&u!=null,u})))!=null)return o&&!vs(i)&&bl(e,t),i}function Ge(e,t,n,i){let a=e.v,o=0|a[Qt];if((t=xw(a,o,t,n,i))==null)return t;if(o=0|a[Qt],!vs(e,o)){const l=o_(t);l!==t&&(cu(e)&&(a=e.v,o=0|a[Qt]),o=Jn(a,o,n,t=l,i),bl(a,o))}return t}function Sw(e,t,n,i,a,o,l,u){var h=vs(e,n);o=h?1:o,l=!!l||o===3,h=u&&!h,(o===2||h)&&cu(e)&&(n=0|(t=e.v)[Qt]);var d=(e=c_(t,a))===gl?7:0|e[Qt],p=u_(d,n);if(u=!(4&p)){var m=e,b=n;const _=!!(2&p);_&&(b|=2);let S=!_,A=!0,x=0,y=0;for(;x32)for(a|=(127&n)>>4,o=3;o<32&&128&n;o+=7)n=l[u++],a|=(127&n)<>>0,a>>>0);throw Error()}function b_(e){let t=0,n=e.g;const i=n+10,a=e.h;for(;n>>0}function Op(e){var t=e.h;const n=e.g;var i=t[n],a=t[n+1];const o=t[n+2];return t=t[n+3],al(e,e.g+4),e=2*((a=(i<<0|a<<8|o<<16|t<<24)>>>0)>>31)+1,i=a>>>23&255,a&=8388607,i==255?a?NaN:e*(1/0):i==0?1401298464324817e-60*e*a:e*Math.pow(2,i-150)*(a+8388608)}function NI(e){return lo(e)}function al(e,t){if(e.g=t,t>e.l)throw Error()}function Aw(e,t){if(t<0)throw Error();const n=e.g;if((t=n+t)>e.l)throw Error();return e.g=t,n}function Tw(e,t){if(t==0)return hl();var n=Aw(e,t);return e.Y&&e.j?n=e.h.subarray(n,n+t):(e=e.h,n=n===(t=n+t)?new Uint8Array(0):dI?e.slice(n,t):new Uint8Array(e.subarray(n,t))),n.length==0?hl():new Ma(n,Gc)}var QA=[];function Ew(e,t,n,i){if(Ip.length){const a=Ip.pop();return a.o(i),a.g.init(e,t,n,i),a}return new UI(e,t,n,i)}function ww(e){e.g.clear(),e.l=-1,e.h=-1,Ip.length<100&&Ip.push(e)}function Rw(e){var t=e.g;if(t.g==t.l)return!1;e.m=e.g.g;var n=Ea(e.g);if(t=n>>>3,!((n&=7)>=0&&n<=5)||t<1)throw Error();return e.l=t,e.h=n,!0}function gp(e){switch(e.h){case 0:e.h!=0?gp(e):b_(e.g);break;case 1:al(e=e.g,e.g+8);break;case 2:if(e.h!=2)gp(e);else{var t=Ea(e.g);al(e=e.g,e.g+t)}break;case 5:al(e=e.g,e.g+4);break;case 3:for(t=e.l;;){if(!Rw(e))throw Error();if(e.h==4){if(e.l!=t)throw Error();break}gp(e)}break;default:throw Error()}}function lh(e,t,n){const i=e.g.l;var a=Ea(e.g);let o=(a=e.g.g+a)-i;if(o<=0&&(e.g.l=a,n(t,e,void 0,void 0,void 0),o=a-e.g.g),o)throw Error();return e.g.g=a,e.g.l=i,t}function v_(e){var t=Ea(e.g),n=Aw(e=e.g,t);if(e=e.h,X8){var i,a=e;(i=xb)||(i=xb=new TextDecoder("utf-8",{fatal:!0})),t=n+t,a=n===0&&t===a.length?a:a.subarray(n,t);try{var o=i.decode(a)}catch(u){if(Jd===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),Jd=!0}catch{Jd=!1}}throw!Jd&&(xb=void 0),u}}else{t=(o=n)+t,n=[];let u,h=null;for(;o=t?Vo():(u=e[o++],l<194||(192&u)!=128?(o--,Vo()):n.push((31&l)<<6|63&u)):l<240?o>=t-1?Vo():(u=e[o++],(192&u)!=128||l===224&&u<160||l===237&&u>=160||(192&(i=e[o++]))!=128?(o--,Vo()):n.push((15&l)<<12|(63&u)<<6|63&i)):l<=244?o>=t-2?Vo():(u=e[o++],(192&u)!=128||u-144+(l<<28)>>30!=0||(192&(i=e[o++]))!=128||(192&(a=e[o++]))!=128?(o--,Vo()):(l=(7&l)<<18|(63&u)<<12|(63&i)<<6|63&a,l-=65536,n.push(55296+(l>>10&1023),56320+(1023&l)))):Vo(),n.length>=8192&&(h=PA(h,n),n.length=0)}o=PA(h,n)}return o}function Cw(e){const t=Ea(e.g);return Tw(e.g,t)}function om(e,t,n){var i=Ea(e.g);for(i=e.g.g+i;e.g.g>>0,this.g=t>>>0}};let PI;function $A(e){return e?/^-?\d+$/.test(e)?(nm(e),new Wv(Sn,Hn)):null:OI||(OI=new Wv(0,0))}var Wv=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let OI;function Rc(e,t,n){for(;n>0||t>127;)e.g.push(127&t|128),t=(t>>>7|n<<25)>>>0,n>>>=7;e.g.push(t)}function hu(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function lm(e,t){if(t>=0)hu(e,t);else{for(let n=0;n<9;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function __(e){var t=Sn;e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function Yc(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function Vs(e,t,n){hu(e.g,8*t+n)}function y_(e,t){return Vs(e,t,2),t=e.g.end(),Yc(e,t),t.push(e.h),t}function x_(e,t){var n=t.pop();for(n=e.h+e.g.length()-n;n>127;)t.push(127&n|128),n>>>=7,e.h++;t.push(n),e.h++}function cm(e,t,n){Vs(e,t,2),hu(e.g,n.length),Yc(e,e.g.end()),Yc(e,n)}function Fp(e,t,n,i){n!=null&&(t=y_(e,t),i(n,e),x_(e,t))}function La(){const e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var S_=La(),Dw=La(),M_=La(),A_=La(),T_=La(),Lw=La(),II=La(),um=La(),Nw=La(),Uw=La();function Na(e,t,n){var i=e.v;ms&&ms in i&&(i=i[ms])&&delete i[t.g],t.h?t.j(e,t.h,t.g,n,t.l):t.j(e,t.g,n,t.l)}var Jt=class{constructor(e,t){this.v=mw(e,t,void 0,2048)}toJSON(){return pw(this)}j(){var a;var e=bF,t=this.v,n=e.g,i=ms;if(au&&i&&((a=t[i])==null?void 0:a[n])!=null&&Hc(iI,3),t=e.g,zA&&ms&&zA===void 0&&(i=(n=this.v)[ms])&&(i=i.da))try{i(n,t,EI)}catch(o){Y3(o)}return e.h?e.m(this,e.h,e.g,e.l):e.m(this,e.g,e.defaultValue,e.l)}clone(){const e=this.v,t=0|e[Qt];return l_(this,e,t)?r_(this,e,!0):new this.constructor(lu(e,t,!1))}};Jt.prototype[jc]=Wc,Jt.prototype.toString=function(){return this.v.toString()};var du=class{constructor(e,t,n){this.g=e,this.h=t,e=S_,this.l=!!e&&n===e||!1}};function fm(e,t){return new du(e,t,S_)}function Pw(e,t,n,i,a){Fp(e,n,Bw(t,i),a)}const FI=fm((function(e,t,n,i,a){return e.h===2&&(lh(e,d_(t,i,n),a),!0)}),Pw),BI=fm((function(e,t,n,i,a){return e.h===2&&(lh(e,d_(t,i,n),a),!0)}),Pw);var hm=Symbol(),dm=Symbol(),Xv=Symbol(),tT=Symbol(),eT=Symbol();let Ow,Iw;function vl(e,t,n,i){var a=i[e];if(a)return a;(a={}).qa=i,a.T=(function(m){switch(typeof m){case"boolean":return CI||(CI=[0,void 0,!0]);case"number":return m>0?void 0:m===0?DI||(DI=[0,void 0]):[-m,void 0];case"string":return[0,m];case"object":return m}})(i[0]);var o=i[1];let l=1;o&&o.constructor===Object&&(a.ba=o,typeof(o=i[++l])=="function"&&(a.ma=!0,Ow??(Ow=o),Iw??(Iw=i[l+1]),o=i[l+=2]));const u={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var h=0;ha(o,l,u,i):a}function w_(e,t,n,i,a){const o=n.g;let l,u;e[t]=(h,d,p)=>o(h,d,p,u||(u=vl(dm,E_,w_,i).T),l||(l=R_(i)),a)}function R_(e){let t=e[Xv];if(t!=null)return t;const n=vl(dm,E_,w_,e);return t=n.ma?(i,a)=>Ow(i,a,n):(i,a)=>{for(;Rw(a)&&a.h!=4;){var o=a.l,l=n[o];if(l==null){var u=n.ba;u&&(u=u[o])&&(u=zI(u))!=null&&(l=n[o]=u)}if(l==null||!l(a,i,o)){if(l=(u=a).m,gp(u),u.ha)var h=void 0;else h=u.g.g-l,u.g.g=l,h=Tw(u.g,h);l=void 0,u=i,h&&((l=u[ms]??(u[ms]=new Hv))[o]??(l[o]=[])).push(h)}}return(i=sm(i))&&(i.da=n.qa[eT]),!0},e[Xv]=t,e[eT]=kI.bind(e),t}function kI(e,t,n,i){var a=this[dm];const o=this[Xv],l=nl(void 0,a.T),u=sm(e);if(u){var h=!1,d=a.ba;if(d){if(a=(p,m,b)=>{if(b.length!==0)if(d[m])for(const _ of b){p=Ew(_);try{h=!0,o(l,p)}finally{ww(p)}}else i==null||i(e,m,b)},t==null)Up(u,a);else if(u!=null){const p=u[t];p&&a(u,t,p)}if(h){let p=0|e[Qt];if(2&p&&2048&p&&!(n!=null&&n.Ka))throw Error();const m=ru(p),b=(_,S)=>{if(mr(e,_,m)!=null){if((n==null?void 0:n.Qa)===1)return;throw Error()}S!=null&&(p=Jn(e,p,_,S,m)),delete u[_]};t==null?iw(l,0|l[Qt],((_,S)=>{b(_,S)})):b(t,mr(l,t,m))}}}}function zI(e){const t=(e=Fw(e))[0].g;if(e=e[1]){const n=R_(e),i=vl(dm,E_,w_,e).T;return(a,o,l)=>t(a,o,l,i,n)}return t}function pm(e,t,n){e[t]=n.h}function mm(e,t,n,i){let a,o;const l=n.h;e[t]=(u,h,d)=>l(u,h,d,o||(o=vl(hm,pm,mm,i).T),a||(a=kw(i)))}function kw(e){let t=e[tT];if(!t){const n=vl(hm,pm,mm,e);t=(i,a)=>zw(i,a,n),e[tT]=t}return t}function zw(e,t,n){iw(e,0|e[Qt],((i,a)=>{if(a!=null){var o=(function(l,u){var h=l[u];if(h)return h;if((h=l.ba)&&(h=h[u])){var d=(h=Fw(h))[0].h;if(h=h[1]){const p=kw(h),m=vl(hm,pm,mm,h).T;h=l.ma?Iw(m,p):(b,_,S)=>d(b,_,S,m,p)}else h=d;return l[u]=h}})(n,i);o?o(t,a,i):i<500||Hc(Vv,3)}})),(e=sm(e))&&Up(e,((i,a,o)=>{for(Yc(t,t.g.end()),i=0;i{Fp(e,n,nl([l,o],i),a)}));else if(Array.isArray(t)){for(let o=0;o>BigInt(32))),Rc(e.g,n.h,n.g);break;default:n=$A(t),Rc(e.g,n.h,n.g)}}function Hw(e,t,n){(t=ou(t))!=null&&t!=null&&(Vs(e,n,0),lm(e.g,t))}function jw(e,t,n){(t=ow(t))!=null&&(Vs(e,n,0),e.g.g.push(t?1:0))}function Ww(e,t,n){(t=vi(t))!=null&&cm(e,n,q3(t))}function Xw(e,t,n,i,a){Fp(e,n,Bw(t,i),a)}function qw(e,t,n){(t=t==null||typeof t=="string"||t instanceof Ma?t:void 0)!=null&&cm(e,n,m_(t,!0).buffer)}function Yw(e,t,n){(t=lw(t))!=null&&t!=null&&(Vs(e,n,0),hu(e.g,t))}function Kw(e,t,n){return(e.h===5||e.h===2)&&(t=fu(t,0|t[Qt],n),e.h==2?om(e,Op,t):t.push(Op(e.g)),!0)}var jn=Ti((function(e,t,n){return e.h===5&&(Ei(t,n,Op(e.g)),!0)}),Vw,um),HI=mu(Kw,(function(e,t,n){if((t=pu(xa,t))!=null)for(let l=0;l=0?i=String(a):((a=i.indexOf("."))!==-1&&(i=i.substring(0,a)),(a=i[0]!=="-"&&((a=i.length)<20||a===20&&i<="18446744073709551615"))||(nm(i),i=Yf(Sn,Hn))),i;if(a==="number")return(i=qc(i))>=0&&pl(i)||(Xc(i),i=aw(Sn,Hn)),i}})(t),t!=null&&(typeof t=="string"&&JA(t),t!=null))switch(Vs(e,n,0),typeof t){case"number":e=e.g,Xc(t),Rc(e,Sn,Hn);break;case"bigint":n=BigInt.asUintN(64,t),n=new jv(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),Rc(e.g,n.h,n.g);break;default:n=JA(t),Rc(e.g,n.h,n.g)}}),II),Zn=Ti((function(e,t,n){return e.h===0&&(Ei(t,n,lo(e.g)),!0)}),Hw,A_),ch=mu((function(e,t,n){return(e.h===0||e.h===2)&&(t=fu(t,0|t[Qt],n),e.h==2?om(e,lo,t):t.push(lo(e.g)),!0)}),(function(e,t,n){if((t=pu(ou,t))!=null&&t.length){n=y_(e,n);for(let i=0;i{{const o={ea:!0};i&&Object.assign(o,i),n=Ew(n,void 0,void 0,o);try{const l=new e,u=l.v;R_(t)(u,n);var a=l}finally{ww(n)}}return a}}function gm(e){return function(){const t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const l=this.g;return this.g=[],l}}}};zw(this.v,t,vl(hm,pm,mm,e)),Yc(t,t.g.end());const n=new Uint8Array(t.h),i=t.l,a=i.length;let o=0;for(let l=0;la;n=sT.createPolicy("goog#html",{createHTML:i,createScript:i,createScriptURL:i})}catch{}return n})()),e=(t=Eb)?t.createScriptURL(e):e,new class{constructor(n){this.g=n}toString(){return this.g+""}}(e)}function $d(e,...t){if(t.length===0)return aT(e[0]);let n=e[0];for(let i=0;i({index:Bs(i,1)??0??-1,score:In(i,2)??0,categoryName:vi(Mn(i,3))??""??"",displayName:vi(Mn(i,4))??""??""}))),headIndex:t,headName:n}}function xF(e){const t={classifications:gr(e,nF,1).map((n=>{var i;return F_(((i=Ge(n,sR,4))==null?void 0:i.g())??[],Bs(n,2)??0,vi(Mn(n,3))??"")}))};return(function(n){return n==null?n:typeof n=="bigint"?(Gv(n)?n=Number(n):(n=ah(64,n),n=Gv(n)?Number(n):String(n)),n):rh(n)?typeof n=="number"?s_(n):uw(n):void 0})(Mn(e,2,void 0,void 0,Np))!=null&&(t.timestampMs=LR(Mn(e,2,void 0,void 0,Np)??gw)),t}function NR(e){var l,u;var t=$o(e,3,xa,Jo()),n=$o(e,2,ou,Jo()),i=$o(e,1,vi,Jo()),a=$o(e,9,vi,Jo());const o={categories:[],keypoints:[]};for(let h=0;ht>127?t-256:t))}function bT(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let n=0,i=0,a=0;for(let o=0;o=1&&Number(e[1])>=17))}async function vT(e){if(typeof importScripts!="function"){const t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise(((n,i)=>{t.addEventListener("load",(()=>{n()}),!1),t.addEventListener("error",(a=>{i(a)}),!1),document.body.appendChild(t)}))}try{importScripts(e.toString())}catch(t){if(!(t instanceof TypeError))throw t;{const n=self.import;n?await n(e.toString()):await import(e.toString())}}}function OR(e){return e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height]}function $t(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function _T(e,t,n){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(n?e.i._bindTextureToStream(n):e.i._bindTextureToCanvas(),!(n=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1);const[i,a]=OR(t);return!e.l||i===e.i.canvas.width&&a===e.i.canvas.height||(e.i.canvas.width=i,e.i.canvas.height=a),[i,a]}function yT(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const i=new Uint32Array(t.length);for(let a=0;a>2),n(t);for(const a of i)e.i._free(a);e.i._free(t)}function ga(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function Kr(e,t,n){let i=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(a,o,l)=>{o?(n(i,l),i=[]):i.push(a)}}mc.forVisionTasks=function(e,t=!1){return ep("vision",e??$d``,t)},mc.forTextTasks=function(e,t=!1){return ep("text",e??$d``,t)},mc.forGenAiTasks=function(e,t=!1){return ep("genai",e??$d``,t)},mc.forAudioTasks=function(e,t=!1){return ep("audio",e??$d``,t)},mc.isSimdSupported=function(e=!1){return UR(e)};async function MF(e,t,n,i){return e=await(async(a,o,l,u,h)=>{if(o&&await vT(o),!self.ModuleFactory||l&&(await vT(l),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&h&&((o=self.Module).locateFile=h.locateFile,h.mainScriptUrlOrBlob&&(o.mainScriptUrlOrBlob=h.mainScriptUrlOrBlob)),h=await self.ModuleFactory(self.Module||h),self.ModuleFactory=self.Module=void 0,new a(h,u)})(e,n.wasmLoaderPath,n.assetLoaderPath,t,{locateFile:a=>a.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&a.endsWith(".data")?n.assetBinaryPath.toString():a}),await e.o(i),e}function Cb(e,t){const n=Ge(e.baseOptions,Bp,1)||new Bp;typeof t=="string"?(rn(n,2,oh(t)),rn(n,1)):t instanceof Uint8Array&&(rn(n,1,t_(t,!1)),rn(n,2)),ce(e.baseOptions,0,1,n)}function xT(e){try{const t=e.H.length;if(t===1)throw Error(e.H[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.H.map((n=>n.message)).join(", "))}finally{e.H=[]}}function Xt(e,t){e.C=Math.max(e.C,t)}function ym(e,t){e.B=new ts,_s(e.B,2,"PassThroughCalculator"),xn(e.B,"free_memory"),Fe(e.B,"free_memory_unused_out"),En(t,"free_memory"),Gs(t,e.B)}function Kc(e,t){xn(e.B,t),Fe(e.B,t+"_unused_out")}function xm(e){e.g.addBoolToStream(!0,"free_memory",e.C)}var Qv=class{constructor(e){this.g=e,this.H=[],this.C=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){var n,i,a,o,l,u;if(t){const h=e.baseOptions||{};if((n=e.baseOptions)!=null&&n.modelAssetBuffer&&((i=e.baseOptions)!=null&&i.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((a=Ge(this.baseOptions,Bp,1))!=null&&a.g()||(o=Ge(this.baseOptions,Bp,1))!=null&&o.l()||(l=e.baseOptions)!=null&&l.modelAssetBuffer||(u=e.baseOptions)!=null&&u.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if((function(d,p){let m=Ge(d.baseOptions,hT,3);if(!m){var b=m=new hT,_=new rT;Of(b,4,bp,_)}"delegate"in p&&(p.delegate==="GPU"?(p=m,b=new KI,Of(p,2,bp,b)):(p=m,b=new rT,Of(p,4,bp,b))),ce(d.baseOptions,0,3,m)})(this,h),h.modelAssetPath)return fetch(h.modelAssetPath.toString()).then((d=>{if(d.ok)return d.arrayBuffer();throw Error(`Failed to fetch model: ${h.modelAssetPath} (${d.status})`)})).then((d=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(d),!0,!1,!1),Cb(this,"/model.dat"),this.m(),this.L()}));if(h.modelAssetBuffer instanceof Uint8Array)Cb(this,h.modelAssetBuffer);else if(h.modelAssetBuffer)return(async function(d){const p=[];for(var m=0;;){const{done:b,value:_}=await d.read();if(b)break;p.push(_),m+=_.length}if(p.length===0)return new Uint8Array(0);if(p.length===1)return p[0];d=new Uint8Array(m),m=0;for(const b of p)d.set(b,m),m+=b.length;return d})(h.modelAssetBuffer).then((d=>{Cb(this,d),this.m(),this.L()}))}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let e;if(this.g.ca((t=>{e=ZI(t)})),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener(((n,i)=>{this.H.push(Error(i))})),this.g.Ja(),this.g.setGraph(e,t),this.B=void 0,xT(this)}finishProcessing(){this.g.finishProcessing(),xT(this)}close(){this.B=void 0,this.g.closeGraph()}};function ro(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}Qv.prototype.close=Qv.prototype.close;class AF{constructor(t,n,i,a){this.g=t,this.h=n,this.m=i,this.l=a}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function ST(e,t,n){const i=e.g;if(n=ro(i.createShader(n),"Failed to create WebGL shader"),i.shaderSource(n,t),i.compileShader(n),!i.getShaderParameter(n,i.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${i.getShaderInfoLog(n)}`);return i.attachShader(e.h,n),n}function MT(e,t){const n=e.g,i=ro(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(i);const a=ro(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,a),n.enableVertexAttribArray(e.O),n.vertexAttribPointer(e.O,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW);const o=ro(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,o),n.enableVertexAttribArray(e.L),n.vertexAttribPointer(e.L,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindVertexArray(null),new AF(n,i,a,o)}function B_(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function TF(e,t,n,i){return B_(e,t),e.h||(e.m(),e.D()),n?(e.u||(e.u=MT(e,!0)),n=e.u):(e.A||(e.A=MT(e,!1)),n=e.A),t.useProgram(e.h),n.bind(),e.l(),e=i(),n.g.bindVertexArray(null),e}function IR(e,t,n){return B_(e,t),e=ro(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,n??t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,n??t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),e}function FR(e,t,n){B_(e,t),e.B||(e.B=ro(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.B),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0)}function EF(e){var t;(t=e.g)==null||t.bindFramebuffer(e.g.FRAMEBUFFER,null)}var BR=class{H(){return` precision mediump float; varying vec2 vTex; uniform sampler2D inputTexture; void main() { gl_FragColor = texture2D(inputTexture, vTex); } `}m(){const e=this.g;if(this.h=ro(e.createProgram(),"Failed to create WebGL program"),this.X=ST(this,` attribute vec2 aVertex; attribute vec2 aTex; varying vec2 vTex; void main(void) { gl_Position = vec4(aVertex, 0.0, 1.0); vTex = aTex; }`,e.VERTEX_SHADER),this.W=ST(this,this.H(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.O=e.getAttribLocation(this.h,"aVertex"),this.L=e.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){const e=this.g;e.deleteProgram(this.h),e.deleteShader(this.X),e.deleteShader(this.W)}this.B&&this.g.deleteFramebuffer(this.B),this.A&&this.A.close(),this.u&&this.u.close()}};function lr(e,t){switch(t){case 0:return e.g.find((n=>n instanceof Uint8Array));case 1:return e.g.find((n=>n instanceof Float32Array));case 2:return e.g.find((n=>typeof WebGLTexture<"u"&&n instanceof WebGLTexture));default:throw Error(`Type is not supported: ${t}`)}}function Jv(e){var t=lr(e,1);if(!t){if(t=lr(e,0))t=new Float32Array(t).map((i=>i/255));else{t=new Float32Array(e.width*e.height);const i=Zc(e);var n=k_(e);if(FR(n,i,kR(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){n=new Float32Array(e.width*e.height*4),i.readPixels(0,0,e.width,e.height,i.RGBA,i.FLOAT,n);for(let a=0,o=0;aMath.round(255*n)))),e.g.push(t)),t;var e,t}ia(){return Jv(this)}N(){return kR(this)}clone(){const e=[];for(const t of this.g){let n;if(t instanceof Uint8Array)n=new Uint8Array(t);else if(t instanceof Float32Array)n=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{const i=Zc(this),a=k_(this);i.activeTexture(i.TEXTURE1),n=IR(a,i,this.m?i.LINEAR:i.NEAREST),i.bindTexture(i.TEXTURE_2D,n);const o=zR(this);i.texImage2D(i.TEXTURE_2D,0,o,this.width,this.height,0,i.RED,i.FLOAT,null),i.bindTexture(i.TEXTURE_2D,null),FR(a,i,n),TF(a,i,!1,(()=>{VR(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),$v(this)})),EF(a),$v(this)}}e.push(n)}return new oi(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Zc(this).deleteTexture(lr(this,2)),AT=-1}};oi.prototype.close=oi.prototype.close,oi.prototype.clone=oi.prototype.clone,oi.prototype.getAsWebGLTexture=oi.prototype.N,oi.prototype.getAsFloat32Array=oi.prototype.ia,oi.prototype.getAsUint8Array=oi.prototype.ja,oi.prototype.hasWebGLTexture=oi.prototype.R,oi.prototype.hasFloat32Array=oi.prototype.ka,oi.prototype.hasUint8Array=oi.prototype.Fa;var AT=250;function la(...e){return e.map((([t,n])=>({start:t,end:n})))}const wF=(function(e){return class extends e{Ja(){this.i._registerModelResourcesGraphService()}}})((TT=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:PR()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){const t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){const n=e.length,i=this.i._malloc(n);this.i.HEAPU8.set(e,i),t?this.i._changeBinaryGraph(n,i):this.i._changeTextGraph(n,i),this.i._free(i)}configureAudio(e,t,n,i,a){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),$t(this,i||"input_audio",(o=>{$t(this,a=a||"audio_header",(l=>{this.i._configureAudio(o,l,e,t??0,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ca(e){ga(this,"__graph_config__",(t=>{e(t)})),$t(this,"__graph_config__",(t=>{this.i._getGraphConfig(t,void 0)})),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,n){this.addAudioToStreamWithShape(e,0,0,t,n)}addAudioToStreamWithShape(e,t,n,i,a){const o=4*e.length;this.h!==o&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(o),this.h=o),this.i.HEAPF32.set(e,this.g/4),$t(this,i,(l=>{this.i._addAudioToInputStream(this.g,t,n,l,a)}))}addGpuBufferToStream(e,t,n){$t(this,t,(i=>{const[a,o]=_T(this,e,i);this.i._addBoundTextureToStream(i,a,o,n)}))}addBoolToStream(e,t,n){$t(this,t,(i=>{this.i._addBoolToInputStream(e,i,n)}))}addDoubleToStream(e,t,n){$t(this,t,(i=>{this.i._addDoubleToInputStream(e,i,n)}))}addFloatToStream(e,t,n){$t(this,t,(i=>{this.i._addFloatToInputStream(e,i,n)}))}addIntToStream(e,t,n){$t(this,t,(i=>{this.i._addIntToInputStream(e,i,n)}))}addUintToStream(e,t,n){$t(this,t,(i=>{this.i._addUintToInputStream(e,i,n)}))}addStringToStream(e,t,n){$t(this,t,(i=>{$t(this,e,(a=>{this.i._addStringToInputStream(a,i,n)}))}))}addStringRecordToStream(e,t,n){$t(this,t,(i=>{yT(this,Object.keys(e),(a=>{yT(this,Object.values(e),(o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(e).length,i,n)}))}))}))}addProtoToStream(e,t,n,i){$t(this,n,(a=>{$t(this,t,(o=>{const l=this.i._malloc(e.length);this.i.HEAPU8.set(e,l),this.i._addProtoToInputStream(l,e.length,o,a,i),this.i._free(l)}))}))}addEmptyPacketToStream(e,t){$t(this,e,(n=>{this.i._addEmptyPacketToInputStream(n,t)}))}addBoolVectorToStream(e,t,n){$t(this,t,(i=>{const a=this.i._allocateBoolVector(e.length);if(!a)throw Error("Unable to allocate new bool vector on heap.");for(const o of e)this.i._addBoolVectorEntry(a,o);this.i._addBoolVectorToInputStream(a,i,n)}))}addDoubleVectorToStream(e,t,n){$t(this,t,(i=>{const a=this.i._allocateDoubleVector(e.length);if(!a)throw Error("Unable to allocate new double vector on heap.");for(const o of e)this.i._addDoubleVectorEntry(a,o);this.i._addDoubleVectorToInputStream(a,i,n)}))}addFloatVectorToStream(e,t,n){$t(this,t,(i=>{const a=this.i._allocateFloatVector(e.length);if(!a)throw Error("Unable to allocate new float vector on heap.");for(const o of e)this.i._addFloatVectorEntry(a,o);this.i._addFloatVectorToInputStream(a,i,n)}))}addIntVectorToStream(e,t,n){$t(this,t,(i=>{const a=this.i._allocateIntVector(e.length);if(!a)throw Error("Unable to allocate new int vector on heap.");for(const o of e)this.i._addIntVectorEntry(a,o);this.i._addIntVectorToInputStream(a,i,n)}))}addUintVectorToStream(e,t,n){$t(this,t,(i=>{const a=this.i._allocateUintVector(e.length);if(!a)throw Error("Unable to allocate new unsigned int vector on heap.");for(const o of e)this.i._addUintVectorEntry(a,o);this.i._addUintVectorToInputStream(a,i,n)}))}addStringVectorToStream(e,t,n){$t(this,t,(i=>{const a=this.i._allocateStringVector(e.length);if(!a)throw Error("Unable to allocate new string vector on heap.");for(const o of e)$t(this,o,(l=>{this.i._addStringVectorEntry(a,l)}));this.i._addStringVectorToInputStream(a,i,n)}))}addBoolToInputSidePacket(e,t){$t(this,t,(n=>{this.i._addBoolToInputSidePacket(e,n)}))}addDoubleToInputSidePacket(e,t){$t(this,t,(n=>{this.i._addDoubleToInputSidePacket(e,n)}))}addFloatToInputSidePacket(e,t){$t(this,t,(n=>{this.i._addFloatToInputSidePacket(e,n)}))}addIntToInputSidePacket(e,t){$t(this,t,(n=>{this.i._addIntToInputSidePacket(e,n)}))}addUintToInputSidePacket(e,t){$t(this,t,(n=>{this.i._addUintToInputSidePacket(e,n)}))}addStringToInputSidePacket(e,t){$t(this,t,(n=>{$t(this,e,(i=>{this.i._addStringToInputSidePacket(i,n)}))}))}addProtoToInputSidePacket(e,t,n){$t(this,n,(i=>{$t(this,t,(a=>{const o=this.i._malloc(e.length);this.i.HEAPU8.set(e,o),this.i._addProtoToInputSidePacket(o,e.length,a,i),this.i._free(o)}))}))}addBoolVectorToInputSidePacket(e,t){$t(this,t,(n=>{const i=this.i._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(const a of e)this.i._addBoolVectorEntry(i,a);this.i._addBoolVectorToInputSidePacket(i,n)}))}addDoubleVectorToInputSidePacket(e,t){$t(this,t,(n=>{const i=this.i._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(const a of e)this.i._addDoubleVectorEntry(i,a);this.i._addDoubleVectorToInputSidePacket(i,n)}))}addFloatVectorToInputSidePacket(e,t){$t(this,t,(n=>{const i=this.i._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(const a of e)this.i._addFloatVectorEntry(i,a);this.i._addFloatVectorToInputSidePacket(i,n)}))}addIntVectorToInputSidePacket(e,t){$t(this,t,(n=>{const i=this.i._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(const a of e)this.i._addIntVectorEntry(i,a);this.i._addIntVectorToInputSidePacket(i,n)}))}addUintVectorToInputSidePacket(e,t){$t(this,t,(n=>{const i=this.i._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(const a of e)this.i._addUintVectorEntry(i,a);this.i._addUintVectorToInputSidePacket(i,n)}))}addStringVectorToInputSidePacket(e,t){$t(this,t,(n=>{const i=this.i._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(const a of e)$t(this,a,(o=>{this.i._addStringVectorEntry(i,o)}));this.i._addStringVectorToInputSidePacket(i,n)}))}attachBoolListener(e,t){ga(this,e,t),$t(this,e,(n=>{this.i._attachBoolListener(n)}))}attachBoolVectorListener(e,t){Kr(this,e,t),$t(this,e,(n=>{this.i._attachBoolVectorListener(n)}))}attachIntListener(e,t){ga(this,e,t),$t(this,e,(n=>{this.i._attachIntListener(n)}))}attachIntVectorListener(e,t){Kr(this,e,t),$t(this,e,(n=>{this.i._attachIntVectorListener(n)}))}attachUintListener(e,t){ga(this,e,t),$t(this,e,(n=>{this.i._attachUintListener(n)}))}attachUintVectorListener(e,t){Kr(this,e,t),$t(this,e,(n=>{this.i._attachUintVectorListener(n)}))}attachDoubleListener(e,t){ga(this,e,t),$t(this,e,(n=>{this.i._attachDoubleListener(n)}))}attachDoubleVectorListener(e,t){Kr(this,e,t),$t(this,e,(n=>{this.i._attachDoubleVectorListener(n)}))}attachFloatListener(e,t){ga(this,e,t),$t(this,e,(n=>{this.i._attachFloatListener(n)}))}attachFloatVectorListener(e,t){Kr(this,e,t),$t(this,e,(n=>{this.i._attachFloatVectorListener(n)}))}attachStringListener(e,t){ga(this,e,t),$t(this,e,(n=>{this.i._attachStringListener(n)}))}attachStringVectorListener(e,t){Kr(this,e,t),$t(this,e,(n=>{this.i._attachStringVectorListener(n)}))}attachProtoListener(e,t,n){ga(this,e,t),$t(this,e,(i=>{this.i._attachProtoListener(i,n||!1)}))}attachProtoVectorListener(e,t,n){Kr(this,e,t),$t(this,e,(i=>{this.i._attachProtoVectorListener(i,n||!1)}))}attachAudioListener(e,t,n){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),ga(this,e,((i,a)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,a)})),$t(this,e,(i=>{this.i._attachAudioListener(i,n||!1)}))}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends TT{get ga(){return this.i}pa(e,t,n){$t(this,t,(i=>{const[a,o]=_T(this,e,i);this.ga._addBoundTextureAsImageToStream(i,a,o,n)}))}Z(e,t){ga(this,e,t),$t(this,e,(n=>{this.ga._attachImageListener(n)}))}aa(e,t){Kr(this,e,t),$t(this,e,(n=>{this.ga._attachImageVectorListener(n)}))}}));var TT,ca=class extends wF{};async function Be(e,t,n){return(async function(i,a,o,l){return MF(i,a,o,l)})(e,n.canvas??(PR()?void 0:document.createElement("canvas")),t,n)}function GR(e,t,n,i){if(e.U){const o=new cR;if(n!=null&&n.regionOfInterest){if(!e.oa)throw Error("This task doesn't support region-of-interest.");var a=n.regionOfInterest;if(a.left>=a.right||a.top>=a.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(a.left<0||a.top<0||a.right>1||a.bottom>1)throw Error("Expected RectF values to be in [0,1].");ae(o,1,(a.left+a.right)/2),ae(o,2,(a.top+a.bottom)/2),ae(o,4,a.right-a.left),ae(o,3,a.bottom-a.top)}else ae(o,1,.5),ae(o,2,.5),ae(o,4,1),ae(o,3,1);if(n!=null&&n.rotationDegrees){if((n==null?void 0:n.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90ยฐ.");if(ae(o,5,-Math.PI*n.rotationDegrees/180),(n==null?void 0:n.rotationDegrees)%180!=0){const[l,u]=OR(t);n=In(o,3)*u/l,a=In(o,4)*l/u,ae(o,4,n),ae(o,3,a)}}e.g.addProtoToStream(o.g(),"mediapipe.NormalizedRect",e.U,i)}e.g.pa(t,e.X,i??performance.now()),e.finishProcessing()}function ua(e,t,n){var i;if((i=e.baseOptions)!=null&&i.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");GR(e,t,n,e.C+1)}function Pa(e,t,n,i){var a;if(!((a=e.baseOptions)!=null&&a.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");GR(e,t,n,i)}function Qc(e,t,n,i){var a=t.data;const o=t.width,l=o*(t=t.height);if((a instanceof Uint8Array||a instanceof Float32Array)&&a.length!==l)throw Error("Unsupported channel count: "+a.length/l);return e=new oi([a],n,!1,e.g.i.canvas,e.P,o,t),i?e.clone():e}var ys=class extends Qv{constructor(e,t,n,i){super(e),this.g=e,this.X=t,this.U=n,this.oa=i,this.P=new BR}l(e,t=!0){if("runningMode"in e&&rn(this.baseOptions,2,Kf(!!e.runningMode&&e.runningMode!=="IMAGE")),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};ys.prototype.close=ys.prototype.close;var Ns=class extends ys{constructor(e,t){super(new ca(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},ce(e=this.h=new vm,0,1,t=new Un),ae(this.h,2,.5),ae(this.h,3,.3)}get baseOptions(){return Ge(this.h,Un,1)}set baseOptions(e){ce(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&ae(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&ae(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},ua(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},Pa(this,e,n,t),this.j}m(){var e=new Ss;En(e,"image_in"),En(e,"norm_rect_in"),Xe(e,"detections");const t=new xs;Na(t,lF,this.h);const n=new ts;_s(n,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),xn(n,"IMAGE:image_in"),xn(n,"NORM_RECT:norm_rect_in"),Fe(n,"DETECTIONS:detections"),n.o(t),Gs(e,n),this.g.attachProtoVectorListener("detections",((i,a)=>{for(const o of i)i=rR(o),this.j.detections.push(NR(i));Xt(this,a)})),this.g.attachEmptyPacketListener("detections",(i=>{Xt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ns.prototype.detectForVideo=Ns.prototype.G,Ns.prototype.detect=Ns.prototype.F,Ns.prototype.setOptions=Ns.prototype.o,Ns.createFromModelPath=async function(e,t){return Be(Ns,e,{baseOptions:{modelAssetPath:t}})},Ns.createFromModelBuffer=function(e,t){return Be(Ns,e,{baseOptions:{modelAssetBuffer:t}})},Ns.createFromOptions=function(e,t){return Be(Ns,e,t)};var z_=la([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),V_=la([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),G_=la([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),HR=la([474,475],[475,476],[476,477],[477,474]),H_=la([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),j_=la([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),jR=la([469,470],[470,471],[471,472],[472,469]),W_=la([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),WR=[...z_,...V_,...G_,...H_,...j_,...W_],XR=la([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function ET(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Ln=class extends ys{constructor(e,t){super(new ca(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,ce(e=this.h=new pR,0,1,t=new Un),this.A=new dR,ce(this.h,0,3,this.A),this.u=new vm,ce(this.h,0,2,this.u),br(this.u,4,1),ae(this.u,2,.5),ae(this.A,2,.5),ae(this.h,4,.5)}get baseOptions(){return Ge(this.h,Un,1)}set baseOptions(e){ce(this.h,0,1,e)}o(e){return"numFaces"in e&&br(this.u,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&ae(this.u,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&ae(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&ae(this.A,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}F(e,t){return ET(this),ua(this,e,t),this.j}G(e,t,n){return ET(this),Pa(this,e,n,t),this.j}m(){var e=new Ss;En(e,"image_in"),En(e,"norm_rect"),Xe(e,"face_landmarks");const t=new xs;Na(t,uF,this.h);const n=new ts;_s(n,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),xn(n,"IMAGE:image_in"),xn(n,"NORM_RECT:norm_rect"),Fe(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),Gs(e,n),this.g.attachProtoVectorListener("face_landmarks",((i,a)=>{for(const o of i)i=uh(o),this.j.faceLandmarks.push(_m(i));Xt(this,a)})),this.g.attachEmptyPacketListener("face_landmarks",(i=>{Xt(this,i)})),this.outputFaceBlendshapes&&(Xe(e,"blendshapes"),Fe(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((i,a)=>{if(this.outputFaceBlendshapes)for(const o of i)i=bm(o),this.j.faceBlendshapes.push(F_(i.g()??[]));Xt(this,a)})),this.g.attachEmptyPacketListener("blendshapes",(i=>{Xt(this,i)}))),this.outputFacialTransformationMatrixes&&(Xe(e,"face_geometry"),Fe(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((i,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of i)(i=Ge(i=cF(o),tF,2))&&this.j.facialTransformationMatrixes.push({rows:Bs(i,1)??0??0,columns:Bs(i,2)??0??0,data:$o(i,3,xa,Jo()).slice()??[]});Xt(this,a)})),this.g.attachEmptyPacketListener("face_geometry",(i=>{Xt(this,i)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ln.prototype.detectForVideo=Ln.prototype.G,Ln.prototype.detect=Ln.prototype.F,Ln.prototype.setOptions=Ln.prototype.o,Ln.createFromModelPath=function(e,t){return Be(Ln,e,{baseOptions:{modelAssetPath:t}})},Ln.createFromModelBuffer=function(e,t){return Be(Ln,e,{baseOptions:{modelAssetBuffer:t}})},Ln.createFromOptions=function(e,t){return Be(Ln,e,t)},Ln.FACE_LANDMARKS_LIPS=z_,Ln.FACE_LANDMARKS_LEFT_EYE=V_,Ln.FACE_LANDMARKS_LEFT_EYEBROW=G_,Ln.FACE_LANDMARKS_LEFT_IRIS=HR,Ln.FACE_LANDMARKS_RIGHT_EYE=H_,Ln.FACE_LANDMARKS_RIGHT_EYEBROW=j_,Ln.FACE_LANDMARKS_RIGHT_IRIS=jR,Ln.FACE_LANDMARKS_FACE_OVAL=W_,Ln.FACE_LANDMARKS_CONTOURS=WR,Ln.FACE_LANDMARKS_TESSELATION=XR;var X_=la([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function wT(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function RT(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function CT(e,t=!0){const n=[];for(const a of e){var i=bm(a);e=[];for(const o of i.g())i=t&&Bs(o,1)!=null?Bs(o,1)??0:-1,e.push({score:In(o,2)??0,index:i,categoryName:vi(Mn(o,3))??""??"",displayName:vi(Mn(o,4))??""??""});n.push(e)}return n}var us=class extends ys{constructor(e,t){super(new ca(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ce(e=this.j=new bR,0,1,t=new Un),this.u=new U_,ce(this.j,0,2,this.u),this.D=new N_,ce(this.u,0,3,this.D),this.A=new gR,ce(this.u,0,2,this.A),this.h=new fF,ce(this.j,0,3,this.h),ae(this.A,2,.5),ae(this.u,4,.5),ae(this.D,2,.5)}get baseOptions(){return Ge(this.j,Un,1)}set baseOptions(e){ce(this.j,0,1,e)}o(e){var a,o,l,u;if(br(this.A,3,e.numHands??1),"minHandDetectionConfidence"in e&&ae(this.A,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&ae(this.u,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&ae(this.D,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new pc,n=t,i=Zv(e.cannedGesturesClassifierOptions,(a=Ge(this.h,pc,3))==null?void 0:a.l());ce(n,0,2,i),ce(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&((o=Ge(this.h,pc,3))==null||o.g());return e.customGesturesClassifierOptions?(ce(n=t=new pc,0,2,i=Zv(e.customGesturesClassifierOptions,(l=Ge(this.h,pc,4))==null?void 0:l.l())),ce(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&((u=Ge(this.h,pc,4))==null||u.g()),this.l(e)}Ha(e,t){return wT(this),ua(this,e,t),RT(this)}Ia(e,t,n){return wT(this),Pa(this,e,n,t),RT(this)}m(){var e=new Ss;En(e,"image_in"),En(e,"norm_rect"),Xe(e,"hand_gestures"),Xe(e,"hand_landmarks"),Xe(e,"world_hand_landmarks"),Xe(e,"handedness");const t=new xs;Na(t,hF,this.j);const n=new ts;_s(n,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),xn(n,"IMAGE:image_in"),xn(n,"NORM_RECT:norm_rect"),Fe(n,"HAND_GESTURES:hand_gestures"),Fe(n,"LANDMARKS:hand_landmarks"),Fe(n,"WORLD_LANDMARKS:world_hand_landmarks"),Fe(n,"HANDEDNESS:handedness"),n.o(t),Gs(e,n),this.g.attachProtoVectorListener("hand_landmarks",((i,a)=>{for(const o of i){i=uh(o);const l=[];for(const u of gr(i,lR,1))l.push({x:In(u,1)??0,y:In(u,2)??0,z:In(u,3)??0,visibility:In(u,4)??0});this.landmarks.push(l)}Xt(this,a)})),this.g.attachEmptyPacketListener("hand_landmarks",(i=>{Xt(this,i)})),this.g.attachProtoVectorListener("world_hand_landmarks",((i,a)=>{for(const o of i){i=Cc(o);const l=[];for(const u of gr(i,oR,1))l.push({x:In(u,1)??0,y:In(u,2)??0,z:In(u,3)??0,visibility:In(u,4)??0});this.worldLandmarks.push(l)}Xt(this,a)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(i=>{Xt(this,i)})),this.g.attachProtoVectorListener("hand_gestures",((i,a)=>{this.gestures.push(...CT(i,!1)),Xt(this,a)})),this.g.attachEmptyPacketListener("hand_gestures",(i=>{Xt(this,i)})),this.g.attachProtoVectorListener("handedness",((i,a)=>{this.handedness.push(...CT(i)),Xt(this,a)})),this.g.attachEmptyPacketListener("handedness",(i=>{Xt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function DT(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}us.prototype.recognizeForVideo=us.prototype.Ia,us.prototype.recognize=us.prototype.Ha,us.prototype.setOptions=us.prototype.o,us.createFromModelPath=function(e,t){return Be(us,e,{baseOptions:{modelAssetPath:t}})},us.createFromModelBuffer=function(e,t){return Be(us,e,{baseOptions:{modelAssetBuffer:t}})},us.createFromOptions=function(e,t){return Be(us,e,t)},us.HAND_CONNECTIONS=X_;var fs=class extends ys{constructor(e,t){super(new ca(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ce(e=this.h=new U_,0,1,t=new Un),this.u=new N_,ce(this.h,0,3,this.u),this.j=new gR,ce(this.h,0,2,this.j),br(this.j,3,1),ae(this.j,2,.5),ae(this.u,2,.5),ae(this.h,4,.5)}get baseOptions(){return Ge(this.h,Un,1)}set baseOptions(e){ce(this.h,0,1,e)}o(e){return"numHands"in e&&br(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&ae(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&ae(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&ae(this.u,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ua(this,e,t),DT(this)}G(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Pa(this,e,n,t),DT(this)}m(){var e=new Ss;En(e,"image_in"),En(e,"norm_rect"),Xe(e,"hand_landmarks"),Xe(e,"world_hand_landmarks"),Xe(e,"handedness");const t=new xs;Na(t,dF,this.h);const n=new ts;_s(n,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),xn(n,"IMAGE:image_in"),xn(n,"NORM_RECT:norm_rect"),Fe(n,"LANDMARKS:hand_landmarks"),Fe(n,"WORLD_LANDMARKS:world_hand_landmarks"),Fe(n,"HANDEDNESS:handedness"),n.o(t),Gs(e,n),this.g.attachProtoVectorListener("hand_landmarks",((i,a)=>{for(const o of i)i=uh(o),this.landmarks.push(_m(i));Xt(this,a)})),this.g.attachEmptyPacketListener("hand_landmarks",(i=>{Xt(this,i)})),this.g.attachProtoVectorListener("world_hand_landmarks",((i,a)=>{for(const o of i)i=Cc(o),this.worldLandmarks.push(Ff(i));Xt(this,a)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(i=>{Xt(this,i)})),this.g.attachProtoVectorListener("handedness",((i,a)=>{var o=this.handedness,l=o.push;const u=[];for(const h of i){i=bm(h);const d=[];for(const p of i.g())d.push({score:In(p,2)??0,index:Bs(p,1)??0??-1,categoryName:vi(Mn(p,3))??""??"",displayName:vi(Mn(p,4))??""??""});u.push(d)}l.call(o,...u),Xt(this,a)})),this.g.attachEmptyPacketListener("handedness",(i=>{Xt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};fs.prototype.detectForVideo=fs.prototype.G,fs.prototype.detect=fs.prototype.F,fs.prototype.setOptions=fs.prototype.o,fs.createFromModelPath=function(e,t){return Be(fs,e,{baseOptions:{modelAssetPath:t}})},fs.createFromModelBuffer=function(e,t){return Be(fs,e,{baseOptions:{modelAssetBuffer:t}})},fs.createFromOptions=function(e,t){return Be(fs,e,t)},fs.HAND_CONNECTIONS=X_;var qR=la([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function LT(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function NT(e){try{if(!e.D)return e.h;e.D(e.h)}finally{xm(e)}}function ip(e,t){e=uh(e),t.push(_m(e))}var _n=class extends ys{constructor(e,t){super(new ca(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,ce(e=this.j=new SR,0,1,t=new Un),this.I=new N_,ce(this.j,0,2,this.I),this.W=new pF,ce(this.j,0,3,this.W),this.u=new vm,ce(this.j,0,4,this.u),this.O=new dR,ce(this.j,0,5,this.O),this.A=new yR,ce(this.j,0,6,this.A),this.M=new xR,ce(this.j,0,7,this.M),ae(this.u,2,.5),ae(this.u,3,.3),ae(this.O,2,.5),ae(this.A,2,.5),ae(this.A,3,.3),ae(this.M,2,.5),ae(this.I,2,.5)}get baseOptions(){return Ge(this.j,Un,1)}set baseOptions(e){ce(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&ae(this.u,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&ae(this.u,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&ae(this.O,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&ae(this.A,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&ae(this.A,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&ae(this.M,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&ae(this.I,2,e.minHandLandmarksConfidence??.5),this.l(e)}F(e,t,n){const i=typeof t!="function"?t:{};return this.D=typeof t=="function"?t:n,LT(this),ua(this,e,i),NT(this)}G(e,t,n,i){const a=typeof n!="function"?n:{};return this.D=typeof n=="function"?n:i,LT(this),Pa(this,e,a,t),NT(this)}m(){var e=new Ss;En(e,"input_frames_image"),Xe(e,"pose_landmarks"),Xe(e,"pose_world_landmarks"),Xe(e,"face_landmarks"),Xe(e,"left_hand_landmarks"),Xe(e,"left_hand_world_landmarks"),Xe(e,"right_hand_landmarks"),Xe(e,"right_hand_world_landmarks");const t=new xs,n=new nT;_s(n,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),(function(a,o){if(o!=null)if(Array.isArray(o))rn(a,2,am(o,0,Zf));else{if(!(typeof o=="string"||o instanceof Ma||J1(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Jr(a,2,t_(o,!1),hl())}})(n,this.j.g());const i=new ts;_s(i,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),p_(i,8,nT,n),xn(i,"IMAGE:input_frames_image"),Fe(i,"POSE_LANDMARKS:pose_landmarks"),Fe(i,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),Fe(i,"FACE_LANDMARKS:face_landmarks"),Fe(i,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),Fe(i,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),Fe(i,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),Fe(i,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),i.o(t),Gs(e,i),ym(this,e),this.g.attachProtoListener("pose_landmarks",((a,o)=>{ip(a,this.h.poseLandmarks),Xt(this,o)})),this.g.attachEmptyPacketListener("pose_landmarks",(a=>{Xt(this,a)})),this.g.attachProtoListener("pose_world_landmarks",((a,o)=>{var l=this.h.poseWorldLandmarks;a=Cc(a),l.push(Ff(a)),Xt(this,o)})),this.g.attachEmptyPacketListener("pose_world_landmarks",(a=>{Xt(this,a)})),this.outputPoseSegmentationMasks&&(Fe(i,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Kc(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",((a,o)=>{this.h.poseSegmentationMasks=[Qc(this,a,!0,!this.D)],Xt(this,o)})),this.g.attachEmptyPacketListener("pose_segmentation_mask",(a=>{this.h.poseSegmentationMasks=[],Xt(this,a)}))),this.g.attachProtoListener("face_landmarks",((a,o)=>{ip(a,this.h.faceLandmarks),Xt(this,o)})),this.g.attachEmptyPacketListener("face_landmarks",(a=>{Xt(this,a)})),this.outputFaceBlendshapes&&(Xe(e,"extra_blendshapes"),Fe(i,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",((a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=bm(a),l.push(F_(a.g()??[]))),Xt(this,o)})),this.g.attachEmptyPacketListener("extra_blendshapes",(a=>{Xt(this,a)}))),this.g.attachProtoListener("left_hand_landmarks",((a,o)=>{ip(a,this.h.leftHandLandmarks),Xt(this,o)})),this.g.attachEmptyPacketListener("left_hand_landmarks",(a=>{Xt(this,a)})),this.g.attachProtoListener("left_hand_world_landmarks",((a,o)=>{var l=this.h.leftHandWorldLandmarks;a=Cc(a),l.push(Ff(a)),Xt(this,o)})),this.g.attachEmptyPacketListener("left_hand_world_landmarks",(a=>{Xt(this,a)})),this.g.attachProtoListener("right_hand_landmarks",((a,o)=>{ip(a,this.h.rightHandLandmarks),Xt(this,o)})),this.g.attachEmptyPacketListener("right_hand_landmarks",(a=>{Xt(this,a)})),this.g.attachProtoListener("right_hand_world_landmarks",((a,o)=>{var l=this.h.rightHandWorldLandmarks;a=Cc(a),l.push(Ff(a)),Xt(this,o)})),this.g.attachEmptyPacketListener("right_hand_world_landmarks",(a=>{Xt(this,a)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};_n.prototype.detectForVideo=_n.prototype.G,_n.prototype.detect=_n.prototype.F,_n.prototype.setOptions=_n.prototype.o,_n.createFromModelPath=function(e,t){return Be(_n,e,{baseOptions:{modelAssetPath:t}})},_n.createFromModelBuffer=function(e,t){return Be(_n,e,{baseOptions:{modelAssetBuffer:t}})},_n.createFromOptions=function(e,t){return Be(_n,e,t)},_n.HAND_CONNECTIONS=X_,_n.POSE_CONNECTIONS=qR,_n.FACE_LANDMARKS_LIPS=z_,_n.FACE_LANDMARKS_LEFT_EYE=V_,_n.FACE_LANDMARKS_LEFT_EYEBROW=G_,_n.FACE_LANDMARKS_LEFT_IRIS=HR,_n.FACE_LANDMARKS_RIGHT_EYE=H_,_n.FACE_LANDMARKS_RIGHT_EYEBROW=j_,_n.FACE_LANDMARKS_RIGHT_IRIS=jR,_n.FACE_LANDMARKS_FACE_OVAL=W_,_n.FACE_LANDMARKS_CONTOURS=WR,_n.FACE_LANDMARKS_TESSELATION=XR;var Us=class extends ys{constructor(e,t){super(new ca(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},ce(e=this.h=new MR,0,1,t=new Un)}get baseOptions(){return Ge(this.h,Un,1)}set baseOptions(e){ce(this.h,0,1,e)}o(e){return ce(this.h,0,2,Zv(e,Ge(this.h,D_,2))),this.l(e)}sa(e,t){return this.j={classifications:[]},ua(this,e,t),this.j}ta(e,t,n){return this.j={classifications:[]},Pa(this,e,n,t),this.j}m(){var e=new Ss;En(e,"input_image"),En(e,"norm_rect"),Xe(e,"classifications");const t=new xs;Na(t,mF,this.h);const n=new ts;_s(n,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),xn(n,"IMAGE:input_image"),xn(n,"NORM_RECT:norm_rect"),Fe(n,"CLASSIFICATIONS:classifications"),n.o(t),Gs(e,n),this.g.attachProtoListener("classifications",((i,a)=>{this.j=xF(iF(i)),Xt(this,a)})),this.g.attachEmptyPacketListener("classifications",(i=>{Xt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Us.prototype.classifyForVideo=Us.prototype.ta,Us.prototype.classify=Us.prototype.sa,Us.prototype.setOptions=Us.prototype.o,Us.createFromModelPath=function(e,t){return Be(Us,e,{baseOptions:{modelAssetPath:t}})},Us.createFromModelBuffer=function(e,t){return Be(Us,e,{baseOptions:{modelAssetBuffer:t}})},Us.createFromOptions=function(e,t){return Be(Us,e,t)};var hs=class extends ys{constructor(e,t){super(new ca(e,t),"image_in","norm_rect",!0),this.h=new AR,this.embeddings={embeddings:[]},ce(e=this.h,0,1,t=new Un)}get baseOptions(){return Ge(this.h,Un,1)}set baseOptions(e){ce(this.h,0,1,e)}o(e){var t=this.h,n=Ge(this.h,fT,2);return n=n?n.clone():new fT,e.l2Normalize!==void 0?rn(n,1,Kf(e.l2Normalize)):"l2Normalize"in e&&rn(n,1),e.quantize!==void 0?rn(n,2,Kf(e.quantize)):"quantize"in e&&rn(n,2),ce(t,0,2,n),this.l(e)}za(e,t){return ua(this,e,t),this.embeddings}Aa(e,t,n){return Pa(this,e,n,t),this.embeddings}m(){var e=new Ss;En(e,"image_in"),En(e,"norm_rect"),Xe(e,"embeddings_out");const t=new xs;Na(t,gF,this.h);const n=new ts;_s(n,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),xn(n,"IMAGE:image_in"),xn(n,"NORM_RECT:norm_rect"),Fe(n,"EMBEDDINGS:embeddings_out"),n.o(t),Gs(e,n),this.g.attachProtoListener("embeddings_out",((i,a)=>{i=rF(i),this.embeddings=(function(o){return{embeddings:gr(o,aF,1).map((l=>{var d,p;const u={headIndex:Bs(l,3)??0??-1,headName:vi(Mn(l,4))??""??""};var h=l.v;return xw(h,0|h[Qt],uT,Ab(l,1))!==void 0?(l=$o(l=Ge(l,uT,Ab(l,1),void 0),1,xa,Jo()),u.floatEmbedding=l.slice()):(h=new Uint8Array(0),u.quantizedEmbedding=((p=(d=Ge(l,sF,Ab(l,2),void 0))==null?void 0:d.na())==null?void 0:p.h())??h),u})),timestampMs:LR(Mn(o,2,void 0,void 0,Np)??gw)}})(i),Xt(this,a)})),this.g.attachEmptyPacketListener("embeddings_out",(i=>{Xt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};hs.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=bT(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=bT(gT(e.quantizedEmbedding),gT(t.quantizedEmbedding))}return e},hs.prototype.embedForVideo=hs.prototype.Aa,hs.prototype.embed=hs.prototype.za,hs.prototype.setOptions=hs.prototype.o,hs.createFromModelPath=function(e,t){return Be(hs,e,{baseOptions:{modelAssetPath:t}})},hs.createFromModelBuffer=function(e,t){return Be(hs,e,{baseOptions:{modelAssetBuffer:t}})},hs.createFromOptions=function(e,t){return Be(hs,e,t)};var t1=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach((n=>{n.close()})),(t=this.categoryMask)==null||t.close()}};function RF(e){var n,i;const t=(function(a){return gr(a,ts,1)})(e.ca()).filter((a=>(vi(Mn(a,1))??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator")));if(e.u=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(((i=(n=Ge(t[0],xs,7))==null?void 0:n.j())==null?void 0:i.g())??new Map).forEach(((a,o)=>{e.u[Number(o)]=vi(Mn(a,1))??""}))}function UT(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function PT(e){try{const t=new t1(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{xm(e)}}t1.prototype.close=t1.prototype.close;var qi=class extends ys{constructor(e,t){super(new ca(e,t),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new I_,this.A=new TR,ce(this.h,0,3,this.A),ce(e=this.h,0,1,t=new Un)}get baseOptions(){return Ge(this.h,Un,1)}set baseOptions(e){ce(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?rn(this.h,2,oh(e.displayNamesLocale)):"displayNamesLocale"in e&&rn(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}L(){RF(this)}segment(e,t,n){const i=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:n,UT(this),ua(this,e,i),PT(this)}La(e,t,n,i){const a=typeof n!="function"?n:{};return this.j=typeof n=="function"?n:i,UT(this),Pa(this,e,a,t),PT(this)}Da(){return this.u}m(){var e=new Ss;En(e,"image_in"),En(e,"norm_rect");const t=new xs;Na(t,wR,this.h);const n=new ts;_s(n,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),xn(n,"IMAGE:image_in"),xn(n,"NORM_RECT:norm_rect"),n.o(t),Gs(e,n),ym(this,e),this.outputConfidenceMasks&&(Xe(e,"confidence_masks"),Fe(n,"CONFIDENCE_MASKS:confidence_masks"),Kc(this,"confidence_masks"),this.g.aa("confidence_masks",((i,a)=>{this.confidenceMasks=i.map((o=>Qc(this,o,!0,!this.j))),Xt(this,a)})),this.g.attachEmptyPacketListener("confidence_masks",(i=>{this.confidenceMasks=[],Xt(this,i)}))),this.outputCategoryMask&&(Xe(e,"category_mask"),Fe(n,"CATEGORY_MASK:category_mask"),Kc(this,"category_mask"),this.g.Z("category_mask",((i,a)=>{this.categoryMask=Qc(this,i,!1,!this.j),Xt(this,a)})),this.g.attachEmptyPacketListener("category_mask",(i=>{this.categoryMask=void 0,Xt(this,i)}))),Xe(e,"quality_scores"),Fe(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((i,a)=>{this.qualityScores=i,Xt(this,a)})),this.g.attachEmptyPacketListener("quality_scores",(i=>{this.categoryMask=void 0,Xt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};qi.prototype.getLabels=qi.prototype.Da,qi.prototype.segmentForVideo=qi.prototype.La,qi.prototype.segment=qi.prototype.segment,qi.prototype.setOptions=qi.prototype.o,qi.createFromModelPath=function(e,t){return Be(qi,e,{baseOptions:{modelAssetPath:t}})},qi.createFromModelBuffer=function(e,t){return Be(qi,e,{baseOptions:{modelAssetBuffer:t}})},qi.createFromOptions=function(e,t){return Be(qi,e,t)};var e1=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach((n=>{n.close()})),(t=this.categoryMask)==null||t.close()}};e1.prototype.close=e1.prototype.close;var ba=class extends ys{constructor(e,t){super(new ca(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new I_,this.u=new TR,ce(this.h,0,3,this.u),ce(e=this.h,0,1,t=new Un)}get baseOptions(){return Ge(this.h,Un,1)}set baseOptions(e){ce(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,n,i){const a=typeof n!="function"?n:{};if(this.j=typeof n=="function"?n:i,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.C+1,i=new RR,t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var o=new Rb;Jr(o,3,Kf(!0),!1),Jr(o,1,Cf(t.keypoint.x),0),Jr(o,2,Cf(t.keypoint.y),0),Of(i,1,Kv,o)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");{const u=new vF;for(o of t.scribble)Jr(t=new Rb,3,Kf(!0),!1),Jr(t,1,Cf(o.x),0),Jr(t,2,Cf(o.y),0),p_(u,1,Rb,t);Of(i,2,Kv,u)}}this.g.addProtoToStream(i.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",n),ua(this,e,a);t:{try{const u=new e1(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=u;break t}this.j(u)}finally{xm(this)}l=void 0}return l}m(){var e=new Ss;En(e,"image_in"),En(e,"roi_in"),En(e,"norm_rect_in");const t=new xs;Na(t,wR,this.h);const n=new ts;_s(n,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),xn(n,"IMAGE:image_in"),xn(n,"ROI:roi_in"),xn(n,"NORM_RECT:norm_rect_in"),n.o(t),Gs(e,n),ym(this,e),this.outputConfidenceMasks&&(Xe(e,"confidence_masks"),Fe(n,"CONFIDENCE_MASKS:confidence_masks"),Kc(this,"confidence_masks"),this.g.aa("confidence_masks",((i,a)=>{this.confidenceMasks=i.map((o=>Qc(this,o,!0,!this.j))),Xt(this,a)})),this.g.attachEmptyPacketListener("confidence_masks",(i=>{this.confidenceMasks=[],Xt(this,i)}))),this.outputCategoryMask&&(Xe(e,"category_mask"),Fe(n,"CATEGORY_MASK:category_mask"),Kc(this,"category_mask"),this.g.Z("category_mask",((i,a)=>{this.categoryMask=Qc(this,i,!1,!this.j),Xt(this,a)})),this.g.attachEmptyPacketListener("category_mask",(i=>{this.categoryMask=void 0,Xt(this,i)}))),Xe(e,"quality_scores"),Fe(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((i,a)=>{this.qualityScores=i,Xt(this,a)})),this.g.attachEmptyPacketListener("quality_scores",(i=>{this.categoryMask=void 0,Xt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ba.prototype.segment=ba.prototype.segment,ba.prototype.setOptions=ba.prototype.o,ba.createFromModelPath=function(e,t){return Be(ba,e,{baseOptions:{modelAssetPath:t}})},ba.createFromModelBuffer=function(e,t){return Be(ba,e,{baseOptions:{modelAssetBuffer:t}})},ba.createFromOptions=function(e,t){return Be(ba,e,t)};var Ps=class extends ys{constructor(e,t){super(new ca(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},ce(e=this.h=new CR,0,1,t=new Un)}get baseOptions(){return Ge(this.h,Un,1)}set baseOptions(e){ce(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?rn(this.h,2,oh(e.displayNamesLocale)):"displayNamesLocale"in e&&rn(this.h,2),e.maxResults!==void 0?br(this.h,3,e.maxResults):"maxResults"in e&&rn(this.h,3),e.scoreThreshold!==void 0?ae(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&rn(this.h,4),e.categoryAllowlist!==void 0?Pp(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&rn(this.h,5),e.categoryDenylist!==void 0?Pp(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&rn(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},ua(this,e,t),this.j}G(e,t,n){return this.j={detections:[]},Pa(this,e,n,t),this.j}m(){var e=new Ss;En(e,"input_frame_gpu"),En(e,"norm_rect"),Xe(e,"detections");const t=new xs;Na(t,_F,this.h);const n=new ts;_s(n,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),xn(n,"IMAGE:input_frame_gpu"),xn(n,"NORM_RECT:norm_rect"),Fe(n,"DETECTIONS:detections"),n.o(t),Gs(e,n),this.g.attachProtoVectorListener("detections",((i,a)=>{for(const o of i)i=rR(o),this.j.detections.push(NR(i));Xt(this,a)})),this.g.attachEmptyPacketListener("detections",(i=>{Xt(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ps.prototype.detectForVideo=Ps.prototype.G,Ps.prototype.detect=Ps.prototype.F,Ps.prototype.setOptions=Ps.prototype.o,Ps.createFromModelPath=async function(e,t){return Be(Ps,e,{baseOptions:{modelAssetPath:t}})},Ps.createFromModelBuffer=function(e,t){return Be(Ps,e,{baseOptions:{modelAssetBuffer:t}})},Ps.createFromOptions=function(e,t){return Be(Ps,e,t)};var n1=class{constructor(e,t,n){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=n}close(){var e;(e=this.segmentationMasks)==null||e.forEach((t=>{t.close()}))}};function OT(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function IT(e){try{const t=new n1(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.u)return t;e.u(t)}finally{xm(e)}}n1.prototype.close=n1.prototype.close;var Yi=class extends ys{constructor(e,t){super(new ca(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,ce(e=this.h=new DR,0,1,t=new Un),this.A=new xR,ce(this.h,0,3,this.A),this.j=new yR,ce(this.h,0,2,this.j),br(this.j,4,1),ae(this.j,2,.5),ae(this.A,2,.5),ae(this.h,4,.5)}get baseOptions(){return Ge(this.h,Un,1)}set baseOptions(e){ce(this.h,0,1,e)}o(e){return"numPoses"in e&&br(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&ae(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&ae(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&ae(this.A,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}F(e,t,n){const i=typeof t!="function"?t:{};return this.u=typeof t=="function"?t:n,OT(this),ua(this,e,i),IT(this)}G(e,t,n,i){const a=typeof n!="function"?n:{};return this.u=typeof n=="function"?n:i,OT(this),Pa(this,e,a,t),IT(this)}m(){var e=new Ss;En(e,"image_in"),En(e,"norm_rect"),Xe(e,"normalized_landmarks"),Xe(e,"world_landmarks"),Xe(e,"segmentation_masks");const t=new xs;Na(t,yF,this.h);const n=new ts;_s(n,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),xn(n,"IMAGE:image_in"),xn(n,"NORM_RECT:norm_rect"),Fe(n,"NORM_LANDMARKS:normalized_landmarks"),Fe(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),Gs(e,n),ym(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((i,a)=>{this.landmarks=[];for(const o of i)i=uh(o),this.landmarks.push(_m(i));Xt(this,a)})),this.g.attachEmptyPacketListener("normalized_landmarks",(i=>{this.landmarks=[],Xt(this,i)})),this.g.attachProtoVectorListener("world_landmarks",((i,a)=>{this.worldLandmarks=[];for(const o of i)i=Cc(o),this.worldLandmarks.push(Ff(i));Xt(this,a)})),this.g.attachEmptyPacketListener("world_landmarks",(i=>{this.worldLandmarks=[],Xt(this,i)})),this.outputSegmentationMasks&&(Fe(n,"SEGMENTATION_MASK:segmentation_masks"),Kc(this,"segmentation_masks"),this.g.aa("segmentation_masks",((i,a)=>{this.segmentationMasks=i.map((o=>Qc(this,o,!0,!this.u))),Xt(this,a)})),this.g.attachEmptyPacketListener("segmentation_masks",(i=>{this.segmentationMasks=[],Xt(this,i)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Yi.prototype.detectForVideo=Yi.prototype.G,Yi.prototype.detect=Yi.prototype.F,Yi.prototype.setOptions=Yi.prototype.o,Yi.createFromModelPath=function(e,t){return Be(Yi,e,{baseOptions:{modelAssetPath:t}})},Yi.createFromModelBuffer=function(e,t){return Be(Yi,e,{baseOptions:{modelAssetBuffer:t}})},Yi.createFromOptions=function(e,t){return Be(Yi,e,t)},Yi.POSE_CONNECTIONS=qR;const q_=pt.createContext({});function Y_(e){const t=pt.useRef(null);return t.current===null&&(t.current=e()),t.current}const CF=typeof window<"u",YR=CF?pt.useLayoutEffect:pt.useEffect,Sm=pt.createContext(null);function K_(e,t){e.indexOf(t)===-1&&e.push(t)}function kp(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const wa=(e,t,n)=>n>t?t:n{};const uo={},KR=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function ZR(e){return typeof e=="object"&&e!==null}const QR=e=>/^0[^.\s]+$/u.test(e);function JR(e){let t;return()=>(t===void 0&&(t=e()),t)}const zs=e=>e,DF=(e,t)=>n=>t(e(n)),fh=(...e)=>e.reduce(DF),Qf=(e,t,n)=>{const i=t-e;return i===0?1:(n-e)/i};class Q_{constructor(){this.subscriptions=[]}add(t){return K_(this.subscriptions,t),()=>kp(this.subscriptions,t)}notify(t,n,i){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](t,n,i);else for(let o=0;oe*1e3,ks=e=>e/1e3;function $R(e,t){return t?e*(1e3/t):0}const t4=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,LF=1e-7,NF=12;function UF(e,t,n,i,a){let o,l,u=0;do l=t+(n-t)/2,o=t4(l,i,a)-e,o>0?n=l:t=l;while(Math.abs(o)>LF&&++uUF(o,0,1,e,n);return o=>o===0||o===1?o:t4(a(o),t,i)}const e4=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,n4=e=>t=>1-e(1-t),i4=hh(.33,1.53,.69,.99),J_=n4(i4),s4=e4(J_),a4=e=>e>=1?1:(e*=2)<1?.5*J_(e):.5*(2-Math.pow(2,-10*(e-1))),$_=e=>1-Math.sin(Math.acos(e)),r4=n4($_),o4=e4($_),PF=hh(.42,0,1,1),OF=hh(0,0,.58,1),l4=hh(.42,0,.58,1),IF=e=>Array.isArray(e)&&typeof e[0]!="number",c4=e=>Array.isArray(e)&&typeof e[0]=="number",FF={linear:zs,easeIn:PF,easeInOut:l4,easeOut:OF,circIn:$_,circInOut:o4,circOut:r4,backIn:J_,backInOut:s4,backOut:i4,anticipate:a4},BF=e=>typeof e=="string",FT=e=>{if(c4(e)){Z_(e.length===4);const[t,n,i,a]=e;return hh(t,n,i,a)}else if(BF(e))return FF[e];return e},sp=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function kF(e,t){let n=new Set,i=new Set,a=!1,o=!1;const l=new WeakSet;let u={delta:0,timestamp:0,isProcessing:!1};function h(p){l.has(p)&&(d.schedule(p),e()),p(u)}const d={schedule:(p,m=!1,b=!1)=>{const S=b&&a?n:i;return m&&l.add(p),S.add(p),p},cancel:p=>{i.delete(p),l.delete(p)},process:p=>{if(u=p,a){o=!0;return}a=!0;const m=n;n=i,i=m,n.forEach(h),n.clear(),a=!1,o&&(o=!1,d.process(p))}};return d}const zF=40;function u4(e,t){let n=!1,i=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,l=sp.reduce((w,T)=>(w[T]=kF(o),w),{}),{setup:u,read:h,resolveKeyframes:d,preUpdate:p,update:m,preRender:b,render:_,postRender:S}=l,A=()=>{const w=uo.useManualTiming,T=w?a.timestamp:performance.now();n=!1,w||(a.delta=i?1e3/60:Math.max(Math.min(T-a.timestamp,zF),1)),a.timestamp=T,a.isProcessing=!0,u.process(a),h.process(a),d.process(a),p.process(a),m.process(a),b.process(a),_.process(a),S.process(a),a.isProcessing=!1,n&&t&&(i=!1,e(A))},x=()=>{n=!0,i=!0,a.isProcessing||e(A)};return{schedule:sp.reduce((w,T)=>{const P=l[T];return w[T]=(O,U=!1,I=!1)=>(n||x(),P.schedule(O,U,I)),w},{}),cancel:w=>{for(let T=0;T(vp===void 0&&Pi.set(gi.isProcessing||uo.useManualTiming?gi.timestamp:performance.now()),vp),set:e=>{vp=e,queueMicrotask(VF)}},f4=e=>t=>typeof t=="string"&&t.startsWith(e),h4=f4("--"),GF=f4("var(--"),ty=e=>GF(e)?HF.test(e.split("/*")[0].trim()):!1,HF=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function BT(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const gu={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Jf={...gu,transform:e=>wa(0,1,e)},ap={...gu,default:1},Bf=e=>Math.round(e*1e5)/1e5,ey=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function jF(e){return e==null}const WF=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ny=(e,t)=>n=>!!(typeof n=="string"&&WF.test(n)&&n.startsWith(e)||t&&!jF(n)&&Object.prototype.hasOwnProperty.call(n,t)),d4=(e,t,n)=>i=>{if(typeof i!="string")return i;const[a,o,l,u]=i.match(ey);return{[e]:parseFloat(a),[t]:parseFloat(o),[n]:parseFloat(l),alpha:u!==void 0?parseFloat(u):1}},XF=e=>wa(0,255,e),Lb={...gu,transform:e=>Math.round(XF(e))},tl={test:ny("rgb","red"),parse:d4("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+Lb.transform(e)+", "+Lb.transform(t)+", "+Lb.transform(n)+", "+Bf(Jf.transform(i))+")"};function qF(e){let t="",n="",i="",a="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),i=e.substring(5,7),a=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),i=e.substring(3,4),a=e.substring(4,5),t+=t,n+=n,i+=i,a+=a),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:a?parseInt(a,16)/255:1}}const i1={test:ny("#"),parse:qF,transform:tl.transform},dh=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Zr=dh("deg"),Aa=dh("%"),Wt=dh("px"),YF=dh("vh"),KF=dh("vw"),kT={...Aa,parse:e=>Aa.parse(e)/100,transform:e=>Aa.transform(e*100)},xc={test:ny("hsl","hue"),parse:d4("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+Aa.transform(Bf(t))+", "+Aa.transform(Bf(n))+", "+Bf(Jf.transform(i))+")"},Gn={test:e=>tl.test(e)||i1.test(e)||xc.test(e),parse:e=>tl.test(e)?tl.parse(e):xc.test(e)?xc.parse(e):i1.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?tl.transform(e):xc.transform(e),getAnimatableNone:e=>{const t=Gn.parse(e);return t.alpha=0,Gn.transform(t)}},ZF=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function QF(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(ey))==null?void 0:t.length)||0)+(((n=e.match(ZF))==null?void 0:n.length)||0)>0}const p4="number",m4="color",JF="var",$F="var(",zT="${}",tB=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Jc(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},a=[];let o=0;const u=t.replace(tB,h=>(Gn.test(h)?(i.color.push(o),a.push(m4),n.push(Gn.parse(h))):h.startsWith($F)?(i.var.push(o),a.push(JF),n.push(h)):(i.number.push(o),a.push(p4),n.push(parseFloat(h))),++o,zT)).split(zT);return{values:n,split:u,indexes:i,types:a}}function eB(e){return Jc(e).values}function g4({split:e,types:t}){const n=e.length;return i=>{let a="";for(let o=0;otypeof e=="number"?0:Gn.test(e)?Gn.getAnimatableNone(e):e,sB=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:iB(e);function aB(e){const t=Jc(e);return g4(t)(t.values.map((i,a)=>sB(i,t.split[a])))}const ra={test:QF,parse:eB,createTransformer:nB,getAnimatableNone:aB};function Nb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function rB({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let a=0,o=0,l=0;if(!t)a=o=l=n;else{const u=n<.5?n*(1+t):n+t-n*t,h=2*n-u;a=Nb(h,u,e+1/3),o=Nb(h,u,e),l=Nb(h,u,e-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:i}}function zp(e,t){return n=>n>0?t:e}const gn=(e,t,n)=>e+(t-e)*n,Ub=(e,t,n)=>{const i=e*e,a=n*(t*t-i)+i;return a<0?0:Math.sqrt(a)},oB=[i1,tl,xc],lB=e=>oB.find(t=>t.test(e));function VT(e){const t=lB(e);if(!t)return!1;let n=t.parse(e);return t===xc&&(n=rB(n)),n}const GT=(e,t)=>{const n=VT(e),i=VT(t);if(!n||!i)return zp(e,t);const a={...n};return o=>(a.red=Ub(n.red,i.red,o),a.green=Ub(n.green,i.green,o),a.blue=Ub(n.blue,i.blue,o),a.alpha=gn(n.alpha,i.alpha,o),tl.transform(a))},s1=new Set(["none","hidden"]);function cB(e,t){return s1.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function uB(e,t){return n=>gn(e,t,n)}function iy(e){return typeof e=="number"?uB:typeof e=="string"?ty(e)?zp:Gn.test(e)?GT:dB:Array.isArray(e)?b4:typeof e=="object"?Gn.test(e)?GT:fB:zp}function b4(e,t){const n=[...e],i=n.length,a=e.map((o,l)=>iy(o)(o,t[l]));return o=>{for(let l=0;l{for(const o in i)n[o]=i[o](a);return n}}function hB(e,t){const n=[],i={color:0,var:0,number:0};for(let a=0;a{const n=ra.createTransformer(t),i=Jc(e),a=Jc(t);return i.indexes.var.length===a.indexes.var.length&&i.indexes.color.length===a.indexes.color.length&&i.indexes.number.length>=a.indexes.number.length?s1.has(e)&&!a.values.length||s1.has(t)&&!i.values.length?cB(e,t):fh(b4(hB(i,a),a.values),n):zp(e,t)};function v4(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?gn(e,t,n):iy(e)(e,t)}const pB=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>fn.update(t,n),stop:()=>fo(t),now:()=>gi.isProcessing?gi.timestamp:Pi.now()}},_4=(e,t,n=10)=>{let i="";const a=Math.max(Math.round(t/n),2);for(let o=0;o=Vp?1/0:t}function mB(e,t=100,n){const i=n({...e,keyframes:[0,t]}),a=Math.min(sy(i),Vp);return{type:"keyframes",ease:o=>i.next(a*o).value/t,duration:ks(a)}}const Nn={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function a1(e,t){return e*Math.sqrt(1-t*t)}const gB=12;function bB(e,t,n){let i=n;for(let a=1;a{const p=d*l,m=p*e,b=p-n,_=a1(d,l),S=Math.exp(-m);return Pb-b/_*S},o=d=>{const m=d*l*e,b=m*n+n,_=Math.pow(l,2)*Math.pow(d,2)*e,S=Math.exp(-m),A=a1(Math.pow(d,2),l);return(-a(d)+Pb>0?-1:1)*((b-_)*S)/A}):(a=d=>{const p=Math.exp(-d*e),m=(d-n)*e+1;return-Pb+p*m},o=d=>{const p=Math.exp(-d*e),m=(n-d)*(e*e);return p*m});const u=5/e,h=bB(a,o,u);if(e=bs(e),isNaN(h))return{stiffness:Nn.stiffness,damping:Nn.damping,duration:e};{const d=Math.pow(h,2)*i;return{stiffness:d,damping:l*2*Math.sqrt(i*d),duration:e}}}const _B=["duration","bounce"],yB=["stiffness","damping","mass"];function HT(e,t){return t.some(n=>e[n]!==void 0)}function xB(e){let t={velocity:Nn.velocity,stiffness:Nn.stiffness,damping:Nn.damping,mass:Nn.mass,isResolvedFromDuration:!1,...e};if(!HT(e,yB)&&HT(e,_B))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),a=i*i,o=2*wa(.05,1,1-(e.bounce||0))*Math.sqrt(a);t={...t,mass:Nn.mass,stiffness:a,damping:o}}else{const n=vB({...e,velocity:0});t={...t,...n,mass:Nn.mass},t.isResolvedFromDuration=!0}return t}function Gp(e=Nn.visualDuration,t=Nn.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:a}=n;const o=n.keyframes[0],l=n.keyframes[n.keyframes.length-1],u={done:!1,value:o},{stiffness:h,damping:d,mass:p,duration:m,velocity:b,isResolvedFromDuration:_}=xB({...n,velocity:-ks(n.velocity||0)}),S=b||0,A=d/(2*Math.sqrt(h*p)),x=l-o,y=ks(Math.sqrt(h/p)),E=Math.abs(x)<5;i||(i=E?Nn.restSpeed.granular:Nn.restSpeed.default),a||(a=E?Nn.restDelta.granular:Nn.restDelta.default);let w,T,P,O,U,I;if(A<1)P=a1(y,A),O=(S+A*y*x)/P,w=R=>{const F=Math.exp(-A*y*R);return l-F*(O*Math.sin(P*R)+x*Math.cos(P*R))},U=A*y*O+x*P,I=A*y*x-O*P,T=R=>Math.exp(-A*y*R)*(U*Math.sin(P*R)+I*Math.cos(P*R));else if(A===1){w=F=>l-Math.exp(-y*F)*(x+(S+y*x)*F);const R=S+y*x;T=F=>Math.exp(-y*F)*(y*R*F-S)}else{const R=y*Math.sqrt(A*A-1);w=lt=>{const ut=Math.exp(-A*y*lt),k=Math.min(R*lt,300);return l-ut*((S+A*y*x)*Math.sinh(k)+R*x*Math.cosh(k))/R};const F=(S+A*y*x)/R,Y=A*y*F-x*R,$=A*y*x-F*R;T=lt=>{const ut=Math.exp(-A*y*lt),k=Math.min(R*lt,300);return ut*(Y*Math.sinh(k)+$*Math.cosh(k))}}const C={calculatedDuration:_&&m||null,velocity:R=>bs(T(R)),next:R=>{if(!_&&A<1){const Y=Math.exp(-A*y*R),$=Math.sin(P*R),lt=Math.cos(P*R),ut=l-Y*(O*$+x*lt),k=bs(Y*(U*$+I*lt));return u.done=Math.abs(k)<=i&&Math.abs(l-ut)<=a,u.value=u.done?l:ut,u}const F=w(R);if(_)u.done=R>=m;else{const Y=bs(T(R));u.done=Math.abs(Y)<=i&&Math.abs(l-F)<=a}return u.value=u.done?l:F,u},toString:()=>{const R=Math.min(sy(C),Vp),F=_4(Y=>C.next(R*Y).value,R,30);return R+"ms "+F},toTransition:()=>{}};return C}Gp.applyToOptions=e=>{const t=mB(e,100,Gp);return e.ease=t.ease,e.duration=bs(t.duration),e.type="keyframes",e};const SB=5;function y4(e,t,n){const i=Math.max(t-SB,0);return $R(n-e(i),t-i)}function r1({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:u,max:h,restDelta:d=.5,restSpeed:p}){const m=e[0],b={done:!1,value:m},_=I=>u!==void 0&&Ih,S=I=>u===void 0?h:h===void 0||Math.abs(u-I)-A*Math.exp(-I/i),w=I=>y+E(I),T=I=>{const C=E(I),R=w(I);b.done=Math.abs(C)<=d,b.value=b.done?y:R};let P,O;const U=I=>{_(b.value)&&(P=I,O=Gp({keyframes:[b.value,S(b.value)],velocity:y4(w,I,b.value),damping:a,stiffness:o,restDelta:d,restSpeed:p}))};return U(0),{calculatedDuration:null,next:I=>{let C=!1;return!O&&P===void 0&&(C=!0,T(I),U(I)),P!==void 0&&I>=P?O.next(I-P):(!C&&T(I),b)}}}function MB(e,t,n){const i=[],a=n||uo.mix||v4,o=e.length-1;for(let l=0;lt[0];if(o===2&&t[0]===t[1])return()=>t[1];const l=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const u=MB(t,i,a),h=u.length,d=p=>{if(l&&p1)for(;md(wa(e[0],e[o-1],p)):d}function TB(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const a=Qf(0,t,i);e.push(gn(n,1,a))}}function EB(e){const t=[0];return TB(t,e.length-1),t}function wB(e,t){return e.map(n=>n*t)}function RB(e,t){return e.map(()=>t||l4).splice(0,e.length-1)}function kf({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const a=IF(i)?i.map(FT):FT(i),o={done:!1,value:t[0]},l=wB(n&&n.length===t.length?n:EB(t),e),u=AB(l,t,{ease:Array.isArray(a)?a:RB(t,a)});return{calculatedDuration:e,next:h=>(o.value=u(h),o.done=h>=e,o)}}const CB=e=>e!==null;function Mm(e,{repeat:t,repeatType:n="loop"},i,a=1){const o=e.filter(CB),u=a<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!u||i===void 0?o[u]:i}const DB={decay:r1,inertia:r1,tween:kf,keyframes:kf,spring:Gp};function x4(e){typeof e.type=="string"&&(e.type=DB[e.type])}class ay{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const LB=e=>e/100;class Hp extends ay{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var i,a;const{motionValue:n}=this.options;n&&n.updatedAt!==Pi.now()&&this.tick(Pi.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(a=(i=this.options).onStop)==null||a.call(i))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;x4(t);const{type:n=kf,repeat:i=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=t;let{keyframes:u}=t;const h=n||kf;h!==kf&&typeof u[0]!="number"&&(this.mixKeyframes=fh(LB,v4(u[0],u[1])),u=[0,100]);const d=h({...t,keyframes:u});o==="mirror"&&(this.mirroredGenerator=h({...t,keyframes:[...u].reverse(),velocity:-l})),d.calculatedDuration===null&&(d.calculatedDuration=sy(d));const{calculatedDuration:p}=d;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(i+1)-a,this.generator=d}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:i,totalDuration:a,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:u,calculatedDuration:h}=this;if(this.startTime===null)return i.next(0);const{delay:d=0,keyframes:p,repeat:m,repeatType:b,repeatDelay:_,type:S,onUpdate:A,finalKeyframe:x}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const y=this.currentTime-d*(this.playbackSpeed>=0?1:-1),E=this.playbackSpeed>=0?y<0:y>a;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let w=this.currentTime,T=i;if(m){const I=Math.min(this.currentTime,a)/u;let C=Math.floor(I),R=I%1;!R&&I>=1&&(R=1),R===1&&C--,C=Math.min(C,m+1),!!(C%2)&&(b==="reverse"?(R=1-R,_&&(R-=_/u)):b==="mirror"&&(T=l)),w=wa(0,1,R)*u}let P;E?(this.delayState.value=p[0],P=this.delayState):P=T.next(w),o&&!E&&(P.value=o(P.value));let{done:O}=P;!E&&h!==null&&(O=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const U=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return U&&S!==r1&&(P.value=Mm(p,this.options,x,this.speed)),A&&A(P.value),U&&this.finish(),P}then(t,n){return this.finished.then(t,n)}get duration(){return ks(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+ks(t)}get time(){return ks(this.currentTime)}set time(t){t=bs(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return y4(i=>this.generator.next(i).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(Pi.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=ks(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:t=pB,startTime:n}=this.options;this.driver||(this.driver=t(l=>this.tick(l))),(o=(a=this.options).onPlay)==null||o.call(a);const i=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=i):this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime||(this.startTime=n??i),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Pi.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function NB(e){for(let t=1;te*180/Math.PI,o1=e=>{const t=el(Math.atan2(e[1],e[0]));return l1(t)},UB={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:o1,rotateZ:o1,skewX:e=>el(Math.atan(e[1])),skewY:e=>el(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},l1=e=>(e=e%360,e<0&&(e+=360),e),jT=o1,WT=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),XT=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),PB={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:WT,scaleY:XT,scale:e=>(WT(e)+XT(e))/2,rotateX:e=>l1(el(Math.atan2(e[6],e[5]))),rotateY:e=>l1(el(Math.atan2(-e[2],e[0]))),rotateZ:jT,rotate:jT,skewX:e=>el(Math.atan(e[4])),skewY:e=>el(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function c1(e){return e.includes("scale")?1:0}function u1(e,t){if(!e||e==="none")return c1(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,a;if(n)i=PB,a=n;else{const u=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=UB,a=u}if(!a)return c1(t);const o=i[t],l=a[1].split(",").map(IB);return typeof o=="function"?o(l):l[o]}const OB=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return u1(n,t)};function IB(e){return parseFloat(e.trim())}const bu=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],vu=new Set(bu),qT=e=>e===gu||e===Wt,FB=new Set(["x","y","z"]),BB=bu.filter(e=>!FB.has(e));function kB(e){const t=[];return BB.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const io={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:i})=>{const a=e.max-e.min;return i==="border-box"?a:a-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:i})=>{const a=e.max-e.min;return i==="border-box"?a:a-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>u1(t,"x"),y:(e,{transform:t})=>u1(t,"y")};io.translateX=io.x;io.translateY=io.y;const ol=new Set;let f1=!1,h1=!1,d1=!1;function S4(){if(h1){const e=Array.from(ol).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const a=kB(i);a.length&&(n.set(i,a),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const a=n.get(i);a&&a.forEach(([o,l])=>{var u;(u=i.getValue(o))==null||u.set(l)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}h1=!1,f1=!1,ol.forEach(e=>e.complete(d1)),ol.clear()}function M4(){ol.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(h1=!0)})}function zB(){d1=!0,M4(),S4(),d1=!1}class ry{constructor(t,n,i,a,o,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=i,this.motionValue=a,this.element=o,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?(ol.add(this),f1||(f1=!0,fn.read(M4),fn.resolveKeyframes(S4))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:a}=this;if(t[0]===null){const o=a==null?void 0:a.get(),l=t[t.length-1];if(o!==void 0)t[0]=o;else if(i&&n){const u=i.readValue(n,l);u!=null&&(t[0]=u)}t[0]===void 0&&(t[0]=l),a&&o===void 0&&a.set(t[0])}NB(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),ol.delete(this)}cancel(){this.state==="scheduled"&&(ol.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const VB=e=>e.startsWith("--");function A4(e,t,n){VB(t)?e.style.setProperty(t,n):e.style[t]=n}const GB={};function T4(e,t){const n=JR(e);return()=>GB[t]??n()}const HB=T4(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),E4=T4(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Df=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,YT={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Df([0,.65,.55,1]),circOut:Df([.55,0,1,.45]),backIn:Df([.31,.01,.66,-.59]),backOut:Df([.33,1.53,.69,.99])};function w4(e,t){if(e)return typeof e=="function"?E4()?_4(e,t):"ease-out":c4(e)?Df(e):Array.isArray(e)?e.map(n=>w4(n,t)||YT.easeOut):YT[e]}function jB(e,t,n,{delay:i=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:u="easeOut",times:h}={},d=void 0){const p={[t]:n};h&&(p.offset=h);const m=w4(u,a);Array.isArray(m)&&(p.easing=m);const b={delay:i,duration:a,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return d&&(b.pseudoElement=d),e.animate(p,b)}function R4(e){return typeof e=="function"&&"applyToOptions"in e}function WB({type:e,...t}){return R4(e)&&E4()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class C4 extends ay{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:i,keyframes:a,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:u,onComplete:h}=t;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=t,Z_(typeof t.type!="string");const d=WB(t);this.animation=jB(n,i,a,d,o),d.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=Mm(a,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(p),A4(n,i,p),this.animation.cancel()}h==null||h(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var n,i,a;const t=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((a=(i=this.animation).commitStyles)==null||a.call(i))}get duration(){var n,i;const t=((i=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:i.call(n).duration)||0;return ks(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+ks(t)}get time(){return ks(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=bs(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:i,observe:a}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&HB()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),i&&(this.animation.rangeEnd=i),zs):a(this)}}const D4={anticipate:a4,backInOut:s4,circInOut:o4};function XB(e){return e in D4}function qB(e){typeof e.ease=="string"&&XB(e.ease)&&(e.ease=D4[e.ease])}const Ob=10;class YB extends C4{constructor(t){qB(t),x4(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:i,onComplete:a,element:o,...l}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const u=new Hp({...l,autoplay:!1}),h=Math.max(Ob,Pi.now()-this.startTime),d=wa(0,Ob,h-Ob),p=u.sample(h).value,{name:m}=this.options;o&&m&&A4(o,m,p),n.setWithVelocity(u.sample(Math.max(0,h-d)).value,p,d),u.stop()}}const KT=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(ra.test(e)||e==="0")&&!e.startsWith("url("));function KB(e){const t=e[0];if(e.length===1)return!0;for(let n=0;nObject.hasOwnProperty.call(Element.prototype,"animate"));function ek(e){var m;const{motionValue:t,name:n,repeatDelay:i,repeatType:a,damping:o,type:l,keyframes:u}=e;if(!(((m=t==null?void 0:t.owner)==null?void 0:m.current)instanceof HTMLElement))return!1;const{onUpdate:d,transformTemplate:p}=t.owner.getProps();return tk()&&n&&(L4.has(n)||$B.has(n)&&JB(u))&&(n!=="transform"||!p)&&!d&&!i&&a!=="mirror"&&o!==0&&l!=="inertia"}const nk=40;class ik extends ay{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:u,name:h,motionValue:d,element:p,...m}){var S;super(),this.stop=()=>{var A,x;this._animation&&(this._animation.stop(),(A=this.stopTimeline)==null||A.call(this)),(x=this.keyframeResolver)==null||x.cancel()},this.createdAt=Pi.now();const b={autoplay:t,delay:n,type:i,repeat:a,repeatDelay:o,repeatType:l,name:h,motionValue:d,element:p,...m},_=(p==null?void 0:p.KeyframeResolver)||ry;this.keyframeResolver=new _(u,(A,x,y)=>this.onKeyframesResolved(A,x,b,!y),h,d,p),(S=this.keyframeResolver)==null||S.scheduleResolve()}onKeyframesResolved(t,n,i,a){var y,E;this.keyframeResolver=void 0;const{name:o,type:l,velocity:u,delay:h,isHandoff:d,onUpdate:p}=i;this.resolvedAt=Pi.now();let m=!0;ZB(t,o,l,u)||(m=!1,(uo.instantAnimations||!h)&&(p==null||p(Mm(t,i,n))),t[0]=t[t.length-1],p1(i),i.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>nk?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},S=m&&!d&&ek(_),A=(E=(y=_.motionValue)==null?void 0:y.owner)==null?void 0:E.current;let x;if(S)try{x=new YB({..._,element:A})}catch{x=new Hp(_)}else x=new Hp(_);x.finished.then(()=>{this.notifyFinished()}).catch(zs),this.pendingTimeline&&(this.stopTimeline=x.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=x}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),zB()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function N4(e,t,n,i=0,a=1){const o=Array.from(e).sort((d,p)=>d.sortNodePosition(p)).indexOf(t),l=e.size,u=(l-1)*i;return typeof n=="function"?n(o,l):a===1?o*i:u-o*i}const sk=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ak(e){const t=sk.exec(e);if(!t)return[,];const[,n,i,a]=t;return[`--${n??i}`,a]}function U4(e,t,n=1){const[i,a]=ak(e);if(!i)return;const o=window.getComputedStyle(t).getPropertyValue(i);if(o){const l=o.trim();return KR(l)?parseFloat(l):l}return ty(a)?U4(a,t,n+1):a}const rk={type:"spring",stiffness:500,damping:25,restSpeed:10},ok=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),lk={type:"keyframes",duration:.8},ck={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},uk=(e,{keyframes:t})=>t.length>2?lk:vu.has(e)?e.startsWith("scale")?ok(t[1]):rk:ck;function P4(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...i}=e;return{...t,...i}}return e}function oy(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?P4(n,e):n}const fk=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function hk(e){for(const t in e)if(!fk.has(t))return!0;return!1}const ly=(e,t,n,i={},a,o)=>l=>{const u=oy(i,e)||{},h=u.delay||i.delay||0;let{elapsed:d=0}=i;d=d-bs(h);const p={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...u,delay:-d,onUpdate:b=>{t.set(b),u.onUpdate&&u.onUpdate(b)},onComplete:()=>{l(),u.onComplete&&u.onComplete()},name:e,motionValue:t,element:o?void 0:a};hk(u)||Object.assign(p,uk(e,p)),p.duration&&(p.duration=bs(p.duration)),p.repeatDelay&&(p.repeatDelay=bs(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let m=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(p1(p),p.delay===0&&(m=!0)),(uo.instantAnimations||uo.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(m=!0,p1(p),p.delay=0),p.allowFlatten=!u.type&&!u.ease,m&&!o&&t.get()!==void 0){const b=Mm(p.keyframes,u);if(b!==void 0){fn.update(()=>{p.onUpdate(b),p.onComplete()});return}}return u.isSync?new Hp(p):new ik(p)};function ZT(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function cy(e,t,n,i){if(typeof t=="function"){const[a,o]=ZT(i);t=t(n!==void 0?n:e.custom,a,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[a,o]=ZT(i);t=t(n!==void 0?n:e.custom,a,o)}return t}function ll(e,t,n){const i=e.getProps();return cy(i,t,n!==void 0?n:i.custom,e)}const O4=new Set(["width","height","top","left","right","bottom",...bu]),QT=30,dk=e=>!isNaN(parseFloat(e));class pk{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{var o;const a=Pi.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&((o=this.events.change)==null||o.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Pi.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=dk(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Q_);const i=this.events[t].add(n);return t==="change"?()=>{i(),fn.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Pi.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>QT)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,QT);return $R(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function $c(e,t){return new pk(e,t)}const m1=e=>Array.isArray(e);function mk(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,$c(n))}function gk(e){return m1(e)?e[e.length-1]||0:e}function bk(e,t){const n=ll(e,t);let{transitionEnd:i={},transition:a={},...o}=n||{};o={...o,...i};for(const l in o){const u=gk(o[l]);mk(e,l,u)}}const bi=e=>!!(e&&e.getVelocity);function vk(e){return!!(bi(e)&&e.add)}function g1(e,t){const n=e.getValue("willChange");if(vk(n))return n.add(t);if(!n&&uo.WillChange){const i=new uo.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function uy(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const _k="framerAppearId",I4="data-"+uy(_k);function F4(e){return e.props[I4]}function yk({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function B4(e,t,{delay:n=0,transitionOverride:i,type:a}={}){let{transition:o,transitionEnd:l,...u}=t;const h=e.getDefaultTransition();o=o?P4(o,h):h;const d=o==null?void 0:o.reduceMotion;i&&(o=i);const p=[],m=a&&e.animationState&&e.animationState.getState()[a];for(const b in u){const _=e.getValue(b,e.latestValues[b]??null),S=u[b];if(S===void 0||m&&yk(m,b))continue;const A={delay:n,...oy(o||{},b)},x=_.get();if(x!==void 0&&!_.isAnimating()&&!Array.isArray(S)&&S===x&&!A.velocity){fn.update(()=>_.set(S));continue}let y=!1;if(window.MotionHandoffAnimation){const T=F4(e);if(T){const P=window.MotionHandoffAnimation(T,b,fn);P!==null&&(A.startTime=P,y=!0)}}g1(e,b);const E=d??e.shouldReduceMotion;_.start(ly(b,_,S,E&&O4.has(b)?{type:!1}:A,e,y));const w=_.animation;w&&p.push(w)}if(l){const b=()=>fn.update(()=>{l&&bk(e,l)});p.length?Promise.all(p).then(b):b()}return p}function b1(e,t,n={}){var h;const i=ll(e,t,n.type==="exit"?(h=e.presenceContext)==null?void 0:h.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(a=n.transitionOverride);const o=i?()=>Promise.all(B4(e,i,n)):()=>Promise.resolve(),l=e.variantChildren&&e.variantChildren.size?(d=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:b}=a;return xk(e,t,d,p,m,b,n)}:()=>Promise.resolve(),{when:u}=a;if(u){const[d,p]=u==="beforeChildren"?[o,l]:[l,o];return d().then(()=>p())}else return Promise.all([o(),l(n.delay)])}function xk(e,t,n=0,i=0,a=0,o=1,l){const u=[];for(const h of e.variantChildren)h.notify("AnimationStart",t),u.push(b1(h,t,{...l,delay:n+(typeof i=="function"?0:i)+N4(e.variantChildren,h,i,a,o)}).then(()=>h.notify("AnimationComplete",t)));return Promise.all(u)}function Sk(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const a=t.map(o=>b1(e,o,n));i=Promise.all(a)}else if(typeof t=="string")i=b1(e,t,n);else{const a=typeof t=="function"?ll(e,t,n.custom):t;i=Promise.all(B4(e,a,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const Mk={test:e=>e==="auto",parse:e=>e},k4=e=>t=>t.test(e),z4=[gu,Wt,Aa,Zr,KF,YF,Mk],JT=e=>z4.find(k4(e));function Ak(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||QR(e):!0}const Tk=new Set(["brightness","contrast","saturate","opacity"]);function Ek(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(ey)||[];if(!i)return e;const a=n.replace(i,"");let o=Tk.has(t)?1:0;return i!==n&&(o*=100),t+"("+o+a+")"}const wk=/\b([a-z-]*)\(.*?\)/gu,v1={...ra,getAnimatableNone:e=>{const t=e.match(wk);return t?t.map(Ek).join(" "):e}},_1={...ra,getAnimatableNone:e=>{const t=ra.parse(e);return ra.createTransformer(e)(t.map(i=>typeof i=="number"?0:typeof i=="object"?{...i,alpha:1}:i))}},$T={...gu,transform:Math.round},Rk={rotate:Zr,rotateX:Zr,rotateY:Zr,rotateZ:Zr,scale:ap,scaleX:ap,scaleY:ap,scaleZ:ap,skew:Zr,skewX:Zr,skewY:Zr,distance:Wt,translateX:Wt,translateY:Wt,translateZ:Wt,x:Wt,y:Wt,z:Wt,perspective:Wt,transformPerspective:Wt,opacity:Jf,originX:kT,originY:kT,originZ:Wt},fy={borderWidth:Wt,borderTopWidth:Wt,borderRightWidth:Wt,borderBottomWidth:Wt,borderLeftWidth:Wt,borderRadius:Wt,borderTopLeftRadius:Wt,borderTopRightRadius:Wt,borderBottomRightRadius:Wt,borderBottomLeftRadius:Wt,width:Wt,maxWidth:Wt,height:Wt,maxHeight:Wt,top:Wt,right:Wt,bottom:Wt,left:Wt,inset:Wt,insetBlock:Wt,insetBlockStart:Wt,insetBlockEnd:Wt,insetInline:Wt,insetInlineStart:Wt,insetInlineEnd:Wt,padding:Wt,paddingTop:Wt,paddingRight:Wt,paddingBottom:Wt,paddingLeft:Wt,paddingBlock:Wt,paddingBlockStart:Wt,paddingBlockEnd:Wt,paddingInline:Wt,paddingInlineStart:Wt,paddingInlineEnd:Wt,margin:Wt,marginTop:Wt,marginRight:Wt,marginBottom:Wt,marginLeft:Wt,marginBlock:Wt,marginBlockStart:Wt,marginBlockEnd:Wt,marginInline:Wt,marginInlineStart:Wt,marginInlineEnd:Wt,fontSize:Wt,backgroundPositionX:Wt,backgroundPositionY:Wt,...Rk,zIndex:$T,fillOpacity:Jf,strokeOpacity:Jf,numOctaves:$T},Ck={...fy,color:Gn,backgroundColor:Gn,outlineColor:Gn,fill:Gn,stroke:Gn,borderColor:Gn,borderTopColor:Gn,borderRightColor:Gn,borderBottomColor:Gn,borderLeftColor:Gn,filter:v1,WebkitFilter:v1,mask:_1,WebkitMask:_1},V4=e=>Ck[e],Dk=new Set([v1,_1]);function G4(e,t){let n=V4(e);return Dk.has(n)||(n=ra),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Lk=new Set(["auto","none","0"]);function Nk(e,t,n){let i=0,a;for(;i{t.getValue(h).set(d)}),this.resolveNoneKeyframes()}}function H4(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let i=document;const a=(n==null?void 0:n[e])??i.querySelectorAll(e);return a?Array.from(a):[]}return Array.from(e).filter(i=>i!=null)}const j4=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function _p(e){return ZR(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:hy}=u4(queueMicrotask,!1),$s={x:!1,y:!1};function W4(){return $s.x||$s.y}function Pk(e){return e==="x"||e==="y"?$s[e]?null:($s[e]=!0,()=>{$s[e]=!1}):$s.x||$s.y?null:($s.x=$s.y=!0,()=>{$s.x=$s.y=!1})}function X4(e,t){const n=H4(e),i=new AbortController,a={passive:!0,...t,signal:i.signal};return[n,a,()=>i.abort()]}function Ok(e){return!(e.pointerType==="touch"||W4())}function Ik(e,t,n={}){const[i,a,o]=X4(e,n);return i.forEach(l=>{let u=!1,h=!1,d;const p=()=>{l.removeEventListener("pointerleave",S)},m=x=>{d&&(d(x),d=void 0),p()},b=x=>{u=!1,window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b),h&&(h=!1,m(x))},_=()=>{u=!0,window.addEventListener("pointerup",b,a),window.addEventListener("pointercancel",b,a)},S=x=>{if(x.pointerType!=="touch"){if(u){h=!0;return}m(x)}},A=x=>{if(!Ok(x))return;h=!1;const y=t(l,x);typeof y=="function"&&(d=y,l.addEventListener("pointerleave",S,a))};l.addEventListener("pointerenter",A,a),l.addEventListener("pointerdown",_,a)}),o}const q4=(e,t)=>t?e===t?!0:q4(e,t.parentElement):!1,dy=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Fk=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Bk(e){return Fk.has(e.tagName)||e.isContentEditable===!0}const kk=new Set(["INPUT","SELECT","TEXTAREA"]);function zk(e){return kk.has(e.tagName)||e.isContentEditable===!0}const yp=new WeakSet;function tE(e){return t=>{t.key==="Enter"&&e(t)}}function Ib(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Vk=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=tE(()=>{if(yp.has(n))return;Ib(n,"down");const a=tE(()=>{Ib(n,"up")}),o=()=>Ib(n,"cancel");n.addEventListener("keyup",a,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function eE(e){return dy(e)&&!W4()}const nE=new WeakSet;function Gk(e,t,n={}){const[i,a,o]=X4(e,n),l=u=>{const h=u.currentTarget;if(!eE(u)||nE.has(u))return;yp.add(h),n.stopPropagation&&nE.add(u);const d=t(h,u),p=(_,S)=>{window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",b),yp.has(h)&&yp.delete(h),eE(_)&&typeof d=="function"&&d(_,{success:S})},m=_=>{p(_,h===window||h===document||n.useGlobalTarget||q4(h,_.target))},b=_=>{p(_,!1)};window.addEventListener("pointerup",m,a),window.addEventListener("pointercancel",b,a)};return i.forEach(u=>{(n.useGlobalTarget?window:u).addEventListener("pointerdown",l,a),_p(u)&&(u.addEventListener("focus",d=>Vk(d,a)),!Bk(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function py(e){return ZR(e)&&"ownerSVGElement"in e}const xp=new WeakMap;let Qr;const Y4=(e,t,n)=>(i,a)=>a&&a[0]?a[0][e+"Size"]:py(i)&&"getBBox"in i?i.getBBox()[t]:i[n],Hk=Y4("inline","width","offsetWidth"),jk=Y4("block","height","offsetHeight");function Wk({target:e,borderBoxSize:t}){var n;(n=xp.get(e))==null||n.forEach(i=>{i(e,{get width(){return Hk(e,t)},get height(){return jk(e,t)}})})}function Xk(e){e.forEach(Wk)}function qk(){typeof ResizeObserver>"u"||(Qr=new ResizeObserver(Xk))}function Yk(e,t){Qr||qk();const n=H4(e);return n.forEach(i=>{let a=xp.get(i);a||(a=new Set,xp.set(i,a)),a.add(t),Qr==null||Qr.observe(i)}),()=>{n.forEach(i=>{const a=xp.get(i);a==null||a.delete(t),a!=null&&a.size||Qr==null||Qr.unobserve(i)})}}const Sp=new Set;let Sc;function Kk(){Sc=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Sp.forEach(t=>t(e))},window.addEventListener("resize",Sc)}function Zk(e){return Sp.add(e),Sc||Kk(),()=>{Sp.delete(e),!Sp.size&&typeof Sc=="function"&&(window.removeEventListener("resize",Sc),Sc=void 0)}}function iE(e,t){return typeof e=="function"?Zk(e):Yk(e,t)}function Qk(e){return py(e)&&e.tagName==="svg"}const Jk=[...z4,Gn,ra],$k=e=>Jk.find(k4(e)),sE=()=>({translate:0,scale:1,origin:0,originPoint:0}),Mc=()=>({x:sE(),y:sE()}),aE=()=>({min:0,max:0}),Kn=()=>({x:aE(),y:aE()}),tz=new WeakMap;function Am(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function $f(e){return typeof e=="string"||Array.isArray(e)}const my=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],gy=["initial",...my];function Tm(e){return Am(e.animate)||gy.some(t=>$f(e[t]))}function K4(e){return!!(Tm(e)||e.variants)}function ez(e,t,n){for(const i in t){const a=t[i],o=n[i];if(bi(a))e.addValue(i,a);else if(bi(o))e.addValue(i,$c(a,{owner:e}));else if(o!==a)if(e.hasValue(i)){const l=e.getValue(i);l.liveStyle===!0?l.jump(a):l.hasAnimated||l.set(a)}else{const l=e.getStaticValue(i);e.addValue(i,$c(l!==void 0?l:a,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const y1={current:null},Z4={current:!1},nz=typeof window<"u";function iz(){if(Z4.current=!0,!!nz)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>y1.current=e.matches;e.addEventListener("change",t),t()}else y1.current=!1}const rE=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let jp={};function Q4(e){jp=e}function sz(){return jp}class az{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:l,visualState:u},h={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=ry,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const _=Pi.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,fn.render(this.render,!1,!0))};const{latestValues:d,renderState:p}=u;this.latestValues=d,this.baseTarget={...d},this.initialValues=n.initial?{...d}:{},this.renderState=p,this.parent=t,this.props=n,this.presenceContext=i,this.depth=t?t.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=h,this.blockInitialAnimation=!!l,this.isControllingVariants=Tm(n),this.isVariantNode=K4(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:m,...b}=this.scrapeMotionValuesFromProps(n,{},this);for(const _ in b){const S=b[_];d[_]!==void 0&&bi(S)&&S.set(d[_])}}mount(t){var n,i;if(this.hasBeenMounted)for(const a in this.initialValues)(n=this.values.get(a))==null||n.jump(this.initialValues[a]),this.latestValues[a]=this.initialValues[a];this.current=t,tz.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((a,o)=>this.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(Z4.current||iz(),this.shouldReduceMotion=y1.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(i=this.parent)==null||i.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),fo(this.notifyUpdate),fo(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const i=this.features[n];i&&(i.unmount(),i.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&L4.has(t)&&this.current instanceof HTMLElement){const{factory:l,keyframes:u,times:h,ease:d,duration:p}=n.accelerate,m=new C4({element:this.current,name:t,keyframes:u,times:h,ease:d,duration:bs(p)}),b=l(m);this.valueSubscriptions.set(t,()=>{b(),m.cancel()});return}const i=vu.has(t);i&&this.onBindTransform&&this.onBindTransform();const a=n.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&fn.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{a(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in jp){const n=jp[t];if(!n)continue;const{isEnabled:i,Feature:a}=n;if(!this.features[t]&&a&&i(this.props)&&(this.features[t]=new a(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Kn()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;in.variantChildren.delete(t)}addValue(t,n){const i=this.values.get(t);n!==i&&(i&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let i=this.values.get(t);return i===void 0&&n!==void 0&&(i=$c(n===null?void 0:n,{owner:this}),this.addValue(t,i)),i}readValue(t,n){let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(KR(i)||QR(i))?i=parseFloat(i):!$k(i)&&ra.test(n)&&(i=G4(t,n)),this.setBaseTarget(t,bi(i)?i.get():i)),bi(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var o;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const l=cy(this.props,n,(o=this.presenceContext)==null?void 0:o.custom);l&&(i=l[t])}if(n&&i!==void 0)return i;const a=this.getBaseTargetFromProps(this.props,t);return a!==void 0&&!bi(a)?a:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Q_),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){hy.render(this.render)}}class J4 extends az{constructor(){super(...arguments),this.KeyframeResolver=Uk}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const i=t.style;return i?i[n]:void 0}removeValueFromRenderState(t,{vars:n,style:i}){delete n[t],delete i[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;bi(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class po{constructor(t){this.isMounted=!1,this.node=t}update(){}}function $4({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function rz({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function oz(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),i=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}function Fb(e){return e===void 0||e===1}function x1({scale:e,scaleX:t,scaleY:n}){return!Fb(e)||!Fb(t)||!Fb(n)}function qo(e){return x1(e)||tC(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function tC(e){return oE(e.x)||oE(e.y)}function oE(e){return e&&e!=="0%"}function Wp(e,t,n){const i=e-n,a=t*i;return n+a}function lE(e,t,n,i,a){return a!==void 0&&(e=Wp(e,a,i)),Wp(e,n,i)+t}function S1(e,t=0,n=1,i,a){e.min=lE(e.min,t,n,i,a),e.max=lE(e.max,t,n,i,a)}function eC(e,{x:t,y:n}){S1(e.x,t.translate,t.scale,t.originPoint),S1(e.y,n.translate,n.scale,n.originPoint)}const cE=.999999999999,uE=1.0000000000001;function lz(e,t,n,i=!1){var u;const a=n.length;if(!a)return;t.x=t.y=1;let o,l;for(let h=0;hcE&&(t.x=1),t.ycE&&(t.y=1)}function ya(e,t){e.min+=t,e.max+=t}function fE(e,t,n,i,a=.5){const o=gn(e.min,e.max,a);S1(e,t,n,o,i)}function hE(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Mp(e,t,n){const i=n??e;fE(e.x,hE(t.x,i.x),t.scaleX,t.scale,t.originX),fE(e.y,hE(t.y,i.y),t.scaleY,t.scale,t.originY)}function nC(e,t){return $4(oz(e.getBoundingClientRect(),t))}function cz(e,t,n){const i=nC(e,n),{scroll:a}=t;return a&&(ya(i.x,a.offset.x),ya(i.y,a.offset.y)),i}const uz={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fz=bu.length;function hz(e,t,n){let i="",a=!0;for(let o=0;o{if(!t.target)return e;if(typeof e=="string")if(Wt.test(e))e=parseFloat(e);else return e;const n=dE(e,t.target.x),i=dE(e,t.target.y);return`${n}% ${i}%`}},dz={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,a=ra.parse(e);if(a.length>5)return i;const o=ra.createTransformer(e),l=typeof a[0]!="number"?1:0,u=n.x.scale*t.x,h=n.y.scale*t.y;a[0+l]/=u,a[1+l]/=h;const d=gn(u,h,.5);return typeof a[2+l]=="number"&&(a[2+l]/=d),typeof a[3+l]=="number"&&(a[3+l]/=d),o(a)}},M1={borderRadius:{...Sf,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Sf,borderTopRightRadius:Sf,borderBottomLeftRadius:Sf,borderBottomRightRadius:Sf,boxShadow:dz};function sC(e,{layout:t,layoutId:n}){return vu.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!M1[e]||e==="opacity")}function vy(e,t,n){var l;const i=e.style,a=t==null?void 0:t.style,o={};if(!i)return o;for(const u in i)(bi(i[u])||a&&bi(a[u])||sC(u,e)||((l=n==null?void 0:n.getValue(u))==null?void 0:l.liveStyle)!==void 0)&&(o[u]=i[u]);return o}function pz(e){return window.getComputedStyle(e)}class mz extends J4{constructor(){super(...arguments),this.type="html",this.renderInstance=iC}readValueFromInstance(t,n){var i;if(vu.has(n))return(i=this.projection)!=null&&i.isProjecting?c1(n):OB(t,n);{const a=pz(t),o=(h4(n)?a.getPropertyValue(n):a[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:n}){return nC(t,n)}build(t,n,i){by(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return vy(t,n,i)}}const gz={offset:"stroke-dashoffset",array:"stroke-dasharray"},bz={offset:"strokeDashoffset",array:"strokeDasharray"};function vz(e,t,n=1,i=0,a=!0){e.pathLength=1;const o=a?gz:bz;e[o.offset]=`${-i}`,e[o.array]=`${t} ${n}`}const _z=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function aC(e,{attrX:t,attrY:n,attrScale:i,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...u},h,d,p){if(by(e,u,d),h){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:m,style:b}=e;m.transform&&(b.transform=m.transform,delete m.transform),(b.transform||m.transformOrigin)&&(b.transformOrigin=m.transformOrigin??"50% 50%",delete m.transformOrigin),b.transform&&(b.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete m.transformBox);for(const _ of _z)m[_]!==void 0&&(b[_]=m[_],delete m[_]);t!==void 0&&(m.x=t),n!==void 0&&(m.y=n),i!==void 0&&(m.scale=i),a!==void 0&&vz(m,a,o,l,!1)}const rC=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),oC=e=>typeof e=="string"&&e.toLowerCase()==="svg";function yz(e,t,n,i){iC(e,t,void 0,i);for(const a in t.attrs)e.setAttribute(rC.has(a)?a:uy(a),t.attrs[a])}function lC(e,t,n){const i=vy(e,t,n);for(const a in e)if(bi(e[a])||bi(t[a])){const o=bu.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;i[o]=e[a]}return i}class xz extends J4{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Kn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(vu.has(n)){const i=V4(n);return i&&i.default||0}return n=rC.has(n)?n:uy(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return lC(t,n,i)}build(t,n,i){aC(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,a){yz(t,n,i,a)}mount(t){this.isSVGTag=oC(t.tagName),super.mount(t)}}const Sz=gy.length;function cC(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?cC(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;nPromise.all(t.map(({animation:n,options:i})=>Sk(e,n,i)))}function Ez(e){let t=Tz(e),n=pE(),i=!0,a=!1;const o=d=>(p,m)=>{var _;const b=ll(e,m,d==="exit"?(_=e.presenceContext)==null?void 0:_.custom:void 0);if(b){const{transition:S,transitionEnd:A,...x}=b;p={...p,...x,...A}}return p};function l(d){t=d(e)}function u(d){const{props:p}=e,m=cC(e.parent)||{},b=[],_=new Set;let S={},A=1/0;for(let y=0;yA&&P,R=!1;const F=Array.isArray(T)?T:[T];let Y=F.reduce(o(E),{});O===!1&&(Y={});const{prevResolvedValues:$={}}=w,lt={...$,...Y},ut=X=>{C=!0,_.has(X)&&(R=!0,_.delete(X)),w.needsAnimating[X]=!0;const yt=e.getValue(X);yt&&(yt.liveStyle=!1)};for(const X in lt){const yt=Y[X],At=$[X];if(S.hasOwnProperty(X))continue;let z=!1;m1(yt)&&m1(At)?z=!uC(yt,At):z=yt!==At,z?yt!=null?ut(X):_.add(X):yt!==void 0&&_.has(X)?ut(X):w.protectedKeys[X]=!0}w.prevProp=T,w.prevResolvedValues=Y,w.isActive&&(S={...S,...Y}),(i||a)&&e.blockInitialAnimation&&(C=!1);const k=U&&I;C&&(!k||R)&&b.push(...F.map(X=>{const yt={type:E};if(typeof X=="string"&&(i||a)&&!k&&e.manuallyAnimateOnMount&&e.parent){const{parent:At}=e,z=ll(At,X);if(At.enteringChildren&&z){const{delayChildren:it}=z.transition||{};yt.delay=N4(At.enteringChildren,e,it)}}return{animation:X,options:yt}}))}if(_.size){const y={};if(typeof p.initial!="boolean"){const E=ll(e,Array.isArray(p.initial)?p.initial[0]:p.initial);E&&E.transition&&(y.transition=E.transition)}_.forEach(E=>{const w=e.getBaseTarget(E),T=e.getValue(E);T&&(T.liveStyle=!0),y[E]=w??null}),b.push({animation:y})}let x=!!b.length;return i&&(p.initial===!1||p.initial===p.animate)&&!e.manuallyAnimateOnMount&&(x=!1),i=!1,a=!1,x?t(b):Promise.resolve()}function h(d,p){var b;if(n[d].isActive===p)return Promise.resolve();(b=e.variantChildren)==null||b.forEach(_=>{var S;return(S=_.animationState)==null?void 0:S.setActive(d,p)}),n[d].isActive=p;const m=u(d);for(const _ in n)n[_].protectedKeys={};return m}return{animateChanges:u,setActive:h,setAnimateFunction:l,getState:()=>n,reset:()=>{n=pE(),a=!0}}}function wz(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!uC(t,e):!1}function Go(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function pE(){return{animate:Go(!0),whileInView:Go(),whileHover:Go(),whileTap:Go(),whileDrag:Go(),whileFocus:Go(),exit:Go()}}function A1(e,t){e.min=t.min,e.max=t.max}function Js(e,t){A1(e.x,t.x),A1(e.y,t.y)}function mE(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const fC=1e-4,Rz=1-fC,Cz=1+fC,hC=.01,Dz=0-hC,Lz=0+hC;function Oi(e){return e.max-e.min}function Nz(e,t,n){return Math.abs(e-t)<=n}function gE(e,t,n,i=.5){e.origin=i,e.originPoint=gn(t.min,t.max,e.origin),e.scale=Oi(n)/Oi(t),e.translate=gn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Rz&&e.scale<=Cz||isNaN(e.scale))&&(e.scale=1),(e.translate>=Dz&&e.translate<=Lz||isNaN(e.translate))&&(e.translate=0)}function zf(e,t,n,i){gE(e.x,t.x,n.x,i?i.originX:void 0),gE(e.y,t.y,n.y,i?i.originY:void 0)}function bE(e,t,n,i=0){const a=i?gn(n.min,n.max,i):n.min;e.min=a+t.min,e.max=e.min+Oi(t)}function Uz(e,t,n,i){bE(e.x,t.x,n.x,i==null?void 0:i.x),bE(e.y,t.y,n.y,i==null?void 0:i.y)}function vE(e,t,n,i=0){const a=i?gn(n.min,n.max,i):n.min;e.min=t.min-a,e.max=e.min+Oi(t)}function Xp(e,t,n,i){vE(e.x,t.x,n.x,i==null?void 0:i.x),vE(e.y,t.y,n.y,i==null?void 0:i.y)}function _E(e,t,n,i,a){return e-=t,e=Wp(e,1/n,i),a!==void 0&&(e=Wp(e,1/a,i)),e}function Pz(e,t=0,n=1,i=.5,a,o=e,l=e){if(Aa.test(t)&&(t=parseFloat(t),t=gn(l.min,l.max,t/100)-l.min),typeof t!="number")return;let u=gn(o.min,o.max,i);e===o&&(u-=t),e.min=_E(e.min,t,n,u,a),e.max=_E(e.max,t,n,u,a)}function yE(e,t,[n,i,a],o,l){Pz(e,t[n],t[i],t[a],t.scale,o,l)}const Oz=["x","scaleX","originX"],Iz=["y","scaleY","originY"];function xE(e,t,n,i){yE(e.x,t,Oz,n?n.x:void 0,i?i.x:void 0),yE(e.y,t,Iz,n?n.y:void 0,i?i.y:void 0)}function SE(e){return e.translate===0&&e.scale===1}function dC(e){return SE(e.x)&&SE(e.y)}function ME(e,t){return e.min===t.min&&e.max===t.max}function Fz(e,t){return ME(e.x,t.x)&&ME(e.y,t.y)}function AE(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function pC(e,t){return AE(e.x,t.x)&&AE(e.y,t.y)}function TE(e){return Oi(e.x)/Oi(e.y)}function EE(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function va(e){return[e("x"),e("y")]}function Bz(e,t,n){let i="";const a=e.x.translate/t.x,o=e.y.translate/t.y,l=(n==null?void 0:n.z)||0;if((a||o||l)&&(i=`translate3d(${a}px, ${o}px, ${l}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:d,rotate:p,rotateX:m,rotateY:b,skewX:_,skewY:S}=n;d&&(i=`perspective(${d}px) ${i}`),p&&(i+=`rotate(${p}deg) `),m&&(i+=`rotateX(${m}deg) `),b&&(i+=`rotateY(${b}deg) `),_&&(i+=`skewX(${_}deg) `),S&&(i+=`skewY(${S}deg) `)}const u=e.x.scale*t.x,h=e.y.scale*t.y;return(u!==1||h!==1)&&(i+=`scale(${u}, ${h})`),i||"none"}const mC=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],kz=mC.length,wE=e=>typeof e=="string"?parseFloat(e):e,RE=e=>typeof e=="number"||Wt.test(e);function zz(e,t,n,i,a,o){a?(e.opacity=gn(0,n.opacity??1,Vz(i)),e.opacityExit=gn(t.opacity??1,0,Gz(i))):o&&(e.opacity=gn(t.opacity??1,n.opacity??1,i));for(let l=0;lit?1:n(Qf(e,t,i))}function Hz(e,t,n){const i=bi(e)?e:$c(e);return i.start(ly("",i,t,n)),i.animation}function th(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n)}const jz=(e,t)=>e.depth-t.depth;class Wz{constructor(){this.children=[],this.isDirty=!1}add(t){K_(this.children,t),this.isDirty=!0}remove(t){kp(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(jz),this.isDirty=!1,this.children.forEach(t)}}function Xz(e,t){const n=Pi.now(),i=({timestamp:a})=>{const o=a-n;o>=t&&(fo(i),e(o-t))};return fn.setup(i,!0),()=>fo(i)}function Ap(e){return bi(e)?e.get():e}class qz{constructor(){this.members=[]}add(t){K_(this.members,t);for(let n=this.members.length-1;n>=0;n--){const i=this.members[n];if(i===t||i===this.lead||i===this.prevLead)continue;const a=i.instance;(!a||a.isConnected===!1)&&!i.snapshot&&(kp(this.members,i),i.unmount())}t.scheduleRender()}remove(t){if(kp(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){var n;for(let i=this.members.indexOf(t)-1;i>=0;i--){const a=this.members[i];if(a.isPresent!==!1&&((n=a.instance)==null?void 0:n.isConnected)!==!1)return this.promote(a),!0}return!1}promote(t,n){var a;const i=this.lead;if(t!==i&&(this.prevLead=i,this.lead=t,t.show(),i)){i.updateSnapshot(),t.scheduleRender();const{layoutDependency:o}=i.options,{layoutDependency:l}=t.options;(o===void 0||o!==l)&&(t.resumeFrom=i,n&&(i.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),(a=t.root)!=null&&a.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var n,i,a,o,l;(i=(n=t.options).onExitComplete)==null||i.call(n),(l=(a=t.resumingFrom)==null?void 0:(o=a.options).onExitComplete)==null||l.call(o)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const Tp={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Bb=["","X","Y","Z"],Yz=1e3;let Kz=0;function kb(e,t,n,i){const{latestValues:a}=t;a[e]&&(n[e]=a[e],t.setStaticValue(e,0),i&&(i[e]=0))}function bC(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=F4(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",fn,!(a||o))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&bC(i)}function vC({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:a}){return class{constructor(l={},u=t==null?void 0:t()){this.id=Kz++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Jz),this.nodes.forEach(s7),this.nodes.forEach(a7),this.nodes.forEach($z)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let h=0;hthis.root.updateBlockedByResize=!1;fn.read(()=>{m=window.innerWidth}),e(l,()=>{const _=window.innerWidth;_!==m&&(m=_,this.root.updateBlockedByResize=!0,p&&p(),p=Xz(b,250),Tp.hasAnimatedSinceResize&&(Tp.hasAnimatedSinceResize=!1,this.nodes.forEach(NE)))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&d&&(u||h)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:m,hasRelativeLayoutChanged:b,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const S=this.options.transition||d.getDefaultTransition()||u7,{onLayoutAnimationStart:A,onLayoutAnimationComplete:x}=d.getProps(),y=!this.targetLayout||!pC(this.targetLayout,_),E=!m&&b;if(this.options.layoutRoot||this.resumeFrom||E||m&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...oy(S,"layout"),onPlay:A,onComplete:x};(d.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(p,E)}else m||NE(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=_})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),fo(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(r7),this.animationId++)}getTransformTemplate(){const{visualElement:l}=this.options;return l&&l.getProps().transformTemplate}willUpdate(l=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&bC(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Oi(this.snapshot.measuredBox.x)&&!Oi(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h{const P=T/1e3;UE(m.x,l.x,P),UE(m.y,l.y,P),this.setTargetDelta(m),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Xp(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),l7(this.relativeTarget,this.relativeTargetOrigin,b,P),w&&Fz(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=Kn()),Js(w,this.relativeTarget)),A&&(this.animationValues=p,zz(p,d,this.latestValues,P,E,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var u,h,d;this.notifyListeners("animationStart"),(u=this.currentAnimation)==null||u.stop(),(d=(h=this.resumingFrom)==null?void 0:h.currentAnimation)==null||d.stop(),this.pendingAnimation&&(fo(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=fn.update(()=>{Tp.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=$c(0)),this.motionValue.jump(0,!1),this.currentAnimation=Hz(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),l.onUpdate&&l.onUpdate(p)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Yz),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:u,target:h,layout:d,latestValues:p}=l;if(!(!u||!h||!d)){if(this!==l&&this.layout&&d&&_C(this.options.animationType,this.layout.layoutBox,d.layoutBox)){h=this.target||Kn();const m=Oi(this.layout.layoutBox.x);h.x.min=l.target.x.min,h.x.max=h.x.min+m;const b=Oi(this.layout.layoutBox.y);h.y.min=l.target.y.min,h.y.max=h.y.min+b}Js(u,h),Mp(u,p),zf(this.projectionDeltaWithTransform,this.layoutCorrected,u,p)}}registerSharedNode(l,u){this.sharedNodes.has(l)||this.sharedNodes.set(l,new qz),this.sharedNodes.get(l).add(u);const d=u.options.initialPromotionConfig;u.promote({transition:d?d.transition:void 0,preserveFollowOpacity:d&&d.shouldPreserveFollowOpacity?d.shouldPreserveFollowOpacity(u):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var u;const{layoutId:l}=this.options;return l?((u=this.getStack())==null?void 0:u.lead)||this:this}getPrevLead(){var u;const{layoutId:l}=this.options;return l?(u=this.getStack())==null?void 0:u.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:u,preserveFollowOpacity:h}={}){const d=this.getStack();d&&d.promote(this,h),l&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let u=!1;const{latestValues:h}=l;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(u=!0),!u)return;const d={};h.z&&kb("z",l,d,this.animationValues);for(let p=0;p{var u;return(u=l.currentAnimation)==null?void 0:u.stop()}),this.root.nodes.forEach(DE),this.root.sharedNodes.clear()}}}function Zz(e){e.updateLayout()}function Qz(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:a}=e.layout,{animationType:o}=e.options,l=t.source!==e.layout.source;if(o==="size")va(m=>{const b=l?t.measuredBox[m]:t.layoutBox[m],_=Oi(b);b.min=i[m].min,b.max=b.min+_});else if(o==="x"||o==="y"){const m=o==="x"?"y":"x";A1(l?t.measuredBox[m]:t.layoutBox[m],i[m])}else _C(o,t.layoutBox,i)&&va(m=>{const b=l?t.measuredBox[m]:t.layoutBox[m],_=Oi(i[m]);b.max=b.min+_,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[m].max=e.relativeTarget[m].min+_)});const u=Mc();zf(u,i,t.layoutBox);const h=Mc();l?zf(h,e.applyTransform(a,!0),t.measuredBox):zf(h,i,t.layoutBox);const d=!dC(u);let p=!1;if(!e.resumeFrom){const m=e.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:b,layout:_}=m;if(b&&_){const S=e.options.layoutAnchor||void 0,A=Kn();Xp(A,t.layoutBox,b.layoutBox,S);const x=Kn();Xp(x,i,_.layoutBox,S),pC(A,x)||(p=!0),m.options.layoutRoot&&(e.relativeTarget=x,e.relativeTargetOrigin=A,e.relativeParent=m)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:t,delta:h,layoutDelta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:p})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function Jz(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function $z(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function t7(e){e.clearSnapshot()}function DE(e){e.clearMeasurements()}function e7(e){e.isLayoutDirty=!0,e.updateLayout()}function LE(e){e.isLayoutDirty=!1}function n7(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function i7(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function NE(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function s7(e){e.resolveTargetDelta()}function a7(e){e.calcProjection()}function r7(e){e.resetSkewAndRotation()}function o7(e){e.removeLeadSnapshot()}function UE(e,t,n){e.translate=gn(t.translate,0,n),e.scale=gn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function PE(e,t,n,i){e.min=gn(t.min,n.min,i),e.max=gn(t.max,n.max,i)}function l7(e,t,n,i){PE(e.x,t.x,n.x,i),PE(e.y,t.y,n.y,i)}function c7(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const u7={duration:.45,ease:[.4,0,.1,1]},OE=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),IE=OE("applewebkit/")&&!OE("chrome/")?Math.round:zs;function FE(e){e.min=IE(e.min),e.max=IE(e.max)}function f7(e){FE(e.x),FE(e.y)}function _C(e,t,n){return e==="position"||e==="preserve-aspect"&&!Nz(TE(t),TE(n),.2)}function h7(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const d7=vC({attachResizeListener:(e,t)=>th(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),zb={current:void 0},yC=vC({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!zb.current){const e=new d7({});e.mount(window),e.setOptions({layoutScroll:!0}),zb.current=e}return zb.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),_y=pt.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function BE(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function p7(...e){return t=>{let n=!1;const i=e.map(a=>{const o=BE(a,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let a=0;a{const{width:_,height:S,top:A,left:x,right:y,bottom:E}=h.current;if(t||o===!1||!u.current||!_||!S)return;const w=n==="left"?`left: ${x}`:`right: ${y}`,T=i==="bottom"?`bottom: ${E}`:`top: ${A}`;u.current.dataset.motionPopId=l;const P=document.createElement("style");d&&(P.nonce=d);const O=a??document.head;return O.appendChild(P),P.sheet&&P.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${_}px !important; height: ${S}px !important; ${w}px !important; ${T}px !important; } `),()=>{var U;(U=u.current)==null||U.removeAttribute("data-motion-pop-id"),O.contains(P)&&O.removeChild(P)}},[t]),xt.jsx(g7,{isPresent:t,childRef:u,sizeRef:h,pop:o,children:o===!1?e:pt.cloneElement(e,{ref:m})})}const v7=({children:e,initial:t,isPresent:n,onExitComplete:i,custom:a,presenceAffectsLayout:o,mode:l,anchorX:u,anchorY:h,root:d})=>{const p=Y_(_7),m=pt.useId();let b=!0,_=pt.useMemo(()=>(b=!1,{id:m,initial:t,isPresent:n,custom:a,onExitComplete:S=>{p.set(S,!0);for(const A of p.values())if(!A)return;i&&i()},register:S=>(p.set(S,!1),()=>p.delete(S))}),[n,p,i]);return o&&b&&(_={..._}),pt.useMemo(()=>{p.forEach((S,A)=>p.set(A,!1))},[n]),pt.useEffect(()=>{!n&&!p.size&&i&&i()},[n]),e=xt.jsx(b7,{pop:l==="popLayout",isPresent:n,anchorX:u,anchorY:h,root:d,children:e}),xt.jsx(Sm.Provider,{value:_,children:e})};function _7(){return new Map}function xC(e=!0){const t=pt.useContext(Sm);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:a}=t,o=pt.useId();pt.useEffect(()=>{if(e)return a(o)},[e]);const l=pt.useCallback(()=>e&&i&&i(o),[o,i,e]);return!n&&i?[!1,l]:[!0]}const rp=e=>e.key||"";function kE(e){const t=[];return pt.Children.forEach(e,n=>{pt.isValidElement(n)&&t.push(n)}),t}const Vb=({children:e,custom:t,initial:n=!0,onExitComplete:i,presenceAffectsLayout:a=!0,mode:o="sync",propagate:l=!1,anchorX:u="left",anchorY:h="top",root:d})=>{const[p,m]=xC(l),b=pt.useMemo(()=>kE(e),[e]),_=l&&!p?[]:b.map(rp),S=pt.useRef(!0),A=pt.useRef(b),x=Y_(()=>new Map),y=pt.useRef(new Set),[E,w]=pt.useState(b),[T,P]=pt.useState(b);YR(()=>{S.current=!1,A.current=b;for(let I=0;I{const C=rp(I),R=l&&!p?!1:b===T||_.includes(C),F=()=>{if(y.current.has(C))return;if(x.has(C))y.current.add(C),x.set(C,!0);else return;let Y=!0;x.forEach($=>{$||(Y=!1)}),Y&&(U==null||U(),P(A.current),l&&(m==null||m()),i&&i())};return xt.jsx(v7,{isPresent:R,initial:!S.current||n?void 0:!1,custom:t,presenceAffectsLayout:a,mode:o,root:d,onExitComplete:R?void 0:F,anchorX:u,anchorY:h,children:I},C)})})},SC=pt.createContext({strict:!1}),zE={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let VE=!1;function y7(){if(VE)return;const e={};for(const t in zE)e[t]={isEnabled:n=>zE[t].some(i=>!!n[i])};Q4(e),VE=!0}function MC(){return y7(),sz()}function x7(e){const t=MC();for(const n in e)t[n]={...t[n],...e[n]};Q4(t)}const S7=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function qp(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||S7.has(e)}let AC=e=>!qp(e);function M7(e){typeof e=="function"&&(AC=t=>t.startsWith("on")?!qp(t):e(t))}try{M7(require("@emotion/is-prop-valid").default)}catch{}function A7(e,t,n){const i={};for(const a in e)a==="values"&&typeof e.values=="object"||bi(e[a])||(AC(a)||n===!0&&qp(a)||!t&&!qp(a)||e.draggable&&a.startsWith("onDrag"))&&(i[a]=e[a]);return i}const Em=pt.createContext({});function T7(e,t){if(Tm(e)){const{initial:n,animate:i}=e;return{initial:n===!1||$f(n)?n:void 0,animate:$f(i)?i:void 0}}return e.inherit!==!1?t:{}}function E7(e){const{initial:t,animate:n}=T7(e,pt.useContext(Em));return pt.useMemo(()=>({initial:t,animate:n}),[GE(t),GE(n)])}function GE(e){return Array.isArray(e)?e.join(" "):e}const yy=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function TC(e,t,n){for(const i in t)!bi(t[i])&&!sC(i,n)&&(e[i]=t[i])}function w7({transformTemplate:e},t){return pt.useMemo(()=>{const n=yy();return by(n,t,e),Object.assign({},n.vars,n.style)},[t])}function R7(e,t){const n=e.style||{},i={};return TC(i,n,e),Object.assign(i,w7(e,t)),i}function C7(e,t){const n={},i=R7(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=i,n}const EC=()=>({...yy(),attrs:{}});function D7(e,t,n,i){const a=pt.useMemo(()=>{const o=EC();return aC(o,t,oC(i),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};TC(o,e.style,e),a.style={...o,...a.style}}return a}const L7=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function xy(e){return typeof e!="string"||e.includes("-")?!1:!!(L7.indexOf(e)>-1||/[A-Z]/u.test(e))}function N7(e,t,n,{latestValues:i},a,o=!1,l){const h=(l??xy(e)?D7:C7)(t,i,a,e),d=A7(t,typeof e=="string",o),p=e!==pt.Fragment?{...d,...h,ref:n}:{},{children:m}=t,b=pt.useMemo(()=>bi(m)?m.get():m,[m]);return pt.createElement(e,{...p,children:b})}function U7({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,a){return{latestValues:P7(n,i,a,e),renderState:t()}}function P7(e,t,n,i){const a={},o=i(e,{});for(const b in o)a[b]=Ap(o[b]);let{initial:l,animate:u}=e;const h=Tm(e),d=K4(e);t&&d&&!h&&e.inherit!==!1&&(l===void 0&&(l=t.initial),u===void 0&&(u=t.animate));let p=n?n.initial===!1:!1;p=p||l===!1;const m=p?u:l;if(m&&typeof m!="boolean"&&!Am(m)){const b=Array.isArray(m)?m:[m];for(let _=0;_(t,n)=>{const i=pt.useContext(Em),a=pt.useContext(Sm),o=()=>U7(e,t,i,a);return n?o():Y_(o)},O7=wC({scrapeMotionValuesFromProps:vy,createRenderState:yy}),I7=wC({scrapeMotionValuesFromProps:lC,createRenderState:EC}),F7=Symbol.for("motionComponentSymbol");function B7(e,t,n){const i=pt.useRef(n);pt.useInsertionEffect(()=>{i.current=n});const a=pt.useRef(null);return pt.useCallback(o=>{var u;o&&((u=e.onMount)==null||u.call(e,o));const l=i.current;if(typeof l=="function")if(o){const h=l(o);typeof h=="function"&&(a.current=h)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);t&&(o?t.mount(o):t.unmount())},[t])}const RC=pt.createContext({});function gc(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function k7(e,t,n,i,a,o){var w,T;const{visualElement:l}=pt.useContext(Em),u=pt.useContext(SC),h=pt.useContext(Sm),d=pt.useContext(_y),p=d.reducedMotion,m=d.skipAnimations,b=pt.useRef(null),_=pt.useRef(!1);i=i||u.renderer,!b.current&&i&&(b.current=i(e,{visualState:t,parent:l,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:p,skipAnimations:m,isSVG:o}),_.current&&b.current&&(b.current.manuallyAnimateOnMount=!0));const S=b.current,A=pt.useContext(RC);S&&!S.projection&&a&&(S.type==="html"||S.type==="svg")&&z7(b.current,n,a,A);const x=pt.useRef(!1);pt.useInsertionEffect(()=>{S&&x.current&&S.update(n,h)});const y=n[I4],E=pt.useRef(!!y&&typeof window<"u"&&!((w=window.MotionHandoffIsComplete)!=null&&w.call(window,y))&&((T=window.MotionHasOptimisedAnimation)==null?void 0:T.call(window,y)));return YR(()=>{_.current=!0,S&&(x.current=!0,window.MotionIsMounted=!0,S.updateFeatures(),S.scheduleRenderMicrotask(),E.current&&S.animationState&&S.animationState.animateChanges())}),pt.useEffect(()=>{S&&(!E.current&&S.animationState&&S.animationState.animateChanges(),E.current&&(queueMicrotask(()=>{var P;(P=window.MotionHandoffMarkAsComplete)==null||P.call(window,y)}),E.current=!1),S.enteringChildren=void 0)}),S}function z7(e,t,n,i){const{layoutId:a,layout:o,drag:l,dragConstraints:u,layoutScroll:h,layoutRoot:d,layoutAnchor:p,layoutCrossfade:m}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:CC(e.parent)),e.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||u&&gc(u),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:i,crossfade:m,layoutScroll:h,layoutRoot:d,layoutAnchor:p})}function CC(e){if(e)return e.options.allowProjection!==!1?e.projection:CC(e.parent)}function Gb(e,{forwardMotionProps:t=!1,type:n}={},i,a){i&&x7(i);const o=n?n==="svg":xy(e),l=o?I7:O7;function u(d,p){let m;const b={...pt.useContext(_y),...d,layoutId:V7(d)},{isStatic:_}=b,S=E7(d),A=l(d,_);if(!_&&typeof window<"u"){G7();const x=H7(b);m=x.MeasureLayout,S.visualElement=k7(e,A,b,a,x.ProjectionNode,o)}return xt.jsxs(Em.Provider,{value:S,children:[m&&S.visualElement?xt.jsx(m,{visualElement:S.visualElement,...b}):null,N7(e,d,B7(A,S.visualElement,p),A,_,t,o)]})}u.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=pt.forwardRef(u);return h[F7]=e,h}function V7({layoutId:e}){const t=pt.useContext(q_).id;return t&&e!==void 0?t+"-"+e:e}function G7(e,t){pt.useContext(SC).strict}function H7(e){const t=MC(),{drag:n,layout:i}=t;if(!n&&!i)return{};const a={...n,...i};return{MeasureLayout:n!=null&&n.isEnabled(e)||i!=null&&i.isEnabled(e)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}function j7(e,t){if(typeof Proxy>"u")return Gb;const n=new Map,i=(o,l)=>Gb(o,l,e,t),a=(o,l)=>i(o,l);return new Proxy(a,{get:(o,l)=>l==="create"?i:(n.has(l)||n.set(l,Gb(l,void 0,e,t)),n.get(l))})}const W7=(e,t)=>t.isSVG??xy(e)?new xz(t):new mz(t,{allowProjection:e!==pt.Fragment});class X7 extends po{constructor(t){super(t),t.animationState||(t.animationState=Ez(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Am(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let q7=0;class Y7 extends po{constructor(){super(...arguments),this.id=q7++,this.isExitComplete=!1}update(){var o;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;if(t&&i===!1){if(this.isExitComplete){const{initial:l,custom:u}=this.node.getProps();if(typeof l=="string"){const h=ll(this.node,l,u);if(h){const{transition:d,transitionEnd:p,...m}=h;for(const b in m)(o=this.node.getValue(b))==null||o.jump(m[b])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const a=this.node.animationState.setActive("exit",!t);n&&!t&&a.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const K7={animation:{Feature:X7},exit:{Feature:Y7}};function ph(e){return{point:{x:e.pageX,y:e.pageY}}}const Z7=e=>t=>dy(t)&&e(t,ph(t));function Vf(e,t,n,i){return th(e,t,Z7(n),i)}const DC=({current:e})=>e?e.ownerDocument.defaultView:null,HE=(e,t)=>Math.abs(e-t);function Q7(e,t){const n=HE(e.x,t.x),i=HE(e.y,t.y);return Math.sqrt(n**2+i**2)}const jE=new Set(["auto","scroll"]);class LC{constructor(t,n,{transformPagePoint:i,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:l=3,element:u}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=_=>{this.handleScroll(_.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=op(this.lastRawMoveEventInfo,this.transformPagePoint));const _=Hb(this.lastMoveEventInfo,this.history),S=this.startEvent!==null,A=Q7(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!S&&!A)return;const{point:x}=_,{timestamp:y}=gi;this.history.push({...x,timestamp:y});const{onStart:E,onMove:w}=this.handlers;S||(E&&E(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,_)},this.handlePointerMove=(_,S)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=S,this.lastMoveEventInfo=op(S,this.transformPagePoint),fn.update(this.updatePoint,!0)},this.handlePointerUp=(_,S)=>{this.end();const{onEnd:A,onSessionEnd:x,resumeAnimation:y}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&y&&y(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=Hb(_.type==="pointercancel"?this.lastMoveEventInfo:op(S,this.transformPagePoint),this.history);this.startEvent&&A&&A(_,E),x&&x(_,E)},!dy(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=l,this.contextWindow=a||window;const h=ph(t),d=op(h,this.transformPagePoint),{point:p}=d,{timestamp:m}=gi;this.history=[{...p,timestamp:m}];const{onSessionStart:b}=n;b&&b(t,Hb(d,this.history)),this.removeListeners=fh(Vf(this.contextWindow,"pointermove",this.handlePointerMove),Vf(this.contextWindow,"pointerup",this.handlePointerUp),Vf(this.contextWindow,"pointercancel",this.handlePointerUp)),u&&this.startScrollTracking(u)}startScrollTracking(t){let n=t.parentElement;for(;n;){const i=getComputedStyle(n);(jE.has(i.overflowX)||jE.has(i.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const i=t===window,a=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:a.x-n.x,y:a.y-n.y};o.x===0&&o.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(t,a),fn.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),fo(this.updatePoint)}}function op(e,t){return t?{point:t(e.point)}:e}function WE(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Hb({point:e},t){return{point:e,delta:WE(e,NC(t)),offset:WE(e,J7(t)),velocity:$7(t,.1)}}function J7(e){return e[0]}function NC(e){return e[e.length-1]}function $7(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const a=NC(e);for(;n>=0&&(i=e[n],!(a.timestamp-i.timestamp>bs(t)));)n--;if(!i)return{x:0,y:0};i===e[0]&&e.length>2&&a.timestamp-i.timestamp>bs(t)*2&&(i=e[1]);const o=ks(a.timestamp-i.timestamp);if(o===0)return{x:0,y:0};const l={x:(a.x-i.x)/o,y:(a.y-i.y)/o};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function tV(e,{min:t,max:n},i){return t!==void 0&&en&&(e=i?gn(n,e,i.max):Math.min(e,n)),e}function XE(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function eV(e,{top:t,left:n,bottom:i,right:a}){return{x:XE(e.x,n,a),y:XE(e.y,t,i)}}function qE(e,t){let n=t.min-e.min,i=t.max-e.max;return t.max-t.mini?n=Qf(t.min,t.max-i,e.min):i>a&&(n=Qf(e.min,e.max-a,t.min)),wa(0,1,n)}function sV(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const T1=.35;function aV(e=T1){return e===!1?e=0:e===!0&&(e=T1),{x:YE(e,"left","right"),y:YE(e,"top","bottom")}}function YE(e,t,n){return{min:KE(e,t),max:KE(e,n)}}function KE(e,t){return typeof e=="number"?e:e[t]||0}const rV=new WeakMap;class oV{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Kn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=m=>{n&&this.snapToCursor(ph(m).point),this.stopAnimation()},l=(m,b)=>{const{drag:_,dragPropagation:S,onDragStart:A}=this.getProps();if(_&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Pk(_),!this.openDragLock))return;this.latestPointerEvent=m,this.latestPanInfo=b,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),va(y=>{let E=this.getAxisMotionValue(y).get()||0;if(Aa.test(E)){const{projection:w}=this.visualElement;if(w&&w.layout){const T=w.layout.layoutBox[y];T&&(E=Oi(T)*(parseFloat(E)/100))}}this.originPoint[y]=E}),A&&fn.update(()=>A(m,b),!1,!0),g1(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},u=(m,b)=>{this.latestPointerEvent=m,this.latestPanInfo=b;const{dragPropagation:_,dragDirectionLock:S,onDirectionLock:A,onDrag:x}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:y}=b;if(S&&this.currentDirection===null){this.currentDirection=cV(y),this.currentDirection!==null&&A&&A(this.currentDirection);return}this.updateAxis("x",b.point,y),this.updateAxis("y",b.point,y),this.visualElement.render(),x&&fn.update(()=>x(m,b),!1,!0)},h=(m,b)=>{this.latestPointerEvent=m,this.latestPanInfo=b,this.stop(m,b),this.latestPointerEvent=null,this.latestPanInfo=null},d=()=>{const{dragSnapToOrigin:m}=this.getProps();(m||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new LC(t,{onSessionStart:o,onStart:l,onMove:u,onSessionEnd:h,resumeAnimation:d},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:i,contextWindow:DC(this.visualElement),element:this.visualElement.current})}stop(t,n){const i=t||this.latestPointerEvent,a=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!a||!i)return;const{velocity:l}=a;this.startAnimation(l);const{onDragEnd:u}=this.getProps();u&&fn.postRender(()=>u(i,a))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,i){const{drag:a}=this.getProps();if(!i||!lp(t,a,this.currentDirection))return;const o=this.getAxisMotionValue(t);let l=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(l=tV(l,this.constraints[t],this.elastic[t])),o.set(l)}resolveConstraints(){var o;const{dragConstraints:t,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,a=this.constraints;t&&gc(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=eV(i.layoutBox,t):this.constraints=!1,this.elastic=aV(n),a!==this.constraints&&!gc(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&va(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=sV(i.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!gc(t))return!1;const i=t.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=cz(i,a.root,this.visualElement.getTransformPagePoint());let l=nV(a.layout.layoutBox,o);if(n){const u=n(rz(l));this.hasMutatedConstraints=!!u,u&&(l=$4(u))}return l}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:u}=this.getProps(),h=this.constraints||{},d=va(p=>{if(!lp(p,n,this.currentDirection))return;let m=h&&h[p]||{};(l===!0||l===p)&&(m={min:0,max:0});const b=a?200:1e6,_=a?40:1e7,S={type:"inertia",velocity:i?t[p]:0,bounceStiffness:b,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...m};return this.startAxisValueAnimation(p,S)});return Promise.all(d).then(u)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return g1(this.visualElement,t),i.start(ly(t,i,0,n,this.visualElement,!1))}stopAnimation(){va(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),a=i[n];return a||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){va(n=>{const{drag:i}=this.getProps();if(!lp(n,i,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(n);if(a&&a.layout){const{min:l,max:u}=a.layout.layoutBox[n],h=o.get()||0;o.set(t[n]-gn(l,u,.5)+h)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!gc(n)||!i||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};va(l=>{const u=this.getAxisMotionValue(l);if(u&&this.constraints!==!1){const h=u.get();a[l]=iV({min:h,max:h},this.constraints[l])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),va(l=>{if(!lp(l,t,null))return;const u=this.getAxisMotionValue(l),{min:h,max:d}=this.constraints[l];u.set(gn(h,d,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;rV.set(this.visualElement,this);const t=this.visualElement.current,n=Vf(t,"pointerdown",d=>{const{drag:p,dragListener:m=!0}=this.getProps(),b=d.target,_=b!==t&&zk(b);p&&m&&!_&&this.start(d)});let i;const a=()=>{const{dragConstraints:d}=this.getProps();gc(d)&&d.current&&(this.constraints=this.resolveRefConstraints(),i||(i=lV(t,d.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),fn.read(a);const u=th(window,"resize",()=>this.scalePositionWithinConstraints()),h=o.addEventListener("didUpdate",(({delta:d,hasLayoutChanged:p})=>{this.isDragging&&p&&(va(m=>{const b=this.getAxisMotionValue(m);b&&(this.originPoint[m]+=d[m].translate,b.set(b.get()+d[m].translate))}),this.visualElement.render())}));return()=>{u(),n(),l(),h&&h(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=T1,dragMomentum:u=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:u}}}function ZE(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function lV(e,t,n){const i=iE(e,ZE(n)),a=iE(t,ZE(n));return()=>{i(),a()}}function lp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function cV(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class uV extends po{constructor(t){super(t),this.removeGroupControls=zs,this.removeListeners=zs,this.controls=new oV(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||zs}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const jb=e=>(t,n)=>{e&&fn.update(()=>e(t,n),!1,!0)};class fV extends po{constructor(){super(...arguments),this.removePointerDownListener=zs}onPointerDown(t){this.session=new LC(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:DC(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:a}=this.node.getProps();return{onSessionStart:jb(t),onStart:jb(n),onMove:jb(i),onEnd:(o,l)=>{delete this.session,a&&fn.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=Vf(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Wb=!1;class hV extends pt.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:a}=this.props,{projection:o}=t;o&&(n.group&&n.group.add(o),i&&i.register&&a&&i.register(o),Wb&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Tp.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:a,isPresent:o}=this.props,{projection:l}=i;return l&&(l.isPresent=o,t.layoutDependency!==n&&l.setOptions({...l.options,layoutDependency:n}),Wb=!0,a||t.layoutDependency!==n||n===void 0||t.isPresent!==o?l.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?l.promote():l.relegate()||fn.postRender(()=>{const u=l.getStack();(!u||!u.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:i}=t;i&&(i.options.layoutAnchor=n,i.root.didUpdate(),hy.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:a}=t;Wb=!0,a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),i&&i.deregister&&i.deregister(a))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function UC(e){const[t,n]=xC(),i=pt.useContext(q_);return xt.jsx(hV,{...e,layoutGroup:i,switchLayoutGroup:pt.useContext(RC),isPresent:t,safeToRemove:n})}const dV={pan:{Feature:fV},drag:{Feature:uV,ProjectionNode:yC,MeasureLayout:UC}};function QE(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,o=i[a];o&&fn.postRender(()=>o(t,ph(t)))}class pV extends po{mount(){const{current:t}=this.node;t&&(this.unmount=Ik(t,(n,i)=>(QE(this.node,i,"Start"),a=>QE(this.node,a,"End"))))}unmount(){}}class mV extends po{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=fh(th(this.node.current,"focus",()=>this.onFocus()),th(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function JE(e,t,n){const{props:i}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),o=i[a];o&&fn.postRender(()=>o(t,ph(t)))}class gV extends po{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:i}=this.node.props;this.unmount=Gk(t,(a,o)=>(JE(this.node,o,"Start"),(l,{success:u})=>JE(this.node,l,u?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(i==null?void 0:i.tap)===!1})}unmount(){}}const E1=new WeakMap,Xb=new WeakMap,bV=e=>{const t=E1.get(e.target);t&&t(e)},vV=e=>{e.forEach(bV)};function _V({root:e,...t}){const n=e||document;Xb.has(n)||Xb.set(n,{});const i=Xb.get(n),a=JSON.stringify(t);return i[a]||(i[a]=new IntersectionObserver(vV,{root:e,...t})),i[a]}function yV(e,t,n){const i=_V(t);return E1.set(e,n),i.observe(e),()=>{E1.delete(e),i.unobserve(e)}}const xV={some:0,all:1};class SV extends po{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var h;(h=this.stopObserver)==null||h.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:i,amount:a="some",once:o}=t,l={root:n?n.current:void 0,rootMargin:i,threshold:typeof a=="number"?a:xV[a]},u=d=>{const{isIntersecting:p}=d;if(this.isInView===p||(this.isInView=p,o&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:m,onViewportLeave:b}=this.node.getProps(),_=p?m:b;_&&_(d)};this.stopObserver=yV(this.node.current,l,u)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(MV(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function MV({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const AV={inView:{Feature:SV},tap:{Feature:gV},focus:{Feature:mV},hover:{Feature:pV}},TV={layout:{ProjectionNode:yC,MeasureLayout:UC}},EV={...K7,...AV,...dV,...TV},qb=j7(EV,W7);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wV=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),RV=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,i)=>i?i.toUpperCase():n.toLowerCase()),$E=e=>{const t=RV(e);return t.charAt(0).toUpperCase()+t.slice(1)},PC=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim(),CV=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var DV={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LV=pt.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:a="",children:o,iconNode:l,...u},h)=>pt.createElement("svg",{ref:h,...DV,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:PC("lucide",a),...!o&&!CV(u)&&{"aria-hidden":"true"},...u},[...l.map(([d,p])=>pt.createElement(d,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sy=(e,t)=>{const n=pt.forwardRef(({className:i,...a},o)=>pt.createElement(LV,{ref:o,iconNode:t,className:PC(`lucide-${wV($E(e))}`,`lucide-${e}`,i),...a}));return n.displayName=$E(e),n};/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NV=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],UV=Sy("play",NV);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PV=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],OV=Sy("rotate-ccw",PV);/** * @license lucide-react v0.546.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IV=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],FV=Sy("shield",IV);function BV(e){const t=[...e];for(let i=t.length-1;i>0;i--){const a=Math.floor(Math.random()*(i+1));[t[i],t[a]]=[t[a],t[i]]}const n=t.indexOf(e[0]);return{options:t,correctZone:n}}function kV(e){let t="",n=0,i=0,a=0;if(e===1)if(Math.random()>.5){const p=Math.floor(Math.random()*10)+1,m=Math.floor(Math.random()*10)+1;t=`${p} + ${m} = ?`,n=p+m}else{let p=Math.floor(Math.random()*10)+5,m=Math.floor(Math.random()*p)+1;t=`${p} - ${m} = ?`,n=p-m}else if(e===1.5){const d=Math.floor(Math.random()*3);if(d===0){const p=Math.floor(Math.random()*40)+10,m=Math.floor(Math.random()*40)+10;t=`${p} + ${m} = ?`,n=p+m}else if(d===1){const p=Math.floor(Math.random()*50)+20,m=Math.floor(Math.random()*20)+5;t=`${p} - ${m} = ?`,n=p-m}else{const p=Math.floor(Math.random()*9)+2,m=Math.floor(Math.random()*9)+2;t=`${p} ร— ${m} = ?`,n=p*m}}else{const d=Math.floor(Math.random()*3);if(d===0){const p=Math.floor(Math.random()*10)+5,m=Math.floor(Math.random()*15)+5;t=`${p} ร— ${m} = ?`,n=p*m}else if(d===1){const p=Math.floor(Math.random()*10)+3,m=Math.floor(Math.random()*10)+3;t=`${p*m} รท ${p} = ?`,n=m}else{const p=Math.floor(Math.random()*10)+2,m=Math.floor(Math.random()*10)+2,b=p*m;t=`${p}x = ${b}, x = ?`,n=m}}let o=Math.floor(Math.random()*3)+1,l=Math.floor(Math.random()*3)+1;Math.random()>.5&&(o*=-1),Math.random()>.5&&(l*=-1),i=n+o,a=n+l*2,i===a&&(a+=1),i===n&&(i+=1),a===n&&(a-=1);const{options:u,correctZone:h}=BV([n,i,a]);return{question:t,correctAnswer:n,options:u,correctZone:h}}const ds=new(window.AudioContext||window.webkitAudioContext);let Mf=null;function Af(e){if(ds.state==="suspended"&&ds.resume(),e==="BGM_START"){if(Mf)return;const a=[220,261.63,329.63,440,392,329.63,261.63,196];let o=0;Mf=setInterval(()=>{const l=ds.currentTime,u=ds.createOscillator(),h=ds.createGain();u.type="sawtooth",u.frequency.setValueAtTime(a[o%a.length]/2,l),h.gain.setValueAtTime(.04,l),h.gain.exponentialRampToValueAtTime(.001,l+.2);const d=ds.createBiquadFilter();d.type="lowpass",d.frequency.setValueAtTime(600,l),d.frequency.exponentialRampToValueAtTime(100,l+.2),u.connect(d),d.connect(h),h.connect(ds.destination),u.start(l),u.stop(l+.2),o++},280);return}if(e==="BGM_STOP"){Mf&&(clearInterval(Mf),Mf=null);return}const t=ds.createOscillator(),n=ds.createGain();t.connect(n),n.connect(ds.destination);const i=ds.currentTime;if(e==="SAVE")t.type="sine",t.frequency.setValueAtTime(400,i),t.frequency.exponentialRampToValueAtTime(800,i+.1),n.gain.setValueAtTime(.5,i),n.gain.exponentialRampToValueAtTime(.01,i+.1),t.start(i),t.stop(i+.1);else if(e==="SUPER_SAVE"){t.type="sawtooth",t.frequency.setValueAtTime(150,i),t.frequency.exponentialRampToValueAtTime(800,i+.3);const a=ds.createOscillator();a.type="square",a.frequency.setValueAtTime(200,i),a.frequency.exponentialRampToValueAtTime(1e3,i+.3),a.connect(n),a.start(i),a.stop(i+.3),n.gain.setValueAtTime(.8,i),n.gain.exponentialRampToValueAtTime(.01,i+.3),t.start(i),t.stop(i+.3)}else if(e==="GOAL")t.type="square",t.frequency.setValueAtTime(200,i),t.frequency.exponentialRampToValueAtTime(50,i+.4),n.gain.setValueAtTime(.5,i),n.gain.exponentialRampToValueAtTime(.01,i+.4),t.start(i),t.stop(i+.4);else if(e==="KICK")t.type="triangle",t.frequency.setValueAtTime(150,i),t.frequency.exponentialRampToValueAtTime(10,i+.3),n.gain.setValueAtTime(1,i),n.gain.exponentialRampToValueAtTime(.01,i+.3),t.start(i),t.stop(i+.3);else if(e==="WHOOSH"){const a=ds.createOscillator();t.type="sine",a.type="square",t.frequency.setValueAtTime(800,i),t.frequency.exponentialRampToValueAtTime(100,i+.3),a.frequency.setValueAtTime(1200,i),a.frequency.exponentialRampToValueAtTime(200,i+.3),a.connect(n),n.gain.setValueAtTime(.2,i),n.gain.exponentialRampToValueAtTime(.01,i+.3),t.start(i),t.stop(i+.3),a.start(i),a.stop(i+.3)}}const t3=[{id:"1",name:"WAKABAYASHI",score:25500},{id:"2",name:"MULLER",score:21e3},{id:"3",name:"WAKASHIMAZU",score:18500},{id:"4",name:"HERNANDEZ",score:15e3},{id:"5",name:"MORISAKI",score:12500}],e3={left:{scale:.42,forwardMul:.02,sideMul:-.015,offsetX:0,offsetY:0,offsetZ:0,rotationDeg:0},right:{scale:.42,forwardMul:.02,sideMul:.015,offsetX:0,offsetY:0,offsetZ:0,rotationDeg:0}},zV=(e,t,n)=>Math.min(n,Math.max(t,e)),OC="ar-goalkeeper-glove-calibration-v1",IC=()=>({left:{...e3.left},right:{...e3.right}}),Ho=(e,t,n,i)=>{const a=Number(e);return Number.isFinite(a)?zV(a,n,i):t},VV=e=>{const t=IC(),n=e&&typeof e=="object"?e:{},i=a=>{const o=n[a]&&typeof n[a]=="object"?n[a]:{},l=t[a];return{scale:Ho(o.scale,l.scale,.2,.9),forwardMul:Ho(o.forwardMul,l.forwardMul,-.2,.2),sideMul:Ho(o.sideMul,l.sideMul,-.2,.2),offsetX:Ho(o.offsetX,l.offsetX,-.2,.2),offsetY:Ho(o.offsetY,l.offsetY,-.2,.2),offsetZ:Ho(o.offsetZ,l.offsetZ,-.2,.2),rotationDeg:Ho(o.rotationDeg,l.rotationDeg,-180,180)}};return{left:i("left"),right:i("right")}},GV=()=>{const e={gloveStaticWrap:!0,swapGloveHands:!1,gloveTrackingMode:"both",manualCalibration:IC()};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(OC);if(!t)return e;const n=JSON.parse(t),i=n.gloveTrackingMode==="right-only"?"right-only":"both";return{gloveStaticWrap:!!n.gloveStaticWrap,swapGloveHands:!!n.swapGloveHands,gloveTrackingMode:i,manualCalibration:VV(n.manualCalibration)}}catch(t){return console.warn("Failed to parse saved glove calibration, using defaults.",t),e}};function HV(){const e=pt.useRef(GV()),t=pt.useRef(null),n=pt.useRef(null),i=pt.useRef(null),a=pt.useRef(null),o=pt.useRef(null),l=pt.useRef(null),[u,h]=pt.useState([]),[d,p]=pt.useState(!1),[m,b]=pt.useState("IDLE"),_=pt.useRef("IDLE"),[S,A]=pt.useState(1),x=pt.useRef(1),[y,E]=pt.useState(0),[w,T]=pt.useState(0),[P,O]=pt.useState(0),U=pt.useRef(0),[I,C]=pt.useState(null),[R,F]=pt.useState(null),Y=pt.useRef(null),[$,lt]=pt.useState(!1),[ut,k]=pt.useState(e.current.gloveStaticWrap),[Q,X]=pt.useState(e.current.swapGloveHands),[yt,At]=pt.useState(""),[z,it]=pt.useState(!1),[Tt,J]=pt.useState("right"),[ht,Et]=pt.useState(e.current.gloveTrackingMode),Mt=pt.useRef(e.current.gloveTrackingMode),[Ht,ee]=pt.useState({leftDetected:!1,rightDetected:!1}),[oe,on]=pt.useState(!1),[$e,Me]=pt.useState(!1),[G,ii]=pt.useState(e.current.manualCalibration),me=pt.useRef({leftDetected:!1,rightDetected:!1}),Se=pt.useRef(e.current.swapGloveHands);pt.useRef(null),pt.useRef(null);const Zt=pt.useRef(!1),[He,Yt]=pt.useState(!1),[B,L]=pt.useState(!1),[nt,dt]=pt.useState(null),[St,bt]=pt.useState(!1),kt=pt.useRef(null),Pt=pt.useRef(-1);pt.useEffect(()=>{async function mt(){const Ut=await mc.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.21/wasm");l.current=await Yi.createFromOptions(Ut,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/1/pose_landmarker_lite.task",delegate:"GPU"},runningMode:"VIDEO",numPoses:1});let Vt=null;if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)try{Vt=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:640,height:480}}),t.current&&(t.current.srcObject=Vt,t.current.play().catch(Lt=>{Lt.name!=="AbortError"&&console.error("Error playing video:",Lt)})),n.current&&(n.current.srcObject=Vt,n.current.play().catch(Lt=>{Lt.name!=="AbortError"&&console.error("Error playing preview:",Lt)}))}catch(Lt){console.error("Camera access denied:",Lt),dt("Camera access denied. Please allow camera permissions in your browser or open the app in a new tab.")}if(i.current&&!o.current){o.current=new W8(i.current,()=>{var j;return ye((j=o.current)!=null&&j.isSuperBall?"SUPER_SAVE":"SAVE")},()=>ye("GOAL"));const Lt=e.current;o.current.setGloveStaticWrap(Lt.gloveStaticWrap),o.current.setSwapGloveHands(Lt.swapGloveHands),o.current.setGloveTrackingMode(Lt.gloveTrackingMode),o.current.setGloveCalibration("left",{scale:Lt.manualCalibration.left.scale,forwardMul:Lt.manualCalibration.left.forwardMul,sideMul:Lt.manualCalibration.left.sideMul,offsetX:Lt.manualCalibration.left.offsetX,offsetY:Lt.manualCalibration.left.offsetY,offsetZ:Lt.manualCalibration.left.offsetZ,rotationFine:Ki.degToRad(Lt.manualCalibration.left.rotationDeg)}),o.current.setGloveCalibration("right",{scale:Lt.manualCalibration.right.scale,forwardMul:Lt.manualCalibration.right.forwardMul,sideMul:Lt.manualCalibration.right.sideMul,offsetX:Lt.manualCalibration.right.offsetX,offsetY:Lt.manualCalibration.right.offsetY,offsetZ:Lt.manualCalibration.right.offsetZ,rotationFine:Ki.degToRad(Lt.manualCalibration.right.rotationDeg)}),k(Lt.gloveStaticWrap),X(Lt.swapGloveHands),Et(Lt.gloveTrackingMode),ii({left:{...Lt.manualCalibration.left},right:{...Lt.manualCalibration.right}}),Se.current=Lt.swapGloveHands,Mt.current=Lt.gloveTrackingMode}p(!0)}return mt(),()=>{var Ut,Vt;(Ut=o.current)==null||Ut.cleanup(),(Vt=l.current)==null||Vt.close(),t.current&&t.current.srcObject&&(t.current.srcObject.getTracks().forEach(j=>j.stop()),t.current.srcObject=null)}},[]),pt.useEffect(()=>{try{const mt={gloveStaticWrap:ut,swapGloveHands:Q,gloveTrackingMode:ht,manualCalibration:{left:{...G.left},right:{...G.right}}};window.localStorage.setItem(OC,JSON.stringify(mt)),e.current=mt}catch(mt){console.warn("Failed to save glove calibration.",mt)}},[ut,Q,ht,G]);const zt=()=>{if(_.current!=="PLAYING"||!o.current||U.current>=10)return;const mt=kV(x.current);F(mt),Y.current=mt,o.current.shootBall(x.current,mt.correctZone);const Ut=o.current.isSuperBall;Yt(Ut),Ut&&(L(!0),setTimeout(()=>L(!1),500)),Af("KICK"),Ut&&Af("WHOOSH")},ye=mt=>{Af(mt),o.current&&o.current.hideTrails();let Ut="";if(Y.current){const Vt=Y.current.options[Y.current.correctZone];Ut=mt==="GOAL"?`Miss... = ${Vt}`:`Correct! = ${Vt}`}else Ut=mt==="SAVE"?"SAVE!":mt==="SUPER_SAVE"?"SUPER SAVE!!":"GOAL!";if(mt==="SAVE"||mt==="SUPER_SAVE"){const Vt=mt==="SAVE"?100:300;E(Lt=>Lt+Vt*x.current)}else T(Vt=>Vt+1);O(Vt=>{const Lt=Vt+1;return U.current=Lt,Lt}),C({text:Ut,type:mt}),setTimeout(()=>C(null),1e3),setTimeout(zt,2e3)};pt.useEffect(()=>{const mt=()=>{a.current&&(a.current.width=window.innerWidth,a.current.height=window.innerHeight)};window.addEventListener("resize",mt),mt();let Ut;const Vt=()=>{if(t.current&&l.current&&t.current.readyState>=2){const Lt=performance.now();if(Pt.current!==t.current.currentTime){Pt.current=t.current.currentTime;const j=l.current.detectForVideo(t.current,Lt);if(j.landmarks&&j.landmarks[0]?kt.current=j.landmarks[0]:kt.current=null,o.current){o.current.updateGloveLandmarks(kt.current);const Ct=o.current.getHandDetectionStatus(kt.current);(Ct.leftDetected!==me.current.leftDetected||Ct.rightDetected!==me.current.rightDetected)&&(me.current=Ct,ee(Ct))}if(!Zt.current&&kt.current&&o.current&&o.current.calibrateGloves(kt.current)){Zt.current=!0;const ot=o.current.getSwapGloveHands();X(ot),Se.current=ot,At(ot?"Gloves calibrated (mapping swapped)":"Gloves calibrated"),setTimeout(()=>At(""),1600)}}}if(o.current&&_.current==="PLAYING"){const Lt=o.current.getBallScreenPosition();if(Lt){const j=Lt.x,Ct=Lt.y;let ot=!1;const vt=kt.current;if(vt){const wt=[15,17,19,21],Nt=[16,18,20,22],ne=ln=>ln.reduce((bn,Oa)=>{const fa=vt[Oa];return fa?bn+(fa.visibility??1):bn},0);let je=[...wt,...Nt];const hn=Mt.current;if(hn==="right-only"){const ln=ne(Nt),bn=ne(wt);ln<=.01&&bn<=.01?je=[...Nt,...wt]:je=ln>=bn?Nt:wt}const Te=hn==="right-only"?.2:.15;for(const ln of je){const bn=vt[ln];if(!bn||(bn.visibility??1)<.12)continue;const Oa=1-bn.x,fa=bn.y;if(Math.hypot(Oa-j,fa-Ct){cancelAnimationFrame(Ut),window.removeEventListener("resize",mt)}},[S]);const Dt=mt=>{try{const Ut=JSON.parse(localStorage.getItem("ar-goalkeeper-scores")||"[]");mt&&mt>0&&(Ut.push({id:Date.now().toString(),name:"YOU",score:mt,isYou:!0}),Ut.sort((Lt,j)=>j.score-Lt.score),localStorage.setItem("ar-goalkeeper-scores",JSON.stringify(Ut.slice(0,10))));const Vt=[...t3,...Ut];Vt.sort((Lt,j)=>j.score-Lt.score),h(Vt.slice(0,5))}catch(Ut){console.error(Ut),h(t3)}};pt.useEffect(()=>{Dt()},[]),pt.useEffect(()=>{P>=10&&m==="PLAYING"&&(b("GAMEOVER"),_.current="GAMEOVER",Af("BGM_STOP"),o.current&&(o.current.isBallActive=!1),Dt(y))},[P,y,m]);const Gt=mt=>{A(mt),x.current=mt},te=()=>{E(0),T(0),O(0),U.current=0,b("PLAYING"),_.current="PLAYING",Zt.current=!1,Af("BGM_START"),Yt(!1),setTimeout(()=>{_.current==="PLAYING"&&zt()},1e3)},qt=G[Tt];return`${Ki.mapLinear(qt.offsetX,-.2,.2,0,100)}`,`${Ki.mapLinear(qt.offsetY,.2,-.2,0,100)}`,`${qt.rotationDeg}`,xt.jsxs("div",{className:`relative w-screen h-screen overflow-hidden text-white font-anime tracking-wide ${B?"camera-shake":""}`,style:{background:"radial-gradient(circle at center, #1a2a1a 0%, #050505 100%)"},children:[He&&m==="PLAYING"&&xt.jsx("div",{className:"speed-lines pointer-events-none"}),xt.jsx("video",{ref:t,playsInline:!0,muted:!0,className:`absolute inset-0 w-full h-full object-cover -scale-x-100 ${m==="PLAYING"?"opacity-40":"opacity-0"}`}),xt.jsx("div",{className:`absolute inset-0 pointer-events-none ${m==="PLAYING"?"opacity-40":"opacity-0"}`,style:{backgroundImage:"repeating-linear-gradient(0deg, rgba(0,0,0,0.1) 0px, rgba(0,0,0,0.1) 1px, transparent 1px, transparent 2px)"}}),xt.jsx("div",{ref:i,className:"absolute inset-0 w-full h-full pointer-events-none"}),xt.jsx("canvas",{ref:a,className:"absolute inset-0 w-full h-full pointer-events-none opacity-50 z-10"}),xt.jsxs("div",{className:"absolute inset-0 z-20 flex flex-col pointer-events-none",children:[m==="PLAYING"&&R&&xt.jsx("div",{className:"absolute inset-0 z-30 pointer-events-none",children:R.options.map((mt,Ut)=>{const Vt=Ut===0?"22.5%":Ut===1?"50%":"77.5%";return xt.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2 flex items-center justify-center w-32 h-32 md:w-48 md:h-48 transition-all duration-300 border-2 border-white/20 bg-black/10 rounded-[2rem] shadow-[0_0_10px_rgba(255,255,255,0.05)]",style:{left:Vt,top:"45%"},children:xt.jsx("div",{className:"font-mono font-bold tracking-tighter text-4xl md:text-6xl tabular-nums transition-colors duration-300 text-white/80 drop-shadow-[0_0_8px_rgba(255,255,255,0.3)]",children:mt})},Ut)})}),m==="PLAYING"&&xt.jsxs("header",{className:"absolute top-8 left-8 right-8 flex justify-between items-start z-50 pointer-events-auto",children:[xt.jsxs("div",{className:"flex gap-4",children:[xt.jsx("div",{className:"bg-white border-4 border-black px-6 py-2 skew-x-[-15deg] shadow-[6px_6px_0_#FFE600] transition-transform",children:xt.jsxs("div",{className:"skew-x-[15deg]",children:[xt.jsx("div",{className:"text-[14px] font-anime font-bold uppercase tracking-widest text-[#FF0055] mb-[-4px]",children:"SCORE"}),xt.jsx("div",{className:"text-[32px] font-comic font-[800] tabular-nums leading-none text-black tracking-widest",children:String(y).padStart(5,"0")})]})}),xt.jsx("div",{className:"bg-black border-4 border-black px-6 py-2 skew-x-[-15deg] shadow-[6px_6px_0_#FF0055]",children:xt.jsxs("div",{className:"skew-x-[15deg]",children:[xt.jsx("div",{className:"text-[14px] font-anime font-bold uppercase tracking-widest text-[#FF0055] mb-[-4px]",children:"GOALS"}),xt.jsx("div",{className:"text-[32px] font-comic font-[800] tabular-nums leading-none text-white tracking-widest",children:String(w).padStart(2,"0")})]})})]}),xt.jsx("div",{className:"flex flex-col items-end gap-2",children:xt.jsx("div",{className:"bg-white border-4 border-black px-6 py-2 skew-x-[-15deg] shadow-[6px_6px_0_#00E5FF]",children:xt.jsxs("div",{className:"skew-x-[15deg]",children:[xt.jsx("div",{className:"text-[14px] font-anime font-bold uppercase tracking-widest text-black mb-[-4px]",children:"KICKS"}),xt.jsxs("div",{className:"text-[32px] font-comic font-[800] tabular-nums leading-none text-black tracking-widest",children:[String(P).padStart(2,"0")," ",xt.jsx("span",{className:"text-black/50 text-[20px] font-black tracking-wide",children:"/ 10"})]})]})})})]}),m==="PLAYING"&&R&&xt.jsx("div",{className:"absolute bottom-20 left-1/2 -translate-x-1/2 z-50 flex flex-col items-center pointer-events-none",children:xt.jsx("div",{className:"bg-[#FF0055] border-black px-8 sm:px-12 py-3 skew-x-[-10deg] shadow-[8px_8px_0_#00E5FF] border-4",children:xt.jsxs("div",{className:"skew-x-[10deg] text-white flex flex-col items-center",children:[xt.jsx("div",{className:"text-[15px] sm:text-[18px] font-anime font-bold uppercase tracking-widest text-[#FFE600] mb-[-6px] drop-shadow-md",children:"MATH QUESTION"}),xt.jsx("div",{className:"text-[52px] sm:text-[64px] font-comic font-black tracking-widest drop-shadow-xl leading-none",children:R.question})]})})}),xt.jsx(Vb,{children:m==="IDLE"&&xt.jsx(qb.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.05},className:"absolute inset-0 bg-white p-4 sm:p-10 border-[16px] border-[#FF0055] flex flex-col items-center justify-center text-center pointer-events-auto z-40 bg-[radial-gradient(#e5e7eb_1px,transparent_1px)] [background-size:16px_16px] overflow-y-auto",children:xt.jsxs("div",{className:"max-w-3xl w-full py-8",children:[xt.jsx("div",{className:"w-20 h-20 sm:w-24 sm:h-24 bg-[#00E5FF] border-[6px] border-black flex items-center justify-center mx-auto mb-4 sm:mb-6 shadow-[8px_8px_0_#000] rotate-12",children:xt.jsx(FV,{className:"w-10 h-10 sm:w-12 sm:h-12 text-white -rotate-12"})}),xt.jsx("h1",{className:"text-5xl sm:text-7xl md:text-8xl font-comic mb-4 tracking-widest text-[#FFE600] drop-shadow-[4px_4px_0_#000] sm:drop-shadow-[8px_8px_0_#000]",style:{WebkitTextStroke:"3px black"},children:"AR GOALKEEPER"}),xt.jsx("p",{className:"text-black text-lg sm:text-[24px] md:text-[28px] font-anime font-black mb-4 sm:mb-6 leading-relaxed tracking-wider bg-white inline-block px-4 border-4 border-black",children:"STAND IN FRONT OF THE CAMERA. BLOCK THE EPIC SHOTS!"}),xt.jsxs("div",{className:"bg-[#FFE600] border-4 border-black text-black px-4 sm:px-6 py-2 sm:py-3 text-sm sm:text-lg font-anime font-black flex items-center justify-center gap-2 sm:gap-3 mb-6 sm:mb-10 mx-auto w-fit tracking-widest shadow-[4px_4px_0_#00E5FF] sm:shadow-[6px_6px_0_#00E5FF]",children:[xt.jsx("span",{className:"animate-pulse",children:"โ–ถ"})," LIVE TRACKING ACTIVE"]}),nt?xt.jsx("div",{className:"flex flex-col items-center gap-4 py-4 sm:py-8",children:xt.jsx("p",{className:"text-[#FF0055] font-anime font-black text-xl sm:text-2xl tracking-widest mt-4 max-w-md text-center",children:nt})}):d?xt.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[xt.jsxs("div",{children:[xt.jsx("p",{className:"text-[18px] sm:text-[24px] font-anime font-black text-black mb-4 tracking-widest bg-[#00E5FF] inline-block px-4 border-4 border-black",children:"SELECT RANK"}),xt.jsx("div",{className:"flex flex-wrap justify-center gap-3 sm:gap-4",children:[1,1.5,2].map((mt,Ut)=>{const Vt=["GENIN","CHUNIN","JONIN"];return xt.jsx("button",{onClick:()=>Gt(mt),className:`px-6 sm:px-8 py-2 sm:py-3 skew-x-[-15deg] font-anime font-black text-lg sm:text-xl tracking-widest transition-transform border-4 border-black active:translate-y-1 active:shadow-none ${S===mt?"bg-[#FF0055] text-white shadow-[6px_6px_0_#000] sm:shadow-[8px_8px_0_#000] -translate-y-1":"bg-white text-black hover:bg-[#FFE600] shadow-[3px_3px_0_#000] sm:shadow-[4px_4px_0_#000]"}`,children:xt.jsx("div",{className:"skew-x-[15deg]",children:Vt[Ut]})},mt)})})]}),xt.jsx("button",{onClick:te,className:"w-full max-w-sm sm:max-w-lg mx-auto py-4 sm:py-6 skew-x-[-10deg] font-anime font-black text-[28px] sm:text-[40px] tracking-widest text-black bg-[#00E5FF] border-4 border-black hover:bg-[#FF0055] hover:text-white transition-colors flex items-center justify-center gap-3 sm:gap-4 active:translate-y-2 active:translate-x-2 shadow-[8px_8px_0_#000] sm:shadow-[12px_12px_0_#000] active:shadow-[0_0_0_#000] mb-6",children:xt.jsxs("div",{className:"skew-x-[10deg] flex items-center justify-center gap-3 sm:gap-4",children:[xt.jsx(UV,{className:"fill-current w-8 h-8 sm:w-10 sm:h-10"})," ",xt.jsx("span",{className:"mt-1",children:"START GAME!"})]})}),xt.jsx("button",{onClick:()=>bt(!St),className:"w-full max-w-xs sm:max-w-sm mx-auto py-2 sm:py-3 skew-x-[-10deg] font-anime font-bold text-lg sm:text-xl tracking-widest text-white bg-black border-4 border-white hover:bg-white hover:text-black transition-colors flex items-center justify-center shadow-[4px_4px_0_#FF0055]",children:xt.jsx("div",{className:"skew-x-[10deg]",children:St?"HIDE RANKING":"SHOW RANKING"})}),St&&xt.jsx("div",{className:"w-full max-w-sm sm:max-w-lg mx-auto mt-8 bg-black border-4 border-black p-4 sm:p-6 shadow-[8px_8px_0_#FFE600] skew-x-[-5deg]",children:xt.jsxs("div",{className:"skew-x-[5deg]",children:[xt.jsx("h3",{className:"text-[#00E5FF] font-anime font-black text-xl sm:text-2xl tracking-widest mb-4 sm:mb-6 uppercase text-center",children:"๐Ÿ† Global Top 5 ๐Ÿ†"}),xt.jsx("div",{className:"flex flex-col gap-2 sm:gap-3",children:u.map((mt,Ut)=>xt.jsxs("div",{className:`flex justify-between items-center px-3 sm:px-4 py-2 border-2 ${mt.isYou?"bg-[#FF0055] border-black text-white shadow-[4px_4px_0_#000]":"bg-white/10 border-white/20 text-white"}`,children:[xt.jsxs("span",{className:"font-anime font-bold text-base sm:text-lg tracking-widest truncate",children:[Ut+1,". ",mt.name]}),xt.jsx("span",{className:"font-comic font-black text-xl sm:text-2xl tabular-nums ml-4",children:String(mt.score).padStart(5,"0")})]},mt.id+Ut))})]})})]}):xt.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 sm:py-8",children:[xt.jsx("div",{className:"w-12 h-12 sm:w-16 sm:h-16 border-[8px] sm:border-[12px] border-black border-r-[#00E5FF] animate-spin"}),xt.jsx("p",{className:"text-black font-anime font-black text-xl sm:text-3xl tracking-widest mt-4",children:"LOADING KI..."})]})]})})}),xt.jsx(Vb,{children:m==="GAMEOVER"&&xt.jsx(qb.div,{initial:{opacity:0,scale:.9,y:50},animate:{opacity:1,scale:1,y:0},className:"absolute inset-0 bg-[#FFE600] p-4 sm:p-10 border-[16px] border-[#00E5FF] flex flex-col items-center justify-center text-center pointer-events-auto z-40 bg-[radial-gradient(#000_1px,transparent_1px)] [background-size:24px_24px] overflow-y-auto",children:xt.jsxs("div",{className:"max-w-3xl w-full py-8",children:[xt.jsx("h2",{className:"text-6xl sm:text-7xl md:text-9xl font-comic tracking-widest mb-4 sm:mb-6 text-[#FF0055] drop-shadow-[4px_4px_0_#000] sm:drop-shadow-[8px_8px_0_#000]",style:{WebkitTextStroke:"4px black"},children:"FULL TIME"}),xt.jsx("p",{className:"text-black font-anime font-black tracking-widest text-xl sm:text-3xl mb-10 sm:mb-16 bg-white border-4 border-black inline-block px-4 sm:px-6 py-2 shadow-[4px_4px_0_#00E5FF] sm:shadow-[6px_6px_0_#00E5FF]",children:"MATCH FINISHED"}),xt.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6 sm:gap-8 mb-10 sm:mb-16",children:[xt.jsx("div",{className:"bg-white border-4 border-black py-8 sm:py-10 skew-x-[-10deg] shadow-[8px_8px_0_#000] sm:shadow-[12px_12px_0_#000]",children:xt.jsxs("div",{className:"skew-x-[10deg]",children:[xt.jsx("div",{className:"text-[14px] sm:text-[18px] font-anime font-black uppercase tracking-widest text-[#FF0055] mb-[4px]",children:"FINAL SCORE"}),xt.jsx("div",{className:"text-5xl sm:text-7xl font-comic font-[900] text-black tabular-nums leading-none tracking-widest",children:String(y).padStart(5,"0")})]})}),xt.jsx("div",{className:"bg-black border-4 border-black py-8 sm:py-10 skew-x-[-10deg] shadow-[8px_8px_0_#FF0055] sm:shadow-[12px_12px_0_#FF0055]",children:xt.jsxs("div",{className:"skew-x-[10deg]",children:[xt.jsx("div",{className:"text-[14px] sm:text-[18px] font-anime font-black uppercase tracking-widest text-[#00E5FF] mb-[4px]",children:"CONCEDED"}),xt.jsx("div",{className:"text-5xl sm:text-7xl font-comic font-[900] text-white tabular-nums leading-none tracking-widest",children:String(w).padStart(2,"0")})]})})]}),xt.jsx("button",{onClick:te,className:"w-full max-w-sm sm:max-w-lg mx-auto py-4 sm:py-6 skew-x-[-10deg] font-anime font-black text-[24px] sm:text-[36px] tracking-widest text-white bg-black border-4 border-white hover:bg-[#00E5FF] hover:border-black hover:text-black transition-colors flex items-center justify-center gap-3 sm:gap-4 active:translate-y-2 active:translate-x-2 shadow-[8px_8px_0_#FF0055] sm:shadow-[12px_12px_0_#FF0055] active:shadow-transparent mb-6",children:xt.jsxs("div",{className:"skew-x-[10deg] flex items-center justify-center gap-3 sm:gap-4",children:[xt.jsx(OV,{className:"w-6 h-6 sm:w-8 sm:h-8 stroke-[4]"})," PLAY AGAIN!"]})}),xt.jsx("button",{onClick:()=>bt(!St),className:"w-full max-w-xs sm:max-w-sm mx-auto py-2 sm:py-3 skew-x-[-10deg] font-anime font-bold text-lg sm:text-xl tracking-widest text-[#00E5FF] bg-black border-4 border-[#00E5FF] hover:bg-[#00E5FF] hover:text-black transition-colors flex items-center justify-center shadow-[4px_4px_0_#FF0055]",children:xt.jsx("div",{className:"skew-x-[10deg]",children:St?"HIDE RANKING":"SHOW RANKING"})}),St&&xt.jsx("div",{className:"w-full max-w-sm sm:max-w-lg mx-auto mt-10 mb-16 bg-white border-4 border-black p-4 sm:p-6 shadow-[8px_8px_0_#000] skew-x-[5deg]",children:xt.jsxs("div",{className:"skew-x-[-5deg]",children:[xt.jsx("h3",{className:"text-black font-anime font-black text-xl sm:text-2xl tracking-widest mb-4 sm:mb-6 uppercase text-center bg-[#FFE600] border-2 border-black inline-block px-4 py-1",children:"๐Ÿ† GLOBAL RANKING ๐Ÿ†"}),xt.jsx("div",{className:"flex flex-col gap-2 sm:gap-3",children:u.map((mt,Ut)=>xt.jsxs("div",{className:`flex justify-between items-center px-3 sm:px-4 py-2 border-2 ${mt.isYou?"bg-[#FF0055] border-black text-white shadow-[4px_4px_0_#000]":"bg-black/5 border-black/20 text-black shadow-[2px_2px_0_rgba(0,0,0,0.1)]"}`,children:[xt.jsxs("span",{className:"font-anime font-bold text-base sm:text-lg tracking-widest truncate",children:[Ut+1,". ",mt.name]}),xt.jsx("span",{className:"font-comic font-black text-xl sm:text-2xl tabular-nums ml-4",children:String(mt.score).padStart(5,"0")})]},mt.id+Ut))})]})})]})})}),xt.jsx(Vb,{children:I&&xt.jsx(qb.div,{initial:{opacity:0,scale:.5,y:"100%",rotate:-5},animate:{opacity:1,scale:1,y:0,rotate:0},exit:{opacity:0,scale:1.5,y:"-100%",rotate:5},transition:{type:"spring",damping:15,stiffness:300,duration:.4},className:"absolute inset-0 flex items-center justify-center pointer-events-none z-50 overflow-hidden",children:xt.jsx("div",{className:`w-full flex items-center justify-center py-8 ${I.type==="SUPER_SAVE"?"cut-in-banner":""}`,children:xt.jsx("div",{className:`uppercase whitespace-nowrap text-center font-comic px-10 cut-in-text ${I.type==="SAVE"?"text-[#ffcc00] text-[120px] opacity-90 drop-shadow-[0_10px_0_#997300]":I.type==="SUPER_SAVE"?"text-[#00ffff] text-[150px] scale-110 drop-shadow-[0px_10px_0_#008080] super-aura":"text-[#ff4444] text-[150px] opacity-90 drop-shadow-[0_10px_0_#800000]"}`,style:{WebkitTextStroke:I.type==="SUPER_SAVE"?"4px #fff":"3px #000"},children:I.text})})})}),xt.jsxs("div",{className:"absolute bottom-8 left-8 text-[10px] opacity-40 uppercase font-mono tracking-widest z-50 pointer-events-none",children:["v1.0.4-beta // latency: ",(1e3/60).toFixed(0),"ms"]}),m!=="PLAYING"&&xt.jsx("div",{className:"absolute bottom-8 right-8 w-48 h-36 bg-white border-4 border-black box-content overflow-hidden shadow-[6px_6px_0_#00E5FF] skew-x-[-10deg] z-50 pointer-events-none fade-in",children:xt.jsxs("div",{className:"skew-x-[10deg] w-full h-full transform scale-110",children:[xt.jsx("video",{ref:n,playsInline:!0,muted:!0,className:"w-full h-full object-cover -scale-x-100"}),xt.jsxs("div",{className:"absolute top-2 left-2 text-[10px] font-anime font-black tracking-widest uppercase bg-[#FF0055] px-2 py-0.5 text-white flex items-center gap-1 border-2 border-black",children:[xt.jsx("div",{className:"w-1.5 h-1.5 bg-white animate-[pulse_1s_ease-in-out_infinite]"}),"REC"]})]})}),!1]})]})}QL.createRoot(document.getElementById("root")).render(xt.jsx(pt.StrictMode,{children:xt.jsx(HV,{})}));