@iwsdk/vite-plugin-dev 1.0.1-rc.0 → 1.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/bundle-feature-gates.d.ts +9 -0
- package/dist/index.js +8704 -7942
- package/dist/index.js.map +1 -1
- package/dist/injection/chunks/_iwsdk-legacy-capture-B-A3EajS.js +1 -0
- package/dist/injection/chunks/bedroom-DETf9sEz.js +1 -0
- package/dist/injection/chunks/conference_room-CqY6mchI.js +1 -0
- package/dist/injection/chunks/home_office-BxWjiBZF.js +1 -0
- package/dist/injection/chunks/index-C3rlN7Lf.js +1 -0
- package/dist/injection/chunks/injection-template-9pnR-F15.js +984 -0
- package/dist/injection/chunks/kitchen-X_P3Lfoy.js +1 -0
- package/dist/injection/chunks/music_studio-glBmJOMe.js +1 -0
- package/dist/injection/chunks/open_office-BEqVZ5xR.js +1 -0
- package/dist/injection/chunks/open_studio-CVCR0jsb.js +1 -0
- package/dist/injection/chunks/sunlit_living_room-1m7CU_6o.js +1 -0
- package/dist/injection/runtime.js +1 -0
- package/dist/injection-bundler.d.ts +24 -1
- package/dist/injection-template.d.ts +3 -1
- package/dist/types.d.ts +18 -6
- package/package.json +8 -8
- package/dist/injection-bundle.js +0 -1045
package/dist/injection-bundle.js
DELETED
|
@@ -1,1045 +0,0 @@
|
|
|
1
|
-
!function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,n={exports:{}},i={};var r,a={exports:{}},s={};a.exports=function(){if(r)return s;r=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),f=Symbol.iterator,m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||m}function x(){}function b(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||m}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},x.prototype=y.prototype;var _=b.prototype=new x;_.constructor=b,g(_,y.prototype),_.isPureReactComponent=!0;var w=Array.isArray;function S(){}var E={H:null,A:null,T:null,S:null},M=Object.prototype.hasOwnProperty;function T(t,n,i){var r=i.ref;return{$$typeof:e,type:t,key:n,ref:void 0!==r?r:null,props:i}}function A(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var R=/\/+/g;function P(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,i={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return i[e]})):t.toString(36);var n,i}function C(n,i,r,a,s){var o=typeof n;"undefined"!==o&&"boolean"!==o||(n=null);var l,c,u=!1;if(null===n)u=!0;else switch(o){case"bigint":case"string":case"number":u=!0;break;case"object":switch(n.$$typeof){case e:case t:u=!0;break;case h:return C((u=n._init)(n._payload),i,r,a,s)}}if(u)return s=s(n),u=""===a?"."+P(n,0):a,w(s)?(r="",null!=u&&(r=u.replace(R,"$&/")+"/"),C(s,i,r,"",function(e){return e})):null!=s&&(A(s)&&(l=s,c=r+(null==s.key||n&&n.key===s.key?"":(""+s.key).replace(R,"$&/")+"/")+u,s=T(l.type,c,l.props)),i.push(s)),1;u=0;var d,p=""===a?".":a+":";if(w(n))for(var m=0;m<n.length;m++)u+=C(a=n[m],i,r,o=p+P(a,m),s);else if("function"==typeof(m=null===(d=n)||"object"!=typeof d?null:"function"==typeof(d=f&&d[f]||d["@@iterator"])?d:null))for(n=m.call(n),m=0;!(a=n.next()).done;)u+=C(a=a.value,i,r,o=p+P(a,m++),s);else if("object"===o){if("function"==typeof n.then)return C(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(S,S):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(n),i,r,a,s);throw i=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===i?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.")}return u}function L(e,t,n){if(null==e)return e;var i=[],r=0;return C(e,i,"","",function(e){return t.call(n,e,r++)}),i}function I(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var D="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},N={map:L,forEach:function(e,t,n){L(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return L(e,function(){t++}),t},toArray:function(e){return L(e,function(e){return e})||[]},only:function(e){if(!A(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};return s.Activity=p,s.Children=N,s.Component=y,s.Fragment=n,s.Profiler=a,s.PureComponent=b,s.StrictMode=i,s.Suspense=u,s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,s.__COMPILER_RUNTIME={__proto__:null,c:function(e){return E.H.useMemoCache(e)}},s.cache=function(e){return function(){return e.apply(null,arguments)}},s.cacheSignal=function(){return null},s.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var i=g({},e.props),r=e.key;if(null!=t)for(a in void 0!==t.key&&(r=""+t.key),t)!M.call(t,a)||"key"===a||"__self"===a||"__source"===a||"ref"===a&&void 0===t.ref||(i[a]=t[a]);var a=arguments.length-2;if(1===a)i.children=n;else if(1<a){for(var s=Array(a),o=0;o<a;o++)s[o]=arguments[o+2];i.children=s}return T(e.type,r,i)},s.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:o,_context:e},e},s.createElement=function(e,t,n){var i,r={},a=null;if(null!=t)for(i in void 0!==t.key&&(a=""+t.key),t)M.call(t,i)&&"key"!==i&&"__self"!==i&&"__source"!==i&&(r[i]=t[i]);var s=arguments.length-2;if(1===s)r.children=n;else if(1<s){for(var o=Array(s),l=0;l<s;l++)o[l]=arguments[l+2];r.children=o}if(e&&e.defaultProps)for(i in s=e.defaultProps)void 0===r[i]&&(r[i]=s[i]);return T(e,a,r)},s.createRef=function(){return{current:null}},s.forwardRef=function(e){return{$$typeof:c,render:e}},s.isValidElement=A,s.lazy=function(e){return{$$typeof:h,_payload:{_status:-1,_result:e},_init:I}},s.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},s.startTransition=function(e){var t=E.T,n={};E.T=n;try{var i=e(),r=E.S;null!==r&&r(n,i),"object"==typeof i&&null!==i&&"function"==typeof i.then&&i.then(S,D)}catch(e){D(e)}finally{null!==t&&null!==n.types&&(t.types=n.types),E.T=t}},s.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},s.use=function(e){return E.H.use(e)},s.useActionState=function(e,t,n){return E.H.useActionState(e,t,n)},s.useCallback=function(e,t){return E.H.useCallback(e,t)},s.useContext=function(e){return E.H.useContext(e)},s.useDebugValue=function(){},s.useDeferredValue=function(e,t){return E.H.useDeferredValue(e,t)},s.useEffect=function(e,t){return E.H.useEffect(e,t)},s.useEffectEvent=function(e){return E.H.useEffectEvent(e)},s.useId=function(){return E.H.useId()},s.useImperativeHandle=function(e,t,n){return E.H.useImperativeHandle(e,t,n)},s.useInsertionEffect=function(e,t){return E.H.useInsertionEffect(e,t)},s.useLayoutEffect=function(e,t){return E.H.useLayoutEffect(e,t)},s.useMemo=function(e,t){return E.H.useMemo(e,t)},s.useOptimistic=function(e,t){return E.H.useOptimistic(e,t)},s.useReducer=function(e,t,n){return E.H.useReducer(e,t,n)},s.useRef=function(e){return E.H.useRef(e)},s.useState=function(e){return E.H.useState(e)},s.useSyncExternalStore=function(e,t,n){return E.H.useSyncExternalStore(e,t,n)},s.useTransition=function(){return E.H.useTransition()},s.version="19.2.8",s}();var o=a.exports,l=e(o);n.exports=function(){if(t)return i;t=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function r(t,n,i){var r=null;if(void 0!==i&&(r=""+i),void 0!==n.key&&(r=""+n.key),"key"in n)for(var a in i={},n)"key"!==a&&(i[a]=n[a]);else i=n;return n=i.ref,{$$typeof:e,type:t,key:r,ref:void 0!==n?n:null,props:i}}return i.Fragment=n,i.jsx=r,i.jsxs=r,i}();var c=n.exports,u="-ms-",d="-moz-",h="-webkit-",p="comm",f="rule",m="decl",g="@keyframes",v=Math.abs,y=String.fromCharCode,x=Object.assign;function b(e){return e.trim()}function _(e,t){return(e=t.exec(e))?e[0]:e}function w(e,t,n){return e.replace(t,n)}function S(e,t,n){return e.indexOf(t,n)}function E(e,t){return 0|e.charCodeAt(t)}function M(e,t,n){return e.slice(t,n)}function T(e){return e.length}function A(e){return e.length}function R(e,t){return t.push(e),e}function P(e,t){return e.filter(function(e){return!_(e,t)})}var C,L,I=1,D=1,N=0,k=0,F=0,O="";function U(e,t,n,i,r,a,s,o){return{value:e,root:t,parent:n,type:i,props:r,children:a,line:I,column:D,length:s,return:"",siblings:o}}function z(e,t){return x(U("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function B(e){for(;e.root;)e=z(e.root,{children:[e]});R(e,e.siblings)}function V(){return F=k>0?E(O,--k):0,D--,10===F&&(D=1,I--),F}function H(){return F=k<N?E(O,k++):0,D++,10===F&&(D=1,I++),F}function G(){return E(O,k)}function W(){return k}function j(e,t){return M(O,e,t)}function X(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function q(e){return b(j(k-1,K(91===e?e+2:40===e?e+1:e)))}function $(e){for(;(F=G())&&F<33;)H();return X(e)>2||X(F)>3?"":" "}function Y(e,t){for(;--t&&H()&&!(F<48||F>102||F>57&&F<65||F>70&&F<97););return j(e,W()+(t<6&&32==G()&&32==H()))}function K(e){for(;H();)switch(F){case e:return k;case 34:case 39:34!==e&&39!==e&&K(F);break;case 40:41===e&&K(e);break;case 92:H()}return k}function Q(e,t){for(;H()&&e+F!==57&&(e+F!==84||47!==G()););return"/*"+j(t,k-1)+"*"+y(47===e?e:H())}function Z(e){for(;!X(G());)H();return j(e,k)}function J(e){return function(e){return O="",e}(ee("",null,null,null,[""],e=function(e){return I=D=1,N=T(O=e),k=0,[]}(e),0,[0],e))}function ee(e,t,n,i,r,a,s,o,l){for(var c=0,u=0,d=s,h=0,p=0,f=0,m=1,g=1,x=1,b=0,_="",A=r,P=a,C=i,L=_;g;)switch(f=b,b=H()){case 40:if(108!=f&&58==E(L,d-1)){-1!=S(L+=w(q(b),"&","&\f"),"&\f",v(c?o[c-1]:0))&&(x=-1);break}case 34:case 39:case 91:L+=q(b);break;case 9:case 10:case 13:case 32:L+=$(f);break;case 92:L+=Y(W()-1,7);continue;case 47:switch(G()){case 42:case 47:R(ne(Q(H(),W()),t,n,l),l),5!=X(f||1)&&5!=X(G()||1)||!T(L)||" "===M(L,-1,void 0)||(L+=" ");break;default:L+="/"}break;case 123*m:o[c++]=T(L)*x;case 125*m:case 59:case 0:switch(b){case 0:case 125:g=0;case 59+u:-1==x&&(L=w(L,/\f/g,"")),p>0&&(T(L)-d||0===m&&47===f)&&R(p>32?ie(L+";",i,n,d-1,l):ie(w(L," ","")+";",i,n,d-2,l),l);break;case 59:L+=";";default:if(R(C=te(L,t,n,c,u,r,o,_,A=[],P=[],d,a),a),123===b)if(0===u)ee(L,t,C,C,A,a,d,o,P);else{switch(h){case 99:if(110===E(L,3))break;case 108:if(97===E(L,2))break;default:u=0;case 100:case 109:case 115:}u?ee(e,C,C,i&&R(te(e,C,C,0,0,r,o,_,r,A=[],d,P),P),r,P,d,o,i?A:P):ee(L,C,C,C,[""],P,0,o,P)}}c=u=p=0,m=x=1,_=L="",d=s;break;case 58:d=1+T(L),p=f;default:if(m<1)if(123==b)--m;else if(125==b&&0==m++&&125==V())continue;switch(L+=y(b),b*m){case 38:x=u>0?1:(L+="\f",-1);break;case 44:o[c++]=(T(L)-1)*x,x=1;break;case 64:45===G()&&(L+=q(H())),h=G(),u=d=T(_=L+=Z(W())),b++;break;case 45:45===f&&2==T(L)&&(m=0)}}return a}function te(e,t,n,i,r,a,s,o,l,c,u,d){for(var h=r-1,p=0===r?a:[""],m=A(p),g=0,y=0,x=0;g<i;++g)for(var _=0,S=M(e,h+1,h=v(y=s[g])),E=e;_<m;++_)(E=b(y>0?p[_]+" "+S:w(S,/&\f/g,p[_])))&&(l[x++]=E);return U(e,t,n,0===r?f:o,l,c,u,d)}function ne(e,t,n,i){return U(e,t,n,p,y(F),M(e,2,-2),0,i)}function ie(e,t,n,i,r){return U(e,t,n,m,M(e,0,i),M(e,i+1,-1),i,r)}function re(e,t,n){switch(function(e,t){return 45^E(e,0)?(((t<<2^E(e,0))<<2^E(e,1))<<2^E(e,2))<<2^E(e,3):0}(e,t)){case 5103:return h+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return h+e+e;case 4855:return h+e.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+e;case 4789:return d+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return h+e+d+e+u+e+e;case 5936:switch(E(e,t+11)){case 114:return h+e+u+w(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return h+e+u+w(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return h+e+u+w(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return h+e+u+e+e;case 6165:return h+e+u+"flex-"+e+e;case 5187:return h+e+w(e,/(\w+).+(:[^]+)/,h+"box-$1$2"+u+"flex-$1$2")+e;case 5443:return h+e+u+"flex-item-"+w(e,/flex-|-self/g,"")+(_(e,/flex-|baseline/)?"":u+"grid-row-"+w(e,/flex-|-self/g,""))+e;case 4675:return h+e+u+"flex-line-pack"+w(e,/align-content|flex-|-self/g,"")+e;case 5548:return h+e+u+w(e,"shrink","negative")+e;case 5292:return h+e+u+w(e,"basis","preferred-size")+e;case 6060:return h+"box-"+w(e,"-grow","")+h+e+u+w(e,"grow","positive")+e;case 4554:return h+w(e,/([^-])(transform)/g,"$1"+h+"$2")+e;case 6187:return w(w(w(e,/(zoom-|grab)/,h+"$1"),/(image-set)/,h+"$1"),e,"")+e;case 5495:case 3959:return w(e,/(image-set\([^]*)/,h+"$1$`$1");case 4968:return w(w(e,/(.+:)(flex-)?(.*)/,h+"box-pack:$3"+u+"flex-pack:$3"),/space-between/,"justify")+h+e+e;case 4200:if(!_(e,/flex-|baseline/))return u+"grid-column-align"+M(e,t)+e;break;case 2592:case 3360:return u+w(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(e,n){return t=n,_(e.props,/grid-\w+-end/)})?~S(e+(n=n[t].value),"span",0)?e:u+w(e,"-start","")+e+u+"grid-row-span:"+(~S(n,"span",0)?_(n,/\d+/):+_(n,/\d+/)-+_(e,/\d+/))+";":u+w(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(e){return _(e.props,/grid-\w+-start/)})?e:u+w(w(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return w(e,/(.+)-inline(.+)/,h+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(T(e)-1-t>6)switch(E(e,t+1)){case 109:if(45!==E(e,t+4))break;case 102:return w(e,/(.+:)(.+)-([^]+)/,"$1"+h+"$2-$3$1"+d+(108==E(e,t+3)?"$3":"$2-$3"))+e;case 115:return~S(e,"stretch",0)?re(w(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return w(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(t,n,i,r,a,s,o){return u+n+":"+i+o+(r?u+n+"-span:"+(a?s:+s-+i)+o:"")+e});case 4949:if(121===E(e,t+6))return w(e,":",":"+h)+e;break;case 6444:switch(E(e,45===E(e,14)?18:11)){case 120:return w(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+h+(45===E(e,14)?"inline-":"")+"box$3$1"+h+"$2$3$1"+u+"$2box$3")+e;case 100:return w(e,":",":"+u)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return w(e,"scroll-","scroll-snap-")+e}return e}function ae(e,t){for(var n="",i=0;i<e.length;i++)n+=t(e[i],i,e,t)||"";return n}function se(e,t,n,i){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case"@namespace":case m:return e.return=e.return||e.value;case p:return"";case g:return e.return=e.value+"{"+ae(e.children,i)+"}";case f:if(!T(e.value=e.props.join(",")))return""}return T(n=ae(e.children,i))?e.return=e.value+"{"+n+"}":""}function oe(e,t,n,i){if(e.length>-1&&!e.return)switch(e.type){case m:return void(e.return=re(e.value,e.length,n));case g:return ae([z(e,{value:w(e.value,"@","@"+h)})],i);case f:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,function(t){switch(_(t,i=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":B(z(e,{props:[w(t,/:(read-\w+)/,":-moz-$1")]})),B(z(e,{props:[t]})),x(e,{props:P(n,i)});break;case"::placeholder":B(z(e,{props:[w(t,/:(plac\w+)/,":"+h+"input-$1")]})),B(z(e,{props:[w(t,/:(plac\w+)/,":-moz-$1")]})),B(z(e,{props:[w(t,/:(plac\w+)/,u+"input-$1")]})),B(z(e,{props:[t]})),x(e,{props:P(n,i)})}return""})}}const le="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",ce="active",ue="data-styled-version",de="6.4.4",he="/*!sc*/\n",pe="undefined"!=typeof window&&"undefined"!=typeof document;function fe(e){if("undefined"!=typeof process&&void 0!==process.env){const t=process.env[e];if(void 0!==t&&""!==t)return"false"!==t}}const me=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:null!==(L=null!==(C=fe("REACT_APP_SC_DISABLE_SPEEDY"))&&void 0!==C?C:fe("SC_DISABLE_SPEEDY"))&&void 0!==L?L:"undefined"!=typeof process&&void 0!==process.env&&!1);function ge(e,...t){return new Error(`An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#${e} for more information.${t.length>0?` Args: ${t.join(", ")}`:""}`)}let ve=new Map,ye=new Map,xe=1;const be=e=>{if(ve.has(e))return ve.get(e);for(;ye.has(xe);)xe++;const t=xe++;return ve.set(e,t),ye.set(t,e),t},_e=e=>ye.get(e),we=(e,t)=>{xe=t+1,ve.set(e,t),ye.set(t,e)},Se=Object.freeze([]),Ee=Object.freeze({});const Me=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Te=/(^-|-$)/g;function Ae(e){return e.replace(Me,"-").replace(Te,"")}const Re=/(a)(d)/gi,Pe=e=>String.fromCharCode(e+(e>25?39:97));function Ce(e){let t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=Pe(t%52)+n;return(Pe(t%52)+n).replace(Re,"$1-$2")}const Le=5381,Ie=(e,t)=>{let n=t.length;for(;n;)e=33*e^t.charCodeAt(--n);return e},De=e=>Ie(Le,e);function Ne(e){return"string"==typeof e&&!0}function ke(e){return Ne(e)?`styled.${e}`:`Styled(${function(e){return e.displayName||e.name||"Component"}(e)})`}const Fe=Symbol.for("react.memo"),Oe=Symbol.for("react.forward_ref"),Ue={contextType:!0,defaultProps:!0,displayName:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,propTypes:!0,type:!0},ze={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Be={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Ve={[Oe]:{$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},[Fe]:Be};function He(e){return("type"in(t=e)&&t.type.$$typeof)===Fe?Be:"$$typeof"in e?Ve[e.$$typeof]:Ue;var t}const Ge=Object.defineProperty,We=Object.getOwnPropertyNames,je=Object.getOwnPropertySymbols,Xe=Object.getOwnPropertyDescriptor,qe=Object.getPrototypeOf,$e=Object.prototype;function Ye(e,t,n){if("string"!=typeof t){const i=qe(t);i&&i!==$e&&Ye(e,i,n);const r=We(t).concat(je(t)),a=He(e),s=He(t);for(let i=0;i<r.length;++i){const o=r[i];if(!(o in ze||n&&n[o]||s&&o in s||a&&o in a)){const n=Xe(t,o);try{Ge(e,o,n)}catch(e){}}}}return e}function Ke(e){return"function"==typeof e}const Qe=Symbol.for("react.forward_ref");function Ze(e){return null!=e&&("object"==typeof e||"function"==typeof e)&&e.$$typeof===Qe&&"styledComponentId"in e}function Je(e,t){return e&&t?e+" "+t:e||t||""}function et(e,t){return e.join("")}function tt(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function nt(e,t,n=!1){if(!n&&!tt(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(let n=0;n<t.length;n++)e[n]=nt(e[n],t[n]);else if(tt(t))for(const n in t)e[n]=nt(e[n],t[n]);return e}function it(e,t){Object.defineProperty(e,"toString",{value:t})}const rt=class{constructor(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e,this._cGroup=0,this._cIndex=0}indexOfGroup(e){if(e===this._cGroup)return this._cIndex;let t=this._cIndex;if(e>this._cGroup)for(let n=this._cGroup;n<e;n++)t+=this.groupSizes[n];else for(let n=this._cGroup-1;n>=e;n--)t-=this.groupSizes[n];return this._cGroup=e,this._cIndex=t,t}insertRules(e,t){if(e>=this.groupSizes.length){const t=this.groupSizes,n=t.length;let i=n;for(;e>=i;)if(i<<=1,i<0)throw ge(16,`${e}`);this.groupSizes=new Uint32Array(i),this.groupSizes.set(t),this.length=i;for(let e=n;e<i;e++)this.groupSizes[e]=0}let n=this.indexOfGroup(e+1),i=0;for(let r=0,a=t.length;r<a;r++)this.tag.insertRule(n,t[r])&&(this.groupSizes[e]++,n++,i++);i>0&&this._cGroup>e&&(this._cIndex+=i)}clearGroup(e){if(e<this.length){const t=this.groupSizes[e],n=this.indexOfGroup(e),i=n+t;this.groupSizes[e]=0;for(let e=n;e<i;e++)this.tag.deleteRule(n);t>0&&this._cGroup>e&&(this._cIndex-=t)}}getGroup(e){let t="";if(e>=this.length||0===this.groupSizes[e])return t;const n=this.groupSizes[e],i=this.indexOfGroup(e),r=i+n;for(let e=i;e<r;e++)t+=this.tag.getRule(e)+he;return t}},at=`style[${le}][${ue}="${de}"]`,st=new RegExp(`^${le}\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)`),ot=e=>"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot||"host"in e&&11===e.nodeType,lt=e=>{if(!e)return document;if(ot(e))return e;if("getRootNode"in e){const t=e.getRootNode();if(ot(t))return t}return document},ct=(e,t,n)=>{const i=n.split(",");let r;for(let n=0,a=i.length;n<a;n++)(r=i[n])&&e.registerName(t,r)},ut=(e,t)=>{var n;const i=(null!==(n=t.textContent)&&void 0!==n?n:"").split(he),r=[];for(let t=0,n=i.length;t<n;t++){const n=i[t].trim();if(!n)continue;const a=n.match(st);if(a){const t=0|parseInt(a[1],10),n=a[2];0!==t&&(we(n,t),ct(e,n,a[3]),e.getTag().insertRules(t,r)),r.length=0}else r.push(n)}},dt=e=>{const t=lt(e.options.target).querySelectorAll(at);for(let n=0,i=t.length;n<i;n++){const i=t[n];i&&i.getAttribute(le)!==ce&&(ut(e,i),i.parentNode&&i.parentNode.removeChild(i))}};let ht=!1;const pt=(e,t)=>{const n=document.head,i=e||n,r=document.createElement("style"),a=(e=>{const t=Array.from(e.querySelectorAll(`style[${le}]`));return t[t.length-1]})(i),s=void 0!==a?a.nextSibling:null;r.setAttribute(le,ce),r.setAttribute(ue,de);const o=t||function(){if(!1!==ht)return ht;if("undefined"!=typeof document){const e=document.head.querySelector('meta[property="csp-nonce"]');if(e)return ht=e.nonce||e.getAttribute("content")||void 0;const t=document.head.querySelector('meta[name="sc-nonce"]');if(t)return ht=t.getAttribute("content")||void 0}return ht="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:void 0}();return o&&r.setAttribute("nonce",o),i.insertBefore(r,s),r},ft=class{constructor(e,t){this.element=pt(e,t),this.element.appendChild(document.createTextNode("")),this.sheet=(e=>{var t;if(e.sheet)return e.sheet;const n=null!==(t=e.getRootNode().styleSheets)&&void 0!==t?t:document.styleSheets;for(let t=0,i=n.length;t<i;t++){const i=n[t];if(i.ownerNode===e)return i}throw ge(17)})(this.element),this.length=0}insertRule(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}}deleteRule(e){this.sheet.deleteRule(e),this.length--}getRule(e){const t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""}},mt=class{constructor(e,t){this.element=pt(e,t),this.nodes=this.element.childNodes,this.length=0}insertRule(e,t){if(e<=this.length&&e>=0){const n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1}deleteRule(e){this.element.removeChild(this.nodes[e]),this.length--}getRule(e){return e<this.length?this.nodes[e].textContent:""}};let gt=pe;const vt={isServer:!pe,useCSSOMInjection:!me};class yt{static registerId(e){return be(e)}constructor(e=Ee,t={},n){this.options=Object.assign(Object.assign({},vt),e),this.gs=t,this.keyframeIds=new Set,this.names=new Map(n),this.server=!!e.isServer,!this.server&&pe&>&&(gt=!1,dt(this)),it(this,()=>(e=>{const t=e.getTag(),{length:n}=t;let i="";for(let r=0;r<n;r++){const n=_e(r);if(void 0===n)continue;const a=e.names.get(n);if(void 0===a||!a.size)continue;const s=t.getGroup(r);if(0===s.length)continue;const o=le+".g"+r+'[id="'+n+'"]';let l="";for(const e of a)e.length>0&&(l+=e+",");i+=s+o+'{content:"'+l+'"}'+he}return i})(this))}rehydrate(){!this.server&&pe&&dt(this)}reconstructWithOptions(e,t=!0){const n=new yt(Object.assign(Object.assign({},this.options),e),this.gs,t&&this.names||void 0);return n.keyframeIds=new Set(this.keyframeIds),!this.server&&pe&&e.target!==this.options.target&<(this.options.target)!==lt(e.target)&&dt(n),n}allocateGSInstance(e){return this.gs[e]=(this.gs[e]||0)+1}getTag(){return this.tag||(this.tag=(e=(({useCSSOMInjection:e,target:t,nonce:n})=>e?new ft(t,n):new mt(t,n))(this.options),new rt(e)));var e}hasNameForId(e,t){var n,i;return null!==(i=null===(n=this.names.get(e))||void 0===n?void 0:n.has(t))&&void 0!==i&&i}registerName(e,t){be(e),e.startsWith("sc-keyframes-")&&this.keyframeIds.add(e);const n=this.names.get(e);n?n.add(t):this.names.set(e,new Set([t]))}insertRules(e,t,n){this.registerName(e,t),this.getTag().insertRules(be(e),n)}clearNames(e){this.names.has(e)&&this.names.get(e).clear()}clearRules(e){this.getTag().clearGroup(be(e)),this.clearNames(e)}clearTag(){this.tag=void 0}}const xt=new WeakSet,bt={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexShrink:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function _t(e,t){return null==t||"boolean"==typeof t||""===t?"":"number"!=typeof t||0===t||e in bt||e.startsWith("--")?String(t).trim():t+"px"}const wt=47;function St(e){if(45===e.charCodeAt(0)&&45===e.charCodeAt(1))return e;let t="";for(let n=0;n<e.length;n++){const i=e.charCodeAt(n);t+=i>=65&&i<=90?"-"+String.fromCharCode(i+32):e[n]}return t.startsWith("ms-")?"-"+t:t}const Et=Symbol.for("sc-keyframes");function Mt(e){return Ke(e)&&!(e.prototype&&e.prototype.isReactComponent)}const Tt=e=>null==e||!1===e||""===e,At=Symbol.for("react.client.reference");function Rt(e){return e.$$typeof===At}function Pt(e,t){for(const n in e){const i=e[n];e.hasOwnProperty(n)&&!Tt(i)&&(Array.isArray(i)&&xt.has(i)||Ke(i)?t.push(St(n)+":",i,";"):tt(i)?(t.push(n+" {"),Pt(i,t),t.push("}")):t.push(St(n)+": "+_t(n,i)+";"))}}function Ct(e,t,n,i,r=[]){if(Tt(e))return r;const a=typeof e;if("string"===a)return r.push(e),r;if("function"===a){if(Rt(e))return r;if(Mt(e)&&t){return Ct(e(t),t,n,i,r)}return r.push(e),r}if(Array.isArray(e)){for(let a=0;a<e.length;a++)Ct(e[a],t,n,i,r);return r}return Ze(e)?(r.push(`.${e.styledComponentId}`),r):function(e){return"object"==typeof e&&null!==e&&Et in e}(e)?(n?(e.inject(n,i),r.push(e.getName(i))):r.push(e),r):Rt(e)?r:tt(e)?e.toString!==Object.prototype.toString?(r.push(e.toString()),r):(Pt(e,r),r):(r.push(e.toString()),r)}const Lt=De(de);class It{constructor(e,t,n){this.rules=e,this.componentId=t,this.baseHash=Ie(Lt,t),this.baseStyle=n,yt.registerId(t)}generateAndInjectStyles(e,t,n){let i=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";{let r="";for(let i=0;i<this.rules.length;i++){const a=this.rules[i];if("string"==typeof a)r+=a;else if(a)if(Mt(a)){const i=a(e);"string"==typeof i?r+=i:null!=i&&!1!==i&&(r+=et(Ct(i,e,t,n)))}else r+=et(Ct(a,e,t,n))}if(r){this.dynamicNameCache||(this.dynamicNameCache=new Map);const e=n.hash?n.hash+r:r;let a=this.dynamicNameCache.get(e);if(!a){if(a=Ce(Ie(Ie(this.baseHash,n.hash),r)>>>0),this.dynamicNameCache.size>=200){const e=this.dynamicNameCache.keys().next().value;void 0!==e&&this.dynamicNameCache.delete(e)}this.dynamicNameCache.set(e,a)}if(!t.hasNameForId(this.componentId,a)){const e=n(r,"."+a,void 0,this.componentId);t.insertRules(this.componentId,a,e)}i=Je(i,a)}}return i}}const Dt=/&/g;function Nt(e,t){let n=0;for(;--t>=0&&92===e.charCodeAt(t);)n++;return!(1&~n)}function kt(e){const t=e.length;let n="",i=0,r=0,a=0,s=!1,o=!1;for(let l=0;l<t;l++){const c=e.charCodeAt(l);if(0!==a||s||c!==wt||42!==e.charCodeAt(l+1))if(s)42===c&&e.charCodeAt(l+1)===wt&&(s=!1,l++);else if(34!==c&&39!==c||Nt(e,l)){if(0===a)if(123===c)r++;else if(125===c){if(r--,r<0){o=!0;let n=l+1;for(;n<t;){const t=e.charCodeAt(n);if(59===t||10===t)break;n++}n<t&&59===e.charCodeAt(n)&&n++,r=0,l=n-1,i=n;continue}0===r&&(n+=e.substring(i,l+1),i=l+1)}else 59===c&&0===r&&(n+=e.substring(i,l+1),i=l+1)}else 0===a?a=c:a===c&&(a=0);else s=!0,l++}return o||0!==r||0!==a?(i<t&&0===r&&0===a&&(n+=e.substring(i)),n):e}function Ft(e,t){const n=t+" ",i=","+n;for(let r=0;r<e.length;r++){const a=e[r];if("rule"===a.type){a.value=(n+a.value).replaceAll(",",i);const e=a.props,t=[];for(let i=0;i<e.length;i++)t[i]=n+e[i];a.props=t}Array.isArray(a.children)&&"@keyframes"!==a.type&&Ft(a.children,t)}return e}function Ot({options:e=Ee,plugins:t=Se}=Ee){let n,i,r;const a=(e,t,r)=>r.startsWith(i)&&r.endsWith(i)&&r.replaceAll(i,"").length>0?`.${n}`:e,s=t.slice();s.push(e=>{e.type===f&&e.value.includes("&")&&(r||(r=new RegExp(`\\${i}\\b`,"g")),e.props[0]=e.props[0].replace(Dt,i).replace(r,a))}),e.prefix&&s.push(oe),s.push(se);let o=[];const l=function(e){var t=A(e);return function(n,i,r,a){for(var s="",o=0;o<t;o++)s+=e[o](n,i,r,a)||"";return s}}(s.concat((d=e=>o.push(e),function(e){e.root||(e=e.return)&&d(e)}))),c=(t,a="",s="",c="&")=>{n=c,i=a,r=void 0;const u=function(e){const t=-1!==e.indexOf("//"),n=-1!==e.indexOf("}");if(!t&&!n)return e;if(!t)return kt(e);const i=e.length;let r="",a=0,s=0,o=0,l=0,c=0,u=!1;for(;s<i;){const t=e.charCodeAt(s);if(34!==t&&39!==t||Nt(e,s))if(0===o)if(t===wt&&s+1<i&&42===e.charCodeAt(s+1)){for(s+=2;s+1<i&&(42!==e.charCodeAt(s)||e.charCodeAt(s+1)!==wt);)s++;s+=2}else if(40!==t)if(41!==t)if(l>0)s++;else if(42===t&&s+1<i&&e.charCodeAt(s+1)===wt)r+=e.substring(a,s),s+=2,a=s,u=!0;else if(t===wt&&s+1<i&&e.charCodeAt(s+1)===wt){for(r+=e.substring(a,s);s<i&&10!==e.charCodeAt(s);)s++;a=s,u=!0}else 123===t?c++:125===t&&c--,s++;else l>0&&l--,s++;else l++,s++;else s++;else 0===o?o=t:o===t&&(o=0),s++}return u?(a<i&&(r+=e.substring(a)),0===c?r:kt(r)):0===c?e:kt(e)}(t);let d=J(s||a?s+" "+a+" { "+u+" }":u);return e.namespace&&(d=Ft(d,e.namespace)),o=[],ae(d,l),o},u=e;var d;let h=Le;for(let e=0;e<t.length;e++)t[e].name||ge(15),h=Ie(h,t[e].name);return(null==u?void 0:u.namespace)&&(h=Ie(h,u.namespace)),(null==u?void 0:u.prefix)&&(h=Ie(h,"p")),c.hash=h!==Le?h.toString():"",c}const Ut=new yt,zt=Ot(),Bt=l.createContext({shouldForwardProp:void 0,styleSheet:Ut,stylis:zt,stylisPlugins:void 0});function Vt(){return l.useContext(Bt)}function Ht(e){var t;const n=Vt(),{styleSheet:i}=n,r=l.useMemo(()=>{let t=i;return e.sheet?t=e.sheet:e.target?t=t.reconstructWithOptions(void 0!==e.nonce?{target:e.target,nonce:e.nonce}:{target:e.target},!1):void 0!==e.nonce&&(t=t.reconstructWithOptions({nonce:e.nonce})),e.disableCSSOMInjection&&(t=t.reconstructWithOptions({useCSSOMInjection:!1})),t},[e.disableCSSOMInjection,e.nonce,e.sheet,e.target,i]),a=l.useMemo(()=>{var t;return void 0===e.stylisPlugins&&void 0===e.namespace&&void 0===e.enableVendorPrefixes?n.stylis:Ot({options:{namespace:e.namespace,prefix:e.enableVendorPrefixes},plugins:null!==(t=e.stylisPlugins)&&void 0!==t?t:n.stylisPlugins})},[e.enableVendorPrefixes,e.namespace,e.stylisPlugins,n.stylis,n.stylisPlugins]),s="shouldForwardProp"in e?e.shouldForwardProp:n.shouldForwardProp,o=null!==(t=e.stylisPlugins)&&void 0!==t?t:n.stylisPlugins,c=l.useMemo(()=>({shouldForwardProp:s,styleSheet:r,stylis:a,stylisPlugins:o}),[s,r,a,o]);return l.createElement(Bt.Provider,{value:c},e.children)}Bt.Consumer;const Gt=l.createContext(void 0);Gt.Consumer;const Wt=Object.prototype.hasOwnProperty,jt={};function Xt(e,t){const n="string"!=typeof e?"sc":Ae(e);jt[n]=(jt[n]||0)+1;const i=n+"-"+function(e){return Ce(De(e)>>>0)}(de+n+jt[n]);return t?t+"-"+i:i}function qt(e,t,n){const i=Ze(e),r=e,a=!Ne(e),{attrs:s=Se,componentId:c=Xt(t.displayName,t.parentComponentId),displayName:u=ke(e)}=t,d=t.displayName&&t.componentId?Ae(t.displayName)+"-"+t.componentId:t.componentId||c,h=i&&r.attrs?r.attrs.concat(s).filter(Boolean):s;let{shouldForwardProp:p}=t;if(i&&r.shouldForwardProp){const e=r.shouldForwardProp;if(t.shouldForwardProp){const n=t.shouldForwardProp;p=(t,i)=>e(t,i)&&n(t,i)}else p=e}const f=new It(n,d,i?r.componentStyle:void 0);function m(e,t){return function(e,t,n){const{attrs:i,componentStyle:r,defaultProps:a,foldedComponentIds:s,styledComponentId:c,target:u}=e,d=l.useContext(Gt),h=Vt(),p=e.shouldForwardProp||h.shouldForwardProp,f=function(e,t,n=Ee){return e.theme!==n.theme&&e.theme||t||n.theme}(t,d,a)||Ee;let m,g;{const e=l.useRef(null),n=e.current;if(null!==n&&n[1]===f&&n[2]===h.styleSheet&&n[3]===h.stylis&&n[7]===r&&function(e,t,n){const i=e,r=t;let a=0;for(const e in r)if(Wt.call(r,e)&&(a++,i[e]!==r[e]))return!1;return a===n}(n[0],t,n[4]))m=n[5],g=n[6];else{m=function(e,t,n){const i=Object.assign(Object.assign({},t),{className:void 0,theme:n}),r=e.length>1;for(let n=0;n<e.length;n++){const a=e[n],s=Ke(a)?a(r?Object.assign({},i):i):a;for(const e in s)"className"===e?i.className=Je(i.className,s[e]):"style"===e?i.style=Object.assign(Object.assign({},i.style),s[e]):e in t&&void 0===t[e]||(i[e]=s[e])}return"className"in t&&"string"==typeof t.className&&(i.className=Je(i.className,t.className)),i}(i,t,f),g=function(e,t,n,i){return e.generateAndInjectStyles(t,n,i)}(r,m,h.styleSheet,h.stylis);let n=0;for(const e in t)Wt.call(t,e)&&n++;e.current=[t,f,h.styleSheet,h.stylis,n,m,g,r]}}const v=m.as||u,y=function(e,t,n,i){const r={};for(const a in e)void 0===e[a]||"$"===a[0]||"as"===a||"theme"===a&&e.theme===n||("forwardedAs"===a?r.as=e.forwardedAs:i&&!i(a,t)||(r[a]=e[a]));return r}(m,v,f,p);let x=Je(s,c);return g&&(x+=" "+g),m.className&&(x+=" "+m.className),y[Ne(v)&&v.includes("-")?"class":"className"]=x,n&&(y.ref=n),o.createElement(v,y)}(g,e,t)}m.displayName=u;let g=l.forwardRef(m);return g.attrs=h,g.componentStyle=f,g.displayName=u,g.shouldForwardProp=p,g.foldedComponentIds=i?Je(r.foldedComponentIds,r.styledComponentId):"",g.styledComponentId=d,g.target=i?r.target:e,Object.defineProperty(g,"defaultProps",{get(){return this._foldedDefaultProps},set(e){this._foldedDefaultProps=i?function(e,...t){for(const n of t)nt(e,n,!0);return e}({},r.defaultProps,e):e}}),it(g,()=>`.${g.styledComponentId}`),a&&Ye(g,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),g}var $t=new Set(["a","abbr","address","area","article","aside","audio","b","bdi","bdo","blockquote","body","button","br","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","slot","small","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","tspan","use"]);function Yt(e,t){const n=[e[0]];for(let i=0,r=t.length;i<r;i+=1)n.push(t[i],e[i+1]);return n}const Kt=e=>(xt.add(e),e);function Qt(e,t,n=Ee){if(!t)throw ge(1,t);const i=(i,...r)=>e(t,n,function(e,...t){if(Ke(e)||tt(e))return Kt(Ct(Yt(Se,[e,...t])));const n=e;return 0===t.length&&1===n.length&&"string"==typeof n[0]?Ct(n):Kt(Ct(Yt(n,t)))}(i,...r));return i.attrs=i=>Qt(e,t,Object.assign(Object.assign({},n),{attrs:Array.prototype.concat(n.attrs,i).filter(Boolean)})),i.withConfig=i=>Qt(e,t,Object.assign(Object.assign({},n),i)),i}const Zt=e=>Qt(qt,e),Jt=Zt;$t.forEach(e=>{Jt[e]=Zt(e)});const en="#EDEDED",tn="#9C9C9C",nn="#6B6B6E",rn="rgba(243, 151, 143, 1)",an="rgba(240, 97, 84,1)",sn="#2D7FF9",on="rgba(45, 127, 249, 0.35)",ln="rgba(38, 38, 38, 0.72)",cn="rgba(61, 61, 63, 0.7)",un="rgba(61, 61, 63, 0.6)",dn="rgba(61, 61, 63, 1)",hn="linear-gradient(to bottom, rgba(52, 52, 52, 0.75), rgba(57, 57, 57, 0.75))",pn="30px",fn="30px",mn="14px",gn="3px",vn="10px",yn="10px 3px 3px 10px",xn="3px 10px 10px 3px",bn="70px",_n="3px",wn=Jt.button`
|
|
2
|
-
background: ${hn};
|
|
3
|
-
border: none;
|
|
4
|
-
display: flex;
|
|
5
|
-
align-items: center;
|
|
6
|
-
justify-content: center;
|
|
7
|
-
cursor: pointer;
|
|
8
|
-
color: ${en};
|
|
9
|
-
border: 1px solid transparent;
|
|
10
|
-
border-radius: ${gn};
|
|
11
|
-
font-size: ${mn};
|
|
12
|
-
height: ${pn};
|
|
13
|
-
min-width: ${fn};
|
|
14
|
-
transition: all 0.2s ease-in-out;
|
|
15
|
-
text-transform: none;
|
|
16
|
-
box-shadow: none;
|
|
17
|
-
font-family:
|
|
18
|
-
system-ui,
|
|
19
|
-
-apple-system,
|
|
20
|
-
'Segoe UI',
|
|
21
|
-
Roboto,
|
|
22
|
-
sans-serif;
|
|
23
|
-
|
|
24
|
-
&:first-child {
|
|
25
|
-
border-radius: ${({$reverse:e})=>e?xn:yn};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&:last-child {
|
|
29
|
-
border-radius: ${({$reverse:e})=>e?yn:xn};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&:first-child:last-child {
|
|
33
|
-
border-radius: ${vn};
|
|
34
|
-
}
|
|
35
|
-
`,Sn=Jt.div`
|
|
36
|
-
padding: 4px;
|
|
37
|
-
display: flex;
|
|
38
|
-
gap: 2px;
|
|
39
|
-
background-color: ${ln};
|
|
40
|
-
border: 1px solid ${cn};
|
|
41
|
-
backdrop-filter: blur(40px);
|
|
42
|
-
-webkit-backdrop-filter: blur(40px);
|
|
43
|
-
box-shadow:
|
|
44
|
-
0 5px 10px rgba(0, 0, 0, 0.3),
|
|
45
|
-
inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
|
46
|
-
justify-content: center;
|
|
47
|
-
pointer-events: all;
|
|
48
|
-
border-radius: 14px;
|
|
49
|
-
align-items: center;
|
|
50
|
-
`,En=Jt.button`
|
|
51
|
-
background-color: ${({$active:e,$open:t})=>e?"rgba(45, 127, 249, 0.18)":t?"rgba(255, 255, 255, 0.1)":"transparent"};
|
|
52
|
-
border: none;
|
|
53
|
-
display: flex;
|
|
54
|
-
align-items: center;
|
|
55
|
-
justify-content: center;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
color: ${({$active:e})=>e?sn:en};
|
|
58
|
-
border-radius: 8px;
|
|
59
|
-
height: 28px;
|
|
60
|
-
min-width: 28px;
|
|
61
|
-
padding: 0 6px;
|
|
62
|
-
transition: all 0.15s ease-in-out;
|
|
63
|
-
text-transform: none;
|
|
64
|
-
box-shadow: none;
|
|
65
|
-
font-family:
|
|
66
|
-
system-ui,
|
|
67
|
-
-apple-system,
|
|
68
|
-
'Segoe UI',
|
|
69
|
-
Roboto,
|
|
70
|
-
sans-serif;
|
|
71
|
-
|
|
72
|
-
&:hover:not(:disabled) {
|
|
73
|
-
background-color: ${({$active:e,$open:t})=>e?"rgba(45, 127, 249, 0.24)":t?"rgba(255, 255, 255, 0.14)":"rgba(255, 255, 255, 0.06)"};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&:active:not(:disabled) {
|
|
77
|
-
background-color: ${({$active:e,$open:t})=>e?"rgba(45, 127, 249, 0.32)":t?"rgba(255, 255, 255, 0.18)":"rgba(255, 255, 255, 0.1)"};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
&:focus {
|
|
81
|
-
outline: none;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
&:focus-visible {
|
|
85
|
-
outline: 2px solid ${sn};
|
|
86
|
-
outline-offset: 1px;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
&:disabled {
|
|
90
|
-
cursor: not-allowed;
|
|
91
|
-
opacity: 0.45;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&:disabled:hover,
|
|
95
|
-
&:disabled:active {
|
|
96
|
-
background-color: transparent;
|
|
97
|
-
}
|
|
98
|
-
`,Mn=Jt.div`
|
|
99
|
-
background-color: ${({$pressed:e})=>e?dn:un};
|
|
100
|
-
border: none;
|
|
101
|
-
display: flex;
|
|
102
|
-
align-items: center;
|
|
103
|
-
justify-content: center;
|
|
104
|
-
color: ${en};
|
|
105
|
-
border-radius: 8px;
|
|
106
|
-
font-size: 14px;
|
|
107
|
-
font-family:
|
|
108
|
-
system-ui,
|
|
109
|
-
-apple-system,
|
|
110
|
-
'Segoe UI',
|
|
111
|
-
Roboto,
|
|
112
|
-
sans-serif;
|
|
113
|
-
height: 30px;
|
|
114
|
-
width: 30px;
|
|
115
|
-
transition: all 0.2s ease-in-out;
|
|
116
|
-
`,Tn=Jt.div`
|
|
117
|
-
display: flex;
|
|
118
|
-
flex-direction: row;
|
|
119
|
-
align-items: center;
|
|
120
|
-
gap: 3px;
|
|
121
|
-
margin-bottom: 3px;
|
|
122
|
-
|
|
123
|
-
&:last-child {
|
|
124
|
-
margin-bottom: 0;
|
|
125
|
-
}
|
|
126
|
-
`,An=Jt.div`
|
|
127
|
-
flex: none;
|
|
128
|
-
box-sizing: border-box;
|
|
129
|
-
width: 30px;
|
|
130
|
-
height: 30px;
|
|
131
|
-
border-radius: 50%;
|
|
132
|
-
border: 1px solid ${cn};
|
|
133
|
-
display: flex;
|
|
134
|
-
align-items: center;
|
|
135
|
-
justify-content: center;
|
|
136
|
-
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
137
|
-
font-size: 9px;
|
|
138
|
-
font-weight: 600;
|
|
139
|
-
color: ${tn};
|
|
140
|
-
`;Jt.div`
|
|
141
|
-
display: flex;
|
|
142
|
-
align-items: center;
|
|
143
|
-
height: 30px;
|
|
144
|
-
margin-bottom: 3px;
|
|
145
|
-
justify-content: flex-start;
|
|
146
|
-
flex-direction: ${({$reverse:e})=>e?"row-reverse":"row"};
|
|
147
|
-
|
|
148
|
-
&:last-child {
|
|
149
|
-
margin-bottom: 0;
|
|
150
|
-
}
|
|
151
|
-
`,Jt.div`
|
|
152
|
-
display: flex;
|
|
153
|
-
flex-direction: ${({$reverse:e})=>e?"row-reverse":"row"};
|
|
154
|
-
height: 100%;
|
|
155
|
-
justify-content: space-between;
|
|
156
|
-
align-items: center;
|
|
157
|
-
margin: ${({$reverse:e})=>e?"0 5px 0 0":"0 0 0 5px"};
|
|
158
|
-
gap: 3px;
|
|
159
|
-
`,Jt.button`
|
|
160
|
-
background-color: rgba(255, 255, 255, 0.3);
|
|
161
|
-
border: none;
|
|
162
|
-
display: flex;
|
|
163
|
-
justify-content: center;
|
|
164
|
-
align-items: center;
|
|
165
|
-
padding: 0;
|
|
166
|
-
pointer-events: none;
|
|
167
|
-
width: 50px;
|
|
168
|
-
height: 50px;
|
|
169
|
-
border-radius: 50%;
|
|
170
|
-
position: relative;
|
|
171
|
-
margin: 0 5px;
|
|
172
|
-
backdrop-filter: blur(10px);
|
|
173
|
-
-webkit-backdrop-filter: blur(10px);
|
|
174
|
-
`,Jt.div`
|
|
175
|
-
position: absolute;
|
|
176
|
-
background-color: ${sn};
|
|
177
|
-
box-shadow: 0 0 8px ${on};
|
|
178
|
-
border-radius: 50%;
|
|
179
|
-
width: 36px;
|
|
180
|
-
height: 36px;
|
|
181
|
-
cursor: pointer;
|
|
182
|
-
pointer-events: auto;
|
|
183
|
-
`,Jt.input.attrs({type:"range"})`
|
|
184
|
-
-webkit-appearance: none;
|
|
185
|
-
appearance: none;
|
|
186
|
-
background: ${hn};
|
|
187
|
-
border: none;
|
|
188
|
-
height: 100%;
|
|
189
|
-
width: ${bn};
|
|
190
|
-
cursor: pointer;
|
|
191
|
-
margin: 0;
|
|
192
|
-
transition: all 0.2s ease-in-out;
|
|
193
|
-
border-radius: ${({$reverse:e})=>e?yn:xn};
|
|
194
|
-
|
|
195
|
-
&::-webkit-slider-thumb {
|
|
196
|
-
-webkit-appearance: none;
|
|
197
|
-
appearance: none;
|
|
198
|
-
width: 8px;
|
|
199
|
-
height: 30px;
|
|
200
|
-
background-color: ${sn};
|
|
201
|
-
border-radius: ${gn};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
&::-moz-range-thumb {
|
|
205
|
-
width: 10px;
|
|
206
|
-
height: 30px;
|
|
207
|
-
background-color: ${sn};
|
|
208
|
-
border-radius: ${gn};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
&::-ms-thumb {
|
|
212
|
-
width: 8px;
|
|
213
|
-
height: 24px;
|
|
214
|
-
background-color: ${sn};
|
|
215
|
-
border-radius: ${gn};
|
|
216
|
-
}
|
|
217
|
-
`,Jt.div`
|
|
218
|
-
display: flex;
|
|
219
|
-
flex-direction: column;
|
|
220
|
-
align-items: ${({$reverse:e})=>e?"flex-start":"flex-end"};
|
|
221
|
-
justify-content: center;
|
|
222
|
-
margin: ${({$reverse:e})=>e?"2px -26px 0 0":"2px 0 0 -26px"};
|
|
223
|
-
`,Jt.div`
|
|
224
|
-
display: flex;
|
|
225
|
-
flex-direction: ${({$reverse:e})=>e?"row-reverse":"row"};
|
|
226
|
-
align-items: center;
|
|
227
|
-
justify-content: center;
|
|
228
|
-
`;const Rn="40px",Pn="52px",Cn="4px",Ln="26px",In="8px",Dn="rgba(0, 0, 0, 0.25)",Nn="rgba(45, 127, 249, 0.45)",kn="rgba(45, 127, 249, 0.18)",Fn=Jt.span`
|
|
229
|
-
flex: none;
|
|
230
|
-
width: ${Rn};
|
|
231
|
-
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
232
|
-
font-size: 10px;
|
|
233
|
-
color: ${tn};
|
|
234
|
-
`,On=Jt.div`
|
|
235
|
-
position: fixed;
|
|
236
|
-
padding: 5px;
|
|
237
|
-
font-family:
|
|
238
|
-
system-ui,
|
|
239
|
-
-apple-system,
|
|
240
|
-
'Segoe UI',
|
|
241
|
-
Roboto,
|
|
242
|
-
sans-serif;
|
|
243
|
-
color: ${en};
|
|
244
|
-
pointer-events: all;
|
|
245
|
-
background-color: ${ln};
|
|
246
|
-
border: 1px solid ${cn};
|
|
247
|
-
backdrop-filter: blur(40px);
|
|
248
|
-
-webkit-backdrop-filter: blur(40px);
|
|
249
|
-
border-radius: 12px;
|
|
250
|
-
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
|
|
251
|
-
overflow: hidden;
|
|
252
|
-
display: flex;
|
|
253
|
-
flex-direction: column;
|
|
254
|
-
`,Un=Jt.hr`
|
|
255
|
-
width: ${({$horizontal:e=!0})=>e?"unset":"1px"};
|
|
256
|
-
height: ${({$horizontal:e=!0})=>e?"1px":"unset"};
|
|
257
|
-
background-color: ${cn};
|
|
258
|
-
margin: 5px 3px;
|
|
259
|
-
border: none;
|
|
260
|
-
`,zn=Jt.button`
|
|
261
|
-
background-color: transparent;
|
|
262
|
-
border: none;
|
|
263
|
-
display: flex;
|
|
264
|
-
align-items: center;
|
|
265
|
-
justify-content: center;
|
|
266
|
-
cursor: pointer;
|
|
267
|
-
color: ${({$isRed:e})=>e?rn:en};
|
|
268
|
-
font-size: 12px;
|
|
269
|
-
padding: 3px;
|
|
270
|
-
text-transform: none;
|
|
271
|
-
box-shadow: none;
|
|
272
|
-
|
|
273
|
-
&:hover {
|
|
274
|
-
color: ${({$isRed:e})=>e?an:"#ffffff"};
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
&:active {
|
|
278
|
-
color: ${({$isRed:e})=>e?an:"#ffffff"};
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
&:focus {
|
|
282
|
-
outline: none;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
&:focus-visible {
|
|
286
|
-
outline: 2px solid ${sn};
|
|
287
|
-
outline-offset: 1px;
|
|
288
|
-
}
|
|
289
|
-
`,Bn=Jt.div`
|
|
290
|
-
display: flex;
|
|
291
|
-
flex-direction: row;
|
|
292
|
-
gap: ${Cn};
|
|
293
|
-
height: ${Ln};
|
|
294
|
-
`,Vn=Jt.input.attrs({type:"text"})`
|
|
295
|
-
width: ${Pn};
|
|
296
|
-
outline: none;
|
|
297
|
-
background: ${Dn};
|
|
298
|
-
border: 1px solid ${cn};
|
|
299
|
-
border-radius: ${In};
|
|
300
|
-
height: ${Ln};
|
|
301
|
-
color: ${en};
|
|
302
|
-
padding: 0 10px 0 5px;
|
|
303
|
-
box-sizing: border-box;
|
|
304
|
-
font-size: 10px;
|
|
305
|
-
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
306
|
-
|
|
307
|
-
&:focus-visible {
|
|
308
|
-
outline: 2px solid ${sn};
|
|
309
|
-
outline-offset: 1px;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
&:read-only {
|
|
313
|
-
background: ${Dn};
|
|
314
|
-
cursor: default;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
&:invalid {
|
|
318
|
-
background-color: ${rn};
|
|
319
|
-
}
|
|
320
|
-
`,Hn=Jt.span`
|
|
321
|
-
position: absolute;
|
|
322
|
-
right: 5px;
|
|
323
|
-
top: 50%;
|
|
324
|
-
transform: translateY(-50%);
|
|
325
|
-
pointer-events: none;
|
|
326
|
-
color: ${tn};
|
|
327
|
-
font-size: 10px;
|
|
328
|
-
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
329
|
-
`
|
|
330
|
-
/**
|
|
331
|
-
* @license lucide-react v1.26.0 - ISC
|
|
332
|
-
*
|
|
333
|
-
* This source code is licensed under the ISC license.
|
|
334
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
335
|
-
*/,Gn=(...e)=>e.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),Wn=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)};
|
|
336
|
-
/**
|
|
337
|
-
* @license lucide-react v1.26.0 - ISC
|
|
338
|
-
*
|
|
339
|
-
* This source code is licensed under the ISC license.
|
|
340
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
341
|
-
*/
|
|
342
|
-
var jn={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};
|
|
343
|
-
/**
|
|
344
|
-
* @license lucide-react v1.26.0 - ISC
|
|
345
|
-
*
|
|
346
|
-
* This source code is licensed under the ISC license.
|
|
347
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
348
|
-
*/const Xn=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1},qn=o.createContext({}),$n=o.forwardRef(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:i,className:r="",children:a,iconNode:s,...l},c)=>{const{size:u=24,strokeWidth:d=2,absoluteStrokeWidth:h=!1,color:p="currentColor",className:f=""}=o.useContext(qn)??{},m=i??h?24*Number(n??d)/Number(t??u):n??d;return o.createElement("svg",{ref:c,...jn,width:t??u??jn.width,height:t??u??jn.height,stroke:e??p,strokeWidth:m,className:Gn("lucide",f,r),...!a&&!Xn(l)&&{"aria-hidden":"true"},...l},[...s.map(([e,t])=>o.createElement(e,t)),...Array.isArray(a)?a:[a]])}),Yn=(e,t)=>{const n=o.forwardRef(({className:n,...i},r)=>{return o.createElement($n,{ref:r,iconNode:t,className:Gn(`lucide-${a=Wn(e),a.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,n),...i});var a});return n.displayName=Wn(e),n},Kn=Yn("armchair",[["path",{d:"M19 9V6a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v3",key:"irtipd"}],["path",{d:"M3 16a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"1qyhux"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]),Qn=Yn("arrow-big-up",[["path",{d:"M9 19a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-6a1 1 0 0 1 1-1h3.293a.707.707 0 0 0 .5-1.207l-7.086-7.086a1 1 0 0 0-1.414 0l-7.086 7.086a.707.707 0 0 0 .5 1.207H8a1 1 0 0 1 1 1z",key:"106j91"}]]),Zn=Yn("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),Jn=Yn("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),ei=Yn("arrow-right-to-line",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]),ti=Yn("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),ni=Yn("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),ii=Yn("atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]),ri=Yn("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]),ai=Yn("box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]),si=Yn("bug",[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]]),oi=Yn("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),li=Yn("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),ci=Yn("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),ui=Yn("circle-play",[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),di=Yn("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),hi=Yn("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]),pi=Yn("delete",[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]]),fi=Yn("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),mi=Yn("gamepad-2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]),gi=Yn("glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]),vi=Yn("hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]),yi=Yn("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),xi=Yn("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),bi=Yn("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),_i=Yn("mouse-left",[["path",{d:"M12 7.318V10",key:"17s7lh"}],["path",{d:"M5 10v5a7 7 0 0 0 14 0V9c0-3.527-2.608-6.515-6-7",key:"imk5ea"}],["circle",{cx:"7",cy:"4",r:"2",key:"ra7k3"}]]),wi=Yn("mouse-right",[["path",{d:"M12 7.318V10",key:"17s7lh"}],["path",{d:"M19 10v5a7 7 0 0 1-14 0V9c0-3.527 2.608-6.515 6-7",key:"2es5nn"}],["circle",{cx:"17",cy:"4",r:"2",key:"y5j2s2"}]]),Si=Yn("mouse",[["rect",{x:"5",y:"2",width:"14",height:"20",rx:"7",key:"11ol66"}],["path",{d:"M12 6v4",key:"16clxf"}]]),Ei=Yn("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),Mi=Yn("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]),Ti=Yn("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),Ai=Yn("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),Ri=Yn("scan-eye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),Pi=Yn("scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]),Ci=Yn("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Li=Yn("shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]),Ii=Yn("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),Di={"rotate-ccw":Ti,"circle-play":ui,"gamepad-2":mi,hand:vi,eye:fi,keyboard:yi,armchair:Kn,layers:xi,box:ai,shapes:Li,save:Ai,scan:Pi,"scan-eye":Ri,"log-out":bi,atom:ii,bug:si,x:Yn("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),settings:Ci,"circle-x":di,plug:Mi,glasses:gi,video:Ii,pin:Ei,"circle-dot":ci,"chevron-left":oi,"chevron-right":li,ban:ri,mouse:Si,"mouse-left":_i,"mouse-right":wi,"corner-down-left":hi,"arrow-big-up":Qn,"arrow-up":ni,"arrow-down":Zn,"arrow-left":Jn,"arrow-right":ti,"arrow-right-to-line":ei,delete:pi},Ni=({size:e,color:t,style:n})=>c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 14 14",fill:"none",style:n,children:[c.jsx("path",{fill:t,d:"M10.5 8.367a1.4 1.4 0 1 0 0-2.8 1.4 1.4 0 0 0 0 2.8Z"}),c.jsx("path",{fill:t,fillRule:"evenodd",d:"M0 5.8A2.8 2.8 0 0 1 2.8 3h8.4A2.8 2.8 0 0 1 14 5.8v2.8a2.8 2.8 0 0 1-2.8 2.8H9.526c-.619 0-1.184-.35-1.46-.903l-.108-.214a.933.933 0 0 0-.835-.516h-.246c-.354 0-.677.2-.835.516l-.107.214a1.633 1.633 0 0 1-1.461.903H2.8A2.8 2.8 0 0 1 0 8.6V5.8Zm4.9 1.167a1.4 1.4 0 1 1-2.8 0 1.4 1.4 0 0 1 2.8 0Zm8.367-.768a.268.268 0 0 0 .076-.292 2.942 2.942 0 0 0-.187-.407l-.055-.096a3.012 3.012 0 0 0-.262-.37.27.27 0 0 0-.29-.08l-.66.21a2.279 2.279 0 0 0-.522-.302l-.148-.676a.268.268 0 0 0-.215-.211 3.062 3.062 0 0 0-1.008.001.268.268 0 0 0-.215.21l-.148.677a2.28 2.28 0 0 0-.522.301l-.66-.21a.268.268 0 0 0-.29.081c-.096.116-.184.24-.262.37l-.056.096c-.072.13-.135.265-.187.406a.268.268 0 0 0 .076.292l.513.467a2.293 2.293 0 0 0 0 .603l-.513.467a.268.268 0 0 0-.076.291c.052.141.115.276.187.407l.056.096c.078.13.166.253.262.37a.27.27 0 0 0 .29.08l.66-.211c.158.122.333.224.52.3l.149.677a.268.268 0 0 0 .215.211 3.06 3.06 0 0 0 1.007 0 .268.268 0 0 0 .216-.21l.148-.677a2.28 2.28 0 0 0 .521-.301l.66.21c.105.033.22.004.29-.08.097-.117.184-.24.263-.37l.055-.097c.073-.13.135-.265.188-.406a.268.268 0 0 0-.076-.292l-.513-.466a2.299 2.299 0 0 0 0-.602l.513-.467Z"})]}),ki=({name:e,size:t=16,color:n="currentColor",strokeWidth:i=2,style:r})=>{if("iwer"===e)return c.jsx(Ni,{size:t,color:n,style:r});const a=Di[e];return a?c.jsx(a,{size:t,color:n,strokeWidth:i,style:r}):null},Fi={KeyA:"A",KeyB:"B",KeyC:"C",KeyD:"D",KeyE:"E",KeyF:"F",KeyG:"G",KeyH:"H",KeyI:"I",KeyJ:"J",KeyK:"K",KeyL:"L",KeyM:"M",KeyN:"N",KeyO:"O",KeyP:"P",KeyQ:"Q",KeyR:"R",KeyS:"S",KeyT:"T",KeyU:"U",KeyV:"V",KeyW:"W",KeyX:"X",KeyY:"Y",KeyZ:"Z",Digit0:"0",Digit1:"1",Digit2:"2",Digit3:"3",Digit4:"4",Digit5:"5",Digit6:"6",Digit7:"7",Digit8:"8",Digit9:"9",Tab:c.jsx(ki,{name:"arrow-right-to-line",size:15}),Backspace:c.jsx(ki,{name:"delete",size:15}),Enter:c.jsx(ki,{name:"corner-down-left",size:15}),ShiftLeft:c.jsx(ki,{name:"arrow-big-up",size:15}),ShiftRight:c.jsx(ki,{name:"arrow-big-up",size:15}),Space:" ",ArrowUp:c.jsx(ki,{name:"arrow-up",size:15}),ArrowDown:c.jsx(ki,{name:"arrow-down",size:15}),ArrowLeft:c.jsx(ki,{name:"arrow-left",size:15}),ArrowRight:c.jsx(ki,{name:"arrow-right",size:15}),Semicolon:";",Equal:"=",Comma:",",Minus:"-",Period:".",Slash:"/",Backquote:"`",BracketLeft:"[",Backslash:"\\",BracketRight:"]",Quote:"'",MouseLeft:c.jsx(ki,{name:"mouse-left",size:15}),MouseRight:c.jsx(ki,{name:"mouse-right",size:15})},Oi=e=>{let t;const n=new Set,i=(e,i)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=i?i:"object"!=typeof r||null===r)?r:Object.assign({},t,r),n.forEach(n=>n(t,e))}},r=()=>t,a={setState:i,getState:r,getInitialState:()=>s,subscribe:e=>(n.add(e),()=>n.delete(e))},s=t=e(i,r,a);return a},Ui=e=>e;const zi=e=>{const t=(e=>e?Oi(e):Oi)(e),n=e=>function(e,t=Ui){const n=l.useSyncExternalStore(e.subscribe,l.useCallback(()=>t(e.getState()),[e,t]),l.useCallback(()=>t(e.getInitialState()),[e,t]));return l.useDebugValue(n),n}(t,e);return Object.assign(n,t),n},Bi=e=>e?zi(e):zi;function Vi(e){if("undefined"==typeof window||!e)return;const t="null"===window.location.origin?"*":window.location.origin;window.postMessage({channel:"iwer-prefs",scope:"origin",patch:e},t)}const Hi={thumbstick:"Press",trigger:"Trig",squeeze:"Grip","x-button":"X","y-button":"Y","a-button":"A","b-button":"B",thumbrest:"Rest",pose:"Pose",pinch:"Pinch"},Gi=e=>{var t;return null!==(t=Hi[e])&&void 0!==t?t:e},Wi={"thumbstick-up":"arrow-up","thumbstick-down":"arrow-down","thumbstick-left":"arrow-left","thumbstick-right":"arrow-right"},ji=["thumbstick-up","thumbstick-down","thumbstick-left","thumbstick-right","thumbstick"],Xi=["trigger","squeeze","a-button","b-button","x-button","y-button","thumbrest","pose","pinch"],qi={left:{"thumbstick-up":"KeyW","thumbstick-down":"KeyS","thumbstick-left":"KeyA","thumbstick-right":"KeyD",thumbstick:"KeyR","x-button":"KeyX","y-button":"KeyZ",trigger:"KeyQ",squeeze:"KeyE",pinch:"MouseLeft",pose:"KeyF"},right:{"thumbstick-up":"ArrowUp","thumbstick-down":"ArrowDown","thumbstick-left":"ArrowLeft","thumbstick-right":"ArrowRight",thumbstick:"Slash","a-button":"Enter","b-button":"ShiftRight",trigger:"MouseLeft",squeeze:"MouseRight",pinch:"MouseRight",pose:"Backslash"}},$i=Bi(e=>({keyMap:qi,bindKey:(t,n,i="Unmapped")=>{Vi({keymap:{[t]:{[n]:i}}}),e(e=>({keyMap:{...e.keyMap,[t]:{...e.keyMap[t],[n]:i}}}))},resetKeyMap:t=>{const n={...qi[t]};Vi({keymap:{[t]:n}}),e(e=>({keyMap:{...e.keyMap,[t]:n}}))}})),Yi=Jt.div`
|
|
349
|
-
display: flex;
|
|
350
|
-
align-items: center;
|
|
351
|
-
gap: 6px;
|
|
352
|
-
padding: 6px 8px;
|
|
353
|
-
background-color: ${Dn};
|
|
354
|
-
border-radius: ${In};
|
|
355
|
-
margin-bottom: ${Cn};
|
|
356
|
-
color: ${nn};
|
|
357
|
-
font-size: 10px;
|
|
358
|
-
line-height: 1.3;
|
|
359
|
-
`,Ki=Jt.div`
|
|
360
|
-
font-size: 10px;
|
|
361
|
-
font-weight: 600;
|
|
362
|
-
letter-spacing: 0.5px;
|
|
363
|
-
text-transform: uppercase;
|
|
364
|
-
color: ${nn};
|
|
365
|
-
margin: 4px 0 1px;
|
|
366
|
-
`,Qi=Jt.div`
|
|
367
|
-
display: flex;
|
|
368
|
-
flex-direction: row;
|
|
369
|
-
align-items: center;
|
|
370
|
-
gap: ${Cn};
|
|
371
|
-
height: ${Ln};
|
|
372
|
-
margin-bottom: ${Cn};
|
|
373
|
-
`,Zi=Jt.div`
|
|
374
|
-
flex: none;
|
|
375
|
-
width: ${Rn};
|
|
376
|
-
height: ${Ln};
|
|
377
|
-
display: flex;
|
|
378
|
-
align-items: center;
|
|
379
|
-
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
380
|
-
font-size: 10px;
|
|
381
|
-
color: ${tn};
|
|
382
|
-
`,Ji=Jt.button`
|
|
383
|
-
flex: 1 1 auto;
|
|
384
|
-
height: ${Ln};
|
|
385
|
-
display: flex;
|
|
386
|
-
align-items: center;
|
|
387
|
-
justify-content: center;
|
|
388
|
-
gap: 4px;
|
|
389
|
-
border-radius: ${In};
|
|
390
|
-
border: 1px solid
|
|
391
|
-
${({$listening:e})=>e?sn:cn};
|
|
392
|
-
background-color: ${({$listening:e})=>e?kn:un};
|
|
393
|
-
color: ${({$listening:e})=>e?sn:en};
|
|
394
|
-
cursor: pointer;
|
|
395
|
-
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
396
|
-
font-size: 12px;
|
|
397
|
-
transition: all 0.12s ease;
|
|
398
|
-
|
|
399
|
-
&:hover {
|
|
400
|
-
background-color: ${({$listening:e})=>e?kn:dn};
|
|
401
|
-
}
|
|
402
|
-
&:focus {
|
|
403
|
-
outline: none;
|
|
404
|
-
}
|
|
405
|
-
`,er=Jt.button`
|
|
406
|
-
flex: none;
|
|
407
|
-
width: 24px;
|
|
408
|
-
height: 24px;
|
|
409
|
-
display: flex;
|
|
410
|
-
align-items: center;
|
|
411
|
-
justify-content: center;
|
|
412
|
-
border: none;
|
|
413
|
-
border-radius: 6px;
|
|
414
|
-
background-color: transparent;
|
|
415
|
-
color: ${tn};
|
|
416
|
-
cursor: pointer;
|
|
417
|
-
transition: all 0.12s ease;
|
|
418
|
-
|
|
419
|
-
&:hover {
|
|
420
|
-
background-color: rgba(255, 255, 255, 0.06);
|
|
421
|
-
color: ${en};
|
|
422
|
-
}
|
|
423
|
-
&:focus {
|
|
424
|
-
outline: none;
|
|
425
|
-
}
|
|
426
|
-
`,tr=Jt.button`
|
|
427
|
-
display: flex;
|
|
428
|
-
align-items: center;
|
|
429
|
-
justify-content: center;
|
|
430
|
-
gap: 6px;
|
|
431
|
-
width: 100%;
|
|
432
|
-
height: ${Ln};
|
|
433
|
-
border: none;
|
|
434
|
-
border-radius: ${In};
|
|
435
|
-
background-color: transparent;
|
|
436
|
-
color: ${tn};
|
|
437
|
-
cursor: pointer;
|
|
438
|
-
font-family:
|
|
439
|
-
system-ui,
|
|
440
|
-
-apple-system,
|
|
441
|
-
'Segoe UI',
|
|
442
|
-
Roboto,
|
|
443
|
-
sans-serif;
|
|
444
|
-
font-size: 12px;
|
|
445
|
-
transition: all 0.12s ease;
|
|
446
|
-
|
|
447
|
-
&:hover {
|
|
448
|
-
background-color: rgba(255, 255, 255, 0.06);
|
|
449
|
-
color: ${en};
|
|
450
|
-
}
|
|
451
|
-
&:focus {
|
|
452
|
-
outline: none;
|
|
453
|
-
}
|
|
454
|
-
`,nr=({handedness:e,actions:t})=>{var n;const{keyMap:i,bindKey:r,resetKeyMap:a}=$i(),[s,l]=o.useState(null);o.useEffect(()=>{if(!s)return;const t=t=>{Fi[t.code]&&(r(e,s,t.code),l(null))},n=t=>{const n=0===t.button?"MouseLeft":2===t.button?"MouseRight":null;n&&Fi[n]&&(r(e,s,n),l(null))},i=e=>e.preventDefault();return window.addEventListener("keydown",t),window.addEventListener("mousedown",n),window.addEventListener("contextmenu",i),()=>{window.removeEventListener("keydown",t),window.removeEventListener("mousedown",n),window.removeEventListener("contextmenu",i)}},[s,e,r]);const u=null!==(n=i[e])&&void 0!==n?n:{},d=Object.keys(u).filter(e=>t.includes(e)),h=ji.filter(e=>d.includes(e)),p=d.filter(e=>!e.startsWith("thumbstick")).sort((e,t)=>Xi.indexOf(e)-Xi.indexOf(t)),f=t=>{const n=Fi[u[t]];return c.jsxs(Qi,{children:[c.jsx(Zi,{children:Wi[t]?c.jsx(ki,{name:Wi[t],size:14}):Gi(t)}),c.jsx(Ji,{type:"button",$listening:s===t,onClick:()=>l(s===t?null:t),onContextMenu:e=>e.preventDefault(),title:"Click, then press a key or mouse button",children:s===t?"press a key…":null!=n?n:"—"}),c.jsx(er,{type:"button",onClick:()=>r(e,t),onContextMenu:e=>e.preventDefault(),title:"Clear binding",children:c.jsx(ki,{name:"ban",size:12})})]},t)};return c.jsxs(c.Fragment,{children:[c.jsx(Un,{}),c.jsxs(Yi,{children:[c.jsx(ki,{name:"keyboard",size:12}),"Click a binding, then press a key or mouse button"]}),h.length>0&&c.jsx(Ki,{children:"Thumbstick"}),h.map(f),p.length>0&&h.length>0&&c.jsx(Ki,{children:"Buttons"}),p.map(f),c.jsx(Un,{}),c.jsxs(tr,{type:"button",onClick:()=>a(e),children:[c.jsx(ki,{name:"rotate-ccw",size:12}),"Reset to defaults"]})]})},ir=Jt.div`
|
|
455
|
-
display: flex;
|
|
456
|
-
flex-direction: row;
|
|
457
|
-
align-items: flex-start;
|
|
458
|
-
gap: 0;
|
|
459
|
-
margin-bottom: ${Cn};
|
|
460
|
-
`,rr=Jt.div`
|
|
461
|
-
position: relative;
|
|
462
|
-
flex: none;
|
|
463
|
-
width: ${Pn};
|
|
464
|
-
height: ${Pn};
|
|
465
|
-
border-radius: 50%;
|
|
466
|
-
background-color: ${Dn};
|
|
467
|
-
box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
|
|
468
|
-
display: flex;
|
|
469
|
-
align-items: center;
|
|
470
|
-
justify-content: center;
|
|
471
|
-
`,ar=Jt.div`
|
|
472
|
-
position: absolute;
|
|
473
|
-
width: 18px;
|
|
474
|
-
height: 18px;
|
|
475
|
-
border-radius: 50%;
|
|
476
|
-
background-color: ${sn};
|
|
477
|
-
box-shadow: 0 0 8px ${on};
|
|
478
|
-
cursor: grab;
|
|
479
|
-
pointer-events: auto;
|
|
480
|
-
`,sr=Jt.div`
|
|
481
|
-
display: flex;
|
|
482
|
-
flex-direction: column;
|
|
483
|
-
gap: ${Cn};
|
|
484
|
-
flex: 1 1 auto;
|
|
485
|
-
/* Joystick occupies column 1 (= label-width's first field). Offset the X/Y
|
|
486
|
-
stack by one grid gap so the fields land exactly in columns 2 and 3,
|
|
487
|
-
lining up with the Position/Rotation fields above. */
|
|
488
|
-
margin-left: ${Cn};
|
|
489
|
-
`,or=Jt.div`
|
|
490
|
-
display: flex;
|
|
491
|
-
gap: ${Cn};
|
|
492
|
-
align-items: center;
|
|
493
|
-
`,lr=Jt.div`
|
|
494
|
-
position: relative;
|
|
495
|
-
display: inline-block;
|
|
496
|
-
height: ${Ln};
|
|
497
|
-
`,cr=Jt.div`
|
|
498
|
-
flex: 1 1 auto;
|
|
499
|
-
height: ${Ln};
|
|
500
|
-
border-radius: ${In};
|
|
501
|
-
display: flex;
|
|
502
|
-
align-items: center;
|
|
503
|
-
justify-content: center;
|
|
504
|
-
cursor: pointer;
|
|
505
|
-
user-select: none;
|
|
506
|
-
font-size: 11px;
|
|
507
|
-
color: ${en};
|
|
508
|
-
background-color: ${({$active:e})=>e?kn:Dn};
|
|
509
|
-
transition: background-color 0.12s ease;
|
|
510
|
-
`,ur=Jt.button`
|
|
511
|
-
flex: none;
|
|
512
|
-
width: 22px;
|
|
513
|
-
height: ${Ln};
|
|
514
|
-
display: flex;
|
|
515
|
-
align-items: center;
|
|
516
|
-
justify-content: center;
|
|
517
|
-
border: none;
|
|
518
|
-
border-radius: 6px;
|
|
519
|
-
cursor: pointer;
|
|
520
|
-
background-color: ${({$active:e})=>e?kn:"transparent"};
|
|
521
|
-
color: ${({$active:e})=>e?sn:tn};
|
|
522
|
-
|
|
523
|
-
&:hover {
|
|
524
|
-
background-color: rgba(255, 255, 255, 0.06);
|
|
525
|
-
}
|
|
526
|
-
&:focus {
|
|
527
|
-
outline: none;
|
|
528
|
-
}
|
|
529
|
-
`,dr=Jt.div`
|
|
530
|
-
flex: none;
|
|
531
|
-
display: flex;
|
|
532
|
-
align-items: center;
|
|
533
|
-
gap: ${Cn};
|
|
534
|
-
margin-left: ${Cn};
|
|
535
|
-
`,hr=({xrController:e,pointerLocked:t,buttonId:n,mappedKeyUp:i,mappedKeyDown:r,mappedKeyLeft:a,mappedKeyRight:s,mappedKeyPressed:l})=>{const u=o.useRef(null),d=o.useRef({x:0,y:0}),h=o.useRef(!1),[p,f]=o.useState({x:0,y:0}),[m,g]=o.useState(!1),[v,y]=o.useState(!1),x=o.useRef(!1);x.current=v;const[b,_]=o.useState(!1),[w,S]=o.useState({up:!1,down:!1,left:!1,right:!1,pressed:!1}),E=o.useRef(w);E.current=w;o.useEffect(()=>{const t=t=>{if(!h.current||!u.current)return;const i=t.clientX-d.current.x,r=t.clientY-d.current.y;let a=i,s=r;if(Math.sqrt(i*i+r*r)>16){const e=Math.atan2(r,i);a=16*Math.cos(e),s=16*Math.sin(e)}u.current.style.transform=`translate(${a}px, ${s}px)`;const o=a/16,l=s/16;e.updateAxes(n,o,l),f({x:o,y:l})},i=()=>{h.current&&(h.current=!1,u.current&&(u.current.style.transform="translate(0, 0)"),e.updateAxes(n,0,0),f({x:0,y:0}))};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",i),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i)}},[n,e]),o.useEffect(()=>{const t=()=>{m&&!x.current&&(g(!1),e.updateButtonValue(n,0))};return window.addEventListener("mouseup",t),()=>window.removeEventListener("mouseup",t)},[m,n,e]),o.useEffect(()=>{if(!t)return;const o=(t,o)=>{if(!t)return;const c={...E.current};let u=!1;t===i&&(c.up=o,u=!0),t===r&&(c.down=o,u=!0),t===a&&(c.left=o,u=!0),t===s&&(c.right=o,u=!0),t===l&&(c.pressed=o,u=!0,e.updateButtonValue(n,o?1:0)),u&&(S(c),(t=>{const i=(t.right?1:0)-(t.left?1:0),r=(t.down?1:0)-(t.up?1:0),a=Math.sqrt(i*i+r*r);0===a?e.updateAxes(n,0,0):e.updateAxes(n,i/a,r/a)})(c))},c=e=>0===e.button?"MouseLeft":2===e.button?"MouseRight":null,u=e=>o(e.code,!0),d=e=>o(e.code,!1),h=e=>o(c(e),!0),p=e=>o(c(e),!1);return window.addEventListener("keydown",u),window.addEventListener("keyup",d),window.addEventListener("mousedown",h),window.addEventListener("mouseup",p),()=>{window.removeEventListener("keydown",u),window.removeEventListener("keyup",d),window.removeEventListener("mousedown",h),window.removeEventListener("mouseup",p)}},[t,i,r,a,s,l,n,e]);return t?c.jsxs(c.Fragment,{children:[c.jsxs(Tn,{children:[c.jsx(An,{children:"Stick"}),c.jsx(Mn,{$pressed:w.up,children:Fi[i]}),c.jsx(Mn,{$pressed:w.pressed,children:Fi[l]})]}),c.jsxs(Tn,{children:[c.jsx(Mn,{$pressed:w.left,children:Fi[a]}),c.jsx(Mn,{$pressed:w.down,children:Fi[r]}),c.jsx(Mn,{$pressed:w.right,children:Fi[s]})]})]}):c.jsxs(ir,{children:[c.jsx(Fn,{children:"Stick"}),c.jsx(rr,{children:c.jsx(ar,{ref:u,onMouseDown:e=>{const t=u.current;if(!t)return;const n=t.getBoundingClientRect();d.current={x:n.left+n.width/2,y:n.top+n.height/2},h.current=!0,e.preventDefault()}})}),c.jsxs(sr,{children:[c.jsxs(or,{children:[c.jsxs(lr,{children:[c.jsx(Vn,{readOnly:!0,value:p.x.toFixed(2)}),c.jsx(Hn,{children:"X"})]}),c.jsxs(lr,{children:[c.jsx(Vn,{readOnly:!0,value:p.y.toFixed(2)}),c.jsx(Hn,{children:"Y"})]})]}),c.jsxs(or,{style:{gap:0},children:[c.jsx(cr,{$active:m||v,onMouseDown:()=>{v||(g(!0),e.updateButtonValue(n,1))},children:"click"}),c.jsxs(dr,{children:[c.jsx(ur,{$active:v,onClick:()=>{const t=!v;y(t),g(t),e.updateButtonValue(n,t?1:0)},type:"button",title:"Hold (latch)",children:c.jsx(ki,{name:"pin",size:12})}),c.jsx(ur,{$active:b,onClick:()=>{const t=!b;_(t),e.updateButtonTouch(n,t)},type:"button",title:"Toggle touch state",children:c.jsx(ki,{name:"circle-dot",size:12})})]})]})]})]})},pr=Jt.div`
|
|
536
|
-
display: flex;
|
|
537
|
-
flex-direction: row;
|
|
538
|
-
align-items: center;
|
|
539
|
-
gap: 0;
|
|
540
|
-
height: ${Ln};
|
|
541
|
-
margin-bottom: ${Cn};
|
|
542
|
-
|
|
543
|
-
&:last-child {
|
|
544
|
-
margin-bottom: 0;
|
|
545
|
-
}
|
|
546
|
-
`,fr=Jt.div`
|
|
547
|
-
flex: none;
|
|
548
|
-
display: flex;
|
|
549
|
-
align-items: center;
|
|
550
|
-
gap: ${Cn};
|
|
551
|
-
margin-left: ${Cn};
|
|
552
|
-
`,mr=Jt.div`
|
|
553
|
-
position: relative;
|
|
554
|
-
flex: 1 1 auto;
|
|
555
|
-
height: ${Ln};
|
|
556
|
-
border-radius: ${In};
|
|
557
|
-
cursor: pointer;
|
|
558
|
-
overflow: hidden;
|
|
559
|
-
display: flex;
|
|
560
|
-
align-items: center;
|
|
561
|
-
justify-content: center;
|
|
562
|
-
padding: 0 8px;
|
|
563
|
-
user-select: none;
|
|
564
|
-
background-color: ${({$active:e})=>e?kn:Dn};
|
|
565
|
-
transition: background-color 0.12s ease;
|
|
566
|
-
`,gr=Jt.div`
|
|
567
|
-
position: absolute;
|
|
568
|
-
left: 0;
|
|
569
|
-
top: 0;
|
|
570
|
-
bottom: 0;
|
|
571
|
-
background-color: ${Nn};
|
|
572
|
-
pointer-events: none;
|
|
573
|
-
`,vr=Jt.span`
|
|
574
|
-
position: relative;
|
|
575
|
-
z-index: 1;
|
|
576
|
-
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
577
|
-
font-size: 11px;
|
|
578
|
-
color: ${en};
|
|
579
|
-
pointer-events: none;
|
|
580
|
-
`,yr=Jt.button`
|
|
581
|
-
flex: none;
|
|
582
|
-
width: 22px;
|
|
583
|
-
height: ${Ln};
|
|
584
|
-
display: flex;
|
|
585
|
-
align-items: center;
|
|
586
|
-
justify-content: center;
|
|
587
|
-
border: none;
|
|
588
|
-
border-radius: 6px;
|
|
589
|
-
cursor: pointer;
|
|
590
|
-
background-color: ${({$active:e})=>e?kn:"transparent"};
|
|
591
|
-
color: ${({$active:e})=>e?sn:tn};
|
|
592
|
-
transition: all 0.12s ease;
|
|
593
|
-
|
|
594
|
-
&:hover {
|
|
595
|
-
background-color: rgba(255, 255, 255, 0.06);
|
|
596
|
-
}
|
|
597
|
-
&:focus {
|
|
598
|
-
outline: none;
|
|
599
|
-
}
|
|
600
|
-
`,xr=({label:e,analog:t,supportsTouch:n,mappedKey:i,pointerLocked:r,onValue:a,onTouch:s})=>{const[l,u]=o.useState(0),[d,h]=o.useState(!1),[p,f]=o.useState(!1),[m,g]=o.useState(!1),v=o.useRef(null),y=o.useRef(!1),x=o.useRef(!1);x.current=d;const b=e=>{const t=Math.min(1,Math.max(0,e));u(t),a(t)};o.useEffect(()=>{if(!r)return;const e=e=>{a(e?1:0),g(e)},t=e=>"MouseLeft"===i&&0===e.button||"MouseRight"===i&&2===e.button,n=t=>{t.code===i&&e(!0)},s=t=>{t.code===i&&e(!1)},o=n=>{t(n)&&e(!0)},l=n=>{t(n)&&e(!1)};return window.addEventListener("keydown",n),window.addEventListener("keyup",s),window.addEventListener("mousedown",o),window.addEventListener("mouseup",l),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",s),window.removeEventListener("mousedown",o),window.removeEventListener("mouseup",l)}},[i,r,a]),o.useEffect(()=>{const e=e=>{if(!y.current||!t||!v.current)return;const n=v.current.getBoundingClientRect();b((e.clientX-n.left)/n.width)},n=()=>{y.current&&(y.current=!1,x.current||b(0))};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",n),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",n)}},[t]);if(r)return c.jsxs(Tn,{children:[c.jsx(An,{children:e}),c.jsx(Mn,{$pressed:m,children:Fi[i]})]});const _=t?l.toFixed(2):d?"hold":"press";return c.jsxs(pr,{children:[c.jsx(Fn,{children:e}),c.jsxs(mr,{ref:v,$active:!t&&l>0,onMouseDown:()=>{d||(y.current=!0,b(1))},title:"Click to press; drag to set value",children:[t&&c.jsx(gr,{style:{width:100*l+"%"}}),c.jsx(vr,{children:_})]}),c.jsxs(fr,{children:[c.jsx(yr,{$active:d,onClick:()=>{const e=!d;h(e),b(e?l>0?l:1:0)},title:"Hold (latch)",type:"button",children:c.jsx(ki,{name:"pin",size:12})}),n&&c.jsx(yr,{$active:p,onClick:()=>{const e=!p;f(e),null==s||s(e)},title:"Toggle touch state",type:"button",children:c.jsx(ki,{name:"circle-dot",size:12})})]})]})};function br(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}const _r=Jt.div`
|
|
601
|
-
width: 100%;
|
|
602
|
-
display: flex;
|
|
603
|
-
flex-direction: row;
|
|
604
|
-
align-items: center;
|
|
605
|
-
margin-bottom: ${({$mb:e})=>null!=e?e:"0"};
|
|
606
|
-
`,wr=Jt.div`
|
|
607
|
-
position: relative;
|
|
608
|
-
display: inline-block;
|
|
609
|
-
height: 26px;
|
|
610
|
-
`,Sr=({vector:e,label:t="",multiplier:n=1,precision:i=2,onValidInput:r=()=>{},marginBottom:a="0"})=>{const[s,l]=o.useState({x:(e.x/n).toFixed(i),y:(e.y/n).toFixed(i),z:(e.z/n).toFixed(i)}),u=o.useRef({x:br(e.x/n,i),y:br(e.y/n,i),z:br(e.z/n,i)}),d=o.useRef(null),h=o.useRef({x:0,y:0,z:0}),p=()=>{const t=h.current;t.x=br(e.x/n,i),t.y=br(e.y/n,i),t.z=br(e.z/n,i);const{x:r,y:a,z:s}=u.current;t.x===r&&t.y===a&&t.z===s||(u.current={x:t.x,y:t.y,z:t.z},l({x:t.x.toFixed(i),y:t.y.toFixed(i),z:t.z.toFixed(i)})),d.current=requestAnimationFrame(p)};o.useEffect(()=>(d.current=requestAnimationFrame(p),()=>{d.current&&cancelAnimationFrame(d.current)}),[e,n,i]);const f=t=>i=>{const a=i.target.value,s=parseFloat(a);l(e=>({...e,[t]:a})),isNaN(s)||(u.current[t]=s,e[t]=s*n,r())};return c.jsxs(_r,{$mb:a,children:[c.jsx(Fn,{children:t}),c.jsx(Bn,{children:["x","y","z"].map(e=>c.jsxs(wr,{children:[c.jsx(Vn,{value:s[e],onChange:f(e),className:parseFloat(s[e])!==u.current[e]?"invalid":void 0}),c.jsx(Hn,{children:e.toUpperCase()})]},`${t}-${e}`))})]})},Er={thumbstick:"Stick",trigger:"Trig",squeeze:"Grip","a-button":"A","b-button":"B","x-button":"X","y-button":"Y",thumbrest:"Rest",menu:"Menu"};const Mr=({controller:e,handle:t,handedness:n,pointerLocked:i})=>{const{keyMap:r}=$i(),[a,s]=l.useState(e.connected),[o,u]=l.useState(!1),d=function(e){const t=new Set;for(const n of e.axes)n&&n.id&&t.add(n.id);const n=e.buttons.filter(e=>null!==e).map(e=>({id:e.id,type:e.type,hasAxes:t.has(e.id)}));return n.sort((e,t)=>e.hasAxes&&!t.hasAxes?-1:!e.hasAxes&&t.hasAxes?1:0),n}(e.gamepadConfig),h=d.flatMap(e=>e.hasAxes?[`${e.id}-left`,`${e.id}-right`,`${e.id}-up`,`${e.id}-down`,e.id]:e.id);return l.useEffect(()=>{i&&u(!1)},[i]),c.jsxs(On,{style:"left"===n?{left:"8px",bottom:"8px"}:{right:"8px",bottom:"8px"},children:[!i&&c.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[c.jsxs("div",{style:{fontSize:"14px",fontWeight:600,display:"flex",flexDirection:"row",alignItems:"center",gap:"6px"},children:[c.jsx(ki,{name:"gamepad-2",size:15}),"Controller [","left"===n?"L":"R","]"]}),c.jsx("div",{style:{display:"flex",flexDirection:"row",gap:"1px"},children:a?c.jsxs(c.Fragment,{children:[c.jsx(zn,{title:`Click to ${o?"close":"change"} key bindings`,onClick:()=>u(!o),children:c.jsx(ki,{name:"settings",size:14})}),c.jsx(zn,{title:`Click to disconnect ${n} controller`,$isRed:!0,onClick:()=>{e.connected=!1,s(!1)},children:c.jsx(ki,{name:"circle-x",size:14})})]}):c.jsx(zn,{title:`Click to reconnect ${n} controller`,onClick:()=>{e.connected=!0,s(!0)},style:{marginLeft:"5px"},children:c.jsx(ki,{name:"plug",size:14})})})]}),a&&!i&&c.jsxs(c.Fragment,{children:[!o&&c.jsxs(c.Fragment,{children:[c.jsx(Un,{}),c.jsx(Sr,{vector:t.position,label:"Pos",marginBottom:Cn}),c.jsx(Sr,{vector:t.rotation,label:"Rot"})]}),c.jsx(Un,{})]}),a&&(o?c.jsx(nr,{handedness:n,actions:h}):d.map(t=>{const a=r[n];return t.hasAxes?c.jsx(hr,{xrController:e,pointerLocked:i,buttonId:t.id,mappedKeyUp:a[`${t.id}-up`],mappedKeyDown:a[`${t.id}-down`],mappedKeyLeft:a[`${t.id}-left`],mappedKeyRight:a[`${t.id}-right`],mappedKeyPressed:a[t.id]},t.id):c.jsx(xr,{label:(s=t.id,Er[s]?Er[s]:s.charAt(0).toUpperCase()+s.slice(1).replace(/-button$/,"")),analog:"analog"===t.type,supportsTouch:!0,mappedKey:a[t.id],pointerLocked:i,onValue:n=>e.updateButtonValue(t.id,n),onTouch:n=>e.updateButtonTouch(t.id,n)},t.id);var s}))]},n)},Tr=["default","pinch","point"],Ar=Jt.div`
|
|
611
|
-
display: flex;
|
|
612
|
-
flex-direction: row;
|
|
613
|
-
align-items: center;
|
|
614
|
-
gap: 0;
|
|
615
|
-
height: ${Ln};
|
|
616
|
-
margin-bottom: ${Cn};
|
|
617
|
-
`,Rr=Jt.div`
|
|
618
|
-
flex: 1 1 auto;
|
|
619
|
-
display: flex;
|
|
620
|
-
flex-direction: row;
|
|
621
|
-
align-items: center;
|
|
622
|
-
gap: ${Cn};
|
|
623
|
-
height: ${Ln};
|
|
624
|
-
`,Pr=Jt.button`
|
|
625
|
-
flex: none;
|
|
626
|
-
width: 22px;
|
|
627
|
-
height: ${Ln};
|
|
628
|
-
display: flex;
|
|
629
|
-
align-items: center;
|
|
630
|
-
justify-content: center;
|
|
631
|
-
border: none;
|
|
632
|
-
border-radius: 6px;
|
|
633
|
-
cursor: pointer;
|
|
634
|
-
background-color: ${Dn};
|
|
635
|
-
color: ${tn};
|
|
636
|
-
|
|
637
|
-
&:hover {
|
|
638
|
-
color: ${en};
|
|
639
|
-
}
|
|
640
|
-
&:focus {
|
|
641
|
-
outline: none;
|
|
642
|
-
}
|
|
643
|
-
`,Cr=Jt.div`
|
|
644
|
-
flex: 1 1 auto;
|
|
645
|
-
height: ${Ln};
|
|
646
|
-
border-radius: ${In};
|
|
647
|
-
background-color: ${Dn};
|
|
648
|
-
display: flex;
|
|
649
|
-
align-items: center;
|
|
650
|
-
justify-content: center;
|
|
651
|
-
font-size: 11px;
|
|
652
|
-
color: ${en};
|
|
653
|
-
`,Lr=({hand:e,pointerLocked:t,mappedKey:n})=>{const[i,r]=o.useState(e.poseId),[a,s]=o.useState(!1),l=e.inputSource.handedness,u=t=>{const n=(Tr.indexOf(e.poseId)+Tr.length+t)%Tr.length;r(Tr[n]),e.poseId=Tr[n],Vi({handPoses:{[l]:Tr[n]}})};return o.useEffect(()=>{const e=e=>"MouseLeft"===n&&0===e.button||"MouseRight"===n&&2===e.button,i=e=>{e.repeat||e.code===n&&(u(1),s(!0))},r=e=>{e.code===n&&s(!1)},a=t=>{e(t)&&(u(1),s(!0))},o=t=>{e(t)&&s(!1)};return t&&(window.addEventListener("keydown",i),window.addEventListener("keyup",r),window.addEventListener("mousedown",a),window.addEventListener("mouseup",o)),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",r),window.removeEventListener("mousedown",a),window.removeEventListener("mouseup",o)}},[n,t,e]),t?c.jsxs(Tn,{children:[c.jsx(An,{children:"Pose"}),c.jsx(Mn,{$pressed:a,children:Fi[n]})]}):c.jsxs(Ar,{children:[c.jsx(Fn,{children:"Pose"}),c.jsxs(Rr,{children:[c.jsx(Pr,{type:"button",onClick:()=>u(-1),title:"Previous pose",children:c.jsx(ki,{name:"chevron-left",size:14})}),c.jsx(Cr,{children:i}),c.jsx(Pr,{type:"button",onClick:()=>u(1),title:"Next pose",children:c.jsx(ki,{name:"chevron-right",size:14})})]})]})},Ir=({hand:e,handle:t,handedness:n,pointerLocked:i})=>{const{keyMap:r}=$i(),[a,s]=l.useState(e.connected),[o,u]=l.useState(!1);return l.useEffect(()=>{i&&u(!1)},[i]),c.jsxs(On,{style:"left"===n?{left:"8px",bottom:"8px"}:{right:"8px",bottom:"8px"},children:[!i&&c.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[c.jsxs("div",{style:{fontSize:"14px",fontWeight:600,display:"flex",flexDirection:"row",alignItems:"center",gap:"6px"},children:[c.jsx(ki,{name:"hand",size:15}),"Hand [","left"===n?"L":"R","]"]}),c.jsx("div",{style:{display:"flex",flexDirection:"row",gap:"1px"},children:a?c.jsxs(c.Fragment,{children:[c.jsx(zn,{title:`Click to ${o?"close":"change"} key bindings`,onClick:()=>u(!o),children:c.jsx(ki,{name:"settings",size:14})}),c.jsx(zn,{title:`Click to disconnect ${n} hand`,$isRed:!0,onClick:()=>{e.connected=!1,s(!1)},children:c.jsx(ki,{name:"circle-x",size:14})})]}):c.jsx(zn,{title:`Click to reconnect ${n} hand`,onClick:()=>{e.connected=!0,s(!0)},style:{marginLeft:"5px"},children:c.jsx(ki,{name:"plug",size:14})})})]}),a&&!i&&c.jsxs(c.Fragment,{children:[!o&&c.jsxs(c.Fragment,{children:[c.jsx(Un,{}),c.jsx(Sr,{vector:t.position,label:"Pos",marginBottom:Cn}),c.jsx(Sr,{vector:t.rotation,label:"Rot"})]}),c.jsx(Un,{})]}),a&&(o?c.jsx(nr,{handedness:n,actions:["pose","pinch"]}):c.jsxs(c.Fragment,{children:[c.jsx(Lr,{hand:e,pointerLocked:i,mappedKey:r[n].pose}),c.jsx(xr,{label:"Pinch",analog:!0,supportsTouch:!1,mappedKey:r[n].pinch,pointerLocked:i,onValue:t=>e.updatePinchValue(t)})]}))]},n)},Dr=Bi(e=>({inputMode:"controller",setInputMode:t=>e(()=>({inputMode:t}))})),Nr=({xrDevice:e,inputLayer:t,pointerLocked:n})=>{const i=Dr(e=>e.inputMode);return c.jsx(c.Fragment,{children:"controller"===i?Object.entries(e.controllers).map(([e,i])=>c.jsx(Mr,{controller:i,handle:t.transformHandles.get(e),handedness:e,pointerLocked:n},`controller-${e}`)):Object.entries(e.hands).map(([e,i])=>c.jsx(Ir,{hand:i,handle:t.transformHandles.get(e),handedness:e,pointerLocked:n},`hand-${e}`))})};var kr=1e-6,Fr="undefined"!=typeof Float32Array?Float32Array:Array;function Or(){var e=new Fr(16);return Fr!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Ur(e){var t=new Fr(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function zr(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Br(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Vr(e,t){var n=t[0],i=t[1],r=t[2],a=t[3],s=t[4],o=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],y=n*o-i*s,x=n*l-r*s,b=n*c-a*s,_=i*l-r*o,w=i*c-a*o,S=r*c-a*l,E=u*m-d*f,M=u*g-h*f,T=u*v-p*f,A=d*g-h*m,R=d*v-p*m,P=h*v-p*g,C=y*P-x*R+b*A+_*T-w*M+S*E;return C?(C=1/C,e[0]=(o*P-l*R+c*A)*C,e[1]=(r*R-i*P-a*A)*C,e[2]=(m*S-g*w+v*_)*C,e[3]=(h*w-d*S-p*_)*C,e[4]=(l*T-s*P-c*M)*C,e[5]=(n*P-r*T+a*M)*C,e[6]=(g*b-f*S-v*x)*C,e[7]=(u*S-h*b+p*x)*C,e[8]=(s*R-o*T+c*E)*C,e[9]=(i*T-n*R-a*E)*C,e[10]=(f*w-m*b+v*y)*C,e[11]=(d*b-u*w-p*y)*C,e[12]=(o*M-s*A-l*E)*C,e[13]=(n*A-i*M+r*E)*C,e[14]=(m*x-f*_-g*y)*C,e[15]=(u*_-d*x+h*y)*C,e):null}function Hr(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],y=t[15],x=n[0],b=n[1],_=n[2],w=n[3];return e[0]=x*i+b*o+_*d+w*m,e[1]=x*r+b*l+_*h+w*g,e[2]=x*a+b*c+_*p+w*v,e[3]=x*s+b*u+_*f+w*y,x=n[4],b=n[5],_=n[6],w=n[7],e[4]=x*i+b*o+_*d+w*m,e[5]=x*r+b*l+_*h+w*g,e[6]=x*a+b*c+_*p+w*v,e[7]=x*s+b*u+_*f+w*y,x=n[8],b=n[9],_=n[10],w=n[11],e[8]=x*i+b*o+_*d+w*m,e[9]=x*r+b*l+_*h+w*g,e[10]=x*a+b*c+_*p+w*v,e[11]=x*s+b*u+_*f+w*y,x=n[12],b=n[13],_=n[14],w=n[15],e[12]=x*i+b*o+_*d+w*m,e[13]=x*r+b*l+_*h+w*g,e[14]=x*a+b*c+_*p+w*v,e[15]=x*s+b*u+_*f+w*y,e}function Gr(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Wr(e,t,n){var i,r,a,s=n[0],o=n[1],l=n[2],c=Math.sqrt(s*s+o*o+l*l);return c<kr?null:(s*=c=1/c,o*=c,l*=c,i=Math.sin(t),a=1-(r=Math.cos(t)),e[0]=s*s*a+r,e[1]=o*s*a+l*i,e[2]=l*s*a-o*i,e[3]=0,e[4]=s*o*a-l*i,e[5]=o*o*a+r,e[6]=l*o*a+s*i,e[7]=0,e[8]=s*l*a+o*i,e[9]=o*l*a-s*i,e[10]=l*l*a+r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function jr(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=i+i,l=r+r,c=a+a,u=i*o,d=i*l,h=i*c,p=r*l,f=r*c,m=a*c,g=s*o,v=s*l,y=s*c;return e[0]=1-(p+m),e[1]=d+y,e[2]=h-v,e[3]=0,e[4]=d-y,e[5]=1-(u+m),e[6]=f+g,e[7]=0,e[8]=h+v,e[9]=f-g,e[10]=1-(u+p),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Xr(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function qr(e,t){var n=t[0],i=t[1],r=t[2],a=t[4],s=t[5],o=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(n*n+i*i+r*r),e[1]=Math.sqrt(a*a+s*s+o*o),e[2]=Math.sqrt(l*l+c*c+u*u),e}function $r(e,t){var n=new Fr(3);qr(n,t);var i=1/n[0],r=1/n[1],a=1/n[2],s=t[0]*i,o=t[1]*r,l=t[2]*a,c=t[4]*i,u=t[5]*r,d=t[6]*a,h=t[8]*i,p=t[9]*r,f=t[10]*a,m=s+u+f,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(d-p)/g,e[1]=(h-l)/g,e[2]=(o-c)/g):s>u&&s>f?(g=2*Math.sqrt(1+s-u-f),e[3]=(d-p)/g,e[0]=.25*g,e[1]=(o+c)/g,e[2]=(h+l)/g):u>f?(g=2*Math.sqrt(1+u-s-f),e[3]=(h-l)/g,e[0]=(o+c)/g,e[1]=.25*g,e[2]=(d+p)/g):(g=2*Math.sqrt(1+f-s-u),e[3]=(o-c)/g,e[0]=(h+l)/g,e[1]=(d+p)/g,e[2]=.25*g),e}var Yr=function(e,t,n,i,r){var a=1/Math.tan(t/2);if(e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0){var s=1/(i-r);e[10]=(r+i)*s,e[14]=2*r*i*s}else e[10]=-1,e[14]=-2*i;return e};function Kr(){var e=new Fr(3);return Fr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Qr(e,t,n){var i=new Fr(3);return i[0]=e,i[1]=t,i[2]=n,i}function Zr(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Jr(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function ea(e,t){var n=t[0],i=t[1],r=t[2],a=n*n+i*i+r*r;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e}function ta(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function na(e,t,n){var i=t[0],r=t[1],a=t[2],s=n[0],o=n[1],l=n[2];return e[0]=r*l-a*o,e[1]=a*s-i*l,e[2]=i*o-r*s,e}function ia(e,t,n,i){var r=t[0],a=t[1],s=t[2];return e[0]=r+i*(n[0]-r),e[1]=a+i*(n[1]-a),e[2]=s+i*(n[2]-s),e}function ra(){var e=new Fr(4);return Fr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function aa(e,t,n,i,r){return e[0]=t,e[1]=n,e[2]=i,e[3]=r,e}function sa(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3];return e[0]=n[0]*i+n[4]*r+n[8]*a+n[12]*s,e[1]=n[1]*i+n[5]*r+n[9]*a+n[13]*s,e[2]=n[2]*i+n[6]*r+n[10]*a+n[14]*s,e[3]=n[3]*i+n[7]*r+n[11]*a+n[15]*s,e}function oa(){var e=new Fr(4);return Fr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function la(e,t,n){n*=.5;var i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function ca(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=n[0],l=n[1],c=n[2],u=n[3];return e[0]=i*u+s*o+r*c-a*l,e[1]=r*u+s*l+a*o-i*c,e[2]=a*u+s*c+i*l-r*o,e[3]=s*u-i*o-r*l-a*c,e}function ua(e,t,n,i){var r,a,s,o,l,c=t[0],u=t[1],d=t[2],h=t[3],p=n[0],f=n[1],m=n[2],g=n[3];return(a=c*p+u*f+d*m+h*g)<0&&(a=-a,p=-p,f=-f,m=-m,g=-g),1-a>kr?(r=Math.acos(a),s=Math.sin(r),o=Math.sin((1-i)*r)/s,l=Math.sin(i*r)/s):(o=1-i,l=i),e[0]=o*c+l*p,e[1]=o*u+l*f,e[2]=o*d+l*m,e[3]=o*h+l*g,e}Kr(),function(){var e=ra()}();var da,ha=function(e,t,n,i){var r=new Fr(4);return r[0]=e,r[1]=t,r[2]=n,r[3]=i,r},pa=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},fa=aa,ma=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},ga=function(e,t){var n=t[0],i=t[1],r=t[2],a=t[3],s=n*n+i*i+r*r+a*a;return s>0&&(s=1/Math.sqrt(s)),e[0]=n*s,e[1]=i*s,e[2]=r*s,e[3]=a*s,e};Kr(),Qr(1,0,0),Qr(0,1,0),oa(),oa(),da=new Fr(9),Fr!=Float32Array&&(da[1]=0,da[2]=0,da[3]=0,da[5]=0,da[6]=0,da[7]=0),da[0]=1,da[4]=1,da[8]=1;const va=Symbol("@iwer/action-player"),ya=Symbol("@iwer/xr-anchor"),xa=Symbol("@iwer/xr-controller"),ba=Symbol("@iwer/xr-device"),_a=Symbol("@iwer/xr-hand-input"),wa=Symbol("@iwer/xr-tracked-input"),Sa=Symbol("@iwer/xr-frame"),Ea=Symbol("@iwer/gamepad"),Ma=Symbol("@iwer/xr-system"),Ta=Symbol("@iwer/xr-input-source"),Aa=Symbol("@iwer/xr-webgl-layer"),Ra=Symbol("@iwer/xr-mesh"),Pa=Symbol("@iwer/xr-plane"),Ca=Symbol("@iwer/xr-joint-pose"),La=Symbol("@iwer/xr-pose"),Ia=Symbol("@iwer/xr-viewer-pose"),Da=Symbol("@iwer/xr-rigid-transform"),Na=Symbol("@iwer/xr-render-state"),ka=Symbol("@iwer/xr-session"),Fa=Symbol("@iwer/xr-joint-space"),Oa=Symbol("@iwer/xr-reference-space"),Ua=Symbol("@iwer/xr-space"),za=Symbol("@iwer/xr-view"),Ba=Symbol("@iwer/xr-viewport"),Va=Symbol("@iwer/xr-ray"),Ha=Symbol("@iwer/xr-depth-info"),Ga=Symbol("@iwer/xr-hit-test"),Wa=Kr();class ja extends EventTarget{constructor(e,t){super(),this[Ua]={parentSpace:e,offsetMatrix:t?Ur(t):Or(),emulated:!0}}}class Xa extends ja{constructor(){super(void 0,Or())}}class qa{static updateOffsetPosition(e,t){Gr(e[Ua].offsetMatrix,t)}static updateOffsetQuaternion(e,t){const n=e[Ua].offsetMatrix;Xr(Wa,n),jr(n,t,Wa)}static updateOffsetMatrix(e,t){zr(e[Ua].offsetMatrix,t)}static calculateGlobalOffsetMatrix(e,t=Or()){const n=[];let i=e;for(;i;)n.push(i),i=i[Ua].parentSpace;Br(t);for(let e=n.length-1;e>=0;e--)Hr(t,t,n[e][Ua].offsetMatrix);return t}}let $a=class e{constructor(e=0,t=0,n=0){this.vec3=Qr(e,t,n),this.tempVec3=Kr()}get x(){return this.vec3[0]}set x(e){this.vec3[0]=e}get y(){return this.vec3[1]}set y(e){this.vec3[1]=e}get z(){return this.vec3[2]}set z(e){this.vec3[2]=e}set(e,t,n){return Jr(this.vec3,e,t,n),this}clone(){return new e(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}normalize(){return Zr(this.tempVec3,this.vec3),ea(this.vec3,this.tempVec3),this}add(e){return Zr(this.tempVec3,this.vec3),function(e,t,n){e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2]}(this.vec3,this.tempVec3,e.vec3),this}applyQuaternion(e){return Zr(this.tempVec3,this.vec3),function(e,t,n){var i=n[0],r=n[1],a=n[2],s=n[3],o=t[0],l=t[1],c=t[2],u=r*c-a*l,d=a*o-i*c,h=i*l-r*o;u+=u,d+=d,h+=h,e[0]=o+s*u+r*h-a*d,e[1]=l+s*d+a*u-i*h,e[2]=c+s*h+i*d-r*u}(this.vec3,this.tempVec3,e.quat),this}},Ya=class e{constructor(e=0,t=0,n=0,i=1){this.quat=ha(e,t,n,i),this.tempQuat=oa()}get x(){return this.quat[0]}set x(e){this.quat[0]=e}get y(){return this.quat[1]}set y(e){this.quat[1]=e}get z(){return this.quat[2]}set z(e){this.quat[2]=e}get w(){return this.quat[3]}set w(e){this.quat[3]=e}set(e,t,n,i){return fa(this.quat,e,t,n,i),this}clone(){return new e(this.x,this.y,this.z,this.w)}copy(e){return fa(this.quat,e.x,e.y,e.z,e.w),this}normalize(){return pa(this.tempQuat,this.quat),ga(this.quat,this.tempQuat),this}invert(){return pa(this.tempQuat,this.quat),function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this.quat,this.tempQuat),this}multiply(e){return pa(this.tempQuat,this.quat),ca(this.quat,this.tempQuat,e.quat),this}setFromAxisAngle(e,t){return la(this.quat,e.vec3,t),this}};function Ka(e){return{x:e.x,y:e.y,z:e.z}}function Qa(e){return{x:e.x,y:e.y,z:e.z,w:e.w}}function Za(e){const{x:t,y:n,z:i,w:r}=e,a=180/Math.PI,s=Math.max(-1,Math.min(1,2*(r*t-n*i)));let o;o=Math.abs(s)>=1?Math.sign(s)*Math.PI/2:Math.asin(s);const l=2*(r*n+t*i),c=1-2*(t*t+n*n),u=2*(r*i+t*n),d=1-2*(t*t+i*i);return{pitch:o*a,yaw:Math.atan2(l,c)*a,roll:Math.atan2(u,d)*a}}function Ja(e){return function(e){return"pitch"in e||"yaw"in e||"roll"in e}(e)?function(e){var t,n,i;const r=Math.PI/180,a=(null!==(t=e.pitch)&&void 0!==t?t:0)*r,s=(null!==(n=e.yaw)&&void 0!==n?n:0)*r,o=(null!==(i=e.roll)&&void 0!==i?i:0)*r,l=Math.cos(.5*a),c=Math.sin(.5*a),u=Math.cos(.5*s),d=Math.sin(.5*s),h=Math.cos(.5*o),p=Math.sin(.5*o);return{w:l*u*h+c*d*p,x:c*u*h+l*d*p,y:l*d*h-c*u*p,z:l*u*p-c*d*h}}(e):e}function es(e,t,n){return e+(t-e)*n}const ts={right:"controller-right",left:"controller-left","right-controller":"controller-right","left-controller":"controller-left","controllers.right":"controller-right","controllers.left":"controller-left",rightController:"controller-right",leftController:"controller-left","right-hand":"hand-right","left-hand":"hand-left","hands.right":"hand-right","hands.left":"hand-left",rightHand:"hand-right",leftHand:"hand-left"};function ns(e){var t;return null!==(t=ts[e])&&void 0!==t?t:e}const is=.15;function rs(e){switch(e){case"controller-left":case"controller-right":case"hand-left":case"hand-right":return e;default:throw new Error(`Unsupported select device: ${String(e)}`)}}const as=oa(),ss=oa(),os=oa();function ls(e){return"number"==typeof e&&Number.isFinite(e)}function cs(e,t,n){return Math.min(n,Math.max(t,e))}function us(e){if(!ls(e.x)||!ls(e.y)||!ls(e.z))throw new Error(`Invalid position: x, y, z must be finite numbers (got ${JSON.stringify(e)}).`)}function ds(e){if(!(ls(e.x)&&ls(e.y)&&ls(e.z)&&ls(e.w)))throw new Error(`Invalid orientation: x, y, z, w must be finite numbers (got ${JSON.stringify(e)}).`);const t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w);if(t<1e-6)throw new Error("Invalid orientation: quaternion has near-zero length.");return{x:e.x/t,y:e.y/t,z:e.z/t,w:e.w/t}}class hs{constructor(e){this.commandQueue=[],this._isCaptured=!1,this.releaseTimer=null,this.actionIdCounter=0,this.RELEASE_TIMEOUT_MS=3e4,this.ACTION_TIMEOUT_MS=1e4,this.actionTimers=new WeakMap,this.device=e}generateActionId(){return"action_"+ ++this.actionIdCounter}get isCaptured(){return this._isCaptured}get queueLength(){return this.commandQueue.length}enqueueDiscrete(e,t){return new Promise((n,i)=>{const r={type:"discrete",id:this.generateActionId(),method:e,params:t,resolve:n,reject:i};this.commandQueue.push(r),this.armActionTimeout(r,e)})}enqueueDuration(e,t,n,i,r){return new Promise((a,s)=>{const o={type:"duration",id:this.generateActionId(),method:e,params:t,durationMs:n,elapsedMs:0,startState:i,targetState:r,resolve:a,reject:s};this.commandQueue.push(o),this.armActionTimeout(o,e,n)})}armActionTimeout(e,t,n=0){const i=this.ACTION_TIMEOUT_MS+n,r=setTimeout(()=>{const n=this.commandQueue.indexOf(e);-1!==n&&(this.commandQueue.splice(n,1),this.actionTimers.delete(e),e.reject(new Error(`RemoteControlInterface: action '${t}' timed out after ${i}ms with no frame processing the queue (is the XR render loop running?).`)))},i);this.actionTimers.set(e,r)}clearActionTimeout(e){const t=this.actionTimers.get(e);void 0!==t&&(clearTimeout(t),this.actionTimers.delete(e))}update(e){if(0!==this.commandQueue.length){for(this.cancelReleaseTimer(),this._isCaptured||(this._isCaptured=!0,this.device.controlMode="programmatic");this.commandQueue.length>0;){const t=this.commandQueue[0];if("discrete"===t.type){try{const e=this.executeDiscreteAction(t);t.resolve(e)}catch(e){t.reject(e)}this.clearActionTimeout(t),this.commandQueue.shift()}else{if(t.elapsedMs+=e,!(t.elapsedMs>=t.durationMs)){try{const e=t.elapsedMs/t.durationMs;this.applyDurationLerpState(t,e)}catch(e){t.reject(e),this.clearActionTimeout(t),this.commandQueue.shift();continue}break}try{this.applyDurationFinalState(t),t.resolve(this.getDurationResult(t))}catch(e){t.reject(e)}this.clearActionTimeout(t),this.commandQueue.shift()}}this.device.notifyStateChange(),0===this.commandQueue.length&&this.startReleaseTimer()}}startReleaseTimer(){this.cancelReleaseTimer(),this.releaseTimer=setTimeout(()=>{this._isCaptured=!1,this.device.controlMode="manual",this.releaseTimer=null},this.RELEASE_TIMEOUT_MS)}cancelReleaseTimer(){null!==this.releaseTimer&&(clearTimeout(this.releaseTimer),this.releaseTimer=null)}getDeviceTransform(e){switch(e){case"headset":return{position:Ka(this.device.position),orientation:Qa(this.device.quaternion)};case"controller-left":{const e=this.device.controllers.left;if(!e)throw new Error("Left controller not available");return{position:Ka(e.position),orientation:Qa(e.quaternion)}}case"controller-right":{const e=this.device.controllers.right;if(!e)throw new Error("Right controller not available");return{position:Ka(e.position),orientation:Qa(e.quaternion)}}case"hand-left":{const e=this.device.hands.left;if(!e)throw new Error("Left hand not available");return{position:Ka(e.position),orientation:Qa(e.quaternion)}}case"hand-right":{const e=this.device.hands.right;if(!e)throw new Error("Right hand not available");return{position:Ka(e.position),orientation:Qa(e.quaternion)}}case"gaze":{const e=this.device.gaze;if(!e)throw new Error("Gaze input not available");return ca(as,this.device.quaternion.quat,e.quaternion.quat),{position:Ka(this.device.position),orientation:{x:as[0],y:as[1],z:as[2],w:as[3]}}}default:throw new Error(`Unknown device: ${e}`)}}setDeviceTransform(e,t,n){if("gaze"===e&&t)throw new Error("Gaze position is derived from the headset. Move the headset transform instead.");t&&us(t);const i=n?ds(n):void 0;switch(e){case"headset":t&&this.device.position.set(t.x,t.y,t.z),i&&this.device.quaternion.set(i.x,i.y,i.z,i.w);break;case"controller-left":{const e=this.device.controllers.left;if(!e)throw new Error("Left controller not available");t&&e.position.set(t.x,t.y,t.z),i&&e.quaternion.set(i.x,i.y,i.z,i.w);break}case"controller-right":{const e=this.device.controllers.right;if(!e)throw new Error("Right controller not available");t&&e.position.set(t.x,t.y,t.z),i&&e.quaternion.set(i.x,i.y,i.z,i.w);break}case"hand-left":{const e=this.device.hands.left;if(!e)throw new Error("Left hand not available");t&&e.position.set(t.x,t.y,t.z),i&&e.quaternion.set(i.x,i.y,i.z,i.w);break}case"hand-right":{const e=this.device.hands.right;if(!e)throw new Error("Right hand not available");t&&e.position.set(t.x,t.y,t.z),i&&e.quaternion.set(i.x,i.y,i.z,i.w);break}case"gaze":{const e=this.device.gaze;if(!e)throw new Error("Gaze input not available");i&&(!function(e,t){var n=t[0],i=t[1],r=t[2],a=t[3],s=n*n+i*i+r*r+a*a,o=s?1/s:0;e[0]=-n*o,e[1]=-i*o,e[2]=-r*o,e[3]=a*o}(ss,this.device.quaternion.quat),fa(as,i.x,i.y,i.z,i.w),ca(os,ss,as),e.quaternion.set(os[0],os[1],os[2],os[3]));break}default:throw new Error(`Unknown device: ${e}`)}}transformXROriginToGlobal(e){const t=this.device[ba].runtime.getSession();if(!t)return e;const n=t.originOffsetMatrix;if(!n)return e;const i=Qr(e.x,e.y,e.z);return function(e,t,n){var i=t[0],r=t[1],a=t[2],s=n[3]*i+n[7]*r+n[11]*a+n[15];s=s||1,e[0]=(n[0]*i+n[4]*r+n[8]*a+n[12])/s,e[1]=(n[1]*i+n[5]*r+n[9]*a+n[13])/s,e[2]=(n[2]*i+n[6]*r+n[10]*a+n[14])/s}(i,i,n),{x:i[0],y:i[1],z:i[2]}}getDeviceSelectValue(e){var t,n,i,r,a,s,o,l;switch(e){case"controller-left":return null!==(n=null===(t=this.device.controllers.left)||void 0===t?void 0:t.getButtonValue("trigger"))&&void 0!==n?n:0;case"controller-right":return null!==(r=null===(i=this.device.controllers.right)||void 0===i?void 0:i.getButtonValue("trigger"))&&void 0!==r?r:0;case"hand-left":return null!==(s=null===(a=this.device.hands.left)||void 0===a?void 0:a.pinchValue)&&void 0!==s?s:0;case"hand-right":return null!==(l=null===(o=this.device.hands.right)||void 0===o?void 0:o.pinchValue)&&void 0!==l?l:0;default:throw new Error(`Unknown input device: ${e}`)}}setDeviceSelectValue(e,t){var n,i,r,a;switch(e){case"controller-left":null===(n=this.device.controllers.left)||void 0===n||n.updateButtonValue("trigger",t);break;case"controller-right":null===(i=this.device.controllers.right)||void 0===i||i.updateButtonValue("trigger",t);break;case"hand-left":null===(r=this.device.hands.left)||void 0===r||r.updatePinchValue(t);break;case"hand-right":null===(a=this.device.hands.right)||void 0===a||a.updatePinchValue(t);break;default:throw new Error(`Unknown input device: ${e}`)}}setDeviceConnected(e,t){switch(e){case"controller-left":this.device.controllers.left&&(this.device.controllers.left.connected=t);break;case"controller-right":this.device.controllers.right&&(this.device.controllers.right.connected=t);break;case"hand-left":this.device.hands.left&&(this.device.hands.left.connected=t);break;case"hand-right":this.device.hands.right&&(this.device.hands.right.connected=t);break;case"gaze":if(!this.device.gaze)throw new Error("Gaze input not available");this.device.gaze.connected=t;break;default:throw new Error(`Unknown input device: ${e}`)}}executeDiscreteAction(e){const{method:t,params:n}=e;switch(t){case"get_session_status":return this.executeGetSessionStatus();case"accept_session":return this.executeAcceptSession();case"end_session":return this.executeEndSession();case"get_transform":return this.executeGetTransform(n);case"set_transform":return this.executeSetTransform(n);case"look_at":return this.executeLookAt(n);case"set_input_mode":return this.executeSetInputMode(n);case"set_connected":return this.executeSetConnected(n);case"get_select_value":return this.executeGetSelectValue(n);case"set_select_value":return this.executeSetSelectValue(n);case"set_hand_pose":return this.executeSetHandPose(n);case"get_gamepad_state":return this.executeGetGamepadState(n);case"set_gamepad_state":return this.executeSetGamepadState(n);case"get_device_state":return this.executeGetDeviceState();case"set_device_state":return this.executeSetDeviceState(n);case"_select_press":{const e=rs(n.device);return void this.setDeviceSelectValue(e,1)}case"_select_release":{const e=rs(n.device);return void this.setDeviceSelectValue(e,0)}default:throw new Error(`Unknown method: ${t}`)}}executeGetSessionStatus(){var e,t;const n=this.device[ba].runtime,i=n.getSession();return{deviceName:this.device.name,isRuntimeInstalled:!0,sessionActive:!!i,sessionOffered:"emulated"===n.kind&&this.device.sessionOffered,sessionMode:null!==(e=null==i?void 0:i.mode)&&void 0!==e?e:null,enabledFeatures:i?Array.from(i.enabledFeatures):[],visibilityState:null!==(t=null==i?void 0:i.visibilityState)&&void 0!==t?t:this.device.visibilityState,runtimeKind:n.kind}}executeAcceptSession(){if("native"===this.device[ba].runtime.kind)throw new Error("Session start is app-driven in native override mode; immersive sessions require a user gesture.");if(!this.device.sessionOffered)throw new Error("No session has been offered");return this.device.grantOfferedSession(),{success:!0}}executeEndSession(){const e=this.device[ba].runtime.getSession();if(!e)throw new Error("No active session");return e.end(),{success:!0}}executeGetTransform(e){const{device:t}=e,n=this.getDeviceTransform(t);return{device:t,position:n.position,orientation:n.orientation,euler:Za(n.orientation)}}executeSetTransform(e){const{device:t,position:n,orientation:i}=e,r=i?Ja(i):void 0;this.setDeviceTransform(t,n,r);const a=this.getDeviceTransform(t);return{device:t,position:a.position,orientation:a.orientation}}executeLookAt(e){const{device:t,target:n,moveToDistance:i}=e;if("gaze"===t&&void 0!==i)throw new Error("Gaze origin is derived from the headset; moveToDistance is not supported for gaze.");const r=this.getDeviceTransform(t),a=this.transformXROriginToGlobal(n),s=function(e,t){const n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,a=Math.sqrt(n*n+i*i+r*r);return 0===a?{x:0,y:0,z:-1}:{x:n/a,y:i/a,z:r/a}}(r.position,a),o="headset"===t?function(e){const t=Math.sqrt(e.x*e.x+e.z*e.z);let n=0;t>1e-4&&(n=Math.atan2(-e.x,-e.z));const i=Math.atan2(e.y,t),r=Math.cos(.5*i),a=Math.sin(.5*i),s=Math.cos(.5*n),o=Math.sin(.5*n);return{w:r*s,x:a*s,y:r*o,z:-a*o}}(s):function(e,t={x:0,y:1,z:0}){const n=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);if(0===n)return{x:0,y:0,z:0,w:1};const i=e.x/n,r=e.y/n,a=e.z/n,s={x:r*t.z-a*t.y,y:a*t.x-i*t.z,z:i*t.y-r*t.x},o=Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z);if(0===o){const e={x:1,y:0,z:0};s.x=r*e.z-a*e.y,s.y=a*e.x-i*e.z,s.z=i*e.y-r*e.x;const t=Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z);s.x/=t,s.y/=t,s.z/=t}else s.x/=o,s.y/=o,s.z/=o;const l={x:s.y*a-s.z*r,y:s.z*i-s.x*a,z:s.x*r-s.y*i},c=s.x,u=l.x,d=-i,h=s.y,p=l.y,f=-r,m=s.z,g=l.z,v=-a,y=c+p+v;let x,b,_,w;if(y>0){const e=.5/Math.sqrt(y+1);x=.25/e,b=(g-f)*e,_=(d-m)*e,w=(h-u)*e}else if(c>p&&c>v){const e=2*Math.sqrt(1+c-p-v);x=(g-f)/e,b=.25*e,_=(u+h)/e,w=(d+m)/e}else if(p>v){const e=2*Math.sqrt(1+p-c-v);x=(d-m)/e,b=(u+h)/e,_=.25*e,w=(f+g)/e}else{const e=2*Math.sqrt(1+v-c-p);x=(h-u)/e,b=(d+m)/e,_=(f+g)/e,w=.25*e}const S=Math.sqrt(b*b+_*_+w*w+x*x);return S>0&&(b/=S,_/=S,w/=S,x/=S),{x:b,y:_,z:w,w:x}}(s);let l;void 0!==i&&(l={x:a.x-s.x*i,y:a.y-s.y*i,z:a.z-s.z*i}),this.setDeviceTransform(t,l,o);const c=this.getDeviceTransform(t);return{device:t,position:c.position,orientation:c.orientation}}executeSetInputMode(e){var t,n,i,r,a;const{mode:s}=e;this.device.primaryInputMode=s;const o=[];return"controller"===s?((null===(t=this.device.controllers.left)||void 0===t?void 0:t.connected)&&o.push("controller-left"),(null===(n=this.device.controllers.right)||void 0===n?void 0:n.connected)&&o.push("controller-right")):((null===(i=this.device.hands.left)||void 0===i?void 0:i.connected)&&o.push("hand-left"),(null===(r=this.device.hands.right)||void 0===r?void 0:r.connected)&&o.push("hand-right")),(null===(a=this.device.gaze)||void 0===a?void 0:a.connected)&&o.push("gaze"),{mode:s,activeDevices:o}}executeSetConnected(e){const{device:t,connected:n}=e;return this.setDeviceConnected(t,n),{device:t,connected:n}}executeGetSelectValue(e){const{device:t}=e;return{device:t,value:this.getDeviceSelectValue(t)}}executeSetSelectValue(e){const{device:t,value:n}=e;return this.setDeviceSelectValue(t,n),{device:t,value:n}}executeSetHandPose(e){const{device:t,poseId:n}=e,i="hand-left"===t?"left":"hand-right"===t?"right":null;if(!i)throw new Error(`set_hand_pose requires device 'hand-left' or 'hand-right', got '${t}'.`);const r=this.device.hands[i];if(!r)throw new Error(`Hand ${i} not available`);return r.poseId=n,{device:t,poseId:n}}requireSem(){const e=this.device.sem;if(!e)throw new Error("Scene understanding (SEM) is not installed on this device. Install @iwer/sem to query the emulated world.");return e}executeGetObjects(){const e=this.requireSem(),t=[];return e.trackedPlanes.forEach(e=>{var n;t.push({type:"plane",semanticLabel:null!==(n=e.semanticLabel)&&void 0!==n?n:null})}),e.trackedMeshes.forEach(e=>{var n;t.push({type:"mesh",semanticLabel:null!==(n=e.semanticLabel)&&void 0!==n?n:null})}),{objects:t}}executeGetWorldState(){const e=this.requireSem();return{planeCount:e.trackedPlanes.size,meshCount:e.trackedMeshes.size,objects:this.executeGetObjects().objects}}listMethods(){const e=[];return hs.IMMEDIATE_METHODS.forEach(t=>{e.push({method:t,immediate:!0,requiresSession:!1})}),hs.SESSION_REQUIRED_METHODS.forEach(t=>{e.push({method:t,immediate:!1,requiresSession:!0})}),e}describe(){return this.listMethods()}connectTransport(e){e.addEventListener("message",t=>{const n=t.data;if(!n||"string"!=typeof n.method)return;const{id:i,method:r,params:a}=n;this.dispatch(r,null!=a?a:{}).then(t=>e.postMessage({id:i,result:t})).catch(t=>e.postMessage({id:i,error:t instanceof Error?t.message:String(t)}))})}executeGetGamepadState(e){const{device:t}=e,n="controller-left"===t?"left":"right",i=this.device.controllers[n];if(!i)throw new Error(`Controller ${n} not available`);const r=["trigger","squeeze","thumbstick","left"===n?"x-button":"a-button","left"===n?"y-button":"b-button","thumbrest"].map((e,t)=>({index:t,name:e.replace("x-button","x").replace("y-button","y").replace("a-button","a").replace("b-button","b"),value:i.getButtonValue(e),touched:i.getButtonTouched(e),pressed:i.getButtonValue(e)>.5})),a=i.getAxes(),s=[{index:0,name:"thumbstick-x",value:a.x},{index:1,name:"thumbstick-y",value:a.y}];return{device:t,connected:i.connected,buttons:r,axes:s}}executeSetGamepadState(e){const{device:t,buttons:n,axes:i}=e,r="controller-left"===t?"left":"right",a=this.device.controllers[r];if(!a)throw new Error(`Controller ${r} not available`);let s=0,o=0;const l=["trigger","squeeze","thumbstick","left"===r?"x-button":"a-button","left"===r?"y-button":"b-button","thumbrest"];if(n)for(const e of n){const t=l[e.index];t&&ls(e.value)&&(a.updateButtonValue(t,cs(e.value,0,1)),void 0!==e.touched&&a.updateButtonTouch(t,e.touched),s++)}if(i){let e,t;for(const n of i)ls(n.value)&&(0===n.index?(e=cs(n.value,-1,1),o++):1===n.index&&(t=cs(n.value,-1,1),o++));if(void 0!==e||void 0!==t){const n=a.getAxes();a.updateAxes("thumbstick",null!=e?e:n.x,null!=t?t:n.y)}}return{device:t,buttonsSet:s,axesSet:o}}executeGetDeviceState(){var e,t,n,i,r,a,s,o,l,c,u,d,h,p,f,m,g,v,y,x,b,_,w,S;return{headset:{position:Ka(this.device.position),orientation:Qa(this.device.quaternion)},inputMode:this.device.primaryInputMode,controllers:{left:{connected:null!==(t=null===(e=this.device.controllers.left)||void 0===e?void 0:e.connected)&&void 0!==t&&t,position:Ka(null!==(i=null===(n=this.device.controllers.left)||void 0===n?void 0:n.position)&&void 0!==i?i:{x:0,y:0,z:0}),orientation:Qa(null!==(a=null===(r=this.device.controllers.left)||void 0===r?void 0:r.quaternion)&&void 0!==a?a:{x:0,y:0,z:0,w:1})},right:{connected:null!==(o=null===(s=this.device.controllers.right)||void 0===s?void 0:s.connected)&&void 0!==o&&o,position:Ka(null!==(c=null===(l=this.device.controllers.right)||void 0===l?void 0:l.position)&&void 0!==c?c:{x:0,y:0,z:0}),orientation:Qa(null!==(d=null===(u=this.device.controllers.right)||void 0===u?void 0:u.quaternion)&&void 0!==d?d:{x:0,y:0,z:0,w:1})}},hands:{left:{connected:null!==(p=null===(h=this.device.hands.left)||void 0===h?void 0:h.connected)&&void 0!==p&&p,position:Ka(null!==(m=null===(f=this.device.hands.left)||void 0===f?void 0:f.position)&&void 0!==m?m:{x:0,y:0,z:0}),orientation:Qa(null!==(v=null===(g=this.device.hands.left)||void 0===g?void 0:g.quaternion)&&void 0!==v?v:{x:0,y:0,z:0,w:1})},right:{connected:null!==(x=null===(y=this.device.hands.right)||void 0===y?void 0:y.connected)&&void 0!==x&&x,position:Ka(null!==(_=null===(b=this.device.hands.right)||void 0===b?void 0:b.position)&&void 0!==_?_:{x:0,y:0,z:0}),orientation:Qa(null!==(S=null===(w=this.device.hands.right)||void 0===w?void 0:w.quaternion)&&void 0!==S?S:{x:0,y:0,z:0,w:1})}},...this.device.gaze?{gaze:{connected:this.device.gaze.connected,orientation:this.getDeviceTransform("gaze").orientation}}:{},stereoEnabled:this.device.stereoEnabled,fov:this.device.fovy*(180/Math.PI)}}executeSetDeviceState(e){const{state:t}=e;if(t){if(t.headset){t.headset.position&&us(t.headset.position);const e=t.headset.orientation?ds(t.headset.orientation):void 0;t.headset.position&&this.device.position.set(t.headset.position.x,t.headset.position.y,t.headset.position.z),e&&this.device.quaternion.set(e.x,e.y,e.z,e.w)}void 0!==t.inputMode&&(this.device.primaryInputMode=t.inputMode),void 0!==t.stereoEnabled&&(this.device.stereoEnabled=t.stereoEnabled),void 0!==t.fov&&(this.device.fovy=t.fov*(Math.PI/180)),t.controllers&&(this.applyInputState("controller-left",t.controllers.left),this.applyInputState("controller-right",t.controllers.right)),t.hands&&(this.applyInputState("hand-left",t.hands.left),this.applyInputState("hand-right",t.hands.right)),t.gaze&&this.applyInputState("gaze",t.gaze)}else this.device.position.set(0,1.6,0),this.device.quaternion.set(0,0,0,1),this.device.primaryInputMode="controller",this.device.stereoEnabled=!1,this.device.controllers.left&&(this.device.controllers.left.position.set(-.2,1.4,-.3),this.device.controllers.left.quaternion.set(0,0,0,1),this.device.controllers.left.connected=!0),this.device.controllers.right&&(this.device.controllers.right.position.set(.2,1.4,-.3),this.device.controllers.right.quaternion.set(0,0,0,1),this.device.controllers.right.connected=!0),this.device.hands.left&&(this.device.hands.left.position.set(-.15,1.3,-.4),this.device.hands.left.quaternion.set(0,0,0,1),this.device.hands.left.connected=!0),this.device.hands.right&&(this.device.hands.right.position.set(.15,1.3,-.4),this.device.hands.right.quaternion.set(0,0,0,1),this.device.hands.right.connected=!0),this.device.gaze&&(this.device.gaze.quaternion.set(0,0,0,1),this.device.gaze.connected=!0);return{state:this.executeGetDeviceState()}}applyInputState(e,t){t&&(void 0!==t.connected&&this.setDeviceConnected(e,t.connected),(t.position||t.orientation)&&this.setDeviceTransform(e,t.position,t.orientation))}applyDurationLerpState(e,t){const{startState:n,targetState:i,params:r}=e,a=r.device;let s,o;n.position&&i.position&&(s=function(e,t,n){return{x:es(e.x,t.x,n),y:es(e.y,t.y,n),z:es(e.z,t.z,n)}}(n.position,i.position,t)),n.orientation&&i.orientation&&(o=function(e,t,n){let i=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,r=t.x,a=t.y,s=t.z,o=t.w;if(i<0&&(i=-i,r=-r,a=-a,s=-s,o=-o),i>.9995){const t={x:es(e.x,r,n),y:es(e.y,a,n),z:es(e.z,s,n),w:es(e.w,o,n)},i=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w);return{x:t.x/i,y:t.y/i,z:t.z/i,w:t.w/i}}const l=Math.acos(i),c=l*n,u=Math.sin(c),d=Math.sin(l),h=Math.cos(c)-i*u/d,p=u/d;return{x:h*e.x+p*r,y:h*e.y+p*a,z:h*e.z+p*s,w:h*e.w+p*o}}(n.orientation,i.orientation,t)),this.setDeviceTransform(a,s,o)}applyDurationFinalState(e){const{targetState:t,params:n}=e,i=n.device;this.setDeviceTransform(i,t.position,t.orientation)}getDurationResult(e){const{params:t,elapsedMs:n}=e,i=t.device,r=this.getDeviceTransform(i);return{device:i,position:r.position,orientation:r.orientation,actualDuration:n/1e3}}activateCaptureMode(){this._isCaptured||(this._isCaptured=!0,this.cancelReleaseTimer(),this.device.controlMode="programmatic"),this.startReleaseTimer()}async dispatch(e,t={}){var n;const i="string"==typeof t.device?{...t,device:ns(t.device)}:t;if(hs.IMMEDIATE_METHODS.has(e))return hs.ACTIVE_IMMEDIATE_METHODS.has(e)&&this.activateCaptureMode(),this.executeImmediateMethod(e,i);if(hs.SESSION_REQUIRED_METHODS.has(e)&&!this.device[ba].runtime.getSession()){const t="native"===this.device[ba].runtime.kind?"The application must start its native immersive session first.":"Use 'get_session_status' to check session state, and 'accept_session' to start a session.";throw new Error(`Cannot execute '${e}': No active XR session. `+t)}if("animate_to"===e){const t=i;if("gaze"===t.device&&t.position)throw new Error("Gaze position is derived from the headset. Move the headset transform instead.");const r=this.getDeviceTransform(t.device),a=1e3*(null!==(n=t.duration)&&void 0!==n?n:.5),s=t.orientation?Ja(t.orientation):void 0,o=t.position?this.transformXROriginToGlobal(t.position):void 0;return this.enqueueDuration(e,i,a,{position:t.position?r.position:void 0,orientation:s?r.orientation:void 0},{position:o,orientation:s})}if("select"===e){const e=i;return this.executeSelectSequence(e)}return this.enqueueDiscrete(e,i)}executeImmediateMethod(e,t){switch(e){case"get_session_status":return this.executeGetSessionStatus();case"accept_session":return this.executeAcceptSession();case"end_session":return this.executeEndSession();case"get_transform":return this.executeGetTransform(t);case"get_select_value":return this.executeGetSelectValue(t);case"get_gamepad_state":return this.executeGetGamepadState(t);case"get_device_state":return this.executeGetDeviceState();case"get_world_state":return this.executeGetWorldState();case"get_objects":return this.executeGetObjects();default:throw new Error(`Unknown immediate method: ${e}`)}}executeSelectSequence(e){const{device:t,duration:n=is}=e;return this.getDeviceSelectValue(t),new Promise((e,i)=>{let r=0;const a=()=>{r++,3===r&&e({device:t,duration:n})},s={type:"discrete",id:this.generateActionId(),method:"_select_press",params:{device:t},resolve:a,reject:i},o={type:"duration",id:this.generateActionId(),method:"_select_wait",params:{device:t},durationMs:1e3*n,elapsedMs:0,startState:{},targetState:{},resolve:a,reject:i},l={type:"discrete",id:this.generateActionId(),method:"_select_release",params:{device:t},resolve:a,reject:i};this.commandQueue.push(s,o,l)})}async acceptSession(){if("native"===this.device[ba].runtime.kind)throw new Error("Session start is app-driven in native override mode; immersive sessions require a user gesture.");if(!this.device.sessionOffered)throw new Error("No session has been offered");return this.device.grantOfferedSession(),await function(e,t=5e3){return new Promise((n,i)=>{const r=Date.now(),a=()=>{e()?n():Date.now()-r>t?i(new Error("Timeout waiting for condition")):requestAnimationFrame(a)};a()})}(()=>!!this.device.activeSession,5e3),{success:!0}}forceRelease(){this.cancelReleaseTimer(),this._isCaptured=!1,this.device.controlMode="manual";for(const e of this.commandQueue)this.clearActionTimeout(e),e.reject(new Error("Capture released"));this.commandQueue=[];for(const e of["left","right"]){const t=this.device.controllers[e];if(t){const n=["trigger","squeeze","thumbstick","thumbrest","left"===e?"x-button":"a-button","left"===e?"y-button":"b-button"];for(const e of n)t.updateButtonValue(e,0);t.updateAxes("thumbstick",0,0)}const n=this.device.hands[e];n&&n.updatePinchValue(0)}}}var ps,fs,ms;hs.IMMEDIATE_METHODS=new Set(["get_session_status","accept_session","end_session","get_transform","get_select_value","get_gamepad_state","get_device_state","get_world_state","get_objects"]),hs.ACTIVE_IMMEDIATE_METHODS=new Set(["accept_session","end_session"]),hs.SESSION_REQUIRED_METHODS=new Set(["set_transform","look_at","animate_to","set_input_mode","set_connected","set_select_value","select","set_gamepad_state","set_device_state","set_hand_pose"]),function(e){e.None="",e.Standard="standard",e.XRStandard="xr-standard"}(ps||(ps={}));class gs{constructor(e,t){this[Ea]={type:e,eventTrigger:t,pressed:!1,touched:!1,value:0,lastFrameValue:0,pendingValue:null,immediateTransitionFrom:null}}get pressed(){return"manual"===this[Ea].type?this[Ea].pressed:this[Ea].value>0}get touched(){return"manual"===this[Ea].type?this[Ea].touched:this[Ea].touched||this.pressed}get value(){return this[Ea].value}}class vs{constructor(){this.pressed=!1,this.touched=!1,this.value=0}}class ys{constructor(e="vibration"){this[Ea]={type:e,lastPulse:null}}get type(){return this[Ea].type}pulse(e,t){return this[Ea].lastPulse={value:e,duration:t,startTime:performance.now()},Promise.resolve(!0)}}class xs{constructor(e,t="",n=-1,i=0){this[Ea]={id:t,index:n,connected:!1,timestamp:performance.now(),mapping:e.mapping,buttonsMap:{},buttonsSequence:[],axesMap:{},axesSequence:[],hapticActuators:Array.from({length:Math.max(0,i)},()=>new ys("vibration")),buttonsView:[],axesView:[],axesResolvers:[]},e.buttons.forEach(e=>{var t;null===e?this[Ea].buttonsSequence.push(null):(this[Ea].buttonsSequence.push(e.id),this[Ea].buttonsMap[e.id]=new gs(e.type,null!==(t=e.eventTrigger)&&void 0!==t?t:null))}),e.axes.forEach(e=>{null===e?this[Ea].axesSequence.push(null):(this[Ea].axesSequence.push(e.id+e.type),this[Ea].axesMap[e.id]||(this[Ea].axesMap[e.id]={x:0,y:0}))}),this[Ea].buttonsView=this[Ea].buttonsSequence.map(e=>null===e?new vs:this[Ea].buttonsMap[e]),this[Ea].axesResolvers=this[Ea].axesSequence.map(e=>null===e?null:{axisId:e.substring(0,e.length-6),isY:"y-axis"===e.substring(e.length-6)}),this[Ea].axesView=this[Ea].axesResolvers.map(()=>null)}get id(){return this[Ea].id}get index(){return this[Ea].index}get connected(){return this[Ea].connected}get timestamp(){return this[Ea].timestamp}get mapping(){return this[Ea].mapping}get axes(){const{axesView:e,axesResolvers:t,axesMap:n}=this[Ea];for(let i=0;i<t.length;i++){const r=t[i];if(null===r)e[i]=null;else{const t=n[r.axisId];e[i]=r.isY?t.y:t.x}}return e}get buttons(){return this[Ea].buttonsView}get hapticActuators(){return this[Ea].hapticActuators}get vibrationActuator(){var e;return null!==(e=this[Ea].hapticActuators[0])&&void 0!==e?e:null}}!function(e){e.None="none",e.Left="left",e.Right="right"}(fs||(fs={})),function(e){e.Gaze="gaze",e.TrackedPointer="tracked-pointer",e.Screen="screen",e.TransientPointer="transient-pointer"}(ms||(ms={}));class bs extends Array{}class _s{constructor(e,t,n,i,r,a,s){this[Ta]={handedness:e,targetRayMode:t,targetRaySpace:i,gripSpace:a,profiles:n,gamepad:r,hand:s}}get handedness(){return this[Ta].handedness}get targetRayMode(){return this[Ta].targetRayMode}get targetRaySpace(){return this[Ta].targetRaySpace}get gripSpace(){return this[Ta].gripSpace}get profiles(){return this[Ta].profiles}get gamepad(){return this[Ta].gamepad}get hand(){return this[Ta].hand}}class ws extends Event{constructor(e,t){if(super(e,t),!t.frame)throw new Error("XRInputSourceEventInit.frame is required");if(!t.inputSource)throw new Error("XRInputSourceEventInit.inputSource is required");this.frame=t.frame,this.inputSource=t.inputSource}}const Ss={[fs.Left]:{position:new $a(-.25,1.5,-.4),quaternion:new Ya},[fs.Right]:{position:new $a(.25,1.5,-.4),quaternion:new Ya},[fs.None]:{position:new $a(.25,1.5,-.4),quaternion:new Ya}};class Es{constructor(e){this[wa]={inputSource:e,position:Ss[e.handedness].position.clone(),quaternion:Ss[e.handedness].quaternion.clone(),connected:!0,lastFrameConnected:!1,inputSourceChanged:!0}}get position(){return this[wa].position}get quaternion(){return this[wa].quaternion}get inputSource(){return this[wa].inputSource}get connected(){return this[wa].connected}set connected(e){this[wa].connected=e;const t=this[wa].inputSource.gamepad;t&&(t[Ea].connected=e)}updateTargetRaySpace(){jr(this[wa].inputSource.targetRaySpace[Ua].offsetMatrix,this[wa].quaternion.quat,this[wa].position.vec3)}onFrameStart(e){var t;this.updateTargetRaySpace();const n=e.session;null===(t=this[wa].inputSource.gamepad)||void 0===t||t.buttons.forEach(t=>{var i;t instanceof gs&&(t[Ea].lastFrameValue=null!==(i=t[Ea].immediateTransitionFrom)&&void 0!==i?i:t[Ea].value,t[Ea].immediateTransitionFrom=null,null!=t[Ea].pendingValue&&(t[Ea].value=t[Ea].pendingValue,t[Ea].pendingValue=null),null!=t[Ea].eventTrigger&&(0===t[Ea].lastFrameValue&&t[Ea].value>0?(n.dispatchEvent(new ws(t[Ea].eventTrigger,{frame:e,inputSource:this[wa].inputSource})),n.dispatchEvent(new ws(t[Ea].eventTrigger+"start",{frame:e,inputSource:this[wa].inputSource}))):t[Ea].lastFrameValue>0&&0===t[Ea].value&&n.dispatchEvent(new ws(t[Ea].eventTrigger+"end",{frame:e,inputSource:this[wa].inputSource}))))}),this[wa].inputSourceChanged=this.connected!==this[wa].lastFrameConnected,this[wa].lastFrameConnected=this.connected}}class Ms extends Es{constructor(e,t,n){if(!e.layout[t])throw new DOMException("Handedness not supported","InvalidStateError");const i=new ja(n),r=e.layout[t].gripOffsetMatrix?new ja(i,e.layout[t].gripOffsetMatrix):void 0,a=[e.profileId,...e.fallbackProfileIds];super(new _s(t,ms.TrackedPointer,a,i,new xs(e.layout[t].gamepad,"",-1,e.layout[t].numHapticActuators),r)),this[xa]={profileId:e.profileId,gamepadConfig:e.layout[t].gamepad}}get gamepadConfig(){return this[xa].gamepadConfig}get profileId(){return this[xa].profileId}updateButtonValue(e,t){if(t>1||t<0)return void console.warn(`Out-of-range value ${t} provided for button ${e}.`);const n=this[wa].inputSource.gamepad[Ea].buttonsMap[e];if(n){if("binary"===n[Ea].type&&1!=t&&0!=t)return void console.warn(`Non-binary value ${t} provided for binary button ${e}.`);n[Ea].pendingValue=t}else console.warn(`Current controller does not have button ${e}.`)}setButtonValueImmediate(e,t){if(t>1||t<0)return void console.warn(`Out-of-range value ${t} provided for button ${e}.`);const n=this[wa].inputSource.gamepad[Ea].buttonsMap[e];if(n){if("binary"===n[Ea].type&&1!=t&&0!=t)return void console.warn(`Non-binary value ${t} provided for binary button ${e}.`);null===n[Ea].immediateTransitionFrom&&(n[Ea].immediateTransitionFrom=n[Ea].value),n[Ea].value=t,n[Ea].pendingValue=t}else console.warn(`Current controller does not have button ${e}.`)}updateButtonTouch(e,t){const n=this[wa].inputSource.gamepad[Ea].buttonsMap[e];n?n[Ea].touched=t:console.warn(`Current controller does not have button ${e}.`)}updateAxis(e,t,n){if(n>1||n<-1)return void console.warn(`Out-of-range value ${n} provided for ${e} axes.`);const i=this[wa].inputSource.gamepad[Ea].axesMap[e];i?"x-axis"===t?i.x=n:"y-axis"===t&&(i.y=n):console.warn(`Current controller does not have ${e} axes.`)}updateAxes(e,t,n){if(t>1||t<-1||n>1||n<-1)return void console.warn(`Out-of-range value x:${t}, y:${n} provided for ${e} axes.`);const i=this[wa].inputSource.gamepad[Ea].axesMap[e];i?(i.x=t,i.y=n):console.warn(`Current controller does not have ${e} axes.`)}getButtonValue(e){var t;const n=this[wa].inputSource.gamepad[Ea].buttonsMap[e];return n?null!==(t=n[Ea].pendingValue)&&void 0!==t?t:n.value:0}getButtonTouched(e){const t=this[wa].inputSource.gamepad[Ea].buttonsMap[e];return!!t&&t.touched}getAxes(e="thumbstick"){const t=this[wa].inputSource.gamepad[Ea].axesMap[e];return t?{x:t.x,y:t.y}:{x:0,y:0}}}class Ts{constructor(e,t,n,i,r){this[Ra]={nativeMesh:e,frame:void 0,meshSpace:t,vertices:n,indices:i,lastChangedTime:performance.now(),semanticLabel:r}}get meshSpace(){return this[Ra].meshSpace}get vertices(){return this[Ra].vertices}get indices(){return this[Ra].indices}get lastChangedTime(){return this[Ra].lastChangedTime}get semanticLabel(){return this[Ra].semanticLabel}}class As extends Set{}class Rs{constructor(e,t,n,i){this.transform=e,this.vertices=t,this.indices=n,this.semanticLabel=i}}var Ps,Cs;!function(e){e.Desk="desk",e.Couch="couch",e.Floor="floor",e.Ceiling="ceiling",e.Wall="wall",e.Door="door",e.Window="window",e.Table="table",e.Shelf="shelf",e.Bed="bed",e.Screen="screen",e.Lamp="lamp",e.Plant="plant",e.WallArt="wall art",e.GlobalMesh="global mesh",e.Other="other"}(Ps||(Ps={})),function(e){e.Horizontal="horizontal",e.Vertical="vertical"}(Cs||(Cs={}));const Ls={[Ps.Desk]:Cs.Horizontal,[Ps.Couch]:Cs.Horizontal,[Ps.Floor]:Cs.Horizontal,[Ps.Ceiling]:Cs.Horizontal,[Ps.Wall]:Cs.Vertical,[Ps.Door]:Cs.Vertical,[Ps.Window]:Cs.Vertical,[Ps.Table]:Cs.Horizontal,[Ps.Shelf]:Cs.Horizontal,[Ps.Bed]:Cs.Horizontal,[Ps.Screen]:Cs.Horizontal,[Ps.Lamp]:Cs.Horizontal,[Ps.Plant]:Cs.Horizontal,[Ps.WallArt]:Cs.Vertical};class Is{constructor(e,t,n,i){this[Pa]={nativePlane:e,frame:void 0,planeSpace:t,polygon:n,lastChangedTime:performance.now(),semanticLabel:i,orientation:i?Ls[i]:void 0}}get planeSpace(){return this[Pa].planeSpace}get polygon(){return this[Pa].polygon}get orientation(){return this[Pa].orientation}get lastChangedTime(){return this[Pa].lastChangedTime}get semanticLabel(){return this[Pa].semanticLabel}}class Ds extends Set{}class Ns{constructor(e,t,n){this.transform=e,this.polygon=t,this.semanticLabel=n}}class ks{constructor(e,t,n,i,r,a){this[Ha]={data:e,width:t,height:n,normDepthBufferFromNormView:i,rawValueToMeters:r,dataFormat:a,view:"float32"===a?new Float32Array(e):new Uint8Array(e)}}get data(){return this[Ha].data}get width(){return this[Ha].width}get height(){return this[Ha].height}get normDepthBufferFromNormView(){return this[Ha].normDepthBufferFromNormView}get rawValueToMeters(){return this[Ha].rawValueToMeters}get dataFormat(){return this[Ha].dataFormat}getDepthInMeters(e,t){const{width:n,height:i,rawValueToMeters:r,dataFormat:a,view:s}=this[Ha];if(e<0||e>=1||t<0||t>=1)throw new RangeError("Normalized coordinates must be in [0, 1) range.");const o=Math.floor(e*n),l=Math.floor(t*i);if("float32"===a){return s[l*n+o]*r}{const e=s,t=2*(l*n+o);return(e[t]+256*e[t+1])*r}}}class Fs{constructor(e,t,n,i,r,a,s,o,l){this.texture=e,this.width=t,this.height=n,this.normDepthBufferFromNormView=i,this.rawValueToMeters=r,this.depthNear=a,this.depthFar=s,this.textureType=o,this.imageIndex=l,this.isValid=!0}}let Os=class{constructor(e,t){this._session=e}getDepthInformation(e){var t;const n=this._session[ka].activeFrame;if(!n||!n[Sa].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(!this._session[ka].enabledFeatures.includes("depth-sensing"))throw new DOMException("depth-sensing feature is not enabled on this session.","InvalidStateError");if("gpu-optimized"!==this._session[ka].depthSensingUsage)throw new DOMException("getDepthInformation on XRWebGLBinding requires gpu-optimized depth sensing usage.","InvalidStateError");const i=e[za].eye;return null!==(t=n[Sa].gpuDepthDataMap.get(i))&&void 0!==t?t:null}};class Us{constructor(e,t){this[ya]={anchorSpace:e,session:t,deleted:!1},t[ka].trackedAnchors.add(this)}get anchorSpace(){if(this[ya].deleted)throw new DOMException("XRAnchor has already been deleted.","InvalidStateError");return this[ya].anchorSpace}requestPersistentHandle(){return new Promise((e,t)=>{if(this[ya].deleted)t(new DOMException("XRAnchor has already been deleted.","InvalidStateError"));else{const t=this[ya].session[ka].persistentAnchors;for(const[n,i]of t.entries())if(i===this)return void e(n);const n=crypto.randomUUID();Vs.createPersistentAnchor(this[ya].session,this,n),e(n)}})}delete(){this[ya].deleted||(this[ya].anchorSpace=null,this[ya].deleted=!0,this[ya].session[ka].trackedAnchors.delete(this))}}class zs extends Set{}const Bs="@immersive-web-emulation-runtime/persistent-anchors";class Vs{static recoverPersistentAnchorsFromStorage(e){const t=JSON.parse(localStorage.getItem(Bs)||"{}"),n=e[ka].device[ba].globalSpace;Object.entries(t).forEach(([t,i])=>{const r=new ja(n,i),a=new Us(r,e);e[ka].persistentAnchors.set(t,a)})}static createPersistentAnchor(e,t,n){e[ka].trackedAnchors.add(t),e[ka].persistentAnchors.set(n,t);const i=JSON.parse(localStorage.getItem(Bs)||"{}");i[n]=Array.from(t[ya].anchorSpace[Ua].offsetMatrix),localStorage.setItem(Bs,JSON.stringify(i))}}class Hs{constructor(e,t){const n=Qr(0,0,0),i=oa(),r=e?Qr(e.x,e.y,e.z):n,a=t?ga(oa(),ha(t.x,t.y,t.z,t.w)):i;this[Da]={matrix:Or(),position:r,orientation:a,positionPoint:new DOMPointReadOnly(r[0],r[1],r[2],1),orientationPoint:new DOMPointReadOnly(a[0],a[1],a[2],a[3]),inverse:null},this.updateMatrix()}updateMatrix(){jr(this[Da].matrix,this[Da].orientation,this[Da].position)}get matrix(){return this[Da].matrix}get position(){return this[Da].positionPoint}get orientation(){return this[Da].orientationPoint}get inverse(){if(!this[Da].inverse){const e=Or();if(!Vr(e,this[Da].matrix))throw new Error("Matrix is not invertible.");let t=Kr();Xr(t,e);let n=oa();$r(n,e),this[Da].inverse=new Hs(new DOMPointReadOnly(t[0],t[1],t[2],1),new DOMPointReadOnly(n[0],n[1],n[2],n[3])),this[Da].inverse[Da].inverse=this}return this[Da].inverse}}let Gs=class{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}};class Ws{constructor(e,t){const n={x:0,y:0,z:0,w:1},i={x:0,y:0,z:-1,w:0};if(e instanceof Hs){const t=e.matrix,r=aa(ra(),n.x,n.y,n.z,n.w),a=aa(ra(),i.x,i.y,i.z,i.w);sa(r,r,t),sa(a,a,t),n.x=r[0],n.y=r[1],n.z=r[2],n.w=r[3],i.x=a[0],i.y=a[1],i.z=a[2],i.w=a[3]}else if(e&&(n.x=e.x,n.y=e.y,n.z=e.z,n.w=e.w),t){if(0===t.x&&0===t.y&&0===t.z||0!==t.w)throw new DOMException("Invalid direction value to construct XRRay","TypeError");i.x=t.x,i.y=t.y,i.z=t.z,i.w=t.w}const r=Math.sqrt(i.x*i.x+i.y*i.y+i.z*i.z)||1;i.x=i.x/r,i.y=i.y/r,i.z=i.z/r,this[Va]={origin:new Gs(n.x,n.y,n.z,n.w),direction:new Gs(i.x,i.y,i.z,i.w),matrix:null}}get origin(){return this[Va].origin}get direction(){return this[Va].direction}get matrix(){if(this[Va].matrix)return this[Va].matrix;const e=Jr(Kr(),0,0,-1),t=Jr(Kr(),this[Va].origin.x,this[Va].origin.y,this[Va].origin.z),n=Jr(Kr(),this[Va].direction.x,this[Va].direction.y,this[Va].direction.z),i=na(Kr(),n,e),r=ta(n,e),a=Or();r>-1&&r<1?Wr(a,Math.acos(r),i):-1===r?Wr(a,Math.acos(r),Jr(Kr(),1,0,0)):Br(a);const s=Gr(Or(),t),o=Hr(Or(),s,a);return this[Va].matrix=new Float32Array(o),this[Va].matrix}}class js{constructor(e,t){var n;this[Ga]={session:e,space:t.space,offsetRay:null!==(n=t.offsetRay)&&void 0!==n?n:new Ws,entityTypes:t.entityTypes}}cancel(){this[Ga].session[ka].hitTestSources.delete(this)}}class Xs{constructor(e,t){this[Ga]={frame:e,offsetSpace:t}}getPose(e){return this[Ga].frame.getPose(this[Ga].offsetSpace,e)}createAnchor(){return this[Ga].frame.createAnchor(new Hs,this[Ga].offsetSpace)}}class qs extends Event{constructor(e,t){if(super(e,t),!t.session)throw new Error("XRInputSourcesChangeEventInit.session is required");if(!t.added)throw new Error("XRInputSourcesChangeEventInit.added is required");if(!t.removed)throw new Error("XRInputSourcesChangeEventInit.removed is required");this.session=t.session,this.added=t.added,this.removed=t.removed}}var $s,Ys,Ks;!function(e){e.Viewer="viewer",e.Local="local",e.LocalFloor="local-floor",e.BoundedFloor="bounded-floor",e.Unbounded="unbounded"}(Ys||(Ys={}));class Qs extends ja{constructor(e,t,n){super(t,n),this[$s]={type:null,onreset:null},this[Oa].type=e}get onreset(){return this[Oa].onreset}set onreset(e){this[Oa].onreset&&this.removeEventListener("reset",this[Oa].onreset),this[Oa].onreset=e,e&&this.addEventListener("reset",e)}getOffsetReferenceSpace(e){return new Qs(this[Oa].type,this,e)}}$s=Oa;class Zs{constructor(e={},t){var n,i,r,a,s,o,l,c;this[Na]={depthNear:null!==(i=null!==(n=e.depthNear)&&void 0!==n?n:null==t?void 0:t.depthNear)&&void 0!==i?i:.1,depthFar:null!==(a=null!==(r=e.depthFar)&&void 0!==r?r:null==t?void 0:t.depthFar)&&void 0!==a?a:1e3,inlineVerticalFieldOfView:null!==(o=null!==(s=e.inlineVerticalFieldOfView)&&void 0!==s?s:null==t?void 0:t.inlineVerticalFieldOfView)&&void 0!==o?o:null,baseLayer:null!==(c=null!==(l=e.baseLayer)&&void 0!==l?l:null==t?void 0:t.baseLayer)&&void 0!==c?c:null}}get depthNear(){return this[Na].depthNear}get depthFar(){return this[Na].depthFar}get inlineVerticalFieldOfView(){return this[Na].inlineVerticalFieldOfView}get baseLayer(){return this[Na].baseLayer}}class Js extends Event{constructor(e,t){if(super(e,t),!t.session)throw new Error("XRSessionEventInit.session is required");this.session=t.session}}!function(e){e.None="none",e.Left="left",e.Right="right"}(Ks||(Ks={}));class eo{constructor(e,t,n,i){this[za]={eye:e,projectionMatrix:t,transform:n,recommendedViewportScale:null,requestedViewportScale:1,session:i}}get eye(){return this[za].eye}get projectionMatrix(){return this[za].projectionMatrix}get transform(){return this[za].transform}get recommendedViewportScale(){return this[za].recommendedViewportScale}requestViewportScale(e){null===e||e<=0||e>1?console.warn("Invalid scale value. Scale must be > 0 and <= 1."):this[za].requestedViewportScale=e}}class to{constructor(e,t=!1,n=void 0,i=void 0){this[La]={transform:e,emulatedPosition:t,linearVelocity:n,angularVelocity:i}}get transform(){return this[La].transform}get emulatedPosition(){return this[La].emulatedPosition}get linearVelocity(){return this[La].linearVelocity}get angularVelocity(){return this[La].angularVelocity}}class no extends to{constructor(e,t,n=!1,i=void 0,r=void 0){super(e,n,i,r),this[Ca]={radius:t}}get radius(){return this[Ca].radius}}class io extends to{constructor(e,t,n=!1,i=void 0,r=void 0){super(e,n,i,r),this[Ia]={views:Object.freeze(t)}}get views(){return this[Ia].views}}const ro=Or(),ao=Or(),so=Or(),oo=Kr(),lo=oa(),co=[Ks.None],uo=[Ks.Left,Ks.Right],ho=(e,t,n)=>{qa.calculateGlobalOffsetMatrix(t,ro),qa.calculateGlobalOffsetMatrix(n,ao),Vr(so,ao),Hr(e,so,ro)};class po{constructor(e,t,n,i,r){this[Sa]={session:e,id:t,active:n,animationFrame:i,predictedDisplayTime:r,tempMat4:Or(),detectedPlanes:new Ds,detectedMeshes:new As,trackedAnchors:e[ka].frameTrackedAnchors,hitTestResultsMap:new Map,depthDataMap:new Map,gpuDepthDataMap:new Map}}get session(){return this[Sa].session}get predictedDisplayTime(){return this[Sa].predictedDisplayTime}getPose(e,t){if(!this[Sa].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return ho(this[Sa].tempMat4,e,t),Xr(oo,this[Sa].tempMat4),$r(lo,this[Sa].tempMat4),new to(new Hs({x:oo[0],y:oo[1],z:oo[2],w:1},{x:lo[0],y:lo[1],z:lo[2],w:lo[3]}),e[Ua].emulated)}getViewerPose(e){if(!this[Sa].animationFrame)throw new DOMException("getViewerPose can only be called on XRFrame objects passed to XRSession.requestAnimationFrame callbacks.","InvalidStateError");const t=this[Sa].session,n=t[ka].device,i=this.getPose(n.viewerSpace,e),r="inline"===t[ka].mode?co:uo,a=[];return r.forEach(i=>{const r=n.viewSpaces[i],s=this.getPose(r,e),o=t[ka].getProjectionMatrix(i),l=new eo(i,new Float32Array(o),s.transform,t);a.push(l)}),new io(i.transform,a,!1)}getJointPose(e,t){const n=this.getPose(e,t),i=e[Fa].radius;return new no(n.transform,i,!1)}fillJointRadii(e,t){if(e=Array.from(e),!this[Sa].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(e.length>t.length)throw new DOMException("The length of jointSpaces is larger than the number of elements in radii","TypeError");let n=!0;for(let i=0;i<e.length;i++)e[i][Fa].radius?t[i]=e[i][Fa].radius:(t[i]=NaN,n=!1);return n}fillPoses(e,t,n){if(e=Array.from(e),!this[Sa].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(16*e.length>n.length)throw new DOMException("The length of spaces multiplied by 16 is larger than the number of elements in transforms","TypeError");return e.forEach((e,i)=>{ho(this[Sa].tempMat4,e,t),n.set(this[Sa].tempMat4,16*i)}),!0}get detectedPlanes(){if(!this[Sa].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[Sa].detectedPlanes}get detectedMeshes(){if(!this[Sa].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[Sa].detectedMeshes}get trackedAnchors(){if(!this[Sa].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");return this[Sa].trackedAnchors}createAnchor(e,t){return new Promise((n,i)=>{if(this[Sa].active){const r=this[Sa].session[ka].device[ba].globalSpace,a=new ja(t,e.matrix),s=qa.calculateGlobalOffsetMatrix(a),o=new ja(r,s),l=new Us(o,this[Sa].session);this[Sa].session[ka].trackedAnchors.add(l),this[Sa].session[ka].newAnchors.set(l,{resolve:n,reject:i})}else i(new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError"))})}getHitTestResults(e){if(this[Sa].active){if(this[Sa].hitTestResultsMap.has(e))return[...this[Sa].hitTestResultsMap.get(e)];throw new DOMException("Requested hit test results are not available for current frame.","InvalidStateError")}throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError")}getDepthInformation(e){var t;if(!this[Sa].active)throw new DOMException("XRFrame access outside the callback that produced it is invalid.","InvalidStateError");if(!this[Sa].session[ka].enabledFeatures.includes("depth-sensing"))throw new DOMException("depth-sensing feature is not enabled on this session.","InvalidStateError");return null!==(t=this[Sa].depthDataMap.get(e[za].eye))&&void 0!==t?t:null}}var fo,mo,go;!function(e){e.Opaque="opaque",e.AlphaBlend="alpha-blend",e.Additive="additive"}(fo||(fo={})),function(e){e.ScreenSpace="screen-space",e.WorldSpace="world-space"}(mo||(mo={}));class vo extends EventTarget{constructor(e,t,n,i){var r,a;super(),this[ka]={device:e,mode:t,renderState:new Zs,pendingRenderState:null,enabledFeatures:n,hasAnchors:n.includes("anchors"),hasPlanes:n.includes("plane-detection"),hasMeshes:n.includes("mesh-detection"),hasDepth:n.includes("depth-sensing"),hasHitTest:n.includes("hit-test"),hasGazeTracking:n.includes("gaze-tracking")||n.includes("eye-tracking"),supportedFrameRates:new Float32Array(e.supportedFrameRates),isSystemKeyboardSupported:!1,ended:!1,projectionMatrices:{[Ks.Left]:Or(),[Ks.Right]:Or(),[Ks.None]:Or()},getProjectionMatrix:e=>this[ka].projectionMatrices[e],referenceSpaceIsSupported:e=>{if(!this[ka].enabledFeatures.includes(e))return!1;switch(e){case Ys.Viewer:return!0;case Ys.Local:case Ys.LocalFloor:case Ys.BoundedFloor:case Ys.Unbounded:return"inline"!=this[ka].mode}},frameHandle:0,frameCallbacks:[],currentFrameCallbacks:null,onDeviceFrame:()=>{if(this[ka].ended)return;this[ka].deviceFrameHandle=globalThis.requestAnimationFrame(this[ka].onDeviceFrame),null!=this[ka].pendingRenderState&&(this[ka].renderState=this[ka].pendingRenderState,this[ka].pendingRenderState=null,this[ka].device[ba].onBaseLayerSet(this[ka].renderState.baseLayer));const e=this[ka].renderState.baseLayer;if(null===e)return;const t=e.context,n=t.canvas;if("inline"!=this[ka].mode){const e=t.getParameter(t.COLOR_CLEAR_VALUE),n=t.getParameter(t.DEPTH_CLEAR_VALUE),i=t.getParameter(t.STENCIL_CLEAR_VALUE);t.clearColor(0,0,0,0),t.clearDepth(1),t.clearStencil(0),t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),t.clearColor(e[0],e[1],e[2],e[3]),t.clearDepth(n),t.clearStencil(i)}const{depthNear:i,depthFar:r}=this[ka].renderState,{width:a,height:s}=n;if("inline"!==this[ka].mode){const e=a*(this[ka].device.stereoEnabled?.5:1)/s;Yr(this[ka].projectionMatrices[Ks.Left],this[ka].device.fovy,e,i,r),zr(this[ka].projectionMatrices[Ks.Right],this[ka].projectionMatrices[Ks.Left])}else{const e=a/s;Yr(this[ka].projectionMatrices[Ks.None],this[ka].renderState.inlineVerticalFieldOfView,e,i,r)}const o=performance.now(),l=new po(this,this[ka].frameHandle,!0,!0,o),c=this[ka].device[ba].devui;if(c&&c.render(o),"immersive-ar"===this[ka].mode){const e=this[ka].device[ba].sem;e&&e.render(o)}this[ka].hasAnchors&&this[ka].updateTrackedAnchors(),this[ka].hasPlanes&&this[ka].updateTrackedPlanes(l),this[ka].hasMeshes&&this[ka].updateTrackedMeshes(l),this[ka].hasDepth&&this[ka].computeDepthSensing(l),this[ka].hasHitTest&&this[ka].computeHitTestResults(l),this[ka].activeFrame=l,this[ka].device[ba].onFrameStart(l),this[ka].updateActiveInputSources();const u=this[ka].currentFrameCallbacks=this[ka].frameCallbacks;this[ka].frameCallbacks=[];for(let e=0;e<u.length;e++)try{u[e].cancelled||u[e].callback(o,l)}catch(e){console.error(e)}this[ka].currentFrameCallbacks=null,l[Sa].active=!1,this[ka].activeFrame=null},nominalFrameRate:e.internalNominalFrameRate,referenceSpaces:[],inputSourceArray:[],activeInputSources:[],updateActiveInputSources:()=>{const e=this[ka].enabledFeatures.includes("hand-tracking"),t=this[ka].hasGazeTracking,n=this[ka].activeInputSources,i=this[ka].device.inputSources.filter(n=>(!n.hand||e)&&("gaze"!==n.targetRayMode||t)),r=i.filter(e=>!n.includes(e)),a=n.filter(e=>!i.includes(e));this[ka].activeInputSources=i,(r.length>0||a.length>0)&&this.dispatchEvent(new qs("inputsourceschange",{session:this,added:r,removed:a}))},trackedAnchors:new zs,persistentAnchors:new Map,newAnchors:new Map,frameTrackedAnchors:new zs,updateTrackedAnchors:()=>{this[ka].enabledFeatures.includes("anchors")&&(this[ka].frameTrackedAnchors.clear(),Array.from(this[ka].trackedAnchors).forEach(e=>{if(e[ya].deleted){if(this[ka].trackedAnchors.delete(e),this[ka].newAnchors.has(e)){const{reject:t}=this[ka].newAnchors.get(e);t(new DOMException("Anchor is no longer tracked","InvalidStateError"))}}else if(this[ka].frameTrackedAnchors.add(e),this[ka].newAnchors.has(e)){const{resolve:t}=this[ka].newAnchors.get(e);t(e),this[ka].newAnchors.delete(e)}}))},trackedPlanes:new Map,updateTrackedPlanes:e=>{const t=this[ka].device[ba].sem;if(!t)return;Array.from(this[ka].trackedPlanes.keys()).forEach(e=>{t.trackedPlanes.has(e)||this[ka].trackedPlanes.delete(e)}),t.trackedPlanes.forEach(t=>{let n=this[ka].trackedPlanes.get(t);if(!n){const e=new ja(this[ka].device[ba].globalSpace,t.transform.matrix);n=new Is(t,e,t.polygon,t.semanticLabel),this[ka].trackedPlanes.set(t,n)}n[Pa].lastChangedTime=e.predictedDisplayTime,n[Pa].frame=e,e[Sa].detectedPlanes.add(n)})},trackedMeshes:new Map,updateTrackedMeshes:e=>{const t=this[ka].device[ba].sem;if(!t)return;Array.from(this[ka].trackedMeshes.keys()).forEach(e=>{t.trackedMeshes.has(e)||this[ka].trackedMeshes.delete(e)}),t.trackedMeshes.forEach(t=>{let n=this[ka].trackedMeshes.get(t);if(!n){const e=new ja(this[ka].device[ba].globalSpace,t.transform.matrix);n=new Ts(t,e,t.vertices,t.indices,t.semanticLabel),this[ka].trackedMeshes.set(t,n)}n[Ra].lastChangedTime=e.predictedDisplayTime,n[Ra].frame=e,e[Sa].detectedMeshes.add(n)})},depthSensingUsage:null!==(a=null===(r=null==i?void 0:i.usagePreference)||void 0===r?void 0:r[0])&&void 0!==a?a:"cpu-optimized",depthSensingDataFormat:"float32",depthTexture:null,depthTextureWidth:0,depthTextureHeight:0,depthFlipScratch:null,depthFlipScratchSize:0,activeFrame:null,computeDepthSensing:e=>{const t=this[ka].device[ba].sem;if(!t)return;const{depthNear:n,depthFar:i}=this[ka].renderState,r=this[ka].renderState.baseLayer;if(!r)return;const a=r.context.canvas,s=Math.max(1,Math.floor(a.width/4)),o=Math.max(1,Math.floor(a.height/4)),l="inline"===this[ka].mode?[Ks.None]:[Ks.Left,Ks.Right],c="gpu-optimized"===this[ka].depthSensingUsage;for(const a of l){const l=this[ka].getProjectionMatrix(a),u=this[ka].device.viewSpaces[a],d=qa.calculateGlobalOffsetMatrix(u),h=Or();Vr(h,d);const p=t.computeDepthBuffer(h,l,s,o,n,i);if(p)if(c){const t=r.context,{width:s,height:o}=p,l=2;this[ka].depthTexture&&this[ka].depthTextureWidth===s&&this[ka].depthTextureHeight===o?t.bindTexture(t.TEXTURE_2D_ARRAY,this[ka].depthTexture):(this[ka].depthTexture&&t.deleteTexture(this[ka].depthTexture),this[ka].depthTexture=t.createTexture(),t.bindTexture(t.TEXTURE_2D_ARRAY,this[ka].depthTexture),t.texStorage3D(t.TEXTURE_2D_ARRAY,1,t.R32F,s,o,l),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this[ka].depthTextureWidth=s,this[ka].depthTextureHeight=o);const c=new Float32Array(p.data),u=s*o;this[ka].depthFlipScratch&&this[ka].depthFlipScratchSize===u||(this[ka].depthFlipScratch=new Float32Array(u),this[ka].depthFlipScratchSize=u);const d=this[ka].depthFlipScratch;for(let e=0;e<o;e++){const t=o-1-e;for(let i=0;i<s;i++){const r=c[t*s+i];d[e*s+i]=r>0?1-n/r:0}}const h=t.getParameter(t.UNPACK_FLIP_Y_WEBGL),f=t.getParameter(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL);t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);const m=a===Ks.Right?1:0;t.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,m,s,o,1,t.RED,t.FLOAT,d),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,h),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,f);const g=new Fs(this[ka].depthTexture,s,o,new Hs,p.rawValueToMeters,n,i,"texture-array",m);e[Sa].gpuDepthDataMap.set(a,g)}else{const t=new ks(p.data,p.width,p.height,new Hs,p.rawValueToMeters,this[ka].depthSensingDataFormat);e[Sa].depthDataMap.set(a,t)}}},hitTestSources:new Set,computeHitTestResults:e=>{const t=this[ka].device[ba].sem;if(!t)return;const n=this[ka].device[ba].globalSpace;this[ka].hitTestSources.forEach(i=>{const r=i[Ga].space,a=qa.calculateGlobalOffsetMatrix(r),s=i[Ga].offsetRay.matrix,o=Or();Hr(o,a,s);const l=[];t.computeHitTestResults(o).forEach(t=>{const i=new ja(n,t),r=new Xs(e,i);l.push(r)}),e[Sa].hitTestResultsMap.set(i,l)})},onend:null,oninputsourceschange:null,onselect:null,onselectstart:null,onselectend:null,onsqueeze:null,onsqueezestart:null,onsqueezeend:null,onvisibilitychange:null,onframeratechange:null},Vs.recoverPersistentAnchorsFromStorage(this),this[ka].onDeviceFrame()}get visibilityState(){return this[ka].device.visibilityState}get frameRate(){return this[ka].nominalFrameRate}get supportedFrameRates(){return this[ka].supportedFrameRates}get renderState(){return this[ka].renderState}get inputSources(){return this[ka].inputSourceArray.length=0,this[ka].ended||"inline"===this[ka].mode||this[ka].inputSourceArray.push(...this[ka].activeInputSources),this[ka].inputSourceArray}get enabledFeatures(){return this[ka].enabledFeatures}get isSystemKeyboardSupported(){return this[ka].isSystemKeyboardSupported}get environmentBlendMode(){var e;return null!==(e=this[ka].device[ba].environmentBlendModes[this[ka].mode])&&void 0!==e?e:fo.Opaque}get interactionMode(){return this[ka].device[ba].interactionMode}get depthUsage(){return this[ka].depthSensingUsage}get depthDataFormat(){return this[ka].depthSensingDataFormat}updateRenderState(e={}){var t,n,i,r,a,s,o,l,c,u,d,h;if(this[ka].ended)throw new DOMException("XRSession has already ended.","InvalidStateError");if(e.baseLayer&&e.baseLayer[Aa].session!==this)throw new DOMException("Base layer was created by a different XRSession","InvalidStateError");if(null!=e.inlineVerticalFieldOfView&&"inline"!==this[ka].mode)throw new DOMException("InlineVerticalFieldOfView must not be set for an immersive session","InvalidStateError");const p={baseLayer:null!==(i=null!==(t=e.baseLayer)&&void 0!==t?t:null===(n=this[ka].pendingRenderState)||void 0===n?void 0:n.baseLayer)&&void 0!==i?i:void 0,depthFar:null!==(s=null!==(r=e.depthFar)&&void 0!==r?r:null===(a=this[ka].pendingRenderState)||void 0===a?void 0:a.depthFar)&&void 0!==s?s:void 0,depthNear:null!==(c=null!==(o=e.depthNear)&&void 0!==o?o:null===(l=this[ka].pendingRenderState)||void 0===l?void 0:l.depthNear)&&void 0!==c?c:void 0,inlineVerticalFieldOfView:null!==(h=null!==(u=e.inlineVerticalFieldOfView)&&void 0!==u?u:null===(d=this[ka].pendingRenderState)||void 0===d?void 0:d.inlineVerticalFieldOfView)&&void 0!==h?h:void 0};this[ka].pendingRenderState=new Zs(p,this[ka].renderState)}async updateTargetFrameRate(e){return new Promise((t,n)=>{this[ka].ended?n(new DOMException("XRSession has already ended.","InvalidStateError")):this[ka].device.supportedFrameRates.includes(e)?(this[ka].nominalFrameRate===e?console.log("Requested frame rate is the same as the current nominal frame rate, no update made"):(this[ka].nominalFrameRate=e,this.dispatchEvent(new Js("frameratechange",{session:this})),console.log(`Nominal frame rate updated to ${e}`)),t()):n(new DOMException("Requested frame rate not supported.","InvalidStateError"))})}async requestReferenceSpace(e){return new Promise((t,n)=>{if(this[ka].ended||!this[ka].referenceSpaceIsSupported(e))return void n(new DOMException("The requested reference space type is not supported.","NotSupportedError"));let i;switch(e){case Ys.Viewer:i=this[ka].device.viewerSpace;break;case Ys.Local:i=new Qs(e,this[ka].device[ba].globalSpace,this[ka].device.viewerSpace[Ua].offsetMatrix);break;case Ys.LocalFloor:case Ys.BoundedFloor:case Ys.Unbounded:i=new Qs(e,this[ka].device[ba].globalSpace)}this[ka].referenceSpaces.push(i),t(i)})}requestAnimationFrame(e){if(this[ka].ended)return 0;const t=++this[ka].frameHandle;return this[ka].frameCallbacks.push({handle:t,callback:e,cancelled:!1}),t}cancelAnimationFrame(e){let t=this[ka].frameCallbacks,n=t.findIndex(t=>t&&t.handle===e);n>-1&&(t[n].cancelled=!0,t.splice(n,1)),t=this[ka].currentFrameCallbacks,t&&(n=t.findIndex(t=>t&&t.handle===e),n>-1&&(t[n].cancelled=!0))}async end(){return new Promise((e,t)=>{var n;if(this[ka].ended)t(new DOMException("XRSession has already ended.","InvalidStateError"));else{if(this[ka].ended=!0,globalThis.cancelAnimationFrame(this[ka].deviceFrameHandle),this[ka].deviceFrameHandle=void 0,this[ka].device[ba].onSessionEnd(),this[ka].frameCallbacks.length=0,this[ka].currentFrameCallbacks=null,this[ka].referenceSpaces.length=0,this[ka].hitTestSources.clear(),this[ka].trackedPlanes.clear(),this[ka].trackedMeshes.clear(),this[ka].trackedAnchors.clear(),this[ka].frameTrackedAnchors.clear(),this[ka].newAnchors.forEach(({reject:e})=>{e(new DOMException("XRSession has ended before the anchor was resolved.","InvalidStateError"))}),this[ka].newAnchors.clear(),this[ka].depthTexture){const e=null===(n=this[ka].renderState.baseLayer)||void 0===n?void 0:n.context;null==e||e.deleteTexture(this[ka].depthTexture),this[ka].depthTexture=null}this.dispatchEvent(new Js("end",{session:this})),e()}})}get persistentAnchors(){return Array.from(this[ka].persistentAnchors.keys())}restorePersistentAnchor(e){return new Promise((t,n)=>{if(this[ka].persistentAnchors.has(e))if(this[ka].ended)n(new DOMException("XRSession has already ended.","InvalidStateError"));else{const i=this[ka].persistentAnchors.get(e);this[ka].newAnchors.has(i)?n(new DOMException(`Multiple concurrent attempts detected to restore the anchor with UUID: ${e}.`,"InvalidStateError")):(this[ka].trackedAnchors.add(i),this[ka].newAnchors.set(i,{resolve:t,reject:n}))}else n(new DOMException(`Persistent anchor with uuid ${e} not found.`,"InvalidStateError"))})}deletePersistentAnchor(e){return new Promise((t,n)=>{if(this[ka].persistentAnchors.has(e)){const n=this[ka].persistentAnchors.get(e);this[ka].persistentAnchors.delete(e),n.delete(),t(void 0)}else n(new DOMException(`Persistent anchor with uuid ${e} not found.`,"InvalidStateError"))})}requestHitTestSource(e){return new Promise((t,n)=>{if(this[ka].enabledFeatures.includes("hit-test"))if(this[ka].ended)n(new DOMException("XRSession has already ended.","InvalidStateError"));else if(this[ka].device[ba].sem){const n=new js(this,e);this[ka].hitTestSources.add(n),t(n)}else n(new DOMException("Synthethic Environment Module required for emulating hit-test","OperationError"));else n(new DOMException('WebXR feature "hit-test" is not supported by current session',"NotSupportedError"))})}get onend(){return this[ka].onend}set onend(e){this[ka].onend&&this.removeEventListener("end",this[ka].onend),this[ka].onend=e,e&&this.addEventListener("end",e)}get oninputsourceschange(){return this[ka].oninputsourceschange}set oninputsourceschange(e){this[ka].oninputsourceschange&&this.removeEventListener("inputsourceschange",this[ka].oninputsourceschange),this[ka].oninputsourceschange=e,e&&this.addEventListener("inputsourceschange",e)}get onselect(){return this[ka].onselect}set onselect(e){this[ka].onselect&&this.removeEventListener("select",this[ka].onselect),this[ka].onselect=e,e&&this.addEventListener("select",e)}get onselectstart(){return this[ka].onselectstart}set onselectstart(e){this[ka].onselectstart&&this.removeEventListener("selectstart",this[ka].onselectstart),this[ka].onselectstart=e,e&&this.addEventListener("selectstart",e)}get onselectend(){return this[ka].onselectend}set onselectend(e){this[ka].onselectend&&this.removeEventListener("selectend",this[ka].onselectend),this[ka].onselectend=e,e&&this.addEventListener("selectend",e)}get onsqueeze(){return this[ka].onsqueeze}set onsqueeze(e){this[ka].onsqueeze&&this.removeEventListener("squeeze",this[ka].onsqueeze),this[ka].onsqueeze=e,e&&this.addEventListener("squeeze",e)}get onsqueezestart(){return this[ka].onsqueezestart}set onsqueezestart(e){this[ka].onsqueezestart&&this.removeEventListener("squeezestart",this[ka].onsqueezestart),this[ka].onsqueezestart=e,e&&this.addEventListener("squeezestart",e)}get onsqueezeend(){return this[ka].onsqueezeend}set onsqueezeend(e){this[ka].onsqueezeend&&this.removeEventListener("squeezeend",this[ka].onsqueezeend),this[ka].onsqueezeend=e,e&&this.addEventListener("squeezeend",e)}get onvisibilitychange(){return this[ka].onvisibilitychange}set onvisibilitychange(e){this[ka].onvisibilitychange&&this.removeEventListener("visibilitychange",this[ka].onvisibilitychange),this[ka].onvisibilitychange=e,e&&this.addEventListener("visibilitychange",e)}get onframeratechange(){return this[ka].onframeratechange}set onframeratechange(e){this[ka].onframeratechange&&this.removeEventListener("frameratechange",this[ka].onframeratechange),this[ka].onframeratechange=e,e&&this.addEventListener("frameratechange",e)}}!function(e){e.Wrist="wrist",e.ThumbMetacarpal="thumb-metacarpal",e.ThumbPhalanxProximal="thumb-phalanx-proximal",e.ThumbPhalanxDistal="thumb-phalanx-distal",e.ThumbTip="thumb-tip",e.IndexFingerMetacarpal="index-finger-metacarpal",e.IndexFingerPhalanxProximal="index-finger-phalanx-proximal",e.IndexFingerPhalanxIntermediate="index-finger-phalanx-intermediate",e.IndexFingerPhalanxDistal="index-finger-phalanx-distal",e.IndexFingerTip="index-finger-tip",e.MiddleFingerMetacarpal="middle-finger-metacarpal",e.MiddleFingerPhalanxProximal="middle-finger-phalanx-proximal",e.MiddleFingerPhalanxIntermediate="middle-finger-phalanx-intermediate",e.MiddleFingerPhalanxDistal="middle-finger-phalanx-distal",e.MiddleFingerTip="middle-finger-tip",e.RingFingerMetacarpal="ring-finger-metacarpal",e.RingFingerPhalanxProximal="ring-finger-phalanx-proximal",e.RingFingerPhalanxIntermediate="ring-finger-phalanx-intermediate",e.RingFingerPhalanxDistal="ring-finger-phalanx-distal",e.RingFingerTip="ring-finger-tip",e.PinkyFingerMetacarpal="pinky-finger-metacarpal",e.PinkyFingerPhalanxProximal="pinky-finger-phalanx-proximal",e.PinkyFingerPhalanxIntermediate="pinky-finger-phalanx-intermediate",e.PinkyFingerPhalanxDistal="pinky-finger-phalanx-distal",e.PinkyFingerTip="pinky-finger-tip"}(go||(go={}));class yo extends Map{}class xo extends ja{constructor(e,t,n){super(t,n),this[Fa]={jointName:e,radius:0}}get jointName(){return this[Fa].jointName}}const bo={profileId:"oculus-hand",fallbackProfileIds:["generic-hand","generic-hand-select","generic-trigger"],poses:{default:{jointTransforms:{wrist:{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.04913589730858803,.0021463718730956316,.11701996624469757,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[-.07536252588033676,-.9959676265716553,-.04867160692811012,0,.5877083539962769,-.08379616588354111,.8047218918800354,0,-.8055551648139954,.032041035592556,.5916536450386047,0,-.010643752291798592,.0006936835707165301,.08736639469861984,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[.1374533325433731,-.9904957413673401,.004982374142855406,0,.5534393787384033,.08097179979085922,.8289443850517273,0,-.8214688897132874,-.11118389666080475,.559309184551239,0,.015547193586826324,-.0003480653394944966,.0681300163269043,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[-.04659227654337883,-.9974699020385742,-.05369402840733528,0,.6812446117401123,-.07104194164276123,.728600800037384,0,-.7305715084075928,-.002631746232509613,.6828309893608093,0,.04330715537071228,.003409178927540779,.0492292083799839,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[-.04659227654337883,-.9974699020385742,-.05369402840733528,0,.6812446117401123,-.07104194164276123,.728600800037384,0,-.7305715084075928,-.002631746232509613,.6828309893608093,0,.062003348022699356,.004069602582603693,.03322213143110275,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.02009812369942665,.008770795539021492,.08660387247800827,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.9001791477203369,-.2598813474178314,.3494834005832672,0,.06073702871799469,.8695210218429565,.490146666765213,0,-.4312632381916046,-.41999316215515137,.7985095381736755,0,-.00017739279428496957,.03890012577176094,.039073407649993896,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.9082008600234985,-.20898112654685974,.36262574791908264,0,.11045389622449875,.9553793668746948,.27395179867744446,0,-.40369608998298645,-.20874978601932526,.8907597661018372,0,.01617925800383091,.05482936650514603,.008788082748651505,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.9309692978858948,-.16783711314201355,.32423174381256104,0,.1080828532576561,.9749603867530823,.1943446695804596,0,-.34873148798942566,-.14588497579097748,.9257990717887878,0,.02599053829908371,.059902746230363846,-.012860597111284733,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.9309692978858948,-.16783711314201355,.32423174381256104,0,.1080828532576561,.9749603867530823,.1943446695804596,0,-.34873148798942566,-.14588497579097748,.9257990717887878,0,.03362493962049484,.06421422213315964,-.033461250364780426,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.03627845644950867,.011579737067222595,.08550142496824265,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9876697659492493,-.06786545366048813,.1410750150680542,0,-.015095947310328484,.855663537979126,.5173118710517883,0,-.15582047402858734,-.5130629539489746,.8440889716148376,0,-.021259509027004242,.04587256908416748,.03659208118915558,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.988391637802124,-.04354291781783104,.14555205404758453,0,.008894841186702251,.9729899168014526,.23067504167556763,0,-.15166506171226501,-.22670257091522217,.9620829224586487,0,-.014570588245987892,.06789684295654297,.0003578895702958107,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9853697419166565,.044260796159505844,.16458062827587128,0,-.0757969319820404,.9787378311157227,.19059516489505768,0,-.1526455283164978,-.20028135180473328,.9677740931510925,0,-.010392282158136368,.07414241135120392,-.026147106662392616,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9853697419166565,.044260796159505844,.16458062827587128,0,-.0757969319820404,.9787378311157227,.19059516489505768,0,-.1526455283164978,-.20028135180473328,.9677740931510925,0,-.0069718430750072,.08024183660745621,-.05014154314994812,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9616971015930176,-.13805118203163147,.2368120402097702,0,.0005348679260350764,.8648636937141418,.5020061135292053,0,-.2741127610206604,-.48265108466148376,.8318111300468445,0,-.05402477830648422,.015797706320881844,.08152295649051666,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9940828680992126,.05735103040933609,.09224652498960495,0,-.10022822767496109,.8116500377655029,.5754809379577637,0,-.041867565363645554,-.5813214182853699,.8125960826873779,0,-.041623555123806,.04171867296099663,.03582974523305893,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9843675494194031,.12044742703437805,.12850022315979004,0,-.15629759430885315,.9337108135223389,.3221098482608795,0,-.08118485659360886,-.3371586799621582,.937940776348114,0,-.039990875869989395,.06438793987035751,.004141641780734062,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9748351573944092,.11857274919748306,.18877571821212769,0,-.15575434267520905,.9681083559989929,.19623035192489624,0,-.15948788821697235,-.22069483995437622,.9622148275375366,0,-.03783353418111801,.07334739714860916,-.020782606676220894,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9748351573944092,.11857274919748306,.18877571821212769,0,-.15575434267520905,.9681083559989929,.19623035192489624,0,-.15948788821697235,-.22069483995437622,.9622148275375366,0,-.03445569798350334,.0802423357963562,-.04392268508672714,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.9181402921676636,.35625091195106506,.17350243031978607,0,-.39615097641944885,.8352503180503845,.38134080171585083,0,-.009065053425729275,-.41885748505592346,.9080066680908203,0,-.06191859766840935,.013620133511722088,.07850203663110733,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9714386463165283,.236698180437088,-.016745081171393394,0,-.18462024629116058,.7982627749443054,.5733163952827454,0,.14906984567642212,-.5538501739501953,.8191629648208618,0,-.061502378433942795,.032741155475378036,.03705105185508728,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9337416291236877,.35620439052581787,-.03527557849884033,0,-.33203884959220886,.8987522721290588,.28634607791900635,0,.13370157778263092,-.2556603252887726,.9574766755104065,0,-.06608185172080994,.049755651503801346,.011886020191013813,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9419984817504883,.3303581774234772,.059175245463848114,0,-.33483216166496277,.9130291938781738,.23294763267040253,0,.02292730286717415,-.2392500638961792,.970687210559845,0,-.0687975287437439,.054948460310697556,-.007561664097011089,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9419984817504883,.3303581774234772,.059175245463848114,0,-.33483216166496277,.9130291938781738,.23294763267040253,0,.02292730286717415,-.2392500638961792,.970687210559845,0,-.06947512179613113,.0613851435482502,-.028543535619974136,1],radius:.005425984505563974}},gripOffsetMatrix:[-.0005348679260350764,-.8648636937141418,-.5020061135292053,0,-.2741127908229828,-.48265108466148376,.8318111896514893,0,-.9616971015930176,.13805119693279266,-.2368120402097702,0,-.02878567762672901,.0017147823236882687,.04536811262369156,1]},pinch:{jointTransforms:{wrist:{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.06867414712905884,-.009423808194696903,.10627774149179459,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[-.5012241005897522,-.8650535345077515,-.0213695727288723,0,.7415963411331177,-.4421543478965759,.5045139193534851,0,-.44587990641593933,.23702676594257355,.8631392121315002,0,-.032122574746608734,-.01196830440312624,.07194234430789948,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[-.3175753057003021,-.9460570216178894,-.06419729441404343,0,.8958902955055237,-.32153913378715515,.30658137798309326,0,-.3106854259967804,.03984907269477844,.9496771097183228,0,-.017625702545046806,-.01967475935816765,.04387917369604111,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[-.4944636821746826,-.8691971898078918,.001086252392269671,0,.8307800889015198,-.4722411036491394,.2946045398712158,0,-.25555649399757385,.14657381176948547,.9556186199188232,0,-.007126678712666035,-.021021386608481407,.011786630377173424,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[-.4944636821746826,-.8691971898078918,.001086252392269671,0,.8307800889015198,-.4722411036491394,.2946045398712158,0,-.25555649399757385,.14657381176948547,.9556186199188232,0,.0003423091256991029,-.024528030306100845,-.011410919018089771,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.038037415593862534,-.0020236473064869642,.07626739144325256,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.7986818552017212,-.35985732078552246,.48229536414146423,0,.538311243057251,.7854709625244141,-.30537736415863037,0,-.2689369022846222,.5035246014595032,.8210577368736267,0,-.006869405973702669,.033938243985176086,.04206443578004837,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.8285930156707764,-.32672837376594543,.4546217918395996,0,.5577570199966431,.4116027057170868,-.7207564115524292,0,.04836784675717354,.8507823944091797,.5232869386672974,0,.0033306588884443045,.014840902760624886,.010923954658210278,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.8412464261054993,-.35794928669929504,.4051857888698578,0,.5139996409416199,.29711154103279114,-.8046918511390686,0,.16765329241752625,.8852096796035767,.4339304566383362,0,.0021551470272243023,-.0058362227864563465,-.0017938464879989624,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.8412464261054993,-.35794928669929504,.4051857888698578,0,.5139996409416199,.29711154103279114,-.8046918511390686,0,.16765329241752625,.8852096796035767,.4339304566383362,0,-.00131594471167773,-.025222131982445717,-.012442642822861671,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.05395089089870453,.003063359996303916,.07402937114238739,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9187911748886108,-.1530158370733261,.36387869715690613,0,.038666240870952606,.9522662162780762,.302808940410614,0,-.3928440511226654,-.26414817571640015,.8808513283729553,0,-.02717282809317112,.04162866622209549,.03678669035434723,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.9228746294975281,-.12856416404247284,.36300456523895264,0,.14524033665657043,.9892153143882751,-.01890045404434204,0,-.3566599190235138,.07016586512327194,.9315956234931946,0,-.01030921470373869,.05296773463487625,-.0010256498353555799,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9325166344642639,-.040404170751571655,.35885775089263916,0,.06836572289466858,.995502769947052,-.0655682161450386,0,-.3545948565006256,.08567725121974945,.9310863614082336,0,-.0004833847051486373,.05103470757603645,-.026690717786550522,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9325166344642639,-.040404170751571655,.35885775089263916,0,.06836572289466858,.995502769947052,-.0655682161450386,0,-.3545948565006256,.08567725121974945,.9310863614082336,0,.008158999495208263,.05004044249653816,-.050120558589696884,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9060805439949036,-.1844543218612671,.3807799518108368,0,-.08027800172567368,.8086723685264587,.5827555656433105,0,-.4154181182384491,-.5585917234420776,.7179155349731445,0,-.06732909381389618,.007902119308710098,.07209732383489609,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9391821026802063,-.027994679287075996,.34227466583251953,0,-.18282271921634674,.8029410243034363,.5673282742500305,0,-.2907087206840515,-.5954000353813171,.7489906549453735,0,-.047129884362220764,.03806127607822418,.032147664576768875,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9249380826950073,.03699534013867378,.3783116042613983,0,-.12898847460746765,.9667453765869141,.2208271026611328,0,-.3575615882873535,-.25304901599884033,.8989526629447937,0,-.03579339757561684,.06127955764532089,.002939916681498289,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9001164436340332,.03983335196971893,.4338230490684509,0,-.09662467986345291,.9892624020576477,.10964841395616531,0,-.4247973561286926,-.14061418175697327,.8943013548851013,0,-.026291755959391594,.06800390034914017,-.02094830758869648,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9001164436340332,.03983335196971893,.4338230490684509,0,-.09662467986345291,.9892624020576477,.10964841395616531,0,-.4247973561286926,-.14061418175697327,.8943013548851013,0,-.016345610842108727,.07300511747598648,-.04263874143362045,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.8769711852073669,.31462907791137695,.36322021484375,0,-.4506046175956726,.801031768321991,.39408499002456665,0,-.16696058213710785,-.5092697143554688,.8442559838294983,0,-.07460174709558487,.0062340241856873035,.06756893545389175,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9498357176780701,.1553308218717575,.2714462876319885,0,-.3019258379936218,.6817675232887268,.6663586497306824,0,-.08155745267868042,-.7148879170417786,.694466233253479,0,-.06697750836610794,.029482364654541016,.02902858518064022,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9214097261428833,.27928245067596436,.2701927423477173,0,-.3670244514942169,.8538867831230164,.36901235580444336,0,-.12765564024448395,-.43917882442474365,.8892839550971985,0,-.06447203457355499,.05144399777054787,.0076942890882492065,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9038633704185486,.23618005216121674,.3567195236682892,0,-.3532794713973999,.8823202252388,.3109731376171112,0,-.24129553139209747,-.4070987403392792,.8809353709220886,0,-.06187915802001953,.060364335775375366,-.010368337854743004,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9038633704185486,.23618005216121674,.3567195236682892,0,-.3532794713973999,.8823202252388,.3109731376171112,0,-.24129553139209747,-.4070987403392792,.8809353709220886,0,-.056796226650476456,.07042007893323898,-.02921444922685623,1],radius:.005425984505563974}},gripOffsetMatrix:[.08027800917625427,-.8086723685264587,-.5827556252479553,0,-.4154181480407715,-.5585916638374329,.7179154753684998,0,-.9060805439949036,.1844543218612671,-.3807799518108368,0,-.038054611533880234,-.002910431008785963,.03720742464065552,1]},point:{jointTransforms:{wrist:{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.05789132043719292,.01670890860259533,.11183350533246994,1],radius:.021460847929120064},"thumb-metacarpal":{offsetMatrix:[.02145560085773468,-.9978390336036682,.0621047280728817,0,.41311800479888916,.06541631370782852,.9083252549171448,0,-.9104245901107788,.006167683284729719,.4136286973953247,0,-.016488194465637207,.012708572670817375,.08862338215112686,1],radius:.019382517784833908},"thumb-phalanx-proximal":{offsetMatrix:[.21270370483398438,-.966137707233429,.14606566727161407,0,.49890995025634766,.2359165996313095,.8339261412620544,0,-.8401462435722351,-.10450579971075058,.5321959853172302,0,.013112368993461132,.012508046813309193,.07517509907484055,1],radius:.01228295173496008},"thumb-phalanx-distal":{offsetMatrix:[.01653280481696129,-.9986647963523865,.048943229019641876,0,.26313456892967224,.051570065319538116,.9633802771568298,0,-.9646173715591431,-.0030490627977997065,.26363563537597656,0,.04150351136922836,.016039609909057617,.05719054117798805,1],radius:.009768804535269737},"thumb-tip":{offsetMatrix:[.01653280481696129,-.9986647963523865,.048943229019641876,0,.26313456892967224,.051570065319538116,.9633802771568298,0,-.9646173715591431,-.0030490627977997065,.26363563537597656,0,.06548332422971725,.01683700829744339,.0516640841960907,1],radius:.008768804371356964},"index-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.02592567168176174,.019982583820819855,.08479326963424683,1],radius:.021228281781077385},"index-finger-phalanx-proximal":{offsetMatrix:[.9063700437545776,-.21756279468536377,.3621589243412018,0,.0970839336514473,.9415287375450134,.3226419687271118,0,-.41117796301841736,-.2572731077671051,.8744958639144897,0,-.0015709538711234927,.043078210204839706,.034657616168260574,1],radius:.010295259766280651},"index-finger-phalanx-intermediate":{offsetMatrix:[.9159826040267944,-.1651475727558136,.36565208435058594,0,.09755707532167435,.9756820797920227,.1962820291519165,0,-.3891757130622864,-.14411886036396027,.9098196625709534,0,.014023927971720695,.052835866808891296,.0014903299743309617,1],radius:.00853810179978609},"index-finger-phalanx-distal":{offsetMatrix:[.9378057718276978,-.12329639494419098,.3245268166065216,0,.032558172941207886,.9619227051734924,.2713746726512909,0,-.3456292748451233,-.2439306229352951,.9061115384101868,0,.023482320830225945,.05633850023150444,-.020621655508875847,1],radius:.007636196445673704},"index-finger-tip":{offsetMatrix:[.9378057718276978,-.12329639494419098,.3245268166065216,0,.032558172941207886,.9619227051734924,.2713746726512909,0,-.3456292748451233,-.2439306229352951,.9061115384101868,0,.03096788562834263,.06281610578298569,-.040703095495700836,1],radius:.006636196281760931},"middle-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.04184452444314957,.022474845871329308,.08177298307418823,1],radius:.021231964230537415},"middle-finger-phalanx-proximal":{offsetMatrix:[.9720265865325928,-.08313076198101044,.21966552734375,0,.20477405190467834,.7580050826072693,-.6192700862884521,0,-.11502730846405029,.6469289064407349,.7538246512413025,0,-.022107340395450592,.05035499855875969,.02970452979207039,1],radius:.01117393933236599},"middle-finger-phalanx-intermediate":{offsetMatrix:[.9779140949249268,-.07129573822021484,.19646917283535004,0,.1287083923816681,-.5352076292037964,-.8348574042320251,0,.1646735966205597,.8417060971260071,-.5142109394073486,0,-.017169542610645294,.022584279999136925,-.00265491777099669,1],radius:.008030958473682404},"middle-finger-phalanx-distal":{offsetMatrix:[.9774913787841797,-.19657190144062042,.07661263644695282,0,-.1924918293952942,-.9796126484870911,-.05749811604619026,0,.08635343611240387,.041456472128629684,-.995401918888092,0,-.02170622907578945,-.0006043742760084569,.011511396616697311,1],radius:.007629410829395056},"middle-finger-tip":{offsetMatrix:[.9774913787841797,-.19657190144062042,.07661263644695282,0,-.1924918293952942,-.9796126484870911,-.05749811604619026,0,.08635343611240387,.041456472128629684,-.995401918888092,0,-.02438267692923546,-.0026927536819130182,.03627248480916023,1],radius:.006629410665482283},"ring-finger-metacarpal":{offsetMatrix:[.9340395331382751,-.13936476409435272,.32885703444480896,0,-.005510995630174875,.914999783039093,.40341612696647644,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.05944233387708664,.0264605600386858,.07478221505880356,1],radius:.019088275730609894},"ring-finger-phalanx-proximal":{offsetMatrix:[.9842101335525513,.024470895528793335,.1753024309873581,0,.12200043350458145,.6237703561782837,-.7720272541046143,0,-.12824076414108276,.7812241315841675,.610936164855957,0,-.04249368980526924,.0467497780919075,.027722163125872612,1],radius:.00992213748395443},"ring-finger-phalanx-intermediate":{offsetMatrix:[.9941774606704712,.05949164181947708,.08983955532312393,0,.10504482686519623,-.7208291888237,-.6851072907447815,0,.024001073092222214,.6905553936958313,-.7228817939758301,0,-.0374927744269371,.016285063698887825,.0038980208337306976,1],radius:.007611672393977642},"ring-finger-phalanx-distal":{offsetMatrix:[.9995742440223694,.01638498157262802,.02412819117307663,0,.007813597097992897,-.9474818110466003,.31971633434295654,0,.028100071474909782,-.31939181685447693,-.9472070932388306,0,-.038130562752485275,-.0020653479732573032,.02310742810368538,1],radius:.007231088820844889},"ring-finger-tip":{offsetMatrix:[.9995742440223694,.01638498157262802,.02412819117307663,0,.007813597097992897,-.9474818110466003,.31971633434295654,0,.028100071474909782,-.31939181685447693,-.9472070932388306,0,-.0390593595802784,.004176302347332239,.0466572530567646,1],radius:.0062310886569321156},"pinky-finger-metacarpal":{offsetMatrix:[.9147363901138306,.3458845317363739,.20885537564754486,0,-.3923271894454956,.8839452862739563,.2544005811214447,0,-.09662359952926636,-.3146490156650543,.9442773461341858,0,-.06715242564678192,.024195827543735504,.07137546688318253,1],radius:.01808827556669712},"pinky-finger-phalanx-proximal":{offsetMatrix:[.9613109827041626,.22439135611057281,.15977802872657776,0,.01002211682498455,.5511574745178223,-.8343409299850464,0,-.27528178691864014,.8036624789237976,.5275853276252747,0,-.06273911893367767,.038559623062610626,.028268879279494286,1],radius:.008483353070914745},"pinky-finger-phalanx-intermediate":{offsetMatrix:[.9820972084999084,.18811029195785522,-.00995189044624567,0,.14063723385334015,-.7673450708389282,-.6256227493286133,0,-.12532226741313934,.6130226850509644,-.7800630927085876,0,-.05428232625126839,.013870777562260628,.012061242014169693,1],radius:.0067641944624483585},"pinky-finger-phalanx-distal":{offsetMatrix:[.9744614362716675,.20454788208007812,-.09265263378620148,0,.22429193556308746,-.9065253138542175,.35764020681381226,0,-.010836843401193619,-.3692878782749176,-.9292529225349426,0,-.05173685774207115,.0014194445684552193,.02790539152920246,1],radius:.0064259846694767475},"pinky-finger-tip":{offsetMatrix:[.9744614362716675,.20454788208007812,-.09265263378620148,0,.22429193556308746,-.9065253138542175,.35764020681381226,0,-.010836843401193619,-.3692878782749176,-.9292529225349426,0,-.05098633095622063,.008463085629045963,.048688892275094986,1],radius:.005425984505563974}},gripOffsetMatrix:[.005510995630174875,-.9149997234344482,-.40341615676879883,0,-.3571262061595917,-.37861889600753784,.8538784384727478,0,-.9340395331382751,.13936474919319153,-.32885703444480896,0,-.031803809106349945,.007837686687707901,.04313928261399269,1]}}},_o={mapping:ps.None,buttons:[{id:"pinch",type:"analog",eventTrigger:"select"}],axes:[]},wo=Kr(),So=oa(),Eo=Kr(),Mo=Kr(),To=oa(),Ao=Kr(),Ro=Kr(),Po=oa(),Co=Kr(),Lo=(e,t,n,i)=>(Xr(wo,t),$r(So,t),qr(Eo,t),Xr(Mo,n),$r(To,n),qr(Ao,n),ia(Ro,wo,Mo,i),ua(Po,So,To,i),ia(Co,Eo,Ao,i),function(e,t,n,i){var r=t[0],a=t[1],s=t[2],o=t[3],l=r+r,c=a+a,u=s+s,d=r*l,h=r*c,p=r*u,f=a*c,m=a*u,g=s*u,v=o*l,y=o*c,x=o*u,b=i[0],_=i[1],w=i[2];e[0]=(1-(f+g))*b,e[1]=(h+x)*b,e[2]=(p-y)*b,e[3]=0,e[4]=(h-x)*_,e[5]=(1-(d+g))*_,e[6]=(m+v)*_,e[7]=0,e[8]=(p+y)*w,e[9]=(m-v)*w,e[10]=(1-(d+f))*w,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1}(e,Po,Ro,Co),e),Io=[1,-1,-1,0,-1,1,1,0,-1,1,1,0,-1,1,1,1];class Do extends Es{constructor(e,t,n){if(t!==fs.Left&&t!==fs.Right)throw new DOMException('handedness for XRHandInput must be either "left" or "right"',"InvalidStateError");if(!e.poses.default||!e.poses.pinch)throw new DOMException('"default" and "pinch" hand pose configs are required',"InvalidStateError");const i=new ja(n),r=new ja(i),a=[e.profileId,...e.fallbackProfileIds],s=new yo;Object.values(go).forEach(e=>{s.set(e,new xo(e,i))});super(new _s(t,ms.TrackedPointer,a,i,new xs(_o),r,s)),this[_a]={poseId:"default",poses:e.poses},this.updateHandPose()}get poseId(){return this[_a].poseId}set poseId(e){this[_a].poses[e]?this[_a].poseId=e:console.warn(`Pose config ${e} not found`)}updateHandPose(){const e=this[_a].poses[this[_a].poseId],t=this[_a].poses.pinch;Object.values(go).forEach(n=>{const i=e.jointTransforms[n].offsetMatrix,r=t.jointTransforms[n].offsetMatrix,a=this.inputSource.hand.get(n);Lo(a[Ua].offsetMatrix,i,r,this.pinchValue),this.inputSource.handedness===fs.Right&&(e=>{for(let t=0;t<16;t++)e[t]*=Io[t]})(a[Ua].offsetMatrix),a[Fa].radius=(1-this.pinchValue)*e.jointTransforms[n].radius+this.pinchValue*t.jointTransforms[n].radius}),e.gripOffsetMatrix&&t.gripOffsetMatrix&&Lo(this.inputSource.gripSpace[Ua].offsetMatrix,e.gripOffsetMatrix,t.gripOffsetMatrix,this.pinchValue)}get pinchValue(){return this[wa].inputSource.gamepad[Ea].buttonsMap.pinch.value}updatePinchValue(e){if(e>1||e<0)return void console.warn(`Out-of-range value ${e} provided for pinch`);this[wa].inputSource.gamepad[Ea].buttonsMap.pinch[Ea].pendingValue=e}setPinchValueImmediate(e){if(e>1||e<0)return void console.warn(`Out-of-range value ${e} provided for pinch`);const t=this[wa].inputSource.gamepad[Ea].buttonsMap.pinch;null===t[Ea].immediateTransitionFrom&&(t[Ea].immediateTransitionFrom=t[Ea].value),t[Ea].value=e,t[Ea].pendingValue=e}onFrameStart(e){super.onFrameStart(e),this.updateHandPose()}}class No extends EventTarget{}const ko={antialias:!0,depth:!0,stencil:!1,alpha:!0,ignoreDepthValues:!1,framebufferScaleFactor:1};let Fo=class extends No{constructor(e,t,n={}){if(super(),e[ka].ended)throw new DOMException("Session has ended","InvalidStateError");const i={...ko,...n};this[Aa]={session:e,context:t,antialias:i.antialias}}get context(){return this[Aa].context}get antialias(){return this[Aa].antialias}get ignoreDepthValues(){return!0}get framebuffer(){return null}get framebufferWidth(){return this[Aa].context.drawingBufferWidth}get framebufferHeight(){return this[Aa].context.drawingBufferHeight}getViewport(e){if(e[za].session!==this[Aa].session)throw new DOMException("View's session differs from Layer's session","InvalidStateError");return this[Aa].session[ka].device[ba].getViewport(this,e)}static getNativeFramebufferScaleFactor(e){if(!(e instanceof vo))throw new TypeError("getNativeFramebufferScaleFactor must be passed a session.");return e[ka].ended?0:1}};class Oo{constructor(e,t,n,i={}){var r;const{schema:a,frames:s}=t;if(!s||!a||0===s.length)throw new DOMException("wrong recording format","NotSupportedError");const o=new Qs(Ys.Viewer,e),l={[Ks.Left]:new ja(o),[Ks.Right]:new ja(o),[Ks.None]:new ja(o)};this[va]={refSpace:e,inputSources:new Map,inputSchemas:new Map,frames:s,recordedFramePointer:0,startingTimeStamp:s[0][0],endingTimeStamp:s[s.length-1][0],playbackTime:s[0][0],playing:!1,autoAdvance:!0,manualFrameActive:!1,viewerSpace:o,viewSpaces:l,vec3:Kr(),quat:oa(),f1p:Kr(),f1q:oa(),f2p:Kr(),f2q:oa(),lastFrameInputs:new Map,nextFrameInputs:new Map,loop:null!==(r=i.loop)&&void 0!==r&&r,playbackRate:null!=i.playbackRate&&i.playbackRate>0?i.playbackRate:1,eventContext:i.eventContext,lastEventFramePointer:-1},Gr(this[va].viewSpaces[Ks.Left][Ua].offsetMatrix,Qr(-n/2,0,0)),Gr(this[va].viewSpaces[Ks.Right][Ua].offsetMatrix,Qr(n/2,0,0)),a.forEach(t=>{const n=t[0],i=t[1];let r;if(i.hasGamepad){const e=[];for(let t=0;t<i.numButtons;t++)e.push({id:t.toString(),type:"manual"});const t=[];for(let e=0;e<i.numAxes;e++)t.push({id:e.toString(),type:"manual"});r=new xs({mapping:i.mapping,buttons:e,axes:t})}const a=new ja(e);let s;i.hasHand&&(s=new yo,Object.values(go).forEach(e=>{s.set(e,new xo(e,a))}));const o=new _s(i.handedness,i.targetRayMode,i.profiles,a,r,i.hasGrip?new ja(e):void 0,i.hasHand?s:void 0);this[va].inputSources.set(n,{active:!1,source:o}),this[va].inputSchemas.set(n,i)}),s.forEach((e,t)=>{for(let n=8;n<e.length;n++){const i=e[n],r=i[0],a=this[va].inputSchemas.get(r);if(!a)throw new DOMException(`recording frame ${t} references unknown input source ${r}`,"NotSupportedError");if(a.hasGamepad){let e=8;a.hasGrip&&e++,a.hasHand&&e++;const n=i[e],s=a.numButtons+a.numAxes;if(!Array.isArray(n)||n.length!==s){const e=Array.isArray(n)?n.length:"no";throw new DOMException(`recording frame ${t} input source ${r} has ${e} gamepad entries, expected ${s} (${a.numButtons} buttons + ${a.numAxes} axes)`,"NotSupportedError")}}}})}play(){var e,t;null===(t=null===(e=this[va].eventContext)||void 0===e?void 0:e.onDiscontinuity)||void 0===t||t.call(e),this[va].recordedFramePointer=0,this[va].playbackTime=this[va].startingTimeStamp,this[va].playing=!0,this[va].autoAdvance=!0,this[va].manualFrameActive=!1,this[va].actualTimeStamp=performance.now(),this[va].lastEventFramePointer=-1}stop(){this[va].playing=!1,this[va].autoAdvance=!0,this[va].manualFrameActive=!1}get playing(){return this[va].playing}get viewerSpace(){return this[va].viewerSpace}get viewSpaces(){return this[va].viewSpaces}get inputSources(){return Array.from(this[va].inputSources.values()).filter(e=>e.active).map(e=>e.source)}get loop(){return this[va].loop}set loop(e){this[va].loop=e}get playbackRate(){return this[va].playbackRate}set playbackRate(e){e>0&&(this[va].playbackRate=e)}setEventContext(e){this[va].eventContext=e}get duration(){return this[va].endingTimeStamp-this[va].startingTimeStamp}get currentTime(){return this[va].playbackTime-this[va].startingTimeStamp}seek(e){var t,n;const i=this[va],r=Math.max(0,Math.min(e,this.duration)),a=i.startingTimeStamp+r,s=this.findFramePointer(a);s!==i.recordedFramePointer&&(null===(n=null===(t=i.eventContext)||void 0===t?void 0:t.onDiscontinuity)||void 0===n||n.call(t),i.lastEventFramePointer=-1),i.playbackTime=a,i.recordedFramePointer=s,i.actualTimeStamp=performance.now()}findFramePointer(e){const t=this[va].frames;let n=0,i=t.length-1,r=0;for(;n<=i;){const a=n+i>>1;t[a][0]<=e?(r=a,n=a+1):i=a-1}return r}stepFrames(e=1){var t,n;const i=this[va],r=i.frames;i.playing=!0,i.autoAdvance=!1,i.manualFrameActive=!0;for(let a=0;a<e;a++){if(i.recordedFramePointer+1>=r.length){if(!i.loop)return i.playbackTime=i.endingTimeStamp,this.applyFrameAtPointer(0),void(i.playing=!1);null===(n=null===(t=i.eventContext)||void 0===t?void 0:t.onDiscontinuity)||void 0===n||n.call(t),i.recordedFramePointer=0,i.playbackTime=i.startingTimeStamp,i.lastEventFramePointer=-1}else i.recordedFramePointer++,i.playbackTime=r[i.recordedFramePointer][0];this.applyFrameAtPointer(0)}i.actualTimeStamp=performance.now()}playFrame(){var e,t;const n=performance.now(),i=(n-this[va].actualTimeStamp)*this[va].playbackRate;this[va].actualTimeStamp=n,this[va].playbackTime+=i;const r=this[va].frames;if(this[va].playbackTime>this[va].endingTimeStamp)if(this[va].loop){null===(t=null===(e=this[va].eventContext)||void 0===e?void 0:e.onDiscontinuity)||void 0===t||t.call(e);const n=this[va].playbackTime-this[va].endingTimeStamp,i=this.duration>0?this[va].startingTimeStamp+n%this.duration:this[va].startingTimeStamp;this[va].playbackTime=i,this[va].recordedFramePointer=this.findFramePointer(i),this[va].lastEventFramePointer=-1}else this[va].playbackTime=this[va].endingTimeStamp,this.stop();for(;this[va].recordedFramePointer+1<r.length&&r[this[va].recordedFramePointer+1][0]<this[va].playbackTime;)this[va].recordedFramePointer++;const a=this[va].recordedFramePointer+1<r.length,s=r[this[va].recordedFramePointer],o=a?r[this[va].recordedFramePointer+1]:s,l=a?(this[va].playbackTime-s[0])/(o[0]-s[0]):0;this.applyFrameAtPointer(l)}applyFrameAtPointer(e){const t=this[va].frames,n=this[va].recordedFramePointer+1<t.length,i=t[this[va].recordedFramePointer],r=n?t[this[va].recordedFramePointer+1]:i;this.updateXRSpaceFromMergedFrames(this[va].viewerSpace,i.slice(1,8),r.slice(1,8),e);const a=this[va].lastFrameInputs;a.clear();for(let e=8;e<i.length;e++){const{index:t,inputData:n}=this.processRawInputData(i[e]);a.set(t,n)}const s=this[va].nextFrameInputs;s.clear();for(let e=8;e<r.length;e++){const{index:t,inputData:n}=this.processRawInputData(r[e]);s.set(t,n)}this[va].inputSources.forEach(e=>{e.active=!1}),s.forEach((t,n)=>{this[va].inputSources.get(n).active=!0;const i=this[va].inputSources.get(n).source,r=this[va].inputSchemas.get(n);this.updateInputSource(i,r,a.has(n)?a.get(n):t,t,e)}),this.dispatchSelectSqueezeEdges()}dispatchSelectSqueezeEdges(){const e=this[va],t=e.eventContext,n=e.recordedFramePointer;if(!t)return void(e.lastEventFramePointer=n);const i=e.lastEventFramePointer;if(i<0||i===n)return void(e.lastEventFramePointer=n);const r=t.getFrame();if(!r)return void(e.lastEventFramePointer=n);const a=e.frames,s=n>i?1:-1;for(let e=i;e!==n;e+=s){const n=s>0?e:e-1,i=n+1;this.dispatchEdgesBetweenFrames(a[n],a[i],t,r)}e.lastEventFramePointer=n}dispatchEdgesBetweenFrames(e,t,n,i){var r;const a=new Map;for(let t=8;t<e.length;t++){const{index:n,inputData:i}=this.processRawInputData(e[t]);a.set(n,i)}for(let e=8;e<t.length;e++){const{index:s,inputData:o}=this.processRawInputData(t[e]),l=this[va].inputSchemas.get(s);if(!l||!l.hasGamepad||!o.buttons)continue;const c=a.get(s);if(!c||!c.buttons)continue;const u=null===(r=this[va].inputSources.get(s))||void 0===r?void 0:r.source;u&&o.buttons.forEach((e,t)=>{var r,a;const s=this.eventTriggerForButton(l,t);if(null==s)return;const o=null!==(a=null===(r=c.buttons[t])||void 0===r?void 0:r[2])&&void 0!==a?a:0,d=e[2];0===o&&d>0?(n.session.dispatchEvent(new ws(s,{frame:i,inputSource:u})),n.session.dispatchEvent(new ws(s+"start",{frame:i,inputSource:u}))):o>0&&0===d&&n.session.dispatchEvent(new ws(s+"end",{frame:i,inputSource:u}))})}}eventTriggerForButton(e,t){return e.mapping!==ps.XRStandard?null:0===t?"select":1===t?"squeeze":null}updateInputSource(e,t,n,i,r){if(this.updateXRSpaceFromMergedFrames(e.targetRaySpace,n.targetRayTransform,i.targetRayTransform,r),t.hasGrip&&this.updateXRSpaceFromMergedFrames(e.gripSpace,n.gripTransform,i.gripTransform,r),t.hasHand)for(let a=0;a<25;a++){const s=n.handTransforms.slice(8*a,8*a+7),o=i.handTransforms.slice(8*a,8*a+7),l=n.handTransforms[8*a+7],c=i.handTransforms[8*a+7],u=e.hand.get(t.jointSequence[a]);this.updateXRSpaceFromMergedFrames(u,s,o,r),u[Fa].radius=(c-l)*r+l}if(t.hasGamepad){const t=e.gamepad;i.buttons.forEach((e,i)=>{const a=t.buttons[i];a[Ea].pressed=1===e[0],a[Ea].touched=1===e[1];const s=n.buttons[i][2],o=e[2];a[Ea].value=(o-s)*r+s}),i.axes.forEach((e,i)=>{const a=n.axes[i];t[Ea].axesMap[i.toString()].x=(e-a)*r+a})}}updateXRSpaceFromMergedFrames(e,t,n,i){const r=Jr(this[va].f1p,t[0],t[1],t[2]),a=fa(this[va].f1q,t[3],t[4],t[5],t[6]),s=Jr(this[va].f2p,n[0],n[1],n[2]),o=fa(this[va].f2q,n[3],n[4],n[5],n[6]);ia(this[va].vec3,r,s,i),ua(this[va].quat,a,o,i),jr(e[Ua].offsetMatrix,this[va].quat,this[va].vec3)}processRawInputData(e){const t=e[0],n=this[va].inputSchemas.get(t),i={targetRayTransform:e.slice(1,8)};let r=8;if(n.hasGrip&&(i.gripTransform=e[r++]),n.hasHand&&(i.handTransforms=e[r++]),n.hasGamepad){const t=e[r];i.buttons=t.slice(0,n.numButtons),i.axes=t.slice(n.numButtons)}return{index:t,inputData:i}}}const Uo="2.5.0";class zo extends Event{constructor(e,t){if(super(e,t),!t.referenceSpace)throw new Error("XRReferenceSpaceEventInit.referenceSpace is required");this.referenceSpace=t.referenceSpace,this.transform=t.transform}}const Bo=["gaze-tracking","eye-tracking"],Vo=e=>Bo.includes(e),Ho=e=>e.some(Vo);class Go extends Es{constructor(e){super(new _s(fs.None,ms.Gaze,["eye-gaze"],new ja(e))),this.position.set(0,0,0)}updateTargetRaySpace(){this.position.set(0,0,0),super.updateTargetRaySpace()}}class Wo extends EventTarget{constructor(e){super(),this[Ma]={device:e,grantSession:({resolve:e,reject:t,mode:n,options:i})=>{if(this[Ma].activeSession)return void t(new DOMException("An active XRSession already exists.","InvalidStateError"));const{requiredFeatures:r=[],optionalFeatures:a=[]}=i,{supportedFeatures:s}=this[Ma].device,o=e=>Vo(e)?Ho(s):s.includes(e);if(!r.every(o))return void t(new Error("One or more required features are not supported by the device."));const l=a.filter(o),c=Array.from(new Set([...r,...l,"viewer","local"])),u=new vo(this[Ma].device,n,c,i.depthSensing);this[Ma].activeSession=u,u.addEventListener("end",()=>{this[Ma].activeSession=void 0},{once:!0}),e(u)}}}isSessionSupported(e){return new Promise((t,n)=>{t("inline"===e||this[Ma].device.supportedSessionModes.includes(e))})}requestSession(e,t={}){return new Promise((n,i)=>{this.isSessionSupported(e).then(r=>{if(!r)return void i(new DOMException("The requested XRSession mode is not supported.","NotSupportedError"));const a={resolve:n,reject:i,mode:e,options:t};this[Ma].grantSession(a)}).catch(i)})}offerSession(e,t={}){return new Promise((n,i)=>{this.isSessionSupported(e).then(r=>{var a;r?(null===(a=this[Ma].offeredSessionConfig)||void 0===a||a.reject(new Error("Offer superseded by a new offerSession call.")),this[Ma].offeredSessionConfig={resolve:n,reject:i,mode:e,options:t}):i(new DOMException("The requested XRSession mode is not supported.","NotSupportedError"))}).catch(i)})}}class jo{constructor(e,t,n,i){this[Ba]={x:e,y:t,width:n,height:i}}get x(){return this[Ba].x}get y(){return this[Ba].y}get width(){return this[Ba].width}get height(){return this[Ba].height}}const Xo=(e,t,n)=>Math.min(n,Math.max(t,e));
|
|
654
|
-
/**
|
|
655
|
-
* @license
|
|
656
|
-
* webxr-layers-polyfill
|
|
657
|
-
* Version 1.1.0
|
|
658
|
-
* Copyright (c) 2021 Facebook, Inc. and its affiliates.
|
|
659
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
660
|
-
* you may not use this file except in compliance with the License.
|
|
661
|
-
* You may obtain a copy of the License at
|
|
662
|
-
*
|
|
663
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
664
|
-
*
|
|
665
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
666
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
667
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
668
|
-
* See the License for the specific language governing permissions and
|
|
669
|
-
* limitations under the License.
|
|
670
|
-
*/
|
|
671
|
-
/**
|
|
672
|
-
* @license
|
|
673
|
-
* gl-matrix
|
|
674
|
-
* Version 3.4.3
|
|
675
|
-
* Copyright (c) 2015-2021, Brandon Jones, Colin MacKenzie IV.
|
|
676
|
-
*
|
|
677
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
678
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
679
|
-
* in the Software without restriction, including without limitation the rights
|
|
680
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
681
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
682
|
-
* furnished to do so, subject to the following conditions:
|
|
683
|
-
*
|
|
684
|
-
* The above copyright notice and this permission notice shall be included in
|
|
685
|
-
* all copies or substantial portions of the Software.
|
|
686
|
-
*
|
|
687
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
688
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
689
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
690
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
691
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
692
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
693
|
-
* THE SOFTWARE.
|
|
694
|
-
*/
|
|
695
|
-
var qo,$o;!function(e){e.texture="texture",e["texture-array"]="texture-array"}(qo||(qo={})),function(e){e.default="default",e.mono="mono",e.stereo="stereo",e["stereo-left-right"]="stereo-left-right",e["stereo-top-bottom"]="stereo-top-bottom"}($o||($o={}));const Yo=e=>e&&"function"==typeof e.getOffsetReferenceSpace,Ko=()=>"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Qo=(e,t)=>{switch(t){case e.RGBA8:case e.RGB5_A1:case e.RGBA4:case e.SRGB8_ALPHA8:return{internalFormat:t,textureFormat:e.RGBA,type:e.UNSIGNED_BYTE};case e.RGBA8_SNORM:return{internalFormat:t,textureFormat:e.RGBA,type:e.BYTE};case e.RGB10_A2:return{internalFormat:t,textureFormat:e.RGBA,type:e.UNSIGNED_INT_2_10_10_10_REV};case e.RGBA16F:return{internalFormat:t,textureFormat:e.RGBA,type:e.HALF_FLOAT};case e.RGBA32F:return{internalFormat:t,textureFormat:e.RGBA,type:e.FLOAT};case e.RGBA8UI:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.UNSIGNED_BYTE};case e.RGBA8I:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.BYTE};case e.RGBA16UI:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.UNSIGNED_SHORT};case e.RGBA16I:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.SHORT};case e.RGBA32UI:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.UNSIGNED_INT};case e.RGBA32I:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.INT};case e.RGB10_A2UI:return{internalFormat:t,textureFormat:e.RGBA_INTEGER,type:e.UNSIGNED_INT_2_10_10_10_REV};case e.RGB8:case e.RGB565:case e.SRGB8:return{internalFormat:t,textureFormat:e.RGB,type:e.UNSIGNED_BYTE};case e.RGB8_SNORM:return{internalFormat:t,textureFormat:e.RGB,type:e.BYTE};case e.RGB16F:case e.R11F_G11F_B10F:case e.RGB9_E5:return{internalFormat:t,textureFormat:e.RGB,type:e.HALF_FLOAT};case e.RGB32F:return{internalFormat:t,textureFormat:e.RGB,type:e.FLOAT};case e.RGB8UI:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.UNSIGNED_BYTE};case e.RGB8I:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.BYTE};case e.RGB16UI:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.UNSIGNED_SHORT};case e.RGB16I:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.SHORT};case e.RGB32UI:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.UNSIGNED_INT};case e.RGB32I:return{internalFormat:t,textureFormat:e.RGB_INTEGER,type:e.INT};case e.DEPTH_COMPONENT16:return{internalFormat:t,textureFormat:e.DEPTH_COMPONENT,type:e.UNSIGNED_SHORT};case e.DEPTH_COMPONENT24:return{internalFormat:t,textureFormat:e.DEPTH_COMPONENT,type:e.UNSIGNED_INT};case e.DEPTH_COMPONENT32F:return{internalFormat:t,textureFormat:e.DEPTH_COMPONENT,type:e.FLOAT};case e.DEPTH24_STENCIL8:return{internalFormat:t,textureFormat:e.DEPTH_STENCIL,type:e.UNSIGNED_INT_24_8};case e.DEPTH32F_STENCIL8:return{internalFormat:t,textureFormat:e.DEPTH_STENCIL,type:e.FLOAT_32_UNSIGNED_INT_24_8_REV};case e.DEPTH_COMPONENT:return Qo(e,e.DEPTH_COMPONENT24);case e.DEPTH_STENCIL:return Qo(e,e.DEPTH24_STENCIL8);case e.RGBA:case e.RGB:case e.LUMINANCE_ALPHA:case e.LUMINANCE:case e.ALPHA:return{internalFormat:t,textureFormat:t,type:e.UNSIGNED_BYTE};default:throw new Error("Attempted to create polyfill with unsupported format.")}};class Zo{constructor(){this._hasRunDeferredInitialize=!1,this._media=null}initialize(e,t){this.session=e,t&&(this.context=t),this.blendTextureSourceAlpha=!0}destroy(){this._colorTextures=[],this._depthStencilTextures=[]}addEventListener(e,t,n){}dispatchEvent(e){return!1}removeEventListener(e,t,n){}getContext(){return this.context}getTextureType(){throw new Error("Unimplemented")}get colorTextures(){return this._colorTextures}get depthStencilTextures(){return this._depthStencilTextures}get colorTexturesMeta(){return this._texturesMeta}get media(){return this.isMediaLayer()||console.warn("Attempted to retrieve media from a non-media layer"),this._media}determineLayoutAttribute(e,t,n){if(!(t instanceof WebGL2RenderingContext)&&e===qo["texture-array"])throw new TypeError;if(n===$o.mono)return n;if(n===$o.default){if(this.session.internalViews&&1===this.session.internalViews.length)return $o.mono;if(e===qo["texture-array"])return n}return n===$o.default||n===$o.stereo?$o["stereo-left-right"]:n}isMediaLayer(){return null!==this._media}_deferredInitialize(){}initializeIfNeeded(){this._hasRunDeferredInitialize||(this._hasRunDeferredInitialize=!0,this._deferredInitialize())}_allocateColorTexturesInternal(e,t){let n=this.session.internalViews;if(n&&0!==n.length){if(this.initializeIfNeeded(),this.layout===$o.mono){if(e===qo["texture-array"]){const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}{const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}}if(this.layout===$o.stereo){if(e===qo["texture-array"]){const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat,2);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}{const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat),i=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n,i],void(this._colorTextures=[n.texture,i.texture])}}if(this.layout===$o["stereo-left-right"]){const n=this._createNewColorTexture(2*t.viewPixelWidth,t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}if(this.layout===$o["stereo-top-bottom"]){const n=this._createNewColorTexture(t.viewPixelWidth,2*t.viewPixelHeight,e,t.colorFormat);return this._texturesMeta=[n],void(this._colorTextures=[n.texture])}}else console.warn("We can't allocate color textures without views")}_allocateDepthStencilTexturesInternal(e,t){if(t.depthFormat){if(this._getSupportedDepthFormats().indexOf(t.depthFormat)<0)throw new Error("Depth format provided is not supported in non-projection layers.");if(t.mipLevels<1)throw new Error("Invalid miplevel. Miplevel needs to be >= 1");if(this.layout===$o.mono){if(e===qo["texture-array"]){const n=this._createNewDepthStencilTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture])}{const n=this._createNewColorTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture])}}if(this.layout===$o.stereo){if(e===qo["texture-array"]){const n=this._createNewDepthStencilTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat,2);return void(this._depthStencilTextures=[n.texture])}{const n=this._createNewDepthStencilTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat),i=this._createNewDepthStencilTexture(t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture,i.texture])}}if(this.layout===$o["stereo-left-right"]){const n=this._createNewDepthStencilTexture(2*t.viewPixelWidth,t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture])}if(this.layout===$o["stereo-top-bottom"]){const n=this._createNewDepthStencilTexture(t.viewPixelWidth,2*t.viewPixelHeight,e,t.depthFormat);return void(this._depthStencilTextures=[n.texture])}}else this._depthStencilTextures=[]}_createNewColorTexture(e,t,n,i,r=1){return this._createGenericPolyfillTexture(n,e,t,i,0,r)}_createNewDepthStencilTexture(e,t,n,i,r=1){return this._createGenericPolyfillTexture(n,e,t,i,0,r)}_createGenericPolyfillTexture(e,t,n,i,r=0,a=1){if(e===qo["texture-array"]&&a<=1&&console.warn("creating a texture array with a single layer..."),e===qo["texture-array"]&&this.context instanceof WebGLRenderingContext)throw new Error("WebGL 1 does not support texture array");let s=this.context.createTexture(),o={width:t,height:n,layers:a,type:e,textureFormat:i,texture:s},l=i,c=this.context.UNSIGNED_BYTE;if(this.context instanceof WebGL2RenderingContext){const e=Qo(this.context,i);l=e.internalFormat,i=e.textureFormat,c=e.type}else i===this.context.DEPTH_COMPONENT&&(c=this.context.UNSIGNED_INT),i===this.context.DEPTH_STENCIL&&(c=this.context.UNSIGNED_INT_24_8_WEBGL);if(e===qo["texture-array"]&&this.context instanceof WebGL2RenderingContext){console.warn("texture-array layers are supported...questionably in the polyfill at the moment. Use at your own risk.");const e=this.context.getParameter(this.context.TEXTURE_BINDING_2D_ARRAY);this.context.bindTexture(this.context.TEXTURE_2D_ARRAY,s),this._getSupportedDepthFormats().indexOf(i)>=0?this.context.texStorage3D(this.context.TEXTURE_2D_ARRAY,1,l,t,n,a):this.context.texImage3D(this.context.TEXTURE_2D_ARRAY,0,l,t,n,a,0,i,c,null),this.context.bindTexture(this.context.TEXTURE_2D_ARRAY,e)}else{const e=this.context.getParameter(this.context.TEXTURE_BINDING_2D);this.context.bindTexture(this.context.TEXTURE_2D,s),this.context.texImage2D(this.context.TEXTURE_2D,0,l,t,n,0,i,c,null),this.context.bindTexture(this.context.TEXTURE_2D,e)}return o}_getSupportedDepthFormats(){const e=[];return this.context instanceof WebGLRenderingContext&&!this.context.getExtension("WEBGL_depth_texture")||(e.push(this.context.DEPTH_COMPONENT,this.context.DEPTH_STENCIL),this.context instanceof WebGL2RenderingContext&&e.push(this.context.DEPTH_COMPONENT24,this.context.DEPTH24_STENCIL8)),e}}const Jo={colorFormat:6408,mipLevels:1,layout:$o.mono,isStatic:!1,space:null,viewPixelHeight:0,viewPixelWidth:0,textureType:qo.texture,radius:2,centralAngle:.78539,aspectRatio:2},el={layout:$o.mono,invertStereo:!1,space:null,radius:2,centralAngle:.78539};class tl extends Zo{constructor(e,t){super(),this._media=null!=t?t:null,this.isMediaLayer()?this.init=Object.assign(Object.assign({},el),e):this.init=Object.assign(Object.assign({},Jo),e),this.radius=this.init.radius,this.centralAngle=this.init.centralAngle,this.aspectRatio=this.init.aspectRatio,this.space=this.init.space,this.layout=this.init.layout;const n=Ko();this.init.transform?this.transform=new n.XRRigidTransform(e.transform.position,e.transform.orientation):this.transform=new n.XRRigidTransform({x:0,y:0,z:0,w:1}),this.isMediaLayer()||(this.isStatic=e.isStatic)}getTextureType(){return this.isMediaLayer()?qo.texture:this.init.textureType}_deferredInitialize(){let e=this.determineLayoutAttribute(this.init.textureType,this.context,this.init.layout);this.layout=e,this.needsRedraw=!0}get colorTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._colorTextures}get depthStencilTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._depthStencilTextures&&this._depthStencilTextures.length||this._allocateDepthStencilTexturesInternal(this.getTextureType(),this.init),this._depthStencilTextures}get colorTexturesMeta(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._texturesMeta}get width(){return 2*this.radius*Math.PI*(this.centralAngle/(2*Math.PI))}get height(){return this.width/this.aspectRatio}}const nl={colorFormat:6408,mipLevels:1,layout:$o.mono,isStatic:!1,space:null,viewPixelHeight:0,viewPixelWidth:0,textureType:qo.texture,radius:0,centralHorizontalAngle:6.28318,upperVerticalAngle:1.570795,lowerVerticalAngle:-1.570795},il={space:null,layout:$o.mono,invertStereo:!1,radius:0,centralHorizontalAngle:6.28318,upperVerticalAngle:1.570795,lowerVerticalAngle:-1.570795};class rl extends Zo{constructor(e,t){if(super(),this._media=null!=t?t:null,this.isMediaLayer()?this.init=Object.assign(Object.assign({},il),e):this.init=Object.assign(Object.assign({},nl),e),!Yo(this.init.space))throw new TypeError("Equirect layer's space needs to be an XRReferenceSpace");this.radius=this.init.radius,this.centralHorizontalAngle=this.init.centralHorizontalAngle,this.upperVerticalAngle=this.init.upperVerticalAngle,this.lowerVerticalAngle=this.init.lowerVerticalAngle,this.space=this.init.space,this.layout=this.init.layout;const n=Ko();e.transform?this.transform=new n.XRRigidTransform(e.transform.position,e.transform.orientation):this.transform=new n.XRRigidTransform({x:0,y:0,z:0,w:1}),this.isMediaLayer()||(this.isStatic=e.isStatic)}getTextureType(){return this.isMediaLayer()?qo.texture:this.init.textureType}_deferredInitialize(){let e=this.determineLayoutAttribute(this.init.textureType,this.context,this.init.layout);this.layout=e,this.needsRedraw=!0}get colorTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._colorTextures}get depthStencilTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._depthStencilTextures&&this._depthStencilTextures.length||this._allocateDepthStencilTexturesInternal(this.getTextureType(),this.init),this._depthStencilTextures}get colorTexturesMeta(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._texturesMeta}}const al={colorFormat:6408,mipLevels:1,layout:$o.mono,isStatic:!1,space:null,viewPixelHeight:0,viewPixelWidth:0,textureType:qo.texture,width:1,height:1},sl={space:null,layout:$o.mono,invertStereo:!1};class ol extends Zo{constructor(e,t){super(),this._media=null!=t?t:null,this.isMediaLayer()?this.init=Object.assign(Object.assign({},sl),e):this.init=Object.assign(Object.assign({},al),e),this.width=this.init.width,this.height=this.init.height,this.space=this.init.space,this.layout=this.init.layout;const n=Ko();this.init.transform?this.transform=new n.XRRigidTransform(e.transform.position,e.transform.orientation):this.transform=new n.XRRigidTransform({x:0,y:0,z:0,w:1}),this.isMediaLayer()||(this.isStatic=e.isStatic)}getTextureType(){return this.isMediaLayer()?qo.texture:this.init.textureType}_deferredInitialize(){let e=this.determineLayoutAttribute(this.init.textureType,this.context,this.init.layout);this.layout=e,this.needsRedraw=!0}get colorTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._colorTextures}get depthStencilTextures(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._depthStencilTextures&&this._depthStencilTextures.length||this._allocateDepthStencilTexturesInternal(this.getTextureType(),this.init),this._depthStencilTextures}get colorTexturesMeta(){if(this.isMediaLayer())throw new Error("Media layers do not have associated textures");return this._colorTextures&&this._colorTextures.length||this._allocateColorTexturesInternal(this.getTextureType(),this.init),this._texturesMeta}}class ll{constructor(e){if(this.session=e,this.session.ended)throw new Error("Session has ended")}createQuadLayer(e,t){if(this.session.ended)throw new Error("Session has ended");if(t.layout===$o.default)throw new TypeError("Media Quad layer cannot be created with layout of default");let n=this.calculateAspectRatio(e,t.layout);void 0===t.width&&void 0===t.height&&(t.width=1),void 0===t.height&&(t.height=t.width/n),void 0===t.width&&(t.width=t.height/n);let i=new ol(t,e);return i.needsRedraw=!1,i.initialize(this.session),i}createCylinderLayer(e,t){if(this.session.ended)throw new Error("Session has ended");if(t.layout===$o.default)throw new TypeError("Media Cylinder layer cannot be created with layout of default");let n=this.calculateAspectRatio(e,t.layout);void 0===t.aspectRatio&&(t.aspectRatio=n);let i=new tl(t,e);return i.needsRedraw=!1,i.initialize(this.session),i}createEquirectLayer(e,t){if(this.session.ended)throw new Error("Session has ended");if(t.layout===$o.default)throw new TypeError("Media Equirect layer cannot be created with layout of default");if(!Yo(t.space))throw new Error("Media Equirect layer's space must be of type XRReferenceSpace");let n=new rl(t,e);return n.needsRedraw=!1,n.initialize(this.session),n}calculateAspectRatio(e,t){let n=e.videoWidth,i=e.videoHeight;return t===$o["stereo-left-right"]&&(n/=2),t===$o["stereo-top-bottom"]&&(i/=2),n/i}}const cl={textureType:qo.texture,colorFormat:6408,depthFormat:6402,scaleFactor:1};class ul extends Zo{constructor(e=cl){super(),this.init=Object.assign(Object.assign({},cl),e)}initialize(e,t){super.initialize(e,t),this.initializeIfNeeded();let n=e.getBaseLayer();this.textureWidth=n.framebufferWidth*this.init.scaleFactor,this.textureHeight=n.framebufferHeight*this.init.scaleFactor}_allocateProjectionColorTextures(){let e=[],t=[];const n=()=>{e=[];for(let n of t)e.push(n.texture)};let i=this.session,r=i.internalViews;if(!r||0===r.length)return void console.warn("We can't allocate color textures without views");let a=i.getBaseLayer(),s=r.length,o=a.framebufferWidth*this.init.scaleFactor/r.length,l=a.framebufferHeight*this.init.scaleFactor;if(this.layout===$o.mono||this.layout===$o.default){if(this.init.textureType===qo["texture-array"]){let e=this._createNewColorTexture(o,l,qo["texture-array"],this.init.colorFormat,s);t=[e]}else for(let e of r){let e=this._createNewColorTexture(o,l,qo.texture,this.init.colorFormat);t.push(e)}return n(),this._colorTexturesMeta=t,void(this._colorTextures=e)}if(this.layout===$o["stereo-left-right"]){let e=this._createNewColorTexture(o*s,l,this.init.textureType,this.init.colorFormat);t=[e]}else if(this.layout===$o["stereo-top-bottom"]){let e=this._createNewColorTexture(o,l*s,this.init.textureType,this.init.colorFormat);t=[e]}n(),this._colorTexturesMeta=t,this._colorTextures=e}_allocateProjectionDepthStencilTextures(){let e=this.session,t=e.internalViews;if(!t||0===t.length)return;if(0===this.init.depthFormat)return void(this._depthStencilTextures=[]);if(this.context instanceof WebGLRenderingContext){if(!this.context.getExtension("WEBGL_depth_texture"))return void(this._depthStencilTextures=[])}let n=[],i=[];const r=()=>{n=[];for(let e of i)n.push(e.texture)};this.initializeIfNeeded();let a=e.getBaseLayer(),s=t.length,o=a.framebufferWidth*this.init.scaleFactor/t.length,l=a.framebufferHeight*this.init.scaleFactor;if(this.layout===$o.mono||this.layout===$o.default){if(this.init.textureType===qo["texture-array"]){let e=this._createNewDepthStencilTexture(o,l,this.init.textureType,this.init.depthFormat,s);i=[e]}else for(let e of t){let e=this._createNewDepthStencilTexture(o,l,this.init.textureType,this.init.depthFormat);i.push(e)}return r(),void(this._depthStencilTextures=n)}if(this.layout===$o["stereo-left-right"]){let e=this._createNewDepthStencilTexture(o*s,l,this.init.textureType,this.init.depthFormat);i=[e]}else if(this.layout===$o["stereo-top-bottom"]){let e=this._createNewDepthStencilTexture(o,l*s,this.init.textureType,this.init.depthFormat);i=[e]}r(),this._depthStencilTextures=n}get colorTextures(){return this._colorTextures&&this._colorTextures.length||this._allocateProjectionColorTextures(),this._colorTextures}get depthStencilTextures(){return void 0===this._depthStencilTextures&&this._allocateProjectionDepthStencilTextures(),this._depthStencilTextures||[]}get colorTexturesMeta(){return this._colorTextures&&this._colorTextures.length||this._allocateProjectionColorTextures(),this._colorTexturesMeta}getTextureType(){return this.init.textureType}_deferredInitialize(){this.isStatic=!1,this.ignoreDepthValues=!1,this.fixedFoveation=0;let e=this.determineLayoutAttribute(this.init.textureType,this.context,$o.default);this.layout=e,this.needsRedraw=!0;let t=this.determineMaximumScaleFactor(),n=Math.min(this.init.scaleFactor,t);this.init.scaleFactor=n}determineMaximumScaleFactor(){let e=this.session.getBaseLayer(this.context),t=e.framebufferWidth,n=e.framebufferHeight;this.layout===$o["stereo-left-right"]&&(t*=2),this.layout===$o["stereo-top-bottom"]&&(n*=2);let i=Math.max(t,n);return this.context.getParameter(this.context.MAX_TEXTURE_SIZE)/i}}const dl=(e,t,n,i,r)=>{let a=0,s=0,o=t.width,l=t.height;n===$o["stereo-left-right"]?(a=t.width*i/r,o=t.width/r):n===$o["stereo-top-bottom"]&&(s=t.height*i/r,l=t.height/r),e.x=a,e.y=s,e.width=o,e.height=l},hl=(e,t,n)=>{var i=e.createShader(n);if(e.shaderSource(i,t),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw"could not compile shader:"+e.getShaderInfoLog(i);return i},pl=(e,t,n)=>{const i=e.createProgram(),r=hl(e,t,e.VERTEX_SHADER),a=hl(e,n,e.FRAGMENT_SHADER);if(e.attachShader(i,r),e.attachShader(i,a),e.deleteShader(r),e.deleteShader(a),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw"program failed to link:"+e.getProgramInfoLog(i);return i},fl=e=>{if(e instanceof WebGL2RenderingContext)return e;const t=e.getExtension("OES_vertex_array_object");if(!t)throw new Error("Cannot use VAOs.");return{VERTEX_ARRAY_BINDING:t.VERTEX_ARRAY_BINDING_OES,bindVertexArray:t.bindVertexArrayOES.bind(t),createVertexArray:t.createVertexArrayOES.bind(t),deleteVertexArray:t.deleteVertexArrayOES.bind(t),isVertexArray:t.isVertexArrayOES.bind(t)}},ml=e=>e,gl=ml`
|
|
696
|
-
attribute vec2 a_position;
|
|
697
|
-
attribute vec2 a_texCoord;
|
|
698
|
-
|
|
699
|
-
varying vec2 v_texCoord;
|
|
700
|
-
|
|
701
|
-
void main() {
|
|
702
|
-
// convert the rectangle from pixels to 0.0 to 1.0
|
|
703
|
-
vec2 zeroToOne = a_position;
|
|
704
|
-
|
|
705
|
-
// convert from 0->1 to 0->2
|
|
706
|
-
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
707
|
-
|
|
708
|
-
// convert from 0->2 to -1->+1 (clipspace)
|
|
709
|
-
vec2 clipSpace = zeroToTwo - 1.0;
|
|
710
|
-
|
|
711
|
-
gl_Position = vec4(clipSpace * vec2(1, 1), 0, 1);
|
|
712
|
-
|
|
713
|
-
// pass the texCoord to the fragment shader
|
|
714
|
-
// The GPU will interpolate this value between points.
|
|
715
|
-
v_texCoord = a_texCoord;
|
|
716
|
-
}
|
|
717
|
-
`,vl=ml`
|
|
718
|
-
precision mediump float;
|
|
719
|
-
|
|
720
|
-
// our texture
|
|
721
|
-
uniform sampler2D u_image;
|
|
722
|
-
|
|
723
|
-
// the texCoords passed in from the vertex shader.
|
|
724
|
-
varying vec2 v_texCoord;
|
|
725
|
-
|
|
726
|
-
void main() {
|
|
727
|
-
vec4 tex = texture2D(u_image, v_texCoord);
|
|
728
|
-
gl_FragColor = vec4(tex.rgb, tex.a);
|
|
729
|
-
}
|
|
730
|
-
`;class yl{constructor(e,t){this.gl=t,this.layer=e,this.program=pl(this.gl,gl,vl),this.programInfo={attribLocations:{a_position:this.gl.getAttribLocation(this.program,"a_position"),a_texCoord:this.gl.getAttribLocation(this.program,"a_texCoord")}},this._createVAOs()}render(e){let t=this.gl,n=e.getBaseLayer();t.viewport(0,0,n.framebufferWidth,n.framebufferHeight);const i=this.layer.getTextureType(),r=t.getParameter(t.TEXTURE_BINDING_2D),a=t.getParameter(t.ACTIVE_TEXTURE);if(i!==qo.texture)throw new Error("Created a texture projection renderer instead of a texture-array projection renderer for a texture-array layer.\nThis is probably an error with the polyfill itself; please file an issue on Github if you run into this.");t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.layer.colorTextures[0]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let i of e.internalViews){let e=n.getViewport(i);t.viewport(e.x,e.y,e.width,e.height),this._shouldUseStereoTexturePoints()?this._renderInternalStereo(i):this._renderInternal()}t.activeTexture(a),t.bindTexture(t.TEXTURE_2D,r)}_renderInternal(){let e=this.gl;const t=e.getParameter(e.CURRENT_PROGRAM);e.useProgram(this.program),this.vaoGl.bindVertexArray(this.vao);var n=e.TRIANGLES;e.drawArrays(n,0,6),this.vaoGl.bindVertexArray(null),e.useProgram(t)}_renderInternalStereo(e){if("none"===e.eye)return this._renderInternal();let t=this.gl;this.vaoGl.bindVertexArray(this.vao);const n=t.getParameter(t.CURRENT_PROGRAM);t.useProgram(this.program),this._setStereoTextureBuffer("right"===e.eye?1:0);var i=t.TRIANGLES;t.drawArrays(i,0,6),this.vaoGl.bindVertexArray(null),t.useProgram(n)}_createVAOs(){this._createTextureUVs();let e=this.gl;this.vaoGl=fl(e);let t=e.createBuffer();this.vao=this.vaoGl.createVertexArray(),this.vaoGl.bindVertexArray(this.vao),e.enableVertexAttribArray(this.programInfo.attribLocations.a_position),e.bindBuffer(e.ARRAY_BUFFER,t),((e,t,n,i,r)=>{var a=t,s=t+i,o=n,l=n+r;e.bufferData(e.ARRAY_BUFFER,new Float32Array([a,o,s,o,a,l,a,l,s,o,s,l]),e.DYNAMIC_DRAW)})(e,0,0,1,1);let n=e.FLOAT,i=!1;e.vertexAttribPointer(this.programInfo.attribLocations.a_position,2,n,i,0,0),this.texcoordBuffer=e.createBuffer(),e.enableVertexAttribArray(this.programInfo.attribLocations.a_texCoord),e.bindBuffer(e.ARRAY_BUFFER,this.texcoordBuffer),e.bufferData(e.ARRAY_BUFFER,this.texturePoints,e.DYNAMIC_DRAW),e.vertexAttribPointer(this.programInfo.attribLocations.a_texCoord,2,n,i,0,0),this.vaoGl.bindVertexArray(null),e.bindBuffer(e.ARRAY_BUFFER,null)}_setStereoTextureBuffer(e){let t=this.gl;t.enableVertexAttribArray(this.programInfo.attribLocations.a_texCoord),t.bindBuffer(t.ARRAY_BUFFER,this.texcoordBuffer),t.bufferData(t.ARRAY_BUFFER,this.stereoTexturePoints[e],t.STATIC_DRAW);var n=t.FLOAT;t.vertexAttribPointer(this.programInfo.attribLocations.a_texCoord,2,n,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,null)}_createTextureUVs(){this.texturePoints=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);const e={x:0,y:0,width:1,height:1};this._shouldUseStereoTexturePoints()&&(this.stereoTexturePoints=[],dl(e,this.layer.colorTexturesMeta[0],this.layer.layout,0,2),this.stereoTexturePoints[0]=this._offsetTextureUVsByRect(this.layer.colorTexturesMeta[0],this.texturePoints,e),dl(e,this.layer.colorTexturesMeta[0],this.layer.layout,1,2),this.stereoTexturePoints[1]=this._offsetTextureUVsByRect(this.layer.colorTexturesMeta[0],this.texturePoints,e))}_offsetTextureUVsByRect(e,t,n){const i=(n=null!=n?n:{x:0,y:0,width:e.width,height:e.height}).x/e.width,r=n.y/e.height,a=n.width/e.width,s=n.height/e.height,o=[];for(let e=0;e<t.length;e+=2){let n=t[e]*a+i,l=t[e+1]*s+r;o[e]=n,o[e+1]=l}return new Float32Array(o)}_shouldUseStereoTexturePoints(){return this.layer.layout===$o["stereo-left-right"]||this.layer.layout===$o["stereo-top-bottom"]}}const xl=ml`#version 300 es
|
|
731
|
-
|
|
732
|
-
in vec2 a_position;
|
|
733
|
-
in vec2 a_texCoord;
|
|
734
|
-
|
|
735
|
-
out vec2 v_texCoord;
|
|
736
|
-
|
|
737
|
-
void main() {
|
|
738
|
-
// convert the rectangle from pixels to 0.0 to 1.0
|
|
739
|
-
vec2 zeroToOne = a_position;
|
|
740
|
-
|
|
741
|
-
// convert from 0->1 to 0->2
|
|
742
|
-
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
743
|
-
|
|
744
|
-
// convert from 0->2 to -1->+1 (clipspace)
|
|
745
|
-
vec2 clipSpace = zeroToTwo - 1.0;
|
|
746
|
-
|
|
747
|
-
gl_Position = vec4(clipSpace * vec2(1, 1), 0, 1);
|
|
748
|
-
|
|
749
|
-
// pass the texCoord to the fragment shader
|
|
750
|
-
// The GPU will interpolate this value between points.
|
|
751
|
-
v_texCoord = a_texCoord;
|
|
752
|
-
}
|
|
753
|
-
`,bl=ml`#version 300 es
|
|
754
|
-
precision mediump float;
|
|
755
|
-
precision mediump int;
|
|
756
|
-
precision mediump sampler2DArray;
|
|
757
|
-
|
|
758
|
-
uniform sampler2DArray u_image;
|
|
759
|
-
uniform int u_layer;
|
|
760
|
-
|
|
761
|
-
in vec2 v_texCoord;
|
|
762
|
-
|
|
763
|
-
out vec4 fragColor;
|
|
764
|
-
|
|
765
|
-
void main() {
|
|
766
|
-
vec4 tex = texture(u_image, vec3(v_texCoord.x, v_texCoord.y, u_layer));
|
|
767
|
-
fragColor = vec4(tex.rgb, tex.a);
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
`;class _l extends yl{constructor(e,t){super(e,t),this.program=pl(this.gl,xl,bl),this._createVAOs(),this.u_layerInfo=this.gl.getUniformLocation(this.program,"u_layer")}render(e){let t=this.gl;if(this.layer.getTextureType()===qo.texture)throw new Error("Using texture array projection renderer on a layer without texture array.");let n=e.getBaseLayer();const i=t.getParameter(t.TEXTURE_BINDING_2D_ARRAY);t.bindTexture(t.TEXTURE_2D_ARRAY,this.layer.colorTextures[0]),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D_ARRAY,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let i of e.internalViews){let r=e.getViewIndex(i),a=n.getViewport(i);t.viewport(a.x,a.y,a.width,a.height),this._renderInternal(r)}t.bindTexture(t.TEXTURE_2D_ARRAY,i)}_renderInternal(e=0){let t=this.gl;const n=t.getParameter(t.CURRENT_PROGRAM);t.useProgram(this.program),t.bindVertexArray(this.vao),t.uniform1i(this.u_layerInfo,e);var i=t.TRIANGLES;t.drawArrays(i,0,6),t.bindVertexArray(null),t.useProgram(n)}}const wl=(e,t)=>e.getTextureType()===qo["texture-array"]&&t instanceof WebGL2RenderingContext?new _l(e,t):new yl(e,t);var Sl="undefined"!=typeof Float32Array?Float32Array:Array;function El(){var e=new Sl(16);return Sl!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Ml(e,t,n){var i=t[0],r=t[1],a=t[2],s=t[3],o=t[4],l=t[5],c=t[6],u=t[7],d=t[8],h=t[9],p=t[10],f=t[11],m=t[12],g=t[13],v=t[14],y=t[15],x=n[0],b=n[1],_=n[2],w=n[3];return e[0]=x*i+b*o+_*d+w*m,e[1]=x*r+b*l+_*h+w*g,e[2]=x*a+b*c+_*p+w*v,e[3]=x*s+b*u+_*f+w*y,x=n[4],b=n[5],_=n[6],w=n[7],e[4]=x*i+b*o+_*d+w*m,e[5]=x*r+b*l+_*h+w*g,e[6]=x*a+b*c+_*p+w*v,e[7]=x*s+b*u+_*f+w*y,x=n[8],b=n[9],_=n[10],w=n[11],e[8]=x*i+b*o+_*d+w*m,e[9]=x*r+b*l+_*h+w*g,e[10]=x*a+b*c+_*p+w*v,e[11]=x*s+b*u+_*f+w*y,x=n[12],b=n[13],_=n[14],w=n[15],e[12]=x*i+b*o+_*d+w*m,e[13]=x*r+b*l+_*h+w*g,e[14]=x*a+b*c+_*p+w*v,e[15]=x*s+b*u+_*f+w*y,e}function Tl(e,t){var n=t[0],i=t[1],r=t[2],a=t[3],s=n+n,o=i+i,l=r+r,c=n*s,u=i*s,d=i*o,h=r*s,p=r*o,f=r*l,m=a*s,g=a*o,v=a*l;return e[0]=1-d-f,e[1]=u+v,e[2]=h-g,e[3]=0,e[4]=u-v,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=h+g,e[9]=p-m,e[10]=1-c-d,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Al(){var e=new Sl(2);return Sl!=Float32Array&&(e[0]=0,e[1]=0),e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),function(){var e=Al()}();const Rl=e=>e,Pl=Rl`
|
|
771
|
-
attribute vec4 a_position;
|
|
772
|
-
attribute vec2 a_texCoord;
|
|
773
|
-
|
|
774
|
-
uniform mat4 u_matrix;
|
|
775
|
-
uniform mat4 u_projectionMatrix;
|
|
776
|
-
|
|
777
|
-
varying vec2 v_texCoord;
|
|
778
|
-
|
|
779
|
-
void main() {
|
|
780
|
-
// Multiply the position by the matrix.
|
|
781
|
-
gl_Position = u_projectionMatrix * u_matrix * a_position;
|
|
782
|
-
|
|
783
|
-
// pass the texCoord to the fragment shader
|
|
784
|
-
// The GPU will interpolate this value between points.
|
|
785
|
-
v_texCoord = a_texCoord;
|
|
786
|
-
}
|
|
787
|
-
`,Cl=Rl`
|
|
788
|
-
precision mediump float;
|
|
789
|
-
|
|
790
|
-
// our texture
|
|
791
|
-
uniform sampler2D u_image;
|
|
792
|
-
|
|
793
|
-
// the texCoords passed in from the vertex shader.
|
|
794
|
-
varying vec2 v_texCoord;
|
|
795
|
-
|
|
796
|
-
void main() {
|
|
797
|
-
vec4 tex = texture2D(u_image, v_texCoord);
|
|
798
|
-
gl_FragColor = vec4(tex.rgb, tex.a);
|
|
799
|
-
// gl_FragColor = vec4(1.0, 0, 0, 1.0);
|
|
800
|
-
}
|
|
801
|
-
`,Ll=Rl`#version 300 es
|
|
802
|
-
|
|
803
|
-
in vec4 a_position;
|
|
804
|
-
in vec2 a_texCoord;
|
|
805
|
-
|
|
806
|
-
uniform mat4 u_matrix;
|
|
807
|
-
uniform mat4 u_projectionMatrix;
|
|
808
|
-
|
|
809
|
-
out vec2 v_texCoord;
|
|
810
|
-
|
|
811
|
-
void main() {
|
|
812
|
-
// Multiply the position by the matrix.
|
|
813
|
-
gl_Position = u_projectionMatrix * u_matrix * a_position;
|
|
814
|
-
|
|
815
|
-
// pass the texCoord to the fragment shader
|
|
816
|
-
// The GPU will interpolate this value between points.
|
|
817
|
-
v_texCoord = a_texCoord;
|
|
818
|
-
}
|
|
819
|
-
`,Il=Rl`#version 300 es
|
|
820
|
-
precision mediump float;
|
|
821
|
-
precision mediump int;
|
|
822
|
-
precision mediump sampler2DArray;
|
|
823
|
-
|
|
824
|
-
uniform sampler2DArray u_image;
|
|
825
|
-
uniform int u_layer;
|
|
826
|
-
|
|
827
|
-
in vec2 v_texCoord;
|
|
828
|
-
|
|
829
|
-
out vec4 fragColor;
|
|
830
|
-
|
|
831
|
-
void main() {
|
|
832
|
-
vec4 tex = texture(u_image, vec3(v_texCoord.x, v_texCoord.y, u_layer));
|
|
833
|
-
fragColor = vec4(tex.rgb, tex.a);
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
`;class Dl{constructor(e,t){this.usesTextureArrayShaders=!1,this.savedVaoState={vao:null,arrayBuffer:null},this.hasMipmap=!1,this.gl=t,this.layer=e;let n=this.gl;this.transformMatrix=El(),t instanceof WebGL2RenderingContext&&this.layer.getTextureType()===qo["texture-array"]&&(this.usesTextureArrayShaders=!0),this.usesTextureArrayShaders?this.program=pl(n,Ll,Il):this.program=pl(n,Pl,Cl),this.programInfo={attribLocations:{a_position:n.getAttribLocation(this.program,"a_position"),a_texCoord:n.getAttribLocation(this.program,"a_texCoord")},uniformLocations:{u_matrix:n.getUniformLocation(this.program,"u_matrix"),u_projectionMatrix:n.getUniformLocation(this.program,"u_projectionMatrix")}},this.usesTextureArrayShaders&&(this.programInfo.uniformLocations.u_layer=n.getUniformLocation(this.program,"u_layer"))}saveVaoState(){this.savedVaoState.vao=this.gl.getParameter(this.vaoGl.VERTEX_ARRAY_BINDING),this.savedVaoState.arrayBuffer=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING)}restoreVaoState(){this.vaoGl.bindVertexArray(this.savedVaoState.vao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.savedVaoState.arrayBuffer),this.savedVaoState.vao=this.savedVaoState.arrayBuffer=null}initialize(){let e=this.gl;if(this.layer.isMediaLayer()){this.mediaTexture=e.createTexture(),this.mediaTexturePolyfill={texture:this.mediaTexture,textureFormat:e.RGBA,width:this.layer.media.videoWidth,height:this.layer.media.videoHeight,type:qo.texture};const t=e.getParameter(e.TEXTURE_BINDING_2D);e.bindTexture(e.TEXTURE_2D,this.mediaTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.layer.media.videoWidth,this.layer.media.videoHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindTexture(e.TEXTURE_2D,t)}this._createVAOs()}render(e,t){this.saveVaoState();let n=this.gl,i=e.getBaseLayer(),r=t.getViewerPose(e.getReferenceSpace());const a=n.getParameter(n.ACTIVE_TEXTURE);for(let s of r.views){let r=i.getViewport(s);if(n.viewport(r.x,r.y,r.width,r.height),n.activeTexture(n.TEXTURE0),this.usesTextureArrayShaders){if(n instanceof WebGLRenderingContext)throw new Error("This should never happen; texture-arrays only supported on WebGL2.");if(this.layer.isMediaLayer())throw new Error("This should never happen. Media layers should never be created with texture-array");const i=n.getParameter(n.TEXTURE_BINDING_2D_ARRAY);n.bindTexture(n.TEXTURE_2D_ARRAY,this.layer.colorTextures[0]),this.layer.isStatic?(!0===this.layer.needsRedraw&&n.generateMipmap(n.TEXTURE_2D_ARRAY),this.hasMipmap=!0):this.hasMipmap=this.layer.mipLevels>0,n.texParameteri(n.TEXTURE_2D_ARRAY,n.TEXTURE_MAG_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),n.texParameteri(n.TEXTURE_2D_ARRAY,n.TEXTURE_MIN_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR);let r=0;if(this.layer.layout===$o.stereo&&"right"===s.eye)r=1;this._shouldUseStereoTexturePoints()?this._renderInternalStereo(e,t,s,r):this._renderInternal(e,t,s,r),n.activeTexture(a),n.bindTexture(n.TEXTURE_2D_ARRAY,i)}else{const i=n.getParameter(n.TEXTURE_BINDING_2D);if(this.layer.isMediaLayer())n.bindTexture(n.TEXTURE_2D,this.mediaTexture),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.layer.media.videoWidth,this.layer.media.videoHeight,n.RGBA,n.UNSIGNED_BYTE,this.layer.media);else if(this.layer.layout===$o.stereo)if("right"===s.eye)n.bindTexture(n.TEXTURE_2D,this.layer.colorTextures[1]);else n.bindTexture(n.TEXTURE_2D,this.layer.colorTextures[0]);else n.bindTexture(n.TEXTURE_2D,this.layer.colorTextures[0]);this.layer.isStatic?(!0===this.layer.needsRedraw&&n.generateMipmap(n.TEXTURE_2D),this.hasMipmap=!0):this.hasMipmap=this.layer.mipLevels>0,n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),this._shouldUseStereoTexturePoints()?this._renderInternalStereo(e,t,s):this._renderInternal(e,t,s),n.activeTexture(a),n.bindTexture(n.TEXTURE_2D,i)}}this.restoreVaoState()}createPositionPoints(){return new Float32Array([])}createTextureUVs(){return new Float32Array([])}_offsetTextureUVsByRect(e,t,n){const i=(n=null!=n?n:{x:0,y:0,width:e.width,height:e.height}).x/e.width,r=n.y/e.height,a=n.width/e.width,s=n.height/e.height,o=[];for(let e=0;e<t.length;e+=2){let n=t[e]*a+i,l=t[e+1]*s+r;o[e]=n,o[e+1]=l}return new Float32Array(o)}_shouldUseStereoTexturePoints(){return this.layer.layout===$o["stereo-left-right"]||this.layer.layout===$o["stereo-top-bottom"]}_setStereoTextureBuffer(e){let t=this.gl;t.enableVertexAttribArray(this.programInfo.attribLocations.a_texCoord),t.bindBuffer(t.ARRAY_BUFFER,this.texcoordBuffer),t.bufferData(t.ARRAY_BUFFER,this.stereoTexturePoints[e],t.STATIC_DRAW);var n=t.FLOAT;t.vertexAttribPointer(this.programInfo.attribLocations.a_texCoord,2,n,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,null)}_recalculateVertices(){this.positionPoints=this.createPositionPoints(),this.texturePoints=this.createTextureUVs();const e={x:0,y:0,width:1,height:1};if(this._shouldUseStereoTexturePoints()){if(this.stereoTexturePoints=[],this.layer.isMediaLayer())return dl(e,this.mediaTexturePolyfill,this.layer.layout,0,2),this.stereoTexturePoints[0]=this._offsetTextureUVsByRect(this.mediaTexturePolyfill,this.texturePoints,e),dl(e,this.mediaTexturePolyfill,this.layer.layout,1,2),this.stereoTexturePoints[1]=this._offsetTextureUVsByRect(this.mediaTexturePolyfill,this.texturePoints,e),void(this.layer.layout===$o["stereo-top-bottom"]&&([this.stereoTexturePoints[0],this.stereoTexturePoints[1]]=[this.stereoTexturePoints[1],this.stereoTexturePoints[0]]));dl(e,this.layer.colorTexturesMeta[0],this.layer.layout,0,2),this.stereoTexturePoints[0]=this._offsetTextureUVsByRect(this.layer.colorTexturesMeta[0],this.texturePoints,e),dl(e,this.layer.colorTexturesMeta[0],this.layer.layout,1,2),this.stereoTexturePoints[1]=this._offsetTextureUVsByRect(this.layer.colorTexturesMeta[0],this.texturePoints,e),this.layer.layout===$o["stereo-top-bottom"]&&([this.stereoTexturePoints[0],this.stereoTexturePoints[1]]=[this.stereoTexturePoints[1],this.stereoTexturePoints[0]])}}_createVAOs(){this._recalculateVertices();let e=this.gl;this.vaoGl=fl(e),this.saveVaoState();let t=e.createBuffer();this.vao=this.vaoGl.createVertexArray(),this.vaoGl.bindVertexArray(this.vao),e.enableVertexAttribArray(this.programInfo.attribLocations.a_position),e.bindBuffer(e.ARRAY_BUFFER,t);const n=this.positionPoints;e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW);var i=3,r=e.FLOAT,a=!1,s=0,o=0;e.vertexAttribPointer(this.programInfo.attribLocations.a_position,i,r,a,s,o),e.enableVertexAttribArray(this.programInfo.attribLocations.a_texCoord),this.texcoordBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.texcoordBuffer),e.bufferData(e.ARRAY_BUFFER,this.texturePoints,e.STATIC_DRAW);i=2,r=e.FLOAT,a=!1,s=0,o=0;e.vertexAttribPointer(this.programInfo.attribLocations.a_texCoord,i,r,a,s,o),this.restoreVaoState()}_renderInternal(e,t,n,i){let r=this.gl;const a=r.getParameter(r.CURRENT_PROGRAM);r.useProgram(this.program),this.vaoGl.bindVertexArray(this.vao),this.usesTextureArrayShaders&&r.uniform1i(this.programInfo.uniformLocations.u_layer,i),this._setTransformMatrix(e,t,n),r.uniformMatrix4fv(this.programInfo.uniformLocations.u_matrix,!1,this.transformMatrix),r.uniformMatrix4fv(this.programInfo.uniformLocations.u_projectionMatrix,!1,n.projectionMatrix);var s=r.TRIANGLES,o=this.positionPoints.length/3;r.drawArrays(s,0,o),this.vaoGl.bindVertexArray(null),r.useProgram(a)}_renderInternalStereo(e,t,n,i){if("none"===n.eye)return this._renderInternal(e,t,n);let r=this.gl;this.vaoGl.bindVertexArray(this.vao);const a=r.getParameter(r.CURRENT_PROGRAM);r.useProgram(this.program),this._setStereoTextureBuffer("right"===n.eye?1:0),this.usesTextureArrayShaders&&r.uniform1i(this.programInfo.uniformLocations.u_layer,i),this._setTransformMatrix(e,t,n),r.uniformMatrix4fv(this.programInfo.uniformLocations.u_matrix,!1,this.transformMatrix),r.uniformMatrix4fv(this.programInfo.uniformLocations.u_projectionMatrix,!1,n.projectionMatrix);var s=r.TRIANGLES,o=this.positionPoints.length/3;r.drawArrays(s,0,o),this.vaoGl.bindVertexArray(null),r.useProgram(a)}_setTransformMatrix(e,t,n){let i=t.getPose(this.layer.space,e.getReferenceSpace());Ml(this.transformMatrix,i.transform.matrix,this.layer.transform.matrix),Ml(this.transformMatrix,n.transform.inverse.matrix,this.transformMatrix)}}class Nl extends Dl{constructor(e,t){super(e,t),this.initialize()}createPositionPoints(){const e=this.layer.width,t=this.layer.height;return new Float32Array([-e,-t,0,e,-t,0,-e,t,0,-e,t,0,e,-t,0,e,t,0])}createTextureUVs(){return new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1])}}class kl extends Dl{constructor(e,t){super(e,t),this.segments=16,this.initialize()}createPositionPoints(){const e=[],t=this.layer.centralAngle,n=this.layer.height,i=this.layer.radius,r=t/this.segments,a=Math.PI/2-t/2,s=[],o=Al();o[0]=i*Math.cos(a),o[1]=-i*Math.sin(a),s.push(o);for(let e=0;e<this.segments;e++){const t=Al();t[0]=i*Math.cos(a+r*(e+1)),t[1]=-i*Math.sin(a+r*(e+1)),s.push(t)}s.reverse();for(let t=0;t<this.segments;t++){const i=s[t],r=s[t+1];e.push(i[0],-n/2,i[1]),e.push(r[0],-n/2,r[1]),e.push(i[0],n/2,i[1]),e.push(i[0],n/2,i[1]),e.push(r[0],-n/2,r[1]),e.push(r[0],n/2,r[1])}return new Float32Array(e)}createTextureUVs(){let e=[];const t=1/this.segments;for(let n=0;n<this.segments;n++){let i=t*n,r=t*(n+1);e.push(i,0),e.push(r,0),e.push(i,1),e.push(i,1),e.push(r,0),e.push(r,1)}return new Float32Array(e)}}class Fl extends Dl{constructor(e,t){super(e,t),this.segmentsPerAxis=40,this.initialize()}createPositionPoints(){const e=[];let t=this.layer.radius;0===t&&(t=25),t>25&&(t=25);const n=this.layer.centralHorizontalAngle,i=this.layer.upperVerticalAngle+Math.PI/2,r=this.layer.lowerVerticalAngle+Math.PI/2,a=Math.PI/2-n/2,s=a+n,o=r-i,l=s-a,c=[];for(let e=0;e<=this.segmentsPerAxis;e++)for(let n=0;n<=this.segmentsPerAxis;n++){let r=t,a=s-l*(n/this.segmentsPerAxis),u=o*(e/this.segmentsPerAxis)+i;const d=Math.cos(a)*Math.sin(u),h=Math.cos(u),p=-Math.sin(a)*Math.sin(u);c.push([r*d,r*h,r*p])}const u=this.segmentsPerAxis+1;for(let t=0;t<this.segmentsPerAxis;t++)for(let n=0;n<this.segmentsPerAxis;n++)e.push(...c[n*u+t]),e.push(...c[n*u+t+1]),e.push(...c[(n+1)*u+t]),e.push(...c[(n+1)*u+t]),e.push(...c[n*u+t+1]),e.push(...c[(n+1)*u+t+1]);return new Float32Array(e)}createTextureUVs(){const e=[],t=[];for(let e=0;e<=this.segmentsPerAxis;e++)for(let n=0;n<=this.segmentsPerAxis;n++){const i=n/this.segmentsPerAxis,r=e/this.segmentsPerAxis;t.push([i,r])}const n=this.segmentsPerAxis+1;for(let i=0;i<this.segmentsPerAxis;i++)for(let r=0;r<this.segmentsPerAxis;r++)e.push(...t[r*n+i]),e.push(...t[r*n+i+1]),e.push(...t[(r+1)*n+i]),e.push(...t[(r+1)*n+i]),e.push(...t[r*n+i+1]),e.push(...t[(r+1)*n+i+1]);return new Float32Array(e)}}const Ol={colorFormat:6408,mipLevels:1,layout:$o.mono,isStatic:!1,space:null,viewPixelHeight:0,viewPixelWidth:0};class Ul extends Zo{constructor(e=Ol){if(super(),!Yo(e.space))throw new TypeError("XRCubeLayer's space needs to be an XRReferenceSpace");switch(this.init=Object.assign(Object.assign({},Ol),e),this.space=this.init.space,this.isStatic=this.init.isStatic,this.init.orientation?this.orientation=DOMPointReadOnly.fromPoint(this.init.orientation):this.orientation=new DOMPointReadOnly,this.init.layout){case $o.default:case $o["stereo-left-right"]:case $o["stereo-top-bottom"]:throw new TypeError("Invalid layout format for XRCubeLayer")}this.layout=this.init.layout,this.needsRedraw=!0}initialize(e,t){super.initialize(e,t),this._allocateColorTexturesInternal(),this._allocateDepthStencilTexturesInternal()}_allocateColorTexturesInternal(){if(this._colorTextures=[],this._texturesMeta=[],this.layout===$o.mono){const e=this._createCubeColorTexture();return this._texturesMeta.push(e),void this._colorTextures.push(e.texture)}{const e=this._createCubeColorTexture(),t=this._createCubeColorTexture();return this._texturesMeta.push(e,t),void this._colorTextures.push(e.texture,t.texture)}}_allocateDepthStencilTexturesInternal(){if(this._depthStencilTextures=[],this.init.depthFormat){if(this.context instanceof WebGLRenderingContext){if(!this.context.getExtension("WEBGL_depth_texture"))throw new TypeError("Depth textures not supported in the current context")}if(this.layout===$o.mono){const e=this._createCubeDepthTexture();return void this._depthStencilTextures.push(e.texture)}{const e=this._createCubeDepthTexture(),t=this._createCubeDepthTexture();return void this._depthStencilTextures.push(e.texture,t.texture)}}}_createCubeColorTexture(){let e=this.context.createTexture(),t={width:this.init.viewPixelWidth,height:this.init.viewPixelHeight,layers:1,type:qo.texture,textureFormat:this.init.colorFormat,texture:e};const n=this.context.getParameter(this.context.TEXTURE_BINDING_CUBE_MAP);this.context.bindTexture(this.context.TEXTURE_CUBE_MAP,e);for(let e=0;e<6;e++)this.context.texImage2D(this.context.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,t.textureFormat,t.width,t.height,0,t.textureFormat,this.context.UNSIGNED_BYTE,null);return this.context.bindTexture(this.context.TEXTURE_CUBE_MAP,n),t}_createCubeDepthTexture(){let e=this.context.createTexture(),t={width:this.init.viewPixelWidth,height:this.init.viewPixelHeight,layers:1,type:qo.texture,textureFormat:this.init.depthFormat,texture:e};const n=this.context.getParameter(this.context.TEXTURE_BINDING_CUBE_MAP);this.context.bindTexture(this.context.TEXTURE_CUBE_MAP,e);let i=this.init.depthFormat;this.context instanceof WebGL2RenderingContext&&(i===this.context.DEPTH_COMPONENT&&(i=this.context.DEPTH_COMPONENT24),i===this.context.DEPTH_STENCIL&&(i=this.context.DEPTH24_STENCIL8));for(let e=0;e<6;e++)this.context.texImage2D(this.context.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,i,t.width,t.height,0,t.textureFormat,this.context.UNSIGNED_INT,null);return this.context.bindTexture(this.context.TEXTURE_CUBE_MAP,n),t}getTextureType(){return qo.texture}}const zl=e=>e,Bl=zl`
|
|
837
|
-
attribute vec4 a_position;
|
|
838
|
-
uniform mat4 u_projectionMatrix;
|
|
839
|
-
uniform mat4 u_matrix;
|
|
840
|
-
varying vec3 v_normal;
|
|
841
|
-
|
|
842
|
-
void main() {
|
|
843
|
-
gl_Position = u_projectionMatrix * u_matrix * a_position;
|
|
844
|
-
|
|
845
|
-
v_normal = normalize(a_position.xyz);
|
|
846
|
-
}
|
|
847
|
-
`,Vl=zl`
|
|
848
|
-
precision mediump float;
|
|
849
|
-
|
|
850
|
-
varying vec3 v_normal;
|
|
851
|
-
|
|
852
|
-
uniform samplerCube u_texture;
|
|
853
|
-
|
|
854
|
-
void main() {
|
|
855
|
-
gl_FragColor = textureCube(u_texture, normalize(v_normal));
|
|
856
|
-
}
|
|
857
|
-
`;class Hl{constructor(e,t){this.savedVaoState={vao:null,arrayBuffer:null},this.hasMipmap=!1,this.layer=e,this.gl=t,this.transformMatrix=El(),this.program=pl(t,Bl,Vl),this.programInfo={attribLocations:{a_position:t.getAttribLocation(this.program,"a_position")},uniformLocations:{u_matrix:t.getUniformLocation(this.program,"u_matrix"),u_texture:t.getUniformLocation(this.program,"u_texture"),u_projectionMatrix:t.getUniformLocation(this.program,"u_projectionMatrix")}},this._createVAOs()}saveVaoState(){this.savedVaoState.vao=this.gl.getParameter(this.vaoGl.VERTEX_ARRAY_BINDING),this.savedVaoState.arrayBuffer=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING)}restoreVaoState(){this.vaoGl.bindVertexArray(this.savedVaoState.vao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.savedVaoState.arrayBuffer),this.savedVaoState.vao=this.savedVaoState.arrayBuffer=null}render(e,t){this.saveVaoState();let n=this.gl,i=e.getBaseLayer(),r=t.getViewerPose(e.getReferenceSpace());const a=n.getParameter(n.ACTIVE_TEXTURE);for(let e of r.views){let t=i.getViewport(e);n.viewport(t.x,t.y,t.width,t.height),n.activeTexture(n.TEXTURE0);const r=n.getParameter(n.TEXTURE_BINDING_CUBE_MAP);if(this.layer.layout===$o.stereo){const t="right"===e.eye?1:0;n.bindTexture(n.TEXTURE_CUBE_MAP,this.layer.colorTextures[t])}else n.bindTexture(n.TEXTURE_CUBE_MAP,this.layer.colorTextures[0]);this.layer.isStatic?(!0===this.layer.needsRedraw&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this.hasMipmap=!0):this.hasMipmap=this.layer.mipLevels>0,n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,this.hasMipmap?n.LINEAR_MIPMAP_LINEAR:n.LINEAR),this._renderInternal(this.layer.orientation,e),n.activeTexture(a),n.bindTexture(n.TEXTURE_CUBE_MAP,r)}this.restoreVaoState()}createPositionPoints(){const e=.5;return new Float32Array([-e,-e,-e,-e,e,-e,e,-e,-e,-e,e,-e,e,e,-e,e,-e,-e,-e,-e,e,e,-e,e,-e,e,e,-e,e,e,e,-e,e,e,e,e,-e,e,-e,-e,e,e,e,e,-e,-e,e,e,e,e,e,e,e,-e,-e,-e,-e,e,-e,-e,-e,-e,e,-e,-e,e,e,-e,-e,e,-e,e,-e,-e,-e,-e,-e,e,-e,e,-e,-e,-e,e,-e,e,e,-e,e,-e,e,-e,-e,e,e,-e,e,-e,e,e,-e,e,e,e,-e,e,e,e])}_renderInternal(e,t){let n=this.gl;const i=n.getParameter(n.CURRENT_PROGRAM);n.useProgram(this.program),this.vaoGl.bindVertexArray(this.vao),Tl(this.transformMatrix,[e.x,e.y,e.z,e.w]),this._poseOrientationMatrix||(this._poseOrientationMatrix=El()),Tl(this._poseOrientationMatrix,[t.transform.inverse.orientation.x,t.transform.inverse.orientation.y,t.transform.inverse.orientation.z,t.transform.inverse.orientation.w]),Ml(this.transformMatrix,this.transformMatrix,this._poseOrientationMatrix),n.uniformMatrix4fv(this.programInfo.uniformLocations.u_matrix,!1,this.transformMatrix),n.uniformMatrix4fv(this.programInfo.uniformLocations.u_projectionMatrix,!1,t.projectionMatrix),n.uniform1i(this.programInfo.uniformLocations.u_texture,0);var r=n.TRIANGLES,a=this.positionPoints.length/3;n.drawArrays(r,0,a),this.vaoGl.bindVertexArray(null),n.useProgram(i)}_recalculateVertices(){this.positionPoints=this.createPositionPoints()}_createVAOs(){this._recalculateVertices();let e=this.gl;this.vaoGl=fl(e),this.saveVaoState();let t=e.createBuffer();this.vao=this.vaoGl.createVertexArray(),this.vaoGl.bindVertexArray(this.vao),e.enableVertexAttribArray(this.programInfo.attribLocations.a_position),e.bindBuffer(e.ARRAY_BUFFER,t);const n=this.positionPoints;e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW);var i=e.FLOAT;e.vertexAttribPointer(this.programInfo.attribLocations.a_position,3,i,!1,0,0),this.restoreVaoState()}}class Gl{constructor(){this.mode="inline",this.layers=[],this.views=[],this.initializedViews=!1,this.isPolyfillActive=!1,this.taskQueue=[]}requestAnimationFrame(e){this.injectedFrameCallback||(this.injectedFrameCallback=(t,n)=>{let i=this.context;if(!this.initializedViews&&this.referenceSpace){let e=n.getViewerPose(this.referenceSpace);e&&(this.views=e.views,this.initializedViews=!0)}if(this.isPolyfillActive&&this.initializedViews){this.tempFramebuffer||(this.tempFramebuffer=i.createFramebuffer()),i.bindFramebuffer(i.FRAMEBUFFER,this.tempFramebuffer);const e=i.getParameter(i.COLOR_CLEAR_VALUE),t=i.getParameter(i.FRAMEBUFFER_BINDING);i.clearColor(0,0,0,0);for(let e of this.layers)if(e instanceof ul)for(let t=0;t<e.colorTextures.length;t++){e.colorTexturesMeta[t].type===qo["texture-array"]||(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e.colorTextures[t],0),e.depthStencilTextures&&t<e.depthStencilTextures.length?i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,e.depthStencilTextures[t],0):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,null,0),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT))}i.bindFramebuffer(i.FRAMEBUFFER,t),i.clearColor(e[0],e[1],e[2],e[3])}if(e(t,n),this.isPolyfillActive&&this.initializedViews){let e=i.isEnabled(i.BLEND),t=i.isEnabled(i.DEPTH_TEST),r=i.isEnabled(i.CULL_FACE);const a=i.getParameter(i.FRAMEBUFFER_BINDING),s=i.getParameter(i.COLOR_CLEAR_VALUE);i.bindFramebuffer(i.FRAMEBUFFER,this.getBaseLayer().framebuffer),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.clearColor(s[0],s[1],s[2],s[3]),i.enable(i.BLEND),i.disable(i.DEPTH_TEST),i.disable(i.CULL_FACE);let o=i.getParameter(i.BLEND_SRC_RGB),l=i.getParameter(i.BLEND_SRC_ALPHA),c=i.getParameter(i.BLEND_DST_RGB),u=i.getParameter(i.BLEND_DST_ALPHA);i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA);for(let e of this.layers)if(this.renderers||(this.renderers=new WeakMap),e instanceof ul){this.renderers.has(e)||this.renderers.set(e,wl(e,this.context));this.renderers.get(e).render(this)}else if(e instanceof ol){this.renderers.has(e)||this.renderers.set(e,new Nl(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof tl){this.renderers.has(e)||this.renderers.set(e,new kl(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof rl){this.renderers.has(e)||this.renderers.set(e,new Fl(e,this.context));this.renderers.get(e).render(this,n)}else if(e instanceof Ul){this.renderers.has(e)||this.renderers.set(e,new Hl(e,this.context));this.renderers.get(e).render(this,n)}else{const t=e;if(null===t.framebuffer)continue;i instanceof WebGL2RenderingContext?(i.bindFramebuffer(i.READ_FRAMEBUFFER,t.framebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,this.getBaseLayer().framebuffer),i.blitFramebuffer(0,0,t.framebufferWidth,t.framebufferHeight,0,0,this.getBaseLayer().framebufferWidth,this.getBaseLayer().framebufferHeight,i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT,i.LINEAR)):console.warn("GL blitFramebuffer is not supported on WebGL1, so XRWebGLLayers may not show up properly when polyfilled.")}for(e||i.disable(i.BLEND),t&&i.enable(i.DEPTH_TEST),r&&i.enable(i.CULL_FACE),i.blendFuncSeparate(o,c,l,u),i.bindFramebuffer(i.FRAMEBUFFER,a);this.taskQueue.length>0;){this.taskQueue.shift()()}}}),this._requestAnimationFrame(this.injectedFrameCallback)}updateRenderState(e){if(this.existingBaseLayer=e.baseLayer,e.layers&&(this.layers=e.layers),this.activeRenderState||this.createActiveRenderState(),this.activeRenderState=Object.assign(Object.assign({},this.activeRenderState),e),!e.layers)return void this._updateRenderState(e);let t,n=Object.assign({},e);delete n.layers;for(let i of this.layers)if(i instanceof Zo){t=i.getContext();break}if(!t&&!this.context){console.log("No existing context! Have the session make one");const r=document.createElement("canvas");if(t=r.getContext("webgl2",{xrCompatible:!0}),t||(t=r.getContext("webgl",{xrCompatible:!0})),!t)throw new Error("No webGL support detected.");function a(){t.canvas.width=t.canvas.clientWidth*window.devicePixelRatio,t.canvas.height=t.canvas.clientHeight*window.devicePixelRatio}document.body.appendChild(t.canvas),window.addEventListener("resize",a),a()}this.createInternalLayer(t),this.isPolyfillActive=!0,this._updateRenderState(Object.assign(Object.assign({},n),{baseLayer:this.internalLayer}))}initializeSession(e){this.mode=e,this.requestReferenceSpace("local").then(e=>{this.referenceSpace=e}).catch(e=>{}),this.requestReferenceSpace("viewer").then(e=>{this.viewerSpace=e})}getBaseLayer(e){return this.internalLayer||this.existingBaseLayer||!e||this.createInternalLayer(e),this.internalLayer||this.existingBaseLayer}getReferenceSpace(){return this.referenceSpace?this.referenceSpace:this.viewerSpace}getViewerSpace(){return this.viewerSpace}queueTask(e){this.taskQueue.push(e)}get renderState(){return this.activeRenderState||this.createActiveRenderState(),this.activeRenderState}get internalViews(){return this.views}getViewIndex(e){for(let t=0;t<this.views.length;t++){let n=this.views[t];if(e.eye===n.eye&&e.recommendedViewportScale===n.recommendedViewportScale)return t}return-1}createInternalLayer(e){if(!e&&this.internalLayer)return this.internalLayer;if(e===this.context&&this.internalLayer)return this.internalLayer;const t=Ko();return this.internalLayer=new t.XRWebGLLayer(this,e),this.setContext(e),this.internalLayer}setContext(e){this.context=e,this.tempFramebuffer=e.createFramebuffer(),this.renderers=new WeakMap}createActiveRenderState(){const e=Ko();let t=Object.getOwnPropertyNames(e.XRRenderState.prototype);const n={};for(let e of t)n[e]=this._renderState[e];n.layers=[],this.activeRenderState=n}}class Wl{constructor(){this.viewport={x:0,y:0,width:0,height:0}}}class jl{constructor(e,t){this.session=e,this.context=t,this.subImageCache=new Xl}createProjectionLayer(e=cl){const t=new ul(e);if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");return t.initialize(this.session,this.context),t}createQuadLayer(e=al){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===$o.default)throw new TypeError("Trying to create a quad layer with default layout");const t=new ol(e);return t.initialize(this.session,this.context),t}createCylinderLayer(e=Jo){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===$o.default)throw new TypeError("Cylinder Layer cannot have a default layout");const t=new tl(e);return t.initialize(this.session,this.context),t}createEquirectLayer(e=nl){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(e.layout===$o.default)throw new TypeError("Equirect Layer cannot have a default layout");if(!Yo(e.space))throw new TypeError("Equirect layer requires an XRReferenceSpace");let t=new rl(e);return t.initialize(this.session,this.context),t}createCubeLayer(e){if(this.session.ended)throw new Error("Session has ended");if(this.context.isContextLost())throw new Error("context is lost");if(!(this.context instanceof WebGL2RenderingContext))throw new Error("XRCubeLayer only work on WebGL2");if(!Yo(e.space))throw new TypeError("XRCubeLayer requires a space of type XRReferenceSpace");let t=new Ul(e);return t.initialize(this.session,this.context),t}getSubImage(e,t,n="none"){if(e.isStatic&&!1===e.needsRedraw)throw new Error("Invalid state for subimage creation");let i=this.subImageCache.tryGetCachedSubImage(this.context,e,n);if(i)return i;let r=new Wl;if(e instanceof ul)throw new TypeError;if(e.layout===$o.default)throw new TypeError;if(!this.validateStateofSubImageCreation(e,t))throw new Error("Invalid state for subimage creation");let a=0;if(e.layout===$o.stereo){if("none"===n)throw new TypeError;"right"===n&&(a=1)}e.getTextureType()===qo["texture-array"]?r.imageIndex=a:r.imageIndex=0;let s=0;e.getTextureType()===qo.texture?(r.colorTexture=e.colorTextures[a],s=a):(r.colorTexture=e.colorTextures[0],s=0),e.depthStencilTextures&&e.depthStencilTextures.length?e.getTextureType()===qo.texture?r.depthStencilTexture=e.depthStencilTextures[a]:r.depthStencilTexture=e.depthStencilTextures[0]:r.depthStencilTexture=null;const o=e.colorTexturesMeta[s];r.textureWidth=o.width,r.textureHeight=o.height;let l=1;return e.layout!==$o["stereo-left-right"]&&e.layout!==$o["stereo-top-bottom"]||(l=2),dl(r.viewport,o,e.layout,a,l),this.session.queueTask(()=>{e.needsRedraw=!1}),this.subImageCache.cacheSubImage(r,this.context,e,n),r}getViewSubImage(e,t){let n=this.subImageCache.tryGetCachedViewSubImage(this.context,e,t);if(n)return n;let i=new Wl,r=this.session;if(!r.internalViews||!r.internalViews.length)return console.warn("Tried to get view sub image before we have any views"),i;let a=r.getViewIndex(t),s=0;return e.getTextureType()===qo["texture-array"]?i.imageIndex=a:i.imageIndex=0,e.layout===$o.default&&e.getTextureType()===qo.texture?(i.colorTexture=e.colorTextures[a],s=a):(i.colorTexture=e.colorTextures[0],s=0),0===e.depthStencilTextures.length?i.depthStencilTexture=null:e.layout===$o.default&&e.getTextureType()===qo.texture?i.depthStencilTexture=e.depthStencilTextures[a]:i.depthStencilTexture=e.depthStencilTextures[0],i.textureWidth=e.colorTexturesMeta[s].width,i.textureHeight=e.colorTexturesMeta[s].height,dl(i.viewport,e.colorTexturesMeta[s],e.layout,a,r.internalViews.length),e.needsRedraw=!1,this.subImageCache.cacheViewSubImage(i,this.context,e,t),i}validateStateofSubImageCreation(e,t){return t.session===e.session&&(this.session===e.session&&(this.context===e.context&&(!(!e.colorTextures||!e.colorTextures.length)&&(!e.isStatic||!1!==e.needsRedraw))))}}class Xl{constructor(){this.cache=new Map,this.viewCache=new Map}cacheSubImage(e,t,n,i){let r=new Map;r.set(i,e);let a=new Map;a.set(n,r),this.cache.set(t,a)}tryGetCachedSubImage(e,t,n){var i,r;return null===(r=null===(i=this.cache.get(e))||void 0===i?void 0:i.get(t))||void 0===r?void 0:r.get(n)}cacheViewSubImage(e,t,n,i){let r=new Map;r.set(i,e);let a=new Map;a.set(n,r),this.viewCache.set(t,a)}tryGetCachedViewSubImage(e,t,n){var i,r;return null===(r=null===(i=this.viewCache.get(e))||void 0===i?void 0:i.get(t))||void 0===r?void 0:r.get(n)}}class ql{constructor(){this.injected=!1;const e=Ko();this._injectPolyfill(e)}_injectPolyfill(e){if(!("xr"in e.navigator))throw new Error("WebXR Layers polyfill requires WebXR support.");!0===this.injected&&console.warn("Polyfill has already been injected..."),(e=>!!e.navigator.xr&&!(!e.XRMediaBinding||!e.XRWebGLBinding))(e)||(this._polyfillRequiredLayersFeature(e),this._polyfillXRSession(e),e.XRWebGLBinding=jl,e.XRMediaBinding=ll,this.injected=!0,console.log("Injected Layers Polyfill"))}_polyfillXRSession(e){e.XRSession.prototype._updateRenderState=e.XRSession.prototype.updateRenderState,e.XRSession.prototype._requestAnimationFrame=e.XRSession.prototype.requestAnimationFrame;let t=Object.getOwnPropertyDescriptor(e.XRSession.prototype,"renderState");Object.defineProperty(e.XRSession.prototype,"_renderState",t);let n=Object.getOwnPropertyDescriptor(Gl.prototype,"renderState");Object.defineProperty(e.XRSession.prototype,"renderState",n);let i=Object.getOwnPropertyNames(Gl.prototype);for(let t of i){let n=Object.getOwnPropertyDescriptor(Gl.prototype,t);Object.defineProperty(e.XRSession.prototype,t,n)}}_polyfillRequiredLayersFeature(e){const t=e.navigator.xr.requestSession;Object.defineProperty(e.navigator.xr,"requestSessionInternal",{writable:!0}),e.navigator.xr.requestSessionInternal=t;Object.defineProperty(e.navigator.xr,"requestSession",{writable:!0}),e.navigator.xr.requestSession=(t,n)=>{const i=(n,i)=>e.navigator.xr.requestSessionInternal(n,i).then(e=>{Object.assign(e,new Gl);let n=e;return n.initializeSession(t),Promise.resolve(n)});if("immersive-vr"!==t)return i(t,n);if(!n)return i(t,n);if(n.requiredFeatures&&n.requiredFeatures.indexOf("layers")>-1){const e=Object.assign({},n),r=[...n.requiredFeatures],a=r.indexOf("layers");return r.splice(a,1),e.requiredFeatures=r,i(t,e)}return i(t,n)}}}const $l={ipd:.063,fovy:Math.PI/2,headsetPosition:new $a(0,1.6,0),headsetQuaternion:new Ya,stereoEnabled:!1},Yl=Kr(),Kl=Kr();class Ql{constructor(e,t={}){var n,i,r,a,s,o,l,c;this.version=Uo;const u=new Xa,d=new Qs(Ys.Viewer,u),h={[Ks.Left]:new ja(d),[Ks.Right]:new ja(d),[Ks.None]:new ja(d)},p=e.controllerConfig,f={};p&&Object.values(fs).forEach(e=>{p.layout[e]&&(f[e]=new Ms(p,e,u))});const m={[fs.Left]:new Do(bo,fs.Left,u),[fs.Right]:new Do(bo,fs.Right,u)},g=Ho(e.supportedFeatures)?new Go(d):void 0,v=null!==(n=t.canvasContainer)&&void 0!==n?n:document.createElement("div");v.dataset.webxr_runtime=`Immersive Web Emulation Runtime v${Uo}`,v.style.position="fixed",v.style.width="100%",v.style.height="100%",v.style.top="0",v.style.left="0",v.style.display="flex",v.style.justifyContent="center",v.style.alignItems="center",v.style.overflow="hidden",v.style.zIndex="999";const y=null===t.visibilityMask?void 0:null!==(i=t.visibilityMask)&&void 0!==i?i:e.visibilityMask,x=y?document.createElement("canvas"):void 0;x&&(x.dataset.webxrVisibilityMask=e.name,x.style.position="absolute",x.style.inset="0",x.style.width="100%",x.style.height="100%",x.style.pointerEvents="none",x.style.zIndex=4..toString()),this[ba]={name:e.name,supportedSessionModes:e.supportedSessionModes,supportedFeatures:e.supportedFeatures,supportedFrameRates:e.supportedFrameRates,isSystemKeyboardSupported:e.isSystemKeyboardSupported,internalNominalFrameRate:e.internalNominalFrameRate,environmentBlendModes:e.environmentBlendModes,interactionMode:e.interactionMode,userAgent:e.userAgent,position:null!==(r=t.headsetPosition)&&void 0!==r?r:$l.headsetPosition.clone(),quaternion:null!==(a=t.headsetQuaternion)&&void 0!==a?a:$l.headsetQuaternion.clone(),stereoEnabled:null!==(s=t.stereoEnabled)&&void 0!==s?s:$l.stereoEnabled,ipd:null!==(o=t.ipd)&&void 0!==o?o:$l.ipd,fovy:null!==(l=t.fovy)&&void 0!==l?l:$l.fovy,visibilityMask:y,visibilityMaskEnabled:Boolean(y)&&(null===(c=t.visibilityMaskEnabled)||void 0===c||c),visibilityMaskCanvas:x,controllers:f,hands:m,gaze:g,primaryInputMode:"controller",pendingReferenceSpaceReset:!1,visibilityState:"visible",pendingVisibilityState:null,xrSystem:null,installedGlobalObject:null,previousNavigatorXRDescriptor:null,previousUserAgentDescriptor:null,previousGlobals:null,previousMakeXRCompatible:null,matrix:Or(),globalSpace:u,viewerSpace:d,viewSpaces:h,canvasContainer:v,getViewport:(e,t)=>{const n=e.context.canvas,{width:i,height:r}=n,a=this[ba].stereoEnabled,s=t.eye;let o,l,c,u;switch(s){case Ks.None:o=0,l=0,c=i,u=r;break;case Ks.Left:o=0,l=0,c=a?i/2:i,u=r;break;case Ks.Right:o=i/2,l=0,c=a?i/2:0,u=r}const d=this[ba].viewportCache[s];if(d&&d.x===o&&d.y===l&&d.width===c&&d.height===u)return d;const h=new jo(o,l,c,u);return this[ba].viewportCache[s]=h,h},viewportCache:{},updateViews:()=>{jr(this[ba].viewerSpace[Ua].offsetMatrix,this[ba].quaternion.quat,this[ba].position.vec3),Jr(Yl,-this[ba].ipd/2,0,0),Gr(this[ba].viewSpaces[Ks.Left][Ua].offsetMatrix,Yl),Jr(Kl,this[ba].ipd/2,0,0),Gr(this[ba].viewSpaces[Ks.Right][Ua].offsetMatrix,Kl)},onBaseLayerSet:e=>{if(!e)return;const t=e.context.canvas;if(t.parentElement!==this[ba].canvasContainer){const e=this[ba].devui;if(e){const{devUICanvas:t,devUIContainer:n}=e;t.style.zIndex=3..toString(),n.style.zIndex=5..toString(),this[ba].canvasContainer.appendChild(e.devUICanvas),this[ba].canvasContainer.appendChild(e.devUIContainer)}const n=this[ba].sem;n&&(n.environmentCanvas.style.zIndex=1..toString(),this[ba].canvasContainer.appendChild(n.environmentCanvas)),this[ba].canvasData={canvas:t,parent:t.parentElement,width:t.width,height:t.height,zIndex:t.style.zIndex},t.style.zIndex=2..toString(),this[ba].canvasContainer.appendChild(t),this[ba].visibilityMaskCanvas&&this[ba].canvasContainer.appendChild(this[ba].visibilityMaskCanvas),document.body.appendChild(this[ba].canvasContainer)}t.width=window.innerWidth,t.height=window.innerHeight},onSessionEnd:()=>{var e,t;if(null===(t=null===(e=this[ba].devui)||void 0===e?void 0:e.onSessionEnd)||void 0===t||t.call(e),this[ba].canvasData){const{canvas:e,parent:t,width:n,height:i,zIndex:r}=this[ba].canvasData;e.width=n,e.height=i,e.style.zIndex=r,t?t.appendChild(e):this[ba].canvasContainer.removeChild(e);const a=this[ba].devui;a&&(this[ba].canvasContainer.removeChild(a.devUICanvas),this[ba].canvasContainer.removeChild(a.devUIContainer));const s=this[ba].sem;s&&this[ba].canvasContainer.removeChild(s.environmentCanvas);const o=this[ba].visibilityMaskCanvas;(null==o?void 0:o.parentElement)===this[ba].canvasContainer&&this[ba].canvasContainer.removeChild(o),document.body.removeChild(this[ba].canvasContainer),this[ba].canvasData=void 0,window.dispatchEvent(new Event("resize"))}},onFrameStart:e=>{var t;const n=performance.now(),i=this[ba].lastFrameTime>0?n-this[ba].lastFrameTime:16.67;if(this[ba].lastFrameTime=n,this[ba].remote&&this[ba].remote.update(i),null===(t=this[ba].actionPlayer)||void 0===t?void 0:t.playing)this[ba].actionPlayer.playFrame();else{const t=e.session;this[ba].pendingVisibilityState&&(this[ba].visibilityState=this[ba].pendingVisibilityState,this[ba].pendingVisibilityState=null,t.dispatchEvent(new Js("visibilitychange",{session:t}))),"visible"===this[ba].visibilityState&&this.activeInputs.forEach(t=>{t.onFrameStart(e)}),this[ba].pendingReferenceSpaceReset&&(t[ka].referenceSpaces.forEach(e=>{switch(e[Oa].type){case Ys.Local:case Ys.LocalFloor:case Ys.BoundedFloor:case Ys.Unbounded:e.dispatchEvent(new zo("reset",{referenceSpace:e}))}}),this[ba].pendingReferenceSpaceReset=!1)}this[ba].updateViews(),this.drawVisibilityMask()},controlMode:"manual",controlModeListeners:new Set,stateChangeListeners:new Set,remote:null,runtime:null,lastFrameTime:0},this[ba].runtime={kind:"emulated",getSession:()=>{var e,t,n,i,r,a;const s=this.activeSession;if(!s)return null;const o=s[ka],l=s,c=null===(e=null==o?void 0:o.referenceSpaces)||void 0===e?void 0:e[0];return{mode:null!==(n=null!==(t=null==o?void 0:o.mode)&&void 0!==t?t:l.mode)&&void 0!==n?n:"immersive-vr",enabledFeatures:null!==(i=l.enabledFeatures)&&void 0!==i?i:[],visibilityState:null!==(r=l.visibilityState)&&void 0!==r?r:this.visibilityState,originOffsetMatrix:null!==(a=null==c?void 0:c[Ua].offsetMatrix)&&void 0!==a?a:null,end:()=>{var e;return null===(e=l.end)||void 0===e?void 0:e.call(l)}}}},this[ba].remote=new hs(this),this[ba].updateViews()}drawVisibilityMask(){var e;const t=this[ba].visibilityMask,n=this[ba].visibilityMaskCanvas,i=null===(e=this[ba].canvasData)||void 0===e?void 0:e.canvas;if(!(this[ba].visibilityMaskEnabled&&t&&n&&i))return;const r=i.width,a=i.height;if(r<=0||a<=0)return;n.width===r&&n.height===a||(n.width=r,n.height=a);const s=n.getContext("2d");if(!s)return;s.clearRect(0,0,r,a),s.fillStyle="#000";const o=this[ba].stereoEnabled?["left","right"]:["left"],l=r/o.length;o.forEach((e,n)=>{const i=n*l,r=function(e,t,n,i){if(!Number.isFinite(t)||t<=0||t>=Math.PI||!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=0)return{x:0,y:0,width:0,height:0};const r=Math.tan(t/2),a=r*(n/i),s=Xo(-Math.tan(e.angleLeft)/a,-1,1),o=Xo(Math.tan(e.angleRight)/a,-1,1),l=Xo(-Math.tan(e.angleDown)/r,-1,1),c=(s+1)/2*n,u=(o+1)/2*n,d=(1-Xo(Math.tan(e.angleUp)/r,-1,1))/2*i,h=(1-l)/2*i;return{x:c,y:d,width:Math.max(0,u-c),height:Math.max(0,h-d)}}(t[e],this[ba].fovy,l,a);s.fillRect(i,0,l,a),s.clearRect(i+r.x,r.y,r.width,r.height)})}isNativeXRAvailable(){var e;const t=null===(e=globalThis.navigator)||void 0===e?void 0:e.xr;return Boolean(t)&&!(t instanceof Wo)}installRuntime(e){var t,n,i,r;if("native"===this[ba].runtime.kind)throw new DOMException("Cannot install the emulated runtime while a native override is installed.","InvalidStateError");const a=null!==(t=null==e?void 0:e.globalObject)&&void 0!==t?t:globalThis,s=null==e?void 0:e.polyfillLayers;if(this.isNativeXRAvailable()&&!(null==e?void 0:e.forceInstall))return void console.warn("IWER: a native WebXR runtime is already available on navigator.xr; skipping installRuntime. Pass { forceInstall: true } to override.");const o=new Map,l=new Map;this[ba].installedGlobalObject=a,this[ba].previousGlobals=o,this[ba].previousMakeXRCompatible=l;const c=e=>{e&&(l.set(e,{existed:"makeXRCompatible"in e,descriptor:Object.getOwnPropertyDescriptor(e,"makeXRCompatible")}),Object.defineProperty(e,"makeXRCompatible",{value:function(){return new Promise((e,t)=>{e(!0)})},configurable:!0}))};c(WebGL2RenderingContext.prototype),c(null===(n=globalThis.WebGLRenderingContext)||void 0===n?void 0:n.prototype),this[ba].xrSystem=new Wo(this),this[ba].previousNavigatorXRDescriptor=null!==(i=Object.getOwnPropertyDescriptor(globalThis.navigator,"xr"))&&void 0!==i?i:null,this[ba].previousUserAgentDescriptor=null!==(r=Object.getOwnPropertyDescriptor(navigator,"userAgent"))&&void 0!==r?r:null,Object.defineProperty(globalThis.navigator,"xr",{value:this[ba].xrSystem,configurable:!0}),Object.defineProperty(navigator,"userAgent",{value:this[ba].userAgent,writable:!1,configurable:!0,enumerable:!0});const u=(e,t)=>{o.set(e,{existed:e in a,value:a[e]}),a[e]=t};u("XRSystem",Wo),u("XRSession",vo),u("XRRenderState",Zs),u("XRFrame",po),u("XRSpace",ja),u("XRReferenceSpace",Qs),u("XRJointSpace",xo),u("XRView",eo),u("XRViewport",jo),u("XRRigidTransform",Hs),u("XRPose",to),u("XRViewerPose",io),u("XRJointPose",no),u("XRInputSource",_s),u("XRInputSourceArray",bs),u("XRHand",yo),u("XRLayer",No),u("XRWebGLLayer",Fo),u("XRSessionEvent",Js),u("XRInputSourceEvent",ws),u("XRInputSourcesChangeEvent",qs),u("XRReferenceSpaceEvent",zo),s?new ql:u("XRMediaBinding",void 0),u("XRWebGLBinding",Os)}uninstallRuntime(){var e,t,n;const i=this[ba].previousGlobals,r=this[ba].installedGlobalObject;i&&r&&i.forEach(({existed:e,value:t},n)=>{e?r[n]=t:delete r[n]});const a=this[ba].previousNavigatorXRDescriptor;a?Object.defineProperty(globalThis.navigator,"xr",a):(null===(e=Object.getOwnPropertyDescriptor(globalThis.navigator,"xr"))||void 0===e?void 0:e.configurable)&&delete globalThis.navigator.xr;const s=this[ba].previousUserAgentDescriptor;s&&(null===(t=Object.getOwnPropertyDescriptor(navigator,"userAgent"))||void 0===t?void 0:t.configurable)&&Object.defineProperty(navigator,"userAgent",s),null===(n=this[ba].previousMakeXRCompatible)||void 0===n||n.forEach(({existed:e,descriptor:t},n)=>{e&&t?Object.defineProperty(n,"makeXRCompatible",t):delete n.makeXRCompatible}),this[ba].xrSystem=null,this[ba].installedGlobalObject=null,this[ba].previousGlobals=null,this[ba].previousMakeXRCompatible=null,this[ba].previousNavigatorXRDescriptor=null,this[ba].previousUserAgentDescriptor=null}installDevUI(e){this[ba].devui=new e(this)}installSEM(e){this[ba].sem=new e(this)}get supportedSessionModes(){return this[ba].supportedSessionModes}get supportedFeatures(){return this[ba].supportedFeatures}get supportedFrameRates(){return this[ba].supportedFrameRates}get isSystemKeyboardSupported(){return this[ba].isSystemKeyboardSupported}get internalNominalFrameRate(){return this[ba].internalNominalFrameRate}get stereoEnabled(){return this[ba].stereoEnabled}set stereoEnabled(e){this[ba].stereoEnabled=e}get ipd(){return this[ba].ipd}set ipd(e){this[ba].ipd=e}get fovy(){return this[ba].fovy}set fovy(e){this[ba].fovy=e}get visibilityMask(){return this[ba].visibilityMask}get visibilityMaskEnabled(){return this[ba].visibilityMaskEnabled}set visibilityMaskEnabled(e){const t=Boolean(this[ba].visibilityMask)&&e;this[ba].visibilityMaskEnabled=t,this[ba].visibilityMaskCanvas&&(this[ba].visibilityMaskCanvas.style.display=t?"":"none")}get position(){return this[ba].position}get quaternion(){return this[ba].quaternion}get viewerSpace(){var e;return(null===(e=this[ba].actionPlayer)||void 0===e?void 0:e.playing)?this[ba].actionPlayer.viewerSpace:this[ba].viewerSpace}get viewSpaces(){var e;return(null===(e=this[ba].actionPlayer)||void 0===e?void 0:e.playing)?this[ba].actionPlayer.viewSpaces:this[ba].viewSpaces}get controllers(){return this[ba].controllers}get hands(){return this[ba].hands}get gaze(){return this[ba].gaze}get primaryInputMode(){return this[ba].primaryInputMode}set primaryInputMode(e){"controller"===e||"hand"===e?this[ba].primaryInputMode=e:console.warn('primary input mode can only be "controller" or "hand"')}get activeInputs(){if("visible"!==this[ba].visibilityState)return[];const e="controller"===this[ba].primaryInputMode?Object.values(this[ba].controllers):Object.values(this[ba].hands);return(this[ba].gaze?[...e,this[ba].gaze]:e).filter(e=>e.connected)}get inputSources(){var e;return(null===(e=this[ba].actionPlayer)||void 0===e?void 0:e.playing)?this[ba].actionPlayer.inputSources:this.activeInputs.map(e=>e.inputSource)}get canvasContainer(){return this[ba].canvasContainer}get canvasDimensions(){if(this[ba].canvasData){const{width:e,height:t}=this[ba].canvasData.canvas;return{width:e,height:t}}}get appCanvas(){var e;return null===(e=this[ba].canvasData)||void 0===e?void 0:e.canvas}get activeSession(){var e;return null===(e=this[ba].xrSystem)||void 0===e?void 0:e[Ma].activeSession}get sessionOffered(){var e;return Boolean(null===(e=this[ba].xrSystem)||void 0===e?void 0:e[Ma].offeredSessionConfig)}get name(){return this[ba].name}grantOfferedSession(){const e=this[ba].xrSystem,t=null==e?void 0:e[Ma];if(t&&t.offeredSessionConfig){const{resolve:n,reject:i,mode:r,options:a}=t.offeredSessionConfig;t.offeredSessionConfig=void 0,e.requestSession(r,a).then(n).catch(i)}}recenter(){const e=new $a(-this.position.x,0,-this.position.z),t=new $a(0,0,-1).applyQuaternion(this.quaternion);t.y=0,t.normalize();const n=Math.atan2(t.x,-t.z),i=(new Ya).setFromAxisAngle(new $a(0,1,0),n);this.position.add(e),this.quaternion.multiply(i),[...Object.values(this[ba].controllers),...Object.values(this[ba].hands)].forEach(t=>{t.position.add(e),t.quaternion.multiply(i),t.position.applyQuaternion(i)}),this[ba].pendingReferenceSpaceReset=!0}get visibilityState(){return this[ba].visibilityState}updateVisibilityState(e){if(!Object.values(["visible","visible-blurred","hidden"]).includes(e))throw new DOMException("Invalid XRVisibilityState value","NotSupportedError");e!==this[ba].visibilityState&&(this[ba].pendingVisibilityState=e)}createActionPlayer(e,t,n={}){var i,r;const a=new Oo(e,t,this[ba].ipd,n);return this[ba].actionPlayer=a,null===(r=(i=this[ba].runtime).onActionPlayerCreated)||void 0===r||r.call(i,a),a}get devui(){return this[ba].devui}get sem(){return this[ba].sem}get remote(){return this[ba].remote}get controlMode(){return this[ba].controlMode}set controlMode(e){if("manual"!==e&&"programmatic"!==e)return void console.warn('control mode can only be "manual" or "programmatic"');this[ba].controlMode!==e&&(this[ba].controlMode=e,this[ba].controlModeListeners.forEach(t=>t(e)))}onControlModeChange(e){return this[ba].controlModeListeners.add(e),()=>{this[ba].controlModeListeners.delete(e)}}onStateChange(e){return this[ba].stateChangeListeners.add(e),()=>{this[ba].stateChangeListeners.delete(e)}}notifyStateChange(){this[ba].stateChangeListeners.forEach(e=>e())}}const Zl={mapping:ps.XRStandard,buttons:[{id:"trigger",type:"analog",eventTrigger:"select"},{id:"squeeze",type:"analog",eventTrigger:"squeeze"},null,{id:"thumbstick",type:"binary"},{id:"x-button",type:"binary"},{id:"y-button",type:"binary"},{id:"thumbrest",type:"binary"}],axes:[null,null,{id:"thumbstick",type:"x-axis"},{id:"thumbstick",type:"y-axis"}]},Jl={mapping:ps.XRStandard,buttons:[{id:"trigger",type:"analog",eventTrigger:"select"},{id:"squeeze",type:"analog",eventTrigger:"squeeze"},null,{id:"thumbstick",type:"binary"},{id:"a-button",type:"binary"},{id:"b-button",type:"binary"},{id:"thumbrest",type:"binary"}],axes:[null,null,{id:"thumbstick",type:"x-axis"},{id:"thumbstick",type:"y-axis"}]},ec={profileId:"oculus-touch-v2",fallbackProfileIds:["oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:Zl,gripOffsetMatrix:[.9925461411476135,4.673031295254759e-9,-.12186938524246216,0,.08617470413446426,.7071065306663513,.7018362283706665,0,.0861746296286583,-.70710688829422,.7018358707427979,0,-.003979847766458988,-.01585787907242775,.04964185878634453,1],numHapticActuators:1},right:{gamepad:Jl,gripOffsetMatrix:[.9925461411476135,3.688163374704345e-8,.12186937034130096,0,-.08617469668388367,.7071066498756409,.7018361687660217,0,-.0861746147274971,-.7071068286895752,.7018359899520874,0,.003979853354394436,-.01585787907242775,.04964182525873184,1],numHapticActuators:1}}},tc={profileId:"oculus-touch-v3",fallbackProfileIds:["oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:Zl,gripOffsetMatrix:[.9925461411476135,2.0823669899527886e-8,-.12186937034130096,0,.08617465198040009,.7071067094802856,.701836109161377,0,.08617466688156128,-.7071067690849304,.7018360495567322,0,-.003979838453233242,-.015857907012104988,.04964181408286095,1],numHapticActuators:1},right:{gamepad:Jl,gripOffsetMatrix:[.9925461411476135,-8.329467959811154e-8,.12186941504478455,0,-.08617465943098068,.7071066498756409,.7018361687660217,0,-.08617471158504486,-.7071068286895752,.7018359303474426,0,.003979798872023821,-.015857888385653496,.049641866236925125,1],numHapticActuators:1}}},nc={profileId:"meta-quest-touch-pro",fallbackProfileIds:["oculus-touch-v2","oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:Zl,gripOffsetMatrix:[.9925461411476135,-1.5779937356796836e-8,-.12186935544013977,0,.08617467433214188,.7071067094802856,.701836109161377,0,.0861746296286583,-.7071067690849304,.7018360495567322,0,-.003979836590588093,-.015857847407460213,.049641840159893036,1],numHapticActuators:3},right:{gamepad:Jl,gripOffsetMatrix:[.9925461411476135,9267653311439972e-26,.12186937034130096,0,-.08617467433214188,.7071067094802856,.7018361687660217,0,-.08617464452981949,-.7071067690849304,.7018360495567322,0,.003979847766458988,-.01585782691836357,.04964186251163483,1],numHapticActuators:3}}},ic={profileId:"meta-quest-touch-plus",fallbackProfileIds:["oculus-touch-v3","oculus-touch","generic-trigger-squeeze-thumbstick"],layout:{left:{gamepad:Zl,gripOffsetMatrix:[.9925461411476135,1.0736208366779465e-8,-.12186933308839798,0,.08617459982633591,.70710688829422,.7018360495567322,0,.08617466688156128,-.7071067094802856,.7018362283706665,0,-.003979803062975407,-.015857873484492302,.04964187368750572,1],numHapticActuators:1},right:{gamepad:Jl,gripOffsetMatrix:[.9925461411476135,-2.6238110351073374e-8,.12186934053897858,0,-.0861746147274971,.7071067690849304,.7018360495567322,0,-.08617465943098068,-.7071067094802856,.701836109161377,0,.003979838453233242,-.015857869759202003,.04964182525873184,1],numHapticActuators:1}}},rc=e=>e*Math.PI/180,ac={left:{angleLeft:rc(37),angleRight:rc(37),angleUp:rc(25),angleDown:rc(43)},right:{angleLeft:rc(37),angleRight:rc(37),angleUp:rc(25),angleDown:rc(43)}},sc={name:"Oculus Quest 1",controllerConfig:ec,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","hand-tracking"],supportedFrameRates:[72,80,90],isSystemKeyboardSupported:!0,internalNominalFrameRate:72,environmentBlendModes:{"immersive-vr":fo.Opaque,"immersive-ar":fo.AlphaBlend},interactionMode:mo.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 1) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},oc={name:"Meta Quest 2",controllerConfig:tc,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:72,environmentBlendModes:{"immersive-vr":fo.Opaque,"immersive-ar":fo.AlphaBlend},interactionMode:mo.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 2) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},lc={name:"Meta Quest Pro",controllerConfig:nc,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking","gaze-tracking","eye-tracking"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:90,environmentBlendModes:{"immersive-vr":fo.Opaque,"immersive-ar":fo.AlphaBlend},interactionMode:mo.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest Pro) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},cc={name:"Meta Quest 3",controllerConfig:ic,supportedSessionModes:["inline","immersive-vr","immersive-ar"],supportedFeatures:["viewer","local","local-floor","bounded-floor","unbounded","anchors","plane-detection","mesh-detection","hit-test","hand-tracking","depth-sensing"],supportedFrameRates:[72,80,90,120],isSystemKeyboardSupported:!0,internalNominalFrameRate:90,environmentBlendModes:{"immersive-vr":fo.Opaque,"immersive-ar":fo.AlphaBlend},interactionMode:mo.WorldSpace,userAgent:"Mozilla/5.0 (X11; Linux x86_64; Quest 3) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36"},uc={...cc,name:"Meta VR Glasses",supportedFrameRates:[72,90,96,100,120],visibilityMask:ac};class dc{constructor(){this.entries=[]}get size(){return this.entries.length}define(e,t,n){const i=Object.getOwnPropertyDescriptor(e,t);try{return Object.defineProperty(e,t,n),this.entries.push({target:e,key:t,descriptor:i}),!0}catch(e){return!1}}revert(){for(let e=this.entries.length-1;e>=0;e--){const{target:t,key:n,descriptor:i}=this.entries[e];try{i?Object.defineProperty(t,n,i):Reflect.deleteProperty(t,n)}catch(e){}}this.entries=[]}}const hc=Symbol.for("@iwer/native-override"),pc=["select","selectstart","selectend","squeeze","squeezestart","squeezeend"],fc="hand-tracking",mc=Math.PI/180,gc=Or(),vc=Or(),yc=Or(),xc=Or(),bc=Or(),_c=Or(),wc=Or(),Sc=Or(),Ec=Kr(),Mc=oa(),Tc=new Float32Array(1);function Ac(e,t){const n=function(e,t){let n=e;for(;n;){if(Object.prototype.hasOwnProperty.call(n,t))return n;n=Object.getPrototypeOf(n)}return null}(e,t),i=n?Object.getOwnPropertyDescriptor(n,t):void 0;return n&&i?{owner:n,descriptor:i}:null}function Rc(e){const t=Or();for(let n=0;n<16;n++)t[n]=e.matrix[n];return t}function Pc(e,t,n){for(let i=0;i<16;i++)t[n+i]=e[i]}const Cc=Kr(),Lc=Kr(),Ic=oa(),Dc=oa();function Nc(e,t){if(Xr(Cc,e),Xr(Lc,t),function(e,t){var n=t[0]-e[0],i=t[1]-e[1],r=t[2]-e[2];return n*n+i*i+r*r}(Cc,Lc)>25e-6)return!1;$r(Ic,e),$r(Dc,t);const n=Math.abs(ma(Ic,Dc));return Math.min(n,1)>=Math.cos(mc/2)}function kc(e){return Number.isFinite(e)&&e>0}function Fc(e){return new DOMException(e,"InvalidStateError")}function Oc(e){return new DOMException(e,"NotSupportedError")}function Uc(e){var t,n,i;const r=null!==(t=e.globalObject)&&void 0!==t?t:globalThis;return null!==(n=e.xrSystem)&&void 0!==n?n:null===(i=r.navigator)||void 0===i?void 0:i.xr}function zc(e={}){var t;const n=null!==(t=e.globalObject)&&void 0!==t?t:globalThis,i=Uc(e),r=[],a=Boolean(i&&"function"==typeof i.requestSession&&function(e,t){const n=Object.getOwnPropertyDescriptor(e,t);if(n)return n.configurable||!0===n.writable;if(Object.isExtensible(e))return!0;const i=Ac(Object.getPrototypeOf(e),t);return Boolean(i&&(i.descriptor.configurable||!0===i.descriptor.writable))}(i,"requestSession"));return i?a||r.push("The native XRSystem.requestSession method cannot be patched."):r.push("navigator.xr is unavailable."),"function"!=typeof n.XRRigidTransform&&r.push("The native XRRigidTransform constructor is unavailable."),{supported:a&&"function"==typeof n.XRRigidTransform,requestSession:a,notes:r}}class Bc{constructor(e,t={}){var n,i,r;this.patches=new dc,this.sessionsByObject=new WeakMap,this.liveSessions=new Set,this.frameSessions=new WeakMap,this.spaces=new WeakMap,this.hitTestBindings=new WeakMap,this.syntheticEvents=new WeakSet,this.patchedFrameOwners=new WeakSet,this.patchedViewerFrameOwners=new WeakSet,this.patchedFillPosesOwners=new WeakSet,this.patchedJointPoseOwners=new WeakSet,this.patchedJointRadiiOwners=new WeakSet,this.patchedReferenceSpaceOwners=new WeakSet,this.patchedEnabledFeaturesOwners=new WeakSet,this.patchedInputSourceOwners=new WeakSet,this.patchedRafOwners=new WeakSet,this.patchedRequestReferenceSpaceOwners=new WeakSet,this.patchedHitTestOwners=new WeakSet,this.patchedHitTestResultOwners=new WeakSet,this.patchedCreateAnchorOwners=new WeakSet,this.instancePatchedReferenceSpaces=new WeakSet,this.rawGetPoseByOwner=new WeakMap,this.rawGetPoseByFrame=new WeakMap,this.rawRafByOwner=new WeakMap,this.rawRequestReferenceSpaceByOwner=new WeakMap,this.rawInputSourcesGetterByOwner=new WeakMap,this.rawTransformGetters=new WeakMap,this.transformReaders=new WeakMap,this.transformOverrides=new WeakMap,this.patchedTransformOwners=new WeakSet,this.instancePatchedFrameEpochs=new WeakMap,this.instancePatchedTransformEpochs=new WeakMap,this.warned=new Set,this.unhealthyFrameAdapters=new Set,this.installedState=!1,this.primarySession=null,this.previousRuntime=null,this.epoch=0,this.wiredPlayer=null,this.playbackFrame=null,this.detachedPlaybackFrame={},this.device=e,this.mode=null!==(n=t.mode)&&void 0!==n?n:"full",this.options={...t,mode:this.mode,onUnsupported:null!==(i=t.onUnsupported)&&void 0!==i?i:"warn"},this.globalObject=null!==(r=t.globalObject)&&void 0!==r?r:globalThis,this.xrSystem=Uc(t);const a=zc({xrSystem:this.xrSystem,globalObject:this.globalObject});this.capabilityState={phase:"uninstalled",supported:a.supported,requestSession:!1,offerSession:!1,inputSources:!1,inputEvents:!1,brandedInputEvents:!1,enabledFeatures:!1,viewerSpaceTagging:!1,poseOverride:!1,batchPoses:!1,viewerPose:!1,viewTransforms:!1,handInput:!1,jointPoses:!1,actionPlayback:!1,anchors:!1,hitTest:!1,notes:[...a.notes]}}get installed(){return this.installedState}get capabilities(){return{...this.capabilityState,notes:[...this.capabilityState.notes]}}get sessions(){return Array.from(this.liveSessions,e=>({session:e.session,mode:e.mode,primary:e===this.primarySession,anchorSpace:e.anchorSpace}))}install(){if(this.installedState)return;const e=Uc(this.options);this.xrSystem=e;const t=zc({xrSystem:e,globalObject:this.globalObject});if(Object.assign(this.capabilityState,{phase:"uninstalled",supported:t.supported,requestSession:!1,offerSession:!1,inputSources:!1,inputEvents:!1,brandedInputEvents:!1,enabledFeatures:!1,viewerSpaceTagging:!1,poseOverride:!1,batchPoses:!1,viewerPose:!1,viewTransforms:!1,handInput:!1,jointPoses:!1,actionPlayback:!1,anchors:!1,hitTest:!1,notes:[]}),this.warned.clear(),!e||!t.supported){const e=t.notes.length>0?t.notes:["Native WebXR override prerequisites are unavailable."];this.capabilityState.supported=!1;for(const t of e)this.note(t);if("throw"===this.options.onUnsupported)throw new Error(e.join(" "));return}if(this.device[ba].installedGlobalObject)throw Fc("Cannot install a native override while the emulated IWER runtime is installed.");const n=function(e){try{const t=Reflect.get(e,hc),n=Reflect.get(e,"requestSession"),i=null!=t?t:"function"==typeof n?Reflect.get(n,hc):null;if(null!==i&&"object"==typeof i&&"boolean"==typeof i.installed&&"function"==typeof i.uninstall)return i}catch(e){}return null}(e);if(n&&n!==this)throw Fc("A native IWER override is already installed on this XRSystem.");const i=this,r=t=>{const n=async function(n,r){if(this!==e||!function(e){return"immersive-vr"===e||"immersive-ar"===e}(n))return t.call(this,n,r);const a=i.prepareSessionRequest(r),s=await t.call(this,n,a.options);if("gaze-only"===i.options.mode&&0===a.gaze.enabled.length)return s;try{await i.attachSession(s,n,a.gaze.enabled)}catch(e){i.detachSession(s);if(a.gaze.required.length>0||0===a.gaze.enabled.length&&"throw"===i.options.onUnsupported){if(await s.end().catch(()=>{}),a.gaze.required.length>0&&(!(e instanceof DOMException)||"NotSupportedError"!==e.name))throw Oc(i.errorText(e));throw e}i.note(`Native session override was skipped: ${i.errorText(e)}`,"session-attach-failed")}return s};return Object.defineProperty(n,hc,{value:this}),n},a=(t,n)=>{let i=this.patches.define(e,t,{configurable:!0,writable:!0,value:n});if(!i){const r=Ac(e,t);if(r&&"function"==typeof r.descriptor.value){const e=r.descriptor;i=this.patches.define(r.owner,t,{...e,value:n})}}return i};if(!a("requestSession",r(e.requestSession)))return void this.unsupported("Unable to patch native XRSystem.requestSession.");const s=Reflect.get(e,"offerSession");"function"==typeof s&&(a("offerSession",r(s))?this.capabilityState.offerSession=!0:this.note("The native XRSystem.offerSession method could not be patched; sessions created through it are not overridden.")),this.patches.define(e,hc,{configurable:!0,value:this}),this.previousRuntime=this.device[ba].runtime,this.device[ba].runtime={kind:"native",getSession:()=>{const e=this.primarySession;return!e||e.ended?null:{mode:e.mode,enabledFeatures:e.enabledFeatures,visibilityState:e.session.visibilityState,originOffsetMatrix:null,end:()=>e.session.end()}},onActionPlayerCreated:"full"===this.options.mode?e=>this.wirePlayer(e):void 0},this.installedState=!0,this.capabilityState.phase="installed",this.capabilityState.requestSession=!0}uninstall(){if(this.installedState){this.installedState=!1;for(const e of Array.from(this.liveSessions))this.detachAdapter(e,!0);this.unwirePlayer(),this.patches.revert(),this.previousRuntime&&(this.device[ba].runtime=this.previousRuntime,this.previousRuntime=null),this.resetPatchTracking(),this.playbackFrame=null,this.warned.clear(),Object.assign(this.capabilityState,{phase:"uninstalled",requestSession:!1,offerSession:!1,inputSources:!1,inputEvents:!1,brandedInputEvents:!1,enabledFeatures:!1,viewerSpaceTagging:!1,poseOverride:!1,batchPoses:!1,viewerPose:!1,viewTransforms:!1,handInput:!1,jointPoses:!1,actionPlayback:!1,anchors:!1,hitTest:!1,notes:[]})}}prepareSessionRequest(e){var t,n;const i=Array.from(null!==(t=null==e?void 0:e.requiredFeatures)&&void 0!==t?t:[]),r=Array.from(null!==(n=null==e?void 0:e.optionalFeatures)&&void 0!==n?n:[]),a=i.filter(Vo),s=r.filter(Vo),o=Ho(this.device.supportedFeatures);if(s.length>0&&!o&&this.note("Optional gaze tracking was not enabled because the selected IWER device profile does not advertise gaze support.","unsupported-optional-gaze"),a.length>0&&!o)throw Oc(`Required gaze tracking is unavailable because the selected IWER device profile "${this.device.name}" does not advertise gaze support. Select a gaze-capable profile such as metaQuestPro.`);const l=o?Array.from(new Set([...a,...s])):[];if(!e)return{options:void 0,gaze:{required:a,optional:s,enabled:l}};const c={...e};return e.requiredFeatures&&(c.requiredFeatures=i.filter(e=>!Vo(e))),e.optionalFeatures&&(c.optionalFeatures=r.filter(e=>!Vo(e))),{options:c,gaze:{required:a,optional:s,enabled:l}}}failWhenGazeRequested(e){if(e.length>0)throw Oc("Native override was uninstalled before the session could attach.")}async attachSession(e,t,n=[]){var i,r,a,s,o,l;if(!this.installedState)return void this.failWhenGazeRequested(n);if(this.sessionsByObject.has(e))return;const c=this.captureNativeRequestReferenceSpace(e),u=this.captureNativeRequestAnimationFrame(e),d="gaze-only"===this.options.mode?this.captureNativeInputSources(e):{read:()=>[],live:!1};let h,p;for(const t of["local-floor","local","unbounded"])try{h=await c.call(e,t),p=t;break}catch(e){}if(!h||!p)throw new Error("No native local-floor, local, or unbounded reference space is available.");if("local-floor"!==p&&this.note(`Native local-floor is unavailable; poses are anchored to "${p}" and are offset by the viewer's initial height.`),!this.installedState)return void this.failWhenGazeRequested(n);const f=d.read(),m={session:e,mode:t,anchorSpace:h,handTracking:this.sessionEnablesHandTracking(e),enabledFeatures:Object.freeze(Array.from(new Set([...Array.from(null!==(i=e.enabledFeatures)&&void 0!==i?i:[]),...n]))),syntheticGazeFeatures:Object.freeze([...n]),nativeRequestAnimationFrame:u,nativeRequestReferenceSpace:c,nativeInputSources:d.read,nativeInputSourcesLive:d.live,nativeSources:Object.freeze([...f]),patches:new dc,instancePatches:new dc,cleanupListeners:[],sources:Object.freeze("gaze-only"===this.options.mode?Array.from(f):[]),deviceBindings:[],playbackBindings:new Map,bindingByFacade:new Map,spaceTokens:new Set([h]),hitTests:new Set,baseSpaceCache:new Map,lastFrameTime:void 0,lastPreparedFrame:null,nativeViewerPoseValid:"full"===this.options.mode,nativeViewerMatrix:Or(),framePreparationFailures:0,activeFrame:null,framesInstrumented:!1,pendingEvents:[],retainedSources:new Set,createAnchorAvailable:!0,hitTestResultsAvailable:!0,ended:!1};this.sessionsByObject.set(e,m),this.liveSessions.add(m),null!==(r=this.primarySession)&&void 0!==r||(this.primarySession=m),this.spaces.set(h,{adapter:m,localOffset:Or()});const g=this.capabilityState.handInput;try{"full"===this.options.mode&&this.ensureReferenceSpacePatch(h,m),this.createDeviceBindings(m);const e=this.patchEnabledFeatures(m),t=this.patchInputSources(m),i=this.patchRequestAnimationFrame(m);m.framesInstrumented=i;const r="full"===this.options.mode&&this.patchRequestReferenceSpace(m);if("full"===this.options.mode&&this.patchRequestHitTestSource(m),this.installSessionListeners(m),!t){if(n.length>0)throw Oc("Unable to expose the synthetic gaze input source.");this.unsupportedForSession(m,"Unable to override XRSession.inputSources.")}if(!i){if(n.length>0)throw Oc("Unable to update the synthetic gaze input on native frames.");this.unsupportedForSession(m,"Unable to wrap XRSession.requestAnimationFrame.")}if("full"!==this.options.mode||r||this.note("XRReferenceSpace tagging is unavailable; viewer-relative offset spaces will use native behavior."),!e&&n.length>0)throw Oc("Unable to expose the synthetic gaze feature through XRSession.enabledFeatures.");(a=this.capabilityState).inputSources||(a.inputSources=t),(s=this.capabilityState).inputEvents||(s.inputEvents=t&&i),(o=this.capabilityState).enabledFeatures||(o.enabledFeatures=e),(l=this.capabilityState).viewerSpaceTagging||(l.viewerSpaceTagging=r),"installed"===this.capabilityState.phase&&(this.capabilityState.phase="attached")}catch(e){throw this.capabilityState.handInput=g,this.detachAdapter(m),e}}sessionEnablesHandTracking(e){const t=e.enabledFeatures;return t?Array.prototype.includes.call(t,fc):this.device.supportedFeatures.includes(fc)}createDeviceBindings(e){if("full"===this.options.mode){for(const t of Object.values(this.device.controllers))e.deviceBindings.push(this.createInputBinding(e,"controller",t.inputSource,{trackedInput:t,exposeHand:!1}));if(e.handTracking)for(const t of Object.values(this.device.hands))e.deviceBindings.push(this.createInputBinding(e,"hand",t.inputSource,{trackedInput:t,exposeHand:!0}))}if(e.syntheticGazeFeatures.length>0){const t=this.device.gaze;if(!t)throw new Error("The selected device does not provide a synthetic gaze input.");e.deviceBindings.push(this.createInputBinding(e,"gaze",t.inputSource,{trackedInput:t,exposeHand:!1,available:"gaze-only"===this.options.mode?()=>e.nativeViewerPoseValid:void 0}))}}createInputBinding(e,t,n,i){const r=this.createSpaceToken(e);let a;this.spaces.set(r,{adapter:e,origin:()=>n.targetRaySpace,available:i.available,localOffset:Or()}),n.gripSpace&&(a=this.createSpaceToken(e),this.spaces.set(a,{adapter:e,origin:()=>{var e;return null!==(e=n.gripSpace)&&void 0!==e?e:null},available:i.available,localOffset:Or()}));const s=[];if(i.exposeHand&&n.hand)for(const t of Object.values(go)){const r=n.hand.get(t);if(!r)continue;const a={name:t,space:this.createJointSpaceFacade(t),source:r};this.spaces.set(a.space,{adapter:e,origin:()=>a.source,available:i.available,localOffset:Or(),joint:a}),s.push(a)}const o={kind:t,iwerSource:n,trackedInput:i.trackedInput,inputSource:void 0,targetRaySpace:r,gripSpace:a,joints:s,eventButtons:this.eventButtons(n),previousButtonValues:new Map,activeButtons:new Set,activeActions:new Set,pendingActions:new Set};return o.inputSource=this.createInputSourceFacade(o,e),this.resetButtonBaseline(o),e.bindingByFacade.set(o.inputSource,o),s.length>0&&(this.capabilityState.handInput=!0),o}playbackBinding(e,t){const n=e.playbackBindings.get(t);if(n)return n;const i=Boolean(t.hand)&&e.handTracking;t.hand&&!e.handTracking&&this.note(`Recorded hand joints are hidden because the native session does not enable the "${fc}" feature.`);const r=this.createInputBinding(e,"playback",t,{exposeHand:i});return e.playbackBindings.set(t,r),r}createSpaceToken(e){const t=new(this.getRigidTransformConstructor()),n=e.anchorSpace.getOffsetReferenceSpace(t);if(e.spaceTokens.has(n))throw new Error("Native getOffsetReferenceSpace(identity) reused a space object; stable synthetic input tokens require distinct objects.");return e.spaceTokens.add(n),n}createInputSourceFacade(e,t){var n;const i=this.constructorPrototype("XRInputSource"),r=Object.create(null!=i?i:Object.prototype),a=e.iwerSource,s=e.joints.length>0||!a.gamepad?null:this.createGamepadFacade(e,t);return Object.defineProperties(r,{handedness:{configurable:!0,enumerable:!0,value:a.handedness},targetRayMode:{configurable:!0,enumerable:!0,value:a.targetRayMode},profiles:{configurable:!0,enumerable:!0,value:Object.freeze([...a.profiles])},targetRaySpace:{configurable:!0,enumerable:!0,value:e.targetRaySpace},gripSpace:{configurable:!0,enumerable:!0,value:null!==(n=e.gripSpace)&&void 0!==n?n:null},gamepad:{configurable:!0,enumerable:!0,value:s},hand:{configurable:!0,enumerable:!0,value:e.joints.length>0?this.createHandFacade(e.joints):null}}),r}createHandFacade(e){const t=this.constructorPrototype("XRHand"),n=Object.create(null!=t?t:Object.prototype),i=new Map(e.map(e=>[e.name,e.space])),r=(e,t)=>{Object.defineProperty(n,e,{configurable:!0,writable:!0,value:t})};return Object.defineProperty(n,"size",{configurable:!0,enumerable:!0,get:()=>i.size}),r("get",e=>i.get(e)),r("has",e=>i.has(e)),r("keys",()=>i.keys()),r("values",()=>i.values()),r("entries",()=>i.entries()),r("forEach",function(e,t){i.forEach((i,r)=>{e.call(t,i,r,n)})}),r(Symbol.iterator,()=>i.entries()),n}createJointSpaceFacade(e){var t;const n=null!==(t=this.constructorPrototype("XRJointSpace"))&&void 0!==t?t:this.constructorPrototype("XRSpace"),i=Object.create(null!=n?n:Object.prototype);return Object.defineProperty(i,"jointName",{configurable:!0,enumerable:!0,value:e}),i}createGamepadFacade(e,t){const n=this.constructorPrototype("Gamepad"),i=Object.create(null!=n?n:Object.prototype),r=e.iwerSource.gamepad;let a=Object.freeze(r.axes.map(e=>null!=e?e:0));const s=Object.freeze(r.buttons.map(e=>Object.freeze({get pressed(){var t;return null!==(t=null==e?void 0:e.pressed)&&void 0!==t&&t},get touched(){var t;return null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t},get value(){var t;return null!==(t=null==e?void 0:e.value)&&void 0!==t?t:0}}))),o=Object.freeze([...r.hapticActuators]);return Object.defineProperties(i,{id:{configurable:!0,enumerable:!0,value:""},index:{configurable:!0,enumerable:!0,value:-1},connected:{configurable:!0,enumerable:!0,get:()=>{var n,i;return(null===(i=null===(n=e.trackedInput)||void 0===n?void 0:n.connected)||void 0===i||i)&&!t.ended}},timestamp:{configurable:!0,enumerable:!0,get:()=>{var e;return null!==(e=t.lastFrameTime)&&void 0!==e?e:0}},mapping:{configurable:!0,enumerable:!0,get:()=>r.mapping},axes:{configurable:!0,enumerable:!0,get:()=>{const e=r.axes.map(e=>null!=e?e:0);return(e.length!==a.length||e.some((e,t)=>e!==a[t]))&&(a=Object.freeze(e)),a}},buttons:{configurable:!0,enumerable:!0,get:()=>s},hapticActuators:{configurable:!0,enumerable:!0,get:()=>o},vibrationActuator:{configurable:!0,enumerable:!0,get:()=>r.vibrationActuator}}),i}eventButtons(e){const t=e.gamepad;return t?Object.values(t[Ea].buttonsMap).filter(e=>null!==e):[]}resetButtonBaseline(e){for(const t of e.eventButtons)e.previousButtonValues.set(t,t.value)}clearActionState(e){e.activeButtons.clear(),e.activeActions.clear(),e.pendingActions.clear()}captureNativeRequestAnimationFrame(e){const t=Ac(e,"requestAnimationFrame");if(!t||"function"!=typeof t.descriptor.value)throw new Error("Native XRSession.requestAnimationFrame is unavailable.");const n=this.rawRafByOwner.get(t.owner);if(n)return n;const i=t.descriptor.value;return this.rawRafByOwner.set(t.owner,i),i}captureNativeRequestReferenceSpace(e){const t=Ac(e,"requestReferenceSpace");if(!t||"function"!=typeof t.descriptor.value)throw new Error("Native XRSession.requestReferenceSpace is unavailable.");const n=this.rawRequestReferenceSpaceByOwner.get(t.owner);if(n)return n;const i=t.descriptor.value;return this.rawRequestReferenceSpaceByOwner.set(t.owner,i),i}captureNativeInputSources(e){const t=Ac(e,"inputSources");if(!t)throw new Error("Native XRSession.inputSources is unavailable.");let n=this.rawInputSourcesGetterByOwner.get(t.owner);if(!n&&t.descriptor.get&&(n=t.descriptor.get,this.rawInputSourcesGetterByOwner.set(t.owner,n)),n)return{read:()=>{var t;return Array.from(null!==(t=n.call(e))&&void 0!==t?t:[])},live:!0};if("value"in t.descriptor){const n=t.descriptor.value;return{read:()=>{const t=Object.getOwnPropertyDescriptor(e,"inputSources"),i=t&&"value"in t?t.value:n;return Array.from(null!=i?i:[])},live:!1}}throw new Error("Native XRSession.inputSources cannot be read.")}patchEnabledFeatures(e){var t,n;if(0===e.syntheticGazeFeatures.length)return!1;if(e.patches.define(e.session,"enabledFeatures",{configurable:!0,enumerable:!0,value:e.enabledFeatures})){const n=Array.from(null!==(t=e.session.enabledFeatures)&&void 0!==t?t:[]);return e.syntheticGazeFeatures.every(e=>n.includes(e))}const i=Ac(e.session,"enabledFeatures"),r=null==i?void 0:i.descriptor.get;if(!i||!r)return!1;if(!this.patchedEnabledFeaturesOwners.has(i.owner)){const e=this,t=this.patches.define(i.owner,"enabledFeatures",{...i.descriptor,get(){var t,n;return null!==(n=null===(t=e.sessionsByObject.get(this))||void 0===t?void 0:t.enabledFeatures)&&void 0!==n?n:r.call(this)}});if(!t)return!1;this.patchedEnabledFeaturesOwners.add(i.owner)}const a=Array.from(null!==(n=e.session.enabledFeatures)&&void 0!==n?n:[]);return e.syntheticGazeFeatures.every(e=>a.includes(e))}patchInputSources(e){if(e.patches.define(e.session,"inputSources",{configurable:!0,enumerable:!0,get:()=>e.sources}))return e.session.inputSources===e.sources;const t=Ac(e.session,"inputSources"),n=null==t?void 0:t.descriptor.get;if(!t||!n)return!1;if(!this.patchedInputSourceOwners.has(t.owner)){const e=this,i=this.patches.define(t.owner,"inputSources",{...t.descriptor,get(){var t,i;return null!==(i=null===(t=e.sessionsByObject.get(this))||void 0===t?void 0:t.sources)&&void 0!==i?i:n.call(this)}});if(!i)return!1;this.patchedInputSourceOwners.add(t.owner)}return e.session.inputSources===e.sources}patchRequestAnimationFrame(e){const t=this;if(e.patches.define(e.session,"requestAnimationFrame",{configurable:!0,writable:!0,value:function(n){return e.nativeRequestAnimationFrame.call(this,(i,r)=>{t.prepareFrameCallback(e,i,r);try{n(i,r)}finally{t.releaseFrameCallback(e,r)}})}}))return!0;const n=Ac(e.session,"requestAnimationFrame"),i=null==n?void 0:n.descriptor.value;if(!n||"function"!=typeof i)return!1;if(!this.patchedRafOwners.has(n.owner)){if(!this.patches.define(n.owner,"requestAnimationFrame",{...n.descriptor,value(e){const n=t.sessionsByObject.get(this);return n?n.nativeRequestAnimationFrame.call(this,(i,r)=>{t.prepareFrameCallback(n,i,r);try{e(i,r)}finally{t.releaseFrameCallback(n,r)}}):i.call(this,e)}}))return!1;this.patchedRafOwners.add(n.owner)}return!0}patchRequestReferenceSpace(e){const t=this;if(e.patches.define(e.session,"requestReferenceSpace",{configurable:!0,writable:!0,value:function(n){return e.nativeRequestReferenceSpace.call(this,n).then(i=>(t.tagRequestedReferenceSpace(e,i,n),t.ensureReferenceSpacePatch(i,e),i))}}))return!0;const n=Ac(e.session,"requestReferenceSpace"),i=null==n?void 0:n.descriptor.value;if(!n||"function"!=typeof i)return!1;if(!this.patchedRequestReferenceSpaceOwners.has(n.owner)){const e=this.patches.define(n.owner,"requestReferenceSpace",{...n.descriptor,value(e){const n=t.sessionsByObject.get(this);return n?n.nativeRequestReferenceSpace.call(this,e).then(i=>(t.tagRequestedReferenceSpace(n,i,e),t.ensureReferenceSpacePatch(i,n),i)):i.call(this,e)}});if(!e)return!1;this.patchedRequestReferenceSpaceOwners.add(n.owner)}return!0}patchRequestHitTestSource(e){const t=e.session.requestHitTestSource;if("function"!=typeof t)return;const n=this;if(e.patches.define(e.session,"requestHitTestSource",{configurable:!0,writable:!0,value:function(e){return n.handleRequestHitTestSource(this,t,e)}}))return;const i=Ac(e.session,"requestHitTestSource");if(!i||"function"!=typeof i.descriptor.value||this.patchedHitTestOwners.has(i.owner))return;const r=i.descriptor.value;this.patches.define(i.owner,"requestHitTestSource",{...i.descriptor,value(e){return n.handleRequestHitTestSource(this,r,e)}})&&this.patchedHitTestOwners.add(i.owner)}tagRequestedReferenceSpace(e,t,n){this.spaces.has(t)||"viewer"===n&&this.spaces.set(t,{adapter:e,origin:()=>this.currentViewerSpace(),localOffset:Or()})}ensureReferenceSpacePatch(e,t){if(this.instancePatchedReferenceSpaces.has(e))return;const n=Ac(e,"getOffsetReferenceSpace"),i=null==n?void 0:n.descriptor.value;if(!n||"function"!=typeof i)return;const r=this,a=function(e){const t=r.spaces.get(this);if(!t||t.adapter.ended)return i.call(this,e);const n=i.call(this,e);return r.propagateSpaceMetadata(this,n,e),r.ensureReferenceSpacePatch(n,t.adapter),n};if(n.owner===e||this.patchedReferenceSpaceOwners.has(n.owner)){if(n.owner!==e)return}else{if(this.patches.define(n.owner,"getOffsetReferenceSpace",{...n.descriptor,value:a}))return void this.patchedReferenceSpaceOwners.add(n.owner)}t.patches.define(e,"getOffsetReferenceSpace",{configurable:!0,writable:!0,value:a})&&this.instancePatchedReferenceSpaces.add(e)}propagateSpaceMetadata(e,t,n){const i=this.spaces.get(e);if(!i)return;const r=Or();Hr(r,i.localOffset,Rc(n)),this.spaces.set(t,{adapter:i.adapter,origin:i.origin,available:i.available,localOffset:r})}installSessionListeners(e){const{session:t}=e;if("full"===this.options.mode){const n=e=>{this.syntheticEvents.has(e)||e.stopImmediatePropagation()};for(const i of["inputsourceschange",...pc])t.addEventListener(i,n,!0),e.cleanupListeners.push(()=>t.removeEventListener(i,n,!0))}else{const n=t=>{if(!this.syntheticEvents.has(t)){try{if(!e.nativeInputSourcesLive){const n=t;if(null==n.added||null==n.removed)e.nativeSources=Object.freeze([...e.nativeInputSources()]);else{const t=new Set(Array.from(n.removed)),i=e.nativeSources.filter(e=>!t.has(e));for(const e of Array.from(n.added))i.includes(e)||i.push(e);e.nativeSources=Object.freeze(i)}}}catch(t){try{e.nativeSources=Object.freeze([...e.nativeInputSources()])}catch(e){this.note(`A native input-source change could not be reconciled; preserving the last known set: ${this.errorText(null!=e?e:t)}`,"gaze-only-native-input-change-failed")}}this.refreshInputSources(e,!0)}};t.addEventListener("inputsourceschange",n,!0),e.cleanupListeners.push(()=>t.removeEventListener("inputsourceschange",n,!0))}const n=()=>{var n;const i=this.sharedStateDriver();this.device[ba].visibilityState=null!==(n=null==i?void 0:i.session.visibilityState)&&void 0!==n?n:t.visibilityState,this.device[ba].pendingVisibilityState=null,void 0!==e.lastFrameTime&&this.refreshInputSources(e,!0)};t.addEventListener("visibilitychange",n),e.cleanupListeners.push(()=>t.removeEventListener("visibilitychange",n));const i=()=>this.detachAdapter(e);t.addEventListener("end",i,{once:!0}),e.cleanupListeners.push(()=>t.removeEventListener("end",i))}tick(e,t,n){e.ended||e.lastFrameTime===t&&e.lastPreparedFrame===n||(e.lastFrameTime=t,e.lastPreparedFrame=n,e.baseSpaceCache.clear(),"gaze-only"===this.options.mode&&this.syncDeviceViewerFromNative(e,n),e===this.sharedStateDriver()&&this.advanceSharedState(e,t),this.refreshInputSources(e,!0),this.drainPendingEvents(e,n),this.refreshInputSources(e,!0),this.dispatchButtonTransitions(e,n),this.updateHitTestSources(e))}syncDeviceViewerFromNative(e,t){e.nativeViewerPoseValid=!1;const n=Ac(t,"getViewerPose"),i=null==n?void 0:n.descriptor.value;if(!n||"function"!=typeof i)return void this.note("The native XRFrame.getViewerPose implementation is unavailable; synthetic gaze is untracked for this frame.","gaze-only-viewer-pose-unavailable");let r;try{r=i.call(t,e.anchorSpace)}catch(e){return}if(!r)return;const a=this.readNativeTransform(r);if(!a)return;const s=Rc(a);zr(e.nativeViewerMatrix,s),this.applyDeviceViewerMatrix(s),e.nativeViewerPoseValid=!0}applyDeviceViewerMatrix(e){Xr(Ec,e),$r(Mc,e),this.device.position.set(Ec[0],Ec[1],Ec[2]),this.device.quaternion.set(Mc[0],Mc[1],Mc[2],Mc[3]),this.device[ba].updateViews()}sharedStateDriver(){var e,t;return"visible"===(null===(e=this.primarySession)||void 0===e?void 0:e.session.visibilityState)?this.primarySession:null!==(t=Array.from(this.liveSessions).find(e=>"visible"===e.session.visibilityState))&&void 0!==t?t:this.primarySession}advanceSharedState(e,t){var n;const i=this.lastPrimaryTime;this.lastPrimaryTime=t;const r=void 0===i?16.67:Math.max(0,t-i);if("gaze-only"===this.options.mode)return this.device[ba].remote.update(r),e.nativeViewerPoseValid&&this.applyDeviceViewerMatrix(e.nativeViewerMatrix),this.device[ba].visibilityState=e.session.visibilityState,this.device[ba].pendingVisibilityState=null,void(null===(n=this.device.gaze)||void 0===n||n.updateTargetRaySpace());this.device[ba].remote.update(r),this.device[ba].visibilityState=e.session.visibilityState,this.device[ba].pendingVisibilityState=null;const a=this.device[ba].actionPlayer;a&&(a.playing||a[va].manualFrameActive)?(this.wirePlayer(a),this.playbackFrame=a,this.capabilityState.actionPlayback=!0,a.playing&&a[va].autoAdvance&&a.playFrame()):(this.playbackFrame=null,this.wiredPlayer&&this.wiredPlayer!==a&&this.unwirePlayer(),this.updateDeviceInputs()),this.device[ba].updateViews()}updateDeviceInputs(){var e,t,n,i,r;for(const a of this.device.activeInputs){a.updateTargetRaySpace();for(const i of null!==(t=null===(e=a.inputSource.gamepad)||void 0===e?void 0:e.buttons)&&void 0!==t?t:[])i instanceof gs&&(i[Ea].lastFrameValue=null!==(n=i[Ea].immediateTransitionFrom)&&void 0!==n?n:i[Ea].value,i[Ea].immediateTransitionFrom=null,null!=i[Ea].pendingValue&&(i[Ea].value=i[Ea].pendingValue,i[Ea].pendingValue=null));null===(r=(i=a).updateHandPose)||void 0===r||r.call(i)}}prepareFrameCallback(e,t,n){if(!this.installedState||e.ended)return;const i=e.lastFrameTime!==t||e.lastPreparedFrame!==n;"gaze-only"===this.options.mode&&i&&(e.nativeViewerPoseValid=!1);try{i&&(e.instancePatches.revert(),this.epoch+=1),this.frameSessions.set(n,e),e.activeFrame=n,this.ensureFramePatches(n),this.tick(e,t,n),this.unhealthyFrameAdapters.delete(e)&&0===this.unhealthyFrameAdapters.size&&(this.capabilityState.supported=!0),e.framePreparationFailures=0}catch(t){"gaze-only"===this.options.mode&&(e.nativeViewerPoseValid=!1),e.framePreparationFailures+=1;const n=e.framePreparationFailures;n>=3&&(this.unhealthyFrameAdapters.add(e),this.capabilityState.supported=!1);try{1!==n&&3!==n&&60!==n||this.note(`Native frame preparation failed ${n} consecutive time${1===n?"":"s"}; the application frame was preserved${n>=3?" and the override was marked unsupported":""}: ${this.errorText(t)}`,`frame-preparation-failed-${n}`)}catch(e){}}}releaseFrameCallback(e,t){e.activeFrame===t&&(e.activeFrame=null)}activePlayer(){if(this.playbackFrame)return this.playbackFrame;const e=this.device[ba].actionPlayer;return e&&(e.playing||e[va].manualFrameActive)?e:null}currentViewerSpace(){if("gaze-only"===this.options.mode)return this.device[ba].viewerSpace;const e=this.activePlayer();return e?e.viewerSpace:this.device[ba].viewerSpace}refreshInputSources(e,t){const n="visible"===e.session.visibilityState,i="gaze-only"===this.options.mode||n?this.expectedSources(e):[];if(n)for(const t of e.retainedSources)i.includes(t)||i.push(t);else{e.pendingEvents.length=0,e.retainedSources.clear();for(const t of e.bindingByFacade.values())t.pendingActions.clear()}const r=e.sources.filter(e=>!i.includes(e)),a=i.filter(t=>!e.sources.includes(t));if(0!==a.length||0!==r.length){for(const t of r){const i=e.bindingByFacade.get(t);if(i){if(n)for(const n of Array.from(i.activeActions))this.emitInputEvent(e,`${n}end`,t,!1);this.clearActionState(i),this.resetButtonBaseline(i)}}for(const t of a){const n=e.bindingByFacade.get(t);n&&(n.activeButtons.clear(),this.resetButtonBaseline(n))}if(n&&r.some(t=>{var n;return"gaze"===(null===(n=e.bindingByFacade.get(t))||void 0===n?void 0:n.kind)})&&this.releaseGazeCommitActions(e,i),e.sources=Object.freeze([...i]),t){const t="gaze-only"===this.options.mode?a.filter(t=>e.bindingByFacade.has(t)):a,n="gaze-only"===this.options.mode?r.filter(t=>e.bindingByFacade.has(t)):r;(t.length>0||n.length>0)&&this.dispatchInputSourcesChange(e,t,n)}}}expectedSources(e){if("gaze-only"===this.options.mode){const t=this.readNativeInputSources(e),n="visible"===e.session.visibilityState?this.connectedSources(e,"gaze"):[];return[...t,...n.filter(e=>!t.includes(e))]}const t=this.activePlayer();if(t)try{return t.inputSources.map(t=>this.playbackBinding(e,t).inputSource)}catch(e){return this.note(`Recorded input sources could not be published: ${this.errorText(e)}`,"recorded-input-publication-failed"),[]}const n=this.device.primaryInputMode,i=this.connectedSources(e,"gaze");return"hand"!==n||e.handTracking?[...this.connectedSources(e,n),...i]:(this.note(`Native hand input requires the "${fc}" feature on the browser session; no synthetic hand input sources are published while hand mode is selected.`),i)}readNativeInputSources(e){if(!e.nativeInputSourcesLive)return Array.from(e.nativeSources);try{const t=Array.from(e.nativeInputSources());return e.nativeSources=Object.freeze([...t]),t}catch(t){return this.note(`Native input sources could not be read; preserving the last known set: ${this.errorText(t)}`,"gaze-only-native-input-sources-unavailable"),e.sources.filter(t=>!e.bindingByFacade.has(t))}}releaseGazeCommitActions(e,t){const n=e===this.sharedStateDriver();for(const i of e.deviceBindings){if("gaze"===i.kind||!t.includes(i.inputSource))continue;const r=i.eventButtons.filter(e=>"select"===e[Ea].eventTrigger);if(0!==r.length){i.activeActions.has("select")&&(this.emitInputEvent(e,"selectend",i.inputSource,!1),i.activeActions.delete("select")),i.pendingActions.delete("select");for(const e of r)i.activeButtons.delete(e),n&&this.releaseButton(e),i.previousButtonValues.set(e,e.value)}}}releaseButton(e){e[Ea].value=0,e[Ea].pendingValue=0,e[Ea].lastFrameValue=0,e[Ea].immediateTransitionFrom=null}connectedSources(e,t){return e.deviceBindings.filter(e=>e.kind===t&&e.trackedInput.connected).map(e=>e.inputSource)}dispatchButtonTransitions(e,t){var n;const i=new Set(e.sources);for(const r of e.deviceBindings)if(i.has(r.inputSource))for(const i of r.eventButtons){const a=null!==(n=r.previousButtonValues.get(i))&&void 0!==n?n:0,s=i.value;r.previousButtonValues.set(i,s);const o=i[Ea].eventTrigger;o&&(0===a&&s>0?(r.activeButtons.add(i),this.dispatchInputEvent(e,`${o}start`,t,r.inputSource)):a>0&&0===s&&r.activeButtons.delete(i)&&(this.dispatchInputEvent(e,o,t,r.inputSource),this.dispatchInputEvent(e,`${o}end`,t,r.inputSource)))}}wirePlayer(e){if(this.wiredPlayer===e)return;this.unwirePlayer(),this.previousPlayerContext=e[va].eventContext;const t=this,n={dispatchEvent:e=>(t.forwardPlaybackEvent(e),!0)};e.setEventContext({session:n,getFrame:()=>{var e,t;return null!==(t=null===(e=this.primarySession)||void 0===e?void 0:e.activeFrame)&&void 0!==t?t:this.detachedPlaybackFrame},onDiscontinuity:()=>{t.terminatePlaybackActions()}}),this.wiredPlayer=e}unwirePlayer(){const e=this.wiredPlayer;if(!e)return;this.wiredPlayer=null;const t=this.previousPlayerContext;this.previousPlayerContext=void 0;try{e.setEventContext(t)}catch(e){}}forwardPlaybackEvent(e){const t=e.inputSource;if(!t)return;const n=e.type,i=n.startsWith("select")?"select":n.startsWith("squeeze")?"squeeze":null;if(!i)return;const r=n.slice(i.length);if((""===r||"start"===r||"end"===r)&&""!==r)for(const e of this.liveSessions){let n;try{n=this.playbackBinding(e,t)}catch(e){this.note(`A recorded input event could not be bound to a native input source: ${this.errorText(e)}`,"recorded-input-binding-failed");continue}if("start"===r)this.terminatePlaybackAction(e,n,i),n.pendingActions.add(i),this.emitInputEvent(e,`${i}start`,n.inputSource,!0);else{if(!n.pendingActions.delete(i))continue;this.emitInputEvent(e,i,n.inputSource,!0),this.emitInputEvent(e,`${i}end`,n.inputSource,!0)}}}terminatePlaybackActions(){for(const e of this.liveSessions)for(const t of e.playbackBindings.values())for(const n of new Set([...t.pendingActions,...t.activeActions]))this.terminatePlaybackAction(e,t,n)}terminatePlaybackAction(e,t,n){if(!t.pendingActions.delete(n)&&!t.activeActions.has(n))return;const i=`${n}end`;e.pendingEvents.some(e=>e.inputSource===t.inputSource&&e.type===i)||this.emitInputEvent(e,i,t.inputSource,!0)}emitInputEvent(e,t,n,i){const r=e.activeFrame;r&&e.sources.includes(n)?this.dispatchInputEvent(e,t,r,n):(e.pendingEvents.length>=256&&this.compactPendingEvents(e),e.pendingEvents.push({type:t,inputSource:n}),i&&e.retainedSources.add(n))}compactPendingEvents(e){const t=new Map;let n;for(let i=0;i<e.pendingEvents.length;i++){const r=e.pendingEvents[i];if(r.type.endsWith("start")){const e=r.type.slice(0,-5);let n=t.get(r.inputSource);n||(n=new Map,t.set(r.inputSource,n)),n.has(e)||n.set(e,i);continue}if(!r.type.endsWith("end"))continue;const a=r.type.slice(0,-3),s=t.get(r.inputSource),o=null==s?void 0:s.get(a);void 0!==o&&(s.delete(a),(!n||o<n.startIndex)&&(n={startIndex:o,endIndex:i,inputSource:r.inputSource,trigger:a}))}if(!n)return;const{startIndex:i,endIndex:r,inputSource:a,trigger:s}=n,o=`${s}start`,l=`${s}end`;e.pendingEvents=e.pendingEvents.filter((e,t)=>t<i||t>r||e.inputSource!==a||e.type!==s&&e.type!==o&&e.type!==l),this.note("A native session fell too far behind; an oldest complete queued input action was discarded.")}drainPendingEvents(e,t){if(0===e.pendingEvents.length)return void e.retainedSources.clear();const n=e.pendingEvents.splice(0);e.retainedSources.clear();for(const i of n)this.dispatchInputEvent(e,i.type,t,i.inputSource)}dispatchInputEvent(e,t,n,i){this.recordDeliveredAction(e,t,i);const r=this.createEvent(t,"XRInputSourceEvent",{frame:n,inputSource:i});this.syntheticEvents.add(r),e.session.dispatchEvent(r)}recordDeliveredAction(e,t,n){const i=e.bindingByFacade.get(n);i&&(t.endsWith("start")?i.activeActions.add(t.slice(0,-5)):t.endsWith("end")&&i.activeActions.delete(t.slice(0,-3)))}dispatchInputSourcesChange(e,t,n){const i=this.createEvent("inputsourceschange","XRInputSourcesChangeEvent",{session:e.session,added:Object.freeze([...t]),removed:Object.freeze([...n])});this.syntheticEvents.add(i),e.session.dispatchEvent(i)}createEvent(e,t,n){const i=function(e){const t=e.Event;return"function"==typeof t?t:void 0}(this.globalObject);if(!i)throw new Error("Event constructor is unavailable.");const r=new i(e),a=this.constructorPrototype(t);if(a)try{Object.setPrototypeOf(r,a),"XRInputSourceEvent"===t&&(this.capabilityState.brandedInputEvents=!0)}catch(e){}for(const[e,t]of Object.entries(n))Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:t});return r}ensureFramePatches(e){var t,n,i;if(this.instancePatchedFrameEpochs.get(e)===this.epoch)return;const r=this.adapterForFrame(e),a=this.patchFrameGetPose(e),s=this.patchFrameFillPoses(e),o="full"===this.options.mode,l=!!o&&this.patchFrameGetViewerPose(e),c=!!o&&this.patchFrameGetJointPose(e),u=!!o&&this.patchFrameFillJointRadii(e);r&&o&&(this.recordAnchorAvailability(r,this.patchFrameCreateAnchor(e)),this.recordHitTestAvailability(r,this.patchFrameGetHitTestResults(e))),(t=this.capabilityState).poseOverride||(t.poseOverride=a),(n=this.capabilityState).batchPoses||(n.batchPoses=s),(i=this.capabilityState).jointPoses||(i.jointPoses=o&&c&&u),a||this.note("Unable to patch native XRFrame.getPose."),s||this.note("Unable to patch native XRFrame.fillPoses."),o&&!l&&this.note("Unable to patch native XRFrame.getViewerPose."),this.instancePatchedFrameEpochs.set(e,this.epoch)}patchFrameGetPose(e){const t=Ac(e,"getPose");if(t&&t.owner!==e&&this.patchedFrameOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){this.rawGetPoseByOwner.set(t.owner,n);const e=this.patches.define(t.owner,"getPose",{...t.descriptor,value(e,t){return i.handleGetPose(this,n,e,t)}});if(e)return this.patchedFrameOwners.add(t.owner),!0}return this.rawGetPoseByFrame.set(e,n),this.defineFrameMethod(e,"getPose",function(e,t){return i.handleGetPose(this,n,e,t)})}patchFrameGetViewerPose(e){const t=Ac(e,"getViewerPose");if(t&&t.owner!==e&&this.patchedViewerFrameOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){if(this.patches.define(t.owner,"getViewerPose",{...t.descriptor,value(e){return i.handleGetViewerPose(this,n,e)}}))return this.patchedViewerFrameOwners.add(t.owner),!0}return this.defineFrameMethod(e,"getViewerPose",function(e){return i.handleGetViewerPose(this,n,e)})}patchFrameFillPoses(e){const t=Ac(e,"fillPoses");if(t&&t.owner!==e&&this.patchedFillPosesOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){if(this.patches.define(t.owner,"fillPoses",{...t.descriptor,value(e,t,r){return i.handleFillPoses(this,n,e,t,r)}}))return this.patchedFillPosesOwners.add(t.owner),!0}return this.defineFrameMethod(e,"fillPoses",function(e,t,r){return i.handleFillPoses(this,n,e,t,r)})}patchFrameGetJointPose(e){const t=Ac(e,"getJointPose");if(t&&t.owner!==e&&this.patchedJointPoseOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){if(this.patches.define(t.owner,"getJointPose",{...t.descriptor,value(e,t){return i.handleGetJointPose(this,n,e,t)}}))return this.patchedJointPoseOwners.add(t.owner),!0}return this.defineFrameMethod(e,"getJointPose",function(e,t){return i.handleGetJointPose(this,n,e,t)})}patchFrameFillJointRadii(e){const t=Ac(e,"fillJointRadii");if(t&&t.owner!==e&&this.patchedJointRadiiOwners.has(t.owner))return!0;const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return!1;const i=this;if(t.owner!==e){if(this.patches.define(t.owner,"fillJointRadii",{...t.descriptor,value(e,t){return i.handleFillJointRadii(this,n,e,t)}}))return this.patchedJointRadiiOwners.add(t.owner),!0}return this.defineFrameMethod(e,"fillJointRadii",function(e,t){return i.handleFillJointRadii(this,n,e,t)})}patchFrameCreateAnchor(e){const t=Ac(e,"createAnchor");if(t&&t.owner!==e&&this.patchedCreateAnchorOwners.has(t.owner))return"patched";const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return"unavailable";const i=this,r=function(e,t){return i.handleCreateAnchor(this,n,e,t)};if(t.owner!==e){if(this.patches.define(t.owner,"createAnchor",{...t.descriptor,value:r}))return this.patchedCreateAnchorOwners.add(t.owner),"patched"}return this.defineFrameMethod(e,"createAnchor",r)?"patched":"failed"}patchFrameGetHitTestResults(e){const t=Ac(e,"getHitTestResults");if(t&&t.owner!==e&&this.patchedHitTestResultOwners.has(t.owner))return"patched";const n=null==t?void 0:t.descriptor.value;if(!t||"function"!=typeof n)return"unavailable";const i=this,r=function(e){return i.handleGetHitTestResults(this,n,e)};if(t.owner!==e){if(this.patches.define(t.owner,"getHitTestResults",{...t.descriptor,value:r}))return this.patchedHitTestResultOwners.add(t.owner),"patched"}return this.defineFrameMethod(e,"getHitTestResults",r)?"patched":"failed"}recordAnchorAvailability(e,t){"unavailable"!==t&&(e.createAnchorAvailable="patched"===t,"failed"===t&&this.note("Unable to override XRFrame.createAnchor on a native frame; anchors in IWER-controlled spaces are unavailable until a frame can be instrumented."))}recordHitTestAvailability(e,t){"unavailable"!==t&&(e.hitTestResultsAvailable="patched"===t,"failed"===t&&this.note("Unable to override XRFrame.getHitTestResults on a native frame; hit test sources in IWER-controlled spaces are unavailable until a frame can be instrumented."))}defineFrameMethod(e,t,n){const i=this.adapterForFrame(e);return!!i&&i.instancePatches.define(e,t,{configurable:!0,writable:!0,value:n})}handleGetPose(e,t,n,i){if(!this.installedState)return t.call(e,n,i);const r=this.spaces.get(n),a=this.spaces.get(i);if(!Boolean(r||a))return t.call(e,n,i);const s=this.adapterForFrame(e);if(!s)throw Fc("The IWER-controlled space was queried from a frame owned by another native session.");if(this.assertFrameActive(s,e,"getPose"),r&&r.adapter!==s||a&&a.adapter!==s)throw Fc("The IWER-controlled space belongs to a different native session.");if((null==r?void 0:r.available)&&!r.available()||(null==a?void 0:a.available)&&!a.available())return null;const o=this.effectivePoseMatrix(s,e,t,n,i);return o?(this.capabilityState.phase="active",this.createPoseFacade(o)):(this.note("A synthetic pose could not be resolved in the requested base space."),null)}handleGetJointPose(e,t,n,i){if(!this.installedState)return t.call(e,n,i);const r=this.spaces.get(n),a=this.spaces.get(i);if(!r&&!a)return t.call(e,n,i);if(r&&!r.joint)throw new TypeError("Failed to execute 'getJointPose' on 'XRFrame': parameter 1 is not of type 'XRJointSpace'.");const s=this.adapterForFrame(e);if(!s)throw Fc("The IWER-controlled joint space was queried from a frame owned by another native session.");if(this.assertFrameActive(s,e,"getJointPose"),r&&r.adapter!==s||a&&a.adapter!==s)throw Fc("The IWER-controlled joint space belongs to a different native session.");const o=this.nativeGetPose(e);if(!o)return this.note("The native XRFrame.getPose implementation is unavailable."),null;let l;if(null==r?void 0:r.joint){if(l=r.joint.source[Fa].radius,!kc(l))return null}else{const i=t.call(e,n,s.anchorSpace);if(!i)return i;l=i.radius}const c=this.effectivePoseMatrix(s,e,o,n,i,!0);return c?this.createJointPoseFacade(c,l):(this.note("A synthetic joint pose could not be resolved in the requested base space."),null)}handleFillJointRadii(e,t,n,i){const r=Array.from(n);if(!this.installedState)return t.call(e,r,i);if(!r.some(e=>this.spaces.has(e)))return t.call(e,r,i);for(const e of r){const t=this.spaces.get(e);if(t&&!t.joint)throw new TypeError("Failed to execute 'fillJointRadii' on 'XRFrame': an element of jointSpaces is not of type 'XRJointSpace'.")}const a=this.adapterForFrame(e);if(!a)throw Fc("IWER-controlled joint radii were queried from a frame owned by another native session.");this.assertFrameActive(a,e,"fillJointRadii");for(const e of r){const t=this.spaces.get(e);if(t&&t.adapter!==a)throw Fc("An IWER-controlled joint space belongs to a different native session.")}if(r.length>i.length)throw new TypeError("The length of jointSpaces is larger than the number of elements in radii.");let s=!0;for(let n=0;n<r.length;n++){const o=this.spaces.get(r[n]);if((null==o?void 0:o.joint)&&o.adapter===a){const e=o.joint.source[Fa].radius;kc(e)?i[n]=e:(i[n]=NaN,s=!1)}else{const a=t.call(e,[r[n]],Tc);i[n]=a?Tc[0]:NaN,s&&(s=a)}}return s}handleFillPoses(e,t,n,i,r){const a=Array.from(n);if(!this.installedState)return t.call(e,a,i,r);const s=this.spaces.get(i),o=Boolean(s)||a.some(e=>this.spaces.has(e));if(!o)return t.call(e,a,i,r);const l=this.adapterForFrame(e);if(!l)throw Fc("IWER-controlled poses were queried from a frame owned by another native session.");if(this.assertFrameActive(l,e,"fillPoses"),s&&s.adapter!==l||a.some(e=>{const t=this.spaces.get(e);return null!=t&&t.adapter!==l}))throw Fc("An IWER-controlled space belongs to a different native session.");if(r.length<16*a.length)throw new TypeError("The length of transforms is too small to hold a transform for every space.");const c=this.nativeGetPose(e);if(!c)return!1;let u=!0;for(let t=0;t<a.length;t++){const n=this.effectivePoseMatrix(l,e,c,a[t],i,!0);n?Pc(n,r,16*t):u=!1}return u}handleGetViewerPose(e,t,n){const i=t.call(e,n),r=this.adapterForFrame(e);if(!i||!r||!this.installedState)return i;const a=this.nativeGetPose(e);if(!a)return this.viewerOverrideFailure("The native XRFrame.getPose implementation could not be recovered.");const s=this.viewerToBaseMatrix(r,e,a,n);if(!s)return this.viewerOverrideFailure("The overridden viewer pose could not be resolved in the requested reference space.");const o=this.readNativeTransform(i);if(!o)return this.viewerOverrideFailure("The browser-owned XRViewerPose transform could not be read.");const l=Rc(o),c=[];if(!this.overrideTransform(r,i,this.rigidTransformFromMatrix(s)))return this.viewerOverrideFailure("The browser-owned XRViewerPose transform could not be overridden.");c.push(i);const u=Vr(bc,l);if(!u)return this.clearTransformOverrides(c),this.viewerOverrideFailure("The browser-owned XRViewerPose transform was not invertible.");for(const e of i.views){const t=this.readNativeTransform(e);if(!t)return this.clearTransformOverrides(c),this.viewerOverrideFailure("A browser-owned XRView transform could not be read.");const n=Rc(t),i=Or();Hr(i,u,n);const a=Or();if(Hr(a,s,i),!this.overrideTransform(r,e,this.rigidTransformFromMatrix(a)))return this.clearTransformOverrides(c),this.viewerOverrideFailure("A browser-owned XRView transform could not be overridden.");c.push(e)}return this.capabilityState.viewerPose=!0,this.capabilityState.viewTransforms=!0,this.capabilityState.phase="active",i}viewerOverrideFailure(e){return this.note(e),null}effectivePoseMatrix(e,t,n,i,r,a=!1){const s=this.spaces.get(i),o=this.spaces.get(r);if(s&&s.adapter!==e||o&&o.adapter!==e)return null;if(!s&&!o&&!a)return null;const l=s?this.controlledSpaceToAnchor(s,vc):this.nativePoseMatrix(n.call(t,i,e.anchorSpace));if(!l)return null;let c;if(o){const e=this.controlledSpaceToAnchor(o,xc);c=e?Vr(yc,e):null}else c=this.anchorToNativeBase(e,t,n,r);return c?Ur(Hr(_c,c,l)):null}viewerToBaseMatrix(e,t,n,i){const r=this.viewerMatrix(gc),a=this.spaces.get(i);let s;if(a){if(a.adapter!==e)return null;const t=this.controlledSpaceToAnchor(a,xc);s=t?Vr(yc,t):null}else s=this.anchorToNativeBase(e,t,n,i);return s?Ur(Hr(_c,s,r)):null}controlledSpaceToAnchor(e,t){if(e.available&&!e.available())return null;if(e.origin){const n=e.origin();if(!n)return null;qa.calculateGlobalOffsetMatrix(n,t)}else Br(t);return Hr(t,t,e.localOffset),t}viewerMatrix(e){return qa.calculateGlobalOffsetMatrix(this.currentViewerSpace(),e)}anchorToNativeBase(e,t,n,i){if(e.baseSpaceCache.has(i)){const t=e.baseSpaceCache.get(i);return t?Ur(t):null}const r=n.call(t,e.anchorSpace,i),a=this.nativePoseMatrix(r);return e.baseSpaceCache.set(i,a?Ur(a):null),a}nativePoseMatrix(e){if(!e)return null;const t=this.readNativeTransform(e);return t?Rc(t):null}createPoseFacade(e){const t=this.constructorPrototype("XRPose"),n=Object.create(null!=t?t:Object.prototype);return Object.defineProperties(n,this.poseProperties(e)),n}createJointPoseFacade(e,t){var n;const i=null!==(n=this.constructorPrototype("XRJointPose"))&&void 0!==n?n:this.constructorPrototype("XRPose"),r=Object.create(null!=i?i:Object.prototype);return Object.defineProperties(r,{...this.poseProperties(e),radius:{configurable:!0,enumerable:!0,value:t}}),r}poseProperties(e){return{transform:{configurable:!0,enumerable:!0,value:this.rigidTransformFromMatrix(e)},emulatedPosition:{configurable:!0,enumerable:!0,value:!1},linearVelocity:{configurable:!0,enumerable:!0,value:null},angularVelocity:{configurable:!0,enumerable:!0,value:null}}}rigidTransformFromMatrix(e){return Xr(Ec,e),$r(Mc,e),new(this.getRigidTransformConstructor())({x:Ec[0],y:Ec[1],z:Ec[2],w:1},{x:Mc[0],y:Mc[1],z:Mc[2],w:Mc[3]})}getRigidTransformConstructor(){const e=this.globalObject.XRRigidTransform;if("function"!=typeof e)throw new Error("Native XRRigidTransform constructor is unavailable.");return e}readNativeTransform(e){let t=this.transformReaders.get(e);if(!t){const n=Ac(e,"transform");if(!n)return null;let i=this.rawTransformGetters.get(n.owner);if(!i&&n.descriptor.get&&(i=n.descriptor.get,this.rawTransformGetters.set(n.owner,i)),i)t=()=>i.call(e);else{if(!("value"in n.descriptor))return null;{const e=n.descriptor.value;t=()=>e}}this.transformReaders.set(e,t)}try{return t()}catch(e){return null}}overrideTransform(e,t,n){if(!this.readNativeTransform(t))return!1;this.transformOverrides.set(t,{epoch:this.epoch,transform:n});const i=Ac(t,"transform");if(!i)return!1;if(i.owner!==t&&this.patchedTransformOwners.has(i.owner))return!0;const r=this.rawTransformGetters.get(i.owner);if(i.owner!==t&&r&&!1!==i.descriptor.configurable){const e=this;if(this.patches.define(i.owner,"transform",{...i.descriptor,get(){const t=e.transformOverrides.get(this);return e.installedState&&t&&t.epoch===e.epoch?t.transform:r.call(this)}}))return this.patchedTransformOwners.add(i.owner),!0}if(this.instancePatchedTransformEpochs.get(t)===this.epoch)return!0;const a=this,s=e.instancePatches.define(t,"transform",{configurable:!0,get(){var e;const t=a.transformOverrides.get(this);return a.installedState&&t&&t.epoch===a.epoch?t.transform:null===(e=a.transformReaders.get(this))||void 0===e?void 0:e()}});return s?(this.instancePatchedTransformEpochs.set(t,this.epoch),!0):(this.transformOverrides.delete(t),!1)}clearTransformOverrides(e){for(const t of e)this.transformOverrides.delete(t)}nativeGetPose(e){var t;const n=this.rawGetPoseByFrame.get(e);if(n)return n;const i=Ac(e,"getPose");return i&&null!==(t=this.rawGetPoseByOwner.get(i.owner))&&void 0!==t?t:null}handleCreateAnchor(e,t,n,i){if(!this.installedState)return t.call(e,n,i);const r=this.spaces.get(i);if(!r)return t.call(e,n,i);try{const i=this.adapterForFrame(e);if(!i||i.ended)throw Fc("The IWER-controlled anchor space belongs to a different native session.");if(this.assertFrameActive(i,e,"createAnchor"),i!==r.adapter)throw Fc("The IWER-controlled anchor space belongs to a different native session.");if(!i.createAnchorAvailable)throw new DOMException("Anchors in IWER-controlled spaces are unavailable because XRFrame.createAnchor could not be overridden.","NotSupportedError");const a=this.controlledSpaceToAnchor(r,wc);if(!a)throw Fc("The IWER-controlled anchor space could not be resolved for this frame.");const s=Hr(Or(),a,Rc(n)),o=this.rigidTransformFromMatrix(s);return this.capabilityState.anchors=!0,t.call(e,o,i.anchorSpace)}catch(e){return Promise.reject(e)}}handleRequestHitTestSource(e,t,n){const i=this.installedState&&n?this.spaces.get(n.space):null;if(!i)return t.call(e,n);const r=this.sessionsByObject.get(e);if(!r||r!==i.adapter||r.ended)return Promise.reject(Fc("The IWER-controlled hit test space belongs to a different native session."));if(!r.hitTestResultsAvailable)return Promise.reject(new DOMException("Hit test sources in IWER-controlled spaces are unavailable because XRFrame.getHitTestResults could not be overridden.","NotSupportedError"));const a=this.controlledSpaceToAnchor(i,Sc);if(!a)return Promise.reject(Fc("The IWER-controlled hit test space could not be resolved."));const s={adapter:r,facade:void 0,space:n.space,requestedOptions:{...n,entityTypes:n.entityTypes?Array.from(n.entityTypes):void 0},nativeMethod:t,current:null,currentMatrix:null,pendingMatrix:null,pendingToken:0,failures:0,backoffFrames:0,cancelled:!1};return s.facade=this.createHitTestSourceFacade(s),r.hitTests.add(s),this.hitTestBindings.set(s.facade,s),this.capabilityState.hitTest=!0,this.requestBackingSource(s,a).then(()=>s.facade,e=>{throw this.disposeHitTestBinding(s),e})}createHitTestSourceFacade(e){const t=this.constructorPrototype("XRHitTestSource"),n=Object.create(null!=t?t:Object.prototype);return Object.defineProperty(n,"cancel",{configurable:!0,writable:!0,value:()=>{if(e.cancelled)throw Fc("The IWER-controlled hit test source has already been cancelled.");this.disposeHitTestBinding(e)}}),n}requestBackingSource(e,t){const n=++e.pendingToken;e.pendingMatrix=Ur(t);const i=e.adapter;let r;try{const n=this.createDetachedOffsetSpace(i,t);r=Promise.resolve(e.nativeMethod.call(i.session,{...e.requestedOptions,space:n}))}catch(e){r=Promise.reject(e)}return r.then(t=>{if(n!==e.pendingToken||e.cancelled||i.ended||!this.installedState)return void this.cancelNativeHitTestSource(t);const r=e.current;e.current=t,e.currentMatrix=e.pendingMatrix,e.pendingMatrix=null,e.failures=0,e.backoffFrames=0,this.cancelNativeHitTestSource(r)},t=>{throw n!==e.pendingToken||e.cancelled||(e.pendingMatrix=null,e.failures+=1,e.backoffFrames=Math.min(2**Math.min(e.failures,5),32)),t})}createDetachedOffsetSpace(e,t){const n=this.rigidTransformFromMatrix(t),i=this.spaces.get(e.anchorSpace);this.spaces.delete(e.anchorSpace);try{return e.anchorSpace.getOffsetReferenceSpace(n)}finally{i&&this.spaces.set(e.anchorSpace,i)}}updateHitTestSources(e){if(0!==e.hitTests.size)for(const t of Array.from(e.hitTests)){if(t.cancelled)continue;if(t.pendingMatrix)continue;if(t.backoffFrames>0){t.backoffFrames-=1;continue}const e=this.spaces.get(t.space);if(!e)continue;const n=this.controlledSpaceToAnchor(e,Sc);n&&(t.currentMatrix&&Nc(t.currentMatrix,n)||this.requestBackingSource(t,n).catch(e=>{this.note(`A native hit test subscription could not follow its IWER-controlled space: ${this.errorText(e)}`,"hit-test-resubscribe-failed")}))}}handleGetHitTestResults(e,t,n){if(!this.installedState)return t.call(e,n);const i=this.hitTestBindings.get(n);if(!i)return t.call(e,n);if(i.cancelled)throw Fc("The IWER-controlled hit test source has been cancelled.");const r=this.adapterForFrame(e);if(!r||r!==i.adapter)throw Fc("The IWER-controlled hit test source belongs to a different native session.");if(r.framesInstrumented&&r.activeFrame!==e)throw Fc("Failed to execute 'getHitTestResults' on 'XRFrame': the frame is not active.");return i.current?t.call(e,i.current):[]}cancelNativeHitTestSource(e){if(e)try{e.cancel()}catch(e){}}disposeHitTestBinding(e){e.cancelled=!0,e.pendingToken+=1,e.pendingMatrix=null,this.cancelNativeHitTestSource(e.current),e.current=null,e.currentMatrix=null,e.adapter.hitTests.delete(e)}adapterForFrame(e){var t;const n=this.frameSessions.get(e);if(n&&!n.ended)return n;try{return null!==(t=this.sessionsByObject.get(e.session))&&void 0!==t?t:null}catch(e){return null}}assertFrameActive(e,t,n){if(e.framesInstrumented&&e.activeFrame!==t)throw Fc(`Failed to execute '${n}' on 'XRFrame': the frame is not active.`)}constructorPrototype(e){var t;const n=this.globalObject[e];return null!==(t=null==n?void 0:n.prototype)&&void 0!==t?t:null}detachSession(e){const t=this.sessionsByObject.get(e);t&&this.detachAdapter(t)}detachAdapter(e,t=!1){var n;if(e.ended)return;const i="gaze-only"===this.options.mode?e.sources.filter(t=>e.bindingByFacade.has(t)):[...e.sources],r=this.unhealthyFrameAdapters.delete(e);e.ended=!0;for(const t of e.cleanupListeners.splice(0))try{t()}catch(e){}const a=e===this.sharedStateDriver();for(const t of e.deviceBindings){for(const e of t.eventButtons)a&&this.releaseButton(e),t.previousButtonValues.set(e,e.value);t.activeButtons.clear()}for(const t of Array.from(e.hitTests))this.disposeHitTestBinding(t);if(e.instancePatches.revert(),e.patches.revert(),e.baseSpaceCache.clear(),e.activeFrame=null,e.lastPreparedFrame=null,this.sessionsByObject.delete(e.session),t){let t=[];if("full"===this.options.mode)try{t=Array.from(e.session.inputSources)}catch(e){}if(t.length>0||i.length>0)try{this.dispatchInputSourcesChange(e,t,i)}catch(e){}}e.sources=Object.freeze([]),e.deviceBindings.splice(0),e.playbackBindings.clear(),e.bindingByFacade.clear(),e.spaceTokens.clear(),e.pendingEvents.length=0,e.retainedSources.clear(),this.liveSessions.delete(e),r&&0===this.unhealthyFrameAdapters.size&&this.installedState&&(this.capabilityState.supported=!0),this.primarySession===e&&(this.primarySession=null!==(n=this.liveSessions.values().next().value)&&void 0!==n?n:null,this.lastPrimaryTime=void 0),0===this.liveSessions.size&&(this.unwirePlayer(),this.playbackFrame=null,this.device.remote.forceRelease())}resetPatchTracking(){this.sessionsByObject=new WeakMap,this.frameSessions=new WeakMap,this.spaces=new WeakMap,this.hitTestBindings=new WeakMap,this.syntheticEvents=new WeakSet,this.patchedFrameOwners=new WeakSet,this.patchedViewerFrameOwners=new WeakSet,this.patchedFillPosesOwners=new WeakSet,this.patchedJointPoseOwners=new WeakSet,this.patchedJointRadiiOwners=new WeakSet,this.patchedReferenceSpaceOwners=new WeakSet,this.patchedEnabledFeaturesOwners=new WeakSet,this.patchedInputSourceOwners=new WeakSet,this.patchedRafOwners=new WeakSet,this.patchedRequestReferenceSpaceOwners=new WeakSet,this.instancePatchedReferenceSpaces=new WeakSet,this.patchedHitTestOwners=new WeakSet,this.patchedHitTestResultOwners=new WeakSet,this.patchedCreateAnchorOwners=new WeakSet,this.rawGetPoseByOwner=new WeakMap,this.rawGetPoseByFrame=new WeakMap,this.rawRafByOwner=new WeakMap,this.rawRequestReferenceSpaceByOwner=new WeakMap,this.rawInputSourcesGetterByOwner=new WeakMap,this.rawTransformGetters=new WeakMap,this.transformReaders=new WeakMap,this.transformOverrides=new WeakMap,this.patchedTransformOwners=new WeakSet,this.instancePatchedFrameEpochs=new WeakMap,this.instancePatchedTransformEpochs=new WeakMap,this.unhealthyFrameAdapters.clear(),this.lastPrimaryTime=void 0}unsupportedForSession(e,t){if("throw"===this.options.onUnsupported)throw this.detachAdapter(e),new Error(t);this.note(t)}unsupported(e){if(this.capabilityState.supported=!1,this.note(e),"throw"===this.options.onUnsupported)throw new Error(e)}note(e,t=e){this.warned.has(t)||(this.warned.add(t),this.capabilityState.notes.push(e),console.warn(`[IWER native override] ${e}`))}errorText(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}}const Vc=Bi(e=>({mode:"off",commitHand:"right",setMode:t=>e({mode:t}),setCommitHand:t=>e({commitHand:t})}));const Hc=Jt.td`
|
|
858
|
-
text-align: right;
|
|
859
|
-
color: ${en};
|
|
860
|
-
padding: 0 8px 0 0;
|
|
861
|
-
font-weight: bold;
|
|
862
|
-
`,Gc=Jt.td`
|
|
863
|
-
text-align: left;
|
|
864
|
-
color: ${tn};
|
|
865
|
-
padding: 0;
|
|
866
|
-
`,Wc=Jt(On)`
|
|
867
|
-
position: absolute;
|
|
868
|
-
top: calc(100% + 8px);
|
|
869
|
-
left: ${({$left:e})=>`${e}px`};
|
|
870
|
-
width: ${248}px;
|
|
871
|
-
box-sizing: border-box;
|
|
872
|
-
gap: ${_n};
|
|
873
|
-
padding: 8px;
|
|
874
|
-
overflow: visible;
|
|
875
|
-
z-index: 10;
|
|
876
|
-
`,jc=Jt.div`
|
|
877
|
-
min-height: 26px;
|
|
878
|
-
display: flex;
|
|
879
|
-
align-items: center;
|
|
880
|
-
gap: 8px;
|
|
881
|
-
padding: 0 2px 4px;
|
|
882
|
-
|
|
883
|
-
&:focus {
|
|
884
|
-
outline: none;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
&:focus-visible {
|
|
888
|
-
outline: 2px solid ${sn};
|
|
889
|
-
outline-offset: 1px;
|
|
890
|
-
border-radius: ${In};
|
|
891
|
-
}
|
|
892
|
-
`,Xc=Jt.strong`
|
|
893
|
-
flex: 1;
|
|
894
|
-
font-size: 14px;
|
|
895
|
-
font-weight: 600;
|
|
896
|
-
letter-spacing: -0.01em;
|
|
897
|
-
`,qc=Jt.button`
|
|
898
|
-
width: 100%;
|
|
899
|
-
min-height: 42px;
|
|
900
|
-
box-sizing: border-box;
|
|
901
|
-
display: grid;
|
|
902
|
-
grid-template-columns: 18px minmax(0, 1fr) 16px;
|
|
903
|
-
align-items: center;
|
|
904
|
-
gap: 8px;
|
|
905
|
-
padding: 6px 8px;
|
|
906
|
-
border: 1px solid
|
|
907
|
-
${({$selected:e})=>e?Nn:"rgba(255, 255, 255, 0.04)"};
|
|
908
|
-
border-radius: ${In};
|
|
909
|
-
background: ${({$selected:e})=>e?kn:"transparent"};
|
|
910
|
-
color: ${({$selected:e,$unavailable:t})=>t?tn:e?sn:en};
|
|
911
|
-
cursor: ${({$unavailable:e})=>e?"default":"pointer"};
|
|
912
|
-
text-align: left;
|
|
913
|
-
font-family:
|
|
914
|
-
system-ui,
|
|
915
|
-
-apple-system,
|
|
916
|
-
'Segoe UI',
|
|
917
|
-
Roboto,
|
|
918
|
-
sans-serif;
|
|
919
|
-
&:hover {
|
|
920
|
-
background: ${({$selected:e,$unavailable:t})=>t?e?kn:"transparent":e?"rgba(45, 127, 249, 0.24)":"rgba(255, 255, 255, 0.07)"};
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
&:focus {
|
|
924
|
-
outline: none;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
&:focus-visible {
|
|
928
|
-
outline: 2px solid ${sn};
|
|
929
|
-
outline-offset: 1px;
|
|
930
|
-
}
|
|
931
|
-
`,$c=Jt.span`
|
|
932
|
-
min-width: 0;
|
|
933
|
-
display: flex;
|
|
934
|
-
flex-direction: column;
|
|
935
|
-
gap: 1px;
|
|
936
|
-
`,Yc=Jt.span`
|
|
937
|
-
font-size: 12px;
|
|
938
|
-
font-weight: 600;
|
|
939
|
-
line-height: 15px;
|
|
940
|
-
`,Kc=Jt.span`
|
|
941
|
-
color: ${tn};
|
|
942
|
-
font-size: 10px;
|
|
943
|
-
font-weight: 400;
|
|
944
|
-
line-height: 13px;
|
|
945
|
-
`,Qc=Jt.div`
|
|
946
|
-
padding: 5px 2px 3px;
|
|
947
|
-
color: ${tn};
|
|
948
|
-
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
949
|
-
font-size: 10px;
|
|
950
|
-
font-weight: 600;
|
|
951
|
-
letter-spacing: 0.04em;
|
|
952
|
-
text-transform: uppercase;
|
|
953
|
-
`,Zc=Jt.div`
|
|
954
|
-
display: grid;
|
|
955
|
-
grid-auto-flow: column;
|
|
956
|
-
grid-auto-columns: 1fr;
|
|
957
|
-
gap: 2px;
|
|
958
|
-
padding: 2px;
|
|
959
|
-
border-radius: ${In};
|
|
960
|
-
background: ${({$unavailable:e})=>e?"rgba(20, 20, 22, 0.42)":Dn};
|
|
961
|
-
`,Jc=Jt.button`
|
|
962
|
-
height: ${Ln};
|
|
963
|
-
min-width: 0;
|
|
964
|
-
padding: 0 6px;
|
|
965
|
-
overflow: hidden;
|
|
966
|
-
border: 1px solid
|
|
967
|
-
${({$selected:e,$unavailable:t})=>e?t?"rgba(255, 255, 255, 0.08)":Nn:"transparent"};
|
|
968
|
-
border-radius: 6px;
|
|
969
|
-
background: ${({$selected:e,$unavailable:t})=>e?t?"rgba(255, 255, 255, 0.04)":kn:"transparent"};
|
|
970
|
-
color: ${({$selected:e,$unavailable:t})=>t?tn:e?sn:tn};
|
|
971
|
-
cursor: ${({$unavailable:e})=>e?"not-allowed":"pointer"};
|
|
972
|
-
font-family:
|
|
973
|
-
system-ui,
|
|
974
|
-
-apple-system,
|
|
975
|
-
'Segoe UI',
|
|
976
|
-
Roboto,
|
|
977
|
-
sans-serif;
|
|
978
|
-
font-size: 11px;
|
|
979
|
-
font-weight: 600;
|
|
980
|
-
white-space: nowrap;
|
|
981
|
-
|
|
982
|
-
&:hover {
|
|
983
|
-
color: ${({$unavailable:e})=>e?tn:en};
|
|
984
|
-
background: ${({$selected:e,$unavailable:t})=>t?e?"rgba(255, 255, 255, 0.04)":"transparent":e?"rgba(45, 127, 249, 0.24)":"rgba(255, 255, 255, 0.06)"};
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
&:focus {
|
|
988
|
-
outline: none;
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
&:focus-visible {
|
|
992
|
-
outline: 2px solid ${sn};
|
|
993
|
-
outline-offset: 1px;
|
|
994
|
-
}
|
|
995
|
-
`,eu=Jt.div`
|
|
996
|
-
display: grid;
|
|
997
|
-
grid-template-columns: 8px minmax(0, 1fr);
|
|
998
|
-
align-items: start;
|
|
999
|
-
gap: 7px;
|
|
1000
|
-
padding: 7px 8px;
|
|
1001
|
-
border-radius: ${In};
|
|
1002
|
-
background: ${Dn};
|
|
1003
|
-
color: ${tn};
|
|
1004
|
-
font-size: 10px;
|
|
1005
|
-
line-height: 14px;
|
|
1006
|
-
`,tu=Jt.span`
|
|
1007
|
-
width: 6px;
|
|
1008
|
-
height: 6px;
|
|
1009
|
-
margin-top: 4px;
|
|
1010
|
-
border-radius: 50%;
|
|
1011
|
-
background: ${({$tone:e})=>"active"===e?sn:"error"===e?rn:tn};
|
|
1012
|
-
box-shadow: ${({$tone:e})=>"active"===e?`0 0 6px ${on}`:"none"};
|
|
1013
|
-
`,nu=Jt.div`
|
|
1014
|
-
display: grid;
|
|
1015
|
-
gap: 4px;
|
|
1016
|
-
padding: 2px;
|
|
1017
|
-
`,iu=Jt.div`
|
|
1018
|
-
display: grid;
|
|
1019
|
-
grid-template-columns: 42px minmax(0, 1fr);
|
|
1020
|
-
align-items: center;
|
|
1021
|
-
gap: 7px;
|
|
1022
|
-
color: ${tn};
|
|
1023
|
-
font-size: 10px;
|
|
1024
|
-
line-height: 13px;
|
|
1025
|
-
|
|
1026
|
-
> :first-child {
|
|
1027
|
-
justify-self: center;
|
|
1028
|
-
}
|
|
1029
|
-
`,ru=Jt.span`
|
|
1030
|
-
min-width: 20px;
|
|
1031
|
-
box-sizing: border-box;
|
|
1032
|
-
padding: 2px 4px;
|
|
1033
|
-
border: 1px solid ${cn};
|
|
1034
|
-
border-radius: 5px;
|
|
1035
|
-
color: ${en};
|
|
1036
|
-
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
1037
|
-
font-size: 10px;
|
|
1038
|
-
text-align: center;
|
|
1039
|
-
`;function au(e){var t;const n=e.activeSession;return{supported:Ho(e.supportedFeatures),sessionActive:null!=n,negotiated:Boolean(null==n?void 0:n.enabledFeatures.some(e=>"gaze-tracking"===e||"eye-tracking"===e)),connected:Boolean(null===(t=e.gaze)||void 0===t?void 0:t.connected)}}function su(e,t){const[n,i]=l.useState(0);return l.useLayoutEffect(()=>{if(!e)return;const n=()=>{const e=t.current,n=null==e?void 0:e.offsetParent;if(!e||!n)return;const r=e.getBoundingClientRect(),a=n.getBoundingClientRect(),s=Math.max(8,Math.min(r.left+r.width/2-124,window.innerWidth-248-8));i(s-a.left)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e,t]),n}function ou(e,t){l.useEffect(()=>{if(!e)return;const n=window.requestAnimationFrame(()=>{var e;const n=t.current,i=null==n?void 0:n.querySelector('[data-autofocus="true"]'),r=null==n?void 0:n.querySelector("button:not([disabled]), input:not([disabled])");null===(e=null!=i?i:r)||void 0===e||e.focus()});return()=>window.cancelAnimationFrame(n)},[e,t])}const lu=["meeting_room","living_room","music_room","office_large","office_small","none"],cu=Bi(e=>({infoPanelOpen:!1,envDropDownOpen:!1,headsetOpen:!1,inputMenuOpen:!1,gazePanelOpen:!1,setInfoPanelOpen:t=>e(()=>({infoPanelOpen:t})),setEnvDropDownOpen:t=>e(()=>({envDropDownOpen:t})),setHeadsetOpen:t=>e(()=>({headsetOpen:t})),setInputMenuOpen:t=>e(()=>({inputMenuOpen:t})),setGazePanelOpen:t=>e(()=>({gazePanelOpen:t}))}));const uu=[{value:"off",label:"Off"},{value:"cursor",label:"Cursor"},{value:"head-locked",label:"Head"}],du=[{value:"left",label:"Left"},{value:"right",label:"Right"}],hu=({xrDevice:e,inputLayer:t})=>{var n,i,r;const[a,s]=l.useState(Boolean(null===(n=e.sem)||void 0===n?void 0:n.planesVisible)),[o,u]=l.useState(Boolean(null===(i=e.sem)||void 0===i?void 0:i.boundingBoxesVisible)),[d,h]=l.useState(Boolean(null===(r=e.sem)||void 0===r?void 0:r.meshesVisible)),p=void 0!==e.visibilityMask,[f,m]=l.useState(e.visibilityMaskEnabled),{inputMode:g,setInputMode:v}=Dr(),y=Vc(e=>e.mode),x=Vc(e=>e.setMode),b=Vc(e=>e.commitHand),_=Vc(e=>e.setCommitHand),w=function(e){const[t,n]=l.useState(()=>au(e));return l.useEffect(()=>{const t=()=>{const t=au(e);n(e=>e.supported===t.supported&&e.sessionActive===t.sessionActive&&e.negotiated===t.negotiated&&e.connected===t.connected?e:t)};t();const i=window.setInterval(t,500);return()=>window.clearInterval(i)},[e]),t}(e),S=l.useRef(null),E=l.useRef(null),M=l.useRef(null),T=l.useRef(null),A=l.useRef(null),R=l.useRef(null),P=l.useRef(null),C=l.useRef(null),L=l.useRef(null),{infoPanelOpen:I,setInfoPanelOpen:D,envDropDownOpen:N,setEnvDropDownOpen:k,headsetOpen:F,setHeadsetOpen:O,inputMenuOpen:U,setInputMenuOpen:z,gazePanelOpen:B,setGazePanelOpen:V}=cu(),H=su(U,E),G=su(B,M),W=su(F,T),j=su(N,A);ou(U,R),ou(B,P),ou(F,C),ou(N,L),l.useEffect(()=>{if(!(U||B||F||N))return;const e=()=>{z(!1),V(!1),O(!1),k(!1)},t=t=>{const n=S.current;n&&t.composedPath().includes(n)||e()},n=t=>{if("Escape"!==t.key)return;const n=Boolean(S.current&&t.composedPath().includes(S.current)),i=U?E.current:B?M.current:F?T.current:A.current;e(),n&&(null==i||i.focus())};return document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",n),()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",n)}},[N,B,F,U,k,V,O,z]);const X="off"===y?g:"hand"===g&&"cursor"===y?"gaze-hands":null,q="off"!==y&&w.sessionActive&&w.negotiated&&w.connected?"active":"off"!==y&&w.sessionActive&&w.negotiated&&!w.connected?"error":"idle",$=w.supported?"off"===y?"Off · the app receives no gaze input":w.sessionActive?w.negotiated?w.connected?"Streaming to the XR session":"Source disconnected · far rays are active":"Session didn't request gaze-tracking":"Ready · enter XR to publish gaze":"No eye tracking on this profile · choose a gaze-capable device",Y=e=>{t.setGazeCommitHand(e),_(e),Vi({gazeCommitHand:e})},K=(n,i)=>{const r="controller"===n?"controller":"hand",a="gaze-hands"===n?"cursor":"off";v(r),e.primaryInputMode=r,t.setGazeMode(a),x(t.currentGazeMode),Vi({inputMode:r,gazeMode:a}),z(!1),i&&window.requestAnimationFrame(()=>{var e;return null===(e=E.current)||void 0===e?void 0:e.focus()})},Q=e=>{w.supported&&(e=>{t.setGazeMode(e),x(t.currentGazeMode),Vi({gazeMode:e})})(e)},Z=e=>e?sn:tn;return c.jsxs("div",{style:{display:"flex",justifyContent:"center",flexDirection:"row",alignItems:"center",gap:"6px",padding:"8px"},children:[c.jsxs("div",{ref:S,style:{position:"relative"},children:[c.jsxs(Sn,{children:[c.jsx(En,{title:"Reset device transforms",onClick:()=>t.resetDeviceTransforms(),children:c.jsx(ki,{name:"rotate-ccw",size:16})}),c.jsx(En,{title:"cursor"===y?"Pointer lock is unavailable while cursor gaze is active":"Play mode (lock pointer)",disabled:"cursor"===y,onClick:()=>{t.lockPointer(),k(!1),D(!1)},children:c.jsx(ki,{name:"circle-play",size:16})}),c.jsx(En,{ref:E,title:"Select input mode","aria-expanded":U,"aria-controls":U?"iwer-input-mode-menu":void 0,$open:U,onClick:()=>{z(!U),O(!1),V(!1),k(!1),D(!1)},children:c.jsx(ki,{name:"hand"===g&&"cursor"===y?"eye":"controller"===g?"gamepad-2":"hand",size:16})}),c.jsx(En,{ref:M,title:"Configure gaze emulation","aria-expanded":B,"aria-controls":B?"iwer-gaze-settings":void 0,$active:"off"!==y,$open:B,onClick:()=>{V(!B),O(!1),z(!1),k(!1),D(!1)},children:c.jsx(ki,{name:"scan-eye",size:16,color:"error"===q?rn:void 0})}),c.jsx(En,{ref:T,title:"Headset position","aria-expanded":F,"aria-controls":F?"iwer-headset-settings":void 0,$open:F,onClick:()=>{O(!F),z(!1),V(!1),k(!1),D(!1)},children:c.jsx(ki,{name:"glasses",size:16})}),c.jsx(En,{"aria-label":"Field-of-view mask","aria-pressed":f,disabled:!p,title:p?(f?"Disable":"Enable")+" field-of-view mask":"Field-of-view mask unavailable for this device profile",onClick:()=>{e.visibilityMaskEnabled=!e.visibilityMaskEnabled,m(e.visibilityMaskEnabled),Vi({visibilityMaskEnabled:e.visibilityMaskEnabled})},children:c.jsx(ki,{name:"scan",size:16,color:p?f?sn:tn:nn})}),e.sem&&c.jsxs(c.Fragment,{children:[c.jsx(Un,{$horizontal:!1}),c.jsx(En,{ref:A,title:"Select emulated environment","aria-expanded":N,"aria-controls":N?"iwer-environment-menu":void 0,$open:N,onClick:()=>{k(!N),z(!1),V(!1),O(!1),D(!1)},children:c.jsx(ki,{name:"armchair",size:16})}),c.jsx(En,{title:"Toggle plane visibility",onClick:()=>{e.sem.planesVisible=!a,s(!a)},children:c.jsx(ki,{name:"layers",size:16,color:Z(a)})}),c.jsx(En,{title:"Toggle bounding-box visibility",onClick:()=>{e.sem.boundingBoxesVisible=!o,u(!o)},children:c.jsx(ki,{name:"box",size:16,color:Z(o)})}),c.jsx(En,{title:"Toggle mesh visibility",onClick:()=>{e.sem.meshesVisible=!d,h(!d)},children:c.jsx(ki,{name:"shapes",size:16,color:Z(d)})})]}),c.jsx(Un,{$horizontal:!1}),c.jsx(En,{title:"Save current device pose as the default for this site",onClick:()=>{const e=t.captureDefaultPose();t.applyDefaultPose(e),Vi({defaultPose:e})},children:c.jsx(ki,{name:"save",size:16})}),c.jsx(Un,{$horizontal:!1}),c.jsx(En,{title:"Exit XR session",onClick:()=>{var t;return null===(t=e.activeSession)||void 0===t?void 0:t.end()},children:c.jsx(ki,{name:"log-out",size:16})})]}),U&&c.jsxs(Wc,{ref:R,id:"iwer-input-mode-menu",role:"group","aria-label":"Input mode",$left:H,children:[c.jsxs(jc,{children:[c.jsx(ki,{name:"gamepad-2",size:15}),c.jsx(Xc,{children:"Input setup"})]}),c.jsxs(qc,{type:"button","aria-pressed":"controller"===X,"data-autofocus":"controller"===X,$selected:"controller"===X,onClick:e=>K("controller",0===e.detail),children:[c.jsx(ki,{name:"gamepad-2",size:15}),c.jsxs($c,{children:[c.jsx(Yc,{children:"Controllers"}),c.jsx(Kc,{children:"Ray + trigger"})]}),"controller"===X?c.jsx(ki,{name:"circle-dot",size:14,color:sn}):c.jsx("span",{"aria-hidden":"true"})]}),c.jsxs(qc,{type:"button","aria-pressed":"hand"===X,"data-autofocus":"hand"===X,$selected:"hand"===X,onClick:e=>K("hand",0===e.detail),children:[c.jsx(ki,{name:"hand",size:15}),c.jsxs($c,{children:[c.jsx(Yc,{children:"Hands"}),c.jsx(Kc,{children:"Ray, poke + grab"})]}),"hand"===X?c.jsx(ki,{name:"circle-dot",size:14,color:sn}):c.jsx("span",{"aria-hidden":"true"})]}),c.jsxs(qc,{type:"button","aria-pressed":"gaze-hands"===X,"data-autofocus":"gaze-hands"===X,"aria-disabled":!w.supported,"aria-describedby":w.supported?void 0:"iwer-gaze-preset-hint",$selected:"gaze-hands"===X,$unavailable:!w.supported,title:w.supported?"Use cursor gaze with hand pinch":"Select a gaze-capable device profile first",onClick:e=>{w.supported&&K("gaze-hands",0===e.detail)},children:[c.jsx(ki,{name:"eye",size:15}),c.jsxs($c,{children:[c.jsx(Yc,{children:"Gaze + Hands"}),c.jsx(Kc,{children:"Look, then pinch"})]}),"gaze-hands"===X?c.jsx(ki,{name:"circle-dot",size:14,color:sn}):c.jsx("span",{"aria-hidden":"true"})]}),!w.supported&&c.jsx(Kc,{id:"iwer-gaze-preset-hint",style:{padding:"4px"},children:"Needs an eye-tracking profile, such as Meta Quest Pro."}),null==X&&c.jsxs(Kc,{style:{padding:"5px 4px 2px"},children:["Custom · ","controller"===g?"Controllers":"Hands"," + ","head-locked"===y?"head gaze":"cursor gaze"]})]}),B&&c.jsxs(Wc,{ref:P,id:"iwer-gaze-settings",role:"group","aria-label":"Gaze emulation settings",$left:G,children:[c.jsxs(jc,{children:[c.jsx(ki,{name:"eye",size:15}),c.jsx(Xc,{children:"Gaze emulation"}),c.jsx(zn,{title:"Close gaze settings",onClick:e=>{var t;V(!1),0===e.detail&&(null===(t=M.current)||void 0===t||t.focus())},children:c.jsx(ki,{name:"circle-x",size:14})})]}),c.jsxs(eu,{"aria-live":"polite",children:[c.jsx(tu,{$tone:q}),c.jsx("span",{children:$})]}),c.jsx(Qc,{id:"iwer-gaze-mode-label",children:"Gaze mode"}),c.jsx(Zc,{role:"radiogroup","aria-label":"Gaze mode","aria-labelledby":"iwer-gaze-mode-label","aria-disabled":!w.supported,$unavailable:!w.supported,children:uu.map(({value:e,label:t})=>c.jsx(Jc,{type:"button",role:"radio","aria-checked":y===e,"aria-disabled":!w.supported,tabIndex:y===e?0:-1,"data-autofocus":y===e,$selected:y===e,$unavailable:!w.supported,onClick:()=>Q(e),onKeyDown:t=>((e,t)=>{var n,i;if(!w.supported)return;const r="ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:0;if(0===r)return;e.preventDefault();const a=uu.findIndex(e=>e.value===t),s=uu[(a+r+uu.length)%uu.length];Q(s.value);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.querySelectorAll('[role="radio"]');null===(i=null==o?void 0:o["off"===s.value?0:"cursor"===s.value?1:2])||void 0===i||i.focus()})(t,e),children:t},e))}),c.jsx(Qc,{id:"iwer-gaze-hand-label",children:"Commit hand"}),c.jsx(Zc,{role:"radiogroup","aria-label":"Gaze commit hand","aria-labelledby":"iwer-gaze-hand-label","aria-disabled":"off"===y||!w.supported,$unavailable:"off"===y||!w.supported,children:du.map(({value:e,label:t})=>c.jsx(Jc,{type:"button",role:"radio","aria-checked":b===e,"aria-disabled":"off"===y||!w.supported,tabIndex:b===e?0:-1,$selected:b===e,$unavailable:"off"===y||!w.supported,onClick:()=>{"off"!==y&&w.supported&&Y(e)},onKeyDown:t=>((e,t)=>{var n,i;if("off"===y||!w.supported)return;const r="ArrowRight"===e.key?1:"ArrowLeft"===e.key?-1:0;if(0===r)return;e.preventDefault();const a=du.findIndex(e=>e.value===t),s=du[(a+r+du.length)%du.length];Y(s.value);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.querySelectorAll('[role="radio"]');null===(i=null==o?void 0:o["left"===s.value?0:1])||void 0===i||i.focus()})(t,e),children:t},e))}),c.jsxs(Kc,{style:{padding:"3px 2px 1px"},children:["hand"===g?"Pinch":"Trigger"," confirms the gaze target."]}),"cursor"===y&&w.sessionActive&&w.connected&&c.jsxs(c.Fragment,{children:[c.jsx(Un,{}),c.jsx(Qc,{children:"Cursor controls"}),c.jsxs(nu,{children:[c.jsxs(iu,{children:[c.jsx(ki,{name:"mouse-left",size:14}),c.jsxs("span",{children:["Aim + commit · drag to move"," ","hand"===g?"hand":"controller"]})]}),c.jsxs(iu,{children:[c.jsx(ki,{name:"mouse-right",size:14}),c.jsx("span",{children:"Drag to look around"})]}),c.jsxs(iu,{children:[c.jsx(ki,{name:"mouse",size:14}),c.jsx("span",{children:"While held, wheel to adjust depth"})]}),c.jsxs(iu,{children:[c.jsx(ru,{children:"Space"}),c.jsx("span",{children:"Reset commit-hand pose"})]})]}),c.jsx(Kc,{style:{padding:"3px 2px 1px"},children:"Play mode is unavailable while cursor gaze is on."})]})]}),F&&c.jsxs(Wc,{ref:C,id:"iwer-headset-settings",role:"group","aria-label":"Headset position",$left:W,children:[c.jsxs(jc,{tabIndex:-1,"data-autofocus":"true",style:{fontSize:"13px",fontWeight:600},children:[c.jsx(ki,{name:"glasses",size:15}),e.name]}),c.jsx(Un,{}),c.jsx(Sr,{vector:t.combinedCameraPosition,label:"Pos"})]}),N&&c.jsx(Wc,{ref:L,id:"iwer-environment-menu",role:"group","aria-label":"Emulated environment",$left:j,children:lu.map(t=>{return c.jsx(En,{style:{fontSize:"12px",width:"100%",justifyContent:"start",borderRadius:"8px",padding:"6px 10px"},onClick:n=>{"none"===t?e.sem.deleteAll():e.sem.loadDefaultEnvironment(t),Vi({environment:t}),k(!1),0===n.detail&&window.requestAnimationFrame(()=>{var e;return null===(e=A.current)||void 0===e?void 0:e.focus()})},children:(n=t,n.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "))},t);var n})})]}),c.jsxs(Sn,{children:[c.jsx(En,{title:"About IWER",onClick:()=>{D(!I),z(!1),V(!1),O(!1),k(!1)},children:c.jsx(ki,{name:"iwer",size:16})}),c.jsx(En,{title:"Report issues",onClick:()=>window.open("https://github.com/meta-quest/immersive-web-emulation-runtime/issues","_blank"),children:c.jsx(ki,{name:"bug",size:16})})]}),I&&c.jsxs(On,{style:{top:"50vh",left:"50vw",transform:"translate(-50%, -50%)",maxWidth:"240px",gap:"4px",padding:"16px"},children:[c.jsx("div",{style:{display:"flex",justifyContent:"end"},children:c.jsx(zn,{$isRed:!0,onClick:()=>D(!1),children:c.jsx(ki,{name:"circle-x",size:14})})}),c.jsx("div",{style:{display:"flex",justifyContent:"center"},children:c.jsx(ki,{name:"iwer",size:72})}),c.jsxs("p",{style:{textAlign:"center",padding:"0 5px",margin:"0"},children:[c.jsx("b",{children:"Immersive Web Emulation Runtime"})," (IWER) is a free, open-source WebXR developer tool created by Meta Platforms, Inc."]}),c.jsx("table",{style:{width:"100%",borderCollapse:"collapse",display:"flex",justifyContent:"center",fontSize:"12px",padding:"8px"},children:c.jsxs("tbody",{children:[c.jsxs("tr",{children:[c.jsx(Hc,{children:"IWER"}),c.jsxs(Gc,{children:["v",e.version]})]}),c.jsxs("tr",{children:[c.jsx(Hc,{children:"DevUI"}),c.jsxs(Gc,{children:["v",e.devui.version]})]}),e.sem&&c.jsxs("tr",{children:[c.jsx(Hc,{children:"SEM"}),c.jsxs(Gc,{children:["v",e.sem.version]})]})]})}),c.jsx(wn,{style:{borderRadius:vn},onClick:()=>window.open("https://github.com/meta-quest/immersive-web-emulation-runtime/blob/main/LICENSE","_blank"),children:"MIT License"}),c.jsx(wn,{style:{borderRadius:vn},onClick:()=>window.open("https://github.com/meta-quest/immersive-web-emulation-runtime","_blank"),children:"View Source on GitHub"})]})]})},pu="181",fu=0,mu=1,gu=2,vu=100,yu=101,xu=102,bu=200,_u=201,wu=202,Su=203,Eu=204,Mu=205,Tu=206,Au=207,Ru=208,Pu=209,Cu=210,Lu=211,Iu=212,Du=213,Nu=214,ku=0,Fu=1,Ou=2,Uu=3,zu=4,Bu=5,Vu=6,Hu=7,Gu=301,Wu=302,ju=306,Xu=1e3,qu=1001,$u=1002,Yu=1003,Ku=1004,Qu=1005,Zu=1006,Ju=1007,ed=1008,td=1009,nd=1010,id=1011,rd=1012,ad=1013,sd=1014,od=1015,ld=1016,cd=1017,ud=1018,dd=1020,hd=35902,pd=35899,fd=1023,md=1026,gd=1027,vd=1029,yd=1030,xd=1031,bd=1033,_d=33776,wd=33777,Sd=33778,Ed=33779,Md=35840,Td=35841,Ad=35842,Rd=35843,Pd=36196,Cd=37492,Ld=37496,Id=37808,Dd=37809,Nd=37810,kd=37811,Fd=37812,Od=37813,Ud=37814,zd=37815,Bd=37816,Vd=37817,Hd=37818,Gd=37819,Wd=37820,jd=37821,Xd=36492,qd=36494,$d=36495,Yd=36283,Kd=36284,Qd=36285,Zd=36286,Jd="",eh="srgb",th="srgb-linear",nh="linear",ih="srgb",rh=7680,ah=512,sh=513,oh=514,lh=515,ch=516,uh=517,dh=518,hh=519,ph="300 es",fh=2e3,mh=2001;function gh(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function vh(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function yh(){const e=vh("canvas");return e.style.display="block",e}const xh={};function bh(...e){const t="THREE."+e.shift();console.log(t,...e)}function _h(...e){const t="THREE."+e.shift();console.warn(t,...e)}function wh(...e){const t="THREE."+e.shift();console.error(t,...e)}function Sh(...e){const t=e.join(" ");t in xh||(xh[t]=!0,_h(...e))}class Eh{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return void 0!==n&&(void 0!==n[e]&&-1!==n[e].indexOf(t))}removeEventListener(e,t){const n=this._listeners;if(void 0===n)return;const i=n[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){const t=this._listeners;if(void 0===t)return;const n=t[e.type];if(void 0!==n){e.target=this;const t=n.slice(0);for(let n=0,i=t.length;n<i;n++)t[n].call(this,e);e.target=null}}}const Mh=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Th=Math.PI/180,Ah=180/Math.PI;function Rh(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(Mh[255&e]+Mh[e>>8&255]+Mh[e>>16&255]+Mh[e>>24&255]+"-"+Mh[255&t]+Mh[t>>8&255]+"-"+Mh[t>>16&15|64]+Mh[t>>24&255]+"-"+Mh[63&n|128]+Mh[n>>8&255]+"-"+Mh[n>>16&255]+Mh[n>>24&255]+Mh[255&i]+Mh[i>>8&255]+Mh[i>>16&255]+Mh[i>>24&255]).toLowerCase()}function Ph(e,t,n){return Math.max(t,Math.min(n,e))}function Ch(e,t,n){return(1-n)*e+n*t}function Lh(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Ih(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}let Dh=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=Ph(this.x,e.x,t.x),this.y=Ph(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ph(this.x,e,t),this.y=Ph(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ph(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ph(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Nh=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,s){let o=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3],d=r[a+0],h=r[a+1],p=r[a+2],f=r[a+3];if(s<=0)return e[t+0]=o,e[t+1]=l,e[t+2]=c,void(e[t+3]=u);if(s>=1)return e[t+0]=d,e[t+1]=h,e[t+2]=p,void(e[t+3]=f);if(u!==f||o!==d||l!==h||c!==p){let e=o*d+l*h+c*p+u*f;e<0&&(d=-d,h=-h,p=-p,f=-f,e=-e);let t=1-s;if(e<.9995){const n=Math.acos(e),i=Math.sin(n);t=Math.sin(t*n)/i,o=o*t+d*(s=Math.sin(s*n)/i),l=l*t+h*s,c=c*t+p*s,u=u*t+f*s}else{o=o*t+d*s,l=l*t+h*s,c=c*t+p*s,u=u*t+f*s;const e=1/Math.sqrt(o*o+l*l+c*c+u*u);o*=e,l*=e,c*=e,u*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,a){const s=n[i],o=n[i+1],l=n[i+2],c=n[i+3],u=r[a],d=r[a+1],h=r[a+2],p=r[a+3];return e[t]=s*p+c*u+o*h-l*d,e[t+1]=o*p+c*d+l*u-s*h,e[t+2]=l*p+c*h+s*d-o*u,e[t+3]=c*p-s*u-o*d-l*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),c=s(i/2),u=s(r/2),d=o(n/2),h=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"YXZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"ZXY":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"ZYX":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"YZX":this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p;break;case"XZY":this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*p;break;default:_h("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],c=t[6],u=t[10],d=n+s+u;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>u){const e=2*Math.sqrt(1+n-s-u);this._w=(c-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>u){const e=2*Math.sqrt(1+s-n-u);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+u-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ph(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),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 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+a*s+i*l-r*o,this._y=i*c+a*o+r*s-n*l,this._z=r*c+a*l+n*o-i*s,this._w=a*c-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,i=e._y,r=e._z,a=e._w,s=this.dot(e);s<0&&(n=-n,i=-i,r=-r,a=-a,s=-s);let o=1-t;if(s<.9995){const e=Math.acos(s),l=Math.sin(e);o=Math.sin(o*e)/l,t=Math.sin(t*e)/l,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+a*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*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}},kh=class e{constructor(t=0,n=0,i=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=i}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Oh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Oh.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=2*(a*i-s*n),c=2*(s*t-r*i),u=2*(r*n-a*t);return this.x=t+o*l+a*u-s*c,this.y=n+o*c+s*l-r*u,this.z=i+o*u+r*c-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=Ph(this.x,e.x,t.x),this.y=Ph(this.y,e.y,t.y),this.z=Ph(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ph(this.x,e,t),this.y=Ph(this.y,e,t),this.z=Ph(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ph(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Fh.copy(this).projectOnVector(e),this.sub(Fh)}reflect(e){return this.sub(Fh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ph(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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=2*Math.random()-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const Fh=new kh,Oh=new Nh;class Uh{constructor(e,t,n,i,r,a,s,o,l){Uh.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=s,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],c=n[4],u=n[7],d=n[2],h=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],y=i[4],x=i[7],b=i[2],_=i[5],w=i[8];return r[0]=a*f+s*v+o*b,r[3]=a*m+s*y+o*_,r[6]=a*g+s*x+o*w,r[1]=l*f+c*v+u*b,r[4]=l*m+c*y+u*_,r[7]=l*g+c*x+u*w,r[2]=d*f+h*v+p*b,r[5]=d*m+h*y+p*_,r[8]=d*g+h*x+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8];return t*a*c-t*s*l-n*r*c+n*s*o+i*r*l-i*a*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],u=c*a-s*l,d=s*o-c*r,h=l*r-a*o,p=t*u+n*d+i*h;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=u*f,e[1]=(i*l-c*n)*f,e[2]=(s*n-i*a)*f,e[3]=d*f,e[4]=(c*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=h*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,s){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(zh.makeScale(e,t)),this}rotate(e){return this.premultiply(zh.makeRotation(-e)),this}translate(e,t){return this.premultiply(zh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const zh=new Uh,Bh=(new Uh).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Vh=(new Uh).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Hh(){const e={enabled:!0,workingColorSpace:th,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n?(this.spaces[t].transfer===ih&&(e.r=Wh(e.r),e.g=Wh(e.g),e.b=Wh(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===ih&&(e.r=jh(e.r),e.g=jh(e.g),e.b=jh(e.b)),e):e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===Jd?nh:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return Sh("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return Sh("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return e.define({[th]:{primaries:t,whitePoint:i,transfer:nh,toXYZ:Bh,fromXYZ:Vh,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:eh},outputColorSpaceConfig:{drawingBufferColorSpace:eh}},[eh]:{primaries:t,whitePoint:i,transfer:ih,toXYZ:Bh,fromXYZ:Vh,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:eh}}}),e}const Gh=Hh();function Wh(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function jh(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let Xh;class qh{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{void 0===Xh&&(Xh=vh("canvas")),Xh.width=e.width,Xh.height=e.height;const t=Xh.getContext("2d");e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Xh}return n.toDataURL(t)}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=vh("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e<r.length;e++)r[e]=255*Wh(r[e]/255);return n.putImageData(i,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*Wh(t[e]/255)):t[e]=Wh(t[e]);return{data:t,width:e.width,height:e.height}}return _h("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let $h=0;class Yh{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:$h++}),this.uuid=Rh(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):null!==t?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;t<n;t++)i[t].isDataTexture?e.push(Kh(i[t].image)):e.push(Kh(i[t]))}else e=Kh(i);n.url=e}return t||(e.images[this.uuid]=n),n}}function Kh(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?qh.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(_h("Texture: Unable to serialize Texture."),{})}let Qh=0;const Zh=new kh;class Jh extends Eh{constructor(e=Jh.DEFAULT_IMAGE,t=Jh.DEFAULT_MAPPING,n=1001,i=1001,r=1006,a=1008,s=1023,o=1009,l=Jh.DEFAULT_ANISOTROPY,c=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Qh++}),this.uuid=Rh(),this.name="",this.source=new Yh(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new Dh(0,0),this.repeat=new Dh(1,1),this.center=new Dh(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Uh,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Zh).x}get height(){return this.source.getSize(Zh).y}get depth(){return this.source.getSize(Zh).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(void 0===n){_h(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n:_h(`Texture.setValues(): property '${t}' does not exist.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Xu:e.x=e.x-Math.floor(e.x);break;case qu:e.x=e.x<0?0:1;break;case $u:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Xu:e.y=e.y-Math.floor(e.y);break;case qu:e.y=e.y<0?0:1;break;case $u:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}Jh.DEFAULT_IMAGE=null,Jh.DEFAULT_MAPPING=300,Jh.DEFAULT_ANISOTROPY=1;class ep{constructor(e=0,t=0,n=0,i=1){ep.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const a=.01,s=.1,o=e.elements,l=o[0],c=o[4],u=o[8],d=o[1],h=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-d)<a&&Math.abs(u-f)<a&&Math.abs(p-m)<a){if(Math.abs(c+d)<s&&Math.abs(u+f)<s&&Math.abs(p+m)<s&&Math.abs(l+h+g-3)<s)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,o=(h+1)/2,v=(g+1)/2,y=(c+d)/4,x=(u+f)/4,b=(p+m)/4;return e>o&&e>v?e<a?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(e),i=y/n,r=x/n):o>v?o<a?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),n=y/i,r=b/i):v<a?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),n=x/r,i=b/r),this.set(n,i,r,t),this}let v=Math.sqrt((m-p)*(m-p)+(u-f)*(u-f)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(u-f)/v,this.z=(d-c)/v,this.w=Math.acos((l+h+g-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=Ph(this.x,e.x,t.x),this.y=Ph(this.y,e.y,t.y),this.z=Ph(this.z,e.z,t.z),this.w=Ph(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ph(this.x,e,t),this.y=Ph(this.y,e,t),this.z=Ph(this.z,e,t),this.w=Ph(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ph(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class tp extends Eh{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Zu,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ep(0,0,e,t),this.scissorTest=!1,this.viewport=new ep(0,0,e,t);const i={width:e,height:t,depth:n.depth},r=new Jh(i);this.textures=[];const a=n.count;for(let e=0;e<a;e++)this.textures[e]=r.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:Zu,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==e.mapping&&(t.mapping=e.mapping),void 0!==e.wrapS&&(t.wrapS=e.wrapS),void 0!==e.wrapT&&(t.wrapT=e.wrapT),void 0!==e.wrapR&&(t.wrapR=e.wrapR),void 0!==e.magFilter&&(t.magFilter=e.magFilter),void 0!==e.minFilter&&(t.minFilter=e.minFilter),void 0!==e.format&&(t.format=e.format),void 0!==e.type&&(t.type=e.type),void 0!==e.anisotropy&&(t.anisotropy=e.anisotropy),void 0!==e.colorSpace&&(t.colorSpace=e.colorSpace),void 0!==e.flipY&&(t.flipY=e.flipY),void 0!==e.generateMipmaps&&(t.generateMipmaps=e.generateMipmaps),void 0!==e.internalFormat&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){this.textures[e].setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==e&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,!0!==this.textures[i].isData3DTexture&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const n=Object.assign({},e.textures[t].image);this.textures[t].source=new Yh(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class np extends tp{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class ip extends Jh{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Yu,this.minFilter=Yu,this.wrapR=qu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class rp extends Jh{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Yu,this.minFilter=Yu,this.wrapR=qu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ap{constructor(e=new kh(1/0,1/0,1/0),t=new kh(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(op.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(op.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=op.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===t&&void 0!==i&&!0!==e.isInstancedMesh)for(let t=0,n=i.count;t<n;t++)!0===e.isMesh?e.getVertexPosition(t,op):op.fromBufferAttribute(i,t),op.applyMatrix4(e.matrixWorld),this.expandByPoint(op);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),lp.copy(e.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),lp.copy(n.boundingBox)),lp.applyMatrix4(e.matrixWorld),this.union(lp)}const i=e.children;for(let e=0,n=i.length;e<n;e++)this.expandByObject(i[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,op),op.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(mp),gp.subVectors(this.max,mp),cp.subVectors(e.a,mp),up.subVectors(e.b,mp),dp.subVectors(e.c,mp),hp.subVectors(up,cp),pp.subVectors(dp,up),fp.subVectors(cp,dp);let t=[0,-hp.z,hp.y,0,-pp.z,pp.y,0,-fp.z,fp.y,hp.z,0,-hp.x,pp.z,0,-pp.x,fp.z,0,-fp.x,-hp.y,hp.x,0,-pp.y,pp.x,0,-fp.y,fp.x,0];return!!xp(t,cp,up,dp,gp)&&(t=[1,0,0,0,1,0,0,0,1],!!xp(t,cp,up,dp,gp)&&(vp.crossVectors(hp,pp),t=[vp.x,vp.y,vp.z],xp(t,cp,up,dp,gp)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,op).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(op).length()),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()||(sp[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),sp[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),sp[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),sp[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),sp[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),sp[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),sp[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),sp[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(sp)),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 sp=[new kh,new kh,new kh,new kh,new kh,new kh,new kh,new kh],op=new kh,lp=new ap,cp=new kh,up=new kh,dp=new kh,hp=new kh,pp=new kh,fp=new kh,mp=new kh,gp=new kh,vp=new kh,yp=new kh;function xp(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){yp.fromArray(e,a);const s=r.x*Math.abs(yp.x)+r.y*Math.abs(yp.y)+r.z*Math.abs(yp.z),o=t.dot(yp),l=n.dot(yp),c=i.dot(yp);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>s)return!1}return!0}const bp=new ap,_p=new kh,wp=new kh;class Sp{constructor(e=new kh,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):bp.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;t<r;t++)i=Math.max(i,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;_p.subVectors(e,this.center);const t=_p.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(_p,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(wp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(_p.copy(e.center).add(wp)),this.expandByPoint(_p.copy(e.center).sub(wp))),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 Ep=new kh,Mp=new kh,Tp=new kh,Ap=new kh,Rp=new kh,Pp=new kh,Cp=new kh;class Lp{constructor(e=new kh,t=new kh(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,Ep)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ep.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ep.copy(this.origin).addScaledVector(this.direction,t),Ep.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Mp.copy(e).add(t).multiplyScalar(.5),Tp.copy(t).sub(e).normalize(),Ap.copy(this.origin).sub(Mp);const r=.5*e.distanceTo(t),a=-this.direction.dot(Tp),s=Ap.dot(this.direction),o=-Ap.dot(Tp),l=Ap.lengthSq(),c=Math.abs(1-a*a);let u,d,h,p;if(c>0)if(u=a*o-s,d=a*s-o,p=r*c,u>=0)if(d>=-p)if(d<=p){const e=1/c;u*=e,d*=e,h=u*(u+a*d+2*s)+d*(a*u+d+2*o)+l}else d=r,u=Math.max(0,-(a*d+s)),h=-u*u+d*(d+2*o)+l;else d=-r,u=Math.max(0,-(a*d+s)),h=-u*u+d*(d+2*o)+l;else d<=-p?(u=Math.max(0,-(-a*r+s)),d=u>0?-r:Math.min(Math.max(-r,-o),r),h=-u*u+d*(d+2*o)+l):d<=p?(u=0,d=Math.min(Math.max(-r,-o),r),h=d*(d+2*o)+l):(u=Math.max(0,-(a*r+s)),d=u>0?r:Math.min(Math.max(-r,-o),r),h=-u*u+d*(d+2*o)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+s)),h=-u*u+d*(d+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Mp).addScaledVector(Tp,d),h}intersectSphere(e,t){Ep.subVectors(e.center,this.origin);const n=Ep.dot(this.direction),i=Ep.dot(Ep)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,s,o;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),c>=0?(r=(e.min.y-d.y)*c,a=(e.max.y-d.y)*c):(r=(e.max.y-d.y)*c,a=(e.min.y-d.y)*c),n>a||r>i?null:((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),u>=0?(s=(e.min.z-d.z)*u,o=(e.max.z-d.z)*u):(s=(e.max.z-d.z)*u,o=(e.min.z-d.z)*u),n>o||s>i?null:((s>n||n!=n)&&(n=s),(o<i||i!=i)&&(i=o),i<0?null:this.at(n>=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Ep)}intersectTriangle(e,t,n,i,r){Rp.subVectors(t,e),Pp.subVectors(n,e),Cp.crossVectors(Rp,Pp);let a,s=this.direction.dot(Cp);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}Ap.subVectors(this.origin,e);const o=a*this.direction.dot(Pp.crossVectors(Ap,Pp));if(o<0)return null;const l=a*this.direction.dot(Rp.cross(Ap));if(l<0)return null;if(o+l>s)return null;const c=-a*Ap.dot(Cp);return c<0?null:this.at(c/s,r)}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 Ip{constructor(e,t,n,i,r,a,s,o,l,c,u,d,h,p,f,m){Ip.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l,c,u,d,h,p,f,m)}set(e,t,n,i,r,a,s,o,l,c,u,d,h,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=c,g[10]=u,g[14]=d,g[3]=h,g[7]=p,g[11]=f,g[15]=m,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 Ip).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Dp.setFromMatrixColumn(e,0).length(),r=1/Dp.setFromMatrixColumn(e,1).length(),a=1/Dp.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=a*c,n=a*u,i=s*c,r=s*u;t[0]=o*c,t[4]=-o*u,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){const e=o*c,n=o*u,i=l*c,r=l*u;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*u,t[5]=a*c,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){const e=o*c,n=o*u,i=l*c,r=l*u;t[0]=e-r*s,t[4]=-a*u,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*c,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){const e=a*c,n=a*u,i=s*c,r=s*u;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*u,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=r-e*u,t[8]=i*u+n,t[1]=u,t[5]=a*c,t[9]=-s*c,t[2]=-l*c,t[6]=n*u+i,t[10]=e-r*u}else if("XZY"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=-u,t[8]=l*c,t[1]=e*u+r,t[5]=a*c,t[9]=n*u-i,t[2]=i*u-n,t[6]=s*c,t[10]=r*u+e}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(kp,e,Fp)}lookAt(e,t,n){const i=this.elements;return zp.subVectors(e,t),0===zp.lengthSq()&&(zp.z=1),zp.normalize(),Op.crossVectors(n,zp),0===Op.lengthSq()&&(1===Math.abs(n.z)?zp.x+=1e-4:zp.z+=1e-4,zp.normalize(),Op.crossVectors(n,zp)),Op.normalize(),Up.crossVectors(zp,Op),i[0]=Op.x,i[4]=Up.x,i[8]=zp.x,i[1]=Op.y,i[5]=Up.y,i[9]=zp.y,i[2]=Op.z,i[6]=Up.z,i[10]=zp.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],c=n[1],u=n[5],d=n[9],h=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],x=n[11],b=n[15],_=i[0],w=i[4],S=i[8],E=i[12],M=i[1],T=i[5],A=i[9],R=i[13],P=i[2],C=i[6],L=i[10],I=i[14],D=i[3],N=i[7],k=i[11],F=i[15];return r[0]=a*_+s*M+o*P+l*D,r[4]=a*w+s*T+o*C+l*N,r[8]=a*S+s*A+o*L+l*k,r[12]=a*E+s*R+o*I+l*F,r[1]=c*_+u*M+d*P+h*D,r[5]=c*w+u*T+d*C+h*N,r[9]=c*S+u*A+d*L+h*k,r[13]=c*E+u*R+d*I+h*F,r[2]=p*_+f*M+m*P+g*D,r[6]=p*w+f*T+m*C+g*N,r[10]=p*S+f*A+m*L+g*k,r[14]=p*E+f*R+m*I+g*F,r[3]=v*_+y*M+x*P+b*D,r[7]=v*w+y*T+x*C+b*N,r[11]=v*S+y*A+x*L+b*k,r[15]=v*E+y*R+x*I+b*F,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],c=e[2],u=e[6],d=e[10],h=e[14];return e[3]*(+r*o*u-i*l*u-r*s*d+n*l*d+i*s*h-n*o*h)+e[7]*(+t*o*h-t*l*d+r*a*d-i*a*h+i*l*c-r*o*c)+e[11]*(+t*l*u-t*s*h-r*a*u+n*a*h+r*s*c-n*l*c)+e[15]*(-i*s*c-t*o*u+t*s*d+i*a*u-n*a*d+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=u*m*l-f*d*l+f*o*h-s*m*h-u*o*g+s*d*g,y=p*d*l-c*m*l-p*o*h+a*m*h+c*o*g-a*d*g,x=c*f*l-p*u*l+p*s*h-a*f*h-c*s*g+a*u*g,b=p*u*o-c*f*o-p*s*d+a*f*d+c*s*m-a*u*m,_=t*v+n*y+i*x+r*b;if(0===_)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/_;return e[0]=v*w,e[1]=(f*d*r-u*m*r-f*i*h+n*m*h+u*i*g-n*d*g)*w,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*w,e[3]=(u*o*r-s*d*r-u*i*l+n*d*l+s*i*h-n*o*h)*w,e[4]=y*w,e[5]=(c*m*r-p*d*r+p*i*h-t*m*h-c*i*g+t*d*g)*w,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*w,e[7]=(a*d*r-c*o*r+c*i*l-t*d*l-a*i*h+t*o*h)*w,e[8]=x*w,e[9]=(p*u*r-c*f*r-p*n*h+t*f*h+c*n*g-t*u*g)*w,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*w,e[11]=(c*s*r-a*u*r-c*n*l+t*u*l+a*n*h-t*s*h)*w,e[12]=b*w,e[13]=(c*f*i-p*u*i+p*n*d-t*f*d-c*n*m+t*u*m)*w,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*w,e[15]=(a*u*i-c*s*i+c*n*o-t*u*o-a*n*d+t*s*d)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,c=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,c*s+n,c*o-i*a,0,l*o-i*s,c*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,c=a+a,u=s+s,d=r*l,h=r*c,p=r*u,f=a*c,m=a*u,g=s*u,v=o*l,y=o*c,x=o*u,b=n.x,_=n.y,w=n.z;return i[0]=(1-(f+g))*b,i[1]=(h+x)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(h-x)*_,i[5]=(1-(d+g))*_,i[6]=(m+v)*_,i[7]=0,i[8]=(p+y)*w,i[9]=(m-v)*w,i[10]=(1-(d+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Dp.set(i[0],i[1],i[2]).length();const a=Dp.set(i[4],i[5],i[6]).length(),s=Dp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Np.copy(this);const o=1/r,l=1/a,c=1/s;return Np.elements[0]*=o,Np.elements[1]*=o,Np.elements[2]*=o,Np.elements[4]*=l,Np.elements[5]*=l,Np.elements[6]*=l,Np.elements[8]*=c,Np.elements[9]*=c,Np.elements[10]*=c,t.setFromRotationMatrix(Np),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=2e3,o=!1){const l=this.elements,c=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),h=(n+i)/(n-i);let p,f;if(o)p=r/(a-r),f=a*r/(a-r);else if(s===fh)p=-(a+r)/(a-r),f=-2*a*r/(a-r);else{if(s!==mh)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);p=-a/(a-r),f=-a*r/(a-r)}return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=2e3,o=!1){const l=this.elements,c=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),h=-(n+i)/(n-i);let p,f;if(o)p=1/(a-r),f=a/(a-r);else if(s===fh)p=-2/(a-r),f=-(a+r)/(a-r);else{if(s!==mh)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=-1/(a-r),f=-r/(a-r)}return l[0]=c,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=h,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Dp=new kh,Np=new Ip,kp=new kh(0,0,0),Fp=new kh(1,1,1),Op=new kh,Up=new kh,zp=new kh,Bp=new Ip,Vp=new Nh;class Hp{constructor(e=0,t=0,n=0,i=Hp.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],c=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":this._y=Math.asin(Ph(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,h),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ph(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,h),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ph(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,h),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Ph(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,h),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ph(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(s,h));break;case"XZY":this._z=Math.asin(-Ph(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,h),this._y=0);break;default:_h("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Bp.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Bp,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Vp.setFromEuler(this),this.setFromQuaternion(Vp,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],void 0!==e[3]&&(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}}Hp.DEFAULT_ORDER="XYZ";class Gp{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return 0!==(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}}let Wp=0;const jp=new kh,Xp=new Nh,qp=new Ip,$p=new kh,Yp=new kh,Kp=new kh,Qp=new Nh,Zp=new kh(1,0,0),Jp=new kh(0,1,0),ef=new kh(0,0,1),tf={type:"added"},nf={type:"removed"},rf={type:"childadded",child:null},af={type:"childremoved",child:null};class sf extends Eh{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Wp++}),this.uuid=Rh(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=sf.DEFAULT_UP.clone();const e=new kh,t=new Hp,n=new Nh,i=new kh(1,1,1);t._onChange(function(){n.setFromEuler(t,!1)}),n._onChange(function(){t.setFromQuaternion(n,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ip},normalMatrix:{value:new Uh}}),this.matrix=new Ip,this.matrixWorld=new Ip,this.matrixAutoUpdate=sf.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=sf.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Gp,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Xp.setFromAxisAngle(e,t),this.quaternion.multiply(Xp),this}rotateOnWorldAxis(e,t){return Xp.setFromAxisAngle(e,t),this.quaternion.premultiply(Xp),this}rotateX(e){return this.rotateOnAxis(Zp,e)}rotateY(e){return this.rotateOnAxis(Jp,e)}rotateZ(e){return this.rotateOnAxis(ef,e)}translateOnAxis(e,t){return jp.copy(e).applyQuaternion(this.quaternion),this.position.add(jp.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Zp,e)}translateY(e){return this.translateOnAxis(Jp,e)}translateZ(e){return this.translateOnAxis(ef,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(qp.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?$p.copy(e):$p.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Yp.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?qp.lookAt(Yp,$p,this.up):qp.lookAt($p,Yp,this.up),this.quaternion.setFromRotationMatrix(qp),i&&(qp.extractRotation(i.matrixWorld),Xp.setFromRotationMatrix(qp),this.quaternion.premultiply(Xp.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(wh("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(tf),rf.child=e,this.dispatchEvent(rf),rf.child=null):wh("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(nf),af.child=e,this.dispatchEvent(af),af.child=null),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),qp.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),qp.multiply(e.parent.matrixWorld)),e.applyMatrix4(qp),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(tf),rf.child=e,this.dispatchEvent(rf),rf.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(e,t);if(void 0!==i)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Yp,e,Kp),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Yp,Qp,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){t[n].updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===t){const e=this.children;for(let t=0,n=e.length;t<n;t++){e[t].updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};function r(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(e=>({...e})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const i=n[t];r(e.shapes,i)}else r(e.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,i=this.material.length;n<i;n++)t.push(r(e.materials,this.material[n]));i.material=t}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];i.animations.push(r(e.animations,n))}}if(t){const t=a(e.geometries),i=a(e.materials),r=a(e.textures),s=a(e.images),o=a(e.shapes),l=a(e.skeletons),c=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=i,n;function a(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}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)),!0===t)for(let t=0;t<e.children.length;t++){const n=e.children[t];this.add(n.clone())}return this}}sf.DEFAULT_UP=new kh(0,1,0),sf.DEFAULT_MATRIX_AUTO_UPDATE=!0,sf.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const of=new kh,lf=new kh,cf=new kh,uf=new kh,df=new kh,hf=new kh,pf=new kh,ff=new kh,mf=new kh,gf=new kh,vf=new ep,yf=new ep,xf=new ep;class bf{constructor(e=new kh,t=new kh,n=new kh){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),of.subVectors(e,t),i.cross(of);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){of.subVectors(i,t),lf.subVectors(n,t),cf.subVectors(e,t);const a=of.dot(of),s=of.dot(lf),o=of.dot(cf),l=lf.dot(lf),c=lf.dot(cf),u=a*l-s*s;if(0===u)return r.set(0,0,0),null;const d=1/u,h=(l*o-s*c)*d,p=(a*c-s*o)*d;return r.set(1-h-p,p,h)}static containsPoint(e,t,n,i){return null!==this.getBarycoord(e,t,n,i,uf)&&(uf.x>=0&&uf.y>=0&&uf.x+uf.y<=1)}static getInterpolation(e,t,n,i,r,a,s,o){return null===this.getBarycoord(e,t,n,i,uf)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,uf.x),o.addScaledVector(a,uf.y),o.addScaledVector(s,uf.z),o)}static getInterpolatedAttribute(e,t,n,i,r,a){return vf.setScalar(0),yf.setScalar(0),xf.setScalar(0),vf.fromBufferAttribute(e,t),yf.fromBufferAttribute(e,n),xf.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(vf,r.x),a.addScaledVector(yf,r.y),a.addScaledVector(xf,r.z),a}static isFrontFacing(e,t,n,i){return of.subVectors(n,t),lf.subVectors(e,t),of.cross(lf).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 of.subVectors(this.c,this.b),lf.subVectors(this.a,this.b),.5*of.cross(lf).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return bf.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return bf.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return bf.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return bf.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return bf.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,s;df.subVectors(i,n),hf.subVectors(r,n),ff.subVectors(e,n);const o=df.dot(ff),l=hf.dot(ff);if(o<=0&&l<=0)return t.copy(n);mf.subVectors(e,i);const c=df.dot(mf),u=hf.dot(mf);if(c>=0&&u<=c)return t.copy(i);const d=o*u-c*l;if(d<=0&&o>=0&&c<=0)return a=o/(o-c),t.copy(n).addScaledVector(df,a);gf.subVectors(e,r);const h=df.dot(gf),p=hf.dot(gf);if(p>=0&&h<=p)return t.copy(r);const f=h*l-o*p;if(f<=0&&l>=0&&p<=0)return s=l/(l-p),t.copy(n).addScaledVector(hf,s);const m=c*p-h*u;if(m<=0&&u-c>=0&&h-p>=0)return pf.subVectors(r,i),s=(u-c)/(u-c+(h-p)),t.copy(i).addScaledVector(pf,s);const g=1/(m+f+d);return a=f*g,s=d*g,t.copy(n).addScaledVector(df,a).addScaledVector(hf,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const _f={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},wf={h:0,s:0,l:0},Sf={h:0,s:0,l:0};function Ef(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class Mf{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=eh){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Gh.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Gh.workingColorSpace){return this.r=e,this.g=t,this.b=n,Gh.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Gh.workingColorSpace){if(e=function(e,t){return(e%t+t)%t}(e,1),t=Ph(t,0,1),n=Ph(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=Ef(r,i,e+1/3),this.g=Ef(r,i,e),this.b=Ef(r,i,e-1/3)}return Gh.colorSpaceToWorking(this,i),this}setStyle(e,t=eh){function n(t){void 0!==t&&parseFloat(t)<1&&_h("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:_h("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);_h("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=eh){const n=_f[e.toLowerCase()];return void 0!==n?this.setHex(n,t):_h("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=Wh(e.r),this.g=Wh(e.g),this.b=Wh(e.b),this}copyLinearToSRGB(e){return this.r=jh(e.r),this.g=jh(e.g),this.b=jh(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=eh){return Gh.workingToColorSpace(Tf.copy(this),e),65536*Math.round(Ph(255*Tf.r,0,255))+256*Math.round(Ph(255*Tf.g,0,255))+Math.round(Ph(255*Tf.b,0,255))}getHexString(e=eh){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Gh.workingColorSpace){Gh.workingToColorSpace(Tf.copy(this),t);const n=Tf.r,i=Tf.g,r=Tf.b,a=Math.max(n,i,r),s=Math.min(n,i,r);let o,l;const c=(s+a)/2;if(s===a)o=0,l=0;else{const e=a-s;switch(l=c<=.5?e/(a+s):e/(2-a-s),a){case n:o=(i-r)/e+(i<r?6:0);break;case i:o=(r-n)/e+2;break;case r:o=(n-i)/e+4}o/=6}return e.h=o,e.s=l,e.l=c,e}getRGB(e,t=Gh.workingColorSpace){return Gh.workingToColorSpace(Tf.copy(this),t),e.r=Tf.r,e.g=Tf.g,e.b=Tf.b,e}getStyle(e=eh){Gh.workingToColorSpace(Tf.copy(this),e);const t=Tf.r,n=Tf.g,i=Tf.b;return e!==eh?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(e,t,n){return this.getHSL(wf),this.setHSL(wf.h+e,wf.s+t,wf.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(wf),e.getHSL(Sf);const n=Ch(wf.h,Sf.h,t),i=Ch(wf.s,Sf.s,t),r=Ch(wf.l,Sf.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Tf=new Mf;Mf.NAMES=_f;let Af=0;class Rf extends Eh{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Af++}),this.uuid=Rh(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=vu,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mf(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=rh,this.stencilZFail=rh,this.stencilZPass=rh,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){_h(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:_h(`Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==vu&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==rh&&(n.stencilFail=this.stencilFail),this.stencilZFail!==rh&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==rh&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}class Pf extends Rf{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mf(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 Hp,this.combine=0,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 Cf=new kh,Lf=new Dh;let If=0;class Df{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:If++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=od,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)Lf.fromBufferAttribute(this,t),Lf.applyMatrix3(e),this.setXY(t,Lf.x,Lf.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)Cf.fromBufferAttribute(this,t),Cf.applyMatrix3(e),this.setXYZ(t,Cf.x,Cf.y,Cf.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Cf.fromBufferAttribute(this,t),Cf.applyMatrix4(e),this.setXYZ(t,Cf.x,Cf.y,Cf.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Cf.fromBufferAttribute(this,t),Cf.applyNormalMatrix(e),this.setXYZ(t,Cf.x,Cf.y,Cf.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Cf.fromBufferAttribute(this,t),Cf.transformDirection(e),this.setXYZ(t,Cf.x,Cf.y,Cf.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Lh(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Ih(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Lh(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ih(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Lh(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ih(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Lh(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ih(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Lh(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ih(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Ih(t,this.array),n=Ih(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Ih(t,this.array),n=Ih(n,this.array),i=Ih(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=Ih(t,this.array),n=Ih(n,this.array),i=Ih(i,this.array),r=Ih(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),35044!==this.usage&&(e.usage=this.usage),e}}class Nf extends Df{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class kf extends Df{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Ff extends Df{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Of=0;const Uf=new Ip,zf=new sf,Bf=new kh,Vf=new ap,Hf=new ap,Gf=new kh;class Wf extends Eh{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Of++}),this.uuid=Rh(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(gh(e)?kf:Nf)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new Uh).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return Uf.makeRotationFromQuaternion(e),this.applyMatrix4(Uf),this}rotateX(e){return Uf.makeRotationX(e),this.applyMatrix4(Uf),this}rotateY(e){return Uf.makeRotationY(e),this.applyMatrix4(Uf),this}rotateZ(e){return Uf.makeRotationZ(e),this.applyMatrix4(Uf),this}translate(e,t,n){return Uf.makeTranslation(e,t,n),this.applyMatrix4(Uf),this}scale(e,t,n){return Uf.makeScale(e,t,n),this.applyMatrix4(Uf),this}lookAt(e){return zf.lookAt(e),zf.updateMatrix(),this.applyMatrix4(zf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Bf).negate(),this.translate(Bf.x,Bf.y,Bf.z),this}setFromPoints(e){const t=this.getAttribute("position");if(void 0===t){const t=[];for(let n=0,i=e.length;n<i;n++){const i=e[n];t.push(i.x,i.y,i.z||0)}this.setAttribute("position",new Ff(t,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const n=e[i];t.setXYZ(i,n.x,n.y,n.z||0)}e.length>t.count&&_h("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new ap);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return wh("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new kh(-1/0,-1/0,-1/0),new kh(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];Vf.setFromBufferAttribute(n),this.morphTargetsRelative?(Gf.addVectors(this.boundingBox.min,Vf.min),this.boundingBox.expandByPoint(Gf),Gf.addVectors(this.boundingBox.max,Vf.max),this.boundingBox.expandByPoint(Gf)):(this.boundingBox.expandByPoint(Vf.min),this.boundingBox.expandByPoint(Vf.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&wh('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sp);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return wh("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new kh,1/0);if(e){const n=this.boundingSphere.center;if(Vf.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];Hf.setFromBufferAttribute(n),this.morphTargetsRelative?(Gf.addVectors(Vf.min,Hf.min),Vf.expandByPoint(Gf),Gf.addVectors(Vf.max,Hf.max),Vf.expandByPoint(Gf)):(Vf.expandByPoint(Hf.min),Vf.expandByPoint(Hf.max))}Vf.getCenter(n);let i=0;for(let t=0,r=e.count;t<r;t++)Gf.fromBufferAttribute(e,t),i=Math.max(i,n.distanceToSquared(Gf));if(t)for(let r=0,a=t.length;r<a;r++){const a=t[r],s=this.morphTargetsRelative;for(let t=0,r=a.count;t<r;t++)Gf.fromBufferAttribute(a,t),s&&(Bf.fromBufferAttribute(e,t),Gf.add(Bf)),i=Math.max(i,n.distanceToSquared(Gf))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&wh('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void wh("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=t.position,i=t.normal,r=t.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Df(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),s=[],o=[];for(let e=0;e<n.count;e++)s[e]=new kh,o[e]=new kh;const l=new kh,c=new kh,u=new kh,d=new Dh,h=new Dh,p=new Dh,f=new kh,m=new kh;function g(e,t,i){l.fromBufferAttribute(n,e),c.fromBufferAttribute(n,t),u.fromBufferAttribute(n,i),d.fromBufferAttribute(r,e),h.fromBufferAttribute(r,t),p.fromBufferAttribute(r,i),c.sub(l),u.sub(l),h.sub(d),p.sub(d);const a=1/(h.x*p.y-p.x*h.y);isFinite(a)&&(f.copy(c).multiplyScalar(p.y).addScaledVector(u,-h.y).multiplyScalar(a),m.copy(u).multiplyScalar(h.x).addScaledVector(c,-p.x).multiplyScalar(a),s[e].add(f),s[t].add(f),s[i].add(f),o[e].add(m),o[t].add(m),o[i].add(m))}let v=this.groups;0===v.length&&(v=[{start:0,count:e.count}]);for(let t=0,n=v.length;t<n;++t){const n=v[t],i=n.start;for(let t=i,r=i+n.count;t<r;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}const y=new kh,x=new kh,b=new kh,_=new kh;function w(e){b.fromBufferAttribute(i,e),_.copy(b);const t=s[e];y.copy(t),y.sub(b.multiplyScalar(b.dot(t))).normalize(),x.crossVectors(_,t);const n=x.dot(o[e])<0?-1:1;a.setXYZW(e,y.x,y.y,y.z,n)}for(let t=0,n=v.length;t<n;++t){const n=v[t],i=n.start;for(let t=i,r=i+n.count;t<r;t+=3)w(e.getX(t+0)),w(e.getX(t+1)),w(e.getX(t+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new Df(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const i=new kh,r=new kh,a=new kh,s=new kh,o=new kh,l=new kh,c=new kh,u=new kh;if(e)for(let d=0,h=e.count;d<h;d+=3){const h=e.getX(d+0),p=e.getX(d+1),f=e.getX(d+2);i.fromBufferAttribute(t,h),r.fromBufferAttribute(t,p),a.fromBufferAttribute(t,f),c.subVectors(a,r),u.subVectors(i,r),c.cross(u),s.fromBufferAttribute(n,h),o.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),s.add(c),o.add(c),l.add(c),n.setXYZ(h,s.x,s.y,s.z),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,s=t.count;e<s;e+=3)i.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),c.subVectors(a,r),u.subVectors(i,r),c.cross(u),n.setXYZ(e+0,c.x,c.y,c.z),n.setXYZ(e+1,c.x,c.y,c.z),n.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gf.fromBufferAttribute(e,t),Gf.normalize(),e.setXYZ(t,Gf.x,Gf.y,Gf.z)}toNonIndexed(){function e(e,t){const n=e.array,i=e.itemSize,r=e.normalized,a=new n.constructor(t.length*i);let s=0,o=0;for(let r=0,l=t.length;r<l;r++){s=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*i;for(let e=0;e<i;e++)a[o++]=n[s++]}return new Df(a,i,r)}if(null===this.index)return _h("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Wf,n=this.index.array,i=this.attributes;for(const r in i){const a=e(i[r],n);t.setAttribute(r,a)}const r=this.morphAttributes;for(const i in r){const a=[],s=r[i];for(let t=0,i=s.length;t<i;t++){const i=e(s[t],n);a.push(i)}t.morphAttributes[i]=a}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let e=0,n=a.length;e<n;e++){const n=a[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t<i;t++){const i=n[t];a.push(i.toJSON(e.data))}a.length>0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const s=this.boundingSphere;return null!==s&&(e.data.boundingSphere=s.toJSON()),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone());const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e<r;e++)n.push(i[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let e=0,t=a.length;e<t;e++){const t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}const s=e.boundingBox;null!==s&&(this.boundingBox=s.clone());const o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const jf=new Ip,Xf=new Lp,qf=new Sp,$f=new kh,Yf=new kh,Kf=new kh,Qf=new kh,Zf=new kh,Jf=new kh,em=new kh,tm=new kh;class nm extends sf{constructor(e=new Wf,t=new Pf){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const s=this.morphTargetInfluences;if(r&&s){Jf.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=s[n],o=r[n];0!==i&&(Zf.fromBufferAttribute(o,e),a?Jf.addScaledVector(Zf,i):Jf.addScaledVector(Zf.sub(t),i))}t.add(Jf)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),qf.copy(n.boundingSphere),qf.applyMatrix4(r),Xf.copy(e.ray).recast(e.near),!1===qf.containsPoint(Xf.origin)){if(null===Xf.intersectSphere(qf,$f))return;if(Xf.origin.distanceToSquared($f)>(e.far-e.near)**2)return}jf.copy(r).invert(),Xf.copy(e.ray).applyMatrix4(jf),null!==n.boundingBox&&!1===Xf.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,Xf)}}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,u=r.attributes.normal,d=r.groups,h=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=d.length;r<o;r++){const o=d[r],p=a[o.materialIndex];for(let r=Math.max(o.start,h.start),a=Math.min(s.count,Math.min(o.start+o.count,h.start+h.count));r<a;r+=3){i=im(this,p,e,n,l,c,u,s.getX(r),s.getX(r+1),s.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,t.push(i))}}else{for(let r=Math.max(0,h.start),o=Math.min(s.count,h.start+h.count);r<o;r+=3){i=im(this,a,e,n,l,c,u,s.getX(r),s.getX(r+1),s.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),t.push(i))}}else if(void 0!==o)if(Array.isArray(a))for(let r=0,s=d.length;r<s;r++){const s=d[r],p=a[s.materialIndex];for(let r=Math.max(s.start,h.start),a=Math.min(o.count,Math.min(s.start+s.count,h.start+h.count));r<a;r+=3){i=im(this,p,e,n,l,c,u,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=s.materialIndex,t.push(i))}}else{for(let r=Math.max(0,h.start),s=Math.min(o.count,h.start+h.count);r<s;r+=3){i=im(this,a,e,n,l,c,u,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),t.push(i))}}}}function im(e,t,n,i,r,a,s,o,l,c){e.getVertexPosition(o,Yf),e.getVertexPosition(l,Kf),e.getVertexPosition(c,Qf);const u=function(e,t,n,i,r,a,s,o){let l;if(l=1===t.side?i.intersectTriangle(s,a,r,!0,o):i.intersectTriangle(r,a,s,0===t.side,o),null===l)return null;tm.copy(o),tm.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(tm);return c<n.near||c>n.far?null:{distance:c,point:tm.clone(),object:e}}(e,t,n,i,Yf,Kf,Qf,em);if(u){const e=new kh;bf.getBarycoord(em,Yf,Kf,Qf,e),r&&(u.uv=bf.getInterpolatedAttribute(r,o,l,c,e,new Dh)),a&&(u.uv1=bf.getInterpolatedAttribute(a,o,l,c,e,new Dh)),s&&(u.normal=bf.getInterpolatedAttribute(s,o,l,c,e,new kh),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const t={a:o,b:l,c:c,normal:new kh,materialIndex:0};bf.getNormal(Yf,Kf,Qf,t.normal),u.face=t,u.barycoord=e}return u}class rm extends Wf{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const o=[],l=[],c=[],u=[];let d=0,h=0;function p(e,t,n,i,r,a,p,f,m,g,v){const y=a/m,x=p/g,b=a/2,_=p/2,w=f/2,S=m+1,E=g+1;let M=0,T=0;const A=new kh;for(let a=0;a<E;a++){const s=a*x-_;for(let o=0;o<S;o++){const d=o*y-b;A[e]=d*i,A[t]=s*r,A[n]=w,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[n]=f>0?1:-1,c.push(A.x,A.y,A.z),u.push(o/m),u.push(1-a/g),M+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){const n=d+t+S*e,i=d+t+S*(e+1),r=d+(t+1)+S*(e+1),a=d+(t+1)+S*e;o.push(n,i,a),o.push(i,r,a),T+=6}s.addGroup(h,T,v),h+=T,d+=M}p("z","y","x",-1,-1,n,t,e,a,r,0),p("z","y","x",1,-1,n,t,-e,a,r,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(o),this.setAttribute("position",new Ff(l,3)),this.setAttribute("normal",new Ff(c,3)),this.setAttribute("uv",new Ff(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rm(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function am(e){const t={};for(const n in e){t[n]={};for(const i in e[n]){const r=e[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(_h("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][i]=null):t[n][i]=r.clone():Array.isArray(r)?t[n][i]=r.slice():t[n][i]=r}}return t}function sm(e){const t={};for(let n=0;n<e.length;n++){const i=am(e[n]);for(const e in i)t[e]=i[e]}return t}function om(e){const t=e.getRenderTarget();return null===t?e.outputColorSpace:!0===t.isXRRenderTarget?t.texture.colorSpace:Gh.workingColorSpace}const lm={clone:am,merge:sm};class cm extends Rf{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=am(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class um extends sf{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ip,this.projectionMatrix=new Ip,this.projectionMatrixInverse=new Ip,this.coordinateSystem=fh,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 dm=new kh,hm=new Dh,pm=new Dh;class fm extends um{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*Ah*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Th*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Ah*Math.atan(Math.tan(.5*Th*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){dm.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(dm.x,dm.y).multiplyScalar(-e/dm.z),dm.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(dm.x,dm.y).multiplyScalar(-e/dm.z)}getViewSize(e,t){return this.getViewBounds(e,hm,pm),t.subVectors(pm,hm)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Th*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}const s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const mm=-90;class gm extends sf{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new fm(mm,1,e,t);i.layers=this.layers,this.add(i);const r=new fm(mm,1,e,t);r.layers=this.layers,this.add(r);const a=new fm(mm,1,e,t);a.layers=this.layers,this.add(a);const s=new fm(mm,1,e,t);s.layers=this.layers,this.add(s);const o=new fm(mm,1,e,t);o.layers=this.layers,this.add(o);const l=new fm(mm,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(const e of t)this.remove(e);if(e===fh)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==mh)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,s,o,l,c]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),h=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,s),e.setRenderTarget(n,3,i),e.render(t,o),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),e.render(t,c),e.setRenderTarget(u,d,h),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class vm extends Jh{constructor(e=[],t=301,n,i,r,a,s,o,l,c){super(e,t,n,i,r,a,s,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class ym extends np{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new vm(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new rm(5,5,5),r=new cm({name:"CubemapFromEquirect",uniforms:am(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;const a=new nm(i,r),s=t.minFilter;t.minFilter===ed&&(t.minFilter=Zu);return new gm(1,10,this).update(e,a),t.minFilter=s,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}class xm extends sf{constructor(){super(),this.isGroup=!0,this.type="Group"}}const bm={type:"move"};class _m{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new xm,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new xm,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new kh,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new kh),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new xm,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new kh,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new kh),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,a=null;const s=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){a=!0;for(const i of e.hand.values()){const e=t.getJointPose(i,n),r=this._getHandJoint(l,i);null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=e.radius),r.visible=null!==e}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],s=i.position.distanceTo(r.position),o=.02,c=.005;l.inputState.pinching&&s>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==s&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(bm)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new xm;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class wm extends sf{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 Hp,this.environmentIntensity=1,this.environmentRotation=new Hp,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(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),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Sm extends Jh{constructor(e=null,t=1,n=1,i,r,a,s,o,l=1003,c=1003,u,d){super(null,a,s,o,l,c,i,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Em=new kh,Mm=new kh,Tm=new Uh;class Am{constructor(e=new kh(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Em.subVectors(n,t).cross(Mm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Em),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Tm.getNormalMatrix(e),i=this.coplanarPoint(Em).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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 Rm=new Sp,Pm=new Dh(.5,.5),Cm=new kh;class Lm{constructor(e=new Am,t=new Am,n=new Am,i=new Am,r=new Am,a=new Am){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3,n=!1){const i=this.planes,r=e.elements,a=r[0],s=r[1],o=r[2],l=r[3],c=r[4],u=r[5],d=r[6],h=r[7],p=r[8],f=r[9],m=r[10],g=r[11],v=r[12],y=r[13],x=r[14],b=r[15];if(i[0].setComponents(l-a,h-c,g-p,b-v).normalize(),i[1].setComponents(l+a,h+c,g+p,b+v).normalize(),i[2].setComponents(l+s,h+u,g+f,b+y).normalize(),i[3].setComponents(l-s,h-u,g-f,b-y).normalize(),n)i[4].setComponents(o,d,m,x).normalize(),i[5].setComponents(l-o,h-d,g-m,b-x).normalize();else if(i[4].setComponents(l-o,h-d,g-m,b-x).normalize(),t===fh)i[5].setComponents(l+o,h+d,g+m,b+x).normalize();else{if(t!==mh)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);i[5].setComponents(o,d,m,x).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Rm.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Rm.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Rm)}intersectsSprite(e){Rm.center.set(0,0,0);const t=Pm.distanceTo(e.center);return Rm.radius=.7071067811865476+t,Rm.applyMatrix4(e.matrixWorld),this.intersectsSphere(Rm)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<i)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Cm.x=i.normal.x>0?e.max.x:e.min.x,Cm.y=i.normal.y>0?e.max.y:e.min.y,Cm.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Cm)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}class Im extends Rf{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Mf(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Dm=new kh,Nm=new kh,km=new Ip,Fm=new Lp,Om=new Sp,Um=new kh,zm=new kh;class Bm extends sf{constructor(e=new Wf,t=new Im){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,i=t.count;e<i;e++)Dm.fromBufferAttribute(t,e-1),Nm.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Dm.distanceTo(Nm);e.setAttribute("lineDistance",new Ff(n,1))}else _h("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Om.copy(n.boundingSphere),Om.applyMatrix4(i),Om.radius+=r,!1===e.ray.intersectsSphere(Om))return;km.copy(i).invert(),Fm.copy(e.ray).applyMatrix4(km);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=this.isLineSegments?2:1,c=n.index,u=n.attributes.position;if(null!==c){const n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){const n=c.getX(r),i=c.getX(r+1),a=Vm(this,e,Fm,o,n,i,r);a&&t.push(a)}if(this.isLineLoop){const r=c.getX(i-1),a=c.getX(n),s=Vm(this,e,Fm,o,r,a,i-1);s&&t.push(s)}}else{const n=Math.max(0,a.start),i=Math.min(u.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){const n=Vm(this,e,Fm,o,r,r+1,r);n&&t.push(n)}if(this.isLineLoop){const r=Vm(this,e,Fm,o,i-1,n,i-1);r&&t.push(r)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function Vm(e,t,n,i,r,a,s){const o=e.geometry.attributes.position;Dm.fromBufferAttribute(o,r),Nm.fromBufferAttribute(o,a);if(n.distanceSqToSegment(Dm,Nm,Um,zm)>i)return;Um.applyMatrix4(e.matrixWorld);const l=t.ray.origin.distanceTo(Um);return l<t.near||l>t.far?void 0:{distance:l,point:zm.clone().applyMatrix4(e.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:e}}const Hm=new kh,Gm=new kh;class Wm extends Bm{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;e<i;e+=2)Hm.fromBufferAttribute(t,e),Gm.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+Hm.distanceTo(Gm);e.setAttribute("lineDistance",new Ff(n,1))}else _h("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class jm extends Jh{constructor(e,t,n=1014,i,r,a,s=1003,o=1003,l,c=1026,u=1){if(c!==md&&c!==gd)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:u},i,r,a,s,o,c,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Yh(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class Xm extends Jh{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class qm extends Wf{constructor(e=1,t=1,n=1,i=32,r=1,a=!1,s=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],u=[],d=[],h=[];let p=0;const f=[],m=n/2;let g=0;function v(n){const r=p,a=new Dh,f=new kh;let v=0;const y=!0===n?e:t,x=!0===n?1:-1;for(let e=1;e<=i;e++)u.push(0,m*x,0),d.push(0,x,0),h.push(.5,.5),p++;const b=p;for(let e=0;e<=i;e++){const t=e/i*o+s,n=Math.cos(t),r=Math.sin(t);f.x=y*r,f.y=m*x,f.z=y*n,u.push(f.x,f.y,f.z),d.push(0,x,0),a.x=.5*n+.5,a.y=.5*r*x+.5,h.push(a.x,a.y),p++}for(let e=0;e<i;e++){const t=r+e,i=b+e;!0===n?c.push(i,i+1,t):c.push(i+1,i,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const a=new kh,v=new kh;let y=0;const x=(t-e)/n;for(let l=0;l<=r;l++){const c=[],g=l/r,y=g*(t-e)+e;for(let e=0;e<=i;e++){const t=e/i,r=t*o+s,l=Math.sin(r),f=Math.cos(r);v.x=y*l,v.y=-g*n+m,v.z=y*f,u.push(v.x,v.y,v.z),a.set(l,x,f).normalize(),d.push(a.x,a.y,a.z),h.push(t,1-g),c.push(p++)}f.push(c)}for(let n=0;n<i;n++)for(let i=0;i<r;i++){const a=f[i][n],s=f[i+1][n],o=f[i+1][n+1],l=f[i][n+1];(e>0||0!==i)&&(c.push(a,s,l),y+=3),(t>0||i!==r-1)&&(c.push(s,o,l),y+=3)}l.addGroup(g,y,0),g+=y}(),!1===a&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Ff(u,3)),this.setAttribute("normal",new Ff(d,3)),this.setAttribute("uv",new Ff(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qm(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class $m extends Wf{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function s(e,t,n,i){const r=i+1,a=[];for(let i=0;i<=r;i++){a[i]=[];const s=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)a[i][e]=0===e&&i===r?s:s.clone().lerp(o,e/l)}for(let e=0;e<r;e++)for(let t=0;t<2*(r-e)-1;t++){const n=Math.floor(t/2);t%2==0?(o(a[e][n+1]),o(a[e+1][n]),o(a[e][n])):(o(a[e][n+1]),o(a[e+1][n+1]),o(a[e+1][n]))}}function o(e){r.push(e.x,e.y,e.z)}function l(t,n){const i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function c(e,t,n,i){i<0&&1===e.x&&(a[t]=e.x-1),0===n.x&&0===n.z&&(a[t]=i/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}function d(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}!function(e){const n=new kh,i=new kh,r=new kh;for(let a=0;a<t.length;a+=3)l(t[a+0],n),l(t[a+1],i),l(t[a+2],r),s(n,i,r,e)}(i),function(e){const t=new kh;for(let n=0;n<r.length;n+=3)t.x=r[n+0],t.y=r[n+1],t.z=r[n+2],t.normalize().multiplyScalar(e),r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z}(n),function(){const e=new kh;for(let t=0;t<r.length;t+=3){e.x=r[t+0],e.y=r[t+1],e.z=r[t+2];const n=u(e)/2/Math.PI+.5,i=d(e)/Math.PI+.5;a.push(n,1-i)}(function(){const e=new kh,t=new kh,n=new kh,i=new kh,s=new Dh,o=new Dh,l=new Dh;for(let d=0,h=0;d<r.length;d+=9,h+=6){e.set(r[d+0],r[d+1],r[d+2]),t.set(r[d+3],r[d+4],r[d+5]),n.set(r[d+6],r[d+7],r[d+8]),s.set(a[h+0],a[h+1]),o.set(a[h+2],a[h+3]),l.set(a[h+4],a[h+5]),i.copy(e).add(t).add(n).divideScalar(3);const p=u(i);c(s,h+0,e,p),c(o,h+2,t,p),c(l,h+4,n,p)}})(),function(){for(let e=0;e<a.length;e+=6){const t=a[e+0],n=a[e+2],i=a[e+4],r=Math.max(t,n,i),s=Math.min(t,n,i);r>.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new Ff(r,3)),this.setAttribute("normal",new Ff(r.slice(),3)),this.setAttribute("uv",new Ff(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $m(e.vertices,e.indices,e.radius,e.details)}}class Ym extends $m{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ym(e.radius,e.detail)}}class Km extends Wf{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,s=Math.floor(n),o=Math.floor(i),l=s+1,c=o+1,u=e/s,d=t/o,h=[],p=[],f=[],m=[];for(let e=0;e<c;e++){const t=e*d-a;for(let n=0;n<l;n++){const i=n*u-r;p.push(i,-t,0),f.push(0,0,1),m.push(n/s),m.push(1-e/o)}}for(let e=0;e<o;e++)for(let t=0;t<s;t++){const n=t+l*e,i=t+l*(e+1),r=t+1+l*(e+1),a=t+1+l*e;h.push(n,i,a),h.push(i,r,a)}this.setIndex(h),this.setAttribute("position",new Ff(p,3)),this.setAttribute("normal",new Ff(f,3)),this.setAttribute("uv",new Ff(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Km(e.width,e.height,e.widthSegments,e.heightSegments)}}class Qm extends Wf{constructor(e=.5,t=1,n=32,i=1,r=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n);const s=[],o=[],l=[],c=[];let u=e;const d=(t-e)/(i=Math.max(1,i)),h=new kh,p=new Dh;for(let e=0;e<=i;e++){for(let e=0;e<=n;e++){const i=r+e/n*a;h.x=u*Math.cos(i),h.y=u*Math.sin(i),o.push(h.x,h.y,h.z),l.push(0,0,1),p.x=(h.x/t+1)/2,p.y=(h.y/t+1)/2,c.push(p.x,p.y)}u+=d}for(let e=0;e<i;e++){const t=e*(n+1);for(let e=0;e<n;e++){const i=e+t,r=i,a=i+n+1,o=i+n+2,l=i+1;s.push(r,a,l),s.push(a,o,l)}}this.setIndex(s),this.setAttribute("position",new Ff(o,3)),this.setAttribute("normal",new Ff(l,3)),this.setAttribute("uv",new Ff(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qm(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Zm extends Wf{constructor(e=1,t=32,n=16,i=0,r=2*Math.PI,a=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:s},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const o=Math.min(a+s,Math.PI);let l=0;const c=[],u=new kh,d=new kh,h=[],p=[],f=[],m=[];for(let h=0;h<=n;h++){const g=[],v=h/n;let y=0;0===h&&0===a?y=.5/t:h===n&&o===Math.PI&&(y=-.5/t);for(let n=0;n<=t;n++){const o=n/t;u.x=-e*Math.cos(i+o*r)*Math.sin(a+v*s),u.y=e*Math.cos(a+v*s),u.z=e*Math.sin(i+o*r)*Math.sin(a+v*s),p.push(u.x,u.y,u.z),d.copy(u).normalize(),f.push(d.x,d.y,d.z),m.push(o+y,1-v),g.push(l++)}c.push(g)}for(let e=0;e<n;e++)for(let i=0;i<t;i++){const t=c[e][i+1],r=c[e][i],s=c[e+1][i],l=c[e+1][i+1];(0!==e||a>0)&&h.push(t,r,l),(e!==n-1||o<Math.PI)&&h.push(r,s,l)}this.setIndex(h),this.setAttribute("position",new Ff(p,3)),this.setAttribute("normal",new Ff(f,3)),this.setAttribute("uv",new Ff(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zm(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Jm extends Wf{constructor(e=1,t=.4,n=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const a=[],s=[],o=[],l=[],c=new kh,u=new kh,d=new kh;for(let a=0;a<=n;a++)for(let h=0;h<=i;h++){const p=h/i*r,f=a/n*Math.PI*2;u.x=(e+t*Math.cos(f))*Math.cos(p),u.y=(e+t*Math.cos(f))*Math.sin(p),u.z=t*Math.sin(f),s.push(u.x,u.y,u.z),c.x=e*Math.cos(p),c.y=e*Math.sin(p),d.subVectors(u,c).normalize(),o.push(d.x,d.y,d.z),l.push(h/i),l.push(a/n)}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*e+t-1,r=(i+1)*(e-1)+t-1,s=(i+1)*(e-1)+t,o=(i+1)*e+t;a.push(n,r,o),a.push(r,s,o)}this.setIndex(a),this.setAttribute("position",new Ff(s,3)),this.setAttribute("normal",new Ff(o,3)),this.setAttribute("uv",new Ff(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jm(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class eg extends Rf{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,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 tg extends Rf{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 ng extends Rf{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Mf(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Dh(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 ig extends um{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,s=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}class rg extends fm{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const ag=new Ip;class sg{constructor(e,t,n=0,i=1/0){this.ray=new Lp(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Gp,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):wh("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return ag.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(ag),this}intersectObject(e,t=!0,n=[]){return lg(e,this,n,t),n.sort(og),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)lg(e[i],this,n,t);return n.sort(og),n}}function og(e,t){return e.distance-t.distance}function lg(e,t,n,i){let r=!0;if(e.layers.test(t.layers)){!1===e.raycast(t,n)&&(r=!1)}if(!0===r&&!0===i){const i=e.children;for(let e=0,r=i.length;e<r;e++)lg(i[e],t,n,!0)}}const cg=new kh,ug=new kh,dg=new kh,hg=new kh,pg=new kh,fg=new kh,mg=new kh;class gg extends Wm{constructor(e=10,t=10,n=4473924,i=8947848){n=new Mf(n),i=new Mf(i);const r=t/2,a=e/t,s=e/2,o=[],l=[];for(let e=0,c=0,u=-s;e<=t;e++,u+=a){o.push(-s,0,u,s,0,u),o.push(u,0,-s,u,0,s);const t=e===r?n:i;t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3}const c=new Wf;c.setAttribute("position",new Ff(o,3)),c.setAttribute("color",new Ff(l,3));super(c,new Im({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}function vg(e,t,n,i){const r=function(e){switch(e){case td:case nd:return{byteLength:1,components:1};case rd:case id:case ld:return{byteLength:2,components:1};case cd:case ud:return{byteLength:2,components:4};case sd:case ad:case od:return{byteLength:4,components:1};case hd:case pd:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${e}.`)}(i);switch(n){case 1021:return e*t;case 1028:case vd:return e*t/r.components*r.byteLength;case yd:case xd:return e*t*2/r.components*r.byteLength;case 1022:return e*t*3/r.components*r.byteLength;case fd:case bd:return e*t*4/r.components*r.byteLength;case _d:case wd:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Sd:case Ed:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Td:case Rd:return Math.max(e,16)*Math.max(t,8)/4;case Md:case Ad:return Math.max(e,8)*Math.max(t,8)/2;case Pd:case Cd:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Ld:case Id:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case Dd:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case Nd:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case kd:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case Fd:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case Od:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case Ud:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case zd:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case Bd:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case Vd:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case Hd:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case Gd:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case Wd:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case jd:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case Xd:case qd:case $d:return Math.ceil(e/4)*Math.ceil(t/4)*16;case Yd:case Kd:return Math.ceil(e/4)*Math.ceil(t/4)*8;case Qd:case Zd:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}
|
|
1040
|
-
/**
|
|
1041
|
-
* @license
|
|
1042
|
-
* Copyright 2010-2025 Three.js Authors
|
|
1043
|
-
* SPDX-License-Identifier: MIT
|
|
1044
|
-
*/
|
|
1045
|
-
function yg(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function xg(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const e=t.get(n);return void((!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const r=t.get(n);if(void 0===r)t.set(n,function(t,n){const i=t.array,r=t.usage,a=i.byteLength,s=e.createBuffer();let o;if(e.bindBuffer(n,s),e.bufferData(n,i,r),t.onUploadCallback(),i instanceof Float32Array)o=e.FLOAT;else if("undefined"!=typeof Float16Array&&i instanceof Float16Array)o=e.HALF_FLOAT;else if(i instanceof Uint16Array)o=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(i instanceof Int16Array)o=e.SHORT;else if(i instanceof Uint32Array)o=e.UNSIGNED_INT;else if(i instanceof Int32Array)o=e.INT;else if(i instanceof Int8Array)o=e.BYTE;else if(i instanceof Uint8Array)o=e.UNSIGNED_BYTE;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);o=e.UNSIGNED_BYTE}return{buffer:s,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version,size:a}}(n,i));else if(r.version<n.version){if(r.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(t,n,i){const r=n.array,a=n.updateRanges;if(e.bindBuffer(i,t),0===a.length)e.bufferSubData(i,0,r);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){const n=a[t],i=a[e];i.start<=n.start+n.count+1?n.count=Math.max(n.count,i.start+i.count-n.start):(++t,a[t]=i)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){const n=a[t];e.bufferSubData(i,n.start*r.BYTES_PER_ELEMENT,r,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(r.buffer,n,i),r.version=n.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:pu}})),"undefined"!=typeof window&&(window.__THREE__IWER__?_h("WARNING: Multiple instances of Three.js being imported."):window.__THREE__IWER__=pu);const bg={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn 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 );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid 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 ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 uv = vec2( roughness, dotNV );\n\treturn texture2D( dfgLUT, uv ).rg;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );\n\tvec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );\n\tvec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid 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 ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid 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 ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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 ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid 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) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\tfloat depth = unpackRGBAToDepth( texture2D( depths, uv ) );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\treturn step( depth, compare );\n\t\t#else\n\t\t\treturn step( compare, depth );\n\t\t#endif\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow( sampler2D shadow, vec2 uv, float compare ) {\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\tfloat hard_shadow = step( distribution.x, compare );\n\t\t#else\n\t\t\tfloat hard_shadow = step( compare, distribution.x );\n\t\t#endif\n\t\tif ( hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},_g={common:{diffuse:{value:new Mf(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Uh},alphaMap:{value:null},alphaMapTransform:{value:new Uh},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Uh}},envmap:{envMap:{value:null},envMapRotation:{value:new Uh},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 Uh}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Uh}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Uh},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Uh},normalScale:{value:new Dh(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Uh},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Uh}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Uh}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Uh}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Mf(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 Mf(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Uh},alphaTest:{value:0},uvTransform:{value:new Uh}},sprite:{diffuse:{value:new Mf(16777215)},opacity:{value:1},center:{value:new Dh(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Uh},alphaMap:{value:null},alphaMapTransform:{value:new Uh},alphaTest:{value:0}}},wg={basic:{uniforms:sm([_g.common,_g.specularmap,_g.envmap,_g.aomap,_g.lightmap,_g.fog]),vertexShader:bg.meshbasic_vert,fragmentShader:bg.meshbasic_frag},lambert:{uniforms:sm([_g.common,_g.specularmap,_g.envmap,_g.aomap,_g.lightmap,_g.emissivemap,_g.bumpmap,_g.normalmap,_g.displacementmap,_g.fog,_g.lights,{emissive:{value:new Mf(0)}}]),vertexShader:bg.meshlambert_vert,fragmentShader:bg.meshlambert_frag},phong:{uniforms:sm([_g.common,_g.specularmap,_g.envmap,_g.aomap,_g.lightmap,_g.emissivemap,_g.bumpmap,_g.normalmap,_g.displacementmap,_g.fog,_g.lights,{emissive:{value:new Mf(0)},specular:{value:new Mf(1118481)},shininess:{value:30}}]),vertexShader:bg.meshphong_vert,fragmentShader:bg.meshphong_frag},standard:{uniforms:sm([_g.common,_g.envmap,_g.aomap,_g.lightmap,_g.emissivemap,_g.bumpmap,_g.normalmap,_g.displacementmap,_g.roughnessmap,_g.metalnessmap,_g.fog,_g.lights,{emissive:{value:new Mf(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:bg.meshphysical_vert,fragmentShader:bg.meshphysical_frag},toon:{uniforms:sm([_g.common,_g.aomap,_g.lightmap,_g.emissivemap,_g.bumpmap,_g.normalmap,_g.displacementmap,_g.gradientmap,_g.fog,_g.lights,{emissive:{value:new Mf(0)}}]),vertexShader:bg.meshtoon_vert,fragmentShader:bg.meshtoon_frag},matcap:{uniforms:sm([_g.common,_g.bumpmap,_g.normalmap,_g.displacementmap,_g.fog,{matcap:{value:null}}]),vertexShader:bg.meshmatcap_vert,fragmentShader:bg.meshmatcap_frag},points:{uniforms:sm([_g.points,_g.fog]),vertexShader:bg.points_vert,fragmentShader:bg.points_frag},dashed:{uniforms:sm([_g.common,_g.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:bg.linedashed_vert,fragmentShader:bg.linedashed_frag},depth:{uniforms:sm([_g.common,_g.displacementmap]),vertexShader:bg.depth_vert,fragmentShader:bg.depth_frag},normal:{uniforms:sm([_g.common,_g.bumpmap,_g.normalmap,_g.displacementmap,{opacity:{value:1}}]),vertexShader:bg.meshnormal_vert,fragmentShader:bg.meshnormal_frag},sprite:{uniforms:sm([_g.sprite,_g.fog]),vertexShader:bg.sprite_vert,fragmentShader:bg.sprite_frag},background:{uniforms:{uvTransform:{value:new Uh},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:bg.background_vert,fragmentShader:bg.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Uh}},vertexShader:bg.backgroundCube_vert,fragmentShader:bg.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:bg.cube_vert,fragmentShader:bg.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:bg.equirect_vert,fragmentShader:bg.equirect_frag},distanceRGBA:{uniforms:sm([_g.common,_g.displacementmap,{referencePosition:{value:new kh},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:bg.distanceRGBA_vert,fragmentShader:bg.distanceRGBA_frag},shadow:{uniforms:sm([_g.lights,_g.fog,{color:{value:new Mf(0)},opacity:{value:1}}]),vertexShader:bg.shadow_vert,fragmentShader:bg.shadow_frag}};wg.physical={uniforms:sm([wg.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Uh},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Uh},clearcoatNormalScale:{value:new Dh(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Uh},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Uh},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Uh},sheen:{value:0},sheenColor:{value:new Mf(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Uh},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Uh},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Uh},transmissionSamplerSize:{value:new Dh},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Uh},attenuationDistance:{value:0},attenuationColor:{value:new Mf(0)},specularColor:{value:new Mf(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Uh},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Uh},anisotropyVector:{value:new Dh},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Uh}}]),vertexShader:bg.meshphysical_vert,fragmentShader:bg.meshphysical_frag};const Sg={r:0,b:0,g:0},Eg=new Hp,Mg=new Ip;function Tg(e,t,n,i,r,a,s){const o=new Mf(0);let l,c,u=!0===a?0:1,d=null,h=0,p=null;function f(e){let i=!0===e.isScene?e.background:null;if(i&&i.isTexture){i=(e.backgroundBlurriness>0?n:t).get(i)}return i}function m(t,n){t.getRGB(Sg,om(e)),i.buffers.color.setClear(Sg.r,Sg.g,Sg.b,n,s)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),u=t,m(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(e){u=e,m(o,u)},render:function(t){let n=!1;const r=f(t);null===r?m(o,u):r&&r.isColor&&(m(r,1),n=!0);const a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===ju)?(void 0===c&&(c=new nm(new rm(1e4,1e4,1e4),new cm({name:"BackgroundCubeMaterial",uniforms:am(wg.backgroundCube.uniforms),vertexShader:wg.backgroundCube.vertexShader,fragmentShader:wg.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),Eg.copy(n.backgroundRotation),Eg.x*=-1,Eg.y*=-1,Eg.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(Eg.y*=-1,Eg.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Mg.makeRotationFromEuler(Eg)),c.material.toneMapped=Gh.getTransfer(i.colorSpace)!==ih,d===i&&h===i.version&&p===e.toneMapping||(c.material.needsUpdate=!0,d=i,h=i.version,p=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new nm(new Km(2,2),new cm({name:"BackgroundMaterial",uniforms:am(wg.background.uniforms),vertexShader:wg.background.vertexShader,fragmentShader:wg.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=Gh.getTransfer(i.colorSpace)!==ih,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),d===i&&h===i.version&&p===e.toneMapping||(l.material.needsUpdate=!0,d=i,h=i.version,p=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==c&&(c.geometry.dispose(),c.material.dispose(),c=void 0),void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}}}function Ag(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=c(null);let a=r,s=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){const t=[],i=[],r=[];for(let e=0;e<n;e++)t[e]=0,i[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:r,object:e,attributes:{},index:null}}function u(){const e=a.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function d(e){h(e,0)}function h(t,n){const i=a.newAttributes,r=a.enabledAttributes,s=a.attributeDivisors;i[t]=1,0===r[t]&&(e.enableVertexAttribArray(t),r[t]=1),s[t]!==n&&(e.vertexAttribDivisor(t,n),s[t]=n)}function p(){const t=a.newAttributes,n=a.enabledAttributes;for(let i=0,r=n.length;i<r;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function f(t,n,i,r,a,s,o){!0===o?e.vertexAttribIPointer(t,n,i,a,s):e.vertexAttribPointer(t,n,i,r,a,s)}function m(){g(),s=!0,a!==r&&(a=r,o(a.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(n,r,l,m,g){let v=!1;const y=function(t,n,r){const a=!0===r.wireframe;let s=i[t.id];void 0===s&&(s={},i[t.id]=s);let o=s[n.id];void 0===o&&(o={},s[n.id]=o);let l=o[a];void 0===l&&(l=c(e.createVertexArray()),o[a]=l);return l}(m,l,r);a!==y&&(a=y,o(a.object)),v=function(e,t,n,i){const r=a.attributes,s=t.attributes;let o=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}}return a.attributesNum!==o||a.index!==i}(n,m,l,g),v&&function(e,t,n,i){const r={},s=t.attributes;let o=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,o++}}a.attributes=r,a.attributesNum=o,a.index=i}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(v||s)&&(s=!1,function(n,i,r,a){u();const s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,s=o.itemSize,l=t.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,p=l.bytesPerElement,m=u===e.INT||u===e.UNSIGNED_INT||o.gpuType===ad;if(o.isInterleavedBufferAttribute){const t=o.data,l=t.stride,g=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)h(r.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<r.locationSize;e++)d(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)f(r.location+e,s/r.locationSize,u,i,l*p,(g+s/r.locationSize*e)*p,m)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)h(r.location+e,o.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<r.locationSize;e++)d(r.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<r.locationSize;e++)f(r.location+e,s/r.locationSize,u,i,s*p,s/r.locationSize*e*p,m)}}else if(void 0!==l){const t=l[i];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(r.location,t);break;case 3:e.vertexAttrib3fv(r.location,t);break;case 4:e.vertexAttrib4fv(r.location,t);break;default:e.vertexAttrib1fv(r.location,t)}}}}p()}(n,r,l,m),null!==g&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const e in i){const t=i[e];for(const e in t){const n=t[e];for(const e in n)l(n[e].object),delete n[e];delete t[e]}delete i[e]}},releaseStatesOfGeometry:function(e){if(void 0===i[e.id])return;const t=i[e.id];for(const e in t){const n=t[e];for(const e in n)l(n[e].object),delete n[e];delete t[e]}delete i[e.id]},releaseStatesOfProgram:function(e){for(const t in i){const n=i[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)l(r[e].object),delete r[e];delete n[e.id]}},initAttributes:u,enableAttribute:d,disableUnusedAttributes:p}}function Rg(e,t,n){let i;function r(t,r,a){0!==a&&(e.drawArraysInstanced(i,t,r,a),n.update(r,i,a))}this.setMode=function(e){i=e},this.render=function(t,r){e.drawArrays(i,t,r),n.update(r,i,1)},this.renderInstances=r,this.renderMultiDraw=function(e,r,a){if(0===a)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,e,0,r,0,a);let s=0;for(let e=0;e<a;e++)s+=r[e];n.update(s,i,1)},this.renderMultiDrawInstances=function(e,a,s,o){if(0===s)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<e.length;t++)r(e[t],a[t],o[t]);else{l.multiDrawArraysInstancedWEBGL(i,e,0,a,0,o,0,s);let t=0;for(let e=0;e<s;e++)t+=a[e]*o[e];n.update(t,i,1)}}}function Pg(e,t,n,i){let r;function a(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp";const o=a(s);o!==s&&(_h("WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reversedDepthBuffer&&t.has("EXT_clip_control"),u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return t===fd||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===ld&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==td&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==od&&!r)},precision:s,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:u,maxVertexTextures:d,maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:d>0,maxSamples:e.getParameter(e.MAX_SAMPLES)}}function Cg(e){const t=this;let n=null,i=0,r=!1,a=!1;const s=new Am,o=new Uh,l={value:null,needsUpdate:!1};function c(e,n,i,r){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==a;++t,n+=4)s.copy(e[t]).applyMatrix4(r,o),s.normal.toArray(c,n),c[n+3]=s.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==i||r;return r=t,i=e.length,n},this.beginShadows=function(){a=!0,c(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=c(e,t,0)},this.setState=function(s,o,u){const d=s.clippingPlanes,h=s.clipIntersection,p=s.clipShadows,f=e.get(s);if(!r||null===d||0===d.length||a&&!p)a?c(null):function(){l.value!==n&&(l.value=n,l.needsUpdate=i>0);t.numPlanes=i,t.numIntersection=0}();else{const e=a?0:i,t=4*e;let r=f.clippingState||null;l.value=r,r=c(d,o,t,u);for(let e=0;e!==t;++e)r[e]=n[e];f.clippingState=r,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=e}}}function Lg(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=Gu:304===t&&(e.mapping=Wu),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping;if(303===a||304===a){if(t.has(r)){return n(t.get(r).texture,r.mapping)}{const a=r.image;if(a&&a.height>0){const s=new ym(a.height);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}const Ig=[.125,.215,.35,.446,.526,.582],Dg=20,Ng=new ig,kg=new Mf;let Fg=null,Og=0,Ug=0,zg=!1;const Bg=new kh;class Vg{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:a=256,position:s=Bg}=r;Fg=this._renderer.getRenderTarget(),Og=this._renderer.getActiveCubeFace(),Ug=this._renderer.getActiveMipmapLevel(),zg=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,s),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=jg(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Wg(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(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(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Fg,Og,Ug),this._renderer.xr.enabled=zg,e.scissorTest=!1,Gg(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Gu||e.mapping===Wu?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Fg=this._renderer.getRenderTarget(),Og=this._renderer.getActiveCubeFace(),Ug=this._renderer.getActiveMipmapLevel(),zg=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Zu,minFilter:Zu,generateMipmaps:!1,type:ld,format:fd,colorSpace:th,depthBuffer:!1},i=Hg(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Hg(e,t,n);const{_lodMax:i}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(e){const t=[],n=[],i=[];let r=e;const a=e-4+1+Ig.length;for(let s=0;s<a;s++){const a=Math.pow(2,r);t.push(a);let o=1/a;s>e-4?o=Ig[s-e+4-1]:0===s&&(o=0),n.push(o);const l=1/(a-2),c=-l,u=1+l,d=[c,c,u,c,u,u,c,c,u,u,c,u],h=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*h),y=new Float32Array(m*p*h),x=new Float32Array(g*p*h);for(let e=0;e<h;e++){const t=e%3*2/3-1,n=e>2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,f*p*e),y.set(d,m*p*e);const r=[e,e,e,e,e,e];x.set(r,g*p*e)}const b=new Wf;b.setAttribute("position",new Df(v,f)),b.setAttribute("uv",new Df(y,m)),b.setAttribute("faceIndex",new Df(x,g)),i.push(new nm(b,null)),r>4&&r--}return{lodMeshes:i,sizeLods:t,sigmas:n}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(Dg),r=new kh(0,1,0),a=new cm({name:"SphericalGaussianBlur",defines:{n:Dg,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Xg(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return a}(i,e,t)}return i}_compileMaterial(e){const t=new nm(new Wf,e);this._renderer.compile(t,Ng)}_sceneToCubeUV(e,t,n,i,r){const a=new fm(90,1,t,n),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,u=l.toneMapping;l.getClearColor(kg),l.toneMapping=0,l.autoClear=!1;l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new nm(new rm,new Pf({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const d=this._backgroundBox,h=d.material;let p=!1;const f=e.background;f?f.isColor&&(h.color.copy(f),e.background=null,p=!0):(h.color.copy(kg),p=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+o[t],r.y,r.z)):1===n?(a.up.set(0,0,s[t]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+o[t],r.z)):(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+o[t]));const c=this._cubeSize;Gg(i,n*c,t>2?c:0,c,c),l.setRenderTarget(i),p&&l.render(d,a),l.render(e,a)}l.toneMapping=u,l.autoClear=c,e.background=f}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Gu||e.mapping===Wu;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=jg()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Wg());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;r.uniforms.envMap.value=e;const s=this._cubeSize;Gg(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Ng)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let t=1;t<i;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget;if(null===this._ggxMaterial){const e=3*Math.max(this._cubeSize,16),t=4*this._cubeSize;this._ggxMaterial=function(e,t,n){const i=new cm({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Xg(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 3.2: Transform view direction to hemisphere configuration\n\t\t\t\tvec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tfloat lensq = Vh.x * Vh.x + Vh.y * Vh.y;\n\t\t\t\tvec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(Vh, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + Vh.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return i}(this._lodMax,e,t)}const a=this._ggxMaterial,s=this._lodMeshes[n];s.material=a;const o=a.uniforms,l=n/(this._lodMeshes.length-1),c=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-c*c)*(.05+.95*l),{_lodMax:d}=this,h=this._sizeLods[n],p=3*h*(n>d-4?n-d+4:0),f=4*(this._cubeSize-h);o.envMap.value=e.texture,o.roughness.value=u,o.mipInt.value=d-t,Gg(r,p,f,3*h,2*h),i.setRenderTarget(r),i.render(s,Ng),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=d-n,Gg(e,p,f,3*h,2*h),i.setRenderTarget(e),i.render(s,Ng)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,s){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&wh("blur direction must be either latitudinal or longitudinal!");const c=this._lodMeshes[i];c.material=l;const u=l.uniforms,d=this._sizeLods[n]-1,h=isFinite(r)?Math.PI/(2*d):2*Math.PI/39,p=r/h,f=isFinite(r)?1+Math.floor(3*p):Dg;f>Dg&&_h(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<Dg;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e<f&&(g+=2*n)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===a,s&&(u.poleAxis.value=s);const{_lodMax:v}=this;u.dTheta.value=h,u.mipInt.value=v-n;const y=this._sizeLods[i];Gg(t,3*y*(i>v-4?i-v+4:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(c,Ng)}}function Hg(e,t,n){const i=new np(e,t,n);return i.texture.mapping=ju,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Gg(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Wg(){return new cm({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Xg(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function jg(){return new cm({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Xg(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Xg(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function qg(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping,s=303===a||304===a,o=a===Gu||a===Wu;if(s||o){let a=t.get(r);const l=void 0!==a?a.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new Vg(e)),a=s?n.fromEquirectangular(r,a):n.fromCubemap(r,a),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),a.texture;if(void 0!==a)return a.texture;{const l=r.image;return s&&l&&l.height>0||o&&l&&function(e){let t=0;const n=6;for(let i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(l)?(null===n&&(n=new Vg(e)),a=s?n.fromEquirectangular(r):n.fromCubemap(r),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),r.addEventListener("dispose",i),a.texture):null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function $g(e){const t={};function n(n){if(void 0!==t[n])return t[n];const i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){const t=n(e);return null===t&&Sh("WebGLRenderer: "+e+" extension not supported."),t}}}function Yg(e,t,n,i){const r={},a=new WeakMap;function s(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",s),delete r[o.id];const l=a.get(o);l&&(t.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){const n=[],i=e.index,r=e.attributes.position;let s=0;if(null!==i){const e=i.array;s=i.version;for(let t=0,i=e.length;t<i;t+=3){const i=e[t+0],r=e[t+1],a=e[t+2];n.push(i,r,r,a,a,i)}}else{if(void 0===r)return;{const e=r.array;s=r.version;for(let t=0,i=e.length/3-1;t<i;t+=3){const e=t+0,i=t+1,r=t+2;n.push(e,i,i,r,r,e)}}}const o=new(gh(n)?kf:Nf)(n,1);o.version=s;const l=a.get(e);l&&t.remove(l),a.set(e,o)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",s),r[t.id]=!0,n.memory.geometries++),t},update:function(n){const i=n.attributes;for(const n in i)t.update(i[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){const t=a.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&o(e)}else o(e);return a.get(e)}}}function Kg(e,t,n){let i,r,a;function s(t,s,o){0!==o&&(e.drawElementsInstanced(i,s,r,t*a,o),n.update(s,i,o))}this.setMode=function(e){i=e},this.setIndex=function(e){r=e.type,a=e.bytesPerElement},this.render=function(t,s){e.drawElements(i,s,r,t*a),n.update(s,i,1)},this.renderInstances=s,this.renderMultiDraw=function(e,a,s){if(0===s)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,a,0,r,e,0,s);let o=0;for(let e=0;e<s;e++)o+=a[e];n.update(o,i,1)},this.renderMultiDrawInstances=function(e,o,l,c){if(0===l)return;const u=t.get("WEBGL_multi_draw");if(null===u)for(let t=0;t<e.length;t++)s(e[t]/a,o[t],c[t]);else{u.multiDrawElementsInstancedWEBGL(i,o,0,r,e,0,c,0,l);let t=0;for(let e=0;e<l;e++)t+=o[e]*c[e];n.update(t,i,1)}}}function Qg(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,i,r){switch(t.calls++,i){case e.TRIANGLES:t.triangles+=r*(n/3);break;case e.LINES:t.lines+=r*(n/2);break;case e.LINE_STRIP:t.lines+=r*(n-1);break;case e.LINE_LOOP:t.lines+=r*n;break;case e.POINTS:t.points+=r*n;break;default:wh("WebGLInfo: Unknown draw mode:",i)}}}}function Zg(e,t,n){const i=new WeakMap,r=new ep;return{update:function(a,s,o){const l=a.morphTargetInfluences,c=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,u=void 0!==c?c.length:0;let d=i.get(s);if(void 0===d||d.count!==u){void 0!==d&&d.texture.dispose();const h=void 0!==s.morphAttributes.position,p=void 0!==s.morphAttributes.normal,f=void 0!==s.morphAttributes.color,m=s.morphAttributes.position||[],g=s.morphAttributes.normal||[],v=s.morphAttributes.color||[];let y=0;!0===h&&(y=1),!0===p&&(y=2),!0===f&&(y=3);let x=s.attributes.position.count*y,b=1;x>t.maxTextureSize&&(b=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);const _=new Float32Array(x*b*4*u),w=new ip(_,x,b,u);w.type=od,w.needsUpdate=!0;const S=4*y;for(let M=0;M<u;M++){const T=m[M],A=g[M],R=v[M],P=x*b*4*M;for(let C=0;C<T.count;C++){const L=C*S;!0===h&&(r.fromBufferAttribute(T,C),_[P+L+0]=r.x,_[P+L+1]=r.y,_[P+L+2]=r.z,_[P+L+3]=0),!0===p&&(r.fromBufferAttribute(A,C),_[P+L+4]=r.x,_[P+L+5]=r.y,_[P+L+6]=r.z,_[P+L+7]=0),!0===f&&(r.fromBufferAttribute(R,C),_[P+L+8]=r.x,_[P+L+9]=r.y,_[P+L+10]=r.z,_[P+L+11]=4===R.itemSize?r.w:1)}}function E(){w.dispose(),i.delete(s),s.removeEventListener("dispose",E)}d={count:u,texture:w,size:new Dh(x,b)},i.set(s,d),s.addEventListener("dispose",E)}if(!0===a.isInstancedMesh&&null!==a.morphTexture)o.getUniforms().setValue(e,"morphTexture",a.morphTexture,n);else{let I=0;for(let N=0;N<l.length;N++)I+=l[N];const D=s.morphTargetsRelative?1:1-I;o.getUniforms().setValue(e,"morphTargetBaseInfluence",D),o.getUniforms().setValue(e,"morphTargetInfluences",l)}o.getUniforms().setValue(e,"morphTargetsTexture",d.texture,n),o.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}}}class Jg{constructor(e,t,n){if(this.renderer=e,this.DEFAULT_NUMVIEWS=2,this.maxNumViews=0,this.gl=n,this.extensions=t,this.available=this.extensions.has("OCULUS_multiview"),this.available){const e=this.extensions.get("OCULUS_multiview");this.maxNumViews=this.gl.getParameter(e.MAX_VIEWS_OVR),this.mat4=[],this.mat3=[],this.cameraArray=[];for(var i=0;i<this.maxNumViews;i++)this.mat4[i]=new Ip,this.mat3[i]=new Uh}}getCameraArray(e){return e.isArrayCamera?e.cameras:(this.cameraArray[0]=e,this.cameraArray)}updateCameraProjectionMatricesUniform(e,t){for(var n=this.getCameraArray(e),i=0;i<n.length;i++)this.mat4[i].copy(n[i].projectionMatrix);t.setValue(this.gl,"projectionMatrices",this.mat4)}updateCameraViewMatricesUniform(e,t){for(var n=this.getCameraArray(e),i=0;i<n.length;i++)this.mat4[i].copy(n[i].matrixWorldInverse);t.setValue(this.gl,"viewMatrices",this.mat4)}updateObjectMatricesUniforms(e,t,n){for(var i=this.getCameraArray(t),r=0;r<i.length;r++)this.mat4[r].multiplyMatrices(i[r].matrixWorldInverse,e.matrixWorld),this.mat3[r].getNormalMatrix(this.mat4[r]);n.setValue(this.gl,"modelViewMatrices",this.mat4),n.setValue(this.gl,"normalMatrices",this.mat3)}}function ev(e,t,n,i){let r=new WeakMap;function a(e){const t=e.target;t.removeEventListener("dispose",a),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(s){const o=i.render.frame,l=s.geometry,c=t.get(s,l);if(r.get(c)!==o&&(t.update(c),r.set(c,o)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",a)&&s.addEventListener("dispose",a),r.get(s)!==o&&(n.update(s.instanceMatrix,e.ARRAY_BUFFER),null!==s.instanceColor&&n.update(s.instanceColor,e.ARRAY_BUFFER),r.set(s,o))),s.isSkinnedMesh){const e=s.skeleton;r.get(e)!==o&&(e.update(),r.set(e,o))}return c},dispose:function(){r=new WeakMap}}}const tv=new Jh,nv=new jm(1,1),iv=new ip,rv=new rp,av=new vm,sv=[],ov=[],lv=new Float32Array(16),cv=new Float32Array(9),uv=new Float32Array(4);function dv(e,t,n){const i=e[0];if(i<=0||i>0)return e;const r=t*n;let a=sv[r];if(void 0===a&&(a=new Float32Array(r),sv[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function hv(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function pv(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function fv(e,t){let n=ov[t];void 0===n&&(n=new Int32Array(t),ov[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function mv(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function gv(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(hv(n,t))return;e.uniform2fv(this.addr,t),pv(n,t)}}function vv(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(hv(n,t))return;e.uniform3fv(this.addr,t),pv(n,t)}}function yv(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(hv(n,t))return;e.uniform4fv(this.addr,t),pv(n,t)}}function xv(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(hv(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),pv(n,t)}else{if(hv(n,i))return;uv.set(i),e.uniformMatrix2fv(this.addr,!1,uv),pv(n,i)}}function bv(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(hv(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),pv(n,t)}else{if(hv(n,i))return;cv.set(i),e.uniformMatrix3fv(this.addr,!1,cv),pv(n,i)}}function _v(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(hv(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),pv(n,t)}else{if(hv(n,i))return;lv.set(i),e.uniformMatrix4fv(this.addr,!1,lv),pv(n,i)}}function wv(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Sv(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(hv(n,t))return;e.uniform2iv(this.addr,t),pv(n,t)}}function Ev(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(hv(n,t))return;e.uniform3iv(this.addr,t),pv(n,t)}}function Mv(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(hv(n,t))return;e.uniform4iv(this.addr,t),pv(n,t)}}function Tv(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Av(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(hv(n,t))return;e.uniform2uiv(this.addr,t),pv(n,t)}}function Rv(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(hv(n,t))return;e.uniform3uiv(this.addr,t),pv(n,t)}}function Pv(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(hv(n,t))return;e.uniform4uiv(this.addr,t),pv(n,t)}}function Cv(e,t,n){const i=this.cache,r=n.allocateTextureUnit();let a;i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),this.type===e.SAMPLER_2D_SHADOW?(nv.compareFunction=515,a=nv):a=tv,n.setTexture2D(t||a,r)}function Lv(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||rv,r)}function Iv(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||av,r)}function Dv(e,t,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||iv,r)}function Nv(e,t){e.uniform1fv(this.addr,t)}function kv(e,t){const n=dv(t,this.size,2);e.uniform2fv(this.addr,n)}function Fv(e,t){const n=dv(t,this.size,3);e.uniform3fv(this.addr,n)}function Ov(e,t){const n=dv(t,this.size,4);e.uniform4fv(this.addr,n)}function Uv(e,t){const n=dv(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function zv(e,t){const n=dv(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Bv(e,t){const n=dv(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Vv(e,t){e.uniform1iv(this.addr,t)}function Hv(e,t){e.uniform2iv(this.addr,t)}function Gv(e,t){e.uniform3iv(this.addr,t)}function Wv(e,t){e.uniform4iv(this.addr,t)}function jv(e,t){e.uniform1uiv(this.addr,t)}function Xv(e,t){e.uniform2uiv(this.addr,t)}function qv(e,t){e.uniform3uiv(this.addr,t)}function $v(e,t){e.uniform4uiv(this.addr,t)}function Yv(e,t,n){const i=this.cache,r=t.length,a=fv(n,r);hv(i,a)||(e.uniform1iv(this.addr,a),pv(i,a));for(let e=0;e!==r;++e)n.setTexture2D(t[e]||tv,a[e])}function Kv(e,t,n){const i=this.cache,r=t.length,a=fv(n,r);hv(i,a)||(e.uniform1iv(this.addr,a),pv(i,a));for(let e=0;e!==r;++e)n.setTexture3D(t[e]||rv,a[e])}function Qv(e,t,n){const i=this.cache,r=t.length,a=fv(n,r);hv(i,a)||(e.uniform1iv(this.addr,a),pv(i,a));for(let e=0;e!==r;++e)n.setTextureCube(t[e]||av,a[e])}function Zv(e,t,n){const i=this.cache,r=t.length,a=fv(n,r);hv(i,a)||(e.uniform1iv(this.addr,a),pv(i,a));for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||iv,a[e])}class Jv{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return mv;case 35664:return gv;case 35665:return vv;case 35666:return yv;case 35674:return xv;case 35675:return bv;case 35676:return _v;case 5124:case 35670:return wv;case 35667:case 35671:return Sv;case 35668:case 35672:return Ev;case 35669:case 35673:return Mv;case 5125:return Tv;case 36294:return Av;case 36295:return Rv;case 36296:return Pv;case 35678:case 36198:case 36298:case 36306:case 35682:return Cv;case 35679:case 36299:case 36307:return Lv;case 35680:case 36300:case 36308:case 36293:return Iv;case 36289:case 36303:case 36311:case 36292:return Dv}}(t.type)}}class ey{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Nv;case 35664:return kv;case 35665:return Fv;case 35666:return Ov;case 35674:return Uv;case 35675:return zv;case 35676:return Bv;case 5124:case 35670:return Vv;case 35667:case 35671:return Hv;case 35668:case 35672:return Gv;case 35669:case 35673:return Wv;case 5125:return jv;case 36294:return Xv;case 36295:return qv;case 36296:return $v;case 35678:case 36198:case 36298:case 36306:case 35682:return Yv;case 35679:case 36299:case 36307:return Kv;case 35680:case 36300:case 36308:case 36293:return Qv;case 36289:case 36303:case 36311:case 36292:return Zv}}(t.type)}}class ty{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const a=i[r];a.setValue(e,t[a.id],n)}}}const ny=/(\w+)(\])?(\[|\.)?/g;function iy(e,t){e.seq.push(t),e.map[t.id]=t}function ry(e,t,n){const i=e.name,r=i.length;for(ny.lastIndex=0;;){const a=ny.exec(i),s=ny.lastIndex;let o=a[1];const l="]"===a[2],c=a[3];if(l&&(o|=0),void 0===c||"["===c&&s+2===r){iy(n,void 0===c?new Jv(o,e,t):new ey(o,e,t));break}{let e=n.map[o];void 0===e&&(e=new ty(o),iy(n,e)),n=e}}}class ay{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i);ry(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,i){const r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const a=t[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(e,s.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const r=e[i];r.id in t&&n.push(r)}return n}}function sy(e,t,n){const i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let oy=0;const ly=new Uh;function cy(e,t,n){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&""===r)return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){const n=e.split("\n"),i=[],r=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=r;e<a;e++){const r=e+1;i.push(`${r===t?">":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function uy(e,t){const n=function(e){Gh._getMatrix(ly,Gh.workingColorSpace,e);const t=`mat3( ${ly.elements.map(e=>e.toFixed(4))} )`;switch(Gh.getTransfer(e)){case nh:return[t,"LinearTransferOETF"];case ih:return[t,"sRGBTransferOETF"];default:return _h("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function dy(e,t){let n;switch(t){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="Cineon";break;case 4:n="ACESFilmic";break;case 6:n="AgX";break;case 7:n="Neutral";break;case 5:n="Custom";break;default:_h("WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const hy=new kh;function py(){Gh.getLuminanceCoefficients(hy);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${hy.x.toFixed(4)}, ${hy.y.toFixed(4)}, ${hy.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function fy(e){return""!==e}function my(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function gy(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const vy=/^[ \t]*#include +<([\w\d./]+)>/gm;function yy(e){return e.replace(vy,by)}const xy=new Map;function by(e,t){let n=bg[t];if(void 0===n){const e=xy.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=bg[e],_h('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return yy(n)}const _y=/#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 wy(e){return e.replace(_y,Sy)}function Sy(e,t,n,i){let r="";for(let e=parseInt(t);e<parseInt(n);e++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function Ey(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function My(e,t,n,i){const r=e.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(n),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case Gu:case Wu:t="ENVMAP_TYPE_CUBE";break;case ju:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),u=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===Wu&&(t="ENVMAP_MODE_REFRACTION");return t}(n),d=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(n),h=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),p=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(fy).join("\n")}(n),f=function(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(a),m=r.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";const x=n.numMultiviewViews;n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(fy).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(fy).join("\n"),v.length>0&&(v+="\n")):(g=[Ey(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(fy).join("\n"),v=[Ey(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?bg.tonemapping_pars_fragment:"",0!==n.toneMapping?dy("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",bg.colorspace_pars_fragment,uy("linearToOutputTexel",n.outputColorSpace),py(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(fy).join("\n")),s=yy(s),s=my(s,n),s=gy(s,n),o=yy(o),o=my(o,n),o=gy(o,n),s=wy(s),o=wy(o),!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===ph?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===ph?"":"#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("\n")+"\n"+v,x>0&&(g=["#extension GL_OVR_multiview : require","layout(num_views = "+x+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n")+"\n"+g,g=g.replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+x+"];","uniform mat4 projectionMatrices["+x+"];","uniform mat4 viewMatrices["+x+"];","uniform mat3 normalMatrices["+x+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),v=["#extension GL_OVR_multiview : require","#define VIEW_ID gl_ViewID_OVR"].join("\n")+"\n"+v,v=v.replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+x+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n"))));const b=y+g+s,_=y+v+o,w=sy(r,r.VERTEX_SHADER,b),S=sy(r,r.FRAGMENT_SHADER,_);function E(t){if(e.debug.checkShaderErrors){const n=r.getProgramInfoLog(m)||"",i=r.getShaderInfoLog(w)||"",a=r.getShaderInfoLog(S)||"",s=n.trim(),o=i.trim(),l=a.trim();let c=!0,u=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(c=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,m,w,S);else{const e=cy(r,w,"vertex"),n=cy(r,S,"fragment");wh("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+s+"\n"+e+"\n"+n)}else""!==s?_h("WebGLProgram: Program Info Log:",s):""!==o&&""!==l||(u=!1);u&&(t.diagnostics={runnable:c,programLog:s,vertexShader:{log:o,prefix:g},fragmentShader:{log:l,prefix:v}})}r.deleteShader(w),r.deleteShader(S),M=new ay(r,m),T=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r),a=i.name;let s=1;i.type===e.FLOAT_MAT2&&(s=2),i.type===e.FLOAT_MAT3&&(s=3),i.type===e.FLOAT_MAT4&&(s=4),n[a]={type:i.type,location:e.getAttribLocation(t,a),locationSize:s}}return n}(r,m)}let M,T;r.attachShader(m,w),r.attachShader(m,S),void 0!==n.index0AttributeName?r.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===M&&E(this),M},this.getAttributes=function(){return void 0===T&&E(this),T};let A=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===A&&(A=r.getProgramParameter(m,37297)),A},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=oy++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=S,this.numMultiviewViews=x,this}let Ty=0;class Ay{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new Ry(e),t.set(e,n)),n}}class Ry{constructor(e){this.id=Ty++,this.code=e,this.usedTimes=0}}function Py(e,t,n,i,r,a,s){const o=new Gp,l=new Ay,c=new Set,u=[],d=r.logarithmicDepthBuffer,h=r.vertexTextures;let p=r.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(e){return c.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(a,o,u,g,v){const y=g.fog,x=v.geometry,b=a.isMeshStandardMaterial?g.environment:null,_=(a.isMeshStandardMaterial?n:t).get(a.envMap||b),w=_&&_.mapping===ju?_.image.height:null,S=f[a.type];null!==a.precision&&(p=r.getMaxPrecision(a.precision),p!==a.precision&&_h("WebGLProgram.getParameters:",a.precision,"not supported, using",p,"instead."));const E=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,M=void 0!==E?E.length:0;let T,A,R,P,C=0;if(void 0!==x.morphAttributes.position&&(C=1),void 0!==x.morphAttributes.normal&&(C=2),void 0!==x.morphAttributes.color&&(C=3),S){const e=wg[S];T=e.vertexShader,A=e.fragmentShader}else T=a.vertexShader,A=a.fragmentShader,l.update(a),R=l.getVertexShaderID(a),P=l.getFragmentShaderID(a);const L=e.getRenderTarget(),I=e.state.buffers.depth.getReversed(),D=L&&L.isWebGLMultiviewRenderTarget?L.numViews:0,N=!0===v.isInstancedMesh,k=!0===v.isBatchedMesh,F=!!a.map,O=!!a.matcap,U=!!_,z=!!a.aoMap,B=!!a.lightMap,V=!!a.bumpMap,H=!!a.normalMap,G=!!a.displacementMap,W=!!a.emissiveMap,j=!!a.metalnessMap,X=!!a.roughnessMap,q=a.anisotropy>0,$=a.clearcoat>0,Y=a.dispersion>0,K=a.iridescence>0,Q=a.sheen>0,Z=a.transmission>0,J=q&&!!a.anisotropyMap,ee=$&&!!a.clearcoatMap,te=$&&!!a.clearcoatNormalMap,ne=$&&!!a.clearcoatRoughnessMap,ie=K&&!!a.iridescenceMap,re=K&&!!a.iridescenceThicknessMap,ae=Q&&!!a.sheenColorMap,se=Q&&!!a.sheenRoughnessMap,oe=!!a.specularMap,le=!!a.specularColorMap,ce=!!a.specularIntensityMap,ue=Z&&!!a.transmissionMap,de=Z&&!!a.thicknessMap,he=!!a.gradientMap,pe=!!a.alphaMap,fe=a.alphaTest>0,me=!!a.alphaHash,ge=!!a.extensions;let ve=0;a.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(ve=e.toneMapping));const ye={shaderID:S,shaderType:a.type,shaderName:a.name,vertexShader:T,fragmentShader:A,defines:a.defines,customVertexShaderID:R,customFragmentShaderID:P,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,batching:k,batchingColor:k&&null!==v._colorsTexture,instancing:N,instancingColor:N&&null!==v.instanceColor,instancingMorph:N&&null!==v.morphTexture,supportsVertexTextures:h,numMultiviewViews:D,outputColorSpace:null===L?e.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:th,alphaToCoverage:!!a.alphaToCoverage,map:F,matcap:O,envMap:U,envMapMode:U&&_.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:B,bumpMap:V,normalMap:H,displacementMap:h&&G,emissiveMap:W,normalMapObjectSpace:H&&1===a.normalMapType,normalMapTangentSpace:H&&0===a.normalMapType,metalnessMap:j,roughnessMap:X,anisotropy:q,anisotropyMap:J,clearcoat:$,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:ne,dispersion:Y,iridescence:K,iridescenceMap:ie,iridescenceThicknessMap:re,sheen:Q,sheenColorMap:ae,sheenRoughnessMap:se,specularMap:oe,specularColorMap:le,specularIntensityMap:ce,transmission:Z,transmissionMap:ue,thicknessMap:de,gradientMap:he,opaque:!1===a.transparent&&1===a.blending&&!1===a.alphaToCoverage,alphaMap:pe,alphaTest:fe,alphaHash:me,combine:a.combine,mapUv:F&&m(a.map.channel),aoMapUv:z&&m(a.aoMap.channel),lightMapUv:B&&m(a.lightMap.channel),bumpMapUv:V&&m(a.bumpMap.channel),normalMapUv:H&&m(a.normalMap.channel),displacementMapUv:G&&m(a.displacementMap.channel),emissiveMapUv:W&&m(a.emissiveMap.channel),metalnessMapUv:j&&m(a.metalnessMap.channel),roughnessMapUv:X&&m(a.roughnessMap.channel),anisotropyMapUv:J&&m(a.anisotropyMap.channel),clearcoatMapUv:ee&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:te&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:re&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:se&&m(a.sheenRoughnessMap.channel),specularMapUv:oe&&m(a.specularMap.channel),specularColorMapUv:le&&m(a.specularColorMap.channel),specularIntensityMapUv:ce&&m(a.specularIntensityMap.channel),transmissionMapUv:ue&&m(a.transmissionMap.channel),thicknessMapUv:de&&m(a.thicknessMap.channel),alphaMapUv:pe&&m(a.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(H||q),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(F||pe),fog:!!y,useFog:!0===a.fog,fogExp2:!!y&&y.isFogExp2,flatShading:!0===a.flatShading&&!1===a.wireframe,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:I,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:M,morphTextureStride:C,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:ve,decodeVideoTexture:F&&!0===a.map.isVideoTexture&&Gh.getTransfer(a.map.colorSpace)===ih,decodeVideoTextureEmissive:W&&!0===a.emissiveMap.isVideoTexture&&Gh.getTransfer(a.emissiveMap.colorSpace)===ih,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:ge&&!0===a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&!0===a.extensions.multiDraw||k)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return ye.vertexUv1s=c.has(1),ye.vertexUv2s=c.has(2),ye.vertexUv3s=c.has(3),c.clear(),ye},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.supportsVertexTextures&&o.enable(0);t.instancing&&o.enable(1);t.instancingColor&&o.enable(2);t.instancingMorph&&o.enable(3);t.matcap&&o.enable(4);t.envMap&&o.enable(5);t.normalMapObjectSpace&&o.enable(6);t.normalMapTangentSpace&&o.enable(7);t.clearcoat&&o.enable(8);t.iridescence&&o.enable(9);t.alphaTest&&o.enable(10);t.vertexColors&&o.enable(11);t.vertexAlphas&&o.enable(12);t.vertexUv1s&&o.enable(13);t.vertexUv2s&&o.enable(14);t.vertexUv3s&&o.enable(15);t.vertexTangents&&o.enable(16);t.anisotropy&&o.enable(17);t.alphaHash&&o.enable(18);t.batching&&o.enable(19);t.dispersion&&o.enable(20);t.batchingColor&&o.enable(21);t.gradientMap&&o.enable(22);e.push(o.mask),o.disableAll(),t.fog&&o.enable(0);t.useFog&&o.enable(1);t.flatShading&&o.enable(2);t.logarithmicDepthBuffer&&o.enable(3);t.reversedDepthBuffer&&o.enable(4);t.skinning&&o.enable(5);t.morphTargets&&o.enable(6);t.morphNormals&&o.enable(7);t.morphColors&&o.enable(8);t.premultipliedAlpha&&o.enable(9);t.shadowMapEnabled&&o.enable(10);t.doubleSided&&o.enable(11);t.flipSided&&o.enable(12);t.useDepthPacking&&o.enable(13);t.dithering&&o.enable(14);t.transmission&&o.enable(15);t.sheen&&o.enable(16);t.opaque&&o.enable(17);t.pointsUvs&&o.enable(18);t.decodeVideoTexture&&o.enable(19);t.decodeVideoTextureEmissive&&o.enable(20);t.alphaToCoverage&&o.enable(21);t.numMultiviewViews&&o.enable(22);e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=f[e.type];let n;if(t){const e=wg[t];n=lm.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=u.length;e<t;e++){const t=u[e];if(t.cacheKey===n){i=t,++i.usedTimes;break}}return void 0===i&&(i=new My(e,n,t,a),u.push(i)),i},releaseProgram:function(e){if(0===--e.usedTimes){const t=u.indexOf(e);u[t]=u[u.length-1],u.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:u,dispose:function(){l.dispose()}}}function Cy(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function Ly(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Iy(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Dy(){const e=[];let t=0;const n=[],i=[],r=[];function a(n,i,r,a,s,o){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:a,renderOrder:n.renderOrder,z:s,group:o},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=o),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,s,o,l,c){const u=a(e,t,s,o,l,c);s.transmission>0?i.push(u):!0===s.transparent?r.push(u):n.push(u)},unshift:function(e,t,s,o,l,c){const u=a(e,t,s,o,l,c);s.transmission>0?i.unshift(u):!0===s.transparent?r.unshift(u):n.unshift(u)},finish:function(){for(let n=t,i=e.length;n<i;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Ly),i.length>1&&i.sort(t||Iy),r.length>1&&r.sort(t||Iy)}}}function Ny(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new Dy,e.set(t,[r])):n>=i.length?(r=new Dy,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function ky(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new kh,color:new Mf};break;case"SpotLight":n={position:new kh,direction:new kh,color:new Mf,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new kh,color:new Mf,distance:0,decay:0};break;case"HemisphereLight":n={direction:new kh,skyColor:new Mf,groundColor:new Mf};break;case"RectAreaLight":n={color:new Mf,position:new kh,halfWidth:new kh,halfHeight:new kh}}return e[t.id]=n,n}}}let Fy=0;function Oy(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Uy(e){const t=new ky,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dh};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dh,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),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 e=0;e<9;e++)i.probe.push(new kh);const r=new kh,a=new Ip,s=new Ip;return{setup:function(r){let a=0,s=0,o=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let l=0,c=0,u=0,d=0,h=0,p=0,f=0,m=0,g=0,v=0,y=0;r.sort(Oy);for(let e=0,x=r.length;e<x;e++){const x=r[e],b=x.color,_=x.intensity,w=x.distance,S=x.shadow&&x.shadow.map?x.shadow.map.texture:null;if(x.isAmbientLight)a+=b.r*_,s+=b.g*_,o+=b.b*_;else if(x.isLightProbe){for(let e=0;e<9;e++)i.probe[e].addScaledVector(x.sh.coefficients[e],_);y++}else if(x.isDirectionalLight){const e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),x.castShadow){const e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,i.directionalShadow[l]=t,i.directionalShadowMap[l]=S,i.directionalShadowMatrix[l]=x.shadow.matrix,p++}i.directional[l]=e,l++}else if(x.isSpotLight){const e=t.get(x);e.position.setFromMatrixPosition(x.matrixWorld),e.color.copy(b).multiplyScalar(_),e.distance=w,e.coneCos=Math.cos(x.angle),e.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),e.decay=x.decay,i.spot[u]=e;const r=x.shadow;if(x.map&&(i.spotLightMap[g]=x.map,g++,r.updateMatrices(x),x.castShadow&&v++),i.spotLightMatrix[u]=r.matrix,x.castShadow){const e=n.get(x);e.shadowIntensity=r.intensity,e.shadowBias=r.bias,e.shadowNormalBias=r.normalBias,e.shadowRadius=r.radius,e.shadowMapSize=r.mapSize,i.spotShadow[u]=e,i.spotShadowMap[u]=S,m++}u++}else if(x.isRectAreaLight){const e=t.get(x);e.color.copy(b).multiplyScalar(_),e.halfWidth.set(.5*x.width,0,0),e.halfHeight.set(0,.5*x.height,0),i.rectArea[d]=e,d++}else if(x.isPointLight){const e=t.get(x);if(e.color.copy(x.color).multiplyScalar(x.intensity),e.distance=x.distance,e.decay=x.decay,x.castShadow){const e=x.shadow,t=n.get(x);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,i.pointShadow[c]=t,i.pointShadowMap[c]=S,i.pointShadowMatrix[c]=x.shadow.matrix,f++}i.point[c]=e,c++}else if(x.isHemisphereLight){const e=t.get(x);e.skyColor.copy(x.color).multiplyScalar(_),e.groundColor.copy(x.groundColor).multiplyScalar(_),i.hemi[h]=e,h++}}d>0&&(!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=_g.LTC_FLOAT_1,i.rectAreaLTC2=_g.LTC_FLOAT_2):(i.rectAreaLTC1=_g.LTC_HALF_1,i.rectAreaLTC2=_g.LTC_HALF_2)),i.ambient[0]=a,i.ambient[1]=s,i.ambient[2]=o;const x=i.hash;x.directionalLength===l&&x.pointLength===c&&x.spotLength===u&&x.rectAreaLength===d&&x.hemiLength===h&&x.numDirectionalShadows===p&&x.numPointShadows===f&&x.numSpotShadows===m&&x.numSpotMaps===g&&x.numLightProbes===y||(i.directional.length=l,i.spot.length=u,i.rectArea.length=d,i.point.length=c,i.hemi.length=h,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=y,x.directionalLength=l,x.pointLength=c,x.spotLength=u,x.rectAreaLength=d,x.hemiLength=h,x.numDirectionalShadows=p,x.numPointShadows=f,x.numSpotShadows=m,x.numSpotMaps=g,x.numLightProbes=y,i.version=Fy++)},setupView:function(e,t){let n=0,o=0,l=0,c=0,u=0;const d=t.matrixWorldInverse;for(let t=0,h=e.length;t<h;t++){const h=e[t];if(h.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(h.matrixWorld),r.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(d),n++}else if(h.isSpotLight){const e=i.spot[l];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),e.direction.setFromMatrixPosition(h.matrixWorld),r.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(d),l++}else if(h.isRectAreaLight){const e=i.rectArea[c];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),s.identity(),a.copy(h.matrixWorld),a.premultiply(d),s.extractRotation(a),e.halfWidth.set(.5*h.width,0,0),e.halfHeight.set(0,.5*h.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),c++}else if(h.isPointLight){const e=i.point[o];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(d),o++}else if(h.isHemisphereLight){const e=i.hemi[u];e.direction.setFromMatrixPosition(h.matrixWorld),e.direction.transformDirection(d),u++}}},state:i}}function zy(e){const t=new Uy(e),n=[],i=[];const r={lightsArray:n,shadowsArray:i,camera:null,lights:t,transmissionRenderTarget:{}};return{init:function(e){r.camera=e,n.length=0,i.length=0},state:r,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){i.push(e)}}}function By(e){let t=new WeakMap;return{get:function(n,i=0){const r=t.get(n);let a;return void 0===r?(a=new zy(e),t.set(n,[a])):i>=r.length?(a=new zy(e),r.push(a)):a=r[i],a},dispose:function(){t=new WeakMap}}}function Vy(e,t,n){let i=new Lm;const r=new Dh,a=new Dh,s=new ep,o=new eg({depthPacking:3201}),l=new tg,c={},u=n.maxTextureSize,d={[fu]:1,[mu]:0,[gu]:2},h=new cm({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dh},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=h.clone();p.defines.HORIZONTAL_PASS=1;const f=new Wf;f.setAttribute("position",new Df(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new nm(f,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function y(n,i){const a=t.update(m);h.defines.VSM_SAMPLES!==n.blurSamples&&(h.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,h.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new np(r.x,r.y)),h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,a,h,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,a,p,m,null)}function x(t,n,i,r){let a=null;const s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const e=a.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r,n.addEventListener("dispose",_)),a=r}if(a.visible=n.visible,a.wireframe=n.wireframe,a.side=3===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial){e.properties.get(a).light=i}return a}function b(n,r,a,s,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const i=t.update(n),l=n.material;if(Array.isArray(l)){const t=i.groups;for(let c=0,u=t.length;c<u;c++){const u=t[c],d=l[u.materialIndex];if(d&&d.visible){const t=x(n,d,s,o);n.onBeforeShadow(e,n,r,a,i,t,u),e.renderBufferDirect(a,null,i,t,n,u),n.onAfterShadow(e,n,r,a,i,t,u)}}}else if(l.visible){const t=x(n,l,s,o);n.onBeforeShadow(e,n,r,a,i,t,null),e.renderBufferDirect(a,null,i,t,n,null),n.onAfterShadow(e,n,r,a,i,t,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)b(l[e],r,a,s,o)}function _(e){e.target.removeEventListener("dispose",_);for(const t in c){const n=c[t],i=e.target.uuid;if(i in n){n[i].dispose(),delete n[i]}}}this.render=function(t,n,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),c=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),h=e.state;h.setBlending(0),!0===h.buffers.depth.getReversed()?h.buffers.color.setClear(0,0,0,0):h.buffers.color.setClear(1,1,1,1),h.buffers.depth.setTest(!0),h.setScissorTest(!1);const p=3!==v&&3===this.type,f=3===v&&3!==this.type;for(let l=0,c=t.length;l<c;l++){const c=t[l],d=c.shadow;if(void 0===d){_h("WebGLShadowMap:",c,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;r.copy(d.mapSize);const m=d.getFrameExtents();if(r.multiply(m),a.copy(d.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/m.x),r.x=a.x*m.x,d.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/m.y),r.y=a.y*m.y,d.mapSize.y=a.y)),null===d.map||!0===p||!0===f){const e=3!==this.type?{minFilter:Yu,magFilter:Yu}:{};null!==d.map&&d.map.dispose(),d.map=new np(r.x,r.y,e),d.map.texture.name=c.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const g=d.getViewportCount();for(let e=0;e<g;e++){const t=d.getViewport(e);s.set(a.x*t.x,a.y*t.y,a.x*t.z,a.y*t.w),h.viewport(s),d.updateMatrices(c,e),i=d.getFrustum(),b(n,o,d.camera,c,this.type)}!0!==d.isPointLightShadow&&3===this.type&&y(d,o),d.needsUpdate=!1}v=this.type,g.needsUpdate=!1,e.setRenderTarget(l,c,d)}}const Hy={[ku]:1,[Ou]:6,[zu]:7,[Uu]:5,[Fu]:0,[Vu]:2,[Hu]:4,[Bu]:3};function Gy(e,t){const n=new function(){let t=!1;const n=new ep;let i=null;const r=new ep(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,a,s,o){!0===o&&(t*=s,i*=s,a*=s),n.set(t,i,a,s),!1===r.equals(n)&&(e.clearColor(t,i,a,s),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}},i=new function(){let n=!1,i=!1,r=null,a=null,s=null;return{setReversed:function(e){if(i!==e){const n=t.get("EXT_clip_control");e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),i=e;const r=s;s=null,this.setClear(r)}},getReversed:function(){return i},setTest:function(t){t?B(e.DEPTH_TEST):V(e.DEPTH_TEST)},setMask:function(t){r===t||n||(e.depthMask(t),r=t)},setFunc:function(t){if(i&&(t=Hy[t]),a!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){s!==t&&(i&&(t=1-t),e.clearDepth(t),s=t)},reset:function(){n=!1,r=null,a=null,s=null,i=!1}}},r=new function(){let t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null;return{setTest:function(n){t||(n?B(e.STENCIL_TEST):V(e.STENCIL_TEST))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,s){i===t&&r===n&&a===s||(e.stencilFunc(t,n,s),i=t,r=n,a=s)},setOp:function(t,n,i){s===t&&o===n&&l===i||(e.stencilOp(t,n,i),s=t,o=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,r=null,a=null,s=null,o=null,l=null,c=null}}},a=new WeakMap,s=new WeakMap;let o={},l={},c=new WeakMap,u=[],d=null,h=!1,p=null,f=null,m=null,g=null,v=null,y=null,x=null,b=new Mf(0,0,0),_=0,w=!1,S=null,E=null,M=null,T=null,A=null;const R=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let P=!1,C=0;const L=e.getParameter(e.VERSION);-1!==L.indexOf("WebGL")?(C=parseFloat(/^WebGL (\d)/.exec(L)[1]),P=C>=1):-1!==L.indexOf("OpenGL ES")&&(C=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),P=C>=2);let I=null,D={};const N=e.getParameter(e.SCISSOR_BOX),k=e.getParameter(e.VIEWPORT),F=(new ep).fromArray(N),O=(new ep).fromArray(k);function U(t,n,i,r){const a=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;s<i;s++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,r,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+s,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return s}const z={};function B(t){!0!==o[t]&&(e.enable(t),o[t]=!0)}function V(t){!1!==o[t]&&(e.disable(t),o[t]=!1)}z[e.TEXTURE_2D]=U(e.TEXTURE_2D,e.TEXTURE_2D,1),z[e.TEXTURE_CUBE_MAP]=U(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),z[e.TEXTURE_2D_ARRAY]=U(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),z[e.TEXTURE_3D]=U(e.TEXTURE_3D,e.TEXTURE_3D,1,1),n.setClear(0,0,0,1),i.setClear(1),r.setClear(0),B(e.DEPTH_TEST),i.setFunc(3),j(!1),X(1),B(e.CULL_FACE),W(0);const H={[vu]:e.FUNC_ADD,[yu]:e.FUNC_SUBTRACT,[xu]:e.FUNC_REVERSE_SUBTRACT};H[103]=e.MIN,H[104]=e.MAX;const G={[bu]:e.ZERO,[_u]:e.ONE,[wu]:e.SRC_COLOR,[Eu]:e.SRC_ALPHA,[Cu]:e.SRC_ALPHA_SATURATE,[Ru]:e.DST_COLOR,[Tu]:e.DST_ALPHA,[Su]:e.ONE_MINUS_SRC_COLOR,[Mu]:e.ONE_MINUS_SRC_ALPHA,[Pu]:e.ONE_MINUS_DST_COLOR,[Au]:e.ONE_MINUS_DST_ALPHA,[Lu]:e.CONSTANT_COLOR,[Iu]:e.ONE_MINUS_CONSTANT_COLOR,[Du]:e.CONSTANT_ALPHA,[Nu]:e.ONE_MINUS_CONSTANT_ALPHA};function W(t,n,i,r,a,s,o,l,c,u){if(0!==t){if(!1===h&&(B(e.BLEND),h=!0),5===t)a=a||n,s=s||i,o=o||r,n===f&&a===v||(e.blendEquationSeparate(H[n],H[a]),f=n,v=a),i===m&&r===g&&s===y&&o===x||(e.blendFuncSeparate(G[i],G[r],G[s],G[o]),m=i,g=r,y=s,x=o),!1!==l.equals(b)&&c===_||(e.blendColor(l.r,l.g,l.b,c),b.copy(l),_=c),p=t,w=!1;else if(t!==p||u!==w){if(f===vu&&v===vu||(e.blendEquation(e.FUNC_ADD),f=vu,v=vu),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:wh("WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:wh("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:wh("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:wh("WebGLState: Invalid blending: ",t)}m=null,g=null,y=null,x=null,b.set(0,0,0),_=0,p=t,w=u}}else!0===h&&(V(e.BLEND),h=!1)}function j(t){S!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),S=t)}function X(t){0!==t?(B(e.CULL_FACE),t!==E&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):V(e.CULL_FACE),E=t}function q(t,n,i){t?(B(e.POLYGON_OFFSET_FILL),T===n&&A===i||(e.polygonOffset(n,i),T=n,A=i)):V(e.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:i,stencil:r},enable:B,disable:V,bindFramebuffer:function(t,n){return l[t]!==n&&(e.bindFramebuffer(t,n),l[t]=n,t===e.DRAW_FRAMEBUFFER&&(l[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(l[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let i=u,r=!1;if(t){i=c.get(n),void 0===i&&(i=[],c.set(n,i));const a=t.textures;if(i.length!==a.length||i[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)i[t]=e.COLOR_ATTACHMENT0+t;i.length=a.length,r=!0}}else i[0]!==e.BACK&&(i[0]=e.BACK,r=!0);r&&e.drawBuffers(i)},useProgram:function(t){return d!==t&&(e.useProgram(t),d=t,!0)},setBlending:W,setMaterial:function(t,a){2===t.side?V(e.CULL_FACE):B(e.CULL_FACE);let s=1===t.side;a&&(s=!s),j(s),1===t.blending&&!1===t.transparent?W(0):W(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),i.setFunc(t.depthFunc),i.setTest(t.depthTest),i.setMask(t.depthWrite),n.setMask(t.colorWrite);const o=t.stencilWrite;r.setTest(o),o&&(r.setMask(t.stencilWriteMask),r.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),r.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?B(e.SAMPLE_ALPHA_TO_COVERAGE):V(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:j,setCullFace:X,setLineWidth:function(t){t!==M&&(P&&e.lineWidth(t),M=t)},setPolygonOffset:q,setScissorTest:function(t){t?B(e.SCISSOR_TEST):V(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+R-1),I!==t&&(e.activeTexture(t),I=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===I?e.TEXTURE0+R-1:I);let r=D[i];void 0===r&&(r={type:void 0,texture:void 0},D[i]=r),r.type===t&&r.texture===n||(I!==i&&(e.activeTexture(i),I=i),e.bindTexture(t,n||z[t]),r.type=t,r.texture=n)},unbindTexture:function(){const t=D[I];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){e("WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){e("WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){e("WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){e("WebGLState:",e)}},updateUBOMapping:function(t,n){let i=s.get(n);void 0===i&&(i=new WeakMap,s.set(n,i));let r=i.get(t);void 0===r&&(r=e.getUniformBlockIndex(n,t.name),i.set(t,r))},uniformBlockBinding:function(t,n){const i=s.get(n).get(t);a.get(n)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),a.set(n,i))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){e("WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){e("WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){e("WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){e("WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){e("WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){e("WebGLState:",e)}},scissor:function(t){!1===F.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),F.copy(t))},viewport:function(t){!1===O.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),O.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),i.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),o={},I=null,D={},l={},c=new WeakMap,u=[],d=null,h=!1,p=null,f=null,m=null,g=null,v=null,y=null,x=null,b=new Mf(0,0,0),_=0,w=!1,S=null,E=null,M=null,T=null,A=null,F.set(0,0,e.canvas.width,e.canvas.height),O.set(0,0,e.canvas.width,e.canvas.height),n.reset(),i.reset(),r.reset()}}}function Wy(e,t,n,i,r,a,s){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=t.has("OCULUS_multiview")?t.get("OCULUS_multiview"):null,u=new Dh,d=new WeakMap;let h;const p=new WeakMap;let f=[],m=!1,g=!1;try{g="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function v(e,t){return g?new OffscreenCanvas(e,t):vh("canvas")}function y(e,t,n){let i=1;const r=q(e);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===h&&(h=v(n,a));const s=t?v(n,a):h;s.width=n,s.height=a;return s.getContext("2d").drawImage(e,0,0,n,a),_h("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}return"data"in e&&_h("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function x(e){return e.generateMipmaps}function b(t){e.generateMipmap(t)}function _(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function w(n,i,r,a,s=!1){if(null!==n){if(void 0!==e[n])return e[n];_h("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RG8UI),r===e.UNSIGNED_SHORT&&(o=e.RG16UI),r===e.UNSIGNED_INT&&(o=e.RG32UI),r===e.BYTE&&(o=e.RG8I),r===e.SHORT&&(o=e.RG16I),r===e.INT&&(o=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGB8UI),r===e.UNSIGNED_SHORT&&(o=e.RGB16UI),r===e.UNSIGNED_INT&&(o=e.RGB32UI),r===e.BYTE&&(o=e.RGB8I),r===e.SHORT&&(o=e.RGB16I),r===e.INT&&(o=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(o=e.RGBA16UI),r===e.UNSIGNED_INT&&(o=e.RGBA32UI),r===e.BYTE&&(o=e.RGBA8I),r===e.SHORT&&(o=e.RGBA16I),r===e.INT&&(o=e.RGBA32I)),i===e.RGB&&(r===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(o=e.R11F_G11F_B10F)),i===e.RGBA){const t=s?nh:Gh.getTransfer(a);r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=t===ih?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return o!==e.R16F&&o!==e.R32F&&o!==e.RG16F&&o!==e.RG32F&&o!==e.RGBA16F&&o!==e.RGBA32F||t.get("EXT_color_buffer_float"),o}function S(t,n){let i;return t?null===n||n===sd||n===dd?i=e.DEPTH24_STENCIL8:n===od?i=e.DEPTH32F_STENCIL8:n===rd&&(i=e.DEPTH24_STENCIL8,_h("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===sd||n===dd?i=e.DEPTH_COMPONENT24:n===od?i=e.DEPTH_COMPONENT32F:n===rd&&(i=e.DEPTH_COMPONENT16),i}function E(e,t){return!0===x(e)||e.isFramebufferTexture&&e.minFilter!==Yu&&e.minFilter!==Zu?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function M(e){const t=e.target;t.removeEventListener("dispose",M),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=p.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&A(e),0===Object.keys(r).length&&p.delete(n)}i.remove(e)}(t),t.isVideoTexture&&d.delete(t)}function T(t){const n=t.target;n.removeEventListener("dispose",T),function(t){const n=i.get(t);t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i<n.__webglFramebuffer[t].length;i++)e.deleteFramebuffer(n.__webglFramebuffer[t][i]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=t.textures;for(let t=0,n=r.length;t<n;t++){const n=i.get(r[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),s.memory.textures--),i.remove(r[t])}i.remove(t)}(n)}function A(t){const n=i.get(t);e.deleteTexture(n.__webglTexture);const r=t.source;delete p.get(r)[n.__cacheKey],s.memory.textures--}let R=0;function P(t,r){const a=i.get(t);if(t.isVideoTexture&&function(e){const t=s.render.frame;d.get(e)!==t&&(d.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&a.__version!==t.version){const e=t.image;if(null===e)_h("WebGLRenderer: Texture marked for update but no image data found.");else if(!1===e.complete)_h("WebGLRenderer: Texture marked for update but image is incomplete");else if(O(a,t,r))return}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}function C(t,r){const a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?O(a,t,r):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r))}const L={[Xu]:e.REPEAT,[qu]:e.CLAMP_TO_EDGE,[$u]:e.MIRRORED_REPEAT},I={[Yu]:e.NEAREST,[Ku]:e.NEAREST_MIPMAP_NEAREST,[Qu]:e.NEAREST_MIPMAP_LINEAR,[Zu]:e.LINEAR,[Ju]:e.LINEAR_MIPMAP_NEAREST,[ed]:e.LINEAR_MIPMAP_LINEAR},D={[ah]:e.NEVER,[hh]:e.ALWAYS,[sh]:e.LESS,[lh]:e.LEQUAL,[oh]:e.EQUAL,[dh]:e.GEQUAL,[ch]:e.GREATER,[uh]:e.NOTEQUAL};function N(n,a){if(a.type!==od||!1!==t.has("OES_texture_float_linear")||a.magFilter!==Zu&&a.magFilter!==Ju&&a.magFilter!==Qu&&a.magFilter!==ed&&a.minFilter!==Zu&&a.minFilter!==Ju&&a.minFilter!==Qu&&a.minFilter!==ed||_h("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,L[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,L[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,L[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,I[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,I[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,D[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(a.magFilter===Yu)return;if(a.minFilter!==Qu&&a.minFilter!==ed)return;if(a.type===od&&!1===t.has("OES_texture_float_linear"))return;if(a.anisotropy>1||i.get(a).__currentAnisotropy){const s=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}}function k(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",M));const r=n.source;let a=p.get(r);void 0===a&&(a={},p.set(r,a));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&A(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function F(e,t,n){return Math.floor(Math.floor(e/n)/t)}function O(t,s,o){if(m)return s.isPendingDeferredUpload||(s.isPendingDeferredUpload=!0,f.push({textureProperties:t,texture:s,slot:o})),!1;let l=e.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=e.TEXTURE_3D);const c=k(t,s),u=s.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);const d=i.get(u);if(u.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+o);const t=Gh.getPrimaries(Gh.workingColorSpace),i=s.colorSpace===Jd?null:Gh.getPrimaries(s.colorSpace),h=s.colorSpace===Jd||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,h);let p=y(s.image,!1,r.maxTextureSize);p=X(s,p);const f=a.convert(s.format,s.colorSpace),m=a.convert(s.type);let g,v=w(s.internalFormat,f,m,s.colorSpace,s.isVideoTexture);N(l,s);const _=s.mipmaps,M=!0!==s.isVideoTexture,T=void 0===d.__version||!0===c,A=u.dataReady,R=E(s,p);if(s.isDepthTexture)v=S(s.format===gd,s.type),T&&(M?n.texStorage2D(e.TEXTURE_2D,1,v,p.width,p.height):n.texImage2D(e.TEXTURE_2D,0,v,p.width,p.height,0,f,m,null));else if(s.isDataTexture)if(_.length>0){M&&T&&n.texStorage2D(e.TEXTURE_2D,R,v,_[0].width,_[0].height);for(let t=0,i=_.length;t<i;t++)g=_[t],M?A&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,f,m,g.data):n.texImage2D(e.TEXTURE_2D,t,v,g.width,g.height,0,f,m,g.data);s.generateMipmaps=!1}else M?(T&&n.texStorage2D(e.TEXTURE_2D,R,v,p.width,p.height),A&&function(t,i,r,a){const s=t.updateRanges;if(0===s.length)n.texSubImage2D(e.TEXTURE_2D,0,0,0,i.width,i.height,r,a,i.data);else{s.sort((e,t)=>e.start-t.start);let o=0;for(let e=1;e<s.length;e++){const t=s[o],n=s[e],r=t.start+t.count,a=F(n.start,i.width,4),l=F(t.start,i.width,4);n.start<=r+1&&a===l&&F(n.start+n.count-1,i.width,4)===a?t.count=Math.max(t.count,n.start+n.count-t.start):(++o,s[o]=n)}s.length=o+1;const l=e.getParameter(e.UNPACK_ROW_LENGTH),c=e.getParameter(e.UNPACK_SKIP_PIXELS),u=e.getParameter(e.UNPACK_SKIP_ROWS);e.pixelStorei(e.UNPACK_ROW_LENGTH,i.width);for(let t=0,o=s.length;t<o;t++){const o=s[t],l=Math.floor(o.start/4),c=Math.ceil(o.count/4),u=l%i.width,d=Math.floor(l/i.width),h=c,p=1;e.pixelStorei(e.UNPACK_SKIP_PIXELS,u),e.pixelStorei(e.UNPACK_SKIP_ROWS,d),n.texSubImage2D(e.TEXTURE_2D,0,u,d,h,p,r,a,i.data)}t.clearUpdateRanges(),e.pixelStorei(e.UNPACK_ROW_LENGTH,l),e.pixelStorei(e.UNPACK_SKIP_PIXELS,c),e.pixelStorei(e.UNPACK_SKIP_ROWS,u)}}(s,p,f,m)):n.texImage2D(e.TEXTURE_2D,0,v,p.width,p.height,0,f,m,p.data);else if(s.isCompressedTexture)if(s.isCompressedArrayTexture){M&&T&&n.texStorage3D(e.TEXTURE_2D_ARRAY,R,v,_[0].width,_[0].height,p.depth);for(let t=0,i=_.length;t<i;t++)if(g=_[t],s.format!==fd)if(null!==f)if(M){if(A)if(s.layerUpdates.size>0){const i=vg(g.width,g.height,s.format,s.type);for(const r of s.layerUpdates){const a=g.data.subarray(r*i/g.data.BYTES_PER_ELEMENT,(r+1)*i/g.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,r,g.width,g.height,1,f,a)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,p.depth,f,g.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,v,g.width,g.height,p.depth,0,g.data,0,0);else _h("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else M?A&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,p.depth,f,m,g.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,v,g.width,g.height,p.depth,0,f,m,g.data)}else{M&&T&&n.texStorage2D(e.TEXTURE_2D,R,v,_[0].width,_[0].height);for(let t=0,i=_.length;t<i;t++)g=_[t],s.format!==fd?null!==f?M?A&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,f,g.data):n.compressedTexImage2D(e.TEXTURE_2D,t,v,g.width,g.height,0,g.data):_h("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):M?A&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,f,m,g.data):n.texImage2D(e.TEXTURE_2D,t,v,g.width,g.height,0,f,m,g.data)}else if(s.isDataArrayTexture)if(M){if(T&&n.texStorage3D(e.TEXTURE_2D_ARRAY,R,v,p.width,p.height,p.depth),A)if(s.layerUpdates.size>0){const t=vg(p.width,p.height,s.format,s.type);for(const i of s.layerUpdates){const r=p.data.subarray(i*t/p.data.BYTES_PER_ELEMENT,(i+1)*t/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,m,r)}s.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,m,p.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,v,p.width,p.height,p.depth,0,f,m,p.data);else if(s.isData3DTexture)M?(T&&n.texStorage3D(e.TEXTURE_3D,R,v,p.width,p.height,p.depth),A&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,m,p.data)):n.texImage3D(e.TEXTURE_3D,0,v,p.width,p.height,p.depth,0,f,m,p.data);else if(s.isFramebufferTexture){if(T)if(M)n.texStorage2D(e.TEXTURE_2D,R,v,p.width,p.height);else{let t=p.width,i=p.height;for(let r=0;r<R;r++)n.texImage2D(e.TEXTURE_2D,r,v,t,i,0,f,m,null),t>>=1,i>>=1}}else if(_.length>0){if(M&&T){const t=q(_[0]);n.texStorage2D(e.TEXTURE_2D,R,v,t.width,t.height)}for(let t=0,i=_.length;t<i;t++)g=_[t],M?A&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,f,m,g):n.texImage2D(e.TEXTURE_2D,t,v,f,m,g);s.generateMipmaps=!1}else if(M){if(T){const t=q(p);n.texStorage2D(e.TEXTURE_2D,R,v,t.width,t.height)}A&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,f,m,p)}else n.texImage2D(e.TEXTURE_2D,0,v,f,m,p);x(s)&&b(l),d.__version=u.version,s.onUpdate&&s.onUpdate(s)}return t.__version=s.version,!0}function U(t,r,s,l,u,d){const h=a.convert(s.format,s.colorSpace),p=a.convert(s.type),f=w(s.internalFormat,h,p,s.colorSpace),m=i.get(r),g=i.get(s);if(g.__renderTarget=r,!m.__hasExternalTextures){const t=Math.max(1,r.width>>d),i=Math.max(1,r.height>>d);!0===r.isWebGLMultiviewRenderTarget?n.texStorage3D(e.TEXTURE_2D_ARRAY,0,f,r.width,r.height,r.numViews):u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?n.texImage3D(u,d,f,t,i,r.depth,0,h,p,null):n.texImage2D(u,d,f,t,i,0,h,p,null)}n.bindFramebuffer(e.FRAMEBUFFER,t);const v=j(r);!0===r.isWebGLMultiviewRenderTarget?v?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,g.__webglTexture,0,W(r),0,r.numViews):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,g.__webglTexture,0,0,r.numViews):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&(v?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,g.__webglTexture,0,W(r)):e.framebufferTexture2D(e.FRAMEBUFFER,l,u,g.__webglTexture,d)),n.bindFramebuffer(e.FRAMEBUFFER,null)}function z(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),!0===n.isWebGLMultiviewRenderTarget){const t=j(n),r=n.numViews,a=n.depthTexture;let s=e.DEPTH_COMPONENT24,o=e.DEPTH_ATTACHMENT;a&&a.isDepthTexture&&(a.type===od?s=e.DEPTH_COMPONENT32F:a.type===dd&&(s=e.DEPTH24_STENCIL8,o=e.DEPTH_STENCIL_ATTACHMENT));let l=i.get(n.depthTexture).__webglTexture;void 0===l&&(l=e.createTexture(),e.bindTexture(e.TEXTURE_2D_ARRAY,l),e.texStorage3D(e.TEXTURE_2D_ARRAY,1,s,n.width,n.height,r)),t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,o,l,0,W(n),0,r):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,o,l,0,0,r)}else if(n.depthBuffer){const i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,s=S(n.stencilBuffer,a),l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=W(n);j(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,c,s,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,c,s,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,s,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,t)}else{const t=n.textures;for(let i=0;i<t.length;i++){const s=t[i],l=a.convert(s.format,s.colorSpace),c=a.convert(s.type),u=w(s.internalFormat,l,c,s.colorSpace),d=W(n);r&&!1===j(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,d,u,n.width,n.height):j(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,d,u,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,u,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function B(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const a=i.get(r.depthTexture);a.__renderTarget=r,a.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),1!=r.depthTexture.image.depth?C(r.depthTexture,0):P(r.depthTexture,0);const s=a.__webglTexture,l=W(r);if(!0===r.isWebGLMultiviewRenderTarget){const t=j(r),n=r.numViews;if(r.depthTexture.format===md)t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,s,0,l,0,n):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,s,0,0,n);else{if(r.depthTexture.format!==gd)throw new Error("Unknown depthTexture format");t?c.framebufferTextureMultisampleMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,s,0,l,0,n):c.framebufferTextureMultiviewOVR(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,s,0,0,n)}}else if(r.depthTexture.format===md)j(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0);else{if(r.depthTexture.format!==gd)throw new Error("Unknown depthTexture format");j(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0)}}function V(t){const r=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==t.depthTexture){const e=t.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),e){const t=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");const e=t.texture.mipmaps;e&&e.length>0?B(r.__webglFramebuffer[0],t):B(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=e.createRenderbuffer(),z(r.__webglDepthbuffer[i],t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{const i=t.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),z(r.__webglDepthbuffer,t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}const H=[],G=[];function W(e){return Math.min(r.maxSamples,e.samples)}function j(e){const n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function X(e,t){const n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==th&&n!==Jd&&(Gh.getTransfer(n)===ih?i===fd&&r===td||_h("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):wh("WebGLTextures: Unsupported texture color space:",n)),t}function q(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(u.width=e.naturalWidth||e.width,u.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(u.width=e.displayWidth,u.height=e.displayHeight):(u.width=e.width,u.height=e.height),u}this.allocateTextureUnit=function(){const e=R;return e>=r.maxTextures&&_h("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),R+=1,e},this.resetTextureUnits=function(){R=0},this.setTexture2D=P,this.setTexture2DArray=C,this.setTexture3D=function(t,r){const a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?O(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,s){const o=i.get(t);t.version>0&&o.__version!==t.version?function(t,s,o){if(6!==s.image.length)return;const l=k(t,s),c=s.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);const u=i.get(c);if(c.version!==u.__version||!0===l){n.activeTexture(e.TEXTURE0+o);const t=Gh.getPrimaries(Gh.workingColorSpace),i=s.colorSpace===Jd?null:Gh.getPrimaries(s.colorSpace),d=s.colorSpace===Jd||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const h=s.isCompressedTexture||s.image[0].isCompressedTexture,p=s.image[0]&&s.image[0].isDataTexture,f=[];for(let e=0;e<6;e++)f[e]=h||p?p?s.image[e].image:s.image[e]:y(s.image[e],!0,r.maxCubemapSize),f[e]=X(s,f[e]);const m=f[0],g=a.convert(s.format,s.colorSpace),v=a.convert(s.type),_=w(s.internalFormat,g,v,s.colorSpace),S=!0!==s.isVideoTexture,M=void 0===u.__version||!0===l,T=c.dataReady;let A,R=E(s,m);if(N(e.TEXTURE_CUBE_MAP,s),h){S&&M&&n.texStorage2D(e.TEXTURE_CUBE_MAP,R,_,m.width,m.height);for(let t=0;t<6;t++){A=f[t].mipmaps;for(let i=0;i<A.length;i++){const r=A[i];s.format!==fd?null!==g?S?T&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,r.width,r.height,g,r.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,_,r.width,r.height,0,r.data):_h("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,r.width,r.height,g,v,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,_,r.width,r.height,0,g,v,r.data)}}}else{if(A=s.mipmaps,S&&M){A.length>0&&R++;const t=q(f[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,R,_,t.width,t.height)}for(let t=0;t<6;t++)if(p){S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,f[t].width,f[t].height,g,v,f[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,_,f[t].width,f[t].height,0,g,v,f[t].data);for(let i=0;i<A.length;i++){const r=A[i].image[t].image;S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,r.width,r.height,g,v,r.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,_,r.width,r.height,0,g,v,r.data)}}else{S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,v,f[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,_,g,v,f[t]);for(let i=0;i<A.length;i++){const r=A[i];S?T&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,0,0,g,v,r.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i+1,_,g,v,r.image[t])}}}x(s)&&b(e.TEXTURE_CUBE_MAP),u.__version=c.version,s.onUpdate&&s.onUpdate(s)}t.__version=s.version}(o,t,s):n.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture,e.TEXTURE0+s)},this.rebindTextures=function(t,n,r){const a=i.get(t);void 0!==n&&U(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&V(t)},this.uploadTexture=O,this.setupRenderTarget=function(t){const r=t.texture,o=i.get(t),l=i.get(r);t.addEventListener("dispose",T);const c=t.textures,u=!0===t.isWebGLCubeRenderTarget,d=c.length>1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,s.memory.textures++),u){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n<r.mipmaps.length;n++)o.__webglFramebuffer[t][n]=e.createFramebuffer()}else o.__webglFramebuffer[t]=e.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let t=0;t<r.mipmaps.length;t++)o.__webglFramebuffer[t]=e.createFramebuffer()}else o.__webglFramebuffer=e.createFramebuffer();if(d)for(let t=0,n=c.length;t<n;t++){const n=i.get(c[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),s.memory.textures++)}if(t.samples>0&&!1===j(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const i=c[n];o.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,o.__webglColorRenderbuffer[n]);const r=a.convert(i.format,i.colorSpace),s=a.convert(i.type),l=w(i.internalFormat,r,s,i.colorSpace,!0===t.isXRRenderTarget),u=W(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,o.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(o.__webglDepthRenderbuffer=e.createRenderbuffer(),z(o.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),N(e.TEXTURE_CUBE_MAP,r);for(let n=0;n<6;n++)if(r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)U(o.__webglFramebuffer[n][i],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else U(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);x(r)&&b(e.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(d){for(let r=0,a=c.length;r<a;r++){const a=c[r],s=i.get(a);let l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(l,s.__webglTexture),N(l,a),U(o.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+r,l,0),x(a)&&b(l)}n.unbindTexture()}else{let i=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),!0===t.isWebGLMultiviewRenderTarget&&(i=e.TEXTURE_2D_ARRAY),n.bindTexture(i,l.__webglTexture),N(i,r),r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)U(o.__webglFramebuffer[n],t,r,e.COLOR_ATTACHMENT0,i,n);else U(o.__webglFramebuffer,t,r,e.COLOR_ATTACHMENT0,i,0);x(r)&&b(i),n.unbindTexture()}(t.depthBuffer||!0===t.isWebGLMultiviewRenderTarget)&&this.setupDepthRenderbuffer(t)},this.updateRenderTargetMipmap=function(e){const t=e.textures;for(let r=0,a=t.length;r<a;r++){const a=t[r];if(x(a)){const t=_(e),r=i.get(a).__webglTexture;n.bindTexture(t,r),b(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===j(t)){const r=t.textures,a=t.width,s=t.height;let o=e.COLOR_BUFFER_BIT;const c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=i.get(t),d=r.length>1;if(d)for(let t=0;t<r.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer);const h=t.texture.mipmaps;h&&h.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<r.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),d){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]);const t=i.get(r[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,s,0,0,a,s,o,e.NEAREST),!0===l&&(H.length=0,G.length=0,H.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&!1===t.resolveDepthBuffer&&(H.push(c),G.push(c),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,G)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),d)for(let t=0;t<r.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);const a=i.get(r[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&l){const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}},this.setupDepthTexture=B,this.setupDepthRenderbuffer=V,this.setupFrameBufferTexture=U,this.useMultisampledRTT=j,this.runDeferredUploads=function(){const e=m;m=!1;for(const e of f)O(e.textureProperties,e.texture,e.slot),e.texture.isPendingDeferredUpload=!1;f=[],m=e},this.setDeferTextureUploads=function(e){m=e}}function jy(e,t){return{convert:function(n,i=""){let r;const a=Gh.getTransfer(i);if(n===td)return e.UNSIGNED_BYTE;if(n===cd)return e.UNSIGNED_SHORT_4_4_4_4;if(n===ud)return e.UNSIGNED_SHORT_5_5_5_1;if(n===hd)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===pd)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===nd)return e.BYTE;if(n===id)return e.SHORT;if(n===rd)return e.UNSIGNED_SHORT;if(n===ad)return e.INT;if(n===sd)return e.UNSIGNED_INT;if(n===od)return e.FLOAT;if(n===ld)return e.HALF_FLOAT;if(1021===n)return e.ALPHA;if(1022===n)return e.RGB;if(n===fd)return e.RGBA;if(n===md)return e.DEPTH_COMPONENT;if(n===gd)return e.DEPTH_STENCIL;if(1028===n)return e.RED;if(n===vd)return e.RED_INTEGER;if(n===yd)return e.RG;if(n===xd)return e.RG_INTEGER;if(n===bd)return e.RGBA_INTEGER;if(n===_d||n===wd||n===Sd||n===Ed)if(a===ih){if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===_d)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===wd)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Sd)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ed)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=t.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===_d)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===wd)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Sd)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ed)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Md||n===Td||n===Ad||n===Rd){if(r=t.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Md)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Td)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ad)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Rd)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Pd||n===Cd||n===Ld){if(r=t.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===Pd||n===Cd)return a===ih?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ld)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(n===Id||n===Dd||n===Nd||n===kd||n===Fd||n===Od||n===Ud||n===zd||n===Bd||n===Vd||n===Hd||n===Gd||n===Wd||n===jd){if(r=t.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===Id)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Dd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Nd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===kd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Fd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Od)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ud)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===zd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Bd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Vd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Hd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Gd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Wd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===jd)return a===ih?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===Xd||n===qd||n===$d){if(r=t.get("EXT_texture_compression_bptc"),null===r)return null;if(n===Xd)return a===ih?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===qd)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===$d)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===Yd||n===Kd||n===Qd||n===Zd){if(r=t.get("EXT_texture_compression_rgtc"),null===r)return null;if(n===Yd)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Kd)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Qd)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Zd)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===dd?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}class Xy extends np{constructor(e,t,n,i={}){super(e,t,i),this.depthBuffer=!1,this.stencilBuffer=!1,this.numViews=n}copy(e){return super.copy(e),this.numViews=e.numViews,this}}Xy.prototype.isWebGLMultiviewRenderTarget=!0;class qy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){const n=new Xm(e.texture);e.depthNear===t.depthNear&&e.depthFar===t.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new cm({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new nm(new Km(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class $y extends Eh{constructor(e,t,n,i){super();const r=this;let a=null,s=1;var o=null;let l=null,c="local-floor",u=1,d=null,h=null;var p=[];let f=null,m=null,g=null,v=null;const y="undefined"!=typeof XRWebGLBinding,x=new qy,b={},_=t.getContextAttributes();let w=null,S=null;const E=[],M=[],T=new Dh;let A=null;const R=new fm;R.viewport=new ep;const P=new fm;P.viewport=new ep;const C=[R,P],L=new rg;let I=null,D=null;function N(e){const t=M.indexOf(e.inputSource);if(-1===t)return;const n=E[t];void 0!==n&&(n.update(e.inputSource,e.frame,d||l),n.dispatchEvent({type:e.type,data:e.inputSource}))}function k(){a.removeEventListener("select",N),a.removeEventListener("selectstart",N),a.removeEventListener("selectend",N),a.removeEventListener("squeeze",N),a.removeEventListener("squeezestart",N),a.removeEventListener("squeezeend",N),a.removeEventListener("end",k),a.removeEventListener("inputsourceschange",F);for(let e=0;e<E.length;e++){const t=M[e];null!==t&&(M[e]=null,E[e].disconnect(t))}I=null,D=null,x.reset();for(const e in b)delete b[e];r.isPresenting=!1,e.setRenderTarget(w),g=null,m=null,f=null,a=null,S=null,V.stop(),e.setPixelRatio(A),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}function F(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],i=M.indexOf(n);i>=0&&(M[i]=null,E[i].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let i=M.indexOf(n);if(-1===i){for(let e=0;e<E.length;e++){if(e>=M.length){M.push(n),i=e;break}if(null===M[e]){M[e]=n,i=e;break}}if(-1===i)break}const r=E[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.layersEnabled=!1,this.isPresenting=!1,this.isMultiview=!1,this.getCameraPose=function(){return h},this.getController=function(e){let t=E[e];return void 0===t&&(t=new _m,E[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=E[e];return void 0===t&&(t=new _m,E[e]=t),t.getGripSpace()},this.getHand=function(e){let t=E[e];return void 0===t&&(t=new _m,E[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){s=e,!0===r.isPresenting&&_h("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){c=e,!0===r.isPresenting&&_h("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||l},this.setReferenceSpace=function(e){d=e},this.getBaseLayer=function(){return null!==m?m:g},this.getBinding=function(){return null===f&&y&&(f=new XRWebGLBinding(a,t)),f},this.getFrame=function(){return v},this.getRenderTarget=function(){return S},this.getSession=function(){return a},this.setSession=async function(o){if(a=o,null!==a){w=e.getRenderTarget(),a.addEventListener("select",N),a.addEventListener("selectstart",N),a.addEventListener("selectend",N),a.addEventListener("squeeze",N),a.addEventListener("squeezestart",N),a.addEventListener("squeezeend",N),a.addEventListener("end",k),a.addEventListener("inputsourceschange",F),!0!==_.xrCompatible&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(T);if(y&&"createProjectionLayer"in XRWebGLBinding.prototype){let o=null,l=null,c=null;_.depth&&(c=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,o=_.stencil?gd:md,l=_.stencil?dd:sd),r.isMultiview=i&&n.has("OCULUS_multiview");const u={colorFormat:t.RGBA8,depthFormat:c,scaleFactor:s};r.isMultiview&&(u.textureType="texture-array"),f=this.getBinding(),m=f.createProjectionLayer(u),a.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1);const d={format:fd,type:td,depthTexture:new jm(m.textureWidth,m.textureHeight,l,void 0,void 0,void 0,void 0,void 0,void 0,o),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:!1===m.ignoreDepthValues,resolveStencilBuffer:!1===m.ignoreDepthValues};if(r.isMultiview){const e=n.get("OCULUS_multiview");this.maxNumViews=t.getParameter(e.MAX_VIEWS_OVR),S=new Xy(m.textureWidth,m.textureHeight,2,d)}else S=new np(m.textureWidth,m.textureHeight,d)}else{const n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};g=new XRWebGLLayer(a,t,n),a.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),S=new np(g.framebufferWidth,g.framebufferHeight,{format:fd,type:td,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:!1===g.ignoreDepthValues,resolveStencilBuffer:!1===g.ignoreDepthValues})}S.isXRRenderTarget=!0,this.setFoveation(u),d=null,l=await a.requestReferenceSpace(c),V.setContext(a),V.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==a)return a.environmentBlendMode},this.addLayer=function(e){window.XRWebGLBinding&&this.layersEnabled&&a&&(p.push(e),this.updateLayers())},this.removeLayer=function(e){p.splice(p.indexOf(e),1),window.XRWebGLBinding&&this.layersEnabled&&a&&this.updateLayers()},this.updateLayers=function(){var e=p.map(function(e){return e});e.unshift(a.renderState.layers[0]),a.updateRenderState({layers:e})},this.getDepthTexture=function(){return x.getDepthTexture()};const O=new kh,U=new kh;function z(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.setPoseTarget=function(e){void 0!==e&&(o=e)},this.updateCamera=function(e){if(null===a)return;let t=e.near,n=e.far;null!==x.texture&&(x.depthNear>0&&(t=x.depthNear),x.depthFar>0&&(n=x.depthFar)),L.near=P.near=R.near=t,L.far=P.far=R.far=n,I===L.near&&D===L.far||(a.updateRenderState({depthNear:L.near,depthFar:L.far}),I=L.near,D=L.far),L.layers.mask=6|e.layers.mask,R.layers.mask=3&L.layers.mask,P.layers.mask=5&L.layers.mask;const i=L.cameras;var r=o||e;const s=r.parent;z(L,s);for(let e=0;e<i.length;e++)z(i[e],s);2===i.length?function(e,t,n){O.setFromMatrixPosition(t.matrixWorld),U.setFromMatrixPosition(n.matrixWorld);const i=O.distanceTo(U),r=t.projectionMatrix.elements,a=n.projectionMatrix.elements,s=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],u=(r[8]-1)/r[0],d=(a[8]+1)/a[0],h=s*u,p=s*d,f=i/(-u+d),m=f*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===r[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{const t=s+f,n=o+f,r=h-m,a=p+(i-m),u=l*o/n*t,d=c*o/n*t;e.projectionMatrix.makePerspective(r,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(L,R,P):L.projectionMatrix.copy(R.projectionMatrix),function(e,t,n){t.matrixWorld.decompose(t.position,t.quaternion,t.scale),null===n.parent?n.matrix.copy(t.matrixWorld):(n.matrix.copy(n.parent.matrixWorld),n.matrix.invert(),n.matrix.multiply(t.matrixWorld));n.matrix.decompose(n.position,n.quaternion,n.scale),n.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*Ah*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,L,r)},this.getCamera=function(){return L},this.getFoveation=function(){if(null!==m||null!==g)return u},this.setFoveation=function(e){u=e,null!==m&&(m.fixedFoveation=e),null!==g&&void 0!==g.fixedFoveation&&(g.fixedFoveation=e)},this.hasDepthSensing=function(){return null!==x.texture},this.getDepthSensingMesh=function(){return x.getMesh(L)},this.getCameraTexture=function(e){return b[e]};let B=null;const V=new yg;V.setAnimationLoop(function(t,n){if(h=n.getViewerPose(d||l),v=n,null!==h){const t=h.views;null!==g&&(e.setRenderTargetFramebuffer(S,g.framebuffer),e.setRenderTarget(S));let n=!1;t.length!==L.cameras.length&&(L.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const r=t[i];let a=null;if(null!==g)a=g.getViewport(r);else{const t=f.getViewSubImage(m,r);a=t.viewport,0===i&&(e.setRenderTargetTextures(S,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(S))}let s=C[i];void 0===s&&(s=new fm,s.layers.enable(i),s.viewport=new ep,C[i]=s),s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.projectionMatrix.fromArray(r.projectionMatrix),s.projectionMatrixInverse.copy(s.projectionMatrix).invert(),s.viewport.set(a.x,a.y,a.width,a.height),0===i&&(L.matrix.copy(s.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),!0===n&&L.cameras.push(s)}const i=a.enabledFeatures;if(i&&i.includes("depth-sensing")&&"gpu-optimized"==a.depthUsage&&y){f=r.getBinding();const e=f.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&x.init(e,a.renderState)}if(i&&i.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let e=0;e<t.length;e++){const n=t[e].camera;if(n){let e=b[n];e||(e=new Xm,b[n]=e);const t=f.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<E.length;e++){const t=M[e],i=E[e];null!==t&&void 0!==i&&i.update(t,n,d||l)}B&&B(t,n),n.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:n}),v=null}),this.setAnimationLoop=function(e){B=e},this.dispose=function(){}}}const Yy=new Hp,Ky=new Ip;function Qy(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function i(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map,n(i.map,e.mapTransform)),i.alphaMap&&(e.alphaMap.value=i.alphaMap,n(i.alphaMap,e.alphaMapTransform)),i.bumpMap&&(e.bumpMap.value=i.bumpMap,n(i.bumpMap,e.bumpMapTransform),e.bumpScale.value=i.bumpScale,1===i.side&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,n(i.normalMap,e.normalMapTransform),e.normalScale.value.copy(i.normalScale),1===i.side&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,n(i.displacementMap,e.displacementMapTransform),e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,e.emissiveMapTransform)),i.specularMap&&(e.specularMap.value=i.specularMap,n(i.specularMap,e.specularMapTransform)),i.alphaTest>0&&(e.alphaTest.value=i.alphaTest);const r=t.get(i),a=r.envMap,s=r.envMapRotation;a&&(e.envMap.value=a,Yy.copy(s),Yy.x*=-1,Yy.y*=-1,Yy.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(Yy.y*=-1,Yy.z*=-1),e.envMapRotation.value.setFromMatrix4(Ky.makeRotationFromEuler(Yy)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,om(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Zy(e,t,n,i){let r={},a={},s=[];const o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,n,i){const r=e.value,a=t+"_"+n;if(void 0===i[a])return i[a]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const e=i[a];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return i[a]=r,!0}else if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?_h("WebGLRenderer: Texture samplers can not be part of an uniforms group."):_h("WebGLRenderer: Unsupported uniform value type.",e),t}function u(t){const n=t.target;n.removeEventListener("dispose",u);const i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,d){let h=r[n.id];void 0===h&&(!function(e){const t=e.uniforms;let n=0;const i=16;for(let e=0,r=t.length;e<r;e++){const r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){const t=r[e],a=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=a.length;e<r;e++){const r=c(a[e]),s=n%i,o=s%r.boundary,l=s+o;n+=o,0!==l&&i-l<r.storage&&(n+=i-l),t.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=r.storage}}}const r=n%i;r>0&&(n+=i-r);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;e<o;e++)if(-1===s.indexOf(e))return s.push(e),e;return wh("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const i=e.createBuffer(),r=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,i),e.bufferData(e.UNIFORM_BUFFER,r,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,i),i}(n),r[n.id]=h,n.addEventListener("dispose",u));const p=d.program;i.updateUBOMapping(n,p);const f=t.render.frame;a[n.id]!==f&&(!function(t){const n=r[t.id],i=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=i.length;t<n;t++){const n=Array.isArray(i[t])?i[t]:[i[t]];for(let i=0,r=n.length;i<r;i++){const r=n[i];if(!0===l(r,t,i,a)){const t=r.__offset,n=Array.isArray(r.value)?r.value:[r.value];let i=0;for(let a=0;a<n.length;a++){const s=n[a],o=c(s);"number"==typeof s||"boolean"==typeof s?(r.__data[0]=s,e.bufferSubData(e.UNIFORM_BUFFER,t+i,r.__data)):s.isMatrix3?(r.__data[0]=s.elements[0],r.__data[1]=s.elements[1],r.__data[2]=s.elements[2],r.__data[3]=0,r.__data[4]=s.elements[3],r.__data[5]=s.elements[4],r.__data[6]=s.elements[5],r.__data[7]=0,r.__data[8]=s.elements[6],r.__data[9]=s.elements[7],r.__data[10]=s.elements[8],r.__data[11]=0):(s.toArray(r.__data,i),i+=o.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,r.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),a[n.id]=f)},dispose:function(){for(const t in r)e.deleteBuffer(r[t]);s=[],r={},a={}}}}const Jy=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let ex=null;class tx{constructor(e={}){const{canvas:t=yh(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:s=!1,premultipliedAlpha:o=!0,preserveDrawingBuffer:l=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,multiviewStereo:h=!1}=e;let p;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const f=new Set([bd,xd,vd]),m=new Set([td,sd,rd,dd,cd,ud]),g=new Uint32Array(4),v=new Int32Array(4);let y=null,x=null;const b=[],_=[];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=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const w=this;let S=!1;this._outputColorSpace=eh;let E=0,M=0,T=null,A=-1,R=null;const P=new ep,C=new ep;let L=null;const I=new Mf(0);let D=0,N=t.width,k=t.height,F=1,O=null,U=null;const z=new ep(0,0,N,k),B=new ep(0,0,N,k);let V=!1;const H=new Lm;let G=!1,W=!1;const j=new Ip,X=new kh,q=new ep,$={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Y=!1;function K(){return null===T?F:1}let Q,Z,J,ee,te,ne,ie,re,ae,se,oe,le,ce,ue,de,he,pe,fe,me,ge,ve,ye,xe,be,_e,we=n;function Se(e,n){return t.getContext(e,n)}try{const e={alpha:!0,depth:i,stencil:r,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${pu}`),t.addEventListener("webglcontextlost",Te,!1),t.addEventListener("webglcontextrestored",Ae,!1),t.addEventListener("webglcontextcreationerror",Re,!1),null===we){const t="webgl2";if(we=Se(t,e),null===we)throw Se(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){throw e("WebGLRenderer: "+e.message),e}function Ee(){Q=new $g(we),Q.init(),xe=new jy(we,Q),Z=new Pg(we,Q,e,xe),J=new Gy(we,Q),Z.reversedDepthBuffer&&d&&J.buffers.depth.setReversed(!0),ee=new Qg(we),te=new Cy,ne=new Wy(we,Q,J,te,Z,xe,ee),ie=new Lg(w),re=new qg(w),ae=new xg(we),be=new Ag(we,ae),se=new Yg(we,ae,ee,be),oe=new ev(we,se,ae,ee),ge=new Zg(we,Z,ne),he=new Cg(te),le=new Py(w,ie,re,Q,Z,be,he),ce=new Qy(w,te),ue=new Ny,de=new By(Q),me=new Tg(w,ie,re,J,oe,p,o),fe=new Jg(w,Q,we),pe=new Vy(w,oe,Z),_e=new Zy(we,ee,Z,J),ve=new Rg(we,Q,ee),ye=new Kg(we,Q,ee),ee.programs=le.programs,w.capabilities=Z,w.extensions=Q,w.properties=te,w.renderLists=ue,w.shadowMap=pe,w.state=J,w.info=ee}Ee();const Me=new $y(w,we,Q,h);function Te(e){e.preventDefault(),bh("WebGLRenderer: Context Lost."),S=!0}function Ae(){bh("WebGLRenderer: Context Restored."),S=!1;const e=ee.autoReset,t=pe.enabled,n=pe.autoUpdate,i=pe.needsUpdate,r=pe.type;Ee(),ee.autoReset=e,pe.enabled=t,pe.autoUpdate=n,pe.needsUpdate=i,pe.type=r}function Re(e){wh("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Pe(e){const t=e.target;t.removeEventListener("dispose",Pe),function(e){(function(e){const t=te.get(e).programs;void 0!==t&&(t.forEach(function(e){le.releaseProgram(e)}),e.isShaderMaterial&&le.releaseShaderCache(e))})(e),te.remove(e)}(t)}function Ce(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,Be(e,t,n),e.side=0,e.needsUpdate=!0,Be(e,t,n),e.side=2):Be(e,t,n)}this.xr=Me,this.getContext=function(){return we},this.getContextAttributes=function(){return we.getContextAttributes()},this.forceContextLoss=function(){const e=Q.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=Q.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return F},this.setPixelRatio=function(e){void 0!==e&&(F=e,this.setSize(N,k,!1))},this.getSize=function(e){return e.set(N,k)},this.setSize=function(e,n,i=!0){Me.isPresenting?_h("WebGLRenderer: Can't change size while VR device is presenting."):(N=e,k=n,t.width=Math.floor(e*F),t.height=Math.floor(n*F),!0===i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(N*F,k*F).floor()},this.setDrawingBufferSize=function(e,n,i){N=e,k=n,F=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(P)},this.getViewport=function(e){return e.copy(z)},this.setViewport=function(e,t,n,i){e.isVector4?z.set(e.x,e.y,e.z,e.w):z.set(e,t,n,i),J.viewport(P.copy(z).multiplyScalar(F).round())},this.getScissor=function(e){return e.copy(B)},this.setScissor=function(e,t,n,i){e.isVector4?B.set(e.x,e.y,e.z,e.w):B.set(e,t,n,i),J.scissor(C.copy(B).multiplyScalar(F).round())},this.getScissorTest=function(){return V},this.setScissorTest=function(e){J.setScissorTest(V=e)},this.setOpaqueSort=function(e){O=e},this.setTransparentSort=function(e){U=e},this.getClearColor=function(e){return e.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor(...arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==T){const t=T.texture.format;e=f.has(t)}if(e){const e=T.texture.type,t=m.has(e),n=me.getClearColor(),i=me.getClearAlpha(),r=n.r,a=n.g,s=n.b;t?(g[0]=r,g[1]=a,g[2]=s,g[3]=i,we.clearBufferuiv(we.COLOR,0,g)):(v[0]=r,v[1]=a,v[2]=s,v[3]=i,we.clearBufferiv(we.COLOR,0,v))}else i|=we.COLOR_BUFFER_BIT}t&&(i|=we.DEPTH_BUFFER_BIT),n&&(i|=we.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),we.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Te,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",Re,!1),me.dispose(),ue.dispose(),de.dispose(),te.dispose(),ie.dispose(),re.dispose(),oe.dispose(),be.dispose(),_e.dispose(),le.dispose(),Me.dispose(),Me.removeEventListener("sessionstart",Ie),Me.removeEventListener("sessionend",De),Ne.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=$);const s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,n,i,r){!0!==t.isScene&&(t=$);ne.resetTextureUnits();const a=t.fog,s=i.isMeshStandardMaterial?t.environment:null,o=null===T?w.outputColorSpace:!0===T.isXRRenderTarget?T.texture.colorSpace:th,l=(i.isMeshStandardMaterial?re:ie).get(i.envMap||s),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),d=!!n.morphAttributes.position,h=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=0;i.toneMapped&&(null!==T&&!0!==T.isXRRenderTarget||(f=w.toneMapping));const m=T&&T.isWebGLMultiviewRenderTarget?T.numViews:0,g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,y=te.get(i),b=x.state.lights;if(!0===G&&(!0===W||e!==R)){const t=e===R&&i.id===A;he.setState(i,e,t)}let _=!1;i.version===y.__version?y.needsLights&&y.lightsStateVersion!==b.state.version||y.outputColorSpace!==o||r.isBatchedMesh&&!1===y.batching?_=!0:r.isBatchedMesh||!0!==y.batching?r.isBatchedMesh&&!0===y.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===y.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===y.instancing?_=!0:r.isInstancedMesh||!0!==y.instancing?r.isSkinnedMesh&&!1===y.skinning?_=!0:r.isSkinnedMesh||!0!==y.skinning?r.isInstancedMesh&&!0===y.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===y.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===y.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===y.instancingMorph&&null!==r.morphTexture||y.envMap!==l||!0===i.fog&&y.fog!==a?_=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===he.numPlanes&&y.numIntersection===he.numIntersection?(y.vertexAlphas!==c||y.vertexTangents!==u||y.morphTargets!==d||y.morphNormals!==h||y.morphColors!==p||y.toneMapping!==f||y.morphTargetsCount!==v||y.numMultiviewViews!==m)&&(_=!0):_=!0:_=!0:_=!0:_=!0:(_=!0,y.__version=i.version);let S=y.currentProgram;!0===_&&(S=Be(i,t,r));let E=!1,M=!1,P=!1;const C=S.getUniforms(),L=y.uniforms;J.useProgram(S.program)&&(E=!0,M=!0,P=!0);i.id!==A&&(A=i.id,M=!0);if(E||R!==e){if(S.numMultiviewViews>0)fe.updateCameraProjectionMatricesUniform(e,C),fe.updateCameraViewMatricesUniform(e,C);else{J.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),C.setValue(we,"projectionMatrix",e.projectionMatrix),C.setValue(we,"viewMatrix",e.matrixWorldInverse)}const t=C.map.cameraPosition;void 0!==t&&t.setValue(we,X.setFromMatrixPosition(e.matrixWorld)),Z.logarithmicDepthBuffer&&C.setValue(we,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&C.setValue(we,"isOrthographic",!0===e.isOrthographicCamera),R!==e&&(R=e,M=!0,P=!0)}if(r.isSkinnedMesh){C.setOptional(we,r,"bindMatrix"),C.setOptional(we,r,"bindMatrixInverse");const e=r.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),C.setValue(we,"boneTexture",e.boneTexture,ne))}r.isBatchedMesh&&(C.setOptional(we,r,"batchingTexture"),C.setValue(we,"batchingTexture",r._matricesTexture,ne),C.setOptional(we,r,"batchingIdTexture"),C.setValue(we,"batchingIdTexture",r._indirectTexture,ne),C.setOptional(we,r,"batchingColorTexture"),null!==r._colorsTexture&&C.setValue(we,"batchingColorTexture",r._colorsTexture,ne));const I=n.morphAttributes;void 0===I.position&&void 0===I.normal&&void 0===I.color||ge.update(r,n,S);(M||y.receiveShadow!==r.receiveShadow)&&(y.receiveShadow=r.receiveShadow,C.setValue(we,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(L.envMap.value=l,L.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);i.isMeshStandardMaterial&&null===i.envMap&&null!==t.environment&&(L.envMapIntensity.value=t.environmentIntensity);void 0!==L.dfgLUT&&(L.dfgLUT.value=(null===ex&&(ex=new Sm(Jy,32,32,yd,ld),ex.minFilter=Zu,ex.magFilter=Zu,ex.wrapS=qu,ex.wrapT=qu,ex.generateMipmaps=!1,ex.needsUpdate=!0),ex));M&&(C.setValue(we,"toneMappingExposure",w.toneMappingExposure),y.needsLights&&(N=P,(D=L).ambientLightColor.needsUpdate=N,D.lightProbe.needsUpdate=N,D.directionalLights.needsUpdate=N,D.directionalLightShadows.needsUpdate=N,D.pointLights.needsUpdate=N,D.pointLightShadows.needsUpdate=N,D.spotLights.needsUpdate=N,D.spotLightShadows.needsUpdate=N,D.rectAreaLights.needsUpdate=N,D.hemisphereLights.needsUpdate=N),a&&!0===i.fog&&ce.refreshFogUniforms(L,a),ce.refreshMaterialUniforms(L,i,F,k,x.state.transmissionRenderTarget[e.id]),ay.upload(we,Ve(y),L,ne));var D,N;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(ay.upload(we,Ve(y),L,ne),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&C.setValue(we,"center",r.center);S.numMultiviewViews>0?fe.updateObjectMatricesUniforms(r,e,C):(C.setValue(we,"modelViewMatrix",r.modelViewMatrix),C.setValue(we,"normalMatrix",r.normalMatrix));if(C.setValue(we,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++){const n=e[t];_e.update(n,S),_e.bind(n,S)}}return S}(e,t,n,i,r);J.setMaterial(i,s);let l=n.index,c=1;if(!0===i.wireframe){if(l=se.getWireframeAttribute(n),void 0===l)return;c=2}const u=n.drawRange,d=n.attributes.position;let h=u.start*c,p=(u.start+u.count)*c;null!==a&&(h=Math.max(h,a.start*c),p=Math.min(p,(a.start+a.count)*c)),null!==l?(h=Math.max(h,0),p=Math.min(p,l.count)):null!=d&&(h=Math.max(h,0),p=Math.min(p,d.count));const f=p-h;if(f<0||f===1/0)return;let m;be.setup(r,i,o,n,l);let g=ve;if(null!==l&&(m=ae.get(l),g=ye,g.setIndex(m)),r.isMesh)!0===i.wireframe?(J.setLineWidth(i.wireframeLinewidth*K()),g.setMode(we.LINES)):g.setMode(we.TRIANGLES);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),J.setLineWidth(e*K()),r.isLineSegments?g.setMode(we.LINES):r.isLineLoop?g.setMode(we.LINE_LOOP):g.setMode(we.LINE_STRIP)}else r.isPoints?g.setMode(we.POINTS):r.isSprite&&g.setMode(we.TRIANGLES);if(r.isBatchedMesh)if(null!==r._multiDrawInstances)Sh("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),g.renderMultiDrawInstances(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount,r._multiDrawInstances);else if(Q.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const e=r._multiDrawStarts,t=r._multiDrawCounts,n=r._multiDrawCount,a=l?ae.get(l).bytesPerElement:1,s=te.get(i).currentProgram.getUniforms();for(let i=0;i<n;i++)s.setValue(we,"_gl_DrawID",i),g.render(e[i]/a,t[i])}else if(r.isInstancedMesh)g.renderInstances(h,f,r.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);g.renderInstances(h,f,t)}else g.render(h,f)},this.compile=function(e,t,n=null){null===n&&(n=e),x=de.get(n),x.init(t),_.push(x),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),x.setupLights();const i=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;const t=e.material;if(t)if(Array.isArray(t))for(let r=0;r<t.length;r++){const a=t[r];Ce(a,n,e),i.add(a)}else Ce(t,n,e),i.add(t)}),x=_.pop(),i},this.compileAsync=function(e,t,n=null){const i=this.compile(e,t,n);return new Promise(t=>{function n(){i.forEach(function(e){te.get(e).currentProgram.isReady()&&i.delete(e)}),0!==i.size?setTimeout(n,10):t(e)}null!==Q.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let Le=null;function Ie(){Ne.stop()}function De(){Ne.start()}const Ne=new yg;function ke(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||H.intersectsSprite(e)){i&&q.setFromMatrixPosition(e.matrixWorld).applyMatrix4(j);const t=oe.update(e),r=e.material;r.visible&&y.push(e,t,r,n,q.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||H.intersectsObject(e))){const t=oe.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),q.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),q.copy(t.boundingSphere.center)),q.applyMatrix4(e.matrixWorld).applyMatrix4(j)),Array.isArray(r)){const i=t.groups;for(let a=0,s=i.length;a<s;a++){const s=i[a],o=r[s.materialIndex];o&&o.visible&&y.push(e,t,o,n,q.z,s)}}else r.visible&&y.push(e,t,r,n,q.z,null)}const r=e.children;for(let e=0,a=r.length;e<a;e++)ke(r[e],t,n,i)}function Fe(e,t,n,i){const{opaque:r,transmissive:a,transparent:s}=e;x.setupLightsView(n),!0===G&&he.setGlobalState(w.clippingPlanes,n),i&&J.viewport(P.copy(i)),r.length>0&&Ue(r,t,n),a.length>0&&Ue(a,t,n),s.length>0&&Ue(s,t,n),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function Oe(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===x.state.transmissionRenderTarget[i.id]&&(x.state.transmissionRenderTarget[i.id]=new np(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")||Q.has("EXT_color_buffer_float")?ld:td,minFilter:ed,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Gh.workingColorSpace}));const a=x.state.transmissionRenderTarget[i.id],s=i.viewport||P;a.setSize(s.z*w.transmissionResolutionScale,s.w*w.transmissionResolutionScale);const o=w.getRenderTarget(),l=w.getActiveCubeFace(),c=w.getActiveMipmapLevel();w.setRenderTarget(a),w.getClearColor(I),D=w.getClearAlpha(),D<1&&w.setClearColor(16777215,.5),w.clear(),Y&&me.render(n);const u=w.toneMapping;w.toneMapping=0;const d=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),x.setupLightsView(i),!0===G&&he.setGlobalState(w.clippingPlanes,i),Ue(e,n,i),ne.updateMultisampleRenderTarget(a),ne.updateRenderTargetMipmap(a),!1===Q.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let r=0,a=t.length;r<a;r++){const a=t[r],{object:s,geometry:o,material:l,group:c}=a;if(2===l.side&&s.layers.test(i.layers)){const t=l.side;l.side=1,l.needsUpdate=!0,ze(s,n,i,o,l,c),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(ne.updateMultisampleRenderTarget(a),ne.updateRenderTargetMipmap(a))}w.setRenderTarget(o,l,c),w.setClearColor(I,D),void 0!==d&&(i.viewport=d),w.toneMapping=u}function Ue(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r<a;r++){const a=e[r],{object:s,geometry:o,group:l}=a;let c=a.material;!0===c.allowOverride&&null!==i&&(c=i),s.layers.test(n.layers)&&ze(s,t,n,o,c,l)}}function ze(e,t,n,i,r,a){e.onBeforeRender(w,t,n,i,r,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(w,t,n,i,e,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,w.renderBufferDirect(n,t,i,r,e,a),r.side=0,r.needsUpdate=!0,w.renderBufferDirect(n,t,i,r,e,a),r.side=2):w.renderBufferDirect(n,t,i,r,e,a),e.onAfterRender(w,t,n,i,r,a)}function Be(e,t,n){!0!==t.isScene&&(t=$);const i=te.get(e),r=x.state.lights,a=x.state.shadowsArray,s=r.state.version,o=le.getParameters(e,r.state,a,t,n),l=le.getProgramCacheKey(o);let c=i.programs;i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?re:ie).get(e.envMap||i.environment),i.envMapRotation=null!==i.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===c&&(e.addEventListener("dispose",Pe),c=new Map,i.programs=c);let u=c.get(l);if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===s)return He(e,o),u}else o.uniforms=le.getUniforms(e),e.onBeforeCompile(o,w),u=le.acquireProgram(o,l),c.set(l,u),i.uniforms=o.uniforms;const d=i.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(d.clippingPlanes=he.uniform),He(e,o),i.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),i.lightsStateVersion=s,i.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMap.value=r.state.directionalShadowMap,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotShadowMap.value=r.state.spotShadowMap,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMap.value=r.state.pointShadowMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),i.currentProgram=u,i.uniformsList=null,u}function Ve(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=ay.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function He(e,t){const n=te.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping,n.numMultiviewViews=t.numMultiviewViews}var Ge;Ne.setAnimationLoop(function(e){Le&&Le(e)}),"undefined"!=typeof self&&Ne.setContext(self),this.setAnimationLoop=function(e){Le=e,Me.setAnimationLoop(e),null===e?Ne.stop():Ne.start()},Me.addEventListener("sessionstart",Ie),Me.addEventListener("sessionend",De),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void wh("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===S)return;if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Me.enabled&&!0===Me.isPresenting&&(!0===Me.cameraAutoUpdate&&Me.updateCamera(t),t=Me.getCamera()),!0===e.isScene&&e.onBeforeRender(w,e,t,T),x=de.get(e,_.length),x.init(t),_.push(x),j.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),H.setFromProjectionMatrix(j,fh,t.reversedDepth),W=this.localClippingEnabled,G=he.init(this.clippingPlanes,W),y=ue.get(e,b.length),y.init(),b.push(y),!0===Me.enabled&&!0===Me.isPresenting){const e=w.xr.getDepthSensingMesh();null!==e&&ke(e,t,-1/0,w.sortObjects)}ke(e,t,0,w.sortObjects),y.finish(),!0===w.sortObjects&&y.sort(O,U),Y=!1===Me.enabled||!1===Me.isPresenting||!1===Me.hasDepthSensing(),Y&&me.addToRenderList(y,e),this.info.render.frame++,!0===G&&he.beginShadows();const n=x.state.shadowsArray;pe.render(n,e,t),!0===G&&he.endShadows(),!0===this.info.autoReset&&this.info.reset();const i=y.opaque,r=y.transmissive;if(x.setupLights(),t.isArrayCamera){const n=t.cameras;if(r.length>0)for(let t=0,a=n.length;t<a;t++){Oe(i,r,e,n[t])}if(Y&&me.render(e),Me.enabled&&Me.isMultiview)ne.setDeferTextureUploads(!0),Fe(y,e,t,t.cameras[0].viewport);else for(let t=0,i=n.length;t<i;t++){const i=n[t];Fe(y,e,i,i.viewport)}}else r.length>0&&Oe(i,r,e,t),Y&&me.render(e),Fe(y,e,t);null!==T&&0===M&&(ne.updateMultisampleRenderTarget(T),ne.updateRenderTargetMipmap(T)),!0===e.isScene&&e.onAfterRender(w,e,t),ne.runDeferredUploads(),be.resetDefaultState(),A=-1,R=null,_.pop(),_.length>0?(x=_[_.length-1],!0===G&&he.setGlobalState(w.clippingPlanes,x.state.camera)):x=null,b.pop(),y=b.length>0?b[b.length-1]:null},this.setTexture2D=(Ge=!1,function(e,t){e&&e.isWebGLRenderTarget&&(Ge||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),Ge=!0),e=e.texture),ne.setTexture2D(e,t)}),this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(e,t,n){const i=te.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,i.__autoAllocateDepthBuffer||(i.__useRenderToTexture=!1),te.get(e.texture).__webglTexture=t,te.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){const n=te.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};const We=we.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){null===e&&this.xr.isPresenting&&(e=this.xr.getRenderTarget()),T=e,E=t,M=n;let i=!0,r=null,a=!1,s=!1;if(e){const o=te.get(e);if(void 0!==o.__useDefaultFramebuffer)J.bindFramebuffer(we.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)ne.setupRenderTarget(e);else if(o.__hasExternalTextures)ne.rebindTextures(e,te.get(e.texture).__webglTexture,te.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&te.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ne.setupDepthRenderbuffer(e)}}const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);const c=te.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],a=!0):r=e.samples>0&&!1===ne.useMultisampledRTT(e)?te.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,P.copy(e.viewport),C.copy(e.scissor),L=e.scissorTest}else P.copy(z).multiplyScalar(F).floor(),C.copy(B).multiplyScalar(F).floor(),L=V;0!==n&&(r=We);if(J.bindFramebuffer(we.FRAMEBUFFER,r)&&i&&J.drawBuffers(e,r),J.viewport(P),J.scissor(C),J.setScissorTest(L),a){const i=te.get(e.texture);we.framebufferTexture2D(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){const i=t;for(let t=0;t<e.textures.length;t++){const r=te.get(e.textures[t]);we.framebufferTextureLayer(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0+t,r.__webglTexture,n,i)}}else if(null!==e&&0!==n){const t=te.get(e.texture);we.framebufferTexture2D(we.FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,t.__webglTexture,n)}A=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s,o=0){if(!e||!e.isWebGLRenderTarget)return void wh("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=te.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){J.bindFramebuffer(we.FRAMEBUFFER,l);try{const s=e.textures[o],l=s.format,c=s.type;if(!Z.textureFormatReadable(l))return void wh("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(c))return void wh("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&(e.textures.length>1&&we.readBuffer(we.COLOR_ATTACHMENT0+o),we.readPixels(t,n,i,r,xe.convert(l),xe.convert(c),a))}finally{const e=null!==T?te.get(T).__webglFramebuffer:null;J.bindFramebuffer(we.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,i,r,a,s,o=0){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=te.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(l=l[s]),l){if(t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r){J.bindFramebuffer(we.FRAMEBUFFER,l);const s=e.textures[o],c=s.format,u=s.type;if(!Z.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(u))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const d=we.createBuffer();we.bindBuffer(we.PIXEL_PACK_BUFFER,d),we.bufferData(we.PIXEL_PACK_BUFFER,a.byteLength,we.STREAM_READ),e.textures.length>1&&we.readBuffer(we.COLOR_ATTACHMENT0+o),we.readPixels(t,n,i,r,xe.convert(c),xe.convert(u),0);const h=null!==T?te.get(T).__webglFramebuffer:null;J.bindFramebuffer(we.FRAMEBUFFER,h);const p=we.fenceSync(we.SYNC_GPU_COMMANDS_COMPLETE,0);return we.flush(),await function(e,t,n){return new Promise(function(i,r){setTimeout(function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:i()}},n)})}(we,p,4),we.bindBuffer(we.PIXEL_PACK_BUFFER,d),we.getBufferSubData(we.PIXEL_PACK_BUFFER,0,a),we.deleteBuffer(d),we.deleteSync(p),a}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){const i=Math.pow(2,-n),r=Math.floor(e.image.width*i),a=Math.floor(e.image.height*i),s=null!==t?t.x:0,o=null!==t?t.y:0;ne.setTexture2D(e,0),we.copyTexSubImage2D(we.TEXTURE_2D,n,0,0,s,o,r,a),J.unbindTexture()};const je=we.createFramebuffer(),Xe=we.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,i=null,r=0,a=null){let s,o,l,c,u,d,h,p,f;null===a&&(0!==r?(Sh("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),a=r,r=0):a=0);const m=e.isCompressedTexture?e.mipmaps[a]:e.image;if(null!==n)s=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{const t=Math.pow(2,-r);s=Math.floor(m.width*t),o=Math.floor(m.height*t),l=e.isDataArrayTexture?m.depth:e.isData3DTexture?Math.floor(m.depth*t):1,c=0,u=0,d=0}null!==i?(h=i.x,p=i.y,f=i.z):(h=0,p=0,f=0);const g=xe.convert(t.format),v=xe.convert(t.type);let y;t.isData3DTexture?(ne.setTexture3D(t,0),y=we.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(ne.setTexture2DArray(t,0),y=we.TEXTURE_2D_ARRAY):(ne.setTexture2D(t,0),y=we.TEXTURE_2D),we.pixelStorei(we.UNPACK_FLIP_Y_WEBGL,t.flipY),we.pixelStorei(we.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),we.pixelStorei(we.UNPACK_ALIGNMENT,t.unpackAlignment);const x=we.getParameter(we.UNPACK_ROW_LENGTH),b=we.getParameter(we.UNPACK_IMAGE_HEIGHT),_=we.getParameter(we.UNPACK_SKIP_PIXELS),w=we.getParameter(we.UNPACK_SKIP_ROWS),S=we.getParameter(we.UNPACK_SKIP_IMAGES);we.pixelStorei(we.UNPACK_ROW_LENGTH,m.width),we.pixelStorei(we.UNPACK_IMAGE_HEIGHT,m.height),we.pixelStorei(we.UNPACK_SKIP_PIXELS,c),we.pixelStorei(we.UNPACK_SKIP_ROWS,u),we.pixelStorei(we.UNPACK_SKIP_IMAGES,d);const E=e.isDataArrayTexture||e.isData3DTexture,M=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const n=te.get(e),i=te.get(t),m=te.get(n.__renderTarget),g=te.get(i.__renderTarget);J.bindFramebuffer(we.READ_FRAMEBUFFER,m.__webglFramebuffer),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<l;n++)E&&(we.framebufferTextureLayer(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,te.get(e).__webglTexture,r,d+n),we.framebufferTextureLayer(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,te.get(t).__webglTexture,a,f+n)),we.blitFramebuffer(c,u,s,o,h,p,s,o,we.DEPTH_BUFFER_BIT,we.NEAREST);J.bindFramebuffer(we.READ_FRAMEBUFFER,null),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,null)}else if(0!==r||e.isRenderTargetTexture||te.has(e)){const n=te.get(e),i=te.get(t);J.bindFramebuffer(we.READ_FRAMEBUFFER,je),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,Xe);for(let e=0;e<l;e++)E?we.framebufferTextureLayer(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,n.__webglTexture,r,d+e):we.framebufferTexture2D(we.READ_FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,n.__webglTexture,r),M?we.framebufferTextureLayer(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,i.__webglTexture,a,f+e):we.framebufferTexture2D(we.DRAW_FRAMEBUFFER,we.COLOR_ATTACHMENT0,we.TEXTURE_2D,i.__webglTexture,a),0!==r?we.blitFramebuffer(c,u,s,o,h,p,s,o,we.COLOR_BUFFER_BIT,we.NEAREST):M?we.copyTexSubImage3D(y,a,h,p,f+e,c,u,s,o):we.copyTexSubImage2D(y,a,h,p,c,u,s,o);J.bindFramebuffer(we.READ_FRAMEBUFFER,null),J.bindFramebuffer(we.DRAW_FRAMEBUFFER,null)}else M?e.isDataTexture||e.isData3DTexture?we.texSubImage3D(y,a,h,p,f,s,o,l,g,v,m.data):t.isCompressedArrayTexture?we.compressedTexSubImage3D(y,a,h,p,f,s,o,l,g,m.data):we.texSubImage3D(y,a,h,p,f,s,o,l,g,v,m):e.isDataTexture?we.texSubImage2D(we.TEXTURE_2D,a,h,p,s,o,g,v,m.data):e.isCompressedTexture?we.compressedTexSubImage2D(we.TEXTURE_2D,a,h,p,m.width,m.height,g,m.data):we.texSubImage2D(we.TEXTURE_2D,a,h,p,s,o,g,v,m);we.pixelStorei(we.UNPACK_ROW_LENGTH,x),we.pixelStorei(we.UNPACK_IMAGE_HEIGHT,b),we.pixelStorei(we.UNPACK_SKIP_PIXELS,_),we.pixelStorei(we.UNPACK_SKIP_ROWS,w),we.pixelStorei(we.UNPACK_SKIP_IMAGES,S),0===a&&t.generateMipmaps&&we.generateMipmap(y),J.unbindTexture()},this.initRenderTarget=function(e){void 0===te.get(e).__webglFramebuffer&&ne.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?ne.setTextureCube(e,0):e.isData3DTexture?ne.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ne.setTexture2DArray(e,0):ne.setTexture2D(e,0),J.unbindTexture()},this.resetState=function(){E=0,M=0,T=null,J.reset(),be.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return fh}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Gh._getDrawingBufferColorSpace(e),t.unpackColorSpace=Gh._getUnpackColorSpace()}}const nx=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];const ix=new Ip,rx=new Ip,ax={x:"XYZ",y:"YXZ",z:"ZXY"};function sx(e,t,n,i,r,a){ix.copy(n),null!=r&&ix.premultiply(rx.copy(r).invert());const s=new kh,o=new Nh,l=new kh;let c;ix.decompose(s,o,l),vx(s,i.initialTargetPosition,a.translate??!0);const u=a.rotate??!0;if(!1===u)o.copy(i.initialTargetQuaternion),c=i.initialTargetRotation.clone();else if(Array.isArray(u)||!0===u||"string"!=typeof u&&!Array.isArray(u)&&!0===u.x&&!0===u.y&&!0===u.z)c=(new Hp).setFromQuaternion(o,i.initialTargetRotation.order);else if("string"==typeof u){const e=ax[u];c=(new Hp).setFromQuaternion(o,e);for(const t of e){const e=t.toLowerCase();e!==u&&(c[e]=0)}c.order=i.initialTargetRotation.order,o.setFromEuler(c)}else c=function(e,t,n){let i="",r="";for(const e of t.order)!1===n[e.toLowerCase()]?r+=e:i+=e;const a=i+r,s=(new Hp).setFromQuaternion(e,a);for(const e of a){const i=e.toLowerCase();s[i]=yx(i,s[i],t[i],n)}return e.setFromEuler(s),s}(o,i.initialTargetRotation,u);return"object"==typeof a.scale&&a.scale.uniform||vx(l,i.initialTargetScale,a.scale??!0),{pointerAmount:t,position:s,quaternion:o,rotation:c,scale:l,time:e}}const ox=new Am,lx=new kh,cx=new kh,ux=new kh,dx=new Nh;function hx(e,t,n){return ox.normal.copy(e),ox.constant=0,function(e,t){if(0===t.x)return void e.set(1,0,0);if(0===t.y)return void e.set(0,1,0);if(0===t.z)return void e.set(0,0,1);e.set(-t.y,t.x,0)}(lx,ox.normal),cx.copy(lx),cx.applyQuaternion(dx.copy(t).invert().premultiply(n)),ox.projectPoint(lx,lx).normalize(),ox.projectPoint(cx,cx).normalize(),(ux.crossVectors(lx,ox.normal).dot(cx)<0?1:-1)*lx.angleTo(cx)}const px=new kh,fx=new Am,mx=new kh,gx=new kh;function vx(e,t,n){if(Array.isArray(n))switch(n.length){case 0:return void e.copy(t);case 1:return e.sub(t),Nx(e,n[0]instanceof kh?n[0]:px.fromArray(n[0])),void e.add(t);case 2:return px.crossVectors(n[0]instanceof kh?n[0]:mx.fromArray(n[0]),n[1]instanceof kh?n[1]:gx.fromArray(n[1])),fx.setFromNormalAndCoplanarPoint(px,t),void fx.projectPoint(e,e)}else e.x=yx("x",e.x,t.x,n),e.y=yx("y",e.y,t.y,n),e.z=yx("z",e.z,t.z,n)}function yx(e,t,n,i){if("boolean"==typeof i)return i?t:n;if("string"==typeof i)return i===e?t:n;const r=i[e];return!1===r?n:Array.isArray(r)?function(e,t,n){return Math.max(t,Math.min(n,e))}(t,...r):t}function xx(e=!0,t,n,i,r,a){if(e){switch(t.length){case 0:case 3:return;case 1:return void function(e,t,n,i,r){const a=null==r?0:1-Math.abs(t.dot(r));if(null==r||a<.001)return void Dx(i,e,t);Ix.subVectors(n,e);const s=t.dot(r),o=t.dot(Ix),l=r.dot(Ix),c=1-s*s,u=(o-s*l)/c;if((s*o-l)/c<0)return void Dx(i,e,t);Ix.copy(i),i.copy(e).addScaledVector(t,u)}(n,...t,i,r,a);case 2:return void function(e,t,n,i,r,a){Lx.crossVectors(e,t).normalize(),Cx.setFromNormalAndCoplanarPoint(Lx,n);const s=null==a?0:Math.abs(Lx.dot(a));if(null==a||s<.01)return void Cx.projectPoint(r,r);const o=Cx.distanceToPoint(i),l=-o/a.dot(Cx.normal);if(l<0)return void Cx.projectPoint(r,r);Ix.copy(r),r.copy(i).addScaledVector(a,l)}(...t,n,i,r,a)}throw new Error(`space cannot be ${t.length}D but received (${t.map(e=>e.toArray().join("/")).join("; ")})`)}}const bx={x:new kh(1,0,0),y:new kh(0,1,0),z:new kh(0,0,1)};function _x(e,t,n,i,r){if(!1!==i){if(!0===i)return e[0]=bx.x,e[1]=bx.y,void(e[2]=bx.z);if("string"!=typeof i)if(Array.isArray(i))for(const a of i)Ax(e,t,n,a,r);else!1!==i.x&&Ax(e,t,n,"x",r),!1!==i.y&&Ax(e,t,n,"y",r),!1!==i.z&&Ax(e,t,n,"z",r);else Ax(e,t,n,i,r)}}const wx=new Nh,Sx=new Hp,Ex=new kh,Mx=new kh,Tx=new kh;function Ax(e,t,n,i,r){if(Array.isArray(i)?Ex.set(...i):i instanceof kh?Ex.copy(i):Ex.copy(bx[i]),"translate"===r)return Ex.applyQuaternion(t),void Px(e,Ex);if("scale"===r)return Array.isArray(i)?wx.identity():wx.setFromEuler(n),wx.premultiply(t),Ex.applyQuaternion(wx),void Px(e,Ex);if(Array.isArray(i))Sx.set(0,0,0);else{Sx.copy(n);for(let e=2;e>=0;e--){const t=n.order[e].toLowerCase();if(Sx[t]=0,t===i)break}}wx.setFromEuler(Sx).premultiply(t),Ex.normalize(),Mx.set(0,1,0),Ex.dot(Mx)>.99&&Mx.set(0,0,1),Tx.crossVectors(Ex,Mx).normalize(),Mx.copy(Tx),Tx.applyQuaternion(wx),Px(e,Tx),Tx.crossVectors(Ex,Mx).normalize(),Tx.applyQuaternion(wx),Px(e,Tx)}const Rx=new kh;function Px(e,t){3!==e.length&&(0!==e.length?1!==e.length?(Rx.crossVectors(e[0],e[1]),Math.abs(Rx.dot(t))<.001||e.push(t.clone())):Math.abs(e[0].dot(t))<.999&&e.push(t.clone()):e.push(t.clone()))}const Cx=new Am,Lx=new kh,Ix=new kh;function Dx(e,t,n){e.sub(t),Nx(e,n),e.add(t)}function Nx(e,t){const n=e.dot(t);e.copy(t).multiplyScalar(n)}const kx=new Ip,Fx=new Ip,Ox=new kh,Ux=new kh,zx=new Nh,Bx=new kh(1,1,1),Vx=[];const Hx=new kh,Gx=new kh,Wx=new kh,jx=new kh,Xx=new kh,qx=new kh,$x=new kh,Yx=new Ip,Kx=new Ip,Qx=new Ip,Zx=new Nh,Jx=new Nh,eb=[];const tb=new kh,nb=new kh,ib=new kh,rb=new kh,ab=new kh,sb=new Nh,ob=new Nh,lb=new Ip,cb=new kh,ub=[];class db{t1;t2;_position;_quaternion;_rotation;_scale;constructor(e,t){this.t1=e,this.t2=t}get time(){return this.t1.time-this.t2.time}get position(){return this._position??=this.t1.position.clone().sub(this.t2.position)}get quaternion(){return this._quaternion??=this.t2.quaternion.clone().invert().premultiply(this.t1.quaternion)}get rotation(){return this._rotation??=(new Hp).setFromQuaternion(this.quaternion)}get scale(){return this._scale??=this.t1.scale.clone().sub(this.t2.scale)}}class hb{cancel;previous;memo;event;initial;current;first;last;_delta;_offset;constructor(e){this.cancel=e}start(e,t){this.event=e,this.previous=void 0,this.current=t,this.initial=t,this.first=!0,this.last=!1,this.memo=void 0,this._delta=void 0,this._offset=void 0}update(e,t){this.event=e,this.previous=this.current,this.current=t,this.first=!1,this.last=!1,this._delta=void 0,this._offset=void 0}end(e){this.event=e,this.first=!1,this.last=!0,this._delta=void 0,this._offset=void 0}get delta(){if(null!=this.previous)return this._delta??=new db(this.current,this.previous)}get offset(){return this._offset??=new db(this.current,this.initial)}}function pb(e,t){if("sphere"===e.details.type)return!1;if("lines"===e.details.type){const{line:n}=e.details;return t.copy(n.end).sub(n.start).normalize(),!0}return"screen-ray"===e.details.type?(t.copy(e.details.direction),!0):(t.set(0,0,-1).applyQuaternion(e.pointerQuaternion),!0)}const fb=new kh;class mb{target;getOptions;outputState;latestMoveEvent;inputState=new Map;capturedObjects=new Map;initialTargetPosition=new kh;initialTargetQuaternion=new Nh;initialTargetRotation=new Hp;initialTargetScale=new kh;initialTargetParentWorldMatrix;prevTwoPointerDeltaRotation;prevTranslateAsDeltaRotation;prevAngle;handlers={onPointerDown:this.onPointerDown.bind(this),onPointerMove:this.onPointerMove.bind(this),onPointerEnd:this.onPointerEnd.bind(this)};constructor(e,t=()=>({})){this.target=e,this.getOptions=t,this.outputState=new hb(this.cancel.bind(this))}firstOnPointer(e){const t=this.getTarget();if(null==t)return;const n=pb(e,fb)?fb.clone():void 0;e.intersection.details.type,this.inputState.set(e.pointerId,{pointerWorldDirection:n,pointerWorldPoint:e.point,pointerWorldOrigin:e.pointerPosition,pointerWorldQuaternion:e.pointerQuaternion,initialPointerWorldPoint:e.point.clone(),initialPointerWorldDirection:n?.clone(),initialPointerWorldQuaternion:e.pointerQuaternion.clone(),prevPointerWorldQuaternion:e.pointerQuaternion}),this.save(),1===this.inputState.size&&this.outputState.start(e,{pointerAmount:1,time:e.timeStamp,position:this.initialTargetPosition.clone(),quaternion:this.initialTargetQuaternion.clone(),rotation:this.initialTargetRotation.clone(),scale:this.initialTargetScale.clone()}),this.outputState.memo=this.apply(t)}onPointerDown(e){!1!==this.getOptions().filter?.(e)&&(this.stopPropagation(e),this.capturePointer(e.pointerId,e.object)&&this.firstOnPointer(e))}onPointerMove(e){if(!this.capturedObjects.has(e.pointerId))return;this.stopPropagation(e);const t=this.inputState.get(e.pointerId);null!=t?(this.latestMoveEvent=e,t.pointerWorldPoint=e.point,t.prevPointerWorldQuaternion=t.pointerWorldQuaternion,t.pointerWorldQuaternion=e.pointerQuaternion,t.pointerWorldOrigin=e.pointerPosition,null!=t.pointerWorldDirection&&pb(e,t.pointerWorldDirection)):this.firstOnPointer(e)}cancel(){if(0===this.capturedObjects.size)return;for(const[e,t]of this.capturedObjects)t.releasePointerCapture(e);this.capturedObjects.clear(),this.inputState.clear(),this.outputState.end(void 0);const e=this.getTarget();null!=e&&this.apply(e)}onPointerEnd(e){const t=this.capturedObjects.get(e.pointerId);null!=t&&(this.stopPropagation(e),this.releasePointer(e.pointerId,t,e))}update(e){const t=this.getTarget();if(null==t||0===this.inputState.size||null==this.latestMoveEvent&&!1===(this.getOptions().alwaysUpdate??!1))return;const n=this.getOptions();let i;if("as-rotate"===n.translate||"as-rotate-and-scale"===n.translate||"as-scale"===n.translate){n.translate,this.prevTwoPointerDeltaRotation=void 0,this.prevAngle=void 0;const[r]=this.inputState.values(),a=t.matrixWorld,s=t.parent?.matrixWorld;i=function(e,t,n,i,r,a){if(null==r?sb.identity():r.decompose(tb,sb,nb),ub.length=0,"as-scale"===a.translate&&_x(ub,sb,n.initialTargetRotation,a.scale??!0,"scale"),"as-scale"!=a.translate&&_x(ub,sb,n.initialTargetRotation,a.rotate??!0,"rotate"),lb.makeTranslation(n.initialTargetPosition),null!=n.initialTargetParentWorldMatrix&&lb.premultiply(n.initialTargetParentWorldMatrix),rb.setFromMatrixPosition(lb),xx(a.projectRays,ub,t.initialPointerWorldPoint,t.pointerWorldOrigin,rb,void 0),rb.negate().add(t.initialPointerWorldPoint),ab.setFromMatrixPosition(i),xx(a.projectRays,ub,t.initialPointerWorldPoint,t.pointerWorldOrigin,ab,void 0),xx(a.projectRays,ub,t.initialPointerWorldPoint,t.pointerWorldOrigin,nb.copy(t.pointerWorldPoint),t.pointerWorldDirection),ab.negate().add(nb),"as-scale"===a.translate?sb.copy(n.initialTargetQuaternion):(tb.copy(rb),null!=n.prevTranslateAsDeltaRotation&&tb.applyQuaternion(n.prevTranslateAsDeltaRotation),tb.normalize(),nb.copy(ab).normalize(),sb.setFromUnitVectors(tb,nb),null==n.prevTranslateAsDeltaRotation?n.prevTranslateAsDeltaRotation=new Nh:sb.multiply(n.prevTranslateAsDeltaRotation),n.prevTranslateAsDeltaRotation.copy(sb),null!=n.initialTargetParentWorldMatrix&&(ob.setFromRotationMatrix(n.initialTargetParentWorldMatrix),sb.multiply(ob.normalize()),sb.premultiply(ob.invert())),sb.multiply(n.initialTargetQuaternion)),"as-rotate"===a.translate)cb.set(1,1,1);else if("object"==typeof a.scale&&a.scale.uniform)cb.setScalar(ab.length()/rb.length());else if("as-rotate-and-scale"===a.translate){lb.compose(n.initialTargetPosition,n.initialTargetQuaternion,n.initialTargetScale),null!=n.initialTargetParentWorldMatrix&&lb.premultiply(n.initialTargetParentWorldMatrix),lb.decompose(nb,ob,ib),tb.copy(rb).applyQuaternion(ob.invert()).divide(ib),tb.x=Math.abs(tb.x),tb.y=Math.abs(tb.y),tb.z=Math.abs(tb.z);const e=Math.max(...tb.toArray());tb.divideScalar(e),cb.set(1,1,1),cb.addScaledVector(tb,ab.length()/rb.length()-1)}else null!=n.initialTargetParentWorldMatrix?(n.initialTargetParentWorldMatrix.decompose(tb,ob,nb),ob.multiply(n.initialTargetQuaternion)):ob.copy(n.initialTargetQuaternion),tb.copy(rb).applyQuaternion(ob.invert()),null!=r?(r.decompose(nb,ob,ib),ob.multiply(n.initialTargetQuaternion)):ob.copy(n.initialTargetQuaternion),nb.copy(ab).applyQuaternion(ob.invert()),cb.x=Math.abs(tb.x)<.001?1:Math.abs(nb.x/tb.x),cb.y=Math.abs(tb.y)<.001?1:Math.abs(nb.y/tb.y),cb.z=Math.abs(tb.z)<.001?1:Math.abs(nb.z/tb.z);return cb.multiply(n.initialTargetScale),lb.compose(n.initialTargetPosition,sb,cb),sx(e,1,lb,n,void 0,a)}(e,r,this,a,s,n)}else if(1===this.inputState.size){this.prevTwoPointerDeltaRotation=void 0,this.prevAngle=void 0,this.prevTranslateAsDeltaRotation=void 0;const[r]=this.inputState.values();i=function(e,t,n,i,r){return null==i?zx.identity():i.decompose(Ox,zx,Ux),Vx.length=0,_x(Vx,zx,n.initialTargetRotation,r.translate??!0,"translate"),Fx.makeRotationFromQuaternion(zx.copy(t.initialPointerWorldQuaternion).invert()).multiply(kx.makeTranslation(Ox.copy(t.initialPointerWorldPoint).negate())),null!=n.initialTargetParentWorldMatrix&&Fx.multiply(n.initialTargetParentWorldMatrix),xx(r.projectRays,Vx,t.initialPointerWorldPoint,t.pointerWorldOrigin,Ox.copy(t.pointerWorldPoint),t.pointerWorldDirection),zx.copy(t.pointerWorldQuaternion),!1===(r.rotate??!0)&&zx.copy(t.initialPointerWorldQuaternion),kx.compose(Ox,zx,Bx).multiply(Fx).multiply(Fx.compose(n.initialTargetPosition,n.initialTargetQuaternion,n.initialTargetScale)),sx(e,1,kx,n,i,r)}(e,r,this,t.parent?.matrixWorld,n)}else{this.prevTranslateAsDeltaRotation=void 0;const[r,a]=this.inputState.values();i=function(e,t,n,i,r,a){null==r?Zx.identity():r.decompose(Wx,Zx,jx),eb.length=0,_x(eb,Zx,i.initialTargetRotation,a.translate??!0,"translate"),_x(eb,Zx,i.initialTargetRotation,a.rotate??!0,"rotate"),_x(eb,Zx,i.initialTargetRotation,a.scale??!0,"scale"),xx(a.projectRays,eb,t.initialPointerWorldPoint,t.pointerWorldOrigin,Wx.copy(t.pointerWorldPoint),t.pointerWorldDirection),xx(a.projectRays,eb,n.initialPointerWorldPoint,n.pointerWorldOrigin,jx.copy(n.pointerWorldPoint),n.pointerWorldDirection),Hx.copy(n.initialPointerWorldPoint).sub(t.initialPointerWorldPoint),Gx.copy(jx).sub(Wx),Wx.copy(Hx),null!=i.prevTwoPointerDeltaRotation&&Wx.applyQuaternion(i.prevTwoPointerDeltaRotation),Wx.normalize(),jx.copy(Gx).normalize(),Zx.setFromUnitVectors(Wx,jx),null==i.prevTwoPointerDeltaRotation?i.prevTwoPointerDeltaRotation=new Nh:Zx.multiply(i.prevTwoPointerDeltaRotation),i.prevTwoPointerDeltaRotation.copy(Zx);const s=.5*(hx(jx,t.prevPointerWorldQuaternion,t.pointerWorldQuaternion)+hx(jx,n.prevPointerWorldQuaternion,n.pointerWorldQuaternion))+(i.prevAngle??0);if(i.prevAngle=s,Zx.premultiply(Jx.setFromAxisAngle(jx,s)),Qx.compose(i.initialTargetPosition,i.initialTargetQuaternion,i.initialTargetScale),null!=i.initialTargetParentWorldMatrix&&Qx.premultiply(i.initialTargetParentWorldMatrix),"object"==typeof a.scale&&a.scale.uniform)$x.setScalar(Gx.length()/Hx.length());else{Qx.decompose(Xx,Jx,qx),Wx.copy(Hx).applyQuaternion(Jx.invert()).divide(qx),Wx.x=Math.abs(Wx.x),Wx.y=Math.abs(Wx.y),Wx.z=Math.abs(Wx.z);const e=Math.max(...Wx.toArray());Wx.divideScalar(e),$x.set(1,1,1),$x.addScaledVector(Wx,Gx.length()/Hx.length()-1)}return Yx.makeTranslation(Wx.copy(Gx).multiplyScalar(.5).add(t.pointerWorldPoint)).multiply(Kx.makeRotationFromQuaternion(Zx)).multiply(Kx.makeRotationFromQuaternion(Jx.invert())).multiply(Kx.makeScale($x.x,$x.y,$x.z)).multiply(Kx.makeRotationFromQuaternion(Jx.invert())).multiply(Kx.makeTranslation(Wx.copy(Hx).multiplyScalar(.5).add(t.initialPointerWorldPoint).negate())).multiply(Qx),sx(e,2,Yx,i,r,a)}(e,r,a,this,t.parent?.matrixWorld,n)}this.outputState.update(this.latestMoveEvent,i),this.outputState.memo=this.apply(t),this.latestMoveEvent=void 0}getTarget(){return this.target instanceof sf?this.target:this.target?.current}capturePointer(e,t){if(this.capturedObjects.has(e))return!1;const{multitouch:n,translate:i}=this.getOptions();return(!1!==(n??!0)&&"string"!=typeof i||1!==this.capturedObjects.size)&&(this.capturedObjects.set(e,t),t.setPointerCapture(e),!0)}releasePointer(e,t,n){const i=this.getTarget();null!=i&&this.capturedObjects.delete(e)&&(this.inputState.delete(e),t.releasePointerCapture(e),this.inputState.size>0?this.save():(this.outputState.end(n),this.apply(i)))}stopPropagation(e){null!=e&&(this.getOptions()?.stopPropagation??1)&&e.stopPropagation()}apply(e){return(this.getOptions().apply??vb)(this.outputState,e)}getState(){return 0===this.inputState.size?void 0:this.outputState}save(){const e=this.getTarget();if(null!=e){e.updateWorldMatrix(!0,!1),this.prevAngle=void 0,this.prevTwoPointerDeltaRotation=void 0,this.prevTranslateAsDeltaRotation=void 0,this.initialTargetParentWorldMatrix=e.parent?.matrixWorld.clone(),e.matrixAutoUpdate?(this.initialTargetPosition.copy(e.position),this.initialTargetQuaternion.copy(e.quaternion),this.initialTargetRotation.copy(e.rotation),this.initialTargetScale.copy(e.scale)):(e.matrix.decompose(this.initialTargetPosition,this.initialTargetQuaternion,this.initialTargetScale),this.initialTargetRotation.setFromQuaternion(this.initialTargetQuaternion,e.rotation.order));for(const e of this.inputState.values())null!=e.pointerWorldDirection&&e.initialPointerWorldDirection?.copy(e.pointerWorldDirection),e.initialPointerWorldPoint.copy(e.pointerWorldPoint),e.initialPointerWorldQuaternion.copy(e.pointerWorldQuaternion)}}bind(e){const{onPointerDown:t,onPointerMove:n,onPointerEnd:i}=this.handlers;return e.addEventListener("pointerdown",t),e.addEventListener("pointermove",n),e.addEventListener("pointercancel",i),e.addEventListener("pointerup",i),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointermove",n),e.removeEventListener("pointercancel",i),e.removeEventListener("pointerup",i),this.cancel()}}capture(e,t){return this.capturePointer(e,t)?()=>this.releasePointer(e,t,void 0):gb}}function gb(){}function vb(e,t){t.position.copy(e.current.position),t.rotation.order=e.current.rotation.order,t.quaternion.copy(e.current.quaternion),t.scale.copy(e.current.scale)}class yb{target;getOptions;handles=[];hoveredTagMap=new Map;hoverSubscriptions=[];applySubscriptions=[];space;constructor(e,t){this.target=e,this.getOptions=t}getSpace(){return this.space??"world"}getTarget(){return this.target instanceof sf?this.target:this.target.current}getHandleOptions(e,t){const n=this.getOptions?.(),i=t?.();return{...n,...i,apply:(t,r)=>(this.onApply(e,t,r),(i?.apply??n?.apply??vb)?.(t,r))}}registerHandle(e,t,n){const i={object:t,store:e,tag:n};this.handles.push(i);const r=e.bind(t),a=this.onPointerEnter.bind(this,n),s=this.onPointerLeave.bind(this);return t.addEventListener("pointerenter",a),t.addEventListener("pointerleave",s),()=>{const t=this.handles.indexOf(i);-1!=t&&this.handles.splice(t,1),r(),e.cancel()}}subscribeHover(e){return this.hoverSubscriptions.push(e),e(Array.from(this.hoveredTagMap.values())),()=>{const t=this.hoverSubscriptions.indexOf(e);-1!==t&&this.hoverSubscriptions.splice(t,1)}}subscribeApply(e){return this.applySubscriptions.push(e),()=>{const t=this.applySubscriptions.indexOf(e);-1!==t&&this.applySubscriptions.splice(t,1)}}update(e){for(const{store:t}of this.handles)t.update(e)}onPointerEnter(e,t){this.hoveredTagMap.set(t.pointerId,e),this.updateHover()}onPointerLeave(e){this.hoveredTagMap.delete(e.pointerId),this.updateHover()}updateHover(){const e=Array.from(this.hoveredTagMap.values());for(const t of this.hoverSubscriptions)t(e)}onApply(e,t,n){for(const i of this.applySubscriptions)i(e,t,n)}}const xb={depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0};function bb(e,t,n,{color:i,hoverColor:r,hoverOpacity:a,opacity:s,disabled:o=!1}){return null==r&&null==a||o?(t.color.set(i),t.opacity=s??1,void(o&&(t.opacity*=.5,t.color.lerp(new Mf(1,1,1),.5)))):(r??=i,e.subscribeHover(e=>{const o=e.some(e=>e.includes(n));t.color.set(o?r:i),t.opacity=(o?a:s)??1}))}const _b=new Nh,wb=new Wf;wb.setAttribute("position",new Ff([-1e3,0,0,1e3,0,0],3));class Sb extends Wm{context;rotationOffset;constructor(e,t){super(wb),this.context=e,this.rotationOffset=t,this.renderOrder=1/0}update(){this.quaternion.setFromEuler(this.rotationOffset);const e=this.context.getTarget();"world"===this.context.getSpace()&&null!=e&&(e.getWorldQuaternion(_b).invert(),this.quaternion.premultiply(_b))}bind(e){this.material=new Im({...xb,color:this.material.color??"white",opacity:this.material.opacity??1});const t=this.context.subscribeHover(t=>{const n=t.some(t=>t.includes(e));this.visible=n}),n=this.context.subscribeApply((e,t)=>{if(t.last)return void this.position.set(0,0,0);this.position.copy(t.initial.position).sub(t.current.position);const n=this.context.getTarget();null!=n&&(_b.copy(n.quaternion).invert(),this.position.applyQuaternion(_b))});return()=>{this.material.dispose(),t(),n()}}}class Eb extends xm{context;axis;store;options;tag;constructor(e,t,n,i){super(),this.context=e,this.axis=t,this.tag=(n??"")+t,this.store=new mb(e.target,()=>e.getHandleOptions(this.tag,i))}}function Mb(e,t=!0){if(!1===t)return{options:!1,disabled:!0};if(!0===t){const t={x:!1,y:!1,z:!1,e:!1};for(const n of e)t[n]=!0;return{options:t,disabled:!1}}if("disabled"===t)return{options:{x:!0,y:!0,z:!0,e:!0},disabled:!0};if("string"==typeof t)return{options:t===e&&{x:!1,y:!1,z:!1,e:!1,[e]:!0},disabled:!1};const n={x:!1,y:!1,z:!1,e:!1};let i=!1;for(const r of e){let e=t[r]??!0;if(!1===e)return{options:!1,disabled:!0};"disabled"===e&&(i=!0,e=!0),n[r]=e}return{options:n,disabled:i}}const Tb=new kh,Ab=new kh;function Rb(e,t,n,i){if(!n)return i;let r;return t instanceof ig?r=(t.top-t.bottom)/t.zoom:(t.getWorldPosition(Tb),e.getWorldPosition(Ab),r=Tb.distanceTo(Ab)*Math.min(1.9*Math.tan(Math.PI*t.fov/360)/t.zoom,7)),r*i/4}const Pb=new qm(0,.04,.1,12);Pb.translate(0,.05,0);const Cb=new qm(.0075,.0075,.5,3);Cb.translate(0,.25,0);const Lb=new Hp(0,0,-Math.PI/2),Ib=new Hp(0,0,Math.PI/2);class Db extends Eb{invert;showArrowBody;constructor(e,t,n="",i,r=!1,a=!0){super(e,t,n,()=>({scale:!1,rotate:!1,translate:null!=i?[i]:this.options,multitouch:!1})),this.invert=r,this.showArrowBody=a}bind(e,t,n){const{options:i,disabled:r}=Mb(this.axis,n);if(!1===i)return;this.options=i;const a=this.invert?Ib:Lb,s=new Pf(xb),o=bb(this.context,s,this.tag,{color:e,hoverColor:t,disabled:r}),l=new nm(Pb,s);let c,u;if(l.renderOrder=1/0,l.position.x=this.invert?-.5:.5,l.rotation.copy(a),this.add(l),this.showArrowBody){const t=new Pf(xb);c=bb(this.context,t,this.tag,{color:e,hoverColor:16777024,disabled:r}),u=new nm(Cb,t),u.renderOrder=1/0,u.rotation.copy(a),this.add(u)}const d=new nm(new qm(.13,0,.6,4));d.pointerEventsOrder=1/0,d.position.x=this.invert?-.3:.3,d.rotation.copy(a),d.visible=!1,this.add(d);const h=r?void 0:this.context.registerHandle(this.store,d,this.tag);return()=>{s.dispose(),h?.(),o?.(),c?.(),this.remove(l),null!=u&&this.remove(u),this.remove(d)}}}class Nb extends Eb{constructor(e,t,n="",i){super(e,t,n,()=>({translate:i??this.options,scale:!1,rotate:!1,multitouch:!1}))}bind(e,t,n){const{options:i,disabled:r}=Mb(this.axis,n);if(!1===i)return;this.options=i;const a=new Pf(xb),s=bb(this.context,a,this.tag,{opacity:.5,hoverOpacity:1,color:e,hoverColor:t,disabled:r}),o=new nm(new rm(.2,.2,.01),a);o.renderOrder=1/0,o.pointerEventsOrder=1/0,o.position.set(.15,.15,0);const l=r?void 0:this.context.registerHandle(this.store,o,this.tag);return this.add(o),()=>{a.dispose(),o.geometry.dispose(),l?.(),s?.(),this.remove(o)}}}new kh;const kb=new Nh;class Fb extends Eb{constructor(e){super(e,"xyz","",()=>({translate:this.options,scale:!1,rotate:!1,multitouch:!1}))}bind(e){const{options:t,disabled:n}=Mb(this.axis,e);if(!1===t)return;this.options=t;const i=new Pf(xb),r=bb(this.context,i,this.tag,{color:16777215,hoverColor:16776960,opacity:.25,hoverOpacity:1,disabled:n}),a=new nm(new Ym(.1,0),i);a.renderOrder=1/0,this.add(a);const s=new nm(new Ym(.2,0));s.pointerEventsOrder=1/0,s.visible=!1,this.add(s);const o=n?void 0:this.context.registerHandle(this.store,s,this.tag);return()=>{i.dispose(),a.geometry.dispose(),s.geometry.dispose(),o?.(),r?.(),this.remove(a),this.remove(s)}}}const Ob=new kh,Ub=new Nh,zb=new Nh,Bb=(new Nh).setFromEuler(new Hp(0,0,Math.PI/2)),Vb=(new Nh).setFromEuler(new Hp(0,-Math.PI/2,0)),Hb=new Nh,Gb=(new Nh).setFromEuler(new Hp(0,-Math.PI/2,0)),Wb=(new Nh).setFromEuler(new Hp(Math.PI/2,0,0));class jb extends xm{context;size;fixed;free;translationX;translationY;translationZ;translationNegX;translationNegY;translationNegZ;translationXY;translationYZ;translationXZ;scaleGroup=new xm;xAxis=new kh;yAxis=new kh;zAxis=new kh;negXAxis=new kh;negYAxis=new kh;negZAxis=new kh;constructor(e,t,n){super(),this.context=e,this.size=t,this.fixed=n,this.add(this.scaleGroup),this.free=new Fb(this.context),this.scaleGroup.add(this.free),this.translationX=new Db(this.context,"x",void 0,this.xAxis),this.scaleGroup.add(this.translationX),this.translationY=new Db(this.context,"y",void 0,this.yAxis),this.scaleGroup.add(this.translationY),this.translationZ=new Db(this.context,"z",void 0,this.zAxis),this.scaleGroup.add(this.translationZ),this.translationNegX=new Db(this.context,"x",void 0,this.negXAxis,!0,!1),this.scaleGroup.add(this.translationNegX),this.translationNegY=new Db(this.context,"y",void 0,this.negYAxis,!0,!1),this.scaleGroup.add(this.translationNegY),this.translationNegZ=new Db(this.context,"z",void 0,this.negZAxis,!0,!1),this.scaleGroup.add(this.translationNegZ),this.translationXY=new Nb(this.context,"xy",void 0,[this.xAxis,this.yAxis]),this.scaleGroup.add(this.translationXY),this.translationXZ=new Nb(this.context,"xz",void 0,[this.xAxis,this.zAxis]),this.scaleGroup.add(this.translationXZ),this.translationYZ=new Nb(this.context,"yz",void 0,[this.yAxis,this.zAxis]),this.scaleGroup.add(this.translationYZ)}update(e){this.updateWorldMatrix(!0,!1),this.xAxis.set(1,0,0),this.yAxis.set(0,1,0),this.zAxis.set(0,0,1),this.free.quaternion.identity(),this.translationX.quaternion.copy(zb),this.translationY.quaternion.copy(Bb),this.translationZ.quaternion.copy(Vb),this.translationNegX.quaternion.copy(zb),this.translationNegY.quaternion.copy(Bb),this.translationNegZ.quaternion.copy(Vb),this.translationXY.quaternion.copy(Hb),this.translationYZ.quaternion.copy(Gb),this.translationXZ.quaternion.copy(Wb);const t=this.context.getSpace(),n=this.context.getTarget();"world"==t&&null!=n?(n.getWorldQuaternion(Ub).invert(),this.free.quaternion.premultiply(Ub),this.translationX.quaternion.premultiply(Ub),this.translationY.quaternion.premultiply(Ub),this.translationZ.quaternion.premultiply(Ub),this.translationNegX.quaternion.premultiply(Ub),this.translationNegY.quaternion.premultiply(Ub),this.translationNegZ.quaternion.premultiply(Ub),this.translationXY.quaternion.premultiply(Ub),this.translationYZ.quaternion.premultiply(Ub),this.translationXZ.quaternion.premultiply(Ub),null!=n.parent&&(n.parent.getWorldQuaternion(Ub).invert(),this.xAxis.applyQuaternion(Ub),this.yAxis.applyQuaternion(Ub),this.zAxis.applyQuaternion(Ub))):null!=n&&(this.xAxis.applyQuaternion(n.quaternion),this.yAxis.applyQuaternion(n.quaternion),this.zAxis.applyQuaternion(n.quaternion)),this.negXAxis.copy(this.xAxis).negate(),this.negYAxis.copy(this.yAxis).negate(),this.negZAxis.copy(this.zAxis).negate(),this.scaleGroup.scale.setScalar(1),null!=n&&(n.getWorldScale(Ob),this.scaleGroup.scale.divide(Ob)),this.scaleGroup.scale.multiplyScalar(Rb(this,e,this.fixed??!0,this.size??1))}bind(e){const t=function(e,t){const n=new nm(new Ym(.01,2),new Pf(xb));n.renderOrder=1/0,n.visible=!1,e.add(n);const i=new nm(new Ym(.01,2),new Pf(xb));i.renderOrder=1/0,i.visible=!1,e.add(i);const r=new Wf;r.setAttribute("position",new Ff([0,0,0,1,1,1],3));const a=new Wm(r,new Im(xb));a.renderOrder=1/0,a.visible=!1,e.add(a);const s=t.subscribeApply((e,r)=>{i.position.set(0,0,0),n.position.copy(r.initial.position).sub(r.current.position);const s=t.getTarget();null!=s&&(kb.copy(s.quaternion).invert(),n.position.applyQuaternion(kb)),a.position.set(0,0,0),a.scale.copy(n.position),n.visible=!r.last,a.visible=!r.last,i.visible=!r.last});return()=>{n.geometry.dispose(),n.material.dispose(),i.geometry.dispose(),i.material.dispose(),a.geometry.dispose(),a.material.dispose(),e.remove(n),e.remove(i),e.remove(a),s()}}(this,this.context),n=this.translationX.bind(16711680,16776960,e),i=this.translationY.bind(65280,16776960,e),r=this.translationZ.bind(255,16776960,e),a=this.translationNegX.bind(16711680,16776960,e),s=this.translationNegY.bind(65280,16776960,e),o=this.translationNegZ.bind(255,16776960,e),l=this.translationXY.bind(255,16776960,e),c=this.translationYZ.bind(16711680,16776960,e),u=this.translationXZ.bind(65280,16776960,e),d=this.free.bind(e);return()=>{t(),n?.(),i?.(),r?.(),a?.(),s?.(),o?.(),l?.(),c?.(),u?.(),d?.()}}}const Xb=new Hp(0,0,-Math.PI/2),qb=new Hp(0,0,Math.PI/2);class $b extends Eb{invert;showHandleLine;constructor(e,t,n="",i=!1,r=!0){super(e,t,n,()=>({scale:this.options,rotate:!1,translate:"as-scale",multitouch:!1})),this.invert=i,this.showHandleLine=r}bind(e,t,n){const{options:i,disabled:r}=Mb(this.axis,n);if(!1===i)return;this.options=i;const a=this.invert?qb:Xb,s=new xm;s.position.x=this.invert?-.5:.5,s.rotation.copy(a),this.add(s);const o=new Pf(xb),l=bb(this.context,o,this.tag,{color:e,hoverColor:t,disabled:r}),c=new nm(new rm(.08,.08,.08),o);let u,d,h;if(c.renderOrder=1/0,c.rotation.copy(a),s.add(c),this.showHandleLine){h=new xm,h.rotation.copy(a),this.add(h);const n=new Pf(xb);u=bb(this.context,n,this.tag,{color:e,hoverColor:t,disabled:r}),d=new nm(new qm(.0075,.0075,.5,3),n),d.renderOrder=1/0,d.position.y=.25,h.add(d)}const p=new xm;p.visible=!1,p.rotation.copy(a),p.position.x=this.invert?-.3:.3,this.add(p);const f=new nm(new qm(.2,0,.5,4));f.pointerEventsOrder=1/0,f.position.y=.04,p.add(f);const m=r?void 0:this.context.registerHandle(this.store,f,this.tag);return()=>{o.dispose(),f.geometry.dispose(),c.geometry.dispose(),d?.geometry.dispose(),m?.(),l?.(),u?.(),null!=h&&this.remove(h),this.remove(p),this.remove(s)}}}class Yb extends Eb{constructor(e,t,n=""){super(e,t,n,()=>({translate:"as-scale",scale:this.options,rotate:!1,multitouch:!1}))}bind(e,t,n){const{options:i,disabled:r}=Mb(this.axis,n);if(!1===i)return;this.options=i;const a=new Pf(xb),s=bb(this.context,a,this.tag,{opacity:.5,hoverOpacity:1,color:e,hoverColor:t,disabled:r}),o=new nm(new rm(.2,.2,.01),a);o.renderOrder=1/0,o.pointerEventsOrder=1/0,o.position.set(.15,.15,0);const l=r?void 0:this.context.registerHandle(this.store,o,this.tag);return this.add(o),()=>{a.dispose(),o.geometry.dispose(),l?.(),s?.(),this.remove(o)}}}const Kb=new Hp(0,0,-Math.PI/2),Qb=new Hp(0,0,Math.PI/2);class Zb extends Eb{actualAxis;invert;constructor(e,t="",n,i=!1){super(e,"xyz",t,()=>({scale:{uniform:!0,...this.options},rotate:!1,translate:"as-scale",multitouch:!1})),this.actualAxis=n,this.invert=i}bind(e,t,n){const{options:i,disabled:r}=Mb(this.actualAxis,n);if(!1===i)return;this.options=i;const a=this.invert?Qb:Kb,s=new xm;s.position.x=this.invert?-.7:.7,s.rotation.copy(a),this.add(s);const o=new Pf(xb),l=bb(this.context,o,this.tag,{color:e,hoverColor:t,opacity:.5,hoverOpacity:1,disabled:r}),c=new nm(new rm(.08,.08,.08),o);c.renderOrder=1/0,c.rotation.copy(a),s.add(c);const u=new nm(new rm(.15,.15,.15),o);u.visible=!1,u.pointerEventsOrder=1/0,u.rotation.copy(a),s.add(u);const d=r?void 0:this.context.registerHandle(this.store,u,this.tag);return()=>{o.dispose(),c.geometry.dispose(),d?.(),l?.(),this.remove(s)}}}const Jb=new kh;class e_ extends xm{context;size;fixed;scaleX;scaleY;scaleZ;scaleNegX;scaleNegY;scaleNegZ;translationX;translationY;translationZ;translationNegX;translationNegY;translationNegZ;translationXY;translationYZ;translationXZ;constructor(e,t,n){super(),this.context=e,this.size=t,this.fixed=n,this.scaleX=new Zb(this.context,void 0,"x"),this.add(this.scaleX),this.scaleY=new Zb(this.context,void 0,"y"),this.scaleY.rotation.z=Math.PI/2,this.add(this.scaleY),this.scaleZ=new Zb(this.context,void 0,"z"),this.scaleZ.rotation.y=-Math.PI/2,this.add(this.scaleZ),this.scaleNegX=new Zb(this.context,void 0,"x",!0),this.add(this.scaleNegX),this.scaleNegY=new Zb(this.context,void 0,"y",!0),this.scaleNegY.rotation.z=Math.PI/2,this.add(this.scaleNegY),this.scaleNegZ=new Zb(this.context,void 0,"z",!0),this.scaleNegZ.rotation.y=-Math.PI/2,this.add(this.scaleNegZ),this.translationX=new $b(this.context,"x"),this.add(this.translationX),this.translationY=new $b(this.context,"y"),this.translationY.rotation.z=Math.PI/2,this.add(this.translationY),this.translationZ=new $b(this.context,"z"),this.translationZ.rotation.y=-Math.PI/2,this.add(this.translationZ),this.translationNegX=new $b(this.context,"x",void 0,!0,!1),this.add(this.translationNegX),this.translationNegY=new $b(this.context,"y",void 0,!0,!1),this.translationNegY.rotation.z=Math.PI/2,this.add(this.translationNegY),this.translationNegZ=new $b(this.context,"z",void 0,!0,!1),this.translationNegZ.rotation.y=-Math.PI/2,this.add(this.translationNegZ),this.translationXY=new Yb(this.context,"xy"),this.add(this.translationXY),this.translationXZ=new Yb(this.context,"xz"),this.translationXZ.rotation.x=Math.PI/2,this.add(this.translationXZ),this.translationYZ=new Yb(this.context,"yz"),this.translationYZ.rotation.y=-Math.PI/2,this.add(this.translationYZ)}update(e){this.updateWorldMatrix(!0,!1),this.scale.setScalar(1);const t=this.context.getTarget();null!=t&&(t.getWorldScale(Jb),this.scale.divide(Jb)),this.scale.multiplyScalar(Rb(this,e,this.fixed??!0,this.size??1))}bind(e){const t=this.scaleX.bind(16777215,16776960,e),n=this.scaleY.bind(16777215,16776960,e),i=this.scaleZ.bind(16777215,16776960,e),r=this.scaleNegX.bind(16777215,16776960,e),a=this.scaleNegY.bind(16777215,16776960,e),s=this.scaleNegZ.bind(16777215,16776960,e),o=this.translationX.bind(16711680,16776960,e),l=this.translationY.bind(65280,16776960,e),c=this.translationZ.bind(255,16776960,e),u=this.translationNegX.bind(16711680,16776960,e),d=this.translationNegY.bind(65280,16776960,e),h=this.translationNegZ.bind(255,16776960,e),p=this.translationXY.bind(255,16776960,e),f=this.translationYZ.bind(16711680,16776960,e),m=this.translationXZ.bind(65280,16776960,e);return()=>{o?.(),l?.(),c?.(),u?.(),d?.(),h?.(),p?.(),f?.(),m?.(),t?.(),n?.(),i?.(),r?.(),a?.(),s?.()}}}const t_={x:{vector1:new kh(0,0,-1),vector2:new kh(0,-1,0),rotationOffset:new Nh,axis:[1,0,0]},y:{vector1:new kh(0,0,-1),vector2:new kh(-1,0,-1),rotationOffset:(new Nh).setFromEuler(new Hp(0,0,Math.PI/2)),axis:[0,1,0]},z:{vector1:new kh(-1,0,0),vector2:new kh(0,-1,0),rotationOffset:(new Nh).setFromEuler(new Hp(0,Math.PI/2,0)),axis:[0,0,1]}},n_=new kh,i_=new kh,r_=new kh,a_=new kh,s_=new Nh;class o_ extends Eb{direction=new kh(1,0,0);constructor(e,t,n=""){super(e,t,n,()=>({scale:!1,translate:"as-rotate",rotate:[this.direction],multitouch:!1}))}update(e){const{rotationOffset:t,vector1:n,vector2:i}=t_[this.axis];e.getWorldPosition(n_),this.getWorldPosition(i_).sub(n_),r_.copy(n),a_.copy(i);const r=this.context.getTarget(),a=this.context.getSpace();"local"===a&&null!=r&&(r.getWorldQuaternion(s_),r_.applyQuaternion(s_),a_.applyQuaternion(s_)),a_.crossVectors(r_,a_);const s=i_.dot(a_);a_.multiplyScalar(s),i_.sub(a_),this.quaternion.setFromUnitVectors(r_,i_.normalize()),"local"===a&&null!=r&&(r.getWorldQuaternion(s_),this.quaternion.multiply(s_)),this.quaternion.multiply(t),null!=r?.parent?(r.parent.matrixWorld.decompose(n_,s_,i_),s_.invert(),this.quaternion.premultiply(s_)):s_.identity(),null==this.store.getState()&&(this.direction.fromArray(t_[this.axis].axis),this.direction.applyQuaternion("local"===a&&null!=r?r?.quaternion:s_)),null!=r&&this.quaternion.premultiply(s_.copy(r.quaternion).invert())}bind(e,t){const{options:n,disabled:i}=Mb(this.axis,t);if(!1===n)return;this.options=n;const r=new Pf(xb),a=bb(this.context,r,this.tag,{color:e,hoverColor:16776960,disabled:i}),s=new nm(y_(.5,.5),r);s.renderOrder=1/0,this.add(s);const o=new nm(new Jm(.5,.1,4,24));o.visible=!1,o.pointerEventsOrder=1/0,o.rotation.set(0,-Math.PI/2,-Math.PI/2),this.add(o);const l=i?void 0:this.context.registerHandle(this.store,o,this.tag);return()=>{r.dispose(),o.geometry.dispose(),s.geometry.dispose(),l?.(),a?.(),this.remove(o),this.remove(s)}}}const l_=new kh,c_=new kh,u_=new kh(1,0,0),d_=new Nh;class h_ extends Eb{constructor(e,t=""){super(e,"xyz",t,()=>({scale:!1,translate:"as-rotate",rotate:this.options,multitouch:!1}))}update(e){e.getWorldPosition(l_),this.getWorldPosition(c_).sub(l_),this.quaternion.setFromUnitVectors(u_,c_.normalize());const t=this.context.getTarget();null!=t?.parent&&(t.parent.matrixWorld.decompose(l_,d_,c_),d_.invert(),this.quaternion.premultiply(d_)),null!=t&&(d_.copy(t.quaternion).invert(),this.quaternion.premultiply(d_))}bind(e){const{options:t,disabled:n}=Mb(this.axis,e);if(!1===t)return;this.options=t;const i=new Pf(xb),r=bb(this.context,i,this.tag,{color:16777215,hoverColor:16776960,opacity:.25,disabled:n}),a=new nm(y_(.5,1),i);a.renderOrder=1/0,this.add(a);const s=new nm(new Zm(.25,10,8));s.visible=!1,s.pointerEventsOrder=1/0,this.add(s);const o=n?void 0:this.context.registerHandle(this.store,s,this.tag);return()=>{this.pointerEvents="none",i.dispose(),s.geometry.dispose(),a.geometry.dispose(),o?.(),r?.(),this.remove(s),this.remove(a)}}}const p_=new kh,f_=new kh,m_=new kh(1,0,0),g_=new Nh;class v_ extends Eb{direction=new kh(1,0,0);constructor(e,t=""){super(e,"e",t,()=>({scale:!1,translate:"as-rotate",rotate:[this.direction],multitouch:!1}))}update(e){e.getWorldPosition(p_),this.getWorldPosition(this.direction).sub(p_).normalize(),this.quaternion.setFromUnitVectors(m_,this.direction);const t=this.context.getTarget();null!=t?.parent&&(t.parent.matrixWorld.decompose(p_,g_,f_),g_.invert(),this.quaternion.premultiply(g_),this.direction.applyQuaternion(g_)),null!=t&&(g_.copy(t.quaternion).invert(),this.quaternion.premultiply(g_)),this.direction.negate()}bind(e){const{options:t,disabled:n}=Mb(this.axis,e);if(!1===t)return;this.options=t;const i=new Pf(xb),r=bb(this.context,i,this.tag,{color:16776960,hoverColor:16776960,opacity:.5,disabled:n}),a=new nm(y_(.75,1),i);a.renderOrder=1/0,this.add(a);const s=new nm(new Jm(.75,.1,2,24),new Pf({color:"white"}));s.visible=!1,s.rotation.y=Math.PI/2,s.pointerEventsOrder=1/0,this.add(s);const o=n?void 0:this.context.registerHandle(this.store,s,this.tag);return()=>{i.dispose(),s.geometry.dispose(),a.geometry.dispose(),o?.(),r?.(),this.remove(s),this.remove(a)}}}function y_(e,t){const n=new Jm(e,.0075,3,64,t*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}const x_=new kh;class b_ extends xm{context;fixed;size;rotationX;rotationY;rotationZ;free;screen;constructor(e,t,n){super(),this.context=e,this.fixed=t,this.size=n,this.rotationX=new o_(this.context,"x"),this.add(this.rotationX),this.rotationY=new o_(this.context,"y"),this.add(this.rotationY),this.rotationZ=new o_(this.context,"z"),this.add(this.rotationZ),this.free=new h_(this.context),this.add(this.free),this.screen=new v_(this.context),this.add(this.screen)}update(e){this.updateWorldMatrix(!0,!1),this.rotationX.update(e),this.rotationY.update(e),this.rotationZ.update(e),this.free.update(e),this.screen.update(e),this.scale.setScalar(1);const t=this.context.getTarget();null!=t&&(t.getWorldScale(x_),this.scale.divide(x_)),this.scale.multiplyScalar(Rb(this,e,this.fixed??!0,this.size??1))}bind(e){const t=this.rotationX.bind(16711680,e),n=this.rotationY.bind(65280,e),i=this.rotationZ.bind(255,e),r=this.screen.bind(e),a=this.free.bind(e);return()=>{t?.(),n?.(),i?.(),r?.(),a?.()}}}const __=new Hp,w_=new Hp(0,0,Math.PI/2),S_=new Hp(0,-Math.PI/2,0);class E_ extends xm{xAxisHighlight;yAxisHighlight;zAxisHighlight;handles;context;constructor(e){super(),this.context=new yb(this,e),this.xAxisHighlight=new Sb(this.context,__),this.add(this.xAxisHighlight),this.yAxisHighlight=new Sb(this.context,w_),this.add(this.yAxisHighlight),this.zAxisHighlight=new Sb(this.context,S_),this.add(this.zAxisHighlight)}set space(e){this.context.space=e}get space(){return this.context.space}update(e,t){this.context.update(e),this.xAxisHighlight.update(),this.yAxisHighlight.update(),this.zAxisHighlight.update(),this.handles?.update(t)}bind(e,t){const n=this.xAxisHighlight.bind("x"),i=this.yAxisHighlight.bind("y"),r=this.zAxisHighlight.bind("z");switch(e){case"rotate":this.handles=new b_(this.context);break;case"scale":this.handles=new e_(this.context);break;case"translate":this.handles=new jb(this.context)}this.add(this.handles);const a=this.handles.bind(t);return()=>{null!=this.handles&&this.remove(this.handles),this.handles=void 0,a(),n(),i(),r()}}}new kh(0,0,1),new kh(0,1,0),new kh,new kh,new kh;class M_{nativeEvent;NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;relatedTarget=null;get altKey(){return this.getFromNative("altKey",!1)}get button(){return this.getFromNative("button",0)}get buttons(){return this.getFromNative("buttons",0)}get clientX(){return this.getFromNative("clientX",0)}get clientY(){return this.getFromNative("clientY",0)}get ctrlKey(){return this.getFromNative("ctrlKey",!1)}get layerX(){return this.getFromNative("layerX",0)}get layerY(){return this.getFromNative("layerY",0)}get metaKey(){return this.getFromNative("metaKey",!1)}get movementX(){return this.getFromNative("movementX",0)}get movementY(){return this.getFromNative("movementY",0)}get offsetX(){return this.getFromNative("offsetX",0)}get offsetY(){return this.getFromNative("offsetY",0)}get pageX(){return this.getFromNative("pageX",0)}get pageY(){return this.getFromNative("pageY",0)}get screenX(){return this.getFromNative("screenX",0)}get screenY(){return this.getFromNative("screenY",0)}get shiftKey(){return this.getFromNative("shiftKey",!1)}get x(){return this.getFromNative("x",0)}get y(){return this.getFromNative("y",0)}get detail(){return this.getFromNative("detail",0)}get view(){return this.getFromNative("view",null)}get which(){return this.getFromNative("which",0)}get cancelBubble(){return this.getFromNative("cancelBubble",!1)}get composed(){return this.getFromNative("composed",!1)}get eventPhase(){return this.getFromNative("eventPhase",0)}get isTrusted(){return this.getFromNative("isTrusted",!1)}get returnValue(){return this.getFromNative("returnValue",!1)}get timeStamp(){return this.getFromNative("timeStamp",0)}get cancelable(){return this.getFromNative("cancelable",!1)}get defaultPrevented(){return this.getFromNative("defaultPrevented",!1)}constructor(e){this.nativeEvent=e}getFromNative(e,t){return e in this.nativeEvent?this.nativeEvent[e]:t}}const T_=new kh;class A_ extends M_{type;bubbles;internalPointer;intersection;camera;currentObject;object;propagationState;get pointerId(){return this.internalPointer.id}get pointerType(){return this.internalPointer.type}get pointerState(){return this.internalPointer.state}get distance(){return this.intersection.distance}get distanceToRay(){return this.intersection.distanceToRay}get point(){return this.intersection.point}get index(){return this.intersection.index}get face(){return this.intersection.face}get faceIndex(){return this.intersection.faceIndex}get uv(){return this.intersection.uv}get uv1(){return this.intersection.uv1}get normal(){return this.intersection.normal}get instanceId(){return this.intersection.instanceId}get pointOnLine(){return this.intersection.pointOnLine}get batchId(){return this.intersection.batchId}get pointerPosition(){return this.intersection.pointerPosition}get pointerQuaternion(){return this.intersection.pointerQuaternion}get pointOnFace(){return this.intersection.pointOnFace}get localPoint(){return this.intersection.localPoint}get details(){return this.intersection.details}get target(){return this.object}get currentTarget(){return this.currentObject}get eventObject(){return this.currentObject}get srcElement(){return this.currentObject}_pointer;get pointer(){return null==this._pointer&&(T_.copy(this.intersection.point).project(this.camera),this._pointer=new Dh(T_.x,T_.y)),this._pointer}_ray;get ray(){if(null!=this._ray)return this._ray;switch(this.intersection.details.type){case"screen-ray":case"ray":case"sphere":return this._ray=new Lp(this.intersection.pointerPosition,new kh(0,0,-1).applyQuaternion(this.intersection.pointerQuaternion));case"lines":return this._ray=new Lp(this.intersection.details.line.start,this.intersection.details.line.end.clone().sub(this.intersection.details.line.start).normalize())}}_intersections=[];get intersections(){return null==this._intersections&&(this._intersections=[{...this.intersection,eventObject:this.currentObject}]),this._intersections}_unprojectedPoint;get unprojectedPoint(){if(null==this._unprojectedPoint){const e=this.pointer;this._unprojectedPoint=new kh(e.x,e.y,0).unproject(this.camera)}return this._unprojectedPoint}get stopped(){return this.propagationState.stoppedImmediate||this.propagationState.stopped}get stoppedImmediate(){return this.propagationState.stoppedImmediate}get delta(){throw new Error("not supported")}constructor(e,t,n,i,r,a,s=r.object,o=s,l={stopped:!t,stoppedImmediate:!1}){super(n),this.type=e,this.bubbles=t,this.internalPointer=i,this.intersection=r,this.camera=a,this.currentObject=s,this.object=o,this.propagationState=l}stopPropagation(){this.propagationState.stopped=!0}stopImmediatePropagation(){this.propagationState.stoppedImmediate=!0}retarget(e){return new A_(this.type,this.bubbles,this.nativeEvent,this.internalPointer,this.intersection,this.camera,e,this.target,this.propagationState)}}class R_ extends A_{get deltaX(){return this.nativeEvent.deltaX}get deltaY(){return this.nativeEvent.deltaY}get deltaZ(){return this.nativeEvent.deltaZ}constructor(e,t,n,i,r,a){super("wheel",!0,e,t,n,i,r,a)}retarget(e){return new R_(this.nativeEvent,this.internalPointer,this.intersection,this.camera,e,this.target)}}function P_(e){C_(e,e.currentObject)}function C_(e,t){if(null==t)return;const n=function(e,t){if(null!=e._listeners&&t in e._listeners)return e._listeners[t];let n;e.isVoidObject&&"click"===t&&null!=e.parent?.__r3f&&(n=e.parent.__r3f.root.getState().onPointerMissed);null!=e.__r3f&&(n=e.__r3f.handlers[L_[t]]);if(null==n)return;return[n]}(t,e.type);if(null!=n&&n.length>0){const i=e.retarget(t),r=n.length;for(let e=0;e<r&&!i.stoppedImmediate;e++)n[e](i)}e.stopped||C_(e,t.parent)}const L_={click:"onClick",contextmenu:"onContextMenu",dblclick:"onDoubleClick",pointercancel:"onPointerCancel",pointerdown:"onPointerDown",pointerenter:"onPointerEnter",pointerleave:"onPointerLeave",pointermove:"onPointerMove",pointerout:"onPointerOut",pointerover:"onPointerOver",pointerup:"onPointerUp",wheel:"onWheel"},I_=Object.keys(L_);const D_=new Zm(1e10),N_=new Map;function k_(e){let t=N_.get(e);return null==t&&(t=new nm(D_),t.isVoidObject=!0,t.parent=e,t.pointerEventsOrder=-1/0,N_.set(e,t)),t}function F_(e,t){return t?!e:e}function O_(e,t,n,i=!1,r,a,s){const o=i||function(e,t){if(t.ancestorsHaveListeners)return!0;if("pointer"===e&&t.ancestorsHavePointerListeners)return!0;if("wheel"===e&&t.ancestorsHaveWheelListeners)return!0;if(null!=t.__r3f&&t.__r3f?.eventCount>0){if("wheel"===e&&null!=t.__r3f.handlers.onWheel)return!0;if("pointer"===e&&Object.keys(t.__r3f.handlers).some(e=>"onWheel"!=e))return!0}if(null==t._listeners)return!1;if("wheel"===e){const e=t._listeners.wheel;return null!=e&&e.length>0}const n=Object.entries(t._listeners),i=n.length;for(let e=0;e<i;e++){const t=n[e];if("wheel"!==t[0]&&(I_.includes(t[0])&&null!=t[1]&&t[1].length>0))return!0}return!1}(e,t),l=t.pointerEvents??r,c=l??t.defaultPointerEvents??"listener",u=t.pointerEventsType??a??"all",d=t.pointerEventsOrder??s??0,h=function(e,t,n){if("none"===t)return!1;if("listener"===t&&!e)return!1;if("all"===n)return!0;if("function"==typeof n)return({id:e,type:t,state:i})=>n(e,t,i);let i,r;return"deny"in n?(r=!0,i=n.deny):(r=!1,i=n.allow),Array.isArray(i)?e=>F_(i.includes(e.type),r):e=>F_(i===e.type,r)}(o,c,u),p=n.length;if(1===p)(!0===h||"function"==typeof h&&h(n[0]))&&U_(n[0],t,c,u,d);else if(!0===h)for(let e=0;e<p;e++)U_(n[e],t,c,u,d);else if("function"==typeof h)for(let e=0;e<p;e++){const i=n[e];h(i)&&U_(i,t,c,u,d)}if(0===t.children.length||!1===t.intersectChildren)return;const f=t.interactableDescendants??t.children,m=f.length;for(let t=0;t<m;t++)O_(e,f[t],n,o,l,u,d)}function U_({intersector:e,options:t},n,i,r,a){!1!==t.filter?.(n,i,r,a)&&e.executeIntersection(n,a)}function z_(e,t=0,n,i=0){return t!=i?i-t:e.distance-n.distance}const B_=1e7;const V_=Symbol("buttonsDownTime"),H_=Symbol("buttonsClickTime");function G_(e){return globalThis.pointerEventspointerMap?.get(e)}globalThis.pointerEventspointerMap??=new Map,sf.prototype.setPointerCapture=function(e){G_(e)?.setCapture(this)},sf.prototype.releasePointerCapture=function(e){const t=G_(e);null!=t&&t.hasCaptured(this)&&t.setCapture(void 0)},sf.prototype.hasPointerCapture=function(e){return G_(e)?.hasCaptured(this)??!1};class W_{id;type;state;intersector;getCamera;onMoveCommited;parentSetPointerCapture;parentReleasePointerCapture;options;prevIntersection;intersection;prevEnabled=!0;enabled=!0;wheelIntersection;pointerEntered=[];pointerEnteredHelper=[];pointerCapture;buttonsDownTime=new Map;buttonsDown=new Set;wasMoved=!1;onFirstMove=[];constructor(e,t,n,i,r,a,s,o,l={}){this.id=e,this.type=t,this.state=n,this.intersector=i,this.getCamera=r,this.onMoveCommited=a,this.parentSetPointerCapture=s,this.parentReleasePointerCapture=o,this.options=l,globalThis.pointerEventspointerMap?.set(e,this)}getPointerCapture(){return this.pointerCapture}hasCaptured(e){return this.pointerCapture?.object===e}setCapture(e){this.pointerCapture?.object!==e&&(this.clearPointerCapture(),null!=e&&null!=this.intersection&&(this.pointerCapture={object:e,intersection:this.intersection},this.parentSetPointerCapture?.()))}getButtonsDown(){return this.buttonsDown}getIntersection(){return this.intersection}getEnabled(){return this.enabled}setEnabled(e,t,n=!0){this.enabled!==e&&(e||null==this.pointerCapture||this.clearPointerCapture(),this.enabled=e,n&&this.commit(t,!1))}computeIntersection(e,t,n){return null!=this.pointerCapture?this.intersector.intersectPointerCapture(this.pointerCapture,n):(this.intersector.startIntersection(n),O_(e,t,[this]),this.intersector.finalizeIntersection(t))}setIntersection(e){this.intersection=e}commit(e,t){const n=this.getCamera(),i=this.prevEnabled?this.prevIntersection:void 0,r=this.enabled?this.intersection:void 0;null!=i&&i.object!=r?.object&&P_(new A_("pointerout",!0,e,this,i,n));const a=this.pointerEntered;this.pointerEntered=[],this.pointerEnteredHelper.length=0,j_(r?.object,this.pointerEntered,a,this.pointerEnteredHelper);const s=a.length;for(let t=0;t<s;t++){const r=a[t];P_(new A_("pointerleave",!1,e,this,i,n,r))}null!=r&&i?.object!=r.object&&P_(new A_("pointerover",!0,e,this,r,n));for(let t=this.pointerEnteredHelper.length-1;t>=0;t--){const i=this.pointerEnteredHelper[t];P_(new A_("pointerenter",!1,e,this,r,n,i))}if(t&&null!=r&&P_(new A_("pointermove",!0,e,this,r,n)),this.prevIntersection=this.intersection,this.prevEnabled=this.enabled,!this.wasMoved&&this.intersector.isReady()){this.wasMoved=!0;const e=this.onFirstMove.length;for(let t=0;t<e;t++)this.onFirstMove[t](n);this.onFirstMove.length=0}this.onMoveCommited?.(this)}move(e,t){this.intersection=this.computeIntersection("pointer",e,t),this.commit(t,!0)}over(e,t){this.wasMoved||(this.intersection=this.computeIntersection("pointer",e,t),this.commit(t,!1))}emitMove(e){null!=this.intersection&&P_(new A_("pointermove",!0,e,this,this.intersection,this.getCamera()))}down(e){if(this.buttonsDown.add(e.button),!this.enabled)return;if(!this.wasMoved)return void this.onFirstMove.push(this.down.bind(this,e));if(null==this.intersection)return;P_(new A_("pointerdown",!0,e,this,this.intersection,this.getCamera()));const{object:t}=this.intersection;t[V_]??=new Map,t[V_].set(e.button,e.timeStamp),this.buttonsDownTime.set(e.button,e.timeStamp)}up(e){if(this.buttonsDown.delete(e.button),!this.enabled)return;if(!this.wasMoved)return void this.onFirstMove.push(this.up.bind(this,e));if(null==this.intersection)return;const{clickThesholdMs:t,contextMenuButton:n=2,dblClickThresholdMs:i=500,clickThresholdMs:r=t??300}=this.options;this.clearPointerCapture();const a=function(e,t,n,i,r){if(null==t)return!1;const a=t.get(n);if(null==a)return!1;if(i-a>r)return!1;if(a!=e.get(n))return!1;return!0}(this.buttonsDownTime,this.intersection.object[V_],e.button,e.timeStamp,r),s=this.getCamera();if(a&&e.button===n&&P_(new A_("contextmenu",!0,e,this,this.intersection,s)),P_(new A_("pointerup",!0,e,this,this.intersection,s)),!a||e.button===n)return;P_(new A_("click",!0,e,this,this.intersection,s));const{object:o}=this.intersection,l=o[H_]??=new Map,c=l.get(e.button);null==c||e.timeStamp-c>i?l.set(e.button,e.timeStamp):(P_(new A_("dblclick",!0,e,this,this.intersection,s)),l.delete(e.button))}cancel(e){this.buttonsDown.clear(),this.buttonsDownTime.clear(),this.clearPointerCapture(),this.onFirstMove.length=0,this.enabled&&this.wasMoved&&null!=this.intersection&&P_(new A_("pointercancel",!0,e,this,this.intersection,this.getCamera()))}wheel(e,t,n=!1){if(!this.enabled)return;if(!this.wasMoved&&n)return void this.onFirstMove.push(this.wheel.bind(this,e,t,n));n||(this.wheelIntersection=this.computeIntersection("wheel",e,t));const i=n?this.intersection:this.wheelIntersection;null!=i&&P_(new R_(t,this,i,this.getCamera()))}emitWheel(e,t=!1){if(!this.enabled)return;if(!this.wasMoved&&t)return void this.onFirstMove.push(this.emitWheel.bind(this,e,t));const n=t?this.intersection:this.wheelIntersection;null!=n&&P_(new R_(e,this,n,this.getCamera()))}exit(e){(this.buttonsDown.size>0||null!=this.pointerCapture)&&this.cancel(e),this.wasMoved&&(this.intersection=void 0,this.commit(e,!1)),this.onFirstMove.length=0,this.wasMoved=!1}clearPointerCapture(){null!=this.pointerCapture&&(this.parentReleasePointerCapture?.(),this.pointerCapture=void 0)}}function j_(e,t,n,i){if(null==e)return;const r=n.indexOf(e);-1!=r?n.splice(r,1):i.push(e),t.push(e),j_(e.parent,t,n,i)}const X_=new bf,q_=new bf,$_=new Dh,Y_=new Dh,K_=new Dh,Q_=new kh,Z_=new Ip,J_=new kh;function ew(e,t,n){J_.copy(t).applyMatrix4(Z_.copy(n.matrixWorld).invert());const i=n.geometry.attributes.uv;if(null==i||!(i instanceof Df))return!1;let r;return function(e,t){const n=e.geometry.drawRange;if(null!=e.geometry.index){const i=e.geometry.index,r=Math.max(0,n.start),a=Math.min(i.count,n.start+n.count);for(let e=r;e<a;e+=3)t(i.getX(e),i.getX(e+1),i.getX(e+2));return}const i=e.geometry.attributes.position;if(null==i)return;const r=Math.max(0,n.start),a=Math.min(i.count,n.start+n.count);for(let e=r;e<a;e+=3)t(e,e+1,e+2)}(n,(e,t,a)=>{n.getVertexPosition(e,X_.a),n.getVertexPosition(t,X_.b),n.getVertexPosition(a,X_.c);const s=X_.closestPointToPoint(J_,Q_).distanceTo(J_);null!=r&&s>=r||(r=s,q_.copy(X_),$_.fromBufferAttribute(i,e),Y_.fromBufferAttribute(i,t),K_.fromBufferAttribute(i,a))}),null!=r&&(q_.closestPointToPoint(J_,Q_),q_.getInterpolation(Q_,$_,Y_,K_,e),!0)}new Ip,new class{constructor(e=new kh,t=new kh){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){cg.subVectors(e,this.start),ug.subVectors(this.end,this.start);const n=ug.dot(ug);let i=ug.dot(cg)/n;return t&&(i=Ph(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=fg,n=mg){const i=1e-8*1e-8;let r,a;const s=this.start,o=e.start,l=this.end,c=e.end;dg.subVectors(l,s),hg.subVectors(c,o),pg.subVectors(s,o);const u=dg.dot(dg),d=hg.dot(hg),h=hg.dot(pg);if(u<=i&&d<=i)return t.copy(s),n.copy(o),t.sub(n),t.dot(t);if(u<=i)r=0,a=h/d,a=Ph(a,0,1);else{const e=dg.dot(pg);if(d<=i)a=0,r=Ph(-e/u,0,1);else{const t=dg.dot(hg),n=u*d-t*t;r=0!==n?Ph((t*h-e*d)/n,0,1):0,a=(t*r+h)/d,a<0?(a=0,r=Ph(-e/u,0,1)):a>1&&(a=1,r=Ph((t-e)/u,0,1))}}return t.copy(s).add(dg.multiplyScalar(r)),n.copy(o).add(hg.multiplyScalar(a)),t.sub(n),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)}},new kh,new Am,new Lp,new Dh,new kh(0,0,0),new kh(0,0,1);const tw=new Ip,nw=new kh;new kh(0,0,-1),new Am;const iw=new Dh,rw=new kh;class aw{prepareTransformation;options;raycaster=new sg;cameraQuaternion=new Nh;fromPosition=new kh;fromQuaternion=new Nh;coords=new Dh;viewPlane=new Am;intersects=[];pointerEventsOrders=[];constructor(e,t){this.prepareTransformation=e,this.options=t}isReady(){return!0}intersectPointerCapture({intersection:e,object:t},n){const i=e.details;if("screen-ray"!=i.type)throw new Error(`unable to process a pointer capture of type "${e.details.type}" with a camera ray intersector`);if(!this.startIntersection(n))return e;this.viewPlane.constant-=i.distanceViewPlane;const r=this.raycaster.ray.intersectPlane(this.viewPlane,new kh);if(null==r)return e;e.object.updateWorldMatrix(!0,!1),function(e,t,n){const i=t.normal??t.face?.normal;null!=i&&(e.setFromNormalAndCoplanarPoint(i,t.localPoint),e.applyMatrix4(n))}(this.viewPlane,e,e.object.matrixWorld);let a=e.uv;return e.object instanceof nm&&ew(iw,r,e.object)&&(a=iw.clone()),{...e,details:{...i,direction:this.raycaster.ray.direction.clone(),screenPoint:this.coords.clone()},uv:a,object:t,point:r,pointOnFace:r,pointerPosition:this.raycaster.ray.origin.clone(),pointerQuaternion:this.cameraQuaternion.clone()}}startIntersection(e){const t=this.prepareTransformation(e,this.coords);return null!=t&&(t.updateWorldMatrix(!0,!1),t.matrixWorld.decompose(this.fromPosition,this.fromQuaternion,nw),this.raycaster.setFromCamera(this.coords,t),this.viewPlane.setFromNormalAndCoplanarPoint(t.getWorldDirection(rw),this.raycaster.ray.origin),!0)}executeIntersection(e,t){const n=this.intersects.length;e.raycast(this.raycaster,this.intersects),function(e,t,n){for(;n>0;)e.push(t),--n}(this.pointerEventsOrders,t,this.intersects.length-n)}finalizeIntersection(e){const t=this.fromPosition.clone(),n=this.cameraQuaternion.clone(),i=this.raycaster.ray.direction.clone(),r=function(e,t,{customSort:n=z_}={}){let i,r,a;const s=e.length;for(let o=0;o<s;o++){const s=e[o],l=t?.[o];(null==i||n(s,l,i,r)<0)&&(a=o,i=s,r=l)}return a}(this.intersects,this.pointerEventsOrders,this.options),a=null==r?void 0:this.intersects[r];return this.intersects.length=0,this.pointerEventsOrders.length=0,null==a?function(e,t,n,i,r,a=0){const s=t.direction.clone().multiplyScalar(B_),o=B_;return{distance:o+a,object:k_(e),point:s,normal:t.origin.clone().sub(s).normalize(),details:n(s,o),pointerPosition:i,pointerQuaternion:r,pointOnFace:s,localPoint:s}}(e,this.raycaster.ray,(e,t)=>({type:"screen-ray",distanceViewPlane:t,screenPoint:this.coords.clone(),direction:i}),t,n):(a.object.updateWorldMatrix(!0,!1),tw.copy(a.object.matrixWorld).invert(),Object.assign(a,{details:{type:"screen-ray",distanceViewPlane:this.viewPlane.distanceToPoint(a.point),screenPoint:this.coords.clone(),direction:i},pointOnFace:a.point,pointerPosition:t,pointerQuaternion:n,localPoint:a.point.clone().applyMatrix4(tw)}))}}new kh,new Dh,new Ip,new kh,new Am,new Sp,new kh,new kh,new kh,new kh(1e-4,1e-4,1e-4),new Ip;let sw=99412;function ow(e,t,n){if(!(t instanceof globalThis.MouseEvent))return n.set(0,0);const{width:i,height:r,top:a,left:s}=e.getBoundingClientRect(),o=t.clientX-s,l=t.clientY-a;return n.set(o/i*2-1,-l/r*2+1)}function lw(e,t,n,i){return function(e,t,n,i,r,a,s={}){const o=s?.forwardPointerCapture??!0,l=new Map,c=s.pointerTypePrefix??"forward-",u=(e,u)=>{let d=l.get(e.pointerId);return null!=d||(d=new W_(sw++,`${c}${e.pointerType}`,e.pointerState,new aw((e,n)=>(i(e,n),t()),s),t,void 0,o?r.bind(null,e.pointerId):void 0,o?a.bind(null,e.pointerId):void 0,s),"move"!=u&&"wheel"!=u&&(d.setIntersection(d.computeIntersection("pointer",n,e)),d.commit(e,!1)),l.set(e.pointerId,d)),d},d=new Map,h=new Map,p=[],f=[],m=(e,t,i)=>{switch(e){case"move":case"over":return void i.move(n,t);case"wheel":return void i.wheel(n,t);case"cancel":return void i.cancel(t);case"down":if(!cw(t))return;return void i.down(t);case"up":if(!cw(t))return;return void i.up(t);case"exit":return h.delete(i),d.delete(i),void i.exit(t)}},g=(e,t)=>{const n=u(t,e);"move"===e&&h.set(n,t),"wheel"===e&&d.set(n,t),s.batchEvents??1?f.push({type:e,event:t}):m(e,t,n)},v=g.bind(null,"move"),y=g.bind(null,"over"),x=g.bind(null,"cancel"),b=g.bind(null,"down"),_=g.bind(null,"up"),w=g.bind(null,"wheel"),S=g.bind(null,"exit");return e.addEventListener("pointermove",v),e.addEventListener("pointerover",y),e.addEventListener("pointercancel",x),e.addEventListener("pointerdown",b),e.addEventListener("pointerup",_),e.addEventListener("wheel",w),e.addEventListener("pointerleave",S),{destroy(){e.removeEventListener("pointermove",v),e.removeEventListener("pointerover",y),e.removeEventListener("pointercancel",x),e.removeEventListener("pointerdown",b),e.removeEventListener("pointerup",_),e.removeEventListener("wheel",w),e.removeEventListener("pointerleave",S),h.clear(),d.clear()},update(){const e=f.length;for(let t=0;t<e;t++){const{type:e,event:n}=f[t],i=u(n,e);"move"!==e||(p.push(i),h.get(i)==n)?"wheel"!==e||d.get(i)==n?m(e,n,i):i.emitWheel(n):i.emitMove(n)}if(f.length=0,s.intersectEveryFrame)for(const[e,t]of h.entries())p.includes(e)||e.move(n,t);p.length=0}}}(e,"function"==typeof t?t:()=>t,n,ow.bind(null,e),e.setPointerCapture.bind(e),t=>{e.hasPointerCapture(t)&&e.releasePointerCapture(t)},{pointerTypePrefix:"screen-",...i})}function cw(e){return null!=e.button}new Dh,new kh,new kh,new kh,new Dh,new Dh,new kh,new kh,new Dh,new Dh,new Dh,new Dh,new kh,new kh;class uw{constructor(e){var t;this.xrDevice=e,this.combinedCameraPosition=new kh,this.isPointerLocked=!1,this.vec3=new kh,this.quat=new Nh,this.quatB=new Nh,this.quatInv=new Nh,this.quatMouse=new Nh,this.euler=new Hp,this.keyState={ShiftLeft:!1,KeyW:!1,KeyA:!1,KeyS:!1,KeyD:!1,ArrowUp:!1,ArrowDown:!1},this.lastTime=0,this.preferredConnectedGazeMode="head-locked",this.gazeCommitHand="right",this.gazePointerId=null,this.gazeHeadsetDragActive=!1,this.gazeLastPointer={x:0,y:0},this.gazeForward=new kh(0,0,-1),this.gazeDirection=new kh,this.gazeQuaternion=new Nh,this.isInProgrammaticMode=!1,this.interactionsEnabled=!0,this.scene=new wm,this.gazeMode=(null===(t=e.gaze)||void 0===t?void 0:t.connected)?"head-locked":"off",this.camera=new fm(50,window.innerWidth/window.innerHeight,.1,40),this.playerRig=new xm,this.cameraRig=new xm,this.scene.add(this.playerRig),this.playerRig.add(this.cameraRig),this.cameraRig.position.fromArray(e.position.vec3),this.cameraRig.quaternion.fromArray(e.quaternion.quat),this.cameraRig.add(this.camera),this.camera.position.x-=e.ipd/2;const n=new nm(new Qm(.25,.27,32),new Pf({color:16777215,side:0}));n.rotateX(-Math.PI/2),this.scene.add(n),this.renderer=new tx({alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.setClearColor(0,0),this.renderer.domElement.style.position="fixed",this.renderer.domElement.style.top="50vh",this.renderer.domElement.style.left="50vw",this.renderer.domElement.style.transform="translate(-50%, -50%)",this.transformHandles=new Map,["left","right"].forEach(t=>{const n=new E_;n.scale.setScalar(.1),n.position.fromArray(e.controllers[t].position.vec3),n.quaternion.fromArray(e.controllers[t].quaternion.quat),this.cameraRig.attach(n),n.userData={defaultPosition:n.position.toArray(),defaultQuaternion:n.quaternion.toArray()},n.userData.setMode=e=>{var t,i;null===(i=(t=n.userData).modeCleanup)||void 0===i||i.call(t),n.userData.modeCleanup=n.bind(e),n.userData.mode=e},n.userData.setMode("translate"),n.space="local",this.transformHandles.set(t,n),n.addEventListener("click",()=>{"translate"===n.userData.mode?n.userData.setMode("rotate"):n.userData.setMode("translate")})}),window.transformHandles=this.transformHandles,this.mouseMoveHandler=t=>{if(!this.isPointerLocked||this.isInProgrammaticMode)return;const n=t.movementX||t.mozMovementX||t.webkitMovementX||0,i=t.movementY||t.mozMovementY||t.webkitMovementY||0;this.playerRig.rotation.y-=.002*n,this.cameraRig.rotation.x-=.002*i,e.quaternion.copy(this.cameraRig.getWorldQuaternion(this.quatMouse))},this.cameraRig.getWorldPosition(this.combinedCameraPosition),this.headsetDefaultPosition=this.cameraRig.position.clone(),this.headsetDefaultQuaternion=this.cameraRig.quaternion.clone(),this.forwardHtmlEvents=lw(this.renderer.domElement,()=>this.camera,this.scene).update,this.pointerLockChangeHandlerBound=this.pointerLockChangeHandler.bind(this),this.gazePointerDownHandlerBound=this.gazePointerDownHandler.bind(this),this.gazePointerMoveHandlerBound=this.gazePointerMoveHandler.bind(this),this.gazePointerUpHandlerBound=this.gazePointerUpHandler.bind(this),this.gazeWheelHandlerBound=this.gazeWheelHandler.bind(this),this.gazeContextMenuHandlerBound=this.gazeContextMenuHandler.bind(this),this.windowBlurHandlerBound=()=>{this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1},this.documentVisibilityHandlerBound=()=>{"visible"!==document.visibilityState&&(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1)},this.keyDownHandlerBound=this.keyDownHandler.bind(this),this.keyUpHandlerBound=this.keyUpHandler.bind(this),document.addEventListener("pointerlockchange",this.pointerLockChangeHandlerBound,!1),document.addEventListener("mozpointerlockchange",this.pointerLockChangeHandlerBound,!1),document.addEventListener("webkitpointerlockchange",this.pointerLockChangeHandlerBound,!1),document.addEventListener("keydown",this.keyDownHandlerBound,!1),document.addEventListener("keyup",this.keyUpHandlerBound,!1),this.renderer.domElement.addEventListener("pointerdown",this.gazePointerDownHandlerBound),this.renderer.domElement.addEventListener("pointermove",this.gazePointerMoveHandlerBound),this.renderer.domElement.addEventListener("pointerup",this.gazePointerUpHandlerBound),this.renderer.domElement.addEventListener("pointercancel",this.gazePointerUpHandlerBound),this.renderer.domElement.addEventListener("wheel",this.gazeWheelHandlerBound,{passive:!1}),this.renderer.domElement.addEventListener("contextmenu",this.gazeContextMenuHandlerBound),window.addEventListener("blur",this.windowBlurHandlerBound),document.addEventListener("visibilitychange",this.documentVisibilityHandlerBound)}lockPointer(){!this.isInProgrammaticMode&&this.interactionsEnabled&&"cursor"!==this.gazeMode&&(this.renderer.domElement.requestPointerLock=this.renderer.domElement.requestPointerLock||this.renderer.domElement.mozRequestPointerLock||this.renderer.domElement.webkitRequestPointerLock,this.renderer.domElement.requestPointerLock())}pointerLockChangeHandler(){this.isPointerLocked=document.pointerLockElement===this.renderer.domElement||document.mozPointerLockElement===this.renderer.domElement||document.webkitPointerLockElement===this.renderer.domElement,this.isPointerLocked?document.addEventListener("mousemove",this.mouseMoveHandler,!1):document.removeEventListener("mousemove",this.mouseMoveHandler,!1)}get currentGazeMode(){return this.gazeMode}get currentGazeCommitHand(){return this.gazeCommitHand}applyGazeModePresentation(e){var t;this.gazeMode=e,"cursor"===e&&this.isPointerLocked&&(null===(t=document.exitPointerLock)||void 0===t||t.call(document));const n="cursor"===e;this.renderer.domElement.style.cursor=n?"crosshair":"",this.renderer.domElement.style.touchAction=n?"none":"",this.setTransformHandleRoutingSuppressed(n)}setGazeMode(e){this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1;const t=this.xrDevice.gaze;t?("off"!==e&&(this.preferredConnectedGazeMode=e),t.connected="off"!==e,"head-locked"===e&&t.quaternion.set(0,0,0,1),this.applyGazeModePresentation(e)):this.applyGazeModePresentation("off")}setProgrammaticMode(e){const t=this.isInProgrammaticMode;if(this.isInProgrammaticMode=e,!t||e)return;const n=this.xrDevice.gaze,i=(null==n?void 0:n.connected)?this.preferredConnectedGazeMode:"off";i!==this.gazeMode&&(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1,this.applyGazeModePresentation(i))}setGazeCommitHand(e){e!==this.gazeCommitHand&&(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1,this.gazeCommitHand=e)}onSessionEnd(){this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1}setTransformHandleRoutingSuppressed(e){this.transformHandles.forEach(t=>{var n,i;e&&!t.userData.gazeSuppressed?(null===(i=(n=t.userData).modeCleanup)||void 0===i||i.call(n),t.userData.modeCleanup=void 0,t.userData.gazeSuppressed=!0):!e&&t.userData.gazeSuppressed&&(t.userData.gazeSuppressed=!1,t.userData.setMode(t.userData.mode))})}gazeInteractionEnabled(){var e;return"cursor"===this.gazeMode&&Boolean(null===(e=this.xrDevice.gaze)||void 0===e?void 0:e.connected)&&"visible"===this.xrDevice.visibilityState&&this.interactionsEnabled&&!this.isInProgrammaticMode&&Boolean(this.xrDevice.activeSession)}updateGazeFromPointer(e,t){if(!this.gazeInteractionEnabled()||this.gazeCommitActive)return;const n=function(e,t,n,i,r){if(n.width<=0||n.height<=0)return[0,0,-1];const a=i?n.width/2:n.width,s=e-n.left,o=(i&&s>=a?s-a:s)/a*2-1,l=1-(t-n.top)/n.height*2,c=Math.tan(r/2),u=o*(a/n.height)*c,d=l*c,h=Math.hypot(u,d,-1);return[u/h,d/h,-1/h]}(e,t,this.renderer.domElement.getBoundingClientRect(),this.xrDevice.stereoEnabled,this.xrDevice.fovy);this.gazeDirection.fromArray(n),this.gazeQuaternion.setFromUnitVectors(this.gazeForward,this.gazeDirection),this.xrDevice.gaze.quaternion.copy(this.gazeQuaternion)}beginGazeCommit(){if(this.gazeCommitActive||this.gazeCommitPendingRelease)return;const e=this.xrDevice.primaryInputMode,t=this.gazeCommitHand,n="hand"===e?this.xrDevice.hands[t]:this.xrDevice.controllers[t];(null==n?void 0:n.connected)&&(this.writeGazeCommitValue({mode:e,handedness:t},1,!1),this.gazeCommitActive={mode:e,handedness:t})}writeGazeCommitValue(e,t,n){if("hand"===e.mode){const i=this.xrDevice.hands[e.handedness];n?null==i||i.setPinchValueImmediate(t):null==i||i.updatePinchValue(t)}else{const i=this.xrDevice.controllers[e.handedness];n?null==i||i.setButtonValueImmediate("trigger",t):null==i||i.updateButtonValue("trigger",t)}}releaseGazeCommit(e){var t,n,i,r,a;const s=this.gazeCommitActive,o=null===(t=this.gazeCommitPendingRelease)||void 0===t?void 0:t.source,l=this.gazePointerId;if(this.gazePointerId=null,null!==l&&(null===(i=(n=this.renderer.domElement).hasPointerCapture)||void 0===i?void 0:i.call(n,l))&&(null===(a=(r=this.renderer.domElement).releasePointerCapture)||void 0===a||a.call(r,l)),e)return this.gazeCommitPendingRelease=void 0,o&&this.writeGazeCommitValue(o,0,!0),s&&s!==o&&this.writeGazeCommitValue(s,0,!0),void(this.gazeCommitActive=void 0);s&&(this.gazeCommitPendingRelease={source:s,queuedForFrame:!1},this.gazeCommitActive=void 0)}schedulePendingGazeRelease(){const e=this.gazeCommitPendingRelease;e&&queueMicrotask(()=>{this.gazeCommitPendingRelease===e&&(e.queuedForFrame?this.gazeCommitPendingRelease=void 0:(this.writeGazeCommitValue(e.source,0,!1),e.queuedForFrame=!0))})}gazeCommitSourceIsActive(){const e=this.gazeCommitActive;if(!e||this.xrDevice.primaryInputMode!==e.mode)return!1;const t="hand"===e.mode?this.xrDevice.hands[e.handedness]:this.xrDevice.controllers[e.handedness];return Boolean(null==t?void 0:t.connected)}moveCommitInput(e,t){const n=this.gazeCommitActive;if(!n)return;const i=this.transformHandles.get(n.handedness);if(!i)return;const r=this.renderer.domElement.getBoundingClientRect(),a=Math.max(.25,Math.abs(i.position.z)),s=2*Math.tan(this.xrDevice.fovy/2)*a/Math.max(r.height,1);i.position.x+=e*s,i.position.y-=t*s,this.syncDeviceTransforms()}moveCommitInputDepth(e){const t=this.gazeCommitActive;if(!t)return;const n=this.transformHandles.get(t.handedness);if(!n)return;const i=this.renderer.domElement.getBoundingClientRect(),r=Math.max(.25,Math.abs(n.position.z)),a=2*Math.tan(this.xrDevice.fovy/2)*r/Math.max(i.height,1);n.position.z-=e*a*.5,this.syncDeviceTransforms()}gazePointerDownHandler(e){var t,n;null===this.gazePointerId&&this.gazeInteractionEnabled()&&(0!==e.button&&2!==e.button||(e.preventDefault(),e.stopPropagation(),this.gazePointerId=e.pointerId,this.gazeLastPointer={x:e.clientX,y:e.clientY},null===(n=(t=this.renderer.domElement).setPointerCapture)||void 0===n||n.call(t,e.pointerId),0===e.button?(this.updateGazeFromPointer(e.clientX,e.clientY),this.beginGazeCommit()):this.gazeHeadsetDragActive=!0))}gazePointerMoveHandler(e){if(null!==this.gazePointerId&&this.gazePointerId!==e.pointerId)return;const t=e.clientX-this.gazeLastPointer.x,n=e.clientY-this.gazeLastPointer.y;return this.gazeLastPointer={x:e.clientX,y:e.clientY},this.gazeInteractionEnabled()?this.gazeCommitActive?(e.preventDefault(),void this.moveCommitInput(t,n)):this.gazeHeadsetDragActive?(e.preventDefault(),this.playerRig.rotation.y-=.002*t,this.cameraRig.rotation.x-=.002*n,void this.xrDevice.quaternion.copy(this.cameraRig.getWorldQuaternion(this.quatMouse))):void this.updateGazeFromPointer(e.clientX,e.clientY):void 0}gazePointerUpHandler(e){var t,n,i,r;this.gazePointerId===e.pointerId&&(this.gazeCommitActive&&this.releaseGazeCommit(!1),this.gazeHeadsetDragActive=!1,this.gazePointerId=null,(null===(n=(t=this.renderer.domElement).hasPointerCapture)||void 0===n?void 0:n.call(t,e.pointerId))&&(null===(r=(i=this.renderer.domElement).releasePointerCapture)||void 0===r||r.call(i,e.pointerId)))}gazeWheelHandler(e){this.gazeInteractionEnabled()&&this.gazeCommitActive&&(e.preventDefault(),e.stopPropagation(),this.moveCommitInputDepth(e.deltaY))}gazeContextMenuHandler(e){"cursor"===this.gazeMode&&e.preventDefault()}resetInputTransform(e){const t=this.transformHandles.get(e);t&&(t.position.fromArray(t.userData.defaultPosition),t.quaternion.fromArray(t.userData.defaultQuaternion),this.syncDeviceTransforms())}keyDownHandler(e){const{keyState:t}=this;if(e.code in t&&(t[e.code]=!0),!this.isInProgrammaticMode){if("cursor"===this.gazeMode&&"Space"===e.code){if(e.composedPath().some(e=>{if("object"!=typeof e||null===e)return!1;const t=e;return!0===t.isContentEditable||"string"==typeof t.tagName&&["A","BUTTON","INPUT","SELECT","TEXTAREA"].includes(t.tagName)}))return;return e.preventDefault(),void this.resetInputTransform(this.gazeCommitHand)}t.ShiftLeft&&t.ArrowUp&&(this.cameraRig.position.y+=.05),t.ShiftLeft&&t.ArrowDown&&(this.cameraRig.position.y-=.05)}}keyUpHandler(e){const{keyState:t}=this;e.code in t&&(t[e.code]=!1)}movePlayerRig(e){const{playerRig:t,keyState:n,vec3:i}=this;i.set((n.KeyD?1:0)-(n.KeyA?1:0),0,(n.KeyS?1:0)-(n.KeyW?1:0)),i.lengthSq()>0&&n.ShiftLeft&&(i.normalize().multiplyScalar(2*e).applyQuaternion(t.quaternion),t.position.add(i))}resetDeviceTransforms(){const{playerRig:e,cameraRig:t,transformHandles:n}=this;t.position.copy(this.headsetDefaultPosition),t.quaternion.copy(this.headsetDefaultQuaternion),e.position.set(0,0,0),e.quaternion.set(0,0,0,1),n.forEach(e=>{e.position.fromArray(e.userData.defaultPosition),e.quaternion.fromArray(e.userData.defaultQuaternion)})}captureDefaultPose(){const e=this.cameraRig.getWorldPosition(this.vec3).toArray(),t=this.cameraRig.getWorldQuaternion(this.quat).toArray(),n={},i={};return this.transformHandles.forEach((e,t)=>{const r=e.getWorldPosition(this.vec3).toArray(),a=e.getWorldQuaternion(this.quat).toArray(),s={position:r,quaternion:a};n[t]=s,i[t]={position:[...r],quaternion:[...a]}}),{headset:{position:e,quaternion:t},controllers:n,hands:i}}applyDefaultPose(e){const{headset:t,controllers:n,hands:i}=e;this.headsetDefaultPosition.fromArray(t.position),this.headsetDefaultQuaternion.fromArray(t.quaternion),this.quatInv.copy(this.headsetDefaultQuaternion).invert(),this.transformHandles.forEach((e,t)=>{var r;const a=null!==(r=null==n?void 0:n[t])&&void 0!==r?r:null==i?void 0:i[t];a&&(this.vec3.fromArray(a.position).sub(this.headsetDefaultPosition).applyQuaternion(this.quatInv),this.quat.fromArray(a.quaternion).premultiply(this.quatInv),e.userData.defaultPosition=this.vec3.toArray(),e.userData.defaultQuaternion=this.quat.toArray())}),this.resetDeviceTransforms(),this.combinedCameraPosition.copy(this.headsetDefaultPosition)}syncDeviceTransforms(){const{xrDevice:e,cameraRig:t,transformHandles:n}=this;e.position.copy(t.getWorldPosition(this.vec3)),e.quaternion.copy(t.getWorldQuaternion(this.quat)),n.forEach((t,n)=>{const i="controller"===e.primaryInputMode?e.controllers[n]:e.hands[n];i.position.copy(t.getWorldPosition(this.vec3)),i.quaternion.copy(t.getWorldQuaternion(this.quat))})}syncFromDevice(){const{xrDevice:e,playerRig:t,cameraRig:n,transformHandles:i}=this;this.syncGazeModeFromDevice();const r=e.position,a=e.quaternion;this.combinedCameraPosition.set(r.x,r.y,r.z),this.quatB.set(a.x,a.y,a.z,a.w),this.euler.setFromQuaternion(this.quatB,"YXZ"),t.position.set(r.x,0,r.z),t.rotation.set(0,this.euler.y,0),n.position.set(0,r.y,0),this.quat.setFromEuler(this.euler.set(0,this.euler.y,0,"YXZ")),n.quaternion.multiplyQuaternions(this.quat.invert(),this.quatB),t.updateMatrixWorld(!0),n.getWorldQuaternion(this.quatInv).invert(),i.forEach((t,i)=>{const r="controller"===e.primaryInputMode?e.controllers[i]:e.hands[i],a=this.vec3.set(r.position.x,r.position.y,r.position.z);n.worldToLocal(a),t.position.copy(a),this.quatB.set(r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w),this.quatB.premultiply(this.quatInv),t.quaternion.copy(this.quatB)})}syncGazeModeFromDevice(){var e;const t=(null===(e=this.xrDevice.gaze)||void 0===e?void 0:e.connected)?"head-locked":"off";t!==this.gazeMode&&(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1,this.applyGazeModePresentation(t))}setInteractionsEnabled(e){this.interactionsEnabled=e,e||(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1),!e&&this.isPointerLocked&&document.exitPointerLock()}renderScene(e){!this.gazeCommitActive||this.gazeInteractionEnabled()&&this.gazeCommitSourceIsActive()||(this.releaseGazeCommit(!0),this.gazeHeadsetDragActive=!1),this.schedulePendingGazeRelease();const t=this.xrDevice.fovy/Math.PI*180;let n=!1;this.camera.fov!==t&&(this.camera.fov=t,n=!0);const i=this.xrDevice.canvasDimensions;if(i){const e=this.renderer.domElement;(e.width!==i.width||e.height!==i.height)&&(this.camera.aspect=i.width/i.height,this.renderer.setSize(i.width,i.height),n=!0)}n&&this.camera.updateProjectionMatrix(),this.isInProgrammaticMode||(this.isPointerLocked?this.cameraRig.getWorldPosition(this.combinedCameraPosition):(this.cameraRig.position.y=this.combinedCameraPosition.y,this.playerRig.position.x=this.combinedCameraPosition.x,this.playerRig.position.z=this.combinedCameraPosition.z)),"cursor"!==this.gazeMode&&this.forwardHtmlEvents(),this.transformHandles.forEach((t,n)=>{const i="controller"===this.xrDevice.primaryInputMode?this.xrDevice.controllers[n]:this.xrDevice.hands[n],r=Boolean(null==i?void 0:i.connected);t.visible=r&&!this.isPointerLocked&&!this.isInProgrammaticMode&&"cursor"!==this.gazeMode,r&&t.update(e,this.camera)});const r=Math.min((e-this.lastTime)/1e3,.1);this.isInProgrammaticMode||(this.movePlayerRig(r),this.syncDeviceTransforms()),this.renderer.render(this.scene,this.camera),this.lastTime=e}get domElement(){return this.renderer.domElement}dispose(){this.releaseGazeCommit(!0),this.setTransformHandleRoutingSuppressed(!1),this.renderer.dispose(),document.removeEventListener("pointerlockchange",this.pointerLockChangeHandlerBound,!1),document.removeEventListener("mozpointerlockchange",this.pointerLockChangeHandlerBound,!1),document.removeEventListener("webkitpointerlockchange",this.pointerLockChangeHandlerBound,!1),document.removeEventListener("mousemove",this.mouseMoveHandler,!1),document.removeEventListener("keydown",this.keyDownHandlerBound,!1),document.removeEventListener("keyup",this.keyUpHandlerBound,!1),this.renderer.domElement.removeEventListener("pointerdown",this.gazePointerDownHandlerBound),this.renderer.domElement.removeEventListener("pointermove",this.gazePointerMoveHandlerBound),this.renderer.domElement.removeEventListener("pointerup",this.gazePointerUpHandlerBound),this.renderer.domElement.removeEventListener("pointercancel",this.gazePointerUpHandlerBound),this.renderer.domElement.removeEventListener("wheel",this.gazeWheelHandlerBound),this.renderer.domElement.removeEventListener("contextmenu",this.gazeContextMenuHandlerBound),window.removeEventListener("blur",this.windowBlurHandlerBound),document.removeEventListener("visibilitychange",this.documentVisibilityHandlerBound)}}var dw,hw,pw={exports:{}},fw={},mw={exports:{}},gw={};function vw(){return hw||(hw=1,mw.exports=(dw||(dw=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var i=n-1>>>1,a=e[i];if(!(0<r(a,t)))break e;e[i]=t,e[n]=a,n=i}}function n(e){return 0===e.length?null:e[0]}function i(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var i=0,a=e.length,s=a>>>1;i<s;){var o=2*(i+1)-1,l=e[o],c=o+1,u=e[c];if(0>r(l,n))c<a&&0>r(u,l)?(e[i]=u,e[c]=n,i=c):(e[i]=l,e[o]=n,i=o);else{if(!(c<a&&0>r(u,n)))break e;e[i]=u,e[c]=n,i=c}}}return t}function r(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(e.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var a=performance;e.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();e.unstable_now=function(){return s.now()-o}}var l=[],c=[],u=1,d=null,h=3,p=!1,f=!1,m=!1,g=!1,v="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,x="undefined"!=typeof setImmediate?setImmediate:null;function b(e){for(var r=n(c);null!==r;){if(null===r.callback)i(c);else{if(!(r.startTime<=e))break;i(c),r.sortIndex=r.expirationTime,t(l,r)}r=n(c)}}function _(e){if(m=!1,b(e),!f)if(null!==n(l))f=!0,S||(S=!0,w());else{var t=n(c);null!==t&&L(_,t.startTime-e)}}var w,S=!1,E=-1,M=5,T=-1;function A(){return!(!g&&e.unstable_now()-T<M)}function R(){if(g=!1,S){var t=e.unstable_now();T=t;var r=!0;try{e:{f=!1,m&&(m=!1,y(E),E=-1),p=!0;var a=h;try{t:{for(b(t),d=n(l);null!==d&&!(d.expirationTime>t&&A());){var s=d.callback;if("function"==typeof s){d.callback=null,h=d.priorityLevel;var o=s(d.expirationTime<=t);if(t=e.unstable_now(),"function"==typeof o){d.callback=o,b(t),r=!0;break t}d===n(l)&&i(l),b(t)}else i(l);d=n(l)}if(null!==d)r=!0;else{var u=n(c);null!==u&&L(_,u.startTime-t),r=!1}}break e}finally{d=null,h=a,p=!1}r=void 0}}finally{r?w():S=!1}}}if("function"==typeof x)w=function(){x(R)};else if("undefined"!=typeof MessageChannel){var P=new MessageChannel,C=P.port2;P.port1.onmessage=R,w=function(){C.postMessage(null)}}else w=function(){v(R,0)};function L(t,n){E=v(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_next=function(e){switch(h){case 1:case 2:case 3:var t=3;break;default:t=h}var n=h;h=t;try{return e()}finally{h=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=h;h=e;try{return t()}finally{h=n}},e.unstable_scheduleCallback=function(i,r,a){var s=e.unstable_now();switch(a="object"==typeof a&&null!==a&&"number"==typeof(a=a.delay)&&0<a?s+a:s,i){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return i={id:u++,callback:r,priorityLevel:i,startTime:a,expirationTime:o=a+o,sortIndex:-1},a>s?(i.sortIndex=a,t(c,i),null===n(l)&&i===n(c)&&(m?(y(E),E=-1):m=!0,L(_,a-s))):(i.sortIndex=o,t(l,i),f||p||(f=!0,S||(S=!0,w()))),i},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(e){var t=h;return function(){var n=h;h=t;try{return e.apply(this,arguments)}finally{h=n}}}}(gw)),gw)),mw.exports}var yw,xw,bw,_w={exports:{}},ww={};function Sw(){if(yw)return ww;yw=1;var e=o;function t(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var i={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");var a=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function s(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}return ww.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,ww.createPortal=function(e,n){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!n||1!==n.nodeType&&9!==n.nodeType&&11!==n.nodeType)throw Error(t(299));return function(e,t,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:r,key:null==i?null:""+i,children:e,containerInfo:t,implementation:n}}(e,n,null,i)},ww.flushSync=function(e){var t=a.T,n=i.p;try{if(a.T=null,i.p=2,e)return e()}finally{a.T=t,i.p=n,i.d.f()}},ww.preconnect=function(e,t){"string"==typeof e&&(t?t="string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,i.d.C(e,t))},ww.prefetchDNS=function(e){"string"==typeof e&&i.d.D(e)},ww.preinit=function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var n=t.as,r=s(n,t.crossOrigin),a="string"==typeof t.integrity?t.integrity:void 0,o="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?i.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):"script"===n&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},ww.preinitModule=function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=s(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&i.d.M(e)},ww.preload=function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var n=t.as,r=s(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},ww.preloadModule=function(e,t){if("string"==typeof e)if(t){var n=s(t.as,t.crossOrigin);i.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else i.d.m(e)},ww.requestFormReset=function(e){i.d.r(e)},ww.unstable_batchedUpdates=function(e,t){return e(t)},ww.useFormState=function(e,t,n){return a.H.useFormState(e,t,n)},ww.useFormStatus=function(){return a.H.useHostTransitionStatus()},ww.version="19.2.8",ww}!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),pw.exports=function(){if(bw)return fw;bw=1;var e=vw(),t=o,n=(xw||(xw=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),_w.exports=Sw()),_w.exports);function i(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function a(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function s(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&null!==(e=e.alternate)&&(t=e.memoizedState),null!==t)return t.dehydrated}return null}function l(e){if(31===e.tag){var t=e.memoizedState;if(null===t&&null!==(e=e.alternate)&&(t=e.memoizedState),null!==t)return t.dehydrated}return null}function c(e){if(a(e)!==e)throw Error(i(188))}function u(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=u(e)))return t;e=e.sibling}return null}var d=Object.assign,h=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),x=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),T=Symbol.for("react.memo_cache_sentinel"),A=Symbol.iterator;function R(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=A&&e[A]||e["@@iterator"])?e:null}var P=Symbol.for("react.client.reference");function C(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===P?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case m:return"Fragment";case v:return"Profiler";case g:return"StrictMode";case _:return"Suspense";case w:return"SuspenseList";case M:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case f:return"Portal";case x:return e.displayName||"Context";case y:return(e._context.displayName||"Context")+".Consumer";case b:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case S:return null!==(t=e.displayName||null)?t:C(e.type)||"Memo";case E:t=e._payload,e=e._init;try{return C(e(t))}catch(e){}}return null}var L=Array.isArray,I=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N={pending:!1,data:null,method:null,action:null},k=[],F=-1;function O(e){return{current:e}}function U(e){0>F||(e.current=k[F],k[F]=null,F--)}function z(e,t){F++,k[F]=e.current,e.current=t}var B,V,H=O(null),G=O(null),W=O(null),j=O(null);function X(e,t){switch(z(W,t),z(G,e),z(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?md(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=gd(t=md(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}U(H),z(H,e)}function q(){U(H),U(G),U(W)}function $(e){null!==e.memoizedState&&z(j,e);var t=H.current,n=gd(t,e.type);t!==n&&(z(G,e),z(H,n))}function Y(e){G.current===e&&(U(H),U(G)),j.current===e&&(U(j),lh._currentValue=N)}function K(e){if(void 0===B)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);B=t&&t[1]||"",V=-1<e.stack.indexOf("\n at")?" (<anonymous>)":-1<e.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+B+e+V}var Q=!1;function Z(e,t){if(!e||Q)return"";Q=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var i=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){i=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){i=e}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(e){if(e&&i&&"string"==typeof e.stack)return[e.stack,i.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var a=i.DetermineComponentFrameRoot(),s=a[0],o=a[1];if(s&&o){var l=s.split("\n"),c=o.split("\n");for(r=i=0;i<l.length&&!l[i].includes("DetermineComponentFrameRoot");)i++;for(;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;if(i===l.length||r===c.length)for(i=l.length-1,r=c.length-1;1<=i&&0<=r&&l[i]!==c[r];)r--;for(;1<=i&&0<=r;i--,r--)if(l[i]!==c[r]){if(1!==i||1!==r)do{if(i--,0>--r||l[i]!==c[r]){var u="\n"+l[i].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=i&&0<=r);break}}}finally{Q=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?K(n):""}function J(e,t){switch(e.tag){case 26:case 27:case 5:return K(e.type);case 16:return K("Lazy");case 13:return e.child!==t&&null!==t?K("Suspense Fallback"):K("Suspense");case 19:return K("SuspenseList");case 0:case 15:return Z(e.type,!1);case 11:return Z(e.type.render,!1);case 1:return Z(e.type,!0);case 31:return K("Activity");default:return""}}function ee(e){try{var t="",n=null;do{t+=J(e,n),n=e,e=e.return}while(e);return t}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}var te=Object.prototype.hasOwnProperty,ne=e.unstable_scheduleCallback,ie=e.unstable_cancelCallback,re=e.unstable_shouldYield,ae=e.unstable_requestPaint,se=e.unstable_now,oe=e.unstable_getCurrentPriorityLevel,le=e.unstable_ImmediatePriority,ce=e.unstable_UserBlockingPriority,ue=e.unstable_NormalPriority,de=e.unstable_LowPriority,he=e.unstable_IdlePriority,pe=e.log,fe=e.unstable_setDisableYieldValue,me=null,ge=null;function ve(e){if("function"==typeof pe&&fe(e),ge&&"function"==typeof ge.setStrictMode)try{ge.setStrictMode(me,e)}catch(e){}}var ye=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(xe(e)/be|0)|0},xe=Math.log,be=Math.LN2,_e=256,we=262144,Se=4194304;function Ee(e){var t=42&e;if(0!==t)return t;switch(e&-e){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 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Me(e,t,n){var i=e.pendingLanes;if(0===i)return 0;var r=0,a=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var o=134217727&i;return 0!==o?0!==(i=o&~a)?r=Ee(i):0!==(s&=o)?r=Ee(s):n||0!==(n=o&~e)&&(r=Ee(n)):0!==(o=i&~a)?r=Ee(o):0!==s?r=Ee(s):n||0!==(n=i&~e)&&(r=Ee(n)),0===r?0:0!==t&&t!==r&&0===(t&a)&&((a=r&-r)>=(n=t&-t)||32===a&&4194048&n)?t:r}function Te(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ae(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+5e3;default:return-1}}function Re(){var e=Se;return!(62914560&(Se<<=1))&&(Se=4194304),e}function Pe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ce(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Le(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-ye(t);e.entangledLanes|=t,e.entanglements[i]=1073741824|e.entanglements[i]|261930&n}function Ie(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var i=31-ye(n),r=1<<i;r&t|e[i]&t&&(e[i]|=t),n&=~r}}function De(e,t){var n=t&-t;return 0!==((n=42&n?1:Ne(n))&(e.suspendedLanes|t))?0:n}function Ne(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function ke(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function Fe(){var e=D.p;return 0!==e?e:void 0===(e=window.event)?32:Eh(e.type)}function Oe(e,t){var n=D.p;try{return D.p=e,t()}finally{D.p=n}}var Ue=Math.random().toString(36).slice(2),ze="__reactFiber$"+Ue,Be="__reactProps$"+Ue,Ve="__reactContainer$"+Ue,He="__reactEvents$"+Ue,Ge="__reactListeners$"+Ue,We="__reactHandles$"+Ue,je="__reactResources$"+Ue,Xe="__reactMarker$"+Ue;function qe(e){delete e[ze],delete e[Be],delete e[He],delete e[Ge],delete e[We]}function $e(e){var t=e[ze];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ve]||n[ze]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Nd(e);null!==e;){if(n=e[ze])return n;e=Nd(e)}return t}n=(e=n).parentNode}return null}function Ye(e){if(e=e[ze]||e[Ve]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function Ke(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(i(33))}function Qe(e){var t=e[je];return t||(t=e[je]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Ze(e){e[Xe]=!0}var Je=new Set,et={};function tt(e,t){nt(e,t),nt(e+"Capture",t)}function nt(e,t){for(et[e]=t,e=0;e<t.length;e++)Je.add(t[e])}var it=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),rt={},at={};function st(e,t,n){if(r=t,te.call(at,r)||!te.call(rt,r)&&(it.test(r)?at[r]=!0:(rt[r]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var i=t.toLowerCase().slice(0,5);if("data-"!==i&&"aria-"!==i)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var r}function ot(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function lt(e,t,n,i){if(null===i)e.removeAttribute(n);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+i)}}function ct(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function ut(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function dt(e){if(!e._valueTracker){var t=ut(e)?"checked":"value";e._valueTracker=function(e,t,n){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==i&&"function"==typeof i.get&&"function"==typeof i.set){var r=i.get,a=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(e){n=""+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function ht(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),i="";return e&&(i=ut(e)?e.checked?"true":"false":e.value),(e=i)!==n&&(t.setValue(e),!0)}function pt(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var ft=/[\n"\\]/g;function mt(e){return e.replace(ft,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function gt(e,t,n,i,r,a,s,o){e.name="",null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s?e.type=s:e.removeAttribute("type"),null!=t?"number"===s?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ct(t)):e.value!==""+ct(t)&&(e.value=""+ct(t)):"submit"!==s&&"reset"!==s||e.removeAttribute("value"),null!=t?yt(e,s,ct(t)):null!=n?yt(e,s,ct(n)):null!=i&&e.removeAttribute("value"),null==r&&null!=a&&(e.defaultChecked=!!a),null!=r&&(e.checked=r&&"function"!=typeof r&&"symbol"!=typeof r),null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.name=""+ct(o):e.removeAttribute("name")}function vt(e,t,n,i,r,a,s,o){if(null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&"boolean"!=typeof a&&(e.type=a),null!=t||null!=n){if(("submit"===a||"reset"===a)&&null==t)return void dt(e);n=null!=n?""+ct(n):"",t=null!=t?""+ct(t):n,o||t===e.value||(e.value=t),e.defaultValue=t}i="function"!=typeof(i=null!=i?i:r)&&"symbol"!=typeof i&&!!i,e.checked=o?e.checked:!!i,e.defaultChecked=!!i,null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s&&(e.name=s),dt(e)}function yt(e,t,n){"number"===t&&pt(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function xt(e,t,n,i){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&i&&(e[n].defaultSelected=!0)}else{for(n=""+ct(n),t=null,r=0;r<e.length;r++){if(e[r].value===n)return e[r].selected=!0,void(i&&(e[r].defaultSelected=!0));null!==t||e[r].disabled||(t=e[r])}null!==t&&(t.selected=!0)}}function bt(e,t,n){null==t||((t=""+ct(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ct(n):"":e.defaultValue!==t&&(e.defaultValue=t)}function _t(e,t,n,r){if(null==t){if(null!=r){if(null!=n)throw Error(i(92));if(L(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}null==n&&(n=""),t=n}n=ct(t),e.defaultValue=n,(r=e.textContent)===n&&""!==r&&null!==r&&(e.value=r),dt(e)}function wt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var St=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Et(e,t,n){var i=0===t.indexOf("--");null==n||"boolean"==typeof n||""===n?i?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":i?e.setProperty(t,n):"number"!=typeof n||0===n||St.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Mt(e,t,n){if(null!=t&&"object"!=typeof t)throw Error(i(62));if(e=e.style,null!=n){for(var r in n)!n.hasOwnProperty(r)||null!=t&&t.hasOwnProperty(r)||(0===r.indexOf("--")?e.setProperty(r,""):"float"===r?e.cssFloat="":e[r]="");for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Et(e,a,r)}else for(var s in t)t.hasOwnProperty(s)&&Et(e,s,t[s])}function Tt(e){if(-1===e.indexOf("-"))return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var At=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Rt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Pt(e){return Rt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Ct(){}var Lt=null;function It(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Dt=null,Nt=null;function kt(e){var t=Ye(e);if(t&&(e=t.stateNode)){var n=e[Be]||null;e:switch(e=t.stateNode,t.type){case"input":if(gt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+mt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[Be]||null;if(!a)throw Error(i(90));gt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)(r=n[t]).form===e.form&&ht(r)}break e;case"textarea":bt(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&xt(e,!!n.multiple,t,!1)}}}var Ft=!1;function Ot(e,t,n){if(Ft)return e(t,n);Ft=!0;try{return e(t)}finally{if(Ft=!1,(null!==Dt||null!==Nt)&&(Qc(),Dt&&(t=Dt,e=Nt,Nt=Dt=null,kt(t),e)))for(t=0;t<e.length;t++)kt(e[t])}}function Ut(e,t){var n=e.stateNode;if(null===n)return null;var r=n[Be]||null;if(null===r)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(i(231,t,typeof n));return n}var zt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Bt=!1;if(zt)try{var Vt={};Object.defineProperty(Vt,"passive",{get:function(){Bt=!0}}),window.addEventListener("test",Vt,Vt),window.removeEventListener("test",Vt,Vt)}catch(e){Bt=!1}var Ht=null,Gt=null,Wt=null;function jt(){if(Wt)return Wt;var e,t,n=Gt,i=n.length,r="value"in Ht?Ht.value:Ht.textContent,a=r.length;for(e=0;e<i&&n[e]===r[e];e++);var s=i-e;for(t=1;t<=s&&n[i-t]===r[a-t];t++);return Wt=r.slice(e,1<t?1-t:void 0)}function Xt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function qt(){return!0}function $t(){return!1}function Yt(e){function t(t,n,i,r,a){for(var s in this._reactName=t,this._targetInst=i,this.type=n,this.nativeEvent=r,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(s)&&(t=e[s],this[s]=t?t(r):r[s]);return this.isDefaultPrevented=(null!=r.defaultPrevented?r.defaultPrevented:!1===r.returnValue)?qt:$t,this.isPropagationStopped=$t,this}return d(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=qt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=qt)},persist:function(){},isPersistent:qt}),t}var Kt,Qt,Zt,Jt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},en=Yt(Jt),tn=d({},Jt,{view:0,detail:0}),nn=Yt(tn),rn=d({},tn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Zt&&(Zt&&"mousemove"===e.type?(Kt=e.screenX-Zt.screenX,Qt=e.screenY-Zt.screenY):Qt=Kt=0,Zt=e),Kt)},movementY:function(e){return"movementY"in e?e.movementY:Qt}}),an=Yt(rn),sn=Yt(d({},rn,{dataTransfer:0})),on=Yt(d({},tn,{relatedTarget:0})),ln=Yt(d({},Jt,{animationName:0,elapsedTime:0,pseudoElement:0})),cn=Yt(d({},Jt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),un=Yt(d({},Jt,{data:0})),dn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},pn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=pn[e])&&!!t[e]}function mn(){return fn}var gn=Yt(d({},tn,{key:function(e){if(e.key){var t=dn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Xt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?hn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mn,charCode:function(e){return"keypress"===e.type?Xt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Xt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),vn=Yt(d({},rn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),yn=Yt(d({},tn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mn})),xn=Yt(d({},Jt,{propertyName:0,elapsedTime:0,pseudoElement:0})),bn=Yt(d({},rn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),_n=Yt(d({},Jt,{newState:0,oldState:0})),wn=[9,13,27,32],Sn=zt&&"CompositionEvent"in window,En=null;zt&&"documentMode"in document&&(En=document.documentMode);var Mn=zt&&"TextEvent"in window&&!En,Tn=zt&&(!Sn||En&&8<En&&11>=En),An=String.fromCharCode(32),Rn=!1;function Pn(e,t){switch(e){case"keyup":return-1!==wn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Ln=!1,In={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Dn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!In[e.type]:"textarea"===t}function Nn(e,t,n,i){Dt?Nt?Nt.push(i):Nt=[i]:Dt=i,0<(t=td(t,"onChange")).length&&(n=new en("onChange","change",null,n,i),e.push({event:n,listeners:t}))}var kn=null,Fn=null;function On(e){qu(e,0)}function Un(e){if(ht(Ke(e)))return e}function zn(e,t){if("change"===e)return t}var Bn=!1;if(zt){var Vn;if(zt){var Hn="oninput"in document;if(!Hn){var Gn=document.createElement("div");Gn.setAttribute("oninput","return;"),Hn="function"==typeof Gn.oninput}Vn=Hn}else Vn=!1;Bn=Vn&&(!document.documentMode||9<document.documentMode)}function Wn(){kn&&(kn.detachEvent("onpropertychange",jn),Fn=kn=null)}function jn(e){if("value"===e.propertyName&&Un(Fn)){var t=[];Nn(t,Fn,e,It(e)),Ot(On,t)}}function Xn(e,t,n){"focusin"===e?(Wn(),Fn=n,(kn=t).attachEvent("onpropertychange",jn)):"focusout"===e&&Wn()}function qn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Un(Fn)}function $n(e,t){if("click"===e)return Un(t)}function Yn(e,t){if("input"===e||"change"===e)return Un(t)}var Kn="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function Qn(e,t){if(Kn(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(i=0;i<n.length;i++){var r=n[i];if(!te.call(t,r)||!Kn(e[r],t[r]))return!1}return!0}function Zn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Jn(e,t){var n,i=Zn(e);for(e=0;i;){if(3===i.nodeType){if(n=e+i.textContent.length,e<=t&&n>=t)return{node:i,offset:t-e};e=n}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Zn(i)}}function ei(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?ei(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ti(e){for(var t=pt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=pt((e=t.contentWindow).document)}return t}function ni(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var ii=zt&&"documentMode"in document&&11>=document.documentMode,ri=null,ai=null,si=null,oi=!1;function li(e,t,n){var i=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;oi||null==ri||ri!==pt(i)||(i="selectionStart"in(i=ri)&&ni(i)?{start:i.selectionStart,end:i.selectionEnd}:{anchorNode:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset},si&&Qn(si,i)||(si=i,0<(i=td(ai,"onSelect")).length&&(t=new en("onSelect","select",null,t,n),e.push({event:t,listeners:i}),t.target=ri)))}function ci(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ui={animationend:ci("Animation","AnimationEnd"),animationiteration:ci("Animation","AnimationIteration"),animationstart:ci("Animation","AnimationStart"),transitionrun:ci("Transition","TransitionRun"),transitionstart:ci("Transition","TransitionStart"),transitioncancel:ci("Transition","TransitionCancel"),transitionend:ci("Transition","TransitionEnd")},di={},hi={};function pi(e){if(di[e])return di[e];if(!ui[e])return e;var t,n=ui[e];for(t in n)if(n.hasOwnProperty(t)&&t in hi)return di[e]=n[t];return e}zt&&(hi=document.createElement("div").style,"AnimationEvent"in window||(delete ui.animationend.animation,delete ui.animationiteration.animation,delete ui.animationstart.animation),"TransitionEvent"in window||delete ui.transitionend.transition);var fi=pi("animationend"),mi=pi("animationiteration"),gi=pi("animationstart"),vi=pi("transitionrun"),yi=pi("transitionstart"),xi=pi("transitioncancel"),bi=pi("transitionend"),_i=new Map,wi="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Si(e,t){_i.set(e,t),tt(t,[e])}wi.push("scrollEnd");var Ei="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},Mi=[],Ti=0,Ai=0;function Ri(){for(var e=Ti,t=Ai=Ti=0;t<e;){var n=Mi[t];Mi[t++]=null;var i=Mi[t];Mi[t++]=null;var r=Mi[t];Mi[t++]=null;var a=Mi[t];if(Mi[t++]=null,null!==i&&null!==r){var s=i.pending;null===s?r.next=r:(r.next=s.next,s.next=r),i.pending=r}0!==a&&Ii(n,r,a)}}function Pi(e,t,n,i){Mi[Ti++]=e,Mi[Ti++]=t,Mi[Ti++]=n,Mi[Ti++]=i,Ai|=i,e.lanes|=i,null!==(e=e.alternate)&&(e.lanes|=i)}function Ci(e,t,n,i){return Pi(e,t,n,i),Di(e)}function Li(e,t){return Pi(e,null,null,t),Di(e)}function Ii(e,t,n){e.lanes|=n;var i=e.alternate;null!==i&&(i.lanes|=n);for(var r=!1,a=e.return;null!==a;)a.childLanes|=n,null!==(i=a.alternate)&&(i.childLanes|=n),22===a.tag&&(null===(e=a.stateNode)||1&e._visibility||(r=!0)),e=a,a=a.return;return 3===e.tag?(a=e.stateNode,r&&null!==t&&(r=31-ye(n),null===(i=(e=a.hiddenUpdates)[r])?e[r]=[t]:i.push(t),t.lane=536870912|n),a):null}function Di(e){if(50<Hc)throw Hc=0,Gc=null,Error(i(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Ni={};function ki(e,t,n,i){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fi(e,t,n,i){return new ki(e,t,n,i)}function Oi(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Ui(e,t){var n=e.alternate;return null===n?((n=Fi(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=65011712&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function zi(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Bi(e,t,n,r,a,s){var o=0;if(r=e,"function"==typeof e)Oi(e)&&(o=1);else if("string"==typeof e)o=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,n,H.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case M:return(e=Fi(31,n,t,a)).elementType=M,e.lanes=s,e;case m:return Vi(n.children,a,s,t);case g:o=8,a|=24;break;case v:return(e=Fi(12,n,t,2|a)).elementType=v,e.lanes=s,e;case _:return(e=Fi(13,n,t,a)).elementType=_,e.lanes=s,e;case w:return(e=Fi(19,n,t,a)).elementType=w,e.lanes=s,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case x:o=10;break e;case y:o=9;break e;case b:o=11;break e;case S:o=14;break e;case E:o=16,r=null;break e}o=29,n=Error(i(130,null===e?"null":typeof e,"")),r=null}return(t=Fi(o,n,t,a)).elementType=e,t.type=r,t.lanes=s,t}function Vi(e,t,n,i){return(e=Fi(7,e,i,t)).lanes=n,e}function Hi(e,t,n){return(e=Fi(6,e,null,t)).lanes=n,e}function Gi(e){var t=Fi(18,null,null,0);return t.stateNode=e,t}function Wi(e,t,n){return(t=Fi(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ji=new WeakMap;function Xi(e,t){if("object"==typeof e&&null!==e){var n=ji.get(e);return void 0!==n?n:(t={value:e,source:t,stack:ee(t)},ji.set(e,t),t)}return{value:e,source:t,stack:ee(t)}}var qi=[],$i=0,Yi=null,Ki=0,Qi=[],Zi=0,Ji=null,er=1,tr="";function nr(e,t){qi[$i++]=Ki,qi[$i++]=Yi,Yi=e,Ki=t}function ir(e,t,n){Qi[Zi++]=er,Qi[Zi++]=tr,Qi[Zi++]=Ji,Ji=e;var i=er;e=tr;var r=32-ye(i)-1;i&=~(1<<r),n+=1;var a=32-ye(t)+r;if(30<a){var s=r-r%5;a=(i&(1<<s)-1).toString(32),i>>=s,r-=s,er=1<<32-ye(t)+r|n<<r|i,tr=a+e}else er=1<<a|n<<r|i,tr=e}function rr(e){null!==e.return&&(nr(e,1),ir(e,1,0))}function ar(e){for(;e===Yi;)Yi=qi[--$i],qi[$i]=null,Ki=qi[--$i],qi[$i]=null;for(;e===Ji;)Ji=Qi[--Zi],Qi[Zi]=null,tr=Qi[--Zi],Qi[Zi]=null,er=Qi[--Zi],Qi[Zi]=null}function sr(e,t){Qi[Zi++]=er,Qi[Zi++]=tr,Qi[Zi++]=Ji,er=t.id,tr=t.overflow,Ji=e}var or=null,lr=null,cr=!1,ur=null,dr=!1,hr=Error(i(519));function pr(e){throw xr(Xi(Error(i(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),hr}function fr(e){var t=e.stateNode,n=e.type,i=e.memoizedProps;switch(t[ze]=e,t[Be]=i,n){case"dialog":$u("cancel",t),$u("close",t);break;case"iframe":case"object":case"embed":$u("load",t);break;case"video":case"audio":for(n=0;n<ju.length;n++)$u(ju[n],t);break;case"source":$u("error",t);break;case"img":case"image":case"link":$u("error",t),$u("load",t);break;case"details":$u("toggle",t);break;case"input":$u("invalid",t),vt(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":$u("invalid",t);break;case"textarea":$u("invalid",t),_t(t,i.value,i.defaultValue,i.children)}"string"!=typeof(n=i.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===i.suppressHydrationWarning||od(t.textContent,n)?(null!=i.popover&&($u("beforetoggle",t),$u("toggle",t)),null!=i.onScroll&&$u("scroll",t),null!=i.onScrollEnd&&$u("scrollend",t),null!=i.onClick&&(t.onclick=Ct),t=!0):t=!1,t||pr(e,!0)}function mr(e){for(or=e.return;or;)switch(or.tag){case 5:case 31:case 13:return void(dr=!1);case 27:case 3:return void(dr=!0);default:or=or.return}}function gr(e){if(e!==or)return!1;if(!cr)return mr(e),cr=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||vd(e.type,e.memoizedProps)),t=!t),t&&lr&&pr(e),mr(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));lr=Dd(e)}else if(31===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));lr=Dd(e)}else 27===n?(n=lr,Ed(e.type)?(e=Id,Id=null,lr=e):lr=n):lr=or?Ld(e.stateNode.nextSibling):null;return!0}function vr(){lr=or=null,cr=!1}function yr(){var e=ur;return null!==e&&(null===Rc?Rc=e:Rc.push.apply(Rc,e),ur=null),e}function xr(e){null===ur?ur=[e]:ur.push(e)}var br=O(null),_r=null,wr=null;function Sr(e,t,n){z(br,t._currentValue),t._currentValue=n}function Er(e){e._currentValue=br.current,U(br)}function Mr(e,t,n){for(;null!==e;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==i&&(i.childLanes|=t)):null!==i&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===n)break;e=e.return}}function Tr(e,t,n,r){var a=e.child;for(null!==a&&(a.return=e);null!==a;){var s=a.dependencies;if(null!==s){var o=a.child;s=s.firstContext;e:for(;null!==s;){var l=s;s=a;for(var c=0;c<t.length;c++)if(l.context===t[c]){s.lanes|=n,null!==(l=s.alternate)&&(l.lanes|=n),Mr(s.return,n,e),r||(o=null);break e}s=l.next}}else if(18===a.tag){if(null===(o=a.return))throw Error(i(341));o.lanes|=n,null!==(s=o.alternate)&&(s.lanes|=n),Mr(o,n,e),o=null}else o=a.child;if(null!==o)o.return=a;else for(o=a;null!==o;){if(o===e){o=null;break}if(null!==(a=o.sibling)){a.return=o.return,o=a;break}o=o.return}a=o}}function Ar(e,t,n,r){e=null;for(var a=t,s=!1;null!==a;){if(!s)if(524288&a.flags)s=!0;else if(262144&a.flags)break;if(10===a.tag){var o=a.alternate;if(null===o)throw Error(i(387));if(null!==(o=o.memoizedProps)){var l=a.type;Kn(a.pendingProps.value,o.value)||(null!==e?e.push(l):e=[l])}}else if(a===j.current){if(null===(o=a.alternate))throw Error(i(387));o.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(null!==e?e.push(lh):e=[lh])}a=a.return}null!==e&&Tr(t,e,n,r),t.flags|=262144}function Rr(e){for(e=e.firstContext;null!==e;){if(!Kn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Pr(e){_r=e,wr=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Cr(e){return Ir(_r,e)}function Lr(e,t){return null===_r&&Pr(e),Ir(e,t)}function Ir(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===wr){if(null===e)throw Error(i(308));wr=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else wr=wr.next=t;return n}var Dr="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Nr=e.unstable_scheduleCallback,kr=e.unstable_NormalPriority,Fr={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Or(){return{controller:new Dr,data:new Map,refCount:0}}function Ur(e){e.refCount--,0===e.refCount&&Nr(kr,function(){e.controller.abort()})}var zr=null,Br=0,Vr=0,Hr=null;function Gr(){if(0===--Br&&null!==zr){null!==Hr&&(Hr.status="fulfilled");var e=zr;zr=null,Vr=0,Hr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Wr=I.S;I.S=function(e,t){Lc=se(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===zr){var n=zr=[];Br=0,Vr=Bu(),Hr={status:"pending",value:void 0,then:function(e){n.push(e)}}}Br++,t.then(Gr,Gr)}(0,t),null!==Wr&&Wr(e,t)};var jr=O(null);function Xr(){var e=jr.current;return null!==e?e:hc.pooledCache}function qr(e,t){z(jr,null===t?jr.current:t.pool)}function $r(){var e=Xr();return null===e?null:{parent:Fr._currentValue,pool:e}}var Yr=Error(i(460)),Kr=Error(i(474)),Qr=Error(i(542)),Zr={then:function(){}};function Jr(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ea(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(Ct,Ct),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ra(e=t.reason),e;default:if("string"==typeof t.status)t.then(Ct,Ct);else{if(null!==(e=hc)&&100<e.shellSuspendCounter)throw Error(i(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw ra(e=t.reason),e}throw na=t,Yr}}function ta(e){try{return(0,e._init)(e._payload)}catch(e){if(null!==e&&"object"==typeof e&&"function"==typeof e.then)throw na=e,Yr;throw e}}var na=null;function ia(){if(null===na)throw Error(i(459));var e=na;return na=null,e}function ra(e){if(e===Yr||e===Qr)throw Error(i(483))}var aa=null,sa=0;function oa(e){var t=sa;return sa+=1,null===aa&&(aa=[]),ea(aa,e,t)}function la(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function ca(e,t){if(t.$$typeof===h)throw Error(i(525));throw e=Object.prototype.toString.call(t),Error(i(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ua(e){function t(t,n){if(e){var i=t.deletions;null===i?(t.deletions=[n],t.flags|=16):i.push(n)}}function n(n,i){if(!e)return null;for(;null!==i;)t(n,i),i=i.sibling;return null}function r(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function a(e,t){return(e=Ui(e,t)).index=0,e.sibling=null,e}function s(t,n,i){return t.index=i,e?null!==(i=t.alternate)?(i=i.index)<n?(t.flags|=67108866,n):i:(t.flags|=67108866,n):(t.flags|=1048576,n)}function o(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function l(e,t,n,i){return null===t||6!==t.tag?((t=Hi(n,e.mode,i)).return=e,t):((t=a(t,n)).return=e,t)}function c(e,t,n,i){var r=n.type;return r===m?d(e,t,n.props.children,i,n.key):null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===E&&ta(r)===t.type)?(la(t=a(t,n.props),n),t.return=e,t):(la(t=Bi(n.type,n.key,n.props,null,e.mode,i),n),t.return=e,t)}function u(e,t,n,i){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Wi(n,e.mode,i)).return=e,t):((t=a(t,n.children||[])).return=e,t)}function d(e,t,n,i,r){return null===t||7!==t.tag?((t=Vi(n,e.mode,i,r)).return=e,t):((t=a(t,n)).return=e,t)}function h(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Hi(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case p:return la(n=Bi(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case f:return(t=Wi(t,e.mode,n)).return=e,t;case E:return h(e,t=ta(t),n)}if(L(t)||R(t))return(t=Vi(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return h(e,oa(t),n);if(t.$$typeof===x)return h(e,Lr(e,t),n);ca(e,t)}return null}function g(e,t,n,i){var r=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==r?null:l(e,t,""+n,i);if("object"==typeof n&&null!==n){switch(n.$$typeof){case p:return n.key===r?c(e,t,n,i):null;case f:return n.key===r?u(e,t,n,i):null;case E:return g(e,t,n=ta(n),i)}if(L(n)||R(n))return null!==r?null:d(e,t,n,i,null);if("function"==typeof n.then)return g(e,t,oa(n),i);if(n.$$typeof===x)return g(e,t,Lr(e,n),i);ca(e,n)}return null}function v(e,t,n,i,r){if("string"==typeof i&&""!==i||"number"==typeof i||"bigint"==typeof i)return l(t,e=e.get(n)||null,""+i,r);if("object"==typeof i&&null!==i){switch(i.$$typeof){case p:return c(t,e=e.get(null===i.key?n:i.key)||null,i,r);case f:return u(t,e=e.get(null===i.key?n:i.key)||null,i,r);case E:return v(e,t,n,i=ta(i),r)}if(L(i)||R(i))return d(t,e=e.get(n)||null,i,r,null);if("function"==typeof i.then)return v(e,t,n,oa(i),r);if(i.$$typeof===x)return v(e,t,n,Lr(t,i),r);ca(t,i)}return null}function y(l,c,u,d){if("object"==typeof u&&null!==u&&u.type===m&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case p:e:{for(var b=u.key;null!==c;){if(c.key===b){if((b=u.type)===m){if(7===c.tag){n(l,c.sibling),(d=a(c,u.props.children)).return=l,l=d;break e}}else if(c.elementType===b||"object"==typeof b&&null!==b&&b.$$typeof===E&&ta(b)===c.type){n(l,c.sibling),la(d=a(c,u.props),u),d.return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}u.type===m?((d=Vi(u.props.children,l.mode,d,u.key)).return=l,l=d):(la(d=Bi(u.type,u.key,u.props,null,l.mode,d),u),d.return=l,l=d)}return o(l);case f:e:{for(b=u.key;null!==c;){if(c.key===b){if(4===c.tag&&c.stateNode.containerInfo===u.containerInfo&&c.stateNode.implementation===u.implementation){n(l,c.sibling),(d=a(c,u.children||[])).return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}(d=Wi(u,l.mode,d)).return=l,l=d}return o(l);case E:return y(l,c,u=ta(u),d)}if(L(u))return function(i,a,o,l){for(var c=null,u=null,d=a,p=a=0,f=null;null!==d&&p<o.length;p++){d.index>p?(f=d,d=null):f=d.sibling;var m=g(i,d,o[p],l);if(null===m){null===d&&(d=f);break}e&&d&&null===m.alternate&&t(i,d),a=s(m,a,p),null===u?c=m:u.sibling=m,u=m,d=f}if(p===o.length)return n(i,d),cr&&nr(i,p),c;if(null===d){for(;p<o.length;p++)null!==(d=h(i,o[p],l))&&(a=s(d,a,p),null===u?c=d:u.sibling=d,u=d);return cr&&nr(i,p),c}for(d=r(d);p<o.length;p++)null!==(f=v(d,i,p,o[p],l))&&(e&&null!==f.alternate&&d.delete(null===f.key?p:f.key),a=s(f,a,p),null===u?c=f:u.sibling=f,u=f);return e&&d.forEach(function(e){return t(i,e)}),cr&&nr(i,p),c}(l,c,u,d);if(R(u)){if("function"!=typeof(b=R(u)))throw Error(i(150));return function(a,o,l,c){if(null==l)throw Error(i(151));for(var u=null,d=null,p=o,f=o=0,m=null,y=l.next();null!==p&&!y.done;f++,y=l.next()){p.index>f?(m=p,p=null):m=p.sibling;var x=g(a,p,y.value,c);if(null===x){null===p&&(p=m);break}e&&p&&null===x.alternate&&t(a,p),o=s(x,o,f),null===d?u=x:d.sibling=x,d=x,p=m}if(y.done)return n(a,p),cr&&nr(a,f),u;if(null===p){for(;!y.done;f++,y=l.next())null!==(y=h(a,y.value,c))&&(o=s(y,o,f),null===d?u=y:d.sibling=y,d=y);return cr&&nr(a,f),u}for(p=r(p);!y.done;f++,y=l.next())null!==(y=v(p,a,f,y.value,c))&&(e&&null!==y.alternate&&p.delete(null===y.key?f:y.key),o=s(y,o,f),null===d?u=y:d.sibling=y,d=y);return e&&p.forEach(function(e){return t(a,e)}),cr&&nr(a,f),u}(l,c,u=b.call(u),d)}if("function"==typeof u.then)return y(l,c,oa(u),d);if(u.$$typeof===x)return y(l,c,Lr(l,u),d);ca(l,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(n(l,c.sibling),(d=a(c,u)).return=l,l=d):(n(l,c),(d=Hi(u,l.mode,d)).return=l,l=d),o(l)):n(l,c)}return function(e,t,n,i){try{sa=0;var r=y(e,t,n,i);return aa=null,r}catch(t){if(t===Yr||t===Qr)throw t;var a=Fi(29,t,null,e.mode);return a.lanes=i,a.return=e,a}}}var da=ua(!0),ha=ua(!1),pa=!1;function fa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ma(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ga(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function va(e,t,n){var i=e.updateQueue;if(null===i)return null;if(i=i.shared,2&dc){var r=i.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),i.pending=t,t=Di(e),Ii(e,null,n),t}return Pi(e,i,t,n),Di(e)}function ya(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,Ie(e,n)}}function xa(e,t){var n=e.updateQueue,i=e.alternate;if(null!==i&&n===(i=i.updateQueue)){var r=null,a=null;if(null!==(n=n.firstBaseUpdate)){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===a?r=a=s:a=a.next=s,n=n.next}while(null!==n);null===a?r=a=t:a=a.next=t}else r=a=t;return n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:i.shared,callbacks:i.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var ba=!1;function _a(){if(ba&&null!==Hr)throw Hr}function wa(e,t,n,i){ba=!1;var r=e.updateQueue;pa=!1;var a=r.firstBaseUpdate,s=r.lastBaseUpdate,o=r.shared.pending;if(null!==o){r.shared.pending=null;var l=o,c=l.next;l.next=null,null===s?a=c:s.next=c,s=l;var u=e.alternate;null!==u&&(o=(u=u.updateQueue).lastBaseUpdate)!==s&&(null===o?u.firstBaseUpdate=c:o.next=c,u.lastBaseUpdate=l)}if(null!==a){var h=r.baseState;for(s=0,u=c=l=null,o=a;;){var p=-536870913&o.lane,f=p!==o.lane;if(f?(fc&p)===p:(i&p)===p){0!==p&&p===Vr&&(ba=!0),null!==u&&(u=u.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var m=e,g=o;p=t;var v=n;switch(g.tag){case 1:if("function"==typeof(m=g.payload)){h=m.call(v,h,p);break e}h=m;break e;case 3:m.flags=-65537&m.flags|128;case 0:if(null==(p="function"==typeof(m=g.payload)?m.call(v,h,p):m))break e;h=d({},h,p);break e;case 2:pa=!0}}null!==(p=o.callback)&&(e.flags|=64,f&&(e.flags|=8192),null===(f=r.callbacks)?r.callbacks=[p]:f.push(p))}else f={lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===u?(c=u=f,l=h):u=u.next=f,s|=p;if(null===(o=o.next)){if(null===(o=r.shared.pending))break;o=(f=o).next,f.next=null,r.lastBaseUpdate=f,r.shared.pending=null}}null===u&&(l=h),r.baseState=l,r.firstBaseUpdate=c,r.lastBaseUpdate=u,null===a&&(r.shared.lanes=0),wc|=s,e.lanes=s,e.memoizedState=h}}function Sa(e,t){if("function"!=typeof e)throw Error(i(191,e));e.call(t)}function Ea(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)Sa(n[e],t)}var Ma=O(null),Ta=O(0);function Aa(e,t){z(Ta,e=bc),z(Ma,t),bc=e|t.baseLanes}function Ra(){z(Ta,bc),z(Ma,Ma.current)}function Pa(){bc=Ta.current,U(Ma),U(Ta)}var Ca=O(null),La=null;function Ia(e){var t=e.alternate;z(Oa,1&Oa.current),z(Ca,e),null===La&&(null===t||null!==Ma.current||null!==t.memoizedState)&&(La=e)}function Da(e){z(Oa,Oa.current),z(Ca,e),null===La&&(La=e)}function Na(e){22===e.tag?(z(Oa,Oa.current),z(Ca,e),null===La&&(La=e)):ka()}function ka(){z(Oa,Oa.current),z(Ca,Ca.current)}function Fa(e){U(Ca),La===e&&(La=null),U(Oa)}var Oa=O(0);function Ua(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Pd(n)||Cd(n)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var za=0,Ba=null,Va=null,Ha=null,Ga=!1,Wa=!1,ja=!1,Xa=0,qa=0,$a=null,Ya=0;function Ka(){throw Error(i(321))}function Qa(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Kn(e[n],t[n]))return!1;return!0}function Za(e,t,n,i,r,a){return za=a,Ba=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=null===e||null===e.memoizedState?fo:mo,ja=!1,a=n(i,r),ja=!1,Wa&&(a=es(t,n,i,r)),Ja(e),a}function Ja(e){I.H=po;var t=null!==Va&&null!==Va.next;if(za=0,Ha=Va=Ba=null,Ga=!1,qa=0,$a=null,t)throw Error(i(300));null===e||Lo||null!==(e=e.dependencies)&&Rr(e)&&(Lo=!0)}function es(e,t,n,r){Ba=e;var a=0;do{if(Wa&&($a=null),qa=0,Wa=!1,25<=a)throw Error(i(301));if(a+=1,Ha=Va=null,null!=e.updateQueue){var s=e.updateQueue;s.lastEffect=null,s.events=null,s.stores=null,null!=s.memoCache&&(s.memoCache.index=0)}I.H=go,s=t(n,r)}while(Wa);return s}function ts(){var e=I.H,t=e.useState()[0];return t="function"==typeof t.then?os(t):t,e=e.useState()[0],(null!==Va?Va.memoizedState:null)!==e&&(Ba.flags|=1024),t}function ns(){var e=0!==Xa;return Xa=0,e}function is(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function rs(e){if(Ga){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Ga=!1}za=0,Ha=Va=Ba=null,Wa=!1,qa=Xa=0,$a=null}function as(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Ha?Ba.memoizedState=Ha=e:Ha=Ha.next=e,Ha}function ss(){if(null===Va){var e=Ba.alternate;e=null!==e?e.memoizedState:null}else e=Va.next;var t=null===Ha?Ba.memoizedState:Ha.next;if(null!==t)Ha=t,Va=e;else{if(null===e){if(null===Ba.alternate)throw Error(i(467));throw Error(i(310))}e={memoizedState:(Va=e).memoizedState,baseState:Va.baseState,baseQueue:Va.baseQueue,queue:Va.queue,next:null},null===Ha?Ba.memoizedState=Ha=e:Ha=Ha.next=e}return Ha}function os(e){var t=qa;return qa+=1,null===$a&&($a=[]),e=ea($a,e,t),t=Ba,null===(null===Ha?t.memoizedState:Ha.next)&&(t=t.alternate,I.H=null===t||null===t.memoizedState?fo:mo),e}function ls(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return os(e);if(e.$$typeof===x)return Cr(e)}throw Error(i(438,String(e)))}function cs(e){var t=null,n=Ba.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var i=Ba.alternate;null!==i&&null!==(i=i.updateQueue)&&null!=(i=i.memoCache)&&(t={data:i.data.map(function(e){return e.slice()}),index:0})}if(null==t&&(t={data:[],index:0}),null===n&&(n={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),i=0;i<e;i++)n[i]=T;return t.index++,n}function us(e,t){return"function"==typeof t?t(e):t}function ds(e){return hs(ss(),Va,e)}function hs(e,t,n){var r=e.queue;if(null===r)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,s=r.pending;if(null!==s){if(null!==a){var o=a.next;a.next=s.next,s.next=o}t.baseQueue=a=s,r.pending=null}if(s=e.baseState,null===a)e.memoizedState=s;else{var l=o=null,c=null,u=t=a.next,d=!1;do{var h=-536870913&u.lane;if(h!==u.lane?(fc&h)===h:(za&h)===h){var p=u.revertLane;if(0===p)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),h===Vr&&(d=!0);else{if((za&p)===p){u=u.next,p===Vr&&(d=!0);continue}h={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=h,o=s):c=c.next=h,Ba.lanes|=p,wc|=p}h=u.action,ja&&n(s,h),s=u.hasEagerState?u.eagerState:n(s,h)}else p={lane:h,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=p,o=s):c=c.next=p,Ba.lanes|=h,wc|=h;u=u.next}while(null!==u&&u!==t);if(null===c?o=s:c.next=l,!Kn(s,e.memoizedState)&&(Lo=!0,d&&null!==(n=Hr)))throw n;e.memoizedState=s,e.baseState=o,e.baseQueue=c,r.lastRenderedState=s}return null===a&&(r.lanes=0),[e.memoizedState,r.dispatch]}function ps(e){var t=ss(),n=t.queue;if(null===n)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,s=t.memoizedState;if(null!==a){n.pending=null;var o=a=a.next;do{s=e(s,o.action),o=o.next}while(o!==a);Kn(s,t.memoizedState)||(Lo=!0),t.memoizedState=s,null===t.baseQueue&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function fs(e,t,n){var r=Ba,a=ss(),s=cr;if(s){if(void 0===n)throw Error(i(407));n=n()}else n=t();var o=!Kn((Va||a).memoizedState,n);if(o&&(a.memoizedState=n,Lo=!0),a=a.queue,zs(vs.bind(null,r,a,e),[e]),a.getSnapshot!==t||o||null!==Ha&&1&Ha.memoizedState.tag){if(r.flags|=2048,Ns(9,{destroy:void 0},gs.bind(null,r,a,n,t),null),null===hc)throw Error(i(349));s||127&za||ms(r,t,n)}return n}function ms(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Ba.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function gs(e,t,n,i){t.value=n,t.getSnapshot=i,ys(t)&&xs(e)}function vs(e,t,n){return n(function(){ys(t)&&xs(e)})}function ys(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Kn(e,n)}catch(e){return!0}}function xs(e){var t=Li(e,2);null!==t&&Xc(t,e,2)}function bs(e){var t=as();if("function"==typeof e){var n=e;if(e=n(),ja){ve(!0);try{n()}finally{ve(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:e},t}function _s(e,t,n,i){return e.baseState=n,hs(e,Va,"function"==typeof i?i:us)}function ws(e,t,n,r,a){if(co(e))throw Error(i(485));if(null!==(e=t.action)){var s={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){s.listeners.push(e)}};null!==I.T?n(!0):s.isTransition=!1,r(s),null===(n=t.pending)?(s.next=t.pending=s,Ss(t,s)):(s.next=n.next,t.pending=n.next=s)}}function Ss(e,t){var n=t.action,i=t.payload,r=e.state;if(t.isTransition){var a=I.T,s={};I.T=s;try{var o=n(r,i),l=I.S;null!==l&&l(s,o),Es(e,t,o)}catch(n){Ts(e,t,n)}finally{null!==a&&null!==s.types&&(a.types=s.types),I.T=a}}else try{Es(e,t,a=n(r,i))}catch(n){Ts(e,t,n)}}function Es(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){Ms(e,t,n)},function(n){return Ts(e,t,n)}):Ms(e,t,n)}function Ms(e,t,n){t.status="fulfilled",t.value=n,As(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,Ss(e,n)))}function Ts(e,t,n){var i=e.pending;if(e.pending=null,null!==i){i=i.next;do{t.status="rejected",t.reason=n,As(t),t=t.next}while(t!==i)}e.action=null}function As(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Rs(e,t){return t}function Ps(e,t){if(cr){var n=hc.formState;if(null!==n){e:{var i=Ba;if(cr){if(lr){t:{for(var r=lr,a=dr;8!==r.nodeType;){if(!a){r=null;break t}if(null===(r=Ld(r.nextSibling))){r=null;break t}}r="F!"===(a=r.data)||"F"===a?r:null}if(r){lr=Ld(r.nextSibling),i="F!"===r.data;break e}}pr(i)}i=!1}i&&(t=n[0])}}return(n=as()).memoizedState=n.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rs,lastRenderedState:t},n.queue=i,n=so.bind(null,Ba,i),i.dispatch=n,i=bs(!1),a=lo.bind(null,Ba,!1,i.queue),r={state:t,dispatch:null,action:e,pending:null},(i=as()).queue=r,n=ws.bind(null,Ba,r,a,n),r.dispatch=n,i.memoizedState=e,[t,n,!1]}function Cs(e){return Ls(ss(),Va,e)}function Ls(e,t,n){if(t=hs(e,t,Rs)[0],e=ds(us)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var i=os(t)}catch(e){if(e===Yr)throw Qr;throw e}else i=t;var r=(t=ss()).queue,a=r.dispatch;return n!==t.memoizedState&&(Ba.flags|=2048,Ns(9,{destroy:void 0},Is.bind(null,r,n),null)),[i,a,e]}function Is(e,t){e.action=t}function Ds(e){var t=ss(),n=Va;if(null!==n)return Ls(t,n,e);ss(),t=t.memoizedState;var i=(n=ss()).queue.dispatch;return n.memoizedState=e,[t,i,!1]}function Ns(e,t,n,i){return e={tag:e,create:n,deps:i,inst:t,next:null},null===(t=Ba.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(i=n.next,n.next=e,e.next=i,t.lastEffect=e),e}function ks(){return ss().memoizedState}function Fs(e,t,n,i){var r=as();Ba.flags|=e,r.memoizedState=Ns(1|t,{destroy:void 0},n,void 0===i?null:i)}function Os(e,t,n,i){var r=ss();i=void 0===i?null:i;var a=r.memoizedState.inst;null!==Va&&null!==i&&Qa(i,Va.memoizedState.deps)?r.memoizedState=Ns(t,a,n,i):(Ba.flags|=e,r.memoizedState=Ns(1|t,a,n,i))}function Us(e,t){Fs(8390656,8,e,t)}function zs(e,t){Os(2048,8,e,t)}function Bs(e){var t=ss().memoizedState;return function(e){Ba.flags|=4;var t=Ba.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Ba.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if(2&dc)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Vs(e,t){return Os(4,2,e,t)}function Hs(e,t){return Os(4,4,e,t)}function Gs(e,t){if("function"==typeof t){e=e();var n=t(e);return function(){"function"==typeof n?n():t(null)}}if(null!=t)return e=e(),t.current=e,function(){t.current=null}}function Ws(e,t,n){n=null!=n?n.concat([e]):null,Os(4,4,Gs.bind(null,t,e),n)}function js(){}function Xs(e,t){var n=ss();t=void 0===t?null:t;var i=n.memoizedState;return null!==t&&Qa(t,i[1])?i[0]:(n.memoizedState=[e,t],e)}function qs(e,t){var n=ss();t=void 0===t?null:t;var i=n.memoizedState;if(null!==t&&Qa(t,i[1]))return i[0];if(i=e(),ja){ve(!0);try{e()}finally{ve(!1)}}return n.memoizedState=[i,t],i}function $s(e,t,n){return void 0===n||1073741824&za&&!(261930&fc)?e.memoizedState=t:(e.memoizedState=n,e=jc(),Ba.lanes|=e,wc|=e,n)}function Ys(e,t,n,i){return Kn(n,t)?n:null!==Ma.current?(e=$s(e,n,i),Kn(e,t)||(Lo=!0),e):42&za&&(!(1073741824&za)||261930&fc)?(e=jc(),Ba.lanes|=e,wc|=e,t):(Lo=!0,e.memoizedState=n)}function Ks(e,t,n,i,r){var a=D.p;D.p=0!==a&&8>a?a:8;var s,o,l,c=I.T,u={};I.T=u,lo(e,!1,t,n);try{var d=r(),h=I.S;if(null!==h&&h(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then){var p=(s=i,o=[],l={status:"pending",value:null,reason:null,then:function(e){o.push(e)}},d.then(function(){l.status="fulfilled",l.value=s;for(var e=0;e<o.length;e++)(0,o[e])(s)},function(e){for(l.status="rejected",l.reason=e,e=0;e<o.length;e++)(0,o[e])(void 0)}),l);oo(e,t,p,Wc())}else oo(e,t,i,Wc())}catch(n){oo(e,t,{then:function(){},status:"rejected",reason:n},Wc())}finally{D.p=a,null!==c&&null!==u.types&&(c.types=u.types),I.T=c}}function Qs(){}function Zs(e,t,n,r){if(5!==e.tag)throw Error(i(476));var a=Js(e).queue;Ks(e,a,t,N,null===n?Qs:function(){return eo(e),n(r)})}function Js(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:N,baseState:N,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:N},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function eo(e){var t=Js(e);null===t.next&&(t=e.alternate.memoizedState),oo(e,t.next.queue,{},Wc())}function to(){return Cr(lh)}function no(){return ss().memoizedState}function io(){return ss().memoizedState}function ro(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Wc(),i=va(t,e=ga(n),n);return null!==i&&(Xc(i,t,n),ya(i,t,n)),t={cache:Or()},void(e.payload=t)}t=t.return}}function ao(e,t,n){var i=Wc();n={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},co(e)?uo(t,n):null!==(n=Ci(e,t,n,i))&&(Xc(n,e,i),ho(n,t,i))}function so(e,t,n){oo(e,t,n,Wc())}function oo(e,t,n,i){var r={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(co(e))uo(t,r);else{var a=e.alternate;if(0===e.lanes&&(null===a||0===a.lanes)&&null!==(a=t.lastRenderedReducer))try{var s=t.lastRenderedState,o=a(s,n);if(r.hasEagerState=!0,r.eagerState=o,Kn(o,s))return Pi(e,t,r,0),null===hc&&Ri(),!1}catch(e){}if(null!==(n=Ci(e,t,r,i)))return Xc(n,e,i),ho(n,t,i),!0}return!1}function lo(e,t,n,r){if(r={lane:2,revertLane:Bu(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},co(e)){if(t)throw Error(i(479))}else null!==(t=Ci(e,n,r,2))&&Xc(t,e,2)}function co(e){var t=e.alternate;return e===Ba||null!==t&&t===Ba}function uo(e,t){Wa=Ga=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ho(e,t,n){if(4194048&n){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,Ie(e,n)}}var po={readContext:Cr,use:ls,useCallback:Ka,useContext:Ka,useEffect:Ka,useImperativeHandle:Ka,useLayoutEffect:Ka,useInsertionEffect:Ka,useMemo:Ka,useReducer:Ka,useRef:Ka,useState:Ka,useDebugValue:Ka,useDeferredValue:Ka,useTransition:Ka,useSyncExternalStore:Ka,useId:Ka,useHostTransitionStatus:Ka,useFormState:Ka,useActionState:Ka,useOptimistic:Ka,useMemoCache:Ka,useCacheRefresh:Ka};po.useEffectEvent=Ka;var fo={readContext:Cr,use:ls,useCallback:function(e,t){return as().memoizedState=[e,void 0===t?null:t],e},useContext:Cr,useEffect:Us,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,Fs(4194308,4,Gs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fs(4194308,4,e,t)},useInsertionEffect:function(e,t){Fs(4,2,e,t)},useMemo:function(e,t){var n=as();t=void 0===t?null:t;var i=e();if(ja){ve(!0);try{e()}finally{ve(!1)}}return n.memoizedState=[i,t],i},useReducer:function(e,t,n){var i=as();if(void 0!==n){var r=n(t);if(ja){ve(!0);try{n(t)}finally{ve(!1)}}}else r=t;return i.memoizedState=i.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},i.queue=e,e=e.dispatch=ao.bind(null,Ba,e),[i.memoizedState,e]},useRef:function(e){return e={current:e},as().memoizedState=e},useState:function(e){var t=(e=bs(e)).queue,n=so.bind(null,Ba,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:js,useDeferredValue:function(e,t){return $s(as(),e,t)},useTransition:function(){var e=bs(!1);return e=Ks.bind(null,Ba,e.queue,!0,!1),as().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ba,a=as();if(cr){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===hc)throw Error(i(349));127&fc||ms(r,t,n)}a.memoizedState=n;var s={value:n,getSnapshot:t};return a.queue=s,Us(vs.bind(null,r,s,e),[e]),r.flags|=2048,Ns(9,{destroy:void 0},gs.bind(null,r,s,n,t),null),n},useId:function(){var e=as(),t=hc.identifierPrefix;if(cr){var n=tr;t="_"+t+"R_"+(n=(er&~(1<<32-ye(er)-1)).toString(32)+n),0<(n=Xa++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=Ya++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:to,useFormState:Ps,useActionState:Ps,useOptimistic:function(e){var t=as();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=lo.bind(null,Ba,!0,n),n.dispatch=t,[e,t]},useMemoCache:cs,useCacheRefresh:function(){return as().memoizedState=ro.bind(null,Ba)},useEffectEvent:function(e){var t=as(),n={impl:e};return t.memoizedState=n,function(){if(2&dc)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},mo={readContext:Cr,use:ls,useCallback:Xs,useContext:Cr,useEffect:zs,useImperativeHandle:Ws,useInsertionEffect:Vs,useLayoutEffect:Hs,useMemo:qs,useReducer:ds,useRef:ks,useState:function(){return ds(us)},useDebugValue:js,useDeferredValue:function(e,t){return Ys(ss(),Va.memoizedState,e,t)},useTransition:function(){var e=ds(us)[0],t=ss().memoizedState;return["boolean"==typeof e?e:os(e),t]},useSyncExternalStore:fs,useId:no,useHostTransitionStatus:to,useFormState:Cs,useActionState:Cs,useOptimistic:function(e,t){return _s(ss(),0,e,t)},useMemoCache:cs,useCacheRefresh:io};mo.useEffectEvent=Bs;var go={readContext:Cr,use:ls,useCallback:Xs,useContext:Cr,useEffect:zs,useImperativeHandle:Ws,useInsertionEffect:Vs,useLayoutEffect:Hs,useMemo:qs,useReducer:ps,useRef:ks,useState:function(){return ps(us)},useDebugValue:js,useDeferredValue:function(e,t){var n=ss();return null===Va?$s(n,e,t):Ys(n,Va.memoizedState,e,t)},useTransition:function(){var e=ps(us)[0],t=ss().memoizedState;return["boolean"==typeof e?e:os(e),t]},useSyncExternalStore:fs,useId:no,useHostTransitionStatus:to,useFormState:Ds,useActionState:Ds,useOptimistic:function(e,t){var n=ss();return null!==Va?_s(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:cs,useCacheRefresh:io};function vo(e,t,n,i){n=null==(n=n(i,t=e.memoizedState))?t:d({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}go.useEffectEvent=Bs;var yo={enqueueSetState:function(e,t,n){e=e._reactInternals;var i=Wc(),r=ga(i);r.payload=t,null!=n&&(r.callback=n),null!==(t=va(e,r,i))&&(Xc(t,e,i),ya(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var i=Wc(),r=ga(i);r.tag=1,r.payload=t,null!=n&&(r.callback=n),null!==(t=va(e,r,i))&&(Xc(t,e,i),ya(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Wc(),i=ga(n);i.tag=2,null!=t&&(i.callback=t),null!==(t=va(e,i,n))&&(Xc(t,e,n),ya(t,e,n))}};function xo(e,t,n,i,r,a,s){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(i,a,s):!(t.prototype&&t.prototype.isPureReactComponent&&Qn(n,i)&&Qn(r,a))}function bo(e,t,n,i){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,i),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,i),t.state!==e&&yo.enqueueReplaceState(t,t.state,null)}function _o(e,t){var n=t;if("ref"in t)for(var i in n={},t)"ref"!==i&&(n[i]=t[i]);if(e=e.defaultProps)for(var r in n===t&&(n=d({},n)),e)void 0===n[r]&&(n[r]=e[r]);return n}function wo(e){Ei(e)}function So(e){console.error(e)}function Eo(e){Ei(e)}function Mo(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function To(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ao(e,t,n){return(n=ga(n)).tag=3,n.payload={element:null},n.callback=function(){Mo(e,t)},n}function Ro(e){return(e=ga(e)).tag=3,e}function Po(e,t,n,i){var r=n.type.getDerivedStateFromError;if("function"==typeof r){var a=i.value;e.payload=function(){return r(a)},e.callback=function(){To(t,n,i)}}var s=n.stateNode;null!==s&&"function"==typeof s.componentDidCatch&&(e.callback=function(){To(t,n,i),"function"!=typeof r&&(null===Nc?Nc=new Set([this]):Nc.add(this));var e=i.stack;this.componentDidCatch(i.value,{componentStack:null!==e?e:""})})}var Co=Error(i(461)),Lo=!1;function Io(e,t,n,i){t.child=null===e?ha(t,null,n,i):da(t,e.child,n,i)}function Do(e,t,n,i,r){n=n.render;var a=t.ref;if("ref"in i){var s={};for(var o in i)"ref"!==o&&(s[o]=i[o])}else s=i;return Pr(t),i=Za(e,t,n,s,a,r),o=ns(),null===e||Lo?(cr&&o&&rr(t),t.flags|=1,Io(e,t,i,r),t.child):(is(e,t,r),nl(e,t,r))}function No(e,t,n,i,r){if(null===e){var a=n.type;return"function"!=typeof a||Oi(a)||void 0!==a.defaultProps||null!==n.compare?((e=Bi(n.type,null,i,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,ko(e,t,a,i,r))}if(a=e.child,!il(e,r)){var s=a.memoizedProps;if((n=null!==(n=n.compare)?n:Qn)(s,i)&&e.ref===t.ref)return nl(e,t,r)}return t.flags|=1,(e=Ui(a,i)).ref=t.ref,e.return=t,t.child=e}function ko(e,t,n,i,r){if(null!==e){var a=e.memoizedProps;if(Qn(a,i)&&e.ref===t.ref){if(Lo=!1,t.pendingProps=i=a,!il(e,r))return t.lanes=e.lanes,nl(e,t,r);131072&e.flags&&(Lo=!0)}}return Ho(e,t,n,i,r)}function Fo(e,t,n,i){var r=i.children,a=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===i.mode){if(128&t.flags){if(a=null!==a?a.baseLanes|n:n,null!==e){for(i=t.child=e.child,r=0;null!==i;)r=r|i.lanes|i.childLanes,i=i.sibling;i=r&~a}else i=0,t.child=null;return Uo(e,t,a,n,i)}if(!(536870912&n))return i=t.lanes=536870912,Uo(e,t,null!==a?a.baseLanes|n:n,n,i);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&qr(0,null!==a?a.cachePool:null),null!==a?Aa(t,a):Ra(),Na(t)}else null!==a?(qr(0,a.cachePool),Aa(t,a),ka(),t.memoizedState=null):(null!==e&&qr(0,null),Ra(),ka());return Io(e,t,r,n),t.child}function Oo(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Uo(e,t,n,i,r){var a=Xr();return a=null===a?null:{parent:Fr._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},null!==e&&qr(0,null),Ra(),Na(t),null!==e&&Ar(e,t,i,!0),t.childLanes=r,null}function zo(e,t){return(t=Qo({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Bo(e,t,n){return da(t,e.child,null,n),(e=zo(t,t.pendingProps)).flags|=2,Fa(t),t.memoizedState=null,e}function Vo(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(i(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Ho(e,t,n,i,r){return Pr(t),n=Za(e,t,n,i,void 0,r),i=ns(),null===e||Lo?(cr&&i&&rr(t),t.flags|=1,Io(e,t,n,r),t.child):(is(e,t,r),nl(e,t,r))}function Go(e,t,n,i,r,a){return Pr(t),t.updateQueue=null,n=es(t,i,n,r),Ja(e),i=ns(),null===e||Lo?(cr&&i&&rr(t),t.flags|=1,Io(e,t,n,a),t.child):(is(e,t,a),nl(e,t,a))}function Wo(e,t,n,i,r){if(Pr(t),null===t.stateNode){var a=Ni,s=n.contextType;"object"==typeof s&&null!==s&&(a=Cr(s)),a=new n(i,a),t.memoizedState=null!==a.state&&void 0!==a.state?a.state:null,a.updater=yo,t.stateNode=a,a._reactInternals=t,(a=t.stateNode).props=i,a.state=t.memoizedState,a.refs={},fa(t),s=n.contextType,a.context="object"==typeof s&&null!==s?Cr(s):Ni,a.state=t.memoizedState,"function"==typeof(s=n.getDerivedStateFromProps)&&(vo(t,n,s,i),a.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof a.getSnapshotBeforeUpdate||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||(s=a.state,"function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount(),s!==a.state&&yo.enqueueReplaceState(a,a.state,null),wa(t,i,a,r),_a(),a.state=t.memoizedState),"function"==typeof a.componentDidMount&&(t.flags|=4194308),i=!0}else if(null===e){a=t.stateNode;var o=t.memoizedProps,l=_o(n,o);a.props=l;var c=a.context,u=n.contextType;s=Ni,"object"==typeof u&&null!==u&&(s=Cr(u));var d=n.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof a.getSnapshotBeforeUpdate,o=t.pendingProps!==o,u||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(o||c!==s)&&bo(t,a,i,s),pa=!1;var h=t.memoizedState;a.state=h,wa(t,i,a,r),_a(),c=t.memoizedState,o||h!==c||pa?("function"==typeof d&&(vo(t,n,d,i),c=t.memoizedState),(l=pa||xo(t,n,l,i,h,c,s))?(u||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(t.flags|=4194308)):("function"==typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=c),a.props=i,a.state=c,a.context=s,i=l):("function"==typeof a.componentDidMount&&(t.flags|=4194308),i=!1)}else{a=t.stateNode,ma(e,t),u=_o(n,s=t.memoizedProps),a.props=u,d=t.pendingProps,h=a.context,c=n.contextType,l=Ni,"object"==typeof c&&null!==c&&(l=Cr(c)),(c="function"==typeof(o=n.getDerivedStateFromProps)||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(s!==d||h!==l)&&bo(t,a,i,l),pa=!1,h=t.memoizedState,a.state=h,wa(t,i,a,r),_a();var p=t.memoizedState;s!==d||h!==p||pa||null!==e&&null!==e.dependencies&&Rr(e.dependencies)?("function"==typeof o&&(vo(t,n,o,i),p=t.memoizedState),(u=pa||xo(t,n,u,i,h,p,l)||null!==e&&null!==e.dependencies&&Rr(e.dependencies))?(c||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(i,p,l),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(i,p,l)),"function"==typeof a.componentDidUpdate&&(t.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=p),a.props=i,a.state=p,a.context=l,i=u):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),i=!1)}return a=i,Vo(e,t),i=!!(128&t.flags),a||i?(a=t.stateNode,n=i&&"function"!=typeof n.getDerivedStateFromError?null:a.render(),t.flags|=1,null!==e&&i?(t.child=da(t,e.child,null,r),t.child=da(t,null,n,r)):Io(e,t,n,r),t.memoizedState=a.state,e=t.child):e=nl(e,t,r),e}function jo(e,t,n,i){return vr(),t.flags|=256,Io(e,t,n,i),t.child}var Xo={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qo(e){return{baseLanes:e,cachePool:$r()}}function $o(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=Mc),e}function Yo(e,t,n){var r,a=t.pendingProps,s=!1,o=!!(128&t.flags);if((r=o)||(r=(null===e||null!==e.memoizedState)&&!!(2&Oa.current)),r&&(s=!0,t.flags&=-129),r=!!(32&t.flags),t.flags&=-33,null===e){if(cr){if(s?Ia(t):ka(),(e=lr)?null!==(e=null!==(e=Rd(e,dr))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==Ji?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},(n=Gi(e)).return=t,t.child=n,or=t,lr=null):e=null,null===e)throw pr(t);return Cd(e)?t.lanes=32:t.lanes=536870912,null}var l=a.children;return a=a.fallback,s?(ka(),l=Qo({mode:"hidden",children:l},s=t.mode),a=Vi(a,s,n,null),l.return=t,a.return=t,l.sibling=a,t.child=l,(a=t.child).memoizedState=qo(n),a.childLanes=$o(e,r,n),t.memoizedState=Xo,Oo(null,a)):(Ia(t),Ko(t,l))}var c=e.memoizedState;if(null!==c&&null!==(l=c.dehydrated)){if(o)256&t.flags?(Ia(t),t.flags&=-257,t=Zo(e,t,n)):null!==t.memoizedState?(ka(),t.child=e.child,t.flags|=128,t=null):(ka(),l=a.fallback,s=t.mode,a=Qo({mode:"visible",children:a.children},s),(l=Vi(l,s,n,null)).flags|=2,a.return=t,l.return=t,a.sibling=l,t.child=a,da(t,e.child,null,n),(a=t.child).memoizedState=qo(n),a.childLanes=$o(e,r,n),t.memoizedState=Xo,t=Oo(null,a));else if(Ia(t),Cd(l)){if(r=l.nextSibling&&l.nextSibling.dataset)var u=r.dgst;r=u,(a=Error(i(419))).stack="",a.digest=r,xr({value:a,source:null,stack:null}),t=Zo(e,t,n)}else if(Lo||Ar(e,t,n,!1),r=0!==(n&e.childLanes),Lo||r){if(null!==(r=hc)&&0!==(a=De(r,n))&&a!==c.retryLane)throw c.retryLane=a,Li(e,a),Xc(r,e,a),Co;Pd(l)||ru(),t=Zo(e,t,n)}else Pd(l)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,lr=Ld(l.nextSibling),or=t,cr=!0,ur=null,dr=!1,null!==e&&sr(t,e),(t=Ko(t,a.children)).flags|=4096);return t}return s?(ka(),l=a.fallback,s=t.mode,u=(c=e.child).sibling,(a=Ui(c,{mode:"hidden",children:a.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?l=Ui(u,l):(l=Vi(l,s,n,null)).flags|=2,l.return=t,a.return=t,a.sibling=l,t.child=a,Oo(null,a),a=t.child,null===(l=e.child.memoizedState)?l=qo(n):(null!==(s=l.cachePool)?(c=Fr._currentValue,s=s.parent!==c?{parent:c,pool:c}:s):s=$r(),l={baseLanes:l.baseLanes|n,cachePool:s}),a.memoizedState=l,a.childLanes=$o(e,r,n),t.memoizedState=Xo,Oo(e.child,a)):(Ia(t),e=(n=e.child).sibling,(n=Ui(n,{mode:"visible",children:a.children})).return=t,n.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n)}function Ko(e,t){return(t=Qo({mode:"visible",children:t},e.mode)).return=e,e.child=t}function Qo(e,t){return(e=Fi(22,e,null,t)).lanes=0,e}function Zo(e,t,n){return da(t,e.child,null,n),(e=Ko(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Jo(e,t,n){e.lanes|=t;var i=e.alternate;null!==i&&(i.lanes|=t),Mr(e.return,t,n)}function el(e,t,n,i,r,a){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:r,treeForkCount:a}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=n,s.tailMode=r,s.treeForkCount=a)}function tl(e,t,n){var i=t.pendingProps,r=i.revealOrder,a=i.tail;i=i.children;var s=Oa.current,o=!!(2&s);if(o?(s=1&s|2,t.flags|=128):s&=1,z(Oa,s),Io(e,t,i,n),i=cr?Ki:0,!o&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Jo(e,n,t);else if(19===e.tag)Jo(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===Ua(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),el(t,!1,r,n,a,i);break;case"backwards":case"unstable_legacy-backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===Ua(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}el(t,!0,n,null,a,i);break;case"together":el(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function nl(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),wc|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Ar(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(i(153));if(null!==t.child){for(n=Ui(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Ui(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function il(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Rr(e))}function rl(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Lo=!0;else{if(!(il(e,n)||128&t.flags))return Lo=!1,function(e,t,n){switch(t.tag){case 3:X(t,t.stateNode.containerInfo),Sr(0,Fr,e.memoizedState.cache),vr();break;case 27:case 5:$(t);break;case 4:X(t,t.stateNode.containerInfo);break;case 10:Sr(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Da(t),null;break;case 13:var i=t.memoizedState;if(null!==i)return null!==i.dehydrated?(Ia(t),t.flags|=128,null):0!==(n&t.child.childLanes)?Yo(e,t,n):(Ia(t),null!==(e=nl(e,t,n))?e.sibling:null);Ia(t);break;case 19:var r=!!(128&e.flags);if((i=0!==(n&t.childLanes))||(Ar(e,t,n,!1),i=0!==(n&t.childLanes)),r){if(i)return tl(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),z(Oa,Oa.current),i)break;return null;case 22:return t.lanes=0,Fo(e,t,n,t.pendingProps);case 24:Sr(0,Fr,e.memoizedState.cache)}return nl(e,t,n)}(e,t,n);Lo=!!(131072&e.flags)}else Lo=!1,cr&&1048576&t.flags&&ir(t,Ki,t.index);switch(t.lanes=0,t.tag){case 16:e:{var r=t.pendingProps;if(e=ta(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var a=e.$$typeof;if(a===b){t.tag=11,t=Do(null,t,e,r,n);break e}if(a===S){t.tag=14,t=No(null,t,e,r,n);break e}}throw t=C(e)||e,Error(i(306,t,""))}Oi(e)?(r=_o(e,r),t.tag=1,t=Wo(null,t,e,r,n)):(t.tag=0,t=Ho(null,t,e,r,n))}return t;case 0:return Ho(e,t,t.type,t.pendingProps,n);case 1:return Wo(e,t,r=t.type,a=_o(r,t.pendingProps),n);case 3:e:{if(X(t,t.stateNode.containerInfo),null===e)throw Error(i(387));r=t.pendingProps;var s=t.memoizedState;a=s.element,ma(e,t),wa(t,r,null,n);var o=t.memoizedState;if(r=o.cache,Sr(0,Fr,r),r!==s.cache&&Tr(t,[Fr],n,!0),_a(),r=o.element,s.isDehydrated){if(s={element:r,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=s,t.memoizedState=s,256&t.flags){t=jo(e,t,r,n);break e}if(r!==a){xr(a=Xi(Error(i(424)),t)),t=jo(e,t,r,n);break e}for(e=9===(e=t.stateNode.containerInfo).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,lr=Ld(e.firstChild),or=t,cr=!0,ur=null,dr=!0,n=ha(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(vr(),r===a){t=nl(e,t,n);break e}Io(e,t,r,n)}t=t.child}return t;case 26:return Vo(e,t),null===e?(n=Gd(t.type,null,t.pendingProps,null))?t.memoizedState=n:cr||(n=t.type,e=t.pendingProps,(r=fd(W.current).createElement(n))[ze]=t,r[Be]=e,ud(r,n,e),Ze(r),t.stateNode=r):t.memoizedState=Gd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return $(t),null===e&&cr&&(r=t.stateNode=kd(t.type,t.pendingProps,W.current),or=t,dr=!0,a=lr,Ed(t.type)?(Id=a,lr=Ld(r.firstChild)):lr=a),Io(e,t,t.pendingProps.children,n),Vo(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&cr&&((a=r=lr)&&(null!==(r=function(e,t,n,i){for(;1===e.nodeType;){var r=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(i){if(!e[Xe])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(a=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(a!==r.rel||e.getAttribute("href")!==(null==r.href||""===r.href?null:r.href)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin)||e.getAttribute("title")!==(null==r.title?null:r.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((a=e.getAttribute("src"))!==(null==r.src?null:r.src)||e.getAttribute("type")!==(null==r.type?null:r.type)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin))&&a&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var a=null==r.name?null:""+r.name;if("hidden"===r.type&&e.getAttribute("name")===a)return e}if(null===(e=Ld(e.nextSibling)))break}return null}(r,t.type,t.pendingProps,dr))?(t.stateNode=r,or=t,lr=Ld(r.firstChild),dr=!1,a=!0):a=!1),a||pr(t)),$(t),a=t.type,s=t.pendingProps,o=null!==e?e.memoizedProps:null,r=s.children,vd(a,s)?r=null:null!==o&&vd(a,o)&&(t.flags|=32),null!==t.memoizedState&&(a=Za(e,t,ts,null,null,n),lh._currentValue=a),Vo(e,t),Io(e,t,r,n),t.child;case 6:return null===e&&cr&&((e=n=lr)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=Ld(e.nextSibling)))return null}return e}(n,t.pendingProps,dr))?(t.stateNode=n,or=t,lr=null,e=!0):e=!1),e||pr(t)),null;case 13:return Yo(e,t,n);case 4:return X(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=da(t,null,r,n):Io(e,t,r,n),t.child;case 11:return Do(e,t,t.type,t.pendingProps,n);case 7:return Io(e,t,t.pendingProps,n),t.child;case 8:case 12:return Io(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Sr(0,t.type,r.value),Io(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Pr(t),r=r(a=Cr(a)),t.flags|=1,Io(e,t,r,n),t.child;case 14:return No(e,t,t.type,t.pendingProps,n);case 15:return ko(e,t,t.type,t.pendingProps,n);case 19:return tl(e,t,n);case 31:return function(e,t,n){var r=t.pendingProps,a=!!(128&t.flags);if(t.flags&=-129,null===e){if(cr){if("hidden"===r.mode)return e=zo(t,r),t.lanes=536870912,Oo(null,e);if(Da(t),(e=lr)?null!==(e=null!==(e=Rd(e,dr))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==Ji?{id:er,overflow:tr}:null,retryLane:536870912,hydrationErrors:null},(n=Gi(e)).return=t,t.child=n,or=t,lr=null):e=null,null===e)throw pr(t);return t.lanes=536870912,null}return zo(t,r)}var s=e.memoizedState;if(null!==s){var o=s.dehydrated;if(Da(t),a)if(256&t.flags)t.flags&=-257,t=Bo(e,t,n);else{if(null===t.memoizedState)throw Error(i(558));t.child=e.child,t.flags|=128,t=null}else if(Lo||Ar(e,t,n,!1),a=0!==(n&e.childLanes),Lo||a){if(null!==(r=hc)&&0!==(o=De(r,n))&&o!==s.retryLane)throw s.retryLane=o,Li(e,o),Xc(r,e,o),Co;ru(),t=Bo(e,t,n)}else e=s.treeContext,lr=Ld(o.nextSibling),or=t,cr=!0,ur=null,dr=!1,null!==e&&sr(t,e),(t=zo(t,r)).flags|=4096;return t}return(e=Ui(e.child,{mode:r.mode,children:r.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,n);case 22:return Fo(e,t,n,t.pendingProps);case 24:return Pr(t),r=Cr(Fr),null===e?(null===(a=Xr())&&(a=hc,s=Or(),a.pooledCache=s,s.refCount++,null!==s&&(a.pooledCacheLanes|=n),a=s),t.memoizedState={parent:r,cache:a},fa(t),Sr(0,Fr,a)):(0!==(e.lanes&n)&&(ma(e,t),wa(t,null,null,n),_a()),a=e.memoizedState,s=t.memoizedState,a.parent!==r?(a={parent:r,cache:r},t.memoizedState=a,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=a),Sr(0,Fr,r)):(r=s.cache,Sr(0,Fr,r),r!==a.cache&&Tr(t,[Fr],n,!0))),Io(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function al(e){e.flags|=4}function sl(e,t,n,i,r){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&r)===r)if(e.stateNode.complete)e.flags|=8192;else{if(!tu())throw na=Zr,Kr;e.flags|=8192}}else e.flags&=-16777217}function ol(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!nh(t)){if(!tu())throw na=Zr,Kr;e.flags|=8192}}function ll(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Re():536870912,e.lanes|=t,Tc|=t)}function cl(e,t){if(!cr)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var i=null;null!==n;)null!==n.alternate&&(i=n),n=n.sibling;null===i?t||null===e.tail?e.tail=null:e.tail.sibling=null:i.sibling=null}}function ul(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,i=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=65011712&r.subtreeFlags,i|=65011712&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=i,e.childLanes=n,t}function dl(e,t,n){var r=t.pendingProps;switch(ar(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return ul(t),null;case 3:return n=t.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Er(Fr),q(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(gr(t)?al(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,yr())),ul(t),null;case 26:var a=t.type,s=t.memoizedState;return null===e?(al(t),null!==s?(ul(t),ol(t,s)):(ul(t),sl(t,a,0,0,n))):s?s!==e.memoizedState?(al(t),ul(t),ol(t,s)):(ul(t),t.flags&=-16777217):((e=e.memoizedProps)!==r&&al(t),ul(t),sl(t,a,0,0,n)),null;case 27:if(Y(t),n=W.current,a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&al(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return ul(t),null}e=H.current,gr(t)?fr(t):(e=kd(a,r,n),t.stateNode=e,al(t))}return ul(t),null;case 5:if(Y(t),a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&al(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return ul(t),null}if(s=H.current,gr(t))fr(t);else{var o=fd(W.current);switch(s){case 1:s=o.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:s=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":s=o.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":s=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":(s=o.createElement("div")).innerHTML="<script><\/script>",s=s.removeChild(s.firstChild);break;case"select":s="string"==typeof r.is?o.createElement("select",{is:r.is}):o.createElement("select"),r.multiple?s.multiple=!0:r.size&&(s.size=r.size);break;default:s="string"==typeof r.is?o.createElement(a,{is:r.is}):o.createElement(a)}}s[ze]=t,s[Be]=r;e:for(o=t.child;null!==o;){if(5===o.tag||6===o.tag)s.appendChild(o.stateNode);else if(4!==o.tag&&27!==o.tag&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;null===o.sibling;){if(null===o.return||o.return===t)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=s;e:switch(ud(s,a,r),a){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&al(t)}}return ul(t),sl(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==r&&al(t);else{if("string"!=typeof r&&null===t.stateNode)throw Error(i(166));if(e=W.current,gr(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,null!==(a=or))switch(a.tag){case 27:case 5:r=a.memoizedProps}e[ze]=t,(e=!!(e.nodeValue===n||null!==r&&!0===r.suppressHydrationWarning||od(e.nodeValue,n)))||pr(t,!0)}else(e=fd(e).createTextNode(r))[ze]=t,t.stateNode=e}return ul(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(r=gr(t),null!==n){if(null===e){if(!r)throw Error(i(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(i(557));e[ze]=t}else vr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ul(t),e=!1}else n=yr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(Fa(t),t):(Fa(t),null);if(128&t.flags)throw Error(i(558))}return ul(t),null;case 13:if(r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(a=gr(t),null!==r&&null!==r.dehydrated){if(null===e){if(!a)throw Error(i(318));if(!(a=null!==(a=t.memoizedState)?a.dehydrated:null))throw Error(i(317));a[ze]=t}else vr(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ul(t),a=!1}else a=yr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return 256&t.flags?(Fa(t),t):(Fa(t),null)}return Fa(t),128&t.flags?(t.lanes=n,t):(n=null!==r,e=null!==e&&null!==e.memoizedState,n&&(a=null,null!==(r=t.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(a=r.alternate.memoizedState.cachePool.pool),s=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(s=r.memoizedState.cachePool.pool),s!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),ll(t,t.updateQueue),ul(t),null);case 4:return q(),null===e&&Qu(t.stateNode.containerInfo),ul(t),null;case 10:return Er(t.type),ul(t),null;case 19:if(U(Oa),null===(r=t.memoizedState))return ul(t),null;if(a=!!(128&t.flags),null===(s=r.rendering))if(a)cl(r,!1);else{if(0!==_c||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(s=Ua(e))){for(t.flags|=128,cl(r,!1),e=s.updateQueue,t.updateQueue=e,ll(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)zi(n,e),n=n.sibling;return z(Oa,1&Oa.current|2),cr&&nr(t,r.treeForkCount),t.child}e=e.sibling}null!==r.tail&&se()>Ic&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=Ua(s))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,ll(t,e),cl(r,!0),null===r.tail&&"hidden"===r.tailMode&&!s.alternate&&!cr)return ul(t),null}else 2*se()-r.renderingStartTime>Ic&&536870912!==n&&(t.flags|=128,a=!0,cl(r,!1),t.lanes=4194304);r.isBackwards?(s.sibling=t.child,t.child=s):(null!==(e=r.last)?e.sibling=s:t.child=s,r.last=s)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=se(),e.sibling=null,n=Oa.current,z(Oa,a?1&n|2:1&n),cr&&nr(t,r.treeForkCount),e):(ul(t),null);case 22:case 23:return Fa(t),Pa(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?!!(536870912&n)&&!(128&t.flags)&&(ul(t),6&t.subtreeFlags&&(t.flags|=8192)):ul(t),null!==(n=t.updateQueue)&&ll(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&U(jr),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Er(Fr),ul(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}function hl(e,t){switch(ar(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Er(Fr),q(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Y(t),null;case 31:if(null!==t.memoizedState){if(Fa(t),null===t.alternate)throw Error(i(340));vr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(Fa(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));vr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return U(Oa),null;case 4:return q(),null;case 10:return Er(t.type),null;case 22:case 23:return Fa(t),Pa(),null!==e&&U(jr),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Er(Fr),null;default:return null}}function pl(e,t){switch(ar(t),t.tag){case 3:Er(Fr),q();break;case 26:case 27:case 5:Y(t);break;case 4:q();break;case 31:null!==t.memoizedState&&Fa(t);break;case 13:Fa(t);break;case 19:U(Oa);break;case 10:Er(t.type);break;case 22:case 23:Fa(t),Pa(),null!==e&&U(jr);break;case 24:Er(Fr)}}function fl(e,t){try{var n=t.updateQueue,i=null!==n?n.lastEffect:null;if(null!==i){var r=i.next;n=r;do{if((n.tag&e)===e){i=void 0;var a=n.create,s=n.inst;i=a(),s.destroy=i}n=n.next}while(n!==r)}}catch(e){_u(t,t.return,e)}}function ml(e,t,n){try{var i=t.updateQueue,r=null!==i?i.lastEffect:null;if(null!==r){var a=r.next;i=a;do{if((i.tag&e)===e){var s=i.inst,o=s.destroy;if(void 0!==o){s.destroy=void 0,r=t;var l=n,c=o;try{c()}catch(e){_u(r,l,e)}}}i=i.next}while(i!==a)}}catch(e){_u(t,t.return,e)}}function gl(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{Ea(t,n)}catch(t){_u(e,e.return,t)}}}function vl(e,t,n){n.props=_o(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){_u(e,t,n)}}function yl(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;default:i=e.stateNode}"function"==typeof n?e.refCleanup=n(i):n.current=i}}catch(n){_u(e,t,n)}}function xl(e,t){var n=e.ref,i=e.refCleanup;if(null!==n)if("function"==typeof i)try{i()}catch(n){_u(e,t,n)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(n){_u(e,t,n)}else n.current=null}function bl(e){var t=e.type,n=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&i.focus();break e;case"img":n.src?i.src=n.src:n.srcSet&&(i.srcset=n.srcSet)}}catch(t){_u(e,e.return,t)}}function _l(e,t,n){try{var r=e.stateNode;!function(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,s=null,o=null,l=null,c=null,u=null,d=null;for(f in n){var h=n[f];if(n.hasOwnProperty(f)&&null!=h)switch(f){case"checked":case"value":break;case"defaultValue":c=h;default:r.hasOwnProperty(f)||ld(e,t,f,null,r,h)}}for(var p in r){var f=r[p];if(h=n[p],r.hasOwnProperty(p)&&(null!=f||null!=h))switch(p){case"type":s=f;break;case"name":a=f;break;case"checked":u=f;break;case"defaultChecked":d=f;break;case"value":o=f;break;case"defaultValue":l=f;break;case"children":case"dangerouslySetInnerHTML":if(null!=f)throw Error(i(137,t));break;default:f!==h&&ld(e,t,p,f,r,h)}}return void gt(e,o,l,c,u,d,s,a);case"select":for(s in f=o=l=p=null,n)if(c=n[s],n.hasOwnProperty(s)&&null!=c)switch(s){case"value":break;case"multiple":f=c;default:r.hasOwnProperty(s)||ld(e,t,s,null,r,c)}for(a in r)if(s=r[a],c=n[a],r.hasOwnProperty(a)&&(null!=s||null!=c))switch(a){case"value":p=s;break;case"defaultValue":l=s;break;case"multiple":o=s;default:s!==c&&ld(e,t,a,s,r,c)}return t=l,n=o,r=f,void(null!=p?xt(e,!!n,p,!1):!!r!=!!n&&(null!=t?xt(e,!!n,t,!0):xt(e,!!n,n?[]:"",!1)));case"textarea":for(l in f=p=null,n)if(a=n[l],n.hasOwnProperty(l)&&null!=a&&!r.hasOwnProperty(l))switch(l){case"value":case"children":break;default:ld(e,t,l,null,r,a)}for(o in r)if(a=r[o],s=n[o],r.hasOwnProperty(o)&&(null!=a||null!=s))switch(o){case"value":p=a;break;case"defaultValue":f=a;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=a)throw Error(i(91));break;default:a!==s&&ld(e,t,o,a,r,s)}return void bt(e,p,f);case"option":for(var m in n)p=n[m],n.hasOwnProperty(m)&&null!=p&&!r.hasOwnProperty(m)&&("selected"===m?e.selected=!1:ld(e,t,m,null,r,p));for(c in r)p=r[c],f=n[c],!r.hasOwnProperty(c)||p===f||null==p&&null==f||("selected"===c?e.selected=p&&"function"!=typeof p&&"symbol"!=typeof p:ld(e,t,c,p,r,f));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var g in n)p=n[g],n.hasOwnProperty(g)&&null!=p&&!r.hasOwnProperty(g)&&ld(e,t,g,null,r,p);for(u in r)if(p=r[u],f=n[u],r.hasOwnProperty(u)&&p!==f&&(null!=p||null!=f))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(i(137,t));break;default:ld(e,t,u,p,r,f)}return;default:if(Tt(t)){for(var v in n)p=n[v],n.hasOwnProperty(v)&&void 0!==p&&!r.hasOwnProperty(v)&&cd(e,t,v,void 0,r,p);for(d in r)p=r[d],f=n[d],!r.hasOwnProperty(d)||p===f||void 0===p&&void 0===f||cd(e,t,d,p,r,f);return}}for(var y in n)p=n[y],n.hasOwnProperty(y)&&null!=p&&!r.hasOwnProperty(y)&&ld(e,t,y,null,r,p);for(h in r)p=r[h],f=n[h],!r.hasOwnProperty(h)||p===f||null==p&&null==f||ld(e,t,h,p,r,f)}(r,e.type,n,t),r[Be]=t}catch(t){_u(e,e.return,t)}}function wl(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&Ed(e.type)||4===e.tag}function Sl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||wl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&Ed(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function El(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=Ct));else if(4!==i&&(27===i&&Ed(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(El(e,t,n),e=e.sibling;null!==e;)El(e,t,n),e=e.sibling}function Ml(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==i&&(27===i&&Ed(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(Ml(e,t,n),e=e.sibling;null!==e;)Ml(e,t,n),e=e.sibling}function Tl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var i=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);ud(t,i,n),t[ze]=e,t[Be]=n}catch(t){_u(e,e.return,t)}}var Al=!1,Rl=!1,Pl=!1,Cl="function"==typeof WeakSet?WeakSet:Set,Ll=null;function Il(e,t,n){var i=n.flags;switch(n.tag){case 0:case 11:case 15:Xl(e,n),4&i&&fl(5,n);break;case 1:if(Xl(e,n),4&i)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(e){_u(n,n.return,e)}else{var r=_o(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){_u(n,n.return,e)}}64&i&&gl(n),512&i&&yl(n,n.return);break;case 3:if(Xl(e,n),64&i&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{Ea(e,t)}catch(e){_u(n,n.return,e)}}break;case 27:null===t&&4&i&&Tl(n);case 26:case 5:Xl(e,n),null===t&&4&i&&bl(n),512&i&&yl(n,n.return);break;case 12:Xl(e,n);break;case 31:Xl(e,n),4&i&&Ul(e,n);break;case 13:Xl(e,n),4&i&&zl(e,n),64&i&&null!==(e=n.memoizedState)&&null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var i=function(){t(),n.removeEventListener("DOMContentLoaded",i)};n.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}(e,n=Mu.bind(null,n));break;case 22:if(!(i=null!==n.memoizedState||Al)){t=null!==t&&null!==t.memoizedState||Rl,r=Al;var a=Rl;Al=i,(Rl=t)&&!a?$l(e,n,!!(8772&n.subtreeFlags)):Xl(e,n),Al=r,Rl=a}break;case 30:break;default:Xl(e,n)}}function Dl(e){var t=e.alternate;null!==t&&(e.alternate=null,Dl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(t=e.stateNode)&&qe(t),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Nl=null,kl=!1;function Fl(e,t,n){for(n=n.child;null!==n;)Ol(e,t,n),n=n.sibling}function Ol(e,t,n){if(ge&&"function"==typeof ge.onCommitFiberUnmount)try{ge.onCommitFiberUnmount(me,n)}catch(e){}switch(n.tag){case 26:Rl||xl(n,t),Fl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Rl||xl(n,t);var i=Nl,r=kl;Ed(n.type)&&(Nl=n.stateNode,kl=!1),Fl(e,t,n),Fd(n.stateNode),Nl=i,kl=r;break;case 5:Rl||xl(n,t);case 6:if(i=Nl,r=kl,Nl=null,Fl(e,t,n),kl=r,null!==(Nl=i))if(kl)try{(9===Nl.nodeType?Nl.body:"HTML"===Nl.nodeName?Nl.ownerDocument.body:Nl).removeChild(n.stateNode)}catch(e){_u(n,t,e)}else try{Nl.removeChild(n.stateNode)}catch(e){_u(n,t,e)}break;case 18:null!==Nl&&(kl?(Md(9===(e=Nl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Hh(e)):Md(Nl,n.stateNode));break;case 4:i=Nl,r=kl,Nl=n.stateNode.containerInfo,kl=!0,Fl(e,t,n),Nl=i,kl=r;break;case 0:case 11:case 14:case 15:ml(2,n,t),Rl||ml(4,n,t),Fl(e,t,n);break;case 1:Rl||(xl(n,t),"function"==typeof(i=n.stateNode).componentWillUnmount&&vl(n,t,i)),Fl(e,t,n);break;case 21:Fl(e,t,n);break;case 22:Rl=(i=Rl)||null!==n.memoizedState,Fl(e,t,n),Rl=i;break;default:Fl(e,t,n)}}function Ul(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)){e=e.dehydrated;try{Hh(e)}catch(e){_u(t,t.return,e)}}}function zl(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))try{Hh(e)}catch(e){_u(t,t.return,e)}}function Bl(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Cl),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Cl),t;default:throw Error(i(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var i=Tu.bind(null,e,t);t.then(i,i)}})}function Vl(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var a=n[r],s=e,o=t,l=o;e:for(;null!==l;){switch(l.tag){case 27:if(Ed(l.type)){Nl=l.stateNode,kl=!1;break e}break;case 5:Nl=l.stateNode,kl=!1;break e;case 3:case 4:Nl=l.stateNode.containerInfo,kl=!0;break e}l=l.return}if(null===Nl)throw Error(i(160));Ol(s,o,a),Nl=null,kl=!1,null!==(s=a.alternate)&&(s.return=null),a.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Gl(t,e),t=t.sibling}var Hl=null;function Gl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Vl(t,e),Wl(e),4&r&&(ml(3,e,e.return),fl(3,e),ml(5,e,e.return));break;case 1:Vl(t,e),Wl(e),512&r&&(Rl||null===n||xl(n,n.return)),64&r&&Al&&null!==(e=e.updateQueue)&&null!==(r=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?r:n.concat(r));break;case 26:var a=Hl;if(Vl(t,e),Wl(e),512&r&&(Rl||null===n||xl(n,n.return)),4&r){var s=null!==n?n.memoizedState:null;if(r=e.memoizedState,null===n)if(null===r)if(null===e.stateNode){e:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;t:switch(r){case"title":(!(s=a.getElementsByTagName("title")[0])||s[Xe]||s[ze]||"http://www.w3.org/2000/svg"===s.namespaceURI||s.hasAttribute("itemprop"))&&(s=a.createElement(r),a.head.insertBefore(s,a.querySelector("head > title"))),ud(s,r,n),s[ze]=e,Ze(s),r=s;break e;case"link":var o=eh("link","href",a).get(r+(n.href||""));if(o)for(var l=0;l<o.length;l++)if((s=o[l]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&s.getAttribute("rel")===(null==n.rel?null:n.rel)&&s.getAttribute("title")===(null==n.title?null:n.title)&&s.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){o.splice(l,1);break t}ud(s=a.createElement(r),r,n),a.head.appendChild(s);break;case"meta":if(o=eh("meta","content",a).get(r+(n.content||"")))for(l=0;l<o.length;l++)if((s=o[l]).getAttribute("content")===(null==n.content?null:""+n.content)&&s.getAttribute("name")===(null==n.name?null:n.name)&&s.getAttribute("property")===(null==n.property?null:n.property)&&s.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&s.getAttribute("charset")===(null==n.charSet?null:n.charSet)){o.splice(l,1);break t}ud(s=a.createElement(r),r,n),a.head.appendChild(s);break;default:throw Error(i(468,r))}s[ze]=e,Ze(s),r=s}e.stateNode=r}else th(a,e.type,e.stateNode);else e.stateNode=Yd(a,r,e.memoizedProps);else s!==r?(null===s?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):s.count--,null===r?th(a,e.type,e.stateNode):Yd(a,r,e.memoizedProps)):null===r&&null!==e.stateNode&&_l(e,e.memoizedProps,n.memoizedProps)}break;case 27:Vl(t,e),Wl(e),512&r&&(Rl||null===n||xl(n,n.return)),null!==n&&4&r&&_l(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Vl(t,e),Wl(e),512&r&&(Rl||null===n||xl(n,n.return)),32&e.flags){a=e.stateNode;try{wt(a,"")}catch(t){_u(e,e.return,t)}}4&r&&null!=e.stateNode&&_l(e,a=e.memoizedProps,null!==n?n.memoizedProps:a),1024&r&&(Pl=!0);break;case 6:if(Vl(t,e),Wl(e),4&r){if(null===e.stateNode)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){_u(e,e.return,t)}}break;case 3:if(Jd=null,a=Hl,Hl=zd(t.containerInfo),Vl(t,e),Hl=a,Wl(e),4&r&&null!==n&&n.memoizedState.isDehydrated)try{Hh(t.containerInfo)}catch(t){_u(e,e.return,t)}Pl&&(Pl=!1,jl(e));break;case 4:r=Hl,Hl=zd(e.stateNode.containerInfo),Vl(t,e),Wl(e),Hl=r;break;case 12:default:Vl(t,e),Wl(e);break;case 31:case 19:Vl(t,e),Wl(e),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,Bl(e,r));break;case 13:Vl(t,e),Wl(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Cc=se()),4&r&&null!==(r=e.updateQueue)&&(e.updateQueue=null,Bl(e,r));break;case 22:a=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=Al,d=Rl;if(Al=u||a,Rl=d||c,Vl(t,e),Rl=d,Al=u,Wl(e),8192&r)e:for(t=e.stateNode,t._visibility=a?-2&t._visibility:1|t._visibility,a&&(null===n||c||Al||Rl||ql(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(s=c.stateNode,a)"function"==typeof(o=s.style).setProperty?o.setProperty("display","none","important"):o.display="none";else{l=c.stateNode;var h=c.memoizedProps.style,p=null!=h&&h.hasOwnProperty("display")?h.display:null;l.style.display=null==p||"boolean"==typeof p?"":(""+p).trim()}}catch(e){_u(c,c.return,e)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=a?"":c.memoizedProps}catch(e){_u(c,c.return,e)}}}else if(18===t.tag){if(null===n){c=t;try{var f=c.stateNode;a?Td(f,!0):Td(c.stateNode,!1)}catch(e){_u(c,c.return,e)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&r&&null!==(r=e.updateQueue)&&null!==(n=r.retryQueue)&&(r.retryQueue=null,Bl(e,n));case 30:case 21:}}function Wl(e){var t=e.flags;if(2&t){try{for(var n,r=e.return;null!==r;){if(wl(r)){n=r;break}r=r.return}if(null==n)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Ml(e,Sl(e),a);break;case 5:var s=n.stateNode;32&n.flags&&(wt(s,""),n.flags&=-33),Ml(e,Sl(e),s);break;case 3:case 4:var o=n.stateNode.containerInfo;El(e,Sl(e),o);break;default:throw Error(i(161))}}catch(t){_u(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function jl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;jl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Xl(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Il(e,t.alternate,t),t=t.sibling}function ql(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ml(4,t,t.return),ql(t);break;case 1:xl(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&vl(t,t.return,n),ql(t);break;case 27:Fd(t.stateNode);case 26:case 5:xl(t,t.return),ql(t);break;case 22:null===t.memoizedState&&ql(t);break;default:ql(t)}e=e.sibling}}function $l(e,t,n){for(n=n&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var i=t.alternate,r=e,a=t,s=a.flags;switch(a.tag){case 0:case 11:case 15:$l(r,a,n),fl(4,a);break;case 1:if($l(r,a,n),"function"==typeof(r=(i=a).stateNode).componentDidMount)try{r.componentDidMount()}catch(e){_u(i,i.return,e)}if(null!==(r=(i=a).updateQueue)){var o=i.stateNode;try{var l=r.shared.hiddenCallbacks;if(null!==l)for(r.shared.hiddenCallbacks=null,r=0;r<l.length;r++)Sa(l[r],o)}catch(e){_u(i,i.return,e)}}n&&64&s&&gl(a),yl(a,a.return);break;case 27:Tl(a);case 26:case 5:$l(r,a,n),n&&null===i&&4&s&&bl(a),yl(a,a.return);break;case 12:$l(r,a,n);break;case 31:$l(r,a,n),n&&4&s&&Ul(r,a);break;case 13:$l(r,a,n),n&&4&s&&zl(r,a);break;case 22:null===a.memoizedState&&$l(r,a,n),yl(a,a.return);break;case 30:break;default:$l(r,a,n)}t=t.sibling}}function Yl(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&Ur(n))}function Kl(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ur(e))}function Ql(e,t,n,i){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)Zl(e,t,n,i),t=t.sibling}function Zl(e,t,n,i){var r=t.flags;switch(t.tag){case 0:case 11:case 15:Ql(e,t,n,i),2048&r&&fl(9,t);break;case 1:case 31:case 13:default:Ql(e,t,n,i);break;case 3:Ql(e,t,n,i),2048&r&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ur(e)));break;case 12:if(2048&r){Ql(e,t,n,i),e=t.stateNode;try{var a=t.memoizedProps,s=a.id,o=a.onPostCommit;"function"==typeof o&&o(s,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(e){_u(t,t.return,e)}}else Ql(e,t,n,i);break;case 23:break;case 22:a=t.stateNode,s=t.alternate,null!==t.memoizedState?2&a._visibility?Ql(e,t,n,i):ec(e,t):2&a._visibility?Ql(e,t,n,i):(a._visibility|=2,Jl(e,t,n,i,!!(10256&t.subtreeFlags)||!1)),2048&r&&Yl(s,t);break;case 24:Ql(e,t,n,i),2048&r&&Kl(t.alternate,t)}}function Jl(e,t,n,i,r){for(r=r&&(!!(10256&t.subtreeFlags)||!1),t=t.child;null!==t;){var a=e,s=t,o=n,l=i,c=s.flags;switch(s.tag){case 0:case 11:case 15:Jl(a,s,o,l,r),fl(8,s);break;case 23:break;case 22:var u=s.stateNode;null!==s.memoizedState?2&u._visibility?Jl(a,s,o,l,r):ec(a,s):(u._visibility|=2,Jl(a,s,o,l,r)),r&&2048&c&&Yl(s.alternate,s);break;case 24:Jl(a,s,o,l,r),r&&2048&c&&Kl(s.alternate,s);break;default:Jl(a,s,o,l,r)}t=t.sibling}}function ec(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,i=t,r=i.flags;switch(i.tag){case 22:ec(n,i),2048&r&&Yl(i.alternate,i);break;case 24:ec(n,i),2048&r&&Kl(i.alternate,i);break;default:ec(n,i)}t=t.sibling}}var tc=8192;function nc(e,t,n){if(e.subtreeFlags&tc)for(e=e.child;null!==e;)ic(e,t,n),e=e.sibling}function ic(e,t,n){switch(e.tag){case 26:nc(e,t,n),e.flags&tc&&null!==e.memoizedState&&function(e,t,n,i){if(!("stylesheet"!==n.type||"string"==typeof i.media&&!1===matchMedia(i.media).matches||4&n.state.loading)){if(null===n.instance){var r=Wd(i.href),a=t.querySelector(jd(r));if(a)return null!==(t=a._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=rh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,void Ze(a);a=t.ownerDocument||t,i=Xd(i),(r=Od.get(r))&&Qd(i,r),Ze(a=a.createElement("link"));var s=a;s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ud(a,"link",i),n.instance=a}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(3&n.state.loading)&&(e.count++,n=rh.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}(n,Hl,e.memoizedState,e.memoizedProps);break;case 5:default:nc(e,t,n);break;case 3:case 4:var i=Hl;Hl=zd(e.stateNode.containerInfo),nc(e,t,n),Hl=i;break;case 22:null===e.memoizedState&&(null!==(i=e.alternate)&&null!==i.memoizedState?(i=tc,tc=16777216,nc(e,t,n),tc=i):nc(e,t,n))}}function rc(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function ac(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var i=t[n];Ll=i,lc(i,e)}rc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)sc(e),e=e.sibling}function sc(e){switch(e.tag){case 0:case 11:case 15:ac(e),2048&e.flags&&ml(9,e,e.return);break;case 3:case 12:default:ac(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,oc(e)):ac(e)}}function oc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var i=t[n];Ll=i,lc(i,e)}rc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:ml(8,t,t.return),oc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,oc(t));break;default:oc(t)}e=e.sibling}}function lc(e,t){for(;null!==Ll;){var n=Ll;switch(n.tag){case 0:case 11:case 15:ml(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var i=n.memoizedState.cachePool.pool;null!=i&&i.refCount++}break;case 24:Ur(n.memoizedState.cache)}if(null!==(i=n.child))i.return=n,Ll=i;else e:for(n=e;null!==Ll;){var r=(i=Ll).sibling,a=i.return;if(Dl(i),i===n){Ll=null;break e}if(null!==r){r.return=a,Ll=r;break e}Ll=a}}}var cc={getCacheForType:function(e){var t=Cr(Fr),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Cr(Fr).controller.signal}},uc="function"==typeof WeakMap?WeakMap:Map,dc=0,hc=null,pc=null,fc=0,mc=0,gc=null,vc=!1,yc=!1,xc=!1,bc=0,_c=0,wc=0,Sc=0,Ec=0,Mc=0,Tc=0,Ac=null,Rc=null,Pc=!1,Cc=0,Lc=0,Ic=1/0,Dc=null,Nc=null,kc=0,Fc=null,Oc=null,Uc=0,zc=0,Bc=null,Vc=null,Hc=0,Gc=null;function Wc(){return 2&dc&&0!==fc?fc&-fc:null!==I.T?Bu():Fe()}function jc(){if(0===Mc)if(536870912&fc&&!cr)Mc=536870912;else{var e=we;!(3932160&(we<<=1))&&(we=262144),Mc=e}return null!==(e=Ca.current)&&(e.flags|=32),Mc}function Xc(e,t,n){(e!==hc||2!==mc&&9!==mc)&&null===e.cancelPendingCommit||(Jc(e,0),Kc(e,fc,Mc,!1)),Ce(e,n),2&dc&&e===hc||(e===hc&&(!(2&dc)&&(Sc|=n),4===_c&&Kc(e,fc,Mc,!1)),Du(e))}function qc(e,t,n){if(6&dc)throw Error(i(327));for(var r=!n&&!(127&t)&&0===(t&e.expiredLanes)||Te(e,t),a=r?function(e,t){var n=dc;dc|=2;var r=nu(),a=iu();hc!==e||fc!==t?(Dc=null,Ic=se()+500,Jc(e,t)):yc=Te(e,t);e:for(;;)try{if(0!==mc&&null!==pc){t=pc;var s=gc;t:switch(mc){case 1:mc=0,gc=null,uu(e,t,s,1);break;case 2:case 9:if(Jr(s)){mc=0,gc=null,cu(t);break}t=function(){2!==mc&&9!==mc||hc!==e||(mc=7),Du(e)},s.then(t,t);break e;case 3:mc=7;break e;case 4:mc=5;break e;case 7:Jr(s)?(mc=0,gc=null,cu(t)):(mc=0,gc=null,uu(e,t,s,7));break;case 5:var o=null;switch(pc.tag){case 26:o=pc.memoizedState;case 5:case 27:var l=pc;if(o?nh(o):l.stateNode.complete){mc=0,gc=null;var c=l.sibling;if(null!==c)pc=c;else{var u=l.return;null!==u?(pc=u,du(u)):pc=null}break t}}mc=0,gc=null,uu(e,t,s,5);break;case 6:mc=0,gc=null,uu(e,t,s,6);break;case 8:Zc(),_c=6;break e;default:throw Error(i(462))}}ou();break}catch(t){eu(e,t)}return wr=_r=null,I.H=r,I.A=a,dc=n,null!==pc?0:(hc=null,fc=0,Ri(),_c)}(e,t):au(e,t,!0),s=r;;){if(0===a){yc&&!r&&Kc(e,t,0,!1);break}if(n=e.current.alternate,!s||Yc(n)){if(2===a){if(s=t,e.errorRecoveryDisabledLanes&s)var o=0;else o=0!=(o=-536870913&e.pendingLanes)?o:536870912&o?536870912:0;if(0!==o){t=o;e:{var l=e;a=Ac;var c=l.current.memoizedState.isDehydrated;if(c&&(Jc(l,o).flags|=256),2!==(o=au(l,o,!1))){if(xc&&!c){l.errorRecoveryDisabledLanes|=s,Sc|=s,a=4;break e}s=Rc,Rc=a,null!==s&&(null===Rc?Rc=s:Rc.push.apply(Rc,s))}a=o}if(s=!1,2!==a)continue}}if(1===a){Jc(e,0),Kc(e,t,0,!0);break}e:{switch(r=e,s=a){case 0:case 1:throw Error(i(345));case 4:if((4194048&t)!==t)break;case 6:Kc(r,t,Mc,!vc);break e;case 2:Rc=null;break;case 3:case 5:break;default:throw Error(i(329))}if((62914560&t)===t&&10<(a=Cc+300-se())){if(Kc(r,t,Mc,!vc),0!==Me(r,0,!0))break e;Uc=t,r.timeoutHandle=xd($c.bind(null,r,n,Rc,Dc,Pc,t,Mc,Sc,Tc,vc,s,"Throttled",-0,0),a)}else $c(r,n,Rc,Dc,Pc,t,Mc,Sc,Tc,vc,s,null,-0,0)}break}a=au(e,t,!1),s=!1}Du(e)}function $c(e,t,n,i,r,a,s,o,l,c,u,d,h,p){if(e.timeoutHandle=-1,8192&(d=t.subtreeFlags)||!(16785408&~d)){ic(t,a,d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ct});var f=(62914560&a)===a?Cc-se():(4194048&a)===a?Lc-se():0;if(f=function(e,t){return e.stylesheets&&0===e.count&&sh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var i=setTimeout(function(){if(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===ih&&(ih=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,n=performance.getEntriesByType("resource"),i=0;i<n.length;i++){var r=n[i],a=r.transferSize,s=r.initiatorType,o=r.duration;if(a&&o&&dd(s)){for(s=0,o=r.responseEnd,i+=1;i<n.length;i++){var l=n[i],c=l.startTime;if(c>o)break;var u=l.transferSize,d=l.initiatorType;u&&dd(d)&&(s+=u*((l=l.responseEnd)<o?1:(o-c)/(l-c)))}if(--i,t+=8*(a+s)/(r.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var r=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>ih?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(r)}}:null}(d,f),null!==f)return Uc=a,e.cancelPendingCommit=f(pu.bind(null,e,t,a,n,i,r,s,o,l,u,d,null,h,p)),void Kc(e,a,s,!c)}pu(e,t,a,n,i,r,s,o,l)}function Yc(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&null!==(n=t.updateQueue)&&null!==(n=n.stores))for(var i=0;i<n.length;i++){var r=n[i],a=r.getSnapshot;r=r.value;try{if(!Kn(a(),r))return!1}catch(e){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Kc(e,t,n,i){t&=~Ec,t&=~Sc,e.suspendedLanes|=t,e.pingedLanes&=~t,i&&(e.warmLanes|=t),i=e.expirationTimes;for(var r=t;0<r;){var a=31-ye(r),s=1<<a;i[a]=-1,r&=~s}0!==n&&Le(e,n,t)}function Qc(){return!!(6&dc)||(Nu(0),!1)}function Zc(){if(null!==pc){if(0===mc)var e=pc.return;else wr=_r=null,rs(e=pc),aa=null,sa=0,e=pc;for(;null!==e;)pl(e.alternate,e),e=e.return;pc=null}}function Jc(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,bd(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Uc=0,Zc(),hc=e,pc=n=Ui(e.current,null),fc=t,mc=0,gc=null,vc=!1,yc=Te(e,t),xc=!1,Tc=Mc=Ec=Sc=wc=_c=0,Rc=Ac=null,Pc=!1,8&t&&(t|=32&t);var i=e.entangledLanes;if(0!==i)for(e=e.entanglements,i&=t;0<i;){var r=31-ye(i),a=1<<r;t|=e[r],i&=~a}return bc=t,Ri(),n}function eu(e,t){Ba=null,I.H=po,t===Yr||t===Qr?(t=ia(),mc=3):t===Kr?(t=ia(),mc=4):mc=t===Co?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,gc=t,null===pc&&(_c=1,Mo(e,Xi(t,e.current)))}function tu(){var e=Ca.current;return null===e||((4194048&fc)===fc?null===La:!!((62914560&fc)===fc||536870912&fc)&&e===La)}function nu(){var e=I.H;return I.H=po,null===e?po:e}function iu(){var e=I.A;return I.A=cc,e}function ru(){_c=4,vc||(4194048&fc)!==fc&&null!==Ca.current||(yc=!0),!(134217727&wc)&&!(134217727&Sc)||null===hc||Kc(hc,fc,Mc,!1)}function au(e,t,n){var i=dc;dc|=2;var r=nu(),a=iu();hc===e&&fc===t||(Dc=null,Jc(e,t)),t=!1;var s=_c;e:for(;;)try{if(0!==mc&&null!==pc){var o=pc,l=gc;switch(mc){case 8:Zc(),s=6;break e;case 3:case 2:case 9:case 6:null===Ca.current&&(t=!0);var c=mc;if(mc=0,gc=null,uu(e,o,l,c),n&&yc){s=0;break e}break;default:c=mc,mc=0,gc=null,uu(e,o,l,c)}}su(),s=_c;break}catch(t){eu(e,t)}return t&&e.shellSuspendCounter++,wr=_r=null,dc=i,I.H=r,I.A=a,null===pc&&(hc=null,fc=0,Ri()),s}function su(){for(;null!==pc;)lu(pc)}function ou(){for(;null!==pc&&!re();)lu(pc)}function lu(e){var t=rl(e.alternate,e,bc);e.memoizedProps=e.pendingProps,null===t?du(e):pc=t}function cu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Go(n,t,t.pendingProps,t.type,void 0,fc);break;case 11:t=Go(n,t,t.pendingProps,t.type.render,t.ref,fc);break;case 5:rs(t);default:pl(n,t),t=rl(n,t=pc=zi(t,bc),bc)}e.memoizedProps=e.pendingProps,null===t?du(e):pc=t}function uu(e,t,n,r){wr=_r=null,rs(t),aa=null,sa=0;var a=t.return;try{if(function(e,t,n,r,a){if(n.flags|=32768,null!==r&&"object"==typeof r&&"function"==typeof r.then){if(null!==(t=n.alternate)&&Ar(t,n,a,!0),null!==(n=Ca.current)){switch(n.tag){case 31:case 13:return null===La?ru():null===n.alternate&&0===_c&&(_c=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Zr?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([r]):t.add(r),wu(e,r,a)),!1;case 22:return n.flags|=65536,r===Zr?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([r]):n.add(r),wu(e,r,a)),!1}throw Error(i(435,n.tag))}return wu(e,r,a),ru(),!1}if(cr)return null!==(t=Ca.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==hr&&xr(Xi(e=Error(i(422),{cause:r}),n))):(r!==hr&&xr(Xi(t=Error(i(423),{cause:r}),n)),(e=e.current.alternate).flags|=65536,a&=-a,e.lanes|=a,r=Xi(r,n),xa(e,a=Ao(e.stateNode,r,a)),4!==_c&&(_c=2)),!1;var s=Error(i(520),{cause:r});if(s=Xi(s,n),null===Ac?Ac=[s]:Ac.push(s),4!==_c&&(_c=2),null===t)return!0;r=Xi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,xa(n,e=Ao(n.stateNode,r,e)),!1;case 1:if(t=n.type,s=n.stateNode,!(128&n.flags||"function"!=typeof t.getDerivedStateFromError&&(null===s||"function"!=typeof s.componentDidCatch||null!==Nc&&Nc.has(s))))return n.flags|=65536,a&=-a,n.lanes|=a,Po(a=Ro(a),e,n,r),xa(n,a),!1}n=n.return}while(null!==n);return!1}(e,a,t,n,fc))return _c=1,Mo(e,Xi(n,e.current)),void(pc=null)}catch(t){if(null!==a)throw pc=a,t;return _c=1,Mo(e,Xi(n,e.current)),void(pc=null)}32768&t.flags?(cr||1===r?e=!0:yc||536870912&fc?e=!1:(vc=e=!0,(2===r||9===r||3===r||6===r)&&null!==(r=Ca.current)&&13===r.tag&&(r.flags|=16384)),hu(t,e)):du(t)}function du(e){var t=e;do{if(32768&t.flags)return void hu(t,vc);e=t.return;var n=dl(t.alternate,t,bc);if(null!==n)return void(pc=n);if(null!==(t=t.sibling))return void(pc=t);pc=t=e}while(null!==t);0===_c&&(_c=5)}function hu(e,t){do{var n=hl(e.alternate,e);if(null!==n)return n.flags&=32767,void(pc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(pc=e);pc=e=n}while(null!==e);_c=6,pc=null}function pu(e,t,n,r,a,s,o,l,c){e.cancelPendingCommit=null;do{yu()}while(0!==kc);if(6&dc)throw Error(i(327));if(null!==t){if(t===e.current)throw Error(i(177));if(s=t.lanes|t.childLanes,function(e,t,n,i,r,a){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=s&~n;0<n;){var u=31-ye(n),d=1<<u;o[u]=0,l[u]=-1;var h=c[u];if(null!==h)for(c[u]=null,u=0;u<h.length;u++){var p=h[u];null!==p&&(p.lane&=-536870913)}n&=~d}0!==i&&Le(e,i,0),0!==a&&0===r&&0!==e.tag&&(e.suspendedLanes|=a&~(s&~t))}(e,n,s|=Ai,o,l,c),e===hc&&(pc=hc=null,fc=0),Oc=t,Fc=e,Uc=n,zc=s,Bc=a,Vc=r,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,ne(ue,function(){return xu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(13878&t.flags),13878&t.subtreeFlags||r){r=I.T,I.T=null,a=D.p,D.p=2,o=dc,dc|=4;try{!function(e,t){if(e=e.containerInfo,hd=vh,ni(e=ti(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(r&&0!==r.rangeCount){n=r.anchorNode;var a=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch(e){n=null;break e}var o=0,l=-1,c=-1,u=0,d=0,h=e,p=null;t:for(;;){for(var f;h!==n||0!==a&&3!==h.nodeType||(l=o+a),h!==s||0!==r&&3!==h.nodeType||(c=o+r),3===h.nodeType&&(o+=h.nodeValue.length),null!==(f=h.firstChild);)p=h,h=f;for(;;){if(h===e)break t;if(p===n&&++u===a&&(l=o),p===s&&++d===r&&(c=o),null!==(f=h.nextSibling))break;p=(h=p).parentNode}h=f}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(pd={focusedElem:e,selectionRange:n},vh=!1,Ll=t;null!==Ll;)if(e=(t=Ll).child,1028&t.subtreeFlags&&null!==e)e.return=t,Ll=e;else for(;null!==Ll;){switch(s=(t=Ll).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(n=0;n<e.length;n++)(a=e[n]).ref.impl=a.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==s){e=void 0,n=t,a=s.memoizedProps,s=s.memoizedState,r=n.stateNode;try{var m=_o(n.type,a);e=r.getSnapshotBeforeUpdate(m,s),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){_u(n,n.return,e)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))Ad(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ad(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(i(163))}if(null!==(e=t.sibling)){e.return=t.return,Ll=e;break}Ll=t.return}}(e,t)}finally{dc=o,D.p=a,I.T=r}}kc=1,fu(),mu(),gu()}}function fu(){if(1===kc){kc=0;var e=Fc,t=Oc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=I.T,I.T=null;var i=D.p;D.p=2;var r=dc;dc|=4;try{Gl(t,e);var a=pd,s=ti(e.containerInfo),o=a.focusedElem,l=a.selectionRange;if(s!==o&&o&&o.ownerDocument&&ei(o.ownerDocument.documentElement,o)){if(null!==l&&ni(o)){var c=l.start,u=l.end;if(void 0===u&&(u=c),"selectionStart"in o)o.selectionStart=c,o.selectionEnd=Math.min(u,o.value.length);else{var d=o.ownerDocument||document,h=d&&d.defaultView||window;if(h.getSelection){var p=h.getSelection(),f=o.textContent.length,m=Math.min(l.start,f),g=void 0===l.end?m:Math.min(l.end,f);!p.extend&&m>g&&(s=g,g=m,m=s);var v=Jn(o,m),y=Jn(o,g);if(v&&y&&(1!==p.rangeCount||p.anchorNode!==v.node||p.anchorOffset!==v.offset||p.focusNode!==y.node||p.focusOffset!==y.offset)){var x=d.createRange();x.setStart(v.node,v.offset),p.removeAllRanges(),m>g?(p.addRange(x),p.extend(y.node,y.offset)):(x.setEnd(y.node,y.offset),p.addRange(x))}}}}for(d=[],p=o;p=p.parentNode;)1===p.nodeType&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for("function"==typeof o.focus&&o.focus(),o=0;o<d.length;o++){var b=d[o];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}vh=!!hd,pd=hd=null}finally{dc=r,D.p=i,I.T=n}}e.current=t,kc=2}}function mu(){if(2===kc){kc=0;var e=Fc,t=Oc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=I.T,I.T=null;var i=D.p;D.p=2;var r=dc;dc|=4;try{Il(e,t.alternate,t)}finally{dc=r,D.p=i,I.T=n}}kc=3}}function gu(){if(4===kc||3===kc){kc=0,ae();var e=Fc,t=Oc,n=Uc,i=Vc;10256&t.subtreeFlags||10256&t.flags?kc=5:(kc=0,Oc=Fc=null,vu(e,e.pendingLanes));var r=e.pendingLanes;if(0===r&&(Nc=null),ke(n),t=t.stateNode,ge&&"function"==typeof ge.onCommitFiberRoot)try{ge.onCommitFiberRoot(me,t,void 0,!(128&~t.current.flags))}catch(e){}if(null!==i){t=I.T,r=D.p,D.p=2,I.T=null;try{for(var a=e.onRecoverableError,s=0;s<i.length;s++){var o=i[s];a(o.value,{componentStack:o.stack})}}finally{I.T=t,D.p=r}}3&Uc&&yu(),Du(e),r=e.pendingLanes,261930&n&&42&r?e===Gc?Hc++:(Hc=0,Gc=e):Hc=0,Nu(0)}}function vu(e,t){0===(e.pooledCacheLanes&=t)&&null!=(t=e.pooledCache)&&(e.pooledCache=null,Ur(t))}function yu(){return fu(),mu(),gu(),xu()}function xu(){if(5!==kc)return!1;var e=Fc,t=zc;zc=0;var n=ke(Uc),r=I.T,a=D.p;try{D.p=32>n?32:n,I.T=null,n=Bc,Bc=null;var s=Fc,o=Uc;if(kc=0,Oc=Fc=null,Uc=0,6&dc)throw Error(i(331));var l=dc;if(dc|=4,sc(s.current),Zl(s,s.current,o,n),dc=l,Nu(0,!1),ge&&"function"==typeof ge.onPostCommitFiberRoot)try{ge.onPostCommitFiberRoot(me,s)}catch(e){}return!0}finally{D.p=a,I.T=r,vu(e,t)}}function bu(e,t,n){t=Xi(n,t),null!==(e=va(e,t=Ao(e.stateNode,t,2),2))&&(Ce(e,2),Du(e))}function _u(e,t,n){if(3===e.tag)bu(e,e,n);else for(;null!==t;){if(3===t.tag){bu(t,e,n);break}if(1===t.tag){var i=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof i.componentDidCatch&&(null===Nc||!Nc.has(i))){e=Xi(n,e),null!==(i=va(t,n=Ro(2),2))&&(Po(n,i,t,e),Ce(i,2),Du(i));break}}t=t.return}}function wu(e,t,n){var i=e.pingCache;if(null===i){i=e.pingCache=new uc;var r=new Set;i.set(t,r)}else void 0===(r=i.get(t))&&(r=new Set,i.set(t,r));r.has(n)||(xc=!0,r.add(n),e=Su.bind(null,e,t,n),t.then(e,e))}function Su(e,t,n){var i=e.pingCache;null!==i&&i.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,hc===e&&(fc&n)===n&&(4===_c||3===_c&&(62914560&fc)===fc&&300>se()-Cc?!(2&dc)&&Jc(e,0):Ec|=n,Tc===fc&&(Tc=0)),Du(e)}function Eu(e,t){0===t&&(t=Re()),null!==(e=Li(e,t))&&(Ce(e,t),Du(e))}function Mu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Eu(e,n)}function Tu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;null!==a&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==r&&r.delete(t),Eu(e,n)}var Au=null,Ru=null,Pu=!1,Cu=!1,Lu=!1,Iu=0;function Du(e){e!==Ru&&null===e.next&&(null===Ru?Au=Ru=e:Ru=Ru.next=e),Cu=!0,Pu||(Pu=!0,wd(function(){6&dc?ne(le,ku):Fu()}))}function Nu(e,t){if(!Lu&&Cu){Lu=!0;do{for(var n=!1,i=Au;null!==i;){if(0!==e){var r=i.pendingLanes;if(0===r)var a=0;else{var s=i.suspendedLanes,o=i.pingedLanes;a=(1<<31-ye(42|e)+1)-1,a=201326741&(a&=r&~(s&~o))?201326741&a|1:a?2|a:0}0!==a&&(n=!0,zu(i,a))}else a=fc,!(3&(a=Me(i,i===hc?a:0,null!==i.cancelPendingCommit||-1!==i.timeoutHandle)))||Te(i,a)||(n=!0,zu(i,a));i=i.next}}while(n);Lu=!1}}function ku(){Fu()}function Fu(){Cu=Pu=!1;var e,t=0;0!==Iu&&((e=window.event)&&"popstate"===e.type?e!==yd&&(yd=e,1):(yd=null,0))&&(t=Iu);for(var n=se(),i=null,r=Au;null!==r;){var a=r.next,s=Ou(r,n);0===s?(r.next=null,null===i?Au=a:i.next=a,null===a&&(Ru=i)):(i=r,(0!==t||3&s)&&(Cu=!0)),r=a}0!==kc&&5!==kc||Nu(t),0!==Iu&&(Iu=0)}function Ou(e,t){for(var n=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,a=-62914561&e.pendingLanes;0<a;){var s=31-ye(a),o=1<<s,l=r[s];-1===l?0!==(o&n)&&0===(o&i)||(r[s]=Ae(o,t)):l<=t&&(e.expiredLanes|=o),a&=~o}if(n=fc,n=Me(e,e===(t=hc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),i=e.callbackNode,0===n||e===t&&(2===mc||9===mc)||null!==e.cancelPendingCommit)return null!==i&&null!==i&&ie(i),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Te(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==i&&ie(i),ke(n)){case 2:case 8:n=ce;break;case 32:default:n=ue;break;case 268435456:n=he}return i=Uu.bind(null,e),n=ne(n,i),e.callbackPriority=t,e.callbackNode=n,t}return null!==i&&null!==i&&ie(i),e.callbackPriority=2,e.callbackNode=null,2}function Uu(e,t){if(0!==kc&&5!==kc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(yu()&&e.callbackNode!==n)return null;var i=fc;return 0===(i=Me(e,e===hc?i:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(qc(e,i,t),Ou(e,se()),null!=e.callbackNode&&e.callbackNode===n?Uu.bind(null,e):null)}function zu(e,t){if(yu())return null;qc(e,t,!0)}function Bu(){if(0===Iu){var e=Vr;0===e&&(e=_e,!(261888&(_e<<=1))&&(_e=256)),Iu=e}return Iu}function Vu(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:Pt(""+e)}function Hu(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Gu=0;Gu<wi.length;Gu++){var Wu=wi[Gu];Si(Wu.toLowerCase(),"on"+(Wu[0].toUpperCase()+Wu.slice(1)))}Si(fi,"onAnimationEnd"),Si(mi,"onAnimationIteration"),Si(gi,"onAnimationStart"),Si("dblclick","onDoubleClick"),Si("focusin","onFocus"),Si("focusout","onBlur"),Si(vi,"onTransitionRun"),Si(yi,"onTransitionStart"),Si(xi,"onTransitionCancel"),Si(bi,"onTransitionEnd"),nt("onMouseEnter",["mouseout","mouseover"]),nt("onMouseLeave",["mouseout","mouseover"]),nt("onPointerEnter",["pointerout","pointerover"]),nt("onPointerLeave",["pointerout","pointerover"]),tt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),tt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),tt("onBeforeInput",["compositionend","keypress","textInput","paste"]),tt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),tt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),tt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ju="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Xu=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ju));function qu(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var i=e[n],r=i.event;i=i.listeners;e:{var a=void 0;if(t)for(var s=i.length-1;0<=s;s--){var o=i[s],l=o.instance,c=o.currentTarget;if(o=o.listener,l!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=c;try{a(r)}catch(e){Ei(e)}r.currentTarget=null,a=l}else for(s=0;s<i.length;s++){if(l=(o=i[s]).instance,c=o.currentTarget,o=o.listener,l!==a&&r.isPropagationStopped())break e;a=o,r.currentTarget=c;try{a(r)}catch(e){Ei(e)}r.currentTarget=null,a=l}}}}function $u(e,t){var n=t[He];void 0===n&&(n=t[He]=new Set);var i=e+"__bubble";n.has(i)||(Zu(t,e,2,!1),n.add(i))}function Yu(e,t,n){var i=0;t&&(i|=4),Zu(n,e,i,t)}var Ku="_reactListening"+Math.random().toString(36).slice(2);function Qu(e){if(!e[Ku]){e[Ku]=!0,Je.forEach(function(t){"selectionchange"!==t&&(Xu.has(t)||Yu(t,!1,e),Yu(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Ku]||(t[Ku]=!0,Yu("selectionchange",!1,t))}}function Zu(e,t,n,i){switch(Eh(t)){case 2:var r=yh;break;case 8:r=xh;break;default:r=bh}n=r.bind(null,t,n,e),r=void 0,!Bt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(r=!0),i?void 0!==r?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):void 0!==r?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function Ju(e,t,n,i,r){var s=i;if(!(1&t||2&t||null===i))e:for(;;){if(null===i)return;var o=i.tag;if(3===o||4===o){var l=i.stateNode.containerInfo;if(l===r)break;if(4===o)for(o=i.return;null!==o;){var c=o.tag;if((3===c||4===c)&&o.stateNode.containerInfo===r)return;o=o.return}for(;null!==l;){if(null===(o=$e(l)))return;if(5===(c=o.tag)||6===c||26===c||27===c){i=s=o;continue e}l=l.parentNode}}i=i.return}Ot(function(){var i=s,r=It(n),o=[];e:{var l=_i.get(e);if(void 0!==l){var c=en,u=e;switch(e){case"keypress":if(0===Xt(n))break e;case"keydown":case"keyup":c=gn;break;case"focusin":u="focus",c=on;break;case"focusout":u="blur",c=on;break;case"beforeblur":case"afterblur":c=on;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=an;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=sn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=yn;break;case fi:case mi:case gi:c=ln;break;case bi:c=xn;break;case"scroll":case"scrollend":c=nn;break;case"wheel":c=bn;break;case"copy":case"cut":case"paste":c=cn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=vn;break;case"toggle":case"beforetoggle":c=_n}var d=!!(4&t),h=!d&&("scroll"===e||"scrollend"===e),p=d?null!==l?l+"Capture":null:l;d=[];for(var f,m=i;null!==m;){var g=m;if(f=g.stateNode,5!==(g=g.tag)&&26!==g&&27!==g||null===f||null===p||null!=(g=Ut(m,p))&&d.push(ed(m,g,f)),h)break;m=m.return}0<d.length&&(l=new c(l,u,null,n,r),o.push({event:l,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(l="mouseover"===e||"pointerover"===e)||n===Lt||!(u=n.relatedTarget||n.fromElement)||!$e(u)&&!u[Ve])&&(c||l)&&(l=r.window===r?r:(l=r.ownerDocument)?l.defaultView||l.parentWindow:window,c?(c=i,null!==(u=(u=n.relatedTarget||n.toElement)?$e(u):null)&&(h=a(u),d=u.tag,u!==h||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=i),c!==u)){if(d=an,g="onMouseLeave",p="onMouseEnter",m="mouse","pointerout"!==e&&"pointerover"!==e||(d=vn,g="onPointerLeave",p="onPointerEnter",m="pointer"),h=null==c?l:Ke(c),f=null==u?l:Ke(u),(l=new d(g,m+"leave",c,n,r)).target=h,l.relatedTarget=f,g=null,$e(r)===i&&((d=new d(p,m+"enter",u,n,r)).target=f,d.relatedTarget=h,g=d),h=g,c&&u)e:{for(d=nd,m=u,f=0,g=p=c;g;g=d(g))f++;g=0;for(var v=m;v;v=d(v))g++;for(;0<f-g;)p=d(p),f--;for(;0<g-f;)m=d(m),g--;for(;f--;){if(p===m||null!==m&&p===m.alternate){d=p;break e}p=d(p),m=d(m)}d=null}else d=null;null!==c&&id(o,l,c,d,!1),null!==u&&null!==h&&id(o,h,u,d,!0)}if("select"===(c=(l=i?Ke(i):window).nodeName&&l.nodeName.toLowerCase())||"input"===c&&"file"===l.type)var y=zn;else if(Dn(l))if(Bn)y=Yn;else{y=qn;var x=Xn}else!(c=l.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==l.type&&"radio"!==l.type?i&&Tt(i.elementType)&&(y=zn):y=$n;switch(y&&(y=y(e,i))?Nn(o,y,n,r):(x&&x(e,l,i),"focusout"===e&&i&&"number"===l.type&&null!=i.memoizedProps.value&&yt(l,"number",l.value)),x=i?Ke(i):window,e){case"focusin":(Dn(x)||"true"===x.contentEditable)&&(ri=x,ai=i,si=null);break;case"focusout":si=ai=ri=null;break;case"mousedown":oi=!0;break;case"contextmenu":case"mouseup":case"dragend":oi=!1,li(o,n,r);break;case"selectionchange":if(ii)break;case"keydown":case"keyup":li(o,n,r)}var b;if(Sn)e:{switch(e){case"compositionstart":var _="onCompositionStart";break e;case"compositionend":_="onCompositionEnd";break e;case"compositionupdate":_="onCompositionUpdate";break e}_=void 0}else Ln?Pn(e,n)&&(_="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(_="onCompositionStart");_&&(Tn&&"ko"!==n.locale&&(Ln||"onCompositionStart"!==_?"onCompositionEnd"===_&&Ln&&(b=jt()):(Gt="value"in(Ht=r)?Ht.value:Ht.textContent,Ln=!0)),0<(x=td(i,_)).length&&(_=new un(_,e,null,n,r),o.push({event:_,listeners:x}),(b||null!==(b=Cn(n)))&&(_.data=b))),(b=Mn?function(e,t){switch(e){case"compositionend":return Cn(t);case"keypress":return 32!==t.which?null:(Rn=!0,An);case"textInput":return(e=t.data)===An&&Rn?null:e;default:return null}}(e,n):function(e,t){if(Ln)return"compositionend"===e||!Sn&&Pn(e,t)?(e=jt(),Wt=Gt=Ht=null,Ln=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Tn&&"ko"!==t.locale?null:t.data}}(e,n))&&0<(_=td(i,"onBeforeInput")).length&&(x=new un("onBeforeInput","beforeinput",null,n,r),o.push({event:x,listeners:_}),x.data=b),function(e,t,n,i,r){if("submit"===t&&n&&n.stateNode===r){var a=Vu((r[Be]||null).action),s=i.submitter;s&&null!==(t=(t=s[Be]||null)?Vu(t.formAction):s.getAttribute("formAction"))&&(a=t,s=null);var o=new en("action","action",null,i,r);e.push({event:o,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(0!==Iu){var e=s?Hu(r,s):new FormData(r);Zs(n,{pending:!0,data:e,method:r.method,action:a},null,e)}}else"function"==typeof a&&(o.preventDefault(),e=s?Hu(r,s):new FormData(r),Zs(n,{pending:!0,data:e,method:r.method,action:a},a,e))},currentTarget:r}]})}}(o,e,i,n,r)}qu(o,t)})}function ed(e,t,n){return{instance:e,listener:t,currentTarget:n}}function td(e,t){for(var n=t+"Capture",i=[];null!==e;){var r=e,a=r.stateNode;if(5!==(r=r.tag)&&26!==r&&27!==r||null===a||(null!=(r=Ut(e,n))&&i.unshift(ed(e,r,a)),null!=(r=Ut(e,t))&&i.push(ed(e,r,a))),3===e.tag)return i;e=e.return}return[]}function nd(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function id(e,t,n,i,r){for(var a=t._reactName,s=[];null!==n&&n!==i;){var o=n,l=o.alternate,c=o.stateNode;if(o=o.tag,null!==l&&l===i)break;5!==o&&26!==o&&27!==o||null===c||(l=c,r?null!=(c=Ut(n,a))&&s.unshift(ed(n,c,l)):r||null!=(c=Ut(n,a))&&s.push(ed(n,c,l))),n=n.return}0!==s.length&&e.push({event:t,listeners:s})}var rd=/\r\n?/g,ad=/\u0000|\uFFFD/g;function sd(e){return("string"==typeof e?e:""+e).replace(rd,"\n").replace(ad,"")}function od(e,t){return t=sd(t),sd(e)===t}function ld(e,t,n,r,a,s){switch(n){case"children":"string"==typeof r?"body"===t||"textarea"===t&&""===r||wt(e,r):("number"==typeof r||"bigint"==typeof r)&&"body"!==t&&wt(e,""+r);break;case"className":ot(e,"class",r);break;case"tabIndex":ot(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":ot(e,n,r);break;case"style":Mt(e,r,s);break;case"data":if("object"!==t){ot(e,"data",r);break}case"src":case"href":if(""===r&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==r||"function"==typeof r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Pt(""+r),e.setAttribute(n,r);break;case"action":case"formAction":if("function"==typeof r){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"==typeof s&&("formAction"===n?("input"!==t&&ld(e,t,"name",a.name,a,null),ld(e,t,"formEncType",a.formEncType,a,null),ld(e,t,"formMethod",a.formMethod,a,null),ld(e,t,"formTarget",a.formTarget,a,null)):(ld(e,t,"encType",a.encType,a,null),ld(e,t,"method",a.method,a,null),ld(e,t,"target",a.target,a,null))),null==r||"symbol"==typeof r||"boolean"==typeof r){e.removeAttribute(n);break}r=Pt(""+r),e.setAttribute(n,r);break;case"onClick":null!=r&&(e.onclick=Ct);break;case"onScroll":null!=r&&$u("scroll",e);break;case"onScrollEnd":null!=r&&$u("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(i(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(i(60));e.innerHTML=n}}break;case"multiple":e.multiple=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"muted":e.muted=r&&"function"!=typeof r&&"symbol"!=typeof r;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==r||"function"==typeof r||"boolean"==typeof r||"symbol"==typeof r){e.removeAttribute("xlink:href");break}n=Pt(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""+r):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===r?e.setAttribute(n,""):!1!==r&&null!=r&&"function"!=typeof r&&"symbol"!=typeof r?e.setAttribute(n,r):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=r&&"function"!=typeof r&&"symbol"!=typeof r&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case"rowSpan":case"start":null==r||"function"==typeof r||"symbol"==typeof r||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case"popover":$u("beforetoggle",e),$u("toggle",e),st(e,"popover",r);break;case"xlinkActuate":lt(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":lt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":lt(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":lt(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":lt(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":lt(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":lt(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":lt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":lt(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":st(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&st(e,n=At.get(n)||n,r)}}function cd(e,t,n,r,a,s){switch(n){case"style":Mt(e,r,s);break;case"dangerouslySetInnerHTML":if(null!=r){if("object"!=typeof r||!("__html"in r))throw Error(i(61));if(null!=(n=r.__html)){if(null!=a.children)throw Error(i(60));e.innerHTML=n}}break;case"children":"string"==typeof r?wt(e,r):("number"==typeof r||"bigint"==typeof r)&&wt(e,""+r);break;case"onScroll":null!=r&&$u("scroll",e);break;case"onScrollEnd":null!=r&&$u("scrollend",e);break;case"onClick":null!=r&&(e.onclick=Ct);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:et.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(a=n.endsWith("Capture"),t=n.slice(2,a?n.length-7:void 0),"function"==typeof(s=null!=(s=e[Be]||null)?s[n]:null)&&e.removeEventListener(t,s,a),"function"!=typeof r)?n in e?e[n]=r:!0===r?e.setAttribute(n,""):st(e,n,r):("function"!=typeof s&&null!==s&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a)))}}function ud(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":$u("error",e),$u("load",e);var r,a=!1,s=!1;for(r in n)if(n.hasOwnProperty(r)){var o=n[r];if(null!=o)switch(r){case"src":a=!0;break;case"srcSet":s=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:ld(e,t,r,o,n,null)}}return s&&ld(e,t,"srcSet",n.srcSet,n,null),void(a&&ld(e,t,"src",n.src,n,null));case"input":$u("invalid",e);var l=r=o=s=null,c=null,u=null;for(a in n)if(n.hasOwnProperty(a)){var d=n[a];if(null!=d)switch(a){case"name":s=d;break;case"type":o=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":r=d;break;case"defaultValue":l=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(i(137,t));break;default:ld(e,t,a,d,n,null)}}return void vt(e,r,l,c,u,o,s,!1);case"select":for(s in $u("invalid",e),a=o=r=null,n)if(n.hasOwnProperty(s)&&null!=(l=n[s]))switch(s){case"value":r=l;break;case"defaultValue":o=l;break;case"multiple":a=l;default:ld(e,t,s,l,n,null)}return t=r,n=o,e.multiple=!!a,void(null!=t?xt(e,!!a,t,!1):null!=n&&xt(e,!!a,n,!0));case"textarea":for(o in $u("invalid",e),r=s=a=null,n)if(n.hasOwnProperty(o)&&null!=(l=n[o]))switch(o){case"value":a=l;break;case"defaultValue":s=l;break;case"children":r=l;break;case"dangerouslySetInnerHTML":if(null!=l)throw Error(i(91));break;default:ld(e,t,o,l,n,null)}return void _t(e,a,s,r);case"option":for(c in n)n.hasOwnProperty(c)&&null!=(a=n[c])&&("selected"===c?e.selected=a&&"function"!=typeof a&&"symbol"!=typeof a:ld(e,t,c,a,n,null));return;case"dialog":$u("beforetoggle",e),$u("toggle",e),$u("cancel",e),$u("close",e);break;case"iframe":case"object":$u("load",e);break;case"video":case"audio":for(a=0;a<ju.length;a++)$u(ju[a],e);break;case"image":$u("error",e),$u("load",e);break;case"details":$u("toggle",e);break;case"embed":case"source":case"link":$u("error",e),$u("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in n)if(n.hasOwnProperty(u)&&null!=(a=n[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:ld(e,t,u,a,n,null)}return;default:if(Tt(t)){for(d in n)n.hasOwnProperty(d)&&void 0!==(a=n[d])&&cd(e,t,d,a,n,void 0);return}}for(l in n)n.hasOwnProperty(l)&&null!=(a=n[l])&&ld(e,t,l,a,n,null)}function dd(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var hd=null,pd=null;function fd(e){return 9===e.nodeType?e:e.ownerDocument}function md(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function gd(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function vd(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var yd=null,xd="function"==typeof setTimeout?setTimeout:void 0,bd="function"==typeof clearTimeout?clearTimeout:void 0,_d="function"==typeof Promise?Promise:void 0,wd="function"==typeof queueMicrotask?queueMicrotask:void 0!==_d?function(e){return _d.resolve(null).then(e).catch(Sd)}:xd;function Sd(e){setTimeout(function(){throw e})}function Ed(e){return"head"===e}function Md(e,t){var n=t,i=0;do{var r=n.nextSibling;if(e.removeChild(n),r&&8===r.nodeType)if("/$"===(n=r.data)||"/&"===n){if(0===i)return e.removeChild(r),void Hh(t);i--}else if("$"===n||"$?"===n||"$~"===n||"$!"===n||"&"===n)i++;else if("html"===n)Fd(e.ownerDocument.documentElement);else if("head"===n){Fd(n=e.ownerDocument.head);for(var a=n.firstChild;a;){var s=a.nextSibling,o=a.nodeName;a[Xe]||"SCRIPT"===o||"STYLE"===o||"LINK"===o&&"stylesheet"===a.rel.toLowerCase()||n.removeChild(a),a=s}}else"body"===n&&Fd(e.ownerDocument.body);n=r}while(n);Hh(t)}function Td(e,t){var n=e;e=0;do{var i=n.nextSibling;if(1===n.nodeType?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",""===n.getAttribute("style")&&n.removeAttribute("style")):3===n.nodeType&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),i&&8===i.nodeType)if("/$"===(n=i.data)){if(0===e)break;e--}else"$"!==n&&"$?"!==n&&"$~"!==n&&"$!"!==n||e++;n=i}while(n)}function Ad(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Ad(n),qe(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function Rd(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Ld(e.nextSibling)))return null}return e}function Pd(e){return"$?"===e.data||"$~"===e.data}function Cd(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Ld(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Id=null;function Dd(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n||"/&"===n){if(0===t)return Ld(e.nextSibling);t--}else"$"!==n&&"$!"!==n&&"$?"!==n&&"$~"!==n&&"&"!==n||t++}e=e.nextSibling}return null}function Nd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n||"$~"===n||"&"===n){if(0===t)return e;t--}else"/$"!==n&&"/&"!==n||t++}e=e.previousSibling}return null}function kd(e,t,n){switch(t=fd(n),e){case"html":if(!(e=t.documentElement))throw Error(i(452));return e;case"head":if(!(e=t.head))throw Error(i(453));return e;case"body":if(!(e=t.body))throw Error(i(454));return e;default:throw Error(i(451))}}function Fd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);qe(e)}var Od=new Map,Ud=new Set;function zd(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Bd=D.d;D.d={f:function(){var e=Bd.f(),t=Qc();return e||t},r:function(e){var t=Ye(e);null!==t&&5===t.tag&&"form"===t.type?eo(t):Bd.r(e)},D:function(e){Bd.D(e),Hd("dns-prefetch",e,null)},C:function(e,t){Bd.C(e,t),Hd("preconnect",e,t)},L:function(e,t,n){Bd.L(e,t,n);var i=Vd;if(i&&e&&t){var r='link[rel="preload"][as="'+mt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(r+='[imagesrcset="'+mt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(r+='[imagesizes="'+mt(n.imageSizes)+'"]')):r+='[href="'+mt(e)+'"]';var a=r;switch(t){case"style":a=Wd(e);break;case"script":a=qd(e)}Od.has(a)||(e=d({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),Od.set(a,e),null!==i.querySelector(r)||"style"===t&&i.querySelector(jd(a))||"script"===t&&i.querySelector($d(a))||(ud(t=i.createElement("link"),"link",e),Ze(t),i.head.appendChild(t)))}},m:function(e,t){Bd.m(e,t);var n=Vd;if(n&&e){var i=t&&"string"==typeof t.as?t.as:"script",r='link[rel="modulepreload"][as="'+mt(i)+'"][href="'+mt(e)+'"]',a=r;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":a=qd(e)}if(!Od.has(a)&&(e=d({rel:"modulepreload",href:e},t),Od.set(a,e),null===n.querySelector(r))){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector($d(a)))return}ud(i=n.createElement("link"),"link",e),Ze(i),n.head.appendChild(i)}}},X:function(e,t){Bd.X(e,t);var n=Vd;if(n&&e){var i=Qe(n).hoistableScripts,r=qd(e),a=i.get(r);a||((a=n.querySelector($d(r)))||(e=d({src:e,async:!0},t),(t=Od.get(r))&&Zd(e,t),Ze(a=n.createElement("script")),ud(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},i.set(r,a))}},S:function(e,t,n){Bd.S(e,t,n);var i=Vd;if(i&&e){var r=Qe(i).hoistableStyles,a=Wd(e);t=t||"default";var s=r.get(a);if(!s){var o={loading:0,preload:null};if(s=i.querySelector(jd(a)))o.loading=5;else{e=d({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Od.get(a))&&Qd(e,n);var l=s=i.createElement("link");Ze(l),ud(l,"link",e),l._p=new Promise(function(e,t){l.onload=e,l.onerror=t}),l.addEventListener("load",function(){o.loading|=1}),l.addEventListener("error",function(){o.loading|=2}),o.loading|=4,Kd(s,t,i)}s={type:"stylesheet",instance:s,count:1,state:o},r.set(a,s)}}},M:function(e,t){Bd.M(e,t);var n=Vd;if(n&&e){var i=Qe(n).hoistableScripts,r=qd(e),a=i.get(r);a||((a=n.querySelector($d(r)))||(e=d({src:e,async:!0,type:"module"},t),(t=Od.get(r))&&Zd(e,t),Ze(a=n.createElement("script")),ud(a,"link",e),n.head.appendChild(a)),a={type:"script",instance:a,count:1,state:null},i.set(r,a))}}};var Vd="undefined"==typeof document?null:document;function Hd(e,t,n){var i=Vd;if(i&&"string"==typeof t&&t){var r=mt(t);r='link[rel="'+e+'"][href="'+r+'"]',"string"==typeof n&&(r+='[crossorigin="'+n+'"]'),Ud.has(r)||(Ud.add(r),e={rel:e,crossOrigin:n,href:t},null===i.querySelector(r)&&(ud(t=i.createElement("link"),"link",e),Ze(t),i.head.appendChild(t)))}}function Gd(e,t,n,r){var a,s,o,l,c=(c=W.current)?zd(c):null;if(!c)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof n.precedence&&"string"==typeof n.href?(t=Wd(n.href),(r=(n=Qe(c).hoistableStyles).get(t))||(r={type:"style",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"==typeof n.href&&"string"==typeof n.precedence){e=Wd(n.href);var u=Qe(c).hoistableStyles,d=u.get(e);if(d||(c=c.ownerDocument||c,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,d),(u=c.querySelector(jd(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Od.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Od.set(e,n),u||(a=c,s=e,o=n,l=d.state,a.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=a.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),ud(s,"link",o),Ze(s),a.head.appendChild(s))))),t&&null===r)throw Error(i(528,""));return d}if(t&&null!==r)throw Error(i(529,""));return null;case"script":return t=n.async,"string"==typeof(n=n.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=qd(n),(r=(n=Qe(c).hoistableScripts).get(t))||(r={type:"script",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Wd(e){return'href="'+mt(e)+'"'}function jd(e){return'link[rel="stylesheet"]['+e+"]"}function Xd(e){return d({},e,{"data-precedence":e.precedence,precedence:null})}function qd(e){return'[src="'+mt(e)+'"]'}function $d(e){return"script[async]"+e}function Yd(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+mt(n.href)+'"]');if(r)return t.instance=r,Ze(r),r;var a=d({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return Ze(r=(e.ownerDocument||e).createElement("style")),ud(r,"style",a),Kd(r,n.precedence,e),t.instance=r;case"stylesheet":a=Wd(n.href);var s=e.querySelector(jd(a));if(s)return t.state.loading|=4,t.instance=s,Ze(s),s;r=Xd(n),(a=Od.get(a))&&Qd(r,a),Ze(s=(e.ownerDocument||e).createElement("link"));var o=s;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ud(s,"link",r),t.state.loading|=4,Kd(s,n.precedence,e),t.instance=s;case"script":return s=qd(n.src),(a=e.querySelector($d(s)))?(t.instance=a,Ze(a),a):(r=n,(a=Od.get(s))&&Zd(r=d({},n),a),Ze(a=(e=e.ownerDocument||e).createElement("script")),ud(a,"link",r),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(i(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(r=t.instance,t.state.loading|=4,Kd(r,n.precedence,e));return t.instance}function Kd(e,t,n){for(var i=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=i.length?i[i.length-1]:null,a=r,s=0;s<i.length;s++){var o=i[s];if(o.dataset.precedence===t)a=o;else if(a!==r)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function Qd(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function Zd(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var Jd=null;function eh(e,t,n){if(null===Jd){var i=new Map,r=Jd=new Map;r.set(n,i)}else(i=(r=Jd).get(n))||(i=new Map,r.set(n,i));if(i.has(e))return i;for(i.set(e,null),n=n.getElementsByTagName(e),r=0;r<n.length;r++){var a=n[r];if(!(a[Xe]||a[ze]||"link"===e&&"stylesheet"===a.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==a.namespaceURI){var s=a.getAttribute(t)||"";s=e+s;var o=i.get(s);o?o.push(a):i.set(s,[a])}}return i}function th(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function nh(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var ih=0;function rh(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)sh(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var ah=null;function sh(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,ah=new Map,t.forEach(oh,e),ah=null,rh.call(e))}function oh(e,t){if(!(4&t.state.loading)){var n=ah.get(e);if(n)var i=n.get(null);else{n=new Map,ah.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),a=0;a<r.length;a++){var s=r[a];"LINK"!==s.nodeName&&"not all"===s.getAttribute("media")||(n.set(s.dataset.precedence,s),i=s)}i&&n.set(null,i)}s=(r=t.instance).getAttribute("data-precedence"),(a=n.get(s)||i)===i&&n.set(null,r),n.set(s,r),this.count++,i=rh.bind(this),r.addEventListener("load",i),r.addEventListener("error",i),a?a.parentNode.insertBefore(r,a.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(r,e.firstChild),t.state.loading|=4}}var lh={$$typeof:x,Provider:null,Consumer:null,_currentValue:N,_currentValue2:N,_threadCount:0};function ch(e,t,n,i,r,a,s,o,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Pe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pe(0),this.hiddenUpdates=Pe(null),this.identifierPrefix=i,this.onUncaughtError=r,this.onCaughtError=a,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function uh(e,t,n,i,r,a,s,o,l,c,u,d){return e=new ch(e,t,n,s,l,c,u,d,o),t=1,!0===a&&(t|=24),a=Fi(3,null,null,t),e.current=a,a.stateNode=e,(t=Or()).refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:i,isDehydrated:n,cache:t},fa(a),e}function dh(e){return e?e=Ni:Ni}function hh(e,t,n,i,r,a){r=dh(r),null===i.context?i.context=r:i.pendingContext=r,(i=ga(t)).payload={element:n},null!==(a=void 0===a?null:a)&&(i.callback=a),null!==(n=va(e,i,t))&&(Xc(n,0,t),ya(n,e,t))}function ph(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function fh(e,t){ph(e,t),(e=e.alternate)&&ph(e,t)}function mh(e){if(13===e.tag||31===e.tag){var t=Li(e,67108864);null!==t&&Xc(t,0,67108864),fh(e,67108864)}}function gh(e){if(13===e.tag||31===e.tag){var t=Wc(),n=Li(e,t=Ne(t));null!==n&&Xc(n,0,t),fh(e,t)}}var vh=!0;function yh(e,t,n,i){var r=I.T;I.T=null;var a=D.p;try{D.p=2,bh(e,t,n,i)}finally{D.p=a,I.T=r}}function xh(e,t,n,i){var r=I.T;I.T=null;var a=D.p;try{D.p=8,bh(e,t,n,i)}finally{D.p=a,I.T=r}}function bh(e,t,n,i){if(vh){var r=_h(i);if(null===r)Ju(e,t,i,wh,n),Dh(e,i);else if(function(e,t,n,i,r){switch(t){case"focusin":return Th=Nh(Th,e,t,n,i,r),!0;case"dragenter":return Ah=Nh(Ah,e,t,n,i,r),!0;case"mouseover":return Rh=Nh(Rh,e,t,n,i,r),!0;case"pointerover":var a=r.pointerId;return Ph.set(a,Nh(Ph.get(a)||null,e,t,n,i,r)),!0;case"gotpointercapture":return a=r.pointerId,Ch.set(a,Nh(Ch.get(a)||null,e,t,n,i,r)),!0}return!1}(r,e,t,n,i))i.stopPropagation();else if(Dh(e,i),4&t&&-1<Ih.indexOf(e)){for(;null!==r;){var a=Ye(r);if(null!==a)switch(a.tag){case 3:if((a=a.stateNode).current.memoizedState.isDehydrated){var s=Ee(a.pendingLanes);if(0!==s){var o=a;for(o.pendingLanes|=2,o.entangledLanes|=2;s;){var l=1<<31-ye(s);o.entanglements[1]|=l,s&=~l}Du(a),!(6&dc)&&(Ic=se()+500,Nu(0))}}break;case 31:case 13:null!==(o=Li(a,2))&&Xc(o,0,2),Qc(),fh(a,2)}if(null===(a=_h(i))&&Ju(e,t,i,wh,n),a===r)break;r=a}null!==r&&i.stopPropagation()}else Ju(e,t,i,null,n)}}function _h(e){return Sh(e=It(e))}var wh=null;function Sh(e){if(wh=null,null!==(e=$e(e))){var t=a(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=s(t)))return e;e=null}else if(31===n){if(null!==(e=l(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return wh=e,null}function Eh(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(oe()){case le:return 2;case ce:return 8;case ue:case de:return 32;case he:return 268435456;default:return 32}default:return 32}}var Mh=!1,Th=null,Ah=null,Rh=null,Ph=new Map,Ch=new Map,Lh=[],Ih="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Dh(e,t){switch(e){case"focusin":case"focusout":Th=null;break;case"dragenter":case"dragleave":Ah=null;break;case"mouseover":case"mouseout":Rh=null;break;case"pointerover":case"pointerout":Ph.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ch.delete(t.pointerId)}}function Nh(e,t,n,i,r,a){return null===e||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:i,nativeEvent:a,targetContainers:[r]},null!==t&&null!==(t=Ye(t))&&mh(t),e):(e.eventSystemFlags|=i,t=e.targetContainers,null!==r&&-1===t.indexOf(r)&&t.push(r),e)}function kh(e){var t=$e(e.target);if(null!==t){var n=a(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=s(n)))return e.blockedOn=t,void Oe(e.priority,function(){gh(n)})}else if(31===t){if(null!==(t=l(n)))return e.blockedOn=t,void Oe(e.priority,function(){gh(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Fh(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=_h(e.nativeEvent);if(null!==n)return null!==(t=Ye(n))&&mh(t),e.blockedOn=n,!1;var i=new(n=e.nativeEvent).constructor(n.type,n);Lt=i,n.target.dispatchEvent(i),Lt=null,t.shift()}return!0}function Oh(e,t,n){Fh(e)&&n.delete(t)}function Uh(){Mh=!1,null!==Th&&Fh(Th)&&(Th=null),null!==Ah&&Fh(Ah)&&(Ah=null),null!==Rh&&Fh(Rh)&&(Rh=null),Ph.forEach(Oh),Ch.forEach(Oh)}function zh(t,n){t.blockedOn===n&&(t.blockedOn=null,Mh||(Mh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Uh)))}var Bh=null;function Vh(t){Bh!==t&&(Bh=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Bh===t&&(Bh=null);for(var e=0;e<t.length;e+=3){var n=t[e],i=t[e+1],r=t[e+2];if("function"!=typeof i){if(null===Sh(i||n))continue;break}var a=Ye(n);null!==a&&(t.splice(e,3),e-=3,Zs(a,{pending:!0,data:r,method:n.method,action:i},i,r))}}))}function Hh(e){function t(t){return zh(t,e)}null!==Th&&zh(Th,e),null!==Ah&&zh(Ah,e),null!==Rh&&zh(Rh,e),Ph.forEach(t),Ch.forEach(t);for(var n=0;n<Lh.length;n++){var i=Lh[n];i.blockedOn===e&&(i.blockedOn=null)}for(;0<Lh.length&&null===(n=Lh[0]).blockedOn;)kh(n),null===n.blockedOn&&Lh.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(i=0;i<n.length;i+=3){var r=n[i],a=n[i+1],s=r[Be]||null;if("function"==typeof a)s||Vh(n);else if(s){var o=null;if(a&&a.hasAttribute("formAction")){if(r=a,s=a[Be]||null)o=s.formAction;else if(null!==Sh(r))continue}else o=s.action;"function"==typeof o?n[i+1]=o:(n.splice(i,3),i-=3),Vh(n)}}}function Gh(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return r=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==r&&(r(),r=null),i||setTimeout(n,20)}function n(){if(!i&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var i=!1,r=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==r&&(r(),r=null)}}}function Wh(e){this._internalRoot=e}function jh(e){this._internalRoot=e}jh.prototype.render=Wh.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(i(409));hh(t.current,Wc(),e,t,null,null)},jh.prototype.unmount=Wh.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;hh(e.current,2,null,e,null,null),Qc(),t[Ve]=null}},jh.prototype.unstable_scheduleHydration=function(e){if(e){var t=Fe();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Lh.length&&0!==t&&t<Lh[n].priority;n++);Lh.splice(n,0,e),0===n&&kh(e)}};var Xh=t.version;if("19.2.8"!==Xh)throw Error(i(527,Xh,"19.2.8"));D.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(i(188));throw e=Object.keys(e).join(","),Error(i(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=a(e)))throw Error(i(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(null===s)break;var o=s.alternate;if(null===o){if(null!==(r=s.return)){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return c(s),e;if(o===r)return c(s),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=s,r=o;else{for(var l=!1,u=s.child;u;){if(u===n){l=!0,n=s,r=o;break}if(u===r){l=!0,r=s,n=o;break}u=u.sibling}if(!l){for(u=o.child;u;){if(u===n){l=!0,n=o,r=s;break}if(u===r){l=!0,r=o,n=s;break}u=u.sibling}if(!l)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(3!==n.tag)throw Error(i(188));return n.stateNode.current===n?e:t}(t),null===(e=null!==e?u(e):null)?null:e.stateNode};var qh={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:I,reconcilerVersion:"19.2.8"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var $h=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$h.isDisabled&&$h.supportsFiber)try{me=$h.inject(qh),ge=$h}catch(e){}}return fw.createRoot=function(e,t){if(!r(e))throw Error(i(299));var n=!1,a="",s=wo,o=So,l=Eo;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(a=t.identifierPrefix),void 0!==t.onUncaughtError&&(s=t.onUncaughtError),void 0!==t.onCaughtError&&(o=t.onCaughtError),void 0!==t.onRecoverableError&&(l=t.onRecoverableError)),t=uh(e,1,!1,null,0,n,a,null,s,o,l,Gh),e[Ve]=t.current,Qu(e),new Wh(t)},fw.hydrateRoot=function(e,t,n){if(!r(e))throw Error(i(299));var a=!1,s="",o=wo,l=So,c=Eo,u=null;return null!=n&&(!0===n.unstable_strictMode&&(a=!0),void 0!==n.identifierPrefix&&(s=n.identifierPrefix),void 0!==n.onUncaughtError&&(o=n.onUncaughtError),void 0!==n.onCaughtError&&(l=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.formState&&(u=n.formState)),(t=uh(e,1,!0,t,0,a,s,u,o,l,c,Gh)).context=dh(null),n=t.current,(s=ga(a=Ne(a=Wc()))).callback=null,va(n,s,a),n=a,t.current.lanes=n,Ce(t,n),Du(t),e[Ve]=t.current,Qu(e),new jh(t)},fw.version="19.2.8",fw}();var Ew=pw.exports;class Mw{constructor(e){this.version="2.5.0",e.ipd=0,Dr.getState().setInputMode(e.primaryInputMode),this.devUIContainer=document.createElement("div"),this.devUIContainer.style.position="fixed",this.devUIContainer.style.width="100vw",this.devUIContainer.style.height="100vh",this.devUIContainer.style.top="50vh",this.devUIContainer.style.left="50vw",this.devUIContainer.style.transform="translate(-50%, -50%)",this.devUIContainer.style.pointerEvents="none";const t=this.devUIContainer.attachShadow({mode:"open"});this.inputLayer=new uw(e),Vc.setState({mode:this.inputLayer.currentGazeMode,commitHand:this.inputLayer.currentGazeCommitHand}),this.unsubscribeControlMode=e.onControlModeChange(t=>{"programmatic"===t?(this.inputLayer.setProgrammaticMode(!0),this.inputLayer.syncFromDevice(),Dr.getState().setInputMode(e.primaryInputMode),Vc.getState().setMode(this.inputLayer.currentGazeMode),this.inputLayer.setInteractionsEnabled(!1)):(this.inputLayer.setProgrammaticMode(!1),this.inputLayer.setInteractionsEnabled(!0),Vc.getState().setMode(this.inputLayer.currentGazeMode))}),this.unsubscribeStateChange=e.onStateChange(()=>{this.inputLayer.isInProgrammaticMode&&(this.inputLayer.syncFromDevice(),Dr.getState().setInputMode(e.primaryInputMode),Vc.getState().setMode(this.inputLayer.currentGazeMode))});Ew.createRoot(t).render(c.jsx(Tw,{xrDevice:e,inputLayer:this.inputLayer,shadowRoot:t}));const n=()=>{const t=document.createElement("div");document.body.appendChild(t);const n=t.attachShadow({mode:"open"});Ew.createRoot(n).render(c.jsx(Aw,{xrDevice:e,shadowRoot:n}))};document.body?n():window.onload=n}render(e){this.inputLayer.renderScene(e)}applyDefaultPose(e){this.inputLayer.applyDefaultPose(e)}setGazeMode(e){this.inputLayer.setGazeMode(e),Vc.getState().setMode(this.inputLayer.currentGazeMode)}setGazeCommitHand(e){this.inputLayer.setGazeCommitHand(e),Vc.getState().setCommitHand(e)}onSessionEnd(){this.inputLayer.onSessionEnd()}dispose(){this.unsubscribeControlMode(),this.unsubscribeStateChange(),this.inputLayer.dispose()}get devUICanvas(){return this.inputLayer.domElement}}const Tw=({xrDevice:e,inputLayer:t,shadowRoot:n})=>{const[i,r]=o.useState(!1),[a,s]=o.useState(e.controlMode);return o.useEffect(()=>{const t=()=>{const e=document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement;r(!!e)};document.addEventListener("pointerlockchange",t,!1),document.addEventListener("mozpointerlockchange",t,!1),document.addEventListener("webkitpointerlockchange",t,!1);const n=e.onControlModeChange(e=>{s(e)});return()=>{document.removeEventListener("pointerlockchange",t,!1),document.removeEventListener("mozpointerlockchange",t,!1),document.removeEventListener("webkitpointerlockchange",t,!1),n()}},[e]),c.jsx(Ht,{target:n,disableCSSOMInjection:!0,children:c.jsxs("div",{style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between",pointerEvents:"none"},children:["programmatic"===a&&c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:999,boxShadow:"inset 0 0 20px 5px rgba(59, 130, 246, 0.5)"}}),c.jsxs("div",{style:{position:"absolute",bottom:"8px",left:"50%",transform:"translateX(-50%)",backgroundColor:"rgba(59, 130, 246, 0.9)",color:"white",padding:"6px 16px",borderRadius:"16px",fontSize:"12px",fontFamily:"system-ui, sans-serif",fontWeight:500,zIndex:1e3,display:"flex",alignItems:"center",gap:"6px",boxShadow:"0 2px 8px rgba(0,0,0,0.3)"},children:[c.jsx("span",{style:{fontSize:"14px"},children:"●"}),"Remote Control Active"]})]}),"programmatic"!==a&&c.jsxs(c.Fragment,{children:[c.jsx(hu,{xrDevice:e,inputLayer:t}),c.jsx(Nr,{xrDevice:e,inputLayer:t,pointerLocked:i})]})]})})},Aw=({xrDevice:e,shadowRoot:t})=>{const[n,i]=l.useState(e.sessionOffered&&!e.activeSession);return l.useEffect(()=>{const t=setInterval(()=>{i(e.sessionOffered&&!e.activeSession)},1e3);return()=>{clearInterval(t)}},[]),c.jsx(Ht,{target:t,disableCSSOMInjection:!0,children:c.jsxs(Sn,{style:{zIndex:899,position:"fixed",top:"8px",display:"flex",flexDirection:"row",alignItems:"center",justifyItems:"space-between",left:"50vw",transform:n?"translateX(-50%)":"translateX(-50%) translateY(calc(-100% - 12px))",transition:"transform 0.2s ease-in-out",paddingLeft:"5px",gap:"3px"},children:[c.jsx(ki,{name:"iwer",size:24}),c.jsx(En,{onClick:()=>{e.grantOfferedSession()},style:{fontSize:"16px"},children:"Enter XR"})]})})};function Rw(){let e=0,t=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(e|=(127&i)<<n,!(128&i))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(t|=(127&i)<<n,!(128&i))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Pw(e,t,n){for(let i=0;i<28;i+=7){const r=e>>>i,a=!(r>>>7==0&&0==t),s=255&(a?128|r:r);if(n.push(s),!a)return}const i=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|i:i)),r){for(let e=3;e<31;e+=7){const i=t>>>e,r=!(i>>>7==0),a=255&(r?128|i:i);if(n.push(a),!r)return}n.push(t>>>31&1)}}const Cw=4294967296;function Lw(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let i=0,r=0;function a(t,a){const s=Number(e.slice(t,a));r*=n,i=i*n+s,i>=Cw&&(r+=i/Cw|0,i%=Cw)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?Nw(i,r):Dw(i,r)}function Iw(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(Cw*t+e);const n=16777215&(e>>>24|t<<8),i=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*i,a=n+8147497*i,s=2*i;const o=1e7;return r>=o&&(a+=Math.floor(r/o),r%=o),a>=o&&(s+=Math.floor(a/o),a%=o),s.toString()+kw(a)+kw(r)}function Dw(e,t){return{lo:0|e,hi:0|t}}function Nw(e,t){return t=~t,e?e=1+~e:t+=1,Dw(e,t)}const kw=e=>{const t=String(e);return"0000000".slice(t.length)+t};function Fw(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function Ow(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;128&e&&t<10;t++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}const Uw=zw();function zw(){const e=new DataView(new ArrayBuffer(8));if(!("function"!=typeof BigInt||"function"!=typeof e.getBigInt64||"function"!=typeof e.getBigUint64||"function"!=typeof e.setBigInt64||"function"!=typeof e.setBigUint64||!globalThis.Deno&&!globalThis.Bun&&"object"==typeof process&&"object"==typeof process.env&&"1"===process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const i="bigint"==typeof e?e:BigInt(e);if(i>n||i<t)throw new Error(`invalid int64: ${e}`);return i},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>r||t<i)throw new Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),Bw(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),Vw(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),Bw(e),Lw(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),Vw(e),Lw(e)),dec:(e,t)=>function(e,t){let n=Dw(e,t);const i=2147483648&n.hi;i&&(n=Nw(n.lo,n.hi));const r=Iw(n.lo,n.hi);return i?"-"+r:r}(e,t),uDec:(e,t)=>Iw(e,t)}}function Bw(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function Vw(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}const Hw=Symbol.for("@bufbuild/protobuf/text-encoding");function Gw(){if(null==globalThis[Hw]){const e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;let n;globalThis[Hw]={encodeUtf8:t=>e.encode(t),decodeUtf8:(e,i)=>i?(void 0===n&&(n=new globalThis.TextDecoder("utf-8",{fatal:!0})),n.decode(e)):t.decode(e),checkUtf8(e){try{return encodeURIComponent(e),!0}catch(e){return!1}}}}return globalThis[Hw]}var Ww;!function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(Ww||(Ww={}));const jw=34028234663852886e22,Xw=-34028234663852886e22;class qw{constructor(e=Gw().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Kw(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return Yw(e),Fw(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){!function(e){if("string"==typeof e){const t=e;if(e=Number(e),Number.isNaN(e)&&"NaN"!==t)throw new Error("invalid float32: "+t)}else if("number"!=typeof e)throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>jw||e<Xw))throw new Error("invalid float32: "+e)}(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Kw(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Yw(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Yw(e),Fw(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=Uw.enc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=Uw.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=Uw.enc(e);return Pw(t.lo,t.hi,this.buf),this}sint64(e){const t=Uw.enc(e),n=t.hi>>31;return Pw(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){const t=Uw.uEnc(e);return Pw(t.lo,t.hi,this.buf),this}}class $w{constructor(e,t=Gw().decodeUtf8){this.decodeUtf8=t,this.varint64=Rw,this.uint32=Ow,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){const e=this.pos,t=this.uint32(),n=this.pos-e;if(n>5||5==n&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");const i=t>>>3,r=7&t;if(i<=0||r>5)throw new Error("illegal tag: field no "+i+" wire type "+r);return[i,r]}skip(e,t,n=100){let i=this.pos;switch(e){case Ww.Varint:for(;128&this.buf[this.pos++];);break;case Ww.Bit64:this.pos+=4;case Ww.Bit32:this.pos+=4;break;case Ww.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Ww.StartGroup:if(n<=0)throw new Error("maximum recursion depth reached");for(;;){const[e,i]=this.tag();if(i===Ww.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(i,e,n-1)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return Uw.dec(...this.varint64())}uint64(){return Uw.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,Uw.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Uw.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Uw.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e){return this.decodeUtf8(this.bytes(),e)}}function Yw(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int32: "+e)}function Kw(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint32: "+e)}const Qw={encode:(e,t=new qw)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:aS(e.x)?globalThis.Number(e.x):0,y:aS(e.y)?globalThis.Number(e.y):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),t},create:e=>Qw.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={x:0,y:0};return i.x=null!==(t=e.x)&&void 0!==t?t:0,i.y=null!==(n=e.y)&&void 0!==n?n:0,i}};const Zw={encode:(e,t=new qw)=>(0!==e.width&&t.uint32(13).float(e.width),0!==e.height&&t.uint32(21).float(e.height),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={width:0,height:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.width=n.float();continue;case 2:if(21!==e)break;r.height=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({width:aS(e.width)?globalThis.Number(e.width):0,height:aS(e.height)?globalThis.Number(e.height):0}),toJSON(e){const t={};return 0!==e.width&&(t.width=e.width),0!==e.height&&(t.height=e.height),t},create:e=>Zw.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={width:0,height:0};return i.width=null!==(t=e.width)&&void 0!==t?t:0,i.height=null!==(n=e.height)&&void 0!==n?n:0,i}};const Jw={encode:(e,t=new qw)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),0!==e.z&&t.uint32(29).float(e.z),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0,z:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue;case 3:if(29!==e)break;r.z=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:aS(e.x)?globalThis.Number(e.x):0,y:aS(e.y)?globalThis.Number(e.y):0,z:aS(e.z)?globalThis.Number(e.z):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),0!==e.z&&(t.z=e.z),t},create:e=>Jw.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={x:0,y:0,z:0};return r.x=null!==(t=e.x)&&void 0!==t?t:0,r.y=null!==(n=e.y)&&void 0!==n?n:0,r.z=null!==(i=e.z)&&void 0!==i?i:0,r}};const eS={encode:(e,t=new qw)=>(0!==e.width&&t.uint32(13).float(e.width),0!==e.height&&t.uint32(21).float(e.height),0!==e.depth&&t.uint32(29).float(e.depth),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={width:0,height:0,depth:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.width=n.float();continue;case 2:if(21!==e)break;r.height=n.float();continue;case 3:if(29!==e)break;r.depth=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({width:aS(e.width)?globalThis.Number(e.width):0,height:aS(e.height)?globalThis.Number(e.height):0,depth:aS(e.depth)?globalThis.Number(e.depth):0}),toJSON(e){const t={};return 0!==e.width&&(t.width=e.width),0!==e.height&&(t.height=e.height),0!==e.depth&&(t.depth=e.depth),t},create:e=>eS.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={width:0,height:0,depth:0};return r.width=null!==(t=e.width)&&void 0!==t?t:0,r.height=null!==(n=e.height)&&void 0!==n?n:0,r.depth=null!==(i=e.depth)&&void 0!==i?i:0,r}};const tS={encode:(e,t=new qw)=>(0!==e.x&&t.uint32(13).float(e.x),0!==e.y&&t.uint32(21).float(e.y),0!==e.z&&t.uint32(29).float(e.z),0!==e.w&&t.uint32(37).float(e.w),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={x:0,y:0,z:0,w:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(13!==e)break;r.x=n.float();continue;case 2:if(21!==e)break;r.y=n.float();continue;case 3:if(29!==e)break;r.z=n.float();continue;case 4:if(37!==e)break;r.w=n.float();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({x:aS(e.x)?globalThis.Number(e.x):0,y:aS(e.y)?globalThis.Number(e.y):0,z:aS(e.z)?globalThis.Number(e.z):0,w:aS(e.w)?globalThis.Number(e.w):0}),toJSON(e){const t={};return 0!==e.x&&(t.x=e.x),0!==e.y&&(t.y=e.y),0!==e.z&&(t.z=e.z),0!==e.w&&(t.w=e.w),t},create:e=>tS.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i,r;const a={x:0,y:0,z:0,w:0};return a.x=null!==(t=e.x)&&void 0!==t?t:0,a.y=null!==(n=e.y)&&void 0!==n?n:0,a.z=null!==(i=e.z)&&void 0!==i?i:0,a.w=null!==(r=e.w)&&void 0!==r?r:0,a}};const nS={encode:(e,t=new qw)=>(void 0!==e.offset&&Qw.encode(e.offset,t.uint32(10).fork()).join(),void 0!==e.extent&&Zw.encode(e.extent,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={offset:void 0,extent:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.offset=Qw.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.extent=Zw.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({offset:aS(e.offset)?Qw.fromJSON(e.offset):void 0,extent:aS(e.extent)?Zw.fromJSON(e.extent):void 0}),toJSON(e){const t={};return void 0!==e.offset&&(t.offset=Qw.toJSON(e.offset)),void 0!==e.extent&&(t.extent=Zw.toJSON(e.extent)),t},create:e=>nS.fromPartial(null!=e?e:{}),fromPartial(e){const t={offset:void 0,extent:void 0};return t.offset=void 0!==e.offset&&null!==e.offset?Qw.fromPartial(e.offset):void 0,t.extent=void 0!==e.extent&&null!==e.extent?Zw.fromPartial(e.extent):void 0,t}};const iS={encode:(e,t=new qw)=>(void 0!==e.offset&&Jw.encode(e.offset,t.uint32(10).fork()).join(),void 0!==e.extent&&eS.encode(e.extent,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={offset:void 0,extent:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.offset=Jw.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.extent=eS.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({offset:aS(e.offset)?Jw.fromJSON(e.offset):void 0,extent:aS(e.extent)?eS.fromJSON(e.extent):void 0}),toJSON(e){const t={};return void 0!==e.offset&&(t.offset=Jw.toJSON(e.offset)),void 0!==e.extent&&(t.extent=eS.toJSON(e.extent)),t},create:e=>iS.fromPartial(null!=e?e:{}),fromPartial(e){const t={offset:void 0,extent:void 0};return t.offset=void 0!==e.offset&&null!==e.offset?Jw.fromPartial(e.offset):void 0,t.extent=void 0!==e.extent&&null!==e.extent?eS.fromPartial(e.extent):void 0,t}};const rS={encode:(e,t=new qw)=>(void 0!==e.orientation&&tS.encode(e.orientation,t.uint32(10).fork()).join(),void 0!==e.position&&Jw.encode(e.position,t.uint32(18).fork()).join(),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={orientation:void 0,position:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.orientation=tS.decode(n,n.uint32());continue;case 2:if(18!==e)break;r.position=Jw.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({orientation:aS(e.orientation)?tS.fromJSON(e.orientation):void 0,position:aS(e.position)?Jw.fromJSON(e.position):void 0}),toJSON(e){const t={};return void 0!==e.orientation&&(t.orientation=tS.toJSON(e.orientation)),void 0!==e.position&&(t.position=Jw.toJSON(e.position)),t},create:e=>rS.fromPartial(null!=e?e:{}),fromPartial(e){const t={orientation:void 0,position:void 0};return t.orientation=void 0!==e.orientation&&null!==e.orientation?tS.fromPartial(e.orientation):void 0,t.position=void 0!==e.position&&null!==e.position?Jw.fromPartial(e.position):void 0,t}};function aS(e){return null!=e}var sS,oS;function lS(e){switch(e){case 0:case"Keyboard":return sS.Keyboard;default:return sS.UNRECOGNIZED}}function cS(e){switch(e){case 0:case"UNKNOWN":return oS.UNKNOWN;case 1:case"FLOOR":return oS.FLOOR;case 2:case"CEILING":return oS.CEILING;case 3:case"WALL_FACE":return oS.WALL_FACE;case 4:case"TABLE":return oS.TABLE;case 5:case"COUCH":return oS.COUCH;case 6:case"DOOR_FRAME":return oS.DOOR_FRAME;case 7:case"WINDOW_FRAME":return oS.WINDOW_FRAME;case 8:case"OTHER":return oS.OTHER;case 9:case"STORAGE":return oS.STORAGE;case 10:case"BED":return oS.BED;case 11:case"SCREEN":return oS.SCREEN;case 12:case"LAMP":return oS.LAMP;case 13:case"PLANT":return oS.PLANT;case 14:case"WALL_ART":return oS.WALL_ART;case 15:case"GLOBAL_MESH":return oS.GLOBAL_MESH;case 16:case"INVISIBLE_WALL_FACE":return oS.INVISIBLE_WALL_FACE;case 17:case"CHAIR":return oS.CHAIR;case 18:case"INNER_WALL_FACE":return oS.INNER_WALL_FACE;case 19:case"OTHER_ROOM_FACE":return oS.OTHER_ROOM_FACE;case 20:case"OPENING":return oS.OPENING;default:return oS.UNRECOGNIZED}}function uS(e){switch(e){case oS.UNKNOWN:return"UNKNOWN";case oS.FLOOR:return"FLOOR";case oS.CEILING:return"CEILING";case oS.WALL_FACE:return"WALL_FACE";case oS.TABLE:return"TABLE";case oS.COUCH:return"COUCH";case oS.DOOR_FRAME:return"DOOR_FRAME";case oS.WINDOW_FRAME:return"WINDOW_FRAME";case oS.OTHER:return"OTHER";case oS.STORAGE:return"STORAGE";case oS.BED:return"BED";case oS.SCREEN:return"SCREEN";case oS.LAMP:return"LAMP";case oS.PLANT:return"PLANT";case oS.WALL_ART:return"WALL_ART";case oS.GLOBAL_MESH:return"GLOBAL_MESH";case oS.INVISIBLE_WALL_FACE:return"INVISIBLE_WALL_FACE";case oS.CHAIR:return"CHAIR";case oS.INNER_WALL_FACE:return"INNER_WALL_FACE";case oS.OTHER_ROOM_FACE:return"OTHER_ROOM_FACE";case oS.OPENING:return"OPENING";case oS.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.Keyboard=0]="Keyboard",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(sS||(sS={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.FLOOR=1]="FLOOR",e[e.CEILING=2]="CEILING",e[e.WALL_FACE=3]="WALL_FACE",e[e.TABLE=4]="TABLE",e[e.COUCH=5]="COUCH",e[e.DOOR_FRAME=6]="DOOR_FRAME",e[e.WINDOW_FRAME=7]="WINDOW_FRAME",e[e.OTHER=8]="OTHER",e[e.STORAGE=9]="STORAGE",e[e.BED=10]="BED",e[e.SCREEN=11]="SCREEN",e[e.LAMP=12]="LAMP",e[e.PLANT=13]="PLANT",e[e.WALL_ART=14]="WALL_ART",e[e.GLOBAL_MESH=15]="GLOBAL_MESH",e[e.INVISIBLE_WALL_FACE=16]="INVISIBLE_WALL_FACE",e[e.CHAIR=17]="CHAIR",e[e.INNER_WALL_FACE=18]="INNER_WALL_FACE",e[e.OTHER_ROOM_FACE=19]="OTHER_ROOM_FACE",e[e.OPENING=20]="OPENING",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(oS||(oS={}));const dS={encode(e,t=new qw){""!==e.floorUuid&&t.uint32(10).string(e.floorUuid),""!==e.ceilingUuid&&t.uint32(18).string(e.ceilingUuid);for(const n of e.wallUuids)t.uint32(26).string(n);return t},decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={floorUuid:"",ceilingUuid:"",wallUuids:[]};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.floorUuid=n.string();continue;case 2:if(18!==e)break;r.ceilingUuid=n.string();continue;case 3:if(26!==e)break;r.wallUuids.push(n.string());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({floorUuid:_S(e.floorUuid)?globalThis.String(e.floorUuid):"",ceilingUuid:_S(e.ceilingUuid)?globalThis.String(e.ceilingUuid):"",wallUuids:globalThis.Array.isArray(null==e?void 0:e.wallUuids)?e.wallUuids.map(e=>globalThis.String(e)):[]}),toJSON(e){var t;const n={};return""!==e.floorUuid&&(n.floorUuid=e.floorUuid),""!==e.ceilingUuid&&(n.ceilingUuid=e.ceilingUuid),(null===(t=e.wallUuids)||void 0===t?void 0:t.length)&&(n.wallUuids=e.wallUuids),n},create:e=>dS.fromPartial(null!=e?e:{}),fromPartial(e){var t,n,i;const r={floorUuid:"",ceilingUuid:"",wallUuids:[]};return r.floorUuid=null!==(t=e.floorUuid)&&void 0!==t?t:"",r.ceilingUuid=null!==(n=e.ceilingUuid)&&void 0!==n?n:"",r.wallUuids=(null===(i=e.wallUuids)||void 0===i?void 0:i.map(e=>e))||[],r}};const hS={encode(e,t=new qw){for(const n of e.uuids)t.uint32(10).string(n);return t},decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={uuids:[]};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.uuids.push(n.string());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({uuids:globalThis.Array.isArray(null==e?void 0:e.uuids)?e.uuids.map(e=>globalThis.String(e)):[]}),toJSON(e){var t;const n={};return(null===(t=e.uuids)||void 0===t?void 0:t.length)&&(n.uuids=e.uuids),n},create:e=>hS.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n={uuids:[]};return n.uuids=(null===(t=e.uuids)||void 0===t?void 0:t.map(e=>e))||[],n}};function pS(){return{vertices:new Uint8Array(0)}}const fS={encode:(e,t=new qw)=>(0!==e.vertices.length&&t.uint32(10).bytes(e.vertices),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r=pS();for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.vertices=n.bytes();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({vertices:_S(e.vertices)?xS(e.vertices):new Uint8Array(0)}),toJSON(e){const t={};return 0!==e.vertices.length&&(t.vertices=bS(e.vertices)),t},create:e=>fS.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n=pS();return n.vertices=null!==(t=e.vertices)&&void 0!==t?t:new Uint8Array(0),n}};function mS(){return{vertices:new Uint8Array(0),indices:new Uint8Array(0)}}const gS={encode:(e,t=new qw)=>(0!==e.vertices.length&&t.uint32(10).bytes(e.vertices),0!==e.indices.length&&t.uint32(18).bytes(e.indices),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r=mS();for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.vertices=n.bytes();continue;case 2:if(18!==e)break;r.indices=n.bytes();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({vertices:_S(e.vertices)?xS(e.vertices):new Uint8Array(0),indices:_S(e.indices)?xS(e.indices):new Uint8Array(0)}),toJSON(e){const t={};return 0!==e.vertices.length&&(t.vertices=bS(e.vertices)),0!==e.indices.length&&(t.indices=bS(e.indices)),t},create:e=>gS.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i=mS();return i.vertices=null!==(t=e.vertices)&&void 0!==t?t:new Uint8Array(0),i.indices=null!==(n=e.indices)&&void 0!==n?n:new Uint8Array(0),i}};const vS={encode:(e,t=new qw)=>(0!==e.classType&&t.uint32(8).int32(e.classType),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={classType:0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(8!==e)break;r.classType=n.int32();continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({classType:_S(e.classType)?lS(e.classType):0}),toJSON(e){const t={};return 0!==e.classType&&(t.classType=function(e){switch(e){case sS.Keyboard:return"Keyboard";case sS.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.classType)),t},create:e=>vS.fromPartial(null!=e?e:{}),fromPartial(e){var t;const n={classType:0};return n.classType=null!==(t=e.classType)&&void 0!==t?t:0,n}};const yS={encode:(e,t=new qw)=>(""!==e.uuid&&t.uint32(10).string(e.uuid),void 0!==e.semanticLabel_META&&t.uint32(16).int32(e.semanticLabel_META),void 0!==e.locatable_META&&rS.encode(e.locatable_META,t.uint32(26).fork()).join(),void 0!==e.boundary2D_META&&fS.encode(e.boundary2D_META,t.uint32(34).fork()).join(),void 0!==e.bounded2D_META&&nS.encode(e.bounded2D_META,t.uint32(42).fork()).join(),void 0!==e.bounded3D_META&&iS.encode(e.bounded3D_META,t.uint32(50).fork()).join(),void 0!==e.roomLayout_META&&dS.encode(e.roomLayout_META,t.uint32(58).fork()).join(),void 0!==e.spaceContainer_META&&hS.encode(e.spaceContainer_META,t.uint32(66).fork()).join(),void 0!==e.triangleMesh_META&&gS.encode(e.triangleMesh_META,t.uint32(74).fork()).join(),void 0!==e.dynamicObject_META&&vS.encode(e.dynamicObject_META,t.uint32(82).fork()).join(),t),decode(e,t){const n=e instanceof $w?e:new $w(e);let i=void 0===t?n.len:n.pos+t;const r={uuid:"",semanticLabel_META:void 0,locatable_META:void 0,boundary2D_META:void 0,bounded2D_META:void 0,bounded3D_META:void 0,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:void 0,dynamicObject_META:void 0};for(;n.pos<i;){const e=n.uint32();switch(e>>>3){case 1:if(10!==e)break;r.uuid=n.string();continue;case 2:if(16!==e)break;r.semanticLabel_META=n.int32();continue;case 3:if(26!==e)break;r.locatable_META=rS.decode(n,n.uint32());continue;case 4:if(34!==e)break;r.boundary2D_META=fS.decode(n,n.uint32());continue;case 5:if(42!==e)break;r.bounded2D_META=nS.decode(n,n.uint32());continue;case 6:if(50!==e)break;r.bounded3D_META=iS.decode(n,n.uint32());continue;case 7:if(58!==e)break;r.roomLayout_META=dS.decode(n,n.uint32());continue;case 8:if(66!==e)break;r.spaceContainer_META=hS.decode(n,n.uint32());continue;case 9:if(74!==e)break;r.triangleMesh_META=gS.decode(n,n.uint32());continue;case 10:if(82!==e)break;r.dynamicObject_META=vS.decode(n,n.uint32());continue}if(4==(7&e)||0===e)break;n.skip(7&e)}return r},fromJSON:e=>({uuid:_S(e.uuid)?globalThis.String(e.uuid):"",semanticLabel_META:_S(e.semanticLabel_META)?cS(e.semanticLabel_META):void 0,locatable_META:_S(e.locatable_META)?rS.fromJSON(e.locatable_META):void 0,boundary2D_META:_S(e.boundary2D_META)?fS.fromJSON(e.boundary2D_META):void 0,bounded2D_META:_S(e.bounded2D_META)?nS.fromJSON(e.bounded2D_META):void 0,bounded3D_META:_S(e.bounded3D_META)?iS.fromJSON(e.bounded3D_META):void 0,roomLayout_META:_S(e.roomLayout_META)?dS.fromJSON(e.roomLayout_META):void 0,spaceContainer_META:_S(e.spaceContainer_META)?hS.fromJSON(e.spaceContainer_META):void 0,triangleMesh_META:_S(e.triangleMesh_META)?gS.fromJSON(e.triangleMesh_META):void 0,dynamicObject_META:_S(e.dynamicObject_META)?vS.fromJSON(e.dynamicObject_META):void 0}),toJSON(e){const t={};return""!==e.uuid&&(t.uuid=e.uuid),void 0!==e.semanticLabel_META&&(t.semanticLabel_META=uS(e.semanticLabel_META)),void 0!==e.locatable_META&&(t.locatable_META=rS.toJSON(e.locatable_META)),void 0!==e.boundary2D_META&&(t.boundary2D_META=fS.toJSON(e.boundary2D_META)),void 0!==e.bounded2D_META&&(t.bounded2D_META=nS.toJSON(e.bounded2D_META)),void 0!==e.bounded3D_META&&(t.bounded3D_META=iS.toJSON(e.bounded3D_META)),void 0!==e.roomLayout_META&&(t.roomLayout_META=dS.toJSON(e.roomLayout_META)),void 0!==e.spaceContainer_META&&(t.spaceContainer_META=hS.toJSON(e.spaceContainer_META)),void 0!==e.triangleMesh_META&&(t.triangleMesh_META=gS.toJSON(e.triangleMesh_META)),void 0!==e.dynamicObject_META&&(t.dynamicObject_META=vS.toJSON(e.dynamicObject_META)),t},create:e=>yS.fromPartial(null!=e?e:{}),fromPartial(e){var t,n;const i={uuid:"",semanticLabel_META:void 0,locatable_META:void 0,boundary2D_META:void 0,bounded2D_META:void 0,bounded3D_META:void 0,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:void 0,dynamicObject_META:void 0};return i.uuid=null!==(t=e.uuid)&&void 0!==t?t:"",i.semanticLabel_META=null!==(n=e.semanticLabel_META)&&void 0!==n?n:void 0,i.locatable_META=void 0!==e.locatable_META&&null!==e.locatable_META?rS.fromPartial(e.locatable_META):void 0,i.boundary2D_META=void 0!==e.boundary2D_META&&null!==e.boundary2D_META?fS.fromPartial(e.boundary2D_META):void 0,i.bounded2D_META=void 0!==e.bounded2D_META&&null!==e.bounded2D_META?nS.fromPartial(e.bounded2D_META):void 0,i.bounded3D_META=void 0!==e.bounded3D_META&&null!==e.bounded3D_META?iS.fromPartial(e.bounded3D_META):void 0,i.roomLayout_META=void 0!==e.roomLayout_META&&null!==e.roomLayout_META?dS.fromPartial(e.roomLayout_META):void 0,i.spaceContainer_META=void 0!==e.spaceContainer_META&&null!==e.spaceContainer_META?hS.fromPartial(e.spaceContainer_META):void 0,i.triangleMesh_META=void 0!==e.triangleMesh_META&&null!==e.triangleMesh_META?gS.fromPartial(e.triangleMesh_META):void 0,i.dynamicObject_META=void 0!==e.dynamicObject_META&&null!==e.dynamicObject_META?vS.fromPartial(e.dynamicObject_META):void 0,i}};function xS(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const t=globalThis.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}}function bS(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{const t=[];return e.forEach(e=>{t.push(globalThis.String.fromCharCode(e))}),globalThis.btoa(t.join(""))}}function _S(e){return null!=e}var wS,SS;!function(e){e.Locatable="locatable",e.Bounded3D="bounded3D",e.Bounded2D="bounded2D",e.TriangleMesh="triangleMesh",e.SemanticLabel="semanticLabel"}(wS||(wS={}));class ES extends EventTarget{constructor(e){super(),this._spatialEntity=e}}class MS extends ES{constructor(e,t){super(e),this._offset=new Dh,this._extent=new Dh,this.type=wS.Bounded2D;const{offset:n,extent:i}=t;this._offset.set(n.x,n.y),this._extent.set(i.width,i.height),this.buildGeometry()}buildGeometry(){var e;const t=new Km(this._extent.x,this._extent.y);t.translate(this._offset.x+this._extent.x/2,this._offset.y+this._extent.y/2,0),t.rotateX(Math.PI/2),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t}get offset(){return this._offset}get extent(){return this._extent}get initData(){return{offset:this.offset,extent:this.extent}}get pbData(){return{offset:{x:this._offset.x,y:this._offset.y},extent:{width:this._extent.x,height:this._extent.y}}}}class TS extends ES{constructor(e,t){super(e),this._offset=new kh,this._extent=new kh,this.type=wS.Bounded3D;const{offset:n,extent:i}=t;this._offset.set(n.x,n.y,n.z),this._extent.set(i.width,i.height,i.depth),this.buildGeometry()}buildGeometry(){var e;const t=new rm(this._extent.x,this._extent.y,this._extent.z);t.translate(this._offset.x+this._extent.x/2,this._offset.y+this._extent.y/2,this._offset.z+this._extent.z/2),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t}get offset(){return this._offset}get extent(){return this._extent}get initData(){return{offset:this.offset,extent:this.extent}}get pbData(){return{offset:{x:this._offset.x,y:this._offset.y,z:this._offset.z},extent:{width:this._extent.x,height:this._extent.y,depth:this._extent.z}}}}class AS extends ES{constructor(e,t){super(e),this.type=wS.Locatable,t.position&&this.position.copy(t.position),t.orientation&&this.orientation.copy(t.orientation)}get position(){return this._spatialEntity.position}get rotation(){return this._spatialEntity.rotation}get orientation(){return this._spatialEntity.quaternion}get initData(){return{position:{x:this.position.x,y:this.position.y,z:this.position.z},orientation:{x:this.orientation.x,y:this.orientation.y,z:this.orientation.z,w:this.orientation.w}}}get pbData(){return{position:{x:this._spatialEntity.position.x,y:this._spatialEntity.position.y,z:this._spatialEntity.position.z},orientation:{x:this._spatialEntity.quaternion.x,y:this._spatialEntity.quaternion.y,z:this._spatialEntity.quaternion.z,w:this._spatialEntity.quaternion.w}}}}function RS(e){return e.toLowerCase().replace(/_/g," ").trim()}class PS extends ES{constructor(e,t){super(e),this._semanticLabel=t,this.type=wS.SemanticLabel,this._spatialEntity.name=RS(uS(t))}get semanticLabel(){return this._semanticLabel}set semanticLabel(e){Object.values(oS).includes(e)?this._semanticLabel=e:this._semanticLabel=oS.UNRECOGNIZED,this._spatialEntity.name=RS(uS(this._semanticLabel))}get initData(){return this._semanticLabel}get pbData(){return this._semanticLabel}}class CS extends ES{constructor(e,t){super(e),this._polygonCount=0,this._vertexCount=0,this._dimensions={x:0,y:0,z:0},this.type=wS.TriangleMesh;const{vertices:n,indices:i}=t,r=new Uint32Array(i.buffer);this._vertices=new Float32Array(n.buffer),this._indices=[...r],this.buildGeometry();const a=e.material;a.polygonOffset=!0,a.polygonOffsetFactor=1,a.polygonOffsetUnits=.005,a.color.setHex(13948116),e.renderOrder=999}buildGeometry(){var e;const t=new Wf;t.setAttribute("position",new Df(this._vertices,3));const n=this._indices.reduce((e,t)=>t>e?t:e,0),i=n<65536?new Uint16Array(this._indices):new Uint32Array(this._indices);t.setIndex(new Df(i,1)),null===(e=this._spatialEntity.geometry)||void 0===e||e.dispose(),this._spatialEntity.geometry=t,t.computeVertexNormals(),this._vertexCount=t.attributes.position.count,this._polygonCount=t.index?t.index.count/3:this._vertexCount/3,t.computeBoundingBox();const r=t.boundingBox;this._dimensions={x:r.max.x-r.min.x,y:r.max.y-r.min.y,z:r.max.z-r.min.z}}get vertexCount(){return this._vertexCount}get polygonCount(){return this._polygonCount}get dimensions(){return this._dimensions}get initData(){const e=[];for(let t=0;t<this._vertices.length/3;t++)e.push({x:this._vertices[3*t],y:this._vertices[3*t+1],z:this._vertices[3*t+2]});return{vertices:e,indices:this._indices}}get pbData(){const e=new Uint32Array(this._indices);return{vertices:new Uint8Array(this._vertices.buffer),indices:new Uint8Array(e.buffer)}}}!function(e){e.Plane="plane",e.Box="box",e.Mesh="mesh"}(SS||(SS={}));const LS=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return t>>>0&16777215},IS={[oS.OTHER]:Ps.Other,[oS.TABLE]:Ps.Table,[oS.COUCH]:Ps.Couch,[oS.FLOOR]:Ps.Floor,[oS.CEILING]:Ps.Ceiling,[oS.WALL_FACE]:Ps.Wall,[oS.INVISIBLE_WALL_FACE]:Ps.Window,[oS.INNER_WALL_FACE]:Ps.Wall,[oS.DOOR_FRAME]:Ps.Door,[oS.WINDOW_FRAME]:Ps.Window,[oS.WALL_ART]:Ps.WallArt,[oS.STORAGE]:Ps.Shelf,[oS.BED]:Ps.Bed,[oS.LAMP]:Ps.Lamp,[oS.SCREEN]:Ps.Screen,[oS.PLANT]:Ps.Plant,[oS.GLOBAL_MESH]:Ps.GlobalMesh,[oS.CHAIR]:Ps.Couch,[oS.UNKNOWN]:Ps.Other,[oS.OTHER_ROOM_FACE]:Ps.Other,[oS.OPENING]:Ps.Other,[oS.UNRECOGNIZED]:Ps.Other};class DS extends nm{constructor(e=function(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(nx[255&e]+nx[e>>8&255]+nx[e>>16&255]+nx[e>>24&255]+"-"+nx[255&t]+nx[t>>8&255]+"-"+nx[t>>16&15|64]+nx[t>>24&255]+"-"+nx[63&n|128]+nx[n>>8&255]+"-"+nx[n>>16&255]+nx[n>>24&255]+nx[255&i]+nx[i>>8&255]+nx[i>>16&255]+nx[i>>24&255]).toLowerCase()}()){super(void 0,new ng({color:LS(e),flatShading:!0})),this.name="generic spatial entity",this.isSpatialEntity=!0,this._componentMap=new Map,this._spatialUUID=e}get spatialUUID(){return this._spatialUUID}updateMatrixWorld(e){super.updateMatrixWorld(e)}addComponent(e,t){let n=null;switch(e){case wS.Locatable:n=new AS(this,t);break;case wS.Bounded3D:n=new TS(this,t);break;case wS.Bounded2D:n=new MS(this,t);break;case wS.TriangleMesh:n=new CS(this,t);break;case wS.SemanticLabel:n=new PS(this,t)}n&&this._componentMap.set(e,n)}getComponent(e){return this._componentMap.get(e)}duplicate(){const e=new DS;return this._componentMap.forEach((t,n,i)=>{e.addComponent(t.type,t.initData)}),e}get nativeEntity(){if(!this._nativeEntity){const e=new Hs({x:this.position.x,y:this.position.y,z:this.position.z,w:1},{x:this.quaternion.x,y:this.quaternion.y,z:this.quaternion.z,w:this.quaternion.w}),t=IS[this.getComponent(wS.SemanticLabel).semanticLabel];if(this.entityType===SS.Plane){const{offset:n,extent:i}=this.getComponent(wS.Bounded2D),r=[new DOMPointReadOnly(n.x,0,n.y),new DOMPointReadOnly(n.x+i.x,0,n.y),new DOMPointReadOnly(n.x+i.x,0,n.y+i.y),new DOMPointReadOnly(n.x,0,n.y+i.y),new DOMPointReadOnly(n.x,0,n.y)];this._nativeEntity=new Ns(e,r,t)}else if(this.entityType===SS.Box||this.entityType===SS.Mesh){const n=this.geometry.getAttribute("position").array,i=new Uint32Array(this.geometry.index.array);this._nativeEntity=new Rs(e,n,i,t)}}return this._nativeEntity}static fromPBJSON(e){const t=yS.fromJSON(e);if(t.locatable_META){const e=new DS(t.uuid);return e.addComponent(wS.Locatable,t.locatable_META),t.semanticLabel_META&&e.addComponent(wS.SemanticLabel,t.semanticLabel_META),t.bounded2D_META?(e.addComponent(wS.Bounded2D,t.bounded2D_META),e._entityType=SS.Plane):t.bounded3D_META?(e.addComponent(wS.Bounded3D,t.bounded3D_META),e._entityType=SS.Box):t.triangleMesh_META&&(e.addComponent(wS.TriangleMesh,t.triangleMesh_META),e._entityType=SS.Mesh),e}}get entityType(){return void 0!==this._entityType?this._entityType:this.getComponent(wS.Bounded2D)?SS.Plane:this.getComponent(wS.Bounded3D)?SS.Box:this.getComponent(wS.TriangleMesh)?SS.Mesh:void 0}static toPBJSON(e){var t,n,i,r,a;return{uuid:e.spatialUUID,locatable_META:null===(t=e.getComponent(wS.Locatable))||void 0===t?void 0:t.pbData,boundary2D_META:void 0,bounded2D_META:null===(n=e.getComponent(wS.Bounded2D))||void 0===n?void 0:n.pbData,bounded3D_META:null===(i=e.getComponent(wS.Bounded3D))||void 0===i?void 0:i.pbData,semanticLabel_META:null===(r=e.getComponent(wS.SemanticLabel))||void 0===r?void 0:r.pbData,roomLayout_META:void 0,spaceContainer_META:void 0,triangleMesh_META:null===(a=e.getComponent(wS.TriangleMesh))||void 0===a?void 0:a.pbData,dynamicObject_META:void 0}}}const NS=256**3;function kS(e,t,n,i){return e/256+t/65536+n/NS+i/4278190080}function FS(e,t,n){return e>=1||e<=0?n:t*n/(n-e*(n-t))}const OS="2.5.0",US=new kh(0,0,-1),zS=new Mf;class BS extends EventTarget{constructor(e){super(),this.xrDevice=e,this.trackedPlanes=new Set,this.trackedMeshes=new Set,this.version=OS,this.objectMap=new Map,this.planes=new xm,this.boxes=new xm,this.meshes=new xm,this.tempPosition=new kh,this.tempQuaternion=new Nh,this.tempDirection=new kh,this.tempScale=new kh,this.tempMatrix=new Ip,this.raycaster=new sg,this.hitTestTarget=new xm,this.hitTestMarker=new sf,this.worldNormal=new kh,this.normalMatrix=new Uh,this.depthRenderTarget=null,this.depthMaterial=new eg({depthPacking:3201,side:2}),this._tempMatrix=new Ip,this.depthReadBuffer=null,this.scene=new wm,this.scene.background=new Mf(4079166),this.camera=new fm(50,window.innerWidth/window.innerHeight,.1,40),this.camera.position.set(0,1.6,5);const t=new gg(50,50);this.scene.add(t),this.scene.add(this.planes,this.boxes,this.meshes),this.planes.renderOrder=1,this.boxes.renderOrder=2,this.meshes.renderOrder=3,this.planes.visible=!1,this.boxes.visible=!1,this.renderer=new tx({antialias:!0,alpha:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.domElement.style.position="fixed",this.renderer.domElement.style.top="50vh",this.renderer.domElement.style.left="50vw",this.renderer.domElement.style.transform="translate(-50%, -50%)",this.hitTestTarget.add(this.hitTestMarker),this.hitTestMarker.rotateX(Math.PI/2),this.depthCamera=new um}get environmentCanvas(){return this.renderer.domElement}get planesVisible(){return this.planes.visible}set planesVisible(e){this.planes.visible=e}get boundingBoxesVisible(){return this.boxes.visible}set boundingBoxesVisible(e){this.boxes.visible=e}get meshesVisible(){return this.meshes.visible}set meshesVisible(e){this.meshes.visible=e}render(){this.camera.position.copy(this.xrDevice.position),this.camera.quaternion.copy(this.xrDevice.quaternion);const e=this.xrDevice.fovy/Math.PI*180;let t=!1;this.camera.fov!==e&&(this.camera.fov=e,t=!0);const n=this.xrDevice.canvasDimensions;if(n){const e=this.renderer.domElement;(e.width!==n.width||e.height!==n.height)&&(this.camera.aspect=n.width/n.height,this.renderer.setSize(n.width,n.height),t=!0)}t&&this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera)}deleteAll(){[...this.objectMap.values()].forEach(e=>{e.removeFromParent()}),this.objectMap.clear(),this.trackedMeshes.clear(),this.trackedPlanes.clear()}loadEnvironment(e){this.deleteAll(),e.spatialEntities.forEach(e=>{const t=DS.fromPBJSON(e);if(t){const n=this.objectMap.get(e.uuid);switch(n&&(n.removeFromParent(),this.trackedMeshes.delete(n.nativeEntity),this.trackedPlanes.delete(n.nativeEntity)),t.entityType){case SS.Box:this.boxes.add(t),this.trackedMeshes.add(t.nativeEntity);break;case SS.Plane:this.planes.add(t),this.trackedPlanes.add(t.nativeEntity);break;case SS.Mesh:this.meshes.add(t),this.trackedMeshes.add(t.nativeEntity)}this.objectMap.set(e.uuid,t)}}),this.dispatchEvent(new CustomEvent("environmentchange",{detail:{entityCount:this.objectMap.size}}))}loadDefaultEnvironment(e){return fetch(`https://www.unpkg.com/@iwer/sem@${OS}/captures/${e}.json`).then(e=>{if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);return e.json()}).then(e=>{this.loadEnvironment(e)}).catch(t=>{throw console.error(`Error loading environment ${e} from CDN`,t),t})}computeHitTestResults(e,t){this.tempMatrix.fromArray(e),this.tempMatrix.decompose(this.tempPosition,this.tempQuaternion,this.tempScale),this.tempDirection.copy(US).applyQuaternion(this.tempQuaternion).normalize(),this.raycaster.set(this.tempPosition,this.tempDirection);const n=[];t&&!t.includes("mesh")||n.push(this.meshes,this.boxes),t&&!t.includes("plane")||n.push(this.planes);const i=this.raycaster.intersectObjects(n,!0).map(e=>{var t;const n=e.point;if(this.hitTestTarget.position.copy(n),null===(t=e.face)||void 0===t?void 0:t.normal){this.worldNormal.copy(e.face.normal);const t=e.object;this.worldNormal.applyMatrix3(this.normalMatrix.getNormalMatrix(t.matrixWorld)).normalize(),this.hitTestTarget.lookAt(this.tempPosition.addVectors(n,this.worldNormal))}else this.hitTestTarget.quaternion.set(0,0,0,1);return this.hitTestTarget.updateMatrixWorld(!0),this.hitTestMarker.matrixWorld.toArray()});return i}computeDepthBuffer(e,t,n,i,r,a){var s;if(0===this.trackedMeshes.size)return null;this.depthRenderTarget&&this.depthRenderTarget.width===n&&this.depthRenderTarget.height===i||(null===(s=this.depthRenderTarget)||void 0===s||s.dispose(),this.depthRenderTarget=new np(n,i),this.depthReadBuffer=new Uint8Array(n*i*4)),this._tempMatrix.fromArray(e),this._tempMatrix.invert(),this._tempMatrix.decompose(this.depthCamera.position,this.depthCamera.quaternion,this.depthCamera.scale),this.depthCamera.projectionMatrix.fromArray(t),this.depthCamera.projectionMatrixInverse.copy(this.depthCamera.projectionMatrix).invert();const o=this.meshes.visible,l=this.boxes.visible;this.meshes.visible=!0,this.boxes.visible=!0;const c=this.scene.overrideMaterial,u=this.scene.background;this.scene.overrideMaterial=this.depthMaterial,this.scene.background=null,this.renderer.setRenderTarget(this.depthRenderTarget);const d=this.renderer.getClearColor(zS),h=this.renderer.getClearAlpha();this.renderer.setClearColor(0,0),this.renderer.clear(),this.renderer.setClearColor(d,h),this.renderer.render(this.scene,this.depthCamera),this.renderer.setRenderTarget(null),this.scene.overrideMaterial=c,this.scene.background=u,this.meshes.visible=o,this.boxes.visible=l,this.renderer.readRenderTargetPixels(this.depthRenderTarget,0,0,n,i,this.depthReadBuffer);const p=new ArrayBuffer(n*i*4),f=new Float32Array(p),m=this.depthReadBuffer;for(let e=0;e<i;e++){const t=i-1-e;for(let i=0;i<n;i++){const s=t*n+i,o=e*n+i,l=kS(m[4*s],m[4*s+1],m[4*s+2],m[4*s+3]);f[o]=FS(l,r,a)}}return{data:p,width:n,height:i,rawValueToMeters:1}}}const VS=["code","details","issues","lifecycle","recoverable","retryAction"];class HS{constructor(e,t={}){this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=Number.POSITIVE_INFINITY,this.reconnectDelay=1e3,this.maxReconnectDelay=5e3,this.reconnectTimer=null,this.connectTimer=null,this.connectTimeoutMs=1e4,this.intentionalDisconnect=!1,this.runtimeReadyListener=()=>this.announceCommandReady(),this.device=e,this.verbose=t.verbose??!1,this.pageRole=this.detectPageRole(),this.deviceClass=t.deviceClass??"managed",this.sceneSessionId="undefined"!=typeof window?window.__IWSDK_SCENE_SESSION_ID:void 0;const n=`iwer-mcp-tab-id:${this.pageRole}`,i=`iwer-mcp-gen:${this.pageRole}`;let r="undefined"!=typeof sessionStorage?sessionStorage.getItem(n):null;r||(r=`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,"undefined"!=typeof sessionStorage&&sessionStorage.setItem(n,r)),this.tabId=r;const a="undefined"!=typeof sessionStorage?parseInt(sessionStorage.getItem(i)||"0",10)+1:1;if("undefined"!=typeof sessionStorage&&sessionStorage.setItem(i,String(a)),this.tabGeneration=a,"undefined"!=typeof window){try{const e=window.location.href,t=e.replace(/^[^#]*/u,e=>{const t=e.indexOf("?");return-1===t?e:e.slice(0,t)+e.slice(t).replace(/^\?__iwsdk_reload=[^&]*$|&__iwsdk_reload=[^&]*$/u,"")});t!==e&&window.history.replaceState(window.history.state,"",t)}catch{}window.__IWSDK_MCP_PAGE_ID=this.tabId,window.__IWSDK_MCP_PAGE_ROLE=this.pageRole,window.__IWSDK_MCP_TAB_GENERATION=this.tabGeneration,"function"==typeof window.addEventListener&&window.addEventListener("iwsdk:mcp-runtime-ready",this.runtimeReadyListener)}}get connected(){return this.ws?.readyState===WebSocket.OPEN}get connectionState(){return null==this.ws||this.ws.readyState===WebSocket.CLOSED?"disconnected":this.ws.readyState===WebSocket.OPEN?"connected":this.ws.readyState===WebSocket.CLOSING?"closing":"connecting"}isTraceEnabled(){return this.verbose||"undefined"!=typeof window&&!0===window.__IWSDK_MCP_TRACE}detectPageRole(){if("undefined"==typeof window)return"app";const e=window.__IWSDK_MCP_PAGE_ROLE;if("app"===e||"editor"===e||"preview"===e)return e;const t=window.location.pathname??"";return t.startsWith("/__iwsdk/editor")||t.startsWith("/__iwsdk/workspace")?"editor":"app"}trace(e,t={}){this.isTraceEnabled()&&console.log(`[IWSDK-MCP-TRACE] ${e} ${JSON.stringify({...t,tabId:this.tabId,tabGeneration:this.tabGeneration})}`)}connect(e){if(null!==this.ws)return;this.intentionalDisconnect=!1;const t=e??this.getVitePort(),n=`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.hostname||"localhost"}:${t}/__iwer_mcp`;this.verbose&&console.log("[IWSDK-MCP] Connecting to:",n),this.trace("client_connect_start",{wsUrl:n,reconnectAttempts:this.reconnectAttempts});try{const e=new WebSocket(n);this.ws=e,this.setupEventHandlers(e),this.connectTimer=setTimeout(()=>{if(this.ws===e&&e.readyState===WebSocket.CONNECTING){this.trace("client_connect_timeout",{timeoutMs:this.connectTimeoutMs}),this.detachEventHandlers(e),this.ws=null;try{e.close()}catch{}this.clearConnectTimer(),this.intentionalDisconnect||this.scheduleReconnect()}},this.connectTimeoutMs)}catch(e){console.error("[IWSDK-MCP] Failed to create WebSocket:",e),this.ws=null,this.scheduleReconnect()}}disconnect(){if(this.intentionalDisconnect=!0,this.reconnectAttempts=0,null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.clearConnectTimer(),this.ws){const e=this.ws;this.ws=null,this.detachEventHandlers(e);try{e.close()}catch{}}}getVitePort(){return parseInt(window.location.port,10)||5173}setupEventHandlers(e){e.onopen=()=>{this.ws===e&&(this.clearConnectTimer(),this.verbose&&console.log("[IWSDK-MCP] Connected"),this.trace("client_open"),this.reconnectAttempts=0,e.send(JSON.stringify({type:"iwsdk_browser_hello",...window.__IWSDK_RUNTIME_IDENTITY??{},headsetToken:(()=>{if("physical"!==this.deviceClass)return;let e=null;try{e=new URL(window.location.href).searchParams.get("__iwsdk_headset")}catch{}try{return e&&window.sessionStorage.setItem("iwsdk:headset-token",e),e??window.sessionStorage.getItem("iwsdk:headset-token")}catch{return e}})(),commandReady:null!=window.FRAMEWORK_MCP_RUNTIME,deviceClass:this.deviceClass,pageId:this.tabId,pageRole:this.pageRole,role:this.pageRole,sceneSessionId:this.sceneSessionId,tabId:this.tabId,tabGeneration:this.tabGeneration})),this.trace("client_hello_sent"))},e.onclose=t=>{this.ws===e&&(this.clearConnectTimer(),this.verbose&&console.log("[IWSDK-MCP] Disconnected:",t.reason||"Connection closed"),this.trace("client_close",{code:t.code,reason:t.reason||"Connection closed",intentional:this.intentionalDisconnect}),this.ws=null,this.detachEventHandlers(e),this.intentionalDisconnect||this.scheduleReconnect())},e.onerror=t=>{this.ws===e&&(this.trace("client_error",{message:t instanceof ErrorEvent&&t.message?t.message:"WebSocket error"}),console.error("[IWSDK-MCP] WebSocket error:",t))},e.onmessage=async t=>{this.ws===e&&await this.handleMessage(t.data)}}clearConnectTimer(){null!=this.connectTimer&&(clearTimeout(this.connectTimer),this.connectTimer=null)}detachEventHandlers(e){e.onopen=null,e.onclose=null,e.onerror=null,e.onmessage=null}announceCommandReady(){this.ws?.readyState===WebSocket.OPEN&&(this.ws.send(JSON.stringify({type:"iwsdk_browser_ready",pageId:this.tabId,pageRole:this.pageRole,tabGeneration:this.tabGeneration})),this.trace("client_command_ready_sent"))}async handleMessage(e){let t;try{t=JSON.parse(e)}catch{return void console.error("[IWSDK-MCP] Invalid JSON received:",e)}if("string"!=typeof t.id||"string"!=typeof t.method)return void console.error("[IWSDK-MCP] Malformed request (missing id or method):",t);this.verbose&&console.debug("[IWSDK-MCP] Received:",t.method,t.params),this.trace("client_request_received",{id:t.id,method:t.method});const n={id:t.id};try{n.result=await this.dispatch(t.method,t.params??{})}catch(e){n.error=function(e){const t="object"==typeof e&&null!==e?e:null,n={};for(const e of VS)null!=t&&void 0!==t[e]&&(n[e]=t[e]);const i=null!=t&&"string"==typeof t.cause?t.cause:void 0;return{code:null!=t&&"number"==typeof t.code&&Number.isInteger(t.code)?t.code:-32e3,message:e instanceof Error?e.message:String(e),...null==i?{}:{cause:i},...0===Object.keys(n).length?{}:{data:n}}}(e)}this.verbose&&(n.error?console.debug("[IWSDK-MCP] Error:",n.error.message):console.debug("[IWSDK-MCP] Result:",n.result)),this.send(n)}async dispatch(e,t){if("reload_page"===e){await(window.FRAMEWORK_MCP_RUNTIME?.prepareForReload?.());const e=`${Date.now()}-${Math.random().toString(36).slice(2)}`,t=window.location.href.replace(/^[^#]*/u,t=>`${t}${t.includes("?")?"&":"?"}__iwsdk_reload=${e}`);return setTimeout(()=>window.location.replace(t),50),{success:!0,message:"Page reload initiated"}}if(window.FRAMEWORK_MCP_RUNTIME?.handles(e))return window.FRAMEWORK_MCP_RUNTIME.dispatch(e,t);if(null==this.device)throw new Error(`Method "${e}" requires IWER device emulation and is unavailable in this workspace-only page`);return this.device.remote.dispatch(e,t)}send(e){if(this.ws&&this.ws.readyState===WebSocket.OPEN){const t={...e,_tabId:this.tabId,_tabGeneration:this.tabGeneration};this.trace("client_response_sent",{id:e.id,hasError:Boolean(e.error)}),this.ws.send(JSON.stringify(t))}}scheduleReconnect(){if(this.intentionalDisconnect||null!=this.reconnectTimer)return;if(this.reconnectAttempts>=this.maxReconnectAttempts)return void(this.verbose&&console.debug("[IWSDK-MCP] Max reconnect attempts reached"));this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*this.reconnectAttempts,this.maxReconnectDelay);this.verbose&&console.debug(`[IWSDK-MCP] Reconnecting in ${e}ms (attempt ${this.reconnectAttempts})`),this.trace("client_reconnect_scheduled",{delay:e,attempt:this.reconnectAttempts}),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}}function GS(e={}){const t=new HS(null,{verbose:e.verbose,deviceClass:e.deviceClass});return t.connect(e.port),t}const WS={...uc,supportedFeatures:[...uc.supportedFeatures,"gaze-tracking","eye-tracking"]},jS={metaQuest2:oc,metaQuest3:cc,metaQuestPro:lc,metaVRGlasses:WS,oculusQuest1:sc},XS=BS;!function(e){console.log("[IWSDK Dev] Configuration:",e);const t=window.__IWSDK_HOST_BROWSER_ENVIRONMENT??{platform:navigator.userAgentData?.platform||navigator.platform||null,userAgent:navigator.userAgent};window.__IWSDK_HOST_BROWSER_ENVIRONMENT=t,window.__IWSDK_EMULATION_PROFILE={active:!1,device:null,runtime:null},window.__IWSDK_TARGET_DEVICE_PREVIEW__={active:!1,gazeSimulation:!1};const n=!0===window.__IWER_MCP_MANAGED,i=/OculusBrowser/i.test(navigator.userAgent||""),r=e.nativeXRControl,a=!r&&i&&"head"===e.targetDevicePreview?.gazeSimulation,s=new URL(location.href).searchParams.has("__iwsdk_headset")||null!=sessionStorage.getItem("iwsdk:headset-token");if(r&&!i)return void console.error("[IWSDK Dev] Native XR control requires Meta Quest Browser; refusing to replace this browser's native navigator.xr with desktop emulation.");if(e.workspace&&i&&s&&!r&&!a)return void(window.IWER_MCP=GS({deviceClass:"physical",verbose:e.verbose}));if(e.workspace&&!1===e.iwer&&n&&(window.IWER_MCP=GS({verbose:e.verbose})),r||a?!1!==e.iwer:function(e,t,n){if(!1===n)return!1;if(t){const e=navigator.userAgent||"";if(t instanceof RegExp){if(t.test(e))return!1}else if("string"==typeof t&&t.startsWith("/")&&t.endsWith("/")){const n=t.slice(1,-1);try{if(new RegExp(n).test(e))return!1}catch{}}}if("always"===e)return!0;if("localhost"===e)return"localhost"===location.hostname||"127.0.0.1"===location.hostname;if(e instanceof RegExp)return e.test(location.hostname);if("string"==typeof e&&e.startsWith("/")&&e.endsWith("/")){const t=e.slice(1,-1);return new RegExp(t).test(location.hostname)}return!1}(e.activation,e.userAgentException,e.iwer)){e.verbose&&console.log("[IWSDK Dev] 🎯 Activating IWER runtime...");try{const t=jS[e.device];if(!t){const t=Object.keys(jS).join(", ");console.error(`[IWSDK Dev] ❌ Invalid device configuration: "${e.device}"\nAvailable devices: ${t}\nFalling back to default device: metaQuest3`)}const i=new Ql(a?WS:t||cc);if(e.verbose&&console.log("[IWSDK Dev] 📱 Using device configuration:",a?"metaVRGlasses (gaze preview)":t?e.device:"metaQuest3 (fallback)"),r||a){const e=a?"Gaze preview":"Native XR control",t=zc();if(!t.supported)return void console.error(`[IWSDK Dev] ${e} is unavailable:`,t.notes.join(" "));const n=function(e,t){const n=new Bc(e,t);return n.install(),n}(i,{mode:a?"gaze-only":"full",onUnsupported:"warn"});if(!n.installed)return void console.error(`[IWSDK Dev] ${e} could not patch this browser:`,n.capabilities.notes.join(" "));a&&(window.__IWSDK_TARGET_DEVICE_PREVIEW__={active:!0,gazeSimulation:"head"}),window.IWER_NATIVE_OVERRIDE=n}else i.installRuntime({forceInstall:!0});window.__IWSDK_EMULATION_PROFILE={active:!0,device:a?"metaVRGlasses":e.device,runtime:r?"IWER-native-override":a?"IWER-native-gaze":"IWER"},r||a||e.ai&&n&&!e.ai.devUI||i.installDevUI(Mw),!e.sem||r||a||(e.verbose&&console.log("[IWSDK Dev] 🌐 Installing SEM with scene:",e.sem.defaultScene),i.installSEM(XS),e.verbose&&console.log("[IWSDK Dev] 📍 Loading default environment from CDN:",e.sem.defaultScene),i.sem?.loadDefaultEnvironment(e.sem.defaultScene));const o=a&&s;if(e.workspace&&(n||r||o)){e.verbose&&console.log("[IWSDK Dev] 🔌 Initializing MCP client...");const t=function(e,t={}){const n=new HS(e,{deviceClass:t.deviceClass,verbose:t.verbose});return n.connect(t.port),n}(i,{deviceClass:r||o?"physical":"managed",verbose:e.verbose});window.IWER_MCP=t,e.verbose&&console.log("[IWSDK Dev] ✅ MCP client initialized")}e.verbose&&console.log("[IWSDK Dev] ✅ Runtime activated successfully!"),window.IWER_DEVICE=i}catch(e){console.error("[IWSDK Dev] ❌ Failed to activate runtime:",e)}}else if(e.verbose){const t=!1===e.iwer?"IWER disabled (iwer: false)":"activation conditions not met (localhost / user-agent)";console.log(`[IWSDK Dev] Skipping activation - ${t}`)}}("__IWSDK_DEV_CONFIG__")}();
|