(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("*{margin:0;padding:0;box-sizing:border-box}html,body{width:100%;height:100%;background:#fceded}#root{width:100vw;height:90dvh}[class*=leva-] button[class*=title]{text-transform:capitalize}#leva__root{z-index:999999!important;position:relative}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})(); function sN(n,e){for(var t=0;ti[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}function Yu(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var SS={exports:{}},pg={};var lw;function aN(){if(lw)return pg;lw=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,r,a){var l=null;if(a!==void 0&&(l=""+a),r.key!==void 0&&(l=""+r.key),"key"in r){a={};for(var u in r)u!=="key"&&(a[u]=r[u])}else a=r;return r=a.ref,{$$typeof:n,type:i,key:l,ref:r!==void 0?r:null,props:a}}return pg.Fragment=e,pg.jsx=t,pg.jsxs=t,pg}var cw;function oN(){return cw||(cw=1,SS.exports=aN()),SS.exports}var ut=oN(),MS={exports:{}},rn={};var uw;function lN(){if(uw)return rn;uw=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),b=Symbol.iterator;function x(j){return j===null||typeof j!="object"?null:(j=b&&j[b]||j["@@iterator"],typeof j=="function"?j:null)}var M={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},A=Object.assign,w={};function E(j,fe,be){this.props=j,this.context=fe,this.refs=w,this.updater=be||M}E.prototype.isReactComponent={},E.prototype.setState=function(j,fe){if(typeof j!="object"&&typeof j!="function"&&j!=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,j,fe,"setState")},E.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function R(){}R.prototype=E.prototype;function D(j,fe,be){this.props=j,this.context=fe,this.refs=w,this.updater=be||M}var P=D.prototype=new R;P.constructor=D,A(P,E.prototype),P.isPureReactComponent=!0;var F=Array.isArray;function L(){}var k={H:null,A:null,T:null,S:null},V=Object.prototype.hasOwnProperty;function N(j,fe,be){var Fe=be.ref;return{$$typeof:n,type:j,key:fe,ref:Fe!==void 0?Fe:null,props:be}}function z(j,fe){return N(j.type,fe,j.props)}function X(j){return typeof j=="object"&&j!==null&&j.$$typeof===n}function Q(j){var fe={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(be){return fe[be]})}var J=/\/+/g;function oe(j,fe){return typeof j=="object"&&j!==null&&j.key!=null?Q(""+j.key):fe.toString(36)}function re(j){switch(j.status){case"fulfilled":return j.value;case"rejected":throw j.reason;default:switch(typeof j.status=="string"?j.then(L,L):(j.status="pending",j.then(function(fe){j.status==="pending"&&(j.status="fulfilled",j.value=fe)},function(fe){j.status==="pending"&&(j.status="rejected",j.reason=fe)})),j.status){case"fulfilled":return j.value;case"rejected":throw j.reason}}throw j}function q(j,fe,be,Fe,rt){var he=typeof j;(he==="undefined"||he==="boolean")&&(j=null);var xe=!1;if(j===null)xe=!0;else switch(he){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(j.$$typeof){case n:case e:xe=!0;break;case g:return xe=j._init,q(xe(j._payload),fe,be,Fe,rt)}}if(xe)return rt=rt(j),xe=Fe===""?"."+oe(j,0):Fe,F(rt)?(be="",xe!=null&&(be=xe.replace(J,"$&/")+"/"),q(rt,fe,be,"",function(ct){return ct})):rt!=null&&(X(rt)&&(rt=z(rt,be+(rt.key==null||j&&j.key===rt.key?"":(""+rt.key).replace(J,"$&/")+"/")+xe)),fe.push(rt)),1;xe=0;var ke=Fe===""?".":Fe+":";if(F(j))for(var Ge=0;Ge>>1,Ee=q[pe];if(0>>1;per(be,ne))Fer(rt,be)?(q[pe]=rt,q[Fe]=ne,pe=Fe):(q[pe]=be,q[fe]=ne,pe=fe);else if(Fer(rt,ne))q[pe]=rt,q[Fe]=ne,pe=Fe;else break e}}return Z}function r(q,Z){var ne=q.sortIndex-Z.sortIndex;return ne!==0?ne:q.id-Z.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;n.unstable_now=function(){return a.now()}}else{var l=Date,u=l.now();n.unstable_now=function(){return l.now()-u}}var h=[],p=[],g=1,y=null,b=3,x=!1,M=!1,A=!1,w=!1,E=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function P(q){for(var Z=t(p);Z!==null;){if(Z.callback===null)i(p);else if(Z.startTime<=q)i(p),Z.sortIndex=Z.expirationTime,e(h,Z);else break;Z=t(p)}}function F(q){if(A=!1,P(q),!M)if(t(h)!==null)M=!0,L||(L=!0,Q());else{var Z=t(p);Z!==null&&re(F,Z.startTime-q)}}var L=!1,k=-1,V=5,N=-1;function z(){return w?!0:!(n.unstable_now()-Nq&&z());){var pe=y.callback;if(typeof pe=="function"){y.callback=null,b=y.priorityLevel;var Ee=pe(y.expirationTime<=q);if(q=n.unstable_now(),typeof Ee=="function"){y.callback=Ee,P(q),Z=!0;break t}y===t(h)&&i(h),P(q)}else i(h);y=t(h)}if(y!==null)Z=!0;else{var j=t(p);j!==null&&re(F,j.startTime-q),Z=!1}}break e}finally{y=null,b=ne,x=!1}Z=void 0}}finally{Z?Q():L=!1}}}var Q;if(typeof D=="function")Q=function(){D(X)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,oe=J.port2;J.port1.onmessage=X,Q=function(){oe.postMessage(null)}}else Q=function(){E(X,0)};function re(q,Z){k=E(function(){q(n.unstable_now())},Z)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(q){q.callback=null},n.unstable_forceFrameRate=function(q){0>q||125pe?(q.sortIndex=ne,e(p,q),t(h)===null&&q===t(p)&&(A?(R(k),k=-1):A=!0,re(F,ne-pe))):(q.sortIndex=Ee,e(h,q),M||x||(M=!0,L||(L=!0,Q()))),q},n.unstable_shouldYield=z,n.unstable_wrapCallback=function(q){var Z=b;return function(){var ne=b;b=Z;try{return q.apply(this,arguments)}finally{b=ne}}}})(wS)),wS}var hw;function s3(){return hw||(hw=1,TS.exports=cN()),TS.exports}var AS={exports:{}},is={};var pw;function uN(){if(pw)return is;pw=1;var n=M0();function e(h){var p="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),AS.exports=uN(),AS.exports}var gw;function fN(){if(gw)return mg;gw=1;var n=s3(),e=M0(),t=a3();function i(s){var o="https://react.dev/errors/"+s;if(1Ee||(s.current=pe[Ee],pe[Ee]=null,Ee--)}function be(s,o){Ee++,pe[Ee]=s.current,s.current=o}var Fe=j(null),rt=j(null),he=j(null),xe=j(null);function ke(s,o){switch(be(he,o),be(rt,s),be(Fe,null),o.nodeType){case 9:case 11:s=(s=o.documentElement)&&(s=s.namespaceURI)?OT(s):0;break;default:if(s=o.tagName,o=o.namespaceURI)o=OT(o),s=PT(o,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}fe(Fe),be(Fe,s)}function Ge(){fe(Fe),fe(rt),fe(he)}function ct(s){s.memoizedState!==null&&be(xe,s);var o=Fe.current,d=PT(o,s.type);o!==d&&(be(rt,s),be(Fe,d))}function _t(s){rt.current===s&&(fe(Fe),fe(rt)),xe.current===s&&(fe(xe),ug._currentValue=ne)}var St,mt;function Ce(s){if(St===void 0)try{throw Error()}catch(d){var o=d.stack.trim().match(/\n( *(at )?)/);St=o&&o[1]||"",mt=-1)":-1S||ae[m]!==Me[S]){var Be=` `+ae[m].replace(" at new "," at ");return s.displayName&&Be.includes("")&&(Be=Be.replace("",s.displayName)),Be}while(1<=m&&0<=S);break}}}finally{Pe=!1,Error.prepareStackTrace=d}return(d=s?s.displayName||s.name:"")?Ce(d):""}function Xe(s,o){switch(s.tag){case 26:case 27:case 5:return Ce(s.type);case 16:return Ce("Lazy");case 13:return s.child!==o&&o!==null?Ce("Suspense Fallback"):Ce("Suspense");case 19:return Ce("SuspenseList");case 0:case 15:return ze(s.type,!1);case 11:return ze(s.type.render,!1);case 1:return ze(s.type,!0);case 31:return Ce("Activity");default:return""}}function Y(s){try{var o="",d=null;do o+=Xe(s,d),d=s,s=s.return;while(s);return o}catch(m){return` Error generating stack: `+m.message+` `+m.stack}}var bt=Object.prototype.hasOwnProperty,st=n.unstable_scheduleCallback,Et=n.unstable_cancelCallback,Te=n.unstable_shouldYield,H=n.unstable_requestPaint,I=n.unstable_now,ee=n.unstable_getCurrentPriorityLevel,ue=n.unstable_ImmediatePriority,De=n.unstable_UserBlockingPriority,_e=n.unstable_NormalPriority,nt=n.unstable_LowPriority,Ye=n.unstable_IdlePriority,dt=n.log,Ct=n.unstable_setDisableYieldValue,$e=null,Ke=null;function ht(s){if(typeof dt=="function"&&Ct(s),Ke&&typeof Ke.setStrictMode=="function")try{Ke.setStrictMode($e,s)}catch{}}var te=Math.clz32?Math.clz32:ie,ye=Math.log,it=Math.LN2;function ie(s){return s>>>=0,s===0?32:31-(ye(s)/it|0)|0}var Qe=256,je=262144,at=4194304;function Ze(s){var o=s&42;if(o!==0)return o;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 He(s,o,d){var m=s.pendingLanes;if(m===0)return 0;var S=0,T=s.suspendedLanes,B=s.pingedLanes;s=s.warmLanes;var $=m&134217727;return $!==0?(m=$&~T,m!==0?S=Ze(m):(B&=$,B!==0?S=Ze(B):d||(d=$&~s,d!==0&&(S=Ze(d))))):($=m&~T,$!==0?S=Ze($):B!==0?S=Ze(B):d||(d=m&~s,d!==0&&(S=Ze(d)))),S===0?0:o!==0&&o!==S&&(o&T)===0&&(T=S&-S,d=o&-o,T>=d||T===32&&(d&4194048)!==0)?o:S}function tt(s,o){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&o)===0}function Nt(s,o){switch(s){case 1:case 2:case 4:case 8:case 64:return o+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 o+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 sn(){var s=at;return at<<=1,(at&62914560)===0&&(at=4194304),s}function ln(s){for(var o=[],d=0;31>d;d++)o.push(s);return o}function pi(s,o){s.pendingLanes|=o,o!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function qi(s,o,d,m,S,T){var B=s.pendingLanes;s.pendingLanes=d,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=d,s.entangledLanes&=d,s.errorRecoveryDisabledLanes&=d,s.shellSuspendCounter=0;var $=s.entanglements,ae=s.expirationTimes,Me=s.hiddenUpdates;for(d=B&~d;0"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var Tn=/[\n"\\]/g;function Xt(s){return s.replace(Tn,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function Bi(s,o,d,m,S,T,B,$){s.name="",B!=null&&typeof B!="function"&&typeof B!="symbol"&&typeof B!="boolean"?s.type=B:s.removeAttribute("type"),o!=null?B==="number"?(o===0&&s.value===""||s.value!=o)&&(s.value=""+Ht(o)):s.value!==""+Ht(o)&&(s.value=""+Ht(o)):B!=="submit"&&B!=="reset"||s.removeAttribute("value"),o!=null?ai(s,B,Ht(o)):d!=null?ai(s,B,Ht(d)):m!=null&&s.removeAttribute("value"),S==null&&T!=null&&(s.defaultChecked=!!T),S!=null&&(s.checked=S&&typeof S!="function"&&typeof S!="symbol"),$!=null&&typeof $!="function"&&typeof $!="symbol"&&typeof $!="boolean"?s.name=""+Ht($):s.removeAttribute("name")}function ua(s,o,d,m,S,T,B,$){if(T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(s.type=T),o!=null||d!=null){if(!(T!=="submit"&&T!=="reset"||o!=null)){$n(s);return}d=d!=null?""+Ht(d):"",o=o!=null?""+Ht(o):d,$||o===s.value||(s.value=o),s.defaultValue=o}m=m??S,m=typeof m!="function"&&typeof m!="symbol"&&!!m,s.checked=$?s.checked:!!m,s.defaultChecked=!!m,B!=null&&typeof B!="function"&&typeof B!="symbol"&&typeof B!="boolean"&&(s.name=B),$n(s)}function ai(s,o,d){o==="number"&>(s.ownerDocument)===s||s.defaultValue===""+d||(s.defaultValue=""+d)}function Nr(s,o,d,m){if(s=s.options,o){o={};for(var S=0;S"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),jp=!1;if(Ca)try{var Uc={};Object.defineProperty(Uc,"passive",{get:function(){jp=!0}}),window.addEventListener("test",Uc,Uc),window.removeEventListener("test",Uc,Uc)}catch{jp=!1}var gs=null,Ld=null,kl=null;function nf(){if(kl)return kl;var s,o=Ld,d=o.length,m,S="value"in gs?gs.value:gs.textContent,T=S.length;for(s=0;s=Hc),av=" ",lf=!1;function Gd(s,o){switch(s){case"keyup":return sv.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function em(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Gl=!1;function ov(s,o){switch(s){case"compositionend":return em(o);case"keypress":return o.which!==32?null:(lf=!0,av);case"textInput":return s=o.data,s===av&&lf?null:s;default:return null}}function tm(s,o){if(Gl)return s==="compositionend"||!Vl&&Gd(s,o)?(s=nf(),kl=Ld=gs=null,Gl=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1=o)return{node:d,offset:o-s};s=m}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=ff(d)}}function Jn(s,o){return s&&o?s===o?!0:s&&s.nodeType===3?!1:o&&o.nodeType===3?Jn(s,o.parentNode):"contains"in s?s.contains(o):s.compareDocumentPosition?!!(s.compareDocumentPosition(o)&16):!1:!1}function dv(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var o=gt(s.document);o instanceof s.HTMLIFrameElement;){try{var d=typeof o.contentWindow.location.href=="string"}catch{d=!1}if(d)s=o.contentWindow;else break;o=gt(s.document)}return o}function cm(s){var o=s&&s.nodeName&&s.nodeName.toLowerCase();return o&&(o==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||o==="textarea"||s.contentEditable==="true")}var hv=Ca&&"documentMode"in document&&11>=document.documentMode,Da=null,Oa=null,$c=null,$d=!1;function Xc(s,o,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;$d||Da==null||Da!==gt(m)||(m=Da,"selectionStart"in m&&cm(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),$c&&Gc($c,m)||($c=m,m=dy(Oa,"onSelect"),0>=B,S-=B,vi=1<<32-te(o)+S|d<hn?(An=Pt,Pt=null):An=Pt.sibling;var zn=Re(me,Pt,Se[hn],Ve);if(zn===null){Pt===null&&(Pt=An);break}s&&Pt&&zn.alternate===null&&o(me,Pt),ce=T(zn,ce,hn),Un===null?Ft=zn:Un.sibling=zn,Un=zn,Pt=An}if(hn===Se.length)return d(me,Pt),_n&&Ia(me,hn),Ft;if(Pt===null){for(;hnhn?(An=Pt,Pt=null):An=Pt.sibling;var Mu=Re(me,Pt,zn.value,Ve);if(Mu===null){Pt===null&&(Pt=An);break}s&&Pt&&Mu.alternate===null&&o(me,Pt),ce=T(Mu,ce,hn),Un===null?Ft=Mu:Un.sibling=Mu,Un=Mu,Pt=An}if(zn.done)return d(me,Pt),_n&&Ia(me,hn),Ft;if(Pt===null){for(;!zn.done;hn++,zn=Se.next())zn=We(me,zn.value,Ve),zn!==null&&(ce=T(zn,ce,hn),Un===null?Ft=zn:Un.sibling=zn,Un=zn);return _n&&Ia(me,hn),Ft}for(Pt=m(Pt);!zn.done;hn++,zn=Se.next())zn=Ue(Pt,me,hn,zn.value,Ve),zn!==null&&(s&&zn.alternate!==null&&Pt.delete(zn.key===null?hn:zn.key),ce=T(zn,ce,hn),Un===null?Ft=zn:Un.sibling=zn,Un=zn);return s&&Pt.forEach(function(rN){return o(me,rN)}),_n&&Ia(me,hn),Ft}function ii(me,ce,Se,Ve){if(typeof Se=="object"&&Se!==null&&Se.type===A&&Se.key===null&&(Se=Se.props.children),typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case x:e:{for(var Ft=Se.key;ce!==null;){if(ce.key===Ft){if(Ft=Se.type,Ft===A){if(ce.tag===7){d(me,ce.sibling),Ve=S(ce,Se.props.children),Ve.return=me,me=Ve;break e}}else if(ce.elementType===Ft||typeof Ft=="object"&&Ft!==null&&Ft.$$typeof===V&&ql(Ft)===ce.type){d(me,ce.sibling),Ve=S(ce,Se.props),Vs(Ve,Se),Ve.return=me,me=Ve;break e}d(me,ce);break}else o(me,ce);ce=ce.sibling}Se.type===A?(Ve=Ko(Se.props.children,me.mode,Ve,Se.key),Ve.return=me,me=Ve):(Ve=Pa(Se.type,Se.key,Se.props,null,me.mode,Ve),Vs(Ve,Se),Ve.return=me,me=Ve)}return B(me);case M:e:{for(Ft=Se.key;ce!==null;){if(ce.key===Ft)if(ce.tag===4&&ce.stateNode.containerInfo===Se.containerInfo&&ce.stateNode.implementation===Se.implementation){d(me,ce.sibling),Ve=S(ce,Se.children||[]),Ve.return=me,me=Ve;break e}else{d(me,ce);break}else o(me,ce);ce=ce.sibling}Ve=Zd(Se,me.mode,Ve),Ve.return=me,me=Ve}return B(me);case V:return Se=ql(Se),ii(me,ce,Se,Ve)}if(re(Se))return Dt(me,ce,Se,Ve);if(Q(Se)){if(Ft=Q(Se),typeof Ft!="function")throw Error(i(150));return Se=Ft.call(Se),jt(me,ce,Se,Ve)}if(typeof Se.then=="function")return ii(me,ce,_f(Se),Ve);if(Se.$$typeof===D)return ii(me,ce,eu(me,Se),Ve);tu(me,Se)}return typeof Se=="string"&&Se!==""||typeof Se=="number"||typeof Se=="bigint"?(Se=""+Se,ce!==null&&ce.tag===6?(d(me,ce.sibling),Ve=S(ce,Se),Ve.return=me,me=Ve):(d(me,ce),Ve=Yd(Se,me.mode,Ve),Ve.return=me,me=Ve),B(me)):d(me,ce)}return function(me,ce,Se,Ve){try{Ql=0;var Ft=ii(me,ce,Se,Ve);return Kl=null,Ft}catch(Pt){if(Pt===jl||Pt===cn)throw Pt;var Un=gi(29,Pt,null,me.mode);return Un.lanes=Ve,Un.return=me,Un}}}var vo=ah(!0),oh=ah(!1),Br=!1;function Sf(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bm(s,o){s=s.updateQueue,o.updateQueue===s&&(o.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function yo(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function rl(s,o,d){var m=s.updateQueue;if(m===null)return null;if(m=m.shared,(It&2)!==0){var S=m.pending;return S===null?o.next=o:(o.next=S.next,S.next=o),m.pending=o,o=ks(s),Yo(s,null,d),o}return or(s,m,o,d),ks(s)}function sl(s,o,d){if(o=o.updateQueue,o!==null&&(o=o.shared,(d&4194048)!==0)){var m=o.lanes;m&=s.pendingLanes,d|=m,o.lanes=d,Vo(s,d)}}function Bt(s,o){var d=s.updateQueue,m=s.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var S=null,T=null;if(d=d.firstBaseUpdate,d!==null){do{var B={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};T===null?S=T=B:T=T.next=B,d=d.next}while(d!==null);T===null?S=T=o:T=T.next=o}else S=T=o;d={baseState:m.baseState,firstBaseUpdate:S,lastBaseUpdate:T,shared:m.shared,callbacks:m.callbacks},s.updateQueue=d;return}s=d.lastBaseUpdate,s===null?d.firstBaseUpdate=o:s.next=o,d.lastBaseUpdate=o}var xm=!1;function Mf(){if(xm){var s=Hs;if(s!==null)throw s}}function nu(s,o,d,m){xm=!1;var S=s.updateQueue;Br=!1;var T=S.firstBaseUpdate,B=S.lastBaseUpdate,$=S.shared.pending;if($!==null){S.shared.pending=null;var ae=$,Me=ae.next;ae.next=null,B===null?T=Me:B.next=Me,B=ae;var Be=s.alternate;Be!==null&&(Be=Be.updateQueue,$=Be.lastBaseUpdate,$!==B&&($===null?Be.firstBaseUpdate=Me:$.next=Me,Be.lastBaseUpdate=ae))}if(T!==null){var We=S.baseState;B=0,Be=Me=ae=null,$=T;do{var Re=$.lane&-536870913,Ue=Re!==$.lane;if(Ue?(an&Re)===Re:(m&Re)===Re){Re!==0&&Re===go&&(xm=!0),Be!==null&&(Be=Be.next={lane:0,tag:$.tag,payload:$.payload,callback:null,next:null});e:{var Dt=s,jt=$;Re=o;var ii=d;switch(jt.tag){case 1:if(Dt=jt.payload,typeof Dt=="function"){We=Dt.call(ii,We,Re);break e}We=Dt;break e;case 3:Dt.flags=Dt.flags&-65537|128;case 0:if(Dt=jt.payload,Re=typeof Dt=="function"?Dt.call(ii,We,Re):Dt,Re==null)break e;We=y({},We,Re);break e;case 2:Br=!0}}Re=$.callback,Re!==null&&(s.flags|=64,Ue&&(s.flags|=8192),Ue=S.callbacks,Ue===null?S.callbacks=[Re]:Ue.push(Re))}else Ue={lane:Re,tag:$.tag,payload:$.payload,callback:$.callback,next:null},Be===null?(Me=Be=Ue,ae=We):Be=Be.next=Ue,B|=Re;if($=$.next,$===null){if($=S.shared.pending,$===null)break;Ue=$,$=Ue.next,Ue.next=null,S.lastBaseUpdate=Ue,S.shared.pending=null}}while(!0);Be===null&&(ae=We),S.baseState=ae,S.firstBaseUpdate=Me,S.lastBaseUpdate=Be,T===null&&(S.shared.lanes=0),ja|=B,s.lanes=B,s.memoizedState=We}}function iu(s,o){if(typeof s!="function")throw Error(i(191,s));s.call(o)}function Sv(s,o){var d=s.callbacks;if(d!==null)for(s.callbacks=null,s=0;sT?T:8;var B=q.T,$={};q.T=$,Gm(s,!1,o,d);try{var ae=S(),Me=q.S;if(Me!==null&&Me($,ae),ae!==null&&typeof ae=="object"&&typeof ae.then=="function"){var Be=vm(ae,m);Af(s,o,Be,Ts(s))}else Af(s,o,m,Ts(s))}catch(We){Af(s,o,{then:function(){},status:"rejected",reason:We},Ts())}finally{Z.p=T,B!==null&&$.types!==null&&(B.types=$.types),q.T=B}}function Y_(){}function Hm(s,o,d,m){if(s.tag!==5)throw Error(i(476));var S=Yv(s).queue;qv(s,S,o,ne,d===null?Y_:function(){return Zv(s),d(m)})}function Yv(s){var o=s.memoizedState;if(o!==null)return o;o={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:xo,lastRenderedState:ne},next:null};var d={};return o.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:xo,lastRenderedState:d},next:null},s.memoizedState=o,s=s.alternate,s!==null&&(s.memoizedState=o),o}function Zv(s){var o=Yv(s);o.next===null&&(o=s.alternate.memoizedState),Af(s,o.next.queue,{},Ts())}function Vm(){return qt(ug)}function Kv(){return Ri().memoizedState}function Qv(){return Ri().memoizedState}function Z_(s){for(var o=s.return;o!==null;){switch(o.tag){case 24:case 3:var d=Ts();s=yo(d);var m=rl(o,s,d);m!==null&&(fn(m,o,d),sl(m,o,d)),o={cache:pm()},s.payload=o;return}o=o.return}}function K_(s,o,d){var m=Ts();d={lane:m,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},gh(s)?ey(o,d):(d=jd(s,o,d,m),d!==null&&(fn(d,s,m),ty(d,o,m)))}function Jv(s,o,d){var m=Ts();Af(s,o,d,m)}function Af(s,o,d,m){var S={lane:m,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(gh(s))ey(o,S);else{var T=s.alternate;if(s.lanes===0&&(T===null||T.lanes===0)&&(T=o.lastRenderedReducer,T!==null))try{var B=o.lastRenderedState,$=T(B,d);if(S.hasEagerState=!0,S.eagerState=$,Ur($,B))return or(s,o,S,0),Zt===null&&gf(),!1}catch{}if(d=jd(s,o,S,m),d!==null)return fn(d,s,m),ty(d,o,m),!0}return!1}function Gm(s,o,d,m){if(m={lane:2,revertLane:Ie(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},gh(s)){if(o)throw Error(i(479))}else o=jd(s,d,m,2),o!==null&&fn(o,s,2)}function gh(s){var o=s.alternate;return s===tn||o!==null&&o===tn}function ey(s,o){su=Gs=!0;var d=s.pending;d===null?o.next=o:(o.next=d.next,d.next=o),s.pending=o}function ty(s,o,d){if((d&4194048)!==0){var m=o.lanes;m&=s.pendingLanes,d|=m,o.lanes=d,Vo(s,d)}}var ou={readContext:qt,use:al,useCallback:yi,useContext:yi,useEffect:yi,useImperativeHandle:yi,useLayoutEffect:yi,useInsertionEffect:yi,useMemo:yi,useReducer:yi,useRef:yi,useState:yi,useDebugValue:yi,useDeferredValue:yi,useTransition:yi,useSyncExternalStore:yi,useId:yi,useHostTransitionStatus:yi,useFormState:yi,useActionState:yi,useOptimistic:yi,useMemoCache:yi,useCacheRefresh:yi};ou.useEffectEvent=yi;var ny={readContext:qt,use:al,useCallback:function(s,o){return Ki().memoizedState=[s,o===void 0?null:o],s},useContext:qt,useEffect:Bv,useImperativeHandle:function(s,o,d){d=d!=null?d.concat([s]):null,ph(4194308,4,Gv.bind(null,o,s),d)},useLayoutEffect:function(s,o){return ph(4194308,4,s,o)},useInsertionEffect:function(s,o){ph(4,2,s,o)},useMemo:function(s,o){var d=Ki();o=o===void 0?null:o;var m=s();if(Jl){ht(!0);try{s()}finally{ht(!1)}}return d.memoizedState=[m,o],m},useReducer:function(s,o,d){var m=Ki();if(d!==void 0){var S=d(o);if(Jl){ht(!0);try{d(o)}finally{ht(!1)}}}else S=o;return m.memoizedState=m.baseState=S,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:S},m.queue=s,s=s.dispatch=K_.bind(null,tn,s),[m.memoizedState,s]},useRef:function(s){var o=Ki();return s={current:s},o.memoizedState=s},useState:function(s){s=Om(s);var o=s.queue,d=Jv.bind(null,tn,o);return o.dispatch=d,[s.memoizedState,d]},useDebugValue:Fm,useDeferredValue:function(s,o){var d=Ki();return km(d,s,o)},useTransition:function(){var s=Om(!1);return s=qv.bind(null,tn,s.queue,!0,!1),Ki().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,o,d){var m=tn,S=Ki();if(_n){if(d===void 0)throw Error(i(407));d=d()}else{if(d=o(),Zt===null)throw Error(i(349));(an&127)!==0||Av(m,o,d)}S.memoizedState=d;var T={value:d,getSnapshot:o};return S.queue=T,Bv(Rv.bind(null,m,T,s),[s]),m.flags|=2048,ol(9,{destroy:void 0},Cv.bind(null,m,T,d,o),null),d},useId:function(){var s=Ki(),o=Zt.identifierPrefix;if(_n){var d=fa,m=vi;d=(m&~(1<<32-te(m)-1)).toString(32)+d,o="_"+o+"R_"+d,d=ch++,0<\/script>",T=T.removeChild(T.firstChild);break;case"select":T=typeof m.is=="string"?B.createElement("select",{is:m.is}):B.createElement("select"),m.multiple?T.multiple=!0:m.size&&(T.size=m.size);break;default:T=typeof m.is=="string"?B.createElement(S,{is:m.is}):B.createElement(S)}}T[mi]=o,T[Yi]=m;e:for(B=o.child;B!==null;){if(B.tag===5||B.tag===6)T.appendChild(B.stateNode);else if(B.tag!==4&&B.tag!==27&&B.child!==null){B.child.return=B,B=B.child;continue}if(B===o)break e;for(;B.sibling===null;){if(B.return===null||B.return===o)break e;B=B.return}B.sibling.return=B.return,B=B.sibling}o.stateNode=T;e:switch(Wr(T,S,m),S){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&Va(o)}}return jn(o),Of(o,o.type,s===null?null:s.memoizedProps,o.pendingProps,d),null;case 6:if(s&&o.stateNode!=null)s.memoizedProps!==m&&Va(o);else{if(typeof m!="string"&&o.stateNode===null)throw Error(i(166));if(s=he.current,Qc(o)){if(s=o.stateNode,d=o.memoizedProps,m=null,S=Mi,S!==null)switch(S.tag){case 27:case 5:m=S.memoizedProps}s[mi]=o,s=!!(s.nodeValue===d||m!==null&&m.suppressHydrationWarning===!0||RT(s.nodeValue,d)),s||La(o,!0)}else s=hy(s).createTextNode(m),s[mi]=o,o.stateNode=s}return jn(o),null;case 31:if(d=o.memoizedState,s===null||s.memoizedState!==null){if(m=Qc(o),d!==null){if(s===null){if(!m)throw Error(i(318));if(s=o.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(i(557));s[mi]=o}else el(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;jn(o),s=!1}else d=Jd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=d),s=!0;if(!s)return o.flags&256?(Ci(o),o):(Ci(o),null);if((o.flags&128)!==0)throw Error(i(558))}return jn(o),null;case 13:if(m=o.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(S=Qc(o),m!==null&&m.dehydrated!==null){if(s===null){if(!S)throw Error(i(318));if(S=o.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(i(317));S[mi]=o}else el(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;jn(o),S=!1}else S=Jd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=S),S=!0;if(!S)return o.flags&256?(Ci(o),o):(Ci(o),null)}return Ci(o),(o.flags&128)!==0?(o.lanes=d,o):(d=m!==null,s=s!==null&&s.memoizedState!==null,d&&(m=o.child,S=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(S=m.alternate.memoizedState.cachePool.pool),T=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(T=m.memoizedState.cachePool.pool),T!==S&&(m.flags|=2048)),d!==s&&d&&(o.child.flags|=8192),_o(o,o.updateQueue),jn(o),null);case 4:return Ge(),s===null&&nS(o.stateNode.containerInfo),jn(o),null;case 10:return Ba(o.type),jn(o),null;case 19:if(fe(Sn),m=o.memoizedState,m===null)return jn(o),null;if(S=(o.flags&128)!==0,T=m.rendering,T===null)if(S)Ga(m,!1);else{if(bi!==0||s!==null&&(s.flags&128)!==0)for(s=o.child;s!==null;){if(T=xs(s),T!==null){for(o.flags|=128,Ga(m,!1),s=T.updateQueue,o.updateQueue=s,_o(o,s),o.subtreeFlags=0,s=d,d=o.child;d!==null;)jc(d,s),d=d.sibling;return be(Sn,Sn.current&1|2),_n&&Ia(o,m.treeForkCount),o.child}s=s.sibling}m.tail!==null&&I()>Oi&&(o.flags|=128,S=!0,Ga(m,!1),o.lanes=4194304)}else{if(!S)if(s=xs(T),s!==null){if(o.flags|=128,S=!0,s=s.updateQueue,o.updateQueue=s,_o(o,s),Ga(m,!0),m.tail===null&&m.tailMode==="hidden"&&!T.alternate&&!_n)return jn(o),null}else 2*I()-m.renderingStartTime>Oi&&d!==536870912&&(o.flags|=128,S=!0,Ga(m,!1),o.lanes=4194304);m.isBackwards?(T.sibling=o.child,o.child=T):(s=m.last,s!==null?s.sibling=T:o.child=T,m.last=T)}return m.tail!==null?(s=m.tail,m.rendering=s,m.tail=s.sibling,m.renderingStartTime=I(),s.sibling=null,d=Sn.current,be(Sn,S?d&1|2:d&1),_n&&Ia(o,m.treeForkCount),s):(jn(o),null);case 22:case 23:return Ci(o),Ef(),m=o.memoizedState!==null,s!==null?s.memoizedState!==null!==m&&(o.flags|=8192):m&&(o.flags|=8192),m?(d&536870912)!==0&&(o.flags&128)===0&&(jn(o),o.subtreeFlags&6&&(o.flags|=8192)):jn(o),d=o.updateQueue,d!==null&&_o(o,d.retryQueue),d=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(d=s.memoizedState.cachePool.pool),m=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(m=o.memoizedState.cachePool.pool),m!==d&&(o.flags|=2048),s!==null&&fe(il),null;case 24:return d=null,s!==null&&(d=s.memoizedState.cache),o.memoizedState.cache!==d&&(o.flags|=2048),Ba(ki),jn(o),null;case 25:return null;case 30:return null}throw Error(i(156,o.tag))}function $s(s,o){switch(Kd(o),o.tag){case 1:return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 3:return Ba(ki),Ge(),s=o.flags,(s&65536)!==0&&(s&128)===0?(o.flags=s&-65537|128,o):null;case 26:case 27:case 5:return _t(o),null;case 31:if(o.memoizedState!==null){if(Ci(o),o.alternate===null)throw Error(i(340));el()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 13:if(Ci(o),s=o.memoizedState,s!==null&&s.dehydrated!==null){if(o.alternate===null)throw Error(i(340));el()}return s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 19:return fe(Sn),null;case 4:return Ge(),null;case 10:return Ba(o.type),null;case 22:case 23:return Ci(o),Ef(),s!==null&&fe(il),s=o.flags,s&65536?(o.flags=s&-65537|128,o):null;case 24:return Ba(ki),null;case 25:return null;default:return null}}function _s(s,o){switch(Kd(o),o.tag){case 3:Ba(ki),Ge();break;case 26:case 27:case 5:_t(o);break;case 4:Ge();break;case 31:o.memoizedState!==null&&Ci(o);break;case 13:Ci(o);break;case 19:fe(Sn);break;case 10:Ba(o.type);break;case 22:case 23:Ci(o),Ef(),s!==null&&fe(il);break;case 24:Ba(ki)}}function Xs(s,o){try{var d=o.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var S=m.next;d=S;do{if((d.tag&s)===s){m=void 0;var T=d.create,B=d.inst;m=T(),B.destroy=m}d=d.next}while(d!==S)}}catch($){Dn(o,o.return,$)}}function mr(s,o,d){try{var m=o.updateQueue,S=m!==null?m.lastEffect:null;if(S!==null){var T=S.next;m=T;do{if((m.tag&s)===s){var B=m.inst,$=B.destroy;if($!==void 0){B.destroy=void 0,S=o;var ae=d,Me=$;try{Me()}catch(Be){Dn(S,ae,Be)}}}m=m.next}while(m!==T)}}catch(Be){Dn(o,o.return,Be)}}function da(s){var o=s.updateQueue;if(o!==null){var d=s.stateNode;try{Sv(o,d)}catch(m){Dn(s,s.return,m)}}}function cr(s,o,d){d.props=ll(s.type,s.memoizedProps),d.state=s.memoizedState;try{d.componentWillUnmount()}catch(m){Dn(s,o,m)}}function So(s,o){try{var d=s.ref;if(d!==null){switch(s.tag){case 26:case 27:case 5:var m=s.stateNode;break;case 30:m=s.stateNode;break;default:m=s.stateNode}typeof d=="function"?s.refCleanup=d(m):d.current=m}}catch(S){Dn(s,o,S)}}function gr(s,o){var d=s.ref,m=s.refCleanup;if(d!==null)if(typeof m=="function")try{m()}catch(S){Dn(s,o,S)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(S){Dn(s,o,S)}else d.current=null}function If(s){var o=s.type,d=s.memoizedProps,m=s.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":d.autoFocus&&m.focus();break e;case"img":d.src?m.src=d.src:d.srcSet&&(m.srcset=d.srcSet)}}catch(S){Dn(s,s.return,S)}}function Ji(s,o,d){try{var m=s.stateNode;CI(m,s.type,d,o),m[Yi]=o}catch(S){Dn(s,s.return,S)}}function ui(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&yu(s.type)||s.tag===4}function bn(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||ui(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&&yu(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Wa(s,o,d){var m=s.tag;if(m===5||m===6)s=s.stateNode,o?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(s,o):(o=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,o.appendChild(s),d=d._reactRootContainer,d!=null||o.onclick!==null||(o.onclick=co));else if(m!==4&&(m===27&&yu(s.type)&&(d=s.stateNode,o=null),s=s.child,s!==null))for(Wa(s,o,d),s=s.sibling;s!==null;)Wa(s,o,d),s=s.sibling}function kr(s,o,d){var m=s.tag;if(m===5||m===6)s=s.stateNode,o?d.insertBefore(s,o):d.appendChild(s);else if(m!==4&&(m===27&&yu(s.type)&&(d=s.stateNode),s=s.child,s!==null))for(kr(s,o,d),s=s.sibling;s!==null;)kr(s,o,d),s=s.sibling}function Ch(s){var o=s.stateNode,d=s.memoizedProps;try{for(var m=s.type,S=o.attributes;S.length;)o.removeAttributeNode(S[0]);Wr(o,m,d),o[mi]=s,o[Yi]=d}catch(T){Dn(s,s.return,T)}}var js=!1,ti=!1,ha=!1,uy=typeof WeakSet=="function"?WeakSet:Set,ur=null;function J_(s,o){if(s=s.containerInfo,sS=xy,s=dv(s),cm(s)){if("selectionStart"in s)var d={start:s.selectionStart,end:s.selectionEnd};else e:{d=(d=s.ownerDocument)&&d.defaultView||window;var m=d.getSelection&&d.getSelection();if(m&&m.rangeCount!==0){d=m.anchorNode;var S=m.anchorOffset,T=m.focusNode;m=m.focusOffset;try{d.nodeType,T.nodeType}catch{d=null;break e}var B=0,$=-1,ae=-1,Me=0,Be=0,We=s,Re=null;t:for(;;){for(var Ue;We!==d||S!==0&&We.nodeType!==3||($=B+S),We!==T||m!==0&&We.nodeType!==3||(ae=B+m),We.nodeType===3&&(B+=We.nodeValue.length),(Ue=We.firstChild)!==null;)Re=We,We=Ue;for(;;){if(We===s)break t;if(Re===d&&++Me===S&&($=B),Re===T&&++Be===m&&(ae=B),(Ue=We.nextSibling)!==null)break;We=Re,Re=We.parentNode}We=Ue}d=$===-1||ae===-1?null:{start:$,end:ae}}else d=null}d=d||{start:0,end:0}}else d=null;for(aS={focusedElem:s,selectionRange:d},xy=!1,ur=o;ur!==null;)if(o=ur,s=o.child,(o.subtreeFlags&1028)!==0&&s!==null)s.return=o,ur=s;else for(;ur!==null;){switch(o=ur,T=o.alternate,s=o.flags,o.tag){case 0:if((s&4)!==0&&(s=o.updateQueue,s=s!==null?s.events:null,s!==null))for(d=0;d title"))),Wr(T,m,d),T[mi]=s,W(T),m=T;break e;case"link":var B=XT("link","href",S).get(m+(d.href||""));if(B){for(var $=0;$ii&&(B=ii,ii=jt,jt=B);var me=Wc($,jt),ce=Wc($,ii);if(me&&ce&&(Ue.rangeCount!==1||Ue.anchorNode!==me.node||Ue.anchorOffset!==me.offset||Ue.focusNode!==ce.node||Ue.focusOffset!==ce.offset)){var Se=We.createRange();Se.setStart(me.node,me.offset),Ue.removeAllRanges(),jt>ii?(Ue.addRange(Se),Ue.extend(ce.node,ce.offset)):(Se.setEnd(ce.node,ce.offset),Ue.addRange(Se))}}}}for(We=[],Ue=$;Ue=Ue.parentNode;)Ue.nodeType===1&&We.push({element:Ue,left:Ue.scrollLeft,top:Ue.scrollTop});for(typeof $.focus=="function"&&$.focus(),$=0;$d?32:d,q.T=null,d=hu,hu=null;var T=Es,B=Qs;if(Hn=0,fu=Es=null,Qs=0,(It&6)!==0)throw Error(i(331));var $=It;if(It|=4,es(T.current),ng(T,T.current,B,d),It=$,Mt(0,!1),Ke&&typeof Ke.onPostCommitFiberRoot=="function")try{Ke.onPostCommitFiberRoot($e,T)}catch{}return!0}finally{Z.p=S,q.T=m,Ya(s,o)}}function sg(s,o,d){o=vs(d,o),o=Ym(s.stateNode,o,2),s=rl(s,o,2),s!==null&&(pi(s,2),Je(s))}function Dn(s,o,d){if(s.tag===3)sg(s,s,d);else for(;o!==null;){if(o.tag===3){sg(o,s,d);break}else if(o.tag===1){var m=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Pi===null||!Pi.has(m))){s=vs(d,s),d=Zm(2),m=rl(o,d,2),m!==null&&(sy(d,m,o,s),pi(m,2),Je(m));break}}o=o.return}}function kf(s,o,d){var m=s.pingCache;if(m===null){m=s.pingCache=new nn;var S=new Set;m.set(o,S)}else S=m.get(o),S===void 0&&(S=new Set,m.set(o,S));S.has(d)||(ig=!0,S.add(d),s=c.bind(null,s,o,d),o.then(s,s))}function c(s,o,d){var m=s.pingCache;m!==null&&m.delete(o),s.pingedLanes|=s.suspendedLanes&d,s.warmLanes&=~d,Zt===s&&(an&d)===d&&(bi===4||bi===3&&(an&62914560)===an&&300>I()-uu?(It&2)===0&&gl(s,0):Lf|=d,oi===an&&(oi=0)),Je(s)}function f(s,o){o===0&&(o=sn()),s=zr(s,o),s!==null&&(pi(s,o),Je(s))}function v(s){var o=s.memoizedState,d=0;o!==null&&(d=o.retryLane),f(s,d)}function _(s,o){var d=0;switch(s.tag){case 31:case 13:var m=s.stateNode,S=s.memoizedState;S!==null&&(d=S.retryLane);break;case 19:m=s.stateNode;break;case 22:m=s.stateNode._retryCache;break;default:throw Error(i(314))}m!==null&&m.delete(o),f(s,d)}function C(s,o){return st(s,o)}var O=null,G=null,le=!1,Ne=!1,qe=!1,ft=0;function Je(s){s!==G&&s.next===null&&(G===null?O=G=s:G=G.next=s),Ne=!0,le||(le=!0,ve())}function Mt(s,o){if(!qe&&Ne){qe=!0;do for(var d=!1,m=O;m!==null;){if(s!==0){var S=m.pendingLanes;if(S===0)var T=0;else{var B=m.suspendedLanes,$=m.pingedLanes;T=(1<<31-te(42|s)+1)-1,T&=S&~(B&~$),T=T&201326741?T&201326741|1:T?T|2:0}T!==0&&(d=!0,Ae(m,T))}else T=an,T=He(m,m===Zt?T:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(T&3)===0||tt(m,T)||(d=!0,Ae(m,T));m=m.next}while(d);qe=!1}}function Jt(){Ii()}function Ii(){Ne=le=!1;var s=0;ft!==0&&DI()&&(s=ft);for(var o=I(),d=null,m=O;m!==null;){var S=m.next,T=vu(m,o);T===0?(m.next=null,d===null?O=S:d.next=S,S===null&&(G=d)):(d=m,(s!==0||(T&3)!==0)&&(Ne=!0)),m=S}Hn!==0&&Hn!==5||Mt(s),ft!==0&&(ft=0)}function vu(s,o){for(var d=s.suspendedLanes,m=s.pingedLanes,S=s.expirationTimes,T=s.pendingLanes&-62914561;0$)break;var Be=ae.transferSize,We=ae.initiatorType;Be&&DT(We)&&(ae=ae.responseEnd,B+=Be*(ae<$?1:($-Me)/(ae-Me)))}if(--m,o+=8*(T+B)/(S.duration/1e3),s++,10"u"?null:document;function VT(s,o,d){var m=Nh;if(m&&typeof o=="string"&&o){var S=Xt(o);S='link[rel="'+s+'"][href="'+S+'"]',typeof d=="string"&&(S+='[crossorigin="'+d+'"]'),HT.has(S)||(HT.add(S),s={rel:s,crossOrigin:d,href:o},m.querySelector(S)===null&&(o=m.createElement("link"),Wr(o,"link",s),W(o),m.head.appendChild(o)))}}function FI(s){hc.D(s),VT("dns-prefetch",s,null)}function kI(s,o){hc.C(s,o),VT("preconnect",s,o)}function HI(s,o,d){hc.L(s,o,d);var m=Nh;if(m&&s&&o){var S='link[rel="preload"][as="'+Xt(o)+'"]';o==="image"&&d&&d.imageSrcSet?(S+='[imagesrcset="'+Xt(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(S+='[imagesizes="'+Xt(d.imageSizes)+'"]')):S+='[href="'+Xt(s)+'"]';var T=S;switch(o){case"style":T=Lh(s);break;case"script":T=Uh(s)}Ka.has(T)||(s=y({rel:"preload",href:o==="image"&&d&&d.imageSrcSet?void 0:s,as:o},d),Ka.set(T,s),m.querySelector(S)!==null||o==="style"&&m.querySelector(lg(T))||o==="script"&&m.querySelector(cg(T))||(o=m.createElement("link"),Wr(o,"link",s),W(o),m.head.appendChild(o)))}}function VI(s,o){hc.m(s,o);var d=Nh;if(d&&s){var m=o&&typeof o.as=="string"?o.as:"script",S='link[rel="modulepreload"][as="'+Xt(m)+'"][href="'+Xt(s)+'"]',T=S;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":T=Uh(s)}if(!Ka.has(T)&&(s=y({rel:"modulepreload",href:s},o),Ka.set(T,s),d.querySelector(S)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(cg(T)))return}m=d.createElement("link"),Wr(m,"link",s),W(m),d.head.appendChild(m)}}}function GI(s,o,d){hc.S(s,o,d);var m=Nh;if(m&&s){var S=Aa(m).hoistableStyles,T=Lh(s);o=o||"default";var B=S.get(T);if(!B){var $={loading:0,preload:null};if(B=m.querySelector(lg(T)))$.loading=5;else{s=y({rel:"stylesheet",href:s,"data-precedence":o},d),(d=Ka.get(T))&&hS(s,d);var ae=B=m.createElement("link");W(ae),Wr(ae,"link",s),ae._p=new Promise(function(Me,Be){ae.onload=Me,ae.onerror=Be}),ae.addEventListener("load",function(){$.loading|=1}),ae.addEventListener("error",function(){$.loading|=2}),$.loading|=4,my(B,o,m)}B={type:"stylesheet",instance:B,count:1,state:$},S.set(T,B)}}}function WI(s,o){hc.X(s,o);var d=Nh;if(d&&s){var m=Aa(d).hoistableScripts,S=Uh(s),T=m.get(S);T||(T=d.querySelector(cg(S)),T||(s=y({src:s,async:!0},o),(o=Ka.get(S))&&pS(s,o),T=d.createElement("script"),W(T),Wr(T,"link",s),d.head.appendChild(T)),T={type:"script",instance:T,count:1,state:null},m.set(S,T))}}function $I(s,o){hc.M(s,o);var d=Nh;if(d&&s){var m=Aa(d).hoistableScripts,S=Uh(s),T=m.get(S);T||(T=d.querySelector(cg(S)),T||(s=y({src:s,async:!0,type:"module"},o),(o=Ka.get(S))&&pS(s,o),T=d.createElement("script"),W(T),Wr(T,"link",s),d.head.appendChild(T)),T={type:"script",instance:T,count:1,state:null},m.set(S,T))}}function GT(s,o,d,m){var S=(S=he.current)?py(S):null;if(!S)throw Error(i(446));switch(s){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(o=Lh(d.href),d=Aa(S).hoistableStyles,m=d.get(o),m||(m={type:"style",instance:null,count:0,state:null},d.set(o,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){s=Lh(d.href);var T=Aa(S).hoistableStyles,B=T.get(s);if(B||(S=S.ownerDocument||S,B={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},T.set(s,B),(T=S.querySelector(lg(s)))&&!T._p&&(B.instance=T,B.state.loading=5),Ka.has(s)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},Ka.set(s,d),T||XI(S,s,d,B.state))),o&&m===null)throw Error(i(528,""));return B}if(o&&m!==null)throw Error(i(529,""));return null;case"script":return o=d.async,d=d.src,typeof d=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=Uh(d),d=Aa(S).hoistableScripts,m=d.get(o),m||(m={type:"script",instance:null,count:0,state:null},d.set(o,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,s))}}function Lh(s){return'href="'+Xt(s)+'"'}function lg(s){return'link[rel="stylesheet"]['+s+"]"}function WT(s){return y({},s,{"data-precedence":s.precedence,precedence:null})}function XI(s,o,d,m){s.querySelector('link[rel="preload"][as="style"]['+o+"]")?m.loading=1:(o=s.createElement("link"),m.preload=o,o.addEventListener("load",function(){return m.loading|=1}),o.addEventListener("error",function(){return m.loading|=2}),Wr(o,"link",d),W(o),s.head.appendChild(o))}function Uh(s){return'[src="'+Xt(s)+'"]'}function cg(s){return"script[async]"+s}function $T(s,o,d){if(o.count++,o.instance===null)switch(o.type){case"style":var m=s.querySelector('style[data-href~="'+Xt(d.href)+'"]');if(m)return o.instance=m,W(m),m;var S=y({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return m=(s.ownerDocument||s).createElement("style"),W(m),Wr(m,"style",S),my(m,d.precedence,s),o.instance=m;case"stylesheet":S=Lh(d.href);var T=s.querySelector(lg(S));if(T)return o.state.loading|=4,o.instance=T,W(T),T;m=WT(d),(S=Ka.get(S))&&hS(m,S),T=(s.ownerDocument||s).createElement("link"),W(T);var B=T;return B._p=new Promise(function($,ae){B.onload=$,B.onerror=ae}),Wr(T,"link",m),o.state.loading|=4,my(T,d.precedence,s),o.instance=T;case"script":return T=Uh(d.src),(S=s.querySelector(cg(T)))?(o.instance=S,W(S),S):(m=d,(S=Ka.get(T))&&(m=y({},d),pS(m,S)),s=s.ownerDocument||s,S=s.createElement("script"),W(S),Wr(S,"link",m),s.head.appendChild(S),o.instance=S);case"void":return null;default:throw Error(i(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(m=o.instance,o.state.loading|=4,my(m,d.precedence,s));return o.instance}function my(s,o,d){for(var m=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),S=m.length?m[m.length-1]:null,T=S,B=0;B title"):null)}function jI(s,o,d){if(d===1||o.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;return o.rel==="stylesheet"?(s=o.disabled,typeof o.precedence=="string"&&s==null):!0;case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function qT(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function qI(s,o,d,m){if(d.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var S=Lh(m.href),T=o.querySelector(lg(S));if(T){o=T._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(s.count++,s=vy.bind(s),o.then(s,s)),d.state.loading|=4,d.instance=T,W(T);return}T=o.ownerDocument||o,m=WT(m),(S=Ka.get(S))&&hS(m,S),T=T.createElement("link"),W(T);var B=T;B._p=new Promise(function($,ae){B.onload=$,B.onerror=ae}),Wr(T,"link",m),d.instance=T}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(d,o),(o=d.state.preload)&&(d.state.loading&3)===0&&(s.count++,d=vy.bind(s),o.addEventListener("load",d),o.addEventListener("error",d))}}var mS=0;function YI(s,o){return s.stylesheets&&s.count===0&&by(s,s.stylesheets),0mS?50:800)+o);return s.unsuspend=d,function(){s.unsuspend=null,clearTimeout(m),clearTimeout(S)}}:null}function vy(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)by(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var yy=null;function by(s,o){s.stylesheets=null,s.unsuspend!==null&&(s.count++,yy=new Map,o.forEach(ZI,s),yy=null,vy.call(s))}function ZI(s,o){if(!(o.state.loading&4)){var d=yy.get(s);if(d)var m=d.get(null);else{d=new Map,yy.set(s,d);for(var S=s.querySelectorAll("link[data-precedence],style[data-precedence]"),T=0;T"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),ES.exports=fN(),ES.exports}var o3=dN();const Td="182",nd={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},id={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},l3=0,sM=1,c3=2,hN=3,u3=0,vp=1,kg=2,ad=3,Al=0,_r=1,xr=2,Pr=0,fd=1,Ub=2,aM=3,oM=4,qx=5,Mc=100,f3=101,d3=102,h3=103,tE=104,p3=200,Iu=201,m3=202,nE=203,zb=204,_p=205,g3=206,v3=207,iE=208,y3=209,b3=210,x3=211,_3=212,S3=213,M3=214,Bb=0,e0=1,Fb=2,vd=3,kb=4,Hb=5,Vb=6,Gb=7,E0=0,E3=1,T3=2,xa=0,rE=1,sE=2,aE=3,Yx=4,oE=5,lE=6,cE=7,lM="attached",w3="detached",Zx=300,Cl=301,Fu=302,t0=303,n0=304,Np=306,i0=1e3,aa=1001,r0=1002,Kn=1003,uE=1004,pN=1004,hp=1005,mN=1005,Nn=1006,Hg=1007,gN=1007,Io=1008,vN=1008,Xi=1009,fE=1010,dE=1011,Sp=1012,Kx=1013,Ea=1014,Or=1015,no=1016,Qx=1017,Jx=1018,yd=1020,hE=35902,pE=35899,mE=1021,gE=1022,$r=1023,Rl=1026,wc=1027,T0=1028,w0=1029,bd=1030,e_=1031,yN=1032,t_=1033,Vg=33776,Gg=33777,Wg=33778,$g=33779,Wb=35840,$b=35841,Xb=35842,jb=35843,qb=36196,Yb=37492,Zb=37496,Kb=37488,Qb=37489,Jb=37490,ex=37491,tx=37808,nx=37809,ix=37810,rx=37811,sx=37812,ax=37813,ox=37814,lx=37815,cx=37816,ux=37817,fx=37818,dx=37819,hx=37820,px=37821,mx=36492,gx=36494,vx=36495,yx=36283,bx=36284,xx=36285,_x=36286,A3=2200,C3=2201,R3=2202,s0=2300,Sx=2301,Rb=2302,od=2400,ld=2401,a0=2402,n_=2500,vE=2501,bN=0,xN=1,_N=2,Zu=3200,SN=3201,MN=3202,EN=3203,Ku=0,D3=1,Po="",Fn="srgb",Dl="srgb-linear",o0="linear",qn="srgb",TN="",wN="rg",AN="ga",CN=0,rd=7680,RN=7681,DN=7682,ON=7683,PN=34055,IN=34056,NN=5386,LN=512,UN=513,zN=514,BN=515,FN=516,kN=517,HN=518,cM=519,O3=512,P3=513,I3=514,i_=515,N3=516,L3=517,r_=518,U3=519,l0=35044,VN=35048,GN=35040,WN=35045,$N=35049,XN=35041,jN=35046,qN=35050,YN=35042,ZN="100",uM="300 es",ba=2e3,Mp=2001,KN={COMPUTE:"compute",RENDER:"render"},QN={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},JN={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function z3(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const eL={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function pp(n,e){return new eL[n](e)}function B3(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function c0(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function F3(){const n=c0("canvas");return n.style.display="block",n}const yw={};let ku=null;function tL(n){ku=n}function nL(){return ku}function u0(...n){const e="THREE."+n.shift();ku?ku("log",e,...n):console.log(e,...n)}function vt(...n){const e="THREE."+n.shift();ku?ku("warn",e,...n):console.warn(e,...n)}function Lt(...n){const e="THREE."+n.shift();ku?ku("error",e,...n):console.error(e,...n)}function Ep(...n){const e=n.join(" ");e in yw||(yw[e]=!0,vt(...n))}function iL(n,e,t){return new Promise(function(i,r){function a(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(a,t);break;default:i()}}setTimeout(a,t)})}let wa=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let a=0,l=r.length;a>8&255]+rs[n>>16&255]+rs[n>>24&255]+"-"+rs[e&255]+rs[e>>8&255]+"-"+rs[e>>16&15|64]+rs[e>>24&255]+"-"+rs[t&63|128]+rs[t>>8&255]+"-"+rs[t>>16&255]+rs[t>>24&255]+rs[i&255]+rs[i>>8&255]+rs[i>>16&255]+rs[i>>24&255]).toLowerCase()}function Yt(n,e,t){return Math.max(e,Math.min(t,n))}function yE(n,e){return(n%e+e)%e}function rL(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function sL(n,e,t){return n!==e?(t-n)/(e-n):0}function Xg(n,e,t){return(1-t)*n+t*e}function aL(n,e,t,i){return Xg(n,e,1-Math.exp(-t*i))}function oL(n,e=1){return e-Math.abs(yE(n,e*2)-e)}function lL(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function cL(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function uL(n,e){return n+Math.floor(Math.random()*(e-n+1))}function fL(n,e){return n+Math.random()*(e-n)}function dL(n){return n*(.5-Math.random())}function hL(n){n!==void 0&&(bw=n);let e=bw+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function pL(n){return n*dd}function mL(n){return n*Tp}function gL(n){return(n&n-1)===0&&n!==0}function vL(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function yL(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function bL(n,e,t,i,r){const a=Math.cos,l=Math.sin,u=a(t/2),h=l(t/2),p=a((e+i)/2),g=l((e+i)/2),y=a((e-i)/2),b=l((e-i)/2),x=a((i-e)/2),M=l((i-e)/2);switch(r){case"XYX":n.set(u*g,h*y,h*b,u*p);break;case"YZY":n.set(h*b,u*g,h*y,u*p);break;case"ZXZ":n.set(h*y,h*b,u*g,u*p);break;case"XZX":n.set(u*g,h*M,h*x,u*p);break;case"YXY":n.set(h*x,u*g,h*M,u*p);break;case"ZYZ":n.set(h*M,h*x,u*g,u*p);break;default:vt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Os(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function dn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const xL={DEG2RAD:dd,RAD2DEG:Tp,generateUUID:_a,clamp:Yt,euclideanModulo:yE,mapLinear:rL,inverseLerp:sL,lerp:Xg,damp:aL,pingpong:oL,smoothstep:lL,smootherstep:cL,randInt:uL,randFloat:fL,randFloatSpread:dL,seededRandom:hL,degToRad:pL,radToDeg:mL,isPowerOfTwo:gL,ceilPowerOfTwo:vL,floorPowerOfTwo:yL,setQuaternionFromProperEuler:bL,normalize:dn,denormalize:Os};class Le{constructor(e=0,t=0){Le.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Yt(this.x,e.x,t.x),this.y=Yt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Yt(this.x,e,t),this.y=Yt(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Yt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Yt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),r=Math.sin(t),a=this.x-e.x,l=this.y-e.y;return this.x=a*i-l*r+e.x,this.y=a*r+l*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class cs{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,a,l,u){let h=i[r+0],p=i[r+1],g=i[r+2],y=i[r+3],b=a[l+0],x=a[l+1],M=a[l+2],A=a[l+3];if(u<=0){e[t+0]=h,e[t+1]=p,e[t+2]=g,e[t+3]=y;return}if(u>=1){e[t+0]=b,e[t+1]=x,e[t+2]=M,e[t+3]=A;return}if(y!==A||h!==b||p!==x||g!==M){let w=h*b+p*x+g*M+y*A;w<0&&(b=-b,x=-x,M=-M,A=-A,w=-w);let E=1-u;if(w<.9995){const R=Math.acos(w),D=Math.sin(R);E=Math.sin(E*R)/D,u=Math.sin(u*R)/D,h=h*E+b*u,p=p*E+x*u,g=g*E+M*u,y=y*E+A*u}else{h=h*E+b*u,p=p*E+x*u,g=g*E+M*u,y=y*E+A*u;const R=1/Math.sqrt(h*h+p*p+g*g+y*y);h*=R,p*=R,g*=R,y*=R}}e[t]=h,e[t+1]=p,e[t+2]=g,e[t+3]=y}static multiplyQuaternionsFlat(e,t,i,r,a,l){const u=i[r],h=i[r+1],p=i[r+2],g=i[r+3],y=a[l],b=a[l+1],x=a[l+2],M=a[l+3];return e[t]=u*M+g*y+h*x-p*b,e[t+1]=h*M+g*b+p*y-u*x,e[t+2]=p*M+g*x+u*b-h*y,e[t+3]=g*M-u*y-h*b-p*x,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,r=e._y,a=e._z,l=e._order,u=Math.cos,h=Math.sin,p=u(i/2),g=u(r/2),y=u(a/2),b=h(i/2),x=h(r/2),M=h(a/2);switch(l){case"XYZ":this._x=b*g*y+p*x*M,this._y=p*x*y-b*g*M,this._z=p*g*M+b*x*y,this._w=p*g*y-b*x*M;break;case"YXZ":this._x=b*g*y+p*x*M,this._y=p*x*y-b*g*M,this._z=p*g*M-b*x*y,this._w=p*g*y+b*x*M;break;case"ZXY":this._x=b*g*y-p*x*M,this._y=p*x*y+b*g*M,this._z=p*g*M+b*x*y,this._w=p*g*y-b*x*M;break;case"ZYX":this._x=b*g*y-p*x*M,this._y=p*x*y+b*g*M,this._z=p*g*M-b*x*y,this._w=p*g*y+b*x*M;break;case"YZX":this._x=b*g*y+p*x*M,this._y=p*x*y+b*g*M,this._z=p*g*M-b*x*y,this._w=p*g*y-b*x*M;break;case"XZY":this._x=b*g*y-p*x*M,this._y=p*x*y-b*g*M,this._z=p*g*M+b*x*y,this._w=p*g*y+b*x*M;break;default:vt("Quaternion: .setFromEuler() encountered an unknown order: "+l)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],a=t[8],l=t[1],u=t[5],h=t[9],p=t[2],g=t[6],y=t[10],b=i+u+y;if(b>0){const x=.5/Math.sqrt(b+1);this._w=.25/x,this._x=(g-h)*x,this._y=(a-p)*x,this._z=(l-r)*x}else if(i>u&&i>y){const x=2*Math.sqrt(1+i-u-y);this._w=(g-h)/x,this._x=.25*x,this._y=(r+l)/x,this._z=(a+p)/x}else if(u>y){const x=2*Math.sqrt(1+u-i-y);this._w=(a-p)/x,this._x=(r+l)/x,this._y=.25*x,this._z=(h+g)/x}else{const x=2*Math.sqrt(1+y-i-u);this._w=(l-r)/x,this._x=(a+p)/x,this._y=(h+g)/x,this._z=.25*x}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Yt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,r=e._y,a=e._z,l=e._w,u=t._x,h=t._y,p=t._z,g=t._w;return this._x=i*g+l*u+r*p-a*h,this._y=r*g+l*h+a*u-i*p,this._z=a*g+l*p+i*h-r*u,this._w=l*g-i*u-r*h-a*p,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,r=e._y,a=e._z,l=e._w,u=this.dot(e);u<0&&(i=-i,r=-r,a=-a,l=-l,u=-u);let h=1-t;if(u<.9995){const p=Math.acos(u),g=Math.sin(p);h=Math.sin(h*p)/g,t=Math.sin(t*p)/g,this._x=this._x*h+i*t,this._y=this._y*h+r*t,this._z=this._z*h+a*t,this._w=this._w*h+l*t,this._onChangeCallback()}else this._x=this._x*h+i*t,this._y=this._y*h+r*t,this._z=this._z*h+a*t,this._w=this._w*h+l*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),a=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),a*Math.sin(t),a*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class K{constructor(e=0,t=0,i=0){K.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(xw.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(xw.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6]*r,this.y=a[1]*t+a[4]*i+a[7]*r,this.z=a[2]*t+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,a=e.elements,l=1/(a[3]*t+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*t+a[4]*i+a[8]*r+a[12])*l,this.y=(a[1]*t+a[5]*i+a[9]*r+a[13])*l,this.z=(a[2]*t+a[6]*i+a[10]*r+a[14])*l,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,a=e.x,l=e.y,u=e.z,h=e.w,p=2*(l*r-u*i),g=2*(u*t-a*r),y=2*(a*i-l*t);return this.x=t+h*p+l*y-u*g,this.y=i+h*g+u*p-a*y,this.z=r+h*y+a*g-l*p,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r,this.y=a[1]*t+a[5]*i+a[9]*r,this.z=a[2]*t+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Yt(this.x,e.x,t.x),this.y=Yt(this.y,e.y,t.y),this.z=Yt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Yt(this.x,e,t),this.y=Yt(this.y,e,t),this.z=Yt(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Yt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,a=e.z,l=t.x,u=t.y,h=t.z;return this.x=r*h-a*u,this.y=a*l-i*h,this.z=i*u-r*l,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return CS.copy(this).projectOnVector(e),this.sub(CS)}reflect(e){return this.sub(CS.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Yt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const CS=new K,xw=new cs;class on{constructor(e,t,i,r,a,l,u,h,p){on.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,l,u,h,p)}set(e,t,i,r,a,l,u,h,p){const g=this.elements;return g[0]=e,g[1]=r,g[2]=u,g[3]=t,g[4]=a,g[5]=h,g[6]=i,g[7]=l,g[8]=p,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,a=this.elements,l=i[0],u=i[3],h=i[6],p=i[1],g=i[4],y=i[7],b=i[2],x=i[5],M=i[8],A=r[0],w=r[3],E=r[6],R=r[1],D=r[4],P=r[7],F=r[2],L=r[5],k=r[8];return a[0]=l*A+u*R+h*F,a[3]=l*w+u*D+h*L,a[6]=l*E+u*P+h*k,a[1]=p*A+g*R+y*F,a[4]=p*w+g*D+y*L,a[7]=p*E+g*P+y*k,a[2]=b*A+x*R+M*F,a[5]=b*w+x*D+M*L,a[8]=b*E+x*P+M*k,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],l=e[4],u=e[5],h=e[6],p=e[7],g=e[8];return t*l*g-t*u*p-i*a*g+i*u*h+r*a*p-r*l*h}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],l=e[4],u=e[5],h=e[6],p=e[7],g=e[8],y=g*l-u*p,b=u*h-g*a,x=p*a-l*h,M=t*y+i*b+r*x;if(M===0)return this.set(0,0,0,0,0,0,0,0,0);const A=1/M;return e[0]=y*A,e[1]=(r*p-g*i)*A,e[2]=(u*i-r*l)*A,e[3]=b*A,e[4]=(g*t-r*h)*A,e[5]=(r*a-u*t)*A,e[6]=x*A,e[7]=(i*h-p*t)*A,e[8]=(l*t-i*a)*A,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,a,l,u){const h=Math.cos(a),p=Math.sin(a);return this.set(i*h,i*p,-i*(h*l+p*u)+l+e,-r*p,r*h,-r*(-p*l+h*u)+u+t,0,0,1),this}scale(e,t){return this.premultiply(RS.makeScale(e,t)),this}rotate(e){return this.premultiply(RS.makeRotation(-e)),this}translate(e,t){return this.premultiply(RS.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const RS=new on,_w=new on().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Sw=new on().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function _L(){const n={enabled:!0,workingColorSpace:Dl,spaces:{},convert:function(r,a,l){return this.enabled===!1||a===l||!a||!l||(this.spaces[a].transfer===qn&&(r.r=Ac(r.r),r.g=Ac(r.g),r.b=Ac(r.b)),this.spaces[a].primaries!==this.spaces[l].primaries&&(r.applyMatrix3(this.spaces[a].toXYZ),r.applyMatrix3(this.spaces[l].fromXYZ)),this.spaces[l].transfer===qn&&(r.r=yp(r.r),r.g=yp(r.g),r.b=yp(r.b))),r},workingToColorSpace:function(r,a){return this.convert(r,this.workingColorSpace,a)},colorSpaceToWorking:function(r,a){return this.convert(r,a,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Po?o0:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,a=this.workingColorSpace){return r.fromArray(this.spaces[a].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,a,l){return r.copy(this.spaces[a].toXYZ).multiply(this.spaces[l].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,a){return Ep("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return Ep("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,a)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Dl]:{primaries:e,whitePoint:i,transfer:o0,toXYZ:_w,fromXYZ:Sw,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Fn},outputColorSpaceConfig:{drawingBufferColorSpace:Fn}},[Fn]:{primaries:e,whitePoint:i,transfer:qn,toXYZ:_w,fromXYZ:Sw,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Fn}}}),n}const Cn=_L();function Ac(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function yp(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Bh;class k3{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Bh===void 0&&(Bh=c0("canvas")),Bh.width=e.width,Bh.height=e.height;const r=Bh.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Bh}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=c0("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let l=0;l1),this.pmremVersion=0}get width(){return this.source.getSize(OS).x}get height(){return this.source.getSize(OS).y}get depth(){return this.source.getSize(OS).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){vt(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){vt(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Zx)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case i0:e.x=e.x-Math.floor(e.x);break;case aa:e.x=e.x<0?0:1;break;case r0:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case i0:e.y=e.y-Math.floor(e.y);break;case aa:e.y=e.y<0?0:1;break;case r0:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ai.DEFAULT_IMAGE=null;Ai.DEFAULT_MAPPING=Zx;Ai.DEFAULT_ANISOTROPY=1;class Zn{constructor(e=0,t=0,i=0,r=1){Zn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,a=this.w,l=e.elements;return this.x=l[0]*t+l[4]*i+l[8]*r+l[12]*a,this.y=l[1]*t+l[5]*i+l[9]*r+l[13]*a,this.z=l[2]*t+l[6]*i+l[10]*r+l[14]*a,this.w=l[3]*t+l[7]*i+l[11]*r+l[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,a;const h=e.elements,p=h[0],g=h[4],y=h[8],b=h[1],x=h[5],M=h[9],A=h[2],w=h[6],E=h[10];if(Math.abs(g-b)<.01&&Math.abs(y-A)<.01&&Math.abs(M-w)<.01){if(Math.abs(g+b)<.1&&Math.abs(y+A)<.1&&Math.abs(M+w)<.1&&Math.abs(p+x+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const D=(p+1)/2,P=(x+1)/2,F=(E+1)/2,L=(g+b)/4,k=(y+A)/4,V=(M+w)/4;return D>P&&D>F?D<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(D),r=L/i,a=k/i):P>F?P<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(P),i=L/r,a=V/r):F<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(F),i=k/a,r=V/a),this.set(i,r,a,t),this}let R=Math.sqrt((w-M)*(w-M)+(y-A)*(y-A)+(b-g)*(b-g));return Math.abs(R)<.001&&(R=1),this.x=(w-M)/R,this.y=(y-A)/R,this.z=(b-g)/R,this.w=Math.acos((p+x+E-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Yt(this.x,e.x,t.x),this.y=Yt(this.y,e.y,t.y),this.z=Yt(this.z,e.z,t.z),this.w=Yt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Yt(this.x,e,t),this.y=Yt(this.y,e,t),this.z=Yt(this.z,e,t),this.w=Yt(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Yt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class bE extends wa{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Nn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Zn(0,0,e,t),this.scissorTest=!1,this.viewport=new Zn(0,0,e,t);const r={width:e,height:t,depth:i.depth},a=new Ai(r);this.textures=[];const l=i.count;for(let u=0;u1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Co),Co.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(gg),Cy.subVectors(this.max,gg),Fh.subVectors(e.a,gg),kh.subVectors(e.b,gg),Hh.subVectors(e.c,gg),Eu.subVectors(kh,Fh),Tu.subVectors(Hh,kh),Hf.subVectors(Fh,Hh);let t=[0,-Eu.z,Eu.y,0,-Tu.z,Tu.y,0,-Hf.z,Hf.y,Eu.z,0,-Eu.x,Tu.z,0,-Tu.x,Hf.z,0,-Hf.x,-Eu.y,Eu.x,0,-Tu.y,Tu.x,0,-Hf.y,Hf.x,0];return!PS(t,Fh,kh,Hh,Cy)||(t=[1,0,0,0,1,0,0,0,1],!PS(t,Fh,kh,Hh,Cy))?!1:(Ry.crossVectors(Eu,Tu),t=[Ry.x,Ry.y,Ry.z],PS(t,Fh,kh,Hh,Cy))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Co).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Co).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(pc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const pc=[new K,new K,new K,new K,new K,new K,new K,new K],Co=new K,Ay=new us,Fh=new K,kh=new K,Hh=new K,Eu=new K,Tu=new K,Hf=new K,gg=new K,Cy=new K,Ry=new K,Vf=new K;function PS(n,e,t,i,r){for(let a=0,l=n.length-3;a<=l;a+=3){Vf.fromArray(n,a);const u=r.x*Math.abs(Vf.x)+r.y*Math.abs(Vf.y)+r.z*Math.abs(Vf.z),h=e.dot(Vf),p=t.dot(Vf),g=i.dot(Vf);if(Math.max(-Math.max(h,p,g),Math.min(h,p,g))>u)return!1}return!0}const wL=new us,vg=new K,IS=new K;class Xr{constructor(e=new K,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):wL.setFromPoints(e).getCenter(i);let r=0;for(let a=0,l=e.length;athis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;vg.subVectors(e,this.center);const t=vg.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(vg,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(IS.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vg.copy(e.center).add(IS)),this.expandByPoint(vg.copy(e.center).sub(IS))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const mc=new K,NS=new K,Dy=new K,wu=new K,LS=new K,Oy=new K,US=new K;class wd{constructor(e=new K,t=new K(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,mc)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=mc.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(mc.copy(this.origin).addScaledVector(this.direction,t),mc.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){NS.copy(e).add(t).multiplyScalar(.5),Dy.copy(t).sub(e).normalize(),wu.copy(this.origin).sub(NS);const a=e.distanceTo(t)*.5,l=-this.direction.dot(Dy),u=wu.dot(this.direction),h=-wu.dot(Dy),p=wu.lengthSq(),g=Math.abs(1-l*l);let y,b,x,M;if(g>0)if(y=l*h-u,b=l*u-h,M=a*g,y>=0)if(b>=-M)if(b<=M){const A=1/g;y*=A,b*=A,x=y*(y+l*b+2*u)+b*(l*y+b+2*h)+p}else b=a,y=Math.max(0,-(l*b+u)),x=-y*y+b*(b+2*h)+p;else b=-a,y=Math.max(0,-(l*b+u)),x=-y*y+b*(b+2*h)+p;else b<=-M?(y=Math.max(0,-(-l*a+u)),b=y>0?-a:Math.min(Math.max(-a,-h),a),x=-y*y+b*(b+2*h)+p):b<=M?(y=0,b=Math.min(Math.max(-a,-h),a),x=b*(b+2*h)+p):(y=Math.max(0,-(l*a+u)),b=y>0?a:Math.min(Math.max(-a,-h),a),x=-y*y+b*(b+2*h)+p);else b=l>0?-a:a,y=Math.max(0,-(l*b+u)),x=-y*y+b*(b+2*h)+p;return i&&i.copy(this.origin).addScaledVector(this.direction,y),r&&r.copy(NS).addScaledVector(Dy,b),x}intersectSphere(e,t){mc.subVectors(e.center,this.origin);const i=mc.dot(this.direction),r=mc.dot(mc)-i*i,a=e.radius*e.radius;if(r>a)return null;const l=Math.sqrt(a-r),u=i-l,h=i+l;return h<0?null:u<0?this.at(h,t):this.at(u,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,a,l,u,h;const p=1/this.direction.x,g=1/this.direction.y,y=1/this.direction.z,b=this.origin;return p>=0?(i=(e.min.x-b.x)*p,r=(e.max.x-b.x)*p):(i=(e.max.x-b.x)*p,r=(e.min.x-b.x)*p),g>=0?(a=(e.min.y-b.y)*g,l=(e.max.y-b.y)*g):(a=(e.max.y-b.y)*g,l=(e.min.y-b.y)*g),i>l||a>r||((a>i||isNaN(i))&&(i=a),(l=0?(u=(e.min.z-b.z)*y,h=(e.max.z-b.z)*y):(u=(e.max.z-b.z)*y,h=(e.min.z-b.z)*y),i>h||u>r)||((u>i||i!==i)&&(i=u),(h=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,mc)!==null}intersectTriangle(e,t,i,r,a){LS.subVectors(t,e),Oy.subVectors(i,e),US.crossVectors(LS,Oy);let l=this.direction.dot(US),u;if(l>0){if(r)return null;u=1}else if(l<0)u=-1,l=-l;else return null;wu.subVectors(this.origin,e);const h=u*this.direction.dot(Oy.crossVectors(wu,Oy));if(h<0)return null;const p=u*this.direction.dot(LS.cross(wu));if(p<0||h+p>l)return null;const g=-u*wu.dot(US);return g<0?null:this.at(g/l,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Kt{constructor(e,t,i,r,a,l,u,h,p,g,y,b,x,M,A,w){Kt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,l,u,h,p,g,y,b,x,M,A,w)}set(e,t,i,r,a,l,u,h,p,g,y,b,x,M,A,w){const E=this.elements;return E[0]=e,E[4]=t,E[8]=i,E[12]=r,E[1]=a,E[5]=l,E[9]=u,E[13]=h,E[2]=p,E[6]=g,E[10]=y,E[14]=b,E[3]=x,E[7]=M,E[11]=A,E[15]=w,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 Kt().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,r=1/Vh.setFromMatrixColumn(e,0).length(),a=1/Vh.setFromMatrixColumn(e,1).length(),l=1/Vh.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*a,t[5]=i[5]*a,t[6]=i[6]*a,t[7]=0,t[8]=i[8]*l,t[9]=i[9]*l,t[10]=i[10]*l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,a=e.z,l=Math.cos(i),u=Math.sin(i),h=Math.cos(r),p=Math.sin(r),g=Math.cos(a),y=Math.sin(a);if(e.order==="XYZ"){const b=l*g,x=l*y,M=u*g,A=u*y;t[0]=h*g,t[4]=-h*y,t[8]=p,t[1]=x+M*p,t[5]=b-A*p,t[9]=-u*h,t[2]=A-b*p,t[6]=M+x*p,t[10]=l*h}else if(e.order==="YXZ"){const b=h*g,x=h*y,M=p*g,A=p*y;t[0]=b+A*u,t[4]=M*u-x,t[8]=l*p,t[1]=l*y,t[5]=l*g,t[9]=-u,t[2]=x*u-M,t[6]=A+b*u,t[10]=l*h}else if(e.order==="ZXY"){const b=h*g,x=h*y,M=p*g,A=p*y;t[0]=b-A*u,t[4]=-l*y,t[8]=M+x*u,t[1]=x+M*u,t[5]=l*g,t[9]=A-b*u,t[2]=-l*p,t[6]=u,t[10]=l*h}else if(e.order==="ZYX"){const b=l*g,x=l*y,M=u*g,A=u*y;t[0]=h*g,t[4]=M*p-x,t[8]=b*p+A,t[1]=h*y,t[5]=A*p+b,t[9]=x*p-M,t[2]=-p,t[6]=u*h,t[10]=l*h}else if(e.order==="YZX"){const b=l*h,x=l*p,M=u*h,A=u*p;t[0]=h*g,t[4]=A-b*y,t[8]=M*y+x,t[1]=y,t[5]=l*g,t[9]=-u*g,t[2]=-p*g,t[6]=x*y+M,t[10]=b-A*y}else if(e.order==="XZY"){const b=l*h,x=l*p,M=u*h,A=u*p;t[0]=h*g,t[4]=-y,t[8]=p*g,t[1]=b*y+A,t[5]=l*g,t[9]=x*y-M,t[2]=M*y-x,t[6]=u*g,t[10]=A*y+b}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(AL,e,CL)}lookAt(e,t,i){const r=this.elements;return ga.subVectors(e,t),ga.lengthSq()===0&&(ga.z=1),ga.normalize(),Au.crossVectors(i,ga),Au.lengthSq()===0&&(Math.abs(i.z)===1?ga.x+=1e-4:ga.z+=1e-4,ga.normalize(),Au.crossVectors(i,ga)),Au.normalize(),Py.crossVectors(ga,Au),r[0]=Au.x,r[4]=Py.x,r[8]=ga.x,r[1]=Au.y,r[5]=Py.y,r[9]=ga.y,r[2]=Au.z,r[6]=Py.z,r[10]=ga.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,a=this.elements,l=i[0],u=i[4],h=i[8],p=i[12],g=i[1],y=i[5],b=i[9],x=i[13],M=i[2],A=i[6],w=i[10],E=i[14],R=i[3],D=i[7],P=i[11],F=i[15],L=r[0],k=r[4],V=r[8],N=r[12],z=r[1],X=r[5],Q=r[9],J=r[13],oe=r[2],re=r[6],q=r[10],Z=r[14],ne=r[3],pe=r[7],Ee=r[11],j=r[15];return a[0]=l*L+u*z+h*oe+p*ne,a[4]=l*k+u*X+h*re+p*pe,a[8]=l*V+u*Q+h*q+p*Ee,a[12]=l*N+u*J+h*Z+p*j,a[1]=g*L+y*z+b*oe+x*ne,a[5]=g*k+y*X+b*re+x*pe,a[9]=g*V+y*Q+b*q+x*Ee,a[13]=g*N+y*J+b*Z+x*j,a[2]=M*L+A*z+w*oe+E*ne,a[6]=M*k+A*X+w*re+E*pe,a[10]=M*V+A*Q+w*q+E*Ee,a[14]=M*N+A*J+w*Z+E*j,a[3]=R*L+D*z+P*oe+F*ne,a[7]=R*k+D*X+P*re+F*pe,a[11]=R*V+D*Q+P*q+F*Ee,a[15]=R*N+D*J+P*Z+F*j,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],r=e[8],a=e[12],l=e[1],u=e[5],h=e[9],p=e[13],g=e[2],y=e[6],b=e[10],x=e[14],M=e[3],A=e[7],w=e[11],E=e[15],R=h*x-p*b,D=u*x-p*y,P=u*b-h*y,F=l*x-p*g,L=l*b-h*g,k=l*y-u*g;return t*(A*R-w*D+E*P)-i*(M*R-w*F+E*L)+r*(M*D-A*F+E*k)-a*(M*P-A*L+w*k)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],l=e[4],u=e[5],h=e[6],p=e[7],g=e[8],y=e[9],b=e[10],x=e[11],M=e[12],A=e[13],w=e[14],E=e[15],R=y*w*p-A*b*p+A*h*x-u*w*x-y*h*E+u*b*E,D=M*b*p-g*w*p-M*h*x+l*w*x+g*h*E-l*b*E,P=g*A*p-M*y*p+M*u*x-l*A*x-g*u*E+l*y*E,F=M*y*h-g*A*h-M*u*b+l*A*b+g*u*w-l*y*w,L=t*R+i*D+r*P+a*F;if(L===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/L;return e[0]=R*k,e[1]=(A*b*a-y*w*a-A*r*x+i*w*x+y*r*E-i*b*E)*k,e[2]=(u*w*a-A*h*a+A*r*p-i*w*p-u*r*E+i*h*E)*k,e[3]=(y*h*a-u*b*a-y*r*p+i*b*p+u*r*x-i*h*x)*k,e[4]=D*k,e[5]=(g*w*a-M*b*a+M*r*x-t*w*x-g*r*E+t*b*E)*k,e[6]=(M*h*a-l*w*a-M*r*p+t*w*p+l*r*E-t*h*E)*k,e[7]=(l*b*a-g*h*a+g*r*p-t*b*p-l*r*x+t*h*x)*k,e[8]=P*k,e[9]=(M*y*a-g*A*a-M*i*x+t*A*x+g*i*E-t*y*E)*k,e[10]=(l*A*a-M*u*a+M*i*p-t*A*p-l*i*E+t*u*E)*k,e[11]=(g*u*a-l*y*a-g*i*p+t*y*p+l*i*x-t*u*x)*k,e[12]=F*k,e[13]=(g*A*r-M*y*r+M*i*b-t*A*b-g*i*w+t*y*w)*k,e[14]=(M*u*r-l*A*r-M*i*h+t*A*h+l*i*w-t*u*w)*k,e[15]=(l*y*r-g*u*r+g*i*h-t*y*h-l*i*b+t*u*b)*k,this}scale(e){const t=this.elements,i=e.x,r=e.y,a=e.z;return t[0]*=i,t[4]*=r,t[8]*=a,t[1]*=i,t[5]*=r,t[9]*=a,t[2]*=i,t[6]*=r,t[10]*=a,t[3]*=i,t[7]*=r,t[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),a=1-i,l=e.x,u=e.y,h=e.z,p=a*l,g=a*u;return this.set(p*l+i,p*u-r*h,p*h+r*u,0,p*u+r*h,g*u+i,g*h-r*l,0,p*h-r*u,g*h+r*l,a*h*h+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,a,l){return this.set(1,i,a,0,e,1,l,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,a=t._x,l=t._y,u=t._z,h=t._w,p=a+a,g=l+l,y=u+u,b=a*p,x=a*g,M=a*y,A=l*g,w=l*y,E=u*y,R=h*p,D=h*g,P=h*y,F=i.x,L=i.y,k=i.z;return r[0]=(1-(A+E))*F,r[1]=(x+P)*F,r[2]=(M-D)*F,r[3]=0,r[4]=(x-P)*L,r[5]=(1-(b+E))*L,r[6]=(w+R)*L,r[7]=0,r[8]=(M+D)*k,r[9]=(w-R)*k,r[10]=(1-(b+A))*k,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;if(e.x=r[12],e.y=r[13],e.z=r[14],this.determinant()===0)return i.set(1,1,1),t.identity(),this;let a=Vh.set(r[0],r[1],r[2]).length();const l=Vh.set(r[4],r[5],r[6]).length(),u=Vh.set(r[8],r[9],r[10]).length();this.determinant()<0&&(a=-a),Ro.copy(this);const p=1/a,g=1/l,y=1/u;return Ro.elements[0]*=p,Ro.elements[1]*=p,Ro.elements[2]*=p,Ro.elements[4]*=g,Ro.elements[5]*=g,Ro.elements[6]*=g,Ro.elements[8]*=y,Ro.elements[9]*=y,Ro.elements[10]*=y,t.setFromRotationMatrix(Ro),i.x=a,i.y=l,i.z=u,this}makePerspective(e,t,i,r,a,l,u=ba,h=!1){const p=this.elements,g=2*a/(t-e),y=2*a/(i-r),b=(t+e)/(t-e),x=(i+r)/(i-r);let M,A;if(h)M=a/(l-a),A=l*a/(l-a);else if(u===ba)M=-(l+a)/(l-a),A=-2*l*a/(l-a);else if(u===Mp)M=-l/(l-a),A=-l*a/(l-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+u);return p[0]=g,p[4]=0,p[8]=b,p[12]=0,p[1]=0,p[5]=y,p[9]=x,p[13]=0,p[2]=0,p[6]=0,p[10]=M,p[14]=A,p[3]=0,p[7]=0,p[11]=-1,p[15]=0,this}makeOrthographic(e,t,i,r,a,l,u=ba,h=!1){const p=this.elements,g=2/(t-e),y=2/(i-r),b=-(t+e)/(t-e),x=-(i+r)/(i-r);let M,A;if(h)M=1/(l-a),A=l/(l-a);else if(u===ba)M=-2/(l-a),A=-(l+a)/(l-a);else if(u===Mp)M=-1/(l-a),A=-a/(l-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+u);return p[0]=g,p[4]=0,p[8]=0,p[12]=b,p[1]=0,p[5]=y,p[9]=0,p[13]=x,p[2]=0,p[6]=0,p[10]=M,p[14]=A,p[3]=0,p[7]=0,p[11]=0,p[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Vh=new K,Ro=new Kt,AL=new K(0,0,0),CL=new K(1,1,1),Au=new K,Py=new K,ga=new K,Mw=new Kt,Ew=new cs;class Ta{constructor(e=0,t=0,i=0,r=Ta.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const r=e.elements,a=r[0],l=r[4],u=r[8],h=r[1],p=r[5],g=r[9],y=r[2],b=r[6],x=r[10];switch(t){case"XYZ":this._y=Math.asin(Yt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-g,x),this._z=Math.atan2(-l,a)):(this._x=Math.atan2(b,p),this._z=0);break;case"YXZ":this._x=Math.asin(-Yt(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(u,x),this._z=Math.atan2(h,p)):(this._y=Math.atan2(-y,a),this._z=0);break;case"ZXY":this._x=Math.asin(Yt(b,-1,1)),Math.abs(b)<.9999999?(this._y=Math.atan2(-y,x),this._z=Math.atan2(-l,p)):(this._y=0,this._z=Math.atan2(h,a));break;case"ZYX":this._y=Math.asin(-Yt(y,-1,1)),Math.abs(y)<.9999999?(this._x=Math.atan2(b,x),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-l,p));break;case"YZX":this._z=Math.asin(Yt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-g,p),this._y=Math.atan2(-y,a)):(this._x=0,this._y=Math.atan2(u,x));break;case"XZY":this._z=Math.asin(-Yt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(b,p),this._y=Math.atan2(u,a)):(this._x=Math.atan2(-g,x),this._y=0);break;default:vt("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Mw.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Mw,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ew.setFromEuler(this),this.setFromQuaternion(Ew,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ta.DEFAULT_ORDER="XYZ";class wp{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(u=>({...u,boundingBox:u.boundingBox?u.boundingBox.toJSON():void 0,boundingSphere:u.boundingSphere?u.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(u=>({...u})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function a(u,h){return u[h.uuid]===void 0&&(u[h.uuid]=h.toJSON(e)),h.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.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 p=0,g=h.length;p0){r.children=[];for(let u=0;u0){r.animations=[];for(let u=0;u0&&(i.geometries=u),h.length>0&&(i.materials=h),p.length>0&&(i.textures=p),g.length>0&&(i.images=g),y.length>0&&(i.shapes=y),b.length>0&&(i.skeletons=b),x.length>0&&(i.animations=x),M.length>0&&(i.nodes=M)}return i.object=r,i;function l(u){const h=[];for(const p in u){const g=u[p];delete g.metadata,h.push(g)}return h}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,t,i,r,a){Do.subVectors(r,t),vc.subVectors(i,t),BS.subVectors(e,t);const l=Do.dot(Do),u=Do.dot(vc),h=Do.dot(BS),p=vc.dot(vc),g=vc.dot(BS),y=l*p-u*u;if(y===0)return a.set(0,0,0),null;const b=1/y,x=(p*h-u*g)*b,M=(l*g-u*h)*b;return a.set(1-x-M,M,x)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,yc)===null?!1:yc.x>=0&&yc.y>=0&&yc.x+yc.y<=1}static getInterpolation(e,t,i,r,a,l,u,h){return this.getBarycoord(e,t,i,r,yc)===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(a,yc.x),h.addScaledVector(l,yc.y),h.addScaledVector(u,yc.z),h)}static getInterpolatedAttribute(e,t,i,r,a,l){return VS.setScalar(0),GS.setScalar(0),WS.setScalar(0),VS.fromBufferAttribute(e,t),GS.fromBufferAttribute(e,i),WS.fromBufferAttribute(e,r),l.setScalar(0),l.addScaledVector(VS,a.x),l.addScaledVector(GS,a.y),l.addScaledVector(WS,a.z),l}static isFrontFacing(e,t,i,r){return Do.subVectors(i,t),vc.subVectors(e,t),Do.cross(vc).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Do.subVectors(this.c,this.b),vc.subVectors(this.a,this.b),Do.cross(vc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return sa.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return sa.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,a){return sa.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}containsPoint(e){return sa.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return sa.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,a=this.c;let l,u;$h.subVectors(r,i),Xh.subVectors(a,i),FS.subVectors(e,i);const h=$h.dot(FS),p=Xh.dot(FS);if(h<=0&&p<=0)return t.copy(i);kS.subVectors(e,r);const g=$h.dot(kS),y=Xh.dot(kS);if(g>=0&&y<=g)return t.copy(r);const b=h*y-g*p;if(b<=0&&h>=0&&g<=0)return l=h/(h-g),t.copy(i).addScaledVector($h,l);HS.subVectors(e,a);const x=$h.dot(HS),M=Xh.dot(HS);if(M>=0&&x<=M)return t.copy(a);const A=x*p-h*M;if(A<=0&&p>=0&&M<=0)return u=p/(p-M),t.copy(i).addScaledVector(Xh,u);const w=g*M-x*y;if(w<=0&&y-g>=0&&x-M>=0)return Dw.subVectors(a,r),u=(y-g)/(y-g+(x-M)),t.copy(r).addScaledVector(Dw,u);const E=1/(w+A+b);return l=A*E,u=b*E,t.copy(i).addScaledVector($h,l).addScaledVector(Xh,u)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const H3={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},Cu={h:0,s:0,l:0},Ny={h:0,s:0,l:0};function $S(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}let pt=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Fn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Cn.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=Cn.workingColorSpace){return this.r=e,this.g=t,this.b=i,Cn.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=Cn.workingColorSpace){if(e=yE(e,1),t=Yt(t,0,1),i=Yt(i,0,1),t===0)this.r=this.g=this.b=i;else{const a=i<=.5?i*(1+t):i+t-i*t,l=2*i-a;this.r=$S(l,a,e+1/3),this.g=$S(l,a,e),this.b=$S(l,a,e-1/3)}return Cn.colorSpaceToWorking(this,r),this}setStyle(e,t=Fn){function i(a){a!==void 0&&parseFloat(a)<1&&vt("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const l=r[1],u=r[2];switch(l){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(u))return i(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:vt("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=r[1],l=a.length;if(l===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(l===6)return this.setHex(parseInt(a,16),t);vt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Fn){const i=H3[e.toLowerCase()];return i!==void 0?this.setHex(i,t):vt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ac(e.r),this.g=Ac(e.g),this.b=Ac(e.b),this}copyLinearToSRGB(e){return this.r=yp(e.r),this.g=yp(e.g),this.b=yp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fn){return Cn.workingToColorSpace(ss.copy(this),e),Math.round(Yt(ss.r*255,0,255))*65536+Math.round(Yt(ss.g*255,0,255))*256+Math.round(Yt(ss.b*255,0,255))}getHexString(e=Fn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Cn.workingColorSpace){Cn.workingToColorSpace(ss.copy(this),t);const i=ss.r,r=ss.g,a=ss.b,l=Math.max(i,r,a),u=Math.min(i,r,a);let h,p;const g=(u+l)/2;if(u===l)h=0,p=0;else{const y=l-u;switch(p=g<=.5?y/(l+u):y/(2-l-u),l){case i:h=(r-a)/y+(r0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){vt(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){vt(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==fd&&(i.blending=this.blending),this.side!==Al&&(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!==zb&&(i.blendSrc=this.blendSrc),this.blendDst!==_p&&(i.blendDst=this.blendDst),this.blendEquation!==Mc&&(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!==vd&&(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!==cM&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==rd&&(i.stencilFail=this.stencilFail),this.stencilZFail!==rd&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==rd&&(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.allowOverride===!1&&(i.allowOverride=!1),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 r(a){const l=[];for(const u in a){const h=a[u];delete h.metadata,l.push(h)}return l}if(t){const a=r(e.textures),l=r(e.images);a.length>0&&(i.textures=a),l.length>0&&(i.images=l)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const r=t.length;i=new Array(r);for(let a=0;a!==r;++a)i[a]=t[a].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Qu extends Ir{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new pt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ta,this.combine=E0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ec=NL();function NL(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let h=0;h<256;++h){const p=h-127;p<-27?(i[h]=0,i[h|256]=32768,r[h]=24,r[h|256]=24):p<-14?(i[h]=1024>>-p-14,i[h|256]=1024>>-p-14|32768,r[h]=-p-1,r[h|256]=-p-1):p<=15?(i[h]=p+15<<10,i[h|256]=p+15<<10|32768,r[h]=13,r[h|256]=13):p<128?(i[h]=31744,i[h|256]=64512,r[h]=24,r[h|256]=24):(i[h]=31744,i[h|256]=64512,r[h]=13,r[h|256]=13)}const a=new Uint32Array(2048),l=new Uint32Array(64),u=new Uint32Array(64);for(let h=1;h<1024;++h){let p=h<<13,g=0;for(;(p&8388608)===0;)p<<=1,g-=8388608;p&=-8388609,g+=947912704,a[h]=p|g}for(let h=1024;h<2048;++h)a[h]=939524096+(h-1024<<13);for(let h=1;h<31;++h)l[h]=h<<23;l[31]=1199570944,l[32]=2147483648;for(let h=33;h<63;++h)l[h]=2147483648+(h-32<<23);l[63]=3347054592;for(let h=1;h<64;++h)h!==32&&(u[h]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:l,offsetTable:u}}function na(n){Math.abs(n)>65504&&vt("DataUtils.toHalfFloat(): Value out of range."),n=Yt(n,-65504,65504),Ec.floatView[0]=n;const e=Ec.uint32View[0],t=e>>23&511;return Ec.baseTable[t]+((e&8388607)>>Ec.shiftTable[t])}function Ug(n){const e=n>>10;return Ec.uint32View[0]=Ec.mantissaTable[Ec.offsetTable[e]+(n&1023)]+Ec.exponentTable[e],Ec.floatView[0]}class LL{static toHalfFloat(e){return na(e)}static fromHalfFloat(e){return Ug(e)}}const dr=new K,Ly=new Le;let UL=0;class Wn{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:UL++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=l0,this.updateRanges=[],this.gpuType=Or,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,a=this.itemSize;rt.count&&vt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new us);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Lt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new K(-1/0,-1/0,-1/0),new K(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0){const h=this.parameters;for(const p in h)h[p]!==void 0&&(e[p]=h[p]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const h in i){const p=i[h];e.data.attributes[h]=p.toJSON(e.data)}const r={};let a=!1;for(const h in this.morphAttributes){const p=this.morphAttributes[h],g=[];for(let y=0,b=p.length;y0&&(r[h]=g,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const l=this.groups;l.length>0&&(e.data.groups=JSON.parse(JSON.stringify(l)));const u=this.boundingSphere;return u!==null&&(e.data.boundingSphere=u.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const p in r){const g=r[p];this.setAttribute(p,g.clone(t))}const a=e.morphAttributes;for(const p in a){const g=[],y=a[p];for(let b=0,x=y.length;b0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,l=r.length;a(e.far-e.near)**2))&&(Ow.copy(a).invert(),Gf.copy(e.ray).applyMatrix4(Ow),!(i.boundingBox!==null&&Gf.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Gf)))}_computeIntersections(e,t,i){let r;const a=this.geometry,l=this.material,u=a.index,h=a.attributes.position,p=a.attributes.uv,g=a.attributes.uv1,y=a.attributes.normal,b=a.groups,x=a.drawRange;if(u!==null)if(Array.isArray(l))for(let M=0,A=b.length;Mt.far?null:{distance:p,point:Hy.clone(),object:n}}function Vy(n,e,t,i,r,a,l,u,h,p){n.getVertexPosition(u,zy),n.getVertexPosition(h,By),n.getVertexPosition(p,Fy);const g=WL(n,e,t,i,zy,By,Fy,Iw);if(g){const y=new K;sa.getBarycoord(Iw,zy,By,Fy,y),r&&(g.uv=sa.getInterpolatedAttribute(r,u,h,p,y,new Le)),a&&(g.uv1=sa.getInterpolatedAttribute(a,u,h,p,y,new Le)),l&&(g.normal=sa.getInterpolatedAttribute(l,u,h,p,y,new K),g.normal.dot(i.direction)>0&&g.normal.multiplyScalar(-1));const b={a:u,b:h,c:p,normal:new K,materialIndex:0};sa.getNormal(zy,By,Fy,b.normal),g.face=b,g.barycoord=y}return g}class Ad extends en{constructor(e=1,t=1,i=1,r=1,a=1,l=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:l};const u=this;r=Math.floor(r),a=Math.floor(a),l=Math.floor(l);const h=[],p=[],g=[],y=[];let b=0,x=0;M("z","y","x",-1,-1,i,t,e,l,a,0),M("z","y","x",1,-1,i,t,-e,l,a,1),M("x","z","y",1,1,e,i,t,r,l,2),M("x","z","y",1,-1,e,i,-t,r,l,3),M("x","y","z",1,-1,e,t,i,r,a,4),M("x","y","z",-1,-1,e,t,-i,r,a,5),this.setIndex(h),this.setAttribute("position",new At(p,3)),this.setAttribute("normal",new At(g,3)),this.setAttribute("uv",new At(y,2));function M(A,w,E,R,D,P,F,L,k,V,N){const z=P/k,X=F/V,Q=P/2,J=F/2,oe=L/2,re=k+1,q=V+1;let Z=0,ne=0;const pe=new K;for(let Ee=0;Ee0?1:-1,g.push(pe.x,pe.y,pe.z),y.push(fe/k),y.push(1-Ee/V),Z+=1}}for(let Ee=0;Ee0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class o_ extends Ln{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Kt,this.projectionMatrix=new Kt,this.projectionMatrixInverse=new Kt,this.coordinateSystem=ba,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Ru=new K,Nw=new Le,Lw=new Le;let $i=class extends o_{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Tp*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(dd*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Tp*2*Math.atan(Math.tan(dd*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Ru.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ru.x,Ru.y).multiplyScalar(-e/Ru.z),Ru.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ru.x,Ru.y).multiplyScalar(-e/Ru.z)}getViewSize(e,t){return this.getViewBounds(e,Nw,Lw),t.subVectors(Lw,Nw)}setViewOffset(e,t,i,r,a,l){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(dd*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,a=-.5*r;const l=this.view;if(this.view!==null&&this.view.enabled){const h=l.fullWidth,p=l.fullHeight;a+=l.offsetX*r/h,t-=l.offsetY*i/p,r*=l.width/h,i*=l.height/p}const u=this.filmOffset;u!==0&&(a+=e*u/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};const qh=-90,Yh=1;class W3 extends Ln{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new $i(qh,Yh,e,t);r.layers=this.layers,this.add(r);const a=new $i(qh,Yh,e,t);a.layers=this.layers,this.add(a);const l=new $i(qh,Yh,e,t);l.layers=this.layers,this.add(l);const u=new $i(qh,Yh,e,t);u.layers=this.layers,this.add(u);const h=new $i(qh,Yh,e,t);h.layers=this.layers,this.add(h);const p=new $i(qh,Yh,e,t);p.layers=this.layers,this.add(p)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,a,l,u,h]=t;for(const p of t)this.remove(p);if(e===ba)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.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(e===Mp)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.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: "+e);for(const p of t)this.add(p),p.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,l,u,h,p,g]=this.children,y=e.getRenderTarget(),b=e.getActiveCubeFace(),x=e.getActiveMipmapLevel(),M=e.xr.enabled;e.xr.enabled=!1;const A=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,a),e.setRenderTarget(i,1,r),e.render(t,l),e.setRenderTarget(i,2,r),e.render(t,u),e.setRenderTarget(i,3,r),e.render(t,h),e.setRenderTarget(i,4,r),e.render(t,p),i.texture.generateMipmaps=A,e.setRenderTarget(i,5,r),e.render(t,g),e.setRenderTarget(y,b,x),e.xr.enabled=M,i.texture.needsPMREMUpdate=!0}}class A0 extends Ai{constructor(e=[],t=Cl,i,r,a,l,u,h,p,g){super(e,t,i,r,a,l,u,h,p,g),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class SE extends Gn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new A0(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const 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 ); } `},r=new Ad(5,5,5),a=new Yn({name:"CubemapFromEquirect",uniforms:Ap(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:_r,blending:Pr});a.uniforms.tEquirect.value=t;const l=new hi(r,a),u=t.minFilter;return t.minFilter===Io&&(t.minFilter=Nn),new W3(1,10,this).update(e,l),t.minFilter=u,l.geometry.dispose(),l.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const a=e.getRenderTarget();for(let l=0;l<6;l++)e.setRenderTarget(this,l),e.clear(t,i,r);e.setRenderTarget(a)}}class mp extends Ln{constructor(){super(),this.isGroup=!0,this.type="Group"}}const qL={type:"move"};class Db{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new mp,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 mp,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new K,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new K),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new mp,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new K,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new K),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,a=null,l=null;const u=this._targetRay,h=this._grip,p=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(p&&e.hand){l=!0;for(const A of e.hand.values()){const w=t.getJointPose(A,i),E=this._getHandJoint(p,A);w!==null&&(E.matrix.fromArray(w.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=w.radius),E.visible=w!==null}const g=p.joints["index-finger-tip"],y=p.joints["thumb-tip"],b=g.position.distanceTo(y.position),x=.02,M=.005;p.inputState.pinching&&b>x+M?(p.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!p.inputState.pinching&&b<=x-M&&(p.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else h!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,i),a!==null&&(h.matrix.fromArray(a.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,a.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(a.linearVelocity)):h.hasLinearVelocity=!1,a.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(a.angularVelocity)):h.hasAngularVelocity=!1));u!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(u.matrix.fromArray(r.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,r.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(r.linearVelocity)):u.hasLinearVelocity=!1,r.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(r.angularVelocity)):u.hasAngularVelocity=!1,this.dispatchEvent(qL)))}return u!==null&&(u.visible=r!==null),h!==null&&(h.visible=a!==null),p!==null&&(p.visible=l!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new mp;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class l_{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new pt(e),this.density=t}clone(){return new l_(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class c_{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new pt(e),this.near=t,this.far=i}clone(){return new c_(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class zu extends Ln{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ta,this.environmentIntensity=1,this.environmentRotation=new Ta,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class u_{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=l0,this.updateRanges=[],this.version=0,this.uuid=_a()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,a=this.stride;re.far||t.push({distance:h,point:xg.clone(),uv:sa.getInterpolation(xg,Gy,Sg,Wy,Uw,qS,zw,new Le),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function $y(n,e,t,i,r,a){Jh.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(_g.x=a*Jh.x-r*Jh.y,_g.y=r*Jh.x+a*Jh.y):_g.copy(Jh),n.copy(e),n.x+=_g.x,n.y+=_g.y,n.applyMatrix4($3)}const Xy=new K,Bw=new K;class j3 extends Ln{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i0){let i,r;for(i=1,r=t.length;i0){Xy.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(Xy);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Xy.setFromMatrixPosition(e.matrixWorld),Bw.setFromMatrixPosition(this.matrixWorld);const i=Xy.distanceTo(Bw)/e.zoom;t[0].object.visible=!0;let r,a;for(r=1,a=t.length;r=l)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r1?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||JL.getNormalMatrix(e),r=this.coplanarPoint(KS).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Wf=new Xr,eU=new Le(.5,.5),Yy=new K;class Lp{constructor(e=new _c,t=new _c,i=new _c,r=new _c,a=new _c,l=new _c){this.planes=[e,t,i,r,a,l]}set(e,t,i,r,a,l){const u=this.planes;return u[0].copy(e),u[1].copy(t),u[2].copy(i),u[3].copy(r),u[4].copy(a),u[5].copy(l),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=ba,i=!1){const r=this.planes,a=e.elements,l=a[0],u=a[1],h=a[2],p=a[3],g=a[4],y=a[5],b=a[6],x=a[7],M=a[8],A=a[9],w=a[10],E=a[11],R=a[12],D=a[13],P=a[14],F=a[15];if(r[0].setComponents(p-l,x-g,E-M,F-R).normalize(),r[1].setComponents(p+l,x+g,E+M,F+R).normalize(),r[2].setComponents(p+u,x+y,E+A,F+D).normalize(),r[3].setComponents(p-u,x-y,E-A,F-D).normalize(),i)r[4].setComponents(h,b,w,P).normalize(),r[5].setComponents(p-h,x-b,E-w,F-P).normalize();else if(r[4].setComponents(p-h,x-b,E-w,F-P).normalize(),t===ba)r[5].setComponents(p+h,x+b,E+w,F+P).normalize();else if(t===Mp)r[5].setComponents(h,b,w,P).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Wf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Wf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Wf)}intersectsSprite(e){Wf.center.set(0,0,0);const t=eU.distanceTo(e.center);return Wf.radius=.7071067811865476+t,Wf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Wf)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(i)0?e.max.x:e.min.x,Yy.y=r.normal.y>0?e.max.y:e.min.y,Yy.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Yy)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const xl=new Kt,_l=new Lp;class d_{constructor(){this.coordinateSystem=ba}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i=a.length&&a.push({start:-1,count:-1,z:-1,index:-1});const u=a[this.index];l.push(u),this.index++,u.start=e,u.count=t,u.z=i,u.index=r}reset(){this.list.length=0,this.index=0}}const ea=new Kt,rU=new pt(1,1,1),jw=new Lp,sU=new d_,Zy=new us,$f=new Xr,Tg=new K,qw=new K,aU=new K,JS=new iU,as=new hi,Ky=[];function oU(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let a=0;a65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new Wn(a,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),a=t.getAttribute(i);if(r.itemSize!==a.itemSize||r.normalized!==a.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new us);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,r=t.length;i=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:e};let r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(QS),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=i):(r=this._instanceInfo.length,this._instanceInfo.push(i));const a=this._matricesTexture;ea.identity().toArray(a.image.data,r*16),a.needsUpdate=!0;const l=this._colorsTexture;return l&&(rU.toArray(l.image.data,r*4),l.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},a=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const l=e.getIndex();if(l!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=i===-1?l.count:i),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let h;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(QS),h=this._availableGeometryIds.shift(),a[h]=r):(h=this._geometryCount,this._geometryCount++,a.push(r)),this.setGeometryAt(h,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,a=i.getIndex(),l=t.getIndex(),u=this._geometryInfo[e];if(r&&l.count>u.reservedIndexCount||t.attributes.position.count>u.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const h=u.vertexStart,p=u.reservedVertexCount;u.vertexCount=t.getAttribute("position").count;for(const g in i.attributes){const y=t.getAttribute(g),b=i.getAttribute(g);oU(y,b,h);const x=y.itemSize;for(let M=y.count,A=p;M=t.length||t[e].active===!1)return this;const i=this._instanceInfo;for(let r=0,a=i.length;ru).sort((l,u)=>i[l].vertexStart-i[u].vertexStart),a=this.geometry;for(let l=0,u=i.length;l=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const a=new us,l=i.index,u=i.attributes.position;for(let h=r.start,p=r.start+r.count;h=this._geometryCount)return null;const i=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const a=new Xr;this.getBoundingBoxAt(e,Zy),Zy.getCenter(a.center);const l=i.index,u=i.attributes.position;let h=0;for(let p=r.start,g=r.start+r.count;pu.active);if(Math.max(...i.map(u=>u.vertexStart+u.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(h=>h.indexStart+h.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const a=this.geometry;a.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new en,this._initializeGeometry(a));const l=this.geometry;a.index&&Xf(a.index.array,l.index.array);for(const u in a.attributes)Xf(a.attributes[u].array,l.attributes[u].array)}raycast(e,t){const i=this._instanceInfo,r=this._geometryInfo,a=this.matrixWorld,l=this.geometry;as.material=this.material,as.geometry.index=l.index,as.geometry.attributes=l.attributes,as.geometry.boundingBox===null&&(as.geometry.boundingBox=new us),as.geometry.boundingSphere===null&&(as.geometry.boundingSphere=new Xr);for(let u=0,h=i.length;u({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,i,r,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const l=r.getIndex(),u=l===null?1:l.array.BYTES_PER_ELEMENT,h=this._instanceInfo,p=this._multiDrawStarts,g=this._multiDrawCounts,y=this._geometryInfo,b=this.perObjectFrustumCulled,x=this._indirectTexture,M=x.image.data,A=i.isArrayCamera?sU:jw;b&&!i.isArrayCamera&&(ea.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),jw.setFromProjectionMatrix(ea,i.coordinateSystem,i.reversedDepth));let w=0;if(this.sortObjects){ea.copy(this.matrixWorld).invert(),Tg.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ea),qw.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(ea);for(let D=0,P=h.length;D0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,l=r.length;ai)return;e1.applyMatrix4(n.matrixWorld);const p=e.ray.origin.distanceTo(e1);if(!(pe.far))return{distance:p,point:Zw.clone().applyMatrix4(n.matrixWorld),index:l,face:null,faceIndex:null,barycoord:null,object:n}}const Kw=new K,Qw=new K;class Il extends Hu{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,a=t.count;r0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,l=r.length;ar.far)return;a.push({distance:p,distanceToRay:Math.sqrt(u),point:h,index:e,face:null,faceIndex:null,barycoord:null,object:l})}}class J3 extends Ai{constructor(e,t,i,r,a=Nn,l=Nn,u,h,p){super(e,t,i,r,a,l,u,h,p),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const g=this;function y(){g.needsUpdate=!0,g._requestVideoFrameCallbackId=e.requestVideoFrameCallback(y)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(y))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class lU extends J3{constructor(e,t,i,r,a,l,u,h){super({},e,t,i,r,a,l,u,h),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class cU extends Ai{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Kn,this.minFilter=Kn,this.generateMipmaps=!1,this.needsUpdate=!0}}class h_ extends Ai{constructor(e,t,i,r,a,l,u,h,p,g,y,b){super(null,l,u,h,p,g,r,a,y,b),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class uU extends h_{constructor(e,t,i,r,a,l){super(e,t,i,a,l),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=aa,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class fU extends h_{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Cl),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class dU extends Ai{constructor(e,t,i,r,a,l,u,h,p){super(e,t,i,r,a,l,u,h,p),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Vu extends Ai{constructor(e,t,i=Ea,r,a,l,u=Kn,h=Kn,p,g=Rl,y=1){if(g!==Rl&&g!==wc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const b={width:e,height:t,depth:y};super(b,r,a,l,u,h,g,i,p),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Lu(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class eD extends Vu{constructor(e,t=Ea,i=Cl,r,a,l=Kn,u=Kn,h,p=Rl){const g={width:e,height:e,depth:1},y=[g,g,g,g,g,g];super(e,e,t,i,r,a,l,u,h,p),this.image=y,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class wE extends Ai{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class p_ extends en{constructor(e=1,t=1,i=4,r=8,a=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:r,heightSegments:a},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),r=Math.max(3,Math.floor(r)),a=Math.max(1,Math.floor(a));const l=[],u=[],h=[],p=[],g=t/2,y=Math.PI/2*e,b=t,x=2*y+b,M=i*2+a,A=r+1,w=new K,E=new K;for(let R=0;R<=M;R++){let D=0,P=0,F=0,L=0;if(R<=i){const N=R/i,z=N*Math.PI/2;P=-g-e*Math.cos(z),F=e*Math.sin(z),L=-e*Math.cos(z),D=N*y}else if(R<=i+a){const N=(R-i)/a;P=-g+N*t,F=e,L=0,D=y+N*b}else{const N=(R-i-a)/i,z=N*Math.PI/2;P=g+e*Math.sin(z),F=e*Math.cos(z),L=e*Math.sin(z),D=y+b+N*y}const k=Math.max(0,Math.min(1,D/x));let V=0;R===0?V=.5/r:R===M&&(V=-.5/r);for(let N=0;N<=r;N++){const z=N/r,X=z*Math.PI*2,Q=Math.sin(X),J=Math.cos(X);E.x=-F*J,E.y=P,E.z=F*Q,u.push(E.x,E.y,E.z),w.set(-F*J,L,F*Q),w.normalize(),h.push(w.x,w.y,w.z),p.push(z+V,k)}if(R>0){const N=(R-1)*A;for(let z=0;z0&&D(!0),t>0&&D(!1)),this.setIndex(g),this.setAttribute("position",new At(y,3)),this.setAttribute("normal",new At(b,3)),this.setAttribute("uv",new At(x,2));function R(){const P=new K,F=new K;let L=0;const k=(t-e)/i;for(let V=0;V<=a;V++){const N=[],z=V/a,X=z*(t-e)+e;for(let Q=0;Q<=r;Q++){const J=Q/r,oe=J*h+u,re=Math.sin(oe),q=Math.cos(oe);F.x=X*re,F.y=-z*i+w,F.z=X*q,y.push(F.x,F.y,F.z),P.set(re,k,q).normalize(),b.push(P.x,P.y,P.z),x.push(J,1-z),N.push(M++)}A.push(N)}for(let V=0;V0||N!==0)&&(g.push(z,X,J),L+=3),(t>0||N!==a-1)&&(g.push(X,Q,J),L+=3)}p.addGroup(E,L,0),E+=L}function D(P){const F=M,L=new Le,k=new K;let V=0;const N=P===!0?e:t,z=P===!0?1:-1;for(let Q=1;Q<=r;Q++)y.push(0,w*z,0),b.push(0,z,0),x.push(.5,.5),M++;const X=M;for(let Q=0;Q<=r;Q++){const oe=Q/r*h+u,re=Math.cos(oe),q=Math.sin(oe);k.x=N*q,k.y=w*z,k.z=N*re,y.push(k.x,k.y,k.z),b.push(0,z,0),L.x=re*.5+.5,L.y=q*.5*z+.5,x.push(L.x,L.y),M++}for(let Q=0;Q.9&&k<.1&&(D<.2&&(l[R+0]+=1),P<.2&&(l[R+2]+=1),F<.2&&(l[R+4]+=1))}}function b(R){a.push(R.x,R.y,R.z)}function x(R,D){const P=R*3;D.x=e[P+0],D.y=e[P+1],D.z=e[P+2]}function M(){const R=new K,D=new K,P=new K,F=new K,L=new Le,k=new Le,V=new Le;for(let N=0,z=0;N0)h=r-1;else{h=r;break}if(r=h,i[r]===l)return r/(a-1);const g=i[r],b=i[r+1]-g,x=(l-g)/b;return(r+x)/(a-1)}getTangent(e,t){let r=e-1e-4,a=e+1e-4;r<0&&(r=0),a>1&&(a=1);const l=this.getPoint(r),u=this.getPoint(a),h=t||(l.isVector2?new Le:new K);return h.copy(u).sub(l).normalize(),h}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new K,r=[],a=[],l=[],u=new K,h=new Kt;for(let x=0;x<=e;x++){const M=x/e;r[x]=this.getTangentAt(M,new K)}a[0]=new K,l[0]=new K;let p=Number.MAX_VALUE;const g=Math.abs(r[0].x),y=Math.abs(r[0].y),b=Math.abs(r[0].z);g<=p&&(p=g,i.set(1,0,0)),y<=p&&(p=y,i.set(0,1,0)),b<=p&&i.set(0,0,1),u.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],u),l[0].crossVectors(r[0],a[0]);for(let x=1;x<=e;x++){if(a[x]=a[x-1].clone(),l[x]=l[x-1].clone(),u.crossVectors(r[x-1],r[x]),u.length()>Number.EPSILON){u.normalize();const M=Math.acos(Yt(r[x-1].dot(r[x]),-1,1));a[x].applyMatrix4(h.makeRotationAxis(u,M))}l[x].crossVectors(r[x],a[x])}if(t===!0){let x=Math.acos(Yt(a[0].dot(a[e]),-1,1));x/=e,r[0].dot(u.crossVectors(a[0],a[e]))>0&&(x=-x);for(let M=1;M<=e;M++)a[M].applyMatrix4(h.makeRotationAxis(r[M],x*M)),l[M].crossVectors(r[M],a[M])}return{tangents:r,normals:a,binormals:l}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class v_ extends Fo{constructor(e=0,t=0,i=1,r=1,a=0,l=Math.PI*2,u=!1,h=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=l,this.aClockwise=u,this.aRotation=h}getPoint(e,t=new Le){const i=t,r=Math.PI*2;let a=this.aEndAngle-this.aStartAngle;const l=Math.abs(a)r;)a-=r;a0?0:(Math.floor(Math.abs(u)/a)+1)*a:h===0&&u===a-1&&(u=a-2,h=1);let p,g;this.closed||u>0?p=r[(u-1)%a]:(sb.subVectors(r[0],r[1]).add(r[0]),p=sb);const y=r[u%a],b=r[(u+1)%a];if(this.closed||u+2r.length-2?r.length-1:l+1],y=r[l>r.length-3?r.length-1:l+2];return i.set(tA(u,h.x,p.x,g.x,y.x),tA(u,h.y,p.y,g.y,y.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const l=r[a]-i,u=this.curves[a],h=u.getLength(),p=h===0?0:1-l/h;return u.getPointAt(p,t)}a++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const y=p.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}this.curves.push(p);const g=p.getPoint(1);return this.currentPoint.copy(g),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class hd extends wx{constructor(e){super(e),this.uuid=_a(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i80*t){u=n[0],h=n[1];let g=u,y=h;for(let b=t;bg&&(g=x),M>y&&(y=M)}p=Math.max(g-u,y-h),p=p!==0?32767/p:0}return f0(a,l,t,u,h,p,0),l}function oD(n,e,t,i,r){let a;if(r===UU(n,e,t,i)>0)for(let l=e;l=e;l-=i)a=nA(l/i|0,n[l],n[l+1],a);return a&&Rp(a,a.next)&&(h0(a),a=a.next),a}function _d(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Rp(t,t.next)||Ui(t.prev,t,t.next)===0)){if(h0(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function f0(n,e,t,i,r,a,l){if(!n)return;!l&&a&&DU(n,i,r,a);let u=n;for(;n.prev!==n.next;){const h=n.prev,p=n.next;if(a?SU(n,i,r,a):_U(n)){e.push(h.i,n.i,p.i),h0(n),n=p.next,u=p.next;continue}if(n=p,n===u){l?l===1?(n=MU(_d(n),e),f0(n,e,t,i,r,a,2)):l===2&&EU(n,e,t,i,r,a):f0(_d(n),e,t,i,r,a,1);break}}}function _U(n){const e=n.prev,t=n,i=n.next;if(Ui(e,t,i)>=0)return!1;const r=e.x,a=t.x,l=i.x,u=e.y,h=t.y,p=i.y,g=Math.min(r,a,l),y=Math.min(u,h,p),b=Math.max(r,a,l),x=Math.max(u,h,p);let M=i.next;for(;M!==e;){if(M.x>=g&&M.x<=b&&M.y>=y&&M.y<=x&&zg(r,u,a,h,l,p,M.x,M.y)&&Ui(M.prev,M,M.next)>=0)return!1;M=M.next}return!0}function SU(n,e,t,i){const r=n.prev,a=n,l=n.next;if(Ui(r,a,l)>=0)return!1;const u=r.x,h=a.x,p=l.x,g=r.y,y=a.y,b=l.y,x=Math.min(u,h,p),M=Math.min(g,y,b),A=Math.max(u,h,p),w=Math.max(g,y,b),E=dM(x,M,e,t,i),R=dM(A,w,e,t,i);let D=n.prevZ,P=n.nextZ;for(;D&&D.z>=E&&P&&P.z<=R;){if(D.x>=x&&D.x<=A&&D.y>=M&&D.y<=w&&D!==r&&D!==l&&zg(u,g,h,y,p,b,D.x,D.y)&&Ui(D.prev,D,D.next)>=0||(D=D.prevZ,P.x>=x&&P.x<=A&&P.y>=M&&P.y<=w&&P!==r&&P!==l&&zg(u,g,h,y,p,b,P.x,P.y)&&Ui(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;D&&D.z>=E;){if(D.x>=x&&D.x<=A&&D.y>=M&&D.y<=w&&D!==r&&D!==l&&zg(u,g,h,y,p,b,D.x,D.y)&&Ui(D.prev,D,D.next)>=0)return!1;D=D.prevZ}for(;P&&P.z<=R;){if(P.x>=x&&P.x<=A&&P.y>=M&&P.y<=w&&P!==r&&P!==l&&zg(u,g,h,y,p,b,P.x,P.y)&&Ui(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function MU(n,e){let t=n;do{const i=t.prev,r=t.next.next;!Rp(i,r)&&cD(i,t,t.next,r)&&d0(i,r)&&d0(r,i)&&(e.push(i.i,t.i,r.i),h0(t),h0(t.next),t=n=r),t=t.next}while(t!==n);return _d(t)}function EU(n,e,t,i,r,a){let l=n;do{let u=l.next.next;for(;u!==l.prev;){if(l.i!==u.i&&IU(l,u)){let h=uD(l,u);l=_d(l,l.next),h=_d(h,h.next),f0(l,e,t,i,r,a,0),f0(h,e,t,i,r,a,0);return}u=u.next}l=l.next}while(l!==n)}function TU(n,e,t,i){const r=[];for(let a=0,l=e.length;a=t.next.y&&t.next.y!==t.y){const y=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(y<=i&&y>a&&(a=y,l=t.x=t.x&&t.x>=h&&i!==t.x&&lD(rl.x||t.x===l.x&&RU(l,t)))&&(l=t,g=y)}t=t.next}while(t!==u);return l}function RU(n,e){return Ui(n.prev,n,e.prev)<0&&Ui(e.next,n,n.next)<0}function DU(n,e,t,i){let r=n;do r.z===0&&(r.z=dM(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,OU(r)}function OU(n){let e,t=1;do{let i=n,r;n=null;let a=null;for(e=0;i;){e++;let l=i,u=0;for(let p=0;p0||h>0&&l;)u!==0&&(h===0||!l||i.z<=l.z)?(r=i,i=i.nextZ,u--):(r=l,l=l.nextZ,h--),a?a.nextZ=r:n=r,r.prevZ=a,a=r;i=l}a.nextZ=null,t*=2}while(e>1);return n}function dM(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function PU(n){let e=n,t=n;do(e.x=(n-l)*(a-u)&&(n-l)*(i-u)>=(t-l)*(e-u)&&(t-l)*(a-u)>=(r-l)*(i-u)}function zg(n,e,t,i,r,a,l,u){return!(n===l&&e===u)&&lD(n,e,t,i,r,a,l,u)}function IU(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!NU(n,e)&&(d0(n,e)&&d0(e,n)&&LU(n,e)&&(Ui(n.prev,n,e.prev)||Ui(n,e.prev,e))||Rp(n,e)&&Ui(n.prev,n,n.next)>0&&Ui(e.prev,e,e.next)>0)}function Ui(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Rp(n,e){return n.x===e.x&&n.y===e.y}function cD(n,e,t,i){const r=ob(Ui(n,e,t)),a=ob(Ui(n,e,i)),l=ob(Ui(t,i,n)),u=ob(Ui(t,i,e));return!!(r!==a&&l!==u||r===0&&ab(n,t,e)||a===0&&ab(n,i,e)||l===0&&ab(t,n,i)||u===0&&ab(t,e,i))}function ab(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ob(n){return n>0?1:n<0?-1:0}function NU(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&cD(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function d0(n,e){return Ui(n.prev,n,n.next)<0?Ui(n,e,n.next)>=0&&Ui(n,n.prev,e)>=0:Ui(n,e,n.prev)<0||Ui(n,n.next,e)<0}function LU(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,a=(n.y+e.y)/2;do t.y>a!=t.next.y>a&&t.next.y!==t.y&&r<(t.next.x-t.x)*(a-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function uD(n,e){const t=hM(n.i,n.x,n.y),i=hM(e.i,e.x,e.y),r=n.next,a=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,a.next=i,i.prev=a,i}function nA(n,e,t,i){const r=hM(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function h0(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function hM(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function UU(n,e,t,i){let r=0;for(let a=e,l=t-i;a2&&n[e-1].equals(n[0])&&n.pop()}function rA(n,e){for(let t=0;tNumber.EPSILON){const ue=Math.sqrt(I),De=Math.sqrt(Te*Te+H*H),_e=Pe.x-Et/ue,nt=Pe.y+st/ue,Ye=ze.x-H/De,dt=ze.y+Te/De,Ct=((Ye-_e)*H-(dt-nt)*Te)/(st*H-Et*Te);Xe=_e+st*Ct-Ce.x,Y=nt+Et*Ct-Ce.y;const $e=Xe*Xe+Y*Y;if($e<=2)return new Le(Xe,Y);bt=Math.sqrt($e/2)}else{let ue=!1;st>Number.EPSILON?Te>Number.EPSILON&&(ue=!0):st<-Number.EPSILON?Te<-Number.EPSILON&&(ue=!0):Math.sign(Et)===Math.sign(H)&&(ue=!0),ue?(Xe=-Et,Y=st,bt=Math.sqrt(I)):(Xe=st,Y=Et,bt=Math.sqrt(I/2))}return new Le(Xe/bt,Y/bt)}const pe=[];for(let Ce=0,Pe=re.length,ze=Pe-1,Xe=Ce+1;Ce=0;Ce--){const Pe=Ce/w,ze=x*Math.cos(Pe*Math.PI/2),Xe=M*Math.sin(Pe*Math.PI/2)+A;for(let Y=0,bt=re.length;Y=0;){const Xe=ze;let Y=ze-1;Y<0&&(Y=Ce.length-1);for(let bt=0,st=g+w*2;bt0)&&x.push(D,P,L),(E!==i-1||h0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class pD extends Ir{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new pt(16777215),this.specular=new pt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ku,this.normalScale=new Le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ta,this.combine=E0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class mD extends Ir{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new pt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ku,this.normalScale=new Le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class LE extends Ir{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ku,this.normalScale=new Le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class gD extends Ir{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new pt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ku,this.normalScale=new Le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ta,this.combine=E0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class UE extends Ir{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Zu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class zE extends Ir{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class vD extends Ir{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new pt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ku,this.normalScale=new Le(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class yD extends Is{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function cd(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function bD(n){function e(r,a){return n[r]-n[a]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function pM(n,e,t){const i=n.length,r=new n.constructor(i);for(let a=0,l=0;l!==i;++a){const u=t[a]*e;for(let h=0;h!==e;++h)r[l++]=n[u+h]}return r}function BE(n,e,t,i){let r=1,a=n[0];for(;a!==void 0&&a[i]===void 0;)a=n[r++];if(a===void 0)return;let l=a[i];if(l!==void 0)if(Array.isArray(l))do l=a[i],l!==void 0&&(e.push(a.time),t.push(...l)),a=n[r++];while(a!==void 0);else if(l.toArray!==void 0)do l=a[i],l!==void 0&&(e.push(a.time),l.toArray(t,t.length)),a=n[r++];while(a!==void 0);else do l=a[i],l!==void 0&&(e.push(a.time),t.push(l)),a=n[r++];while(a!==void 0)}function HU(n,e,t,i,r=30){const a=n.clone();a.name=e;const l=[];for(let h=0;h=i)){y.push(p.times[x]);for(let A=0;Aa.tracks[h].times[0]&&(u=a.tracks[h].times[0]);for(let h=0;h=u.times[M]){const E=M*y+g,R=E+y-g;A=u.values.slice(E,R)}else{const E=u.createInterpolant(),R=g,D=y-g;E.evaluate(a),A=E.resultBuffer.slice(R,D)}h==="quaternion"&&new cs().fromArray(A).normalize().conjugate().toArray(A);const w=p.times.length;for(let E=0;E=a)){const u=t[1];e=a)break t}l=i,i=0;break n}break e}for(;i>>1;et;)--l;if(++l,a!==0||l!==r){a>=l&&(l=Math.max(l,1),a=l-1);const u=this.getValueSize();this.times=i.slice(a,l),this.values=this.values.slice(a*u,l*u)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Lt("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,a=i.length;a===0&&(Lt("KeyframeTrack: Track is empty.",this),e=!1);let l=null;for(let u=0;u!==a;u++){const h=i[u];if(typeof h=="number"&&isNaN(h)){Lt("KeyframeTrack: Time is not a valid number.",this,u,h),e=!1;break}if(l!==null&&l>h){Lt("KeyframeTrack: Out of order keys.",this,u,h,l),e=!1;break}l=h}if(r!==void 0&&B3(r))for(let u=0,h=r.length;u!==h;++u){const p=r[u];if(isNaN(p)){Lt("KeyframeTrack: Value is not a valid number.",this,u,p),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Rb,a=e.length-1;let l=1;for(let u=1;u0){e[l]=e[a];for(let u=a*i,h=l*i,p=0;p!==i;++p)t[h+p]=t[u+p];++l}return l!==e.length?(this.times=e.slice(0,l),this.values=t.slice(0,l*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}io.prototype.ValueTypeName="";io.prototype.TimeBufferType=Float32Array;io.prototype.ValueBufferType=Float32Array;io.prototype.DefaultInterpolation=Sx;class Cd extends io{constructor(e,t,i){super(e,t,i)}}Cd.prototype.ValueTypeName="bool";Cd.prototype.ValueBufferType=Array;Cd.prototype.DefaultInterpolation=s0;Cd.prototype.InterpolantFactoryMethodLinear=void 0;Cd.prototype.InterpolantFactoryMethodSmooth=void 0;class kE extends io{constructor(e,t,i,r){super(e,t,i,r)}}kE.prototype.ValueTypeName="color";class p0 extends io{constructor(e,t,i,r){super(e,t,i,r)}}p0.prototype.ValueTypeName="number";class SD extends P0{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const a=this.resultBuffer,l=this.sampleValues,u=this.valueSize,h=(i-t)/(r-t);let p=e*u;for(let g=p+u;p!==g;p+=4)cs.slerpFlat(a,0,l,p-u,l,p,h);return a}}class I0 extends io{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new SD(this.times,this.values,this.getValueSize(),e)}}I0.prototype.ValueTypeName="quaternion";I0.prototype.InterpolantFactoryMethodSmooth=void 0;class Rd extends io{constructor(e,t,i){super(e,t,i)}}Rd.prototype.ValueTypeName="string";Rd.prototype.ValueBufferType=Array;Rd.prototype.DefaultInterpolation=s0;Rd.prototype.InterpolantFactoryMethodLinear=void 0;Rd.prototype.InterpolantFactoryMethodSmooth=void 0;class m0 extends io{constructor(e,t,i,r){super(e,t,i,r)}}m0.prototype.ValueTypeName="vector";class g0{constructor(e="",t=-1,i=[],r=n_){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=_a(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let l=0,u=i.length;l!==u;++l)t.push($U(i[l]).scale(r));const a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a.userData=JSON.parse(e.userData||"{}"),a}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let a=0,l=i.length;a!==l;++a)t.push(io.toJSON(i[a]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const a=t.length,l=[];for(let u=0;u1){const y=g[1];let b=r[y];b||(r[y]=b=[]),b.push(p)}}const l=[];for(const u in r)l.push(this.CreateFromMorphTargetSequence(u,r[u],t,i));return l}static parseAnimation(e,t){if(vt("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Lt("AnimationClip: No animation in JSONLoader data."),null;const i=function(y,b,x,M,A){if(x.length!==0){const w=[],E=[];BE(x,w,E,M),w.length!==0&&A.push(new y(b,w,E))}},r=[],a=e.name||"default",l=e.fps||30,u=e.blendMode;let h=e.length||-1;const p=e.hierarchy||[];for(let y=0;y{t&&t(a),this.manager.itemEnd(e)},0),a;if(bc[e]!==void 0){bc[e].push({onLoad:t,onProgress:i,onError:r});return}bc[e]=[],bc[e].push({onLoad:t,onProgress:i,onError:r});const l=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),u=this.mimeType,h=this.responseType;fetch(l).then(p=>{if(p.status===200||p.status===0){if(p.status===0&&vt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||p.body===void 0||p.body.getReader===void 0)return p;const g=bc[e],y=p.body.getReader(),b=p.headers.get("X-File-Size")||p.headers.get("Content-Length"),x=b?parseInt(b):0,M=x!==0;let A=0;const w=new ReadableStream({start(E){R();function R(){y.read().then(({done:D,value:P})=>{if(D)E.close();else{A+=P.byteLength;const F=new ProgressEvent("progress",{lengthComputable:M,loaded:A,total:x});for(let L=0,k=g.length;L{E.error(D)})}}});return new Response(w)}else throw new XU(`fetch for "${p.url}" responded with ${p.status}: ${p.statusText}`,p)}).then(p=>{switch(h){case"arraybuffer":return p.arrayBuffer();case"blob":return p.blob();case"document":return p.text().then(g=>new DOMParser().parseFromString(g,u));case"json":return p.json();default:if(u==="")return p.text();{const y=/charset="?([^;"\s]*)"?/i.exec(u),b=y&&y[1]?y[1].toLowerCase():void 0,x=new TextDecoder(b);return p.arrayBuffer().then(M=>x.decode(M))}}}).then(p=>{El.add(`file:${e}`,p);const g=bc[e];delete bc[e];for(let y=0,b=g.length;y{const g=bc[e];if(g===void 0)throw this.manager.itemError(e),p;delete bc[e];for(let y=0,b=g.length;y{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class jU extends la{constructor(e){super(e)}load(e,t,i,r){const a=this,l=new Rc(this.manager);l.setPath(this.path),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(u){try{t(a.parse(JSON.parse(u)))}catch(h){r?r(h):Lt(h),a.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const a in e.uniforms){const l=e.uniforms[a];switch(r.uniforms[a]={},l.type){case"t":r.uniforms[a].value=i(l.value);break;case"c":r.uniforms[a].value=new pt().setHex(l.value);break;case"v2":r.uniforms[a].value=new Le().fromArray(l.value);break;case"v3":r.uniforms[a].value=new K().fromArray(l.value);break;case"v4":r.uniforms[a].value=new Zn().fromArray(l.value);break;case"m3":r.uniforms[a].value=new on().fromArray(l.value);break;case"m4":r.uniforms[a].value=new Kt().fromArray(l.value);break;default:r.uniforms[a].value=l.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const a in e.extensions)r.extensions[a]=e.extensions[a];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let a=e.normalScale;Array.isArray(a)===!1&&(a=[a,a]),r.normalScale=new Le().fromArray(a)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Le().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return A_.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:dD,SpriteMaterial:ME,RawShaderMaterial:IE,ShaderMaterial:Yn,PointsMaterial:TE,MeshPhysicalMaterial:hD,MeshStandardMaterial:NE,MeshPhongMaterial:pD,MeshToonMaterial:mD,MeshNormalMaterial:LE,MeshLambertMaterial:gD,MeshDepthMaterial:UE,MeshDistanceMaterial:zE,MeshBasicMaterial:Qu,MeshMatcapMaterial:vD,LineDashedMaterial:yD,LineBasicMaterial:Is,Material:Ir};return new t[e]}}class mM{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class OD extends en{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class PD extends la{constructor(e){super(e)}load(e,t,i,r){const a=this,l=new Rc(a.manager);l.setPath(a.path),l.setRequestHeader(a.requestHeader),l.setWithCredentials(a.withCredentials),l.load(e,function(u){try{t(a.parse(JSON.parse(u)))}catch(h){r?r(h):Lt(h),a.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(x,M){if(t[M]!==void 0)return t[M];const w=x.interleavedBuffers[M],E=a(x,w.buffer),R=pp(w.type,E),D=new u_(R,w.stride);return D.uuid=w.uuid,t[M]=D,D}function a(x,M){if(i[M]!==void 0)return i[M];const w=x.arrayBuffers[M],E=new Uint32Array(w).buffer;return i[M]=E,E}const l=e.isInstancedBufferGeometry?new OD:new en,u=e.data.index;if(u!==void 0){const x=pp(u.type,u.array);l.setIndex(new Wn(x,1))}const h=e.data.attributes;for(const x in h){const M=h[x];let A;if(M.isInterleavedBufferAttribute){const w=r(e.data,M.data);A=new xd(w,M.itemSize,M.offset,M.normalized)}else{const w=pp(M.type,M.array),E=M.isInstancedBufferAttribute?Cp:Wn;A=new E(w,M.itemSize,M.normalized)}M.name!==void 0&&(A.name=M.name),M.usage!==void 0&&A.setUsage(M.usage),l.setAttribute(x,A)}const p=e.data.morphAttributes;if(p)for(const x in p){const M=p[x],A=[];for(let w=0,E=M.length;w0){const h=new HE(t);a=new v0(h),a.setCrossOrigin(this.crossOrigin);for(let p=0,g=e.length;p0){r=new v0(this.manager),r.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l{let E=null,R=null;return w.boundingBox!==void 0&&(E=new us().fromJSON(w.boundingBox)),w.boundingSphere!==void 0&&(R=new Xr().fromJSON(w.boundingSphere)),{...w,boundingBox:E,boundingSphere:R}}),l._instanceInfo=e.instanceInfo,l._availableInstanceIds=e._availableInstanceIds,l._availableGeometryIds=e._availableGeometryIds,l._nextIndexStart=e.nextIndexStart,l._nextVertexStart=e.nextVertexStart,l._geometryCount=e.geometryCount,l._maxInstanceCount=e.maxInstanceCount,l._maxVertexCount=e.maxVertexCount,l._maxIndexCount=e.maxIndexCount,l._geometryInitialized=e.geometryInitialized,l._matricesTexture=p(e.matricesTexture.uuid),l._indirectTexture=p(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(l._colorsTexture=p(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(l.boundingSphere=new Xr().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(l.boundingBox=new us().fromJSON(e.boundingBox));break;case"LOD":l=new j3;break;case"Line":l=new Hu(u(e.geometry),h(e.material));break;case"LineLoop":l=new K3(u(e.geometry),h(e.material));break;case"LineSegments":l=new Il(u(e.geometry),h(e.material));break;case"PointCloud":case"Points":l=new Q3(u(e.geometry),h(e.material));break;case"Sprite":l=new X3(h(e.material));break;case"Group":l=new mp;break;case"Bone":l=new EE;break;default:l=new Ln}if(l.uuid=e.uuid,e.name!==void 0&&(l.name=e.name),e.matrix!==void 0?(l.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(l.matrixAutoUpdate=e.matrixAutoUpdate),l.matrixAutoUpdate&&l.matrix.decompose(l.position,l.quaternion,l.scale)):(e.position!==void 0&&l.position.fromArray(e.position),e.rotation!==void 0&&l.rotation.fromArray(e.rotation),e.quaternion!==void 0&&l.quaternion.fromArray(e.quaternion),e.scale!==void 0&&l.scale.fromArray(e.scale)),e.up!==void 0&&l.up.fromArray(e.up),e.castShadow!==void 0&&(l.castShadow=e.castShadow),e.receiveShadow!==void 0&&(l.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(l.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(l.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(l.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(l.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&l.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(l.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(l.visible=e.visible),e.frustumCulled!==void 0&&(l.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(l.renderOrder=e.renderOrder),e.userData!==void 0&&(l.userData=e.userData),e.layers!==void 0&&(l.layers.mask=e.layers),e.children!==void 0){const b=e.children;for(let x=0;x"u"&&vt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&vt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=this,l=El.get(`image-bitmap:${e}`);if(l!==void 0){if(a.manager.itemStart(e),l.then){l.then(p=>{if(a1.has(l)===!0)r&&r(a1.get(l)),a.manager.itemError(e),a.manager.itemEnd(e);else return t&&t(p),a.manager.itemEnd(e),p});return}return setTimeout(function(){t&&t(l),a.manager.itemEnd(e)},0),l}const u={};u.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",u.headers=this.requestHeader,u.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const h=fetch(e,u).then(function(p){return p.blob()}).then(function(p){return createImageBitmap(p,Object.assign(a.options,{colorSpaceConversion:"none"}))}).then(function(p){return El.add(`image-bitmap:${e}`,p),t&&t(p),a.manager.itemEnd(e),p}).catch(function(p){r&&r(p),a1.set(h,p),El.remove(`image-bitmap:${e}`),a.manager.itemError(e),a.manager.itemEnd(e)});El.add(`image-bitmap:${e}`,h),a.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let lb;class WE{static getContext(){return lb===void 0&&(lb=new(window.AudioContext||window.webkitAudioContext)),lb}static setContext(e){lb=e}}class rz extends la{constructor(e){super(e)}load(e,t,i,r){const a=this,l=new Rc(this.manager);l.setResponseType("arraybuffer"),l.setPath(this.path),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{const p=h.slice(0);WE.getContext().decodeAudioData(p,function(y){t(y)}).catch(u)}catch(p){u(p)}},i,r);function u(h){r?r(h):Lt(h),a.manager.itemError(e)}}}const fA=new Kt,dA=new Kt,jf=new Kt;class sz{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new $i,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new $i,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,jf.copy(e.projectionMatrix);const r=t.eyeSep/2,a=r*t.near/t.focus,l=t.near*Math.tan(dd*t.fov*.5)/t.zoom;let u,h;dA.elements[12]=-r,fA.elements[12]=r,u=-l*t.aspect+a,h=l*t.aspect+a,jf.elements[0]=2*t.near/(h-u),jf.elements[8]=(h+u)/(h-u),this.cameraL.projectionMatrix.copy(jf),u=-l*t.aspect-a,h=l*t.aspect-a,jf.elements[0]=2*t.near/(h-u),jf.elements[8]=(h+u)/(h-u),this.cameraR.projectionMatrix.copy(jf)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(dA),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(fA)}}class ID extends $i{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class $E{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const qf=new K,o1=new cs,az=new K,Yf=new K,Zf=new K;class oz extends Ln{constructor(){super(),this.type="AudioListener",this.context=WE.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new $E}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(qf,o1,az),Yf.set(0,0,-1).applyQuaternion(o1),Zf.set(0,1,0).applyQuaternion(o1),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(qf.x,i),t.positionY.linearRampToValueAtTime(qf.y,i),t.positionZ.linearRampToValueAtTime(qf.z,i),t.forwardX.linearRampToValueAtTime(Yf.x,i),t.forwardY.linearRampToValueAtTime(Yf.y,i),t.forwardZ.linearRampToValueAtTime(Yf.z,i),t.upX.linearRampToValueAtTime(Zf.x,i),t.upY.linearRampToValueAtTime(Zf.y,i),t.upZ.linearRampToValueAtTime(Zf.z,i)}else t.setPosition(qf.x,qf.y,qf.z),t.setOrientation(Yf.x,Yf.y,Yf.z,Zf.x,Zf.y,Zf.z)}}class ND extends Ln{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){vt("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){vt("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){vt("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){vt("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let h=t,p=t+t;h!==p;++h)if(i[h]!==i[h+t]){u.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let a=i,l=r;a!==l;++a)t[a]=t[r+a%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let l=0;l!==a;++l)e[t+l]=e[i+l]}_slerp(e,t,i,r){cs.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,a){const l=this._workIndex*a;cs.multiplyQuaternionsFlat(e,l,e,t,e,i),cs.slerpFlat(e,t,e,t,e,l,r)}_lerp(e,t,i,r,a){const l=1-r;for(let u=0;u!==a;++u){const h=t+u;e[h]=e[h]*l+e[i+u]*r}}_lerpAdditive(e,t,i,r,a){for(let l=0;l!==a;++l){const u=t+l;e[u]=e[u]+e[i+l]*r}}}const XE="\\[\\]\\.:\\/",fz=new RegExp("["+XE+"]","g"),jE="[^"+XE+"]",dz="[^"+XE.replace("\\.","")+"]",hz=/((?:WC+[\/:])*)/.source.replace("WC",jE),pz=/(WCOD+)?/.source.replace("WCOD",dz),mz=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jE),gz=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jE),vz=new RegExp("^"+hz+pz+mz+gz+"$"),yz=["material","materials","bones","map"];class bz{constructor(e,t,i){const r=i||In.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class In{constructor(e,t,i){this.path=t,this.parsedPath=i||In.parseTrackName(t),this.node=In.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new In.Composite(e,t,i):new In(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fz,"")}static parseTrackName(e){const t=vz.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const a=i.nodeName.substring(r+1);yz.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(a){for(let l=0;l=a){const y=a++,b=e[y];t[b.uuid]=g,e[g]=b,t[p]=y,e[y]=h;for(let x=0,M=r;x!==M;++x){const A=i[x],w=A[y],E=A[g];A[g]=w,A[y]=E}}}this.nCachedObjects_=a}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let a=this.nCachedObjects_,l=e.length;for(let u=0,h=arguments.length;u!==h;++u){const p=arguments[u],g=p.uuid,y=t[g];if(y!==void 0)if(delete t[g],y0&&(t[x.uuid]=y),e[y]=x,e.pop();for(let M=0,A=r;M!==A;++M){const w=i[M];w[y]=w[b],w.pop()}}}this.nCachedObjects_=a}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const a=this._bindings;if(r!==void 0)return a[r];const l=this._paths,u=this._parsedPaths,h=this._objects,p=h.length,g=this.nCachedObjects_,y=new Array(p);r=a.length,i[e]=r,l.push(e),u.push(t),a.push(y);for(let b=g,x=h.length;b!==x;++b){const M=h[b];y[b]=new In(M,e,t)}return y}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,a=this._parsedPaths,l=this._bindings,u=l.length-1,h=l[u],p=e[u];t[p]=i,l[i]=h,l.pop(),a[i]=a[u],a.pop(),r[i]=r[u],r.pop()}}}class UD{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const a=t.tracks,l=a.length,u=new Array(l),h={endingStart:od,endingEnd:od};for(let p=0;p!==l;++p){const g=a[p].createInterpolant(null);u[p]=g,g.settings=h}this._interpolantSettings=h,this._interpolants=u,this._propertyBindings=new Array(l),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=C3,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){const r=this._clip.duration,a=e._clip.duration,l=a/r,u=r/a;e.warp(1,l,t),this.warp(u,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,a=r.time,l=this.timeScale;let u=this._timeScaleInterpolant;u===null&&(u=r._lendControlInterpolant(),this._timeScaleInterpolant=u);const h=u.parameterPositions,p=u.sampleValues;return h[0]=a,h[1]=a+i,p[0]=e/l,p[1]=t/l,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const a=this._startTime;if(a!==null){const h=(e-a)*i;h<0||i===0?t=0:(this._startTime=null,t=i*h)}t*=this._updateTimeScale(e);const l=this._updateTime(t),u=this._updateWeight(e);if(u>0){const h=this._interpolants,p=this._propertyBindings;switch(this.blendMode){case vE:for(let g=0,y=h.length;g!==y;++g)h[g].evaluate(l),p[g].accumulateAdditive(u);break;case n_:default:for(let g=0,y=h.length;g!==y;++g)h[g].evaluate(l),p[g].accumulate(r,u)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,a=this._loopCount;const l=i===R3;if(e===0)return a===-1?r:l&&(a&1)===1?t-r:r;if(i===A3){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,l)):this._setEndings(this.repetitions===0,!0,l)),r>=t||r<0){const u=Math.floor(r/t);r-=t*u,a+=Math.abs(u);const h=this.repetitions-a;if(h<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(h===1){const p=e<0;this._setEndings(p,!p,l)}else this._setEndings(!1,!1,l);this._loopCount=a,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:u})}}else this.time=r;if(l&&(a&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=ld,r.endingEnd=ld):(e?r.endingStart=this.zeroSlopeAtStart?ld:od:r.endingStart=a0,t?r.endingEnd=this.zeroSlopeAtEnd?ld:od:r.endingEnd=a0)}_scheduleFading(e,t,i){const r=this._mixer,a=r.time;let l=this._weightInterpolant;l===null&&(l=r._lendControlInterpolant(),this._weightInterpolant=l);const u=l.parameterPositions,h=l.sampleValues;return u[0]=a,h[0]=t,u[1]=a+e,h[1]=i,this}}const _z=new Float32Array(1);class Sz extends wa{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,a=r.length,l=e._propertyBindings,u=e._interpolants,h=i.uuid,p=this._bindingsByRootAndName;let g=p[h];g===void 0&&(g={},p[h]=g);for(let y=0;y!==a;++y){const b=r[y],x=b.name;let M=g[x];if(M!==void 0)++M.referenceCount,l[y]=M;else{if(M=l[y],M!==void 0){M._cacheIndex===null&&(++M.referenceCount,this._addInactiveBinding(M,h,x));continue}const A=t&&t._propertyBindings[y].binding.parsedPath;M=new LD(In.create(i,x,A),b.ValueTypeName,b.getValueSize()),++M.referenceCount,this._addInactiveBinding(M,h,x),l[y]=M}u[y].resultBuffer=M.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,a=this._actionsByClip[r];this._bindAction(e,a&&a.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const a=t[i];a.useCount++===0&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const a=t[i];--a.useCount===0&&(a.restoreOriginalState(),this._takeBackBinding(a))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,a=Math.sign(e),l=this._accuIndex^=1;for(let p=0;p!==i;++p)t[p]._update(r,e,a,l);const u=this._bindings,h=this._nActiveBindings;for(let p=0;p!==h;++p)u[p].apply(l);return this}setTime(e){this.time=0;for(let t=0;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,gA).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const vA=new K,cb=new K,np=new K,ip=new K,l1=new K,Pz=new K,Iz=new K;class Nz{constructor(e=new K,t=new K){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){vA.subVectors(e,this.start),cb.subVectors(this.end,this.start);const i=cb.dot(cb);let a=cb.dot(vA)/i;return t&&(a=Yt(a,0,1)),a}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=Pz,i=Iz){const r=10000000000000001e-32;let a,l;const u=this.start,h=e.start,p=this.end,g=e.end;np.subVectors(p,u),ip.subVectors(g,h),l1.subVectors(u,h);const y=np.dot(np),b=ip.dot(ip),x=ip.dot(l1);if(y<=r&&b<=r)return t.copy(u),i.copy(h),t.sub(i),t.dot(t);if(y<=r)a=0,l=x/b,l=Yt(l,0,1);else{const M=np.dot(l1);if(b<=r)l=0,a=Yt(-M/y,0,1);else{const A=np.dot(ip),w=y*b-A*A;w!==0?a=Yt((A*x-M*b)/w,0,1):a=0,l=(A*a+x)/b,l<0?(l=0,a=Yt(-M/y,0,1)):l>1&&(l=1,a=Yt((A-M)/y,0,1))}}return t.copy(u).add(np.multiplyScalar(a)),i.copy(h).add(ip.multiplyScalar(l)),t.sub(i),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const yA=new K;class Lz extends Ln{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new en,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let l=0,u=1,h=32;l1)for(let y=0;y.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{MA.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(MA,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class qz extends Il{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new en;r.setAttribute("position",new At(t,3)),r.setAttribute("color",new At(i,3));const a=new Is({vertexColors:!0,toneMapped:!1});super(r,a),this.type="AxesHelper"}setColors(e,t,i){const r=new pt,a=this.geometry.attributes.color.array;return r.set(e),r.toArray(a,0),r.toArray(a,3),r.set(t),r.toArray(a,6),r.toArray(a,9),r.set(i),r.toArray(a,12),r.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Yz{constructor(){this.type="ShapePath",this.color=new pt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new wx,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,a,l){return this.currentPath.bezierCurveTo(e,t,i,r,a,l),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(E){const R=[];for(let D=0,P=E.length;DNumber.EPSILON){if(z<0&&(k=R[L],N=-N,V=R[F],z=-z),E.yV.y)continue;if(E.y===k.y){if(E.x===k.x)return!0}else{const X=z*(E.x-k.x)-N*(E.y-k.y);if(X===0)return!0;if(X<0)continue;P=!P}}else{if(E.y!==k.y)continue;if(V.x<=E.x&&E.x<=k.x||k.x<=E.x&&E.x<=V.x)return!0}}return P}const r=No.isClockWise,a=this.subPaths;if(a.length===0)return[];let l,u,h;const p=[];if(a.length===1)return u=a[0],h=new hd,h.curves=u.curves,p.push(h),p;let g=!r(a[0].getPoints());g=e?!g:g;const y=[],b=[];let x=[],M=0,A;b[M]=void 0,x[M]=[];for(let E=0,R=a.length;E1){let E=!1,R=0;for(let D=0,P=b.length;D0&&E===!1&&(x=y)}let w;for(let E=0,R=b.length;Ee?(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2):(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0),n}function Qz(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0):(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2),n}function Jz(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function yM(n,e,t,i){const r=eB(i);switch(t){case mE:return n*e;case T0:return n*e/r.components*r.byteLength;case w0:return n*e/r.components*r.byteLength;case bd:return n*e*2/r.components*r.byteLength;case e_:return n*e*2/r.components*r.byteLength;case gE:return n*e*3/r.components*r.byteLength;case $r:return n*e*4/r.components*r.byteLength;case t_:return n*e*4/r.components*r.byteLength;case Vg:case Gg:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Wg:case $g:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case $b:case jb:return Math.max(n,16)*Math.max(e,8)/4;case Wb:case Xb:return Math.max(n,8)*Math.max(e,8)/2;case qb:case Yb:case Kb:case Qb:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Zb:case Jb:case ex:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case tx:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case nx:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case ix:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case rx:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case sx:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case ax:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case ox:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case lx:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case cx:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case ux:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case fx:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case dx:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case hx:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case px:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case mx:case gx:case vx:return Math.ceil(n/4)*Math.ceil(e/4)*16;case yx:case bx:return Math.ceil(n/4)*Math.ceil(e/4)*8;case xx:case _x:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function eB(n){switch(n){case Xi:case fE:return{byteLength:1,components:1};case Sp:case dE:case no:return{byteLength:2,components:1};case Qx:case Jx:return{byteLength:2,components:4};case Ea:case Kx:case Or:return{byteLength:4,components:1};case hE:case pE:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}class tB{static contain(e,t){return Kz(e,t)}static cover(e,t){return Qz(e,t)}static fill(e){return Jz(e)}static getByteLength(e,t,i,r){return yM(e,t,i,r)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Td}}));typeof window<"u"&&(window.__THREE__?vt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Td);function FD(){let n=null,e=!1,t=null,i=null;function r(a,l){t(a,l),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(a){t=a},setContext:function(a){n=a}}}function nB(n){const e=new WeakMap;function t(u,h){const p=u.array,g=u.usage,y=p.byteLength,b=n.createBuffer();n.bindBuffer(h,b),n.bufferData(h,p,g),u.onUploadCallback();let x;if(p instanceof Float32Array)x=n.FLOAT;else if(typeof Float16Array<"u"&&p instanceof Float16Array)x=n.HALF_FLOAT;else if(p instanceof Uint16Array)u.isFloat16BufferAttribute?x=n.HALF_FLOAT:x=n.UNSIGNED_SHORT;else if(p instanceof Int16Array)x=n.SHORT;else if(p instanceof Uint32Array)x=n.UNSIGNED_INT;else if(p instanceof Int32Array)x=n.INT;else if(p instanceof Int8Array)x=n.BYTE;else if(p instanceof Uint8Array)x=n.UNSIGNED_BYTE;else if(p instanceof Uint8ClampedArray)x=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+p);return{buffer:b,type:x,bytesPerElement:p.BYTES_PER_ELEMENT,version:u.version,size:y}}function i(u,h,p){const g=h.array,y=h.updateRanges;if(n.bindBuffer(p,u),y.length===0)n.bufferSubData(p,0,g);else{y.sort((x,M)=>x.start-M.start);let b=0;for(let x=1;x 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`,bB=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,xB=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,_B=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,SB=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,MB=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,EB=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,TB=`#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`,wB=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,AB=`#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`,CB=`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`,RB=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,DB=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,OB=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,PB=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,IB="gl_FragColor = linearToOutputTexel( gl_FragColor );",NB=`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 ); }`,LB=`#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`,UB=`#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`,zB=`#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`,BB=`#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`,FB=`#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`,kB=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,HB=`#ifdef USE_FOG varying float vFogDepth; #endif`,VB=`#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`,GB=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,WB=`#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 }`,$B=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,XB=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,jB=`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`,qB=`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`,YB=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,ZB=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,KB=`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`,QB=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,JB=`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`,e4=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb; material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); material.metalness = metalnessFactor; vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = vec3( 0.04 ); material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,t4=`uniform sampler2D dfgLUT; struct PhysicalMaterial { vec3 diffuseColor; vec3 diffuseContribution; vec3 specularColor; vec3 specularColorBlended; float roughness; float metalness; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; vec3 iridescenceFresnelDielectric; vec3 iridescenceFresnelMetallic; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return v; } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColorBlended; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float rInv = 1.0 / ( roughness + 0.1 ); float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; float DG = exp( a * dotNV + b ); return saturate( DG ); } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; float Ess_V = dfgV.x + dfgV.y; float Ess_L = dfgL.x + dfgL.y; float Ems_V = 1.0 - Ess_V; float Ems_L = 1.0 - Ess_L; vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); float compensationFactor = Ems_V * Ems_L; vec3 multiScatter = Fms * compensationFactor; return singleScatter + multiScatter; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); irradiance *= sheenEnergyComp; #endif reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; diffuse *= sheenEnergyComp; #endif reflectedLight.indirectDiffuse += diffuse; } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; #endif vec3 singleScatteringDielectric = vec3( 0.0 ); vec3 multiScatteringDielectric = vec3( 0.0 ); vec3 singleScatteringMetallic = vec3( 0.0 ); vec3 multiScatteringMetallic = vec3( 0.0 ); #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #endif vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; vec3 indirectSpecular = radiance * singleScattering; indirectSpecular += multiScattering * cosineWeightedIrradiance; vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; indirectSpecular *= sheenEnergyComp; indirectDiffuse *= sheenEnergyComp; #endif reflectedLight.indirectSpecular += indirectSpecular; reflectedLight.indirectDiffuse += indirectDiffuse; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,n4=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,i4=`#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`,r4=`#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`,s4=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,a4=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,o4=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,l4=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,c4=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,u4=`#ifdef USE_MAP uniform sampler2D map; #endif`,f4=`#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`,d4=`#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`,h4=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,p4=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,m4=`#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`,g4=`#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`,v4=`#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`,y4=`#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`,b4=`#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`,x4=`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;`,_4=`#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`,S4=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,M4=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,E4=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,T4=`#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`,w4=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,A4=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,C4=`#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`,R4=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,D4=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,O4=`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 ); }`,P4=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,I4=`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;`,N4=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,L4=`#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`,U4=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,z4=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,B4=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #else uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #endif varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #else uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #endif struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #elif defined( SHADOWMAP_TYPE_BASIC ) uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #endif varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #if defined( SHADOWMAP_TYPE_PCF ) float interleavedGradientNoise( vec2 position ) { return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); } vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { const float goldenAngle = 2.399963229728653; float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); float theta = float( sampleIndex ) * goldenAngle + phi; return vec2( cos( theta ), sin( theta ) ) * r; } #endif #if defined( SHADOWMAP_TYPE_PCF ) float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float radius = shadowRadius * texelSize.x; float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718; shadow = ( texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_VSM ) float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; float mean = distribution.x; float variance = distribution.y * distribution.y; #ifdef USE_REVERSED_DEPTH_BUFFER float hard_shadow = step( mean, shadowCoord.z ); #else float hard_shadow = step( shadowCoord.z, mean ); #endif if ( hard_shadow == 1.0 ) { shadow = 1.0; } else { variance = max( variance, 0.0000001 ); float d = shadowCoord.z - mean; float p_max = variance / ( variance + d * d ); p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); shadow = max( hard_shadow, p_max ); } } return mix( 1.0, shadow, shadowIntensity ); } #else float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; 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 ) { float depth = texture2D( shadowMap, shadowCoord.xy ).r; #ifdef USE_REVERSED_DEPTH_BUFFER shadow = step( depth, shadowCoord.z ); #else shadow = step( shadowCoord.z, depth ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 bd3D = normalize( lightToPosition ); vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; float texelSize = shadowRadius / shadowMapSize.x; vec3 absDir = abs( bd3D ); vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); tangent = normalize( cross( bd3D, tangent ) ); vec3 bitangent = cross( bd3D, tangent ); float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718; shadow = ( texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_BASIC ) float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 bd3D = normalize( lightToPosition ); vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; float depth = textureCube( shadowMap, bd3D ).r; #ifdef USE_REVERSED_DEPTH_BUFFER shadow = step( depth, dp ); #else shadow = step( dp, depth ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif #endif #endif`,F4=`#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`,k4=`#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`,H4=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,V4=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,G4=`#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`,W4=`#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`,$4=`#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`,X4=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,j4=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,q4=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,Y4=`#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; }`,Z4=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,K4=`#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`,Q4=`#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`,J4=`#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`,eF=`#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`,tF=`#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 nF=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,iF=`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 }`,rF=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,sF=`#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 }`,aF=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,oF=`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 }`,lF=`#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; }`,cF=`#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 #ifdef USE_REVERSED_DEPTH_BUFFER float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; #else float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; #endif #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,uF=`#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; }`,fF=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #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 = vec4( dist, 0.0, 0.0, 1.0 ); }`,dF=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,hF=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,pF=`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 }`,mF=`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 }`,gF=`#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 }`,vF=`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 }`,yF=`#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 }`,bF=`#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 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 }`,xF=`#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; }`,_F=`#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 }`,SF=`#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 }`,MF=`#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 void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,EF=`#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 }`,TF=`#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 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 }`,wF=`#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 }`,AF=`#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 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 outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,CF=`#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 }`,RF=`#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 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 }`,DF=`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 }`,OF=`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 }`,PF=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,IF=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,NF=`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 }`,LF=`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 }`,pn={alphahash_fragment:iB,alphahash_pars_fragment:rB,alphamap_fragment:sB,alphamap_pars_fragment:aB,alphatest_fragment:oB,alphatest_pars_fragment:lB,aomap_fragment:cB,aomap_pars_fragment:uB,batching_pars_vertex:fB,batching_vertex:dB,begin_vertex:hB,beginnormal_vertex:pB,bsdfs:mB,iridescence_fragment:gB,bumpmap_pars_fragment:vB,clipping_planes_fragment:yB,clipping_planes_pars_fragment:bB,clipping_planes_pars_vertex:xB,clipping_planes_vertex:_B,color_fragment:SB,color_pars_fragment:MB,color_pars_vertex:EB,color_vertex:TB,common:wB,cube_uv_reflection_fragment:AB,defaultnormal_vertex:CB,displacementmap_pars_vertex:RB,displacementmap_vertex:DB,emissivemap_fragment:OB,emissivemap_pars_fragment:PB,colorspace_fragment:IB,colorspace_pars_fragment:NB,envmap_fragment:LB,envmap_common_pars_fragment:UB,envmap_pars_fragment:zB,envmap_pars_vertex:BB,envmap_physical_pars_fragment:YB,envmap_vertex:FB,fog_vertex:kB,fog_pars_vertex:HB,fog_fragment:VB,fog_pars_fragment:GB,gradientmap_pars_fragment:WB,lightmap_pars_fragment:$B,lights_lambert_fragment:XB,lights_lambert_pars_fragment:jB,lights_pars_begin:qB,lights_toon_fragment:ZB,lights_toon_pars_fragment:KB,lights_phong_fragment:QB,lights_phong_pars_fragment:JB,lights_physical_fragment:e4,lights_physical_pars_fragment:t4,lights_fragment_begin:n4,lights_fragment_maps:i4,lights_fragment_end:r4,logdepthbuf_fragment:s4,logdepthbuf_pars_fragment:a4,logdepthbuf_pars_vertex:o4,logdepthbuf_vertex:l4,map_fragment:c4,map_pars_fragment:u4,map_particle_fragment:f4,map_particle_pars_fragment:d4,metalnessmap_fragment:h4,metalnessmap_pars_fragment:p4,morphinstance_vertex:m4,morphcolor_vertex:g4,morphnormal_vertex:v4,morphtarget_pars_vertex:y4,morphtarget_vertex:b4,normal_fragment_begin:x4,normal_fragment_maps:_4,normal_pars_fragment:S4,normal_pars_vertex:M4,normal_vertex:E4,normalmap_pars_fragment:T4,clearcoat_normal_fragment_begin:w4,clearcoat_normal_fragment_maps:A4,clearcoat_pars_fragment:C4,iridescence_pars_fragment:R4,opaque_fragment:D4,packing:O4,premultiplied_alpha_fragment:P4,project_vertex:I4,dithering_fragment:N4,dithering_pars_fragment:L4,roughnessmap_fragment:U4,roughnessmap_pars_fragment:z4,shadowmap_pars_fragment:B4,shadowmap_pars_vertex:F4,shadowmap_vertex:k4,shadowmask_pars_fragment:H4,skinbase_vertex:V4,skinning_pars_vertex:G4,skinning_vertex:W4,skinnormal_vertex:$4,specularmap_fragment:X4,specularmap_pars_fragment:j4,tonemapping_fragment:q4,tonemapping_pars_fragment:Y4,transmission_fragment:Z4,transmission_pars_fragment:K4,uv_pars_fragment:Q4,uv_pars_vertex:J4,uv_vertex:eF,worldpos_vertex:tF,background_vert:nF,background_frag:iF,backgroundCube_vert:rF,backgroundCube_frag:sF,cube_vert:aF,cube_frag:oF,depth_vert:lF,depth_frag:cF,distance_vert:uF,distance_frag:fF,equirect_vert:dF,equirect_frag:hF,linedashed_vert:pF,linedashed_frag:mF,meshbasic_vert:gF,meshbasic_frag:vF,meshlambert_vert:yF,meshlambert_frag:bF,meshmatcap_vert:xF,meshmatcap_frag:_F,meshnormal_vert:SF,meshnormal_frag:MF,meshphong_vert:EF,meshphong_frag:TF,meshphysical_vert:wF,meshphysical_frag:AF,meshtoon_vert:CF,meshtoon_frag:RF,points_vert:DF,points_frag:OF,shadow_vert:PF,shadow_frag:IF,sprite_vert:NF,sprite_frag:LF},yt={common:{diffuse:{value:new pt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new on},alphaMap:{value:null},alphaMapTransform:{value:new on},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new on}},envmap:{envMap:{value:null},envMapRotation:{value:new on},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new on}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new on}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new on},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new on},normalScale:{value:new Le(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new on},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new on}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new on}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new on}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new pt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},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 pt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new on},alphaTest:{value:0},uvTransform:{value:new on}},sprite:{diffuse:{value:new pt(16777215)},opacity:{value:1},center:{value:new Le(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new on},alphaMap:{value:null},alphaMapTransform:{value:new on},alphaTest:{value:0}}},Oo={basic:{uniforms:Cs([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.fog]),vertexShader:pn.meshbasic_vert,fragmentShader:pn.meshbasic_frag},lambert:{uniforms:Cs([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new pt(0)}}]),vertexShader:pn.meshlambert_vert,fragmentShader:pn.meshlambert_frag},phong:{uniforms:Cs([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new pt(0)},specular:{value:new pt(1118481)},shininess:{value:30}}]),vertexShader:pn.meshphong_vert,fragmentShader:pn.meshphong_frag},standard:{uniforms:Cs([yt.common,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.roughnessmap,yt.metalnessmap,yt.fog,yt.lights,{emissive:{value:new pt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:pn.meshphysical_vert,fragmentShader:pn.meshphysical_frag},toon:{uniforms:Cs([yt.common,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.gradientmap,yt.fog,yt.lights,{emissive:{value:new pt(0)}}]),vertexShader:pn.meshtoon_vert,fragmentShader:pn.meshtoon_frag},matcap:{uniforms:Cs([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,{matcap:{value:null}}]),vertexShader:pn.meshmatcap_vert,fragmentShader:pn.meshmatcap_frag},points:{uniforms:Cs([yt.points,yt.fog]),vertexShader:pn.points_vert,fragmentShader:pn.points_frag},dashed:{uniforms:Cs([yt.common,yt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:pn.linedashed_vert,fragmentShader:pn.linedashed_frag},depth:{uniforms:Cs([yt.common,yt.displacementmap]),vertexShader:pn.depth_vert,fragmentShader:pn.depth_frag},normal:{uniforms:Cs([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,{opacity:{value:1}}]),vertexShader:pn.meshnormal_vert,fragmentShader:pn.meshnormal_frag},sprite:{uniforms:Cs([yt.sprite,yt.fog]),vertexShader:pn.sprite_vert,fragmentShader:pn.sprite_frag},background:{uniforms:{uvTransform:{value:new on},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:pn.background_vert,fragmentShader:pn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new on}},vertexShader:pn.backgroundCube_vert,fragmentShader:pn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:pn.cube_vert,fragmentShader:pn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:pn.equirect_vert,fragmentShader:pn.equirect_frag},distance:{uniforms:Cs([yt.common,yt.displacementmap,{referencePosition:{value:new K},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:pn.distance_vert,fragmentShader:pn.distance_frag},shadow:{uniforms:Cs([yt.lights,yt.fog,{color:{value:new pt(0)},opacity:{value:1}}]),vertexShader:pn.shadow_vert,fragmentShader:pn.shadow_frag}};Oo.physical={uniforms:Cs([Oo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new on},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new on},clearcoatNormalScale:{value:new Le(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new on},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new on},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new on},sheen:{value:0},sheenColor:{value:new pt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new on},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new on},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new on},transmissionSamplerSize:{value:new Le},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new on},attenuationDistance:{value:0},attenuationColor:{value:new pt(0)},specularColor:{value:new pt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new on},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new on},anisotropyVector:{value:new Le},anisotropyMap:{value:null},anisotropyMapTransform:{value:new on}}]),vertexShader:pn.meshphysical_vert,fragmentShader:pn.meshphysical_frag};const mb={r:0,b:0,g:0},Jf=new Ta,UF=new Kt;function zF(n,e,t,i,r,a,l){const u=new pt(0);let h=a===!0?0:1,p,g,y=null,b=0,x=null;function M(D){let P=D.isScene===!0?D.background:null;return P&&P.isTexture&&(P=(D.backgroundBlurriness>0?t:e).get(P)),P}function A(D){let P=!1;const F=M(D);F===null?E(u,h):F&&F.isColor&&(E(F,1),P=!0);const L=n.xr.getEnvironmentBlendMode();L==="additive"?i.buffers.color.setClear(0,0,0,1,l):L==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,l),(n.autoClear||P)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function w(D,P){const F=M(P);F&&(F.isCubeTexture||F.mapping===Np)?(g===void 0&&(g=new hi(new Ad(1,1,1),new Yn({name:"BackgroundCubeMaterial",uniforms:Ap(Oo.backgroundCube.uniforms),vertexShader:Oo.backgroundCube.vertexShader,fragmentShader:Oo.backgroundCube.fragmentShader,side:_r,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),g.geometry.deleteAttribute("normal"),g.geometry.deleteAttribute("uv"),g.onBeforeRender=function(L,k,V){this.matrixWorld.copyPosition(V.matrixWorld)},Object.defineProperty(g.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(g)),Jf.copy(P.backgroundRotation),Jf.x*=-1,Jf.y*=-1,Jf.z*=-1,F.isCubeTexture&&F.isRenderTargetTexture===!1&&(Jf.y*=-1,Jf.z*=-1),g.material.uniforms.envMap.value=F,g.material.uniforms.flipEnvMap.value=F.isCubeTexture&&F.isRenderTargetTexture===!1?-1:1,g.material.uniforms.backgroundBlurriness.value=P.backgroundBlurriness,g.material.uniforms.backgroundIntensity.value=P.backgroundIntensity,g.material.uniforms.backgroundRotation.value.setFromMatrix4(UF.makeRotationFromEuler(Jf)),g.material.toneMapped=Cn.getTransfer(F.colorSpace)!==qn,(y!==F||b!==F.version||x!==n.toneMapping)&&(g.material.needsUpdate=!0,y=F,b=F.version,x=n.toneMapping),g.layers.enableAll(),D.unshift(g,g.geometry,g.material,0,0,null)):F&&F.isTexture&&(p===void 0&&(p=new hi(new Gu(2,2),new Yn({name:"BackgroundMaterial",uniforms:Ap(Oo.background.uniforms),vertexShader:Oo.background.vertexShader,fragmentShader:Oo.background.fragmentShader,side:Al,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),p.geometry.deleteAttribute("normal"),Object.defineProperty(p.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(p)),p.material.uniforms.t2D.value=F,p.material.uniforms.backgroundIntensity.value=P.backgroundIntensity,p.material.toneMapped=Cn.getTransfer(F.colorSpace)!==qn,F.matrixAutoUpdate===!0&&F.updateMatrix(),p.material.uniforms.uvTransform.value.copy(F.matrix),(y!==F||b!==F.version||x!==n.toneMapping)&&(p.material.needsUpdate=!0,y=F,b=F.version,x=n.toneMapping),p.layers.enableAll(),D.unshift(p,p.geometry,p.material,0,0,null))}function E(D,P){D.getRGB(mb,V3(n)),i.buffers.color.setClear(mb.r,mb.g,mb.b,P,l)}function R(){g!==void 0&&(g.geometry.dispose(),g.material.dispose(),g=void 0),p!==void 0&&(p.geometry.dispose(),p.material.dispose(),p=void 0)}return{getClearColor:function(){return u},setClearColor:function(D,P=1){u.set(D),h=P,E(u,h)},getClearAlpha:function(){return h},setClearAlpha:function(D){h=D,E(u,h)},render:A,addToRenderList:w,dispose:R}}function BF(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=b(null);let a=r,l=!1;function u(z,X,Q,J,oe){let re=!1;const q=y(J,Q,X);a!==q&&(a=q,p(a.object)),re=x(z,J,Q,oe),re&&M(z,J,Q,oe),oe!==null&&e.update(oe,n.ELEMENT_ARRAY_BUFFER),(re||l)&&(l=!1,P(z,X,Q,J),oe!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(oe).buffer))}function h(){return n.createVertexArray()}function p(z){return n.bindVertexArray(z)}function g(z){return n.deleteVertexArray(z)}function y(z,X,Q){const J=Q.wireframe===!0;let oe=i[z.id];oe===void 0&&(oe={},i[z.id]=oe);let re=oe[X.id];re===void 0&&(re={},oe[X.id]=re);let q=re[J];return q===void 0&&(q=b(h()),re[J]=q),q}function b(z){const X=[],Q=[],J=[];for(let oe=0;oe=0){const Ee=oe[ne];let j=re[ne];if(j===void 0&&(ne==="instanceMatrix"&&z.instanceMatrix&&(j=z.instanceMatrix),ne==="instanceColor"&&z.instanceColor&&(j=z.instanceColor)),Ee===void 0||Ee.attribute!==j||j&&Ee.data!==j.data)return!0;q++}return a.attributesNum!==q||a.index!==J}function M(z,X,Q,J){const oe={},re=X.attributes;let q=0;const Z=Q.getAttributes();for(const ne in Z)if(Z[ne].location>=0){let Ee=re[ne];Ee===void 0&&(ne==="instanceMatrix"&&z.instanceMatrix&&(Ee=z.instanceMatrix),ne==="instanceColor"&&z.instanceColor&&(Ee=z.instanceColor));const j={};j.attribute=Ee,Ee&&Ee.data&&(j.data=Ee.data),oe[ne]=j,q++}a.attributes=oe,a.attributesNum=q,a.index=J}function A(){const z=a.newAttributes;for(let X=0,Q=z.length;X=0){let pe=oe[Z];if(pe===void 0&&(Z==="instanceMatrix"&&z.instanceMatrix&&(pe=z.instanceMatrix),Z==="instanceColor"&&z.instanceColor&&(pe=z.instanceColor)),pe!==void 0){const Ee=pe.normalized,j=pe.itemSize,fe=e.get(pe);if(fe===void 0)continue;const be=fe.buffer,Fe=fe.type,rt=fe.bytesPerElement,he=Fe===n.INT||Fe===n.UNSIGNED_INT||pe.gpuType===Kx;if(pe.isInterleavedBufferAttribute){const xe=pe.data,ke=xe.stride,Ge=pe.offset;if(xe.isInstancedInterleavedBuffer){for(let ct=0;ct0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";k="mediump"}return k==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let p=t.precision!==void 0?t.precision:"highp";const g=h(p);g!==p&&(vt("WebGLRenderer:",p,"not supported, using",g,"instead."),p=g);const y=t.logarithmicDepthBuffer===!0,b=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),x=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),M=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),A=n.getParameter(n.MAX_TEXTURE_SIZE),w=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),E=n.getParameter(n.MAX_VERTEX_ATTRIBS),R=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),D=n.getParameter(n.MAX_VARYING_VECTORS),P=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),F=n.getParameter(n.MAX_SAMPLES),L=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:h,textureFormatReadable:l,textureTypeReadable:u,precision:p,logarithmicDepthBuffer:y,reversedDepthBuffer:b,maxTextures:x,maxVertexTextures:M,maxTextureSize:A,maxCubemapSize:w,maxAttributes:E,maxVertexUniforms:R,maxVaryings:D,maxFragmentUniforms:P,maxSamples:F,samples:L}}function HF(n){const e=this;let t=null,i=0,r=!1,a=!1;const l=new _c,u=new on,h={value:null,needsUpdate:!1};this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(y,b){const x=y.length!==0||b||i!==0||r;return r=b,i=y.length,x},this.beginShadows=function(){a=!0,g(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(y,b){t=g(y,b,0)},this.setState=function(y,b,x){const M=y.clippingPlanes,A=y.clipIntersection,w=y.clipShadows,E=n.get(y);if(!r||M===null||M.length===0||a&&!w)a?g(null):p();else{const R=a?0:i,D=R*4;let P=E.clippingState||null;h.value=P,P=g(M,b,D,x);for(let F=0;F!==D;++F)P[F]=t[F];E.clippingState=P,this.numIntersection=A?this.numPlanes:0,this.numPlanes+=R}};function p(){h.value!==t&&(h.value=t,h.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function g(y,b,x,M){const A=y!==null?y.length:0;let w=null;if(A!==0){if(w=h.value,M!==!0||w===null){const E=x+A*4,R=b.matrixWorldInverse;u.getNormalMatrix(R),(w===null||w.length0){const p=new SE(h.height);return p.fromEquirectangularTexture(n,l),e.set(l,p),l.addEventListener("dispose",r),t(p.texture,l.mapping)}else return null}}return l}function r(l){const u=l.target;u.removeEventListener("dispose",r);const h=e.get(u);h!==void 0&&(e.delete(u),h.dispose())}function a(){e=new WeakMap}return{get:i,dispose:a}}const Uu=4,EA=[.125,.215,.35,.446,.526,.582],sd=20,GF=256,Ag=new Lo,TA=new pt;let f1=null,d1=0,h1=0,p1=!1;const WF=new K;class bM{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,a={}){const{size:l=256,position:u=WF}=a;f1=this._renderer.getRenderTarget(),d1=this._renderer.getActiveCubeFace(),h1=this._renderer.getActiveMipmapLevel(),p1=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(l);const h=this._allocateTargets();return h.depthBuffer=!0,this._sceneToCubeUV(e,i,r,h,u),t>0&&this._blur(h,0,0,t),this._applyPMREM(h),this._cleanup(h),h}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=CA(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=AA(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?F:0,F,F),y.setRenderTarget(r),E&&y.render(A,h),y.render(e,h)}y.toneMapping=x,y.autoClear=b,e.background=R}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===Cl||e.mapping===Fu;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=CA()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=AA());const a=r?this._cubemapMaterial:this._equirectMaterial,l=this._lodMeshes[0];l.material=a;const u=a.uniforms;u.envMap.value=e;const h=this._cubeSize;rp(t,0,0,3*h,2*h),i.setRenderTarget(t),i.render(l,Ag)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let a=1;aM-Uu?i-M+Uu:0),E=4*(this._cubeSize-A);h.envMap.value=e.texture,h.roughness.value=x,h.mipInt.value=M-t,rp(a,w,E,3*A,2*A),r.setRenderTarget(a),r.render(u,Ag),h.envMap.value=a.texture,h.roughness.value=0,h.mipInt.value=M-i,rp(e,w,E,3*A,2*A),r.setRenderTarget(e),r.render(u,Ag)}_blur(e,t,i,r,a){const l=this._pingPongRenderTarget;this._halfBlur(e,l,t,i,r,"latitudinal",a),this._halfBlur(l,e,i,i,r,"longitudinal",a)}_halfBlur(e,t,i,r,a,l,u){const h=this._renderer,p=this._blurMaterial;l!=="latitudinal"&&l!=="longitudinal"&&Lt("blur direction must be either latitudinal or longitudinal!");const g=3,y=this._lodMeshes[r];y.material=p;const b=p.uniforms,x=this._sizeLods[i]-1,M=isFinite(a)?Math.PI/(2*x):2*Math.PI/(2*sd-1),A=a/M,w=isFinite(a)?1+Math.floor(g*A):sd;w>sd&&vt(`sigmaRadians, ${a}, is too large and will clip, as it requested ${w} samples when the maximum is set to ${sd}`);const E=[];let R=0;for(let k=0;kD-Uu?r-D+Uu:0),L=4*(this._cubeSize-P);rp(t,F,L,3*P,2*P),h.setRenderTarget(t),h.render(y,Ag)}}function $F(n){const e=[],t=[],i=[];let r=n;const a=n-Uu+1+EA.length;for(let l=0;ln-Uu?h=EA[l-n+Uu-1]:l===0&&(h=0),t.push(h);const p=1/(u-2),g=-p,y=1+p,b=[g,g,y,g,y,y,g,g,y,y,g,y],x=6,M=6,A=3,w=2,E=1,R=new Float32Array(A*M*x),D=new Float32Array(w*M*x),P=new Float32Array(E*M*x);for(let L=0;L2?0:-1,N=[k,V,0,k+2/3,V,0,k+2/3,V+1,0,k,V,0,k+2/3,V+1,0,k,V+1,0];R.set(N,A*M*L),D.set(b,w*M*L);const z=[L,L,L,L,L,L];P.set(z,E*M*L)}const F=new en;F.setAttribute("position",new Wn(R,A)),F.setAttribute("uv",new Wn(D,w)),F.setAttribute("faceIndex",new Wn(P,E)),i.push(new hi(F,null)),r>Uu&&r--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function wA(n,e,t){const i=new Gn(n,e,t);return i.texture.mapping=Np,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function rp(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function XF(n,e,t){return new Yn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:GF,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:C_(),fragmentShader:` precision highp float; precision highp int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform float roughness; uniform float mipInt; #define ENVMAP_TYPE_CUBE_UV #include #define PI 3.14159265359 // Van der Corput radical inverse float radicalInverse_VdC(uint bits) { bits = (bits << 16u) | (bits >> 16u); bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); return float(bits) * 2.3283064365386963e-10; // / 0x100000000 } // Hammersley sequence vec2 hammersley(uint i, uint N) { return vec2(float(i) / float(N), radicalInverse_VdC(i)); } // GGX VNDF importance sampling (Eric Heitz 2018) // "Sampling the GGX Distribution of Visible Normals" // https://jcgt.org/published/0007/04/01/ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { float alpha = roughness * roughness; // Section 3.2: Transform view direction to hemisphere configuration vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z)); // Section 4.1: Orthonormal basis float lensq = Vh.x * Vh.x + Vh.y * Vh.y; vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0); vec3 T2 = cross(Vh, T1); // Section 4.2: Parameterization of projected area float r = sqrt(Xi.x); float phi = 2.0 * PI * Xi.y; float t1 = r * cos(phi); float t2 = r * sin(phi); float s = 0.5 * (1.0 + Vh.z); t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; // Section 4.3: Reprojection onto hemisphere vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh; // Section 3.4: Transform back to ellipsoid configuration return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); } void main() { vec3 N = normalize(vOutputDirection); vec3 V = N; // Assume view direction equals normal for pre-filtering vec3 prefilteredColor = vec3(0.0); float totalWeight = 0.0; // For very low roughness, just sample the environment directly if (roughness < 0.001) { gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); return; } // Tangent space basis for VNDF sampling vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); vec3 tangent = normalize(cross(up, N)); vec3 bitangent = cross(N, tangent); for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); // For PMREM, V = N, so in tangent space V is always (0, 0, 1) vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); // Transform H back to world space vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); vec3 L = normalize(2.0 * dot(V, H) * H - V); float NdotL = max(dot(N, L), 0.0); if(NdotL > 0.0) { // Sample environment at fixed mip level // VNDF importance sampling handles the distribution filtering vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); // Weight by NdotL for the split-sum approximation // VNDF PDF naturally accounts for the visible microfacet distribution prefilteredColor += sampleColor * NdotL; totalWeight += NdotL; } } if (totalWeight > 0.0) { prefilteredColor = prefilteredColor / totalWeight; } gl_FragColor = vec4(prefilteredColor, 1.0); } `,blending:Pr,depthTest:!1,depthWrite:!1})}function jF(n,e,t){const i=new Float32Array(sd),r=new K(0,1,0);return new Yn({name:"SphericalGaussianBlur",defines:{n:sd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:C_(),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:Pr,depthTest:!1,depthWrite:!1})}function AA(){return new Yn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:C_(),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:Pr,depthTest:!1,depthWrite:!1})}function CA(){return new Yn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:C_(),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:Pr,depthTest:!1,depthWrite:!1})}function C_(){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 qF(n){let e=new WeakMap,t=null;function i(u){if(u&&u.isTexture){const h=u.mapping,p=h===t0||h===n0,g=h===Cl||h===Fu;if(p||g){let y=e.get(u);const b=y!==void 0?y.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==b)return t===null&&(t=new bM(n)),y=p?t.fromEquirectangular(u,y):t.fromCubemap(u,y),y.texture.pmremVersion=u.pmremVersion,e.set(u,y),y.texture;if(y!==void 0)return y.texture;{const x=u.image;return p&&x&&x.height>0||g&&x&&r(x)?(t===null&&(t=new bM(n)),y=p?t.fromEquirectangular(u):t.fromCubemap(u),y.texture.pmremVersion=u.pmremVersion,e.set(u,y),u.addEventListener("dispose",a),y.texture):null}}}return u}function r(u){let h=0;const p=6;for(let g=0;ge.maxTextureSize&&(L=Math.ceil(F/e.maxTextureSize),F=e.maxTextureSize);const k=new Float32Array(F*L*4*y),V=new s_(k,F,L,y);V.type=Or,V.needsUpdate=!0;const N=P*4;for(let X=0;X #include void main() { gl_FragColor = texture2D( tDiffuse, vUv ); #ifdef LINEAR_TONE_MAPPING gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); #elif defined( REINHARD_TONE_MAPPING ) gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); #elif defined( CINEON_TONE_MAPPING ) gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); #elif defined( ACES_FILMIC_TONE_MAPPING ) gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); #elif defined( AGX_TONE_MAPPING ) gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); #elif defined( NEUTRAL_TONE_MAPPING ) gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); #elif defined( CUSTOM_TONE_MAPPING ) gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); #endif #ifdef SRGB_TRANSFER gl_FragColor = sRGBTransferOETF( gl_FragColor ); #endif }`,depthTest:!1,depthWrite:!1}),p=new hi(u,h),g=new Lo(-1,1,1,-1,0,1);let y=null,b=null,x=!1,M,A=null,w=[],E=!1;this.setSize=function(R,D){a.setSize(R,D),l.setSize(R,D);for(let P=0;P0&&w[0].isRenderPass===!0;const D=a.width,P=a.height;for(let F=0;F0)return n;const r=e*t;let a=RA[r];if(a===void 0&&(a=new Float32Array(r),RA[r]=a),e!==0){i.toArray(a,0);for(let l=1,u=0;l!==e;++l)u+=t,n[l].toArray(a,u)}return a}function Sr(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=r.concat(a))}setValue(e,t,i,r){const a=this.map[t];a!==void 0&&a.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let a=0,l=t.length;a!==l;++a){const u=t[a],h=i[u.id];h.needsUpdate!==!1&&u.setValue(e,h.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,a=e.length;r!==a;++r){const l=e[r];l.id in t&&i.push(l)}return i}}function LA(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const j5=37297;let q5=0;function Y5(n,e){const t=n.split(` `),i=[],r=Math.max(e-6,0),a=Math.min(e+6,t.length);for(let l=r;l":" "} ${u}: ${t[l]}`)}return i.join(` `)}const UA=new on;function Z5(n){Cn._getMatrix(UA,Cn.workingColorSpace,n);const e=`mat3( ${UA.elements.map(t=>t.toFixed(4))} )`;switch(Cn.getTransfer(n)){case o0:return[e,"LinearTransferOETF"];case qn:return[e,"sRGBTransferOETF"];default:return vt("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function zA(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),a=(n.getShaderInfoLog(e)||"").trim();if(i&&a==="")return"";const l=/ERROR: 0:(\d+)/.exec(a);if(l){const u=parseInt(l[1]);return t.toUpperCase()+` `+a+` `+Y5(n.getShaderSource(e),u)}else return a}function K5(n,e){const t=Z5(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}const Q5={[rE]:"Linear",[sE]:"Reinhard",[aE]:"Cineon",[Yx]:"ACESFilmic",[lE]:"AgX",[cE]:"Neutral",[oE]:"Custom"};function J5(n,e){const t=Q5[e];return t===void 0?(vt("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const gb=new K;function ek(){Cn.getLuminanceCoefficients(gb);const n=gb.x.toFixed(4),e=gb.y.toFixed(4),t=gb.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function tk(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Bg).join(` `)}function nk(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function ik(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function _M(n){return n.replace(rk,ak)}const sk=new Map;function ak(n,e){let t=pn[e];if(t===void 0){const i=sk.get(e);if(i!==void 0)t=pn[i],vt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return _M(t)}const ok=/#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 kA(n){return n.replace(ok,lk)}function lk(n,e,t,i){let r="";for(let a=parseInt(e);a0&&(w+=` `),E=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,M].filter(Bg).join(` `),E.length>0&&(E+=` `)):(w=[HA(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,M,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+g:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+h:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Bg).join(` `),E=[HA(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,M,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+p:"",t.envMap?"#define "+g:"",t.envMap?"#define "+y:"",b?"#define CUBEUV_TEXEL_WIDTH "+b.texelWidth:"",b?"#define CUBEUV_TEXEL_HEIGHT "+b.texelHeight:"",b?"#define CUBEUV_MAX_MIP "+b.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+h:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==xa?"#define TONE_MAPPING":"",t.toneMapping!==xa?pn.tonemapping_pars_fragment:"",t.toneMapping!==xa?J5("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",pn.colorspace_pars_fragment,K5("linearToOutputTexel",t.outputColorSpace),ek(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Bg).join(` `)),l=_M(l),l=BA(l,t),l=FA(l,t),u=_M(u),u=BA(u,t),u=FA(u,t),l=kA(l),u=kA(u),t.isRawShaderMaterial!==!0&&(R=`#version 300 es `,w=[x,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+w,E=["#define varying in",t.glslVersion===uM?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===uM?"":"#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(` `)+` `+E);const D=R+w+l,P=R+E+u,F=LA(r,r.VERTEX_SHADER,D),L=LA(r,r.FRAGMENT_SHADER,P);r.attachShader(A,F),r.attachShader(A,L),t.index0AttributeName!==void 0?r.bindAttribLocation(A,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(A,0,"position"),r.linkProgram(A);function k(X){if(n.debug.checkShaderErrors){const Q=r.getProgramInfoLog(A)||"",J=r.getShaderInfoLog(F)||"",oe=r.getShaderInfoLog(L)||"",re=Q.trim(),q=J.trim(),Z=oe.trim();let ne=!0,pe=!0;if(r.getProgramParameter(A,r.LINK_STATUS)===!1)if(ne=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,A,F,L);else{const Ee=zA(r,F,"vertex"),j=zA(r,L,"fragment");Lt("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(A,r.VALIDATE_STATUS)+` Material Name: `+X.name+` Material Type: `+X.type+` Program Info Log: `+re+` `+Ee+` `+j)}else re!==""?vt("WebGLProgram: Program Info Log:",re):(q===""||Z==="")&&(pe=!1);pe&&(X.diagnostics={runnable:ne,programLog:re,vertexShader:{log:q,prefix:w},fragmentShader:{log:Z,prefix:E}})}r.deleteShader(F),r.deleteShader(L),V=new Ob(r,A),N=ik(r,A)}let V;this.getUniforms=function(){return V===void 0&&k(this),V};let N;this.getAttributes=function(){return N===void 0&&k(this),N};let z=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return z===!1&&(z=r.getProgramParameter(A,j5)),z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(A),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=q5++,this.cacheKey=e,this.usedTimes=1,this.program=A,this.vertexShader=F,this.fragmentShader=L,this}let bk=0;class xk{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),a=this._getShaderStage(i),l=this._getShaderCacheForMaterial(e);return l.has(r)===!1&&(l.add(r),r.usedTimes++),l.has(a)===!1&&(l.add(a),a.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new _k(e),t.set(e,i)),i}}class _k{constructor(e){this.id=bk++,this.code=e,this.usedTimes=0}}function Sk(n,e,t,i,r,a,l){const u=new wp,h=new xk,p=new Set,g=[],y=new Map,b=r.logarithmicDepthBuffer;let x=r.precision;const M={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function A(N){return p.add(N),N===0?"uv":`uv${N}`}function w(N,z,X,Q,J){const oe=Q.fog,re=J.geometry,q=N.isMeshStandardMaterial?Q.environment:null,Z=(N.isMeshStandardMaterial?t:e).get(N.envMap||q),ne=Z&&Z.mapping===Np?Z.image.height:null,pe=M[N.type];N.precision!==null&&(x=r.getMaxPrecision(N.precision),x!==N.precision&&vt("WebGLProgram.getParameters:",N.precision,"not supported, using",x,"instead."));const Ee=re.morphAttributes.position||re.morphAttributes.normal||re.morphAttributes.color,j=Ee!==void 0?Ee.length:0;let fe=0;re.morphAttributes.position!==void 0&&(fe=1),re.morphAttributes.normal!==void 0&&(fe=2),re.morphAttributes.color!==void 0&&(fe=3);let be,Fe,rt,he;if(pe){const ln=Oo[pe];be=ln.vertexShader,Fe=ln.fragmentShader}else be=N.vertexShader,Fe=N.fragmentShader,h.update(N),rt=h.getVertexShaderID(N),he=h.getFragmentShaderID(N);const xe=n.getRenderTarget(),ke=n.state.buffers.depth.getReversed(),Ge=J.isInstancedMesh===!0,ct=J.isBatchedMesh===!0,_t=!!N.map,St=!!N.matcap,mt=!!Z,Ce=!!N.aoMap,Pe=!!N.lightMap,ze=!!N.bumpMap,Xe=!!N.normalMap,Y=!!N.displacementMap,bt=!!N.emissiveMap,st=!!N.metalnessMap,Et=!!N.roughnessMap,Te=N.anisotropy>0,H=N.clearcoat>0,I=N.dispersion>0,ee=N.iridescence>0,ue=N.sheen>0,De=N.transmission>0,_e=Te&&!!N.anisotropyMap,nt=H&&!!N.clearcoatMap,Ye=H&&!!N.clearcoatNormalMap,dt=H&&!!N.clearcoatRoughnessMap,Ct=ee&&!!N.iridescenceMap,$e=ee&&!!N.iridescenceThicknessMap,Ke=ue&&!!N.sheenColorMap,ht=ue&&!!N.sheenRoughnessMap,te=!!N.specularMap,ye=!!N.specularColorMap,it=!!N.specularIntensityMap,ie=De&&!!N.transmissionMap,Qe=De&&!!N.thicknessMap,je=!!N.gradientMap,at=!!N.alphaMap,Ze=N.alphaTest>0,He=!!N.alphaHash,tt=!!N.extensions;let Nt=xa;N.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(Nt=n.toneMapping);const sn={shaderID:pe,shaderType:N.type,shaderName:N.name,vertexShader:be,fragmentShader:Fe,defines:N.defines,customVertexShaderID:rt,customFragmentShaderID:he,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:x,batching:ct,batchingColor:ct&&J._colorsTexture!==null,instancing:Ge,instancingColor:Ge&&J.instanceColor!==null,instancingMorph:Ge&&J.morphTexture!==null,outputColorSpace:xe===null?n.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:Dl,alphaToCoverage:!!N.alphaToCoverage,map:_t,matcap:St,envMap:mt,envMapMode:mt&&Z.mapping,envMapCubeUVHeight:ne,aoMap:Ce,lightMap:Pe,bumpMap:ze,normalMap:Xe,displacementMap:Y,emissiveMap:bt,normalMapObjectSpace:Xe&&N.normalMapType===D3,normalMapTangentSpace:Xe&&N.normalMapType===Ku,metalnessMap:st,roughnessMap:Et,anisotropy:Te,anisotropyMap:_e,clearcoat:H,clearcoatMap:nt,clearcoatNormalMap:Ye,clearcoatRoughnessMap:dt,dispersion:I,iridescence:ee,iridescenceMap:Ct,iridescenceThicknessMap:$e,sheen:ue,sheenColorMap:Ke,sheenRoughnessMap:ht,specularMap:te,specularColorMap:ye,specularIntensityMap:it,transmission:De,transmissionMap:ie,thicknessMap:Qe,gradientMap:je,opaque:N.transparent===!1&&N.blending===fd&&N.alphaToCoverage===!1,alphaMap:at,alphaTest:Ze,alphaHash:He,combine:N.combine,mapUv:_t&&A(N.map.channel),aoMapUv:Ce&&A(N.aoMap.channel),lightMapUv:Pe&&A(N.lightMap.channel),bumpMapUv:ze&&A(N.bumpMap.channel),normalMapUv:Xe&&A(N.normalMap.channel),displacementMapUv:Y&&A(N.displacementMap.channel),emissiveMapUv:bt&&A(N.emissiveMap.channel),metalnessMapUv:st&&A(N.metalnessMap.channel),roughnessMapUv:Et&&A(N.roughnessMap.channel),anisotropyMapUv:_e&&A(N.anisotropyMap.channel),clearcoatMapUv:nt&&A(N.clearcoatMap.channel),clearcoatNormalMapUv:Ye&&A(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:dt&&A(N.clearcoatRoughnessMap.channel),iridescenceMapUv:Ct&&A(N.iridescenceMap.channel),iridescenceThicknessMapUv:$e&&A(N.iridescenceThicknessMap.channel),sheenColorMapUv:Ke&&A(N.sheenColorMap.channel),sheenRoughnessMapUv:ht&&A(N.sheenRoughnessMap.channel),specularMapUv:te&&A(N.specularMap.channel),specularColorMapUv:ye&&A(N.specularColorMap.channel),specularIntensityMapUv:it&&A(N.specularIntensityMap.channel),transmissionMapUv:ie&&A(N.transmissionMap.channel),thicknessMapUv:Qe&&A(N.thicknessMap.channel),alphaMapUv:at&&A(N.alphaMap.channel),vertexTangents:!!re.attributes.tangent&&(Xe||Te),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!re.attributes.color&&re.attributes.color.itemSize===4,pointsUvs:J.isPoints===!0&&!!re.attributes.uv&&(_t||at),fog:!!oe,useFog:N.fog===!0,fogExp2:!!oe&&oe.isFogExp2,flatShading:N.flatShading===!0&&N.wireframe===!1,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:b,reversedDepthBuffer:ke,skinning:J.isSkinnedMesh===!0,morphTargets:re.morphAttributes.position!==void 0,morphNormals:re.morphAttributes.normal!==void 0,morphColors:re.morphAttributes.color!==void 0,morphTargetsCount:j,morphTextureStride:fe,numDirLights:z.directional.length,numPointLights:z.point.length,numSpotLights:z.spot.length,numSpotLightMaps:z.spotLightMap.length,numRectAreaLights:z.rectArea.length,numHemiLights:z.hemi.length,numDirLightShadows:z.directionalShadowMap.length,numPointLightShadows:z.pointShadowMap.length,numSpotLightShadows:z.spotShadowMap.length,numSpotLightShadowsWithMaps:z.numSpotLightShadowsWithMaps,numLightProbes:z.numLightProbes,numClippingPlanes:l.numPlanes,numClipIntersection:l.numIntersection,dithering:N.dithering,shadowMapEnabled:n.shadowMap.enabled&&X.length>0,shadowMapType:n.shadowMap.type,toneMapping:Nt,decodeVideoTexture:_t&&N.map.isVideoTexture===!0&&Cn.getTransfer(N.map.colorSpace)===qn,decodeVideoTextureEmissive:bt&&N.emissiveMap.isVideoTexture===!0&&Cn.getTransfer(N.emissiveMap.colorSpace)===qn,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===xr,flipSided:N.side===_r,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionClipCullDistance:tt&&N.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(tt&&N.extensions.multiDraw===!0||ct)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()};return sn.vertexUv1s=p.has(1),sn.vertexUv2s=p.has(2),sn.vertexUv3s=p.has(3),p.clear(),sn}function E(N){const z=[];if(N.shaderID?z.push(N.shaderID):(z.push(N.customVertexShaderID),z.push(N.customFragmentShaderID)),N.defines!==void 0)for(const X in N.defines)z.push(X),z.push(N.defines[X]);return N.isRawShaderMaterial===!1&&(R(z,N),D(z,N),z.push(n.outputColorSpace)),z.push(N.customProgramCacheKey),z.join()}function R(N,z){N.push(z.precision),N.push(z.outputColorSpace),N.push(z.envMapMode),N.push(z.envMapCubeUVHeight),N.push(z.mapUv),N.push(z.alphaMapUv),N.push(z.lightMapUv),N.push(z.aoMapUv),N.push(z.bumpMapUv),N.push(z.normalMapUv),N.push(z.displacementMapUv),N.push(z.emissiveMapUv),N.push(z.metalnessMapUv),N.push(z.roughnessMapUv),N.push(z.anisotropyMapUv),N.push(z.clearcoatMapUv),N.push(z.clearcoatNormalMapUv),N.push(z.clearcoatRoughnessMapUv),N.push(z.iridescenceMapUv),N.push(z.iridescenceThicknessMapUv),N.push(z.sheenColorMapUv),N.push(z.sheenRoughnessMapUv),N.push(z.specularMapUv),N.push(z.specularColorMapUv),N.push(z.specularIntensityMapUv),N.push(z.transmissionMapUv),N.push(z.thicknessMapUv),N.push(z.combine),N.push(z.fogExp2),N.push(z.sizeAttenuation),N.push(z.morphTargetsCount),N.push(z.morphAttributeCount),N.push(z.numDirLights),N.push(z.numPointLights),N.push(z.numSpotLights),N.push(z.numSpotLightMaps),N.push(z.numHemiLights),N.push(z.numRectAreaLights),N.push(z.numDirLightShadows),N.push(z.numPointLightShadows),N.push(z.numSpotLightShadows),N.push(z.numSpotLightShadowsWithMaps),N.push(z.numLightProbes),N.push(z.shadowMapType),N.push(z.toneMapping),N.push(z.numClippingPlanes),N.push(z.numClipIntersection),N.push(z.depthPacking)}function D(N,z){u.disableAll(),z.instancing&&u.enable(0),z.instancingColor&&u.enable(1),z.instancingMorph&&u.enable(2),z.matcap&&u.enable(3),z.envMap&&u.enable(4),z.normalMapObjectSpace&&u.enable(5),z.normalMapTangentSpace&&u.enable(6),z.clearcoat&&u.enable(7),z.iridescence&&u.enable(8),z.alphaTest&&u.enable(9),z.vertexColors&&u.enable(10),z.vertexAlphas&&u.enable(11),z.vertexUv1s&&u.enable(12),z.vertexUv2s&&u.enable(13),z.vertexUv3s&&u.enable(14),z.vertexTangents&&u.enable(15),z.anisotropy&&u.enable(16),z.alphaHash&&u.enable(17),z.batching&&u.enable(18),z.dispersion&&u.enable(19),z.batchingColor&&u.enable(20),z.gradientMap&&u.enable(21),N.push(u.mask),u.disableAll(),z.fog&&u.enable(0),z.useFog&&u.enable(1),z.flatShading&&u.enable(2),z.logarithmicDepthBuffer&&u.enable(3),z.reversedDepthBuffer&&u.enable(4),z.skinning&&u.enable(5),z.morphTargets&&u.enable(6),z.morphNormals&&u.enable(7),z.morphColors&&u.enable(8),z.premultipliedAlpha&&u.enable(9),z.shadowMapEnabled&&u.enable(10),z.doubleSided&&u.enable(11),z.flipSided&&u.enable(12),z.useDepthPacking&&u.enable(13),z.dithering&&u.enable(14),z.transmission&&u.enable(15),z.sheen&&u.enable(16),z.opaque&&u.enable(17),z.pointsUvs&&u.enable(18),z.decodeVideoTexture&&u.enable(19),z.decodeVideoTextureEmissive&&u.enable(20),z.alphaToCoverage&&u.enable(21),N.push(u.mask)}function P(N){const z=M[N.type];let X;if(z){const Q=Oo[z];X=G3.clone(Q.uniforms)}else X=N.uniforms;return X}function F(N,z){let X=y.get(z);return X!==void 0?++X.usedTimes:(X=new yk(n,z,N,a),g.push(X),y.set(z,X)),X}function L(N){if(--N.usedTimes===0){const z=g.indexOf(N);g[z]=g[g.length-1],g.pop(),y.delete(N.cacheKey),N.destroy()}}function k(N){h.remove(N)}function V(){h.dispose()}return{getParameters:w,getProgramCacheKey:E,getUniforms:P,acquireProgram:F,releaseProgram:L,releaseShaderCache:k,programs:g,dispose:V}}function Mk(){let n=new WeakMap;function e(l){return n.has(l)}function t(l){let u=n.get(l);return u===void 0&&(u={},n.set(l,u)),u}function i(l){n.delete(l)}function r(l,u,h){n.get(l)[u]=h}function a(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:a}}function Ek(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function VA(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function GA(){const n=[];let e=0;const t=[],i=[],r=[];function a(){e=0,t.length=0,i.length=0,r.length=0}function l(y,b,x,M,A,w){let E=n[e];return E===void 0?(E={id:y.id,object:y,geometry:b,material:x,groupOrder:M,renderOrder:y.renderOrder,z:A,group:w},n[e]=E):(E.id=y.id,E.object=y,E.geometry=b,E.material=x,E.groupOrder=M,E.renderOrder=y.renderOrder,E.z=A,E.group=w),e++,E}function u(y,b,x,M,A,w){const E=l(y,b,x,M,A,w);x.transmission>0?i.push(E):x.transparent===!0?r.push(E):t.push(E)}function h(y,b,x,M,A,w){const E=l(y,b,x,M,A,w);x.transmission>0?i.unshift(E):x.transparent===!0?r.unshift(E):t.unshift(E)}function p(y,b){t.length>1&&t.sort(y||Ek),i.length>1&&i.sort(b||VA),r.length>1&&r.sort(b||VA)}function g(){for(let y=e,b=n.length;y=a.length?(l=new GA,a.push(l)):l=a[r],l}function t(){n=new WeakMap}return{get:e,dispose:t}}function wk(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new K,color:new pt};break;case"SpotLight":t={position:new K,direction:new K,color:new pt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new K,color:new pt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new K,skyColor:new pt,groundColor:new pt};break;case"RectAreaLight":t={color:new pt,position:new K,halfWidth:new K,halfHeight:new K};break}return n[e.id]=t,t}}}function Ak(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Le};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Le};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Le,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Ck=0;function Rk(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Dk(n){const e=new wk,t=Ak(),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 p=0;p<9;p++)i.probe.push(new K);const r=new K,a=new Kt,l=new Kt;function u(p){let g=0,y=0,b=0;for(let N=0;N<9;N++)i.probe[N].set(0,0,0);let x=0,M=0,A=0,w=0,E=0,R=0,D=0,P=0,F=0,L=0,k=0;p.sort(Rk);for(let N=0,z=p.length;N0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=yt.LTC_FLOAT_1,i.rectAreaLTC2=yt.LTC_FLOAT_2):(i.rectAreaLTC1=yt.LTC_HALF_1,i.rectAreaLTC2=yt.LTC_HALF_2)),i.ambient[0]=g,i.ambient[1]=y,i.ambient[2]=b;const V=i.hash;(V.directionalLength!==x||V.pointLength!==M||V.spotLength!==A||V.rectAreaLength!==w||V.hemiLength!==E||V.numDirectionalShadows!==R||V.numPointShadows!==D||V.numSpotShadows!==P||V.numSpotMaps!==F||V.numLightProbes!==k)&&(i.directional.length=x,i.spot.length=A,i.rectArea.length=w,i.point.length=M,i.hemi.length=E,i.directionalShadow.length=R,i.directionalShadowMap.length=R,i.pointShadow.length=D,i.pointShadowMap.length=D,i.spotShadow.length=P,i.spotShadowMap.length=P,i.directionalShadowMatrix.length=R,i.pointShadowMatrix.length=D,i.spotLightMatrix.length=P+F-L,i.spotLightMap.length=F,i.numSpotLightShadowsWithMaps=L,i.numLightProbes=k,V.directionalLength=x,V.pointLength=M,V.spotLength=A,V.rectAreaLength=w,V.hemiLength=E,V.numDirectionalShadows=R,V.numPointShadows=D,V.numSpotShadows=P,V.numSpotMaps=F,V.numLightProbes=k,i.version=Ck++)}function h(p,g){let y=0,b=0,x=0,M=0,A=0;const w=g.matrixWorldInverse;for(let E=0,R=p.length;E=l.length?(u=new WA(n),l.push(u)):u=l[a],u}function i(){e=new WeakMap}return{get:t,dispose:i}}const Pk=`void main() { gl_Position = vec4( position, 1.0 ); }`,Ik=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); }`,Nk=[new K(1,0,0),new K(-1,0,0),new K(0,1,0),new K(0,-1,0),new K(0,0,1),new K(0,0,-1)],Lk=[new K(0,-1,0),new K(0,-1,0),new K(0,0,1),new K(0,0,-1),new K(0,-1,0),new K(0,-1,0)],$A=new Kt,Cg=new K,g1=new K;function Uk(n,e,t){let i=new Lp;const r=new Le,a=new Le,l=new Zn,u=new UE,h=new zE,p={},g=t.maxTextureSize,y={[Al]:_r,[_r]:Al,[xr]:xr},b=new Yn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Le},radius:{value:4}},vertexShader:Pk,fragmentShader:Ik}),x=b.clone();x.defines.HORIZONTAL_PASS=1;const M=new en;M.setAttribute("position",new Wn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const A=new hi(M,b),w=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=vp;let E=this.type;this.render=function(L,k,V){if(w.enabled===!1||w.autoUpdate===!1&&w.needsUpdate===!1||L.length===0)return;L.type===kg&&(vt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),L.type=vp);const N=n.getRenderTarget(),z=n.getActiveCubeFace(),X=n.getActiveMipmapLevel(),Q=n.state;Q.setBlending(Pr),Q.buffers.depth.getReversed()===!0?Q.buffers.color.setClear(0,0,0,0):Q.buffers.color.setClear(1,1,1,1),Q.buffers.depth.setTest(!0),Q.setScissorTest(!1);const J=E!==this.type;J&&k.traverse(function(oe){oe.material&&(Array.isArray(oe.material)?oe.material.forEach(re=>re.needsUpdate=!0):oe.material.needsUpdate=!0)});for(let oe=0,re=L.length;oeg||r.y>g)&&(r.x>g&&(a.x=Math.floor(g/ne.x),r.x=a.x*ne.x,Z.mapSize.x=a.x),r.y>g&&(a.y=Math.floor(g/ne.y),r.y=a.y*ne.y,Z.mapSize.y=a.y)),Z.map===null||J===!0){if(Z.map!==null&&(Z.map.depthTexture!==null&&(Z.map.depthTexture.dispose(),Z.map.depthTexture=null),Z.map.dispose()),this.type===ad){if(q.isPointLight){vt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}Z.map=new Gn(r.x,r.y,{format:bd,type:no,minFilter:Nn,magFilter:Nn,generateMipmaps:!1}),Z.map.texture.name=q.name+".shadowMap",Z.map.depthTexture=new Vu(r.x,r.y,Or),Z.map.depthTexture.name=q.name+".shadowMapDepth",Z.map.depthTexture.format=Rl,Z.map.depthTexture.compareFunction=null,Z.map.depthTexture.minFilter=Kn,Z.map.depthTexture.magFilter=Kn}else{q.isPointLight?(Z.map=new SE(r.x),Z.map.depthTexture=new eD(r.x,Ea)):(Z.map=new Gn(r.x,r.y),Z.map.depthTexture=new Vu(r.x,r.y,Ea)),Z.map.depthTexture.name=q.name+".shadowMap",Z.map.depthTexture.format=Rl;const Ee=n.state.buffers.depth.getReversed();this.type===vp?(Z.map.depthTexture.compareFunction=Ee?r_:i_,Z.map.depthTexture.minFilter=Nn,Z.map.depthTexture.magFilter=Nn):(Z.map.depthTexture.compareFunction=null,Z.map.depthTexture.minFilter=Kn,Z.map.depthTexture.magFilter=Kn)}Z.camera.updateProjectionMatrix()}const pe=Z.map.isWebGLCubeRenderTarget?6:1;for(let Ee=0;Ee0||k.map&&k.alphaTest>0||k.alphaToCoverage===!0){const Q=z.uuid,J=k.uuid;let oe=p[Q];oe===void 0&&(oe={},p[Q]=oe);let re=oe[J];re===void 0&&(re=z.clone(),oe[J]=re,k.addEventListener("dispose",F)),z=re}if(z.visible=k.visible,z.wireframe=k.wireframe,N===ad?z.side=k.shadowSide!==null?k.shadowSide:k.side:z.side=k.shadowSide!==null?k.shadowSide:y[k.side],z.alphaMap=k.alphaMap,z.alphaTest=k.alphaToCoverage===!0?.5:k.alphaTest,z.map=k.map,z.clipShadows=k.clipShadows,z.clippingPlanes=k.clippingPlanes,z.clipIntersection=k.clipIntersection,z.displacementMap=k.displacementMap,z.displacementScale=k.displacementScale,z.displacementBias=k.displacementBias,z.wireframeLinewidth=k.wireframeLinewidth,z.linewidth=k.linewidth,V.isPointLight===!0&&z.isMeshDistanceMaterial===!0){const Q=n.properties.get(z);Q.light=V}return z}function P(L,k,V,N,z){if(L.visible===!1)return;if(L.layers.test(k.layers)&&(L.isMesh||L.isLine||L.isPoints)&&(L.castShadow||L.receiveShadow&&z===ad)&&(!L.frustumCulled||i.intersectsObject(L))){L.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,L.matrixWorld);const J=e.update(L),oe=L.material;if(Array.isArray(oe)){const re=J.groups;for(let q=0,Z=re.length;q=1):ne.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(ne)[1]),q=Z>=2);let pe=null,Ee={};const j=n.getParameter(n.SCISSOR_BOX),fe=n.getParameter(n.VIEWPORT),be=new Zn().fromArray(j),Fe=new Zn().fromArray(fe);function rt(ie,Qe,je,at){const Ze=new Uint8Array(4),He=n.createTexture();n.bindTexture(ie,He),n.texParameteri(ie,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(ie,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let tt=0;tt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new Le,g=new WeakMap;let y;const b=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(H,I){return x?new OffscreenCanvas(H,I):c0("canvas")}function A(H,I,ee){let ue=1;const De=Te(H);if((De.width>ee||De.height>ee)&&(ue=ee/Math.max(De.width,De.height)),ue<1)if(typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&H instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&H instanceof ImageBitmap||typeof VideoFrame<"u"&&H instanceof VideoFrame){const _e=Math.floor(ue*De.width),nt=Math.floor(ue*De.height);y===void 0&&(y=M(_e,nt));const Ye=I?M(_e,nt):y;return Ye.width=_e,Ye.height=nt,Ye.getContext("2d").drawImage(H,0,0,_e,nt),vt("WebGLRenderer: Texture has been resized from ("+De.width+"x"+De.height+") to ("+_e+"x"+nt+")."),Ye}else return"data"in H&&vt("WebGLRenderer: Image in DataTexture is too big ("+De.width+"x"+De.height+")."),H;return H}function w(H){return H.generateMipmaps}function E(H){n.generateMipmap(H)}function R(H){return H.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:H.isWebGL3DRenderTarget?n.TEXTURE_3D:H.isWebGLArrayRenderTarget||H.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function D(H,I,ee,ue,De=!1){if(H!==null){if(n[H]!==void 0)return n[H];vt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+H+"'")}let _e=I;if(I===n.RED&&(ee===n.FLOAT&&(_e=n.R32F),ee===n.HALF_FLOAT&&(_e=n.R16F),ee===n.UNSIGNED_BYTE&&(_e=n.R8)),I===n.RED_INTEGER&&(ee===n.UNSIGNED_BYTE&&(_e=n.R8UI),ee===n.UNSIGNED_SHORT&&(_e=n.R16UI),ee===n.UNSIGNED_INT&&(_e=n.R32UI),ee===n.BYTE&&(_e=n.R8I),ee===n.SHORT&&(_e=n.R16I),ee===n.INT&&(_e=n.R32I)),I===n.RG&&(ee===n.FLOAT&&(_e=n.RG32F),ee===n.HALF_FLOAT&&(_e=n.RG16F),ee===n.UNSIGNED_BYTE&&(_e=n.RG8)),I===n.RG_INTEGER&&(ee===n.UNSIGNED_BYTE&&(_e=n.RG8UI),ee===n.UNSIGNED_SHORT&&(_e=n.RG16UI),ee===n.UNSIGNED_INT&&(_e=n.RG32UI),ee===n.BYTE&&(_e=n.RG8I),ee===n.SHORT&&(_e=n.RG16I),ee===n.INT&&(_e=n.RG32I)),I===n.RGB_INTEGER&&(ee===n.UNSIGNED_BYTE&&(_e=n.RGB8UI),ee===n.UNSIGNED_SHORT&&(_e=n.RGB16UI),ee===n.UNSIGNED_INT&&(_e=n.RGB32UI),ee===n.BYTE&&(_e=n.RGB8I),ee===n.SHORT&&(_e=n.RGB16I),ee===n.INT&&(_e=n.RGB32I)),I===n.RGBA_INTEGER&&(ee===n.UNSIGNED_BYTE&&(_e=n.RGBA8UI),ee===n.UNSIGNED_SHORT&&(_e=n.RGBA16UI),ee===n.UNSIGNED_INT&&(_e=n.RGBA32UI),ee===n.BYTE&&(_e=n.RGBA8I),ee===n.SHORT&&(_e=n.RGBA16I),ee===n.INT&&(_e=n.RGBA32I)),I===n.RGB&&(ee===n.UNSIGNED_INT_5_9_9_9_REV&&(_e=n.RGB9_E5),ee===n.UNSIGNED_INT_10F_11F_11F_REV&&(_e=n.R11F_G11F_B10F)),I===n.RGBA){const nt=De?o0:Cn.getTransfer(ue);ee===n.FLOAT&&(_e=n.RGBA32F),ee===n.HALF_FLOAT&&(_e=n.RGBA16F),ee===n.UNSIGNED_BYTE&&(_e=nt===qn?n.SRGB8_ALPHA8:n.RGBA8),ee===n.UNSIGNED_SHORT_4_4_4_4&&(_e=n.RGBA4),ee===n.UNSIGNED_SHORT_5_5_5_1&&(_e=n.RGB5_A1)}return(_e===n.R16F||_e===n.R32F||_e===n.RG16F||_e===n.RG32F||_e===n.RGBA16F||_e===n.RGBA32F)&&e.get("EXT_color_buffer_float"),_e}function P(H,I){let ee;return H?I===null||I===Ea||I===yd?ee=n.DEPTH24_STENCIL8:I===Or?ee=n.DEPTH32F_STENCIL8:I===Sp&&(ee=n.DEPTH24_STENCIL8,vt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):I===null||I===Ea||I===yd?ee=n.DEPTH_COMPONENT24:I===Or?ee=n.DEPTH_COMPONENT32F:I===Sp&&(ee=n.DEPTH_COMPONENT16),ee}function F(H,I){return w(H)===!0||H.isFramebufferTexture&&H.minFilter!==Kn&&H.minFilter!==Nn?Math.log2(Math.max(I.width,I.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?I.mipmaps.length:1}function L(H){const I=H.target;I.removeEventListener("dispose",L),V(I),I.isVideoTexture&&g.delete(I)}function k(H){const I=H.target;I.removeEventListener("dispose",k),z(I)}function V(H){const I=i.get(H);if(I.__webglInit===void 0)return;const ee=H.source,ue=b.get(ee);if(ue){const De=ue[I.__cacheKey];De.usedTimes--,De.usedTimes===0&&N(H),Object.keys(ue).length===0&&b.delete(ee)}i.remove(H)}function N(H){const I=i.get(H);n.deleteTexture(I.__webglTexture);const ee=H.source,ue=b.get(ee);delete ue[I.__cacheKey],l.memory.textures--}function z(H){const I=i.get(H);if(H.depthTexture&&(H.depthTexture.dispose(),i.remove(H.depthTexture)),H.isWebGLCubeRenderTarget)for(let ue=0;ue<6;ue++){if(Array.isArray(I.__webglFramebuffer[ue]))for(let De=0;De=r.maxTextures&&vt("WebGLTextures: Trying to use "+H+" texture units while this GPU supports only "+r.maxTextures),X+=1,H}function oe(H){const I=[];return I.push(H.wrapS),I.push(H.wrapT),I.push(H.wrapR||0),I.push(H.magFilter),I.push(H.minFilter),I.push(H.anisotropy),I.push(H.internalFormat),I.push(H.format),I.push(H.type),I.push(H.generateMipmaps),I.push(H.premultiplyAlpha),I.push(H.flipY),I.push(H.unpackAlignment),I.push(H.colorSpace),I.join()}function re(H,I){const ee=i.get(H);if(H.isVideoTexture&&st(H),H.isRenderTargetTexture===!1&&H.isExternalTexture!==!0&&H.version>0&&ee.__version!==H.version){const ue=H.image;if(ue===null)vt("WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)vt("WebGLRenderer: Texture marked for update but image is incomplete");else{he(ee,H,I);return}}else H.isExternalTexture&&(ee.__webglTexture=H.sourceTexture?H.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ee.__webglTexture,n.TEXTURE0+I)}function q(H,I){const ee=i.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&ee.__version!==H.version){he(ee,H,I);return}else H.isExternalTexture&&(ee.__webglTexture=H.sourceTexture?H.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ee.__webglTexture,n.TEXTURE0+I)}function Z(H,I){const ee=i.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&ee.__version!==H.version){he(ee,H,I);return}t.bindTexture(n.TEXTURE_3D,ee.__webglTexture,n.TEXTURE0+I)}function ne(H,I){const ee=i.get(H);if(H.isCubeDepthTexture!==!0&&H.version>0&&ee.__version!==H.version){xe(ee,H,I);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ee.__webglTexture,n.TEXTURE0+I)}const pe={[i0]:n.REPEAT,[aa]:n.CLAMP_TO_EDGE,[r0]:n.MIRRORED_REPEAT},Ee={[Kn]:n.NEAREST,[uE]:n.NEAREST_MIPMAP_NEAREST,[hp]:n.NEAREST_MIPMAP_LINEAR,[Nn]:n.LINEAR,[Hg]:n.LINEAR_MIPMAP_NEAREST,[Io]:n.LINEAR_MIPMAP_LINEAR},j={[O3]:n.NEVER,[U3]:n.ALWAYS,[P3]:n.LESS,[i_]:n.LEQUAL,[I3]:n.EQUAL,[r_]:n.GEQUAL,[N3]:n.GREATER,[L3]:n.NOTEQUAL};function fe(H,I){if(I.type===Or&&e.has("OES_texture_float_linear")===!1&&(I.magFilter===Nn||I.magFilter===Hg||I.magFilter===hp||I.magFilter===Io||I.minFilter===Nn||I.minFilter===Hg||I.minFilter===hp||I.minFilter===Io)&&vt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(H,n.TEXTURE_WRAP_S,pe[I.wrapS]),n.texParameteri(H,n.TEXTURE_WRAP_T,pe[I.wrapT]),(H===n.TEXTURE_3D||H===n.TEXTURE_2D_ARRAY)&&n.texParameteri(H,n.TEXTURE_WRAP_R,pe[I.wrapR]),n.texParameteri(H,n.TEXTURE_MAG_FILTER,Ee[I.magFilter]),n.texParameteri(H,n.TEXTURE_MIN_FILTER,Ee[I.minFilter]),I.compareFunction&&(n.texParameteri(H,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(H,n.TEXTURE_COMPARE_FUNC,j[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(I.magFilter===Kn||I.minFilter!==hp&&I.minFilter!==Io||I.type===Or&&e.has("OES_texture_float_linear")===!1)return;if(I.anisotropy>1||i.get(I).__currentAnisotropy){const ee=e.get("EXT_texture_filter_anisotropic");n.texParameterf(H,ee.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,r.getMaxAnisotropy())),i.get(I).__currentAnisotropy=I.anisotropy}}}function be(H,I){let ee=!1;H.__webglInit===void 0&&(H.__webglInit=!0,I.addEventListener("dispose",L));const ue=I.source;let De=b.get(ue);De===void 0&&(De={},b.set(ue,De));const _e=oe(I);if(_e!==H.__cacheKey){De[_e]===void 0&&(De[_e]={texture:n.createTexture(),usedTimes:0},l.memory.textures++,ee=!0),De[_e].usedTimes++;const nt=De[H.__cacheKey];nt!==void 0&&(De[H.__cacheKey].usedTimes--,nt.usedTimes===0&&N(I)),H.__cacheKey=_e,H.__webglTexture=De[_e].texture}return ee}function Fe(H,I,ee){return Math.floor(Math.floor(H/ee)/I)}function rt(H,I,ee,ue){const _e=H.updateRanges;if(_e.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,I.width,I.height,ee,ue,I.data);else{_e.sort(($e,Ke)=>$e.start-Ke.start);let nt=0;for(let $e=1;$e<_e.length;$e++){const Ke=_e[nt],ht=_e[$e],te=Ke.start+Ke.count,ye=Fe(ht.start,I.width,4),it=Fe(Ke.start,I.width,4);ht.start<=te+1&&ye===it&&Fe(ht.start+ht.count-1,I.width,4)===ye?Ke.count=Math.max(Ke.count,ht.start+ht.count-Ke.start):(++nt,_e[nt]=ht)}_e.length=nt+1;const Ye=n.getParameter(n.UNPACK_ROW_LENGTH),dt=n.getParameter(n.UNPACK_SKIP_PIXELS),Ct=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,I.width);for(let $e=0,Ke=_e.length;$e0){ie&&Qe&&t.texStorage2D(n.TEXTURE_2D,at,te,it[0].width,it[0].height);for(let Ze=0,He=it.length;Ze0){const tt=yM(ye.width,ye.height,I.format,I.type);for(const Nt of I.layerUpdates){const sn=ye.data.subarray(Nt*tt/ye.data.BYTES_PER_ELEMENT,(Nt+1)*tt/ye.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ze,0,0,Nt,ye.width,ye.height,1,Ke,sn)}I.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ze,0,0,0,ye.width,ye.height,$e.depth,Ke,ye.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Ze,te,ye.width,ye.height,$e.depth,0,ye.data,0,0);else vt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ie?je&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Ze,0,0,0,ye.width,ye.height,$e.depth,Ke,ht,ye.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Ze,te,ye.width,ye.height,$e.depth,0,Ke,ht,ye.data)}else{ie&&Qe&&t.texStorage2D(n.TEXTURE_2D,at,te,it[0].width,it[0].height);for(let Ze=0,He=it.length;Ze0){const Ze=yM($e.width,$e.height,I.format,I.type);for(const He of I.layerUpdates){const tt=$e.data.subarray(He*Ze/$e.data.BYTES_PER_ELEMENT,(He+1)*Ze/$e.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,He,$e.width,$e.height,1,Ke,ht,tt)}I.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,$e.width,$e.height,$e.depth,Ke,ht,$e.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,te,$e.width,$e.height,$e.depth,0,Ke,ht,$e.data);else if(I.isData3DTexture)ie?(Qe&&t.texStorage3D(n.TEXTURE_3D,at,te,$e.width,$e.height,$e.depth),je&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,$e.width,$e.height,$e.depth,Ke,ht,$e.data)):t.texImage3D(n.TEXTURE_3D,0,te,$e.width,$e.height,$e.depth,0,Ke,ht,$e.data);else if(I.isFramebufferTexture){if(Qe)if(ie)t.texStorage2D(n.TEXTURE_2D,at,te,$e.width,$e.height);else{let Ze=$e.width,He=$e.height;for(let tt=0;tt>=1,He>>=1}}else if(it.length>0){if(ie&&Qe){const Ze=Te(it[0]);t.texStorage2D(n.TEXTURE_2D,at,te,Ze.width,Ze.height)}for(let Ze=0,He=it.length;Ze0&&at++;const He=Te(Ke[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,at,it,He.width,He.height)}for(let He=0;He<6;He++)if($e){ie?je&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,0,0,Ke[He].width,Ke[He].height,te,ye,Ke[He].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+He,0,it,Ke[He].width,Ke[He].height,0,te,ye,Ke[He].data);for(let tt=0;tt>_e),ht=Math.max(1,I.height>>_e);De===n.TEXTURE_3D||De===n.TEXTURE_2D_ARRAY?t.texImage3D(De,_e,dt,Ke,ht,I.depth,0,nt,Ye,null):t.texImage2D(De,_e,dt,Ke,ht,0,nt,Ye,null)}t.bindFramebuffer(n.FRAMEBUFFER,H),bt(I)?u.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ue,De,$e.__webglTexture,0,Y(I)):(De===n.TEXTURE_2D||De>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&De<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ue,De,$e.__webglTexture,_e),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ge(H,I,ee){if(n.bindRenderbuffer(n.RENDERBUFFER,H),I.depthBuffer){const ue=I.depthTexture,De=ue&&ue.isDepthTexture?ue.type:null,_e=P(I.stencilBuffer,De),nt=I.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;bt(I)?u.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Y(I),_e,I.width,I.height):ee?n.renderbufferStorageMultisample(n.RENDERBUFFER,Y(I),_e,I.width,I.height):n.renderbufferStorage(n.RENDERBUFFER,_e,I.width,I.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,nt,n.RENDERBUFFER,H)}else{const ue=I.textures;for(let De=0;De{delete I.__boundDepthTexture,delete I.__depthDisposeCallback,ue.removeEventListener("dispose",De)};ue.addEventListener("dispose",De),I.__depthDisposeCallback=De}I.__boundDepthTexture=ue}if(H.depthTexture&&!I.__autoAllocateDepthBuffer)if(ee)for(let ue=0;ue<6;ue++)ct(I.__webglFramebuffer[ue],H,ue);else{const ue=H.texture.mipmaps;ue&&ue.length>0?ct(I.__webglFramebuffer[0],H,0):ct(I.__webglFramebuffer,H,0)}else if(ee){I.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)if(t.bindFramebuffer(n.FRAMEBUFFER,I.__webglFramebuffer[ue]),I.__webglDepthbuffer[ue]===void 0)I.__webglDepthbuffer[ue]=n.createRenderbuffer(),Ge(I.__webglDepthbuffer[ue],H,!1);else{const De=H.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,_e=I.__webglDepthbuffer[ue];n.bindRenderbuffer(n.RENDERBUFFER,_e),n.framebufferRenderbuffer(n.FRAMEBUFFER,De,n.RENDERBUFFER,_e)}}else{const ue=H.texture.mipmaps;if(ue&&ue.length>0?t.bindFramebuffer(n.FRAMEBUFFER,I.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer===void 0)I.__webglDepthbuffer=n.createRenderbuffer(),Ge(I.__webglDepthbuffer,H,!1);else{const De=H.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,_e=I.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,_e),n.framebufferRenderbuffer(n.FRAMEBUFFER,De,n.RENDERBUFFER,_e)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function St(H,I,ee){const ue=i.get(H);I!==void 0&&ke(ue.__webglFramebuffer,H,H.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ee!==void 0&&_t(H)}function mt(H){const I=H.texture,ee=i.get(H),ue=i.get(I);H.addEventListener("dispose",k);const De=H.textures,_e=H.isWebGLCubeRenderTarget===!0,nt=De.length>1;if(nt||(ue.__webglTexture===void 0&&(ue.__webglTexture=n.createTexture()),ue.__version=I.version,l.memory.textures++),_e){ee.__webglFramebuffer=[];for(let Ye=0;Ye<6;Ye++)if(I.mipmaps&&I.mipmaps.length>0){ee.__webglFramebuffer[Ye]=[];for(let dt=0;dt0){ee.__webglFramebuffer=[];for(let Ye=0;Ye0&&bt(H)===!1){ee.__webglMultisampledFramebuffer=n.createFramebuffer(),ee.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let Ye=0;Ye0)for(let dt=0;dt0)for(let dt=0;dt0){if(bt(H)===!1){const I=H.textures,ee=H.width,ue=H.height;let De=n.COLOR_BUFFER_BIT;const _e=H.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,nt=i.get(H),Ye=I.length>1;if(Ye)for(let Ct=0;Ct0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,nt.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,nt.__webglFramebuffer);for(let Ct=0;Ct0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function st(H){const I=l.render.frame;g.get(H)!==I&&(g.set(H,I),H.update())}function Et(H,I){const ee=H.colorSpace,ue=H.format,De=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||ee!==Dl&&ee!==Po&&(Cn.getTransfer(ee)===qn?(ue!==$r||De!==Xi)&&vt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Lt("WebGLTextures: Unsupported texture color space:",ee)),I}function Te(H){return typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement?(p.width=H.naturalWidth||H.width,p.height=H.naturalHeight||H.height):typeof VideoFrame<"u"&&H instanceof VideoFrame?(p.width=H.displayWidth,p.height=H.displayHeight):(p.width=H.width,p.height=H.height),p}this.allocateTextureUnit=J,this.resetTextureUnits=Q,this.setTexture2D=re,this.setTexture2DArray=q,this.setTexture3D=Z,this.setTextureCube=ne,this.rebindTextures=St,this.setupRenderTarget=mt,this.updateRenderTargetMipmap=Ce,this.updateMultisampleRenderTarget=Xe,this.setupDepthRenderbuffer=_t,this.setupFrameBufferTexture=ke,this.useMultisampledRTT=bt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function WD(n,e){function t(i,r=Po){let a;const l=Cn.getTransfer(r);if(i===Xi)return n.UNSIGNED_BYTE;if(i===Qx)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Jx)return n.UNSIGNED_SHORT_5_5_5_1;if(i===hE)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===pE)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===fE)return n.BYTE;if(i===dE)return n.SHORT;if(i===Sp)return n.UNSIGNED_SHORT;if(i===Kx)return n.INT;if(i===Ea)return n.UNSIGNED_INT;if(i===Or)return n.FLOAT;if(i===no)return n.HALF_FLOAT;if(i===mE)return n.ALPHA;if(i===gE)return n.RGB;if(i===$r)return n.RGBA;if(i===Rl)return n.DEPTH_COMPONENT;if(i===wc)return n.DEPTH_STENCIL;if(i===T0)return n.RED;if(i===w0)return n.RED_INTEGER;if(i===bd)return n.RG;if(i===e_)return n.RG_INTEGER;if(i===t_)return n.RGBA_INTEGER;if(i===Vg||i===Gg||i===Wg||i===$g)if(l===qn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===Vg)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Gg)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Wg)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===$g)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===Vg)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Gg)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Wg)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===$g)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Wb||i===$b||i===Xb||i===jb)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===Wb)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===$b)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Xb)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===jb)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===qb||i===Yb||i===Zb||i===Kb||i===Qb||i===Jb||i===ex)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===qb||i===Yb)return l===qn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===Zb)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(i===Kb)return a.COMPRESSED_R11_EAC;if(i===Qb)return a.COMPRESSED_SIGNED_R11_EAC;if(i===Jb)return a.COMPRESSED_RG11_EAC;if(i===ex)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===tx||i===nx||i===ix||i===rx||i===sx||i===ax||i===ox||i===lx||i===cx||i===ux||i===fx||i===dx||i===hx||i===px)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===tx)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===nx)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===ix)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===rx)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===sx)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ax)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===ox)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===lx)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===cx)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ux)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===fx)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===dx)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===hx)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===px)return l===qn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===mx||i===gx||i===vx)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===mx)return l===qn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===gx)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===vx)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===yx||i===bx||i===xx||i===_x)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===yx)return a.COMPRESSED_RED_RGTC1_EXT;if(i===bx)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===xx)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===_x)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===yd?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const kk=` void main() { gl_Position = vec4( position, 1.0 ); }`,Hk=` 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 Vk{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new wE(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Yn({vertexShader:kk,fragmentShader:Hk,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new hi(new Gu(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Gk extends wa{constructor(e,t){super();const i=this;let r=null,a=1,l=null,u="local-floor",h=1,p=null,g=null,y=null,b=null,x=null,M=null;const A=typeof XRWebGLBinding<"u",w=new Vk,E={},R=t.getContextAttributes();let D=null,P=null;const F=[],L=[],k=new Le;let V=null;const N=new $i;N.viewport=new Zn;const z=new $i;z.viewport=new Zn;const X=[N,z],Q=new ID;let J=null,oe=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(he){let xe=F[he];return xe===void 0&&(xe=new Db,F[he]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(he){let xe=F[he];return xe===void 0&&(xe=new Db,F[he]=xe),xe.getGripSpace()},this.getHand=function(he){let xe=F[he];return xe===void 0&&(xe=new Db,F[he]=xe),xe.getHandSpace()};function re(he){const xe=L.indexOf(he.inputSource);if(xe===-1)return;const ke=F[xe];ke!==void 0&&(ke.update(he.inputSource,he.frame,p||l),ke.dispatchEvent({type:he.type,data:he.inputSource}))}function q(){r.removeEventListener("select",re),r.removeEventListener("selectstart",re),r.removeEventListener("selectend",re),r.removeEventListener("squeeze",re),r.removeEventListener("squeezestart",re),r.removeEventListener("squeezeend",re),r.removeEventListener("end",q),r.removeEventListener("inputsourceschange",Z);for(let he=0;he=0&&(L[Ge]=null,F[Ge].disconnect(ke))}for(let xe=0;xe=L.length){L.push(ke),Ge=_t;break}else if(L[_t]===null){L[_t]=ke,Ge=_t;break}if(Ge===-1)break}const ct=F[Ge];ct&&ct.connect(ke)}}const ne=new K,pe=new K;function Ee(he,xe,ke){ne.setFromMatrixPosition(xe.matrixWorld),pe.setFromMatrixPosition(ke.matrixWorld);const Ge=ne.distanceTo(pe),ct=xe.projectionMatrix.elements,_t=ke.projectionMatrix.elements,St=ct[14]/(ct[10]-1),mt=ct[14]/(ct[10]+1),Ce=(ct[9]+1)/ct[5],Pe=(ct[9]-1)/ct[5],ze=(ct[8]-1)/ct[0],Xe=(_t[8]+1)/_t[0],Y=St*ze,bt=St*Xe,st=Ge/(-ze+Xe),Et=st*-ze;if(xe.matrixWorld.decompose(he.position,he.quaternion,he.scale),he.translateX(Et),he.translateZ(st),he.matrixWorld.compose(he.position,he.quaternion,he.scale),he.matrixWorldInverse.copy(he.matrixWorld).invert(),ct[10]===-1)he.projectionMatrix.copy(xe.projectionMatrix),he.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const Te=St+st,H=mt+st,I=Y-Et,ee=bt+(Ge-Et),ue=Ce*mt/H*Te,De=Pe*mt/H*Te;he.projectionMatrix.makePerspective(I,ee,ue,De,Te,H),he.projectionMatrixInverse.copy(he.projectionMatrix).invert()}}function j(he,xe){xe===null?he.matrixWorld.copy(he.matrix):he.matrixWorld.multiplyMatrices(xe.matrixWorld,he.matrix),he.matrixWorldInverse.copy(he.matrixWorld).invert()}this.updateCamera=function(he){if(r===null)return;let xe=he.near,ke=he.far;w.texture!==null&&(w.depthNear>0&&(xe=w.depthNear),w.depthFar>0&&(ke=w.depthFar)),Q.near=z.near=N.near=xe,Q.far=z.far=N.far=ke,(J!==Q.near||oe!==Q.far)&&(r.updateRenderState({depthNear:Q.near,depthFar:Q.far}),J=Q.near,oe=Q.far),Q.layers.mask=he.layers.mask|6,N.layers.mask=Q.layers.mask&3,z.layers.mask=Q.layers.mask&5;const Ge=he.parent,ct=Q.cameras;j(Q,Ge);for(let _t=0;_t0&&(w.alphaTest.value=E.alphaTest);const R=e.get(E),D=R.envMap,P=R.envMapRotation;D&&(w.envMap.value=D,ed.copy(P),ed.x*=-1,ed.y*=-1,ed.z*=-1,D.isCubeTexture&&D.isRenderTargetTexture===!1&&(ed.y*=-1,ed.z*=-1),w.envMapRotation.value.setFromMatrix4(Wk.makeRotationFromEuler(ed)),w.flipEnvMap.value=D.isCubeTexture&&D.isRenderTargetTexture===!1?-1:1,w.reflectivity.value=E.reflectivity,w.ior.value=E.ior,w.refractionRatio.value=E.refractionRatio),E.lightMap&&(w.lightMap.value=E.lightMap,w.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,w.lightMapTransform)),E.aoMap&&(w.aoMap.value=E.aoMap,w.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,w.aoMapTransform))}function l(w,E){w.diffuse.value.copy(E.color),w.opacity.value=E.opacity,E.map&&(w.map.value=E.map,t(E.map,w.mapTransform))}function u(w,E){w.dashSize.value=E.dashSize,w.totalSize.value=E.dashSize+E.gapSize,w.scale.value=E.scale}function h(w,E,R,D){w.diffuse.value.copy(E.color),w.opacity.value=E.opacity,w.size.value=E.size*R,w.scale.value=D*.5,E.map&&(w.map.value=E.map,t(E.map,w.uvTransform)),E.alphaMap&&(w.alphaMap.value=E.alphaMap,t(E.alphaMap,w.alphaMapTransform)),E.alphaTest>0&&(w.alphaTest.value=E.alphaTest)}function p(w,E){w.diffuse.value.copy(E.color),w.opacity.value=E.opacity,w.rotation.value=E.rotation,E.map&&(w.map.value=E.map,t(E.map,w.mapTransform)),E.alphaMap&&(w.alphaMap.value=E.alphaMap,t(E.alphaMap,w.alphaMapTransform)),E.alphaTest>0&&(w.alphaTest.value=E.alphaTest)}function g(w,E){w.specular.value.copy(E.specular),w.shininess.value=Math.max(E.shininess,1e-4)}function y(w,E){E.gradientMap&&(w.gradientMap.value=E.gradientMap)}function b(w,E){w.metalness.value=E.metalness,E.metalnessMap&&(w.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,w.metalnessMapTransform)),w.roughness.value=E.roughness,E.roughnessMap&&(w.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,w.roughnessMapTransform)),E.envMap&&(w.envMapIntensity.value=E.envMapIntensity)}function x(w,E,R){w.ior.value=E.ior,E.sheen>0&&(w.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),w.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(w.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,w.sheenColorMapTransform)),E.sheenRoughnessMap&&(w.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,w.sheenRoughnessMapTransform))),E.clearcoat>0&&(w.clearcoat.value=E.clearcoat,w.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(w.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,w.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(w.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,w.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(w.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,w.clearcoatNormalMapTransform),w.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===_r&&w.clearcoatNormalScale.value.negate())),E.dispersion>0&&(w.dispersion.value=E.dispersion),E.iridescence>0&&(w.iridescence.value=E.iridescence,w.iridescenceIOR.value=E.iridescenceIOR,w.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],w.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(w.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,w.iridescenceMapTransform)),E.iridescenceThicknessMap&&(w.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,w.iridescenceThicknessMapTransform))),E.transmission>0&&(w.transmission.value=E.transmission,w.transmissionSamplerMap.value=R.texture,w.transmissionSamplerSize.value.set(R.width,R.height),E.transmissionMap&&(w.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,w.transmissionMapTransform)),w.thickness.value=E.thickness,E.thicknessMap&&(w.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,w.thicknessMapTransform)),w.attenuationDistance.value=E.attenuationDistance,w.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(w.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(w.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,w.anisotropyMapTransform))),w.specularIntensity.value=E.specularIntensity,w.specularColor.value.copy(E.specularColor),E.specularColorMap&&(w.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,w.specularColorMapTransform)),E.specularIntensityMap&&(w.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,w.specularIntensityMapTransform))}function M(w,E){E.matcap&&(w.matcap.value=E.matcap)}function A(w,E){const R=e.get(E).light;w.referencePosition.value.setFromMatrixPosition(R.matrixWorld),w.nearDistance.value=R.shadow.camera.near,w.farDistance.value=R.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Xk(n,e,t,i){let r={},a={},l=[];const u=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function h(R,D){const P=D.program;i.uniformBlockBinding(R,P)}function p(R,D){let P=r[R.id];P===void 0&&(M(R),P=g(R),r[R.id]=P,R.addEventListener("dispose",w));const F=D.program;i.updateUBOMapping(R,F);const L=e.render.frame;a[R.id]!==L&&(b(R),a[R.id]=L)}function g(R){const D=y();R.__bindingPointIndex=D;const P=n.createBuffer(),F=R.__size,L=R.usage;return n.bindBuffer(n.UNIFORM_BUFFER,P),n.bufferData(n.UNIFORM_BUFFER,F,L),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,D,P),P}function y(){for(let R=0;R0&&(P+=F-L),R.__size=P,R.__cache={},this}function A(R){const D={boundary:0,storage:0};return typeof R=="number"||typeof R=="boolean"?(D.boundary=4,D.storage=4):R.isVector2?(D.boundary=8,D.storage=8):R.isVector3||R.isColor?(D.boundary=16,D.storage=12):R.isVector4?(D.boundary=16,D.storage=16):R.isMatrix3?(D.boundary=48,D.storage=48):R.isMatrix4?(D.boundary=64,D.storage=64):R.isTexture?vt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):vt("WebGLRenderer: Unsupported uniform value type.",R),D}function w(R){const D=R.target;D.removeEventListener("dispose",w);const P=l.indexOf(D.__bindingPointIndex);l.splice(P,1),n.deleteBuffer(r[D.id]),delete r[D.id],delete a[D.id]}function E(){for(const R in r)n.deleteBuffer(r[R]);l=[],r={},a={}}return{bind:h,update:p,dispose:E}}const jk=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Sl=null;function qk(){return Sl===null&&(Sl=new Sa(jk,16,16,bd,no),Sl.name="DFG_LUT",Sl.minFilter=Nn,Sl.magFilter=Nn,Sl.wrapS=aa,Sl.wrapT=aa,Sl.generateMipmaps=!1,Sl.needsUpdate=!0),Sl}class $D{constructor(e={}){const{canvas:t=F3(),context:i=null,depth:r=!0,stencil:a=!1,alpha:l=!1,antialias:u=!1,premultipliedAlpha:h=!0,preserveDrawingBuffer:p=!1,powerPreference:g="default",failIfMajorPerformanceCaveat:y=!1,reversedDepthBuffer:b=!1,outputBufferType:x=Xi}=e;this.isWebGLRenderer=!0;let M;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");M=i.getContextAttributes().alpha}else M=l;const A=x,w=new Set([t_,e_,w0]),E=new Set([Xi,Ea,Sp,yd,Qx,Jx]),R=new Uint32Array(4),D=new Int32Array(4);let P=null,F=null;const L=[],k=[];let V=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=xa,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const N=this;let z=!1;this._outputColorSpace=Fn;let X=0,Q=0,J=null,oe=-1,re=null;const q=new Zn,Z=new Zn;let ne=null;const pe=new pt(0);let Ee=0,j=t.width,fe=t.height,be=1,Fe=null,rt=null;const he=new Zn(0,0,j,fe),xe=new Zn(0,0,j,fe);let ke=!1;const Ge=new Lp;let ct=!1,_t=!1;const St=new Kt,mt=new K,Ce=new Zn,Pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ze=!1;function Xe(){return J===null?be:1}let Y=i;function bt(W,de){return t.getContext(W,de)}try{const W={alpha:!0,depth:r,stencil:a,antialias:u,premultipliedAlpha:h,preserveDrawingBuffer:p,powerPreference:g,failIfMajorPerformanceCaveat:y};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Td}`),t.addEventListener("webglcontextlost",Nt,!1),t.addEventListener("webglcontextrestored",sn,!1),t.addEventListener("webglcontextcreationerror",ln,!1),Y===null){const de="webgl2";if(Y=bt(de,W),Y===null)throw bt(de)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(W){throw Lt("WebGLRenderer: "+W.message),W}let st,Et,Te,H,I,ee,ue,De,_e,nt,Ye,dt,Ct,$e,Ke,ht,te,ye,it,ie,Qe,je,at,Ze;function He(){st=new YF(Y),st.init(),je=new WD(Y,st),Et=new kF(Y,st,e,je),Te=new Bk(Y,st),Et.reversedDepthBuffer&&b&&Te.buffers.depth.setReversed(!0),H=new QF(Y),I=new Mk,ee=new Fk(Y,st,Te,I,Et,je,H),ue=new VF(N),De=new qF(N),_e=new nB(Y),at=new BF(Y,_e),nt=new ZF(Y,_e,H,at),Ye=new e5(Y,nt,_e,H),it=new JF(Y,Et,ee),ht=new HF(I),dt=new Sk(N,ue,De,st,Et,at,ht),Ct=new $k(N,I),$e=new Tk,Ke=new Ok(st),ye=new zF(N,ue,De,Te,Ye,M,h),te=new Uk(N,Ye,Et),Ze=new Xk(Y,H,Et,Te),ie=new FF(Y,st,H),Qe=new KF(Y,st,H),H.programs=dt.programs,N.capabilities=Et,N.extensions=st,N.properties=I,N.renderLists=$e,N.shadowMap=te,N.state=Te,N.info=H}He(),A!==Xi&&(V=new n5(A,t.width,t.height,r,a));const tt=new Gk(N,Y);this.xr=tt,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){const W=st.get("WEBGL_lose_context");W&&W.loseContext()},this.forceContextRestore=function(){const W=st.get("WEBGL_lose_context");W&&W.restoreContext()},this.getPixelRatio=function(){return be},this.setPixelRatio=function(W){W!==void 0&&(be=W,this.setSize(j,fe,!1))},this.getSize=function(W){return W.set(j,fe)},this.setSize=function(W,de,Oe=!0){if(tt.isPresenting){vt("WebGLRenderer: Can't change size while VR device is presenting.");return}j=W,fe=de,t.width=Math.floor(W*be),t.height=Math.floor(de*be),Oe===!0&&(t.style.width=W+"px",t.style.height=de+"px"),V!==null&&V.setSize(t.width,t.height),this.setViewport(0,0,W,de)},this.getDrawingBufferSize=function(W){return W.set(j*be,fe*be).floor()},this.setDrawingBufferSize=function(W,de,Oe){j=W,fe=de,be=Oe,t.width=Math.floor(W*Oe),t.height=Math.floor(de*Oe),this.setViewport(0,0,W,de)},this.setEffects=function(W){if(A===Xi){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(W){for(let de=0;de{function ot(){if(we.forEach(function(xt){I.get(xt).currentProgram.isReady()&&we.delete(xt)}),we.size===0){ge(W);return}setTimeout(ot,10)}st.get("KHR_parallel_shader_compile")!==null?ot():setTimeout(ot,10)})};let Ll=null;function Go(W){Ll&&Ll(W)}function so(){Er.stop()}function Ul(){Er.start()}const Er=new FD;Er.setAnimationLoop(Go),typeof self<"u"&&Er.setContext(self),this.setAnimationLoop=function(W){Ll=W,tt.setAnimationLoop(W),W===null?Er.stop():Er.start()},tt.addEventListener("sessionstart",so),tt.addEventListener("sessionend",Ul),this.render=function(W,de){if(de!==void 0&&de.isCamera!==!0){Lt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;const Oe=tt.enabled===!0&&tt.isPresenting===!0,we=V!==null&&(J===null||Oe)&&V.begin(N,J);if(W.matrixWorldAutoUpdate===!0&&W.updateMatrixWorld(),de.parent===null&&de.matrixWorldAutoUpdate===!0&&de.updateMatrixWorld(),tt.enabled===!0&&tt.isPresenting===!0&&(V===null||V.isCompositing()===!1)&&(tt.cameraAutoUpdate===!0&&tt.updateCamera(de),de=tt.getCamera()),W.isScene===!0&&W.onBeforeRender(N,W,de,J),F=Ke.get(W,k.length),F.init(de),k.push(F),St.multiplyMatrices(de.projectionMatrix,de.matrixWorldInverse),Ge.setFromProjectionMatrix(St,ba,de.reversedDepth),_t=this.localClippingEnabled,ct=ht.init(this.clippingPlanes,_t),P=$e.get(W,L.length),P.init(),L.push(P),tt.enabled===!0&&tt.isPresenting===!0){const xt=N.xr.getDepthSensingMesh();xt!==null&&ds(xt,de,-1/0,N.sortObjects)}ds(W,de,0,N.sortObjects),P.finish(),N.sortObjects===!0&&P.sort(Fe,rt),ze=tt.enabled===!1||tt.isPresenting===!1||tt.hasDepthSensing()===!1,ze&&ye.addToRenderList(P,W),this.info.render.frame++,ct===!0&&ht.beginShadows();const ge=F.state.shadowsArray;if(te.render(ge,W,de),ct===!0&&ht.endShadows(),this.info.autoReset===!0&&this.info.reset(),(we&&V.hasRenderPass())===!1){const xt=P.opaque,et=P.transmissive;if(F.setupLights(),de.isArrayCamera){const Tt=de.cameras;if(et.length>0)for(let wt=0,zt=Tt.length;wt0&&Yi(xt,et,W,de),ze&&ye.render(W),mi(P,W,de)}J!==null&&Q===0&&(ee.updateMultisampleRenderTarget(J),ee.updateRenderTargetMipmap(J)),we&&V.end(N),W.isScene===!0&&W.onAfterRender(N,W,de),at.resetDefaultState(),oe=-1,re=null,k.pop(),k.length>0?(F=k[k.length-1],ct===!0&&ht.setGlobalState(N.clippingPlanes,F.state.camera)):F=null,L.pop(),L.length>0?P=L[L.length-1]:P=null};function ds(W,de,Oe,we){if(W.visible===!1)return;if(W.layers.test(de.layers)){if(W.isGroup)Oe=W.renderOrder;else if(W.isLOD)W.autoUpdate===!0&&W.update(de);else if(W.isLight)F.pushLight(W),W.castShadow&&F.pushShadow(W);else if(W.isSprite){if(!W.frustumCulled||Ge.intersectsSprite(W)){we&&Ce.setFromMatrixPosition(W.matrixWorld).applyMatrix4(St);const xt=Ye.update(W),et=W.material;et.visible&&P.push(W,xt,et,Oe,Ce.z,null)}}else if((W.isMesh||W.isLine||W.isPoints)&&(!W.frustumCulled||Ge.intersectsObject(W))){const xt=Ye.update(W),et=W.material;if(we&&(W.boundingSphere!==void 0?(W.boundingSphere===null&&W.computeBoundingSphere(),Ce.copy(W.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),Ce.copy(xt.boundingSphere.center)),Ce.applyMatrix4(W.matrixWorld).applyMatrix4(St)),Array.isArray(et)){const Tt=xt.groups;for(let wt=0,zt=Tt.length;wt0&&hs(ge,de,Oe),ot.length>0&&hs(ot,de,Oe),xt.length>0&&hs(xt,de,Oe),Te.buffers.depth.setTest(!0),Te.buffers.depth.setMask(!0),Te.buffers.color.setMask(!0),Te.setPolygonOffset(!1)}function Yi(W,de,Oe,we){if((Oe.isScene===!0?Oe.overrideMaterial:null)!==null)return;if(F.state.transmissionRenderTarget[we.id]===void 0){const Ht=st.has("EXT_color_buffer_half_float")||st.has("EXT_color_buffer_float");F.state.transmissionRenderTarget[we.id]=new Gn(1,1,{generateMipmaps:!0,type:Ht?no:Xi,minFilter:Io,samples:Et.samples,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Cn.workingColorSpace})}const ot=F.state.transmissionRenderTarget[we.id],xt=we.viewport||q;ot.setSize(xt.z*N.transmissionResolutionScale,xt.w*N.transmissionResolutionScale);const et=N.getRenderTarget(),Tt=N.getActiveCubeFace(),wt=N.getActiveMipmapLevel();N.setRenderTarget(ot),N.getClearColor(pe),Ee=N.getClearAlpha(),Ee<1&&N.setClearColor(16777215,.5),N.clear(),ze&&ye.render(Oe);const zt=N.toneMapping;N.toneMapping=xa;const Rt=we.viewport;if(we.viewport!==void 0&&(we.viewport=void 0),F.setupLightsView(we),ct===!0&&ht.setGlobalState(N.clippingPlanes,we),hs(W,Oe,we),ee.updateMultisampleRenderTarget(ot),ee.updateRenderTargetMipmap(ot),st.has("WEBGL_multisampled_render_to_texture")===!1){let Ht=!1;for(let Rn=0,Qn=de.length;Rn0),Rt=!!Oe.morphAttributes.position,Ht=!!Oe.morphAttributes.normal,Rn=!!Oe.morphAttributes.color;let Qn=xa;we.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(Qn=N.toneMapping);const $n=Oe.morphAttributes.position||Oe.morphAttributes.normal||Oe.morphAttributes.color,Qt=$n!==void 0?$n.length:0,gt=I.get(we),Tn=F.state.lights;if(ct===!0&&(_t===!0||W!==re)){const rr=W===re&&we.id===oe;ht.setState(we,W,rr)}let Xt=!1;we.version===gt.__version?(gt.needsLights&>.lightsStateVersion!==Tn.state.version||gt.outputColorSpace!==et||ge.isBatchedMesh&>.batching===!1||!ge.isBatchedMesh&>.batching===!0||ge.isBatchedMesh&>.batchingColor===!0&&ge.colorTexture===null||ge.isBatchedMesh&>.batchingColor===!1&&ge.colorTexture!==null||ge.isInstancedMesh&>.instancing===!1||!ge.isInstancedMesh&>.instancing===!0||ge.isSkinnedMesh&>.skinning===!1||!ge.isSkinnedMesh&>.skinning===!0||ge.isInstancedMesh&>.instancingColor===!0&&ge.instanceColor===null||ge.isInstancedMesh&>.instancingColor===!1&&ge.instanceColor!==null||ge.isInstancedMesh&>.instancingMorph===!0&&ge.morphTexture===null||ge.isInstancedMesh&>.instancingMorph===!1&&ge.morphTexture!==null||gt.envMap!==Tt||we.fog===!0&>.fog!==ot||gt.numClippingPlanes!==void 0&&(gt.numClippingPlanes!==ht.numPlanes||gt.numIntersection!==ht.numIntersection)||gt.vertexAlphas!==wt||gt.vertexTangents!==zt||gt.morphTargets!==Rt||gt.morphNormals!==Ht||gt.morphColors!==Rn||gt.toneMapping!==Qn||gt.morphTargetsCount!==Qt)&&(Xt=!0):(Xt=!0,gt.__version=we.version);let Bi=gt.currentProgram;Xt===!0&&(Bi=ms(we,de,ge));let ua=!1,ai=!1,Nr=!1;const Pn=Bi.getUniforms(),Zi=gt.uniforms;if(Te.useProgram(Bi.program)&&(ua=!0,ai=!0,Nr=!0),we.id!==oe&&(oe=we.id,ai=!0),ua||re!==W){Te.buffers.depth.getReversed()&&W.reversedDepth!==!0&&(W._reversedDepth=!0,W.updateProjectionMatrix()),Pn.setValue(Y,"projectionMatrix",W.projectionMatrix),Pn.setValue(Y,"viewMatrix",W.matrixWorldInverse);const sr=Pn.map.cameraPosition;sr!==void 0&&sr.setValue(Y,mt.setFromMatrixPosition(W.matrixWorld)),Et.logarithmicDepthBuffer&&Pn.setValue(Y,"logDepthBufFC",2/(Math.log(W.far+1)/Math.LN2)),(we.isMeshPhongMaterial||we.isMeshToonMaterial||we.isMeshLambertMaterial||we.isMeshBasicMaterial||we.isMeshStandardMaterial||we.isShaderMaterial)&&Pn.setValue(Y,"isOrthographic",W.isOrthographicCamera===!0),re!==W&&(re=W,ai=!0,Nr=!0)}if(gt.needsLights&&(Tn.state.directionalShadowMap.length>0&&Pn.setValue(Y,"directionalShadowMap",Tn.state.directionalShadowMap,ee),Tn.state.spotShadowMap.length>0&&Pn.setValue(Y,"spotShadowMap",Tn.state.spotShadowMap,ee),Tn.state.pointShadowMap.length>0&&Pn.setValue(Y,"pointShadowMap",Tn.state.pointShadowMap,ee)),ge.isSkinnedMesh){Pn.setOptional(Y,ge,"bindMatrix"),Pn.setOptional(Y,ge,"bindMatrixInverse");const rr=ge.skeleton;rr&&(rr.boneTexture===null&&rr.computeBoneTexture(),Pn.setValue(Y,"boneTexture",rr.boneTexture,ee))}ge.isBatchedMesh&&(Pn.setOptional(Y,ge,"batchingTexture"),Pn.setValue(Y,"batchingTexture",ge._matricesTexture,ee),Pn.setOptional(Y,ge,"batchingIdTexture"),Pn.setValue(Y,"batchingIdTexture",ge._indirectTexture,ee),Pn.setOptional(Y,ge,"batchingColorTexture"),ge._colorsTexture!==null&&Pn.setValue(Y,"batchingColorTexture",ge._colorsTexture,ee));const Fi=Oe.morphAttributes;if((Fi.position!==void 0||Fi.normal!==void 0||Fi.color!==void 0)&&it.update(ge,Oe,Bi),(ai||gt.receiveShadow!==ge.receiveShadow)&&(gt.receiveShadow=ge.receiveShadow,Pn.setValue(Y,"receiveShadow",ge.receiveShadow)),we.isMeshGouraudMaterial&&we.envMap!==null&&(Zi.envMap.value=Tt,Zi.flipEnvMap.value=Tt.isCubeTexture&&Tt.isRenderTargetTexture===!1?-1:1),we.isMeshStandardMaterial&&we.envMap===null&&de.environment!==null&&(Zi.envMapIntensity.value=de.environmentIntensity),Zi.dfgLUT!==void 0&&(Zi.dfgLUT.value=qk()),ai&&(Pn.setValue(Y,"toneMappingExposure",N.toneMappingExposure),gt.needsLights&&ao(Zi,Nr),ot&&we.fog===!0&&Ct.refreshFogUniforms(Zi,ot),Ct.refreshMaterialUniforms(Zi,we,be,fe,F.state.transmissionRenderTarget[W.id]),Ob.upload(Y,Wo(gt),Zi,ee)),we.isShaderMaterial&&we.uniformsNeedUpdate===!0&&(Ob.upload(Y,Wo(gt),Zi,ee),we.uniformsNeedUpdate=!1),we.isSpriteMaterial&&Pn.setValue(Y,"center",ge.center),Pn.setValue(Y,"modelViewMatrix",ge.modelViewMatrix),Pn.setValue(Y,"normalMatrix",ge.normalMatrix),Pn.setValue(Y,"modelMatrix",ge.matrixWorld),we.isShaderMaterial||we.isRawShaderMaterial){const rr=we.uniformsGroups;for(let sr=0,Bl=rr.length;sr0&&ee.useMultisampledRTT(W)===!1?we=I.get(W).__webglMultisampledFramebuffer:Array.isArray(wt)?we=wt[Oe]:we=wt,q.copy(W.viewport),Z.copy(W.scissor),ne=W.scissorTest}else q.copy(he).multiplyScalar(be).floor(),Z.copy(xe).multiplyScalar(be).floor(),ne=ke;if(Oe!==0&&(we=lo),Te.bindFramebuffer(Y.FRAMEBUFFER,we)&&Te.drawBuffers(W,we),Te.viewport(q),Te.scissor(Z),Te.setScissorTest(ne),ge){const et=I.get(W.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+de,et.__webglTexture,Oe)}else if(ot){const et=de;for(let Tt=0;Tt=0&&de<=W.width-we&&Oe>=0&&Oe<=W.height-ge&&(W.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+et),Y.readPixels(de,Oe,we,ge,je.convert(zt),je.convert(Rt),ot))}finally{const wt=J!==null?I.get(J).__webglFramebuffer:null;Te.bindFramebuffer(Y.FRAMEBUFFER,wt)}}},this.readRenderTargetPixelsAsync=async function(W,de,Oe,we,ge,ot,xt,et=0){if(!(W&&W.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Tt=I.get(W).__webglFramebuffer;if(W.isWebGLCubeRenderTarget&&xt!==void 0&&(Tt=Tt[xt]),Tt)if(de>=0&&de<=W.width-we&&Oe>=0&&Oe<=W.height-ge){Te.bindFramebuffer(Y.FRAMEBUFFER,Tt);const wt=W.textures[et],zt=wt.format,Rt=wt.type;if(!Et.textureFormatReadable(zt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Et.textureTypeReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ht=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,Ht),Y.bufferData(Y.PIXEL_PACK_BUFFER,ot.byteLength,Y.STREAM_READ),W.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+et),Y.readPixels(de,Oe,we,ge,je.convert(zt),je.convert(Rt),0);const Rn=J!==null?I.get(J).__webglFramebuffer:null;Te.bindFramebuffer(Y.FRAMEBUFFER,Rn);const Qn=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);return Y.flush(),await iL(Y,Qn,4),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,Ht),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,ot),Y.deleteBuffer(Ht),Y.deleteSync(Qn),ot}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(W,de=null,Oe=0){const we=Math.pow(2,-Oe),ge=Math.floor(W.image.width*we),ot=Math.floor(W.image.height*we),xt=de!==null?de.x:0,et=de!==null?de.y:0;ee.setTexture2D(W,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,Oe,0,0,xt,et,ge,ot),Te.unbindTexture()};const $o=Y.createFramebuffer(),Aa=Y.createFramebuffer();this.copyTextureToTexture=function(W,de,Oe=null,we=null,ge=0,ot=null){ot===null&&(ge!==0?(Ep("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ot=ge,ge=0):ot=0);let xt,et,Tt,wt,zt,Rt,Ht,Rn,Qn;const $n=W.isCompressedTexture?W.mipmaps[ot]:W.image;if(Oe!==null)xt=Oe.max.x-Oe.min.x,et=Oe.max.y-Oe.min.y,Tt=Oe.isBox3?Oe.max.z-Oe.min.z:1,wt=Oe.min.x,zt=Oe.min.y,Rt=Oe.isBox3?Oe.min.z:0;else{const Fi=Math.pow(2,-ge);xt=Math.floor($n.width*Fi),et=Math.floor($n.height*Fi),W.isDataArrayTexture?Tt=$n.depth:W.isData3DTexture?Tt=Math.floor($n.depth*Fi):Tt=1,wt=0,zt=0,Rt=0}we!==null?(Ht=we.x,Rn=we.y,Qn=we.z):(Ht=0,Rn=0,Qn=0);const Qt=je.convert(de.format),gt=je.convert(de.type);let Tn;de.isData3DTexture?(ee.setTexture3D(de,0),Tn=Y.TEXTURE_3D):de.isDataArrayTexture||de.isCompressedArrayTexture?(ee.setTexture2DArray(de,0),Tn=Y.TEXTURE_2D_ARRAY):(ee.setTexture2D(de,0),Tn=Y.TEXTURE_2D),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,de.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,de.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,de.unpackAlignment);const Xt=Y.getParameter(Y.UNPACK_ROW_LENGTH),Bi=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),ua=Y.getParameter(Y.UNPACK_SKIP_PIXELS),ai=Y.getParameter(Y.UNPACK_SKIP_ROWS),Nr=Y.getParameter(Y.UNPACK_SKIP_IMAGES);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,$n.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,$n.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,wt),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,zt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Rt);const Pn=W.isDataArrayTexture||W.isData3DTexture,Zi=de.isDataArrayTexture||de.isData3DTexture;if(W.isDepthTexture){const Fi=I.get(W),rr=I.get(de),sr=I.get(Fi.__renderTarget),Bl=I.get(rr.__renderTarget);Te.bindFramebuffer(Y.READ_FRAMEBUFFER,sr.__webglFramebuffer),Te.bindFramebuffer(Y.DRAW_FRAMEBUFFER,Bl.__webglFramebuffer);for(let Ls=0;Ls"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:u;return x1.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:g,x1}var jA;function Kk(){return jA||(jA=1,b1.exports=Zk()),b1.exports}var qA;function Qk(){if(qA)return y1;qA=1;var n=M0(),e=Kk();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var i=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,a=n.useRef,l=n.useEffect,u=n.useMemo,h=n.useDebugValue;return y1.useSyncExternalStoreWithSelector=function(p,g,y,b,x){var M=a(null);if(M.current===null){var A={hasValue:!1,value:null};M.current=A}else A=M.current;M=u(function(){function E(L){if(!R){if(R=!0,D=L,L=b(L),x!==void 0&&A.hasValue){var k=A.value;if(x(k,L))return P=k}return P=L}if(k=P,i(D,L))return k;var V=b(L);return x!==void 0&&x(k,V)?(D=L,k):(D=L,P=V)}var R=!1,D,P,F=y===void 0?null:y;return[function(){return E(g())},F===null?void 0:function(){return E(F())}]},[g,y,b,x]);var w=r(p,M[0],M[1]);return l(function(){A.hasValue=!0,A.value=w},[w]),h(w),w},y1}var YA;function Jk(){return YA||(YA=1,v1.exports=Qk()),v1.exports}var e6=Jk();const t6=Yu(e6),ZA=n=>{let e;const t=new Set,i=(p,g)=>{const y=typeof p=="function"?p(e):p;if(!Object.is(y,e)){const b=e;e=g??(typeof y!="object"||y===null)?y:Object.assign({},e,y),t.forEach(x=>x(e,b))}},r=()=>e,u={setState:i,getState:r,getInitialState:()=>h,subscribe:p=>(t.add(p),()=>t.delete(p))},h=e=n(i,r,u);return u},n6=(n=>n?ZA(n):ZA),{useSyncExternalStoreWithSelector:i6}=t6,r6=n=>n;function s6(n,e=r6,t){const i=i6(n.subscribe,n.getState,n.getInitialState,e,t);return se.useDebugValue(i),i}const KA=(n,e)=>{const t=n6(n),i=(r,a=e)=>s6(t,r,a);return Object.assign(i,t),i},a6=((n,e)=>n?KA(n,e):KA);var SM=s3();const o6=Yu(SM);function YE(n,e,t){if(!n)return;if(t(n)===!0)return n;let i=e?n.return:n.child;for(;i;){const r=YE(i,e,t);if(r)return r;i=e?null:i.sibling}}function XD(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const ZE=XD(U.createContext(null));let jD=class extends U.Component{render(){return U.createElement(ZE.Provider,{value:this._reactInternals},this.props.children)}};function qD(){const n=U.useContext(ZE);if(n===null)throw new Error("its-fine: useFiber must be called within a !");const e=U.useId();return U.useMemo(()=>{for(const t of[n,n?.alternate]){if(!t)continue;const i=YE(t,!1,r=>{let a=r.memoizedState;for(;a;){if(a.memoizedState===e)return!0;a=a.next}});if(i)return i}},[n,e])}const l6=Symbol.for("react.context"),c6=n=>n!==null&&typeof n=="object"&&"$$typeof"in n&&n.$$typeof===l6;function u6(){const n=qD(),[e]=U.useState(()=>new Map);e.clear();let t=n;for(;t;){const i=t.type;c6(i)&&i!==ZE&&!e.has(i)&&e.set(i,U.use(XD(i))),t=t.return}return e}function f6(){const n=u6();return U.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>i=>U.createElement(e,null,U.createElement(t.Provider,{...i,value:n.get(t)})),e=>U.createElement(jD,{...e})),[n])}function YD(n){let e=n.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const ZD=n=>n&&n.isOrthographicCamera,d6=n=>n&&n.hasOwnProperty("current"),h6=n=>n!=null&&(typeof n=="string"||typeof n=="number"||n.isColor),N0=((n,e)=>typeof window<"u"&&(((n=window.document)==null?void 0:n.createElement)||((e=window.navigator)==null?void 0:e.product)==="ReactNative"))()?U.useLayoutEffect:U.useEffect;function KD(n){const e=U.useRef(n);return N0(()=>{e.current=n},[n]),e}function p6(){const n=qD(),e=f6();return U.useMemo(()=>({children:t})=>{const r=!!YE(n,!0,a=>a.type===U.StrictMode)?U.StrictMode:U.Fragment;return ut.jsx(r,{children:ut.jsx(e,{children:t})})},[n,e])}function m6({set:n}){return N0(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}const g6=(n=>(n=class extends U.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}},n.getDerivedStateFromError=()=>({error:!0}),n))();function QD(n){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(n)?Math.min(Math.max(n[0],t),n[1]):n}function sp(n){var e;return(e=n.__r3f)==null?void 0:e.root.getState()}const Li={obj:n=>n===Object(n)&&!Li.arr(n)&&typeof n!="function",fun:n=>typeof n=="function",str:n=>typeof n=="string",num:n=>typeof n=="number",boo:n=>typeof n=="boolean",und:n=>n===void 0,nul:n=>n===null,arr:n=>Array.isArray(n),equ(n,e,{arrays:t="shallow",objects:i="reference",strict:r=!0}={}){if(typeof n!=typeof e||!!n!=!!e)return!1;if(Li.str(n)||Li.num(n)||Li.boo(n))return n===e;const a=Li.obj(n);if(a&&i==="reference")return n===e;const l=Li.arr(n);if(l&&t==="reference")return n===e;if((l||a)&&n===e)return!0;let u;for(u in n)if(!(u in e))return!1;if(a&&t==="shallow"&&i==="shallow"){for(u in r?e:n)if(!Li.equ(n[u],e[u],{strict:r,objects:"reference"}))return!1}else for(u in r?e:n)if(n[u]!==e[u])return!1;if(Li.und(u)){if(l&&n.length===0&&e.length===0||a&&Object.keys(n).length===0&&Object.keys(e).length===0)return!0;if(n!==e)return!1}return!0}};function v6(n){n.type!=="Scene"&&(n.dispose==null||n.dispose());for(const e in n){const t=n[e];t?.type!=="Scene"&&(t==null||t.dispose==null||t.dispose())}}const JD=["children","key","ref"];function y6(n){const e={};for(const t in n)JD.includes(t)||(e[t]=n[t]);return e}function Ax(n,e,t,i){const r=n;let a=r?.__r3f;return a||(a={root:e,type:t,parent:null,children:[],props:y6(i),object:r,eventCount:0,handlers:{},isHidden:!1},r&&(r.__r3f=a)),a}function y0(n,e){if(!e.includes("-"))return{root:n,key:e,target:n[e]};if(e in n)return{root:n,key:e,target:n[e]};let t=n;const i=e.split("-");for(const r of i){if(typeof t!="object"||t===null){if(t!==void 0){const a=i.slice(i.indexOf(r)).join("-");return{root:t,key:a,target:void 0}}return{root:n,key:e,target:void 0}}e=r,n=t,t=t[e]}return{root:n,key:e,target:t}}const QA=/-\d+$/;function Cx(n,e){if(Li.str(e.props.attach)){if(QA.test(e.props.attach)){const r=e.props.attach.replace(QA,""),{root:a,key:l}=y0(n.object,r);Array.isArray(a[l])||(a[l]=[])}const{root:t,key:i}=y0(n.object,e.props.attach);e.previousAttach=t[i],t[i]=e.object}else Li.fun(e.props.attach)&&(e.previousAttach=e.props.attach(n.object,e.object))}function Rx(n,e){if(Li.str(e.props.attach)){const{root:t,key:i}=y0(n.object,e.props.attach),r=e.previousAttach;r===void 0?delete t[i]:t[i]=r}else e.previousAttach==null||e.previousAttach(n.object,e.object);delete e.previousAttach}const MM=[...JD,"args","dispose","attach","object","onUpdate","dispose"],JA=new Map;function b6(n){let e=JA.get(n.constructor);try{e||(e=new n.constructor,JA.set(n.constructor,e))}catch{}return e}function x6(n,e){const t={};for(const i in e)if(!MM.includes(i)&&!Li.equ(e[i],n.props[i])){t[i]=e[i];for(const r in e)r.startsWith(`${i}-`)&&(t[r]=e[r])}for(const i in n.props){if(MM.includes(i)||e.hasOwnProperty(i))continue;const{root:r,key:a}=y0(n.object,i);if(r.constructor&&r.constructor.length===0){const l=b6(r);Li.und(l)||(t[a]=l[a])}else t[a]=0}return t}const _6=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],S6=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function Nu(n,e){var t;const i=n.__r3f,r=i&&YD(i).getState(),a=i?.eventCount;for(const u in e){let h=e[u];if(MM.includes(u))continue;if(i&&S6.test(u)){typeof h=="function"?i.handlers[u]=h:delete i.handlers[u],i.eventCount=Object.keys(i.handlers).length;continue}if(h===void 0)continue;let{root:p,key:g,target:y}=y0(n,u);if(y===void 0&&(typeof p!="object"||p===null))throw Error(`R3F: Cannot set "${u}". Ensure it is an object before setting "${g}".`);if(y instanceof wp&&h instanceof wp)y.mask=h.mask;else if(y instanceof pt&&h6(h))y.set(h);else if(y!==null&&typeof y=="object"&&typeof y.set=="function"&&typeof y.copy=="function"&&h!=null&&h.constructor&&y.constructor===h.constructor)y.copy(h);else if(y!==null&&typeof y=="object"&&typeof y.set=="function"&&Array.isArray(h))typeof y.fromArray=="function"?y.fromArray(h):y.set(...h);else if(y!==null&&typeof y=="object"&&typeof y.set=="function"&&typeof h=="number")typeof y.setScalar=="function"?y.setScalar(h):y.set(h);else{var l;p[g]=h,r&&!r.linear&&_6.includes(g)&&(l=p[g])!=null&&l.isTexture&&p[g].format===$r&&p[g].type===Xi&&(p[g].colorSpace=Fn)}}if(i!=null&&i.parent&&r!=null&&r.internal&&(t=i.object)!=null&&t.isObject3D&&a!==i.eventCount){const u=i.object,h=r.internal.interaction.indexOf(u);h>-1&&r.internal.interaction.splice(h,1),i.eventCount&&u.raycast!==null&&r.internal.interaction.push(u)}return i&&i.props.attach===void 0&&(i.object.isBufferGeometry?i.props.attach="geometry":i.object.isMaterial&&(i.props.attach="material")),i&&zp(i),n}function zp(n){var e;if(!n.parent)return;n.props.onUpdate==null||n.props.onUpdate(n.object);const t=(e=n.root)==null||e.getState==null?void 0:e.getState();t&&t.internal.frames===0&&t.invalidate()}function M6(n,e){n.manual||(ZD(n)?(n.left=e.width/-2,n.right=e.width/2,n.top=e.height/2,n.bottom=e.height/-2):n.aspect=e.width/e.height,n.updateProjectionMatrix())}const ra=n=>n?.isObject3D;function vb(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function eO(n,e,t,i){const r=t.get(e);r&&(t.delete(e),t.size===0&&(n.delete(i),r.target.releasePointerCapture(i)))}function E6(n,e){const{internal:t}=n.getState();t.interaction=t.interaction.filter(i=>i!==e),t.initialHits=t.initialHits.filter(i=>i!==e),t.hovered.forEach((i,r)=>{(i.eventObject===e||i.object===e)&&t.hovered.delete(r)}),t.capturedMap.forEach((i,r)=>{eO(t.capturedMap,e,i,r)})}function T6(n){function e(h){const{internal:p}=n.getState(),g=h.offsetX-p.initialClick[0],y=h.offsetY-p.initialClick[1];return Math.round(Math.sqrt(g*g+y*y))}function t(h){return h.filter(p=>["Move","Over","Enter","Out","Leave"].some(g=>{var y;return(y=p.__r3f)==null?void 0:y.handlers["onPointer"+g]}))}function i(h,p){const g=n.getState(),y=new Set,b=[],x=p?p(g.internal.interaction):g.internal.interaction;for(let E=0;E{const D=sp(E.object),P=sp(R.object);return!D||!P?E.distance-R.distance:P.events.priority-D.events.priority||E.distance-R.distance}).filter(E=>{const R=vb(E);return y.has(R)?!1:(y.add(R),!0)});g.events.filter&&(A=g.events.filter(A,g));for(const E of A){let R=E.object;for(;R;){var w;(w=R.__r3f)!=null&&w.eventCount&&b.push({...E,eventObject:R}),R=R.parent}}if("pointerId"in h&&g.internal.capturedMap.has(h.pointerId))for(let E of g.internal.capturedMap.get(h.pointerId).values())y.has(vb(E.intersection))||b.push(E.intersection);return b}function r(h,p,g,y){if(h.length){const b={stopped:!1};for(const x of h){let M=sp(x.object);if(M||x.object.traverseAncestors(A=>{const w=sp(A);if(w)return M=w,!1}),M){const{raycaster:A,pointer:w,camera:E,internal:R}=M,D=new K(w.x,w.y,0).unproject(E),P=N=>{var z,X;return(z=(X=R.capturedMap.get(N))==null?void 0:X.has(x.eventObject))!=null?z:!1},F=N=>{const z={intersection:x,target:p.target};R.capturedMap.has(N)?R.capturedMap.get(N).set(x.eventObject,z):R.capturedMap.set(N,new Map([[x.eventObject,z]])),p.target.setPointerCapture(N)},L=N=>{const z=R.capturedMap.get(N);z&&eO(R.capturedMap,x.eventObject,z,N)};let k={};for(let N in p){let z=p[N];typeof z!="function"&&(k[N]=z)}let V={...x,...k,pointer:w,intersections:h,stopped:b.stopped,delta:g,unprojectedPoint:D,ray:A.ray,camera:E,stopPropagation(){const N="pointerId"in p&&R.capturedMap.get(p.pointerId);if((!N||N.has(x.eventObject))&&(V.stopped=b.stopped=!0,R.hovered.size&&Array.from(R.hovered.values()).find(z=>z.eventObject===x.eventObject))){const z=h.slice(0,h.indexOf(x));a([...z,x])}},target:{hasPointerCapture:P,setPointerCapture:F,releasePointerCapture:L},currentTarget:{hasPointerCapture:P,setPointerCapture:F,releasePointerCapture:L},nativeEvent:p};if(y(V),b.stopped===!0)break}}}return h}function a(h){const{internal:p}=n.getState();for(const g of p.hovered.values())if(!h.length||!h.find(y=>y.object===g.object&&y.index===g.index&&y.instanceId===g.instanceId)){const b=g.eventObject.__r3f;if(p.hovered.delete(vb(g)),b!=null&&b.eventCount){const x=b.handlers,M={...g,intersections:h};x.onPointerOut==null||x.onPointerOut(M),x.onPointerLeave==null||x.onPointerLeave(M)}}}function l(h,p){for(let g=0;ga([]);case"onLostPointerCapture":return p=>{const{internal:g}=n.getState();"pointerId"in p&&g.capturedMap.has(p.pointerId)&&requestAnimationFrame(()=>{g.capturedMap.has(p.pointerId)&&(g.capturedMap.delete(p.pointerId),a([]))})}}return function(g){const{onPointerMissed:y,internal:b}=n.getState();b.lastEvent.current=g;const x=h==="onPointerMove",M=h==="onClick"||h==="onContextMenu"||h==="onDoubleClick",w=i(g,x?t:void 0),E=M?e(g):0;h==="onPointerDown"&&(b.initialClick=[g.offsetX,g.offsetY],b.initialHits=w.map(D=>D.eventObject)),M&&!w.length&&E<=2&&(l(g,b.interaction),y&&y(g)),x&&a(w);function R(D){const P=D.eventObject,F=P.__r3f;if(!(F!=null&&F.eventCount))return;const L=F.handlers;if(x){if(L.onPointerOver||L.onPointerEnter||L.onPointerOut||L.onPointerLeave){const k=vb(D),V=b.hovered.get(k);V?V.stopped&&D.stopPropagation():(b.hovered.set(k,D),L.onPointerOver==null||L.onPointerOver(D),L.onPointerEnter==null||L.onPointerEnter(D))}L.onPointerMove==null||L.onPointerMove(D)}else{const k=L[h];k?(!M||b.initialHits.includes(P))&&(l(g,b.interaction.filter(V=>!b.initialHits.includes(V))),k(D)):M&&b.initialHits.includes(P)&&l(g,b.interaction.filter(V=>!b.initialHits.includes(V)))}}r(w,g,E,R)}}return{handlePointer:u}}const eC=n=>!!(n!=null&&n.render),tO=U.createContext(null),w6=(n,e)=>{const t=a6((u,h)=>{const p=new K,g=new K,y=new K;function b(E=h().camera,R=g,D=h().size){const{width:P,height:F,top:L,left:k}=D,V=P/F;R.isVector3?y.copy(R):y.set(...R);const N=E.getWorldPosition(p).distanceTo(y);if(ZD(E))return{width:P/E.zoom,height:F/E.zoom,top:L,left:k,factor:1,distance:N,aspect:V};{const z=E.fov*Math.PI/180,X=2*Math.tan(z/2)*N,Q=X*(P/F);return{width:Q,height:X,top:L,left:k,factor:P/Q,distance:N,aspect:V}}}let x;const M=E=>u(R=>({performance:{...R.performance,current:E}})),A=new Le;return{set:u,get:h,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(E=1)=>n(h(),E),advance:(E,R)=>e(E,R,h()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new $E,pointer:A,mouse:A,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const E=h();x&&clearTimeout(x),E.performance.current!==E.performance.min&&M(E.performance.min),x=setTimeout(()=>M(h().performance.max),E.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:b},setEvents:E=>u(R=>({...R,events:{...R.events,...E}})),setSize:(E,R,D=0,P=0)=>{const F=h().camera,L={width:E,height:R,top:D,left:P};u(k=>({size:L,viewport:{...k.viewport,...b(F,g,L)}}))},setDpr:E=>u(R=>{const D=QD(E);return{viewport:{...R.viewport,dpr:D,initialDpr:R.viewport.initialDpr||D}}}),setFrameloop:(E="always")=>{const R=h().clock;R.stop(),R.elapsedTime=0,E!=="never"&&(R.start(),R.elapsedTime=0),u(()=>({frameloop:E}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:U.createRef(),active:!1,frames:0,priority:0,subscribe:(E,R,D)=>{const P=h().internal;return P.priority=P.priority+(R>0?1:0),P.subscribers.push({ref:E,priority:R,store:D}),P.subscribers=P.subscribers.sort((F,L)=>F.priority-L.priority),()=>{const F=h().internal;F!=null&&F.subscribers&&(F.priority=F.priority-(R>0?1:0),F.subscribers=F.subscribers.filter(L=>L.ref!==E))}}}}}),i=t.getState();let r=i.size,a=i.viewport.dpr,l=i.camera;return t.subscribe(()=>{const{camera:u,size:h,viewport:p,gl:g,set:y}=t.getState();if(h.width!==r.width||h.height!==r.height||p.dpr!==a){r=h,a=p.dpr,M6(u,h),p.dpr>0&&g.setPixelRatio(p.dpr);const b=typeof HTMLCanvasElement<"u"&&g.domElement instanceof HTMLCanvasElement;g.setSize(h.width,h.height,b)}u!==l&&(l=u,y(b=>({viewport:{...b.viewport,...b.viewport.getCurrentViewport(u)}})))}),t.subscribe(u=>n(u)),t};function nO(){const n=U.useContext(tO);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function br(n=t=>t,e){return nO()(n,e)}function pd(n,e=0){const t=nO(),i=t.getState().internal.subscribe,r=KD(n);return N0(()=>i(r,e,t),[e,i,t]),null}const A6=1,C6=8,R6=32,D6=2;var O6={version:"9.5.0"};function P6(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var tC={exports:{}},nC={exports:{}},iC;function I6(){return iC||(iC=1,(function(n){n.exports=function(e){function t(c,f,v,_){return new pm(c,f,v,_)}function i(){}function r(c){var f="https://react.dev/errors/"+c;if(1ic||(c.current=xh[ic],xh[ic]=null,ic--)}function M(c,f){ic++,xh[ic]=c.current,c.current=f}function A(c){return c>>>=0,c===0?32:31-(_h(c)/ay|0)|0}function w(c){var f=c&42;if(f!==0)return f;switch(c&-c){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 c&261888;case 262144:case 524288:case 1048576:case 2097152:return c&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return c&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return c}}function E(c,f,v){var _=c.pendingLanes;if(_===0)return 0;var C=0,O=c.suspendedLanes,G=c.pingedLanes;c=c.warmLanes;var le=_&134217727;return le!==0?(_=le&~O,_!==0?C=w(_):(G&=le,G!==0?C=w(G):v||(v=le&~c,v!==0&&(C=w(v))))):(le=_&~O,le!==0?C=w(le):G!==0?C=w(G):v||(v=_&~c,v!==0&&(C=w(v)))),C===0?0:f!==0&&f!==C&&(f&O)===0&&(O=C&-C,v=f&-f,O>=v||O===32&&(v&4194048)!==0)?f:C}function R(c,f){return(c.pendingLanes&~(c.suspendedLanes&~c.pingedLanes)&f)===0}function D(c,f){switch(c){case 1:case 2:case 4:case 8:case 64:return f+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 f+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 P(){var c=lu;return lu<<=1,(lu&62914560)===0&&(lu=4194304),c}function F(c){for(var f=[],v=0;31>v;v++)f.push(c);return f}function L(c,f){c.pendingLanes|=f,f!==268435456&&(c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0)}function k(c,f,v,_,C,O){var G=c.pendingLanes;c.pendingLanes=v,c.suspendedLanes=0,c.pingedLanes=0,c.warmLanes=0,c.expiredLanes&=v,c.entangledLanes&=v,c.errorRecoveryDisabledLanes&=v,c.shellSuspendCounter=0;var le=c.entanglements,Ne=c.expirationTimes,qe=c.hiddenUpdates;for(v=G&~v;0)":-1C||Ne[_]!==qe[C]){var ft=` `+Ne[_].replace(" at new "," at ");return c.displayName&&ft.includes("")&&(ft=ft.replace("",c.displayName)),ft}while(1<=_&&0<=C);break}}}finally{Of=!1,Error.prepareStackTrace=v}return(v=c?c.displayName||c.name:"")?re(v):""}function Z(c,f){switch(c.tag){case 26:case 27:case 5:return re(c.type);case 16:return re("Lazy");case 13:return c.child!==f&&f!==null?re("Suspense Fallback"):re("Suspense");case 19:return re("SuspenseList");case 0:case 15:return q(c.type,!1);case 11:return q(c.type.render,!1);case 1:return q(c.type,!0);case 31:return re("Activity");default:return""}}function ne(c){try{var f="",v=null;do f+=Z(c,v),v=c,c=c.return;while(c);return f}catch(_){return` Error generating stack: `+_.message+` `+_.stack}}function pe(c,f){if(typeof c=="object"&&c!==null){var v=eg.get(c);return v!==void 0?v:(f={value:c,source:f,stack:ne(f)},eg.set(c,f),f)}return{value:c,source:f,stack:ne(f)}}function Ee(c,f){_o[Ga++]=Pf,_o[Ga++]=jn,jn=c,Pf=f}function j(c,f,v){$s[_s++]=mr,$s[_s++]=da,$s[_s++]=Xs,Xs=c;var _=mr;c=da;var C=32-Qr(_)-1;_&=~(1<>=G,C-=G,mr=1<<32-Qr(f)+C|v<wn?(fr=Gt,Gt=null):fr=Gt.sibling;var On=Mt(Ae,Gt,Ie[wn],lt);if(On===null){Gt===null&&(Gt=fr);break}c&&Gt&&On.alternate===null&&f(Ae,Gt),ve=O(On,ve,wn),Si===null?kt=On:Si.sibling=On,Si=On,Gt=fr}if(wn===Ie.length)return v(Ae,Gt),bn&&Ee(Ae,wn),kt;if(Gt===null){for(;wnwn?(fr=Gt,Gt=null):fr=Gt.sibling;var Js=Mt(Ae,Gt,On.value,lt);if(Js===null){Gt===null&&(Gt=fr);break}c&&Gt&&Js.alternate===null&&f(Ae,Gt),ve=O(Js,ve,wn),Si===null?kt=Js:Si.sibling=Js,Si=Js,Gt=fr}if(On.done)return v(Ae,Gt),bn&&Ee(Ae,wn),kt;if(Gt===null){for(;!On.done;wn++,On=Ie.next())On=Je(Ae,On.value,lt),On!==null&&(ve=O(On,ve,wn),Si===null?kt=On:Si.sibling=On,Si=On);return bn&&Ee(Ae,wn),kt}for(Gt=_(Gt);!On.done;wn++,On=Ie.next())On=Jt(Gt,Ae,wn,On.value,lt),On!==null&&(c&&On.alternate!==null&&Gt.delete(On.key===null?wn:On.key),ve=O(On,ve,wn),Si===null?kt=On:Si.sibling=On,Si=On);return c&&Gt.forEach(function(eS){return f(Ae,eS)}),bn&&Ee(Ae,wn),kt}function bl(Ae,ve,Ie,lt){if(typeof Ie=="object"&&Ie!==null&&Ie.type===Zl&&Ie.key===null&&(Ie=Ie.props.children),typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case ka:e:{for(var kt=Ie.key;ve!==null;){if(ve.key===kt){if(kt=Ie.type,kt===Zl){if(ve.tag===7){v(Ae,ve.sibling),lt=C(ve,Ie.props.children),lt.return=Ae,Ae=lt;break e}}else if(ve.elementType===kt||typeof kt=="object"&&kt!==null&&kt.$$typeof===Br&&sn(kt)===ve.type){v(Ae,ve.sibling),lt=C(ve,Ie.props),Ho(lt,Ie),lt.return=Ae,Ae=lt;break e}v(Ae,ve);break}else f(Ae,ve);ve=ve.sibling}Ie.type===Zl?(lt=Hs(Ie.props.children,Ae.mode,lt,Ie.key),lt.return=Ae,Ae=lt):(lt=go(Ie.type,Ie.key,Ie.props,null,Ae.mode,lt),Ho(lt,Ie),lt.return=Ae,Ae=lt)}return G(Ae);case Yl:e:{for(kt=Ie.key;ve!==null;){if(ve.key===kt)if(ve.tag===4&&ve.stateNode.containerInfo===Ie.containerInfo&&ve.stateNode.implementation===Ie.implementation){v(Ae,ve.sibling),lt=C(ve,Ie.children||[]),lt.return=Ae,Ae=lt;break e}else{v(Ae,ve);break}else f(Ae,ve);ve=ve.sibling}lt=vm(Ie,Ae.mode,lt),lt.return=Ae,Ae=lt}return G(Ae);case Br:return Ie=sn(Ie),bl(Ae,ve,Ie,lt)}if(sl(Ie))return Ii(Ae,ve,Ie,lt);if(g(Ie)){if(kt=g(Ie),typeof kt!="function")throw Error(r(150));return Ie=kt.call(Ie),vu(Ae,ve,Ie,lt)}if(typeof Ie.then=="function")return bl(Ae,ve,qi(Ie),lt);if(Ie.$$typeof===Vs)return bl(Ae,ve,I(Ae,Ie),lt);Vo(Ae,Ie)}return typeof Ie=="string"&&Ie!==""||typeof Ie=="number"||typeof Ie=="bigint"?(Ie=""+Ie,ve!==null&&ve.tag===6?(v(Ae,ve.sibling),lt=C(ve,Ie),lt.return=Ae,Ae=lt):(v(Ae,ve),lt=mm(Ie,Ae.mode,lt),lt.return=Ae,Ae=lt),G(Ae)):v(Ae,ve)}return function(Ae,ve,Ie,lt){try{ac=0;var kt=bl(Ae,ve,Ie,lt);return fl=null,kt}catch(Gt){if(Gt===tr||Gt===Zs)throw Gt;var Si=t(29,Gt,null,Ae.mode);return Si.lanes=lt,Si.return=Ae,Si}}}function Go(){for(var c=Xa,f=oc=Xa=0;fO?O:8);var G=Bt.T,le={};Bt.T=le,Bd(c,!1,f,v);try{var Ne=C(),qe=Bt.S;if(qe!==null&&qe(le,Ne),Ne!==null&&typeof Ne=="object"&&typeof Ne.then=="function"){var ft=Qe(Ne,_);of(c,f,ft,li(c))}else of(c,f,_,li(c))}catch(Je){of(c,f,{then:function(){},status:"rejected",reason:Je},li())}finally{yn(O),G!==null&&le.types!==null&&(G.types=le.types),Bt.T=G}}function q0(c){var f=c.memoizedState;if(f!==null)return f;f={memoizedState:ec,baseState:ec,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ai,lastRenderedState:ec},next:null};var v={};return f.next={memoizedState:v,baseState:v,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ai,lastRenderedState:v},next:null},c.memoizedState=f,c=c.alternate,c!==null&&(c.memoizedState=f),f}function Yp(){return H(tc)}function zd(){return gt().memoizedState}function Y0(){return gt().memoizedState}function V_(c){for(var f=c.return;f!==null;){switch(f.tag){case 24:case 3:var v=li();c=ps(v);var _=ms(f,c,v);_!==null&&(vi(_,f,v),Wo(_,f,v)),f={cache:ue()},c.payload=f;return}f=f.return}}function G_(c,f,v){var _=li();v={lane:_,revertLane:0,gesture:null,action:v,hasEagerState:!1,eagerState:null,next:null},Fd(c)?K0(f,v):(v=Ul(c,f,v,_),v!==null&&(vi(v,c,_),Q0(v,f,_)))}function Z0(c,f,v){var _=li();of(c,f,v,_)}function of(c,f,v,_){var C={lane:_,revertLane:0,gesture:null,action:v,hasEagerState:!1,eagerState:null,next:null};if(Fd(c))K0(f,C);else{var O=c.alternate;if(c.lanes===0&&(O===null||O.lanes===0)&&(O=f.lastRenderedReducer,O!==null))try{var G=f.lastRenderedState,le=O(G,v);if(C.hasEagerState=!0,C.eagerState=le,Di(le,G))return so(c,f,C,0),fn===null&&Go(),!1}catch{}if(v=Ul(c,f,C,_),v!==null)return vi(v,c,_),Q0(v,f,_),!0}return!1}function Bd(c,f,v,_){if(_={lane:2,revertLane:ye(),gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Fd(c)){if(f)throw Error(r(479))}else f=Ul(c,v,_,2),f!==null&&vi(f,c,2)}function Fd(c){var f=c.alternate;return c===nn||f!==null&&f===nn}function K0(c,f){an=un=!0;var v=c.pending;v===null?f.next=f:(f.next=v.next,v.next=f),c.pending=f}function Q0(c,f,v){if((v&4194048)!==0){var _=f.lanes;_&=c.pendingLanes,v|=_,f.lanes=v,N(c,v)}}function Zp(c,f,v,_){f=c.memoizedState,v=v(_,f),v=v==null?f:sh({},f,v),c.memoizedState=v,c.lanes===0&&(c.updateQueue.baseState=v)}function kd(c,f,v,_,C,O,G){return c=c.stateNode,typeof c.shouldComponentUpdate=="function"?c.shouldComponentUpdate(_,O,G):f.prototype&&f.prototype.isPureReactComponent?!He(v,_)||!He(C,O):!0}function J0(c,f,v,_){c=f.state,typeof f.componentWillReceiveProps=="function"&&f.componentWillReceiveProps(v,_),typeof f.UNSAFE_componentWillReceiveProps=="function"&&f.UNSAFE_componentWillReceiveProps(v,_),f.state!==c&&Lf.enqueueReplaceState(f,f.state,null)}function Hl(c,f){var v=f;if("ref"in f){v={};for(var _ in f)_!=="ref"&&(v[_]=f[_])}if(c=c.defaultProps){v===f&&(v=sh({},v));for(var C in c)v[C]===void 0&&(v[C]=c[C])}return v}function Hd(c,f){try{var v=c.onUncaughtError;v(f.value,{componentStack:f.stack})}catch(_){setTimeout(function(){throw _})}}function Kp(c,f,v){try{var _=c.onCaughtError;_(v.value,{componentStack:v.stack,errorBoundary:f.tag===1?f.stateNode:null})}catch(C){setTimeout(function(){throw C})}}function Qp(c,f,v){return v=ps(v),v.tag=3,v.payload={element:null},v.callback=function(){Hd(c,f)},v}function ev(c){return c=ps(c),c.tag=3,c}function tv(c,f,v,_){var C=v.type.getDerivedStateFromError;if(typeof C=="function"){var O=_.value;c.payload=function(){return C(O)},c.callback=function(){Kp(f,v,_)}}var G=v.stateNode;G!==null&&typeof G.componentDidCatch=="function"&&(c.callback=function(){Kp(f,v,_),typeof C!="function"&&(wo===null?wo=new Set([this]):wo.add(this));var le=_.stack;this.componentDidCatch(_.value,{componentStack:le!==null?le:""})})}function W_(c,f,v,_,C){if(v.flags|=32768,_!==null&&typeof _=="object"&&typeof _.then=="function"){if(f=v.alternate,f!==null&&st(f,v,C,!0),v=es.current,v!==null){switch(v.tag){case 31:case 13:return ts===null?Kc():v.alternate===null&&_i===0&&(_i=3),v.flags&=-257,v.flags|=65536,v.lanes=C,_===$a?v.flags|=16384:(f=v.updateQueue,f===null?v.updateQueue=new Set([_]):f.add(_),eu(c,_,C)),!1;case 22:return v.flags|=65536,_===$a?v.flags|=16384:(f=v.updateQueue,f===null?(f={transitions:null,markerInstances:null,retryQueue:new Set([_])},v.updateQueue=f):(v=f.retryQueue,v===null?f.retryQueue=new Set([_]):v.add(_)),eu(c,_,C)),!1}throw Error(r(435,v.tag))}return eu(c,_,C),Kc(),!1}if(bn)return f=es.current,f!==null?((f.flags&65536)===0&&(f.flags|=256),f.flags|=65536,f.lanes=C,_!==Ch&&(c=Error(r(422),{cause:_}),Pe(pe(c,v)))):(_!==Ch&&(f=Error(r(423),{cause:_}),Pe(pe(f,v))),c=c.current.alternate,c.flags|=65536,C&=-C,c.lanes|=C,_=pe(_,v),C=Qp(c.stateNode,_,C),zl(c,C),_i!==4&&(_i=2)),!1;var O=Error(r(520),{cause:_});if(O=pe(O,v),zf===null?zf=[O]:zf.push(O),_i!==4&&(_i=2),f===null)return!0;_=pe(_,v),v=f;do{switch(v.tag){case 3:return v.flags|=65536,c=C&-C,v.lanes|=c,c=Qp(v.stateNode,_,c),zl(v,c),!1;case 1:if(f=v.type,O=v.stateNode,(v.flags&128)===0&&(typeof f.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(wo===null||!wo.has(O))))return v.flags|=65536,C&=-C,v.lanes|=C,C=ev(C),tv(C,c,v,_),zl(v,C),!1}v=v.return}while(v!==null);return!1}function pr(c,f,v,_){f.child=c===null?ng(f,null,v,_):vr(f,c.child,v,_)}function nv(c,f,v,_,C){v=v.render;var O=f.ref;if("ref"in _){var G={};for(var le in _)le!=="ref"&&(G[le]=_[le])}else G=_;return Te(f),_=wt(c,f,v,G,O,C),le=Rn(),c!==null&&!oi?(Qn(c,f,C),Ra(c,f,C)):(bn&&le&&fe(f),f.flags|=1,pr(c,f,_,C),f.child)}function iv(c,f,v,_,C){if(c===null){var O=v.type;return typeof O=="function"&&!Xl(O)&&O.defaultProps===void 0&&v.compare===null?(f.tag=15,f.type=O,rv(c,f,O,_,C)):(c=go(v.type,null,_,f,f.mode,C),c.ref=f.ref,c.return=f,f.child=c)}if(O=c.child,!cf(c,C)){var G=O.memoizedProps;if(v=v.compare,v=v!==null?v:He,v(G,_)&&c.ref===f.ref)return Ra(c,f,C)}return f.flags|=1,c=bs(O,_),c.ref=f.ref,c.return=f,f.child=c}function rv(c,f,v,_,C){if(c!==null){var O=c.memoizedProps;if(He(O,_)&&c.ref===f.ref)if(oi=!1,f.pendingProps=_=O,cf(c,C))(c.flags&131072)!==0&&(oi=!0);else return f.lanes=c.lanes,Ra(c,f,C)}return Gd(c,f,v,_,C)}function sv(c,f,v,_){var C=_.children,O=c!==null?c.memoizedState:null;if(c===null&&f.stateNode===null&&(f.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),_.mode==="hidden"){if((f.flags&128)!==0){if(O=O!==null?O.baseLanes|v:v,c!==null){for(_=f.child=c.child,C=0;_!==null;)C=C|_.lanes|_.childLanes,_=_.sibling;_=C&~O}else _=0,f.child=null;return Hc(c,f,O,v,_)}if((v&536870912)!==0)f.memoizedState={baseLanes:0,cachePool:null},c!==null&&at(f,O!==null?O.cachePool:null),O!==null?$o(f,O):Aa(),we(f);else return _=f.lanes=536870912,Hc(c,f,O!==null?O.baseLanes|v:v,v,_)}else O!==null?(at(f,O.cachePool),$o(f,O),ge(),f.memoizedState=null):(c!==null&&at(f,null),Aa(),ge());return pr(c,f,C,v),f.child}function Vl(c,f){return c!==null&&c.tag===22||f.stateNode!==null||(f.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),f.sibling}function Hc(c,f,v,_,C){var O=je();return O=O===null?null:{parent:Ci?fi._currentValue:fi._currentValue2,pool:O},f.memoizedState={baseLanes:v,cachePool:O},c!==null&&at(f,null),Aa(),we(f),c!==null&&st(c,f,_,!0),f.childLanes=C,null}function Vd(c,f){return f=qo({mode:f.mode,children:f.children},c.mode),f.ref=c.ref,c.child=f,f.return=c,f}function Jp(c,f,v){return vr(f,c.child,null,v),c=Vd(f,f.pendingProps),c.flags|=2,ot(f),f.memoizedState=null,c}function av(c,f,v){var _=f.pendingProps,C=(f.flags&128)!==0;if(f.flags&=-129,c===null){if(bn){if(_.mode==="hidden")return c=Vd(f,_),f.lanes=536870912,Vl(null,c);if(Oe(f),(c=ui)?(c=km(c,kr),c!==null&&(f.memoizedState={dehydrated:c,treeContext:Xs!==null?{id:mr,overflow:da}:null,retryLane:536870912,hydrationErrors:null},v=gm(c),v.return=f,f.child=v,Ji=f,ui=null)):c=null,c===null)throw Ge(f);return f.lanes=536870912,null}return Vd(f,_)}var O=c.memoizedState;if(O!==null){var G=O.dehydrated;if(Oe(f),C)if(f.flags&256)f.flags&=-257,f=Jp(c,f,v);else if(f.memoizedState!==null)f.child=c.child,f.flags|=128,f=null;else throw Error(r(558));else if(oi||st(c,f,v,!1),C=(v&c.childLanes)!==0,oi||C){if(_=fn,_!==null&&(G=z(_,v),G!==0&&G!==O.retryLane))throw O.retryLane=G,Er(c,G),vi(_,c,G),Vr;Kc(),f=Jp(c,f,v)}else c=O.treeContext,ci&&(ui=Gv(G),Ji=f,bn=!0,Wa=null,kr=!1,c!==null&&Fe(f,c)),f=Vd(f,_),f.flags|=4096;return f}return c=bs(c.child,{mode:_.mode,children:_.children}),c.ref=f.ref,f.child=c,c.return=f,c}function lf(c,f){var v=f.ref;if(v===null)c!==null&&c.ref!==null&&(f.flags|=4194816);else{if(typeof v!="function"&&typeof v!="object")throw Error(r(284));(c===null||c.ref!==v)&&(f.flags|=4194816)}}function Gd(c,f,v,_,C){return Te(f),v=wt(c,f,v,_,void 0,C),_=Rn(),c!==null&&!oi?(Qn(c,f,C),Ra(c,f,C)):(bn&&_&&fe(f),f.flags|=1,pr(c,f,v,C),f.child)}function em(c,f,v,_,C,O){return Te(f),f.updateQueue=null,v=Rt(f,_,v,C),zt(c),_=Rn(),c!==null&&!oi?(Qn(c,f,O),Ra(c,f,O)):(bn&&_&&fe(f),f.flags|=1,pr(c,f,v,O),f.child)}function Gl(c,f,v,_,C){if(Te(f),f.stateNode===null){var O=Ha,G=v.contextType;typeof G=="object"&&G!==null&&(O=H(G)),O=new v(_,O),f.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=Lf,f.stateNode=O,O._reactInternals=f,O=f.stateNode,O.props=_,O.state=f.memoizedState,O.refs={},Yi(f),G=v.contextType,O.context=typeof G=="object"&&G!==null?H(G):Ha,O.state=f.memoizedState,G=v.getDerivedStateFromProps,typeof G=="function"&&(Zp(f,v,G,_),O.state=f.memoizedState),typeof v.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(G=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),G!==O.state&&Lf.enqueueReplaceState(O,O.state,null),ao(f,_,O,C),ca(),O.state=f.memoizedState),typeof O.componentDidMount=="function"&&(f.flags|=4194308),_=!0}else if(c===null){O=f.stateNode;var le=f.memoizedProps,Ne=Hl(v,le);O.props=Ne;var qe=O.context,ft=v.contextType;G=Ha,typeof ft=="object"&&ft!==null&&(G=H(ft));var Je=v.getDerivedStateFromProps;ft=typeof Je=="function"||typeof O.getSnapshotBeforeUpdate=="function",le=f.pendingProps!==le,ft||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(le||qe!==G)&&J0(f,O,_,G),Ss=!1;var Mt=f.memoizedState;O.state=Mt,ao(f,_,O,C),ca(),qe=f.memoizedState,le||Mt!==qe||Ss?(typeof Je=="function"&&(Zp(f,v,Je,_),qe=f.memoizedState),(Ne=Ss||kd(f,v,Ne,_,Mt,qe,G))?(ft||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(f.flags|=4194308)):(typeof O.componentDidMount=="function"&&(f.flags|=4194308),f.memoizedProps=_,f.memoizedState=qe),O.props=_,O.state=qe,O.context=G,_=Ne):(typeof O.componentDidMount=="function"&&(f.flags|=4194308),_=!1)}else{O=f.stateNode,hs(c,f),G=f.memoizedProps,ft=Hl(v,G),O.props=ft,Je=f.pendingProps,Mt=O.context,qe=v.contextType,Ne=Ha,typeof qe=="object"&&qe!==null&&(Ne=H(qe)),le=v.getDerivedStateFromProps,(qe=typeof le=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(G!==Je||Mt!==Ne)&&J0(f,O,_,Ne),Ss=!1,Mt=f.memoizedState,O.state=Mt,ao(f,_,O,C),ca();var Jt=f.memoizedState;G!==Je||Mt!==Jt||Ss||c!==null&&c.dependencies!==null&&Et(c.dependencies)?(typeof le=="function"&&(Zp(f,v,le,_),Jt=f.memoizedState),(ft=Ss||kd(f,v,ft,_,Mt,Jt,Ne)||c!==null&&c.dependencies!==null&&Et(c.dependencies))?(qe||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(_,Jt,Ne),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(_,Jt,Ne)),typeof O.componentDidUpdate=="function"&&(f.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(f.flags|=1024)):(typeof O.componentDidUpdate!="function"||G===c.memoizedProps&&Mt===c.memoizedState||(f.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||G===c.memoizedProps&&Mt===c.memoizedState||(f.flags|=1024),f.memoizedProps=_,f.memoizedState=Jt),O.props=_,O.state=Jt,O.context=Ne,_=ft):(typeof O.componentDidUpdate!="function"||G===c.memoizedProps&&Mt===c.memoizedState||(f.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||G===c.memoizedProps&&Mt===c.memoizedState||(f.flags|=1024),_=!1)}return O=_,lf(c,f),_=(f.flags&128)!==0,O||_?(O=f.stateNode,v=_&&typeof v.getDerivedStateFromError!="function"?null:O.render(),f.flags|=1,c!==null&&_?(f.child=vr(f,c.child,null,C),f.child=vr(f,null,v,C)):pr(c,f,v,C),f.memoizedState=O.state,c=f.child):c=Ra(c,f,C),c}function ov(c,f,v,_){return mt(),f.flags|=256,pr(c,f,v,_),f.child}function tm(c){return{baseLanes:c,cachePool:Ze()}}function nm(c,f,v){return c=c!==null?c.childLanes&~v:0,f&&(c|=Gr),c}function im(c,f,v){var _=f.pendingProps,C=!1,O=(f.flags&128)!==0,G;if((G=O)||(G=c!==null&&c.memoizedState===null?!1:(Ei.current&2)!==0),G&&(C=!0,f.flags&=-129),G=(f.flags&32)!==0,f.flags&=-33,c===null){if(bn){if(C?de(f):ge(),(c=ui)?(c=jv(c,kr),c!==null&&(f.memoizedState={dehydrated:c,treeContext:Xs!==null?{id:mr,overflow:da}:null,retryLane:536870912,hydrationErrors:null},v=gm(c),v.return=f,f.child=v,Ji=f,ui=null)):c=null,c===null)throw Ge(f);return hh(c)?f.lanes=32:f.lanes=536870912,null}var le=_.children;return _=_.fallback,C?(ge(),C=f.mode,le=qo({mode:"hidden",children:le},C),_=Hs(_,C,v,null),le.return=f,_.return=f,le.sibling=_,f.child=le,_=f.child,_.memoizedState=tm(v),_.childLanes=nm(c,G,v),f.memoizedState=cc,Vl(null,_)):(de(f),Wd(f,le))}var Ne=c.memoizedState;if(Ne!==null&&(le=Ne.dehydrated,le!==null)){if(O)f.flags&256?(de(f),f.flags&=-257,f=Wl(c,f,v)):f.memoizedState!==null?(ge(),f.child=c.child,f.flags|=128,f=null):(ge(),le=_.fallback,C=f.mode,_=qo({mode:"visible",children:_.children},C),le=Hs(le,C,v,null),le.flags|=2,_.return=f,le.return=f,_.sibling=le,f.child=_,vr(f,c.child,null,v),_=f.child,_.memoizedState=tm(v),_.childLanes=nm(c,G,v),f.memoizedState=cc,f=Vl(null,_));else if(de(f),hh(le))G=ph(le).digest,_=Error(r(419)),_.stack="",_.digest=G,Pe({value:_,source:null,stack:null}),f=Wl(c,f,v);else if(oi||st(c,f,v,!1),G=(v&c.childLanes)!==0,oi||G){if(G=fn,G!==null&&(_=z(G,v),_!==0&&_!==Ne.retryLane))throw Ne.retryLane=_,Er(c,_),vi(G,c,_),Vr;ol(le)||Kc(),f=Wl(c,f,v)}else ol(le)?(f.flags|=192,f.child=c.child,f=null):(c=Ne.treeContext,ci&&(ui=Wv(le),Ji=f,bn=!0,Wa=null,kr=!1,c!==null&&Fe(f,c)),f=Wd(f,_.children),f.flags|=4096);return f}return C?(ge(),le=_.fallback,C=f.mode,Ne=c.child,O=Ne.sibling,_=bs(Ne,{mode:"hidden",children:_.children}),_.subtreeFlags=Ne.subtreeFlags&65011712,O!==null?le=bs(O,le):(le=Hs(le,C,v,null),le.flags|=2),le.return=f,_.return=f,_.sibling=le,f.child=_,Vl(null,_),_=f.child,le=c.child.memoizedState,le===null?le=tm(v):(C=le.cachePool,C!==null?(Ne=Ci?fi._currentValue:fi._currentValue2,C=C.parent!==Ne?{parent:Ne,pool:Ne}:C):C=Ze(),le={baseLanes:le.baseLanes|v,cachePool:C}),_.memoizedState=le,_.childLanes=nm(c,G,v),f.memoizedState=cc,Vl(c.child,_)):(de(f),v=c.child,c=v.sibling,v=bs(v,{mode:"visible",children:_.children}),v.return=f,v.sibling=null,c!==null&&(G=f.deletions,G===null?(f.deletions=[c],f.flags|=16):G.push(c)),f.child=v,f.memoizedState=null,v)}function Wd(c,f){return f=qo({mode:"visible",children:f},c.mode),f.return=c,c.child=f}function qo(c,f){return c=t(22,c,null,f),c.lanes=0,c}function Wl(c,f,v){return vr(f,c.child,null,v),c=Wd(f,f.pendingProps.children),c.flags|=2,f.memoizedState=null,c}function lv(c,f,v){c.lanes|=f;var _=c.alternate;_!==null&&(_.lanes|=f),Y(c.return,f,v)}function Vc(c,f,v,_,C,O){var G=c.memoizedState;G===null?c.memoizedState={isBackwards:f,rendering:null,renderingStartTime:0,last:_,tail:v,tailMode:C,treeForkCount:O}:(G.isBackwards=f,G.rendering=null,G.renderingStartTime=0,G.last=_,G.tail=v,G.tailMode=C,G.treeForkCount=O)}function rm(c,f,v){var _=f.pendingProps,C=_.revealOrder,O=_.tail;_=_.children;var G=Ei.current,le=(G&2)!==0;if(le?(G=G&1|2,f.flags|=128):G&=1,M(Ei,G),pr(c,f,_,v),_=bn?Pf:0,!le&&c!==null&&(c.flags&128)!==0)e:for(c=f.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&lv(c,v,f);else if(c.tag===19)lv(c,v,f);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===f)break e;for(;c.sibling===null;){if(c.return===null||c.return===f)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}switch(C){case"forwards":for(v=f.child,C=null;v!==null;)c=v.alternate,c!==null&&xt(c)===null&&(C=v),v=v.sibling;v=C,v===null?(C=f.child,f.child=null):(C=v.sibling,v.sibling=null),Vc(f,!1,C,v,O,_);break;case"backwards":case"unstable_legacy-backwards":for(v=null,C=f.child,f.child=null;C!==null;){if(c=C.alternate,c!==null&&xt(c)===null){f.child=C;break}c=C.sibling,C.sibling=v,v=C,C=c}Vc(f,!0,v,null,O,_);break;case"together":Vc(f,!1,null,null,void 0,_);break;default:f.memoizedState=null}return f.child}function Ra(c,f,v){if(c!==null&&(f.dependencies=c.dependencies),To|=f.lanes,(v&f.childLanes)===0)if(c!==null){if(st(c,f,v,!1),(v&f.childLanes)===0)return null}else return null;if(c!==null&&f.child!==c.child)throw Error(r(153));if(f.child!==null){for(c=f.child,v=bs(c,c.pendingProps),f.child=v,v.return=f;c.sibling!==null;)c=c.sibling,v=v.sibling=bs(c,c.pendingProps),v.return=f;v.sibling=null}return f.child}function cf(c,f){return(c.lanes&f)!==0?!0:(c=c.dependencies,!!(c!==null&&Et(c)))}function sm(c,f,v){switch(f.tag){case 3:rt(f,f.stateNode.containerInfo),ze(f,fi,c.memoizedState.cache),mt();break;case 27:case 5:xe(f);break;case 4:rt(f,f.stateNode.containerInfo);break;case 10:ze(f,f.type,f.memoizedProps.value);break;case 31:if(f.memoizedState!==null)return f.flags|=128,Oe(f),null;break;case 13:var _=f.memoizedState;if(_!==null)return _.dehydrated!==null?(de(f),f.flags|=128,null):(v&f.child.childLanes)!==0?im(c,f,v):(de(f),c=Ra(c,f,v),c!==null?c.sibling:null);de(f);break;case 19:var C=(c.flags&128)!==0;if(_=(v&f.childLanes)!==0,_||(st(c,f,v,!1),_=(v&f.childLanes)!==0),C){if(_)return rm(c,f,v);f.flags|=128}if(C=f.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),M(Ei,Ei.current),_)break;return null;case 22:return f.lanes=0,sv(c,f,v,f.pendingProps);case 24:ze(f,fi,c.memoizedState.cache)}return Ra(c,f,v)}function am(c,f,v){if(c!==null)if(c.memoizedProps!==f.pendingProps)oi=!0;else{if(!cf(c,v)&&(f.flags&128)===0)return oi=!1,sm(c,f,v);oi=(c.flags&131072)!==0}else oi=!1,bn&&(f.flags&1048576)!==0&&j(f,Pf,f.index);switch(f.lanes=0,f.tag){case 16:e:{var _=f.pendingProps;if(c=sn(f.elementType),f.type=c,typeof c=="function")Xl(c)?(_=Hl(c,_),f.tag=1,f=Gl(null,f,c,_,v)):(f.tag=0,f=Gd(null,f,c,_,v));else{if(c!=null){var C=c.$$typeof;if(C===tu){f.tag=11,f=nv(null,f,c,_,v);break e}else if(C===oh){f.tag=14,f=iv(null,f,c,_,v);break e}}throw f=y(c)||c,Error(r(306,f,""))}}return f;case 0:return Gd(c,f,f.type,f.pendingProps,v);case 1:return _=f.type,C=Hl(_,f.pendingProps),Gl(c,f,_,C,v);case 3:e:{if(rt(f,f.stateNode.containerInfo),c===null)throw Error(r(387));var O=f.pendingProps;C=f.memoizedState,_=C.element,hs(c,f),ao(f,O,null,v);var G=f.memoizedState;if(O=G.cache,ze(f,fi,O),O!==C.cache&&bt(f,[fi],v,!0),ca(),O=G.element,ci&&C.isDehydrated)if(C={element:O,isDehydrated:!1,cache:G.cache},f.updateQueue.baseState=C,f.memoizedState=C,f.flags&256){f=ov(c,f,O,v);break e}else if(O!==_){_=pe(Error(r(424)),f),Pe(_),f=ov(c,f,O,v);break e}else for(ci&&(ui=Vv(f.stateNode.containerInfo),Ji=f,bn=!0,Wa=null,kr=!0),v=ng(f,null,O,v),f.child=v;v;)v.flags=v.flags&-3|4096,v=v.sibling;else{if(mt(),O===_){f=Ra(c,f,v);break e}pr(c,f,O,v)}f=f.child}return f;case 26:if(Ws)return lf(c,f),c===null?(v=$m(f.type,null,f.pendingProps,null))?f.memoizedState=v:bn||(f.stateNode=yh(f.type,f.pendingProps,gr.current,f)):f.memoizedState=$m(f.type,c.memoizedProps,f.pendingProps,c.memoizedState),null;case 27:if(Qi)return xe(f),c===null&&Qi&&bn&&(_=f.stateNode=bh(f.type,f.pendingProps,gr.current,cr.current,!1),Ji=f,kr=!0,ui=Fm(f.type,_,ui)),pr(c,f,f.pendingProps.children,v),lf(c,f),c===null&&(f.flags|=4194304),f.child;case 5:return c===null&&bn&&(ny(f.type,f.pendingProps,cr.current),(C=_=ui)&&(_=$v(_,f.type,f.pendingProps,kr),_!==null?(f.stateNode=_,Ji=f,ui=Hv(_),kr=!1,C=!0):C=!1),C||Ge(f)),xe(f),C=f.type,O=f.pendingProps,G=c!==null?c.memoizedProps:null,_=O.children,Fr(C,O)?_=null:G!==null&&Fr(C,G)&&(f.flags|=32),f.memoizedState!==null&&(C=wt(c,f,Ht,null,null,v),Ci?tc._currentValue=C:tc._currentValue2=C),lf(c,f),pr(c,f,_,v),f.child;case 6:return c===null&&bn&&(Wm(f.pendingProps,cr.current),(c=v=ui)&&(v=Xv(v,f.pendingProps,kr),v!==null?(f.stateNode=v,Ji=f,ui=null,c=!0):c=!1),c||Ge(f)),null;case 13:return im(c,f,v);case 4:return rt(f,f.stateNode.containerInfo),_=f.pendingProps,c===null?f.child=vr(f,null,_,v):pr(c,f,_,v),f.child;case 11:return nv(c,f,f.type,f.pendingProps,v);case 7:return pr(c,f,f.pendingProps,v),f.child;case 8:return pr(c,f,f.pendingProps.children,v),f.child;case 12:return pr(c,f,f.pendingProps.children,v),f.child;case 10:return _=f.pendingProps,ze(f,f.type,_.value),pr(c,f,_.children,v),f.child;case 9:return C=f.type._context,_=f.pendingProps.children,Te(f),C=H(C),_=_(C),f.flags|=1,pr(c,f,_,v),f.child;case 14:return iv(c,f,f.type,f.pendingProps,v);case 15:return rv(c,f,f.type,f.pendingProps,v);case 19:return rm(c,f,v);case 31:return av(c,f,v);case 22:return sv(c,f,v,f.pendingProps);case 24:return Te(f),_=H(fi),c===null?(C=je(),C===null&&(C=fn,O=ue(),C.pooledCache=O,O.refCount++,O!==null&&(C.pooledCacheLanes|=v),C=O),f.memoizedState={parent:_,cache:C},Yi(f),ze(f,fi,C)):((c.lanes&v)!==0&&(hs(c,f),ao(f,null,null,v),ca()),C=c.memoizedState,O=f.memoizedState,C.parent!==_?(C={parent:_,cache:_},f.memoizedState=C,f.lanes===0&&(f.memoizedState=f.updateQueue.baseState=C),ze(f,fi,_)):(_=O.cache,ze(f,fi,_),_!==C.cache&&bt(f,[fi],v,!0))),pr(c,f,f.pendingProps.children,v),f.child;case 29:throw f.pendingProps}throw Error(r(156,f.tag))}function Us(c){c.flags|=4}function uf(c){xs&&(c.flags|=8)}function cv(c,f){if(c!==null&&c.child===f.child)return!1;if((f.flags&16)!==0)return!0;for(c=f.child;c!==null;){if((c.flags&8218)!==0||(c.subtreeFlags&8218)!==0)return!0;c=c.sibling}return!1}function om(c,f,v,_){if(Sn)for(v=f.child;v!==null;){if(v.tag===5||v.tag===6)Ef(c,v.stateNode);else if(!(v.tag===4||Qi&&v.tag===27)&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===f)break;for(;v.sibling===null;){if(v.return===null||v.return===f)return;v=v.return}v.sibling.return=v.return,v=v.sibling}else if(xs)for(var C=f.child;C!==null;){if(C.tag===5){var O=C.stateNode;v&&_&&(O=zv(O,C.type,C.memoizedProps)),Ef(c,O)}else if(C.tag===6)O=C.stateNode,v&&_&&(O=zm(O,C.memoizedProps)),Ef(c,O);else if(C.tag!==4){if(C.tag===22&&C.memoizedState!==null)O=C.child,O!==null&&(O.return=C),om(c,C,!0,!0);else if(C.child!==null){C.child.return=C,C=C.child;continue}}if(C===f)break;for(;C.sibling===null;){if(C.return===null||C.return===f)return;C=C.return}C.sibling.return=C.return,C=C.sibling}}function uv(c,f,v,_){var C=!1;if(xs)for(var O=f.child;O!==null;){if(O.tag===5){var G=O.stateNode;v&&_&&(G=zv(G,O.type,O.memoizedProps)),Lm(c,G)}else if(O.tag===6)G=O.stateNode,v&&_&&(G=zm(G,O.memoizedProps)),Lm(c,G);else if(O.tag!==4){if(O.tag===22&&O.memoizedState!==null)C=O.child,C!==null&&(C.return=O),uv(c,O,!0,!0),C=!0;else if(O.child!==null){O.child.return=O,O=O.child;continue}}if(O===f)break;for(;O.sibling===null;){if(O.return===null||O.return===f)return C;O=O.return}O.sibling.return=O.return,O=O.sibling}return C}function fv(c,f){if(xs&&cv(c,f)){c=f.stateNode;var v=c.containerInfo,_=Nm();uv(_,f,!1,!1),c.pendingChildren=_,Us(f),Uv(v,_)}}function lm(c,f,v,_){if(Sn)c.memoizedProps!==_&&Us(f);else if(xs){var C=c.stateNode,O=c.memoizedProps;if((c=cv(c,f))||O!==_){var G=cr.current;O=Lv(C,v,O,_,!c,null),O===C?f.stateNode=C:(uf(f),Zr(O,v,_,G)&&Us(f),f.stateNode=O,c&&om(O,f,!1,!1))}else f.stateNode=C}}function Ur(c,f,v,_,C){if((c.mode&32)!==0&&(v===null?Tf(f,_):au(f,v,_))){if(c.flags|=16777216,(C&335544128)===C||Mm(f,_))if(yi(c.stateNode,f,_))c.flags|=8192;else if(_n())c.flags|=8192;else throw Hr=$a,Dh}else c.flags&=-16777217}function Gc(c,f){if(Ym(f)){if(c.flags|=16777216,!Zm(f))if(_n())c.flags|=8192;else throw Hr=$a,Dh}else c.flags&=-16777217}function ff(c,f){f!==null&&(c.flags|=4),c.flags&16384&&(f=c.tag!==22?P():536870912,c.lanes|=f,mu|=f)}function Wc(c,f){if(!bn)switch(c.tailMode){case"hidden":f=c.tail;for(var v=null;f!==null;)f.alternate!==null&&(v=f),f=f.sibling;v===null?c.tail=null:v.sibling=null;break;case"collapsed":v=c.tail;for(var _=null;v!==null;)v.alternate!==null&&(_=v),v=v.sibling;_===null?f||c.tail===null?c.tail=null:c.tail.sibling=null:_.sibling=null}}function Jn(c){var f=c.alternate!==null&&c.alternate.child===c.child,v=0,_=0;if(f)for(var C=c.child;C!==null;)v|=C.lanes|C.childLanes,_|=C.subtreeFlags&65011712,_|=C.flags&65011712,C.return=c,C=C.sibling;else for(C=c.child;C!==null;)v|=C.lanes|C.childLanes,_|=C.subtreeFlags,_|=C.flags,C.return=c,C=C.sibling;return c.subtreeFlags|=_,c.childLanes=v,f}function dv(c,f,v){var _=f.pendingProps;switch(be(f),f.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Jn(f),null;case 1:return Jn(f),null;case 3:return v=f.stateNode,_=null,c!==null&&(_=c.memoizedState.cache),f.memoizedState.cache!==_&&(f.flags|=2048),Xe(fi),he(),v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),(c===null||c.child===null)&&(St(f)?Us(f):c===null||c.memoizedState.isDehydrated&&(f.flags&256)===0||(f.flags|=1024,Ce())),fv(c,f),Jn(f),null;case 26:if(Ws){var C=f.type,O=f.memoizedState;return c===null?(Us(f),O!==null?(Jn(f),Gc(f,O)):(Jn(f),Ur(f,C,null,_,v))):O?O!==c.memoizedState?(Us(f),Jn(f),Gc(f,O)):(Jn(f),f.flags&=-16777217):(O=c.memoizedProps,Sn?O!==_&&Us(f):lm(c,f,C,_),Jn(f),Ur(f,C,O,_,v)),null}case 27:if(Qi){if(ke(f),v=gr.current,C=f.type,c!==null&&f.stateNode!=null)Sn?c.memoizedProps!==_&&Us(f):lm(c,f,C,_);else{if(!_){if(f.stateNode===null)throw Error(r(166));return Jn(f),null}c=cr.current,St(f)?ct(f,c):(c=bh(C,_,v,c,!0),f.stateNode=c,Us(f))}return Jn(f),null}case 5:if(ke(f),C=f.type,c!==null&&f.stateNode!=null)lm(c,f,C,_);else{if(!_){if(f.stateNode===null)throw Error(r(166));return Jn(f),null}if(O=cr.current,St(f))ct(f,O),Jv(f.stateNode,C,_,O)&&(f.flags|=64);else{var G=_m(C,_,gr.current,O,f);uf(f),om(G,f,!1,!1),f.stateNode=G,Zr(G,C,_,O)&&Us(f)}}return Jn(f),Ur(f,f.type,c===null?null:c.memoizedProps,f.pendingProps,v),null;case 6:if(c&&f.stateNode!=null)v=c.memoizedProps,Sn?v!==_&&Us(f):xs&&(v!==_?(c=gr.current,v=cr.current,uf(f),f.stateNode=bo(_,c,v,f)):f.stateNode=c.stateNode);else{if(typeof _!="string"&&f.stateNode===null)throw Error(r(166));if(c=gr.current,v=cr.current,St(f)){if(!ci)throw Error(r(176));if(c=f.stateNode,v=f.memoizedProps,_=null,C=Ji,C!==null)switch(C.tag){case 27:case 5:_=C.memoizedProps}Y_(c,v,f,_)||Ge(f,!0)}else uf(f),f.stateNode=bo(_,c,v,f)}return Jn(f),null;case 31:if(v=f.memoizedState,c===null||c.memoizedState!==null){if(_=St(f),v!==null){if(c===null){if(!_)throw Error(r(318));if(!ci)throw Error(r(556));if(c=f.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(r(557));Hm(c,f)}else mt(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;Jn(f),c=!1}else v=Ce(),c!==null&&c.memoizedState!==null&&(c.memoizedState.hydrationErrors=v),c=!0;if(!c)return f.flags&256?(ot(f),f):(ot(f),null);if((f.flags&128)!==0)throw Error(r(558))}return Jn(f),null;case 13:if(_=f.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(C=St(f),_!==null&&_.dehydrated!==null){if(c===null){if(!C)throw Error(r(318));if(!ci)throw Error(r(344));if(C=f.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(r(317));Yv(C,f)}else mt(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;Jn(f),C=!1}else C=Ce(),c!==null&&c.memoizedState!==null&&(c.memoizedState.hydrationErrors=C),C=!0;if(!C)return f.flags&256?(ot(f),f):(ot(f),null)}return ot(f),(f.flags&128)!==0?(f.lanes=v,f):(v=_!==null,c=c!==null&&c.memoizedState!==null,v&&(_=f.child,C=null,_.alternate!==null&&_.alternate.memoizedState!==null&&_.alternate.memoizedState.cachePool!==null&&(C=_.alternate.memoizedState.cachePool.pool),O=null,_.memoizedState!==null&&_.memoizedState.cachePool!==null&&(O=_.memoizedState.cachePool.pool),O!==C&&(_.flags|=2048)),v!==c&&v&&(f.child.flags|=8192),ff(f,f.updateQueue),Jn(f),null);case 4:return he(),fv(c,f),c===null&&Xn(f.stateNode.containerInfo),Jn(f),null;case 10:return Xe(f.type),Jn(f),null;case 19:if(x(Ei),_=f.memoizedState,_===null)return Jn(f),null;if(C=(f.flags&128)!==0,O=_.rendering,O===null)if(C)Wc(_,!1);else{if(_i!==0||c!==null&&(c.flags&128)!==0)for(c=f.child;c!==null;){if(O=xt(c),O!==null){for(f.flags|=128,Wc(_,!1),c=O.updateQueue,f.updateQueue=c,ff(f,c),f.subtreeFlags=0,c=v,v=f.child;v!==null;)nh(v,c),v=v.sibling;return M(Ei,Ei.current&1|2),bn&&Ee(f,_.treeForkCount),f.child}c=c.sibling}_.tail!==null&&wr()>yl&&(f.flags|=128,C=!0,Wc(_,!1),f.lanes=4194304)}else{if(!C)if(c=xt(O),c!==null){if(f.flags|=128,C=!0,c=c.updateQueue,f.updateQueue=c,ff(f,c),Wc(_,!0),_.tail===null&&_.tailMode==="hidden"&&!O.alternate&&!bn)return Jn(f),null}else 2*wr()-_.renderingStartTime>yl&&v!==536870912&&(f.flags|=128,C=!0,Wc(_,!1),f.lanes=4194304);_.isBackwards?(O.sibling=f.child,f.child=O):(c=_.last,c!==null?c.sibling=O:f.child=O,_.last=O)}return _.tail!==null?(c=_.tail,_.rendering=c,_.tail=c.sibling,_.renderingStartTime=wr(),c.sibling=null,v=Ei.current,M(Ei,C?v&1|2:v&1),bn&&Ee(f,_.treeForkCount),c):(Jn(f),null);case 22:case 23:return ot(f),W(),_=f.memoizedState!==null,c!==null?c.memoizedState!==null!==_&&(f.flags|=8192):_&&(f.flags|=8192),_?(v&536870912)!==0&&(f.flags&128)===0&&(Jn(f),f.subtreeFlags&6&&(f.flags|=8192)):Jn(f),v=f.updateQueue,v!==null&&ff(f,v.retryQueue),v=null,c!==null&&c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(v=c.memoizedState.cachePool.pool),_=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(_=f.memoizedState.cachePool.pool),_!==v&&(f.flags|=2048),c!==null&&x(ul),null;case 24:return v=null,c!==null&&(v=c.memoizedState.cache),f.memoizedState.cache!==v&&(f.flags|=2048),Xe(fi),Jn(f),null;case 25:return null;case 30:return null}throw Error(r(156,f.tag))}function cm(c,f){switch(be(f),f.tag){case 1:return c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 3:return Xe(fi),he(),c=f.flags,(c&65536)!==0&&(c&128)===0?(f.flags=c&-65537|128,f):null;case 26:case 27:case 5:return ke(f),null;case 31:if(f.memoizedState!==null){if(ot(f),f.alternate===null)throw Error(r(340));mt()}return c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 13:if(ot(f),c=f.memoizedState,c!==null&&c.dehydrated!==null){if(f.alternate===null)throw Error(r(340));mt()}return c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 19:return x(Ei),null;case 4:return he(),null;case 10:return Xe(f.type),null;case 22:case 23:return ot(f),W(),c!==null&&x(ul),c=f.flags,c&65536?(f.flags=c&-65537|128,f):null;case 24:return Xe(fi),null;case 25:return null;default:return null}}function hv(c,f){switch(be(f),f.tag){case 3:Xe(fi),he();break;case 26:case 27:case 5:ke(f);break;case 4:he();break;case 31:f.memoizedState!==null&&ot(f);break;case 13:ot(f);break;case 19:x(Ei);break;case 10:Xe(f.type);break;case 22:case 23:ot(f),W(),c!==null&&x(ul);break;case 24:Xe(fi)}}function Da(c,f){try{var v=f.updateQueue,_=v!==null?v.lastEffect:null;if(_!==null){var C=_.next;v=C;do{if((v.tag&c)===c){_=void 0;var O=v.create,G=v.inst;_=O(),G.destroy=_}v=v.next}while(v!==C)}}catch(le){qt(f,f.return,le)}}function Oa(c,f,v){try{var _=f.updateQueue,C=_!==null?_.lastEffect:null;if(C!==null){var O=C.next;_=O;do{if((_.tag&c)===c){var G=_.inst,le=G.destroy;if(le!==void 0){G.destroy=void 0,C=f;var Ne=v,qe=le;try{qe()}catch(ft){qt(C,Ne,ft)}}}_=_.next}while(_!==O)}}catch(ft){qt(f,f.return,ft)}}function $c(c){var f=c.updateQueue;if(f!==null){var v=c.stateNode;try{lo(f,v)}catch(_){qt(c,c.return,_)}}}function $d(c,f,v){v.props=Hl(c.type,c.memoizedProps),v.state=c.memoizedState;try{v.componentWillUnmount()}catch(_){qt(c,f,_)}}function Xc(c,f){try{var v=c.ref;if(v!==null){switch(c.tag){case 26:case 27:case 5:var _=iu(c.stateNode);break;case 30:_=c.stateNode;break;default:_=c.stateNode}typeof v=="function"?c.refCleanup=v(_):v.current=_}}catch(C){qt(c,f,C)}}function Tr(c,f){var v=c.ref,_=c.refCleanup;if(v!==null)if(typeof _=="function")try{_()}catch(C){qt(c,f,C)}finally{c.refCleanup=null,c=c.alternate,c!=null&&(c.refCleanup=null)}else if(typeof v=="function")try{v(null)}catch(C){qt(c,f,C)}else v.current=null}function $l(c){var f=c.type,v=c.memoizedProps,_=c.stateNode;try{Av(_,f,v,c)}catch(C){qt(c,c.return,C)}}function df(c,f,v){try{Cv(c.stateNode,c.type,v,f,c)}catch(_){qt(c,c.return,_)}}function um(c){return c.tag===5||c.tag===3||(Ws?c.tag===26:!1)||(Qi?c.tag===27&&nc(c.type):!1)||c.tag===4}function uo(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||um(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&c.tag!==18;){if(Qi&&c.tag===27&&nc(c.type)||c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function Xd(c,f,v){var _=c.tag;if(_===5||_===6)c=c.stateNode,f?Dv(v,c,f):Dm(v,c);else if(_!==4&&(Qi&&_===27&&nc(c.type)&&(v=c.stateNode,f=null),c=c.child,c!==null))for(Xd(c,f,v),c=c.sibling;c!==null;)Xd(c,f,v),c=c.sibling}function hf(c,f,v){var _=c.tag;if(_===5||_===6)c=c.stateNode,f?Rv(v,c,f):Rm(v,c);else if(_!==4&&(Qi&&_===27&&nc(c.type)&&(v=c.stateNode),c=c.child,c!==null))for(hf(c,f,v),c=c.sibling;c!==null;)hf(c,f,v),c=c.sibling}function fm(c,f,v){c=c.containerInfo;try{Um(c,v)}catch(_){qt(f,f.return,_)}}function pv(c){var f=c.stateNode,v=c.memoizedProps;try{Hi(c.type,v,f,c)}catch(_){qt(c,c.return,_)}}function $_(c,f){for(lh(c.containerInfo),Oi=f;Oi!==null;)if(c=Oi,f=c.child,(c.subtreeFlags&1028)!==0&&f!==null)f.return=c,Oi=f;else for(;Oi!==null;){c=Oi;var v=c.alternate;switch(f=c.flags,c.tag){case 0:if((f&4)!==0&&(f=c.updateQueue,f=f!==null?f.events:null,f!==null))for(var _=0;_";case du:return":has("+(Yc(c)||"")+")";case hu:return'[role="'+c.value+'"]';case pl:return'"'+c.value+'"';case Uf:return'[data-testname="'+c.value+'"]';default:throw Error(r(365))}}function Zc(c,f){var v=[];c=[c,0];for(var _=0;_v?32:v;v=Bt.T;var C=Gs();try{yn(_),Bt.T=null,_=Ih,Ih=null;var O=Ao,G=Ya;if(Gi=0,dc=Ao=null,Ya=0,(mn&6)!==0)throw Error(r(331));var le=mn;if(mn|=4,Zd(O.current),qd(O,O.current,G,_),mn=le,Ye(0,!1),Jr&&typeof Jr.onPostCommitFiberRoot=="function")try{Jr.onPostCommitFiberRoot(sc,O)}catch{}return!0}finally{yn(C),Bt.T=v,th(c,f)}}function nl(c,f,v){f=pe(v,f),f=Qp(c.stateNode,f,2),c=ms(c,f,2),c!==null&&(L(c,2),nt(c))}function qt(c,f,v){if(c.tag===3)nl(c,c,v);else for(;f!==null;){if(f.tag===3){nl(f,c,v);break}else if(f.tag===1){var _=f.stateNode;if(typeof f.type.getDerivedStateFromError=="function"||typeof _.componentDidCatch=="function"&&(wo===null||!wo.has(_))){c=pe(v,c),v=ev(2),_=ms(f,v,2),_!==null&&(tv(v,_,f,c),L(_,2),nt(_));break}}f=f.return}}function eu(c,f,v){var _=c.pingCache;if(_===null){_=c.pingCache=new Ts;var C=new Set;_.set(f,C)}else C=_.get(f),C===void 0&&(C=new Set,_.set(f,C));C.has(v)||(gl=!0,C.add(v),c=bv.bind(null,c,f,v),f.then(c,c))}function bv(c,f,v){var _=c.pingCache;_!==null&&_.delete(f),c.pingedLanes|=c.suspendedLanes&v,c.warmLanes&=~v,fn===c&&(xn&v)===v&&(_i===4||_i===3&&(xn&62914560)===xn&&300>wr()-Bf?(mn&2)===0&&Mi(c,0):pu|=v,mu===xn&&(mu=0)),nt(c)}function xv(c,f){f===0&&(f=P()),c=Er(c,f),c!==null&&(L(c,f),nt(c))}function X_(c){var f=c.memoizedState,v=0;f!==null&&(v=f.retryLane),xv(c,v)}function j_(c,f){var v=0;switch(c.tag){case 31:case 13:var _=c.stateNode,C=c.memoizedState;C!==null&&(v=C.retryLane);break;case 19:_=c.stateNode;break;case 22:_=c.stateNode._retryCache;break;default:throw Error(r(314))}_!==null&&_.delete(f),xv(c,v)}function ki(c,f){return Rf(c,f)}function pm(c,f,v,_){this.tag=c,this.key=v,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=f,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=_,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xl(c){return c=c.prototype,!(!c||!c.isReactComponent)}function bs(c,f){var v=c.alternate;return v===null?(v=t(c.tag,f,c.key,c.mode),v.elementType=c.elementType,v.type=c.type,v.stateNode=c.stateNode,v.alternate=c,c.alternate=v):(v.pendingProps=f,v.type=c.type,v.flags=0,v.subtreeFlags=0,v.deletions=null),v.flags=c.flags&65011712,v.childLanes=c.childLanes,v.lanes=c.lanes,v.child=c.child,v.memoizedProps=c.memoizedProps,v.memoizedState=c.memoizedState,v.updateQueue=c.updateQueue,f=c.dependencies,v.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext},v.sibling=c.sibling,v.index=c.index,v.ref=c.ref,v.refCleanup=c.refCleanup,v}function nh(c,f){c.flags&=65011714;var v=c.alternate;return v===null?(c.childLanes=0,c.lanes=f,c.child=null,c.subtreeFlags=0,c.memoizedProps=null,c.memoizedState=null,c.updateQueue=null,c.dependencies=null,c.stateNode=null):(c.childLanes=v.childLanes,c.lanes=v.lanes,c.child=v.child,c.subtreeFlags=0,c.deletions=null,c.memoizedProps=v.memoizedProps,c.memoizedState=v.memoizedState,c.updateQueue=v.updateQueue,c.type=v.type,f=v.dependencies,c.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext}),c}function go(c,f,v,_,C,O){var G=0;if(_=c,typeof c=="function")Xl(c)&&(G=1);else if(typeof c=="string")G=Ws&&Qi?vh(c,v,cr.current)?26:Km(c)?27:5:Ws?vh(c,v,cr.current)?26:5:Qi&&Km(c)?27:5;else e:switch(c){case Sf:return c=t(31,v,f,C),c.elementType=Sf,c.lanes=O,c;case Zl:return Hs(v.children,C,O,f);case Kl:G=8,C|=24;break;case Ql:return c=t(12,v,f,C|2),c.elementType=Ql,c.lanes=O,c;case ah:return c=t(13,v,f,C),c.elementType=ah,c.lanes=O,c;case vo:return c=t(19,v,f,C),c.elementType=vo,c.lanes=O,c;default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case Vs:G=10;break e;case _f:G=9;break e;case tu:G=11;break e;case oh:G=14;break e;case Br:G=16,_=null;break e}G=29,v=Error(r(130,c===null?"null":typeof c,"")),_=null}return f=t(G,v,f,C),f.elementType=c,f.type=_,f.lanes=O,f}function Hs(c,f,v,_){return c=t(7,c,_,f),c.lanes=v,c}function mm(c,f,v){return c=t(6,c,null,f),c.lanes=v,c}function gm(c){var f=t(18,null,null,0);return f.stateNode=c,f}function vm(c,f,v){return f=t(4,c.children!==null?c.children:[],c.key,f),f.lanes=v,f.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},f}function _v(c,f,v,_,C,O,G,le,Ne){this.tag=1,this.containerInfo=c,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=Kr,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=F(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=F(0),this.hiddenUpdates=F(null),this.identifierPrefix=_,this.onUncaughtError=C,this.onCaughtError=O,this.onRecoverableError=G,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ne,this.incompleteTransitions=new Map}function il(c,f,v,_,C,O,G,le,Ne,qe,ft,Je){return c=new _v(c,f,v,G,Ne,qe,ft,Je,le),f=1,O===!0&&(f|=24),O=t(3,null,null,f),c.current=O,O.stateNode=c,f=ue(),f.refCount++,c.pooledCache=f,f.refCount++,O.memoizedState={element:_,isDehydrated:v,cache:f},Yi(O),c}function ih(c){return c?(c=Ha,c):Ha}function bf(c){var f=c._reactInternals;if(f===void 0)throw typeof c.render=="function"?Error(r(188)):(c=Object.keys(c).join(","),Error(r(268,c)));return c=u(f),c=c!==null?h(c):null,c===null?null:iu(c.stateNode)}function ym(c,f,v,_,C,O){C=ih(C),_.context===null?_.context=C:_.pendingContext=C,_=ps(f),_.payload={element:v},O=O===void 0?null:O,O!==null&&(_.callback=O),v=ms(c,_,f),v!==null&&(vi(v,c,f),Wo(v,c,f))}function jl(c,f){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var v=c.retryLane;c.retryLane=v!==0&&v=qe&&O>=Je&&C<=ft&&G<=Mt){c.splice(f,1);break}else if(_!==qe||v.width!==Ne.width||MtG){if(!(O!==Je||v.height!==Ne.height||ft<_||qe>C)){qe>_&&(Ne.width+=qe-_,Ne.x=_),ftO&&(Ne.height+=Je-O,Ne.y=O),Mtv&&(v=le)),le ")+` No matching component was found for: `)+c.join(" > ")}return null},cn.getPublicRootInstance=function(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 27:case 5:return iu(c.child.stateNode);default:return c.child.stateNode}},cn.injectIntoDevTools=function(){var c={bundleType:0,version:xm,rendererPackageName:Mf,currentDispatcherRef:Bt,reconcilerVersion:"19.2.0"};if(nu!==null&&(c.rendererConfig=nu),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")c=!1;else{var f=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(f.isDisabled||!f.supportsFiber)c=!0;else{try{sc=f.inject(c),Jr=f}catch{}c=!!f.checkDCE}}return c},cn.isAlreadyRendering=function(){return(mn&6)!==0},cn.observeVisibleRects=function(c,f,v,_){if(!Ki)throw Error(r(363));c=qr(c,f);var C=dh(c,v,_).disconnect;return{disconnect:function(){C()}}},cn.shouldError=function(){return null},cn.shouldSuspend=function(){return!1},cn.startHostTransition=function(c,f,v,_){if(c.tag!==5)throw Error(r(476));var C=q0(c).queue;j0(c,C,f,ec,v===null?i:function(){var O=q0(c);return O.next===null&&(O=c.alternate.memoizedState),of(c,O.next.queue,{},li()),v(_)})},cn.updateContainer=function(c,f,v,_){var C=f.current,O=li();return ym(C,O,c,f,v,_),O},cn.updateContainerSync=function(c,f,v,_){return ym(f.current,2,c,f,v,_),2},cn},n.exports.default=n.exports,Object.defineProperty(n.exports,"__esModule",{value:!0})})(nC)),nC.exports}var rC;function N6(){return rC||(rC=1,tC.exports=I6()),tC.exports}var L6=N6();const U6=P6(L6);function z6(n){const e=U6(n);return e.injectIntoDevTools(),e}const iO=0,Dp={},B6=/^three(?=[A-Z])/,D_=n=>`${n[0].toUpperCase()}${n.slice(1)}`;let F6=0;const k6=n=>typeof n=="function";function rO(n){if(k6(n)){const e=`${F6++}`;return Dp[e]=n,e}else Object.assign(Dp,n)}function sO(n,e){const t=D_(n),i=Dp[t];if(n!=="primitive"&&!i)throw new Error(`R3F: ${t} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(n==="primitive"&&!e.object)throw new Error("R3F: Primitives without 'object' are invalid!");if(e.args!==void 0&&!Array.isArray(e.args))throw new Error("R3F: The args prop must be an array!")}function H6(n,e,t){var i;return n=D_(n)in Dp?n:n.replace(B6,""),sO(n,e),n==="primitive"&&(i=e.object)!=null&&i.__r3f&&delete e.object.__r3f,Ax(e.object,t,n,e)}function V6(n){if(!n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Rx(n.parent,n):ra(n.object)&&(n.object.visible=!1),n.isHidden=!0,zp(n)}}function aO(n){if(n.isHidden){var e;n.props.attach&&(e=n.parent)!=null&&e.object?Cx(n.parent,n):ra(n.object)&&n.props.visible!==!1&&(n.object.visible=!0),n.isHidden=!1,zp(n)}}function KE(n,e,t){const i=e.root.getState();if(!(!n.parent&&n.object!==i.scene)){if(!e.object){var r,a;const l=Dp[D_(e.type)];e.object=(r=e.props.object)!=null?r:new l(...(a=e.props.args)!=null?a:[]),e.object.__r3f=e}if(Nu(e.object,e.props),e.props.attach)Cx(n,e);else if(ra(e.object)&&ra(n.object)){const l=n.object.children.indexOf(t?.object);if(t&&l!==-1){const u=n.object.children.indexOf(e.object);if(u!==-1){n.object.children.splice(u,1);const h=u{try{n.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<"u"?e():SM.unstable_scheduleCallback(SM.unstable_IdlePriority,e)}}function EM(n,e,t){if(!e)return;e.parent=null;const i=n.children.indexOf(e);i!==-1&&n.children.splice(i,1),e.props.attach?Rx(n,e):ra(e.object)&&ra(n.object)&&(n.object.remove(e.object),E6(YD(e),e.object));const r=e.props.dispose!==null&&t!==!1;for(let a=e.children.length-1;a>=0;a--){const l=e.children[a];EM(e,l,r)}e.children.length=0,delete e.object.__r3f,r&&e.type!=="primitive"&&e.object.type!=="Scene"&&oO(e.object),t===void 0&&zp(e)}function G6(n,e){for(const t of[n,n.alternate])if(t!==null)if(typeof t.ref=="function"){t.refCleanup==null||t.refCleanup();const i=t.ref(e);typeof i=="function"&&(t.refCleanup=i)}else t.ref&&(t.ref.current=e)}const Pb=[];function W6(){for(const[t]of Pb){const i=t.parent;if(i){t.props.attach?Rx(i,t):ra(t.object)&&ra(i.object)&&i.object.remove(t.object);for(const r of t.children)r.props.attach?Rx(t,r):ra(r.object)&&ra(t.object)&&t.object.remove(r.object)}t.isHidden&&aO(t),t.object.__r3f&&delete t.object.__r3f,t.type!=="primitive"&&oO(t.object)}for(const[t,i,r]of Pb){t.props=i;const a=t.parent;if(a){var n,e;const l=Dp[D_(t.type)];t.object=(n=t.props.object)!=null?n:new l(...(e=t.props.args)!=null?e:[]),t.object.__r3f=t,G6(r,t.object),Nu(t.object,t.props),t.props.attach?Cx(a,t):ra(t.object)&&ra(a.object)&&a.object.add(t.object);for(const u of t.children)u.props.attach?Cx(t,u):ra(u.object)&&ra(t.object)&&t.object.add(u.object);zp(t)}}Pb.length=0}const S1=()=>{},aC={};let yb=iO;const $6=0,X6=4,TM=z6({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:H6,removeChild:EM,appendChild:_1,appendInitialChild:_1,insertBefore:sC,appendChildToContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||_1(t,e)},removeChildFromContainer(n,e){const t=n.getState().scene.__r3f;!e||!t||EM(t,e)},insertInContainerBefore(n,e,t){const i=n.getState().scene.__r3f;!e||!t||!i||sC(i,e,t)},getRootHostContext:()=>aC,getChildHostContext:()=>aC,commitUpdate(n,e,t,i,r){var a,l,u;sO(e,i);let h=!1;if((n.type==="primitive"&&t.object!==i.object||((a=i.args)==null?void 0:a.length)!==((l=t.args)==null?void 0:l.length)||(u=i.args)!=null&&u.some((g,y)=>{var b;return g!==((b=t.args)==null?void 0:b[y])}))&&(h=!0),h)Pb.push([n,{...i},r]);else{const g=x6(n,i);Object.keys(g).length&&(Object.assign(n.props,g),Nu(n.object,g))}(r.sibling===null||(r.flags&X6)===$6)&&W6()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:n=>n?.object,prepareForCommit:()=>null,preparePortalMount:n=>Ax(n.getState().scene,n,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:V6,unhideInstance:aO,createTextInstance:S1,hideTextInstance:S1,unhideTextInstance:S1,scheduleTimeout:typeof setTimeout=="function"?setTimeout:void 0,cancelTimeout:typeof clearTimeout=="function"?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:U.createContext(null),setCurrentUpdatePriority(n){yb=n},getCurrentUpdatePriority(){return yb},resolveUpdatePriority(){var n;if(yb!==iO)return yb;switch(typeof window<"u"&&((n=window.event)==null?void 0:n.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return D6;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return C6;default:return R6}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:O6.version,applyViewTransitionName(n,e,t){},restoreViewTransitionName(n,e){},cancelViewTransitionName(n,e,t){},cancelRootViewTransitionName(n){},restoreRootViewTransitionName(n){},InstanceMeasurement:null,measureInstance:n=>null,wasInstanceInViewport:n=>!0,hasInstanceChanged:(n,e)=>!1,hasInstanceAffectedParent:(n,e)=>!1,suspendOnActiveViewTransition(n,e){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(n){},createViewTransitionInstance:n=>null,getCurrentGestureOffset(n){throw new Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance(n,e){return n},cloneMutableTextInstance(n){return n},cloneRootViewTransitionContainer(n){throw new Error("Not implemented.")},removeRootViewTransitionClone(n,e){throw new Error("Not implemented.")},createFragmentInstance:n=>null,updateFragmentInstanceFiber(n,e){},commitNewChildToFragmentInstance(n,e){},deleteChildFromFragmentInstance(n,e){},measureClonedInstance:n=>null,maySuspendCommitOnUpdate:(n,e,t)=>!1,maySuspendCommitInSyncRender:(n,e)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(n,e)=>null}),Sd=new Map,ap={objects:"shallow",strict:!1};function j6(n,e){if(!e&&typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&n.parentElement){const{width:t,height:i,top:r,left:a}=n.parentElement.getBoundingClientRect();return{width:t,height:i,top:r,left:a}}else if(!e&&typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height,top:0,left:0};return{width:0,height:0,top:0,left:0,...e}}function q6(n){const e=Sd.get(n),t=e?.fiber,i=e?.store;e&&console.warn("R3F.createRoot should only be called once!");const r=typeof reportError=="function"?reportError:console.error,a=i||w6(CM,lC),l=t||TM.createContainer(a,A6,null,!1,null,"",r,r,r,null);e||Sd.set(n,{fiber:l,store:a});let u,h,p=!1,g=null;return{async configure(y={}){let b;g=new Promise(j=>b=j);let{gl:x,size:M,scene:A,events:w,onCreated:E,shadows:R=!1,linear:D=!1,flat:P=!1,legacy:F=!1,orthographic:L=!1,frameloop:k="always",dpr:V=[1,2],performance:N,raycaster:z,camera:X,onPointerMissed:Q}=y,J=a.getState(),oe=J.gl;if(!J.gl){const j={canvas:n,powerPreference:"high-performance",antialias:!0,alpha:!0},fe=typeof x=="function"?await x(j):x;eC(fe)?oe=fe:oe=new $D({...j,...x}),J.set({gl:oe})}let re=J.raycaster;re||J.set({raycaster:re=new zD});const{params:q,...Z}=z||{};if(Li.equ(Z,re,ap)||Nu(re,{...Z}),Li.equ(q,re.params,ap)||Nu(re,{params:{...re.params,...q}}),!J.camera||J.camera===h&&!Li.equ(h,X,ap)){h=X;const j=X?.isCamera,fe=j?X:L?new Lo(0,0,0,0,.1,1e3):new $i(75,0,.1,1e3);j||(fe.position.z=5,X&&(Nu(fe,X),fe.manual||("aspect"in X||"left"in X||"right"in X||"bottom"in X||"top"in X)&&(fe.manual=!0,fe.updateProjectionMatrix())),!J.camera&&!(X!=null&&X.rotation)&&fe.lookAt(0,0,0)),J.set({camera:fe}),re.camera=fe}if(!J.scene){let j;A!=null&&A.isScene?(j=A,Ax(j,a,"",{})):(j=new zu,Ax(j,a,"",{}),A&&Nu(j,A)),J.set({scene:j})}w&&!J.events.handlers&&J.set({events:w(a)});const ne=j6(n,M);if(Li.equ(ne,J.size,ap)||J.setSize(ne.width,ne.height,ne.top,ne.left),V&&J.viewport.dpr!==QD(V)&&J.setDpr(V),J.frameloop!==k&&J.setFrameloop(k),J.onPointerMissed||J.set({onPointerMissed:Q}),N&&!Li.equ(N,J.performance,ap)&&J.set(j=>({performance:{...j.performance,...N}})),!J.xr){var pe;const j=(Fe,rt)=>{const he=a.getState();he.frameloop!=="never"&&lC(Fe,!0,he,rt)},fe=()=>{const Fe=a.getState();Fe.gl.xr.enabled=Fe.gl.xr.isPresenting,Fe.gl.xr.setAnimationLoop(Fe.gl.xr.isPresenting?j:null),Fe.gl.xr.isPresenting||CM(Fe)},be={connect(){const Fe=a.getState().gl;Fe.xr.addEventListener("sessionstart",fe),Fe.xr.addEventListener("sessionend",fe)},disconnect(){const Fe=a.getState().gl;Fe.xr.removeEventListener("sessionstart",fe),Fe.xr.removeEventListener("sessionend",fe)}};typeof((pe=oe.xr)==null?void 0:pe.addEventListener)=="function"&&be.connect(),J.set({xr:be})}if(oe.shadowMap){const j=oe.shadowMap.enabled,fe=oe.shadowMap.type;if(oe.shadowMap.enabled=!!R,Li.boo(R))oe.shadowMap.type=kg;else if(Li.str(R)){var Ee;const be={basic:u3,percentage:vp,soft:kg,variance:ad};oe.shadowMap.type=(Ee=be[R])!=null?Ee:kg}else Li.obj(R)&&Object.assign(oe.shadowMap,R);(j!==oe.shadowMap.enabled||fe!==oe.shadowMap.type)&&(oe.shadowMap.needsUpdate=!0)}return Cn.enabled=!F,p||(oe.outputColorSpace=D?Dl:Fn,oe.toneMapping=P?xa:Yx),J.legacy!==F&&J.set(()=>({legacy:F})),J.linear!==D&&J.set(()=>({linear:D})),J.flat!==P&&J.set(()=>({flat:P})),x&&!Li.fun(x)&&!eC(x)&&!Li.equ(x,oe,ap)&&Nu(oe,x),u=E,p=!0,b(),this},render(y){return!p&&!g&&this.configure(),g.then(()=>{TM.updateContainer(ut.jsx(Y6,{store:a,children:y,onCreated:u,rootElement:n}),l,null,()=>{})}),a},unmount(){lO(n)}}}function Y6({store:n,children:e,onCreated:t,rootElement:i}){return N0(()=>{const r=n.getState();r.set(a=>({internal:{...a.internal,active:!0}})),t&&t(r),n.getState().events.connected||r.events.connect==null||r.events.connect(i)},[]),ut.jsx(tO.Provider,{value:n,children:e})}function lO(n,e){const t=Sd.get(n),i=t?.fiber;if(i){const r=t?.store.getState();r&&(r.internal.active=!1),TM.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{var a,l,u,h;r.events.disconnect==null||r.events.disconnect(),(a=r.gl)==null||(l=a.renderLists)==null||l.dispose==null||l.dispose(),(u=r.gl)==null||u.forceContextLoss==null||u.forceContextLoss(),(h=r.gl)!=null&&h.xr&&r.xr.disconnect(),v6(r.scene),Sd.delete(n)}catch{}},500)})}}function cO(n,e){const t={callback:n};return e.add(t),()=>{e.delete(t)}}const uO=new Set,fO=new Set,Z6=new Set,K6=n=>cO(n,uO),Q6=n=>cO(n,fO);function M1(n,e){if(n.size)for(const{callback:t}of n.values())t(e)}function Yg(n,e){switch(n){case"before":return M1(uO,e);case"after":return M1(fO,e);case"tail":return M1(Z6,e)}}let E1,T1;function wM(n,e,t){let i=e.clock.getDelta();e.frameloop==="never"&&typeof n=="number"&&(i=n-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=n),E1=e.internal.subscribers;for(let r=0;r0)&&!((e=op.gl.xr)!=null&&e.isPresenting)&&(w1+=wM(n,op))}if(AM=!1,Yg("after",n),w1===0)return Yg("tail",n),Dx=!1,cancelAnimationFrame(oC)}function CM(n,e=1){var t;if(!n)return Sd.forEach(i=>CM(i.store.getState(),e));(t=n.gl.xr)!=null&&t.isPresenting||!n.internal.active||n.frameloop==="never"||(e>1?n.internal.frames=Math.min(60,n.internal.frames+e):AM?n.internal.frames=2:n.internal.frames=1,Dx||(Dx=!0,requestAnimationFrame(dO)))}function lC(n,e=!0,t,i){if(e&&Yg("before",n),t)wM(n,t,i);else for(const r of Sd.values())wM(n,r.store.getState());e&&Yg("after",n)}const A1={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function J6(n){const{handlePointer:e}=T6(n);return{priority:1,enabled:!0,compute(t,i,r){i.pointer.set(t.offsetX/i.size.width*2-1,-(t.offsetY/i.size.height)*2+1),i.raycaster.setFromCamera(i.pointer,i.camera)},connected:void 0,handlers:Object.keys(A1).reduce((t,i)=>({...t,[i]:e(i)}),{}),update:()=>{var t;const{events:i,internal:r}=n.getState();(t=r.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(r.lastEvent.current)},connect:t=>{const{set:i,events:r}=n.getState();if(r.disconnect==null||r.disconnect(),i(a=>({events:{...a.events,connected:t}})),r.handlers)for(const a in r.handlers){const l=r.handlers[a],[u,h]=A1[a];t.addEventListener(u,l,{passive:h})}},disconnect:()=>{const{set:t,events:i}=n.getState();if(i.connected){if(i.handlers)for(const r in i.handlers){const a=i.handlers[r],[l]=A1[r];i.connected.removeEventListener(l,a)}t(r=>({events:{...r.events,connected:void 0}}))}}}}function cC(n,e){let t;return(...i)=>{window.clearTimeout(t),t=window.setTimeout(()=>n(...i),e)}}function e2({debounce:n,scroll:e,polyfill:t,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const r=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!r)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[a,l]=U.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),u=U.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:a,orientationHandler:null}),h=n?typeof n=="number"?n:n.scroll:null,p=n?typeof n=="number"?n:n.resize:null,g=U.useRef(!1);U.useEffect(()=>(g.current=!0,()=>{g.current=!1}));const[y,b,x]=U.useMemo(()=>{const E=()=>{if(!u.current.element)return;const{left:R,top:D,width:P,height:F,bottom:L,right:k,x:V,y:N}=u.current.element.getBoundingClientRect(),z={left:R,top:D,width:P,height:F,bottom:L,right:k,x:V,y:N};u.current.element instanceof HTMLElement&&i&&(z.height=u.current.element.offsetHeight,z.width=u.current.element.offsetWidth),Object.freeze(z),g.current&&!r2(u.current.lastBounds,z)&&l(u.current.lastBounds=z)};return[E,p?cC(E,p):E,h?cC(E,h):E]},[l,i,h,p]);function M(){u.current.scrollContainers&&(u.current.scrollContainers.forEach(E=>E.removeEventListener("scroll",x,!0)),u.current.scrollContainers=null),u.current.resizeObserver&&(u.current.resizeObserver.disconnect(),u.current.resizeObserver=null),u.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",u.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",u.current.orientationHandler))}function A(){u.current.element&&(u.current.resizeObserver=new r(x),u.current.resizeObserver.observe(u.current.element),e&&u.current.scrollContainers&&u.current.scrollContainers.forEach(E=>E.addEventListener("scroll",x,{capture:!0,passive:!0})),u.current.orientationHandler=()=>{x()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",u.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",u.current.orientationHandler))}const w=E=>{!E||E===u.current.element||(M(),u.current.element=E,u.current.scrollContainers=hO(E),A())};return n2(x,!!e),t2(b),U.useEffect(()=>{M(),A()},[e,x,b]),U.useEffect(()=>M,[]),[w,a,y]}function t2(n){U.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[n])}function n2(n,e){U.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",t,!0)}}},[n,e])}function hO(n){const e=[];if(!n||n===document.body)return e;const{overflow:t,overflowX:i,overflowY:r}=window.getComputedStyle(n);return[t,i,r].some(a=>a==="auto"||a==="scroll")&&e.push(n),[...e,...hO(n.parentElement)]}const i2=["x","y","top","bottom","left","right","width","height"],r2=(n,e)=>i2.every(t=>n[t]===e[t]);function s2({ref:n,children:e,fallback:t,resize:i,style:r,gl:a,events:l=J6,eventSource:u,eventPrefix:h,shadows:p,linear:g,flat:y,legacy:b,orthographic:x,frameloop:M,dpr:A,performance:w,raycaster:E,camera:R,scene:D,onPointerMissed:P,onCreated:F,...L}){U.useMemo(()=>rO(Yk),[]);const k=p6(),[V,N]=e2({scroll:!0,debounce:{scroll:50,resize:0},...i}),z=U.useRef(null),X=U.useRef(null);U.useImperativeHandle(n,()=>z.current);const Q=KD(P),[J,oe]=U.useState(!1),[re,q]=U.useState(!1);if(J)throw J;if(re)throw re;const Z=U.useRef(null);N0(()=>{const pe=z.current;if(N.width>0&&N.height>0&&pe){Z.current||(Z.current=q6(pe));async function Ee(){await Z.current.configure({gl:a,scene:D,events:l,shadows:p,linear:g,flat:y,legacy:b,orthographic:x,frameloop:M,dpr:A,performance:w,raycaster:E,camera:R,size:N,onPointerMissed:(...j)=>Q.current==null?void 0:Q.current(...j),onCreated:j=>{j.events.connect==null||j.events.connect(u?d6(u)?u.current:u:X.current),h&&j.setEvents({compute:(fe,be)=>{const Fe=fe[h+"X"],rt=fe[h+"Y"];be.pointer.set(Fe/be.size.width*2-1,-(rt/be.size.height)*2+1),be.raycaster.setFromCamera(be.pointer,be.camera)}}),F?.(j)}}),Z.current.render(ut.jsx(k,{children:ut.jsx(g6,{set:q,children:ut.jsx(U.Suspense,{fallback:ut.jsx(m6,{set:oe}),children:e??null})})}))}Ee()}}),U.useEffect(()=>{const pe=z.current;if(pe)return()=>lO(pe)},[]);const ne=u?"none":"auto";return ut.jsx("div",{ref:X,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:ne,...r},...L,children:ut.jsx("div",{ref:V,style:{width:"100%",height:"100%"},children:ut.jsx("canvas",{ref:z,style:{display:"block"},children:t})})})}function a2(n){return ut.jsx(jD,{children:ut.jsx(s2,{...n})})}function Ox(){return Ox=Object.assign?Object.assign.bind():function(n){for(var e=1;et?+uC(n-t,t-e,i)+t:n}function l2(n,[e,t],[i,r]){const[[a,l],[u,h]]=n;return[fC(e,a,l,i),fC(t,u,h,r)]}function c2(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function u2(n){var e=c2(n,"string");return typeof e=="symbol"?e:String(e)}function ia(n,e,t){return e=u2(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function dC(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function zi(n){for(var e=1;e{var t,i;return e.target===n.currentTarget||((t=n.currentTarget)===null||t===void 0||(i=t.contains)===null||i===void 0?void 0:i.call(t,e.target))})}function y2(n){return n.type==="touchend"||n.type==="touchcancel"?n.changedTouches:n.targetTouches}function gO(n){return O_(n)?y2(n)[0]:n}function b2(n){return v2(n).map(e=>e.identifier)}function C1(n){const e=gO(n);return O_(n)?e.identifier:e.pointerId}function pC(n){const e=gO(n);return[e.clientX,e.clientY]}function x2(n){const e={};if("buttons"in n&&(e.buttons=n.buttons),"shiftKey"in n){const{shiftKey:t,altKey:i,metaKey:r,ctrlKey:a}=n;Object.assign(e,{shiftKey:t,altKey:i,metaKey:r,ctrlKey:a})}return e}function Px(n,...e){return typeof n=="function"?n(...e):n}function _2(){}function S2(...n){return n.length===0?_2:n.length===1?n[0]:function(){let e;for(const t of n)e=t.apply(this,arguments)||e;return e}}function mC(n,e){return Object.assign({},e,n||{})}const M2=32;class E2{constructor(e,t,i){this.ctrl=e,this.args=t,this.key=i,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:i,args:r}=this;t[i]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=r,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,i=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=i.from?Px(i.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:i,shared:r}=this;t.args=this.args;let a=0;if(e&&(t.event=e,i.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,r.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,r.locked=!!document.pointerLockElement,Object.assign(r,x2(e)),r.down=r.pressed=r.buttons%2===1||r.touches>0,a=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const L=t._delta.map(Math.abs);os.addTo(t._distance,L)}this.axisIntent&&this.axisIntent(e);const[l,u]=t._movement,[h,p]=i.threshold,{_step:g,values:y}=t;if(i.hasCustomTransform?(g[0]===!1&&(g[0]=Math.abs(l)>=h&&y[0]),g[1]===!1&&(g[1]=Math.abs(u)>=p&&y[1])):(g[0]===!1&&(g[0]=Math.abs(l)>=h&&Math.sign(l)*h),g[1]===!1&&(g[1]=Math.abs(u)>=p&&Math.sign(u)*p)),t.intentional=g[0]!==!1||g[1]!==!1,!t.intentional)return;const b=[0,0];if(i.hasCustomTransform){const[L,k]=y;b[0]=g[0]!==!1?L-g[0]:0,b[1]=g[1]!==!1?k-g[1]:0}else b[0]=g[0]!==!1?l-g[0]:0,b[1]=g[1]!==!1?u-g[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(b);const x=t.offset,M=t._active&&!t._blocked||t.active;M&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=r[this.ingKey]=t._active,e&&(t.first&&("bounds"in i&&(t._bounds=Px(i.bounds,t)),this.setup&&this.setup()),t.movement=b,this.computeOffset()));const[A,w]=t.offset,[[E,R],[D,P]]=t._bounds;t.overflow=[AR?1:0,wP?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const F=t._active?i.rubberband||[0,0]:[0,0];if(t.offset=l2(t._bounds,t.offset,F),t.delta=os.sub(t.offset,x),this.computeMovement(),M&&(!t.last||a>M2)){t.delta=os.sub(t.offset,x);const L=t.delta.map(Math.abs);os.addTo(t.distance,L),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&a>0&&(t.velocity=[L[0]/a,L[1]/a],t.timeDelta=a)}}emit(){const e=this.state,t=this.shared,i=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!i.triggerAllEvents)return;const r=this.handler(zi(zi(zi({},t),e),{},{[this.aliasKey]:e.values}));r!==void 0&&(e.memo=r)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function T2([n,e],t){const i=Math.abs(n),r=Math.abs(e);if(i>r&&i>t)return"x";if(r>i&&r>t)return"y"}class w2 extends E2{constructor(...e){super(...e),ia(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=os.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=os.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,i=this.config;if(!t.axis&&e){const r=typeof i.axisThreshold=="object"?i.axisThreshold[mO(e)]:i.axisThreshold;t.axis=T2(t._movement,r)}t._blocked=(i.lockDirection||!!i.axis)&&!t.axis||!!i.axis&&i.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const A2=n=>n,gC=.15,vO={enabled(n=!0){return n},eventOptions(n,e,t){return zi(zi({},t.shared.eventOptions),n)},preventDefault(n=!1){return n},triggerAllEvents(n=!1){return n},rubberband(n=0){switch(n){case!0:return[gC,gC];case!1:return[0,0];default:return os.toVector(n)}},from(n){if(typeof n=="function")return n;if(n!=null)return os.toVector(n)},transform(n,e,t){const i=n||t.shared.transform;return this.hasCustomTransform=!!i,i||A2},threshold(n){return os.toVector(n,0)}},C2=0,L0=zi(zi({},vO),{},{axis(n,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(n=C2){return n},bounds(n={}){if(typeof n=="function")return a=>L0.bounds(n(a));if("current"in n)return()=>n.current;if(typeof HTMLElement=="function"&&n instanceof HTMLElement)return n;const{left:e=-1/0,right:t=1/0,top:i=-1/0,bottom:r=1/0}=n;return[[e,t],[i,r]]}}),vC={ArrowRight:(n,e=1)=>[n*e,0],ArrowLeft:(n,e=1)=>[-1*n*e,0],ArrowUp:(n,e=1)=>[0,-1*n*e],ArrowDown:(n,e=1)=>[0,n*e]};class R2 extends w2{constructor(...e){super(...e),ia(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),i=e.currentTarget.getBoundingClientRect(),r={left:t.left-i.left+e.offset[0],right:t.right-i.right+e.offset[0],top:t.top-i.top+e.offset[1],bottom:t.bottom-i.bottom+e.offset[1]};e._bounds=L0.bounds(r)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,i=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const r=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(r&&r.size>1&&i._pointerActive)&&(this.start(e),this.setupPointer(e),i._pointerId=C1(e),i._pointerActive=!0,this.computeValues(pC(e)),this.computeInitial(),t.preventScrollAxis&&mO(e)!=="mouse"?(i._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,i=this.config;if(!t._pointerActive)return;const r=C1(e);if(t._pointerId!==void 0&&r!==t._pointerId)return;const a=pC(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=os.sub(a,t._values),this.computeValues(a)),os.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(i.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===i.preventScrollAxis||i.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{}const t=this.state,i=this.config;if(!t._active||!t._pointerActive)return;const r=C1(e);if(t._pointerId!==void 0&&r!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[a,l]=t._distance;if(t.tap=a<=i.tapsThreshold&&l<=i.tapsThreshold,t.tap&&i.filterTaps)t._force=!0;else{const[u,h]=t._delta,[p,g]=t._movement,[y,b]=i.swipe.velocity,[x,M]=i.swipe.distance,A=i.swipe.duration;if(t.elapsedTimey&&Math.abs(p)>x&&(t.swipe[0]=Math.sign(u)),E>b&&Math.abs(g)>M&&(t.swipe[1]=Math.sign(h))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,i=t.device;t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,i,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,i,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,i,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,D2(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=vC[e.key];if(t){const i=this.state,r=e.shiftKey?10:e.altKey?.1:1;this.start(e),i._delta=t(this.config.keyboardDisplacement,r),i._keyboardActive=!0,os.addTo(i._movement,i._delta),this.compute(e),this.emit()}}keyUp(e){e.key in vC&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function D2(n){"persist"in n&&typeof n.persist=="function"&&n.persist()}const U0=typeof window<"u"&&window.document&&window.document.createElement;function yO(){return U0&&"ontouchstart"in window}function O2(){return yO()||U0&&window.navigator.maxTouchPoints>1}function P2(){return U0&&"onpointerdown"in window}function I2(){return U0&&"exitPointerLock"in window.document}function N2(){try{return"constructor"in GestureEvent}catch{return!1}}const eo={isBrowser:U0,gesture:N2(),touch:yO(),touchscreen:O2(),pointer:P2(),pointerLock:I2()},L2=250,U2=180,z2=.5,B2=50,F2=250,k2=10,yC={mouse:0,touch:0,pen:8},H2=zi(zi({},L0),{},{device(n,e,{pointer:{touch:t=!1,lock:i=!1,mouse:r=!1}={}}){return this.pointerLock=i&&eo.pointerLock,eo.touch&&t?"touch":this.pointerLock?"mouse":eo.pointer&&!r?"pointer":eo.touch?"touch":"mouse"},preventScrollAxis(n,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&n?L2:void 0,!(!eo.touchscreen||t===!1))return n||(t!==void 0?"y":void 0)},pointerCapture(n,e,{pointer:{capture:t=!0,buttons:i=1,keys:r=!0}={}}){return this.pointerButtons=i,this.keys=r,!this.pointerLock&&this.device==="pointer"&&t},threshold(n,e,{filterTaps:t=!1,tapsThreshold:i=3,axis:r=void 0}){const a=os.toVector(n,t?i:r?1:0);return this.filterTaps=t,this.tapsThreshold=i,a},swipe({velocity:n=z2,distance:e=B2,duration:t=F2}={}){return{velocity:this.transform(os.toVector(n)),distance:this.transform(os.toVector(e)),duration:t}},delay(n=0){switch(n){case!0:return U2;case!1:return 0;default:return n}},axisThreshold(n){return n?zi(zi({},yC),n):yC},keyboardDisplacement(n=k2){return n}});zi(zi({},vO),{},{device(n,e,{shared:t,pointer:{touch:i=!1}={}}){if(t.target&&!eo.touch&&eo.gesture)return"gesture";if(eo.touch&&i)return"touch";if(eo.touchscreen){if(eo.pointer)return"pointer";if(eo.touch)return"touch"}},bounds(n,e,{scaleBounds:t={},angleBounds:i={}}){const r=l=>{const u=mC(Px(t,l),{min:-1/0,max:1/0});return[u.min,u.max]},a=l=>{const u=mC(Px(i,l),{min:-1/0,max:1/0});return[u.min,u.max]};return typeof t!="function"&&typeof i!="function"?[r(),a()]:l=>[r(l),a(l)]},threshold(n,e,t){return this.lockDirection=t.axis==="lock",os.toVector(n,this.lockDirection?[.1,3]:0)},modifierKey(n){return n===void 0?"ctrlKey":n},pinchOnWheel(n=!0){return n}});zi(zi({},L0),{},{mouseOnly:(n=!0)=>n});zi(zi({},L0),{},{mouseOnly:(n=!0)=>n});const bO=new Map,RM=new Map;function V2(n){bO.set(n.key,n.engine),RM.set(n.key,n.resolver)}const G2={key:"drag",engine:R2,resolver:H2};function W2(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,a;for(a=0;a=0)&&(t[r]=n[r]);return t}function $2(n,e){if(n==null)return{};var t=W2(n,e),i,r;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}const X2={target(n){if(n)return()=>"current"in n?n.current:n},enabled(n=!0){return n},window(n=eo.isBrowser?window:void 0){return n},eventOptions({passive:n=!0,capture:e=!1}={}){return{passive:n,capture:e}},transform(n){return n}},j2=["target","eventOptions","window","enabled","transform"];function Ib(n={},e){const t={};for(const[i,r]of Object.entries(e))switch(typeof r){case"function":t[i]=r.call(t,n[i],i,n);break;case"object":t[i]=Ib(n[i],r);break;case"boolean":r&&(t[i]=n[i]);break}return t}function q2(n,e,t={}){const i=n,{target:r,eventOptions:a,window:l,enabled:u,transform:h}=i,p=$2(i,j2);if(t.shared=Ib({target:r,eventOptions:a,window:l,enabled:u,transform:h},X2),e){const g=RM.get(e);t[e]=Ib(zi({shared:t.shared},p),g)}else for(const g in p){const y=RM.get(g);y&&(t[g]=Ib(zi({shared:t.shared},p[g]),y))}return t}class xO{constructor(e,t){ia(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,i,r,a){const l=this._listeners,u=g2(t,i),h=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=zi(zi({},h),a);e.addEventListener(u,r,p);const g=()=>{e.removeEventListener(u,r,p),l.delete(g)};return l.add(g),g}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Y2{constructor(){ia(this,"_timeouts",new Map)}add(e,t,i=140,...r){this.remove(e),this._timeouts.set(e,window.setTimeout(t,i,...r))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>{window.clearTimeout(e)}),this._timeouts.clear()}}class Z2{constructor(e){ia(this,"gestures",new Set),ia(this,"_targetEventStore",new xO(this)),ia(this,"gestureEventStores",{}),ia(this,"gestureTimeoutStores",{}),ia(this,"handlers",{}),ia(this,"config",{}),ia(this,"pointerIds",new Set),ia(this,"touchIds",new Set),ia(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),K2(this,e)}setEventIds(e){if(O_(e))return this.touchIds=new Set(b2(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=q2(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,i={};let r;if(!(t.target&&(r=t.target(),!r))){if(t.enabled){for(const l of this.gestures){const u=this.config[l],h=bC(i,u.eventOptions,!!r);if(u.enabled){const p=bO.get(l);new p(this,e,l).bind(h)}}const a=bC(i,t.eventOptions,!!r);for(const l in this.nativeHandlers)a(l,"",u=>this.nativeHandlers[l](zi(zi({},this.state.shared),{},{event:u,args:e})),void 0,!0)}for(const a in i)i[a]=S2(...i[a]);if(!r)return i;for(const a in i){const{device:l,capture:u,passive:h}=m2(a);this._targetEventStore.add(r,l,"",i[a],{capture:u,passive:h})}}}}function lp(n,e){n.gestures.add(e),n.gestureEventStores[e]=new xO(n,e),n.gestureTimeoutStores[e]=new Y2}function K2(n,e){e.drag&&lp(n,"drag"),e.wheel&&lp(n,"wheel"),e.scroll&&lp(n,"scroll"),e.move&&lp(n,"move"),e.pinch&&lp(n,"pinch"),e.hover&&lp(n,"hover")}const bC=(n,e,t)=>(i,r,a,l={},u=!1)=>{var h,p;const g=(h=l.capture)!==null&&h!==void 0?h:e.capture,y=(p=l.passive)!==null&&p!==void 0?p:e.passive;let b=u?i:h2(i,r,g);t&&y&&(b+="Passive"),n[b]=n[b]||[],n[b].push(a)};function Q2(n,e={},t,i){const r=se.useMemo(()=>new Z2(n),[]);if(r.applyHandlers(n,i),r.applyConfig(e,t),se.useEffect(r.effect.bind(r)),se.useEffect(()=>r.clean.bind(r),[]),e.target===void 0)return r.bind.bind(r)}function J2(n,e){return V2(G2),Q2({drag:n},e||{},"drag")}var eH=Object.defineProperty,tH=(n,e,t)=>e in n?eH(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,nH=(n,e,t)=>(tH(n,e+"",t),t);class iH{constructor(){nH(this,"_listeners")}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let a=0,l=r.length;ae in n?rH(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Wt=(n,e,t)=>(sH(n,typeof e!="symbol"?e+"":e,t),t);const bb=new wd,xC=new _c,aH=Math.cos(70*(Math.PI/180)),_C=(n,e)=>(n%e+e)%e;let oH=class extends iH{constructor(e,t){super(),Wt(this,"object"),Wt(this,"domElement"),Wt(this,"enabled",!0),Wt(this,"target",new K),Wt(this,"minDistance",0),Wt(this,"maxDistance",1/0),Wt(this,"minZoom",0),Wt(this,"maxZoom",1/0),Wt(this,"minPolarAngle",0),Wt(this,"maxPolarAngle",Math.PI),Wt(this,"minAzimuthAngle",-1/0),Wt(this,"maxAzimuthAngle",1/0),Wt(this,"enableDamping",!1),Wt(this,"dampingFactor",.05),Wt(this,"enableZoom",!0),Wt(this,"zoomSpeed",1),Wt(this,"enableRotate",!0),Wt(this,"rotateSpeed",1),Wt(this,"enablePan",!0),Wt(this,"panSpeed",1),Wt(this,"screenSpacePanning",!0),Wt(this,"keyPanSpeed",7),Wt(this,"zoomToCursor",!1),Wt(this,"autoRotate",!1),Wt(this,"autoRotateSpeed",2),Wt(this,"reverseOrbit",!1),Wt(this,"reverseHorizontalOrbit",!1),Wt(this,"reverseVerticalOrbit",!1),Wt(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Wt(this,"mouseButtons",{LEFT:nd.ROTATE,MIDDLE:nd.DOLLY,RIGHT:nd.PAN}),Wt(this,"touches",{ONE:id.ROTATE,TWO:id.DOLLY_PAN}),Wt(this,"target0"),Wt(this,"position0"),Wt(this,"zoom0"),Wt(this,"_domElementKeyEvents",null),Wt(this,"getPolarAngle"),Wt(this,"getAzimuthalAngle"),Wt(this,"setPolarAngle"),Wt(this,"setAzimuthalAngle"),Wt(this,"getDistance"),Wt(this,"getZoomScale"),Wt(this,"listenToKeyEvents"),Wt(this,"stopListenToKeyEvents"),Wt(this,"saveState"),Wt(this,"reset"),Wt(this,"update"),Wt(this,"connect"),Wt(this,"dispose"),Wt(this,"dollyIn"),Wt(this,"dollyOut"),Wt(this,"getScale"),Wt(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>g.phi,this.getAzimuthalAngle=()=>g.theta,this.setPolarAngle=te=>{let ye=_C(te,2*Math.PI),it=g.phi;it<0&&(it+=2*Math.PI),ye<0&&(ye+=2*Math.PI);let ie=Math.abs(ye-it);2*Math.PI-ie{let ye=_C(te,2*Math.PI),it=g.theta;it<0&&(it+=2*Math.PI),ye<0&&(ye+=2*Math.PI);let ie=Math.abs(ye-it);2*Math.PI-iei.object.position.distanceTo(i.target),this.listenToKeyEvents=te=>{te.addEventListener("keydown",_e),this._domElementKeyEvents=te},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",_e),this._domElementKeyEvents=null},this.saveState=()=>{i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=()=>{i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(r),i.update(),h=u.NONE},this.update=(()=>{const te=new K,ye=new K(0,1,0),it=new cs().setFromUnitVectors(e.up,ye),ie=it.clone().invert(),Qe=new K,je=new cs,at=2*Math.PI;return function(){const He=i.object.position;it.setFromUnitVectors(e.up,ye),ie.copy(it).invert(),te.copy(He).sub(i.target),te.applyQuaternion(it),g.setFromVector3(te),i.autoRotate&&h===u.NONE&&oe(Q()),i.enableDamping?(g.theta+=y.theta*i.dampingFactor,g.phi+=y.phi*i.dampingFactor):(g.theta+=y.theta,g.phi+=y.phi);let tt=i.minAzimuthAngle,Nt=i.maxAzimuthAngle;isFinite(tt)&&isFinite(Nt)&&(tt<-Math.PI?tt+=at:tt>Math.PI&&(tt-=at),Nt<-Math.PI?Nt+=at:Nt>Math.PI&&(Nt-=at),tt<=Nt?g.theta=Math.max(tt,Math.min(Nt,g.theta)):g.theta=g.theta>(tt+Nt)/2?Math.max(tt,g.theta):Math.min(Nt,g.theta)),g.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,g.phi)),g.makeSafe(),i.enableDamping===!0?i.target.addScaledVector(x,i.dampingFactor):i.target.add(x),i.zoomToCursor&&N||i.object.isOrthographicCamera?g.radius=be(g.radius):g.radius=be(g.radius*b),te.setFromSpherical(g),te.applyQuaternion(ie),He.copy(i.target).add(te),i.object.matrixAutoUpdate||i.object.updateMatrix(),i.object.lookAt(i.target),i.enableDamping===!0?(y.theta*=1-i.dampingFactor,y.phi*=1-i.dampingFactor,x.multiplyScalar(1-i.dampingFactor)):(y.set(0,0,0),x.set(0,0,0));let sn=!1;if(i.zoomToCursor&&N){let ln=null;if(i.object instanceof $i&&i.object.isPerspectiveCamera){const pi=te.length();ln=be(pi*b);const qi=pi-ln;i.object.position.addScaledVector(k,qi),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){const pi=new K(V.x,V.y,0);pi.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/b)),i.object.updateProjectionMatrix(),sn=!0;const qi=new K(V.x,V.y,0);qi.unproject(i.object),i.object.position.sub(qi).add(pi),i.object.updateMatrixWorld(),ln=te.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;ln!==null&&(i.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(ln).add(i.object.position):(bb.origin.copy(i.object.position),bb.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(bb.direction))p||8*(1-je.dot(i.object.quaternion))>p?(i.dispatchEvent(r),Qe.copy(i.object.position),je.copy(i.object.quaternion),sn=!1,!0):!1}})(),this.connect=te=>{i.domElement=te,i.domElement.style.touchAction="none",i.domElement.addEventListener("contextmenu",dt),i.domElement.addEventListener("pointerdown",Te),i.domElement.addEventListener("pointercancel",I),i.domElement.addEventListener("wheel",De)},this.dispose=()=>{var te,ye,it,ie,Qe,je;i.domElement&&(i.domElement.style.touchAction="auto"),(te=i.domElement)==null||te.removeEventListener("contextmenu",dt),(ye=i.domElement)==null||ye.removeEventListener("pointerdown",Te),(it=i.domElement)==null||it.removeEventListener("pointercancel",I),(ie=i.domElement)==null||ie.removeEventListener("wheel",De),(Qe=i.domElement)==null||Qe.ownerDocument.removeEventListener("pointermove",H),(je=i.domElement)==null||je.ownerDocument.removeEventListener("pointerup",I),i._domElementKeyEvents!==null&&i._domElementKeyEvents.removeEventListener("keydown",_e)};const i=this,r={type:"change"},a={type:"start"},l={type:"end"},u={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let h=u.NONE;const p=1e-6,g=new vM,y=new vM;let b=1;const x=new K,M=new Le,A=new Le,w=new Le,E=new Le,R=new Le,D=new Le,P=new Le,F=new Le,L=new Le,k=new K,V=new Le;let N=!1;const z=[],X={};function Q(){return 2*Math.PI/60/60*i.autoRotateSpeed}function J(){return Math.pow(.95,i.zoomSpeed)}function oe(te){i.reverseOrbit||i.reverseHorizontalOrbit?y.theta+=te:y.theta-=te}function re(te){i.reverseOrbit||i.reverseVerticalOrbit?y.phi+=te:y.phi-=te}const q=(()=>{const te=new K;return function(it,ie){te.setFromMatrixColumn(ie,0),te.multiplyScalar(-it),x.add(te)}})(),Z=(()=>{const te=new K;return function(it,ie){i.screenSpacePanning===!0?te.setFromMatrixColumn(ie,1):(te.setFromMatrixColumn(ie,0),te.crossVectors(i.object.up,te)),te.multiplyScalar(it),x.add(te)}})(),ne=(()=>{const te=new K;return function(it,ie){const Qe=i.domElement;if(Qe&&i.object instanceof $i&&i.object.isPerspectiveCamera){const je=i.object.position;te.copy(je).sub(i.target);let at=te.length();at*=Math.tan(i.object.fov/2*Math.PI/180),q(2*it*at/Qe.clientHeight,i.object.matrix),Z(2*ie*at/Qe.clientHeight,i.object.matrix)}else Qe&&i.object instanceof Lo&&i.object.isOrthographicCamera?(q(it*(i.object.right-i.object.left)/i.object.zoom/Qe.clientWidth,i.object.matrix),Z(ie*(i.object.top-i.object.bottom)/i.object.zoom/Qe.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function pe(te){i.object instanceof $i&&i.object.isPerspectiveCamera||i.object instanceof Lo&&i.object.isOrthographicCamera?b=te:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function Ee(te){pe(b/te)}function j(te){pe(b*te)}function fe(te){if(!i.zoomToCursor||!i.domElement)return;N=!0;const ye=i.domElement.getBoundingClientRect(),it=te.clientX-ye.left,ie=te.clientY-ye.top,Qe=ye.width,je=ye.height;V.x=it/Qe*2-1,V.y=-(ie/je)*2+1,k.set(V.x,V.y,1).unproject(i.object).sub(i.object.position).normalize()}function be(te){return Math.max(i.minDistance,Math.min(i.maxDistance,te))}function Fe(te){M.set(te.clientX,te.clientY)}function rt(te){fe(te),P.set(te.clientX,te.clientY)}function he(te){E.set(te.clientX,te.clientY)}function xe(te){A.set(te.clientX,te.clientY),w.subVectors(A,M).multiplyScalar(i.rotateSpeed);const ye=i.domElement;ye&&(oe(2*Math.PI*w.x/ye.clientHeight),re(2*Math.PI*w.y/ye.clientHeight)),M.copy(A),i.update()}function ke(te){F.set(te.clientX,te.clientY),L.subVectors(F,P),L.y>0?Ee(J()):L.y<0&&j(J()),P.copy(F),i.update()}function Ge(te){R.set(te.clientX,te.clientY),D.subVectors(R,E).multiplyScalar(i.panSpeed),ne(D.x,D.y),E.copy(R),i.update()}function ct(te){fe(te),te.deltaY<0?j(J()):te.deltaY>0&&Ee(J()),i.update()}function _t(te){let ye=!1;switch(te.code){case i.keys.UP:ne(0,i.keyPanSpeed),ye=!0;break;case i.keys.BOTTOM:ne(0,-i.keyPanSpeed),ye=!0;break;case i.keys.LEFT:ne(i.keyPanSpeed,0),ye=!0;break;case i.keys.RIGHT:ne(-i.keyPanSpeed,0),ye=!0;break}ye&&(te.preventDefault(),i.update())}function St(){if(z.length==1)M.set(z[0].pageX,z[0].pageY);else{const te=.5*(z[0].pageX+z[1].pageX),ye=.5*(z[0].pageY+z[1].pageY);M.set(te,ye)}}function mt(){if(z.length==1)E.set(z[0].pageX,z[0].pageY);else{const te=.5*(z[0].pageX+z[1].pageX),ye=.5*(z[0].pageY+z[1].pageY);E.set(te,ye)}}function Ce(){const te=z[0].pageX-z[1].pageX,ye=z[0].pageY-z[1].pageY,it=Math.sqrt(te*te+ye*ye);P.set(0,it)}function Pe(){i.enableZoom&&Ce(),i.enablePan&&mt()}function ze(){i.enableZoom&&Ce(),i.enableRotate&&St()}function Xe(te){if(z.length==1)A.set(te.pageX,te.pageY);else{const it=ht(te),ie=.5*(te.pageX+it.x),Qe=.5*(te.pageY+it.y);A.set(ie,Qe)}w.subVectors(A,M).multiplyScalar(i.rotateSpeed);const ye=i.domElement;ye&&(oe(2*Math.PI*w.x/ye.clientHeight),re(2*Math.PI*w.y/ye.clientHeight)),M.copy(A)}function Y(te){if(z.length==1)R.set(te.pageX,te.pageY);else{const ye=ht(te),it=.5*(te.pageX+ye.x),ie=.5*(te.pageY+ye.y);R.set(it,ie)}D.subVectors(R,E).multiplyScalar(i.panSpeed),ne(D.x,D.y),E.copy(R)}function bt(te){const ye=ht(te),it=te.pageX-ye.x,ie=te.pageY-ye.y,Qe=Math.sqrt(it*it+ie*ie);F.set(0,Qe),L.set(0,Math.pow(F.y/P.y,i.zoomSpeed)),Ee(L.y),P.copy(F)}function st(te){i.enableZoom&&bt(te),i.enablePan&&Y(te)}function Et(te){i.enableZoom&&bt(te),i.enableRotate&&Xe(te)}function Te(te){var ye,it;i.enabled!==!1&&(z.length===0&&((ye=i.domElement)==null||ye.ownerDocument.addEventListener("pointermove",H),(it=i.domElement)==null||it.ownerDocument.addEventListener("pointerup",I)),Ct(te),te.pointerType==="touch"?nt(te):ee(te))}function H(te){i.enabled!==!1&&(te.pointerType==="touch"?Ye(te):ue(te))}function I(te){var ye,it,ie;$e(te),z.length===0&&((ye=i.domElement)==null||ye.releasePointerCapture(te.pointerId),(it=i.domElement)==null||it.ownerDocument.removeEventListener("pointermove",H),(ie=i.domElement)==null||ie.ownerDocument.removeEventListener("pointerup",I)),i.dispatchEvent(l),h=u.NONE}function ee(te){let ye;switch(te.button){case 0:ye=i.mouseButtons.LEFT;break;case 1:ye=i.mouseButtons.MIDDLE;break;case 2:ye=i.mouseButtons.RIGHT;break;default:ye=-1}switch(ye){case nd.DOLLY:if(i.enableZoom===!1)return;rt(te),h=u.DOLLY;break;case nd.ROTATE:if(te.ctrlKey||te.metaKey||te.shiftKey){if(i.enablePan===!1)return;he(te),h=u.PAN}else{if(i.enableRotate===!1)return;Fe(te),h=u.ROTATE}break;case nd.PAN:if(te.ctrlKey||te.metaKey||te.shiftKey){if(i.enableRotate===!1)return;Fe(te),h=u.ROTATE}else{if(i.enablePan===!1)return;he(te),h=u.PAN}break;default:h=u.NONE}h!==u.NONE&&i.dispatchEvent(a)}function ue(te){if(i.enabled!==!1)switch(h){case u.ROTATE:if(i.enableRotate===!1)return;xe(te);break;case u.DOLLY:if(i.enableZoom===!1)return;ke(te);break;case u.PAN:if(i.enablePan===!1)return;Ge(te);break}}function De(te){i.enabled===!1||i.enableZoom===!1||h!==u.NONE&&h!==u.ROTATE||(te.preventDefault(),i.dispatchEvent(a),ct(te),i.dispatchEvent(l))}function _e(te){i.enabled===!1||i.enablePan===!1||_t(te)}function nt(te){switch(Ke(te),z.length){case 1:switch(i.touches.ONE){case id.ROTATE:if(i.enableRotate===!1)return;St(),h=u.TOUCH_ROTATE;break;case id.PAN:if(i.enablePan===!1)return;mt(),h=u.TOUCH_PAN;break;default:h=u.NONE}break;case 2:switch(i.touches.TWO){case id.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Pe(),h=u.TOUCH_DOLLY_PAN;break;case id.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;ze(),h=u.TOUCH_DOLLY_ROTATE;break;default:h=u.NONE}break;default:h=u.NONE}h!==u.NONE&&i.dispatchEvent(a)}function Ye(te){switch(Ke(te),h){case u.TOUCH_ROTATE:if(i.enableRotate===!1)return;Xe(te),i.update();break;case u.TOUCH_PAN:if(i.enablePan===!1)return;Y(te),i.update();break;case u.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;st(te),i.update();break;case u.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Et(te),i.update();break;default:h=u.NONE}}function dt(te){i.enabled!==!1&&te.preventDefault()}function Ct(te){z.push(te)}function $e(te){delete X[te.pointerId];for(let ye=0;ye{j(te),i.update()},this.dollyOut=(te=J())=>{Ee(te),i.update()},this.getScale=()=>b,this.setScale=te=>{pe(te),i.update()},this.getZoomScale=()=>J(),t!==void 0&&this.connect(t),this.update()}};function lH(n,e,t){const i=br(x=>x.size),r=br(x=>x.viewport),a=typeof n=="number"?n:i.width*r.dpr,l=i.height*r.dpr,u=(typeof n=="number"?t:n)||{},{samples:h=0,depth:p,...g}=u,y=p??u.depthBuffer,b=U.useMemo(()=>{const x=new Gn(a,l,{minFilter:Nn,magFilter:Nn,type:no,...g});return y&&(x.depthTexture=new Vu(a,l,Or)),x.samples=h,x},[]);return U.useLayoutEffect(()=>{b.setSize(a,l),h&&(b.samples=h)},[h,b,a,l]),U.useEffect(()=>()=>b.dispose(),[]),b}const cH=n=>typeof n=="function",uH=U.forwardRef(({envMap:n,resolution:e=256,frames:t=1/0,makeDefault:i,children:r,...a},l)=>{const u=br(({set:w})=>w),h=br(({camera:w})=>w),p=br(({size:w})=>w),g=U.useRef(null);U.useImperativeHandle(l,()=>g.current,[]);const y=U.useRef(null),b=lH(e);U.useLayoutEffect(()=>{a.manual||(g.current.aspect=p.width/p.height)},[p,a]),U.useLayoutEffect(()=>{g.current.updateProjectionMatrix()});let x=0,M=null;const A=cH(r);return pd(w=>{A&&(t===1/0||x{if(i){const w=h;return u(()=>({camera:g.current})),()=>u(()=>({camera:w}))}},[g,i,u]),U.createElement(U.Fragment,null,U.createElement("perspectiveCamera",Ox({ref:g},a),!A&&r),U.createElement("group",{ref:y},A&&r(b.texture)))}),fH=U.forwardRef(({makeDefault:n,camera:e,regress:t,domElement:i,enableDamping:r=!0,keyEvents:a=!1,onChange:l,onStart:u,onEnd:h,...p},g)=>{const y=br(L=>L.invalidate),b=br(L=>L.camera),x=br(L=>L.gl),M=br(L=>L.events),A=br(L=>L.setEvents),w=br(L=>L.set),E=br(L=>L.get),R=br(L=>L.performance),D=e||b,P=i||M.connected||x.domElement,F=U.useMemo(()=>new oH(D),[D]);return pd(()=>{F.enabled&&F.update()},-1),U.useEffect(()=>(a&&F.connect(a===!0?P:a),F.connect(P),()=>{F.dispose()}),[a,P,t,F,y]),U.useEffect(()=>{const L=N=>{y(),t&&R.regress(),l&&l(N)},k=N=>{u&&u(N)},V=N=>{h&&h(N)};return F.addEventListener("change",L),F.addEventListener("start",k),F.addEventListener("end",V),()=>{F.removeEventListener("start",k),F.removeEventListener("end",V),F.removeEventListener("change",L)}},[l,u,h,F,y,A]),U.useEffect(()=>{if(n){const L=E().controls;return w({controls:F}),()=>w({controls:L})}},[n,F]),U.createElement("primitive",Ox({ref:g,object:F,enableDamping:r},p))});var Nb={exports:{}},dH=Nb.exports,SC;function hH(){return SC||(SC=1,(function(n,e){(function(t,i){n.exports=i()})(dH,function(){var t=function(){function i(x){return l.appendChild(x.dom),x}function r(x){for(var M=0;Mh+1e3&&(g.update(1e3*p/(x-h),100),h=x,p=0,b)){var M=performance.memory;b.update(M.usedJSHeapSize/1048576,M.jsHeapSizeLimit/1048576)}return x},update:function(){u=this.end()},domElement:l,setMode:r}};return t.Panel=function(i,r,a){var l=1/0,u=0,h=Math.round,p=h(window.devicePixelRatio||1),g=80*p,y=48*p,b=3*p,x=2*p,M=3*p,A=15*p,w=74*p,E=30*p,R=document.createElement("canvas");R.width=g,R.height=y,R.style.cssText="width:80px;height:48px";var D=R.getContext("2d");return D.font="bold "+9*p+"px Helvetica,Arial,sans-serif",D.textBaseline="top",D.fillStyle=a,D.fillRect(0,0,g,y),D.fillStyle=r,D.fillText(i,b,x),D.fillRect(M,A,w,E),D.fillStyle=a,D.globalAlpha=.9,D.fillRect(M,A,w,E),{dom:R,update:function(P,F){l=Math.min(l,P),u=Math.max(u,P),D.fillStyle=a,D.globalAlpha=1,D.fillRect(0,0,g,A),D.fillStyle=r,D.fillText(h(P)+" "+i+" ("+h(l)+"-"+h(u)+")",b,x),D.drawImage(R,M+p,A,w-p,E,M,A,w-p,E),D.fillRect(M+w-p,A,p,E),D.fillStyle=a,D.globalAlpha=.9,D.fillRect(M+w-p,A,p,h((1-P/F)*E))}}},t})})(Nb)),Nb.exports}var pH=hH();const mH=Yu(pH);function gH(n,e=[],t){const[i,r]=U.useState();return U.useLayoutEffect(()=>{const a=n();return r(a),()=>void 0},e),i}function vH({showPanel:n=0,className:e,parent:t}){const i=gH(()=>new mH,[]);return U.useEffect(()=>{if(i){const r=t&&t.current||document.body;i.showPanel(n),r?.appendChild(i.dom);const a=(e??"").split(" ").filter(h=>h);a.length&&i.dom.classList.add(...a);const l=K6(()=>i.begin()),u=Q6(()=>i.end());return()=>{a.length&&i.dom.classList.remove(...a),r?.removeChild(i.dom),l(),u()}}},[t,i,e,n]),null}var R1=1/1e3,yH=1e3,bH=class{constructor(){this.startTime=performance.now(),this.previousTime=0,this.currentTime=0,this._delta=0,this._elapsed=0,this._fixedDelta=1e3/60,this.timescale=1,this.useFixedDelta=!1,this._autoReset=!1}get autoReset(){return this._autoReset}set autoReset(n){typeof document<"u"&&document.hidden!==void 0&&(n?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this._autoReset=n)}get delta(){return this._delta*R1}get fixedDelta(){return this._fixedDelta*R1}set fixedDelta(n){this._fixedDelta=n*yH}get elapsed(){return this._elapsed*R1}update(n){this.useFixedDelta?this._delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=(n!==void 0?n:performance.now())-this.startTime,this._delta=this.currentTime-this.previousTime),this._delta*=this.timescale,this._elapsed+=this._delta}reset(){this._delta=0,this._elapsed=0,this.currentTime=performance.now()-this.startTime}getDelta(){return this.delta}getElapsed(){return this.elapsed}handleEvent(n){document.hidden||(this.currentTime=performance.now()-this.startTime)}dispose(){this.autoReset=!1}},xH=(()=>{const n=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]),t=new en;return t.setAttribute("position",new Wn(n,3)),t.setAttribute("uv",new Wn(e,2)),t})(),Ns=class DM{static get fullscreenGeometry(){return xH}constructor(e="Pass",t=new zu,i=new Lo){this.name=e,this.renderer=null,this.scene=t,this.camera=i,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){const t=this.fullscreenMaterial;t!==null&&(t.needsUpdate=!0),this.rtt=!e}}set mainScene(e){}set mainCamera(e){}setRenderer(e){this.renderer=e}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(e){let t=this.screen;t!==null?t.material=e:(t=new hi(DM.fullscreenGeometry,e),t.frustumCulled=!1,this.scene===null&&(this.scene=new zu),this.scene.add(t),this.screen=t)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(e){this.fullscreenMaterial=e}getDepthTexture(){return null}setDepthTexture(e,t=Zu){}render(e,t,i,r,a){throw new Error("Render method not implemented!")}setSize(e,t){}initialize(e,t,i){}dispose(){for(const e of Object.keys(this)){const t=this[e];(t instanceof Gn||t instanceof Ir||t instanceof Ai||t instanceof DM)&&this[e].dispose()}this.fullscreenMaterial!==null&&this.fullscreenMaterial.dispose()}},_H=class extends Ns{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(n,e,t,i,r){const a=n.state.buffers.stencil;a.setLocked(!1),a.setTest(!1)}},SH=`#ifdef COLOR_WRITE #include #include #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #endif #ifdef DEPTH_WRITE #include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif } #endif #ifdef USE_WEIGHTS uniform vec4 channelWeights; #endif uniform float opacity;varying vec2 vUv;void main(){ #ifdef COLOR_WRITE vec4 texel=texture2D(inputBuffer,vUv); #ifdef USE_WEIGHTS texel*=channelWeights; #endif gl_FragColor=opacity*texel; #ifdef COLOR_SPACE_CONVERSION #include #endif #include #else gl_FragColor=vec4(0.0); #endif #ifdef DEPTH_WRITE gl_FragDepth=readDepth(vUv); #endif }`,QE="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",_O=class extends Yn{constructor(){super({name:"CopyMaterial",defines:{COLOR_SPACE_CONVERSION:"1",DEPTH_PACKING:"0",COLOR_WRITE:"1"},uniforms:{inputBuffer:new Ut(null),depthBuffer:new Ut(null),channelWeights:new Ut(null),opacity:new Ut(1)},blending:Pr,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:SH,vertexShader:QE}),this.depthFunc=e0}get inputBuffer(){return this.uniforms.inputBuffer.value}set inputBuffer(n){const e=n!==null;this.colorWrite!==e&&(e?this.defines.COLOR_WRITE=!0:delete this.defines.COLOR_WRITE,this.colorWrite=e,this.needsUpdate=!0),this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){const e=n!==null;this.depthWrite!==e&&(e?this.defines.DEPTH_WRITE=!0:delete this.defines.DEPTH_WRITE,this.depthTest=e,this.depthWrite=e,this.needsUpdate=!0),this.uniforms.depthBuffer.value=n}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}get colorSpaceConversion(){return this.defines.COLOR_SPACE_CONVERSION!==void 0}set colorSpaceConversion(n){this.colorSpaceConversion!==n&&(n?this.defines.COLOR_SPACE_CONVERSION=!0:delete this.defines.COLOR_SPACE_CONVERSION,this.needsUpdate=!0)}get channelWeights(){return this.uniforms.channelWeights.value}set channelWeights(n){n!==null?(this.defines.USE_WEIGHTS="1",this.uniforms.channelWeights.value=n):delete this.defines.USE_WEIGHTS,this.needsUpdate=!0}setInputBuffer(n){this.uniforms.inputBuffer.value=n}getOpacity(n){return this.uniforms.opacity.value}setOpacity(n){this.uniforms.opacity.value=n}},SO=class extends Ns{constructor(n,e=!0){super("CopyPass"),this.fullscreenMaterial=new _O,this.needsSwap=!1,this.renderTarget=n,n===void 0&&(this.renderTarget=new Gn(1,1,{minFilter:Nn,magFilter:Nn,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=e}get resize(){return this.autoResize}set resize(n){this.autoResize=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(n){this.autoResize=n}render(n,e,t,i,r){this.fullscreenMaterial.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){this.autoResize&&this.renderTarget.setSize(n,e)}initialize(n,e,t){t!==void 0&&(this.renderTarget.texture.type=t,t!==Xi?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":n!==null&&n.outputColorSpace===Fn&&(this.renderTarget.texture.colorSpace=Fn))}},MC=new pt,MO=class extends Ns{constructor(n=!0,e=!0,t=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=n,this.depth=e,this.stencil=t,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(n,e,t){this.color=n,this.depth=e,this.stencil=t}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(n){this.overrideClearColor=n}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(n){this.overrideClearAlpha=n}render(n,e,t,i,r){const a=this.overrideClearColor,l=this.overrideClearAlpha,u=n.getClearAlpha(),h=a!==null,p=l>=0;h?(n.getClearColor(MC),n.setClearColor(a,p?l:u)):p&&n.setClearAlpha(l),n.setRenderTarget(this.renderToScreen?null:e),n.clear(this.color,this.depth,this.stencil),h?n.setClearColor(MC,u):p&&n.setClearAlpha(u)}},MH=class extends Ns{constructor(n,e){super("MaskPass",n,e),this.needsSwap=!1,this.clearPass=new MO(!1,!1,!0),this.inverse=!1}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get inverted(){return this.inverse}set inverted(n){this.inverse=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(n){this.inverted=n}render(n,e,t,i,r){const a=n.getContext(),l=n.state.buffers,u=this.scene,h=this.camera,p=this.clearPass,g=this.inverted?0:1,y=1-g;l.color.setMask(!1),l.depth.setMask(!1),l.color.setLocked(!0),l.depth.setLocked(!0),l.stencil.setTest(!0),l.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),l.stencil.setFunc(a.ALWAYS,g,4294967295),l.stencil.setClear(y),l.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?p.render(n,null):(p.render(n,e),p.render(n,t))),this.renderToScreen?(n.setRenderTarget(null),n.render(u,h)):(n.setRenderTarget(e),n.render(u,h),n.setRenderTarget(t),n.render(u,h)),l.color.setLocked(!1),l.depth.setLocked(!1),l.stencil.setLocked(!1),l.stencil.setFunc(a.EQUAL,1,4294967295),l.stencil.setOp(a.KEEP,a.KEEP,a.KEEP),l.stencil.setLocked(!0)}},EH=class{constructor(n=null,{depthBuffer:e=!0,stencilBuffer:t=!1,multisampling:i=0,frameBufferType:r}={}){this.renderer=null,this.inputBuffer=this.createBuffer(e,t,r,i),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new SO,this.depthTexture=null,this.passes=[],this.timer=new bH,this.autoRenderToScreen=!0,this.setRenderer(n)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(n){const e=this.inputBuffer,t=this.multisampling;t>0&&n>0?(this.inputBuffer.samples=n,this.outputBuffer.samples=n,this.inputBuffer.dispose(),this.outputBuffer.dispose()):t!==n&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(e.depthBuffer,e.stencilBuffer,e.texture.type,n),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(n){if(this.renderer=n,n!==null){const e=n.getSize(new Le),t=n.getContext().getContextAttributes().alpha,i=this.inputBuffer.texture.type;i===Xi&&n.outputColorSpace===Fn&&(this.inputBuffer.texture.colorSpace=Fn,this.outputBuffer.texture.colorSpace=Fn,this.inputBuffer.dispose(),this.outputBuffer.dispose()),n.autoClear=!1,this.setSize(e.width,e.height);for(const r of this.passes)r.initialize(n,t,i)}}replaceRenderer(n,e=!0){const t=this.renderer,i=t.domElement.parentNode;return this.setRenderer(n),e&&i!==null&&(i.removeChild(t.domElement),i.appendChild(n.domElement)),t}createDepthTexture(){const n=this.depthTexture=new Vu;return this.inputBuffer.depthTexture=n,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(n.format=wc,n.type=yd):n.type=Ea,n}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(const n of this.passes)n.setDepthTexture(null)}}createBuffer(n,e,t,i){const r=this.renderer,a=r===null?new Le:r.getDrawingBufferSize(new Le),l={minFilter:Nn,magFilter:Nn,stencilBuffer:e,depthBuffer:n,type:t},u=new Gn(a.width,a.height,l);return i>0&&(u.samples=i),t===Xi&&r!==null&&r.outputColorSpace===Fn&&(u.texture.colorSpace=Fn),u.texture.name="EffectComposer.Buffer",u.texture.generateMipmaps=!1,u}setMainScene(n){for(const e of this.passes)e.mainScene=n}setMainCamera(n){for(const e of this.passes)e.mainCamera=n}addPass(n,e){const t=this.passes,i=this.renderer,r=i.getDrawingBufferSize(new Le),a=i.getContext().getContextAttributes().alpha,l=this.inputBuffer.texture.type;if(n.setRenderer(i),n.setSize(r.width,r.height),n.initialize(i,a,l),this.autoRenderToScreen&&(t.length>0&&(t[t.length-1].renderToScreen=!1),n.renderToScreen&&(this.autoRenderToScreen=!1)),e!==void 0?t.splice(e,0,n):t.push(n),this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!0),n.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){const u=this.createDepthTexture();for(n of t)n.setDepthTexture(u)}else n.setDepthTexture(this.depthTexture)}removePass(n){const e=this.passes,t=e.indexOf(n);if(t!==-1&&e.splice(t,1).length>0){if(this.depthTexture!==null){const a=(u,h)=>u||h.needsDepthTexture;e.reduce(a,!1)||(n.getDepthTexture()===this.depthTexture&&n.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&t===e.length&&(n.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){const n=this.passes;this.deleteDepthTexture(),n.length>0&&(this.autoRenderToScreen&&(n[n.length-1].renderToScreen=!1),this.passes=[])}render(n){const e=this.renderer,t=this.copyPass;let i=this.inputBuffer,r=this.outputBuffer,a=!1,l,u,h;n===void 0&&(this.timer.update(),n=this.timer.getDelta());for(const p of this.passes)p.enabled&&(p.render(e,i,r,n,a),p.needsSwap&&(a&&(t.renderToScreen=p.renderToScreen,l=e.getContext(),u=e.state.buffers.stencil,u.setFunc(l.NOTEQUAL,1,4294967295),t.render(e,i,r,n,a),u.setFunc(l.EQUAL,1,4294967295)),h=i,i=r,r=h),p instanceof MH?a=!0:p instanceof _H&&(a=!1))}setSize(n,e,t){const i=this.renderer,r=i.getSize(new Le);(n===void 0||e===void 0)&&(n=r.width,e=r.height),(r.width!==n||r.height!==e)&&i.setSize(n,e,t);const a=i.getDrawingBufferSize(new Le);this.inputBuffer.setSize(a.width,a.height),this.outputBuffer.setSize(a.width,a.height);for(const l of this.passes)l.setSize(a.width,a.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(const n of this.passes)n.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose(),Ns.fullscreenGeometry.dispose()}},Bu={NONE:0,DEPTH:1,CONVOLUTION:2},Bn={FRAGMENT_HEAD:"FRAGMENT_HEAD",FRAGMENT_MAIN_UV:"FRAGMENT_MAIN_UV",FRAGMENT_MAIN_IMAGE:"FRAGMENT_MAIN_IMAGE",VERTEX_HEAD:"VERTEX_HEAD",VERTEX_MAIN_SUPPORT:"VERTEX_MAIN_SUPPORT"},TH=class{constructor(){this.shaderParts=new Map([[Bn.FRAGMENT_HEAD,null],[Bn.FRAGMENT_MAIN_UV,null],[Bn.FRAGMENT_MAIN_IMAGE,null],[Bn.VERTEX_HEAD,null],[Bn.VERTEX_MAIN_SUPPORT,null]]),this.defines=new Map,this.uniforms=new Map,this.blendModes=new Map,this.extensions=new Set,this.attributes=Bu.NONE,this.varyings=new Set,this.uvTransformation=!1,this.readDepth=!1,this.colorSpace=Dl}},D1=!1,EC=class{constructor(n=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(n),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case xr:t=this.materialsFlatShadedDoubleSide;break;case _r:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case xr:t=this.materialsDoubleSide;break;case _r:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}cloneMaterial(n){if(!(n instanceof Yn))return n.clone();const e=n.uniforms,t=new Map;for(const r in e){const a=e[r].value;a.isRenderTargetTexture&&(e[r].value=null,t.set(r,a))}const i=n.clone();for(const r of t)e[r[0]].value=r[1],i.uniforms[r[0]].value=r[1];return i}setMaterial(n){if(this.disposeMaterials(),this.material=n,n!==null){const e=this.materials=[this.cloneMaterial(n),this.cloneMaterial(n),this.cloneMaterial(n)];for(const t of e)t.uniforms=Object.assign({},n.uniforms),t.side=Al;e[2].skinning=!0,this.materialsBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=_r,i}),this.materialsDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.side=xr,i}),this.materialsFlatShaded=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i}),this.materialsFlatShadedBackSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=_r,i}),this.materialsFlatShadedDoubleSide=e.map(t=>{const i=this.cloneMaterial(t);return i.uniforms=Object.assign({},n.uniforms),i.flatShading=!0,i.side=xr,i})}}render(n,e,t){const i=n.shadowMap.enabled;if(n.shadowMap.enabled=!1,D1){const r=this.originalMaterials;this.meshCount=0,e.traverse(this.replaceMaterial),n.render(e,t);for(const a of r)a[0].material=a[1];this.meshCount!==r.size&&r.clear()}else{const r=e.overrideMaterial;e.overrideMaterial=this.material,n.render(e,t),e.overrideMaterial=r}n.shadowMap.enabled=i}disposeMaterials(){if(this.material!==null){const n=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(const e of n)e.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return D1}static set workaroundEnabled(n){D1=n}},Ou=-1,ls=class extends wa{constructor(n,e=Ou,t=Ou,i=1){super(),this.resizable=n,this.baseSize=new Le(1,1),this.preferredSize=new Le(e,t),this.target=this.preferredSize,this.s=i,this.effectiveSize=new Le,this.addEventListener("change",()=>this.updateEffectiveSize()),this.updateEffectiveSize()}updateEffectiveSize(){const n=this.baseSize,e=this.preferredSize,t=this.effectiveSize,i=this.scale;e.width!==Ou?t.width=e.width:e.height!==Ou?t.width=Math.round(e.height*(n.width/Math.max(n.height,1))):t.width=Math.round(n.width*i),e.height!==Ou?t.height=e.height:e.width!==Ou?t.height=Math.round(e.width/Math.max(n.width/Math.max(n.height,1),1)):t.height=Math.round(n.height*i)}get width(){return this.effectiveSize.width}set width(n){this.preferredWidth=n}get height(){return this.effectiveSize.height}set height(n){this.preferredHeight=n}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(n){this.s!==n&&(this.s=n,this.preferredSize.setScalar(Ou),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getScale(){return this.scale}setScale(n){this.scale=n}get baseWidth(){return this.baseSize.width}set baseWidth(n){this.baseSize.width!==n&&(this.baseSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseWidth(){return this.baseWidth}setBaseWidth(n){this.baseWidth=n}get baseHeight(){return this.baseSize.height}set baseHeight(n){this.baseSize.height!==n&&(this.baseSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(n){this.baseHeight=n}setBaseSize(n,e){(this.baseSize.width!==n||this.baseSize.height!==e)&&(this.baseSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}get preferredWidth(){return this.preferredSize.width}set preferredWidth(n){this.preferredSize.width!==n&&(this.preferredSize.width=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(n){this.preferredWidth=n}get preferredHeight(){return this.preferredSize.height}set preferredHeight(n){this.preferredSize.height!==n&&(this.preferredSize.height=n,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(n){this.preferredHeight=n}setPreferredSize(n,e){(this.preferredSize.width!==n||this.preferredSize.height!==e)&&(this.preferredSize.set(n,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height))}copy(n){this.s=n.scale,this.baseSize.set(n.baseWidth,n.baseHeight),this.preferredSize.set(n.preferredWidth,n.preferredHeight),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.baseSize.width,this.baseSize.height)}static get AUTO_SIZE(){return Ou}},vn={SET:30,ADD:0,ALPHA:1,AVERAGE:2,COLOR:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,DIVIDE:8,DST:9,EXCLUSION:10,HARD_LIGHT:11,HARD_MIX:12,HUE:13,INVERT:14,INVERT_RGB:15,LIGHTEN:16,LINEAR_BURN:17,LINEAR_DODGE:18,LINEAR_LIGHT:19,LUMINOSITY:20,MULTIPLY:21,NEGATION:22,NORMAL:23,OVERLAY:24,PIN_LIGHT:25,REFLECT:26,SATURATION:27,SCREEN:28,SOFT_LIGHT:29,SRC:30,SUBTRACT:31,VIVID_LIGHT:32},wH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",AH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return mix(dst,src,src.a*opacity);}",CH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=(dst.rgb+src.rgb)*0.5;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",RH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(b.xy,a.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",DH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=dst.rgb,b=src.rgb;vec3 c=mix(step(0.0,b)*(1.0-min(vec3(1.0),(1.0-a)/max(b,1e-9))),vec3(1.0),step(1.0,a));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",OH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=dst.rgb,b=src.rgb;vec3 c=step(0.0,a)*mix(min(vec3(1.0),a/max(1.0-b,1e-9)),vec3(1.0),step(1.0,b));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",PH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=min(dst.rgb,src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",IH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=abs(dst.rgb-src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",NH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb/max(src.rgb,1e-9);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",LH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb-2.0*dst.rgb*src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",UH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=min(dst.rgb,1.0);vec3 b=min(src.rgb,1.0);vec3 c=mix(2.0*a*b,1.0-2.0*(1.0-a)*(1.0-b),step(0.5,b));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",zH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=step(1.0,dst.rgb+src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",BH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(b.x,a.yz));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",FH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(1.0-src.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",kH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=src.rgb*max(1.0-dst.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",HH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(dst.rgb,src.rgb);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",VH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=clamp(src.rgb+dst.rgb-1.0,0.0,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",GH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=min(dst.rgb+src.rgb,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",WH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=clamp(2.0*src.rgb+dst.rgb-1.0,0.0,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",$H="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(a.xy,b.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",XH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb*src.rgb;return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",jH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(1.0-abs(1.0-dst.rgb-src.rgb),0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",qH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return mix(dst,src,opacity);}",YH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=2.0*src.rgb*dst.rgb;vec3 b=1.0-2.0*(1.0-src.rgb)*(1.0-dst.rgb);vec3 c=mix(a,b,step(0.5,dst.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",ZH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 src2=2.0*src.rgb;vec3 c=mix(mix(src2,dst.rgb,step(0.5*dst.rgb,src.rgb)),max(src2-1.0,vec3(0.0)),step(dst.rgb,src2-1.0));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",KH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=min(dst.rgb*dst.rgb/max(1.0-src.rgb,1e-9),1.0);vec3 c=mix(a,src.rgb,step(1.0,src.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",QH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 a=RGBToHSL(dst.rgb);vec3 b=RGBToHSL(src.rgb);vec3 c=HSLToRGB(vec3(a.x,b.y,a.z));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",JH="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=dst.rgb+src.rgb-min(dst.rgb*src.rgb,1.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",eV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 src2=2.0*src.rgb;vec3 d=dst.rgb+(src2-1.0);vec3 w=step(0.5,src.rgb);vec3 a=dst.rgb-(1.0-src2)*dst.rgb*(1.0-dst.rgb);vec3 b=mix(d*(sqrt(dst.rgb)-dst.rgb),d*dst.rgb*((16.0*dst.rgb-12.0)*dst.rgb+3.0),w*(1.0-step(0.25,dst.rgb)));vec3 c=mix(a,b,w);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",tV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){return src;}",nV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=max(dst.rgb-src.rgb,0.0);return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",iV="vec4 blend(const in vec4 dst,const in vec4 src,const in float opacity){vec3 c=mix(max(1.0-min((1.0-dst.rgb)/(2.0*src.rgb),1.0),0.0),min(dst.rgb/(2.0*(1.0-src.rgb)),1.0),step(0.5,src.rgb));return mix(dst,vec4(c,max(dst.a,src.a)),opacity);}",rV=new Map([[vn.ADD,wH],[vn.ALPHA,AH],[vn.AVERAGE,CH],[vn.COLOR,RH],[vn.COLOR_BURN,DH],[vn.COLOR_DODGE,OH],[vn.DARKEN,PH],[vn.DIFFERENCE,IH],[vn.DIVIDE,NH],[vn.DST,null],[vn.EXCLUSION,LH],[vn.HARD_LIGHT,UH],[vn.HARD_MIX,zH],[vn.HUE,BH],[vn.INVERT,FH],[vn.INVERT_RGB,kH],[vn.LIGHTEN,HH],[vn.LINEAR_BURN,VH],[vn.LINEAR_DODGE,GH],[vn.LINEAR_LIGHT,WH],[vn.LUMINOSITY,$H],[vn.MULTIPLY,XH],[vn.NEGATION,jH],[vn.NORMAL,qH],[vn.OVERLAY,YH],[vn.PIN_LIGHT,ZH],[vn.REFLECT,KH],[vn.SATURATION,QH],[vn.SCREEN,JH],[vn.SOFT_LIGHT,eV],[vn.SRC,tV],[vn.SUBTRACT,nV],[vn.VIVID_LIGHT,iV]]),sV=class extends wa{constructor(n,e=1){super(),this._blendFunction=n,this.opacity=new Ut(e)}getOpacity(){return this.opacity.value}setOpacity(n){this.opacity.value=n}get blendFunction(){return this._blendFunction}set blendFunction(n){this._blendFunction=n,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(n){this.blendFunction=n}getShaderCode(){return rV.get(this.blendFunction)}},Wu=class extends wa{constructor(n,e,{attributes:t=Bu.NONE,blendFunction:i=vn.NORMAL,defines:r=new Map,uniforms:a=new Map,extensions:l=null,vertexShader:u=null}={}){super(),this.name=n,this.renderer=null,this.attributes=t,this.fragmentShader=e,this.vertexShader=u,this.defines=r,this.uniforms=a,this.extensions=l,this.blendMode=new sV(i),this.blendMode.addEventListener("change",h=>this.setChanged()),this._inputColorSpace=Dl,this._outputColorSpace=Po}get inputColorSpace(){return this._inputColorSpace}set inputColorSpace(n){this._inputColorSpace=n,this.setChanged()}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(n){this._outputColorSpace=n,this.setChanged()}set mainScene(n){}set mainCamera(n){}getName(){return this.name}setRenderer(n){this.renderer=n}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(n){this.attributes=n,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(n){this.fragmentShader=n,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(n){this.vertexShader=n,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(n,e=Zu){}update(n,e,t){}setSize(n,e){}initialize(n,e,t){}dispose(){for(const n of Object.keys(this)){const e=this[n];(e instanceof Gn||e instanceof Ir||e instanceof Ai||e instanceof Ns)&&this[n].dispose()}}},JE={MEDIUM:2,LARGE:3},aV=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25; #include }`,oV="uniform vec4 texelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize.xy*vec2(kernel)+texelSize.zw)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}",lV=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],cV=class extends Yn{constructor(n=new Zn){super({name:"KawaseBlurMaterial",uniforms:{inputBuffer:new Ut(null),texelSize:new Ut(new Zn),scale:new Ut(1),kernel:new Ut(0)},blending:Pr,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:aV,vertexShader:oV}),this.setTexelSize(n.x,n.y),this.kernelSize=JE.MEDIUM}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.inputBuffer=n}get kernelSequence(){return lV[this.kernelSize]}get scale(){return this.uniforms.scale.value}set scale(n){this.uniforms.scale.value=n}getScale(){return this.uniforms.scale.value}setScale(n){this.uniforms.scale.value=n}getKernel(){return null}get kernel(){return this.uniforms.kernel.value}set kernel(n){this.uniforms.kernel.value=n}setKernel(n){this.kernel=n}setTexelSize(n,e){this.uniforms.texelSize.value.set(n,e,n*.5,e*.5)}setSize(n,e){const t=1/n,i=1/e;this.uniforms.texelSize.value.set(t,i,t*.5,i*.5)}},uV=class extends Ns{constructor({kernelSize:n=JE.MEDIUM,resolutionScale:e=.5,width:t=ls.AUTO_SIZE,height:i=ls.AUTO_SIZE,resolutionX:r=t,resolutionY:a=i}={}){super("KawaseBlurPass"),this.renderTargetA=new Gn(1,1,{depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";const l=this.resolution=new ls(this,r,a,e);l.addEventListener("change",u=>this.setSize(l.baseWidth,l.baseHeight)),this._blurMaterial=new cV,this._blurMaterial.kernelSize=n,this.copyMaterial=new _O}getResolution(){return this.resolution}get blurMaterial(){return this._blurMaterial}set blurMaterial(n){this._blurMaterial=n}get dithering(){return this.copyMaterial.dithering}set dithering(n){this.copyMaterial.dithering=n}get kernelSize(){return this.blurMaterial.kernelSize}set kernelSize(n){this.blurMaterial.kernelSize=n}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get scale(){return this.blurMaterial.scale}set scale(n){this.blurMaterial.scale=n}getScale(){return this.blurMaterial.scale}setScale(n){this.blurMaterial.scale=n}getKernelSize(){return this.kernelSize}setKernelSize(n){this.kernelSize=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,e,t,i,r){const a=this.scene,l=this.camera,u=this.renderTargetA,h=this.renderTargetB,p=this.blurMaterial,g=p.kernelSequence;let y=e;this.fullscreenMaterial=p;for(let b=0,x=g.length;b #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #ifdef RANGE uniform vec2 range; #elif defined(THRESHOLD) uniform float threshold;uniform float smoothing; #endif varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=luminance(texel.rgb);float mask=1.0; #ifdef RANGE float low=step(range.x,l);float high=step(l,range.y);mask=low*high; #elif defined(THRESHOLD) mask=smoothstep(threshold,threshold+smoothing,l); #endif #ifdef COLOR gl_FragColor=texel*mask; #else gl_FragColor=vec4(l*mask); #endif }`,dV=class extends Yn{constructor(n=!1,e=null){super({name:"LuminanceMaterial",defines:{THREE_REVISION:Td.replace(/\D+/g,"")},uniforms:{inputBuffer:new Ut(null),threshold:new Ut(0),smoothing:new Ut(1),range:new Ut(null)},blending:Pr,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:fV,vertexShader:QE}),this.colorOutput=n,this.luminanceRange=e}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get threshold(){return this.uniforms.threshold.value}set threshold(n){this.smoothing>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.threshold.value=n}getThreshold(){return this.threshold}setThreshold(n){this.threshold=n}get smoothing(){return this.uniforms.smoothing.value}set smoothing(n){this.threshold>0||n>0?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.uniforms.smoothing.value=n}getSmoothingFactor(){return this.smoothing}setSmoothingFactor(n){this.smoothing=n}get useThreshold(){return this.threshold>0||this.smoothing>0}set useThreshold(n){}get colorOutput(){return this.defines.COLOR!==void 0}set colorOutput(n){n?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}isColorOutputEnabled(n){return this.colorOutput}setColorOutputEnabled(n){this.colorOutput=n}get useRange(){return this.luminanceRange!==null}set useRange(n){this.luminanceRange=null}get luminanceRange(){return this.uniforms.range.value}set luminanceRange(n){n!==null?this.defines.RANGE="1":delete this.defines.RANGE,this.uniforms.range.value=n,this.needsUpdate=!0}getLuminanceRange(){return this.luminanceRange}setLuminanceRange(n){this.luminanceRange=n}},EO=class extends Ns{constructor({renderTarget:n,luminanceRange:e,colorOutput:t,resolutionScale:i=1,width:r=ls.AUTO_SIZE,height:a=ls.AUTO_SIZE,resolutionX:l=r,resolutionY:u=a}={}){super("LuminancePass"),this.fullscreenMaterial=new dV(t,e),this.needsSwap=!1,this.renderTarget=n,this.renderTarget===void 0&&(this.renderTarget=new Gn(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target");const h=this.resolution=new ls(this,l,u,i);h.addEventListener("change",p=>this.setSize(h.baseWidth,h.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(n,e,t,i,r){const a=this.fullscreenMaterial;a.inputBuffer=e.texture,n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}initialize(n,e,t){t!==void 0&&t!==Xi&&(this.renderTarget.texture.type=t,this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},hV=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #define WEIGHT_INNER 0.125 #define WEIGHT_OUTER 0.0555555 varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;float clampToBorder(const in vec2 uv){return float(uv.s>=0.0&&uv.s<=1.0&&uv.t>=0.0&&uv.t<=1.0);}void main(){vec4 c=vec4(0.0);vec4 w=WEIGHT_INNER*vec4(clampToBorder(vUv00),clampToBorder(vUv01),clampToBorder(vUv02),clampToBorder(vUv03));c+=w.x*texture2D(inputBuffer,vUv00);c+=w.y*texture2D(inputBuffer,vUv01);c+=w.z*texture2D(inputBuffer,vUv02);c+=w.w*texture2D(inputBuffer,vUv03);w=WEIGHT_OUTER*vec4(clampToBorder(vUv04),clampToBorder(vUv05),clampToBorder(vUv06),clampToBorder(vUv07));c+=w.x*texture2D(inputBuffer,vUv04);c+=w.y*texture2D(inputBuffer,vUv05);c+=w.z*texture2D(inputBuffer,vUv06);c+=w.w*texture2D(inputBuffer,vUv07);w=WEIGHT_OUTER*vec4(clampToBorder(vUv08),clampToBorder(vUv09),clampToBorder(vUv10),clampToBorder(vUv11));c+=w.x*texture2D(inputBuffer,vUv08);c+=w.y*texture2D(inputBuffer,vUv09);c+=w.z*texture2D(inputBuffer,vUv10);c+=w.w*texture2D(inputBuffer,vUv11);c+=WEIGHT_OUTER*texture2D(inputBuffer,vUv);gl_FragColor=c; #include }`,pV="uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv00;varying vec2 vUv01;varying vec2 vUv02;varying vec2 vUv03;varying vec2 vUv04;varying vec2 vUv05;varying vec2 vUv06;varying vec2 vUv07;varying vec2 vUv08;varying vec2 vUv09;varying vec2 vUv10;varying vec2 vUv11;void main(){vUv=position.xy*0.5+0.5;vUv00=vUv+texelSize*vec2(-1.0,1.0);vUv01=vUv+texelSize*vec2(1.0,1.0);vUv02=vUv+texelSize*vec2(-1.0,-1.0);vUv03=vUv+texelSize*vec2(1.0,-1.0);vUv04=vUv+texelSize*vec2(-2.0,2.0);vUv05=vUv+texelSize*vec2(0.0,2.0);vUv06=vUv+texelSize*vec2(2.0,2.0);vUv07=vUv+texelSize*vec2(-2.0,0.0);vUv08=vUv+texelSize*vec2(2.0,0.0);vUv09=vUv+texelSize*vec2(-2.0,-2.0);vUv10=vUv+texelSize*vec2(0.0,-2.0);vUv11=vUv+texelSize*vec2(2.0,-2.0);gl_Position=vec4(position.xy,1.0,1.0);}",mV=class extends Yn{constructor(){super({name:"DownsamplingMaterial",uniforms:{inputBuffer:new Ut(null),texelSize:new Ut(new Le)},blending:Pr,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:hV,vertexShader:pV})}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setSize(n,e){this.uniforms.texelSize.value.set(1/n,1/e)}},gV=`#ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer;uniform mediump sampler2D supportBuffer; #else uniform lowp sampler2D inputBuffer;uniform lowp sampler2D supportBuffer; #endif uniform float radius;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vec4 c=vec4(0.0);c+=texture2D(inputBuffer,vUv0)*0.0625;c+=texture2D(inputBuffer,vUv1)*0.125;c+=texture2D(inputBuffer,vUv2)*0.0625;c+=texture2D(inputBuffer,vUv3)*0.125;c+=texture2D(inputBuffer,vUv)*0.25;c+=texture2D(inputBuffer,vUv4)*0.125;c+=texture2D(inputBuffer,vUv5)*0.0625;c+=texture2D(inputBuffer,vUv6)*0.125;c+=texture2D(inputBuffer,vUv7)*0.0625;vec4 baseColor=texture2D(supportBuffer,vUv);gl_FragColor=mix(baseColor,c,radius); #include }`,vV="uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;varying vec2 vUv6;varying vec2 vUv7;void main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,1.0);vUv1=vUv+texelSize*vec2(0.0,1.0);vUv2=vUv+texelSize*vec2(1.0,1.0);vUv3=vUv+texelSize*vec2(-1.0,0.0);vUv4=vUv+texelSize*vec2(1.0,0.0);vUv5=vUv+texelSize*vec2(-1.0,-1.0);vUv6=vUv+texelSize*vec2(0.0,-1.0);vUv7=vUv+texelSize*vec2(1.0,-1.0);gl_Position=vec4(position.xy,1.0,1.0);}",yV=class extends Yn{constructor(){super({name:"UpsamplingMaterial",uniforms:{inputBuffer:new Ut(null),supportBuffer:new Ut(null),texelSize:new Ut(new Le),radius:new Ut(.85)},blending:Pr,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:gV,vertexShader:vV})}set inputBuffer(n){this.uniforms.inputBuffer.value=n}set supportBuffer(n){this.uniforms.supportBuffer.value=n}get radius(){return this.uniforms.radius.value}set radius(n){this.uniforms.radius.value=n}setSize(n,e){this.uniforms.texelSize.value.set(1/n,1/e)}},bV=class extends Ns{constructor(){super("MipmapBlurPass"),this.needsSwap=!1,this.renderTarget=new Gn(1,1,{depthBuffer:!1}),this.renderTarget.texture.name="Upsampling.Mipmap0",this.downsamplingMipmaps=[],this.upsamplingMipmaps=[],this.downsamplingMaterial=new mV,this.upsamplingMaterial=new yV,this.resolution=new Le}get texture(){return this.renderTarget.texture}get levels(){return this.downsamplingMipmaps.length}set levels(n){if(this.levels!==n){const e=this.renderTarget;this.dispose(),this.downsamplingMipmaps=[],this.upsamplingMipmaps=[];for(let t=0;t=0;--b){const x=g[b];h.setSize(y.width,y.height),h.inputBuffer=y.texture,h.supportBuffer=p[b].texture,n.setRenderTarget(x),n.render(a,l),y=x}}setSize(n,e){const t=this.resolution;t.set(n,e);let i=t.width,r=t.height;for(let a=0,l=this.downsamplingMipmaps.length;athis.setSize(x.baseWidth,x.baseHeight))}get texture(){return this.mipmapBlurPass.enabled?this.mipmapBlurPass.texture:this.renderTarget.texture}getTexture(){return this.texture}getResolution(){return this.resolution}getBlurPass(){return this.blurPass}getLuminancePass(){return this.luminancePass}get luminanceMaterial(){return this.luminancePass.fullscreenMaterial}getLuminanceMaterial(){return this.luminancePass.fullscreenMaterial}get width(){return this.resolution.width}set width(n){this.resolution.preferredWidth=n}get height(){return this.resolution.height}set height(n){this.resolution.preferredHeight=n}get dithering(){return this.blurPass.dithering}set dithering(n){this.blurPass.dithering=n}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(n){this.blurPass.kernelSize=n}get distinction(){return console.warn(this.name,"distinction was removed"),1}set distinction(n){console.warn(this.name,"distinction was removed")}get intensity(){return this.uniforms.get("intensity").value}set intensity(n){this.uniforms.get("intensity").value=n}getIntensity(){return this.intensity}setIntensity(n){this.intensity=n}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}update(n,e,t){const i=this.renderTarget,r=this.luminancePass;r.enabled?(r.render(n,e),this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(n,r.renderTarget):this.blurPass.render(n,r.renderTarget,i)):this.mipmapBlurPass.enabled?this.mipmapBlurPass.render(n,e):this.blurPass.render(n,e,i)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height),this.blurPass.resolution.copy(t),this.luminancePass.setSize(n,e),this.mipmapBlurPass.setSize(n,e)}initialize(n,e,t){this.blurPass.initialize(n,e,t),this.luminancePass.initialize(n,e,t),this.mipmapBlurPass.initialize(n,e,t),t!==void 0&&(this.renderTarget.texture.type=t,n!==null&&n.outputColorSpace===Fn&&(this.renderTarget.texture.colorSpace=Fn))}},SV=`#ifdef RADIAL_MODULATION uniform float modulationOffset; #endif varying float vActive;varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec2 ra=inputColor.ra;vec2 ba=inputColor.ba; #ifdef RADIAL_MODULATION const vec2 center=vec2(0.5);float d=distance(uv,center)*2.0;d=max(d-modulationOffset,0.0);if(vActive>0.0&&d>0.0){ra=texture2D(inputBuffer,mix(uv,vUvR,d)).ra;ba=texture2D(inputBuffer,mix(uv,vUvB,d)).ba;} #else if(vActive>0.0){ra=texture2D(inputBuffer,vUvR).ra;ba=texture2D(inputBuffer,vUvB).ba;} #endif outputColor=vec4(ra.x,inputColor.g,ba.x,max(max(ra.y,ba.y),inputColor.a));}`,MV="uniform vec2 offset;varying float vActive;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vec2 shift=offset*vec2(1.0,aspect);vActive=(shift.x!=0.0||shift.y!=0.0)?1.0:0.0;vUvR=uv+shift;vUvB=uv-shift;}",EV=class extends Wu{constructor({offset:n=new Le(.001,5e-4),radialModulation:e=!1,modulationOffset:t=.15}={}){super("ChromaticAberrationEffect",SV,{vertexShader:MV,attributes:Bu.CONVOLUTION,uniforms:new Map([["offset",new Ut(n)],["modulationOffset",new Ut(t)]])}),this.radialModulation=e}get offset(){return this.uniforms.get("offset").value}set offset(n){this.uniforms.get("offset").value=n}get radialModulation(){return this.defines.has("RADIAL_MODULATION")}set radialModulation(n){n?this.defines.set("RADIAL_MODULATION","1"):this.defines.delete("RADIAL_MODULATION"),this.setChanged()}get modulationOffset(){return this.uniforms.get("modulationOffset").value}set modulationOffset(n){this.uniforms.get("modulationOffset").value=n}getOffset(){return this.offset}setOffset(n){this.offset=n}},TO=class extends Ns{constructor(n,e,t=null){super("RenderPass",n,e),this.needsSwap=!1,this.clearPass=new MO,this.overrideMaterialManager=t===null?null:new EC(t),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}set mainScene(n){this.scene=n}set mainCamera(n){this.camera=n}get renderToScreen(){return super.renderToScreen}set renderToScreen(n){super.renderToScreen=n,this.clearPass.renderToScreen=n}get overrideMaterial(){const n=this.overrideMaterialManager;return n!==null?n.material:null}set overrideMaterial(n){const e=this.overrideMaterialManager;n!==null?e!==null?e.setMaterial(n):this.overrideMaterialManager=new EC(n):e!==null&&(e.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(n){this.overrideMaterial=n}get clear(){return this.clearPass.enabled}set clear(n){this.clearPass.enabled=n}getSelection(){return this.selection}setSelection(n){this.selection=n}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(n){this.ignoreBackground=n}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(n){this.skipShadowMapUpdate=n}getClearPass(){return this.clearPass}render(n,e,t,i,r){const a=this.scene,l=this.camera,u=this.selection,h=l.layers.mask,p=a.background,g=n.shadowMap.autoUpdate,y=this.renderToScreen?null:e;u!==null&&l.layers.set(u.getLayer()),this.skipShadowMapUpdate&&(n.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(a.background=null),this.clearPass.enabled&&this.clearPass.render(n,e),n.setRenderTarget(y),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(n,a,l):n.render(a,l),l.layers.mask=h,a.background=p,n.shadowMap.autoUpdate=g}},Rs={LINEAR:0,REINHARD:1,REINHARD2:2,REINHARD2_ADAPTIVE:3,UNCHARTED2:4,OPTIMIZED_CINEON:5,CINEON:5,ACES_FILMIC:6,AGX:7,NEUTRAL:8},Rg={DEFAULT:0,ESKIL:1},TV=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*(1.0+time))); #ifdef PREMULTIPLY outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a); #else outputColor=vec4(noise,inputColor.a); #endif }`,wV=class extends Wu{constructor({blendFunction:n=vn.SCREEN,premultiply:e=!1}={}){super("NoiseEffect",TV,{blendFunction:n}),this.premultiply=e}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(n){this.premultiply!==n&&(n?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}isPremultiplied(){return this.premultiply}setPremultiplied(n){this.premultiply=n}},AV=`#include #ifdef GL_FRAGMENT_PRECISION_HIGH uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif #ifdef DOWNSAMPLE_NORMALS uniform lowp sampler2D normalBuffer; #endif varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 return unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else return texture2D(depthBuffer,uv).r; #endif }int findBestDepth(const in float samples[4]){float c=(samples[0]+samples[1]+samples[2]+samples[3])*0.25;float distances[4];distances[0]=abs(c-samples[0]);distances[1]=abs(c-samples[1]);distances[2]=abs(c-samples[2]);distances[3]=abs(c-samples[3]);float maxDistance=max(max(distances[0],distances[1]),max(distances[2],distances[3]));int remaining[3];int rejected[3];int i,j,k;for(i=0,j=0,k=0;i<4;++i){if(distances[i]this.setSize(u.baseWidth,u.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}setDepthTexture(n,e=Zu){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e}render(n,e,t,i,r){n.setRenderTarget(this.renderToScreen?null:this.renderTarget),n.render(this.scene,this.camera)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height),this.fullscreenMaterial.setSize(n,e)}initialize(n,e,t){const i=n.getContext();if(!(i.getExtension("EXT_color_buffer_float")||i.getExtension("EXT_color_buffer_half_float")))throw new Error("Rendering to float texture is not supported.")}},OV=`#include #define packFloatToRGBA(v) packDepthToRGBA(v) #define unpackRGBAToFloat(v) unpackRGBAToDepth(v) uniform lowp sampler2D luminanceBuffer0;uniform lowp sampler2D luminanceBuffer1;uniform float minLuminance;uniform float deltaTime;uniform float tau;varying vec2 vUv;void main(){float l0=unpackRGBAToFloat(texture2D(luminanceBuffer0,vUv)); #if __VERSION__ < 300 float l1=texture2DLodEXT(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r; #else float l1=textureLod(luminanceBuffer1,vUv,MIP_LEVEL_1X1).r; #endif l0=max(minLuminance,l0);l1=max(minLuminance,l1);float adaptedLum=l0+(l1-l0)*(1.0-exp(-deltaTime*tau));gl_FragColor=(adaptedLum==1.0)?vec4(1.0):packFloatToRGBA(adaptedLum);}`,PV=class extends Yn{constructor(){super({name:"AdaptiveLuminanceMaterial",defines:{MIP_LEVEL_1X1:"0.0"},uniforms:{luminanceBuffer0:new Ut(null),luminanceBuffer1:new Ut(null),minLuminance:new Ut(.01),deltaTime:new Ut(0),tau:new Ut(1)},extensions:{shaderTextureLOD:!0},blending:Pr,toneMapped:!1,depthWrite:!1,depthTest:!1,fragmentShader:OV,vertexShader:QE})}set luminanceBuffer0(n){this.uniforms.luminanceBuffer0.value=n}setLuminanceBuffer0(n){this.uniforms.luminanceBuffer0.value=n}set luminanceBuffer1(n){this.uniforms.luminanceBuffer1.value=n}setLuminanceBuffer1(n){this.uniforms.luminanceBuffer1.value=n}set mipLevel1x1(n){this.defines.MIP_LEVEL_1X1=n.toFixed(1),this.needsUpdate=!0}setMipLevel1x1(n){this.mipLevel1x1=n}set deltaTime(n){this.uniforms.deltaTime.value=n}setDeltaTime(n){this.uniforms.deltaTime.value=n}get minLuminance(){return this.uniforms.minLuminance.value}set minLuminance(n){this.uniforms.minLuminance.value=n}getMinLuminance(){return this.uniforms.minLuminance.value}setMinLuminance(n){this.uniforms.minLuminance.value=n}get adaptationRate(){return this.uniforms.tau.value}set adaptationRate(n){this.uniforms.tau.value=n}getAdaptationRate(){return this.uniforms.tau.value}setAdaptationRate(n){this.uniforms.tau.value=n}},IV=class extends Ns{constructor(n,{minLuminance:e=.01,adaptationRate:t=1}={}){super("AdaptiveLuminancePass"),this.fullscreenMaterial=new PV,this.needsSwap=!1,this.renderTargetPrevious=new Gn(1,1,{minFilter:Kn,magFilter:Kn,depthBuffer:!1}),this.renderTargetPrevious.texture.name="Luminance.Previous";const i=this.fullscreenMaterial;i.luminanceBuffer0=this.renderTargetPrevious.texture,i.luminanceBuffer1=n,i.minLuminance=e,i.adaptationRate=t,this.renderTargetAdapted=this.renderTargetPrevious.clone(),this.renderTargetAdapted.texture.name="Luminance.Adapted",this.copyPass=new SO(this.renderTargetPrevious,!1)}get texture(){return this.renderTargetAdapted.texture}getTexture(){return this.renderTargetAdapted.texture}set mipLevel1x1(n){this.fullscreenMaterial.mipLevel1x1=n}get adaptationRate(){return this.fullscreenMaterial.adaptationRate}set adaptationRate(n){this.fullscreenMaterial.adaptationRate=n}render(n,e,t,i,r){this.fullscreenMaterial.deltaTime=i,n.setRenderTarget(this.renderToScreen?null:this.renderTargetAdapted),n.render(this.scene,this.camera),this.copyPass.render(n,this.renderTargetAdapted)}},NV=`#include uniform float whitePoint; #if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3 uniform float middleGrey; #if TONE_MAPPING_MODE == 3 uniform lowp sampler2D luminanceBuffer; #else uniform float averageLuminance; #endif vec3 Reinhard2ToneMapping(vec3 color){color*=toneMappingExposure;float l=luminance(color); #if TONE_MAPPING_MODE == 3 float lumAvg=unpackRGBAToFloat(texture2D(luminanceBuffer,vec2(0.5))); #else float lumAvg=averageLuminance; #endif float lumScaled=(l*middleGrey)/max(lumAvg,1e-6);float lumCompressed=lumScaled*(1.0+lumScaled/(whitePoint*whitePoint));lumCompressed/=(1.0+lumScaled);return clamp(lumCompressed*color,0.0,1.0);} #elif TONE_MAPPING_MODE == 4 #define A 0.15 #define B 0.50 #define C 0.10 #define D 0.20 #define E 0.02 #define F 0.30 vec3 Uncharted2Helper(const in vec3 x){return((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}vec3 Uncharted2ToneMapping(vec3 color){color*=toneMappingExposure;return clamp(Uncharted2Helper(color)/Uncharted2Helper(vec3(whitePoint)),0.0,1.0);} #endif void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){ #if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3 outputColor=vec4(Reinhard2ToneMapping(inputColor.rgb),inputColor.a); #elif TONE_MAPPING_MODE == 4 outputColor=vec4(Uncharted2ToneMapping(inputColor.rgb),inputColor.a); #else outputColor=vec4(toneMapping(inputColor.rgb),inputColor.a); #endif }`,LV=class extends Wu{constructor({blendFunction:n=vn.SRC,adaptive:e=!1,mode:t=e?Rs.REINHARD2_ADAPTIVE:Rs.AGX,resolution:i=256,maxLuminance:r=4,whitePoint:a=r,middleGrey:l=.6,minLuminance:u=.01,averageLuminance:h=1,adaptationRate:p=1}={}){super("ToneMappingEffect",NV,{blendFunction:n,uniforms:new Map([["luminanceBuffer",new Ut(null)],["maxLuminance",new Ut(r)],["whitePoint",new Ut(a)],["middleGrey",new Ut(l)],["averageLuminance",new Ut(h)]])}),this.renderTargetLuminance=new Gn(1,1,{minFilter:Io,depthBuffer:!1}),this.renderTargetLuminance.texture.generateMipmaps=!0,this.renderTargetLuminance.texture.name="Luminance",this.luminancePass=new EO({renderTarget:this.renderTargetLuminance}),this.adaptiveLuminancePass=new IV(this.luminancePass.texture,{minLuminance:u,adaptationRate:p}),this.uniforms.get("luminanceBuffer").value=this.adaptiveLuminancePass.texture,this.resolution=i,this.mode=t}get mode(){return Number(this.defines.get("TONE_MAPPING_MODE"))}set mode(n){if(this.mode===n)return;const t=Td.replace(/\D+/g,"")>=168?"CineonToneMapping(texel)":"OptimizedCineonToneMapping(texel)";switch(this.defines.clear(),this.defines.set("TONE_MAPPING_MODE",n.toFixed(0)),n){case Rs.LINEAR:this.defines.set("toneMapping(texel)","LinearToneMapping(texel)");break;case Rs.REINHARD:this.defines.set("toneMapping(texel)","ReinhardToneMapping(texel)");break;case Rs.CINEON:case Rs.OPTIMIZED_CINEON:this.defines.set("toneMapping(texel)",t);break;case Rs.ACES_FILMIC:this.defines.set("toneMapping(texel)","ACESFilmicToneMapping(texel)");break;case Rs.AGX:this.defines.set("toneMapping(texel)","AgXToneMapping(texel)");break;case Rs.NEUTRAL:this.defines.set("toneMapping(texel)","NeutralToneMapping(texel)");break;default:this.defines.set("toneMapping(texel)","texel");break}this.adaptiveLuminancePass.enabled=n===Rs.REINHARD2_ADAPTIVE,this.setChanged()}getMode(){return this.mode}setMode(n){this.mode=n}get whitePoint(){return this.uniforms.get("whitePoint").value}set whitePoint(n){this.uniforms.get("whitePoint").value=n}get middleGrey(){return this.uniforms.get("middleGrey").value}set middleGrey(n){this.uniforms.get("middleGrey").value=n}get averageLuminance(){return this.uniforms.get("averageLuminance").value}set averageLuminance(n){this.uniforms.get("averageLuminance").value=n}get adaptiveLuminanceMaterial(){return this.adaptiveLuminancePass.fullscreenMaterial}getAdaptiveLuminanceMaterial(){return this.adaptiveLuminanceMaterial}get resolution(){return this.luminancePass.resolution.width}set resolution(n){const e=Math.max(0,Math.ceil(Math.log2(n))),t=Math.pow(2,e);this.luminancePass.resolution.setPreferredSize(t,t),this.adaptiveLuminanceMaterial.mipLevel1x1=e}getResolution(){return this.resolution}setResolution(n){this.resolution=n}get adaptive(){return this.mode===Rs.REINHARD2_ADAPTIVE}set adaptive(n){this.mode=n?Rs.REINHARD2_ADAPTIVE:Rs.REINHARD2}get adaptationRate(){return this.adaptiveLuminanceMaterial.adaptationRate}set adaptationRate(n){this.adaptiveLuminanceMaterial.adaptationRate=n}get distinction(){return console.warn(this.name,"distinction was removed."),1}set distinction(n){console.warn(this.name,"distinction was removed.")}update(n,e,t){this.adaptiveLuminancePass.enabled&&(this.luminancePass.render(n,e),this.adaptiveLuminancePass.render(n,null,null,t))}initialize(n,e,t){this.adaptiveLuminancePass.initialize(n,e,t)}},UV=`uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb; #if VIGNETTE_TECHNIQUE == 0 float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset)); #else vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord)); #endif outputColor=vec4(color,inputColor.a);}`,zV=class extends Wu{constructor({blendFunction:n,eskil:e=!1,technique:t=e?Rg.ESKIL:Rg.DEFAULT,offset:i=.5,darkness:r=.5}={}){super("VignetteEffect",UV,{blendFunction:n,defines:new Map([["VIGNETTE_TECHNIQUE",t.toFixed(0)]]),uniforms:new Map([["offset",new Ut(i)],["darkness",new Ut(r)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(n){this.technique!==n&&(this.defines.set("VIGNETTE_TECHNIQUE",n.toFixed(0)),this.setChanged())}get eskil(){return this.technique===Rg.ESKIL}set eskil(n){this.technique=n?Rg.ESKIL:Rg.DEFAULT}getTechnique(){return this.technique}setTechnique(n){this.technique=n}get offset(){return this.uniforms.get("offset").value}set offset(n){this.uniforms.get("offset").value=n}getOffset(){return this.offset}setOffset(n){this.offset=n}get darkness(){return this.uniforms.get("darkness").value}set darkness(n){this.uniforms.get("darkness").value=n}getDarkness(){return this.darkness}setDarkness(n){this.darkness=n}},BV=`#include #include #include #define packFloatToRGBA(v) packDepthToRGBA(v) #define unpackRGBAToFloat(v) unpackRGBAToDepth(v) #ifdef FRAMEBUFFER_PRECISION_HIGH uniform mediump sampler2D inputBuffer; #else uniform lowp sampler2D inputBuffer; #endif #if DEPTH_PACKING == 3201 uniform lowp sampler2D depthBuffer; #elif defined(GL_FRAGMENT_PRECISION_HIGH) uniform highp sampler2D depthBuffer; #else uniform mediump sampler2D depthBuffer; #endif uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;vec4 sRGBToLinear(const in vec4 value){return vec4(mix(pow(value.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),value.rgb*0.0773993808,vec3(lessThanEqual(value.rgb,vec3(0.04045)))),value.a);}float readDepth(const in vec2 uv){ #if DEPTH_PACKING == 3201 float depth=unpackRGBAToDepth(texture2D(depthBuffer,uv)); #else float depth=texture2D(depthBuffer,uv).r; #endif #if defined(USE_LOGARITHMIC_DEPTH_BUFFER) || defined(LOG_DEPTH) float d=pow(2.0,depth*log2(cameraFar+1.0))-1.0;float a=cameraFar/(cameraFar-cameraNear);float b=cameraFar*cameraNear/(cameraNear-cameraFar);depth=a+b/d; #elif defined(USE_REVERSED_DEPTH_BUFFER) depth=1.0-depth; #endif return depth;}float getViewZ(const in float depth){ #ifdef PERSPECTIVE_CAMERA return perspectiveDepthToViewZ(depth,cameraNear,cameraFar); #else return orthographicDepthToViewZ(depth,cameraNear,cameraFar); #endif }vec3 RGBToHCV(const in vec3 RGB){vec4 P=mix(vec4(RGB.bg,-1.0,2.0/3.0),vec4(RGB.gb,0.0,-1.0/3.0),step(RGB.b,RGB.g));vec4 Q=mix(vec4(P.xyw,RGB.r),vec4(RGB.r,P.yzx),step(P.x,RGB.r));float C=Q.x-min(Q.w,Q.y);float H=abs((Q.w-Q.y)/(6.0*C+EPSILON)+Q.z);return vec3(H,C,Q.x);}vec3 RGBToHSL(const in vec3 RGB){vec3 HCV=RGBToHCV(RGB);float L=HCV.z-HCV.y*0.5;float S=HCV.y/(1.0-abs(L*2.0-1.0)+EPSILON);return vec3(HCV.x,S,L);}vec3 HueToRGB(const in float H){float R=abs(H*6.0-3.0)-1.0;float G=2.0-abs(H*6.0-2.0);float B=2.0-abs(H*6.0-4.0);return clamp(vec3(R,G,B),0.0,1.0);}vec3 HSLToRGB(const in vec3 HSL){vec3 RGB=HueToRGB(HSL.x);float C=(1.0-abs(2.0*HSL.z-1.0))*HSL.y;return(RGB-0.5)*C+HSL.z;}FRAGMENT_HEAD void main(){FRAGMENT_MAIN_UV vec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGE color0.a=clamp(color0.a,0.0,1.0);gl_FragColor=color0; #ifdef ENCODE_OUTPUT #include #endif #include }`,FV="uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEAD void main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORT gl_Position=vec4(position.xy,1.0,1.0);}",kV=class extends Yn{constructor(n,e,t,i,r=!1){super({name:"EffectMaterial",defines:{THREE_REVISION:Td.replace(/\D+/g,""),DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new Ut(null),depthBuffer:new Ut(null),resolution:new Ut(new Le),texelSize:new Ut(new Le),cameraNear:new Ut(.3),cameraFar:new Ut(1e3),aspect:new Ut(1),time:new Ut(0)},blending:Pr,toneMapped:!1,depthWrite:!1,depthTest:!1,dithering:r}),n&&this.setShaderParts(n),e&&this.setDefines(e),t&&this.setUniforms(t),this.copyCameraSettings(i)}set inputBuffer(n){this.uniforms.inputBuffer.value=n}setInputBuffer(n){this.uniforms.inputBuffer.value=n}get depthBuffer(){return this.uniforms.depthBuffer.value}set depthBuffer(n){this.uniforms.depthBuffer.value=n}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(n){this.defines.DEPTH_PACKING=n.toFixed(0),this.needsUpdate=!0}setDepthBuffer(n,e=Zu){this.depthBuffer=n,this.depthPacking=e}setShaderData(n){this.setShaderParts(n.shaderParts),this.setDefines(n.defines),this.setUniforms(n.uniforms),this.setExtensions(n.extensions)}setShaderParts(n){return this.fragmentShader=BV.replace(Bn.FRAGMENT_HEAD,n.get(Bn.FRAGMENT_HEAD)||"").replace(Bn.FRAGMENT_MAIN_UV,n.get(Bn.FRAGMENT_MAIN_UV)||"").replace(Bn.FRAGMENT_MAIN_IMAGE,n.get(Bn.FRAGMENT_MAIN_IMAGE)||""),this.vertexShader=FV.replace(Bn.VERTEX_HEAD,n.get(Bn.VERTEX_HEAD)||"").replace(Bn.VERTEX_MAIN_SUPPORT,n.get(Bn.VERTEX_MAIN_SUPPORT)||""),this.needsUpdate=!0,this}setDefines(n){for(const e of n.entries())this.defines[e[0]]=e[1];return this.needsUpdate=!0,this}setUniforms(n){for(const e of n.entries())this.uniforms[e[0]]=e[1];return this}setExtensions(n){this.extensions={};for(const e of n)this.extensions[e]=!0;return this}get encodeOutput(){return this.defines.ENCODE_OUTPUT!==void 0}set encodeOutput(n){this.encodeOutput!==n&&(n?this.defines.ENCODE_OUTPUT="1":delete this.defines.ENCODE_OUTPUT,this.needsUpdate=!0)}isOutputEncodingEnabled(n){return this.encodeOutput}setOutputEncodingEnabled(n){this.encodeOutput=n}get time(){return this.uniforms.time.value}set time(n){this.uniforms.time.value=n}setDeltaTime(n){this.uniforms.time.value+=n}adoptCameraSettings(n){this.copyCameraSettings(n)}copyCameraSettings(n){n&&(this.uniforms.cameraNear.value=n.near,this.uniforms.cameraFar.value=n.far,n instanceof $i?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(n,e){const t=this.uniforms;t.resolution.value.set(n,e),t.texelSize.value.set(1/n,1/e),t.aspect.value=n/e}static get Section(){return Bn}};function TC(n,e,t){for(const i of e){const r="$1"+n+i.charAt(0).toUpperCase()+i.slice(1),a=new RegExp("([^\\.])(\\b"+i+"\\b)","g");for(const l of t.entries())l[1]!==null&&t.set(l[0],l[1].replace(a,r))}}function HV(n,e,t){let i=e.getFragmentShader(),r=e.getVertexShader();const a=i!==void 0&&/mainImage/.test(i),l=i!==void 0&&/mainUv/.test(i);if(t.attributes|=e.getAttributes(),i===void 0)throw new Error(`Missing fragment shader (${e.name})`);if(l&&(t.attributes&Bu.CONVOLUTION)!==0)throw new Error(`Effects that transform UVs are incompatible with convolution effects (${e.name})`);if(!a&&!l)throw new Error(`Could not find mainImage or mainUv function (${e.name})`);{const u=/\w+\s+(\w+)\([\w\s,]*\)\s*{/g,h=t.shaderParts;let p=h.get(Bn.FRAGMENT_HEAD)||"",g=h.get(Bn.FRAGMENT_MAIN_UV)||"",y=h.get(Bn.FRAGMENT_MAIN_IMAGE)||"",b=h.get(Bn.VERTEX_HEAD)||"",x=h.get(Bn.VERTEX_MAIN_SUPPORT)||"";const M=new Set,A=new Set;if(l&&(g+=` ${n}MainUv(UV); `,t.uvTransformation=!0),r!==null&&/mainSupport/.test(r)){const R=/mainSupport *\([\w\s]*?uv\s*?\)/.test(r);x+=` ${n}MainSupport(`,x+=R?`vUv); `:`); `;for(const D of r.matchAll(/(?:varying\s+\w+\s+([\S\s]*?);)/g))for(const P of D[1].split(/\s*,\s*/))t.varyings.add(P),M.add(P),A.add(P);for(const D of r.matchAll(u))A.add(D[1])}for(const R of i.matchAll(u))A.add(R[1]);for(const R of e.defines.keys())A.add(R.replace(/\([\w\s,]*\)/g,""));for(const R of e.uniforms.keys())A.add(R);A.delete("while"),A.delete("for"),A.delete("if"),e.uniforms.forEach((R,D)=>t.uniforms.set(n+D.charAt(0).toUpperCase()+D.slice(1),R)),e.defines.forEach((R,D)=>t.defines.set(n+D.charAt(0).toUpperCase()+D.slice(1),R));const w=new Map([["fragment",i],["vertex",r]]);TC(n,A,t.defines),TC(n,A,w),i=w.get("fragment"),r=w.get("vertex");const E=e.blendMode;if(t.blendModes.set(E.blendFunction,E),a){e.inputColorSpace!==null&&e.inputColorSpace!==t.colorSpace&&(y+=e.inputColorSpace===Fn?`color0 = sRGBTransferOETF(color0); `:`color0 = sRGBToLinear(color0); `),e.outputColorSpace!==Po?t.colorSpace=e.outputColorSpace:e.inputColorSpace!==null&&(t.colorSpace=e.inputColorSpace);const R=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;y+=`${n}MainImage(color0, UV, `,(t.attributes&Bu.DEPTH)!==0&&R.test(i)&&(y+="depth, ",t.readDepth=!0),y+=`color1); `;const D=n+"BlendOpacity";t.uniforms.set(D,E.opacity),y+=`color0 = blend${E.blendFunction}(color0, color1, ${D}); `,p+=`uniform float ${D}; `}if(p+=i+` `,r!==null&&(b+=r+` `),h.set(Bn.FRAGMENT_HEAD,p),h.set(Bn.FRAGMENT_MAIN_UV,g),h.set(Bn.FRAGMENT_MAIN_IMAGE,y),h.set(Bn.VERTEX_HEAD,b),h.set(Bn.VERTEX_MAIN_SUPPORT,x),e.extensions!==null)for(const R of e.extensions)t.extensions.add(R)}}var VV=class extends Ns{constructor(n,...e){super("EffectPass"),this.fullscreenMaterial=new kV(null,null,null,n),this.listener=t=>this.handleEvent(t),this.effects=[],this.setEffects(e),this.skipRendering=!1,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY,this.timeScale=1}set mainScene(n){for(const e of this.effects)e.mainScene=n}set mainCamera(n){this.fullscreenMaterial.copyCameraSettings(n);for(const e of this.effects)e.mainCamera=n}get encodeOutput(){return this.fullscreenMaterial.encodeOutput}set encodeOutput(n){this.fullscreenMaterial.encodeOutput=n}get dithering(){return this.fullscreenMaterial.dithering}set dithering(n){const e=this.fullscreenMaterial;e.dithering=n,e.needsUpdate=!0}setEffects(n){for(const e of this.effects)e.removeEventListener("change",this.listener);this.effects=n.sort((e,t)=>t.attributes-e.attributes);for(const e of this.effects)e.addEventListener("change",this.listener)}updateMaterial(){const n=new TH;let e=0;for(const l of this.effects)if(l.blendMode.blendFunction===vn.DST)n.attributes|=l.getAttributes()&Bu.DEPTH;else{if((n.attributes&l.getAttributes()&Bu.CONVOLUTION)!==0)throw new Error(`Convolution effects cannot be merged (${l.name})`);HV("e"+e++,l,n)}let t=n.shaderParts.get(Bn.FRAGMENT_HEAD),i=n.shaderParts.get(Bn.FRAGMENT_MAIN_IMAGE),r=n.shaderParts.get(Bn.FRAGMENT_MAIN_UV);const a=/\bblend\b/g;for(const l of n.blendModes.values())t+=l.getShaderCode().replace(a,`blend${l.blendFunction}`)+` `;(n.attributes&Bu.DEPTH)!==0?(n.readDepth&&(i=`float depth = readDepth(UV); `+i),this.needsDepthTexture=this.getDepthTexture()===null):this.needsDepthTexture=!1,n.colorSpace===Fn&&(i+=`color0 = sRGBToLinear(color0); `),n.uvTransformation?(r=`vec2 transformedUv = vUv; `+r,n.defines.set("UV","transformedUv")):n.defines.set("UV","vUv"),n.shaderParts.set(Bn.FRAGMENT_HEAD,t),n.shaderParts.set(Bn.FRAGMENT_MAIN_IMAGE,i),n.shaderParts.set(Bn.FRAGMENT_MAIN_UV,r);for(const[l,u]of n.shaderParts)u!==null&&n.shaderParts.set(l,u.trim().replace(/^#/,` #`));this.skipRendering=e===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderData(n)}recompile(){this.updateMaterial()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(n,e=Zu){this.fullscreenMaterial.depthBuffer=n,this.fullscreenMaterial.depthPacking=e;for(const t of this.effects)t.setDepthTexture(n,e)}render(n,e,t,i,r){for(const a of this.effects)a.update(n,e,i);if(!this.skipRendering||this.renderToScreen){const a=this.fullscreenMaterial;a.inputBuffer=e.texture,a.time+=i*this.timeScale,n.setRenderTarget(this.renderToScreen?null:t),n.render(this.scene,this.camera)}}setSize(n,e){this.fullscreenMaterial.setSize(n,e);for(const t of this.effects)t.setSize(n,e)}initialize(n,e,t){this.renderer=n;for(const i of this.effects)i.initialize(n,e,t);this.updateMaterial(),t!==void 0&&t!==Xi&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(const n of this.effects)n.removeEventListener("change",this.listener),n.dispose()}handleEvent(n){n.type==="change"&&this.recompile()}},GV=class extends Ns{constructor(n,e,{renderTarget:t,resolutionScale:i=1,width:r=ls.AUTO_SIZE,height:a=ls.AUTO_SIZE,resolutionX:l=r,resolutionY:u=a}={}){super("NormalPass"),this.needsSwap=!1,this.renderPass=new TO(n,e,new LE);const h=this.renderPass;h.ignoreBackground=!0,h.skipShadowMapUpdate=!0;const p=h.getClearPass();p.overrideClearColor=new pt(7829503),p.overrideClearAlpha=1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new Gn(1,1,{minFilter:Kn,magFilter:Kn}),this.renderTarget.texture.name="NormalPass.Target");const g=this.resolution=new ls(this,l,u,i);g.addEventListener("change",y=>this.setSize(g.baseWidth,g.baseHeight))}set mainScene(n){this.renderPass.mainScene=n}set mainCamera(n){this.renderPass.mainCamera=n}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}getResolutionScale(){return this.resolution.scale}setResolutionScale(n){this.resolution.scale=n}render(n,e,t,i,r){const a=this.renderToScreen?null:this.renderTarget;this.renderPass.render(n,a,a)}setSize(n,e){const t=this.resolution;t.setBaseSize(n,e),this.renderTarget.setSize(t.width,t.height)}};function Zg(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}new Le;new Le;function wO(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}var Ja=function n(e,t,i){var r=this;wO(this,n),Zg(this,"dot2",function(a,l){return r.x*a+r.y*l}),Zg(this,"dot3",function(a,l,u){return r.x*a+r.y*l+r.z*u}),this.x=e,this.y=t,this.z=i},WV=[new Ja(1,1,0),new Ja(-1,1,0),new Ja(1,-1,0),new Ja(-1,-1,0),new Ja(1,0,1),new Ja(-1,0,1),new Ja(1,0,-1),new Ja(-1,0,-1),new Ja(0,1,1),new Ja(0,-1,1),new Ja(0,1,-1),new Ja(0,-1,-1)],wC=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],AC=new Array(512),CC=new Array(512),$V=function(e){e>0&&e<1&&(e*=65536),e=Math.floor(e),e<256&&(e|=e<<8);for(var t=0;t<256;t++){var i;t&1?i=wC[t]^e&255:i=wC[t]^e>>8&255,AC[t]=AC[t+256]=i,CC[t]=CC[t+256]=WV[i%12]}};$V(0);function XV(n){if(typeof n=="number")n=Math.abs(n);else if(typeof n=="string"){var e=n;n=0;for(var t=0;t(n.getAttributes()&2)===2,YV=U.memo(U.forwardRef(({children:n,camera:e,scene:t,resolutionScale:i,enabled:r=!0,renderPriority:a=1,autoClear:l=!0,depthBuffer:u,enableNormalPass:h,stencilBuffer:p,multisampling:g=8,frameBufferType:y=no},b)=>{const{gl:x,scene:M,camera:A,size:w}=br(),E=t||M,R=e||A,[D,P,F]=U.useMemo(()=>{const V=new EH(x,{depthBuffer:u,stencilBuffer:p,multisampling:g,frameBufferType:y});V.addPass(new TO(E,R));let N=null,z=null;return h&&(z=new GV(E,R),z.enabled=!1,V.addPass(z),i!==void 0&&(N=new DV({normalBuffer:z.texture,resolutionScale:i}),N.enabled=!1,V.addPass(N))),[V,z,N]},[R,x,u,p,g,y,E,h,i]);U.useEffect(()=>D?.setSize(w.width,w.height),[D,w]),pd((V,N)=>{if(r){const z=x.autoClear;x.autoClear=l,p&&!l&&x.clearStencil(),D.render(N),x.autoClear=z}},r?a:0);const L=U.useRef(null);U.useLayoutEffect(()=>{const V=[],N=L.current.__r3f;if(N&&D){const z=N.children;for(let X=0;X{for(const z of V)D?.removePass(z);P&&(P.enabled=!1),F&&(F.enabled=!1)}},[D,n,R,P,F]),U.useEffect(()=>{const V=x.toneMapping;return x.toneMapping=xa,()=>{x.toneMapping=V}},[x]);const k=U.useMemo(()=>({composer:D,normalPass:P,downSamplingPass:F,resolutionScale:i,camera:R,scene:E}),[D,P,F,i,R,E]);return U.useImperativeHandle(b,()=>D,[D]),ut.jsx(qV.Provider,{value:k,children:ut.jsx("group",{ref:L,children:n})})}));let ZV=0;const OC=new WeakMap,z0=(n,e)=>function({blendFunction:t=e?.blendFunction,opacity:i=e?.opacity,...r}){let a=OC.get(n);if(!a){const h=`@react-three/postprocessing/${n.name}-${ZV++}`;rO({[h]:n}),OC.set(n,a=h)}const l=br(h=>h.camera),u=se.useMemo(()=>[...e?.args??[],...r.args??[{...e,...r}]],[JSON.stringify(r)]);return ut.jsx(a,{camera:l,"blendMode-blendFunction":t,"blendMode-opacity-value":i,...r,args:u})},KV=z0(_V,{blendFunction:0}),QV=z0(EV),JV=z0(wV,{blendFunction:5}),e8=z0(LV),t8=z0(zV);var eT=a3();const n8=Yu(eT);function PC(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function Dd(...n){return e=>{let t=!1;const i=n.map(r=>{const a=PC(r,e);return!t&&typeof a=="function"&&(t=!0),a});if(t)return()=>{for(let r=0;r{let{children:a,...l}=i;AO(a)&&typeof Ix=="function"&&(a=Ix(a._payload));const u=U.Children.toArray(a),h=u.find(l8);if(h){const p=h.props.children,g=u.map(y=>y===h?U.Children.count(p)>1?U.Children.only(null):U.isValidElement(p)?p.props.children:null:y);return ut.jsx(e,{...l,ref:r,children:U.isValidElement(p)?U.cloneElement(p,void 0,g):null})}return ut.jsx(e,{...l,ref:r,children:a})});return t.displayName=`${n}.Slot`,t}function a8(n){const e=U.forwardRef((t,i)=>{let{children:r,...a}=t;if(AO(r)&&typeof Ix=="function"&&(r=Ix(r._payload)),U.isValidElement(r)){const l=u8(r),u=c8(a,r.props);return r.type!==U.Fragment&&(u.ref=i?Dd(i,l):l),U.cloneElement(r,u)}return U.Children.count(r)>1?U.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var o8=Symbol("radix.slottable");function l8(n){return U.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===o8}function c8(n,e){const t={...e};for(const i in e){const r=n[i],a=e[i];/^on[A-Z]/.test(i)?r&&a?t[i]=(...u)=>{const h=a(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...a}:i==="className"&&(t[i]=[r,a].filter(Boolean).join(" "))}return{...n,...t}}function u8(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var f8=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],d8=f8.reduce((n,e)=>{const t=s8(`Primitive.${e}`),i=U.forwardRef((r,a)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ut.jsx(h,{...u,ref:a})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{}),$u=globalThis?.document?U.useLayoutEffect:()=>{},h8="Portal",CO=U.forwardRef((n,e)=>{const{container:t,...i}=n,[r,a]=U.useState(!1);$u(()=>a(!0),[]);const l=t||r&&globalThis?.document?.body;return l?n8.createPortal(ut.jsx(d8.div,{...i,ref:e}),l):null});CO.displayName=h8;var p8=CO,IC=Object.prototype.hasOwnProperty;function b0(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&b0(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(IC.call(n,t)&&++i&&!IC.call(e,t)||!(t in e)||!b0(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}function P_(n,e){if(Object.is(n,e))return!0;if(typeof n!="object"||n===null||typeof e!="object"||e===null)return!1;const t=Object.keys(n);if(t.length!==Object.keys(e).length)return!1;for(let i=0;i0;)l[u]=arguments[u+4];n.call(this,l),n.captureStackTrace&&n.captureStackTrace(this,e),this.rule=t,this.value=i,this.cause=r,this.target=a}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e})(Error),Ol=function(e,t){e===void 0&&(e=[]),t===void 0&&(t=[]),this.chain=e,this.nextRuleModifiers=t};Ol.prototype._applyRule=function(e,t){var i=this;return function(){for(var r=[],a=arguments.length;a--;)r[a]=arguments[a];return i.chain.push(new I_(t,e.apply(i,r),r,i.nextRuleModifiers)),i.nextRuleModifiers=[],i}};Ol.prototype._applyModifier=function(e,t){return this.nextRuleModifiers.push(new m8(t,e.simple,e.async)),this};Ol.prototype._clone=function(){return new Ol(this.chain.slice(),this.nextRuleModifiers.slice())};Ol.prototype.test=function(e){return this.chain.every(function(t){return t._test(e)})};Ol.prototype.testAll=function(e){var t=[];return this.chain.forEach(function(i){try{i._check(e)}catch(r){t.push(new tT(i,e,r))}}),t};Ol.prototype.check=function(e){this.chain.forEach(function(t){try{t._check(e)}catch(i){throw new tT(t,e,i)}})};Ol.prototype.testAsync=function(e){var t=this;return new Promise(function(i,r){OO(e,t.chain.slice(),i,r)})};function OO(n,e,t,i){if(e.length){var r=e.shift();r._testAsync(n).then(function(){OO(n,e,t,i)},function(a){i(new tT(r,n,a))})}else t(n)}var NC=function(n,e){return e&&typeof n=="string"&&n.trim().length===0?!0:n==null};function g8(n,e){return e===void 0&&(e=!1),{simple:function(t){return NC(t,e)||n.check(t)===void 0},async:function(t){return NC(t,e)||n.testAsync(t)}}}function oa(){return typeof Proxy<"u"?PO(new Ol):OM(new Ol)}var x0={};oa.extend=function(n){Object.assign(x0,n)};oa.clearCustomRules=function(){x0={}};function PO(n){return new Proxy(n,{get:function(t,i){if(i in t)return t[i];var r=PO(n._clone());if(i in Nx)return r._applyModifier(Nx[i],i);if(i in x0)return r._applyRule(x0[i],i);if(i in PM)return r._applyRule(PM[i],i)}})}function OM(n){var e=function(r,a){return Object.keys(r).forEach(function(l){a[l]=function(){for(var u=[],h=arguments.length;h--;)u[h]=arguments[h];var p=OM(a._clone()),g=p._applyRule(r[l],l).apply(void 0,u);return g}}),a},t=e(PM,n),i=e(x0,t);return Object.keys(Nx).forEach(function(r){Object.defineProperty(i,r,{get:function(){var a=OM(i._clone());return a._applyModifier(Nx[r],r)}})}),i}var Nx={not:{simple:function(n){return function(e){return!n(e)}},async:function(n){return function(e){return Promise.resolve(n(e)).then(function(t){return!t}).catch(function(){return!0})}}},some:{simple:function(n){return function(e){return xb(e).some(function(t){try{return n(t)}catch{return!1}})}},async:function(n){return function(e){return Promise.all(xb(e).map(function(t){try{return n(t).catch(function(){return!1})}catch{return!1}})).then(function(t){return t.some(Boolean)})}}},every:{simple:function(n){return function(e){return e!==!1&&xb(e).every(n)}},async:function(n){return function(e){return Promise.all(xb(e).map(n)).then(function(t){return t.every(Boolean)})}}},strict:{simple:function(n,e){return function(t){return LC(e)&&t&&typeof t=="object"?Object.keys(e.args[0]).length===Object.keys(t).length&&n(t):n(t)}},async:function(n,e){return function(t){return Promise.resolve(n(t)).then(function(i){return LC(e)&&t&&typeof t=="object"?Object.keys(e.args[0]).length===Object.keys(t).length&&i:i}).catch(function(){return!1})}}}};function LC(n){return n&&n.name==="schema"&&n.args.length>0&&typeof n.args[0]=="object"}function xb(n){return typeof n=="string"?n.split(""):n}var PM={equal:function(n){return function(e){return e==n}},exact:function(n){return function(e){return e===n}},number:function(n){return n===void 0&&(n=!0),function(e){return typeof e=="number"&&(n||isFinite(e))}},integer:function(){return function(n){var e=Number.isInteger||v8;return e(n)}},numeric:function(){return function(n){return!isNaN(parseFloat(n))&&isFinite(n)}},string:function(){return cp("string")},boolean:function(){return cp("boolean")},undefined:function(){return cp("undefined")},null:function(){return cp("null")},array:function(){return cp("array")},object:function(){return cp("object")},instanceOf:function(n){return function(e){return e instanceof n}},pattern:function(n){return function(e){return n.test(e)}},lowercase:function(){return function(n){return typeof n=="boolean"||n===n.toLowerCase()&&n.trim()!==""}},uppercase:function(){return function(n){return n===n.toUpperCase()&&n.trim()!==""}},vowel:function(){return function(n){return/^[aeiou]+$/i.test(n)}},consonant:function(){return function(n){return/^(?=[^aeiou])([a-z]+)$/i.test(n)}},first:function(n){return function(e){return e[0]==n}},last:function(n){return function(e){return e[e.length-1]==n}},empty:function(){return function(n){return n.length===0}},length:function(n,e){return function(t){return t.length>=n&&t.length<=(e||n)}},minLength:function(n){return function(e){return e.length>=n}},maxLength:function(n){return function(e){return e.length<=n}},negative:function(){return function(n){return n<0}},positive:function(){return function(n){return n>=0}},between:function(n,e){return function(t){return t>=n&&t<=e}},range:function(n,e){return function(t){return t>=n&&t<=e}},lessThan:function(n){return function(e){return en}},greaterThanOrEqual:function(n){return function(e){return e>=n}},even:function(){return function(n){return n%2===0}},odd:function(){return function(n){return n%2!==0}},includes:function(n){return function(e){return~e.indexOf(n)}},schema:function(n){return y8(n)},passesAnyOf:function(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];return function(t){return n.some(function(i){return i.test(t)})}},optional:g8};function cp(n){return function(e){return Array.isArray(e)&&n==="array"||e===null&&n==="null"||typeof e===n}}function v8(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n}function y8(n){return{simple:function(e){var t=[];if(Object.keys(n).forEach(function(i){var r=n[i];try{r.check((e||{})[i])}catch(a){a.target=i,t.push(a)}}),t.length>0)throw t;return!0},async:function(e){var t=[],i=Object.keys(n).map(function(r){var a=n[r];return a.testAsync((e||{})[r]).catch(function(l){l.target=r,t.push(l)})});return Promise.all(i).then(function(){if(t.length>0)throw t;return!0})}}}var ri="colors",As="sizes",Ot="space",b8={gap:Ot,gridGap:Ot,columnGap:Ot,gridColumnGap:Ot,rowGap:Ot,gridRowGap:Ot,inset:Ot,insetBlock:Ot,insetBlockEnd:Ot,insetBlockStart:Ot,insetInline:Ot,insetInlineEnd:Ot,insetInlineStart:Ot,margin:Ot,marginTop:Ot,marginRight:Ot,marginBottom:Ot,marginLeft:Ot,marginBlock:Ot,marginBlockEnd:Ot,marginBlockStart:Ot,marginInline:Ot,marginInlineEnd:Ot,marginInlineStart:Ot,padding:Ot,paddingTop:Ot,paddingRight:Ot,paddingBottom:Ot,paddingLeft:Ot,paddingBlock:Ot,paddingBlockEnd:Ot,paddingBlockStart:Ot,paddingInline:Ot,paddingInlineEnd:Ot,paddingInlineStart:Ot,top:Ot,right:Ot,bottom:Ot,left:Ot,scrollMargin:Ot,scrollMarginTop:Ot,scrollMarginRight:Ot,scrollMarginBottom:Ot,scrollMarginLeft:Ot,scrollMarginX:Ot,scrollMarginY:Ot,scrollMarginBlock:Ot,scrollMarginBlockEnd:Ot,scrollMarginBlockStart:Ot,scrollMarginInline:Ot,scrollMarginInlineEnd:Ot,scrollMarginInlineStart:Ot,scrollPadding:Ot,scrollPaddingTop:Ot,scrollPaddingRight:Ot,scrollPaddingBottom:Ot,scrollPaddingLeft:Ot,scrollPaddingX:Ot,scrollPaddingY:Ot,scrollPaddingBlock:Ot,scrollPaddingBlockEnd:Ot,scrollPaddingBlockStart:Ot,scrollPaddingInline:Ot,scrollPaddingInlineEnd:Ot,scrollPaddingInlineStart:Ot,fontSize:"fontSizes",background:ri,backgroundColor:ri,backgroundImage:ri,borderImage:ri,border:ri,borderBlock:ri,borderBlockEnd:ri,borderBlockStart:ri,borderBottom:ri,borderBottomColor:ri,borderColor:ri,borderInline:ri,borderInlineEnd:ri,borderInlineStart:ri,borderLeft:ri,borderLeftColor:ri,borderRight:ri,borderRightColor:ri,borderTop:ri,borderTopColor:ri,caretColor:ri,color:ri,columnRuleColor:ri,fill:ri,outline:ri,outlineColor:ri,stroke:ri,textDecorationColor:ri,fontFamily:"fonts",fontWeight:"fontWeights",lineHeight:"lineHeights",letterSpacing:"letterSpacings",blockSize:As,minBlockSize:As,maxBlockSize:As,inlineSize:As,minInlineSize:As,maxInlineSize:As,width:As,minWidth:As,maxWidth:As,height:As,minHeight:As,maxHeight:As,flexBasis:As,gridTemplateColumns:As,gridTemplateRows:As,borderWidth:"borderWidths",borderTopWidth:"borderWidths",borderRightWidth:"borderWidths",borderBottomWidth:"borderWidths",borderLeftWidth:"borderWidths",borderStyle:"borderStyles",borderTopStyle:"borderStyles",borderRightStyle:"borderStyles",borderBottomStyle:"borderStyles",borderLeftStyle:"borderStyles",borderRadius:"radii",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",borderBottomRightRadius:"radii",borderBottomLeftRadius:"radii",boxShadow:"shadows",textShadow:"shadows",transition:"transitions",zIndex:"zIndices"},x8=(n,e)=>typeof e=="function"?{"()":Function.prototype.toString.call(e)}:e,Bp=()=>{const n=Object.create(null);return(e,t,...i)=>{const r=(a=>JSON.stringify(a,x8))(e);return r in n?n[r]:n[r]=t(e,...i)}},md=Symbol.for("sxs.internal"),nT=(n,e)=>Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)),UC=n=>{for(const e in n)return!0;return!1},{hasOwnProperty:_8}=Object.prototype,IM=n=>n.includes("-")?n:n.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase())),S8=/\s+(?![^()]*\))/,up=n=>e=>n(...typeof e=="string"?String(e).split(S8):[e]),zC={appearance:n=>({WebkitAppearance:n,appearance:n}),backfaceVisibility:n=>({WebkitBackfaceVisibility:n,backfaceVisibility:n}),backdropFilter:n=>({WebkitBackdropFilter:n,backdropFilter:n}),backgroundClip:n=>({WebkitBackgroundClip:n,backgroundClip:n}),boxDecorationBreak:n=>({WebkitBoxDecorationBreak:n,boxDecorationBreak:n}),clipPath:n=>({WebkitClipPath:n,clipPath:n}),content:n=>({content:n.includes('"')||n.includes("'")||/^([A-Za-z]+\([^]*|[^]*-quote|inherit|initial|none|normal|revert|unset)$/.test(n)?n:`"${n}"`}),hyphens:n=>({WebkitHyphens:n,hyphens:n}),maskImage:n=>({WebkitMaskImage:n,maskImage:n}),maskSize:n=>({WebkitMaskSize:n,maskSize:n}),tabSize:n=>({MozTabSize:n,tabSize:n}),textSizeAdjust:n=>({WebkitTextSizeAdjust:n,textSizeAdjust:n}),userSelect:n=>({WebkitUserSelect:n,userSelect:n}),marginBlock:up(((n,e)=>({marginBlockStart:n,marginBlockEnd:e||n}))),marginInline:up(((n,e)=>({marginInlineStart:n,marginInlineEnd:e||n}))),maxSize:up(((n,e)=>({maxBlockSize:n,maxInlineSize:e||n}))),minSize:up(((n,e)=>({minBlockSize:n,minInlineSize:e||n}))),paddingBlock:up(((n,e)=>({paddingBlockStart:n,paddingBlockEnd:e||n}))),paddingInline:up(((n,e)=>({paddingInlineStart:n,paddingInlineEnd:e||n})))},O1=/([\d.]+)([^]*)/,M8=(n,e)=>n.length?n.reduce(((t,i)=>(t.push(...e.map((r=>r.includes("&")?r.replace(/&/g,/[ +>|~]/.test(i)&&/&.*&/.test(r)?`:is(${i})`:i):i+" "+r))),t)),[]):e,E8=(n,e)=>n in T8&&typeof e=="string"?e.replace(/^((?:[^]*[^\w-])?)(fit-content|stretch)((?:[^\w-][^]*)?)$/,((t,i,r,a)=>i+(r==="stretch"?`-moz-available${a};${IM(n)}:${i}-webkit-fill-available`:`-moz-fit-content${a};${IM(n)}:${i}fit-content`)+a)):String(e),T8={blockSize:1,height:1,inlineSize:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,width:1},Dc=n=>n?n+"-":"",IO=(n,e,t)=>n.replace(/([+-])?((?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?)?(\$|--)([$\w-]+)/g,((i,r,a,l,u)=>l=="$"==!!a?i:(r||l=="--"?"calc(":"")+"var(--"+(l==="$"?Dc(e)+(u.includes("$")?"":Dc(t))+u.replace(/\$/g,"-"):u)+")"+(r||l=="--"?"*"+(r||"")+(a||"1")+")":""))),w8=/\s*,\s*(?![^()]*\))/,A8=Object.prototype.toString,gp=(n,e,t,i,r)=>{let a,l,u;const h=(p,g,y)=>{let b,x;const M=A=>{for(b in A){const R=b.charCodeAt(0)===64,D=R&&Array.isArray(A[b])?A[b]:[A[b]];for(x of D){const P=/[A-Z]/.test(E=b)?E:E.replace(/-[^]/g,(L=>L[1].toUpperCase())),F=typeof x=="object"&&x&&x.toString===A8&&(!i.utils[P]||!g.length);if(P in i.utils&&!F){const L=i.utils[P];if(L!==l){l=L,M(L(x)),l=null;continue}}else if(P in zC){const L=zC[P];if(L!==u){u=L,M(L(x)),u=null;continue}}if(R&&(w=b.slice(1)in i.media?"@media "+i.media[b.slice(1)]:b,b=w.replace(/\(\s*([\w-]+)\s*(=|<|<=|>|>=)\s*([\w-]+)\s*(?:(<|<=|>|>=)\s*([\w-]+)\s*)?\)/g,((L,k,V,N,z,X)=>{const Q=O1.test(k),J=.0625*(Q?-1:1),[oe,re]=Q?[N,k]:[k,N];return"("+(V[0]==="="?"":V[0]===">"===Q?"max-":"min-")+oe+":"+(V[0]!=="="&&V.length===1?re.replace(O1,((q,Z,ne)=>Number(Z)+J*(V===">"?1:-1)+ne)):re)+(z?") and ("+(z[0]===">"?"min-":"max-")+oe+":"+(z.length===1?X.replace(O1,((q,Z,ne)=>Number(Z)+J*(z===">"?-1:1)+ne)):X):"")+")"}))),F){const L=R?y.concat(b):[...y],k=R?[...g]:M8(g,b.split(w8));a!==void 0&&r(BC(...a)),a=void 0,h(x,k,L)}else a===void 0&&(a=[[],g,y]),b=R||b.charCodeAt(0)!==36?b:`--${Dc(i.prefix)}${b.slice(1).replace(/\$/g,"-")}`,x=F?x:typeof x=="number"?x&&P in C8?String(x)+"px":String(x):IO(E8(P,x??""),i.prefix,i.themeMap[P]),a[0].push(`${R?`${b} `:`${IM(b)}:`}${x}`)}}var w,E};M(p),a!==void 0&&r(BC(...a)),a=void 0};h(n,e,t)},BC=(n,e,t)=>`${t.map((i=>`${i}{`)).join("")}${e.length?`${e.join(",")}{`:""}${n.join(";")}${e.length?"}":""}${Array(t.length?t.length+1:0).join("}")}`,C8={animationDelay:1,animationDuration:1,backgroundSize:1,blockSize:1,border:1,borderBlock:1,borderBlockEnd:1,borderBlockEndWidth:1,borderBlockStart:1,borderBlockStartWidth:1,borderBlockWidth:1,borderBottom:1,borderBottomLeftRadius:1,borderBottomRightRadius:1,borderBottomWidth:1,borderEndEndRadius:1,borderEndStartRadius:1,borderInlineEnd:1,borderInlineEndWidth:1,borderInlineStart:1,borderInlineStartWidth:1,borderInlineWidth:1,borderLeft:1,borderLeftWidth:1,borderRadius:1,borderRight:1,borderRightWidth:1,borderSpacing:1,borderStartEndRadius:1,borderStartStartRadius:1,borderTop:1,borderTopLeftRadius:1,borderTopRightRadius:1,borderTopWidth:1,borderWidth:1,bottom:1,columnGap:1,columnRule:1,columnRuleWidth:1,columnWidth:1,containIntrinsicSize:1,flexBasis:1,fontSize:1,gap:1,gridAutoColumns:1,gridAutoRows:1,gridTemplateColumns:1,gridTemplateRows:1,height:1,inlineSize:1,inset:1,insetBlock:1,insetBlockEnd:1,insetBlockStart:1,insetInline:1,insetInlineEnd:1,insetInlineStart:1,left:1,letterSpacing:1,margin:1,marginBlock:1,marginBlockEnd:1,marginBlockStart:1,marginBottom:1,marginInline:1,marginInlineEnd:1,marginInlineStart:1,marginLeft:1,marginRight:1,marginTop:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,offsetDistance:1,offsetRotate:1,outline:1,outlineOffset:1,outlineWidth:1,overflowClipMargin:1,padding:1,paddingBlock:1,paddingBlockEnd:1,paddingBlockStart:1,paddingBottom:1,paddingInline:1,paddingInlineEnd:1,paddingInlineStart:1,paddingLeft:1,paddingRight:1,paddingTop:1,perspective:1,right:1,rowGap:1,scrollMargin:1,scrollMarginBlock:1,scrollMarginBlockEnd:1,scrollMarginBlockStart:1,scrollMarginBottom:1,scrollMarginInline:1,scrollMarginInlineEnd:1,scrollMarginInlineStart:1,scrollMarginLeft:1,scrollMarginRight:1,scrollMarginTop:1,scrollPadding:1,scrollPaddingBlock:1,scrollPaddingBlockEnd:1,scrollPaddingBlockStart:1,scrollPaddingBottom:1,scrollPaddingInline:1,scrollPaddingInlineEnd:1,scrollPaddingInlineStart:1,scrollPaddingLeft:1,scrollPaddingRight:1,scrollPaddingTop:1,shapeMargin:1,textDecoration:1,textDecorationThickness:1,textIndent:1,textUnderlineOffset:1,top:1,transitionDelay:1,transitionDuration:1,verticalAlign:1,width:1,wordSpacing:1},FC=n=>String.fromCharCode(n+(n>25?39:97)),gd=n=>(e=>{let t,i="";for(t=Math.abs(e);t>52;t=t/52|0)i=FC(t%52)+i;return FC(t%52)+i})(((e,t)=>{let i=t.length;for(;i;)e=33*e^t.charCodeAt(--i);return e})(5381,JSON.stringify(n))>>>0),Fg=["themed","global","styled","onevar","resonevar","allvar","inline"],R8=n=>{if(n.href&&!n.href.startsWith(location.origin))return!1;try{return!!n.cssRules}catch{return!1}},D8=n=>{let e;const t=()=>{const{cssRules:r}=e.sheet;return[].map.call(r,((a,l)=>{const{cssText:u}=a;let h="";if(u.startsWith("--sxs"))return"";if(r[l-1]&&(h=r[l-1].cssText).startsWith("--sxs")){if(!a.cssRules.length)return"";for(const p in e.rules)if(e.rules[p].group===a)return`--sxs{--sxs:${[...e.rules[p].cache].join(" ")}}${u}`;return a.cssRules.length?`${h}${u}`:""}return u})).join("")},i=()=>{if(e){const{rules:u,sheet:h}=e;if(!h.deleteRule){for(;Object(Object(h.cssRules)[0]).type===3;)h.cssRules.splice(0,1);h.cssRules=[]}for(const p in u)delete u[p]}const r=Object(n).styleSheets||[];for(const u of r)if(R8(u)){for(let h=0,p=u.cssRules;p[h];++h){const g=Object(p[h]);if(g.type!==1)continue;const y=Object(p[h+1]);if(y.type!==4)continue;++h;const{cssText:b}=g;if(!b.startsWith("--sxs"))continue;const x=b.slice(14,-3).trim().split(/\s+/),M=Fg[x[0]];M&&(e||(e={sheet:u,reset:i,rules:{},toString:t}),e.rules[M]={group:y,index:h,cache:new Set(x)})}if(e)break}if(!e){const u=(h,p)=>({type:p,cssRules:[],insertRule(g,y){this.cssRules.splice(y,0,u(g,{import:3,undefined:1}[(g.toLowerCase().match(/^@([a-z]+)/)||[])[1]]||4))},get cssText(){return h==="@media{}"?`@media{${[].map.call(this.cssRules,(g=>g.cssText)).join("")}}`:h}});e={sheet:n?(n.head||n).appendChild(document.createElement("style")).sheet:u("","text/css"),rules:{},reset:i,toString:t}}const{sheet:a,rules:l}=e;for(let u=Fg.length-1;u>=0;--u){const h=Fg[u];if(!l[h]){const p=Fg[u+1],g=l[p]?l[p].index:a.cssRules.length;a.insertRule("@media{}",g),a.insertRule(`--sxs{--sxs:${u}}`,g),l[h]={group:a.cssRules[g+1],index:g,cache:new Set([u])}}O8(l[h])}};return i(),e},O8=n=>{const e=n.group;let t=e.cssRules.length;n.apply=i=>{try{e.insertRule(i,t),++t}catch{}}},Dg=Symbol(),P8=Bp(),kC=(n,e)=>P8(n,(()=>(...t)=>{let i={type:null,composers:new Set};for(const r of t)if(r!=null)if(r[md]){i.type==null&&(i.type=r[md].type);for(const a of r[md].composers)i.composers.add(a)}else r.constructor!==Object||r.$$typeof?i.type==null&&(i.type=r):i.composers.add(I8(r,n));return i.type==null&&(i.type="span"),i.composers.size||i.composers.add(["PJLV",{},[],[],{},[]]),N8(n,i,e)})),I8=({variants:n,compoundVariants:e,defaultVariants:t,...i},r)=>{const a=`${Dc(r.prefix)}c-${gd(i)}`,l=[],u=[],h=Object.create(null),p=[];for(const b in t)h[b]=String(t[b]);if(typeof n=="object"&&n)for(const b in n){g=h,y=b,_8.call(g,y)||(h[b]="undefined");const x=n[b];for(const M in x){const A={[b]:String(M)};String(M)==="undefined"&&p.push(b);const w=x[M],E=[A,w,!UC(w)];l.push(E)}}var g,y;if(typeof e=="object"&&e)for(const b of e){let{css:x,...M}=b;x=typeof x=="object"&&x||{};for(const w in M)M[w]=String(M[w]);const A=[M,x,!UC(x)];u.push(A)}return[a,i,l,u,h,p]},N8=(n,e,t)=>{const[i,r,a,l]=L8(e.composers),u=typeof e.type=="function"||e.type.$$typeof?(y=>{function b(){for(let x=0;xb.rules[x]={apply:M=>b[Dg].push([x,M])})),b})(t):null,h=(u||t).rules,p=`.${i}${r.length>1?`:where(.${r.slice(1).join(".")})`:""}`,g=y=>{y=typeof y=="object"&&y||U8;const{css:b,...x}=y,M={};for(const E in a)if(delete x[E],E in y){let R=y[E];typeof R=="object"&&R?M[E]={"@initial":a[E],...R}:(R=String(R),M[E]=R!=="undefined"||l.has(E)?R:a[E])}else M[E]=a[E];const A=new Set([...r]);for(const[E,R,D,P]of e.composers){t.rules.styled.cache.has(E)||(t.rules.styled.cache.add(E),gp(R,[`.${E}`],[],n,(k=>{h.styled.apply(k)})));const F=HC(D,M,n.media),L=HC(P,M,n.media,!0);for(const k of F)if(k!==void 0)for(const[V,N,z]of k){const X=`${E}-${gd(N)}-${V}`;A.add(X);const Q=(z?t.rules.resonevar:t.rules.onevar).cache,J=z?h.resonevar:h.onevar;Q.has(X)||(Q.add(X),gp(N,[`.${X}`],[],n,(oe=>{J.apply(oe)})))}for(const k of L)if(k!==void 0)for(const[V,N]of k){const z=`${E}-${gd(N)}-${V}`;A.add(z),t.rules.allvar.cache.has(z)||(t.rules.allvar.cache.add(z),gp(N,[`.${z}`],[],n,(X=>{h.allvar.apply(X)})))}}if(typeof b=="object"&&b){const E=`${i}-i${gd(b)}-css`;A.add(E),t.rules.inline.cache.has(E)||(t.rules.inline.cache.add(E),gp(b,[`.${E}`],[],n,(R=>{h.inline.apply(R)})))}for(const E of String(y.className||"").trim().split(/\s+/))E&&A.add(E);const w=x.className=[...A].join(" ");return{type:e.type,className:w,selector:p,props:x,toString:()=>w,deferredInjector:u}};return nT(g,{className:i,selector:p,[md]:e,toString:()=>(t.rules.styled.cache.has(i)||g(),i)})},L8=n=>{let e="";const t=[],i={},r=[];for(const[a,,,,l,u]of n){e===""&&(e=a),t.push(a),r.push(...u);for(const h in l){const p=l[h];(i[h]===void 0||p!=="undefined"||u.includes(p))&&(i[h]=p)}}return[e,t,i,new Set(r)]},HC=(n,e,t,i)=>{const r=[];e:for(let[a,l,u]of n){if(u)continue;let h,p=0,g=!1;for(h in a){const y=a[h];let b=e[h];if(b!==y){if(typeof b!="object"||!b)continue e;{let x,M,A=0;for(const w in b){if(y===String(b[w])){if(w!=="@initial"){const E=w.slice(1);(M=M||[]).push(E in t?t[E]:w.replace(/^@media ?/,"")),g=!0}p+=A,x=!0}++A}if(M&&M.length&&(l={["@media "+M.join(", ")]:l}),!x)continue e}}}(r[p]=r[p]||[]).push([i?"cv":`${h}-${a[h]}`,l,g])}return r},U8={},z8=Bp(),B8=(n,e)=>z8(n,(()=>(...t)=>{const i=()=>{for(let r of t){r=typeof r=="object"&&r||{};let a=gd(r);if(!e.rules.global.cache.has(a)){if(e.rules.global.cache.add(a),"@import"in r){let l=[].indexOf.call(e.sheet.cssRules,e.rules.themed.group)-1;for(let u of[].concat(r["@import"]))u=u.includes('"')||u.includes("'")?u:`"${u}"`,e.sheet.insertRule(`@import ${u};`,l++);delete r["@import"]}gp(r,[],[],n,(l=>{e.rules.global.apply(l)}))}}return""};return nT(i,{toString:i})})),F8=Bp(),k8=(n,e)=>F8(n,(()=>t=>{const i=`${Dc(n.prefix)}k-${gd(t)}`,r=()=>{if(!e.rules.global.cache.has(i)){e.rules.global.cache.add(i);const a=[];gp(t,[],[],n,(u=>a.push(u)));const l=`@keyframes ${i}{${a.join("")}}`;e.rules.global.apply(l)}return i};return nT(r,{get name(){return r()},toString:r})})),H8=class{constructor(n,e,t,i){this.token=n==null?"":String(n),this.value=e==null?"":String(e),this.scale=t==null?"":String(t),this.prefix=i==null?"":String(i)}get computedValue(){return"var("+this.variable+")"}get variable(){return"--"+Dc(this.prefix)+Dc(this.scale)+this.token}toString(){return this.computedValue}},V8=Bp(),G8=(n,e)=>V8(n,(()=>(t,i)=>{i=typeof t=="object"&&t||Object(i);const r=`.${t=(t=typeof t=="string"?t:"")||`${Dc(n.prefix)}t-${gd(i)}`}`,a={},l=[];for(const h in i){a[h]={};for(const p in i[h]){const g=`--${Dc(n.prefix)}${h}-${p}`,y=IO(String(i[h][p]),n.prefix,h);a[h][p]=new H8(p,y,h,n.prefix),l.push(`${g}:${y}`)}}const u=()=>{if(l.length&&!e.rules.themed.cache.has(t)){e.rules.themed.cache.add(t);const h=`${i===n.theme?":root,":""}.${t}{${l.join(";")}}`;e.rules.themed.apply(h)}return t};return{...a,get className(){return u()},selector:r,toString:u}})),W8=Bp(),$8=Bp(),X8=n=>{const e=(t=>{let i=!1;const r=W8(t,(a=>{i=!0;const l="prefix"in(a=typeof a=="object"&&a||{})?String(a.prefix):"",u=typeof a.media=="object"&&a.media||{},h=typeof a.root=="object"?a.root||null:globalThis.document||null,p=typeof a.theme=="object"&&a.theme||{},g={prefix:l,media:u,theme:p,themeMap:typeof a.themeMap=="object"&&a.themeMap||{...b8},utils:typeof a.utils=="object"&&a.utils||{}},y=D8(h),b={css:kC(g,y),globalCss:B8(g,y),keyframes:k8(g,y),createTheme:G8(g,y),reset(){y.reset(),b.theme.toString()},theme:{},sheet:y,config:g,prefix:l,getCssText:y.toString,toString:y.toString};return String(b.theme=b.createTheme(p)),b}));return i||r.reset(),r})(n);return e.styled=(({config:t,sheet:i})=>$8(t,(()=>{const r=kC(t,i);return(...a)=>{const l=r(...a),u=l[md].type,h=se.forwardRef(((p,g)=>{const y=p&&p.as||u,{props:b,deferredInjector:x}=l(p);return delete b.as,b.ref=g,x?se.createElement(se.Fragment,null,se.createElement(y,b),se.createElement(x,null)):se.createElement(y,b)}));return h.className=l.className,h.displayName=`Styled.${u.displayName||u.name||u}`,h.selector=l.selector,h.toString=()=>l.selector,h[md]=l[md],h}})))(e),e};function Sc(n,e,{checkForDefaultPrevented:t=!0}={}){return function(r){if(n?.(r),t===!1||!r.defaultPrevented)return e?.(r)}}function NO(n,e=[]){let t=[];function i(a,l){const u=U.createContext(l),h=t.length;t=[...t,l];const p=y=>{const{scope:b,children:x,...M}=y,A=b?.[n]?.[h]||u,w=U.useMemo(()=>M,Object.values(M));return ut.jsx(A.Provider,{value:w,children:x})};p.displayName=a+"Provider";function g(y,b){const x=b?.[n]?.[h]||u,M=U.useContext(x);if(M)return M;if(l!==void 0)return l;throw new Error(`\`${y}\` must be used within \`${a}\``)}return[p,g]}const r=()=>{const a=t.map(l=>U.createContext(l));return function(u){const h=u?.[n]||a;return U.useMemo(()=>({[`__scope${n}`]:{...u,[n]:h}}),[u,h])}};return r.scopeName=n,[i,j8(r,...e)]}function j8(...n){const e=n[0];if(n.length===1)return e;const t=()=>{const i=n.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const l=i.reduce((u,{useScope:h,scopeName:p})=>{const y=h(a)[`__scope${p}`];return{...u,...y}},{});return U.useMemo(()=>({[`__scope${e.scopeName}`]:l}),[l])}};return t.scopeName=e.scopeName,t}function q8(n){const e=Y8(n),t=U.forwardRef((i,r)=>{const{children:a,...l}=i,u=U.Children.toArray(a),h=u.find(K8);if(h){const p=h.props.children,g=u.map(y=>y===h?U.Children.count(p)>1?U.Children.only(null):U.isValidElement(p)?p.props.children:null:y);return ut.jsx(e,{...l,ref:r,children:U.isValidElement(p)?U.cloneElement(p,void 0,g):null})}return ut.jsx(e,{...l,ref:r,children:a})});return t.displayName=`${n}.Slot`,t}function Y8(n){const e=U.forwardRef((t,i)=>{const{children:r,...a}=t;if(U.isValidElement(r)){const l=J8(r),u=Q8(a,r.props);return r.type!==U.Fragment&&(u.ref=i?Dd(i,l):l),U.cloneElement(r,u)}return U.Children.count(r)>1?U.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Z8=Symbol("radix.slottable");function K8(n){return U.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Z8}function Q8(n,e){const t={...e};for(const i in e){const r=n[i],a=e[i];/^on[A-Z]/.test(i)?r&&a?t[i]=(...u)=>{const h=a(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...a}:i==="className"&&(t[i]=[r,a].filter(Boolean).join(" "))}return{...n,...t}}function J8(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var eG=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],LO=eG.reduce((n,e)=>{const t=q8(`Primitive.${e}`),i=U.forwardRef((r,a)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ut.jsx(h,{...u,ref:a})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function tG(n,e){n&&eT.flushSync(()=>n.dispatchEvent(e))}function N_(n){const e=U.useRef(n);return U.useEffect(()=>{e.current=n}),U.useMemo(()=>(...t)=>e.current?.(...t),[])}function nG(n,e=globalThis?.document){const t=N_(n);U.useEffect(()=>{const i=r=>{r.key==="Escape"&&t(r)};return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[t,e])}var iG="DismissableLayer",NM="dismissableLayer.update",rG="dismissableLayer.pointerDownOutside",sG="dismissableLayer.focusOutside",VC,UO=U.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),zO=U.forwardRef((n,e)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:r,onFocusOutside:a,onInteractOutside:l,onDismiss:u,...h}=n,p=U.useContext(UO),[g,y]=U.useState(null),b=g?.ownerDocument??globalThis?.document,[,x]=U.useState({}),M=Od(e,k=>y(k)),A=Array.from(p.layers),[w]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),E=A.indexOf(w),R=g?A.indexOf(g):-1,D=p.layersWithOutsidePointerEventsDisabled.size>0,P=R>=E,F=lG(k=>{const V=k.target,N=[...p.branches].some(z=>z.contains(V));!P||N||(r?.(k),l?.(k),k.defaultPrevented||u?.())},b),L=cG(k=>{const V=k.target;[...p.branches].some(z=>z.contains(V))||(a?.(k),l?.(k),k.defaultPrevented||u?.())},b);return nG(k=>{R===p.layers.size-1&&(i?.(k),!k.defaultPrevented&&u&&(k.preventDefault(),u()))},b),U.useEffect(()=>{if(g)return t&&(p.layersWithOutsidePointerEventsDisabled.size===0&&(VC=b.body.style.pointerEvents,b.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(g)),p.layers.add(g),GC(),()=>{t&&p.layersWithOutsidePointerEventsDisabled.size===1&&(b.body.style.pointerEvents=VC)}},[g,b,t,p]),U.useEffect(()=>()=>{g&&(p.layers.delete(g),p.layersWithOutsidePointerEventsDisabled.delete(g),GC())},[g,p]),U.useEffect(()=>{const k=()=>x({});return document.addEventListener(NM,k),()=>document.removeEventListener(NM,k)},[]),ut.jsx(LO.div,{...h,ref:M,style:{pointerEvents:D?P?"auto":"none":void 0,...n.style},onFocusCapture:Sc(n.onFocusCapture,L.onFocusCapture),onBlurCapture:Sc(n.onBlurCapture,L.onBlurCapture),onPointerDownCapture:Sc(n.onPointerDownCapture,F.onPointerDownCapture)})});zO.displayName=iG;var aG="DismissableLayerBranch",oG=U.forwardRef((n,e)=>{const t=U.useContext(UO),i=U.useRef(null),r=Od(e,i);return U.useEffect(()=>{const a=i.current;if(a)return t.branches.add(a),()=>{t.branches.delete(a)}},[t.branches]),ut.jsx(LO.div,{...n,ref:r})});oG.displayName=aG;function lG(n,e=globalThis?.document){const t=N_(n),i=U.useRef(!1),r=U.useRef(()=>{});return U.useEffect(()=>{const a=u=>{if(u.target&&!i.current){let h=function(){BO(rG,t,p,{discrete:!0})};const p={originalEvent:u};u.pointerType==="touch"?(e.removeEventListener("click",r.current),r.current=h,e.addEventListener("click",r.current,{once:!0})):h()}else e.removeEventListener("click",r.current);i.current=!1},l=window.setTimeout(()=>{e.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(l),e.removeEventListener("pointerdown",a),e.removeEventListener("click",r.current)}},[e,t]),{onPointerDownCapture:()=>i.current=!0}}function cG(n,e=globalThis?.document){const t=N_(n),i=U.useRef(!1);return U.useEffect(()=>{const r=a=>{a.target&&!i.current&&BO(sG,t,{originalEvent:a},{discrete:!1})};return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,t]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function GC(){const n=new CustomEvent(NM);document.dispatchEvent(n)}function BO(n,e,t,{discrete:i}){const r=t.originalEvent.target,a=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:t});e&&r.addEventListener(n,e,{once:!0}),i?tG(r,a):r.dispatchEvent(a)}var uG=eE[" useId ".trim().toString()]||(()=>{}),fG=0;function dG(n){const[e,t]=U.useState(uG());return $u(()=>{t(i=>i??String(fG++))},[n]),e?`radix-${e}`:""}const hG=["top","right","bottom","left"],Xu=Math.min,ya=Math.max,Lx=Math.round,_b=Math.floor,wl=n=>({x:n,y:n}),pG={left:"right",right:"left",bottom:"top",top:"bottom"},mG={start:"end",end:"start"};function LM(n,e,t){return ya(n,Xu(e,t))}function Oc(n,e){return typeof n=="function"?n(e):n}function Pc(n){return n.split("-")[0]}function Fp(n){return n.split("-")[1]}function iT(n){return n==="x"?"y":"x"}function rT(n){return n==="y"?"height":"width"}const gG=new Set(["top","bottom"]);function Tl(n){return gG.has(Pc(n))?"y":"x"}function sT(n){return iT(Tl(n))}function vG(n,e,t){t===void 0&&(t=!1);const i=Fp(n),r=sT(n),a=rT(r);let l=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[a]>e.floating[a]&&(l=Ux(l)),[l,Ux(l)]}function yG(n){const e=Ux(n);return[UM(n),e,UM(e)]}function UM(n){return n.replace(/start|end/g,e=>mG[e])}const WC=["left","right"],$C=["right","left"],bG=["top","bottom"],xG=["bottom","top"];function _G(n,e,t){switch(n){case"top":case"bottom":return t?e?$C:WC:e?WC:$C;case"left":case"right":return e?bG:xG;default:return[]}}function SG(n,e,t,i){const r=Fp(n);let a=_G(Pc(n),t==="start",i);return r&&(a=a.map(l=>l+"-"+r),e&&(a=a.concat(a.map(UM)))),a}function Ux(n){return n.replace(/left|right|bottom|top/g,e=>pG[e])}function MG(n){return{top:0,right:0,bottom:0,left:0,...n}}function FO(n){return typeof n!="number"?MG(n):{top:n,right:n,bottom:n,left:n}}function zx(n){const{x:e,y:t,width:i,height:r}=n;return{width:i,height:r,top:t,left:e,right:e+i,bottom:t+r,x:e,y:t}}function XC(n,e,t){let{reference:i,floating:r}=n;const a=Tl(e),l=sT(e),u=rT(l),h=Pc(e),p=a==="y",g=i.x+i.width/2-r.width/2,y=i.y+i.height/2-r.height/2,b=i[u]/2-r[u]/2;let x;switch(h){case"top":x={x:g,y:i.y-r.height};break;case"bottom":x={x:g,y:i.y+i.height};break;case"right":x={x:i.x+i.width,y};break;case"left":x={x:i.x-r.width,y};break;default:x={x:i.x,y:i.y}}switch(Fp(e)){case"start":x[l]-=b*(t&&p?-1:1);break;case"end":x[l]+=b*(t&&p?-1:1);break}return x}async function EG(n,e){var t;e===void 0&&(e={});const{x:i,y:r,platform:a,rects:l,elements:u,strategy:h}=n,{boundary:p="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:b=!1,padding:x=0}=Oc(e,n),M=FO(x),w=u[b?y==="floating"?"reference":"floating":y],E=zx(await a.getClippingRect({element:(t=await(a.isElement==null?void 0:a.isElement(w)))==null||t?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(u.floating)),boundary:p,rootBoundary:g,strategy:h})),R=y==="floating"?{x:i,y:r,width:l.floating.width,height:l.floating.height}:l.reference,D=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u.floating)),P=await(a.isElement==null?void 0:a.isElement(D))?await(a.getScale==null?void 0:a.getScale(D))||{x:1,y:1}:{x:1,y:1},F=zx(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:R,offsetParent:D,strategy:h}):R);return{top:(E.top-F.top+M.top)/P.y,bottom:(F.bottom-E.bottom+M.bottom)/P.y,left:(E.left-F.left+M.left)/P.x,right:(F.right-E.right+M.right)/P.x}}const TG=async(n,e,t)=>{const{placement:i="bottom",strategy:r="absolute",middleware:a=[],platform:l}=t,u=a.filter(Boolean),h=await(l.isRTL==null?void 0:l.isRTL(e));let p=await l.getElementRects({reference:n,floating:e,strategy:r}),{x:g,y}=XC(p,i,h),b=i,x={},M=0;for(let w=0;w({name:"arrow",options:n,async fn(e){const{x:t,y:i,placement:r,rects:a,platform:l,elements:u,middlewareData:h}=e,{element:p,padding:g=0}=Oc(n,e)||{};if(p==null)return{};const y=FO(g),b={x:t,y:i},x=sT(r),M=rT(x),A=await l.getDimensions(p),w=x==="y",E=w?"top":"left",R=w?"bottom":"right",D=w?"clientHeight":"clientWidth",P=a.reference[M]+a.reference[x]-b[x]-a.floating[M],F=b[x]-a.reference[x],L=await(l.getOffsetParent==null?void 0:l.getOffsetParent(p));let k=L?L[D]:0;(!k||!await(l.isElement==null?void 0:l.isElement(L)))&&(k=u.floating[D]||a.floating[M]);const V=P/2-F/2,N=k/2-A[M]/2-1,z=Xu(y[E],N),X=Xu(y[R],N),Q=z,J=k-A[M]-X,oe=k/2-A[M]/2+V,re=LM(Q,oe,J),q=!h.arrow&&Fp(r)!=null&&oe!==re&&a.reference[M]/2-(oeoe<=0)){var X,Q;const oe=(((X=a.flip)==null?void 0:X.index)||0)+1,re=k[oe];if(re&&(!(y==="alignment"?R!==Tl(re):!1)||z.every(ne=>Tl(ne.placement)===R?ne.overflows[0]>0:!0)))return{data:{index:oe,overflows:z},reset:{placement:re}};let q=(Q=z.filter(Z=>Z.overflows[0]<=0).sort((Z,ne)=>Z.overflows[1]-ne.overflows[1])[0])==null?void 0:Q.placement;if(!q)switch(x){case"bestFit":{var J;const Z=(J=z.filter(ne=>{if(L){const pe=Tl(ne.placement);return pe===R||pe==="y"}return!0}).map(ne=>[ne.placement,ne.overflows.filter(pe=>pe>0).reduce((pe,Ee)=>pe+Ee,0)]).sort((ne,pe)=>ne[1]-pe[1])[0])==null?void 0:J[0];Z&&(q=Z);break}case"initialPlacement":q=u;break}if(r!==q)return{reset:{placement:q}}}return{}}}};function jC(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function qC(n){return hG.some(e=>n[e]>=0)}const CG=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t,platform:i}=e,{strategy:r="referenceHidden",...a}=Oc(n,e);switch(r){case"referenceHidden":{const l=await i.detectOverflow(e,{...a,elementContext:"reference"}),u=jC(l,t.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:qC(u)}}}case"escaped":{const l=await i.detectOverflow(e,{...a,altBoundary:!0}),u=jC(l,t.floating);return{data:{escapedOffsets:u,escaped:qC(u)}}}default:return{}}}}},kO=new Set(["left","top"]);async function RG(n,e){const{placement:t,platform:i,elements:r}=n,a=await(i.isRTL==null?void 0:i.isRTL(r.floating)),l=Pc(t),u=Fp(t),h=Tl(t)==="y",p=kO.has(l)?-1:1,g=a&&h?-1:1,y=Oc(e,n);let{mainAxis:b,crossAxis:x,alignmentAxis:M}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return u&&typeof M=="number"&&(x=u==="end"?M*-1:M),h?{x:x*g,y:b*p}:{x:b*p,y:x*g}}const DG=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,i;const{x:r,y:a,placement:l,middlewareData:u}=e,h=await RG(e,n);return l===((t=u.offset)==null?void 0:t.placement)&&(i=u.arrow)!=null&&i.alignmentOffset?{}:{x:r+h.x,y:a+h.y,data:{...h,placement:l}}}}},OG=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:i,placement:r,platform:a}=e,{mainAxis:l=!0,crossAxis:u=!1,limiter:h={fn:E=>{let{x:R,y:D}=E;return{x:R,y:D}}},...p}=Oc(n,e),g={x:t,y:i},y=await a.detectOverflow(e,p),b=Tl(Pc(r)),x=iT(b);let M=g[x],A=g[b];if(l){const E=x==="y"?"top":"left",R=x==="y"?"bottom":"right",D=M+y[E],P=M-y[R];M=LM(D,M,P)}if(u){const E=b==="y"?"top":"left",R=b==="y"?"bottom":"right",D=A+y[E],P=A-y[R];A=LM(D,A,P)}const w=h.fn({...e,[x]:M,[b]:A});return{...w,data:{x:w.x-t,y:w.y-i,enabled:{[x]:l,[b]:u}}}}}},PG=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:i,placement:r,rects:a,middlewareData:l}=e,{offset:u=0,mainAxis:h=!0,crossAxis:p=!0}=Oc(n,e),g={x:t,y:i},y=Tl(r),b=iT(y);let x=g[b],M=g[y];const A=Oc(u,e),w=typeof A=="number"?{mainAxis:A,crossAxis:0}:{mainAxis:0,crossAxis:0,...A};if(h){const D=b==="y"?"height":"width",P=a.reference[b]-a.floating[D]+w.mainAxis,F=a.reference[b]+a.reference[D]-w.mainAxis;xF&&(x=F)}if(p){var E,R;const D=b==="y"?"width":"height",P=kO.has(Pc(r)),F=a.reference[y]-a.floating[D]+(P&&((E=l.offset)==null?void 0:E[y])||0)+(P?0:w.crossAxis),L=a.reference[y]+a.reference[D]+(P?0:((R=l.offset)==null?void 0:R[y])||0)-(P?w.crossAxis:0);ML&&(M=L)}return{[b]:x,[y]:M}}}},IG=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,i;const{placement:r,rects:a,platform:l,elements:u}=e,{apply:h=()=>{},...p}=Oc(n,e),g=await l.detectOverflow(e,p),y=Pc(r),b=Fp(r),x=Tl(r)==="y",{width:M,height:A}=a.floating;let w,E;y==="top"||y==="bottom"?(w=y,E=b===(await(l.isRTL==null?void 0:l.isRTL(u.floating))?"start":"end")?"left":"right"):(E=y,w=b==="end"?"top":"bottom");const R=A-g.top-g.bottom,D=M-g.left-g.right,P=Xu(A-g[w],R),F=Xu(M-g[E],D),L=!e.middlewareData.shift;let k=P,V=F;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(V=D),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(k=R),L&&!b){const z=ya(g.left,0),X=ya(g.right,0),Q=ya(g.top,0),J=ya(g.bottom,0);x?V=M-2*(z!==0||X!==0?z+X:ya(g.left,g.right)):k=A-2*(Q!==0||J!==0?Q+J:ya(g.top,g.bottom))}await h({...e,availableWidth:V,availableHeight:k});const N=await l.getDimensions(u.floating);return M!==N.width||A!==N.height?{reset:{rects:!0}}:{}}}};function L_(){return typeof window<"u"}function kp(n){return HO(n)?(n.nodeName||"").toLowerCase():"#document"}function Ma(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function Nl(n){var e;return(e=(HO(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function HO(n){return L_()?n instanceof Node||n instanceof Ma(n).Node:!1}function zo(n){return L_()?n instanceof Element||n instanceof Ma(n).Element:!1}function Pl(n){return L_()?n instanceof HTMLElement||n instanceof Ma(n).HTMLElement:!1}function YC(n){return!L_()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Ma(n).ShadowRoot}const NG=new Set(["inline","contents"]);function B0(n){const{overflow:e,overflowX:t,overflowY:i,display:r}=Bo(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!NG.has(r)}const LG=new Set(["table","td","th"]);function UG(n){return LG.has(kp(n))}const zG=[":popover-open",":modal"];function U_(n){return zG.some(e=>{try{return n.matches(e)}catch{return!1}})}const BG=["transform","translate","scale","rotate","perspective"],FG=["transform","translate","scale","rotate","perspective","filter"],kG=["paint","layout","strict","content"];function aT(n){const e=oT(),t=zo(n)?Bo(n):n;return BG.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||FG.some(i=>(t.willChange||"").includes(i))||kG.some(i=>(t.contain||"").includes(i))}function HG(n){let e=ju(n);for(;Pl(e)&&!Op(e);){if(aT(e))return e;if(U_(e))return null;e=ju(e)}return null}function oT(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const VG=new Set(["html","body","#document"]);function Op(n){return VG.has(kp(n))}function Bo(n){return Ma(n).getComputedStyle(n)}function z_(n){return zo(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function ju(n){if(kp(n)==="html")return n;const e=n.assignedSlot||n.parentNode||YC(n)&&n.host||Nl(n);return YC(e)?e.host:e}function VO(n){const e=ju(n);return Op(e)?n.ownerDocument?n.ownerDocument.body:n.body:Pl(e)&&B0(e)?e:VO(e)}function _0(n,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=VO(n),a=r===((i=n.ownerDocument)==null?void 0:i.body),l=Ma(r);if(a){const u=zM(l);return e.concat(l,l.visualViewport||[],B0(r)?r:[],u&&t?_0(u):[])}return e.concat(r,_0(r,[],t))}function zM(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function GO(n){const e=Bo(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=Pl(n),a=r?n.offsetWidth:t,l=r?n.offsetHeight:i,u=Lx(t)!==a||Lx(i)!==l;return u&&(t=a,i=l),{width:t,height:i,$:u}}function lT(n){return zo(n)?n:n.contextElement}function xp(n){const e=lT(n);if(!Pl(e))return wl(1);const t=e.getBoundingClientRect(),{width:i,height:r,$:a}=GO(e);let l=(a?Lx(t.width):t.width)/i,u=(a?Lx(t.height):t.height)/r;return(!l||!Number.isFinite(l))&&(l=1),(!u||!Number.isFinite(u))&&(u=1),{x:l,y:u}}const GG=wl(0);function WO(n){const e=Ma(n);return!oT()||!e.visualViewport?GG:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function WG(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==Ma(n)?!1:e}function Md(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=n.getBoundingClientRect(),a=lT(n);let l=wl(1);e&&(i?zo(i)&&(l=xp(i)):l=xp(n));const u=WG(a,t,i)?WO(a):wl(0);let h=(r.left+u.x)/l.x,p=(r.top+u.y)/l.y,g=r.width/l.x,y=r.height/l.y;if(a){const b=Ma(a),x=i&&zo(i)?Ma(i):i;let M=b,A=zM(M);for(;A&&i&&x!==M;){const w=xp(A),E=A.getBoundingClientRect(),R=Bo(A),D=E.left+(A.clientLeft+parseFloat(R.paddingLeft))*w.x,P=E.top+(A.clientTop+parseFloat(R.paddingTop))*w.y;h*=w.x,p*=w.y,g*=w.x,y*=w.y,h+=D,p+=P,M=Ma(A),A=zM(M)}}return zx({width:g,height:y,x:h,y:p})}function B_(n,e){const t=z_(n).scrollLeft;return e?e.left+t:Md(Nl(n)).left+t}function $O(n,e){const t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-B_(n,t),r=t.top+e.scrollTop;return{x:i,y:r}}function $G(n){let{elements:e,rect:t,offsetParent:i,strategy:r}=n;const a=r==="fixed",l=Nl(i),u=e?U_(e.floating):!1;if(i===l||u&&a)return t;let h={scrollLeft:0,scrollTop:0},p=wl(1);const g=wl(0),y=Pl(i);if((y||!y&&!a)&&((kp(i)!=="body"||B0(l))&&(h=z_(i)),Pl(i))){const x=Md(i);p=xp(i),g.x=x.x+i.clientLeft,g.y=x.y+i.clientTop}const b=l&&!y&&!a?$O(l,h):wl(0);return{width:t.width*p.x,height:t.height*p.y,x:t.x*p.x-h.scrollLeft*p.x+g.x+b.x,y:t.y*p.y-h.scrollTop*p.y+g.y+b.y}}function XG(n){return Array.from(n.getClientRects())}function jG(n){const e=Nl(n),t=z_(n),i=n.ownerDocument.body,r=ya(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),a=ya(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let l=-t.scrollLeft+B_(n);const u=-t.scrollTop;return Bo(i).direction==="rtl"&&(l+=ya(e.clientWidth,i.clientWidth)-r),{width:r,height:a,x:l,y:u}}const ZC=25;function qG(n,e){const t=Ma(n),i=Nl(n),r=t.visualViewport;let a=i.clientWidth,l=i.clientHeight,u=0,h=0;if(r){a=r.width,l=r.height;const g=oT();(!g||g&&e==="fixed")&&(u=r.offsetLeft,h=r.offsetTop)}const p=B_(i);if(p<=0){const g=i.ownerDocument,y=g.body,b=getComputedStyle(y),x=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,M=Math.abs(i.clientWidth-y.clientWidth-x);M<=ZC&&(a-=M)}else p<=ZC&&(a+=p);return{width:a,height:l,x:u,y:h}}const YG=new Set(["absolute","fixed"]);function ZG(n,e){const t=Md(n,!0,e==="fixed"),i=t.top+n.clientTop,r=t.left+n.clientLeft,a=Pl(n)?xp(n):wl(1),l=n.clientWidth*a.x,u=n.clientHeight*a.y,h=r*a.x,p=i*a.y;return{width:l,height:u,x:h,y:p}}function KC(n,e,t){let i;if(e==="viewport")i=qG(n,t);else if(e==="document")i=jG(Nl(n));else if(zo(e))i=ZG(e,t);else{const r=WO(n);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return zx(i)}function XO(n,e){const t=ju(n);return t===e||!zo(t)||Op(t)?!1:Bo(t).position==="fixed"||XO(t,e)}function KG(n,e){const t=e.get(n);if(t)return t;let i=_0(n,[],!1).filter(u=>zo(u)&&kp(u)!=="body"),r=null;const a=Bo(n).position==="fixed";let l=a?ju(n):n;for(;zo(l)&&!Op(l);){const u=Bo(l),h=aT(l);!h&&u.position==="fixed"&&(r=null),(a?!h&&!r:!h&&u.position==="static"&&!!r&&YG.has(r.position)||B0(l)&&!h&&XO(n,l))?i=i.filter(g=>g!==l):r=u,l=ju(l)}return e.set(n,i),i}function QG(n){let{element:e,boundary:t,rootBoundary:i,strategy:r}=n;const l=[...t==="clippingAncestors"?U_(e)?[]:KG(e,this._c):[].concat(t),i],u=l[0],h=l.reduce((p,g)=>{const y=KC(e,g,r);return p.top=ya(y.top,p.top),p.right=Xu(y.right,p.right),p.bottom=Xu(y.bottom,p.bottom),p.left=ya(y.left,p.left),p},KC(e,u,r));return{width:h.right-h.left,height:h.bottom-h.top,x:h.left,y:h.top}}function JG(n){const{width:e,height:t}=GO(n);return{width:e,height:t}}function e9(n,e,t){const i=Pl(e),r=Nl(e),a=t==="fixed",l=Md(n,!0,a,e);let u={scrollLeft:0,scrollTop:0};const h=wl(0);function p(){h.x=B_(r)}if(i||!i&&!a)if((kp(e)!=="body"||B0(r))&&(u=z_(e)),i){const x=Md(e,!0,a,e);h.x=x.x+e.clientLeft,h.y=x.y+e.clientTop}else r&&p();a&&!i&&r&&p();const g=r&&!i&&!a?$O(r,u):wl(0),y=l.left+u.scrollLeft-h.x-g.x,b=l.top+u.scrollTop-h.y-g.y;return{x:y,y:b,width:l.width,height:l.height}}function P1(n){return Bo(n).position==="static"}function QC(n,e){if(!Pl(n)||Bo(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return Nl(n)===t&&(t=t.ownerDocument.body),t}function jO(n,e){const t=Ma(n);if(U_(n))return t;if(!Pl(n)){let r=ju(n);for(;r&&!Op(r);){if(zo(r)&&!P1(r))return r;r=ju(r)}return t}let i=QC(n,e);for(;i&&UG(i)&&P1(i);)i=QC(i,e);return i&&Op(i)&&P1(i)&&!aT(i)?t:i||HG(n)||t}const t9=async function(n){const e=this.getOffsetParent||jO,t=this.getDimensions,i=await t(n.floating);return{reference:e9(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function n9(n){return Bo(n).direction==="rtl"}const i9={convertOffsetParentRelativeRectToViewportRelativeRect:$G,getDocumentElement:Nl,getClippingRect:QG,getOffsetParent:jO,getElementRects:t9,getClientRects:XG,getDimensions:JG,getScale:xp,isElement:zo,isRTL:n9};function qO(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function r9(n,e){let t=null,i;const r=Nl(n);function a(){var u;clearTimeout(i),(u=t)==null||u.disconnect(),t=null}function l(u,h){u===void 0&&(u=!1),h===void 0&&(h=1),a();const p=n.getBoundingClientRect(),{left:g,top:y,width:b,height:x}=p;if(u||e(),!b||!x)return;const M=_b(y),A=_b(r.clientWidth-(g+b)),w=_b(r.clientHeight-(y+x)),E=_b(g),D={rootMargin:-M+"px "+-A+"px "+-w+"px "+-E+"px",threshold:ya(0,Xu(1,h))||1};let P=!0;function F(L){const k=L[0].intersectionRatio;if(k!==h){if(!P)return l();k?l(!1,k):i=setTimeout(()=>{l(!1,1e-7)},1e3)}k===1&&!qO(p,n.getBoundingClientRect())&&l(),P=!1}try{t=new IntersectionObserver(F,{...D,root:r.ownerDocument})}catch{t=new IntersectionObserver(F,D)}t.observe(n)}return l(!0),a}function s9(n,e,t,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:h=!1}=i,p=lT(n),g=r||a?[...p?_0(p):[],..._0(e)]:[];g.forEach(E=>{r&&E.addEventListener("scroll",t,{passive:!0}),a&&E.addEventListener("resize",t)});const y=p&&u?r9(p,t):null;let b=-1,x=null;l&&(x=new ResizeObserver(E=>{let[R]=E;R&&R.target===p&&x&&(x.unobserve(e),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var D;(D=x)==null||D.observe(e)})),t()}),p&&!h&&x.observe(p),x.observe(e));let M,A=h?Md(n):null;h&&w();function w(){const E=Md(n);A&&!qO(A,E)&&t(),A=E,M=requestAnimationFrame(w)}return t(),()=>{var E;g.forEach(R=>{r&&R.removeEventListener("scroll",t),a&&R.removeEventListener("resize",t)}),y?.(),(E=x)==null||E.disconnect(),x=null,h&&cancelAnimationFrame(M)}}const a9=DG,o9=OG,l9=AG,c9=IG,u9=CG,JC=wG,f9=PG,d9=(n,e,t)=>{const i=new Map,r={platform:i9,...t},a={...r.platform,_c:i};return TG(n,e,{...r,platform:a})};var h9=typeof document<"u",p9=function(){},Lb=h9?U.useLayoutEffect:p9;function Bx(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,i,r;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(i=t;i--!==0;)if(!Bx(n[i],e[i]))return!1;return!0}if(r=Object.keys(n),t=r.length,t!==Object.keys(e).length)return!1;for(i=t;i--!==0;)if(!{}.hasOwnProperty.call(e,r[i]))return!1;for(i=t;i--!==0;){const a=r[i];if(!(a==="_owner"&&n.$$typeof)&&!Bx(n[a],e[a]))return!1}return!0}return n!==n&&e!==e}function YO(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function eR(n,e){const t=YO(n);return Math.round(e*t)/t}function I1(n){const e=U.useRef(n);return Lb(()=>{e.current=n}),e}function m9(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:i=[],platform:r,elements:{reference:a,floating:l}={},transform:u=!0,whileElementsMounted:h,open:p}=n,[g,y]=U.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[b,x]=U.useState(i);Bx(b,i)||x(i);const[M,A]=U.useState(null),[w,E]=U.useState(null),R=U.useCallback(ne=>{ne!==L.current&&(L.current=ne,A(ne))},[]),D=U.useCallback(ne=>{ne!==k.current&&(k.current=ne,E(ne))},[]),P=a||M,F=l||w,L=U.useRef(null),k=U.useRef(null),V=U.useRef(g),N=h!=null,z=I1(h),X=I1(r),Q=I1(p),J=U.useCallback(()=>{if(!L.current||!k.current)return;const ne={placement:e,strategy:t,middleware:b};X.current&&(ne.platform=X.current),d9(L.current,k.current,ne).then(pe=>{const Ee={...pe,isPositioned:Q.current!==!1};oe.current&&!Bx(V.current,Ee)&&(V.current=Ee,eT.flushSync(()=>{y(Ee)}))})},[b,e,t,X,Q]);Lb(()=>{p===!1&&V.current.isPositioned&&(V.current.isPositioned=!1,y(ne=>({...ne,isPositioned:!1})))},[p]);const oe=U.useRef(!1);Lb(()=>(oe.current=!0,()=>{oe.current=!1}),[]),Lb(()=>{if(P&&(L.current=P),F&&(k.current=F),P&&F){if(z.current)return z.current(P,F,J);J()}},[P,F,J,z,N]);const re=U.useMemo(()=>({reference:L,floating:k,setReference:R,setFloating:D}),[R,D]),q=U.useMemo(()=>({reference:P,floating:F}),[P,F]),Z=U.useMemo(()=>{const ne={position:t,left:0,top:0};if(!q.floating)return ne;const pe=eR(q.floating,g.x),Ee=eR(q.floating,g.y);return u?{...ne,transform:"translate("+pe+"px, "+Ee+"px)",...YO(q.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:pe,top:Ee}},[t,u,q.floating,g.x,g.y]);return U.useMemo(()=>({...g,update:J,refs:re,elements:q,floatingStyles:Z}),[g,J,re,q,Z])}const g9=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:i,padding:r}=typeof n=="function"?n(t):n;return i&&e(i)?i.current!=null?JC({element:i.current,padding:r}).fn(t):{}:i?JC({element:i,padding:r}).fn(t):{}}}},v9=(n,e)=>({...a9(n),options:[n,e]}),y9=(n,e)=>({...o9(n),options:[n,e]}),b9=(n,e)=>({...f9(n),options:[n,e]}),x9=(n,e)=>({...l9(n),options:[n,e]}),_9=(n,e)=>({...c9(n),options:[n,e]}),S9=(n,e)=>({...u9(n),options:[n,e]}),M9=(n,e)=>({...g9(n),options:[n,e]});function E9(n){const e=T9(n),t=U.forwardRef((i,r)=>{const{children:a,...l}=i,u=U.Children.toArray(a),h=u.find(A9);if(h){const p=h.props.children,g=u.map(y=>y===h?U.Children.count(p)>1?U.Children.only(null):U.isValidElement(p)?p.props.children:null:y);return ut.jsx(e,{...l,ref:r,children:U.isValidElement(p)?U.cloneElement(p,void 0,g):null})}return ut.jsx(e,{...l,ref:r,children:a})});return t.displayName=`${n}.Slot`,t}function T9(n){const e=U.forwardRef((t,i)=>{const{children:r,...a}=t;if(U.isValidElement(r)){const l=R9(r),u=C9(a,r.props);return r.type!==U.Fragment&&(u.ref=i?Dd(i,l):l),U.cloneElement(r,u)}return U.Children.count(r)>1?U.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var w9=Symbol("radix.slottable");function A9(n){return U.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===w9}function C9(n,e){const t={...e};for(const i in e){const r=n[i],a=e[i];/^on[A-Z]/.test(i)?r&&a?t[i]=(...u)=>{const h=a(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...a}:i==="className"&&(t[i]=[r,a].filter(Boolean).join(" "))}return{...n,...t}}function R9(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var D9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],O9=D9.reduce((n,e)=>{const t=E9(`Primitive.${e}`),i=U.forwardRef((r,a)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ut.jsx(h,{...u,ref:a})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{}),P9="Arrow",ZO=U.forwardRef((n,e)=>{const{children:t,width:i=10,height:r=5,...a}=n;return ut.jsx(O9.svg,{...a,ref:e,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:ut.jsx("polygon",{points:"0,0 30,0 15,10"})})});ZO.displayName=P9;var I9=ZO;function N9(n){const e=L9(n),t=U.forwardRef((i,r)=>{const{children:a,...l}=i,u=U.Children.toArray(a),h=u.find(z9);if(h){const p=h.props.children,g=u.map(y=>y===h?U.Children.count(p)>1?U.Children.only(null):U.isValidElement(p)?p.props.children:null:y);return ut.jsx(e,{...l,ref:r,children:U.isValidElement(p)?U.cloneElement(p,void 0,g):null})}return ut.jsx(e,{...l,ref:r,children:a})});return t.displayName=`${n}.Slot`,t}function L9(n){const e=U.forwardRef((t,i)=>{const{children:r,...a}=t;if(U.isValidElement(r)){const l=F9(r),u=B9(a,r.props);return r.type!==U.Fragment&&(u.ref=i?Dd(i,l):l),U.cloneElement(r,u)}return U.Children.count(r)>1?U.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var U9=Symbol("radix.slottable");function z9(n){return U.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===U9}function B9(n,e){const t={...e};for(const i in e){const r=n[i],a=e[i];/^on[A-Z]/.test(i)?r&&a?t[i]=(...u)=>{const h=a(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...a}:i==="className"&&(t[i]=[r,a].filter(Boolean).join(" "))}return{...n,...t}}function F9(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var k9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],KO=k9.reduce((n,e)=>{const t=N9(`Primitive.${e}`),i=U.forwardRef((r,a)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ut.jsx(h,{...u,ref:a})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function H9(n){const[e,t]=U.useState(void 0);return $u(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let l,u;if("borderBoxSize"in a){const h=a.borderBoxSize,p=Array.isArray(h)?h[0]:h;l=p.inlineSize,u=p.blockSize}else l=n.offsetWidth,u=n.offsetHeight;t({width:l,height:u})});return i.observe(n,{box:"border-box"}),()=>i.unobserve(n)}else t(void 0)},[n]),e}var cT="Popper",[QO,JO]=NO(cT),[V9,eP]=QO(cT),tP=n=>{const{__scopePopper:e,children:t}=n,[i,r]=U.useState(null);return ut.jsx(V9,{scope:e,anchor:i,onAnchorChange:r,children:t})};tP.displayName=cT;var nP="PopperAnchor",iP=U.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:i,...r}=n,a=eP(nP,t),l=U.useRef(null),u=Od(e,l),h=U.useRef(null);return U.useEffect(()=>{const p=h.current;h.current=i?.current||l.current,p!==h.current&&a.onAnchorChange(h.current)}),i?null:ut.jsx(KO.div,{...r,ref:u})});iP.displayName=nP;var uT="PopperContent",[G9,W9]=QO(uT),rP=U.forwardRef((n,e)=>{const{__scopePopper:t,side:i="bottom",sideOffset:r=0,align:a="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:h=!0,collisionBoundary:p=[],collisionPadding:g=0,sticky:y="partial",hideWhenDetached:b=!1,updatePositionStrategy:x="optimized",onPlaced:M,...A}=n,w=eP(uT,t),[E,R]=U.useState(null),D=Od(e,xe=>R(xe)),[P,F]=U.useState(null),L=H9(P),k=L?.width??0,V=L?.height??0,N=i+(a!=="center"?"-"+a:""),z=typeof g=="number"?g:{top:0,right:0,bottom:0,left:0,...g},X=Array.isArray(p)?p:[p],Q=X.length>0,J={padding:z,boundary:X.filter(X9),altBoundary:Q},{refs:oe,floatingStyles:re,placement:q,isPositioned:Z,middlewareData:ne}=m9({strategy:"fixed",placement:N,whileElementsMounted:(...xe)=>s9(...xe,{animationFrame:x==="always"}),elements:{reference:w.anchor},middleware:[v9({mainAxis:r+V,alignmentAxis:l}),h&&y9({mainAxis:!0,crossAxis:!1,limiter:y==="partial"?b9():void 0,...J}),h&&x9({...J}),_9({...J,apply:({elements:xe,rects:ke,availableWidth:Ge,availableHeight:ct})=>{const{width:_t,height:St}=ke.reference,mt=xe.floating.style;mt.setProperty("--radix-popper-available-width",`${Ge}px`),mt.setProperty("--radix-popper-available-height",`${ct}px`),mt.setProperty("--radix-popper-anchor-width",`${_t}px`),mt.setProperty("--radix-popper-anchor-height",`${St}px`)}}),P&&M9({element:P,padding:u}),j9({arrowWidth:k,arrowHeight:V}),b&&S9({strategy:"referenceHidden",...J})]}),[pe,Ee]=oP(q),j=N_(M);$u(()=>{Z&&j?.()},[Z,j]);const fe=ne.arrow?.x,be=ne.arrow?.y,Fe=ne.arrow?.centerOffset!==0,[rt,he]=U.useState();return $u(()=>{E&&he(window.getComputedStyle(E).zIndex)},[E]),ut.jsx("div",{ref:oe.setFloating,"data-radix-popper-content-wrapper":"",style:{...re,transform:Z?re.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:rt,"--radix-popper-transform-origin":[ne.transformOrigin?.x,ne.transformOrigin?.y].join(" "),...ne.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:ut.jsx(G9,{scope:t,placedSide:pe,onArrowChange:F,arrowX:fe,arrowY:be,shouldHideArrow:Fe,children:ut.jsx(KO.div,{"data-side":pe,"data-align":Ee,...A,ref:D,style:{...A.style,animation:Z?void 0:"none"}})})})});rP.displayName=uT;var sP="PopperArrow",$9={top:"bottom",right:"left",bottom:"top",left:"right"},aP=U.forwardRef(function(e,t){const{__scopePopper:i,...r}=e,a=W9(sP,i),l=$9[a.placedSide];return ut.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:ut.jsx(I9,{...r,ref:t,style:{...r.style,display:"block"}})})});aP.displayName=sP;function X9(n){return n!==null}var j9=n=>({name:"transformOrigin",options:n,fn(e){const{placement:t,rects:i,middlewareData:r}=e,l=r.arrow?.centerOffset!==0,u=l?0:n.arrowWidth,h=l?0:n.arrowHeight,[p,g]=oP(t),y={start:"0%",center:"50%",end:"100%"}[g],b=(r.arrow?.x??0)+u/2,x=(r.arrow?.y??0)+h/2;let M="",A="";return p==="bottom"?(M=l?y:`${b}px`,A=`${-h}px`):p==="top"?(M=l?y:`${b}px`,A=`${i.floating.height+h}px`):p==="right"?(M=`${-h}px`,A=l?y:`${x}px`):p==="left"&&(M=`${i.floating.width+h}px`,A=l?y:`${x}px`),{data:{x:M,y:A}}}});function oP(n){const[e,t="center"]=n.split("-");return[e,t]}var q9=tP,Y9=iP,Z9=rP,K9=aP;function Q9(n){const e=J9(n),t=U.forwardRef((i,r)=>{const{children:a,...l}=i,u=U.Children.toArray(a),h=u.find(t7);if(h){const p=h.props.children,g=u.map(y=>y===h?U.Children.count(p)>1?U.Children.only(null):U.isValidElement(p)?p.props.children:null:y);return ut.jsx(e,{...l,ref:r,children:U.isValidElement(p)?U.cloneElement(p,void 0,g):null})}return ut.jsx(e,{...l,ref:r,children:a})});return t.displayName=`${n}.Slot`,t}function J9(n){const e=U.forwardRef((t,i)=>{const{children:r,...a}=t;if(U.isValidElement(r)){const l=i7(r),u=n7(a,r.props);return r.type!==U.Fragment&&(u.ref=i?Dd(i,l):l),U.cloneElement(r,u)}return U.Children.count(r)>1?U.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var lP=Symbol("radix.slottable");function e7(n){const e=({children:t})=>ut.jsx(ut.Fragment,{children:t});return e.displayName=`${n}.Slottable`,e.__radixId=lP,e}function t7(n){return U.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===lP}function n7(n,e){const t={...e};for(const i in e){const r=n[i],a=e[i];/^on[A-Z]/.test(i)?r&&a?t[i]=(...u)=>{const h=a(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...a}:i==="className"&&(t[i]=[r,a].filter(Boolean).join(" "))}return{...n,...t}}function i7(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var r7=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],s7=r7.reduce((n,e)=>{const t=Q9(`Primitive.${e}`),i=U.forwardRef((r,a)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ut.jsx(h,{...u,ref:a})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function a7(n,e){return U.useReducer((t,i)=>e[t][i]??t,n)}var cP=n=>{const{present:e,children:t}=n,i=o7(e),r=typeof t=="function"?t({present:i.isPresent}):U.Children.only(t),a=Od(i.ref,l7(r));return typeof t=="function"||i.isPresent?U.cloneElement(r,{ref:a}):null};cP.displayName="Presence";function o7(n){const[e,t]=U.useState(),i=U.useRef(null),r=U.useRef(n),a=U.useRef("none"),l=n?"mounted":"unmounted",[u,h]=a7(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return U.useEffect(()=>{const p=Sb(i.current);a.current=u==="mounted"?p:"none"},[u]),$u(()=>{const p=i.current,g=r.current;if(g!==n){const b=a.current,x=Sb(p);n?h("MOUNT"):x==="none"||p?.display==="none"?h("UNMOUNT"):h(g&&b!==x?"ANIMATION_OUT":"UNMOUNT"),r.current=n}},[n,h]),$u(()=>{if(e){let p;const g=e.ownerDocument.defaultView??window,y=x=>{const A=Sb(i.current).includes(CSS.escape(x.animationName));if(x.target===e&&A&&(h("ANIMATION_END"),!r.current)){const w=e.style.animationFillMode;e.style.animationFillMode="forwards",p=g.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=w)})}},b=x=>{x.target===e&&(a.current=Sb(i.current))};return e.addEventListener("animationstart",b),e.addEventListener("animationcancel",y),e.addEventListener("animationend",y),()=>{g.clearTimeout(p),e.removeEventListener("animationstart",b),e.removeEventListener("animationcancel",y),e.removeEventListener("animationend",y)}}else h("ANIMATION_END")},[e,h]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:U.useCallback(p=>{i.current=p?getComputedStyle(p):null,t(p)},[])}}function Sb(n){return n?.animationName||"none"}function l7(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var c7=eE[" useInsertionEffect ".trim().toString()]||$u;function u7({prop:n,defaultProp:e,onChange:t=()=>{},caller:i}){const[r,a,l]=f7({defaultProp:e,onChange:t}),u=n!==void 0,h=u?n:r;{const g=U.useRef(n!==void 0);U.useEffect(()=>{const y=g.current;y!==u&&console.warn(`${i} is changing from ${y?"controlled":"uncontrolled"} to ${u?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),g.current=u},[u,i])}const p=U.useCallback(g=>{if(u){const y=d7(g)?g(n):g;y!==n&&l.current?.(y)}else a(g)},[u,n,a,l]);return[h,p]}function f7({defaultProp:n,onChange:e}){const[t,i]=U.useState(n),r=U.useRef(t),a=U.useRef(e);return c7(()=>{a.current=e},[e]),U.useEffect(()=>{r.current!==t&&(a.current?.(t),r.current=t)},[t,r]),[t,i,a]}function d7(n){return typeof n=="function"}function h7(n){const e=p7(n),t=U.forwardRef((i,r)=>{const{children:a,...l}=i,u=U.Children.toArray(a),h=u.find(g7);if(h){const p=h.props.children,g=u.map(y=>y===h?U.Children.count(p)>1?U.Children.only(null):U.isValidElement(p)?p.props.children:null:y);return ut.jsx(e,{...l,ref:r,children:U.isValidElement(p)?U.cloneElement(p,void 0,g):null})}return ut.jsx(e,{...l,ref:r,children:a})});return t.displayName=`${n}.Slot`,t}function p7(n){const e=U.forwardRef((t,i)=>{const{children:r,...a}=t;if(U.isValidElement(r)){const l=y7(r),u=v7(a,r.props);return r.type!==U.Fragment&&(u.ref=i?Dd(i,l):l),U.cloneElement(r,u)}return U.Children.count(r)>1?U.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var m7=Symbol("radix.slottable");function g7(n){return U.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===m7}function v7(n,e){const t={...e};for(const i in e){const r=n[i],a=e[i];/^on[A-Z]/.test(i)?r&&a?t[i]=(...u)=>{const h=a(...u);return r(...u),h}:r&&(t[i]=r):i==="style"?t[i]={...r,...a}:i==="className"&&(t[i]=[r,a].filter(Boolean).join(" "))}return{...n,...t}}function y7(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var b7=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],x7=b7.reduce((n,e)=>{const t=h7(`Primitive.${e}`),i=U.forwardRef((r,a)=>{const{asChild:l,...u}=r,h=l?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ut.jsx(h,{...u,ref:a})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{}),_7=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),S7="VisuallyHidden",uP=U.forwardRef((n,e)=>ut.jsx(x7.span,{...n,ref:e,style:{..._7,...n.style}}));uP.displayName=S7;var M7=uP,[F_]=NO("Tooltip",[JO]),k_=JO(),fP="TooltipProvider",E7=700,BM="tooltip.open",[T7,fT]=F_(fP),dP=n=>{const{__scopeTooltip:e,delayDuration:t=E7,skipDelayDuration:i=300,disableHoverableContent:r=!1,children:a}=n,l=U.useRef(!0),u=U.useRef(!1),h=U.useRef(0);return U.useEffect(()=>{const p=h.current;return()=>window.clearTimeout(p)},[]),ut.jsx(T7,{scope:e,isOpenDelayedRef:l,delayDuration:t,onOpen:U.useCallback(()=>{window.clearTimeout(h.current),l.current=!1},[]),onClose:U.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>l.current=!0,i)},[i]),isPointerInTransitRef:u,onPointerInTransitChange:U.useCallback(p=>{u.current=p},[]),disableHoverableContent:r,children:a})};dP.displayName=fP;var S0="Tooltip",[w7,H_]=F_(S0),hP=n=>{const{__scopeTooltip:e,children:t,open:i,defaultOpen:r,onOpenChange:a,disableHoverableContent:l,delayDuration:u}=n,h=fT(S0,n.__scopeTooltip),p=k_(e),[g,y]=U.useState(null),b=dG(),x=U.useRef(0),M=l??h.disableHoverableContent,A=u??h.delayDuration,w=U.useRef(!1),[E,R]=u7({prop:i,defaultProp:r??!1,onChange:k=>{k?(h.onOpen(),document.dispatchEvent(new CustomEvent(BM))):h.onClose(),a?.(k)},caller:S0}),D=U.useMemo(()=>E?w.current?"delayed-open":"instant-open":"closed",[E]),P=U.useCallback(()=>{window.clearTimeout(x.current),x.current=0,w.current=!1,R(!0)},[R]),F=U.useCallback(()=>{window.clearTimeout(x.current),x.current=0,R(!1)},[R]),L=U.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{w.current=!0,R(!0),x.current=0},A)},[A,R]);return U.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),ut.jsx(q9,{...p,children:ut.jsx(w7,{scope:e,contentId:b,open:E,stateAttribute:D,trigger:g,onTriggerChange:y,onTriggerEnter:U.useCallback(()=>{h.isOpenDelayedRef.current?L():P()},[h.isOpenDelayedRef,L,P]),onTriggerLeave:U.useCallback(()=>{M?F():(window.clearTimeout(x.current),x.current=0)},[F,M]),onOpen:P,onClose:F,disableHoverableContent:M,children:t})})};hP.displayName=S0;var FM="TooltipTrigger",pP=U.forwardRef((n,e)=>{const{__scopeTooltip:t,...i}=n,r=H_(FM,t),a=fT(FM,t),l=k_(t),u=U.useRef(null),h=Od(e,u,r.onTriggerChange),p=U.useRef(!1),g=U.useRef(!1),y=U.useCallback(()=>p.current=!1,[]);return U.useEffect(()=>()=>document.removeEventListener("pointerup",y),[y]),ut.jsx(Y9,{asChild:!0,...l,children:ut.jsx(s7.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...i,ref:h,onPointerMove:Sc(n.onPointerMove,b=>{b.pointerType!=="touch"&&!g.current&&!a.isPointerInTransitRef.current&&(r.onTriggerEnter(),g.current=!0)}),onPointerLeave:Sc(n.onPointerLeave,()=>{r.onTriggerLeave(),g.current=!1}),onPointerDown:Sc(n.onPointerDown,()=>{r.open&&r.onClose(),p.current=!0,document.addEventListener("pointerup",y,{once:!0})}),onFocus:Sc(n.onFocus,()=>{p.current||r.onOpen()}),onBlur:Sc(n.onBlur,r.onClose),onClick:Sc(n.onClick,r.onClose)})})});pP.displayName=FM;var A7="TooltipPortal",[UY,C7]=F_(A7,{forceMount:void 0}),Pp="TooltipContent",mP=U.forwardRef((n,e)=>{const t=C7(Pp,n.__scopeTooltip),{forceMount:i=t.forceMount,side:r="top",...a}=n,l=H_(Pp,n.__scopeTooltip);return ut.jsx(cP,{present:i||l.open,children:l.disableHoverableContent?ut.jsx(gP,{side:r,...a,ref:e}):ut.jsx(R7,{side:r,...a,ref:e})})}),R7=U.forwardRef((n,e)=>{const t=H_(Pp,n.__scopeTooltip),i=fT(Pp,n.__scopeTooltip),r=U.useRef(null),a=Od(e,r),[l,u]=U.useState(null),{trigger:h,onClose:p}=t,g=r.current,{onPointerInTransitChange:y}=i,b=U.useCallback(()=>{u(null),y(!1)},[y]),x=U.useCallback((M,A)=>{const w=M.currentTarget,E={x:M.clientX,y:M.clientY},R=I7(E,w.getBoundingClientRect()),D=N7(E,R),P=L7(A.getBoundingClientRect()),F=z7([...D,...P]);u(F),y(!0)},[y]);return U.useEffect(()=>()=>b(),[b]),U.useEffect(()=>{if(h&&g){const M=w=>x(w,g),A=w=>x(w,h);return h.addEventListener("pointerleave",M),g.addEventListener("pointerleave",A),()=>{h.removeEventListener("pointerleave",M),g.removeEventListener("pointerleave",A)}}},[h,g,x,b]),U.useEffect(()=>{if(l){const M=A=>{const w=A.target,E={x:A.clientX,y:A.clientY},R=h?.contains(w)||g?.contains(w),D=!U7(E,l);R?b():D&&(b(),p())};return document.addEventListener("pointermove",M),()=>document.removeEventListener("pointermove",M)}},[h,g,l,p,b]),ut.jsx(gP,{...n,ref:a})}),[D7,O7]=F_(S0,{isInside:!1}),P7=e7("TooltipContent"),gP=U.forwardRef((n,e)=>{const{__scopeTooltip:t,children:i,"aria-label":r,onEscapeKeyDown:a,onPointerDownOutside:l,...u}=n,h=H_(Pp,t),p=k_(t),{onClose:g}=h;return U.useEffect(()=>(document.addEventListener(BM,g),()=>document.removeEventListener(BM,g)),[g]),U.useEffect(()=>{if(h.trigger){const y=b=>{b.target?.contains(h.trigger)&&g()};return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[h.trigger,g]),ut.jsx(zO,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:y=>y.preventDefault(),onDismiss:g,children:ut.jsxs(Z9,{"data-state":h.stateAttribute,...p,...u,ref:e,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[ut.jsx(P7,{children:i}),ut.jsx(D7,{scope:t,isInside:!0,children:ut.jsx(M7,{id:h.contentId,role:"tooltip",children:r||i})})]})})});mP.displayName=Pp;var vP="TooltipArrow",yP=U.forwardRef((n,e)=>{const{__scopeTooltip:t,...i}=n,r=k_(t);return O7(vP,t).isInside?null:ut.jsx(K9,{...r,...i,ref:e})});yP.displayName=vP;function I7(n,e){const t=Math.abs(e.top-n.y),i=Math.abs(e.bottom-n.y),r=Math.abs(e.right-n.x),a=Math.abs(e.left-n.x);switch(Math.min(t,i,r,a)){case a:return"left";case r:return"right";case t:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function N7(n,e,t=5){const i=[];switch(e){case"top":i.push({x:n.x-t,y:n.y+t},{x:n.x+t,y:n.y+t});break;case"bottom":i.push({x:n.x-t,y:n.y-t},{x:n.x+t,y:n.y-t});break;case"left":i.push({x:n.x+t,y:n.y-t},{x:n.x+t,y:n.y+t});break;case"right":i.push({x:n.x-t,y:n.y-t},{x:n.x-t,y:n.y+t});break}return i}function L7(n){const{top:e,right:t,bottom:i,left:r}=n;return[{x:r,y:e},{x:t,y:e},{x:t,y:i},{x:r,y:i}]}function U7(n,e){const{x:t,y:i}=n;let r=!1;for(let a=0,l=e.length-1;ai!=b>i&&t<(y-p)*(i-g)/(b-g)+p&&(r=!r)}return r}function z7(n){const e=n.slice();return e.sort((t,i)=>t.xi.x?1:t.yi.y?1:0),B7(e)}function B7(n){if(n.length<=1)return n.slice();const e=[];for(let i=0;i=2;){const a=e[e.length-1],l=e[e.length-2];if((a.x-l.x)*(r.y-l.y)>=(a.y-l.y)*(r.x-l.x))e.pop();else break}e.push(r)}e.pop();const t=[];for(let i=n.length-1;i>=0;i--){const r=n[i];for(;t.length>=2;){const a=t[t.length-1],l=t[t.length-2];if((a.x-l.x)*(r.y-l.y)>=(a.y-l.y)*(r.x-l.x))t.pop();else break}t.push(r)}return t.pop(),e.length===1&&t.length===1&&e[0].x===t[0].x&&e[0].y===t[0].y?e:e.concat(t)}var F7=dP,k7=hP,H7=pP,V7=mP,G7=yP;function W7(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.indexOf(i)!==-1)continue;t[i]=n[i]}return t}function si(n,e){if(n==null)return{};var t,i,r=W7(n,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);for(i=0;i[`An input with type \`${n}\` input was found at path \`${e}\` but it's not supported yet.`],[hr.NO_COMPONENT_FOR_TYPE]:(n,e)=>[`Type \`${n}\` found at path \`${e}\` can't be displayed in panel because no component supports it yet.`],[hr.UNKNOWN_INPUT]:(n,e)=>[`input at path \`${n}\` is not recognized.`,e],[hr.DUPLICATE_KEYS]:(n,e,t)=>[`Key \`${n}\` of path \`${e}\` already exists at path \`${t}\`. Even nested keys need to be unique. Rename one of the keys.`],[hr.ALREADY_REGISTERED_TYPE]:n=>[`Type ${n} has already been registered. You can't register a component with the same type.`],[hr.CLIPBOARD_ERROR]:n=>["Error copying the value",n],[hr.THEME_ERROR]:(n,e)=>[`Error accessing the theme \`${n}.${e}\` value.`],[hr.PATH_DOESNT_EXIST]:n=>[`Error getting the value at path \`${n}\`. There is probably an error in your \`render\` function.`],[hr.INPUT_TYPE_OVERRIDE]:(n,e,t)=>[`Input at path \`${n}\` already exists with type: \`${e}\`. Its type cannot be overridden with type \`${t}\`.`],[hr.EMPTY_KEY]:()=>["Keys can not be empty, if you want to hide a label use whitespace."]};function bP(n,e,...t){const i=$7[e],[r,...a]=i(...t);console[n]("LEVA: "+r,...a)}const Tc=bP.bind(null,"warn"),X7=bP.bind(null,"log"),j7=["value"],q7=["schema"],Y7=["value"],xP=[],Ed={};function tR(n){let{value:e}=n,t=si(n,j7);for(let i of xP){const r=i(e,t);if(r)return r}}function Ic(n,e){let{schema:t}=e,i=si(e,q7);if(n in Ed){Tc(hr.ALREADY_REGISTERED_TYPE,n);return}xP.push((r,a)=>t(r,a)&&n),Ed[n]=i}function N1(n,e,t,i){const{normalize:r}=Ed[n];if(r)return r(e,t,i);if(typeof e!="object"||!("value"in e))return{value:e};const{value:a}=e,l=si(e,Y7);return{value:a,settings:l}}function Z7(n,e,t,i,r,a){const{sanitize:l}=Ed[n];return l?l(e,t,i,r,a):e}function nR(n,e,t){const{format:i}=Ed[n];return i?i(e,t):e}function K7(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var i=t.call(n,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function Q7(n){var e=K7(n,"string");return typeof e=="symbol"?e:e+""}function J7(n,e,t){return(e=Q7(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function iR(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function Vt(n){for(var e=1;en>t?t:n{if(n===""||typeof n=="number")return n;try{const e=dp(n);if(!isNaN(e))return e}catch{}return parseFloat(n)},tW=Math.log(10);function rR(n){let e=Math.abs(+String(n).replace(".",""));if(e===0)return .01;for(;e!==0&&e%10===0;)e/=10;const t=Math.floor(Math.log(e)/tW)+1,i=Math.floor(Math.log10(Math.abs(n))),r=Math.pow(10,i-t);return Math.max(r,.001)}const Fx=(n,e,t)=>t===e?0:(qu(n,e,t)-e)/(t-e),kx=(n,e,t)=>n*(t-e)+e,nW=()=>"_"+Math.random().toString(36).substr(2,9),sR=/\(([^\(\)]+)\)/,aR=/(-?\d+(?:\.\d+)?)\s*\^\s*(-?\d+(?:\.\d+)?)/,oR=/(-?\d+(?:\.\d+)?)\s*([*/])\s*(-?\d+(?:\.\d+)?)/,lR=/(-?\d+(?:\.\d+)?)\s*([+-])\s*(-?\d+(?:\.\d+)?)/;function dp(n){return n=n.replace(/\s+/g,""),sR.test(n)?dp(n.replace(sR,(e,t)=>dp(t).toString())):aR.test(n)?dp(n.replace(aR,(e,t,i)=>Math.pow(Number(t),Number(i)).toString())):oR.test(n)?dp(n.replace(oR,(e,t,i,r)=>i==="*"?(Number(t)*Number(r)).toString():Number(r)===0?(()=>{throw new Error("Division by zero")})():(Number(t)/Number(r)).toString())):lR.test(n)?dp(n.replace(lR,(e,t,i,r)=>i==="+"?(Number(t)+Number(r)).toString():(Number(t)-Number(r)).toString())):Number(n)}function iW(n,e){return e.reduce((t,i)=>(n&&n.hasOwnProperty(i)&&(t[i]=n[i]),t),{})}function rW(n,e){const t=Vt({},n);return e.forEach(i=>i in n&&delete t[i]),t}function sW(n,e){return n.reduce((t,i,r)=>Object.assign(t,{[e[r]]:i}),{})}function _P(n){return Object.prototype.toString.call(n)==="[object Object]"}const aW=n=>_P(n)&&Object.keys(n).length===0;let Uo=(function(n){return n.BUTTON="BUTTON",n.BUTTON_GROUP="BUTTON_GROUP",n.MONITOR="MONITOR",n.FOLDER="FOLDER",n})({}),Nc=(function(n){return n.SELECT="SELECT",n.IMAGE="IMAGE",n.NUMBER="NUMBER",n.COLOR="COLOR",n.STRING="STRING",n.BOOLEAN="BOOLEAN",n.INTERVAL="INTERVAL",n.VECTOR3D="VECTOR3D",n.VECTOR2D="VECTOR2D",n})({});const oW=["type","__customInput"],lW=["render","label","optional","order","disabled","hint","onChange","onEditStart","onEditEnd","transient"],cW=["type"];function SP(n,e,t={},i){var r,a;if(typeof n!="object"||Array.isArray(n))return{type:i,input:n,options:Vt({key:e,label:e,optional:!1,disabled:!1,order:0},t)};if("__customInput"in n){const{type:F,__customInput:L}=n,k=si(n,oW);return SP(L,e,k,F)}const{render:l,label:u,optional:h,order:p=0,disabled:g,hint:y,onChange:b,onEditStart:x,onEditEnd:M,transient:A}=n,w=si(n,lW),E=Vt({render:l,key:e,label:u??e,hint:y,transient:A??!!b,onEditStart:x,onEditEnd:M,disabled:g,optional:h,order:p},t);let{type:R}=w,D=si(w,cW);if(R=i??R,R in Uo)return{type:R,input:D,options:E};let P;return i&&_P(D)&&"value"in D?P=D.value:P=aW(D)?void 0:D,{type:R,input:P,options:Vt(Vt({},E),{},{onChange:b,optional:(r=E.optional)!==null&&r!==void 0?r:!1,disabled:(a=E.disabled)!==null&&a!==void 0?a:!1})}}function uW(n,e,t,i){const r=SP(n,e),{type:a,input:l,options:u}=r;if(a)return a in Uo?r:{type:a,input:N1(a,l,t,i),options:u};let h=tR(l);return h?{type:h,input:N1(h,l,t,i),options:u}:(h=tR({value:l}),h?{type:h,input:N1(h,{value:l},t,i),options:u}:!1)}function cR(n,e,t,i,r){const{value:a,type:l,settings:u}=n;n.value=MP({type:l,value:a,settings:u},e,t,i),n.fromPanel=r}const fW=function(e,t,i){this.type="LEVA_ERROR",this.message="LEVA: "+e,this.previousValue=t,this.error=i};function MP({type:n,value:e,settings:t},i,r,a){const l=n!=="SELECT"&&typeof i=="function"?i(e):i;let u;try{u=Z7(n,l,t,e,r,a)}catch(h){throw new fW(`The value \`${i}\` did not result in a correct value.`,e,h)}return b0(u,e)?e:u}const EP=(n,e,t=!1)=>{let i=0;return function(){const r=arguments,a=t&&!i,l=()=>n.apply(this,r);window.clearTimeout(i),i=window.setTimeout(l,e),a&&l()}},TP=n=>n.shiftKey?5:n.altKey?1/5:1,dW=["value"],hW=["min","max"],pW=n=>{if(typeof n=="number")return!0;if(typeof n=="string"){const e=parseFloat(n);return isNaN(e)?!1:n.substring((""+e).length).trim().length<4}return!1},wP=(n,{min:e=-1/0,max:t=1/0,suffix:i})=>{const r=parseFloat(n);if(n===""||isNaN(r))throw Error("Invalid number");const a=qu(r,e,t);return i?a+i:a},mW=(n,{pad:e=0,suffix:t})=>{const i=parseFloat(n).toFixed(e);return t?i+t:i},AP=n=>{let{value:e}=n,t=si(n,dW);const{min:i=-1/0,max:r=1/0}=t,a=si(t,hW);let l=parseFloat(e);const u=typeof e=="string"?e.substring((""+l).length):void 0;l=qu(l,i,r);let h=t.step;h||(Number.isFinite(i)?Number.isFinite(r)?h=+(Math.abs(r-i)/100).toPrecision(1):h=+(Math.abs(l-i)/100).toPrecision(1):Number.isFinite(r)&&(h=+(Math.abs(r-l)/100).toPrecision(1)));const p=h?rR(h)*10:rR(l);h=h||p/10;const g=Math.round(qu(Math.log10(1/p),0,2));return{value:u?l+u:l,settings:Vt({initialValue:l,step:h,pad:g,min:i,max:r,suffix:u},a)}},CP=(n,{step:e,initialValue:t})=>{const i=Math.round((n-t)/e);return t+i*e};var RP=Object.freeze({__proto__:null,schema:pW,sanitize:wP,format:mW,normalize:AP,sanitizeStep:CP});function ji(){return ji=Object.assign?Object.assign.bind():function(n){for(var e=1;e({colors:{elevation1:"#292d39",elevation2:"#181c20",elevation3:"#373c4b",accent1:"#0066dc",accent2:"#007bff",accent3:"#3c93ff",highlight1:"#535760",highlight2:"#8c92a4",highlight3:"#fefefe",vivid1:"#ffcc00",folderWidgetColor:"$highlight2",folderTextColor:"$highlight3",toolTipBackground:"$highlight3",toolTipText:"$elevation2"},radii:{xs:"2px",sm:"3px",lg:"10px"},space:{xs:"3px",sm:"6px",md:"10px",rowGap:"7px",colGap:"7px"},fonts:{mono:"ui-monospace, SFMono-Regular, Menlo, 'Roboto Mono', monospace",sans:"system-ui, sans-serif"},fontSizes:{root:"11px",toolTip:"$root"},sizes:{rootWidth:"280px",controlWidth:"160px",numberInputMinWidth:"38px",scrubberWidth:"8px",scrubberHeight:"16px",rowHeight:"24px",folderTitleHeight:"20px",checkboxSize:"16px",joystickWidth:"100px",joystickHeight:"100px",colorPickerWidth:"$controlWidth",colorPickerHeight:"100px",imagePreviewWidth:"$controlWidth",imagePreviewHeight:"100px",monitorHeight:"60px",titleBarHeight:"39px"},shadows:{level1:"0 0 9px 0 #00000088",level2:"0 4px 14px #00000033"},borderWidths:{root:"0px",input:"1px",focus:"1px",hover:"1px",active:"1px",folder:"1px"},fontWeights:{label:"normal",folder:"normal",button:"normal"}});function Mb(n,e){const[t,i]=n.split(" "),r={};return t!=="none"&&(r.boxShadow=`${e.inset?"inset ":""}0 0 0 $borderWidths${[e.key]} $colors${t!=="default"&&t||e.borderColor}`),i&&(r.backgroundColor=i),r}const Og={$inputStyle:()=>n=>Mb(n,{key:"$input",borderColor:"$highlight1",inset:!0}),$focusStyle:()=>n=>Mb(n,{key:"$focus",borderColor:"$accent2"}),$hoverStyle:()=>n=>Mb(n,{key:"$hover",borderColor:"$accent1",inset:!0}),$activeStyle:()=>n=>Mb(n,{key:"$active",borderColor:"$accent1",inset:!0})},k0=X8({prefix:"leva",theme:IP(),utils:Vt(Vt({},Og),{},{$flex:()=>({display:"flex",alignItems:"center"}),$flexCenter:()=>({display:"flex",alignItems:"center",justifyContent:"center"}),$reset:()=>({outline:"none",fontSize:"inherit",fontWeight:"inherit",color:"inherit",fontFamily:"inherit",border:"none",backgroundColor:"transparent",appearance:"none"}),$draggable:()=>({touchAction:"none",WebkitUserDrag:"none",userSelect:"none"}),$focus:n=>({"&:focus":Og.$focusStyle()(n)}),$focusWithin:n=>({"&:focus-within":Og.$focusStyle()(n)}),$hover:n=>({"&:hover":Og.$hoverStyle()(n)}),$active:n=>({"&:active":Og.$activeStyle()(n)})})}),$t=k0.styled;k0.css;const vW=k0.createTheme,yW=k0.globalCss;k0.keyframes;const bW=yW({".leva__panel__dragged":{WebkitUserDrag:"none",userSelect:"none",input:{userSelect:"none"},"*":{cursor:"ew-resize !important"}}});function xW(n){const e=IP();if(!n)return{theme:e,className:""};Object.keys(n).forEach(i=>{Object.assign(e[i],n[i])});const t=vW(e);return{theme:e,className:t.className}}function Cc(n,e){const{theme:t}=U.useContext(dT);if(!(n in t)||!(e in t[n]))return Tc(hr.THEME_ERROR,n,e),"";let i=e;for(;;){let r=t[n][i];if(typeof r=="string"&&r.charAt(0)==="$")i=r.substr(1);else return r}}const NP=$t("input",{$reset:"",padding:"0 $sm",width:0,minWidth:0,flex:1,height:"100%",variants:{levaType:{number:{textAlign:"right"}},as:{textarea:{padding:"$sm"}}}}),LP=$t("div",{$draggable:"",height:"100%",$flexCenter:"",position:"relative",padding:"0 $xs",fontSize:"0.8em",opacity:.8,cursor:"default",touchAction:"none",[`& + ${NP}`]:{paddingLeft:0}}),_W=$t(LP,{cursor:"ew-resize",marginRight:"-$xs",textTransform:"uppercase",opacity:.3,"&:hover":{opacity:1},variants:{dragging:{true:{backgroundColor:"$accent2",opacity:1}}}}),SW=$t("div",{$flex:"",position:"relative",borderRadius:"$sm",overflow:"hidden",color:"inherit",height:"$rowHeight",backgroundColor:"$elevation3",$inputStyle:"$elevation1",$hover:"",$focusWithin:"",variants:{textArea:{true:{height:"auto"}}}}),MW=["innerLabel","value","onUpdate","onChange","onKeyDown","type","id","inputType","rows"],EW=["onUpdate"];function hT(n){let{innerLabel:e,value:t,onUpdate:i,onChange:r,onKeyDown:a,type:l,id:u,inputType:h="text",rows:p=0}=n,g=si(n,MW);const{id:y,emitOnEditStart:b,emitOnEditEnd:x,disabled:M}=fs(),A=u||y,w=U.useRef(null),E=p>0,R=E?"textarea":"input",D=U.useCallback(L=>k=>{const V=k.currentTarget.value;L(V)},[]);se.useEffect(()=>{const L=w.current,k=D(V=>{i(V),x()});return L?.addEventListener("blur",k),()=>L?.removeEventListener("blur",k)},[D,i,x]);const P=U.useCallback(L=>{L.key==="Enter"&&D(i)(L)},[D,i]),F=Object.assign({as:R},E?{rows:p}:{},g);return se.createElement(SW,{textArea:E},e&&typeof e=="string"?se.createElement(LP,null,e):e,se.createElement(NP,ji({levaType:l,ref:w,id:A,type:h,autoComplete:"off",spellCheck:"false",value:t,onChange:D(r),onFocus:()=>b(),onKeyPress:P,onKeyDown:a,disabled:M},F)))}function TW(n){let{onUpdate:e}=n,t=si(n,EW);const i=U.useCallback(a=>e(eW(a)),[e]),r=U.useCallback(a=>{const l=a.key==="ArrowUp"?1:a.key==="ArrowDown"?-1:0;if(l){a.preventDefault();const u=a.altKey?.1:a.shiftKey?10:1;e(h=>parseFloat(h)+l*u)}},[e]);return se.createElement(hT,ji({},t,{onUpdate:i,onKeyDown:r,type:"number"}))}const Hx=$t("div",{}),kM=$t("div",{position:"relative",background:"$elevation2",transition:"height 300ms ease",variants:{fill:{true:{},false:{}},flat:{false:{},true:{}},isRoot:{true:{},false:{paddingLeft:"$md","&::after":{content:'""',position:"absolute",left:0,top:0,width:"$borderWidths$folder",height:"100%",backgroundColor:"$folderWidgetColor",opacity:.4,transform:"translateX(-50%)"}}}},compoundVariants:[{isRoot:!0,fill:!1,css:{overflowY:"auto",maxHeight:"calc(100vh - 20px - $$titleBarHeight)"}},{isRoot:!0,flat:!1,css:{borderRadius:"$lg"}}]}),wW=$t("div",{$flex:"",color:"$folderTextColor",userSelect:"none",cursor:"pointer",height:"$folderTitleHeight",fontWeight:"$folder","> svg":{marginLeft:-4,marginRight:4,cursor:"pointer",fill:"$folderWidgetColor",opacity:.6},"&:hover > svg":{fill:"$folderWidgetColor"},[`&:hover + ${kM}::after`]:{opacity:.6},[`${Hx}:hover > & + ${kM}::after`]:{opacity:.6},[`${Hx}:hover > & > svg`]:{opacity:1}}),UP=$t("div",{position:"relative",display:"grid",gridTemplateColumns:"100%",rowGap:"$rowGap",transition:"opacity 250ms ease",variants:{toggled:{true:{opacity:1,transitionDelay:"250ms"},false:{opacity:0,transitionDelay:"0ms",pointerEvents:"none"}},isRoot:{true:{"& > div":{paddingLeft:"$md",paddingRight:"$md"},"& > div:first-of-type":{paddingTop:"$sm"},"& > div:last-of-type":{paddingBottom:"$sm"},[`> ${Hx}:not(:first-of-type)`]:{paddingTop:"$sm",marginTop:"$md",borderTop:"$borderWidths$folder solid $colors$elevation1"}}}}}),zP=$t("div",{position:"relative",zIndex:100,display:"grid",rowGap:"$rowGap",gridTemplateRows:"minmax($sizes$rowHeight, max-content)",alignItems:"center",color:"$highlight2",[`${UP} > &`]:{"&:first-of-type":{marginTop:"$rowGap"},"&:last-of-type":{marginBottom:"$rowGap"}},variants:{disabled:{true:{pointerEvents:"none"},false:{"&:hover,&:focus-within":{color:"$highlight3"}}}}}),BP=$t(zP,{gridTemplateColumns:"auto $sizes$controlWidth",columnGap:"$colGap"}),AW=$t("div",{$flex:"",height:"100%",position:"relative",overflow:"hidden","& > div":{marginLeft:"$colGap",padding:"0 $xs",opacity:.4},"& > div:hover":{opacity:.8},"& > div > svg":{display:"none",cursor:"pointer",width:13,minWidth:13,height:13,backgroundColor:"$elevation2"},"&:hover > div > svg":{display:"block"},variants:{align:{top:{height:"100%",alignItems:"flex-start",paddingTop:"$sm"}}}}),CW=$t("input",{$reset:"",height:0,width:0,opacity:0,margin:0,"& + label":{position:"relative",$flexCenter:"",height:"100%",userSelect:"none",cursor:"pointer",paddingLeft:2,paddingRight:"$sm",pointerEvents:"auto"},"& + label:after":{content:'""',width:6,height:6,backgroundColor:"$elevation3",borderRadius:"50%",$activeStyle:""},"&:focus + label:after":{$focusStyle:""},"& + label:active:after":{backgroundColor:"$accent1",$focusStyle:""},"&:checked + label:after":{backgroundColor:"$accent1"}}),HM=$t("label",{fontWeight:"$label",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","& > svg":{display:"block"}}),RW=$t("div",{opacity:1,variants:{disabled:{true:{opacity:.6,pointerEvents:"none",[`& ${HM}`]:{pointerEvents:"auto"}}}}}),FP=$t("div",{position:"fixed",top:0,bottom:0,right:0,left:0,zIndex:1e3,userSelect:"none"}),DW=$t("div",{background:"$toolTipBackground",fontFamily:"$sans",fontSize:"$toolTip",padding:"$xs $sm",color:"$toolTipText",borderRadius:"$xs",boxShadow:"$level2",maxWidth:260}),OW=$t(G7,{fill:"$toolTipBackground"});function pT({children:n,container:e=(t=>globalThis==null||(t=globalThis.document)===null||t===void 0?void 0:t.body)()}){const{className:t}=U.useContext(dT);return se.createElement(p8,{className:t,container:e},n)}const PW=["align"];function IW(){const{id:n,disable:e,disabled:t}=fs();return se.createElement(se.Fragment,null,se.createElement(CW,{id:n+"__disable",type:"checkbox",checked:!t,onChange:()=>e(!t)}),se.createElement("label",{htmlFor:n+"__disable"}))}function NW(n){const{id:e,optional:t,hint:i}=fs(),r=n.htmlFor||e||void 0,a=!i&&typeof n.children=="string"?n.children:void 0;return se.createElement(se.Fragment,null,t&&se.createElement(IW,null),i!==void 0?se.createElement(k7,null,se.createElement(H7,{asChild:!0},se.createElement(HM,ji({htmlFor:r},n))),se.createElement(V7,{side:"top",sideOffset:2},se.createElement(DW,null,i,se.createElement(OW,null)))):se.createElement(HM,ji({htmlFor:r,title:a},n)))}function ko(n){let{align:e}=n,t=si(n,PW);const{value:i,label:r,key:a,disabled:l}=fs(),{hideCopyButton:u}=gW(),h=!u&&a!==void 0,[p,g]=U.useState(!1),y=async()=>{try{await navigator.clipboard.writeText(JSON.stringify({[a]:i??""})),g(!0)}catch{Tc(hr.CLIPBOARD_ERROR,{[a]:i})}};return se.createElement(AW,{align:e,onPointerLeave:()=>g(!1)},se.createElement(NW,t),h&&!l&&se.createElement("div",{title:`Click to copy ${typeof r=="string"?r:a} value`},p?se.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},se.createElement("path",{d:"M9 2a1 1 0 000 2h2a1 1 0 100-2H9z"}),se.createElement("path",{fillRule:"evenodd",d:"M4 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v11a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm9.707 5.707a1 1 0 00-1.414-1.414L9 12.586l-1.293-1.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})):se.createElement("svg",{onClick:y,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},se.createElement("path",{d:"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z"}),se.createElement("path",{d:"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z"}))))}const LW=["toggled"],UW=$t("svg",{fill:"currentColor",transition:"transform 350ms ease, fill 250ms ease"});function mT(n){let{toggled:e}=n,t=si(n,LW);return se.createElement(UW,ji({width:"9",height:"5",viewBox:"0 0 9 5",xmlns:"http://www.w3.org/2000/svg",style:{transform:`rotate(${e?0:-90}deg)`}},t),se.createElement("path",{d:"M3.8 4.4c.4.3 1 .3 1.4 0L8 1.7A1 1 0 007.4 0H1.6a1 1 0 00-.7 1.7l3 2.7z"}))}const zW=["input"];function ro(n){let{input:e}=n,t=si(n,zW);return e?se.createElement(BP,t):se.createElement(zP,t)}function kP({value:n,type:e,settings:t,setValue:i}){const[r,a]=U.useState(nR(e,n,t)),l=U.useRef(n),u=U.useRef(t);u.current=t;const h=U.useCallback(g=>a(nR(e,g,u.current)),[e]),p=U.useCallback(g=>{try{i(g)}catch(y){const{type:b,previousValue:x}=y;if(b!=="LEVA_ERROR")throw y;h(x)}},[h,i]);return U.useEffect(()=>{b0(n,l.current)||h(n),l.current=n},[n,h]),{displayValue:r,onChange:a,onUpdate:p}}function H0(n,e){const{emitOnEditStart:t,emitOnEditEnd:i}=fs();return J2(r=>{r.first&&(document.body.classList.add("leva__panel__dragged"),t?.());const a=n(r);return r.last&&(document.body.classList.remove("leva__panel__dragged"),i?.()),a},e)}function BW(n){const e=U.useRef(null),t=U.useRef(null),i=U.useRef(!1);return U.useEffect(()=>{const r=EP(()=>{e.current.width=e.current.offsetWidth*window.devicePixelRatio,e.current.height=e.current.offsetHeight*window.devicePixelRatio,n(e.current,t.current)},250);return window.addEventListener("resize",r),i.current||(r(),i.current=!0),()=>window.removeEventListener("resize",r)},[n]),U.useEffect(()=>{t.current=e.current.getContext("2d")},[]),[e,t]}function HP(){const n=U.useRef(null),e=U.useRef({x:0,y:0}),t=U.useCallback(i=>{Object.assign(e.current,i),n.current&&(n.current.style.transform=`translate3d(${e.current.x}px, ${e.current.y}px, 0)`)},[]);return[n,t]}const FW=["__refCount"],L1=(n,e)=>{if(!n[e])return null;const t=n[e];return si(t,FW)};function kW(n){const e=F0(),[t,i]=U.useState(L1(e.getData(),n)),r=U.useCallback(p=>e.setValueAtPath(n,p,!0),[n,e]),a=U.useCallback(p=>e.setSettingsAtPath(n,p),[n,e]),l=U.useCallback(p=>e.disableInputAtPath(n,p),[n,e]),u=U.useCallback(()=>e.emitOnEditStart(n),[n,e]),h=U.useCallback(()=>e.emitOnEditEnd(n),[n,e]);return U.useEffect(()=>{i(L1(e.getData(),n));const p=e.useStore.subscribe(g=>L1(g.data,n),i,{equalityFn:P_});return()=>p()},[e,n]),[t,{set:r,setSettings:a,disable:l,storeId:e.storeId,emitOnEditStart:u,emitOnEditEnd:h}]}const HW=$t("div",{variants:{hasRange:{true:{position:"relative",display:"grid",gridTemplateColumns:"auto $sizes$numberInputMinWidth",columnGap:"$colGap",alignItems:"center"}}}}),VP=$t("div",{position:"relative",width:"100%",height:2,borderRadius:"$xs",backgroundColor:"$elevation1"}),VM=$t("div",{position:"absolute",width:"$scrubberWidth",height:"$scrubberHeight",borderRadius:"$xs",boxShadow:"0 0 0 2px $colors$elevation2",backgroundColor:"$accent2",cursor:"pointer",$active:"none $accent1",$hover:"none $accent3",variants:{position:{left:{borderTopRightRadius:0,borderBottomRightRadius:0,transform:"translateX(calc(-0.5 * ($sizes$scrubberWidth + 4px)))"},right:{borderTopLeftRadius:0,borderBottomLeftRadius:0,transform:"translateX(calc(0.5 * ($sizes$scrubberWidth + 4px)))"}}}}),GP=$t("div",{position:"relative",$flex:"",height:"100%",cursor:"pointer",touchAction:"none"}),WP=$t("div",{position:"absolute",height:"100%",backgroundColor:"$accent2"});function VW({value:n,min:e,max:t,onDrag:i,step:r,initialValue:a}){const l=U.useRef(null),u=U.useRef(null),h=U.useRef(0),p=Cc("sizes","scrubberWidth"),g=H0(({event:b,first:x,xy:[M],movement:[A],memo:w})=>{if(x){const{width:R,left:D}=l.current.getBoundingClientRect();h.current=R-parseFloat(p),w=b?.target===u.current?n:kx((M-D)/R,e,t)}const E=w+kx(A/h.current,0,t-e);return i(CP(E,{step:r,initialValue:a})),w}),y=Fx(n,e,t);return se.createElement(GP,ji({ref:l},g()),se.createElement(VP,null,se.createElement(WP,{style:{left:0,right:`${(1-y)*100}%`}})),se.createElement(VM,{ref:u,style:{left:`calc(${y} * (100% - ${p}))`}}))}const GW=se.memo(({label:n,onUpdate:e,step:t,innerLabelTrim:i})=>{const[r,a]=U.useState(!1),l=H0(({active:u,delta:[h],event:p,memo:g=0,first:y,last:b,target:x})=>(y&&x.requestPointerLock(),b&&document.exitPointerLock(),a(u),g+=h/2,Math.abs(g)>=1&&(e(M=>parseFloat(M)+Math.floor(g)*t*TP(p)),g=0),g));return se.createElement(_W,ji({dragging:r,title:n.length>1?n:""},l()),n.slice(0,i))});function $P({label:n,id:e,displayValue:t,onUpdate:i,onChange:r,settings:a,innerLabelTrim:l=1}){const u=l>0&&se.createElement(GW,{label:n,step:a.step,onUpdate:i,innerLabelTrim:l});return se.createElement(TW,{id:e,value:String(t),onUpdate:i,onChange:r,innerLabel:u})}function WW(){const n=fs(),{label:e,value:t,onUpdate:i,settings:r,id:a}=n,{min:l,max:u}=r,h=u!==1/0&&l!==-1/0;return se.createElement(ro,{input:!0},se.createElement(ko,null,e),se.createElement(HW,{hasRange:h},h&&se.createElement(VW,ji({value:parseFloat(t),onDrag:i},r)),se.createElement($P,ji({},n,{id:a,label:"value",innerLabelTrim:h?0:1}))))}const{sanitizeStep:$W}=RP,XW=si(RP,["sanitizeStep"]);var jW=Vt({component:WW},XW);const qW=(n,e)=>oa().schema({options:oa().passesAnyOf(oa().object(),oa().array())}).test(e),YW=(n,{values:e})=>{if(e.indexOf(n)<0)throw Error("Selected value doesn't match Select options");return n},ZW=(n,{values:e})=>e.indexOf(n),KW=n=>{let{value:e,options:t}=n,i,r;return Array.isArray(t)?(r=t,i=t.map(a=>String(a))):(r=Object.values(t),i=Object.keys(t)),"value"in n?r.includes(e)||(i.unshift(String(e)),r.unshift(e)):e=r[0],Object.values(t).includes(e)||(t[String(e)]=e),{value:e,settings:{keys:i,values:r}}};var QW=Object.freeze({__proto__:null,schema:qW,sanitize:YW,format:ZW,normalize:KW});const JW=$t("div",{$flexCenter:"",position:"relative","> svg":{pointerEvents:"none",position:"absolute",right:"$md"}}),GM=$t("select",{position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:0}),e$=$t("div",{display:"flex",alignItems:"center",width:"100%",height:"$rowHeight",backgroundColor:"$elevation3",borderRadius:"$sm",padding:"0 $sm",cursor:"pointer",[`${GM}:focus + &`]:{$focusStyle:""},[`${GM}:hover + &`]:{$hoverStyle:""}});function t$({displayValue:n,value:e,onUpdate:t,id:i,settings:r,disabled:a}){const{keys:l,values:u}=r,h=U.useRef();return e===u[n]&&(h.current=l[n]),se.createElement(JW,null,se.createElement(GM,{id:i,value:n,onChange:p=>t(u[Number(p.currentTarget.value)]),disabled:a},l.map((p,g)=>se.createElement("option",{key:p,value:g},p))),se.createElement(e$,null,h.current),se.createElement(mT,{toggled:!0}))}function n$(){const{label:n,value:e,displayValue:t,onUpdate:i,id:r,disabled:a,settings:l}=fs();return se.createElement(ro,{input:!0},se.createElement(ko,null,n),se.createElement(t$,{id:r,value:e,displayValue:t,onUpdate:i,settings:l,disabled:a}))}var i$=Vt({component:n$},QW);const r$=n=>oa().string().test(n),s$=n=>{if(typeof n!="string")throw Error("Invalid string");return n},a$=({value:n,editable:e=!0,rows:t=!1})=>({value:n,settings:{editable:e,rows:typeof t=="number"?t:t?5:0}});var o$=Object.freeze({__proto__:null,schema:r$,sanitize:s$,normalize:a$});const l$=["displayValue","onUpdate","onChange","editable"],c$=$t("div",{whiteSpace:"pre-wrap"});function u$(n){let{displayValue:e,onUpdate:t,onChange:i,editable:r=!0}=n,a=si(n,l$);return r?se.createElement(hT,ji({value:e,onUpdate:t,onChange:i},a)):se.createElement(c$,null,e)}function f$(){const{label:n,settings:e,displayValue:t,onUpdate:i,onChange:r}=fs();return se.createElement(ro,{input:!0},se.createElement(ko,null,n),se.createElement(u$,ji({displayValue:t,onUpdate:i,onChange:r},e)))}var d$=Vt({component:f$},o$);const h$=n=>oa().boolean().test(n),p$=n=>{if(typeof n!="boolean")throw Error("Invalid boolean");return n};var m$=Object.freeze({__proto__:null,schema:h$,sanitize:p$});const g$=$t("div",{position:"relative",$flex:"",height:"$rowHeight",input:{$reset:"",height:0,width:0,opacity:0,margin:0},label:{position:"relative",$flexCenter:"",userSelect:"none",cursor:"pointer",height:"$checkboxSize",width:"$checkboxSize",backgroundColor:"$elevation3",borderRadius:"$sm",$hover:""},"input:focus + label":{$focusStyle:""},"input:focus:checked + label, input:checked + label:hover":{$hoverStyle:"$accent3"},"input + label:active":{backgroundColor:"$accent1"},"input:checked + label:active":{backgroundColor:"$accent1"},"label > svg":{display:"none",width:"90%",height:"90%",stroke:"$highlight3"},"input:checked + label":{backgroundColor:"$accent2"},"input:checked + label > svg":{display:"block"}});function v$({value:n,onUpdate:e,id:t,disabled:i}){return se.createElement(g$,null,se.createElement("input",{id:t,type:"checkbox",checked:n,onChange:r=>e(r.currentTarget.checked),disabled:i}),se.createElement("label",{htmlFor:t},se.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},se.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}))))}function y$(){const{label:n,value:e,onUpdate:t,disabled:i,id:r}=fs();return se.createElement(ro,{input:!0},se.createElement(ko,null,n),se.createElement(v$,{value:e,onUpdate:t,id:r,disabled:i}))}var b$=Vt({component:y$},m$);const x$=["locked"];function _$({value:n,id:e,valueKey:t,settings:i,onUpdate:r,innerLabelTrim:a}){const l=U.useRef(n[t]);l.current=n[t];const u=U.useCallback(p=>r({[t]:MP({type:"NUMBER",value:l.current,settings:i},p)}),[r,i,t]),h=kP({type:"NUMBER",value:n[t],settings:i,setValue:u});return se.createElement($P,{id:e,label:t,value:n[t],displayValue:h.displayValue,onUpdate:h.onUpdate,onChange:h.onChange,settings:i,innerLabelTrim:a})}const S$=$t("div",{display:"grid",columnGap:"$colGap",gridAutoFlow:"column dense",alignItems:"center",variants:{withLock:{true:{gridTemplateColumns:"10px auto","> svg":{cursor:"pointer"}}}}});function M$(n){let{locked:e}=n,t=si(n,x$);return se.createElement("svg",ji({width:"10",height:"10",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),e?se.createElement("path",{d:"M5 4.63601C5 3.76031 5.24219 3.1054 5.64323 2.67357C6.03934 2.24705 6.64582 1.9783 7.5014 1.9783C8.35745 1.9783 8.96306 2.24652 9.35823 2.67208C9.75838 3.10299 10 3.75708 10 4.63325V5.99999H5V4.63601ZM4 5.99999V4.63601C4 3.58148 4.29339 2.65754 4.91049 1.99307C5.53252 1.32329 6.42675 0.978302 7.5014 0.978302C8.57583 0.978302 9.46952 1.32233 10.091 1.99162C10.7076 2.65557 11 3.57896 11 4.63325V5.99999H12C12.5523 5.99999 13 6.44771 13 6.99999V13C13 13.5523 12.5523 14 12 14H3C2.44772 14 2 13.5523 2 13V6.99999C2 6.44771 2.44772 5.99999 3 5.99999H4ZM3 6.99999H12V13H3V6.99999Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}):se.createElement("path",{d:"M9 3.63601C9 2.76044 9.24207 2.11211 9.64154 1.68623C10.0366 1.26502 10.6432 1 11.5014 1C12.4485 1 13.0839 1.30552 13.4722 1.80636C13.8031 2.23312 14 2.84313 14 3.63325H15C15 2.68242 14.7626 1.83856 14.2625 1.19361C13.6389 0.38943 12.6743 0 11.5014 0C10.4294 0 9.53523 0.337871 8.91218 1.0021C8.29351 1.66167 8 2.58135 8 3.63601V6H1C0.447715 6 0 6.44772 0 7V13C0 13.5523 0.447715 14 1 14H10C10.5523 14 11 13.5523 11 13V7C11 6.44772 10.5523 6 10 6H9V3.63601ZM1 7H10V13H1V7Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}))}function gT({value:n,onUpdate:e,settings:t,innerLabelTrim:i}){const{id:r,setSettings:a}=fs(),{lock:l,locked:u}=t;return se.createElement(S$,{withLock:l},l&&se.createElement(M$,{locked:u,onClick:()=>a({locked:!u})}),Object.keys(n).map((h,p)=>se.createElement(_$,{id:p===0?r:`${r}.${h}`,key:h,valueKey:h,value:n,settings:t[h],onUpdate:e,innerLabelTrim:i})))}const XP=(n,e)=>{const t={};let i=0,r=1/0;Object.entries(n).forEach(([a,l])=>{t[a]=AP(Vt({value:l},e[a])).settings,i=Math.max(i,t[a].step),r=Math.min(r,t[a].pad)});for(let a in t){const{step:l,min:u,max:h}=e[a]||{};!isFinite(l)&&(!isFinite(u)||!isFinite(h))&&(t[a].step=i,t[a].pad=r)}return t},E$=["lock"],T$=["value"];function w$(n){const e=oa().array().length(n).every.number(),t=i=>{if(!i||typeof i!="object")return!1;const r=Object.values(i);return r.length===n&&r.every(a=>isFinite(a))};return i=>e.test(i)||t(i)}function A$(n){return Array.isArray(n)?"array":"object"}function Kg(n,e,t){return A$(n)===e?n:e==="array"?Object.values(n):sW(n,t)}const C$=(n,e,t)=>{const i=Kg(n,"object",e.keys);for(let l in i)i[l]=wP(i[l],e[l]);const r=Object.keys(i);let a={};if(r.length===e.keys.length)a=i;else{const l=Kg(t,"object",e.keys);if(r.length===1&&e.locked){const u=r[0],h=i[u],p=l[u],g=p!==0?h/p:1;for(let y in l)y===u?a[u]=h:a[y]=l[y]*g}else a=Vt(Vt({},l),i)}return Kg(a,e.format,e.keys)},R$=(n,e)=>Kg(n,"object",e.keys),D$=n=>!!n&&("step"in n||"min"in n||"max"in n);function O$(n,e,t=[]){const{lock:i=!1}=e,r=si(e,E$),a=Array.isArray(n)?"array":"object",l=a==="object"?Object.keys(n):t,u=Kg(n,"object",l),h=D$(r)?l.reduce((g,y)=>Object.assign(g,{[y]:r}),{}):r,p=XP(u,h);return{value:a==="array"?n:u,settings:Vt(Vt({},p),{},{format:a,keys:l,lock:i,locked:!1})}}function jP(n){return{schema:w$(n.length),normalize:e=>{let{value:t}=e,i=si(e,T$);return O$(t,i,n)},format:(e,t)=>R$(e,t),sanitize:(e,t,i)=>C$(e,t,i)}}var P$={grad:.9,turn:360,rad:360/(2*Math.PI)},xc=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},Dr=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*n)/t+0},to=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),n>t?t:n>e?n:e},qP=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},uR=function(n){return{r:to(n.r,0,255),g:to(n.g,0,255),b:to(n.b,0,255),a:to(n.a)}},U1=function(n){return{r:Dr(n.r),g:Dr(n.g),b:Dr(n.b),a:Dr(n.a,3)}},I$=/^#([0-9a-f]{3,8})$/i,Eb=function(n){var e=n.toString(16);return e.length<2?"0"+e:e},YP=function(n){var e=n.r,t=n.g,i=n.b,r=n.a,a=Math.max(e,t,i),l=a-Math.min(e,t,i),u=l?a===e?(t-i)/l:a===t?2+(i-e)/l:4+(e-t)/l:0;return{h:60*(u<0?u+6:u),s:a?l/a*100:0,v:a/255*100,a:r}},ZP=function(n){var e=n.h,t=n.s,i=n.v,r=n.a;e=e/360*6,t/=100,i/=100;var a=Math.floor(e),l=i*(1-t),u=i*(1-(e-a)*t),h=i*(1-(1-e+a)*t),p=a%6;return{r:255*[i,u,l,l,h,i][p],g:255*[h,i,i,u,l,l][p],b:255*[l,l,h,i,i,u][p],a:r}},fR=function(n){return{h:qP(n.h),s:to(n.s,0,100),l:to(n.l,0,100),a:to(n.a)}},dR=function(n){return{h:Dr(n.h),s:Dr(n.s),l:Dr(n.l),a:Dr(n.a,3)}},hR=function(n){return ZP((t=(e=n).s,{h:e.h,s:(t*=((i=e.l)<50?i:100-i)/100)>0?2*t/(i+t)*100:0,v:i+t,a:e.a}));var e,t,i},Qg=function(n){return{h:(e=YP(n)).h,s:(r=(200-(t=e.s))*(i=e.v)/100)>0&&r<200?t*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,t,i,r},N$=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,L$=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,U$=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,z$=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,WM={string:[[function(n){var e=I$.exec(n);return e?(n=e[1]).length<=4?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?Dr(parseInt(n[3]+n[3],16)/255,2):1}:n.length===6||n.length===8?{r:parseInt(n.substr(0,2),16),g:parseInt(n.substr(2,2),16),b:parseInt(n.substr(4,2),16),a:n.length===8?Dr(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var e=U$.exec(n)||z$.exec(n);return e?e[2]!==e[4]||e[4]!==e[6]?null:uR({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(n){var e=N$.exec(n)||L$.exec(n);if(!e)return null;var t,i,r=fR({h:(t=e[1],i=e[2],i===void 0&&(i="deg"),Number(t)*(P$[i]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return hR(r)},"hsl"]],object:[[function(n){var e=n.r,t=n.g,i=n.b,r=n.a,a=r===void 0?1:r;return xc(e)&&xc(t)&&xc(i)?uR({r:Number(e),g:Number(t),b:Number(i),a:Number(a)}):null},"rgb"],[function(n){var e=n.h,t=n.s,i=n.l,r=n.a,a=r===void 0?1:r;if(!xc(e)||!xc(t)||!xc(i))return null;var l=fR({h:Number(e),s:Number(t),l:Number(i),a:Number(a)});return hR(l)},"hsl"],[function(n){var e=n.h,t=n.s,i=n.v,r=n.a,a=r===void 0?1:r;if(!xc(e)||!xc(t)||!xc(i))return null;var l=(function(u){return{h:qP(u.h),s:to(u.s,0,100),v:to(u.v,0,100),a:to(u.a)}})({h:Number(e),s:Number(t),v:Number(i),a:Number(a)});return ZP(l)},"hsv"]]},pR=function(n,e){for(var t=0;t=.5},n.prototype.toHex=function(){return e=U1(this.rgba),t=e.r,i=e.g,r=e.b,l=(a=e.a)<1?Eb(Dr(255*a)):"","#"+Eb(t)+Eb(i)+Eb(r)+l;var e,t,i,r,a,l},n.prototype.toRgb=function(){return U1(this.rgba)},n.prototype.toRgbString=function(){return e=U1(this.rgba),t=e.r,i=e.g,r=e.b,(a=e.a)<1?"rgba("+t+", "+i+", "+r+", "+a+")":"rgb("+t+", "+i+", "+r+")";var e,t,i,r,a},n.prototype.toHsl=function(){return dR(Qg(this.rgba))},n.prototype.toHslString=function(){return e=dR(Qg(this.rgba)),t=e.h,i=e.s,r=e.l,(a=e.a)<1?"hsla("+t+", "+i+"%, "+r+"%, "+a+")":"hsl("+t+", "+i+"%, "+r+"%)";var e,t,i,r,a},n.prototype.toHsv=function(){return e=YP(this.rgba),{h:Dr(e.h),s:Dr(e.s),v:Dr(e.v),a:Dr(e.a,3)};var e},n.prototype.invert=function(){return Ds({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},n.prototype.saturate=function(e){return e===void 0&&(e=.1),Ds(z1(this.rgba,e))},n.prototype.desaturate=function(e){return e===void 0&&(e=.1),Ds(z1(this.rgba,-e))},n.prototype.grayscale=function(){return Ds(z1(this.rgba,-1))},n.prototype.lighten=function(e){return e===void 0&&(e=.1),Ds(mR(this.rgba,e))},n.prototype.darken=function(e){return e===void 0&&(e=.1),Ds(mR(this.rgba,-e))},n.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},n.prototype.alpha=function(e){return typeof e=="number"?Ds({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):Dr(this.rgba.a,3);var t},n.prototype.hue=function(e){var t=Qg(this.rgba);return typeof e=="number"?Ds({h:e,s:t.s,l:t.l,a:t.a}):Dr(t.h)},n.prototype.isEqual=function(e){return this.toHex()===Ds(e).toHex()},n})(),Ds=function(n){return n instanceof $M?n:new $M(n)},gR=[],F$=function(n){n.forEach(function(e){gR.indexOf(e)<0&&(e($M,WM),gR.push(e))})};function k$(n,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var r in t)i[t[r]]=r;var a={};n.prototype.toName=function(l){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var u,h,p=i[this.toHex()];if(p)return p;if(l?.closest){var g=this.toRgb(),y=1/0,b="black";if(!a.length)for(var x in t)a[x]=new n(t[x]).toRgb();for(var M in t){var A=(u=g,h=a[M],Math.pow(u.r-h.r,2)+Math.pow(u.g-h.g,2)+Math.pow(u.b-h.b,2));A=0||(r[t]=n[t]);return r}function XM(n){var e=U.useRef(n),t=U.useRef(function(i){e.current&&e.current(i)});return e.current=n,t.current}var Ip=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),n>t?t:n0:w.buttons>0)&&r.current?a(vR(r.current,w,u.current)):A(!1)},M=function(){return A(!1)};function A(w){var E=h.current,R=jM(r.current),D=w?R.addEventListener:R.removeEventListener;D(E?"touchmove":"mousemove",x),D(E?"touchend":"mouseup",M)}return[function(w){var E=w.nativeEvent,R=r.current;if(R&&(yR(E),!(function(P,F){return F&&!Jg(P)})(E,h.current)&&R)){if(Jg(E)){h.current=!0;var D=E.changedTouches||[];D.length&&(u.current=D[0].identifier)}R.focus(),a(vR(R,E,u.current)),A(!0)}},function(w){var E=w.which||w.keyCode;E<37||E>40||(w.preventDefault(),l({left:E===39?.05:E===37?-.05:0,top:E===40?.05:E===38?-.05:0}))},A]},[l,a]),g=p[0],y=p[1],b=p[2];return U.useEffect(function(){return b},[b]),se.createElement("div",Hp({},i,{onTouchStart:g,onMouseDown:g,className:"react-colorful__interactive",ref:r,onKeyDown:y,tabIndex:0,role:"slider"}))}),V0=function(n){return n.filter(Boolean).join(" ")},bT=function(n){var e=n.color,t=n.left,i=n.top,r=i===void 0?.5:i,a=V0(["react-colorful__pointer",n.className]);return se.createElement("div",{className:a,style:{top:100*r+"%",left:100*t+"%"}},se.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:e}}))},Ps=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*n)/t},QP=function(n){var e=n.s,t=n.v,i=n.a,r=(200-e)*t/100;return{h:Ps(n.h),s:Ps(r>0&&r<200?e*t/100/(r<=100?r:200-r)*100:0),l:Ps(r/2),a:Ps(i,2)}},qM=function(n){var e=QP(n);return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},F1=function(n){var e=QP(n);return"hsla("+e.h+", "+e.s+"%, "+e.l+"%, "+e.a+")"},JP=function(n){var e=n.h,t=n.s,i=n.v,r=n.a;e=e/360*6,t/=100,i/=100;var a=Math.floor(e),l=i*(1-t),u=i*(1-(e-a)*t),h=i*(1-(1-e+a)*t),p=a%6;return{r:Ps(255*[i,u,l,l,h,i][p]),g:Ps(255*[h,i,i,u,l,l][p]),b:Ps(255*[l,l,h,i,i,u][p]),a:Ps(r,2)}},eI=function(n){var e=n.r,t=n.g,i=n.b,r=n.a,a=Math.max(e,t,i),l=a-Math.min(e,t,i),u=l?a===e?(t-i)/l:a===t?2+(i-e)/l:4+(e-t)/l:0;return{h:Ps(60*(u<0?u+6:u)),s:Ps(a?l/a*100:0),v:Ps(a/255*100),a:r}},tI=se.memo(function(n){var e=n.hue,t=n.onChange,i=V0(["react-colorful__hue",n.className]);return se.createElement("div",{className:i},se.createElement(yT,{onMove:function(r){t({h:360*r.left})},onKey:function(r){t({h:Ip(e+360*r.left,0,360)})},"aria-label":"Hue","aria-valuenow":Ps(e),"aria-valuemax":"360","aria-valuemin":"0"},se.createElement(bT,{className:"react-colorful__hue-pointer",left:e/360,color:qM({h:e,s:100,v:100,a:1})})))}),nI=se.memo(function(n){var e=n.hsva,t=n.onChange,i={backgroundColor:qM({h:e.h,s:100,v:100,a:1})};return se.createElement("div",{className:"react-colorful__saturation",style:i},se.createElement(yT,{onMove:function(r){t({s:100*r.left,v:100-100*r.top})},onKey:function(r){t({s:Ip(e.s+100*r.left,0,100),v:Ip(e.v-100*r.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+Ps(e.s)+"%, Brightness "+Ps(e.v)+"%"},se.createElement(bT,{className:"react-colorful__saturation-pointer",top:1-e.v/100,left:e.s/100,color:qM(e)})))}),xT=function(n,e){if(n===e)return!0;for(var t in n)if(n[t]!==e[t])return!1;return!0};function iI(n,e,t){var i=XM(t),r=U.useState(function(){return n.toHsva(e)}),a=r[0],l=r[1],u=U.useRef({color:e,hsva:a});U.useEffect(function(){if(!n.equal(e,u.current.color)){var p=n.toHsva(e);u.current={hsva:p,color:e},l(p)}},[e,n]),U.useEffect(function(){var p;xT(a,u.current.hsva)||n.equal(p=n.fromHsva(a),u.current.color)||(u.current={hsva:a,color:p},i(p))},[a,n,i]);var h=U.useCallback(function(p){l(function(g){return Object.assign({},g,p)})},[]);return[a,h]}var H$=typeof window<"u"?U.useLayoutEffect:U.useEffect,V$=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},bR=new Map,rI=function(n){H$(function(){var e=n.current?n.current.ownerDocument:document;if(e!==void 0&&!bR.has(e)){var t=e.createElement("style");t.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,bR.set(e,t);var i=V$();i&&t.setAttribute("nonce",i),e.head.appendChild(t)}},[])},G$=function(n){var e=n.className,t=n.colorModel,i=n.color,r=i===void 0?t.defaultColor:i,a=n.onChange,l=vT(n,["className","colorModel","color","onChange"]),u=U.useRef(null);rI(u);var h=iI(t,r,a),p=h[0],g=h[1],y=V0(["react-colorful",e]);return se.createElement("div",Hp({},l,{ref:u,className:y}),se.createElement(nI,{hsva:p,onChange:g}),se.createElement(tI,{hue:p.h,onChange:g,className:"react-colorful__last-control"}))},W$=function(n){var e=n.className,t=n.hsva,i=n.onChange,r={backgroundImage:"linear-gradient(90deg, "+F1(Object.assign({},t,{a:0}))+", "+F1(Object.assign({},t,{a:1}))+")"},a=V0(["react-colorful__alpha",e]),l=Ps(100*t.a);return se.createElement("div",{className:a},se.createElement("div",{className:"react-colorful__alpha-gradient",style:r}),se.createElement(yT,{onMove:function(u){i({a:u.left})},onKey:function(u){i({a:Ip(t.a+u.left)})},"aria-label":"Alpha","aria-valuetext":l+"%","aria-valuenow":l,"aria-valuemin":"0","aria-valuemax":"100"},se.createElement(bT,{className:"react-colorful__alpha-pointer",left:t.a,color:F1(t)})))},$$=function(n){var e=n.className,t=n.colorModel,i=n.color,r=i===void 0?t.defaultColor:i,a=n.onChange,l=vT(n,["className","colorModel","color","onChange"]),u=U.useRef(null);rI(u);var h=iI(t,r,a),p=h[0],g=h[1],y=V0(["react-colorful",e]);return se.createElement("div",Hp({},l,{ref:u,className:y}),se.createElement(nI,{hsva:p,onChange:g}),se.createElement(tI,{hue:p.h,onChange:g}),se.createElement(W$,{hsva:p,onChange:g,className:"react-colorful__last-control"}))},X$={defaultColor:{r:0,g:0,b:0,a:1},toHsva:eI,fromHsva:JP,equal:xT},j$=function(n){return se.createElement($$,Hp({},n,{colorModel:X$}))},q$={defaultColor:{r:0,g:0,b:0},toHsva:function(n){return eI({r:n.r,g:n.g,b:n.b,a:1})},fromHsva:function(n){return{r:(e=JP(n)).r,g:e.g,b:e.b};var e},equal:xT},Y$=function(n){return se.createElement(G$,Hp({},n,{colorModel:q$}))},k1={exports:{}},H1,xR;function Z$(){if(xR)return H1;xR=1;var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return H1=n,H1}var V1,_R;function K$(){if(_R)return V1;_R=1;var n=Z$();function e(){}function t(){}return t.resetWarningCache=e,V1=function(){function i(l,u,h,p,g,y){if(y!==n){var b=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw b.name="Invariant Violation",b}}i.isRequired=i;function r(){return i}var a={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:r,element:i,elementType:i,instanceOf:r,node:i,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:t,resetWarningCache:e};return a.PropTypes=a,a},V1}var SR;function Q$(){return SR||(SR=1,k1.exports=K$()()),k1.exports}var J$=Q$();const di=Yu(J$);function Vp(n,e,t,i){function r(a){return a instanceof t?a:new t(function(l){l(a)})}return new(t||(t=Promise))(function(a,l){function u(g){try{p(i.next(g))}catch(y){l(y)}}function h(g){try{p(i.throw(g))}catch(y){l(y)}}function p(g){g.done?a(g.value):r(g.value).then(u,h)}p((i=i.apply(n,e||[])).next())})}function Gp(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,l=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return l.next=u(0),l.throw=u(1),l.return=u(2),typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function u(p){return function(g){return h([p,g])}}function h(p){if(i)throw new TypeError("Generator is already executing.");for(;l&&(l=0,p[0]&&(t=0)),t;)try{if(i=1,r&&(a=p[0]&2?r.return:p[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,p[1])).done)return a;switch(r=0,a&&(p=[p[0]&2,a.value]),p[0]){case 0:case 1:a=p;break;case 4:return t.label++,{value:p[1],done:!1};case 5:t.label++,r=p[1],p=[0];continue;case 7:p=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(p[0]===6||p[0]===2)){t=0;continue}if(p[0]===3&&(!a||p[1]>a[0]&&p[1]0)&&!(r=i.next()).done;)a.push(r.value)}catch(u){l={error:u}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(l)throw l.error}}return a}function tX(){for(var n=[],e=0;e0?i:n.name,writable:!1,configurable:!1,enumerable:!0})}return t}function iX(n){var e=n.name,t=e&&e.lastIndexOf(".")!==-1;if(t&&!n.type){var i=e.split(".").pop().toLowerCase(),r=nX.get(i);r&&Object.defineProperty(n,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return n}var rX=[".DS_Store","Thumbs.db"];function sX(n){return Vp(this,void 0,void 0,function(){return Gp(this,function(e){return Vx(n)&&aX(n)?[2,uX(n.dataTransfer,n.type)]:oX(n)?[2,lX(n)]:Array.isArray(n)&&n.every(function(t){return"getFile"in t&&typeof t.getFile=="function"})?[2,cX(n)]:[2,[]]})})}function aX(n){return Vx(n.dataTransfer)}function oX(n){return Vx(n)&&Vx(n.target)}function Vx(n){return typeof n=="object"&&n!==null}function lX(n){return YM(n.target.files).map(function(e){return G0(e)})}function cX(n){return Vp(this,void 0,void 0,function(){var e;return Gp(this,function(t){switch(t.label){case 0:return[4,Promise.all(n.map(function(i){return i.getFile()}))];case 1:return e=t.sent(),[2,e.map(function(i){return G0(i)})]}})})}function uX(n,e){return Vp(this,void 0,void 0,function(){var t,i;return Gp(this,function(r){switch(r.label){case 0:return n===null?[2,[]]:n.items?(t=YM(n.items).filter(function(a){return a.kind==="file"}),e!=="drop"?[2,t]:[4,Promise.all(t.map(fX))]):[3,2];case 1:return i=r.sent(),[2,MR(sI(i))];case 2:return[2,MR(YM(n.files).map(function(a){return G0(a)}))]}})})}function MR(n){return n.filter(function(e){return rX.indexOf(e.name)===-1})}function YM(n){if(n===null)return[];for(var e=[],t=0;tn.length)&&(e=n.length);for(var t=0,i=new Array(e);tt)return[!1,DR(t)];if(n.sizet)return[!1,DR(t)]}return[!0,null]}function Pg(n){return n!=null}function AX(n){var e=n.files,t=n.accept,i=n.minSize,r=n.maxSize,a=n.multiple,l=n.maxFiles;return!a&&e.length>1||a&&l>=1&&e.length>l?!1:e.every(function(u){var h=lI(u,t),p=CR(h,1),g=p[0],y=cI(u,i,r),b=CR(y,1),x=b[0];return g&&x})}function Gx(n){return typeof n.isPropagationStopped=="function"?n.isPropagationStopped():typeof n.cancelBubble<"u"?n.cancelBubble:!1}function wb(n){return n.dataTransfer?Array.prototype.some.call(n.dataTransfer.types,function(e){return e==="Files"||e==="application/x-moz-file"}):!!n.target&&!!n.target.files}function PR(n){n.preventDefault()}function CX(n){return n.indexOf("MSIE")!==-1||n.indexOf("Trident/")!==-1}function RX(n){return n.indexOf("Edge/")!==-1}function DX(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return CX(n)||RX(n)}function Ml(){for(var n=arguments.length,e=new Array(n),t=0;t1?r-1:0),l=1;ln.length)&&(e=n.length);for(var t=0,i=new Array(e);t=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}function XX(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,a;for(a=0;a=0)&&(t[r]=n[r]);return t}var _T=U.forwardRef(function(n,e){var t=n.children,i=Wx(n,LX),r=dI(i),a=r.open,l=Wx(r,UX);return U.useImperativeHandle(e,function(){return{open:a}},[a]),se.createElement(U.Fragment,null,t(Ni(Ni({},l),{},{open:a})))});_T.displayName="Dropzone";var fI={disabled:!1,getFilesFromEvent:sX,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!0};_T.defaultProps=fI;_T.propTypes={children:di.func,accept:di.oneOfType([di.string,di.arrayOf(di.string)]),multiple:di.bool,preventDropOnDocument:di.bool,noClick:di.bool,noKeyboard:di.bool,noDrag:di.bool,noDragEventsBubbling:di.bool,minSize:di.number,maxSize:di.number,maxFiles:di.number,disabled:di.bool,getFilesFromEvent:di.func,onFileDialogCancel:di.func,onFileDialogOpen:di.func,useFsAccessApi:di.bool,onDragEnter:di.func,onDragLeave:di.func,onDragOver:di.func,onDrop:di.func,onDropAccepted:di.func,onDropRejected:di.func,validator:di.func};var QM={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,draggedFiles:[],acceptedFiles:[],fileRejections:[]};function dI(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=Ni(Ni({},fI),n),t=e.accept,i=e.disabled,r=e.getFilesFromEvent,a=e.maxSize,l=e.minSize,u=e.multiple,h=e.maxFiles,p=e.onDragEnter,g=e.onDragLeave,y=e.onDragOver,b=e.onDrop,x=e.onDropAccepted,M=e.onDropRejected,A=e.onFileDialogCancel,w=e.onFileDialogOpen,E=e.useFsAccessApi,R=e.preventDropOnDocument,D=e.noClick,P=e.noKeyboard,F=e.noDrag,L=e.noDragEventsBubbling,k=e.validator,V=U.useMemo(function(){return typeof w=="function"?w:NR},[w]),N=U.useMemo(function(){return typeof A=="function"?A:NR},[A]),z=U.useRef(null),X=U.useRef(null),Q=U.useReducer(jX,QM),J=G1(Q,2),oe=J[0],re=J[1],q=oe.isFocused,Z=oe.isFileDialogActive,ne=oe.draggedFiles,pe=U.useRef(typeof window<"u"&&window.isSecureContext&&E&&OX()),Ee=function(){!pe.current&&Z&&setTimeout(function(){if(X.current){var I=X.current.files;I.length||(re({type:"closeDialog"}),N())}},300)};U.useEffect(function(){return window.addEventListener("focus",Ee,!1),function(){window.removeEventListener("focus",Ee,!1)}},[X,Z,N,pe]);var j=U.useRef([]),fe=function(I){z.current&&z.current.contains(I.target)||(I.preventDefault(),j.current=[])};U.useEffect(function(){return R&&(document.addEventListener("dragover",PR,!1),document.addEventListener("drop",fe,!1)),function(){R&&(document.removeEventListener("dragover",PR),document.removeEventListener("drop",fe))}},[z,R]);var be=U.useCallback(function(H){H.preventDefault(),H.persist(),ze(H),j.current=[].concat(FX(j.current),[H.target]),wb(H)&&Promise.resolve(r(H)).then(function(I){Gx(H)&&!L||(re({draggedFiles:I,isDragActive:!0,type:"setDraggedFiles"}),p&&p(H))})},[r,p,L]),Fe=U.useCallback(function(H){H.preventDefault(),H.persist(),ze(H);var I=wb(H);if(I&&H.dataTransfer)try{H.dataTransfer.dropEffect="copy"}catch{}return I&&y&&y(H),!1},[y,L]),rt=U.useCallback(function(H){H.preventDefault(),H.persist(),ze(H);var I=j.current.filter(function(ue){return z.current&&z.current.contains(ue)}),ee=I.indexOf(H.target);ee!==-1&&I.splice(ee,1),j.current=I,!(I.length>0)&&(re({isDragActive:!1,type:"setDraggedFiles",draggedFiles:[]}),wb(H)&&g&&g(H))},[z,g,L]),he=U.useCallback(function(H,I){var ee=[],ue=[];H.forEach(function(De){var _e=lI(De,t),nt=G1(_e,2),Ye=nt[0],dt=nt[1],Ct=cI(De,l,a),$e=G1(Ct,2),Ke=$e[0],ht=$e[1],te=k?k(De):null;if(Ye&&Ke&&!te)ee.push(De);else{var ye=[dt,ht];te&&(ye=ye.concat(te)),ue.push({file:De,errors:ye.filter(function(it){return it})})}}),(!u&&ee.length>1||u&&h>=1&&ee.length>h)&&(ee.forEach(function(De){ue.push({file:De,errors:[wX]})}),ee.splice(0)),re({acceptedFiles:ee,fileRejections:ue,type:"setFiles"}),b&&b(ee,ue,I),ue.length>0&&M&&M(ue,I),ee.length>0&&x&&x(ee,I)},[re,u,t,l,a,h,b,x,M,k]),xe=U.useCallback(function(H){H.preventDefault(),H.persist(),ze(H),j.current=[],wb(H)&&Promise.resolve(r(H)).then(function(I){Gx(H)&&!L||he(I,H)}),re({type:"reset"})},[r,he,L]),ke=U.useCallback(function(){if(pe.current){re({type:"openDialog"}),V();var H={multiple:u,types:PX(t)};window.showOpenFilePicker(H).then(function(I){return r(I)}).then(function(I){he(I,null),re({type:"closeDialog"})}).catch(function(I){IX(I)?(N(I),re({type:"closeDialog"})):NX(I)&&(pe.current=!1,X.current&&(X.current.value=null,X.current.click()))});return}X.current&&(re({type:"openDialog"}),V(),X.current.value=null,X.current.click())},[re,V,N,E,he,t,u]),Ge=U.useCallback(function(H){!z.current||!z.current.isEqualNode(H.target)||(H.key===" "||H.key==="Enter"||H.keyCode===32||H.keyCode===13)&&(H.preventDefault(),ke())},[z,ke]),ct=U.useCallback(function(){re({type:"focus"})},[]),_t=U.useCallback(function(){re({type:"blur"})},[]),St=U.useCallback(function(){D||(DX()?setTimeout(ke,0):ke())},[D,ke]),mt=function(I){return i?null:I},Ce=function(I){return P?null:mt(I)},Pe=function(I){return F?null:mt(I)},ze=function(I){L&&I.stopPropagation()},Xe=U.useMemo(function(){return function(){var H=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},I=H.refKey,ee=I===void 0?"ref":I,ue=H.role,De=H.onKeyDown,_e=H.onFocus,nt=H.onBlur,Ye=H.onClick,dt=H.onDragEnter,Ct=H.onDragOver,$e=H.onDragLeave,Ke=H.onDrop,ht=Wx(H,zX);return Ni(Ni(KM({onKeyDown:Ce(Ml(De,Ge)),onFocus:Ce(Ml(_e,ct)),onBlur:Ce(Ml(nt,_t)),onClick:mt(Ml(Ye,St)),onDragEnter:Pe(Ml(dt,be)),onDragOver:Pe(Ml(Ct,Fe)),onDragLeave:Pe(Ml($e,rt)),onDrop:Pe(Ml(Ke,xe)),role:typeof ue=="string"&&ue!==""?ue:"button"},ee,z),!i&&!P?{tabIndex:0}:{}),ht)}},[z,Ge,ct,_t,St,be,Fe,rt,xe,P,F,i]),Y=U.useCallback(function(H){H.stopPropagation()},[]),bt=U.useMemo(function(){return function(){var H=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},I=H.refKey,ee=I===void 0?"ref":I,ue=H.onChange,De=H.onClick,_e=Wx(H,BX),nt=KM({accept:t,multiple:u,type:"file",style:{display:"none"},onChange:mt(Ml(ue,xe)),onClick:mt(Ml(De,Y)),tabIndex:-1},ee,X);return Ni(Ni({},nt),_e)}},[X,t,u,xe,i]),st=ne.length,Et=st>0&&AX({files:ne,accept:t,minSize:l,maxSize:a,multiple:u,maxFiles:h}),Te=st>0&&!Et;return Ni(Ni({},oe),{},{isDragAccept:Et,isDragReject:Te,isFocused:q&&!i,getRootProps:Xe,getInputProps:bt,rootRef:z,inputRef:X,open:mt(ke)})}function jX(n,e){switch(e.type){case"focus":return Ni(Ni({},n),{},{isFocused:!0});case"blur":return Ni(Ni({},n),{},{isFocused:!1});case"openDialog":return Ni(Ni({},QM),{},{isFileDialogActive:!0});case"closeDialog":return Ni(Ni({},n),{},{isFileDialogActive:!1});case"setDraggedFiles":var t=e.isDragActive,i=e.draggedFiles;return Ni(Ni({},n),{},{draggedFiles:i,isDragActive:t});case"setFiles":return Ni(Ni({},n),{},{acceptedFiles:e.acceptedFiles,fileRejections:e.fileRejections});case"reset":return Ni({},QM);default:return n}}function NR(){}function qX(n){let e;const t=new Set,i=(p,g)=>{const y=typeof p=="function"?p(e):p;if(y!==e){const b=e;e=g?y:Object.assign({},e,y),t.forEach(x=>x(e,b))}},r=()=>e,a=(p,g=r,y=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let b=g(e);function x(){const M=g(e);if(!y(b,M)){const A=b;p(b=M,A)}}return t.add(x),()=>t.delete(x)},h={setState:i,getState:r,subscribe:(p,g,y)=>g||y?a(p,g,y):(t.add(p),()=>t.delete(p)),destroy:()=>t.clear()};return e=n(i,r,h),h}const YX=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),LR=YX?U.useEffect:U.useLayoutEffect;function ZX(n){const e=typeof n=="function"?qX(n):n,t=(i=e.getState,r=Object.is)=>{const[,a]=U.useReducer(w=>w+1,0),l=e.getState(),u=U.useRef(l),h=U.useRef(i),p=U.useRef(r),g=U.useRef(!1),y=U.useRef();y.current===void 0&&(y.current=i(l));let b,x=!1;(u.current!==l||h.current!==i||p.current!==r||g.current)&&(b=i(l),x=!r(y.current,b)),LR(()=>{x&&(y.current=b),u.current=l,h.current=i,p.current=r,g.current=!1});const M=U.useRef(l);LR(()=>{const w=()=>{try{const R=e.getState(),D=h.current(R);p.current(y.current,D)||(u.current=R,y.current=D,a())}catch{g.current=!0,a()}},E=e.subscribe(w);return e.getState()!==M.current&&w(),E},[]);const A=x?b:y.current;return U.useDebugValue(A),A};return Object.assign(t,e),t[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const i=[t,e];return{next(){const r=i.length<=0;return{value:i.shift(),done:r}}}},t}const KX=n=>(e,t,i)=>{const r=i.subscribe;return i.subscribe=(l,u,h)=>{let p=l;if(u){const g=h?.equalityFn||Object.is;let y=l(i.getState());p=b=>{const x=l(b);if(!g(y,x)){const M=y;u(y=x,M)}},h?.fireImmediately&&u(y,y)}return r(p)},n(e,t,i)};var W1,UR;function QX(){return UR||(UR=1,W1=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}),W1}var $1,zR;function hI(){if(zR)return $1;zR=1;var n=QX();function e(t){return n(t)===!0&&Object.prototype.toString.call(t)==="[object Object]"}return $1=function(i){var r,a;return!(e(i)===!1||(r=i.constructor,typeof r!="function")||(a=r.prototype,e(a)===!1)||a.hasOwnProperty("isPrototypeOf")===!1)},$1}var X1,BR;function ST(){if(BR)return X1;BR=1;var n=hI();return X1=function(t){return n(t)||typeof t=="function"||Array.isArray(t)},X1}var j1,FR;function JX(){return FR||(FR=1,j1=function(e,t,i){for(var r in e)if(t.call(i,e[r],r,e)===!1)break}),j1}var q1,kR;function ej(){if(kR)return q1;kR=1;var n=ST(),e=JX();function t(l,u){for(var h=arguments.length,p=0;++p"u")throw new TypeError("expected first argument to be an object.");if(typeof e>"u"||typeof Symbol>"u"||typeof Object.getOwnPropertySymbols!="function")return n;for(var t=Object.prototype.propertyIsEnumerable,i=Object(n),r=arguments.length,a=0;++a"u")throw new TypeError("Cannot convert undefined or null to object");a(u)||(u={});for(var h=1;h","(":")","[":"]","{":"}"}:u.brackets&&(p=u.brackets);var g=[],y=[],b=[""],x=u.sep,M=r.length,A=-1,w;function E(){if(p&&y.length)return p[y[y.length-1]]}for(;++An.filter(Boolean).join(".");function dj(n){const e=n.split(".");return[e.pop(),e.join(".")||void 0]}function hj(n,e){return Object.entries(iW(n,e)).reduce((t,[,{value:i,disabled:r,key:a}])=>(t[a]=r?void 0:i,t),{})}function pj(n,e){const t=U.useRef();return b0(n,t.current)||(t.current=n),t.current}function pI(n,e){var t;return U.useMemo(n,(t=pj(e))!==null&&t!==void 0?t:[])}function mj(n){const e=U.useRef(null),t=U.useRef(null),i=U.useRef(!0);return U.useLayoutEffect(()=>{n||(e.current.style.height="0px",e.current.style.overflow="hidden")},[]),U.useEffect(()=>{if(i.current){i.current=!1;return}let r;const a=e.current,l=()=>{n&&(a.style.removeProperty("height"),a.style.removeProperty("overflow"),t.current.scrollIntoView({behavior:"smooth",block:"nearest"}))};a.addEventListener("transitionend",l,{once:!0});const{height:u}=t.current.getBoundingClientRect();return a.style.height=u+"px",n||(a.style.overflow="hidden",r=window.setTimeout(()=>a.style.height="0px",50)),()=>{a.removeEventListener("transitionend",l),clearTimeout(r)}},[n]),{wrapperRef:e,contentRef:t}}const gj=n=>{const[e,t]=U.useState(n.getVisiblePaths());return U.useEffect(()=>{t(n.getVisiblePaths());const i=n.useStore.subscribe(n.getVisiblePaths,t,{equalityFn:P_});return()=>i()},[n]),e};function vj(n,e,t){return n.useStore(r=>{const a=Vt(Vt({},t),r.data);return hj(a,e)},P_)}function mI(n=3){const e=U.useRef(null),t=U.useRef(null),[i,r]=U.useState(!1),a=U.useCallback(()=>r(!0),[]),l=U.useCallback(()=>r(!1),[]);return U.useLayoutEffect(()=>{if(i){const{bottom:u,top:h,left:p}=e.current.getBoundingClientRect(),{height:g}=t.current.getBoundingClientRect(),y=u+g>window.innerHeight-40?"up":"down";t.current.style.position="fixed",t.current.style.zIndex="10000",t.current.style.left=p+"px",y==="down"?t.current.style.top=u+n+"px":t.current.style.bottom=window.innerHeight-h+n+"px"}},[n,i]),{popinRef:e,wrapperRef:t,shown:i,show:a,hide:l}}F$([k$]);const yj={rgb:"toRgb",hsl:"toHsl",hsv:"toHsv",hex:"toHex"};oa.extend({color:()=>n=>Ds(n).isValid()});const bj=n=>oa().color().test(n);function gI(n,{format:e,hasAlpha:t,isString:i}){const r=yj[e]+(i&&e!=="hex"?"String":""),a=n[r]();return typeof a=="object"&&!t?rW(a,["a"]):a}const vI=(n,e)=>{const t=Ds(n);if(!t.isValid())throw Error("Invalid color");return gI(t,e)},xj=(n,e)=>gI(Ds(n),Vt(Vt({},e),{},{isString:!0,format:"hex"})),_j=({value:n})=>{const e=B$(n),t=e==="name"?"hex":e,i=typeof n=="object"?"a"in n:e==="hex"&&n.length===8||/^(rgba)|(hsla)|(hsva)/.test(n),r={format:t,hasAlpha:i,isString:typeof n=="string"};return{value:vI(n,r),settings:r}};var Sj=Object.freeze({__proto__:null,schema:bj,sanitize:vI,format:xj,normalize:_j});const Mj=$t("div",{position:"relative",boxSizing:"border-box",borderRadius:"$sm",overflow:"hidden",cursor:"pointer",height:"$rowHeight",width:"$rowHeight",backgroundColor:"#fff",backgroundImage:`url('data:image/svg+xml;charset=utf-8,')`,$inputStyle:"",$hover:"",zIndex:1,variants:{active:{true:{$inputStyle:"$accent1"}}},"&::before":{content:'""',position:"absolute",top:0,bottom:0,right:0,left:0,backgroundColor:"currentColor",zIndex:1}}),Ej=$t("div",{position:"relative",display:"grid",gridTemplateColumns:"$sizes$rowHeight auto",columnGap:"$colGap",alignItems:"center"}),Tj=$t("div",{width:"$colorPickerWidth",height:"$colorPickerHeight",".react-colorful":{width:"100%",height:"100%",boxShadow:"$level2",cursor:"crosshair"},".react-colorful__saturation":{borderRadius:"$sm $sm 0 0"},".react-colorful__alpha, .react-colorful__hue":{height:10},".react-colorful__last-control":{borderRadius:"0 0 $sm $sm"},".react-colorful__pointer":{height:12,width:12}});function ZR(n,e){return e!=="rgb"?Ds(n).toRgb():n}function wj({value:n,displayValue:e,settings:t,onUpdate:i}){const{emitOnEditStart:r,emitOnEditEnd:a}=fs(),{format:l,hasAlpha:u}=t,{popinRef:h,wrapperRef:p,shown:g,show:y,hide:b}=mI(),x=U.useRef(0),[M,A]=U.useState(()=>ZR(n,l)),w=u?j$:Y$,E=()=>{A(ZR(n,l)),y(),r()},R=()=>{b(),a(),window.clearTimeout(x.current)},D=()=>{x.current=window.setTimeout(R,500)};return U.useEffect(()=>()=>window.clearTimeout(x.current),[]),se.createElement(se.Fragment,null,se.createElement(Mj,{ref:h,active:g,onClick:()=>E(),style:{color:e}}),g&&se.createElement(pT,null,se.createElement(FP,{onPointerUp:R}),se.createElement(Tj,{ref:p,onMouseEnter:()=>window.clearTimeout(x.current),onMouseLeave:P=>P.buttons===0&&D()},se.createElement(w,{color:M,onChange:i}))))}function Aj(){const{value:n,displayValue:e,label:t,onChange:i,onUpdate:r,settings:a}=fs();return se.createElement(ro,{input:!0},se.createElement(ko,null,t),se.createElement(Ej,null,se.createElement(wj,{value:n,displayValue:e,onChange:i,onUpdate:r,settings:a}),se.createElement(hT,{value:e,onChange:i,onUpdate:r})))}var Cj=Vt({component:Aj},Sj);function Rj(){const{label:n,displayValue:e,onUpdate:t,settings:i}=fs();return se.createElement(ro,{input:!0},se.createElement(ko,null,n),se.createElement(gT,{value:e,settings:i,onUpdate:t}))}var Dj=Vt({component:Rj},jP(["x","y","z"]));const Oj=$t("div",{$flexCenter:"",position:"relative",backgroundColor:"$elevation3",borderRadius:"$sm",cursor:"pointer",height:"$rowHeight",width:"$rowHeight",touchAction:"none",$draggable:"",$hover:"","&:active":{cursor:"none"},"&::after":{content:'""',backgroundColor:"$accent2",height:4,width:4,borderRadius:2}}),Pj=$t("div",{$flexCenter:"",width:"$joystickWidth",height:"$joystickHeight",borderRadius:"$sm",boxShadow:"$level2",position:"fixed",zIndex:1e4,overflow:"hidden",$draggable:"",transform:"translate(-50%, -50%)",variants:{isOutOfBounds:{true:{backgroundColor:"$elevation1"},false:{backgroundColor:"$elevation3"}}},"> div":{position:"absolute",$flexCenter:"",borderStyle:"solid",borderWidth:1,borderColor:"$highlight1",backgroundColor:"$elevation3",width:"80%",height:"80%","&::after,&::before":{content:'""',position:"absolute",zindex:10,backgroundColor:"$highlight1"},"&::before":{width:"100%",height:1},"&::after":{height:"100%",width:1}},"> span":{position:"relative",zindex:100,width:10,height:10,backgroundColor:"$accent2",borderRadius:"50%"}});function Ij({value:n,settings:e,onUpdate:t}){const i=U.useRef(),r=U.useRef(0),a=U.useRef(0),l=U.useRef(1),[u,h]=U.useState(!1),[p,g]=U.useState(!1),[y,b]=HP(),x=U.useRef(null),M=U.useRef(null);U.useLayoutEffect(()=>{if(u){const{top:Q,left:J,width:oe,height:re}=x.current.getBoundingClientRect();M.current.style.left=J+oe/2+"px",M.current.style.top=Q+re/2+"px"}},[u]);const{keys:[A,w],joystick:E}=e,R=E==="invertY"?1:-1,{[A]:{step:D},[w]:{step:P}}=e,F=Cc("sizes","joystickWidth"),L=Cc("sizes","joystickHeight"),k=parseFloat(F)*.8/2,V=parseFloat(L)*.8/2,N=U.useCallback(()=>{i.current||(g(!0),r.current&&b({x:r.current*k}),a.current&&b({y:a.current*-V}),i.current=window.setInterval(()=>{t(Q=>{const J=D*r.current*l.current,oe=R*P*a.current*l.current;return Array.isArray(Q)?{[A]:Q[0]+J,[w]:Q[1]+oe}:{[A]:Q[A]+J,[w]:Q[w]+oe}})},16))},[k,V,t,b,D,P,A,w,R]),z=U.useCallback(()=>{window.clearTimeout(i.current),i.current=void 0,g(!1)},[]);U.useEffect(()=>{function Q(J){l.current=TP(J)}return window.addEventListener("keydown",Q),window.addEventListener("keyup",Q),()=>{window.clearTimeout(i.current),window.removeEventListener("keydown",Q),window.removeEventListener("keyup",Q)}},[]);const X=H0(({first:Q,active:J,delta:[oe,re],movement:[q,Z]})=>{Q&&h(!0);const ne=qu(q,-k,k),pe=qu(Z,-V,V);r.current=Math.abs(q)>Math.abs(ne)?Math.sign(q-ne):0,a.current=Math.abs(Z)>Math.abs(pe)?Math.sign(pe-Z):0;let Ee=n[A],j=n[w];J?(r.current||(Ee+=oe*D*l.current,b({x:ne})),a.current||(j-=R*re*P*l.current,b({y:pe})),r.current||a.current?N():z(),t({[A]:Ee,[w]:j})):(h(!1),r.current=0,a.current=0,b({x:0,y:0}),z())});return se.createElement(Oj,ji({ref:x},X()),u&&se.createElement(pT,null,se.createElement(Pj,{ref:M,isOutOfBounds:p},se.createElement("div",null),se.createElement("span",{ref:y}))))}const Nj=$t("div",{display:"grid",columnGap:"$colGap",variants:{withJoystick:{true:{gridTemplateColumns:"$sizes$rowHeight auto"},false:{gridTemplateColumns:"auto"}}}});function Lj(){const{label:n,displayValue:e,onUpdate:t,settings:i}=fs();return se.createElement(ro,{input:!0},se.createElement(ko,null,n),se.createElement(Nj,{withJoystick:!!i.joystick},i.joystick&&se.createElement(Ij,{value:e,settings:i,onUpdate:t}),se.createElement(gT,{value:e,settings:i,onUpdate:t})))}const Uj=["joystick"],yI=jP(["x","y"]),zj=n=>{let{joystick:e=!0}=n,t=si(n,Uj);const{value:i,settings:r}=yI.normalize(t);return{value:i,settings:Vt(Vt({},r),{},{joystick:e})}};var Bj=Vt(Vt({component:Lj},yI),{},{normalize:zj});const Fj=n=>{if(n!==void 0){if(n instanceof File)try{return URL.createObjectURL(n)}catch{return}if(typeof n=="string"&&n.indexOf("blob:")===0)return n;throw Error("Invalid image format [undefined | blob | File].")}},kj=(n,e)=>typeof e=="object"&&"image"in e,Hj=({image:n})=>({value:n});var Vj=Object.freeze({__proto__:null,sanitize:Fj,schema:kj,normalize:Hj});const Gj=$t("div",{position:"relative",display:"grid",gridTemplateColumns:"$sizes$rowHeight auto 20px",columnGap:"$colGap",alignItems:"center"}),Wj=$t("div",{$flexCenter:"",overflow:"hidden",height:"$rowHeight",background:"$elevation3",textAlign:"center",color:"inherit",borderRadius:"$sm",outline:"none",userSelect:"none",cursor:"pointer",$inputStyle:"",$hover:"",$focusWithin:"",$active:"$accent1 $elevation1",variants:{isDragAccept:{true:{$inputStyle:"$accent1",backgroundColor:"$elevation1"}}}}),$j=$t("div",{boxSizing:"border-box",borderRadius:"$sm",height:"$rowHeight",width:"$rowHeight",$inputStyle:"",backgroundSize:"cover",backgroundPosition:"center",variants:{hasImage:{true:{cursor:"pointer",$hover:"",$active:""}}}}),Xj=$t("div",{$flexCenter:"",width:"$imagePreviewWidth",height:"$imagePreviewHeight",borderRadius:"$sm",boxShadow:"$level2",pointerEvents:"none",$inputStyle:"",backgroundSize:"cover",backgroundPosition:"center"}),jj=$t("div",{fontSize:"0.8em",height:"100%",padding:"$rowGap $md"}),qj=$t("div",{$flexCenter:"",top:"0",right:"0",marginRight:"$sm",height:"100%",cursor:"pointer",variants:{disabled:{true:{color:"$elevation3",cursor:"default"}}},"&::after,&::before":{content:'""',position:"absolute",height:2,width:10,borderRadius:1,backgroundColor:"currentColor"},"&::after":{transform:"rotate(45deg)"},"&::before":{transform:"rotate(-45deg)"}});function Yj(){const{label:n,value:e,onUpdate:t,disabled:i}=fs(),{popinRef:r,wrapperRef:a,shown:l,show:u,hide:h}=mI(),p=U.useCallback(M=>{M.length&&t(M[0])},[t]),g=U.useCallback(M=>{M.stopPropagation(),t(void 0)},[t]),{getRootProps:y,getInputProps:b,isDragAccept:x}=dI({maxFiles:1,accept:"image/*",onDrop:p,disabled:i});return se.createElement(ro,{input:!0},se.createElement(ko,null,n),se.createElement(Gj,null,se.createElement($j,{ref:r,hasImage:!!e,onPointerDown:()=>!!e&&u(),onPointerUp:h,style:{backgroundImage:e?`url(${e})`:"none"}}),l&&!!e&&se.createElement(pT,null,se.createElement(FP,{onPointerUp:h,style:{cursor:"pointer"}}),se.createElement(Xj,{ref:a,style:{backgroundImage:`url(${e})`}})),se.createElement(Wj,y({isDragAccept:x}),se.createElement("input",b()),se.createElement(jj,null,x?"drop image":"click or drop")),se.createElement(qj,{onClick:g,disabled:!e})))}var Zj=Vt({component:Yj},Vj);const KR=oa().number(),Kj=(n,e)=>oa().array().length(2).every.number().test(n)&&oa().schema({min:KR,max:KR}).test(e),$x=n=>({min:n[0],max:n[1]}),bI=(n,{bounds:[e,t]},i)=>{const r=Array.isArray(n)?$x(n):n,a={min:i[0],max:i[1]},{min:l,max:u}=Vt(Vt({},a),r);return[qu(Number(l),e,Math.max(e,u)),qu(Number(u),Math.min(t,l),t)]},Qj=({value:n,min:e,max:t})=>{const i={min:e,max:t},r=XP($x(n),{min:i,max:i}),a=[e,t],l=Vt(Vt({},r),{},{bounds:a});return{value:bI($x(n),l,n),settings:l}};var Jj=Object.freeze({__proto__:null,schema:Kj,format:$x,sanitize:bI,normalize:Qj});const eq=["value","bounds","onDrag"],tq=["bounds"],nq=$t("div",{display:"grid",columnGap:"$colGap",gridTemplateColumns:"auto calc($sizes$numberInputMinWidth * 2 + $space$rowGap)"});function iq(n){let{value:e,bounds:[t,i],onDrag:r}=n,a=si(n,eq);const l=U.useRef(null),u=U.useRef(null),h=U.useRef(null),p=U.useRef(0),g=Cc("sizes","scrubberWidth"),y=H0(({event:M,first:A,xy:[w],movement:[E],memo:R={}})=>{if(A){const{width:P,left:F}=l.current.getBoundingClientRect();p.current=P-parseFloat(g);const L=M?.target===u.current||M?.target===h.current;R.pos=kx((w-F)/P,t,i);const k=Math.abs(R.pos-e.min)-Math.abs(R.pos-e.max);R.key=k<0||k===0&&R.pos<=e.min?"min":"max",L&&(R.pos=e[R.key])}const D=R.pos+kx(E/p.current,0,i-t);return r({[R.key]:$W(D,a[R.key])}),R}),b=`calc(${Fx(e.min,t,i)} * (100% - ${g} - 8px) + 4px)`,x=`calc(${1-Fx(e.max,t,i)} * (100% - ${g} - 8px) + 4px)`;return se.createElement(GP,ji({ref:l},y()),se.createElement(VP,null,se.createElement(WP,{style:{left:b,right:x}})),se.createElement(VM,{position:"left",ref:u,style:{left:b}}),se.createElement(VM,{position:"right",ref:h,style:{right:x}}))}function rq(){const{label:n,displayValue:e,onUpdate:t,settings:i}=fs(),r=si(i,tq);return se.createElement(se.Fragment,null,se.createElement(ro,{input:!0},se.createElement(ko,null,n),se.createElement(nq,null,se.createElement(iq,ji({value:e},i,{onDrag:t})),se.createElement(gT,{value:e,settings:r,onUpdate:t,innerLabelTrim:0}))))}var sq=Vt({component:rq},Jj);const aq=()=>{const n=new Map;return{on:(e,t)=>{let i=n.get(e);i===void 0&&(i=new Set,n.set(e,i)),i.add(t)},off:(e,t)=>{const i=n.get(e);i!==void 0&&(i.delete(t),i.size===0&&n.delete(e))},emit:(e,...t)=>{const i=n.get(e);if(i!==void 0)for(const r of i)r(...t)}}},oq=["type","value"],lq=["onChange","transient","onEditStart","onEditEnd"],cq=function(){const e=ZX(KX(()=>({data:{}}))),t=aq();this.storeId=nW(),this.useStore=e;const i={},r=new Set;this.getVisiblePaths=()=>{const l=this.getData(),u=Object.keys(l),h=[];Object.entries(i).forEach(([g,y])=>{y.render&&u.some(b=>b.indexOf(g)===0)&&!y.render(this.get)&&h.push(g+".")});const p=[];return r.forEach(g=>{g in l&&l[g].__refCount>0&&h.every(y=>g.indexOf(y)===-1)&&(!l[g].render||l[g].render(this.get))&&p.push(g)}),p},this.setOrderedPaths=l=>{l.forEach(u=>r.add(u))},this.orderPaths=l=>(this.setOrderedPaths(l),l),this.disposePaths=l=>{e.setState(u=>{const h=u.data;return l.forEach(p=>{if(p in h){const g=h[p];g.__refCount--,g.__refCount===0&&g.type in Uo&&delete h[p]}}),{data:h}})},this.dispose=()=>{e.setState(()=>({data:{}}))},this.getFolderSettings=l=>i[l]||{},this.getData=()=>e.getState().data,this.addData=(l,u)=>{e.setState(h=>{const p=h.data;return Object.entries(l).forEach(([g,y])=>{let b=p[g];if(b){const{type:x,value:M}=y,A=si(y,oq);x!==b.type?Tc(hr.INPUT_TYPE_OVERRIDE,g,b.type,x):((b.__refCount===0||u)&&Object.assign(b,A),b.__refCount++)}else p[g]=Vt(Vt({},y),{},{__refCount:1})}),{data:p}})},this.setValueAtPath=(l,u,h)=>{e.setState(p=>{const g=p.data;return cR(g[l],u,l,this,h),{data:g}})},this.setSettingsAtPath=(l,u)=>{e.setState(h=>{const p=h.data;return p[l].settings=Vt(Vt({},p[l].settings),u),{data:p}})},this.disableInputAtPath=(l,u)=>{e.setState(h=>{const p=h.data;return p[l].disabled=u,{data:p}})},this.set=(l,u)=>{e.setState(h=>{const p=h.data;return Object.entries(l).forEach(([g,y])=>{try{cR(p[g],y,void 0,void 0,u)}catch{}}),{data:p}})},this.getInput=l=>{try{return this.getData()[l]}catch{Tc(hr.PATH_DOESNT_EXIST,l)}},this.get=l=>{var u;return(u=this.getInput(l))===null||u===void 0?void 0:u.value},this.emitOnEditStart=l=>{t.emit(`onEditStart:${l}`,this.get(l),l,Vt(Vt({},this.getInput(l)),{},{get:this.get}))},this.emitOnEditEnd=l=>{t.emit(`onEditEnd:${l}`,this.get(l),l,Vt(Vt({},this.getInput(l)),{},{get:this.get}))},this.subscribeToEditStart=(l,u)=>{const h=`onEditStart:${l}`;return t.on(h,u),()=>t.off(h,u)},this.subscribeToEditEnd=(l,u)=>{const h=`onEditEnd:${l}`;return t.on(h,u),()=>t.off(h,u)};const a=(l,u,h)=>{const p={};return Object.entries(l).forEach(([g,y])=>{if(g==="")return Tc(hr.EMPTY_KEY);let b=MT(u,g);if(y.type===Uo.FOLDER){const x=a(y.schema,b,h);Object.assign(p,x),b in i||(i[b]=y.settings)}else if(g in h)Tc(hr.DUPLICATE_KEYS,g,b,h[g].path);else{const x=uW(y,g,b,p);if(x){const{type:M,options:A,input:w}=x,{onChange:E,transient:R,onEditStart:D,onEditEnd:P}=A,F=si(A,lq);p[b]=Vt(Vt(Vt({type:M},F),w),{},{fromPanel:!0}),h[g]={path:b,onChange:E,transient:R,onEditStart:D,onEditEnd:P}}else Tc(hr.UNKNOWN_INPUT,b,y)}}),p};this.getDataFromSchema=l=>{const u={};return[a(l,"",u),u]}},ET=new cq,uq={collapsed:!1};function ir(n,e){return{type:Uo.FOLDER,schema:n,settings:Vt(Vt({},uq),e)}}const fq={disabled:!1};function td(n,e){return{type:Uo.BUTTON,onClick:n,settings:Vt(Vt({},fq),e)}}const dq={graph:!1,interval:100};function hq(n,e){return{type:Uo.MONITOR,objectOrFn:n,settings:Vt(Vt({},dq),e)}}const QR=n=>"__levaInput"in n,pq=(n,e)=>{const t={},i=e?e.toLowerCase():null;return n.forEach(r=>{const[a,l]=dj(r);(!i||a.toLowerCase().indexOf(i)>-1)&&fj(t,l,{[a]:{__levaInput:!0,path:r}})}),t},mq=["type","label","path","valueKey","value","settings","setValue","disabled"];function gq(n){let{type:e,label:t,path:i,valueKey:r,value:a,settings:l,setValue:u,disabled:h}=n,p=si(n,mq);const{displayValue:g,onChange:y,onUpdate:b}=kP({type:e,value:a,settings:l,setValue:u}),x=Ed[e].component;return x?se.createElement(DP.Provider,{value:Vt({key:r,path:i,id:""+i,label:t,displayValue:g,value:a,onChange:y,onUpdate:b,settings:l,setValue:u,disabled:h},p)},se.createElement(RW,{disabled:h},se.createElement(x,null))):(Tc(hr.NO_COMPONENT_FOR_TYPE,e,i),null)}const vq=$t("button",{display:"block",$reset:"",fontWeight:"$button",height:"$rowHeight",borderStyle:"none",borderRadius:"$sm",backgroundColor:"$elevation1",color:"$highlight1","&:not(:disabled)":{color:"$highlight3",backgroundColor:"$accent2",cursor:"pointer",$hover:"$accent3",$active:"$accent3 $accent1",$focus:""}});function yq({onClick:n,settings:e,label:t}){const i=F0();return se.createElement(ro,null,se.createElement(vq,{disabled:e.disabled,onClick:()=>n(i.get)},t))}const bq=$t("div",{$flex:"",justifyContent:"flex-end",gap:"$colGap"}),xq=$t("button",{$reset:"",cursor:"pointer",borderRadius:"$xs","&:hover":{backgroundColor:"$elevation3"}}),_q=({label:n,opts:e})=>{let t=typeof n=="string"&&n.trim()===""?null:n,i=e;return typeof e.opts=="object"&&(i.label!==void 0&&(t=e.label),i=e.opts),{label:t,opts:i}};function Sq(n){const{label:e,opts:t}=_q(n),i=F0();return se.createElement(ro,{input:!!e},e&&se.createElement(ko,null,e),se.createElement(bq,null,Object.entries(t).map(([r,a])=>se.createElement(xq,{key:r,onClick:()=>a(i.get)},r))))}const Mq=$t("canvas",{height:"$monitorHeight",width:"100%",display:"block",borderRadius:"$sm"}),xI=100;function Eq(n,e){n.push(e),n.length>xI&&n.shift()}const Tq=U.forwardRef(function({initialValue:n},e){const t=Cc("colors","highlight3"),i=Cc("colors","elevation2"),r=Cc("colors","highlight1"),[a,l]=U.useMemo(()=>[Ds(r).alpha(.4).toRgbString(),Ds(r).alpha(.1).toRgbString()],[r]),u=U.useRef([n]),h=U.useRef(n),p=U.useRef(n),g=U.useRef(),y=U.useCallback((M,A)=>{if(!M)return;const{width:w,height:E}=M,R=new Path2D,D=w/xI,P=E*.05;for(let k=0;k({frame:M=>{(h.current===void 0||Mp.current)&&(p.current=M),Eq(u.current,M),g.current=requestAnimationFrame(()=>y(b.current,x.current))}}),[b,x,y]),U.useEffect(()=>()=>cancelAnimationFrame(g.current),[]),se.createElement(Mq,{ref:b})}),JR=n=>Number.isFinite(n)?n.toPrecision(2):n.toString(),wq=U.forwardRef(function({initialValue:n},e){const[t,i]=U.useState(JR(n));return U.useImperativeHandle(e,()=>({frame:r=>i(JR(r))}),[]),se.createElement("div",null,t)});function e3(n){return typeof n=="function"?n():n.current}function Aq({label:n,objectOrFn:e,settings:t}){const i=U.useRef(),r=U.useRef(e3(e));return U.useEffect(()=>{const a=window.setInterval(()=>{var l;document.hidden||(l=i.current)===null||l===void 0||l.frame(e3(e))},t.interval);return()=>window.clearInterval(a)},[e,t.interval]),se.createElement(ro,{input:!0},se.createElement(ko,{align:"top"},n),t.graph?se.createElement(Tq,{ref:i,initialValue:r.current}):se.createElement(wq,{ref:i,initialValue:r.current}))}const Cq=["type","label","key"],Rq={[Uo.BUTTON]:yq,[Uo.BUTTON_GROUP]:Sq,[Uo.MONITOR]:Aq},Dq=se.memo(({path:n})=>{const[e,{set:t,setSettings:i,disable:r,storeId:a,emitOnEditStart:l,emitOnEditEnd:u}]=kW(n);if(!e)return null;const{type:h,label:p,key:g}=e,y=si(e,Cq);if(h in Uo){const b=Rq[h];return se.createElement(b,ji({label:p,path:n},y))}return h in Ed?se.createElement(gq,ji({key:a+n,type:h,label:p,storeId:a,path:n,valueKey:g,setValue:t,setSettings:i,disable:r,emitOnEditStart:l,emitOnEditEnd:u},y)):(X7(hr.UNSUPPORTED_INPUT,h,n),null)});function Oq({toggle:n,toggled:e,name:t}){return se.createElement(wW,{onClick:()=>n()},se.createElement(mT,{toggled:e}),se.createElement("div",null,t))}const Pq=({name:n,path:e,tree:t})=>{const i=F0(),r=MT(e,n),{collapsed:a,color:l}=i.getFolderSettings(r),[u,h]=U.useState(!a),p=U.useRef(null),g=Cc("colors","folderWidgetColor"),y=Cc("colors","folderTextColor");return U.useLayoutEffect(()=>{p.current.style.setProperty("--leva-colors-folderWidgetColor",l||g),p.current.style.setProperty("--leva-colors-folderTextColor",l||y)},[l,g,y]),se.createElement(Hx,{ref:p},se.createElement(Oq,{name:n,toggled:u,toggle:()=>h(b=>!b)}),se.createElement(_I,{parent:r,tree:t,toggled:u}))},_I=se.memo(({isRoot:n=!1,fill:e=!1,flat:t=!1,parent:i,tree:r,toggled:a})=>{const{wrapperRef:l,contentRef:u}=mj(a),h=F0(),p=([y,b])=>{var x;return(QR(b)?(x=h.getInput(b.path))===null||x===void 0?void 0:x.order:h.getFolderSettings(MT(i,y)).order)||0},g=Object.entries(r).sort((y,b)=>p(y)-p(b));return se.createElement(kM,{ref:l,isRoot:n,fill:e,flat:t},se.createElement(UP,{ref:u,isRoot:n,toggled:a},g.map(([y,b])=>QR(b)?se.createElement(Dq,{key:b.path,valueKey:b.valueKey,path:b.path}):se.createElement(Pq,{key:y,name:y,path:i,tree:b}))))}),Iq=$t("div",{position:"relative",fontFamily:"$mono",fontSize:"$root",color:"$rootText",backgroundColor:"$elevation1",variants:{fill:{false:{position:"fixed",top:"10px",right:"10px",zIndex:1e3,width:"$rootWidth"},true:{position:"relative",width:"100%"}},flat:{false:{borderRadius:"$lg",boxShadow:"$level1"}},oneLineLabels:{true:{[`${BP}`]:{gridTemplateColumns:"auto",gridAutoColumns:"minmax(max-content, 1fr)",gridAutoRows:"minmax($sizes$rowHeight), auto)",rowGap:0,columnGap:0,marginTop:"$rowGap"}}},hideTitleBar:{true:{$$titleBarHeight:"0px"},false:{$$titleBarHeight:"$sizes$titleBarHeight"}}},"&,*,*:after,*:before":{boxSizing:"border-box"},"*::selection":{backgroundColor:"$accent2"}}),SI=40,Xx=$t("i",{$flexCenter:"",width:SI,userSelect:"none",cursor:"pointer","> svg":{fill:"$highlight1",transition:"transform 350ms ease, fill 250ms ease"},"&:hover > svg":{fill:"$highlight3"},variants:{active:{true:{"> svg":{fill:"$highlight2"}}}}}),Nq=$t("div",{display:"flex",alignItems:"stretch",justifyContent:"space-between",height:"$titleBarHeight",variants:{mode:{drag:{cursor:"grab"}}}}),Lq=$t("div",{$flex:"",position:"relative",width:"100%",overflow:"hidden",transition:"height 250ms ease",color:"$highlight3",paddingLeft:"$md",[`> ${Xx}`]:{height:30},variants:{toggled:{true:{height:30},false:{height:0}}}}),Uq=$t("input",{$reset:"",flex:1,position:"relative",height:30,width:"100%",backgroundColor:"transparent",fontSize:"10px",borderRadius:"$root","&:focus":{},"&::placeholder":{color:"$highlight2"}}),zq=$t("div",{touchAction:"none",$flexCenter:"",flex:1,"> svg":{fill:"$highlight1"},color:"$highlight1",variants:{drag:{true:{$draggable:"","> svg":{transition:"fill 250ms ease"},"&:hover":{color:"$highlight3"},"&:hover > svg":{fill:"$highlight3"}}},filterEnabled:{false:{paddingRight:SI}}}}),Bq=se.forwardRef(({setFilter:n,toggle:e},t)=>{const[i,r]=U.useState(""),a=U.useMemo(()=>EP(n,250),[n]),l=()=>{n(""),r("")},u=h=>{const p=h.currentTarget.value;e(!0),r(p)};return U.useEffect(()=>{a(i)},[i,a]),se.createElement(se.Fragment,null,se.createElement(Uq,{ref:t,value:i,placeholder:"[Open filter with CMD+SHIFT+L]",onPointerDown:h=>h.stopPropagation(),onChange:u}),se.createElement(Xx,{onClick:()=>l(),style:{visibility:i?"visible":"hidden"}},se.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"14",width:"14",viewBox:"0 0 20 20",fill:"currentColor"},se.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"}))))});function Fq({setFilter:n,onDrag:e,onDragStart:t,onDragEnd:i,toggle:r,toggled:a,title:l,drag:u,filterEnabled:h,from:p}){const[g,y]=U.useState(!1),b=U.useRef(null);U.useEffect(()=>{var M,A;g?(M=b.current)===null||M===void 0||M.focus():(A=b.current)===null||A===void 0||A.blur()},[g]);const x=H0(({offset:[M,A],first:w,last:E})=>{e({x:M,y:A}),w&&t({x:M,y:A}),E&&i({x:M,y:A})},{filterTaps:!0,from:({offset:[M,A]})=>[p?.x||M,p?.y||A]});return U.useEffect(()=>{const M=A=>{A.key==="L"&&A.shiftKey&&A.metaKey&&y(w=>!w)};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[]),se.createElement(se.Fragment,null,se.createElement(Nq,{mode:u?"drag":void 0},se.createElement(Xx,{active:!a,onClick:()=>r()},se.createElement(mT,{toggled:a,width:12,height:8})),se.createElement(zq,ji({},u?x():{},{drag:u,filterEnabled:h}),l===void 0&&u?se.createElement("svg",{width:"20",height:"10",viewBox:"0 0 28 14",xmlns:"http://www.w3.org/2000/svg"},se.createElement("circle",{cx:"2",cy:"2",r:"2"}),se.createElement("circle",{cx:"14",cy:"2",r:"2"}),se.createElement("circle",{cx:"26",cy:"2",r:"2"}),se.createElement("circle",{cx:"2",cy:"12",r:"2"}),se.createElement("circle",{cx:"14",cy:"12",r:"2"}),se.createElement("circle",{cx:"26",cy:"12",r:"2"})):l),h&&se.createElement(Xx,{active:g,onClick:()=>y(M=>!M)},se.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20",viewBox:"0 0 20 20"},se.createElement("path",{d:"M9 9a2 2 0 114 0 2 2 0 01-4 0z"}),se.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-13a4 4 0 00-3.446 6.032l-2.261 2.26a1 1 0 101.414 1.415l2.261-2.261A4 4 0 1011 5z",clipRule:"evenodd"})))),se.createElement(Lq,{toggled:g},se.createElement(Bq,{ref:b,setFilter:n,toggle:r})))}const kq=["store","hidden","theme","collapsed"];function Hq(n){let{store:e,hidden:t=!1,theme:i,collapsed:r=!1}=n,a=si(n,kq);const l=pI(()=>xW(i),[i]),[u,h]=U.useState(!r),p=typeof r=="object"?!r.collapsed:u,g=U.useMemo(()=>typeof r=="object"?y=>{typeof y=="function"?r.onChange(!y(!r.collapsed)):r.onChange(!y)}:h,[r]);return!e||t?null:se.createElement(dT.Provider,{value:l},se.createElement(Vq,ji({store:e},a,{toggled:p,setToggle:g,rootClass:l.className})))}const Vq=se.memo(({store:n,rootClass:e,fill:t=!1,flat:i=!1,neverHide:r=!1,oneLineLabels:a=!1,titleBar:l={title:void 0,drag:!0,filter:!0,position:void 0,onDrag:void 0,onDragStart:void 0,onDragEnd:void 0},hideCopyButton:u=!1,toggled:h,setToggle:p})=>{var g,y;const b=gj(n),[x,M]=U.useState(""),A=U.useMemo(()=>pq(b,x),[b,x]),[w,E]=HP(),R=r||b.length>0,D=typeof l=="object"&&l.title||void 0,P=typeof l=="object"&&(g=l.drag)!==null&&g!==void 0?g:!0,F=typeof l=="object"&&(y=l.filter)!==null&&y!==void 0?y:!0,L=typeof l=="object"&&l.position||void 0,k=typeof l=="object"&&l.onDrag||void 0,V=typeof l=="object"&&l.onDragStart||void 0,N=typeof l=="object"&&l.onDragEnd||void 0;return se.useEffect(()=>{E({x:L?.x,y:L?.y})},[L,E]),bW(),se.createElement(F7,null,se.createElement(PP.Provider,{value:{hideCopyButton:u}},se.createElement(Iq,{ref:w,className:e,fill:t,flat:i,oneLineLabels:a,hideTitleBar:!l,style:{display:R?"block":"none"}},l&&se.createElement(Fq,{onDrag:z=>{E(z),k?.(z)},onDragStart:z=>V?.(z),onDragEnd:z=>N?.(z),setFilter:M,toggle:z=>p(X=>z??!X),toggled:h,title:D,drag:P,filterEnabled:F,from:L}),R&&se.createElement(OP.Provider,{value:n},se.createElement(_I,{isRoot:!0,fill:t,flat:i,tree:A,toggled:h})))))}),Gq=["isRoot"];let jx=!1,ud=null;function MI(n){let{isRoot:e=!1}=n,t=si(n,Gq);return U.useEffect(()=>(jx=!0,!e&&ud&&(ud.remove(),ud=null),()=>{e||(jx=!1)}),[e]),se.createElement(Hq,ji({store:ET},t))}function Wq(n){U.useEffect(()=>{n&&!jx&&(ud||(ud=document.getElementById("leva__root")||Object.assign(document.createElement("div"),{id:"leva__root"}),document.body&&(document.body.appendChild(ud),o3.createRoot(ud).render(se.createElement(MI,{isRoot:!0})))),jx=!0)},[n])}function $q(n,e,t,i,r){let a,l,u,h,p;return typeof n=="string"?(l=n,a=e,Array.isArray(t)?p=t:t&&("store"in t?(h=t,p=i):(u=t,Array.isArray(i)?p=i:(h=i,p=r)))):(a=n,Array.isArray(e)?p=e:(h=e,p=t)),{schema:a,folderName:l,folderSettings:u,hookSettings:h,deps:p||[]}}function ta(n,e,t,i,r){const{folderName:a,schema:l,folderSettings:u,hookSettings:h,deps:p}=$q(n,e,t,i,r),g=typeof l=="function",y=U.useRef(!1),b=U.useRef(!0),x=pI(()=>{y.current=!0;const X=typeof l=="function"?l():l;return a?{[a]:ir(X,u)}:X},p),M=!(h!=null&&h.store);Wq(M);const[A]=U.useState(()=>h?.store||ET),[w,E]=U.useMemo(()=>A.getDataFromSchema(x),[A,x]),[R,D,P,F,L]=U.useMemo(()=>{const X=[],Q=[],J={},oe={},re={};return Object.values(E).forEach(({path:q,onChange:Z,onEditStart:ne,onEditEnd:pe,transient:Ee})=>{X.push(q),Z?(J[q]=Z,Ee||Q.push(q)):Q.push(q),ne&&(oe[q]=ne),pe&&(re[q]=pe)}),[X,Q,J,oe,re]},[E]),k=U.useMemo(()=>A.orderPaths(R),[R,A]),V=vj(A,D,w),N=U.useCallback(X=>{const Q=Object.entries(X).reduce((J,[oe,re])=>Object.assign(J,{[E[oe].path]:re}),{});A.set(Q,!1)},[A,E]),z=U.useCallback(X=>A.get(E[X].path),[A,E]);return U.useEffect(()=>{const X=!b.current&&y.current;return A.addData(w,X),b.current=!1,y.current=!1,()=>A.disposePaths(k)},[A,k,w]),U.useEffect(()=>{const X=[];return Object.entries(P).forEach(([Q,J])=>{J(A.get(Q),Q,Vt({initial:!0,get:A.get},A.getInput(Q)));const oe=A.useStore.subscribe(re=>{const q=re.data[Q];return[q.disabled?void 0:q.value,q]},([re,q])=>J(re,Q,Vt({initial:!1,get:A.get},q)),{equalityFn:P_});X.push(oe)}),()=>X.forEach(Q=>Q())},[A,P]),U.useEffect(()=>{const X=[];return Object.entries(F).forEach(([Q,J])=>X.push(A.subscribeToEditStart(Q,J))),Object.entries(L).forEach(([Q,J])=>X.push(A.subscribeToEditEnd(Q,J))),()=>X.forEach(Q=>Q())},[F,L,A]),g?[V,N,z]:V}Ic(Nc.SELECT,i$);Ic(Nc.IMAGE,Zj);Ic(Nc.NUMBER,jW);Ic(Nc.COLOR,Cj);Ic(Nc.STRING,d$);Ic(Nc.BOOLEAN,b$);Ic(Nc.INTERVAL,sq);Ic(Nc.VECTOR3D,Dj);Ic(Nc.VECTOR2D,Bj);const fp=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,0,1,0,-1]),Xq=.5*(Math.sqrt(3)-1),Ig=(3-Math.sqrt(3))/6;function jq(n){let e=Math.floor(n)|0;return()=>{e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function qq(n){const e=new Uint8Array(512),t=new Uint8Array(256);for(let r=0;r<256;r++)t[r]=r;const i=jq(n);for(let r=255;r>0;r--){const a=Math.floor(i()*(r+1)),l=t[r];t[r]=t[a],t[a]=l}for(let r=0;r<512;r++)e[r]=t[r&255];return(r,a)=>{const l=(r+a)*Xq,u=Math.floor(r+l),h=Math.floor(a+l),p=(u+h)*Ig,g=r-(u-p),y=a-(h-p),b=g>y?1:0,x=g>y?0:1,M=g-b+Ig,A=y-x+Ig,w=g-1+2*Ig,E=y-1+2*Ig,R=u&255,D=h&255;let P=0,F=.5-g*g-y*y;if(F>=0){const z=(e[R+e[D]]&7)*2;F*=F,P=F*F*(fp[z]*g+fp[z+1]*y)}let L=0,k=.5-M*M-A*A;if(k>=0){const z=(e[R+b+e[D+x]]&7)*2;k*=k,L=k*k*(fp[z]*M+fp[z+1]*A)}let V=0,N=.5-w*w-E*E;if(N>=0){const z=(e[R+1+e[D+1]]&7)*2;N*=N,V=N*N*(fp[z]*w+fp[z+1]*E)}return 70*(P+L+V)}}function Yq(n,e,t,i,r,a){const l=qq(e),u=(n+1)*(n+1),h=new Float32Array(u);let p=1/0,g=-1/0;for(let b=0;b<=n;b++)for(let x=0;x<=n;x++){const M=b*(n+1)+x,A=x/n,w=b/n;let E=1,R=t,D=0,P=0;for(let L=0;Lg&&(g=F)}const y=g-p||1;for(let b=0;bnew Qq,[]);return g.uniforms.get("threshold").value=t,g.uniforms.get("pixelScale").value=i,g.uniforms.get("mix_amount").value=e?r:0,g.uniforms.get("patternSize").value=a,g.uniforms.get("ditherColor").value.set(l),g.uniforms.get("ditherBgColor").value.set(u),g.uniforms.get("blendMode").value=Kq[h]??0,ut.jsx("primitive",{ref:p,object:g,dispose:null})}),eY={normal:0,multiply:1,screen:2,overlay:3,add:4,softLight:5},tY=` attribute float aNormHeight; varying float vNormHeight; varying vec2 vUv; varying vec3 vWorldPos; varying float vViewDist; void main() { vNormHeight = aNormHeight; vUv = uv; vec4 wp = modelMatrix * vec4(position, 1.0); vWorldPos = wp.xyz; vec4 mvPosition = viewMatrix * wp; vViewDist = -mvPosition.z; gl_Position = projectionMatrix * mvPosition; } `,nY=` precision highp float; uniform sampler2D uGradientMap; uniform float uShadingStrength; uniform bool uFogEnabled; uniform vec3 uFogColor; uniform float uFogNear; uniform float uFogFar; uniform bool uGridInScene; uniform vec3 uGridColor; uniform float uGridOpacity; uniform float uGridThickness; uniform float uSubdivisions; varying float vNormHeight; varying vec2 vUv; varying vec3 vWorldPos; varying float vViewDist; void main() { vec3 surfaceColor = texture2D(uGradientMap, vec2(clamp(vNormHeight, 0.0, 1.0), 0.5)).rgb; vec3 dx = dFdx(vWorldPos); vec3 dy = dFdy(vWorldPos); vec3 normal = normalize(cross(dx, dy)); vec3 lightDir = normalize(vec3(0.5, 1.0, 0.3)); float NdotL = max(dot(normal, lightDir), 0.0); float lighting = 0.5 + 0.5 * NdotL; surfaceColor *= mix(1.0, lighting, uShadingStrength); if (uGridInScene) { vec2 coord = vUv * uSubdivisions; vec2 grid = abs(fract(coord - 0.5) - 0.5); vec2 fw = fwidth(coord); vec2 lines = smoothstep(fw * uGridThickness, fw * (uGridThickness + 1.0), grid); float gridMask = 1.0 - min(lines.x, lines.y); surfaceColor = mix(surfaceColor, uGridColor, gridMask * uGridOpacity); } vec3 finalColor = surfaceColor; if (uFogEnabled) { float fogFactor = smoothstep(uFogNear, uFogFar, vViewDist); finalColor = mix(finalColor, uFogColor, fogFactor); } gl_FragColor = vec4(finalColor, 1.0); } `,Ab=` varying vec2 vUv; varying float vViewDist; void main() { vUv = uv; vec4 mvPosition = modelViewMatrix * vec4(position, 1.0); vViewDist = -mvPosition.z; gl_Position = projectionMatrix * mvPosition; } `,iY=` precision highp float; uniform vec3 uGridColor; uniform float uGridOpacity; uniform float uGridThickness; uniform float uSubdivisions; uniform bool uFogEnabled; uniform vec3 uFogColor; uniform float uFogNear; uniform float uFogFar; varying vec2 vUv; varying float vViewDist; void main() { vec2 coord = vUv * uSubdivisions; vec2 grid = abs(fract(coord - 0.5) - 0.5); vec2 fw = fwidth(coord); vec2 lines = smoothstep(fw * uGridThickness, fw * (uGridThickness + 1.0), grid); float gridMask = 1.0 - min(lines.x, lines.y); float alpha = gridMask * uGridOpacity; if (uFogEnabled) { float fogFactor = smoothstep(uFogNear, uFogFar, vViewDist); alpha *= (1.0 - fogFactor); } if (alpha < 0.001) discard; gl_FragColor = vec4(uGridColor * alpha, alpha); } `,rY=` precision highp float; uniform sampler2D uPixelBrightness; uniform vec3 uPixelColor; uniform float uPixelOpacity; uniform bool uFogEnabled; uniform float uFogNear; uniform float uFogFar; varying vec2 vUv; varying float vViewDist; void main() { float brightness = texture2D(uPixelBrightness, vUv).r; if (uFogEnabled) { float fogFactor = smoothstep(uFogNear, uFogFar, vViewDist); brightness *= (1.0 - fogFactor); } float alpha = brightness * uPixelOpacity; gl_FragColor = vec4(uPixelColor * alpha, alpha); } `,Ng=` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `,sY=` precision highp float; uniform sampler2D tInput; uniform float threshold; uniform float pixelScale; uniform float mixAmount; uniform int patternSize; uniform vec3 ditherColor; uniform int blendMode; uniform vec2 res; varying vec2 vUv; const int bayer8x8[64] = int[64]( 0, 32, 8, 40, 2, 34, 10, 42, 48, 16, 56, 24, 50, 18, 58, 26, 12, 44, 4, 36, 14, 46, 6, 38, 60, 28, 52, 20, 62, 30, 54, 22, 3, 35, 11, 43, 1, 33, 9, 41, 51, 19, 59, 27, 49, 17, 57, 25, 15, 47, 7, 39, 13, 45, 5, 37, 63, 31, 55, 23, 61, 29, 53, 21 ); float getBayerValue(ivec2 coord, int size) { if (size <= 2) { int lut[4] = int[4](0, 2, 3, 1); return float(lut[(coord.y % 2) * 2 + (coord.x % 2)]) / 4.0; } else if (size <= 4) { int bayer4x4[16] = int[16](0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5); return float(bayer4x4[(coord.y % 4) * 4 + (coord.x % 4)]) / 16.0; } else { return float(bayer8x8[(coord.y % 8) * 8 + (coord.x % 8)]) / 64.0; } } vec3 blendMultiply(vec3 b, vec3 t) { return b * t; } vec3 blendScreen(vec3 b, vec3 t) { return 1.0 - (1.0 - b) * (1.0 - t); } vec3 blendOverlay(vec3 b, vec3 t) { return vec3( b.r < 0.5 ? 2.0*b.r*t.r : 1.0-2.0*(1.0-b.r)*(1.0-t.r), b.g < 0.5 ? 2.0*b.g*t.g : 1.0-2.0*(1.0-b.g)*(1.0-t.g), b.b < 0.5 ? 2.0*b.b*t.b : 1.0-2.0*(1.0-b.b)*(1.0-t.b) ); } vec3 blendAdd(vec3 b, vec3 t) { return min(b + t, 1.0); } vec3 blendSoftLight(vec3 b, vec3 t) { return vec3( t.r < 0.5 ? b.r-(1.0-2.0*t.r)*b.r*(1.0-b.r) : b.r+(2.0*t.r-1.0)*(sqrt(b.r)-b.r), t.g < 0.5 ? b.g-(1.0-2.0*t.g)*b.g*(1.0-b.g) : b.g+(2.0*t.g-1.0)*(sqrt(b.g)-b.g), t.b < 0.5 ? b.b-(1.0-2.0*t.b)*b.b*(1.0-b.b) : b.b+(2.0*t.b-1.0)*(sqrt(b.b)-b.b) ); } vec3 applyBlend(vec3 b, vec3 t, int mode) { if (mode == 1) return blendMultiply(b, t); if (mode == 2) return blendScreen(b, t); if (mode == 3) return blendOverlay(b, t); if (mode == 4) return blendAdd(b, t); if (mode == 5) return blendSoftLight(b, t); return t; } void main() { vec2 cellIndex = floor(gl_FragCoord.xy / max(pixelScale, 1.0)); vec2 snappedUV = (cellIndex + 0.5) * max(pixelScale, 1.0) / res; vec4 cellColor = texture2D(tInput, clamp(snappedUV, 0.0, 1.0)); float lum = dot(cellColor.rgb, vec3(0.2126, 0.7152, 0.0722)); float patternVal = getBayerValue(ivec2(cellIndex), patternSize); float dithered = step(patternVal, lum + threshold - 0.5); vec3 blended = applyBlend(cellColor.rgb, ditherColor, blendMode); vec3 onColor = mix(cellColor.rgb, blended, mixAmount); // off pixels → black / transparent (works with any composite blend mode) gl_FragColor = vec4(onColor * dithered, dithered * mixAmount); } `,aY=` precision highp float; uniform sampler2D tInput; uniform bool caEnabled; uniform float caStrength; uniform int caSamples; varying vec2 vUv; void main() { vec3 color; if (caEnabled) { float rAcc = 0.0, gAcc = 0.0, bAcc = 0.0; // Unroll up to 8 samples; iterations beyond caSamples are skipped via weight. for (int i = 0; i < 8; i++) { if (i >= caSamples) break; float t = (caSamples == 1) ? 1.0 : float(i) / float(caSamples - 1); vec2 dir = (vUv - 0.5) * t * caStrength; rAcc += texture2D(tInput, clamp(vUv + dir, 0.0, 1.0)).r; gAcc += texture2D(tInput, vUv).g; bAcc += texture2D(tInput, clamp(vUv - dir, 0.0, 1.0)).b; } float n = float(caSamples); color = vec3(rAcc / n, gAcc / n, bAcc / n); } else { color = texture2D(tInput, vUv).rgb; } // Preserve premultiplied alpha from the input so compositing works correctly // regardless of which blend mode is used in the final composite pass. float alpha = texture2D(tInput, vUv).a; gl_FragColor = vec4(color, alpha); } `,oY=` precision highp float; uniform sampler2D tInput; uniform vec2 resolution; uniform vec2 direction; uniform float radius; varying vec2 vUv; void main() { vec2 step = direction * radius / resolution; vec4 sum = vec4(0.0); sum += texture2D(tInput, vUv + step * -4.0) * 0.0625; sum += texture2D(tInput, vUv + step * -3.0) * 0.125; sum += texture2D(tInput, vUv + step * -2.0) * 0.25; sum += texture2D(tInput, vUv + step * -1.0) * 0.5; sum += texture2D(tInput, vUv ) * 1.0; sum += texture2D(tInput, vUv + step * 1.0) * 0.5; sum += texture2D(tInput, vUv + step * 2.0) * 0.25; sum += texture2D(tInput, vUv + step * 3.0) * 0.125; sum += texture2D(tInput, vUv + step * 4.0) * 0.0625; gl_FragColor = sum / 2.8125; } `,lY=` precision highp float; uniform sampler2D tInput; varying vec2 vUv; void main() { gl_FragColor = texture2D(tInput, vUv); } `,cY=` precision highp float; uniform sampler2D tInput; uniform float bloomStrength; varying vec2 vUv; void main() { gl_FragColor = texture2D(tInput, vUv) * bloomStrength; } `;function uY(n){const e=parseInt(n.slice(1,3),16)/255,t=parseInt(n.slice(3,5),16)/255,i=parseInt(n.slice(5,7),16)/255;return[e,t,i]}function fY(n){const t=new Uint8Array(2048),i=n.length,r=n.map(uY);for(let l=0;l<512;l++){const h=l/511*(i-1),p=Math.min(Math.floor(h),i-2),g=h-p,y=r[p],b=r[p+1];t[l*4+0]=Math.round((y[0]+(b[0]-y[0])*g)*255),t[l*4+1]=Math.round((y[1]+(b[1]-y[1])*g)*255),t[l*4+2]=Math.round((y[2]+(b[2]-y[2])*g)*255),t[l*4+3]=255}const a=new Sa(t,512,1,$r);return a.minFilter=Nn,a.magFilter=Nn,a.needsUpdate=!0,a}function EI(n){return n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2}function dY(n){return n<.5?2*n*n:1-Math.pow(-2*n+2,2)/2}function hY(n){return-(Math.cos(Math.PI*n)-1)/2}function pY(n){return n*n*n}function mY(n){return 1-Math.pow(1-n,3)}function gY(n){return n===0?0:n===1?1:n<.5?Math.pow(2,20*n-10)/2:(2-Math.pow(2,-20*n+10))/2}const JM={linear:n=>n,easeInOutCubic:EI,easeInOutQuad:dY,easeInOutSine:hY,easeInCubic:pY,easeOutCubic:mY,easeInOutExpo:gY};function t3(n,e){switch(n.blending=qx,n.blendEquation=Mc,e){case"add":n.blendSrc=Iu,n.blendDst=Iu;break;case"screen":n.blendSrc=Iu,n.blendDst=nE;break;case"multiply":n.blendSrc=iE,n.blendDst=_p;break;case"lighten":n.blendEquation=tE,n.blendSrc=Iu,n.blendDst=Iu;break;default:n.blendSrc=Iu,n.blendDst=_p;break}}function vY(n){return{pixels:[],spawnAccumulator:0,brightnessData:new Float32Array(n*n)}}function yY(n,e,t,i,r){const a=Math.random(),l=Math.random(),u=Math.min(t,e),p=(u+Math.random()*Math.max(0,e-u))/n,g=Math.random()*Math.PI*2,y=Math.max(0,Math.min(1,a+Math.cos(g)*p)),b=Math.max(0,Math.min(1,l+Math.sin(g)*p)),x=i+Math.random()*Math.max(0,r-i),M=Math.floor(a*n),A=Math.floor(l*n);return{x:a,y:l,targetX:y,targetY:b,startX:a,startY:l,lifetime:x,age:0,trail:[{x:M,y:A,age:0}],lastCellX:M,lastCellY:A}}function bY(n,e,t,i){if(!i.enabled){n.pixels=[],n.brightnessData.fill(0);return}for(n.spawnAccumulator+=e*i.spawnRate;n.spawnAccumulator>=1;)n.spawnAccumulator-=1,n.pixels.lengthba.age0?Math.min(a.age/i.fadeInTime,1):1;const u=a.lifetime-a.age;i.fadeOutTime>0&&u=0&&g=i.trailLength){const x=(h-i.trailLength)/Math.max(i.trailFadeCount,1),M=Math.min(p.age/i.trailFadeTime,1);y=Math.max(0,1-Math.max(x,M))}n.brightnessData[g]=Math.min(1,n.brightnessData[g]+y*l)}}}}function xY(n){const{noiseScale:e,noiseDetail:t,seed:i,lacunarity:r,persistence:a,subdivisions:l,surfaceSize:u,heightScale:h,showGrid:p,gridColor:g,gridOpacity:y,gridThickness:b,gridBlendMode:x,gridDithered:M,colors:A,shadingStrength:w,fogEnabled:E,fogColor:R,fogNear:D,fogFar:P,animationDuration:F,loop:L,easingType:k,onAnimationComplete:V,pixelTrails:N,tracerEffects:z,pinEdges:X=!1,pinDepth:Q=1,pinSmoothTiles:J=10}=n,oe=U.useRef({start:new Float32Array(0),target:new Float32Array(0),current:new Float32Array(0),progress:1,dirty:!0}),re=U.useRef(null),q=U.useRef({width:0,height:0}),Z=U.useMemo(()=>new pt,[]),ne=U.useMemo(()=>{const Te=new Gu(u,u,l,l);Te.rotateX(-Math.PI/2);const H=(l+1)**2;return Te.setAttribute("aNormHeight",new Wn(new Float32Array(H),1)),Te},[l,u]);U.useEffect(()=>()=>ne.dispose(),[ne]);const pe=U.useMemo(()=>fY(A),[A]);U.useEffect(()=>()=>pe.dispose(),[pe]);const Ee=U.useMemo(()=>{const Te=new Float32Array(l*l),H=new Sa(Te,l,l,T0,Or);return H.minFilter=Kn,H.magFilter=Kn,H.needsUpdate=!0,H},[l]);U.useEffect(()=>()=>Ee.dispose(),[Ee]),U.useEffect(()=>{re.current=vY(l)},[l]);const j=U.useRef({uGradientMap:{value:pe},uShadingStrength:{value:w},uFogEnabled:{value:E},uFogColor:{value:new pt(R)},uFogNear:{value:D},uFogFar:{value:P},uGridInScene:{value:!1},uGridColor:{value:new pt(g)},uGridOpacity:{value:0},uGridThickness:{value:b},uSubdivisions:{value:l}}).current,fe=U.useMemo(()=>new zu,[]),be=U.useMemo(()=>new Yn({vertexShader:Ab,fragmentShader:iY,transparent:!0,depthTest:!0,depthWrite:!1,side:xr,uniforms:{uGridColor:{value:new pt(g)},uGridOpacity:{value:p?y:0},uGridThickness:{value:b},uSubdivisions:{value:l},uFogEnabled:{value:E},uFogColor:{value:new pt(R)},uFogNear:{value:D},uFogFar:{value:P}}}),[]),Fe=U.useMemo(()=>new Yn({vertexShader:Ab,fragmentShader:"void main() { gl_FragColor = vec4(0.0); }",colorWrite:!1,depthTest:!0,depthWrite:!0,side:xr}),[]);U.useEffect(()=>{const Te=new hi(ne,Fe);Te.renderOrder=-1;const H=new hi(ne,be);return fe.add(Te,H),()=>{fe.remove(Te,H)}},[ne,be,Fe,fe]);const rt=U.useMemo(()=>new zu,[]),he=U.useMemo(()=>new Yn({vertexShader:Ab,fragmentShader:"void main() {}",colorWrite:!1,depthWrite:!0,depthTest:!0,side:xr,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),[]),xe=U.useMemo(()=>new Yn({vertexShader:Ab,fragmentShader:rY,transparent:!0,depthTest:!0,depthWrite:!1,side:xr,uniforms:{uPixelBrightness:{value:Ee},uPixelColor:{value:new pt("#ffffff")},uPixelOpacity:{value:1},uFogEnabled:{value:E},uFogNear:{value:D},uFogFar:{value:P}}}),[]);U.useEffect(()=>{const Te=new hi(ne,he);Te.renderOrder=-1;const H=new hi(ne,xe);return rt.add(Te,H),()=>{rt.remove(Te,H)}},[ne,he,xe,rt]);const ke=U.useMemo(()=>new Gn(1,1,{depthBuffer:!0}),[]),Ge=U.useMemo(()=>new Gn(1,1,{depthBuffer:!1}),[]),ct=U.useMemo(()=>new Gn(1,1,{depthBuffer:!1}),[]),_t=U.useMemo(()=>new Gn(1,1,{depthBuffer:!1}),[]),St=U.useMemo(()=>new Gn(1,1,{depthBuffer:!1}),[]);U.useEffect(()=>()=>{ke.dispose(),Ge.dispose(),ct.dispose(),_t.dispose(),St.dispose()},[ke,Ge,ct,_t,St]);const mt=U.useMemo(()=>new Yn({vertexShader:Ng,fragmentShader:sY,depthTest:!1,depthWrite:!1,uniforms:{tInput:{value:null},threshold:{value:.14},pixelScale:{value:2},mixAmount:{value:1},patternSize:{value:8},ditherColor:{value:new pt("#ffffff")},blendMode:{value:0},res:{value:new Le(1,1)}}}),[]),Ce=U.useMemo(()=>new Yn({vertexShader:Ng,fragmentShader:aY,depthTest:!1,depthWrite:!1,uniforms:{tInput:{value:null},caEnabled:{value:!1},caStrength:{value:.005},caSamples:{value:1}}}),[]),Pe=U.useMemo(()=>new Yn({vertexShader:Ng,fragmentShader:oY,depthTest:!1,depthWrite:!1,uniforms:{tInput:{value:null},resolution:{value:new Le(1,1)},direction:{value:new Le(1,0)},radius:{value:3}}}),[]),ze=U.useMemo(()=>new Yn({vertexShader:Ng,fragmentShader:lY,transparent:!0,depthTest:!1,depthWrite:!1,blending:qx,uniforms:{tInput:{value:null}}}),[]),Xe=U.useMemo(()=>new Yn({vertexShader:Ng,fragmentShader:cY,transparent:!0,depthTest:!1,depthWrite:!1,blending:Ub,uniforms:{tInput:{value:null},bloomStrength:{value:1}}}),[]),{passCam:Y,passScene:bt,passQuad:st}=U.useMemo(()=>{const Te=new Lo(-1,1,1,-1,0,1),H=new zu,I=new hi(new Gu(2,2),void 0);return H.add(I),{passCam:Te,passScene:H,passQuad:I}},[]);U.useEffect(()=>{const Te=(l+1)**2,H=Yq(l,i,e,t,r,a),I=oe.current;I.target=H,I.current.length!==Te?(I.start=new Float32Array(H),I.current=new Float32Array(H),I.progress=1):(I.start=new Float32Array(I.current),I.progress=0),I.dirty=!0},[l,i,e,t,r,a]);const Et=U.useRef(h);return U.useEffect(()=>{Et.current!==h&&(Et.current=h,oe.current.dirty=!0)},[h]),U.useEffect(()=>{oe.current.dirty=!0},[X,Q,J]),pd((Te,H)=>{const I=oe.current;if(I.progress<1){I.progress=Math.min(I.progress+H/Math.max(F,.01),1);const ee=(JM[k]??EI)(I.progress);for(let ue=0;ue=1&&L&&V&&V()}if(I.dirty){I.dirty=!1;const ee=ne.attributes.position.array,ue=ne.attributes.aNormHeight.array,De=l+1,_e=J/Math.max(1,l),nt=-Q,Ye=Math.max(0,Math.min(1,nt/Math.max(h,.001)+.5));for(let dt=0;dt{if((I.width!==q.current.width||I.height!==q.current.height)&&(q.current={width:I.width,height:I.height},ke.setSize(I.width,I.height),Ge.setSize(I.width,I.height),ct.setSize(I.width,I.height),_t.setSize(I.width,I.height),St.setSize(I.width,I.height),mt.uniforms.res.value.set(I.width,I.height),Pe.uniforms.resolution.value.set(I.width,I.height)),!N?.enabled)return;const ee=Te.getClearAlpha();Te.getClearColor(Z),Te.setClearColor(0,0),Te.setRenderTarget(ke),Te.clear(!0,!0,!0),Te.render(rt,H),Te.setClearColor(Z,ee),Te.setRenderTarget(null);const ue=z;let De=ke;if(ue?.ditherEnabled&&(mt.uniforms.tInput.value=De.texture,mt.uniforms.threshold.value=ue.ditherThreshold,mt.uniforms.pixelScale.value=ue.ditherPixelScale,mt.uniforms.mixAmount.value=ue.ditherMix,mt.uniforms.patternSize.value=ue.ditherPattern,mt.uniforms.ditherColor.value.set(ue.ditherColor),mt.uniforms.blendMode.value=eY[ue.ditherBlend]??0,st.material=mt,Te.setRenderTarget(Ge),Te.clear(!0,!1,!1),Te.render(bt,Y),Te.setRenderTarget(null),De=Ge),ue?.caEnabled&&(Ce.uniforms.tInput.value=De.texture,Ce.uniforms.caEnabled.value=ue.caEnabled,Ce.uniforms.caStrength.value=ue.chromaticAberration,Ce.uniforms.caSamples.value=Math.max(1,Math.round(ue.caSamples)),st.material=Ce,Te.setRenderTarget(ct),Te.clear(!0,!1,!1),Te.render(bt,Y),Te.setRenderTarget(null),De=ct),ue?.bloomEnabled){const nt=Math.max(1,Math.round(ue.bloomIterations??1));Pe.uniforms.radius.value=ue.bloomRadius,st.material=Pe;let Ye=De.texture;for(let dt=0;dt{if(!p)return;const I=Te.autoClear;Te.autoClear=!1,Te.clearDepth(),Te.render(fe,H),Te.autoClear=I},3),ut.jsx("mesh",{geometry:ne,children:ut.jsx("shaderMaterial",{vertexShader:tY,fragmentShader:nY,uniforms:j,side:xr})})}const Lg={performance:{showStats:!1,maxPixels:8e6},surface:{noiseScale:4,noiseDetail:7,heightScale:1.8,surfaceSize:17.5,subdivisions:128,lacunarity:4,persistence:.3,animationDuration:10,easingType:"easeInOutCubic",loop:!1,pinEdges:!0,pinDepth:1,pinSmoothTiles:20},animation:{autoRegenerate:!0,matchAnimDuration:!1,regenInterval:20},grid:{showGrid:!0,gridColor:"#ffffff",gridOpacity:1,gridThickness:.2,gridBlendMode:"lighten",gridDithered:!1},gradient:{color1:"#000000",color2:"#140d21",color3:"#101045",color4:"#313131",color5:"#5c7aff",color6:"#d2c7ff"},background:{color:"#fceded"},shading:{shadingStrength:1},fog:{fogEnabled:!0,fogColor:"#ffffff",fogNear:9,fogFar:50},camera:{fov:20,posX:-7.8,posY:2.8,posZ:10.2,targetX:.7,targetY:0,targetZ:0,autoRotate:!0,autoRotateSpeed:.1,rotateHorizontal:!0,rotateVertical:!1,enablePan:!1,enableZoom:!1,minPolarAngle:0,maxPolarAngle:90,minAzimuthAngle:-360,maxAzimuthAngle:360},pixelTrails:{enabled:!0,spawnRate:50,maxTracers:150,range:160,minDistance:50,lifeMin:5,lifeMax:20,easingType:"easeInOutExpo",easingStrength:.25,trailLength:1,trailFadeCount:10,trailFadeTime:5,color:"#e1f0ff",blendMode:"normal",opacity:1,fadeInTime:1.5,fadeOutTime:1.5},surfaceEffects:{bloomEnabled:!0,bloom:1.15,bloomThreshold:0,vignetteEnabled:!1,vignetteDarkness:.5,caEnabled:!1,chromaticAberration:0,noiseEnabled:!0,noise:.23,ditherEnabled:!0,ditherThreshold:.3,ditherPixelScale:1,ditherMix:1,ditherPattern:8,ditherBlend:"normal",ditherColor:"#ffecec",ditherBgColor:"#0020eb",tmEnabled:!1,toneMapping:"ACES_FILMIC"},tracerEffects:{ditherEnabled:!0,useSurfaceDither:!0,ditherThreshold:.14,ditherPixelScale:2,ditherMix:1,ditherPattern:8,ditherBlend:"screen",ditherColor:"#e1f0ff",bloomEnabled:!0,bloom:2.8,bloomRadius:3,bloomIterations:1,caEnabled:!0,chromaticAberration:.016,caSamples:1},intro:{enabled:!0,duration:5,easing:"easeOutExpo",fromJson:'{"fog":{"fogNear":0,"fogFar":1}}'}},Cb={portrait:480,landscape:768,tablet:992,desktop:1440},_Y={portrait:{performance:{maxPixels:2e6},surface:{subdivisions:48}},landscape:{performance:{maxPixels:4e6},surface:{subdivisions:64}},tablet:{performance:{maxPixels:4e6},surface:{subdivisions:96}},desktop:{performance:{maxPixels:4e6},surface:{subdivisions:96}}};function SY(n){return nn,easeOutCubic:n=>1-Math.pow(1-n,3),easeOutQuart:n=>1-Math.pow(1-n,4),easeOutExpo:n=>n===0?0:1-Math.pow(2,-10*n),easeInOutSine:n=>-(Math.cos(Math.PI*n)-1)/2,easeInOutCubic:n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2};function Pu(n,e,t,i,r){const a=n?.[e]?.[t];return typeof a=="number"?a+(i-a)*r:i}function MY({desired:n,introFrom:e,introProgress:t,rotateHorizontal:i,rotateVertical:r,controlsRef:a}){const{camera:l}=br();return pd(()=>{const u=Pu(e,"camera","targetX",n.targetX,t),h=Pu(e,"camera","targetY",n.targetY,t),p=Pu(e,"camera","targetZ",n.targetZ,t),g=Pu(e,"camera","posX",n.posX,t),y=Pu(e,"camera","posY",n.posY,t),b=Pu(e,"camera","posZ",n.posZ,t),x=g-u,M=y-h,A=b-p,w=Math.sqrt(x*x+M*M+A*A)||1,E=Math.acos(Math.max(-1,Math.min(1,M/w))),R=Math.atan2(x,A),D=a.current?.target,P=D?D.x:u,F=D?D.y:h,L=D?D.z:p,k=l.position.x-P,V=l.position.y-F,N=l.position.z-L,z=Math.sqrt(k*k+V*V+N*N)||1,X=Math.acos(Math.max(-1,Math.min(1,V/z))),Q=Math.atan2(k,N),J=i?Q:R,oe=r?X:E;l.position.set(u+w*Math.sin(oe)*Math.sin(J),h+w*Math.cos(oe),p+w*Math.sin(oe)*Math.cos(J)),a.current&&a.current.target.set(u,h,p),l.lookAt(u,h,p);const re=Pu(e,"camera","fov",n.fov,t),q=l;q.fov!==re&&(q.fov=re,q.updateProjectionMatrix())},10),null}const rM="gradient-ascent-settings",EY=["tracerEffects.Dither.ditherThreshold","tracerEffects.Dither.ditherPixelScale","tracerEffects.Dither.ditherMix","tracerEffects.Dither.ditherPattern","tracerEffects.Dither.ditherBlend","tracerEffects.Dither.ditherColor"];function TY({color:n}){const{gl:e}=br();return U.useEffect(()=>{e.setClearColor(new pt(n),1)},[e,n]),null}function wY({maxPixels:n,renderedMpRef:e}){const{size:t,setDpr:i}=br();return U.useEffect(()=>{const r=window.devicePixelRatio,a=t.width*t.height,l=a>0?Math.min(r,Math.sqrt(n/a)):r,u=Math.max(.5,l);i(u),e&&(e.current=Math.round(a*u*u/1e3)/1e3)},[t.width,t.height,n,i,e]),null}function AY(n){const e=Math.PI/180,t=U.useRef(null);t.current===null&&(t.current={pos:[n.desired.posX,n.desired.posY,n.desired.posZ],target:[n.desired.targetX,n.desired.targetY,n.desired.targetZ],fov:n.desired.fov});const i=t.current,r=i.pos[0]-i.target[0],a=i.pos[1]-i.target[1],l=i.pos[2]-i.target[2],u=Math.sqrt(r*r+a*a+l*l)||1,h=Math.acos(Math.min(Math.max(a/u,-1),1)),p=Math.atan2(r,l),g=n.rotateVertical?n.minPolarAngle*e:h,y=n.rotateVertical?n.maxPolarAngle*e:h,b=n.rotateHorizontal?n.minAzimuthAngle<=-360?-1/0:n.minAzimuthAngle*e:p,x=n.rotateHorizontal?n.maxAzimuthAngle>=360?1/0:n.maxAzimuthAngle*e:p,{camera:M}=br(),A=U.useRef(null),w=U.useRef(n.onCameraChange);w.current=n.onCameraChange;const E=U.useCallback(()=>{const R=w.current;if(!R)return;const D=L=>Math.round(L*1e3)/1e3,P=M.position,F=A.current?.target??new K;R({posX:D(P.x),posY:D(P.y),posZ:D(P.z),targetX:D(F.x),targetY:D(F.y),targetZ:D(F.z)})},[M]);return ut.jsxs(ut.Fragment,{children:[ut.jsx(uH,{makeDefault:!0,fov:i.fov,position:i.pos}),ut.jsx(fH,{ref:A,target:i.target,autoRotate:n.autoRotate,autoRotateSpeed:n.autoRotateSpeed,enableRotate:n.rotateHorizontal||n.rotateVertical,enablePan:n.enablePan,enableZoom:n.enableZoom,enableDamping:!0,dampingFactor:.08,minPolarAngle:g,maxPolarAngle:y,minAzimuthAngle:b,maxAzimuthAngle:x,touches:{ONE:0,TWO:0},onEnd:E}),ut.jsx(MY,{desired:n.desired,introFrom:n.introFrom,introProgress:n.introProgress,rotateHorizontal:n.rotateHorizontal,rotateVertical:n.rotateVertical,controlsRef:A})]})}function CY({configOverrides:n,showPanel:e=!0}){const t=U.useMemo(()=>{if(!n)return Lg;const I={};for(const ee of Object.keys(Lg))I[ee]={...Lg[ee],...n[ee]};return I},[]),[i,r]=U.useState(()=>Math.floor(Math.random()*65536)),a=U.useRef(new Le(0,0)),l=n?.responsive??_Y,[u,h]=U.useState(()=>n3(l,window.innerWidth));U.useEffect(()=>{const I=()=>h(n3(l,window.innerWidth));return window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[l]);const p=U.useRef({}),g=U.useRef(structuredClone(Lg)),y=()=>{const I={};for(const[ee,ue]of Object.entries(g.current))I[ee]={...ue};return I},b=()=>{const I=g.current,ee={};for(const[ue,De]of Object.entries(I)){const _e=Lg[ue];for(const[nt,Ye]of Object.entries(De))JSON.stringify(Ye)!==JSON.stringify(_e?.[nt])&&(ee[ue]||(ee[ue]={}),ee[ue][nt]=Ye)}for(const ue of Object.keys(ee))Object.keys(ee[ue]).length===0&&delete ee[ue];return ee},x=I=>{for(const[ee,ue]of Object.entries(I)){const De=p.current[ee];De&&De(ue)}},[M,A]=U.useState(0),w=t.intro,[E,R]=ta("intro",()=>({enabled:{value:w.enabled,label:"Enabled"},duration:{value:w.duration,min:.5,max:30,step:.5,label:"Duration (s)"},easing:{value:w.easing,options:["linear","easeOutCubic","easeOutQuart","easeOutExpo","easeInOutSine","easeInOutCubic"],label:"Easing"},fromJson:{value:w.fromJson,label:"From (JSON)"},"▶ Replay Intro":td(()=>{P(0),A(I=>I+1)})})),[D,P]=U.useState(()=>E.enabled?0:1);U.useEffect(()=>{if(!E.enabled)return;const I=i3[E.easing]??i3.easeOutExpo,ee=E.duration*1e3,ue=performance.now();let De;const _e=()=>{const nt=Math.min((performance.now()-ue)/ee,1),Ye=nt>=1?1:I(nt);P(Ye),nt<1&&(De=requestAnimationFrame(_e))};return De=requestAnimationFrame(_e),()=>cancelAnimationFrame(De)},[M,E.enabled]);const[F,L]=U.useState(()=>localStorage.getItem(rM)!==null),[k,V]=U.useState(!1);ta("presets",()=>({"💾 Save Settings Locally":td(()=>{localStorage.setItem(rM,JSON.stringify(y())),L(!0)}),"📂 Load Local Settings":td(()=>{const I=localStorage.getItem(rM);if(I)try{x(JSON.parse(I))}catch{alert("Failed to parse saved settings.")}},{disabled:!F}),"📋 Copy All Settings":td(()=>{const I=JSON.stringify(y(),null,2);navigator.clipboard.writeText(I).then(()=>alert("All settings copied to clipboard."),()=>{window.prompt("Copy the settings below:",I)})}),"✂️ Copy Modified Settings":td(()=>{const I=b(),ee=JSON.stringify(I,null,2);navigator.clipboard.writeText(ee).then(()=>alert("Modified settings copied to clipboard."),()=>{window.prompt("Copy the settings below:",ee)})},{disabled:!k}),"📥 Import Settings":td(()=>{const I=window.prompt("Paste settings JSON:");if(I)try{x(JSON.parse(I))}catch{alert("Invalid JSON. Could not import settings.")}})}),[F,k]);const N=U.useRef(0),[z,X]=ta("performance",()=>({showStats:{value:t.performance.showStats,label:"Show FPS Monitor"},maxPixels:{value:t.performance.maxPixels,options:{"1 MP":1e6,"2 MP":2e6,"4 MP":4e6,"8 MP":8e6,"16 MP":16e6},label:"Pixel Budget"},"Rendered (MP)":hq(N,{graph:!1,interval:250})})),[Q,J]=ta("surface",()=>({Regenerate:td(()=>r(Math.floor(Math.random()*65536))),noiseScale:{value:t.surface.noiseScale,min:.5,max:10,step:.1,label:"Noise Scale"},noiseDetail:{value:t.surface.noiseDetail,min:1,max:8,step:1,label:"Detail"},heightScale:{value:t.surface.heightScale,min:0,max:5,step:.05,label:"Height"},surfaceSize:{value:t.surface.surfaceSize,min:1,max:100,step:.5,label:"Size"},subdivisions:{value:t.surface.subdivisions,min:16,max:256,step:1,label:"Subdivisions"},lacunarity:{value:t.surface.lacunarity,min:1.5,max:4,step:.1,label:"Lacunarity"},persistence:{value:t.surface.persistence,min:.1,max:.9,step:.05,label:"Persistence"},animationDuration:{value:t.surface.animationDuration,min:.3,max:20,step:.1,label:"Anim Duration"},loop:{value:t.surface.loop,label:"Loop"},easingType:{value:t.surface.easingType,options:["linear","easeInOutCubic","easeInOutQuad","easeInOutSine","easeInCubic","easeOutCubic"],label:"Easing"},"Edge Pinning":ir({pinEdges:{value:t.surface.pinEdges,label:"Enabled"},pinDepth:{value:t.surface.pinDepth,min:0,max:5,step:.05,label:"Depth"},pinSmoothTiles:{value:t.surface.pinSmoothTiles,min:1,max:60,step:1,label:"Radius (tiles)"}})})),[oe,re]=ta("animation",()=>({autoRegenerate:{value:t.animation.autoRegenerate,label:"Auto Regenerate"},matchAnimDuration:{value:t.animation.matchAnimDuration,label:"Match Anim Duration"},regenInterval:{value:t.animation.regenInterval,min:2,max:30,step:.5,label:"Interval (s)",render:I=>!I("animation.matchAnimDuration")}})),q=oe.matchAnimDuration?Q.animationDuration:oe.regenInterval;U.useEffect(()=>{if(!oe.autoRegenerate)return;const I=setInterval(()=>r(Math.floor(Math.random()*65536)),q*1e3);return()=>clearInterval(I)},[oe.autoRegenerate,q]);const[Z,ne]=ta("grid",()=>({showGrid:{value:t.grid.showGrid,label:"Show"},gridColor:{value:t.grid.gridColor,label:"Color"},gridOpacity:{value:t.grid.gridOpacity,min:0,max:1,step:.01,label:"Opacity"},gridThickness:{value:t.grid.gridThickness,min:.2,max:5,step:.1,label:"Thickness"},gridBlendMode:{value:t.grid.gridBlendMode,options:["normal","add","screen","multiply","lighten"],label:"Blend Mode"},gridDithered:{value:t.grid.gridDithered,label:"Dithered"}})),[pe,Ee]=ta("gradient",()=>({color1:{value:t.gradient.color1,label:"Low"},color2:{value:t.gradient.color2,label:"Mid-Low"},color3:{value:t.gradient.color3,label:"Mid"},color4:{value:t.gradient.color4,label:"Mid-High"},color5:{value:t.gradient.color5,label:"High"},color6:{value:t.gradient.color6,label:"Peak"}})),j=U.useMemo(()=>[pe.color1,pe.color2,pe.color3,pe.color4,pe.color5,pe.color6],[pe.color1,pe.color2,pe.color3,pe.color4,pe.color5,pe.color6]),[fe,be]=ta("background",()=>({color:{value:t.background.color,label:"Color"}})),[Fe,rt]=ta("shading",()=>({shadingStrength:{value:t.shading.shadingStrength,min:0,max:1,step:.01,label:"Strength"}})),[he,xe]=ta("fog",()=>({fogEnabled:{value:t.fog.fogEnabled,label:"Enabled"},fogColor:{value:t.fog.fogColor,label:"Color"},fogNear:{value:t.fog.fogNear,min:0,max:30,step:.5,label:"Near"},fogFar:{value:t.fog.fogFar,min:1,max:50,step:.5,label:"Far"}})),ke=t.camera,[Ge,ct]=ta("camera",()=>({fov:{value:ke.fov,min:5,max:120,step:1,label:"FOV"},Position:ir({posX:{value:ke.posX,min:-20,max:20,step:.1,label:"X"},posY:{value:ke.posY,min:.5,max:20,step:.1,label:"Y"},posZ:{value:ke.posZ,min:-20,max:20,step:.1,label:"Z"}}),Target:ir({targetX:{value:ke.targetX,min:-20,max:20,step:.1,label:"X"},targetY:{value:ke.targetY,min:-20,max:20,step:.1,label:"Y"},targetZ:{value:ke.targetZ,min:-20,max:20,step:.1,label:"Z"}}),Rotation:ir({autoRotate:{value:ke.autoRotate,label:"Auto Rotate"},autoRotateSpeed:{value:ke.autoRotateSpeed,min:0,max:5,step:.1,label:"Speed"}}),Interaction:ir({rotateHorizontal:{value:ke.rotateHorizontal,label:"Rotate Horizontal"},rotateVertical:{value:ke.rotateVertical,label:"Rotate Vertical"},enablePan:{value:ke.enablePan,label:"Enable Pan"},enableZoom:{value:ke.enableZoom,label:"Enable Zoom"}}),Constraints:ir({minPolarAngle:{value:ke.minPolarAngle,min:0,max:180,step:1,label:"Min Polar (°)"},maxPolarAngle:{value:ke.maxPolarAngle,min:0,max:180,step:1,label:"Max Polar (°)"},minAzimuthAngle:{value:ke.minAzimuthAngle,min:-360,max:360,step:1,label:"Min Azimuth (°)"},maxAzimuthAngle:{value:ke.maxAzimuthAngle,min:-360,max:360,step:1,label:"Max Azimuth (°)"}})})),_t=t.pixelTrails,[St,mt]=ta("pixelTrails",()=>({enabled:{value:_t.enabled,label:"Enabled"},Behavior:ir({spawnRate:{value:_t.spawnRate,min:.1,max:50,step:.1,label:"Spawn Rate (/s)"},maxTracers:{value:_t.maxTracers,min:10,max:1e3,step:10,label:"Max Tracers"},range:{value:_t.range,min:1,max:200,step:1,label:"Range (cells)"},minDistance:{value:_t.minDistance,min:0,max:200,step:1,label:"Min Distance (cells)"},lifeMin:{value:_t.lifeMin,min:.5,max:30,step:.5,label:"Life Min (s)"},lifeMax:{value:_t.lifeMax,min:.5,max:30,step:.5,label:"Life Max (s)"},easingType:{value:_t.easingType,options:["linear","easeInOutCubic","easeInOutQuad","easeInOutSine","easeInCubic","easeOutCubic","easeInOutExpo"],label:"Easing"},easingStrength:{value:_t.easingStrength,min:0,max:1,step:.01,label:"Easing Strength"}}),Trail:ir({trailLength:{value:_t.trailLength,min:1,max:20,step:1,label:"Fully Lit Cells"},trailFadeCount:{value:_t.trailFadeCount,min:0,max:30,step:1,label:"Fade Cells"},trailFadeTime:{value:_t.trailFadeTime,min:.1,max:10,step:.1,label:"Fade Time (s)"}}),Visual:ir({color:{value:_t.color,label:"Color"},blendMode:{value:_t.blendMode,options:["normal","add","screen","multiply","lighten"],label:"Blend Mode"},opacity:{value:_t.opacity,min:0,max:1,step:.01,label:"Opacity"}}),"Fade In":ir({fadeInTime:{value:_t.fadeInTime,min:0,max:10,step:.1,label:"Duration (s)"}}),"Fade Out":ir({fadeOutTime:{value:_t.fadeOutTime,min:0,max:10,step:.1,label:"Duration (s)"}})})),Ce=t.surfaceEffects,[Pe,ze]=ta("surfaceEffects",()=>({Bloom:ir({bloomEnabled:{value:Ce.bloomEnabled,label:"Enabled"},bloom:{value:Ce.bloom,min:0,max:3,step:.05,label:"Intensity"},bloomThreshold:{value:Ce.bloomThreshold,min:0,max:1,step:.05,label:"Threshold"}}),Vignette:ir({vignetteEnabled:{value:Ce.vignetteEnabled,label:"Enabled"},vignetteDarkness:{value:Ce.vignetteDarkness,min:0,max:1.5,step:.05,label:"Darkness"}}),"Chromatic Aberration":ir({caEnabled:{value:Ce.caEnabled,label:"Enabled"},chromaticAberration:{value:Ce.chromaticAberration,min:0,max:.02,step:5e-4,label:"Offset"}}),Noise:ir({noiseEnabled:{value:Ce.noiseEnabled,label:"Enabled"},noise:{value:Ce.noise,min:0,max:.5,step:.01,label:"Opacity"}}),Dither:ir({ditherEnabled:{value:Ce.ditherEnabled,label:"Enabled"},ditherThreshold:{value:Ce.ditherThreshold,min:0,max:1,step:.01,label:"Threshold"},ditherPixelScale:{value:Ce.ditherPixelScale,min:1,max:8,step:1,label:"Pixel Scale"},ditherMix:{value:Ce.ditherMix,min:0,max:1,step:.01,label:"Mix"},ditherPattern:{value:Ce.ditherPattern,options:[2,4,8],label:"Pattern Size"},ditherBlend:{value:Ce.ditherBlend,options:["normal","multiply","screen","overlay","add","softLight"],label:"Blend Mode"},ditherColor:{value:Ce.ditherColor,label:"Color"},ditherBgColor:{value:Ce.ditherBgColor,label:"BG Color"}}),"Tone Mapping":ir({tmEnabled:{value:Ce.tmEnabled,label:"Enabled"},toneMapping:{value:Ce.toneMapping,options:["LINEAR","REINHARD","REINHARD2","OPTIMIZED_CINEON","ACES_FILMIC","AGX"],label:"Mode"}})})),Xe=t.tracerEffects,[Y,bt]=ta("tracerEffects",()=>({Dither:ir({ditherEnabled:{value:Xe.ditherEnabled,label:"Enabled"},useSurfaceDither:{value:Xe.useSurfaceDither,label:"Use Surface Settings"},ditherThreshold:{value:Xe.ditherThreshold,min:0,max:1,step:.01,label:"Threshold"},ditherPixelScale:{value:Xe.ditherPixelScale,min:1,max:8,step:1,label:"Pixel Scale"},ditherMix:{value:Xe.ditherMix,min:0,max:1,step:.01,label:"Mix"},ditherPattern:{value:Xe.ditherPattern,options:[2,4,8],label:"Pattern Size"},ditherBlend:{value:Xe.ditherBlend,options:["normal","multiply","screen","overlay","add","softLight"],label:"Blend Mode"},ditherColor:{value:Xe.ditherColor,label:"Color"}}),Bloom:ir({bloomEnabled:{value:Xe.bloomEnabled,label:"Enabled"},bloom:{value:Xe.bloom,min:0,max:20,step:.05,label:"Strength"},bloomRadius:{value:Xe.bloomRadius,min:1,max:20,step:.5,label:"Radius"},bloomIterations:{value:Xe.bloomIterations,min:1,max:5,step:1,label:"Iterations"}}),"Chromatic Aberration":ir({caEnabled:{value:Xe.caEnabled,label:"Enabled"},chromaticAberration:{value:Xe.chromaticAberration,min:0,max:.2,step:.001,label:"Strength"},caSamples:{value:Xe.caSamples,min:1,max:8,step:1,label:"Samples"}})}));U.useEffect(()=>{const I=Y.useSurfaceDither;EY.forEach(ee=>ET.disableInputAtPath(ee,I))},[Y.useSurfaceDither]);const st={ditherEnabled:Y.ditherEnabled,ditherThreshold:Y.useSurfaceDither?Pe.ditherThreshold:Y.ditherThreshold,ditherPixelScale:Y.useSurfaceDither?Pe.ditherPixelScale:Y.ditherPixelScale,ditherMix:Y.useSurfaceDither?Pe.ditherMix:Y.ditherMix,ditherPattern:Y.useSurfaceDither?Pe.ditherPattern:Y.ditherPattern,ditherBlend:Y.useSurfaceDither?Pe.ditherBlend:Y.ditherBlend,ditherColor:Y.useSurfaceDither?Pe.ditherColor:Y.ditherColor,bloomEnabled:Y.bloomEnabled,bloom:Y.bloom,bloomRadius:Y.bloomRadius,bloomIterations:Y.bloomIterations,caEnabled:Y.caEnabled,chromaticAberration:Y.chromaticAberration,caSamples:Y.caSamples};p.current={performance:X,surface:J,animation:re,grid:ne,gradient:Ee,background:be,shading:rt,fog:xe,camera:ct,pixelTrails:mt,surfaceEffects:ze,tracerEffects:bt,intro:R},g.current={performance:{...z},surface:{...Q},animation:{...oe},grid:{...Z},gradient:{...pe},background:{...fe},shading:{...Fe},fog:{...he},camera:{...Ge},pixelTrails:{...St},surfaceEffects:{...Pe},tracerEffects:{...Y},intro:{...E}},U.useEffect(()=>{const I=Object.keys(b()).length>0;V(ee=>ee!==I?I:ee)});const Et=D,Te=U.useMemo(()=>{try{return JSON.parse(E.fromJson)}catch{return}},[E.fromJson]),H=(I,ee,ue)=>Pu(Te,I,ee,ue,Et);return ut.jsxs("div",{style:{width:"100%",height:"100%",touchAction:"pan-y"},children:[ut.jsx(MI,{hidden:!e,theme:{sizes:{rootWidth:"340px"}}}),ut.jsxs(a2,{gl:{antialias:!1,alpha:!1,powerPreference:"high-performance"},children:[ut.jsx(TY,{color:fe.color}),ut.jsx(wY,{maxPixels:u.performance?.maxPixels??z.maxPixels,renderedMpRef:N}),ut.jsx(AY,{desired:{posX:Ge.posX,posY:Ge.posY,posZ:Ge.posZ,targetX:Ge.targetX,targetY:Ge.targetY,targetZ:Ge.targetZ,fov:Ge.fov},introFrom:E.enabled?Te:void 0,introProgress:E.enabled?D:1,autoRotate:Ge.autoRotate,autoRotateSpeed:Ge.autoRotateSpeed,rotateHorizontal:Ge.rotateHorizontal,rotateVertical:Ge.rotateVertical,enablePan:Ge.enablePan,enableZoom:Ge.enableZoom,minPolarAngle:Ge.minPolarAngle,maxPolarAngle:Ge.maxPolarAngle,minAzimuthAngle:Ge.minAzimuthAngle,maxAzimuthAngle:Ge.maxAzimuthAngle,onCameraChange:I=>ct(I)}),ut.jsx(xY,{seed:i,noiseScale:Q.noiseScale,noiseDetail:Q.noiseDetail,heightScale:Q.heightScale,surfaceSize:Q.surfaceSize,subdivisions:u.surface?.subdivisions??Q.subdivisions,lacunarity:Q.lacunarity,persistence:Q.persistence,animationDuration:Q.animationDuration,loop:Q.loop,easingType:Q.easingType,onAnimationComplete:()=>r(Math.floor(Math.random()*65536)),showGrid:Z.showGrid,gridColor:Z.gridColor,gridOpacity:Z.gridOpacity,gridThickness:Z.gridThickness,gridBlendMode:Z.gridBlendMode,gridDithered:Z.gridDithered,colors:j,shadingStrength:H("shading","shadingStrength",Fe.shadingStrength),fogEnabled:he.fogEnabled,fogColor:he.fogColor,fogNear:H("fog","fogNear",he.fogNear),fogFar:H("fog","fogFar",he.fogFar),pixelTrails:{enabled:St.enabled,spawnRate:St.spawnRate,maxTracers:St.maxTracers,range:St.range,minDistance:St.minDistance,lifeMin:St.lifeMin,lifeMax:St.lifeMax,easingType:St.easingType,easingStrength:St.easingStrength,trailLength:St.trailLength,trailFadeCount:St.trailFadeCount,trailFadeTime:St.trailFadeTime,color:St.color,blendMode:St.blendMode,opacity:St.opacity,fadeInTime:St.fadeInTime,fadeOutTime:St.fadeOutTime},tracerEffects:st,pinEdges:Q.pinEdges,pinDepth:Q.pinDepth,pinSmoothTiles:Q.pinSmoothTiles}),z.showStats&&ut.jsx(vH,{className:"stats"}),ut.jsxs(YV,{multisampling:8,children:[ut.jsx(KV,{intensity:Pe.bloomEnabled?H("surfaceEffects","bloom",Pe.bloom):0,luminanceThreshold:Pe.bloomThreshold,luminanceSmoothing:.9,mipmapBlur:!0}),ut.jsx(QV,{offset:(()=>{const I=Pe.caEnabled?Pe.chromaticAberration:0;return a.current.set(I,I),a.current})(),radialModulation:!1,modulationOffset:.5}),ut.jsx(JV,{opacity:Pe.noiseEnabled?H("surfaceEffects","noise",Pe.noise):0,blendFunction:vn.OVERLAY}),ut.jsx(Jq,{enabled:Pe.ditherEnabled,threshold:Pe.ditherThreshold,pixelScale:Pe.ditherPixelScale,mixAmount:H("surfaceEffects","ditherMix",Pe.ditherMix),patternSize:Pe.ditherPattern,blendMode:Pe.ditherBlend,color:Pe.ditherColor,bgColor:Pe.ditherBgColor}),ut.jsx(e8,{mode:Pe.tmEnabled?Rs[Pe.toneMapping]:Rs.LINEAR}),ut.jsx(t8,{darkness:Pe.vignetteEnabled?H("surfaceEffects","vignetteDarkness",Pe.vignetteDarkness):0,offset:.5})]})]})]})}function r3(){const n=document.querySelectorAll("[data-gradient]");n.forEach(e=>{getComputedStyle(e).position==="static"&&(e.style.position="relative");let t;const i=e.getAttribute("data-gradient-config");if(i)try{t=JSON.parse(i)}catch(a){console.error("[gradient-ascent] Invalid JSON in data-gradient-config:",a)}if(t?.intro){const a=t.intro;a.from!==void 0&&a.fromJson===void 0&&(a.fromJson=JSON.stringify(a.from),delete a.from)}o3.createRoot(e).render(ut.jsx(U.StrictMode,{children:ut.jsx(CY,{configOverrides:t,showPanel:e.hasAttribute("data-gradient-panel")})}))}),n.length===0&&console.warn("[gradient-ascent] No [data-gradient] elements found.")}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r3):r3();